@septkit/ui 0.0.88 → 0.0.89

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 (34) hide show
  1. package/dist/dialecte/composables/change-id-window.js +14 -0
  2. package/dist/dialecte/composables/use-live-data.js +154 -31
  3. package/dist/dialecte/create-document-store.js +16 -7
  4. package/dist/external/.pnpm/@dialecte_core@0.12.1/node_modules/@dialecte/core/dist/dialecte-DHj8__Ch.js +7293 -0
  5. package/dist/external/.pnpm/@dialecte_core@0.12.1/node_modules/@dialecte/core/dist/helpers-Bfv2XDC-.js +351 -0
  6. package/dist/external/.pnpm/@dialecte_core@0.12.1/node_modules/@dialecte/core/dist/index.js +6 -0
  7. package/dist/external/.pnpm/{@dialecte_core@0.11.0/node_modules/@dialecte/core/dist/open-connections-D59wm6nb.js → @dialecte_core@0.12.1/node_modules/@dialecte/core/dist/open-connections-ClJo0-Af.js} +2 -2
  8. package/dist/external/.pnpm/@dialecte_core@0.12.1/node_modules/@dialecte/core/dist/project-key-DD8DyQ8-.js +1751 -0
  9. package/dist/external/.pnpm/@dialecte_core@0.12.1/node_modules/@dialecte/core/dist/qname-definition-C6GUFWL8.js +56 -0
  10. package/dist/external/.pnpm/{@dialecte_core@0.11.0 → @dialecte_core@0.12.1}/node_modules/@dialecte/core/dist/rolldown-runtime-CYdcPHCu.js +1 -1
  11. package/dist/external/.pnpm/{@dialecte_core@0.11.0/node_modules/@dialecte/core/dist/same-json-value-boJ4pSRe.js → @dialecte_core@0.12.1/node_modules/@dialecte/core/dist/same-json-value-DTtSsGUF.js} +491 -370
  12. package/dist/external/.pnpm/@dialecte_core@0.12.1/node_modules/@dialecte/core/dist/utils-Q5zsKl3Y.js +2449 -0
  13. package/dist/external/.pnpm/@dialecte_core@0.12.1/node_modules/@dialecte/core/dist/utils.js +2 -0
  14. package/dist/external/.pnpm/@tanstack_virtual-core@3.17.3/node_modules/@tanstack/virtual-core/dist/esm/index.js +627 -0
  15. package/dist/external/.pnpm/@tanstack_virtual-core@3.17.3/node_modules/@tanstack/virtual-core/dist/esm/lazy-measurements.js +31 -0
  16. package/dist/external/.pnpm/@tanstack_virtual-core@3.17.3/node_modules/@tanstack/virtual-core/dist/esm/utils.js +38 -0
  17. package/dist/external/.pnpm/@tanstack_vue-virtual@3.13.31_vue@3.5.39_typescript@5.8.3_/node_modules/@tanstack/vue-virtual/dist/esm/index.js +28 -0
  18. package/dist/external/.pnpm/@vueuse_core@14.3.0_vue@3.5.39_typescript@5.8.3_/node_modules/@vueuse/core/dist/index.js +24 -2
  19. package/dist/index.d.ts +266 -7
  20. package/dist/index.js +7 -1
  21. package/dist/ui.css +1 -1
  22. package/dist/virtual/grid-aria.js +16 -0
  23. package/dist/virtual/grid-navigation.js +84 -0
  24. package/dist/virtual/index.js +6 -0
  25. package/dist/virtual/kept-range.js +32 -0
  26. package/dist/virtual/use-virtual-scroller.js +180 -0
  27. package/dist/virtual/virtual.constants.js +7 -0
  28. package/package.json +6 -4
  29. package/dist/external/.pnpm/@dialecte_core@0.11.0/node_modules/@dialecte/core/dist/dialecte-Cs_XRP4I.js +0 -4426
  30. package/dist/external/.pnpm/@dialecte_core@0.11.0/node_modules/@dialecte/core/dist/helpers-D8p0KiJu.js +0 -130
  31. package/dist/external/.pnpm/@dialecte_core@0.11.0/node_modules/@dialecte/core/dist/index.js +0 -6
  32. package/dist/external/.pnpm/@dialecte_core@0.11.0/node_modules/@dialecte/core/dist/project-key-sr4wkl2Q.js +0 -1371
  33. package/dist/external/.pnpm/@dialecte_core@0.11.0/node_modules/@dialecte/core/dist/utils-Cv4oHia0.js +0 -865
  34. package/dist/external/.pnpm/@dialecte_core@0.11.0/node_modules/@dialecte/core/dist/utils.js +0 -2
@@ -0,0 +1,1751 @@
1
+ import { C as e, E as t, K as n, M as r, N as i, Q as a, Z as o, _ as s, a as c, b as l, et as u, f as d, h as f, j as p, rt as m, st as h, tt as g } from "./utils-Q5zsKl3Y.js";
2
+ import { n as _, r as v } from "./qname-definition-C6GUFWL8.js";
3
+ //#region node_modules/.pnpm/@dialecte+core@0.12.1/node_modules/@dialecte/core/dist/project-key-DD8DyQ8-.js
4
+ var ee = {
5
+ bigint: "a BigInt",
6
+ function: "a function",
7
+ symbol: "a symbol"
8
+ }, y = "not well-formed UTF-16 (a lone surrogate)", te = `text that is ${y}`, b = `a key that is ${y}`;
9
+ function ne(e) {
10
+ let { documentId: t } = e;
11
+ h("STORE_DUPLICATE_ID", {
12
+ detail: `Document "${t}" is already registered`,
13
+ meta: { documentId: t }
14
+ });
15
+ }
16
+ function re(e) {
17
+ let { path: t, reason: n } = e;
18
+ h("DOCUMENT_PATH_INVALID", {
19
+ detail: `The document path ${JSON.stringify(t)} is refused: ${n}`,
20
+ meta: { path: t }
21
+ });
22
+ }
23
+ function ie(e) {
24
+ let { documentId: t, path: n, takenBy: r } = e;
25
+ h("DOCUMENT_PATH_TAKEN", {
26
+ detail: `Document "${t}" cannot take the path "${n}": document "${r}" holds that place`,
27
+ meta: {
28
+ documentId: t,
29
+ path: n,
30
+ takenBy: r
31
+ }
32
+ });
33
+ }
34
+ function ae(e) {
35
+ let { documentId: t, what: n } = e;
36
+ h("DOCUMENT_NOT_REGISTERED", {
37
+ detail: `Cannot write ${n} to document "${t}": it is not registered`,
38
+ meta: { documentId: t }
39
+ });
40
+ }
41
+ function oe(e) {
42
+ let { documentId: t, recordId: n } = e;
43
+ h("STORE_RECORD_NOT_FOUND", {
44
+ detail: `Record "${n}" is not in document "${t}": nothing to update`,
45
+ meta: {
46
+ documentId: t,
47
+ recordId: n
48
+ }
49
+ });
50
+ }
51
+ function se(e) {
52
+ let { documentId: t, held: n, repeated: r, cause: i } = e;
53
+ h("STORE_DUPLICATE_ID", {
54
+ detail: `Document "${t}" refuses ids to create - ${[n.length > 0 ? `already holds: ${x(n).join(", ")}` : void 0, r.length > 0 ? `given twice: ${x(r).join(", ")}` : void 0].filter((e) => e !== void 0).join("; ")}`,
55
+ meta: {
56
+ documentId: t,
57
+ recordIds: x([...n, ...r])
58
+ },
59
+ cause: i
60
+ });
61
+ }
62
+ function x(e) {
63
+ return [...new Set(e)];
64
+ }
65
+ function ce(e) {
66
+ let { storeName: t, connections: n } = e;
67
+ h("PROJECT_OPEN_ELSEWHERE", {
68
+ detail: `Project "${t}" cannot be destroyed while another connection has it open: close that one first`,
69
+ meta: {
70
+ project: t,
71
+ ...n !== void 0 && { connections: n }
72
+ }
73
+ });
74
+ }
75
+ function le(e) {
76
+ let { storeName: t } = e;
77
+ h("STORE_CLOSED", {
78
+ detail: `Store "${t}" is closed: open it again before using it`,
79
+ meta: { storeName: t }
80
+ });
81
+ }
82
+ function ue(e) {
83
+ he({ walk: function() {
84
+ S({
85
+ value: e.value,
86
+ field: "",
87
+ inArray: !1,
88
+ ancestors: []
89
+ });
90
+ } });
91
+ }
92
+ var de = crypto.randomUUID.bind(crypto);
93
+ function fe() {
94
+ return de();
95
+ }
96
+ function pe(e) {
97
+ let { field: t, value: n } = e;
98
+ n ?? h("STORE_VALUE_NOT_JSON", { detail: `The ${t} is missing` }), typeof n != "string" && h("STORE_VALUE_NOT_JSON", { detail: `The ${t} is not text` }), ue({ value: { [t]: n } });
99
+ }
100
+ function me(e) {
101
+ return he({ walk: function() {
102
+ return C({
103
+ value: e.value,
104
+ field: "",
105
+ inArray: !1,
106
+ ancestors: []
107
+ });
108
+ } });
109
+ }
110
+ function he(e) {
111
+ try {
112
+ return e.walk();
113
+ } catch (e) {
114
+ let t = e instanceof Error ? e : void 0;
115
+ h("STORE_VALUE_NOT_JSON", {
116
+ detail: t?.message ?? String(e),
117
+ cause: t
118
+ });
119
+ }
120
+ }
121
+ function S(e) {
122
+ let t = ve(e);
123
+ if (t === "leaf") return;
124
+ let { ancestors: n } = e;
125
+ if (n.push(e.value), t === "array") {
126
+ let t = e.value, { length: r } = t;
127
+ for (let e = 0; e < r; e++) {
128
+ let r = t[e];
129
+ T({ value: r }) || S({
130
+ value: r,
131
+ field: e,
132
+ inArray: !0,
133
+ ancestors: n
134
+ });
135
+ }
136
+ } else {
137
+ let t = e.value;
138
+ for (let r of Object.keys(t)) {
139
+ r.isWellFormed() || O({
140
+ step: e,
141
+ kind: b
142
+ });
143
+ let i = t[r];
144
+ T({ value: i }) || S({
145
+ value: i,
146
+ field: r,
147
+ inArray: !1,
148
+ ancestors: n
149
+ });
150
+ }
151
+ }
152
+ n.pop();
153
+ }
154
+ function C(e) {
155
+ let t = ve(e);
156
+ if (t === "leaf") return w({ value: e.value });
157
+ let { ancestors: n } = e;
158
+ n.push(e.value);
159
+ let r = t === "array" ? ge(e) : _e(e);
160
+ return n.pop(), r;
161
+ }
162
+ function ge(e) {
163
+ let { ancestors: t } = e, n = e.value, r = [], { length: i } = n;
164
+ for (let e = 0; e < i; e++) {
165
+ let i = n[e];
166
+ r.push(T({ value: i }) ? w({ value: i }) : C({
167
+ value: i,
168
+ field: e,
169
+ inArray: !0,
170
+ ancestors: t
171
+ }));
172
+ }
173
+ return r;
174
+ }
175
+ function _e(e) {
176
+ let { ancestors: t } = e, n = e.value, r = {};
177
+ for (let i of Object.keys(n)) {
178
+ i.isWellFormed() || O({
179
+ step: e,
180
+ kind: b
181
+ });
182
+ let a = n[i], o = T({ value: a }) ? w({ value: a }) : C({
183
+ value: a,
184
+ field: i,
185
+ inArray: !1,
186
+ ancestors: t
187
+ });
188
+ o !== void 0 && (i === "__proto__" ? Object.defineProperty(r, i, {
189
+ value: o,
190
+ writable: !0,
191
+ enumerable: !0,
192
+ configurable: !0
193
+ }) : r[i] = o);
194
+ }
195
+ return r;
196
+ }
197
+ function w(e) {
198
+ return e.value === 0 ? 0 : e.value;
199
+ }
200
+ function T(e) {
201
+ let { value: t } = e;
202
+ switch (typeof t) {
203
+ case "string": return t.isWellFormed();
204
+ case "boolean": return !0;
205
+ case "number": return Number.isFinite(t);
206
+ case "object": return t === null;
207
+ default: return !1;
208
+ }
209
+ }
210
+ function ve(e) {
211
+ let { value: t } = e, n = typeof t;
212
+ switch (n) {
213
+ case "string": return t.isWellFormed() ? "leaf" : O({
214
+ step: e,
215
+ kind: te
216
+ });
217
+ case "boolean": return "leaf";
218
+ case "number": return Number.isFinite(t) ? "leaf" : O({
219
+ step: e,
220
+ kind: String(t)
221
+ });
222
+ case "undefined": return t === void 0 ? e.inArray ? O({
223
+ step: e,
224
+ kind: "undefined in an array"
225
+ }) : "leaf" : E({
226
+ step: e,
227
+ held: t
228
+ });
229
+ case "object": return t === null ? "leaf" : E({
230
+ step: e,
231
+ held: t
232
+ });
233
+ default: return O({
234
+ step: e,
235
+ kind: ee[n]
236
+ });
237
+ }
238
+ }
239
+ function E(e) {
240
+ let { step: t, held: n } = e, r = Array.isArray(n), i = Object.getPrototypeOf(n);
241
+ return D({
242
+ prototype: i,
243
+ name: r ? "Array" : "Object"
244
+ }) || O({
245
+ step: t,
246
+ kind: `an instance of ${n.constructor?.name || "a class"}`
247
+ }), i === null && JSON.isRawJSON?.(n) && O({
248
+ step: t,
249
+ kind: "a raw JSON value"
250
+ }), typeof n.toJSON == "function" && O({
251
+ step: t,
252
+ kind: "a value with toJSON"
253
+ }), t.ancestors.includes(n) && O({
254
+ step: t,
255
+ kind: "a cycle"
256
+ }), t.ancestors.length >= 512 && O({
257
+ step: t,
258
+ kind: "a value nested more than 512 levels deep"
259
+ }), r ? "array" : "object";
260
+ }
261
+ function D(e) {
262
+ let { prototype: t, name: n } = e;
263
+ if (t === (n === "Array" ? Array.prototype : Object.prototype)) return !0;
264
+ if (t === null) return n === "Object";
265
+ let r = Object.getOwnPropertyDescriptor(t, "constructor")?.value;
266
+ return typeof r == "function" && r.name === n;
267
+ }
268
+ function O(e) {
269
+ let t = String(e.step.field);
270
+ throw TypeError(`${e.kind} is not a JSON value${t ? ` (field "${t}")` : ""}`);
271
+ }
272
+ var ye = /* @__PURE__ */ new WeakSet();
273
+ function be(e) {
274
+ let { listener: t, value: n, of: r, call: i } = e;
275
+ if (t) try {
276
+ let e = t(n);
277
+ Ce(e) && Promise.resolve(e).catch(function(e) {
278
+ Se({
279
+ call: i,
280
+ of: r,
281
+ thrown: e
282
+ });
283
+ });
284
+ } catch (e) {
285
+ Se({
286
+ call: i,
287
+ of: r,
288
+ thrown: e
289
+ });
290
+ }
291
+ }
292
+ function xe(e) {
293
+ return `the changes of project "${e.name}"`;
294
+ }
295
+ function Se(e) {
296
+ let { call: t } = e;
297
+ if (t !== void 0) {
298
+ if (ye.has(t)) return;
299
+ ye.add(t);
300
+ }
301
+ console.error(`[dialecte] a listener of ${e.of} threw; what told it goes on:`, e.thrown);
302
+ }
303
+ function Ce(e) {
304
+ return typeof e == "object" && !!e && typeof e.then == "function";
305
+ }
306
+ var we = {
307
+ importProgress: "an import's progress",
308
+ importedFile: "an imported file's entry",
309
+ exportProgress: "an export's progress",
310
+ commitProgress: "a commit's progress",
311
+ callProgress: "a call's progress",
312
+ engineChanges: "a project engine's changes"
313
+ }, Te = [
314
+ "",
315
+ ".",
316
+ ".."
317
+ ], Ee = "xel_";
318
+ function De(e) {
319
+ return `${Ee}${e}`;
320
+ }
321
+ function Oe(e) {
322
+ let { project: t, dialecteId: n } = e;
323
+ (Te.includes(t) || n !== void 0 && Te.includes(n)) && h("PROJECT_NAME_INVALID", {
324
+ detail: `A project cannot be named ${JSON.stringify(t)}${n === void 0 ? "" : ` in dialecte ${JSON.stringify(n)}`}: neither its name nor its dialecte's id may be empty, \`.\` or \`..\``,
325
+ meta: {
326
+ project: t,
327
+ ...n !== void 0 && { dialecteId: n }
328
+ }
329
+ });
330
+ }
331
+ var ke = Object.freeze({
332
+ start() {},
333
+ stop() {},
334
+ count() {},
335
+ time(e, t) {
336
+ return t();
337
+ },
338
+ profile(e, t) {
339
+ return t();
340
+ },
341
+ report() {
342
+ return {};
343
+ },
344
+ log() {},
345
+ reset() {},
346
+ snapshot() {
347
+ return {
348
+ timeOrigin: performance.timeOrigin,
349
+ spans: [],
350
+ totals: {}
351
+ };
352
+ },
353
+ merge() {}
354
+ }), k = "dialecte::";
355
+ function Ae({ enabled: e, timeline: t = !0 }) {
356
+ if (!e) return ke;
357
+ let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = [], o = 0;
358
+ function s(e) {
359
+ t ? performance.measure(k + e.name, {
360
+ start: e.startTime,
361
+ duration: e.duration
362
+ }) : a.push(e);
363
+ }
364
+ function c() {
365
+ return t ? performance.getEntriesByType("measure").filter((e) => e.name.startsWith(k)).map((e) => ({
366
+ name: e.name.slice(10),
367
+ startTime: e.startTime,
368
+ duration: e.duration
369
+ })) : a;
370
+ }
371
+ function l(e, t, n) {
372
+ let r = i.get(e) ?? i.set(e, {
373
+ calls: 0,
374
+ totalMs: 0
375
+ }).get(e);
376
+ r.calls += t, r.totalMs += n;
377
+ }
378
+ let u = {
379
+ start(e) {
380
+ let r = k + e, i = `${r}:${++o}`;
381
+ t && performance.mark(i), (n.get(r) ?? n.set(r, []).get(r)).push({
382
+ mark: i,
383
+ startTime: performance.now()
384
+ });
385
+ },
386
+ stop(e) {
387
+ let r = k + e, i = n.get(r)?.pop();
388
+ i && (t ? (performance.measure(r, i.mark), performance.clearMarks(i.mark)) : a.push({
389
+ name: e,
390
+ startTime: i.startTime,
391
+ duration: performance.now() - i.startTime
392
+ }));
393
+ },
394
+ count(e) {
395
+ let t = k + e;
396
+ r.set(t, (r.get(t) ?? 0) + 1);
397
+ },
398
+ time(e, t) {
399
+ let n = k + e, r = performance.now();
400
+ try {
401
+ return t();
402
+ } finally {
403
+ l(n, 1, performance.now() - r);
404
+ }
405
+ },
406
+ profile(e, t) {
407
+ return typeof console.profile == "function" ? (console.profile(k + e), Promise.resolve(t()).finally(() => console.profileEnd(k + e))) : t();
408
+ },
409
+ report() {
410
+ let e = {};
411
+ for (let { name: t, duration: n } of c()) {
412
+ let r = e[t] ??= {
413
+ calls: 0,
414
+ totalMs: 0,
415
+ avgMs: 0
416
+ };
417
+ r.calls++, r.totalMs += n, r.avgMs = r.totalMs / r.calls;
418
+ }
419
+ return d(e);
420
+ },
421
+ log() {
422
+ console.table(u.report());
423
+ },
424
+ reset() {
425
+ t && (performance.clearMarks(), performance.clearMeasures()), n.clear(), a.length = 0, r.clear(), i.clear();
426
+ },
427
+ snapshot() {
428
+ return {
429
+ timeOrigin: performance.timeOrigin,
430
+ spans: [...c()],
431
+ totals: d({})
432
+ };
433
+ },
434
+ merge({ report: e, prefix: t }) {
435
+ let n = e.timeOrigin - performance.timeOrigin;
436
+ for (let r of e.spans) s({
437
+ name: `${t}::${r.name}`,
438
+ startTime: Math.max(0, r.startTime + n),
439
+ duration: r.duration
440
+ });
441
+ for (let [n, i] of Object.entries(e.totals)) {
442
+ let e = `${k}${t}::${n}`;
443
+ i.calls > 0 && l(e, i.calls, i.totalMs), i.count !== void 0 && r.set(e, (r.get(e) ?? 0) + i.count);
444
+ }
445
+ }
446
+ };
447
+ function d(e) {
448
+ for (let [t, n] of i) {
449
+ let r = t.slice(10), i = e[r] ??= {
450
+ calls: 0,
451
+ totalMs: 0,
452
+ avgMs: 0
453
+ };
454
+ i.calls += n.calls, i.totalMs += n.totalMs, i.avgMs = i.calls ? i.totalMs / i.calls : 0;
455
+ }
456
+ for (let [t, n] of r) {
457
+ let r = t.slice(10), i = e[r] ??= {
458
+ calls: 0,
459
+ totalMs: 0,
460
+ avgMs: 0
461
+ };
462
+ i.count = n;
463
+ }
464
+ return e;
465
+ }
466
+ return u;
467
+ }
468
+ function je(e) {
469
+ let { configs: t, defaultConfigKey: n, configKey: r = n } = e, i = t[r];
470
+ return d(i, {
471
+ key: "UNKNOWN_CONFIG_KEY",
472
+ detail: `Unknown configKey: "${r}". Available: ${Object.keys(t).join(", ")}`
473
+ }), {
474
+ configKey: r,
475
+ config: i
476
+ };
477
+ }
478
+ function Me() {
479
+ return new Promise(function(e) {
480
+ let t = new MessageChannel();
481
+ t.port1.onmessage = function() {
482
+ t.port1.close(), e();
483
+ }, t.port2.postMessage(null);
484
+ });
485
+ }
486
+ function Ne(e) {
487
+ let { record: t, config: n } = e;
488
+ return t.tagName === n.rootElementName && t.parent === null;
489
+ }
490
+ var Pe = "_temp-idb-id", Fe = {
491
+ namespaceURI: n,
492
+ prefix: null,
493
+ localName: "xmlns",
494
+ value: ""
495
+ }, Ie = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>", Le = " ", Re = /[&<>"\t\n\r]/, ze = /[&<>"\t\n\r]/g, Be = /[&<>]/, Ve = /[&<>]/g, He = /[&<>\r]/, Ue = /[&<>\r]/g, We = {
496
+ "&": "&amp;",
497
+ "<": "&lt;",
498
+ ">": "&gt;",
499
+ "\"": "&quot;",
500
+ " ": "&#9;",
501
+ "\n": "&#10;",
502
+ "\r": "&#13;"
503
+ }, Ge = {
504
+ bindings: /* @__PURE__ */ new Map(),
505
+ parent: void 0
506
+ }, Ke = /* @__PURE__ */ new Set();
507
+ function A(e) {
508
+ let { namespaceURI: t, qualifiedName: n, parent: r } = e;
509
+ if (t === null) return {
510
+ namespaceURI: t,
511
+ prefix: null,
512
+ localName: n,
513
+ attributes: [],
514
+ parent: r
515
+ };
516
+ let { prefix: i, localName: a } = z(n);
517
+ return {
518
+ namespaceURI: t,
519
+ prefix: i,
520
+ localName: a,
521
+ attributes: [],
522
+ parent: r
523
+ };
524
+ }
525
+ function j(e) {
526
+ let { element: t, qualifiedName: n, value: r } = e, i = t.attributes.find((e) => B(e) === n);
527
+ i ? i.value = r : t.attributes.push({
528
+ namespaceURI: null,
529
+ prefix: null,
530
+ localName: n,
531
+ value: r
532
+ });
533
+ }
534
+ function M(e) {
535
+ let { element: t, namespaceURI: n, qualifiedName: r, value: i } = e, { prefix: a, localName: o } = z(r), s = V({
536
+ element: t,
537
+ namespaceURI: n,
538
+ localName: o
539
+ });
540
+ s ? s.value = i : t.attributes.push({
541
+ namespaceURI: n,
542
+ prefix: a,
543
+ localName: o,
544
+ value: i
545
+ });
546
+ }
547
+ function N(e) {
548
+ let { element: t, qualifiedName: n } = e;
549
+ return t.attributes.some((e) => B(e) === n);
550
+ }
551
+ function qe(e) {
552
+ return V(e)?.value ?? null;
553
+ }
554
+ function P(e) {
555
+ return V(e) !== void 0;
556
+ }
557
+ function F(e) {
558
+ let { prefix: t } = e;
559
+ for (let n = e.element; n; n = n.parent) {
560
+ if (n.namespaceURI !== null && n.prefix === t) return n.namespaceURI;
561
+ let e = n.attributes.find((e) => $e({
562
+ attribute: e,
563
+ prefix: t
564
+ }));
565
+ if (e) return e.value || null;
566
+ }
567
+ return null;
568
+ }
569
+ function I(e) {
570
+ let { element: t, prefixes: n } = e, r, i = e.scope, a;
571
+ for (let e of t.attributes) {
572
+ let t = et(e);
573
+ t !== void 0 && H({
574
+ parent: i,
575
+ own: a,
576
+ prefix: t
577
+ }) !== e.value && (a ??= /* @__PURE__ */ new Map(), a.set(t, e.value));
578
+ }
579
+ let o = `<${B(t)}`, s = t.prefix ?? "", c = t.namespaceURI ?? "", l = H({
580
+ parent: i,
581
+ own: a,
582
+ prefix: ""
583
+ });
584
+ (t.namespaceURI !== null || l) && (H({
585
+ parent: i,
586
+ own: a,
587
+ prefix: s
588
+ }) ?? "") !== c && (o += s ? ` xmlns:${s}="${L(c)}"` : ` xmlns="${L(c)}"`, a ??= /* @__PURE__ */ new Map(), a.set(s, c));
589
+ for (let e of t.attributes) {
590
+ let { namespaceURI: t } = e;
591
+ if (t === null || t === "http://www.w3.org/2000/xmlns/" || t === "http://www.w3.org/XML/1998/namespace" || e.prefix === null) {
592
+ o += ` ${B(e)}="${L(e.value)}"`;
593
+ continue;
594
+ }
595
+ let { prefix: s, declare: c } = Je({
596
+ attribute: e,
597
+ parent: i,
598
+ own: a,
599
+ prefixes: n
600
+ });
601
+ c && (o += ` xmlns:${s}="${L(t)}"`, a ??= /* @__PURE__ */ new Map(), a.set(s, t), r ??= /* @__PURE__ */ new Set(), r.add(s)), o += ` ${s}:${e.localName}="${L(e.value)}"`;
602
+ }
603
+ return {
604
+ text: o,
605
+ scope: a ? {
606
+ bindings: a,
607
+ parent: i
608
+ } : i,
609
+ generated: r ?? Ke
610
+ };
611
+ }
612
+ function Je(e) {
613
+ let { attribute: t, parent: n, own: r, prefixes: i } = e, a = t.namespaceURI, o = t.prefix, s = H({
614
+ parent: n,
615
+ own: r,
616
+ prefix: o
617
+ });
618
+ if (s === a) return {
619
+ prefix: o,
620
+ declare: !1
621
+ };
622
+ let c = Ye({
623
+ parent: n,
624
+ own: r,
625
+ namespaceURI: a
626
+ });
627
+ if (c !== void 0) return {
628
+ prefix: c,
629
+ declare: !1
630
+ };
631
+ if (s === void 0) return {
632
+ prefix: o,
633
+ declare: !0
634
+ };
635
+ for (;;) {
636
+ let e = `ns${i.next}`;
637
+ if (i.next++, H({
638
+ parent: n,
639
+ own: r,
640
+ prefix: e
641
+ }) === void 0) return {
642
+ prefix: e,
643
+ declare: !0
644
+ };
645
+ }
646
+ }
647
+ function Ye(e) {
648
+ let { parent: t, own: n, namespaceURI: r } = e, i = /* @__PURE__ */ new Set(), a = [n, ...Xe(t)];
649
+ for (let e of a) if (e) {
650
+ for (let [t, n] of [...e].reverse()) if (!i.has(t) && (i.add(t), t && n === r)) return t;
651
+ }
652
+ }
653
+ function Xe(e) {
654
+ let t = [];
655
+ for (let n = e; n; n = n.parent) t.push(n.bindings);
656
+ return t;
657
+ }
658
+ function L(e) {
659
+ return Re.test(e) ? e.replace(ze, R) : e;
660
+ }
661
+ function Ze(e) {
662
+ return He.test(e) ? e.replace(Ue, R) : e;
663
+ }
664
+ function Qe(e) {
665
+ return Be.test(e) ? e.replace(Ve, R) : e;
666
+ }
667
+ function R(e) {
668
+ return We[e];
669
+ }
670
+ function z(e) {
671
+ let t = e.indexOf(":");
672
+ return t === -1 ? {
673
+ prefix: null,
674
+ localName: e
675
+ } : {
676
+ prefix: e.slice(0, t),
677
+ localName: e.slice(t + 1)
678
+ };
679
+ }
680
+ function B(e) {
681
+ return e.prefix ? `${e.prefix}:${e.localName}` : e.localName;
682
+ }
683
+ function V(e) {
684
+ let { element: t, namespaceURI: n, localName: r } = e;
685
+ return t.attributes.find((e) => e.namespaceURI === n && e.localName === r);
686
+ }
687
+ function $e(e) {
688
+ let { attribute: t, prefix: n } = e;
689
+ return t.namespaceURI === "http://www.w3.org/2000/xmlns/" ? n === null ? t.prefix === null && t.localName === "xmlns" : t.prefix === "xmlns" && t.localName === n : !1;
690
+ }
691
+ function et(e) {
692
+ if (e.namespaceURI === "http://www.w3.org/2000/xmlns/") return e.prefix === "xmlns" ? e.localName : "";
693
+ if (e.namespaceURI === null && e.localName === "xmlns") return "";
694
+ }
695
+ function tt(e) {
696
+ let { prefix: t } = e;
697
+ for (let n = e.scope; n; n = n.parent) {
698
+ let e = n.bindings.get(t);
699
+ if (e !== void 0) return e;
700
+ }
701
+ }
702
+ function H(e) {
703
+ let { parent: t, own: n, prefix: r } = e;
704
+ return n?.get(r) ?? tt({
705
+ scope: t,
706
+ prefix: r
707
+ });
708
+ }
709
+ function nt(e) {
710
+ let { config: t, rootUri: n } = e, r = Object.values(t.namespaces).map((e) => e.prefix).filter((e) => e !== ""), i = !r.includes("xs"), a = /* @__PURE__ */ new Set([
711
+ ...r,
712
+ o.prefix,
713
+ "xml",
714
+ "xmlns"
715
+ ]);
716
+ return i && a.add("xs"), {
717
+ bindings: /* @__PURE__ */ new Map(),
718
+ prefixByUri: /* @__PURE__ */ new Map(),
719
+ reserved: a,
720
+ xsdTakesXs: i,
721
+ nextGenerated: 1,
722
+ defaultOnRoot: n !== "",
723
+ alias: void 0
724
+ };
725
+ }
726
+ function U(e) {
727
+ let { table: t, config: n, uri: r, storedPrefix: i } = e, a = t.prefixByUri.get(r);
728
+ if (a !== void 0) return {
729
+ table: t,
730
+ prefix: a
731
+ };
732
+ if (r === "") return {
733
+ table: t,
734
+ prefix: ""
735
+ };
736
+ if (r === "http://www.w3.org/XML/1998/namespace") return {
737
+ table: t,
738
+ prefix: "xml"
739
+ };
740
+ let { prefix: o, nextGenerated: s } = at({
741
+ table: t,
742
+ config: n,
743
+ uri: r,
744
+ storedPrefix: i
745
+ }), c = new Map(t.prefixByUri).set(r, o), l = o !== "" || t.defaultOnRoot ? new Map(t.bindings).set(o, r) : t.bindings;
746
+ return {
747
+ table: {
748
+ ...t,
749
+ prefixByUri: c,
750
+ bindings: l,
751
+ nextGenerated: s
752
+ },
753
+ prefix: o
754
+ };
755
+ }
756
+ function W(e) {
757
+ let { table: t, config: n, storedPrefix: r } = e;
758
+ if (t.alias !== void 0) return {
759
+ table: t,
760
+ prefix: t.alias
761
+ };
762
+ let { prefix: i, nextGenerated: a } = r && G({
763
+ table: t,
764
+ prefix: r
765
+ }) ? {
766
+ prefix: r,
767
+ nextGenerated: t.nextGenerated
768
+ } : st({ table: t }), o = new Map(t.bindings).set(i, n.namespaces.default.uri);
769
+ return {
770
+ table: {
771
+ ...t,
772
+ alias: i,
773
+ bindings: o,
774
+ nextGenerated: a
775
+ },
776
+ prefix: i
777
+ };
778
+ }
779
+ function rt(e) {
780
+ let { table: t, config: n } = e, { prefixByUri: r } = t, i = t.bindings.get(""), a = [];
781
+ i && a.push(K({
782
+ uri: i,
783
+ prefix: ""
784
+ })), t.alias !== void 0 && a.push(K({
785
+ uri: n.namespaces.default.uri,
786
+ prefix: t.alias
787
+ }));
788
+ let s = [];
789
+ r.has(o.uri) && s.push(o.uri);
790
+ let c = /* @__PURE__ */ new Set();
791
+ for (let e of Object.values(n.namespaces)) c.add(e.uri), e.uri !== n.namespaces.default.uri && e.uri !== o.uri && r.has(e.uri) && !s.includes(e.uri) && s.push(e.uri);
792
+ let l = [...r.keys()].filter((e) => e !== i && e !== o.uri && !c.has(e)).sort(ct);
793
+ for (let e of [...s, ...l]) a.push(K({
794
+ uri: e,
795
+ prefix: r.get(e) ?? ""
796
+ }));
797
+ return a;
798
+ }
799
+ function it(e) {
800
+ let { table: t, config: n, documentRoot: r, element: i } = e;
801
+ if (!r || t.prefixByUri.size === 0) return [];
802
+ let a = {
803
+ ...i,
804
+ attributes: [...i.attributes]
805
+ };
806
+ for (let [e, i] of t.prefixByUri) lt({
807
+ config: n,
808
+ element: a,
809
+ namespace: {
810
+ prefix: i,
811
+ uri: e
812
+ },
813
+ rootRecord: r
814
+ });
815
+ return a.attributes.slice(i.attributes.length);
816
+ }
817
+ function at(e) {
818
+ let { table: t, config: n, uri: r, storedPrefix: i } = e, a = t.nextGenerated;
819
+ if (r === n.namespaces.default.uri) return {
820
+ prefix: "",
821
+ nextGenerated: a
822
+ };
823
+ let s = Object.values(n.namespaces).find((e) => e.uri === r && e.prefix !== "");
824
+ return s ? {
825
+ prefix: s.prefix,
826
+ nextGenerated: a
827
+ } : r === o.uri ? {
828
+ prefix: o.prefix,
829
+ nextGenerated: a
830
+ } : r === "http://www.w3.org/2001/XMLSchema" && t.xsdTakesXs ? {
831
+ prefix: "xs",
832
+ nextGenerated: a
833
+ } : i ? {
834
+ prefix: ot({
835
+ table: t,
836
+ storedPrefix: i
837
+ }),
838
+ nextGenerated: a
839
+ } : st({ table: t });
840
+ }
841
+ function ot(e) {
842
+ let { table: t, storedPrefix: n } = e;
843
+ if (G({
844
+ table: t,
845
+ prefix: n
846
+ })) return n;
847
+ for (let e = 2;; e++) {
848
+ let r = `${n}${e}`;
849
+ if (G({
850
+ table: t,
851
+ prefix: r
852
+ })) return r;
853
+ }
854
+ }
855
+ function st(e) {
856
+ let { table: t } = e;
857
+ for (let e = t.nextGenerated;; e++) {
858
+ let n = `ns${e}`;
859
+ if (G({
860
+ table: t,
861
+ prefix: n
862
+ })) return {
863
+ prefix: n,
864
+ nextGenerated: e + 1
865
+ };
866
+ }
867
+ }
868
+ function G(e) {
869
+ let { table: t, prefix: n } = e;
870
+ return !t.reserved.has(n) && !t.bindings.has(n);
871
+ }
872
+ function K(e) {
873
+ let { uri: t, prefix: r } = e;
874
+ return r ? {
875
+ namespaceURI: n,
876
+ prefix: "xmlns",
877
+ localName: r,
878
+ value: t
879
+ } : {
880
+ namespaceURI: n,
881
+ prefix: null,
882
+ localName: "xmlns",
883
+ value: t
884
+ };
885
+ }
886
+ function ct(e, t) {
887
+ return e === t ? 0 : e < t ? -1 : 1;
888
+ }
889
+ function lt(t) {
890
+ let { config: n, element: r, namespace: i, rootRecord: a } = t, o = e({
891
+ dialecteConfig: n,
892
+ record: a
893
+ })?.attributes.details ?? {}, c = i.uri === n.namespaces.default.uri;
894
+ for (let [e, t] of Object.entries(o)) {
895
+ let o = l({
896
+ dialecteConfig: n,
897
+ record: a,
898
+ attributeName: e,
899
+ defaults: "required"
900
+ });
901
+ if (o === void 0 || !(c ? !t.namespace : t.namespace?.prefix === i.prefix && t.namespace?.uri === i.uri)) continue;
902
+ let u = s(e);
903
+ (t.namespace ? P({
904
+ element: r,
905
+ namespaceURI: t.namespace.uri,
906
+ localName: u
907
+ }) : N({
908
+ element: r,
909
+ qualifiedName: u
910
+ })) || (t.namespace ? M({
911
+ element: r,
912
+ namespaceURI: t.namespace.uri,
913
+ qualifiedName: `${t.namespace.prefix}:${u}`,
914
+ value: o
915
+ }) : j({
916
+ element: r,
917
+ qualifiedName: u,
918
+ value: o
919
+ }));
920
+ }
921
+ }
922
+ function ut(e) {
923
+ let { settings: t, table: n, record: r, parent: i } = e, { config: a, declareNamespaces: o, withDatabaseIds: s } = t, c = o && g({
924
+ dialecteConfig: a,
925
+ tagName: r.tagName
926
+ }), l = o && i !== void 0, u = l || c ? v({
927
+ dialecteConfig: a,
928
+ record: r
929
+ }) : void 0, d = dt({
930
+ settings: t,
931
+ table: n,
932
+ record: r,
933
+ parent: i,
934
+ holdsNoNamespaceName: o && bt({
935
+ config: a,
936
+ record: r,
937
+ definition: u
938
+ })
939
+ }), { element: f } = d, p = pt({
940
+ settings: t,
941
+ table: d.table,
942
+ element: f,
943
+ attributes: r.attributes
944
+ }), m = r.value;
945
+ if (u !== void 0 && c) {
946
+ let e = _t({
947
+ settings: t,
948
+ table: p,
949
+ element: f,
950
+ record: r,
951
+ definition: u
952
+ });
953
+ p = e.table, m = e.text;
954
+ }
955
+ return u !== void 0 && l && (p = ht({
956
+ settings: t,
957
+ table: p,
958
+ element: f,
959
+ record: r,
960
+ definition: u
961
+ })), s && j({
962
+ element: f,
963
+ qualifiedName: "_temp-idb-id",
964
+ value: r.id
965
+ }), o && (p = gt({
966
+ settings: t,
967
+ table: p,
968
+ element: f
969
+ })), {
970
+ element: f,
971
+ table: p,
972
+ text: m
973
+ };
974
+ }
975
+ function dt(e) {
976
+ let { settings: t, table: n, record: r, parent: i, holdsNoNamespaceName: a } = e, { namespace: o, tagName: s } = r;
977
+ if (!t.declareNamespaces) return {
978
+ element: A({
979
+ namespaceURI: null,
980
+ qualifiedName: o.uri !== t.config.namespaces.default.uri && o.prefix ? `${o.prefix}:${s}` : s,
981
+ parent: i
982
+ }),
983
+ table: n
984
+ };
985
+ let c = U({
986
+ table: n,
987
+ config: t.config,
988
+ uri: o.uri,
989
+ storedPrefix: o.prefix
990
+ });
991
+ if (a) return ft({
992
+ settings: t,
993
+ registration: c,
994
+ record: r,
995
+ parent: i
996
+ });
997
+ let { prefix: l } = c;
998
+ return {
999
+ element: A({
1000
+ namespaceURI: o.uri,
1001
+ qualifiedName: l ? `${l}:${s}` : s,
1002
+ parent: i
1003
+ }),
1004
+ table: c.table
1005
+ };
1006
+ }
1007
+ function ft(e) {
1008
+ let { settings: t, registration: n, record: r, parent: i } = e, { namespace: a, tagName: o } = r, s = !n.prefix && a.uri !== "", c = i && F({
1009
+ element: i,
1010
+ prefix: null
1011
+ }), l = s ? W({
1012
+ table: n.table,
1013
+ config: t.config,
1014
+ storedPrefix: void 0
1015
+ }) : n, u = A({
1016
+ namespaceURI: a.uri,
1017
+ qualifiedName: l.prefix ? `${l.prefix}:${o}` : o,
1018
+ parent: i
1019
+ });
1020
+ return {
1021
+ element: c && a.uri !== "" ? {
1022
+ ...u,
1023
+ attributes: [{ ...Fe }]
1024
+ } : u,
1025
+ table: l.table
1026
+ };
1027
+ }
1028
+ function pt(e) {
1029
+ let { settings: t, element: n, attributes: r } = e, { table: i } = e;
1030
+ for (let e of r) {
1031
+ if (Ct(e)) continue;
1032
+ let r = String(e.value);
1033
+ if (!St(e) || !e.namespace.prefix) {
1034
+ j({
1035
+ element: n,
1036
+ qualifiedName: e.name,
1037
+ value: r
1038
+ });
1039
+ continue;
1040
+ }
1041
+ let a = s(e.name);
1042
+ t.declareNamespaces ? i = mt({
1043
+ settings: t,
1044
+ table: i,
1045
+ element: n,
1046
+ namespace: e.namespace,
1047
+ localName: a,
1048
+ value: r
1049
+ }) : j({
1050
+ element: n,
1051
+ qualifiedName: `${e.namespace.prefix}:${a}`,
1052
+ value: r
1053
+ });
1054
+ }
1055
+ return i;
1056
+ }
1057
+ function mt(e) {
1058
+ let { settings: t, table: n, element: r, namespace: i, localName: a, value: o } = e;
1059
+ if (i.uri === "") return j({
1060
+ element: r,
1061
+ qualifiedName: a,
1062
+ value: o
1063
+ }), n;
1064
+ let { config: s } = t, c = U({
1065
+ table: n,
1066
+ config: s,
1067
+ uri: i.uri,
1068
+ storedPrefix: i.prefix
1069
+ }), l = c.prefix ? c : W({
1070
+ table: c.table,
1071
+ config: s,
1072
+ storedPrefix: i.prefix
1073
+ });
1074
+ return M({
1075
+ element: r,
1076
+ namespaceURI: i.uri,
1077
+ qualifiedName: `${l.prefix}:${a}`,
1078
+ value: o
1079
+ }), l.table;
1080
+ }
1081
+ function ht(e) {
1082
+ let { settings: t, element: n, record: r, definition: i } = e, { config: a } = t, { table: o } = e;
1083
+ for (let [e, c] of Object.entries(i.attributes.details)) {
1084
+ let i = l({
1085
+ dialecteConfig: a,
1086
+ record: r,
1087
+ attributeName: e,
1088
+ defaults: "required"
1089
+ });
1090
+ if (i === void 0) continue;
1091
+ let u = s(e);
1092
+ (c.namespace ? P({
1093
+ element: n,
1094
+ namespaceURI: c.namespace.uri,
1095
+ localName: u
1096
+ }) : N({
1097
+ element: n,
1098
+ qualifiedName: u
1099
+ })) || (c.namespace && c.namespace.prefix ? o = mt({
1100
+ settings: t,
1101
+ table: o,
1102
+ element: n,
1103
+ namespace: c.namespace,
1104
+ localName: u,
1105
+ value: i
1106
+ }) : j({
1107
+ element: n,
1108
+ qualifiedName: u,
1109
+ value: i
1110
+ }));
1111
+ }
1112
+ return o;
1113
+ }
1114
+ function gt(e) {
1115
+ let { settings: t, table: n, element: r } = e, { config: i } = t, a = qe({
1116
+ element: r,
1117
+ namespaceURI: o.uri,
1118
+ localName: "type"
1119
+ });
1120
+ if (a === null) return n;
1121
+ let s = vt({
1122
+ settings: t,
1123
+ table: n,
1124
+ element: r,
1125
+ value: a,
1126
+ notation: !1
1127
+ });
1128
+ if (s === void 0) return n;
1129
+ let c = U({
1130
+ table: s.table,
1131
+ config: i,
1132
+ uri: o.uri,
1133
+ storedPrefix: o.prefix
1134
+ });
1135
+ return M({
1136
+ element: r,
1137
+ namespaceURI: o.uri,
1138
+ qualifiedName: `${c.prefix}:type`,
1139
+ value: s.value
1140
+ }), c.table;
1141
+ }
1142
+ function _t(e) {
1143
+ let { settings: t, element: n, record: r, definition: i } = e, { table: a } = e;
1144
+ for (let e of r.attributes) {
1145
+ let r = _({
1146
+ definition: i,
1147
+ attribute: e
1148
+ });
1149
+ if (r === void 0 || !m(r)) continue;
1150
+ let o = q({
1151
+ settings: t,
1152
+ table: a,
1153
+ element: n,
1154
+ type: r,
1155
+ value: String(e.value)
1156
+ });
1157
+ a = o.table, St(e) && e.namespace.prefix ? M({
1158
+ element: n,
1159
+ namespaceURI: e.namespace.uri,
1160
+ qualifiedName: s(e.name),
1161
+ value: o.value
1162
+ }) : j({
1163
+ element: n,
1164
+ qualifiedName: e.name,
1165
+ value: o.value
1166
+ });
1167
+ }
1168
+ let o = i.textContent?.type;
1169
+ if (o === void 0 || !m(o) || r.value === "") return {
1170
+ table: a,
1171
+ text: r.value
1172
+ };
1173
+ let c = q({
1174
+ settings: t,
1175
+ table: a,
1176
+ element: n,
1177
+ type: o,
1178
+ value: r.value
1179
+ });
1180
+ return {
1181
+ table: c.table,
1182
+ text: c.value
1183
+ };
1184
+ }
1185
+ function q(e) {
1186
+ let { settings: t, element: n, value: a } = e, { table: o } = e, s = r({
1187
+ type: e.type,
1188
+ value: a,
1189
+ namespaceOf: i({ dialecteConfig: t.config })
1190
+ });
1191
+ if (s === void 0) return {
1192
+ table: o,
1193
+ value: a
1194
+ };
1195
+ if ("builtin" in s) {
1196
+ let e = s.builtin === "NOTATION";
1197
+ return vt({
1198
+ settings: t,
1199
+ table: o,
1200
+ element: n,
1201
+ value: a,
1202
+ notation: e
1203
+ }) ?? {
1204
+ table: o,
1205
+ value: a
1206
+ };
1207
+ }
1208
+ let c = [];
1209
+ for (let e of p(a)) {
1210
+ let r = q({
1211
+ settings: t,
1212
+ table: o,
1213
+ element: n,
1214
+ type: s.list,
1215
+ value: e
1216
+ });
1217
+ o = r.table, c.push(r.value);
1218
+ }
1219
+ return {
1220
+ table: o,
1221
+ value: c.join(" ")
1222
+ };
1223
+ }
1224
+ function vt(e) {
1225
+ let { settings: t, table: n, element: r, value: o, notation: s } = e, c = a({
1226
+ value: o,
1227
+ namespaceOf: i({ dialecteConfig: t.config })
1228
+ });
1229
+ if (c === void 0) return;
1230
+ if (c.namespace === "") return F({
1231
+ element: r,
1232
+ prefix: null
1233
+ }) ? void 0 : {
1234
+ table: n,
1235
+ value: c.local
1236
+ };
1237
+ let l = xt({
1238
+ settings: t,
1239
+ table: n,
1240
+ element: r,
1241
+ uri: c.namespace
1242
+ }), u = s && l.prefix === "" && c.namespace !== "" ? W({
1243
+ table: l.table,
1244
+ config: t.config,
1245
+ storedPrefix: void 0
1246
+ }) : l;
1247
+ return {
1248
+ table: u.table,
1249
+ value: u.prefix ? `${u.prefix}:${c.local}` : c.local
1250
+ };
1251
+ }
1252
+ function yt(e) {
1253
+ let { settings: t, record: n } = e, { config: r, declareNamespaces: i } = t;
1254
+ return i ? n.namespace.uri === r.namespaces.default.uri ? bt({
1255
+ config: r,
1256
+ record: n,
1257
+ definition: g({
1258
+ dialecteConfig: r,
1259
+ tagName: n.tagName
1260
+ }) ? v({
1261
+ dialecteConfig: r,
1262
+ record: n
1263
+ }) : void 0
1264
+ }) ? "" : n.namespace.uri : "" : n.namespace.uri;
1265
+ }
1266
+ function bt(e) {
1267
+ let { record: n, definition: a, config: o } = e;
1268
+ function s(e, t) {
1269
+ return e === void 0 ? !1 : r({
1270
+ type: e,
1271
+ value: t,
1272
+ namespaceOf: i({ dialecteConfig: o })
1273
+ }) !== void 0;
1274
+ }
1275
+ for (let e of n.attributes) if (typeof e.value == "string" && wt(e.value) && (t(e) || s(a && _({
1276
+ definition: a,
1277
+ attribute: e
1278
+ }), e.value))) return !0;
1279
+ return wt(n.value) && s(a?.textContent?.type, n.value);
1280
+ }
1281
+ function xt(e) {
1282
+ let { settings: t, table: n, element: r, uri: i } = e, { config: a } = t, o = U({
1283
+ table: n,
1284
+ config: a,
1285
+ uri: i,
1286
+ storedPrefix: void 0
1287
+ });
1288
+ return o.prefix !== "" || i === "" || F({
1289
+ element: r,
1290
+ prefix: null
1291
+ }) === i ? o : W({
1292
+ table: o.table,
1293
+ config: a,
1294
+ storedPrefix: void 0
1295
+ });
1296
+ }
1297
+ function St(e) {
1298
+ return !!e.namespace;
1299
+ }
1300
+ function Ct(e) {
1301
+ return e.name === "xmlns" || e.name.startsWith("xmlns:") ? !0 : e.namespace?.prefix === "xmlns";
1302
+ }
1303
+ function wt(e) {
1304
+ return p(e).some((e) => e.startsWith("{}"));
1305
+ }
1306
+ function Tt(e) {
1307
+ let t = f.exec(e.text);
1308
+ if (t) return `U+${t[0].charCodeAt(0).toString(16).toUpperCase().padStart(4, "0")}`;
1309
+ }
1310
+ function Et(e) {
1311
+ let { record: t, withId: n = !1 } = e, r = Dt({ record: t }) ?? Ot({
1312
+ record: t,
1313
+ withId: n
1314
+ });
1315
+ if (!r) return;
1316
+ let { character: i, attribute: a, part: o } = r;
1317
+ h("XML_CHARACTER_NOT_ALLOWED", {
1318
+ detail: `${kt({
1319
+ place: r,
1320
+ element: t.tagName ? `<${t.tagName}> '${t.id}'` : `the record '${t.id}'`
1321
+ })} holds ${i}, a character XML does not allow.`,
1322
+ ...t.tagName && { ref: {
1323
+ tagName: t.tagName,
1324
+ id: t.id
1325
+ } },
1326
+ meta: {
1327
+ recordId: t.id,
1328
+ ...t.tagName && { tagName: t.tagName },
1329
+ ...a && { attribute: a },
1330
+ part: o,
1331
+ character: i
1332
+ }
1333
+ });
1334
+ }
1335
+ function Dt(e) {
1336
+ let { record: t } = e, n = t.value === void 0 ? void 0 : J({
1337
+ text: t.value,
1338
+ part: "value"
1339
+ });
1340
+ if (n) return n;
1341
+ let r = t.namespace && J({
1342
+ text: t.namespace.uri,
1343
+ part: "namespace"
1344
+ });
1345
+ if (r) return r;
1346
+ for (let e of t.attributes ?? []) {
1347
+ let t = J({
1348
+ text: e.value,
1349
+ part: "value",
1350
+ attribute: e.name
1351
+ }) ?? (e.namespace && J({
1352
+ text: e.namespace.uri,
1353
+ part: "namespace",
1354
+ attribute: e.name
1355
+ }));
1356
+ if (t) return t;
1357
+ }
1358
+ }
1359
+ function Ot(e) {
1360
+ let { record: t, withId: n } = e, r = t.tagName === void 0 ? void 0 : J({
1361
+ text: t.tagName,
1362
+ part: "name"
1363
+ });
1364
+ if (r) return r;
1365
+ let i = t.namespace && J({
1366
+ text: t.namespace.prefix,
1367
+ part: "prefix"
1368
+ });
1369
+ if (i) return i;
1370
+ for (let e of t.attributes ?? []) {
1371
+ let t = e.namespace && J({
1372
+ text: e.namespace.prefix,
1373
+ part: "prefix",
1374
+ attribute: e.name
1375
+ }) || J({
1376
+ text: e.name,
1377
+ part: "name",
1378
+ attribute: e.name
1379
+ });
1380
+ if (t) return t;
1381
+ }
1382
+ return n ? J({
1383
+ text: t.id,
1384
+ part: "id"
1385
+ }) : void 0;
1386
+ }
1387
+ function kt(e) {
1388
+ let { place: t, element: n } = e, { part: r, attribute: i } = t;
1389
+ return i ? r === "value" ? `The attribute ${i} of ${n}` : r === "name" ? `The name of the attribute ${i} of ${n}` : `The ${r === "prefix" ? "namespace prefix" : "namespace URI"} of the attribute ${i} of ${n}` : r === "name" ? `The tag name of ${n}` : r === "prefix" ? `The namespace prefix of ${n}` : r === "namespace" ? `The namespace URI of ${n}` : r === "id" ? `The id of ${n}` : `The value of ${n}`;
1390
+ }
1391
+ function J(e) {
1392
+ let { text: t, part: n, attribute: r } = e, i = Tt({ text: t });
1393
+ if (i) return {
1394
+ character: i,
1395
+ part: n,
1396
+ ...r !== void 0 && { attribute: r }
1397
+ };
1398
+ }
1399
+ function Y(e) {
1400
+ let { config: t, documentRoot: n, declareNamespaces: r = !0, withDatabaseIds: i = !1 } = e, a = e.indent ?? !0, o = e.includeXmlDeclaration ?? !0, s = {
1401
+ config: t,
1402
+ declareNamespaces: r,
1403
+ withDatabaseIds: i
1404
+ }, c = [], l = [], u, d, f = {
1405
+ get bindings() {
1406
+ return u ? u.bindings : Ge.bindings;
1407
+ },
1408
+ parent: void 0
1409
+ }, p = { next: 1 }, m = [];
1410
+ function h(e) {
1411
+ return m[e] ??= "\r\n" + Le.repeat(e), m[e];
1412
+ }
1413
+ function g(e) {
1414
+ let { record: t } = e, n = c.at(-1), r = At({
1415
+ settings: s,
1416
+ table: u,
1417
+ record: t,
1418
+ parent: n
1419
+ });
1420
+ u = r.table;
1421
+ let { opened: i, startTag: o, text: m } = jt({
1422
+ element: r.element,
1423
+ record: t,
1424
+ value: r.text,
1425
+ parent: n,
1426
+ rootScope: f,
1427
+ prefixes: p,
1428
+ indent: a
1429
+ });
1430
+ o === void 0 ? d = i : (a && !i.insideInline && l.push(h(i.level)), l.push(o, i.empty ? "/>" : ">")), c.push(i), m && (a && !i.inline && l.push(h(i.level + 1)), l.push(Nt({
1431
+ text: m,
1432
+ indent: a
1433
+ })));
1434
+ }
1435
+ function _() {
1436
+ let e = c.pop();
1437
+ e && !e.empty && (a && !e.inline && l.push(h(e.level)), l.push(`</${e.qualifiedName}>`));
1438
+ }
1439
+ function v() {
1440
+ return l.splice(0).join("");
1441
+ }
1442
+ function ee() {
1443
+ return !d || !u ? "" : Pt({
1444
+ root: d,
1445
+ table: u,
1446
+ settings: s,
1447
+ documentRoot: n,
1448
+ indent: a,
1449
+ includeXmlDeclaration: o
1450
+ });
1451
+ }
1452
+ return {
1453
+ openElement: g,
1454
+ closeElement: _,
1455
+ take: v,
1456
+ head: ee
1457
+ };
1458
+ }
1459
+ function At(e) {
1460
+ let { settings: t, record: n, parent: r } = e;
1461
+ return Et({
1462
+ record: n,
1463
+ withId: t.withDatabaseIds
1464
+ }), ut({
1465
+ settings: t,
1466
+ table: r && e.table ? e.table : nt({
1467
+ config: t.config,
1468
+ rootUri: yt({
1469
+ settings: t,
1470
+ record: n
1471
+ })
1472
+ }),
1473
+ record: n,
1474
+ parent: r?.element
1475
+ });
1476
+ }
1477
+ function jt(e) {
1478
+ let { element: t, record: n, value: r, parent: i, rootScope: a, prefixes: o, indent: s } = e, c = r ? u({ text: r }) : "", l = i ? I({
1479
+ element: t,
1480
+ scope: i.scope,
1481
+ prefixes: o
1482
+ }) : void 0;
1483
+ return {
1484
+ opened: Mt({
1485
+ element: t,
1486
+ parent: i,
1487
+ scope: l ? l.scope : a,
1488
+ text: c,
1489
+ hasChildren: n.children.length > 0,
1490
+ indent: s
1491
+ }),
1492
+ startTag: l?.text,
1493
+ text: c
1494
+ };
1495
+ }
1496
+ function Mt(e) {
1497
+ let { element: t, parent: n, scope: r, text: i, hasChildren: a, indent: o } = e, s = n ? n.inline || n.insideInline : !1;
1498
+ return {
1499
+ element: t,
1500
+ qualifiedName: B(t),
1501
+ level: n ? n.level + 1 : 0,
1502
+ scope: r,
1503
+ empty: !i && !a,
1504
+ inline: !o || s || Ft({
1505
+ element: t,
1506
+ text: i,
1507
+ hasChildren: a
1508
+ }),
1509
+ insideInline: s
1510
+ };
1511
+ }
1512
+ function Nt(e) {
1513
+ let { text: t, indent: n } = e;
1514
+ return n ? Lt(Qe(t)) : Ze(t);
1515
+ }
1516
+ function Pt(e) {
1517
+ let { root: t, table: n, settings: r, documentRoot: i, indent: a, includeXmlDeclaration: o } = e, { config: s } = r, { element: c } = t, l = r.declareNamespaces ? rt({
1518
+ table: n,
1519
+ config: s
1520
+ }) : [], u = it({
1521
+ table: n,
1522
+ config: s,
1523
+ documentRoot: i,
1524
+ element: c
1525
+ }), { text: d } = I({
1526
+ element: {
1527
+ ...c,
1528
+ attributes: [
1529
+ ...l,
1530
+ ...c.attributes,
1531
+ ...u
1532
+ ]
1533
+ },
1534
+ scope: Ge,
1535
+ prefixes: { next: 1 }
1536
+ });
1537
+ return (o ? Ie + (a ? "\r\n" : "") : "") + d + (t.empty ? "/>" : ">");
1538
+ }
1539
+ function Ft(e) {
1540
+ let { element: t, text: n, hasChildren: r } = e;
1541
+ return It(t) ? !0 : n ? !r || !n.includes("\n") : !1;
1542
+ }
1543
+ function It(e) {
1544
+ return e.attributes.some((e) => e.value === "preserve" && (e.namespaceURI === "http://www.w3.org/XML/1998/namespace" && e.localName === "space" || e.namespaceURI === null && e.localName === "xml:space"));
1545
+ }
1546
+ function Lt(e) {
1547
+ return e.includes("\n") ? e.replace(/\r\n/g, "\n").replace(/\n/g, "\r\n") : e;
1548
+ }
1549
+ async function Rt(e, t = {}) {
1550
+ let { source: n, runtime: r, documentId: i } = e, a = Ae({
1551
+ enabled: r.perf ?? !1,
1552
+ timeline: !1
1553
+ });
1554
+ $({
1555
+ signal: t.signal,
1556
+ documentId: i
1557
+ });
1558
+ let o = await Bt({
1559
+ source: n,
1560
+ documentId: i
1561
+ }), { config: s } = je({
1562
+ configs: r.configs,
1563
+ defaultConfigKey: r.defaultConfigKey,
1564
+ configKey: o.configKey
1565
+ }), c = zt({ options: e.options });
1566
+ a.start("export");
1567
+ let l;
1568
+ try {
1569
+ let n = await Vt({
1570
+ ...e,
1571
+ config: s,
1572
+ control: t,
1573
+ perf: a,
1574
+ batchSize: c
1575
+ });
1576
+ l = n.status === "moved" ? await Vt({
1577
+ ...e,
1578
+ config: s,
1579
+ control: t,
1580
+ perf: a,
1581
+ batchSize: c
1582
+ }) : n;
1583
+ } finally {
1584
+ a.stop("export");
1585
+ }
1586
+ return l.status === "moved" && h("EXPORT_CONFLICT", {
1587
+ detail: `Document "${o.name}" changed twice while it was exported: export it again`,
1588
+ meta: { documentId: i }
1589
+ }), {
1590
+ file: l.file,
1591
+ filename: `${o.name}${o.extension}`,
1592
+ ...r.perf && { perf: a.snapshot() }
1593
+ };
1594
+ }
1595
+ function zt(e) {
1596
+ let t = e.options?.batchSize ?? 2e3;
1597
+ return (!Number.isInteger(t) || t < 1) && h("ASSERTION_FAILED", { detail: `An export batch size is a whole number from 1, not ${t}` }), t;
1598
+ }
1599
+ async function Bt(e) {
1600
+ let { source: t, documentId: n } = e, r = await t.getDocument(n);
1601
+ return r && r.status === "ready" || Q({ documentId: n }), r;
1602
+ }
1603
+ async function Vt(e) {
1604
+ let { source: t, documentId: n, options: r, config: i, control: a, perf: o, batchSize: s } = e, c = await t.getExportVersion({ documentId: n });
1605
+ c === void 0 && Q({ documentId: n });
1606
+ let l = await t.count(n), u = await Ut({
1607
+ source: t,
1608
+ documentId: n,
1609
+ config: i
1610
+ });
1611
+ if (!u) {
1612
+ if (await Z({
1613
+ source: t,
1614
+ documentId: n,
1615
+ version: c
1616
+ })) return { status: "moved" };
1617
+ h("EXPORT_ROOT_NOT_FOUND", { detail: `No ${i.rootElementName} root element found in document "${n}"` });
1618
+ }
1619
+ let d = {
1620
+ source: t,
1621
+ documentId: n,
1622
+ version: c,
1623
+ totalRecords: l,
1624
+ control: a,
1625
+ perf: o,
1626
+ writer: Y({
1627
+ config: i,
1628
+ documentRoot: u,
1629
+ indent: r?.indent,
1630
+ withDatabaseIds: r?.withDatabaseIds
1631
+ }),
1632
+ parts: [],
1633
+ recordsWritten: 0
1634
+ }, f = [Ht({
1635
+ pass: d,
1636
+ record: u,
1637
+ config: i
1638
+ })];
1639
+ if (d.recordsWritten % s === 0 && await X(d)) return { status: "moved" };
1640
+ for (; f.length > 0;) {
1641
+ let e = f.at(-1);
1642
+ if (e.next >= e.childRefs.length) {
1643
+ o.time("export::write", () => d.writer.closeElement()), f.pop();
1644
+ continue;
1645
+ }
1646
+ if (e.next >= e.chunkStart + e.chunk.length) {
1647
+ let r = e.childRefs.slice(e.next, e.next + s).map(Gt);
1648
+ o.start("export::read");
1649
+ try {
1650
+ e.chunk = await t.getMany(r, n);
1651
+ } finally {
1652
+ o.stop("export::read");
1653
+ }
1654
+ e.chunkStart = e.next;
1655
+ }
1656
+ let r = e.childRefs[e.next], a = e.chunk[e.next - e.chunkStart];
1657
+ if (e.next++, !a) {
1658
+ if (await Z(d)) return { status: "moved" };
1659
+ h("EXPORT_ORPHAN_CHILD_REF", {
1660
+ detail: `Parent '${e.record.tagName}' references non-existent child '${r.tagName}' (id: ${r.id})`,
1661
+ ref: {
1662
+ tagName: e.record.tagName,
1663
+ id: e.record.id
1664
+ }
1665
+ });
1666
+ }
1667
+ if (f.push(Ht({
1668
+ pass: d,
1669
+ record: a,
1670
+ config: i
1671
+ })), d.recordsWritten % s === 0 && await X(d)) return { status: "moved" };
1672
+ }
1673
+ if (Wt(d), d.recordsWritten % s !== 0 && await X(d)) return { status: "moved" };
1674
+ o.start("export::assemble");
1675
+ try {
1676
+ return {
1677
+ status: "written",
1678
+ file: new Blob([d.writer.head(), ...d.parts], { type: "application/xml" })
1679
+ };
1680
+ } finally {
1681
+ o.stop("export::assemble");
1682
+ }
1683
+ }
1684
+ function Ht(e) {
1685
+ let { pass: t, record: n, config: r } = e;
1686
+ return t.perf.time("export::write", () => t.writer.openElement({ record: n })), t.recordsWritten++, {
1687
+ record: n,
1688
+ childRefs: c({
1689
+ parentTagName: n.tagName,
1690
+ children: n.children,
1691
+ childrenConfig: r.children,
1692
+ definition: r.definition
1693
+ }),
1694
+ next: 0,
1695
+ chunk: [],
1696
+ chunkStart: 0
1697
+ };
1698
+ }
1699
+ async function Ut(e) {
1700
+ let { source: t, documentId: n, config: r } = e;
1701
+ return (await t.getByTagNameInDocument(r.rootElementName, n)).find((e) => Ne({
1702
+ record: e,
1703
+ config: r
1704
+ }));
1705
+ }
1706
+ async function X(e) {
1707
+ let { control: t, documentId: n, recordsWritten: r, totalRecords: i } = e;
1708
+ return Wt(e), be({
1709
+ listener: t.onProgress,
1710
+ value: {
1711
+ recordsWritten: r,
1712
+ totalRecords: i
1713
+ },
1714
+ of: we.exportProgress,
1715
+ call: t
1716
+ }), $({
1717
+ signal: t.signal,
1718
+ documentId: n
1719
+ }), await Me(), Z(e);
1720
+ }
1721
+ function Wt(e) {
1722
+ let t = e.writer.take();
1723
+ t && e.parts.push(new Blob([t]));
1724
+ }
1725
+ async function Z(e) {
1726
+ let { source: t, documentId: n, version: r } = e, i = await t.getExportVersion({ documentId: n });
1727
+ return i === void 0 && Q({ documentId: n }), i !== r;
1728
+ }
1729
+ function Gt(e) {
1730
+ return e.id;
1731
+ }
1732
+ function Q(e) {
1733
+ let { documentId: t } = e;
1734
+ h("DOCUMENT_NOT_REGISTERED", {
1735
+ detail: `Document "${t}" is not registered, or not ready, in this store`,
1736
+ meta: { documentId: t }
1737
+ });
1738
+ }
1739
+ function $(e) {
1740
+ let { signal: t, documentId: n } = e;
1741
+ t?.aborted && h("EXPORT_ABORTED", {
1742
+ detail: `The export of document "${n}" was aborted`,
1743
+ meta: { documentId: n }
1744
+ });
1745
+ }
1746
+ function Kt(e) {
1747
+ let { dialecteId: t, project: n } = e;
1748
+ return `${encodeURIComponent(t)}/${encodeURIComponent(n)}`;
1749
+ }
1750
+ //#endregion
1751
+ export { we as A, ae as B, Ee as D, ue as F, oe as G, ie as H, D as I, le as K, fe as L, be as M, pe as P, me as R, se as U, re as V, ce as W, Et as a, Tt as c, Me as d, je as f, Oe as h, Y as i, xe as j, De as k, Pe as l, ke as m, Rt as n, kt as o, Ae as p, y as q, $ as r, Dt as s, Kt as t, Ne as u, ne as z };