@likec4/core 1.48.0 → 1.50.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 (130) hide show
  1. package/dist/THIRD-PARTY-LICENSES.md +1034 -0
  2. package/dist/_chunks/Builder.view-element.mjs +2 -3284
  3. package/dist/_chunks/LikeC4Model.d.mts +21 -25
  4. package/dist/_chunks/_types.d.mts +1 -5
  5. package/dist/_chunks/_types2.d.mts +2 -4
  6. package/dist/_chunks/assignTagColors.mjs +1 -24
  7. package/dist/_chunks/geometry.mjs +1 -335
  8. package/dist/_chunks/index.d.mts +1995 -131
  9. package/dist/_chunks/index2.d.mts +153 -892
  10. package/dist/_chunks/index3.d.mts +15 -13
  11. package/dist/_chunks/index4.d.mts +229 -3
  12. package/dist/_chunks/index5.d.mts +392 -30
  13. package/dist/_chunks/libs/@mantine/colors-generator.mjs +2 -3403
  14. package/dist/_chunks/libs/@radix-ui/colors.mjs +1 -0
  15. package/dist/_chunks/libs/@ungap/structured-clone.mjs +1 -213
  16. package/dist/_chunks/libs/bail.mjs +1 -14
  17. package/dist/_chunks/libs/ccount.mjs +1 -25
  18. package/dist/_chunks/libs/character-entities-html4.mjs +1 -263
  19. package/dist/_chunks/libs/character-entities-legacy.mjs +1 -117
  20. package/dist/_chunks/libs/character-entities.mjs +2 -2136
  21. package/dist/_chunks/libs/comma-separated-tokens.mjs +1 -18
  22. package/dist/_chunks/libs/decode-named-character-reference.mjs +1 -21
  23. package/dist/_chunks/libs/defu.mjs +1 -42
  24. package/dist/_chunks/libs/devlop.mjs +1 -5
  25. package/dist/_chunks/libs/escape-string-regexp.mjs +1 -8
  26. package/dist/_chunks/libs/extend.mjs +1 -77
  27. package/dist/_chunks/libs/graphology-dag.mjs +1 -703
  28. package/dist/_chunks/libs/graphology.mjs +1 -4565
  29. package/dist/_chunks/libs/hast-util-sanitize.mjs +1 -863
  30. package/dist/_chunks/libs/hast-util-to-html.mjs +9 -2696
  31. package/dist/_chunks/libs/is-plain-obj.mjs +1 -9
  32. package/dist/_chunks/libs/longest-streak.mjs +1 -30
  33. package/dist/_chunks/libs/markdown-table.mjs +2 -290
  34. package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +1 -653
  35. package/dist/_chunks/libs/mdast-util-from-markdown.mjs +3 -8522
  36. package/dist/_chunks/libs/mdast-util-gfm.mjs +15 -2393
  37. package/dist/_chunks/libs/mdast-util-to-hast.mjs +11 -1803
  38. package/dist/_chunks/libs/micromark-extension-gfm.mjs +1 -2243
  39. package/dist/_chunks/libs/mnemonist.d.mts +1 -91
  40. package/dist/_chunks/libs/mnemonist.mjs +1 -1978
  41. package/dist/_chunks/libs/natural-compare-lite.mjs +9 -42
  42. package/dist/_chunks/libs/ohash.mjs +1 -0
  43. package/dist/_chunks/libs/rehype-sanitize.mjs +1 -29
  44. package/dist/_chunks/libs/rehype-stringify.mjs +1 -34
  45. package/dist/_chunks/libs/remark-gfm.mjs +1 -36
  46. package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +3 -100
  47. package/dist/_chunks/libs/remark-parse.mjs +1 -39
  48. package/dist/_chunks/libs/remark-rehype.mjs +1 -171
  49. package/dist/_chunks/libs/remeda.mjs +2 -702
  50. package/dist/_chunks/libs/trough.mjs +1 -158
  51. package/dist/_chunks/libs/unified.mjs +1 -2212
  52. package/dist/_chunks/manual-layout.mjs +1 -0
  53. package/dist/_chunks/model.mjs +4 -1898
  54. package/dist/_chunks/rolldown-runtime.mjs +1 -42
  55. package/dist/_chunks/types.mjs +1 -0
  56. package/dist/_chunks/utils.mjs +1 -483
  57. package/dist/builder/index.d.mts +3 -6
  58. package/dist/builder/index.mjs +1 -662
  59. package/dist/compute-view/index.d.mts +85 -13
  60. package/dist/compute-view/index.mjs +2 -262
  61. package/dist/geometry/index.d.mts +2 -2
  62. package/dist/geometry/index.mjs +1 -3
  63. package/dist/index.d.mts +7 -13
  64. package/dist/index.mjs +1 -27
  65. package/dist/model/index.d.mts +4 -11
  66. package/dist/model/index.mjs +1 -11
  67. package/dist/styles/index.d.mts +2 -7
  68. package/dist/styles/index.mjs +1 -30
  69. package/dist/types/index.d.mts +3 -9
  70. package/dist/types/index.mjs +1 -15
  71. package/dist/utils/graphology/index.d.mts +1 -1
  72. package/dist/utils/graphology/index.mjs +1 -3
  73. package/dist/utils/index.d.mts +5 -10
  74. package/dist/utils/index.mjs +1 -17
  75. package/package.json +14 -13
  76. package/dist/_chunks/LikeC4Styles.mjs +0 -691
  77. package/dist/_chunks/RichText.d.mts +0 -84
  78. package/dist/_chunks/RichText.mjs +0 -148
  79. package/dist/_chunks/_aux.d.mts +0 -289
  80. package/dist/_chunks/_aux.mjs +0 -18
  81. package/dist/_chunks/calcDriftsFromSnapshot.mjs +0 -379
  82. package/dist/_chunks/connection.mjs +0 -0
  83. package/dist/_chunks/const.d.mts +0 -43
  84. package/dist/_chunks/const.mjs +0 -33
  85. package/dist/_chunks/expression-model.d.mts +0 -192
  86. package/dist/_chunks/expression-model.mjs +0 -103
  87. package/dist/_chunks/expression.d.mts +0 -347
  88. package/dist/_chunks/expression.mjs +0 -107
  89. package/dist/_chunks/find.d.mts +0 -82
  90. package/dist/_chunks/find.mjs +0 -646
  91. package/dist/_chunks/find2.d.mts +0 -78
  92. package/dist/_chunks/find2.mjs +0 -287
  93. package/dist/_chunks/fqnRef.d.mts +0 -58
  94. package/dist/_chunks/fqnRef.mjs +0 -41
  95. package/dist/_chunks/index6.d.mts +0 -43
  96. package/dist/_chunks/index7.d.mts +0 -268
  97. package/dist/_chunks/index8.d.mts +0 -144
  98. package/dist/_chunks/invariant.mjs +0 -18
  99. package/dist/_chunks/iterable.mjs +0 -146
  100. package/dist/_chunks/libs/graphology-types.d.mts +0 -601
  101. package/dist/_chunks/libs/graphology.d.mts +0 -6
  102. package/dist/_chunks/mnemonist.mjs +0 -0
  103. package/dist/_chunks/model2.mjs +0 -0
  104. package/dist/_chunks/relationships-view.mjs +0 -132
  105. package/dist/_chunks/scalar.d.mts +0 -109
  106. package/dist/_chunks/scalar.mjs +0 -84
  107. package/dist/compute-view/relationships-view/index.d.mts +0 -16
  108. package/dist/compute-view/relationships-view/index.mjs +0 -7
  109. package/dist/model/connection/deployment/index.d.mts +0 -12
  110. package/dist/model/connection/deployment/index.mjs +0 -9
  111. package/dist/model/connection/index.d.mts +0 -14
  112. package/dist/model/connection/index.mjs +0 -10
  113. package/dist/model/connection/model/index.d.mts +0 -12
  114. package/dist/model/connection/model/index.mjs +0 -8
  115. package/dist/types/RichText.d.mts +0 -3
  116. package/dist/types/RichText.mjs +0 -7
  117. package/dist/types/_aux.d.mts +0 -3
  118. package/dist/types/_aux.mjs +0 -3
  119. package/dist/types/expression-model.d.mts +0 -6
  120. package/dist/types/expression-model.mjs +0 -7
  121. package/dist/types/expression.d.mts +0 -5
  122. package/dist/types/expression.mjs +0 -7
  123. package/dist/types/fqnRef.d.mts +0 -4
  124. package/dist/types/fqnRef.mjs +0 -7
  125. package/dist/types/scalar.d.mts +0 -2
  126. package/dist/types/scalar.mjs +0 -7
  127. package/dist/utils/iterable/index.d.mts +0 -9
  128. package/dist/utils/iterable/index.mjs +0 -3
  129. package/dist/utils/mnemonist.d.mts +0 -2
  130. package/dist/utils/mnemonist.mjs +0 -12
@@ -1,863 +1 @@
1
- import { t as esm_default } from "./@ungap/structured-clone.mjs";
2
-
3
- //#region ../../node_modules/.pnpm/unist-util-position@5.0.0/node_modules/unist-util-position/lib/index.js
4
- /**
5
- * @typedef {import('unist').Node} Node
6
- * @typedef {import('unist').Point} Point
7
- * @typedef {import('unist').Position} Position
8
- */
9
- /**
10
- * @typedef NodeLike
11
- * @property {string} type
12
- * @property {PositionLike | null | undefined} [position]
13
- *
14
- * @typedef PositionLike
15
- * @property {PointLike | null | undefined} [start]
16
- * @property {PointLike | null | undefined} [end]
17
- *
18
- * @typedef PointLike
19
- * @property {number | null | undefined} [line]
20
- * @property {number | null | undefined} [column]
21
- * @property {number | null | undefined} [offset]
22
- */
23
- /**
24
- * Get the ending point of `node`.
25
- *
26
- * @param node
27
- * Node.
28
- * @returns
29
- * Point.
30
- */
31
- const pointEnd = point("end");
32
- /**
33
- * Get the starting point of `node`.
34
- *
35
- * @param node
36
- * Node.
37
- * @returns
38
- * Point.
39
- */
40
- const pointStart = point("start");
41
- /**
42
- * Get the positional info of `node`.
43
- *
44
- * @param {'end' | 'start'} type
45
- * Side.
46
- * @returns
47
- * Getter.
48
- */
49
- function point(type) {
50
- return point;
51
- /**
52
- * Get the point info of `node` at a bound side.
53
- *
54
- * @param {Node | NodeLike | null | undefined} [node]
55
- * @returns {Point | undefined}
56
- */
57
- function point(node) {
58
- const point = node && node.position && node.position[type] || {};
59
- if (typeof point.line === "number" && point.line > 0 && typeof point.column === "number" && point.column > 0) return {
60
- line: point.line,
61
- column: point.column,
62
- offset: typeof point.offset === "number" && point.offset > -1 ? point.offset : void 0
63
- };
64
- }
65
- }
66
- /**
67
- * Get the positional info of `node`.
68
- *
69
- * @param {Node | NodeLike | null | undefined} [node]
70
- * Node.
71
- * @returns {Position | undefined}
72
- * Position.
73
- */
74
- function position(node) {
75
- const start = pointStart(node);
76
- const end = pointEnd(node);
77
- if (start && end) return {
78
- start,
79
- end
80
- };
81
- }
82
-
83
- //#endregion
84
- //#region ../../node_modules/.pnpm/hast-util-sanitize@5.0.2/node_modules/hast-util-sanitize/lib/schema.js
85
- /**
86
- * @import {Schema} from 'hast-util-sanitize'
87
- */
88
- const aria = [
89
- "ariaDescribedBy",
90
- "ariaLabel",
91
- "ariaLabelledBy"
92
- ];
93
- /**
94
- * Default schema.
95
- *
96
- * Follows GitHub style sanitation.
97
- *
98
- * @type {Schema}
99
- */
100
- const defaultSchema = {
101
- ancestors: {
102
- tbody: ["table"],
103
- td: ["table"],
104
- th: ["table"],
105
- thead: ["table"],
106
- tfoot: ["table"],
107
- tr: ["table"]
108
- },
109
- attributes: {
110
- a: [
111
- ...aria,
112
- "dataFootnoteBackref",
113
- "dataFootnoteRef",
114
- ["className", "data-footnote-backref"],
115
- "href"
116
- ],
117
- blockquote: ["cite"],
118
- code: [["className", /^language-./]],
119
- del: ["cite"],
120
- div: ["itemScope", "itemType"],
121
- dl: [...aria],
122
- h2: [["className", "sr-only"]],
123
- img: [
124
- ...aria,
125
- "longDesc",
126
- "src"
127
- ],
128
- input: [["disabled", true], ["type", "checkbox"]],
129
- ins: ["cite"],
130
- li: [["className", "task-list-item"]],
131
- ol: [...aria, ["className", "contains-task-list"]],
132
- q: ["cite"],
133
- section: ["dataFootnotes", ["className", "footnotes"]],
134
- source: ["srcSet"],
135
- summary: [...aria],
136
- table: [...aria],
137
- ul: [...aria, ["className", "contains-task-list"]],
138
- "*": [
139
- "abbr",
140
- "accept",
141
- "acceptCharset",
142
- "accessKey",
143
- "action",
144
- "align",
145
- "alt",
146
- "axis",
147
- "border",
148
- "cellPadding",
149
- "cellSpacing",
150
- "char",
151
- "charOff",
152
- "charSet",
153
- "checked",
154
- "clear",
155
- "colSpan",
156
- "color",
157
- "cols",
158
- "compact",
159
- "coords",
160
- "dateTime",
161
- "dir",
162
- "encType",
163
- "frame",
164
- "hSpace",
165
- "headers",
166
- "height",
167
- "hrefLang",
168
- "htmlFor",
169
- "id",
170
- "isMap",
171
- "itemProp",
172
- "label",
173
- "lang",
174
- "maxLength",
175
- "media",
176
- "method",
177
- "multiple",
178
- "name",
179
- "noHref",
180
- "noShade",
181
- "noWrap",
182
- "open",
183
- "prompt",
184
- "readOnly",
185
- "rev",
186
- "rowSpan",
187
- "rows",
188
- "rules",
189
- "scope",
190
- "selected",
191
- "shape",
192
- "size",
193
- "span",
194
- "start",
195
- "summary",
196
- "tabIndex",
197
- "title",
198
- "useMap",
199
- "vAlign",
200
- "value",
201
- "width"
202
- ]
203
- },
204
- clobber: [
205
- "ariaDescribedBy",
206
- "ariaLabelledBy",
207
- "id",
208
- "name"
209
- ],
210
- clobberPrefix: "user-content-",
211
- protocols: {
212
- cite: ["http", "https"],
213
- href: [
214
- "http",
215
- "https",
216
- "irc",
217
- "ircs",
218
- "mailto",
219
- "xmpp"
220
- ],
221
- longDesc: ["http", "https"],
222
- src: ["http", "https"]
223
- },
224
- required: { input: {
225
- disabled: true,
226
- type: "checkbox"
227
- } },
228
- strip: ["script"],
229
- tagNames: [
230
- "a",
231
- "b",
232
- "blockquote",
233
- "br",
234
- "code",
235
- "dd",
236
- "del",
237
- "details",
238
- "div",
239
- "dl",
240
- "dt",
241
- "em",
242
- "h1",
243
- "h2",
244
- "h3",
245
- "h4",
246
- "h5",
247
- "h6",
248
- "hr",
249
- "i",
250
- "img",
251
- "input",
252
- "ins",
253
- "kbd",
254
- "li",
255
- "ol",
256
- "p",
257
- "picture",
258
- "pre",
259
- "q",
260
- "rp",
261
- "rt",
262
- "ruby",
263
- "s",
264
- "samp",
265
- "section",
266
- "source",
267
- "span",
268
- "strike",
269
- "strong",
270
- "sub",
271
- "summary",
272
- "sup",
273
- "table",
274
- "tbody",
275
- "td",
276
- "tfoot",
277
- "th",
278
- "thead",
279
- "tr",
280
- "tt",
281
- "ul",
282
- "var"
283
- ]
284
- };
285
-
286
- //#endregion
287
- //#region ../../node_modules/.pnpm/hast-util-sanitize@5.0.2/node_modules/hast-util-sanitize/lib/index.js
288
- /**
289
- * @import {
290
- * Comment,
291
- * Doctype,
292
- * ElementContent,
293
- * Element,
294
- * Nodes,
295
- * Properties,
296
- * RootContent,
297
- * Root,
298
- * Text
299
- * } from 'hast'
300
- */
301
- /**
302
- * @typedef {[string, ...Array<Exclude<Properties[keyof Properties], Array<any>> | RegExp>] | string} PropertyDefinition
303
- * Definition for a property.
304
- *
305
- * @typedef Schema
306
- * Schema that defines what nodes and properties are allowed.
307
- *
308
- * The default schema is `defaultSchema`, which follows how GitHub cleans.
309
- * If any top-level key is missing in the given schema, the corresponding
310
- * value of the default schema is used.
311
- *
312
- * To extend the standard schema with a few changes, clone `defaultSchema`
313
- * like so:
314
- *
315
- * ```js
316
- * import deepmerge from 'deepmerge'
317
- * import {h} from 'hastscript'
318
- * import {defaultSchema, sanitize} from 'hast-util-sanitize'
319
- *
320
- * // This allows `className` on all elements.
321
- * const schema = deepmerge(defaultSchema, {attributes: {'*': ['className']}})
322
- *
323
- * const tree = sanitize(h('div', {className: ['foo']}), schema)
324
- *
325
- * // `tree` still has `className`.
326
- * console.log(tree)
327
- * // {
328
- * // type: 'element',
329
- * // tagName: 'div',
330
- * // properties: {className: ['foo']},
331
- * // children: []
332
- * // }
333
- * ```
334
- * @property {boolean | null | undefined} [allowComments=false]
335
- * Whether to allow comment nodes (default: `false`).
336
- *
337
- * For example:
338
- *
339
- * ```js
340
- * allowComments: true
341
- * ```
342
- * @property {boolean | null | undefined} [allowDoctypes=false]
343
- * Whether to allow doctype nodes (default: `false`).
344
- *
345
- * For example:
346
- *
347
- * ```js
348
- * allowDoctypes: true
349
- * ```
350
- * @property {Record<string, Array<string>> | null | undefined} [ancestors]
351
- * Map of tag names to a list of tag names which are required ancestors
352
- * (default: `defaultSchema.ancestors`).
353
- *
354
- * Elements with these tag names will be ignored if they occur outside of one
355
- * of their allowed parents.
356
- *
357
- * For example:
358
- *
359
- * ```js
360
- * ancestors: {
361
- * tbody: ['table'],
362
- * // …
363
- * tr: ['table']
364
- * }
365
- * ```
366
- * @property {Record<string, Array<PropertyDefinition>> | null | undefined} [attributes]
367
- * Map of tag names to allowed property names (default:
368
- * `defaultSchema.attributes`).
369
- *
370
- * The special key `'*'` as a tag name defines property names allowed on all
371
- * elements.
372
- *
373
- * The special value `'data*'` as a property name can be used to allow all
374
- * `data` properties.
375
- *
376
- * For example:
377
- *
378
- * ```js
379
- * attributes: {
380
- * 'ariaDescribedBy', 'ariaLabel', 'ariaLabelledBy', …, 'href'
381
- * // …
382
- * '*': [
383
- * 'abbr',
384
- * 'accept',
385
- * 'acceptCharset',
386
- * // …
387
- * 'vAlign',
388
- * 'value',
389
- * 'width'
390
- * ]
391
- * }
392
- * ```
393
- *
394
- * Instead of a single string in the array, which allows any property value
395
- * for the field, you can use an array to allow several values.
396
- * For example, `input: ['type']` allows `type` set to any value on `input`s.
397
- * But `input: [['type', 'checkbox', 'radio']]` allows `type` when set to
398
- * `'checkbox'` or `'radio'`.
399
- *
400
- * You can use regexes, so for example `span: [['className', /^hljs-/]]`
401
- * allows any class that starts with `hljs-` on `span`s.
402
- *
403
- * When comma- or space-separated values are used (such as `className`), each
404
- * value in is checked individually.
405
- * For example, to allow certain classes on `span`s for syntax highlighting,
406
- * use `span: [['className', 'number', 'operator', 'token']]`.
407
- * This will allow `'number'`, `'operator'`, and `'token'` classes, but drop
408
- * others.
409
- * @property {Array<string> | null | undefined} [clobber]
410
- * List of property names that clobber (default: `defaultSchema.clobber`).
411
- *
412
- * For example:
413
- *
414
- * ```js
415
- * clobber: ['ariaDescribedBy', 'ariaLabelledBy', 'id', 'name']
416
- * ```
417
- * @property {string | null | undefined} [clobberPrefix]
418
- * Prefix to use before clobbering properties (default:
419
- * `defaultSchema.clobberPrefix`).
420
- *
421
- * For example:
422
- *
423
- * ```js
424
- * clobberPrefix: 'user-content-'
425
- * ```
426
- * @property {Record<string, Array<string> | null | undefined> | null | undefined} [protocols]
427
- * Map of *property names* to allowed protocols (default:
428
- * `defaultSchema.protocols`).
429
- *
430
- * This defines URLs that are always allowed to have local URLs (relative to
431
- * the current website, such as `this`, `#this`, `/this`, or `?this`), and
432
- * only allowed to have remote URLs (such as `https://example.com`) if they
433
- * use a known protocol.
434
- *
435
- * For example:
436
- *
437
- * ```js
438
- * protocols: {
439
- * cite: ['http', 'https'],
440
- * // …
441
- * src: ['http', 'https']
442
- * }
443
- * ```
444
- * @property {Record<string, Record<string, Properties[keyof Properties]>> | null | undefined} [required]
445
- * Map of tag names to required property names with a default value
446
- * (default: `defaultSchema.required`).
447
- *
448
- * This defines properties that must be set.
449
- * If a field does not exist (after the element was made safe), these will be
450
- * added with the given value.
451
- *
452
- * For example:
453
- *
454
- * ```js
455
- * required: {
456
- * input: {disabled: true, type: 'checkbox'}
457
- * }
458
- * ```
459
- *
460
- * > 👉 **Note**: properties are first checked based on `schema.attributes`,
461
- * > then on `schema.required`.
462
- * > That means properties could be removed by `attributes` and then added
463
- * > again with `required`.
464
- * @property {Array<string> | null | undefined} [strip]
465
- * List of tag names to strip from the tree (default: `defaultSchema.strip`).
466
- *
467
- * By default, unsafe elements (those not in `schema.tagNames`) are replaced
468
- * by what they contain.
469
- * This option can drop their contents.
470
- *
471
- * For example:
472
- *
473
- * ```js
474
- * strip: ['script']
475
- * ```
476
- * @property {Array<string> | null | undefined} [tagNames]
477
- * List of allowed tag names (default: `defaultSchema.tagNames`).
478
- *
479
- * For example:
480
- *
481
- * ```js
482
- * tagNames: [
483
- * 'a',
484
- * 'b',
485
- * // …
486
- * 'ul',
487
- * 'var'
488
- * ]
489
- * ```
490
- *
491
- * @typedef State
492
- * Info passed around.
493
- * @property {Readonly<Schema>} schema
494
- * Schema.
495
- * @property {Array<string>} stack
496
- * Tag names of ancestors.
497
- */
498
- const own = {}.hasOwnProperty;
499
- /**
500
- * Sanitize a tree.
501
- *
502
- * @param {Readonly<Nodes>} node
503
- * Unsafe tree.
504
- * @param {Readonly<Schema> | null | undefined} [options]
505
- * Configuration (default: `defaultSchema`).
506
- * @returns {Nodes}
507
- * New, safe tree.
508
- */
509
- function sanitize(node, options) {
510
- /** @type {Nodes} */
511
- let result = {
512
- type: "root",
513
- children: []
514
- };
515
- const replace = transform({
516
- schema: options ? {
517
- ...defaultSchema,
518
- ...options
519
- } : defaultSchema,
520
- stack: []
521
- }, node);
522
- if (replace) if (Array.isArray(replace)) if (replace.length === 1) result = replace[0];
523
- else result.children = replace;
524
- else result = replace;
525
- return result;
526
- }
527
- /**
528
- * Sanitize `node`.
529
- *
530
- * @param {State} state
531
- * Info passed around.
532
- * @param {Readonly<unknown>} node
533
- * Unsafe node.
534
- * @returns {Array<ElementContent> | Nodes | undefined}
535
- * Safe result.
536
- */
537
- function transform(state, node) {
538
- if (node && typeof node === "object") {
539
- const unsafe = node;
540
- switch (typeof unsafe.type === "string" ? unsafe.type : "") {
541
- case "comment": return comment(state, unsafe);
542
- case "doctype": return doctype(state, unsafe);
543
- case "element": return element(state, unsafe);
544
- case "root": return root(state, unsafe);
545
- case "text": return text(state, unsafe);
546
- default:
547
- }
548
- }
549
- }
550
- /**
551
- * Make a safe comment.
552
- *
553
- * @param {State} state
554
- * Info passed around.
555
- * @param {Readonly<Record<string, Readonly<unknown>>>} unsafe
556
- * Unsafe comment-like value.
557
- * @returns {Comment | undefined}
558
- * Safe comment (if with `allowComments`).
559
- */
560
- function comment(state, unsafe) {
561
- if (state.schema.allowComments) {
562
- const result = typeof unsafe.value === "string" ? unsafe.value : "";
563
- const index = result.indexOf("-->");
564
- /** @type {Comment} */
565
- const node = {
566
- type: "comment",
567
- value: index < 0 ? result : result.slice(0, index)
568
- };
569
- patch(node, unsafe);
570
- return node;
571
- }
572
- }
573
- /**
574
- * Make a safe doctype.
575
- *
576
- * @param {State} state
577
- * Info passed around.
578
- * @param {Readonly<Record<string, Readonly<unknown>>>} unsafe
579
- * Unsafe doctype-like value.
580
- * @returns {Doctype | undefined}
581
- * Safe doctype (if with `allowDoctypes`).
582
- */
583
- function doctype(state, unsafe) {
584
- if (state.schema.allowDoctypes) {
585
- /** @type {Doctype} */
586
- const node = { type: "doctype" };
587
- patch(node, unsafe);
588
- return node;
589
- }
590
- }
591
- /**
592
- * Make a safe element.
593
- *
594
- * @param {State} state
595
- * Info passed around.
596
- * @param {Readonly<Record<string, Readonly<unknown>>>} unsafe
597
- * Unsafe element-like value.
598
- * @returns {Array<ElementContent> | Element | undefined}
599
- * Safe element.
600
- */
601
- function element(state, unsafe) {
602
- const name = typeof unsafe.tagName === "string" ? unsafe.tagName : "";
603
- state.stack.push(name);
604
- const content = children(state, unsafe.children);
605
- const properties_ = properties(state, unsafe.properties);
606
- state.stack.pop();
607
- let safeElement = false;
608
- if (name && name !== "*" && (!state.schema.tagNames || state.schema.tagNames.includes(name))) {
609
- safeElement = true;
610
- if (state.schema.ancestors && own.call(state.schema.ancestors, name)) {
611
- const ancestors = state.schema.ancestors[name];
612
- let index = -1;
613
- safeElement = false;
614
- while (++index < ancestors.length) if (state.stack.includes(ancestors[index])) safeElement = true;
615
- }
616
- }
617
- if (!safeElement) return state.schema.strip && !state.schema.strip.includes(name) ? content : void 0;
618
- /** @type {Element} */
619
- const node = {
620
- type: "element",
621
- tagName: name,
622
- properties: properties_,
623
- children: content
624
- };
625
- patch(node, unsafe);
626
- return node;
627
- }
628
- /**
629
- * Make a safe root.
630
- *
631
- * @param {State} state
632
- * Info passed around.
633
- * @param {Readonly<Record<string, Readonly<unknown>>>} unsafe
634
- * Unsafe root-like value.
635
- * @returns {Root}
636
- * Safe root.
637
- */
638
- function root(state, unsafe) {
639
- /** @type {Root} */
640
- const node = {
641
- type: "root",
642
- children: children(state, unsafe.children)
643
- };
644
- patch(node, unsafe);
645
- return node;
646
- }
647
- /**
648
- * Make a safe text.
649
- *
650
- * @param {State} _
651
- * Info passed around.
652
- * @param {Readonly<Record<string, Readonly<unknown>>>} unsafe
653
- * Unsafe text-like value.
654
- * @returns {Text}
655
- * Safe text.
656
- */
657
- function text(_, unsafe) {
658
- /** @type {Text} */
659
- const node = {
660
- type: "text",
661
- value: typeof unsafe.value === "string" ? unsafe.value : ""
662
- };
663
- patch(node, unsafe);
664
- return node;
665
- }
666
- /**
667
- * Make children safe.
668
- *
669
- * @param {State} state
670
- * Info passed around.
671
- * @param {Readonly<unknown>} children
672
- * Unsafe value.
673
- * @returns {Array<Nodes>}
674
- * Safe children.
675
- */
676
- function children(state, children) {
677
- /** @type {Array<Nodes>} */
678
- const results = [];
679
- if (Array.isArray(children)) {
680
- const childrenUnknown = children;
681
- let index = -1;
682
- while (++index < childrenUnknown.length) {
683
- const value = transform(state, childrenUnknown[index]);
684
- if (value) if (Array.isArray(value)) results.push(...value);
685
- else results.push(value);
686
- }
687
- }
688
- return results;
689
- }
690
- /**
691
- * Make element properties safe.
692
- *
693
- * @param {State} state
694
- * Info passed around.
695
- * @param {Readonly<unknown>} properties
696
- * Unsafe value.
697
- * @returns {Properties}
698
- * Safe value.
699
- */
700
- function properties(state, properties) {
701
- const tagName = state.stack[state.stack.length - 1];
702
- const attributes = state.schema.attributes;
703
- const required = state.schema.required;
704
- const specific = attributes && own.call(attributes, tagName) ? attributes[tagName] : void 0;
705
- const defaults = attributes && own.call(attributes, "*") ? attributes["*"] : void 0;
706
- const properties_ = properties && typeof properties === "object" ? properties : {};
707
- /** @type {Properties} */
708
- const result = {};
709
- /** @type {string} */
710
- let key;
711
- for (key in properties_) if (own.call(properties_, key)) {
712
- const unsafe = properties_[key];
713
- let safe = propertyValue(state, findDefinition(specific, key), key, unsafe);
714
- if (safe === null || safe === void 0) safe = propertyValue(state, findDefinition(defaults, key), key, unsafe);
715
- if (safe !== null && safe !== void 0) result[key] = safe;
716
- }
717
- if (required && own.call(required, tagName)) {
718
- const properties = required[tagName];
719
- for (key in properties) if (own.call(properties, key) && !own.call(result, key)) result[key] = properties[key];
720
- }
721
- return result;
722
- }
723
- /**
724
- * Sanitize a property value.
725
- *
726
- * @param {State} state
727
- * Info passed around.
728
- * @param {Readonly<PropertyDefinition> | undefined} definition
729
- * Definition.
730
- * @param {string} key
731
- * Field name.
732
- * @param {Readonly<unknown>} value
733
- * Unsafe value (but an array).
734
- * @returns {Array<number | string> | boolean | number | string | undefined}
735
- * Safe value.
736
- */
737
- function propertyValue(state, definition, key, value) {
738
- return definition ? Array.isArray(value) ? propertyValueMany(state, definition, key, value) : propertyValuePrimitive(state, definition, key, value) : void 0;
739
- }
740
- /**
741
- * Sanitize a property value which is a list.
742
- *
743
- * @param {State} state
744
- * Info passed around.
745
- * @param {Readonly<PropertyDefinition>} definition
746
- * Definition.
747
- * @param {string} key
748
- * Field name.
749
- * @param {Readonly<Array<Readonly<unknown>>>} values
750
- * Unsafe value (but an array).
751
- * @returns {Array<number | string>}
752
- * Safe value.
753
- */
754
- function propertyValueMany(state, definition, key, values) {
755
- let index = -1;
756
- /** @type {Array<number | string>} */
757
- const result = [];
758
- while (++index < values.length) {
759
- const value = propertyValuePrimitive(state, definition, key, values[index]);
760
- if (typeof value === "number" || typeof value === "string") result.push(value);
761
- }
762
- return result;
763
- }
764
- /**
765
- * Sanitize a property value which is a primitive.
766
- *
767
- * @param {State} state
768
- * Info passed around.
769
- * @param {Readonly<PropertyDefinition>} definition
770
- * Definition.
771
- * @param {string} key
772
- * Field name.
773
- * @param {Readonly<unknown>} value
774
- * Unsafe value (but not an array).
775
- * @returns {boolean | number | string | undefined}
776
- * Safe value.
777
- */
778
- function propertyValuePrimitive(state, definition, key, value) {
779
- if (typeof value !== "boolean" && typeof value !== "number" && typeof value !== "string") return;
780
- if (!safeProtocol(state, key, value)) return;
781
- if (typeof definition === "object" && definition.length > 1) {
782
- let ok = false;
783
- let index = 0;
784
- while (++index < definition.length) {
785
- const allowed = definition[index];
786
- if (allowed && typeof allowed === "object" && "flags" in allowed) {
787
- if (allowed.test(String(value))) {
788
- ok = true;
789
- break;
790
- }
791
- } else if (allowed === value) {
792
- ok = true;
793
- break;
794
- }
795
- }
796
- if (!ok) return;
797
- }
798
- return state.schema.clobber && state.schema.clobberPrefix && state.schema.clobber.includes(key) ? state.schema.clobberPrefix + value : value;
799
- }
800
- /**
801
- * Check whether `value` is a safe URL.
802
- *
803
- * @param {State} state
804
- * Info passed around.
805
- * @param {string} key
806
- * Field name.
807
- * @param {Readonly<unknown>} value
808
- * Unsafe value.
809
- * @returns {boolean}
810
- * Whether it’s a safe value.
811
- */
812
- function safeProtocol(state, key, value) {
813
- const protocols = state.schema.protocols && own.call(state.schema.protocols, key) ? state.schema.protocols[key] : void 0;
814
- if (!protocols || protocols.length === 0) return true;
815
- const url = String(value);
816
- const colon = url.indexOf(":");
817
- const questionMark = url.indexOf("?");
818
- const numberSign = url.indexOf("#");
819
- const slash = url.indexOf("/");
820
- if (colon < 0 || slash > -1 && colon > slash || questionMark > -1 && colon > questionMark || numberSign > -1 && colon > numberSign) return true;
821
- let index = -1;
822
- while (++index < protocols.length) {
823
- const protocol = protocols[index];
824
- if (colon === protocol.length && url.slice(0, protocol.length) === protocol) return true;
825
- }
826
- return false;
827
- }
828
- /**
829
- * Add data and position.
830
- *
831
- * @param {Nodes} node
832
- * Node to patch safe data and position on.
833
- * @param {Readonly<Record<string, Readonly<unknown>>>} unsafe
834
- * Unsafe node-like value.
835
- * @returns {undefined}
836
- * Nothing.
837
- */
838
- function patch(node, unsafe) {
839
- const cleanPosition = position(unsafe);
840
- if (unsafe.data) node.data = esm_default(unsafe.data);
841
- if (cleanPosition) node.position = cleanPosition;
842
- }
843
- /**
844
- *
845
- * @param {Readonly<Array<PropertyDefinition>> | undefined} definitions
846
- * @param {string} key
847
- * @returns {Readonly<PropertyDefinition> | undefined}
848
- */
849
- function findDefinition(definitions, key) {
850
- /** @type {PropertyDefinition | undefined} */
851
- let dataDefault;
852
- let index = -1;
853
- if (definitions) while (++index < definitions.length) {
854
- const entry = definitions[index];
855
- const name = typeof entry === "string" ? entry : entry[0];
856
- if (name === key) return entry;
857
- if (name === "data*") dataDefault = entry;
858
- }
859
- if (key.length > 4 && key.slice(0, 4).toLowerCase() === "data") return dataDefault;
860
- }
861
-
862
- //#endregion
863
- export { position as a, pointStart as i, defaultSchema as n, pointEnd as r, sanitize as t };
1
+ import{t as e}from"./@ungap/structured-clone.mjs";const t=r(`end`),n=r(`start`);function r(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function i(e){let r=n(e),i=t(e);if(r&&i)return{start:r,end:i}}const a=[`ariaDescribedBy`,`ariaLabel`,`ariaLabelledBy`],o={ancestors:{tbody:[`table`],td:[`table`],th:[`table`],thead:[`table`],tfoot:[`table`],tr:[`table`]},attributes:{a:[...a,`dataFootnoteBackref`,`dataFootnoteRef`,[`className`,`data-footnote-backref`],`href`],blockquote:[`cite`],code:[[`className`,/^language-./]],del:[`cite`],div:[`itemScope`,`itemType`],dl:[...a],h2:[[`className`,`sr-only`]],img:[...a,`longDesc`,`src`],input:[[`disabled`,!0],[`type`,`checkbox`]],ins:[`cite`],li:[[`className`,`task-list-item`]],ol:[...a,[`className`,`contains-task-list`]],q:[`cite`],section:[`dataFootnotes`,[`className`,`footnotes`]],source:[`srcSet`],summary:[...a],table:[...a],ul:[...a,[`className`,`contains-task-list`]],"*":`abbr.accept.acceptCharset.accessKey.action.align.alt.axis.border.cellPadding.cellSpacing.char.charOff.charSet.checked.clear.colSpan.color.cols.compact.coords.dateTime.dir.encType.frame.hSpace.headers.height.hrefLang.htmlFor.id.isMap.itemProp.label.lang.maxLength.media.method.multiple.name.noHref.noShade.noWrap.open.prompt.readOnly.rev.rowSpan.rows.rules.scope.selected.shape.size.span.start.summary.tabIndex.title.useMap.vAlign.value.width`.split(`.`)},clobber:[`ariaDescribedBy`,`ariaLabelledBy`,`id`,`name`],clobberPrefix:`user-content-`,protocols:{cite:[`http`,`https`],href:[`http`,`https`,`irc`,`ircs`,`mailto`,`xmpp`],longDesc:[`http`,`https`],src:[`http`,`https`]},required:{input:{disabled:!0,type:`checkbox`}},strip:[`script`],tagNames:`a.b.blockquote.br.code.dd.del.details.div.dl.dt.em.h1.h2.h3.h4.h5.h6.hr.i.img.input.ins.kbd.li.ol.p.picture.pre.q.rp.rt.ruby.s.samp.section.source.span.strike.strong.sub.summary.sup.table.tbody.td.tfoot.th.thead.tr.tt.ul.var`.split(`.`)},s={}.hasOwnProperty;function c(e,t){let n={type:`root`,children:[]},r=l({schema:t?{...o,...t}:o,stack:[]},e);return r&&(Array.isArray(r)?r.length===1?n=r[0]:n.children=r:n=r),n}function l(e,t){if(t&&typeof t==`object`){let n=t;switch(typeof n.type==`string`?n.type:``){case`comment`:return u(e,n);case`doctype`:return d(e,n);case`element`:return f(e,n);case`root`:return p(e,n);case`text`:return m(e,n);default:}}}function u(e,t){if(e.schema.allowComments){let e=typeof t.value==`string`?t.value:``,n=e.indexOf(`-->`),r={type:`comment`,value:n<0?e:e.slice(0,n)};return x(r,t),r}}function d(e,t){if(e.schema.allowDoctypes){let e={type:`doctype`};return x(e,t),e}}function f(e,t){let n=typeof t.tagName==`string`?t.tagName:``;e.stack.push(n);let r=h(e,t.children),i=g(e,t.properties);e.stack.pop();let a=!1;if(n&&n!==`*`&&(!e.schema.tagNames||e.schema.tagNames.includes(n))&&(a=!0,e.schema.ancestors&&s.call(e.schema.ancestors,n))){let t=e.schema.ancestors[n],r=-1;for(a=!1;++r<t.length;)e.stack.includes(t[r])&&(a=!0)}if(!a)return e.schema.strip&&!e.schema.strip.includes(n)?r:void 0;let o={type:`element`,tagName:n,properties:i,children:r};return x(o,t),o}function p(e,t){let n={type:`root`,children:h(e,t.children)};return x(n,t),n}function m(e,t){let n={type:`text`,value:typeof t.value==`string`?t.value:``};return x(n,t),n}function h(e,t){let n=[];if(Array.isArray(t)){let r=t,i=-1;for(;++i<r.length;){let t=l(e,r[i]);t&&(Array.isArray(t)?n.push(...t):n.push(t))}}return n}function g(e,t){let n=e.stack[e.stack.length-1],r=e.schema.attributes,i=e.schema.required,a=r&&s.call(r,n)?r[n]:void 0,o=r&&s.call(r,`*`)?r[`*`]:void 0,c=t&&typeof t==`object`?t:{},l={},u;for(u in c)if(s.call(c,u)){let t=c[u],n=_(e,S(a,u),u,t);n??=_(e,S(o,u),u,t),n!=null&&(l[u]=n)}if(i&&s.call(i,n)){let e=i[n];for(u in e)s.call(e,u)&&!s.call(l,u)&&(l[u]=e[u])}return l}function _(e,t,n,r){return t?Array.isArray(r)?v(e,t,n,r):y(e,t,n,r):void 0}function v(e,t,n,r){let i=-1,a=[];for(;++i<r.length;){let o=y(e,t,n,r[i]);(typeof o==`number`||typeof o==`string`)&&a.push(o)}return a}function y(e,t,n,r){if(!(typeof r!=`boolean`&&typeof r!=`number`&&typeof r!=`string`)&&b(e,n,r)){if(typeof t==`object`&&t.length>1){let e=!1,n=0;for(;++n<t.length;){let i=t[n];if(i&&typeof i==`object`&&`flags`in i){if(i.test(String(r))){e=!0;break}}else if(i===r){e=!0;break}}if(!e)return}return e.schema.clobber&&e.schema.clobberPrefix&&e.schema.clobber.includes(n)?e.schema.clobberPrefix+r:r}}function b(e,t,n){let r=e.schema.protocols&&s.call(e.schema.protocols,t)?e.schema.protocols[t]:void 0;if(!r||r.length===0)return!0;let i=String(n),a=i.indexOf(`:`),o=i.indexOf(`?`),c=i.indexOf(`#`),l=i.indexOf(`/`);if(a<0||l>-1&&a>l||o>-1&&a>o||c>-1&&a>c)return!0;let u=-1;for(;++u<r.length;){let e=r[u];if(a===e.length&&i.slice(0,e.length)===e)return!0}return!1}function x(t,n){let r=i(n);n.data&&(t.data=e(n.data)),r&&(t.position=r)}function S(e,t){let n,r=-1;if(e)for(;++r<e.length;){let i=e[r],a=typeof i==`string`?i:i[0];if(a===t)return i;a===`data*`&&(n=i)}if(t.length>4&&t.slice(0,4).toLowerCase()===`data`)return n}export{i as a,n as i,o as n,t as r,c as t};