@inpageedit/core 0.12.0 → 0.13.0-alpha.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 (143) hide show
  1. package/LICENSE +20 -20
  2. package/dist/BasePlugin-Bf2UuIHF.js +64 -0
  3. package/dist/BasePlugin-Bf2UuIHF.js.map +1 -0
  4. package/dist/IconQuickEdit-CMCQncyj.js.map +1 -1
  5. package/dist/InputBox-nQKtiWtZ.js +30 -0
  6. package/dist/InputBox-nQKtiWtZ.js.map +1 -0
  7. package/dist/PluginPrefSync-Dn1Xsiqz.js +341 -0
  8. package/dist/PluginPrefSync-Dn1Xsiqz.js.map +1 -0
  9. package/dist/PluginStoreApp-CpOLArL7.js +452 -0
  10. package/dist/PluginStoreApp-CpOLArL7.js.map +1 -0
  11. package/dist/Preferences-DS4-CFWe.js.map +1 -1
  12. package/dist/WatchlistAction-BbNAyryN.js +5 -0
  13. package/dist/WatchlistAction-BbNAyryN.js.map +1 -0
  14. package/dist/components/index.js +6 -7
  15. package/dist/components/index.js.map +1 -1
  16. package/dist/endpoints-DgyuoRZd.js +1507 -0
  17. package/dist/endpoints-DgyuoRZd.js.map +1 -0
  18. package/dist/{index-B5DtUqkK.js → index-2RfILgXm.js} +11 -11
  19. package/dist/{index-B5DtUqkK.js.map → index-2RfILgXm.js.map} +1 -1
  20. package/dist/{index-hSl8LzNb.js → index-BCdABp0e.js} +24 -24
  21. package/dist/index-BCdABp0e.js.map +1 -0
  22. package/dist/{index-Ckozkp6W.js → index-BJ7_Q1mB.js} +8 -7
  23. package/dist/{index-Ckozkp6W.js.map → index-BJ7_Q1mB.js.map} +1 -1
  24. package/dist/{index-CJFePavo.js → index-BNh95-x2.js} +37 -49
  25. package/dist/index-BNh95-x2.js.map +1 -0
  26. package/dist/{index-CYc6LH26.js → index-BQ-cHWkJ.js} +15 -16
  27. package/dist/{index-CYc6LH26.js.map → index-BQ-cHWkJ.js.map} +1 -1
  28. package/dist/index-BwdWyHLe.js +362 -0
  29. package/dist/index-BwdWyHLe.js.map +1 -0
  30. package/dist/{index-D4uwfUZL.js → index-CCRMmnwk.js} +10 -9
  31. package/dist/index-CCRMmnwk.js.map +1 -0
  32. package/dist/index-CG38LlAh.js.map +1 -1
  33. package/dist/index-CM_6yF2v.js.map +1 -1
  34. package/dist/{index-CZXxH2-9.js → index-CnIpUF9x.js} +4 -4
  35. package/dist/{index-CZXxH2-9.js.map → index-CnIpUF9x.js.map} +1 -1
  36. package/dist/{index-CPoUaSMw.js → index-CyG7_IYz.js} +14 -13
  37. package/dist/index-CyG7_IYz.js.map +1 -0
  38. package/dist/index-DD5CVCfD.js.map +1 -1
  39. package/dist/index-DdTiZqwt.js +3744 -0
  40. package/dist/index-DdTiZqwt.js.map +1 -0
  41. package/dist/{index-Bv7Dw5eO.js → index-eSlbrNqF.js} +6 -6
  42. package/dist/{index-Bv7Dw5eO.js.map → index-eSlbrNqF.js.map} +1 -1
  43. package/dist/index.d.ts +1723 -31
  44. package/dist/index.js +73 -9
  45. package/dist/index.js.map +1 -1
  46. package/dist/makeCallable-LDU0xZMJ.js.map +1 -1
  47. package/dist/models/index.js +486 -0
  48. package/dist/models/index.js.map +1 -0
  49. package/dist/noop-ClDc6zv4.js.map +1 -1
  50. package/dist/plugins/index.js +23 -0
  51. package/dist/plugins/index.js.map +1 -0
  52. package/dist/services/index.js +16 -0
  53. package/dist/services/index.js.map +1 -0
  54. package/dist/style.css +1 -1
  55. package/dist/{vueHooks-D0uVqbO-.js → vueHooks-l04s8cIl.js} +1112 -1080
  56. package/dist/{vueHooks-D0uVqbO-.js.map → vueHooks-l04s8cIl.js.map} +1 -1
  57. package/lib/index.umd.js +15 -11
  58. package/lib/index.umd.js.map +1 -1
  59. package/lib/style.css +1 -1
  60. package/package.json +22 -25
  61. package/dist/CheckBox-Bc79KBEB.js +0 -13
  62. package/dist/CheckBox-Bc79KBEB.js.map +0 -1
  63. package/dist/InPageEdit.d.ts +0 -42
  64. package/dist/InputBox-DZAdyZ4B.js +0 -22
  65. package/dist/InputBox-DZAdyZ4B.js.map +0 -1
  66. package/dist/PluginPrefSync-BPQkNtX8.js +0 -292
  67. package/dist/PluginPrefSync-BPQkNtX8.js.map +0 -1
  68. package/dist/PluginStoreApp-Cxspe6t8.js +0 -158
  69. package/dist/PluginStoreApp-Cxspe6t8.js.map +0 -1
  70. package/dist/__test__/utils/constants.d.ts +0 -3
  71. package/dist/components/ActionButton.d.ts +0 -6
  72. package/dist/components/CheckBox.d.ts +0 -10
  73. package/dist/components/Icon/IconEdit.d.ts +0 -2
  74. package/dist/components/Icon/IconQuickEdit.d.ts +0 -2
  75. package/dist/components/InputBox.d.ts +0 -11
  76. package/dist/components/MBox/index.d.ts +0 -14
  77. package/dist/components/MwUserLinks.d.ts +0 -6
  78. package/dist/components/ProgressBar/index.d.ts +0 -7
  79. package/dist/components/RadioBox.d.ts +0 -10
  80. package/dist/components/TabView/index.d.ts +0 -19
  81. package/dist/components/TwinSwapInput/index.d.ts +0 -19
  82. package/dist/components/index.d.ts +0 -8
  83. package/dist/components/utils.d.ts +0 -4
  84. package/dist/constants/endpoints.d.ts +0 -8
  85. package/dist/decorators/Preferences.d.ts +0 -35
  86. package/dist/index-BXaiDKnr.js +0 -5828
  87. package/dist/index-BXaiDKnr.js.map +0 -1
  88. package/dist/index-CB7TltEb.js +0 -297
  89. package/dist/index-CB7TltEb.js.map +0 -1
  90. package/dist/index-CJFePavo.js.map +0 -1
  91. package/dist/index-CPoUaSMw.js.map +0 -1
  92. package/dist/index-D4uwfUZL.js.map +0 -1
  93. package/dist/index-DEav9Ptt.js +0 -365
  94. package/dist/index-DEav9Ptt.js.map +0 -1
  95. package/dist/index-hSl8LzNb.js.map +0 -1
  96. package/dist/models/MemoryStorage.d.ts +0 -10
  97. package/dist/models/WikiPage/index.d.ts +0 -72
  98. package/dist/models/WikiPage/types/PageInfo.d.ts +0 -58
  99. package/dist/models/WikiPage/types/PageParseData.d.ts +0 -17
  100. package/dist/models/WikiPage/types/WatchlistAction.d.ts +0 -6
  101. package/dist/models/WikiTitle/index.d.ts +0 -89
  102. package/dist/models/WikiTitle/index.spec.d.ts +0 -1
  103. package/dist/plugins/BasePlugin.d.ts +0 -25
  104. package/dist/plugins/_debug/index.d.ts +0 -8
  105. package/dist/plugins/analytics/index.d.ts +0 -41
  106. package/dist/plugins/in-article-links/index.d.ts +0 -44
  107. package/dist/plugins/plugin-store/index.d.ts +0 -59
  108. package/dist/plugins/plugin-store/schema.d.ts +0 -41
  109. package/dist/plugins/preferences-ui/PluginPrefSync.d.ts +0 -28
  110. package/dist/plugins/preferences-ui/index.d.ts +0 -48
  111. package/dist/plugins/quick-delete/index.d.ts +0 -55
  112. package/dist/plugins/quick-diff/components/DiffTable.d.ts +0 -23
  113. package/dist/plugins/quick-diff/index.d.ts +0 -85
  114. package/dist/plugins/quick-edit/index.d.ts +0 -79
  115. package/dist/plugins/quick-move/index.d.ts +0 -47
  116. package/dist/plugins/quick-preview/index.d.ts +0 -37
  117. package/dist/plugins/quick-redirect/index.d.ts +0 -48
  118. package/dist/plugins/toolbox/index.d.ts +0 -65
  119. package/dist/polyfills/Promise.withResolvers.d.ts +0 -5
  120. package/dist/polyfills/index.d.ts +0 -0
  121. package/dist/services/ApiService.d.ts +0 -14
  122. package/dist/services/CurrentPageService.d.ts +0 -28
  123. package/dist/services/ModalService.d.ts +0 -27
  124. package/dist/services/PreferencesService.d.ts +0 -94
  125. package/dist/services/ResourceLoaderService.d.ts +0 -17
  126. package/dist/services/WikiMetadataService.d.ts +0 -108
  127. package/dist/services/WikiPageService.d.ts +0 -20
  128. package/dist/services/WikiTitleService.d.ts +0 -70
  129. package/dist/services/storage/index.d.ts +0 -40
  130. package/dist/services/storage/managers/IDBStorageManager.d.ts +0 -28
  131. package/dist/services/storage/managers/LocalStorageManager.d.ts +0 -27
  132. package/dist/types/WikiMetadata.d.ts +0 -131
  133. package/dist/utils/computeable.d.ts +0 -2
  134. package/dist/utils/defineAsyncPlugin.d.ts +0 -2
  135. package/dist/utils/interpolate.d.ts +0 -20
  136. package/dist/utils/interpolate.spec.d.ts +0 -1
  137. package/dist/utils/makeCallable.d.ts +0 -3
  138. package/dist/utils/noop.d.ts +0 -1
  139. package/dist/utils/sleep.d.ts +0 -1
  140. package/dist/utils/string.d.ts +0 -7
  141. package/dist/utils/url.d.ts +0 -24
  142. package/dist/utils/vueHooks.d.ts +0 -6
  143. package/dist/utils/vueReactivity.d.ts +0 -2
@@ -0,0 +1,1507 @@
1
+ const wt = () => {
2
+ let t, e;
3
+ return { promise: new Promise((n, c) => {
4
+ t = n, e = c;
5
+ }), resolve: t, reject: e };
6
+ };
7
+ Promise.withResolvers || (Promise.withResolvers = wt);
8
+ var xt = Object.defineProperty, w = (t, e) => xt(t, "name", { value: e, configurable: !0 });
9
+ function vt() {
10
+ }
11
+ w(vt, "noop");
12
+ function $(t) {
13
+ return t == null;
14
+ }
15
+ w($, "isNullable");
16
+ function St(t) {
17
+ return !$(t);
18
+ }
19
+ w(St, "isNonNullable");
20
+ function J(t) {
21
+ return t && typeof t == "object" && !Array.isArray(t);
22
+ }
23
+ w(J, "isPlainObject");
24
+ function ft(t, e) {
25
+ return Object.fromEntries(Object.entries(t).filter(([r, n]) => e(r, n)));
26
+ }
27
+ w(ft, "filterKeys");
28
+ function N(t, e) {
29
+ return Object.fromEntries(Object.entries(t).map(([r, n]) => [r, e(n, r)]));
30
+ }
31
+ w(N, "mapValues");
32
+ function at(t, e, r) {
33
+ if (!e) return { ...t };
34
+ const n = {};
35
+ for (const c of e)
36
+ (r || t[c] !== void 0) && (n[c] = t[c]);
37
+ return n;
38
+ }
39
+ w(at, "pick");
40
+ function kt(t, e) {
41
+ if (!e) return { ...t };
42
+ const r = { ...t };
43
+ for (const n of e)
44
+ Reflect.deleteProperty(r, n);
45
+ return r;
46
+ }
47
+ w(kt, "omit");
48
+ function A(t, e, r) {
49
+ return Object.defineProperty(t, e, { writable: !0, value: r, enumerable: !1 });
50
+ }
51
+ w(A, "defineProperty");
52
+ function Ot(t, e) {
53
+ return e.every((r) => t.includes(r));
54
+ }
55
+ w(Ot, "contain");
56
+ function jt(t, e) {
57
+ return t.filter((r) => e.includes(r));
58
+ }
59
+ w(jt, "intersection");
60
+ function $t(t, e) {
61
+ return t.filter((r) => !e.includes(r));
62
+ }
63
+ w($t, "difference");
64
+ function _t(t, e) {
65
+ return Array.from(/* @__PURE__ */ new Set([...t, ...e]));
66
+ }
67
+ w(_t, "union");
68
+ function At(t) {
69
+ return [...new Set(t)];
70
+ }
71
+ w(At, "deduplicate");
72
+ function D(t, e) {
73
+ const r = t?.indexOf(e);
74
+ return r >= 0 ? (t.splice(r, 1), !0) : !1;
75
+ }
76
+ w(D, "remove");
77
+ function Rt(t) {
78
+ return Array.isArray(t) ? t : $(t) ? [] : [t];
79
+ }
80
+ w(Rt, "makeArray");
81
+ function B(t, e) {
82
+ return arguments.length === 1 ? (r) => B(t, r) : t in globalThis && e instanceof globalThis[t] || Object.prototype.toString.call(e).slice(8, -1) === t;
83
+ }
84
+ w(B, "is");
85
+ function q(t) {
86
+ return B("ArrayBuffer", t) || B("SharedArrayBuffer", t);
87
+ }
88
+ w(q, "isArrayBufferLike");
89
+ function ut(t) {
90
+ return q(t) || ArrayBuffer.isView(t);
91
+ }
92
+ w(ut, "isArrayBufferSource");
93
+ var E;
94
+ ((t) => {
95
+ t.is = q, t.isSource = ut;
96
+ function e(a) {
97
+ return ArrayBuffer.isView(a) ? a.buffer.slice(a.byteOffset, a.byteOffset + a.byteLength) : a;
98
+ }
99
+ t.fromSource = e, w(e, "fromSource");
100
+ function r(a) {
101
+ if (typeof Buffer < "u")
102
+ return Buffer.from(a).toString("base64");
103
+ let y = "";
104
+ const d = new Uint8Array(a);
105
+ for (let b = 0; b < d.byteLength; b++)
106
+ y += String.fromCharCode(d[b]);
107
+ return btoa(y);
108
+ }
109
+ t.toBase64 = r, w(r, "toBase64");
110
+ function n(a) {
111
+ return typeof Buffer < "u" ? e(Buffer.from(a, "base64")) : Uint8Array.from(atob(a), (y) => y.charCodeAt(0));
112
+ }
113
+ t.fromBase64 = n, w(n, "fromBase64");
114
+ function c(a) {
115
+ return typeof Buffer < "u" ? Buffer.from(a).toString("hex") : Array.from(new Uint8Array(a), (y) => y.toString(16).padStart(2, "0")).join("");
116
+ }
117
+ t.toHex = c, w(c, "toHex");
118
+ function i(a) {
119
+ if (typeof Buffer < "u") return e(Buffer.from(a, "hex"));
120
+ const y = a.length % 2 === 0 ? a : a.slice(0, a.length - 1), d = [];
121
+ for (let b = 0; b < y.length; b += 2)
122
+ d.push(parseInt(`${y[b]}${y[b + 1]}`, 16));
123
+ return Uint8Array.from(d).buffer;
124
+ }
125
+ t.fromHex = i, w(i, "fromHex");
126
+ })(E || (E = {}));
127
+ E.fromBase64;
128
+ E.toBase64;
129
+ E.fromHex;
130
+ E.toHex;
131
+ function V(t, e = /* @__PURE__ */ new Map()) {
132
+ if (!t || typeof t != "object") return t;
133
+ if (B("Date", t)) return new Date(t.valueOf());
134
+ if (B("RegExp", t)) return new RegExp(t.source, t.flags);
135
+ if (q(t)) return t.slice(0);
136
+ if (ArrayBuffer.isView(t)) return t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength);
137
+ const r = e.get(t);
138
+ if (r) return r;
139
+ if (Array.isArray(t)) {
140
+ const c = [];
141
+ return e.set(t, c), t.forEach((i, a) => {
142
+ c[a] = Reflect.apply(V, null, [i, e]);
143
+ }), c;
144
+ }
145
+ const n = Object.create(Object.getPrototypeOf(t));
146
+ e.set(t, n);
147
+ for (const c of Reflect.ownKeys(t)) {
148
+ const i = { ...Reflect.getOwnPropertyDescriptor(t, c) };
149
+ "value" in i && (i.value = Reflect.apply(V, null, [i.value, e])), Reflect.defineProperty(n, c, i);
150
+ }
151
+ return n;
152
+ }
153
+ w(V, "clone");
154
+ function I(t, e, r) {
155
+ if (t === e || !r && $(t) && $(e)) return !0;
156
+ if (typeof t != typeof e || typeof t != "object" || !t || !e) return !1;
157
+ function n(c, i) {
158
+ return c(t) ? c(e) ? i(t, e) : !1 : c(e) ? !1 : void 0;
159
+ }
160
+ return w(n, "check"), n(Array.isArray, (c, i) => c.length === i.length && c.every((a, y) => I(a, i[y]))) ?? n(B("Date"), (c, i) => c.valueOf() === i.valueOf()) ?? n(B("RegExp"), (c, i) => c.source === i.source && c.flags === i.flags) ?? n(q, (c, i) => {
161
+ if (c.byteLength !== i.byteLength) return !1;
162
+ const a = new Uint8Array(c), y = new Uint8Array(i);
163
+ for (let d = 0; d < a.length; d++)
164
+ if (a[d] !== y[d]) return !1;
165
+ return !0;
166
+ }) ?? Object.keys({ ...t, ...e }).every((c) => I(t[c], e[c], r));
167
+ }
168
+ w(I, "deepEqual");
169
+ function Pt(t) {
170
+ return t.charAt(0).toUpperCase() + t.slice(1);
171
+ }
172
+ w(Pt, "capitalize");
173
+ function Et(t) {
174
+ return t.charAt(0).toLowerCase() + t.slice(1);
175
+ }
176
+ w(Et, "uncapitalize");
177
+ function Ct(t) {
178
+ return t.replace(/[_-][a-z]/g, (e) => e.slice(1).toUpperCase());
179
+ }
180
+ w(Ct, "camelCase");
181
+ function T(t, e, r) {
182
+ const n = [];
183
+ let c = 0;
184
+ for (let i = 0; i < t.length; i++) {
185
+ const a = t.charCodeAt(i);
186
+ if (a >= 65 && a <= 90) {
187
+ if (c === 1) {
188
+ const y = t.charCodeAt(i + 1);
189
+ y >= 97 && y <= 122 && n.push(r), n.push(a + 32);
190
+ } else
191
+ c !== 0 && n.push(r), n.push(a + 32);
192
+ c = 1;
193
+ } else a >= 97 && a <= 122 ? (n.push(a), c = 2) : e.includes(a) ? (c !== 0 && n.push(r), c = 0) : n.push(a);
194
+ }
195
+ return String.fromCharCode(...n);
196
+ }
197
+ w(T, "tokenize");
198
+ function Nt(t) {
199
+ return T(t, [45, 95], 45);
200
+ }
201
+ w(Nt, "paramCase");
202
+ function Dt(t) {
203
+ return T(t, [45, 95], 95);
204
+ }
205
+ w(Dt, "snakeCase");
206
+ function Bt(t) {
207
+ return typeof t != "string" ? `[${t.toString()}]` : /^[a-z_$][\w$]*$/i.test(t) ? `.${t}` : `[${JSON.stringify(t)}]`;
208
+ }
209
+ w(Bt, "formatProperty");
210
+ function lt(t) {
211
+ return t.replace(/\/$/, "");
212
+ }
213
+ w(lt, "trimSlash");
214
+ function It(t) {
215
+ return t.startsWith("/") || (t = "/" + t), lt(t);
216
+ }
217
+ w(It, "sanitize");
218
+ var st;
219
+ ((t) => {
220
+ t.millisecond = 1, t.second = 1e3, t.minute = t.second * 60, t.hour = t.minute * 60, t.day = t.hour * 24, t.week = t.day * 7;
221
+ let e = (/* @__PURE__ */ new Date()).getTimezoneOffset();
222
+ function r(x) {
223
+ e = x;
224
+ }
225
+ t.setTimezoneOffset = r, w(r, "setTimezoneOffset");
226
+ function n() {
227
+ return e;
228
+ }
229
+ t.getTimezoneOffset = n, w(n, "getTimezoneOffset");
230
+ function c(x = /* @__PURE__ */ new Date(), v) {
231
+ return typeof x == "number" && (x = new Date(x)), v === void 0 && (v = e), Math.floor((x.valueOf() / t.minute - v) / 1440);
232
+ }
233
+ t.getDateNumber = c, w(c, "getDateNumber");
234
+ function i(x, v) {
235
+ const z = new Date(x * t.day);
236
+ return v === void 0 && (v = e), new Date(+z + v * t.minute);
237
+ }
238
+ t.fromDateNumber = i, w(i, "fromDateNumber");
239
+ const a = /\d+(?:\.\d+)?/.source, y = new RegExp(`^${[
240
+ "w(?:eek(?:s)?)?",
241
+ "d(?:ay(?:s)?)?",
242
+ "h(?:our(?:s)?)?",
243
+ "m(?:in(?:ute)?(?:s)?)?",
244
+ "s(?:ec(?:ond)?(?:s)?)?"
245
+ ].map((x) => `(${a}${x})?`).join("")}$`);
246
+ function d(x) {
247
+ const v = y.exec(x);
248
+ return v ? (parseFloat(v[1]) * t.week || 0) + (parseFloat(v[2]) * t.day || 0) + (parseFloat(v[3]) * t.hour || 0) + (parseFloat(v[4]) * t.minute || 0) + (parseFloat(v[5]) * t.second || 0) : 0;
249
+ }
250
+ t.parseTime = d, w(d, "parseTime");
251
+ function b(x) {
252
+ const v = d(x);
253
+ return v ? x = Date.now() + v : /^\d{1,2}(:\d{1,2}){1,2}$/.test(x) ? x = `${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${x}` : /^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(x) && (x = `${(/* @__PURE__ */ new Date()).getFullYear()}-${x}`), x ? new Date(x) : /* @__PURE__ */ new Date();
254
+ }
255
+ t.parseDate = b, w(b, "parseDate");
256
+ function j(x) {
257
+ const v = Math.abs(x);
258
+ return v >= t.day - t.hour / 2 ? Math.round(x / t.day) + "d" : v >= t.hour - t.minute / 2 ? Math.round(x / t.hour) + "h" : v >= t.minute - t.second / 2 ? Math.round(x / t.minute) + "m" : v >= t.second ? Math.round(x / t.second) + "s" : x + "ms";
259
+ }
260
+ t.format = j, w(j, "format");
261
+ function k(x, v = 2) {
262
+ return x.toString().padStart(v, "0");
263
+ }
264
+ t.toDigits = k, w(k, "toDigits");
265
+ function R(x, v = /* @__PURE__ */ new Date()) {
266
+ return x.replace("yyyy", v.getFullYear().toString()).replace("yy", v.getFullYear().toString().slice(2)).replace("MM", k(v.getMonth() + 1)).replace("dd", k(v.getDate())).replace("hh", k(v.getHours())).replace("mm", k(v.getMinutes())).replace("ss", k(v.getSeconds())).replace("SSS", k(v.getMilliseconds(), 3));
267
+ }
268
+ t.template = R, w(R, "template");
269
+ })(st || (st = {}));
270
+ var zt = Object.defineProperty, g = (t, e) => zt(t, "name", { value: e, configurable: !0 }), h = {
271
+ // internal symbols
272
+ shadow: Symbol.for("cordis.shadow"),
273
+ receiver: Symbol.for("cordis.receiver"),
274
+ original: Symbol.for("cordis.original"),
275
+ // context symbols
276
+ store: Symbol.for("cordis.store"),
277
+ events: Symbol.for("cordis.events"),
278
+ static: Symbol.for("cordis.static"),
279
+ filter: Symbol.for("cordis.filter"),
280
+ expose: Symbol.for("cordis.expose"),
281
+ isolate: Symbol.for("cordis.isolate"),
282
+ internal: Symbol.for("cordis.internal"),
283
+ intercept: Symbol.for("cordis.intercept"),
284
+ // service symbols
285
+ setup: Symbol.for("cordis.setup"),
286
+ invoke: Symbol.for("cordis.invoke"),
287
+ extend: Symbol.for("cordis.extend"),
288
+ tracker: Symbol.for("cordis.tracker"),
289
+ provide: Symbol.for("cordis.provide"),
290
+ immediate: Symbol.for("cordis.immediate")
291
+ }, Ut = function* () {
292
+ }.constructor, ot = async function* () {
293
+ }.constructor;
294
+ function tt(t) {
295
+ return !(!t.prototype || t instanceof Ut || ot !== Function && t instanceof ot);
296
+ }
297
+ g(tt, "isConstructor");
298
+ function L(t, e) {
299
+ const r = t.Config || t.schema;
300
+ return r && t.schema !== !1 && (e = r(e)), e ?? {};
301
+ }
302
+ g(L, "resolveConfig");
303
+ function ht(t) {
304
+ return [Map, Set, Date, Promise].some((e) => t instanceof e);
305
+ }
306
+ g(ht, "isUnproxyable");
307
+ function et(t, e) {
308
+ if (t === Object.prototype) return e;
309
+ const r = Object.create(et(Object.getPrototypeOf(t), e));
310
+ for (const n of Reflect.ownKeys(t))
311
+ Object.defineProperty(r, n, Object.getOwnPropertyDescriptor(t, n));
312
+ return r;
313
+ }
314
+ g(et, "joinPrototype");
315
+ function rt(t) {
316
+ return t && (typeof t == "object" || typeof t == "function");
317
+ }
318
+ g(rt, "isObject");
319
+ function C(t, e, r) {
320
+ if (!rt(e)) return e;
321
+ if (Object.hasOwn(e, h.shadow))
322
+ return Object.getPrototypeOf(e);
323
+ const n = e[h.tracker];
324
+ return n ? G(t, e, n, r) : e;
325
+ }
326
+ g(C, "getTraceable");
327
+ function F(t, e) {
328
+ return e ? new Proxy(t, {
329
+ get: /* @__PURE__ */ g((r, n, c) => n in e && n !== "constructor" ? Reflect.get(e, n, c) : Reflect.get(r, n, c), "get"),
330
+ set: /* @__PURE__ */ g((r, n, c, i) => n in e && n !== "constructor" ? Reflect.set(e, n, c, i) : Reflect.set(r, n, c, i), "set")
331
+ }) : t;
332
+ }
333
+ g(F, "withProps");
334
+ function H(t, e, r) {
335
+ return F(t, Object.defineProperty(/* @__PURE__ */ Object.create(null), e, {
336
+ value: r,
337
+ writable: !1
338
+ }));
339
+ }
340
+ g(H, "withProp");
341
+ function W(t, e, r, n) {
342
+ if (!r) return n;
343
+ const c = Reflect.getOwnPropertyDescriptor(e, r)?.value;
344
+ return c ? H(n, r, t.extend({ [h.shadow]: c })) : n;
345
+ }
346
+ g(W, "createShadow");
347
+ function pt(t, e, r, n) {
348
+ return new Proxy(e, {
349
+ apply: /* @__PURE__ */ g((c, i, a) => (i === r && (i = n), a = a.map((y) => typeof y != "function" || y[h.original] ? y : new Proxy(y, {
350
+ get: /* @__PURE__ */ g((d, b, j) => {
351
+ if (b === h.original) return d;
352
+ const k = Reflect.get(d, b, j);
353
+ return b === "toString" && k === Function.prototype.toString ? function(...R) {
354
+ return Reflect.apply(k, this === j ? d : this, R);
355
+ } : k;
356
+ }, "get"),
357
+ apply: /* @__PURE__ */ g((d, b, j) => Reflect.apply(d, C(t, b), j.map((k) => C(t, k))), "apply"),
358
+ construct: /* @__PURE__ */ g((d, b, j) => Reflect.construct(d, b.map((k) => C(t, k)), j), "construct")
359
+ })), C(t, Reflect.apply(c, i, a))), "apply")
360
+ });
361
+ }
362
+ g(pt, "createShadowMethod");
363
+ function G(t, e, r, n) {
364
+ t[h.shadow] && (t = Object.getPrototypeOf(t));
365
+ const c = new Proxy(e, {
366
+ get: /* @__PURE__ */ g((i, a, y) => {
367
+ if (a === h.original) return i;
368
+ if (a === r.property) return t;
369
+ if (typeof a == "symbol")
370
+ return Reflect.get(i, a, y);
371
+ if (r.associate && t[h.internal][`${r.associate}.${a}`])
372
+ return Reflect.get(t, `${r.associate}.${a}`, H(t, h.receiver, y));
373
+ const d = W(t, i, r.property, y), b = Reflect.get(i, a, d), j = b?.[h.tracker];
374
+ return j ? G(t, b, j) : !n && typeof b == "function" ? pt(t, b, y, d) : b;
375
+ }, "get"),
376
+ set: /* @__PURE__ */ g((i, a, y, d) => {
377
+ if (a === h.original || a === r.property) return !1;
378
+ if (typeof a == "symbol")
379
+ return Reflect.set(i, a, y, d);
380
+ if (r.associate && t[h.internal][`${r.associate}.${a}`])
381
+ return Reflect.set(t, `${r.associate}.${a}`, y, H(t, h.receiver, d));
382
+ const b = W(t, i, r.property, d);
383
+ return Reflect.set(i, a, y, b);
384
+ }, "set"),
385
+ apply: /* @__PURE__ */ g((i, a, y) => nt(c, i, a, y), "apply")
386
+ });
387
+ return c;
388
+ }
389
+ g(G, "createTraceable");
390
+ function nt(t, e, r, n) {
391
+ return e[h.invoke] ? e[h.invoke].apply(t, n) : Reflect.apply(e, r, n);
392
+ }
393
+ g(nt, "applyTraceable");
394
+ function Y(t, e, r) {
395
+ const n = /* @__PURE__ */ g(function(...c) {
396
+ const i = G(n.ctx, n, r);
397
+ return nt(i, n, this, c);
398
+ }, "self");
399
+ return A(n, "name", t), Object.setPrototypeOf(n, e);
400
+ }
401
+ g(Y, "createCallable");
402
+ var Mt = class U {
403
+ constructor(e) {
404
+ this.ctx = e, A(this, h.tracker, {
405
+ associate: "reflect",
406
+ property: "ctx"
407
+ }), this._mixin("reflect", ["get", "set", "provide", "accessor", "mixin", "alias"]), this._mixin("scope", ["config", "runtime", "effect", "collect", "accept", "decline"]), this._mixin("registry", ["using", "inject", "plugin"]), this._mixin("lifecycle", ["on", "once", "parallel", "emit", "serial", "bail", "start", "stop"]);
408
+ }
409
+ static {
410
+ g(this, "ReflectService");
411
+ }
412
+ static resolveInject(e, r) {
413
+ let n = e[h.internal][r];
414
+ for (; n?.type === "alias"; )
415
+ r = n.name, n = e[h.internal][r];
416
+ return [r, n];
417
+ }
418
+ static checkInject(e, r, n) {
419
+ if (e = e[h.shadow] ?? e, ["prototype", "then", "registry", "lifecycle"].includes(r) || r[0] === "$" || r[0] === "_" || !e.runtime.plugin || e.bail(e, "internal/inject", r)) return;
420
+ const c = n.stack.split(`
421
+ `);
422
+ c.splice(1, 1), n.stack = c.join(`
423
+ `), e.emit(e, "internal/warning", n);
424
+ }
425
+ static handler = {
426
+ get: /* @__PURE__ */ g((e, r, n) => {
427
+ if (typeof r != "string") return Reflect.get(e, r, n);
428
+ if (Reflect.has(e, r))
429
+ return C(n, Reflect.get(e, r, n), !0);
430
+ const [c, i] = U.resolveInject(e, r), a = new Error(`property ${c} is not registered, declare it as \`inject\` to suppress this warning`);
431
+ return i ? i.type === "accessor" ? i.get.call(n, n[h.receiver]) : (i.builtin || U.checkInject(n, c, a), n.reflect.get(c)) : (U.checkInject(n, c, a), Reflect.get(e, c, n));
432
+ }, "get"),
433
+ set: /* @__PURE__ */ g((e, r, n, c) => {
434
+ if (typeof r != "string") return Reflect.set(e, r, n, c);
435
+ const [i, a] = U.resolveInject(e, r);
436
+ return a ? a.type === "accessor" ? a.set ? a.set.call(c, n, c[h.receiver]) : !1 : (c.reflect.set(i, n), !0) : Reflect.set(e, i, n, c);
437
+ }, "set"),
438
+ has: /* @__PURE__ */ g((e, r) => {
439
+ if (typeof r != "string") return Reflect.has(e, r);
440
+ if (Reflect.has(e, r)) return !0;
441
+ const [, n] = U.resolveInject(e, r);
442
+ return !!n;
443
+ }, "has")
444
+ };
445
+ get(e) {
446
+ if (this.ctx[h.internal][e]?.type !== "service") return;
447
+ const n = this.ctx[h.isolate][e], c = this.ctx[h.store][n]?.value;
448
+ return C(this.ctx, c);
449
+ }
450
+ set(e, r) {
451
+ this.provide(e);
452
+ const n = this.ctx[h.isolate][e], c = this.ctx[h.store][n]?.value;
453
+ r ??= void 0;
454
+ let i = /* @__PURE__ */ g(() => {
455
+ }, "dispose");
456
+ if (c === r) return i;
457
+ if (!$(r) && !$(c))
458
+ throw new Error(`service ${e} has been registered`);
459
+ const a = this.ctx;
460
+ $(r) || (i = a.effect(() => () => {
461
+ a.set(e, void 0);
462
+ })), ht(r) && a.emit(a, "internal/warning", new Error(`service ${e} is an unproxyable object, which may lead to unexpected behavior`));
463
+ const y = Object.create(a);
464
+ return y[h.filter] = (d) => a[h.isolate][e] === d[h.isolate][e], a.emit(y, "internal/before-service", e, r), a[h.store][n] = { value: r, source: a }, a.emit(y, "internal/service", e, c), i;
465
+ }
466
+ provide(e, r, n) {
467
+ const c = this.ctx.root[h.internal];
468
+ if (e in c) return;
469
+ const i = Symbol(e);
470
+ c[e] = { type: "service", builtin: n }, this.ctx.root[h.isolate][e] = i, rt(r) && (this.ctx[h.store][i] = { value: r, source: null }, A(r, h.tracker, {
471
+ associate: e,
472
+ property: "ctx"
473
+ }));
474
+ }
475
+ _accessor(e, r) {
476
+ const n = this.ctx.root[h.internal];
477
+ return e in n ? () => {
478
+ } : (n[e] = { type: "accessor", ...r }, () => delete this.ctx.root[h.isolate][e]);
479
+ }
480
+ accessor(e, r) {
481
+ this.ctx.scope.effect(() => this._accessor(e, r));
482
+ }
483
+ alias(e, r) {
484
+ const n = this.ctx.root[h.internal];
485
+ if (!(e in n))
486
+ for (const c of r)
487
+ n[c] ||= { type: "alias", name: e };
488
+ }
489
+ _mixin(e, r) {
490
+ const n = Array.isArray(r) ? r.map((a) => [a, a]) : Object.entries(r), c = typeof e == "string" ? (a) => a[e] : () => e, i = n.map(([a, y]) => this._accessor(y, {
491
+ get(d) {
492
+ const b = c(this);
493
+ if ($(b)) return b;
494
+ const j = d ? F(d, b) : b, k = Reflect.get(b, a, j);
495
+ return typeof k != "function" ? k : k.bind(j ?? b);
496
+ },
497
+ set(d, b) {
498
+ const j = c(this), k = b ? F(b, j) : j;
499
+ return Reflect.set(j, a, d, k);
500
+ }
501
+ }));
502
+ return () => i.forEach((a) => a());
503
+ }
504
+ mixin(e, r) {
505
+ this.ctx.scope.effect(() => this._mixin(e, r));
506
+ }
507
+ trace(e) {
508
+ return C(this.ctx, e);
509
+ }
510
+ bind(e) {
511
+ return new Proxy(e, {
512
+ apply: /* @__PURE__ */ g((r, n, c) => r.apply(this.trace(n), c.map((i) => this.trace(i))), "apply")
513
+ });
514
+ }
515
+ }, Q = Mt;
516
+ function X(t) {
517
+ return t !== null && t !== !1 && t !== void 0;
518
+ }
519
+ g(X, "isBailed");
520
+ var Ft = class {
521
+ constructor(t) {
522
+ this.ctx = t, A(this, h.tracker, {
523
+ associate: "lifecycle",
524
+ property: "ctx"
525
+ }), A(this.on("internal/listener", function(r, n, c) {
526
+ const i = c.prepend ? "unshift" : "push";
527
+ if (r === "ready")
528
+ return this.lifecycle.isActive ? (this.scope.ensure(async () => n()), () => !1) : void 0;
529
+ if (r === "dispose")
530
+ return this.scope.disposables[i](n), A(n, "name", "event <dispose>"), () => D(this.scope.disposables, n);
531
+ if (r === "fork")
532
+ return this.scope.runtime.forkables[i](n), this.scope.collect("event <fork>", () => D(this.scope.runtime.forkables, n));
533
+ }), P.static, t.scope);
534
+ for (const r of ["info", "error", "warning"])
535
+ A(this.on(`internal/${r}`, (n, ...c) => {
536
+ this._hooks[`internal/${r}`].length > 1;
537
+ }), P.static, t.scope);
538
+ A(this.on("internal/before-service", function(r) {
539
+ for (const n of this.registry.values()) {
540
+ if (!n.inject[r]?.required) continue;
541
+ const c = n.isReusable ? n.children : [n];
542
+ for (const i of c)
543
+ this[h.filter](i.ctx) && (i.updateStatus(), i.reset());
544
+ }
545
+ }, { global: !0 }), P.static, t.scope), A(this.on("internal/service", function(r) {
546
+ for (const n of this.registry.values()) {
547
+ if (!n.inject[r]?.required) continue;
548
+ const c = n.isReusable ? n.children : [n];
549
+ for (const i of c)
550
+ this[h.filter](i.ctx) && i.start();
551
+ }
552
+ }, { global: !0 }), P.static, t.scope);
553
+ const e = /* @__PURE__ */ g((r, n) => {
554
+ if (!r.runtime.plugin) return !1;
555
+ for (const c in r.runtime.inject)
556
+ if (n === Q.resolveInject(r.ctx, c)[0]) return !0;
557
+ return e(r.parent.scope, n);
558
+ }, "checkInject");
559
+ A(this.on("internal/inject", function(r) {
560
+ return e(this.scope, r);
561
+ }, { global: !0 }), P.static, t.scope);
562
+ }
563
+ static {
564
+ g(this, "Lifecycle");
565
+ }
566
+ isActive = !1;
567
+ _tasks = /* @__PURE__ */ new Set();
568
+ _hooks = {};
569
+ async flush() {
570
+ for (; this._tasks.size; )
571
+ await Promise.all(Array.from(this._tasks));
572
+ }
573
+ filterHooks(t, e) {
574
+ return e = C(this.ctx, e), t.slice().filter((r) => {
575
+ const n = e?.[P.filter];
576
+ return r.global || !n || n.call(e, r.ctx);
577
+ });
578
+ }
579
+ *dispatch(t, e) {
580
+ const r = typeof e[0] == "object" || typeof e[0] == "function" ? e.shift() : null, n = e.shift();
581
+ n !== "internal/event" && this.emit("internal/event", t, n, e, r);
582
+ for (const c of this.filterHooks(this._hooks[n] || [], r))
583
+ yield c.callback.apply(r, e);
584
+ }
585
+ async parallel(...t) {
586
+ await Promise.all(this.dispatch("emit", t));
587
+ }
588
+ emit(...t) {
589
+ Array.from(this.dispatch("emit", t));
590
+ }
591
+ async serial(...t) {
592
+ for await (const e of this.dispatch("serial", t))
593
+ if (X(e)) return e;
594
+ }
595
+ bail(...t) {
596
+ for (const e of this.dispatch("bail", t))
597
+ if (X(e)) return e;
598
+ }
599
+ register(t, e, r, n) {
600
+ const c = n.prepend ? "unshift" : "push";
601
+ return e[c]({ ctx: this.ctx, callback: r, ...n }), this.ctx.state.collect(t, () => this.unregister(e, r));
602
+ }
603
+ unregister(t, e) {
604
+ const r = t.findIndex((n) => n.callback === e);
605
+ if (r >= 0)
606
+ return t.splice(r, 1), !0;
607
+ }
608
+ on(t, e, r) {
609
+ typeof r != "object" && (r = { prepend: r }), this.ctx.scope.assertActive(), e = this.ctx.reflect.bind(e);
610
+ const n = this.bail(this.ctx, "internal/listener", t, e, r);
611
+ if (n) return n;
612
+ const c = this._hooks[t] ||= [], i = typeof t == "string" ? `event <${t}>` : "event (Symbol)";
613
+ return this.register(i, c, e, r);
614
+ }
615
+ once(t, e, r) {
616
+ const n = this.on(t, function(...c) {
617
+ return n(), e.apply(this, c);
618
+ }, r);
619
+ return n;
620
+ }
621
+ async start() {
622
+ this.isActive = !0;
623
+ const t = this._hooks.ready || [];
624
+ for (; t.length; ) {
625
+ const { ctx: e, callback: r } = t.shift();
626
+ e.scope.ensure(async () => r());
627
+ }
628
+ await this.flush();
629
+ }
630
+ async stop() {
631
+ this.isActive = !1, this.ctx.scope.reset();
632
+ }
633
+ }, qt = Ft, Z = class yt extends Error {
634
+ constructor(e, r) {
635
+ super(r ?? yt.Code[e]), this.code = e;
636
+ }
637
+ static {
638
+ g(this, "CordisError");
639
+ }
640
+ };
641
+ ((t) => {
642
+ t.Code = {
643
+ INACTIVE_EFFECT: "cannot create effect on inactive context"
644
+ };
645
+ })(Z || (Z = {}));
646
+ var dt = class {
647
+ constructor(t, e) {
648
+ this.parent = t, this.config = e, this.uid = t.registry ? t.registry.counter : 0, this.ctx = this.context = t.extend({ scope: this }), this.proxy = new Proxy({}, {
649
+ get: /* @__PURE__ */ g((r, n) => Reflect.get(this.config, n), "get")
650
+ });
651
+ }
652
+ static {
653
+ g(this, "EffectScope");
654
+ }
655
+ uid;
656
+ ctx;
657
+ disposables = [];
658
+ error;
659
+ status = 0;
660
+ isActive = !1;
661
+ // Same as `this.ctx`, but with a more specific type.
662
+ context;
663
+ proxy;
664
+ acceptors = [];
665
+ tasks = /* @__PURE__ */ new Set();
666
+ hasError = !1;
667
+ get _config() {
668
+ return this.runtime.isReactive ? this.proxy : this.config;
669
+ }
670
+ assertActive() {
671
+ if (!(this.uid !== null || this.isActive))
672
+ throw new Z("INACTIVE_EFFECT");
673
+ }
674
+ effect(t, e) {
675
+ this.assertActive();
676
+ const r = tt(t) ? new t(this.ctx, e) : t(this.ctx, e);
677
+ let n = !1;
678
+ const c = typeof r == "function" ? r : r.dispose.bind(r), i = /* @__PURE__ */ g((...a) => {
679
+ if (!n)
680
+ return n = !0, D(this.disposables, i), c(...a);
681
+ }, "wrapped");
682
+ return this.disposables.push(i), typeof r == "function" ? i : (r.dispose = i, r);
683
+ }
684
+ collect(t, e) {
685
+ const r = A(() => (D(this.disposables, r), e()), "name", t);
686
+ return this.disposables.push(r), r;
687
+ }
688
+ restart() {
689
+ this.reset(), this.error = null, this.hasError = !1, this.status = 0, this.start();
690
+ }
691
+ _getStatus() {
692
+ return this.uid === null ? 4 : this.hasError ? 3 : this.tasks.size ? 1 : this.ready ? 2 : 0;
693
+ }
694
+ updateStatus(t) {
695
+ const e = this.status;
696
+ t?.(), this.status = this._getStatus(), e !== this.status && this.context.emit("internal/status", this, e);
697
+ }
698
+ ensure(t) {
699
+ const e = t().catch((r) => {
700
+ this.context.emit(this.ctx, "internal/error", r), this.cancel(r);
701
+ }).finally(() => {
702
+ this.updateStatus(() => this.tasks.delete(e)), this.context.events._tasks.delete(e);
703
+ });
704
+ this.updateStatus(() => this.tasks.add(e)), this.context.events._tasks.add(e);
705
+ }
706
+ cancel(t) {
707
+ this.error = t, this.updateStatus(() => this.hasError = !0), this.reset();
708
+ }
709
+ get ready() {
710
+ return Object.entries(this.runtime.inject).every(([t, e]) => !e.required || !$(this.ctx.get(t)));
711
+ }
712
+ reset() {
713
+ this.isActive = !1, this.disposables = this.disposables.splice(0).filter((t) => {
714
+ if (this.uid !== null && t[P.static] === this) return !0;
715
+ (async () => t())().catch((e) => {
716
+ this.context.emit(this.ctx, "internal/error", e);
717
+ });
718
+ });
719
+ }
720
+ init(t) {
721
+ this.config ? this.start() : this.cancel(t);
722
+ }
723
+ start() {
724
+ if (!this.ready || this.isActive || this.uid === null) return !0;
725
+ this.isActive = !0, this.updateStatus(() => this.hasError = !1);
726
+ }
727
+ accept(...t) {
728
+ const r = { keys: Array.isArray(t[0]) ? t.shift() : null, callback: t[0], ...t[1] };
729
+ return this.effect(() => (this.acceptors.push(r), r.immediate && r.callback?.(this.config), () => D(this.acceptors, r)));
730
+ }
731
+ decline(t) {
732
+ return this.accept(t, () => !0);
733
+ }
734
+ checkUpdate(t, e) {
735
+ if (e || !this.config) return [!0, !0];
736
+ if (e === !1) return [!1, !1];
737
+ const r = /* @__PURE__ */ Object.create(null), n = /* @__PURE__ */ g((d) => {
738
+ const b = r[d] ??= !I(this.config[d], t[d]);
739
+ return i ||= b, b;
740
+ }, "checkPropertyUpdate"), c = /* @__PURE__ */ new Set();
741
+ let i = !1, a = !1, y = this.runtime.isReactive || null;
742
+ for (const { keys: d, callback: b, passive: j } of this.acceptors) {
743
+ if (!d)
744
+ y ||= !j;
745
+ else if (j)
746
+ d?.forEach((R) => c.add(R));
747
+ else {
748
+ let R = !1;
749
+ for (const x of d)
750
+ R ||= n(x);
751
+ if (!R) continue;
752
+ }
753
+ b?.(t) && (a = !0);
754
+ }
755
+ for (const d in { ...this.config, ...t })
756
+ if (y !== !1 && !(d in r) && !c.has(d)) {
757
+ const b = n(d);
758
+ y === null && (a ||= b);
759
+ }
760
+ return [i, a];
761
+ }
762
+ }, Lt = class extends dt {
763
+ constructor(t, e, r, n) {
764
+ super(t, r), this.runtime = e, this.dispose = A(t.scope.collect(`fork <${t.runtime.name}>`, () => {
765
+ this.uid = null, this.reset(), this.context.emit("internal/fork", this);
766
+ const c = D(e.disposables, this.dispose);
767
+ return D(e.children, this) && !e.children.length && t.registry.delete(e.plugin), c;
768
+ }), P.static, e), e.children.push(this), e.disposables.push(this.dispose), this.context.emit("internal/fork", this), this.init(n);
769
+ }
770
+ static {
771
+ g(this, "ForkScope");
772
+ }
773
+ dispose;
774
+ start() {
775
+ if (super.start()) return !0;
776
+ for (const t of this.runtime.forkables)
777
+ this.ensure(async () => t(this.context, this._config));
778
+ }
779
+ update(t, e) {
780
+ const r = this.config, n = this.runtime.isForkable ? this : this.runtime;
781
+ if (n.config !== r) return;
782
+ let c;
783
+ try {
784
+ c = L(this.runtime.plugin, t);
785
+ } catch (y) {
786
+ return this.context.emit("internal/error", y), this.cancel(y);
787
+ }
788
+ const [i, a] = n.checkUpdate(c, e);
789
+ this.context.emit("internal/before-update", this, t), this.config = c, n.config = c, i && this.context.emit("internal/update", this, r), a && n.restart();
790
+ }
791
+ }, ct = class extends dt {
792
+ constructor(t, e, r, n) {
793
+ super(t, r), this.plugin = e, e ? (this.setup(), this.init(n)) : (this.name = "root", this.isActive = !0);
794
+ }
795
+ static {
796
+ g(this, "MainScope");
797
+ }
798
+ value;
799
+ runtime = this;
800
+ schema;
801
+ name;
802
+ inject = /* @__PURE__ */ Object.create(null);
803
+ forkables = [];
804
+ children = [];
805
+ isReusable = !1;
806
+ isReactive = !1;
807
+ get isForkable() {
808
+ return this.forkables.length > 0;
809
+ }
810
+ fork(t, e, r) {
811
+ return new Lt(t, this, e, r);
812
+ }
813
+ dispose() {
814
+ return this.uid = null, this.reset(), this.context.emit("internal/runtime", this), !0;
815
+ }
816
+ setup() {
817
+ const { name: t } = this.plugin;
818
+ t && t !== "apply" && (this.name = t), this.schema = this.plugin.Config || this.plugin.schema, this.inject = K.resolve(this.plugin.using || this.plugin.inject), this.isReusable = this.plugin.reusable, this.isReactive = this.plugin.reactive, this.context.emit("internal/runtime", this), this.isReusable && this.forkables.push(this.apply);
819
+ }
820
+ apply = /* @__PURE__ */ g((t, e) => {
821
+ if (typeof this.plugin != "function")
822
+ return this.plugin.apply(t, e);
823
+ if (tt(this.plugin)) {
824
+ const r = new this.plugin(t, e), n = r[P.expose];
825
+ return n && t.set(n, r), r.fork && this.forkables.push(r.fork.bind(r)), r;
826
+ } else
827
+ return this.plugin(t, e);
828
+ }, "apply");
829
+ reset() {
830
+ super.reset();
831
+ for (const t of this.children)
832
+ t.reset();
833
+ }
834
+ start() {
835
+ if (super.start()) return !0;
836
+ !this.isReusable && this.plugin && this.ensure(async () => this.value = this.apply(this.ctx, this._config));
837
+ for (const t of this.children)
838
+ t.start();
839
+ }
840
+ update(t, e) {
841
+ if (this.isForkable) {
842
+ const y = new Error(`attempting to update forkable plugin "${this.plugin.name}", which may lead to unexpected behavior`);
843
+ this.context.emit(this.ctx, "internal/warning", y);
844
+ }
845
+ const r = this.config;
846
+ let n;
847
+ try {
848
+ n = L(this.runtime.plugin || this.context.constructor, t);
849
+ } catch (y) {
850
+ return this.context.emit("internal/error", y), this.cancel(y);
851
+ }
852
+ const [c, i] = this.checkUpdate(n, e), a = this.children.find((y) => y.config === r);
853
+ this.config = n, a && (this.context.emit("internal/before-update", a, t), a.config = n, c && this.context.emit("internal/update", a, r)), i && this.restart();
854
+ }
855
+ };
856
+ function mt(t) {
857
+ return t && typeof t == "object" && typeof t.apply == "function";
858
+ }
859
+ g(mt, "isApplicable");
860
+ function K(t) {
861
+ return function(e, r) {
862
+ if (r.kind === "class")
863
+ e.inject = t;
864
+ else if (r.kind === "method")
865
+ r.addInitializer(function() {
866
+ const n = this[h.tracker]?.property;
867
+ if (!n) throw new Error("missing context tracker");
868
+ this[n].inject(t, (c) => {
869
+ e.call(F(this, { [n]: c }));
870
+ });
871
+ });
872
+ else
873
+ throw new Error("@Inject can only be used on class or class methods");
874
+ };
875
+ }
876
+ g(K, "Inject");
877
+ ((t) => {
878
+ function e(r) {
879
+ if (!r) return {};
880
+ if (Array.isArray(r))
881
+ return Object.fromEntries(r.map((a) => [a, { required: !0 }]));
882
+ const { required: n, optional: c, ...i } = r;
883
+ return Array.isArray(n) && Object.assign(i, Object.fromEntries(n.map((a) => [a, { required: !0 }]))), Array.isArray(c) && Object.assign(i, Object.fromEntries(c.map((a) => [a, { required: !1 }]))), i;
884
+ }
885
+ t.resolve = e, g(e, "resolve");
886
+ })(K || (K = {}));
887
+ var Jt = class {
888
+ constructor(t, e) {
889
+ this.ctx = t, A(this, h.tracker, {
890
+ associate: "registry",
891
+ property: "ctx"
892
+ }), this.context = t;
893
+ const r = new ct(t, null, e);
894
+ t.scope = r, r.ctx = t, this.set(null, r);
895
+ }
896
+ static {
897
+ g(this, "Registry");
898
+ }
899
+ _counter = 0;
900
+ _internal = /* @__PURE__ */ new Map();
901
+ context;
902
+ get counter() {
903
+ return ++this._counter;
904
+ }
905
+ get size() {
906
+ return this._internal.size;
907
+ }
908
+ resolve(t, e = !1) {
909
+ if (t === null || typeof t == "function") return t;
910
+ if (mt(t)) return t.apply;
911
+ if (e) throw new Error('invalid plugin, expect function or object with an "apply" method, received ' + typeof t);
912
+ }
913
+ get(t) {
914
+ const e = this.resolve(t);
915
+ return e && this._internal.get(e);
916
+ }
917
+ has(t) {
918
+ const e = this.resolve(t);
919
+ return !!e && this._internal.has(e);
920
+ }
921
+ set(t, e) {
922
+ const r = this.resolve(t);
923
+ this._internal.set(r, e);
924
+ }
925
+ delete(t) {
926
+ const e = this.resolve(t), r = e && this._internal.get(e);
927
+ if (r)
928
+ return this._internal.delete(e), r.dispose(), r;
929
+ }
930
+ keys() {
931
+ return this._internal.keys();
932
+ }
933
+ values() {
934
+ return this._internal.values();
935
+ }
936
+ entries() {
937
+ return this._internal.entries();
938
+ }
939
+ forEach(t) {
940
+ return this._internal.forEach(t);
941
+ }
942
+ using(t, e) {
943
+ return this.inject(t, e);
944
+ }
945
+ inject(t, e) {
946
+ return this.plugin({ inject: t, apply: e, name: e.name });
947
+ }
948
+ plugin(t, e, r) {
949
+ if (this.resolve(t, !0), this.ctx.scope.assertActive(), !r)
950
+ try {
951
+ e = L(t, e);
952
+ } catch (c) {
953
+ this.context.emit(this.ctx, "internal/error", c), r = c, e = null;
954
+ }
955
+ let n = this.get(t);
956
+ return n ? (n.isForkable || this.context.emit(this.ctx, "internal/warning", new Error(`duplicate plugin detected: ${t.name}`)), n.fork(this.ctx, e, r)) : (n = new ct(this.ctx, t, e, r), this.set(t, n), n.fork(this.ctx, e, r));
957
+ }
958
+ }, Vt = Jt, P = class M {
959
+ static {
960
+ g(this, "Context");
961
+ }
962
+ static store = h.store;
963
+ static events = h.events;
964
+ static static = h.static;
965
+ static filter = h.filter;
966
+ static expose = h.expose;
967
+ static isolate = h.isolate;
968
+ static internal = h.internal;
969
+ static intercept = h.intercept;
970
+ static origin = "ctx";
971
+ static current = "ctx";
972
+ static is(e) {
973
+ return !!e?.[M.is];
974
+ }
975
+ static {
976
+ M.is[Symbol.toPrimitive] = () => Symbol.for("cordis.is"), M.prototype[M.is] = !0;
977
+ }
978
+ /** @deprecated use `Service.traceable` instead */
979
+ static associate(e, r) {
980
+ return e;
981
+ }
982
+ constructor(e) {
983
+ e = L(this.constructor, e), this[h.store] = /* @__PURE__ */ Object.create(null), this[h.isolate] = /* @__PURE__ */ Object.create(null), this[h.internal] = /* @__PURE__ */ Object.create(null), this[h.intercept] = /* @__PURE__ */ Object.create(null);
984
+ const r = new Proxy(this, Q.handler);
985
+ r.root = r, r.reflect = new Q(r), r.registry = new Vt(r, e), r.lifecycle = new qt(r);
986
+ const n = /* @__PURE__ */ g((c) => {
987
+ if (c) {
988
+ n(Object.getPrototypeOf(c));
989
+ for (const i of Object.getOwnPropertyNames(c)) {
990
+ const a = c[i].prototype?.constructor;
991
+ a && (r[c[i].key] = new a(r, e), A(r[c[i].key], "ctx", r));
992
+ }
993
+ }
994
+ }, "attach");
995
+ return n(this[h.internal]), r;
996
+ }
997
+ [Symbol.for("nodejs.util.inspect.custom")]() {
998
+ return `Context <${this.name}>`;
999
+ }
1000
+ get name() {
1001
+ let e = this.runtime;
1002
+ for (; e && !e.name; )
1003
+ e = e.parent.runtime;
1004
+ return e?.name;
1005
+ }
1006
+ get events() {
1007
+ return this.lifecycle;
1008
+ }
1009
+ /** @deprecated */
1010
+ get state() {
1011
+ return this.scope;
1012
+ }
1013
+ extend(e = {}) {
1014
+ const r = Reflect.getOwnPropertyDescriptor(this, h.shadow)?.value, n = Object.assign(Object.create(C(this, this)), e);
1015
+ return r ? Object.assign(Object.create(n), { [h.shadow]: r }) : n;
1016
+ }
1017
+ isolate(e, r) {
1018
+ const n = Object.create(this[h.isolate]);
1019
+ return n[e] = r ?? Symbol(e), this.extend({ [h.isolate]: n });
1020
+ }
1021
+ intercept(e, r) {
1022
+ const n = Object.create(this[h.intercept]);
1023
+ return n[e] = r, this.extend({ [h.intercept]: n });
1024
+ }
1025
+ };
1026
+ P.prototype[P.internal] = /* @__PURE__ */ Object.create(null);
1027
+ var Qt = class bt {
1028
+ static {
1029
+ g(this, "Service");
1030
+ }
1031
+ static setup = h.setup;
1032
+ static invoke = h.invoke;
1033
+ static extend = h.extend;
1034
+ static tracker = h.tracker;
1035
+ static provide = h.provide;
1036
+ static immediate = h.immediate;
1037
+ start() {
1038
+ }
1039
+ stop() {
1040
+ }
1041
+ ctx;
1042
+ name;
1043
+ config;
1044
+ constructor(...e) {
1045
+ let r, n, c, i;
1046
+ P.is(e[0]) ? (r = e[0], typeof e[1] == "string" ? (n = e[1], c = e[2]) : i = e[1]) : i = e[0], n ??= this.constructor[h.provide], c ??= this.constructor[h.immediate];
1047
+ let a = this;
1048
+ const y = {
1049
+ associate: n,
1050
+ property: "ctx"
1051
+ };
1052
+ return a[h.invoke] && (a = Y(n, et(Object.getPrototypeOf(this), Function.prototype), y)), r ? a.ctx = r : a[h.setup](), a.name = n, a.config = i, A(a, h.tracker, y), a.ctx.provide(n), a.ctx.runtime.name = n, c && (r ? a[h.expose] = n : a.ctx.set(n, a)), a.ctx.on("ready", async () => {
1053
+ await Promise.resolve(), await a.start(), c || a.ctx.set(n, a);
1054
+ }), a.ctx.on("dispose", () => a.stop()), a;
1055
+ }
1056
+ [h.filter](e) {
1057
+ return e[h.isolate][this.name] === this.ctx[h.isolate][this.name];
1058
+ }
1059
+ [h.setup]() {
1060
+ this.ctx = new P();
1061
+ }
1062
+ [h.extend](e) {
1063
+ let r;
1064
+ return this[bt.invoke] ? r = Y(this.name, this, this[h.tracker]) : r = Object.create(this), Object.assign(r, e);
1065
+ }
1066
+ static [Symbol.hasInstance](e) {
1067
+ let r = e.constructor;
1068
+ for (; r; ) {
1069
+ if (r = r.prototype?.constructor, r === this) return !0;
1070
+ r = Object.getPrototypeOf(r);
1071
+ }
1072
+ return !1;
1073
+ }
1074
+ }, Ht = Object.defineProperty, Kt = Object.getOwnPropertyNames, S = (t, e) => Ht(t, "name", { value: e, configurable: !0 }), Gt = (t, e) => function() {
1075
+ return e || (0, t[Kt(t)[0]])((e = { exports: {} }).exports, e), e.exports;
1076
+ }, Wt = Gt({
1077
+ "src/index.ts"(t, e) {
1078
+ var r = Symbol.for("schemastery"), n = Symbol.for("ValidationError");
1079
+ globalThis.__schemastery_index__ ??= 0;
1080
+ var c = class extends TypeError {
1081
+ constructor(o, s) {
1082
+ let f = "$";
1083
+ for (const u of s.path || [])
1084
+ typeof u == "string" ? f += "." + u : typeof u == "number" ? f += "[" + u + "]" : typeof u == "symbol" && (f += `[Symbol(${u.toString()})]`);
1085
+ f.startsWith(".") && (f = f.slice(1)), super((f === "$" ? "" : `${f} `) + o), this.options = s;
1086
+ }
1087
+ static {
1088
+ S(this, "ValidationError");
1089
+ }
1090
+ name = "ValidationError";
1091
+ static is(o) {
1092
+ return !!o?.[n];
1093
+ }
1094
+ };
1095
+ Object.defineProperty(c.prototype, n, {
1096
+ value: !0
1097
+ });
1098
+ var i = /* @__PURE__ */ S(function(o) {
1099
+ const s = /* @__PURE__ */ S(function(f, u = {}) {
1100
+ return i.resolve(f, s, u)[0];
1101
+ }, "schema");
1102
+ if (o.refs) {
1103
+ const f = N(o.refs, (l) => new i(l)), u = /* @__PURE__ */ S((l) => f[l], "getRef");
1104
+ for (const l in f) {
1105
+ const p = f[l];
1106
+ p.sKey = u(p.sKey), p.inner = u(p.inner), p.list = p.list && p.list.map(u), p.dict = p.dict && N(p.dict, u);
1107
+ }
1108
+ return f[o.uid];
1109
+ }
1110
+ if (Object.assign(s, o), typeof s.callback == "string")
1111
+ try {
1112
+ s.callback = new Function("return " + s.callback)();
1113
+ } catch {
1114
+ }
1115
+ return Object.defineProperty(s, "uid", { value: globalThis.__schemastery_index__++ }), Object.setPrototypeOf(s, i.prototype), s.meta ||= {}, s.toString = s.toString.bind(s), s;
1116
+ }, "Schema");
1117
+ i.prototype = Object.create(Function.prototype), i.prototype[r] = !0, i.ValidationError = c;
1118
+ var a;
1119
+ i.prototype.toJSON = /* @__PURE__ */ S(function() {
1120
+ if (a)
1121
+ return a[this.uid] ??= JSON.parse(JSON.stringify({ ...this })), this.uid;
1122
+ a = { [this.uid]: { ...this } }, a[this.uid] = JSON.parse(JSON.stringify({ ...this }));
1123
+ const s = { uid: this.uid, refs: a };
1124
+ return a = void 0, s;
1125
+ }, "toJSON"), i.prototype.set = /* @__PURE__ */ S(function(s, f) {
1126
+ return this.dict[s] = f, this;
1127
+ }, "set"), i.prototype.push = /* @__PURE__ */ S(function(s) {
1128
+ return this.list.push(s), this;
1129
+ }, "push");
1130
+ function y(o, s) {
1131
+ const f = typeof o == "string" ? { "": o } : { ...o };
1132
+ for (const u in s) {
1133
+ const l = s[u];
1134
+ l?.$description || l?.$desc ? f[u] = l.$description || l.$desc : typeof l == "string" && (f[u] = l);
1135
+ }
1136
+ return f;
1137
+ }
1138
+ S(y, "mergeDesc");
1139
+ function d(o) {
1140
+ return o?.$value ?? o?.$inner;
1141
+ }
1142
+ S(d, "getInner");
1143
+ function b(o) {
1144
+ return ft(o ?? {}, (s) => !s.startsWith("$"));
1145
+ }
1146
+ S(b, "extractKeys"), i.prototype.i18n = /* @__PURE__ */ S(function(s) {
1147
+ const f = i(this), u = y(f.meta.description, s);
1148
+ return Object.keys(u).length && (f.meta.description = u), f.dict && (f.dict = N(f.dict, (l, p) => l.i18n(N(s, (m) => d(m)?.[p] ?? m?.[p])))), f.list && (f.list = f.list.map((l, p) => l.i18n(N(s, (m = {}) => Array.isArray(d(m)) ? d(m)[p] : Array.isArray(m) ? m[p] : b(m))))), f.inner && (f.inner = f.inner.i18n(N(s, (l) => d(l) ? d(l) : b(l)))), f.sKey && (f.sKey = f.sKey.i18n(N(s, (l) => l?.$key))), f;
1149
+ }, "i18n"), i.prototype.extra = /* @__PURE__ */ S(function(s, f) {
1150
+ const u = i(this);
1151
+ return u.meta = { ...u.meta, [s]: f }, u;
1152
+ }, "extra");
1153
+ for (const o of ["required", "disabled", "collapse", "hidden", "loose"])
1154
+ Object.assign(i.prototype, {
1155
+ [o](s = !0) {
1156
+ const f = i(this);
1157
+ return f.meta = { ...f.meta, [o]: s }, f;
1158
+ }
1159
+ });
1160
+ i.prototype.deprecated = /* @__PURE__ */ S(function() {
1161
+ const s = i(this);
1162
+ return s.meta.badges ||= [], s.meta.badges.push({ text: "deprecated", type: "danger" }), s;
1163
+ }, "deprecated"), i.prototype.experimental = /* @__PURE__ */ S(function() {
1164
+ const s = i(this);
1165
+ return s.meta.badges ||= [], s.meta.badges.push({ text: "experimental", type: "warning" }), s;
1166
+ }, "experimental"), i.prototype.pattern = /* @__PURE__ */ S(function(s) {
1167
+ const f = i(this), u = at(s, ["source", "flags"]);
1168
+ return f.meta = { ...f.meta, pattern: u }, f;
1169
+ }, "pattern"), i.prototype.simplify = /* @__PURE__ */ S(function(s) {
1170
+ if (I(s, this.meta.default, this.type === "dict")) return null;
1171
+ if ($(s)) return s;
1172
+ if (this.type === "object" || this.type === "dict") {
1173
+ const f = {};
1174
+ for (const u in s) {
1175
+ const p = (this.type === "object" ? this.dict[u] : this.inner)?.simplify(s[u]);
1176
+ (this.type === "dict" || !$(p)) && (f[u] = p);
1177
+ }
1178
+ return I(f, this.meta.default, this.type === "dict") ? null : f;
1179
+ } else if (this.type === "array" || this.type === "tuple") {
1180
+ const f = [];
1181
+ return s.forEach((u, l) => {
1182
+ const p = this.type === "array" ? this.inner : this.list[l], m = p ? p.simplify(u) : u;
1183
+ f.push(m);
1184
+ }), f;
1185
+ } else if (this.type === "intersect") {
1186
+ const f = {};
1187
+ for (const u of this.list)
1188
+ Object.assign(f, u.simplify(s));
1189
+ return f;
1190
+ } else if (this.type === "union")
1191
+ for (const f of this.list)
1192
+ try {
1193
+ return i.resolve(s, f, {}), f.simplify(s);
1194
+ } catch {
1195
+ }
1196
+ return s;
1197
+ }, "simplify"), i.prototype.toString = /* @__PURE__ */ S(function(s) {
1198
+ return it[this.type]?.(this, s) ?? `Schema<${this.type}>`;
1199
+ }, "toString"), i.prototype.role = /* @__PURE__ */ S(function(o, s) {
1200
+ const f = i(this);
1201
+ return f.meta = { ...f.meta, role: o, extra: s }, f;
1202
+ }, "role");
1203
+ for (const o of ["default", "link", "comment", "description", "max", "min", "step"])
1204
+ Object.assign(i.prototype, {
1205
+ [o](s) {
1206
+ const f = i(this);
1207
+ return f.meta = { ...f.meta, [o]: s }, f;
1208
+ }
1209
+ });
1210
+ var j = {};
1211
+ i.extend = /* @__PURE__ */ S(function(s, f) {
1212
+ j[s] = f;
1213
+ }, "extend"), i.resolve = /* @__PURE__ */ S(function(s, f, u = {}, l = !1) {
1214
+ if (!f) return [s];
1215
+ if (u.ignore?.(s, f)) return [s];
1216
+ if ($(s) && f.type !== "lazy") {
1217
+ if (f.meta.required) throw new c("missing required value", u);
1218
+ let m = f, O = f.meta.default;
1219
+ for (; m?.type === "intersect" && $(O); )
1220
+ m = m.list[0], O = m?.meta.default;
1221
+ if ($(O)) return [s];
1222
+ s = V(O);
1223
+ }
1224
+ const p = j[f.type];
1225
+ if (!p) throw new c(`unsupported type "${f.type}"`, u);
1226
+ try {
1227
+ return p(s, f, u, l);
1228
+ } catch (m) {
1229
+ if (!f.meta.loose) throw m;
1230
+ return [f.meta.default];
1231
+ }
1232
+ }, "resolve"), i.from = /* @__PURE__ */ S(function(s) {
1233
+ if ($(s))
1234
+ return i.any();
1235
+ if (["string", "number", "boolean"].includes(typeof s))
1236
+ return i.const(s).required();
1237
+ if (s[r])
1238
+ return s;
1239
+ if (typeof s == "function")
1240
+ switch (s) {
1241
+ case String:
1242
+ return i.string().required();
1243
+ case Number:
1244
+ return i.number().required();
1245
+ case Boolean:
1246
+ return i.boolean().required();
1247
+ case Function:
1248
+ return i.function().required();
1249
+ default:
1250
+ return i.is(s).required();
1251
+ }
1252
+ else
1253
+ throw new TypeError(`cannot infer schema from ${s}`);
1254
+ }, "from"), i.lazy = /* @__PURE__ */ S(function(s) {
1255
+ const f = /* @__PURE__ */ S(() => (u.inner[r] || (u.inner = u.builder(), u.inner.meta = { ...u.meta, ...u.inner.meta }), u.inner.toJSON()), "toJSON"), u = new i({ type: "lazy", builder: s, inner: { toJSON: f } });
1256
+ return u;
1257
+ }, "lazy"), i.natural = /* @__PURE__ */ S(function() {
1258
+ return i.number().step(1).min(0);
1259
+ }, "natural"), i.percent = /* @__PURE__ */ S(function() {
1260
+ return i.number().step(0.01).min(0).max(1).role("slider");
1261
+ }, "percent"), i.date = /* @__PURE__ */ S(function() {
1262
+ return i.union([
1263
+ i.is(Date),
1264
+ i.transform(i.string().role("datetime"), (s, f) => {
1265
+ const u = new Date(s);
1266
+ if (isNaN(+u)) throw new c(`invalid date "${s}"`, f);
1267
+ return u;
1268
+ }, !0)
1269
+ ]);
1270
+ }, "date"), i.regExp = /* @__PURE__ */ S(function(s = "") {
1271
+ return i.union([
1272
+ i.is(RegExp),
1273
+ i.transform(i.string().role("regexp", { flag: s }), (f, u) => {
1274
+ try {
1275
+ return new RegExp(f, s);
1276
+ } catch (l) {
1277
+ throw new c(l.message, u);
1278
+ }
1279
+ }, !0)
1280
+ ]);
1281
+ }, "regExp"), i.arrayBuffer = /* @__PURE__ */ S(function(s) {
1282
+ return i.union([
1283
+ i.is(ArrayBuffer),
1284
+ i.is(SharedArrayBuffer),
1285
+ i.transform(i.any(), (f, u) => {
1286
+ if (E.isSource(f)) return E.fromSource(f);
1287
+ throw new c(`expected ArrayBufferSource but got ${f}`, u);
1288
+ }, !0),
1289
+ ...s ? [i.transform(i.string(), (f, u) => {
1290
+ try {
1291
+ return s === "base64" ? E.fromBase64(f) : E.fromHex(f);
1292
+ } catch (l) {
1293
+ throw new c(l.message, u);
1294
+ }
1295
+ }, !0)] : []
1296
+ ]);
1297
+ }, "arrayBuffer"), i.extend("lazy", (o, s, f, u) => (s.inner[r] || (s.inner = s.builder(), s.inner.meta = { ...s.meta, ...s.inner.meta }), i.resolve(o, s.inner, f, u))), i.extend("any", (o) => [o]), i.extend("never", (o, s, f) => {
1298
+ throw new c(`expected nullable but got ${o}`, f);
1299
+ }), i.extend("const", (o, { value: s }, f) => {
1300
+ if (I(o, s)) return [s];
1301
+ throw new c(`expected ${s} but got ${o}`, f);
1302
+ });
1303
+ function k(o, s, f, u, l = !1) {
1304
+ const { max: p = 1 / 0, min: m = -1 / 0 } = s;
1305
+ if (o > p) throw new c(`expected ${f} <= ${p} but got ${o}`, u);
1306
+ if (o < m && !l) throw new c(`expected ${f} >= ${m} but got ${o}`, u);
1307
+ }
1308
+ S(k, "checkWithinRange"), i.extend("string", (o, { meta: s }, f) => {
1309
+ if (typeof o != "string") throw new c(`expected string but got ${o}`, f);
1310
+ if (s.pattern) {
1311
+ const u = new RegExp(s.pattern.source, s.pattern.flags);
1312
+ if (!u.test(o)) throw new c(`expect string to match regexp ${u}`, f);
1313
+ }
1314
+ return k(o.length, s, "string length", f), [o];
1315
+ });
1316
+ function R(o, s) {
1317
+ const f = o.toString();
1318
+ if (f.includes("e")) return o * Math.pow(10, s);
1319
+ const u = f.indexOf(".");
1320
+ if (u === -1) return o * Math.pow(10, s);
1321
+ const l = f.slice(u + 1), p = f.slice(0, u);
1322
+ return l.length <= s ? +(p + l.padEnd(s, "0")) : +(p + l.slice(0, s) + "." + l.slice(s));
1323
+ }
1324
+ S(R, "decimalShift");
1325
+ function x(o, s, f) {
1326
+ if (f = Math.abs(f), !/^\d+\.\d+$/.test(f.toString()))
1327
+ return (o - s) % f === 0;
1328
+ const u = f.toString().indexOf("."), l = f.toString().slice(u + 1).length;
1329
+ return Math.abs(R(o, l) - R(s, l)) % R(f, l) === 0;
1330
+ }
1331
+ S(x, "isMultipleOf"), i.extend("number", (o, { meta: s }, f) => {
1332
+ if (typeof o != "number") throw new c(`expected number but got ${o}`, f);
1333
+ k(o, s, "number", f);
1334
+ const { step: u } = s;
1335
+ if (u && !x(o, s.min ?? 0, u))
1336
+ throw new c(`expected number multiple of ${u} but got ${o}`, f);
1337
+ return [o];
1338
+ }), i.extend("boolean", (o, s, f) => {
1339
+ if (typeof o == "boolean") return [o];
1340
+ throw new c(`expected boolean but got ${o}`, f);
1341
+ }), i.extend("bitset", (o, { bits: s, meta: f }, u) => {
1342
+ let l = 0, p = [];
1343
+ if (typeof o == "number") {
1344
+ l = o;
1345
+ for (const m in s)
1346
+ o & s[m] && p.push(m);
1347
+ } else if (Array.isArray(o)) {
1348
+ p = o;
1349
+ for (const m of p) {
1350
+ if (typeof m != "string") throw new c(`expected string but got ${m}`, u);
1351
+ m in s && (l |= s[m]);
1352
+ }
1353
+ } else
1354
+ throw new c(`expected number or array but got ${o}`, u);
1355
+ return l === f.default ? [l] : [l, p];
1356
+ }), i.extend("function", (o, s, f) => {
1357
+ if (typeof o == "function") return [o];
1358
+ throw new c(`expected function but got ${o}`, f);
1359
+ }), i.extend("is", (o, { constructor: s }, f) => {
1360
+ if (typeof s == "function") {
1361
+ if (o instanceof s) return [o];
1362
+ throw new c(`expected ${s.name} but got ${o}`, f);
1363
+ } else {
1364
+ if ($(o))
1365
+ throw new c(`expected ${s} but got ${o}`, f);
1366
+ let u = Object.getPrototypeOf(o);
1367
+ for (; u; ) {
1368
+ if (u.constructor?.name === s) return [o];
1369
+ u = Object.getPrototypeOf(u);
1370
+ }
1371
+ throw new c(`expected ${s} but got ${o}`, f);
1372
+ }
1373
+ });
1374
+ function v(o, s, f, u) {
1375
+ try {
1376
+ const [l, p] = i.resolve(o[s], f, {
1377
+ ...u,
1378
+ path: [...u.path || [], s]
1379
+ });
1380
+ return p !== void 0 && (o[s] = p), l;
1381
+ } catch (l) {
1382
+ if (!u?.autofix) throw l;
1383
+ return delete o[s], f.meta.default;
1384
+ }
1385
+ }
1386
+ S(v, "property"), i.extend("array", (o, { inner: s, meta: f }, u) => {
1387
+ if (!Array.isArray(o)) throw new c(`expected array but got ${o}`, u);
1388
+ return k(o.length, f, "array length", u, !$(s.meta.default)), [o.map((l, p) => v(o, p, s, u))];
1389
+ }), i.extend("dict", (o, { inner: s, sKey: f }, u, l) => {
1390
+ if (!J(o)) throw new c(`expected object but got ${o}`, u);
1391
+ const p = {};
1392
+ for (const m in o) {
1393
+ let O;
1394
+ try {
1395
+ O = i.resolve(m, f, u)[0];
1396
+ } catch (gt) {
1397
+ if (l) continue;
1398
+ throw gt;
1399
+ }
1400
+ p[O] = v(o, m, s, u), o[O] = o[m], m !== O && delete o[m];
1401
+ }
1402
+ return [p];
1403
+ }), i.extend("tuple", (o, { list: s }, f, u) => {
1404
+ if (!Array.isArray(o)) throw new c(`expected array but got ${o}`, f);
1405
+ const l = s.map((p, m) => v(o, m, p, f));
1406
+ return u ? [l] : (l.push(...o.slice(s.length)), [l]);
1407
+ });
1408
+ function z(o, s) {
1409
+ for (const f in s)
1410
+ f in o || (o[f] = s[f]);
1411
+ }
1412
+ S(z, "merge"), i.extend("object", (o, { dict: s }, f, u) => {
1413
+ if (!J(o)) throw new c(`expected object but got ${o}`, f);
1414
+ const l = {};
1415
+ for (const p in s) {
1416
+ const m = v(o, p, s[p], f);
1417
+ (!$(m) || p in o) && (l[p] = m);
1418
+ }
1419
+ return u || z(l, o), [l];
1420
+ }), i.extend("union", (o, { list: s, toString: f }, u, l) => {
1421
+ for (const p of s)
1422
+ try {
1423
+ return i.resolve(o, p, u, l);
1424
+ } catch {
1425
+ }
1426
+ throw new c(`expected ${f()} but got ${JSON.stringify(o)}`, u);
1427
+ }), i.extend("intersect", (o, { list: s, toString: f }, u, l) => {
1428
+ if (!s.length) return [o];
1429
+ let p;
1430
+ for (const m of s) {
1431
+ const O = i.resolve(o, m, u, !0)[0];
1432
+ if (!$(O))
1433
+ if ($(p))
1434
+ p = O;
1435
+ else {
1436
+ if (typeof p != typeof O)
1437
+ throw new c(`expected ${f()} but got ${JSON.stringify(o)}`, u);
1438
+ if (typeof O == "object")
1439
+ z(p ??= {}, O);
1440
+ else if (p !== O)
1441
+ throw new c(`expected ${f()} but got ${JSON.stringify(o)}`, u);
1442
+ }
1443
+ }
1444
+ return !l && J(o) && z(p, o), [p];
1445
+ }), i.extend("transform", (o, { inner: s, callback: f, preserve: u }, l) => {
1446
+ const [p, m = o] = i.resolve(o, s, l, !0);
1447
+ return u ? [f(p)] : [f(p), f(m)];
1448
+ });
1449
+ var it = {};
1450
+ function _(o, s, f) {
1451
+ it[o] = f, Object.assign(i, {
1452
+ [o](...u) {
1453
+ const l = new i({ type: o });
1454
+ return s.forEach((p, m) => {
1455
+ switch (p) {
1456
+ case "sKey":
1457
+ l.sKey = u[m] ?? i.string();
1458
+ break;
1459
+ case "inner":
1460
+ l.inner = i.from(u[m]);
1461
+ break;
1462
+ case "list":
1463
+ l.list = u[m].map(i.from);
1464
+ break;
1465
+ case "dict":
1466
+ l.dict = N(u[m], i.from);
1467
+ break;
1468
+ case "bits": {
1469
+ l.bits = {};
1470
+ for (const O in u[m])
1471
+ typeof u[m][O] == "number" && (l.bits[O] = u[m][O]);
1472
+ break;
1473
+ }
1474
+ case "callback": {
1475
+ const O = l.callback = u[m];
1476
+ O.toJSON ||= () => O.toString();
1477
+ break;
1478
+ }
1479
+ case "constructor": {
1480
+ const O = l.constructor = u[m];
1481
+ typeof O == "function" && (O.toJSON ||= () => O.name);
1482
+ break;
1483
+ }
1484
+ default:
1485
+ l[p] = u[m];
1486
+ }
1487
+ }), o === "object" || o === "dict" ? l.meta.default = {} : o === "array" || o === "tuple" ? l.meta.default = [] : o === "bitset" && (l.meta.default = 0), l;
1488
+ }
1489
+ });
1490
+ }
1491
+ S(_, "defineMethod"), _("is", ["constructor"], ({ constructor: o }) => typeof o == "function" ? o.name : o), _("any", [], () => "any"), _("never", [], () => "never"), _("const", ["value"], ({ value: o }) => typeof o == "string" ? JSON.stringify(o) : o), _("string", [], () => "string"), _("number", [], () => "number"), _("boolean", [], () => "boolean"), _("bitset", ["bits"], () => "bitset"), _("function", [], () => "function"), _("array", ["inner"], ({ inner: o }) => `${o.toString(!0)}[]`), _("dict", ["inner", "sKey"], ({ inner: o, sKey: s }) => `{ [key: ${s.toString()}]: ${o.toString()} }`), _("tuple", ["list"], ({ list: o }) => `[${o.map((s) => s.toString()).join(", ")}]`), _("object", ["dict"], ({ dict: o }) => Object.keys(o).length === 0 ? "{}" : `{ ${Object.entries(o).map(([s, f]) => `${s}${f.meta.required ? "" : "?"}: ${f.toString()}`).join(", ")} }`), _("union", ["list"], ({ list: o }, s) => {
1492
+ const f = o.map(({ toString: u }) => u()).join(" | ");
1493
+ return s ? `(${f})` : f;
1494
+ }), _("intersect", ["list"], ({ list: o }) => `${o.map((s) => s.toString(!0)).join(" & ")}`), _("transform", ["inner", "callback", "preserve"], ({ inner: o }, s) => o.toString(s)), e.exports = i;
1495
+ }
1496
+ });
1497
+ const Xt = Wt();
1498
+ var Yt = /* @__PURE__ */ ((t) => (t.ANALYTICS_API_BASE = "https://analytics.ipe.wiki/api/v6", t.ANALYTICS_DASH_URL = "https://analytics.ipe.wiki", t.GITHUB_URL = "https://github.com/inpageedit/inpageedit-next", t.HOME_URL = "https://www.ipe.wiki/", t.UPDATE_LOGS_URL = "https://www.ipe.wiki/changelogs/", t.PLUGIN_REGISTRY_URL = "https://registry.ipe.wiki/registry.v1.json", t))(Yt || {});
1499
+ export {
1500
+ P as C,
1501
+ Yt as E,
1502
+ K as I,
1503
+ Xt as S,
1504
+ Qt as a,
1505
+ wt as p
1506
+ };
1507
+ //# sourceMappingURL=endpoints-DgyuoRZd.js.map