likec4 1.48.0 → 1.49.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 (113) hide show
  1. package/README.md +11 -1
  2. package/__app__/src/likec4.js +5595 -4127
  3. package/__app__/src/routes/index.js +3 -153
  4. package/__app__/src/routes/projects.js +21 -1087
  5. package/__app__/src/routes/single.js +1221 -16
  6. package/__app__/src/style.css +1 -1
  7. package/__app__/src/vendors.js +3507 -894
  8. package/__app__/src/webcomponent.js +1 -1
  9. package/config/schema.json +155 -143
  10. package/dist/THIRD-PARTY-LICENSES.md +1739 -0
  11. package/dist/_chunks/GraphvizBinaryAdapter.mjs +72 -0
  12. package/dist/_chunks/filenames.mjs +14 -0
  13. package/dist/_chunks/index.d.mts +224 -129
  14. package/dist/_chunks/index2.d.mts +2033 -1908
  15. package/dist/_chunks/libs/@chevrotain/gast.mjs +1 -3969
  16. package/dist/_chunks/libs/@chevrotain/regexp-to-ast.mjs +9 -785
  17. package/dist/_chunks/libs/@chevrotain/utils.mjs +1 -37
  18. package/dist/_chunks/libs/@hono/mcp.mjs +34 -0
  19. package/dist/_chunks/libs/@hono/node-server.mjs +1 -436
  20. package/dist/_chunks/libs/@logtape/logtape.d.mts +741 -0
  21. package/dist/_chunks/libs/@logtape/logtape.mjs +6 -1354
  22. package/dist/_chunks/libs/@lume/kiwi.mjs +1 -1355
  23. package/dist/_chunks/libs/@modelcontextprotocol/sdk.d.mts +14 -14
  24. package/dist/_chunks/libs/@modelcontextprotocol/sdk.mjs +12 -25105
  25. package/dist/_chunks/libs/@msgpack/msgpack.mjs +1 -1503
  26. package/dist/_chunks/libs/@nanostores/react.mjs +1 -30
  27. package/dist/_chunks/libs/@smithy/util-base64.mjs +1 -100
  28. package/dist/_chunks/libs/ajv.mjs +1 -777
  29. package/dist/_chunks/libs/atomically.mjs +1 -362
  30. package/dist/_chunks/libs/birpc.mjs +1 -201
  31. package/dist/_chunks/libs/chevrotain-allstar.mjs +2 -850
  32. package/dist/_chunks/libs/chevrotain.mjs +55 -6229
  33. package/dist/_chunks/libs/conf.mjs +1 -2258
  34. package/dist/_chunks/libs/defu.mjs +1 -42
  35. package/dist/_chunks/libs/esm-env.mjs +1 -5
  36. package/dist/_chunks/libs/eventemitter3.mjs +1 -243
  37. package/dist/_chunks/libs/fast-equals.mjs +1 -446
  38. package/dist/_chunks/libs/find-up-simple.mjs +1 -24
  39. package/dist/_chunks/libs/get-port.mjs +1 -107
  40. package/dist/_chunks/libs/is-docker.mjs +1 -26
  41. package/dist/_chunks/libs/is-error-instance.mjs +1 -26
  42. package/dist/_chunks/libs/is-inside-container.mjs +1 -20
  43. package/dist/_chunks/libs/is-plain-obj.mjs +1 -9
  44. package/dist/_chunks/libs/isexe.mjs +1 -127
  45. package/dist/_chunks/libs/json5.mjs +14 -959
  46. package/dist/_chunks/libs/khroma.mjs +1 -605
  47. package/dist/_chunks/libs/ky.mjs +2 -807
  48. package/dist/_chunks/libs/langium.d.mts +2880 -2844
  49. package/dist/_chunks/libs/langium.mjs +32 -20351
  50. package/dist/_chunks/libs/merge-error-cause.mjs +2 -746
  51. package/dist/_chunks/libs/nanostores.mjs +1 -198
  52. package/dist/_chunks/libs/p-limit.mjs +1 -120
  53. package/dist/_chunks/libs/p-queue.mjs +1 -449
  54. package/dist/_chunks/libs/package-manager-detector.mjs +1 -559
  55. package/dist/_chunks/libs/package-up.mjs +1 -10
  56. package/dist/_chunks/libs/parse-ms.mjs +1 -36
  57. package/dist/_chunks/libs/pathe.mjs +1 -0
  58. package/dist/_chunks/libs/picomatch.mjs +1 -1673
  59. package/dist/_chunks/libs/pretty-ms.mjs +1 -80
  60. package/dist/_chunks/libs/remeda.mjs +1 -690
  61. package/dist/_chunks/libs/safe-stringify.mjs +1 -21
  62. package/dist/_chunks/libs/strip-indent.mjs +1 -15
  63. package/dist/_chunks/libs/tinyrainbow.mjs +1 -88
  64. package/dist/_chunks/libs/ts-graphviz.mjs +4 -725
  65. package/dist/_chunks/libs/ufo.mjs +1 -240
  66. package/dist/_chunks/libs/which.mjs +1 -84
  67. package/dist/_chunks/libs/word-wrap.mjs +12 -43
  68. package/dist/_chunks/node.mjs +481 -0
  69. package/dist/_chunks/plugin.mjs +98 -772
  70. package/dist/_chunks/rolldown-runtime.mjs +1 -48
  71. package/dist/_chunks/sequence-view.mjs +1 -575
  72. package/dist/cli/index.mjs +127 -1846
  73. package/dist/config/index.d.mts +2 -2
  74. package/dist/config/index.mjs +1 -6
  75. package/dist/index.d.mts +148 -7
  76. package/dist/index.mjs +1 -21
  77. package/dist/model/builder.mjs +1 -3
  78. package/dist/model/index.d.mts +57 -3
  79. package/dist/model/index.mjs +1 -5
  80. package/dist/vite-plugin/index.d.mts +4 -3
  81. package/dist/vite-plugin/index.mjs +1 -22
  82. package/dist/vite-plugin/internal.d.mts +5 -5
  83. package/dist/vite-plugin/internal.mjs +1 -68
  84. package/package.json +60 -41
  85. package/react/{index.d.ts → index.d.mts} +112 -70
  86. package/react/{index.js → index.mjs} +21361 -22064
  87. package/react/package.json +2 -5
  88. package/vite-plugin-modules.d.ts +5 -5
  89. package/dist/_chunks/LikeC4.d.mts +0 -121
  90. package/dist/_chunks/LikeC4.mjs +0 -202
  91. package/dist/_chunks/config-app.prod.d.mts +0 -18
  92. package/dist/_chunks/config-app.prod.mjs +0 -188
  93. package/dist/_chunks/config-webcomponent.prod.mjs +0 -71
  94. package/dist/_chunks/define-config.mjs +0 -409
  95. package/dist/_chunks/index3.d.mts +0 -60
  96. package/dist/_chunks/index4.d.mts +0 -1
  97. package/dist/_chunks/libs/@smithy/is-array-buffer.mjs +0 -10
  98. package/dist/_chunks/libs/hono.mjs +0 -1829
  99. package/dist/_chunks/libs/nanoid.mjs +0 -29
  100. package/dist/_chunks/model.mjs +0 -12
  101. package/dist/_chunks/module.d.mts +0 -71
  102. package/dist/_chunks/module.mjs +0 -18657
  103. package/dist/_chunks/vite-build.mjs +0 -69
  104. package/dist/_chunks/vite-dev.mjs +0 -79
  105. package/dist/_chunks/vite-preview.mjs +0 -27
  106. package/dist/language/module.d.mts +0 -5
  107. package/dist/language/module.mjs +0 -20
  108. package/dist/vite/vite-build.d.mts +0 -26
  109. package/dist/vite/vite-build.mjs +0 -27
  110. package/dist/vite/vite-dev.d.mts +0 -34
  111. package/dist/vite/vite-dev.mjs +0 -29
  112. package/dist/vite/vite-preview.d.mts +0 -20
  113. package/dist/vite/vite-preview.mjs +0 -26
@@ -1,746 +1,2 @@
1
- import { t as main_default$7 } from "./is-error-instance.mjs";
2
- import { t as isPlainObject } from "./is-plain-obj.mjs";
3
-
4
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/descriptors.js
5
- const normalizeDescriptors = (error) => {
6
- CORE_ERROR_PROPS.forEach((propName) => {
7
- normalizeDescriptor$1(error, propName);
8
- });
9
- };
10
- const CORE_ERROR_PROPS = [
11
- "name",
12
- "message",
13
- "stack",
14
- "cause",
15
- "errors"
16
- ];
17
- const normalizeDescriptor$1 = (error, propName) => {
18
- const descriptor = getDescriptor(error, propName);
19
- if (descriptor === void 0) return;
20
- if (isReadonlyGetter(descriptor)) {
21
- setErrorProperty$1(error, propName, error[propName]);
22
- return;
23
- }
24
- if (isInvalidDescriptor(descriptor)) setErrorDescriptor(error, propName, descriptor);
25
- };
26
- const getDescriptor = (value, propName) => {
27
- const descriptor = Object.getOwnPropertyDescriptor(value, propName);
28
- if (descriptor !== void 0) return descriptor;
29
- const prototype = Object.getPrototypeOf(value);
30
- return prototype === null ? void 0 : getDescriptor(prototype, propName);
31
- };
32
- const isReadonlyGetter = ({ get, set }) => get !== void 0 && set === void 0;
33
- const isInvalidDescriptor = ({ enumerable, writable }) => enumerable || !writable;
34
- const setErrorProperty$1 = (error, propName, value) => {
35
- setErrorDescriptor(error, propName, { value });
36
- };
37
- const setErrorDescriptor = (error, propName, descriptor) => {
38
- Object.defineProperty(error, propName, {
39
- ...descriptor,
40
- ..."get" in descriptor || "set" in descriptor ? {} : { writable: true },
41
- enumerable: false,
42
- configurable: true
43
- });
44
- };
45
-
46
- //#endregion
47
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/aggregate.js
48
- const normalizeAggregate = (error, recurse) => {
49
- if (Array.isArray(error.errors)) setErrorProperty$1(error, "errors", error.errors.filter(isDefined).map(recurse).filter(Boolean));
50
- else if (isAggregateError(error)) setErrorProperty$1(error, "errors", []);
51
- else if (error.errors !== void 0) deleteAggregateErrors(error);
52
- };
53
- const isDefined = (error) => error !== void 0;
54
- const isAggregateError = (error) => "AggregateError" in globalThis && (error.name === "AggregateError" || error instanceof AggregateError);
55
- const deleteAggregateErrors = (error) => {
56
- delete error.errors;
57
- if (error.errors !== void 0) setErrorProperty$1(error, "errors", []);
58
- };
59
-
60
- //#endregion
61
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/cause.js
62
- const normalizeCause = (error, recurse) => {
63
- if (!("cause" in error)) return;
64
- const cause = error.cause === void 0 ? error.cause : recurse(error.cause);
65
- if (cause === void 0) delete error.cause;
66
- else setErrorProperty$1(error, "cause", cause);
67
- };
68
-
69
- //#endregion
70
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/modifiable.js
71
- const isNonModifiableError = (error) => !Object.isExtensible(error) || CORE_ERROR_PROPS.some((propName) => isNonConfigurableProp(error, propName) || isThrowingProp(error, propName));
72
- const isNonConfigurableProp = (error, propName) => {
73
- const descriptor = Object.getOwnPropertyDescriptor(error, propName);
74
- return descriptor !== void 0 && !descriptor.configurable;
75
- };
76
- const isThrowingProp = (error, propName) => {
77
- try {
78
- error[propName];
79
- return false;
80
- } catch {
81
- return true;
82
- }
83
- };
84
-
85
- //#endregion
86
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/stack.js
87
- const setStack = (error) => {
88
- setErrorProperty$1(error, "stack", getStack$3(error.message, error.name));
89
- };
90
- const getStack$3 = (message = "", name = "Error") => {
91
- const { stack } = new (getErrorClass(name))(message);
92
- return typeof stack === "string" && stack !== "" ? stack : `${name}: ${message}`;
93
- };
94
- const getErrorClass = (name) => {
95
- const descriptor = {
96
- value: name,
97
- enumerable: false,
98
- writable: true,
99
- configurable: true
100
- };
101
- const StackError = Object.defineProperty(class extends Error {}, "name", descriptor);
102
- Object.defineProperty(StackError.prototype, "name", descriptor);
103
- return StackError;
104
- };
105
-
106
- //#endregion
107
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/copy.js
108
- const copyObject = (object) => {
109
- const objectCopy = {};
110
- for (const propName of getPropsToCopy(object)) try {
111
- const value = object[propName];
112
- const { enumerable, configurable, writable = true } = getDescriptor(object, propName);
113
- Object.defineProperty(objectCopy, propName, {
114
- value,
115
- enumerable,
116
- configurable,
117
- writable
118
- });
119
- } catch {}
120
- return objectCopy;
121
- };
122
- const getPropsToCopy = (object) => {
123
- const propNames = getOwnKeys(object);
124
- for (const propName of CORE_ERROR_PROPS) if (isInheritedProp(object, propName)) propNames.push(propName);
125
- return propNames;
126
- };
127
- const getOwnKeys = (object) => {
128
- try {
129
- return Reflect.ownKeys(object);
130
- } catch {
131
- return [];
132
- }
133
- };
134
- const isInheritedProp = (object, propName) => {
135
- try {
136
- return propName in object && !Object.hasOwn(object, propName);
137
- } catch {
138
- return false;
139
- }
140
- };
141
-
142
- //#endregion
143
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/object.js
144
- const objectifyError = (object) => {
145
- const { name, message, stack, cause, errors, ...objectA } = copyObject(object);
146
- const messageA = getMessage$1(message, objectA);
147
- const error = newError(name, messageA);
148
- if (message === messageA) assignObjectProps(error, objectA);
149
- Object.entries({
150
- name,
151
- stack,
152
- cause,
153
- errors
154
- }).forEach(([propName, propValue]) => {
155
- setNewErrorProperty(error, propName, propValue);
156
- });
157
- if (stack === void 0) setStack(error);
158
- return error;
159
- };
160
- const getMessage$1 = (message, object) => typeof message === "string" && message !== "" ? message : truncateMessage(safeJsonStringify(object));
161
- const safeJsonStringify = (object) => {
162
- try {
163
- return JSON.stringify(object);
164
- } catch {
165
- return safeStringify(object);
166
- }
167
- };
168
- const safeStringify = (object) => {
169
- try {
170
- return String(object);
171
- } catch {
172
- return "Invalid error";
173
- }
174
- };
175
- const truncateMessage = (message) => message.length < MESSAGE_MAX_SIZE ? message : `${message.slice(0, MESSAGE_MAX_SIZE)}...`;
176
- const MESSAGE_MAX_SIZE = 1e3;
177
- const newError = (name, message) => {
178
- if (name === "AggregateError" && "AggregateError" in globalThis) return new AggregateError([], message);
179
- if (name in NATIVE_ERRORS) return new NATIVE_ERRORS[name](message);
180
- return new Error(message);
181
- };
182
- const NATIVE_ERRORS = {
183
- Error,
184
- ReferenceError,
185
- TypeError,
186
- SyntaxError,
187
- RangeError,
188
- URIError,
189
- EvalError
190
- };
191
- const assignObjectProps = (error, object) => {
192
- for (const propName in object) if (!(propName in error)) error[propName] = object[propName];
193
- };
194
- const setNewErrorProperty = (error, propName, propValue) => {
195
- if (propValue !== void 0) setErrorProperty$1(error, propName, propValue);
196
- };
197
-
198
- //#endregion
199
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/string.js
200
- const stringifyError = (value) => {
201
- try {
202
- const error = new Error(String(value));
203
- setStack(error);
204
- return error;
205
- } catch (error_) {
206
- return error_;
207
- }
208
- };
209
-
210
- //#endregion
211
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/main.js
212
- const { toString: objectToString } = Object.prototype;
213
- const createError = (value) => {
214
- if (isErrorPlainObj(value)) return objectifyError(value);
215
- if (!main_default$7(value)) return stringifyError(value);
216
- if (isInvalidError(value)) return objectifyError(value);
217
- return value;
218
- };
219
- const isErrorPlainObj = (value) => {
220
- try {
221
- return isPlainObject(value);
222
- } catch {
223
- return false;
224
- }
225
- };
226
- const isInvalidError = (value) => isProxy(value) || isNonModifiableError(value) || hasInvalidConstructor(value);
227
- const isProxy = (value) => {
228
- try {
229
- return objectToString.call(value) === "[object Object]";
230
- } catch {
231
- return true;
232
- }
233
- };
234
- const hasInvalidConstructor = (error) => typeof error.constructor !== "function" || typeof error.constructor.name !== "string" || error.constructor.name === "" || error.constructor.prototype !== Object.getPrototypeOf(error);
235
-
236
- //#endregion
237
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/main.js
238
- const normalizeException = (error, { shallow = false } = {}) => recurseException(error, [], shallow);
239
- var main_default$6 = normalizeException;
240
- const recurseException = (error, parents, shallow) => {
241
- if (parents.includes(error)) return;
242
- const recurse = shallow ? identity : (innerError) => recurseException(innerError, [...parents, error], shallow);
243
- const errorA = createError(error);
244
- normalizeProps(errorA, recurse);
245
- return errorA;
246
- };
247
- const identity = (error) => error;
248
- const normalizeProps = (error, recurse) => {
249
- normalizeName(error);
250
- normalizeMessage(error);
251
- normalizeStack(error);
252
- normalizeCause(error, recurse);
253
- normalizeAggregate(error, recurse);
254
- normalizeDescriptors(error);
255
- };
256
- const normalizeName = (error) => {
257
- if (isDefinedString$1(error.name)) return;
258
- const prototypeName = Object.getPrototypeOf(error).name;
259
- setErrorProperty$1(error, "name", isDefinedString$1(prototypeName) ? prototypeName : error.constructor.name);
260
- };
261
- const normalizeMessage = (error) => {
262
- if (!isDefinedString$1(error.message)) setErrorProperty$1(error, "message", "");
263
- };
264
- const normalizeStack = (error) => {
265
- if (!isDefinedString$1(error.stack)) setStack(error);
266
- };
267
- const isDefinedString$1 = (value) => typeof value === "string" && value !== "";
268
-
269
- //#endregion
270
- //#region ../../node_modules/.pnpm/set-error-class@3.0.1/node_modules/set-error-class/build/src/args.js
271
- const normalizeArgs$1 = (error, ErrorClass, currentName = error.name) => {
272
- validateErrorClass(ErrorClass);
273
- if (typeof currentName !== "string") throw new TypeError(`currentName must be a string: ${currentName}`);
274
- return currentName;
275
- };
276
- const validateErrorClass = (ErrorClass) => {
277
- if (!isClass(ErrorClass)) throw new TypeError(`ErrorClass must be a class: ${ErrorClass}`);
278
- if (!isErrorClass(ErrorClass.prototype)) throw new TypeError(`ErrorClass must inherit from Error: ${ErrorClass}`);
279
- if (!hasConstructor(ErrorClass)) throw new TypeError(`ErrorClass must be have a valid constructor: ${ErrorClass}`);
280
- };
281
- const isClass = (ErrorClass) => typeof ErrorClass === "function" && typeof ErrorClass.prototype === "object" && ErrorClass.prototype !== null;
282
- const isErrorClass = (prototype) => prototype !== null && (prototype.name === "Error" || isErrorClass(Object.getPrototypeOf(prototype)));
283
- const hasConstructor = (ErrorClass) => typeof ErrorClass.prototype.constructor === "function";
284
-
285
- //#endregion
286
- //#region ../../node_modules/.pnpm/set-error-class@3.0.1/node_modules/set-error-class/build/src/enum.js
287
- const setNonEnumProp$1 = (error, propName, value) => {
288
- Object.defineProperty(error, propName, {
289
- value,
290
- enumerable: false,
291
- writable: true,
292
- configurable: true
293
- });
294
- };
295
-
296
- //#endregion
297
- //#region ../../node_modules/.pnpm/set-error-class@3.0.1/node_modules/set-error-class/build/src/prototype.js
298
- const updatePrototype = (error, ErrorClass) => {
299
- if (Object.getPrototypeOf(error) === ErrorClass.prototype) return;
300
- setPrototype(error, ErrorClass);
301
- deleteOwnProperty(error, "constructor");
302
- fixName(error, ErrorClass);
303
- };
304
- const setPrototype = (error, ErrorClass) => {
305
- Object.setPrototypeOf(error, ErrorClass.prototype);
306
- };
307
- const fixName = (error, ErrorClass) => {
308
- deleteOwnProperty(error, "name");
309
- const prototypeName = getClassName(ErrorClass.prototype);
310
- if (error.name !== prototypeName) setNonEnumProp$1(error, "name", prototypeName);
311
- };
312
- const getClassName = (prototype) => getPrototypeName(prototype) ?? getConstructorName(prototype) ?? getClassName(Object.getPrototypeOf(prototype));
313
- const getPrototypeName = (prototype) => Object.hasOwn(prototype, "name") && isDefinedString(prototype.name) ? prototype.name : void 0;
314
- const getConstructorName = (prototype) => typeof prototype.constructor === "function" && isDefinedString(prototype.constructor.name) ? prototype.constructor.name : void 0;
315
- const isDefinedString = (value) => typeof value === "string" && value !== "";
316
- const deleteOwnProperty = (error, propName) => {
317
- if (Object.hasOwn(error, propName)) delete error[propName];
318
- };
319
-
320
- //#endregion
321
- //#region ../../node_modules/.pnpm/set-error-class@3.0.1/node_modules/set-error-class/build/src/stack.js
322
- const updateStack$1 = (error, currentName) => {
323
- if (!shouldUpdateStack(error, currentName)) return;
324
- setNonEnumProp$1(error, "stack", getStack$2(error, currentName));
325
- };
326
- const shouldUpdateStack = (error, currentName) => currentName !== error.name && currentName !== "" && error.stack.includes(currentName) && stackIncludesName();
327
- const stackIncludesName = () => {
328
- class StackError extends Error {}
329
- const descriptor = {
330
- value: EXAMPLE_NAME,
331
- enumerable: false,
332
- writable: true,
333
- configurable: true
334
- };
335
- Object.defineProperty(StackError, "name", descriptor);
336
- Object.defineProperty(StackError.prototype, "name", descriptor);
337
- const { stack } = new StackError("");
338
- return typeof stack === "string" && stack.includes(EXAMPLE_NAME);
339
- };
340
- const EXAMPLE_NAME = "SetErrorClassError";
341
- const getStack$2 = ({ name, stack }, currentName) => {
342
- if (stack.startsWith(`${currentName}: `)) return stack.replace(currentName, name);
343
- const [fromA, to] = getReplacers$1(currentName, name).find(([from]) => stack.includes(from));
344
- return stack.replace(fromA, to);
345
- };
346
- const getReplacers$1 = (currentName, newName) => [
347
- [`\n${currentName}: `, `\n${newName}: `],
348
- [`${currentName}: `, `${newName}: `],
349
- [`${currentName} `, `${newName} `],
350
- [currentName, newName]
351
- ];
352
-
353
- //#endregion
354
- //#region ../../node_modules/.pnpm/set-error-class@3.0.1/node_modules/set-error-class/build/src/main.js
355
- const setErrorClass = (error, ErrorClass, currentName) => {
356
- const errorA = main_default$6(error);
357
- const currentNameA = normalizeArgs$1(errorA, ErrorClass, currentName);
358
- updatePrototype(errorA, ErrorClass);
359
- updateStack$1(errorA, currentNameA);
360
- return errorA;
361
- };
362
- var main_default$5 = setErrorClass;
363
-
364
- //#endregion
365
- //#region ../../node_modules/.pnpm/redefine-property@3.0.1/node_modules/redefine-property/build/src/merge.js
366
- const mergeDescriptors = (newDescriptor, currentDescriptor) => currentDescriptor.configurable === false ? mergeNonConfig(newDescriptor, currentDescriptor) : mergeConfig(newDescriptor, currentDescriptor);
367
- const mergeNonConfig = (newDescriptor, currentDescriptor) => ({
368
- ...currentDescriptor,
369
- ...getNonConfigWritable(newDescriptor, currentDescriptor),
370
- ...getNonConfigValue(newDescriptor, currentDescriptor)
371
- });
372
- const getNonConfigWritable = (newDescriptor, currentDescriptor) => currentDescriptor.writable === true && newDescriptor.writable === false ? { writable: false } : {};
373
- const getNonConfigValue = (newDescriptor, currentDescriptor) => newDescriptor.hasValue && "value" in currentDescriptor && currentDescriptor.writable === true ? { value: newDescriptor.value } : {};
374
- const mergeConfig = (newDescriptor, currentDescriptor) => {
375
- const enumerable = mergeDescriptor(newDescriptor.enumerable, currentDescriptor.enumerable, true);
376
- const writable = mergeDescriptor(newDescriptor.writable, currentDescriptor.writable, true);
377
- const configurable = mergeDescriptor(newDescriptor.configurable, currentDescriptor.configurable, true);
378
- return {
379
- ...mergeValue(newDescriptor, currentDescriptor, writable),
380
- enumerable,
381
- configurable
382
- };
383
- };
384
- const mergeValue = (newDescriptor, currentDescriptor, writable) => {
385
- if (newDescriptor.hasValue) return {
386
- value: newDescriptor.value,
387
- writable
388
- };
389
- if (!hasGetSet(newDescriptor) && !hasGetSet(currentDescriptor)) return {
390
- value: currentDescriptor.value,
391
- writable
392
- };
393
- return {
394
- get: mergeDescriptor(newDescriptor.get, currentDescriptor.get),
395
- set: mergeDescriptor(newDescriptor.set, currentDescriptor.set)
396
- };
397
- };
398
- const hasGetSet = ({ get, set }) => get !== void 0 || set !== void 0;
399
- const mergeDescriptor = (newValue, currentValue, defaultValue) => newValue ?? currentValue ?? defaultValue;
400
-
401
- //#endregion
402
- //#region ../../node_modules/.pnpm/redefine-property@3.0.1/node_modules/redefine-property/build/src/normalize.js
403
- const normalizeInput = (input, key, newDescriptor) => {
404
- if (!isAnyObj(input)) throw new TypeError(`Argument must be an object: ${input}`);
405
- if (!isValidKey(key)) throw new TypeError(`Property key must be a string, a symbol or an integer: ${key}`);
406
- return normalizeDescriptor(newDescriptor);
407
- };
408
- const isAnyObj = (value) => typeof value === "object" && value !== null;
409
- const isValidKey = (key) => {
410
- const type = typeof key;
411
- return type === "string" || type === "symbol" || type === "number";
412
- };
413
- const normalizeDescriptor = (newDescriptor) => {
414
- if (!isPlainObject(newDescriptor)) throw new TypeError(`Descriptor must be a plain object: ${newDescriptor}`);
415
- const { enumerable, writable, configurable, value, get, set, ...unknownProps } = newDescriptor;
416
- const hasValue = "value" in newDescriptor;
417
- validateDescriptor({
418
- enumerable,
419
- writable,
420
- configurable,
421
- get,
422
- set,
423
- unknownProps,
424
- hasValue
425
- });
426
- return {
427
- enumerable,
428
- writable,
429
- configurable,
430
- value,
431
- get,
432
- set,
433
- hasValue
434
- };
435
- };
436
- const validateDescriptor = ({ enumerable, writable, configurable, get, set, unknownProps, hasValue }) => {
437
- validateGetSet(hasValue, get, "get");
438
- validateGetSet(hasValue, set, "set");
439
- validateBoolean(enumerable, "enumerable");
440
- validateBoolean(writable, "writable");
441
- validateBoolean(configurable, "configurable");
442
- validateUnknownProps(unknownProps);
443
- };
444
- const validateGetSet = (hasValue, getSet, propName) => {
445
- validateFunction(getSet, propName);
446
- if (hasValue && getSet !== void 0) throw new TypeError(`Descriptor property "value" and "${propName}" must not both be defined: ${getSet}`);
447
- };
448
- const validateFunction = (propValue, propName) => {
449
- if (propValue !== void 0 && typeof propValue !== "function") throw new TypeError(`Descriptor property "${propName}" must be a function: ${propValue}`);
450
- };
451
- const validateBoolean = (propValue, propName) => {
452
- if (propValue !== void 0 && typeof propValue !== "boolean") throw new TypeError(`Descriptor property "${propName}" must be a boolean: ${propValue}`);
453
- };
454
- const validateUnknownProps = (unknownProps) => {
455
- const [unknownProp] = Object.keys(unknownProps);
456
- if (unknownProp !== void 0) throw new TypeError(`Unknown descriptor property "${unknownProp}": ${unknownProps[unknownProp]}`);
457
- };
458
-
459
- //#endregion
460
- //#region ../../node_modules/.pnpm/redefine-property@3.0.1/node_modules/redefine-property/build/src/main.js
461
- const redefineProperty = (input, key, newDescriptor) => {
462
- setProperty(input, key, mergeDescriptors(normalizeInput(input, key, newDescriptor), getCurrentDescriptor(input, key)));
463
- return input;
464
- };
465
- var main_default$4 = redefineProperty;
466
- const getCurrentDescriptor = (input, key) => {
467
- const descriptor = Object.getOwnPropertyDescriptor(input, key);
468
- if (descriptor !== void 0) return descriptor;
469
- const prototype = Object.getPrototypeOf(input);
470
- return prototype === null ? {} : getCurrentDescriptor(prototype, key);
471
- };
472
- const setProperty = (input, key, finalDescriptor) => {
473
- try {
474
- Object.defineProperty(input, key, finalDescriptor);
475
- } catch {}
476
- };
477
-
478
- //#endregion
479
- //#region ../../node_modules/.pnpm/set-error-props@6.0.1/node_modules/set-error-props/build/src/assign.js
480
- const assignProp = (error, propName, propValue) => {
481
- if (propValue !== void 0) return setProp(error, propName, propValue);
482
- try {
483
- delete error[propName];
484
- } catch {}
485
- if (error[propName] !== void 0) return setProp(error, propName);
486
- };
487
- const setProp = (error, propName, propValue) => {
488
- main_default$4(error, propName, {
489
- value: propValue,
490
- ...getNonEnum(propName)
491
- });
492
- };
493
- const getNonEnum = (propName) => typeof propName === "string" && propName.startsWith("_") ? { enumerable: false } : {};
494
-
495
- //#endregion
496
- //#region ../../node_modules/.pnpm/set-error-props@6.0.1/node_modules/set-error-props/build/src/options.js
497
- const normalizeOptions = (error, props, opts = {}) => {
498
- validateErrorOrObject(error, "First argument");
499
- validateErrorOrObject(props, "Second argument");
500
- if (!isPlainObject(opts)) throw new TypeError(`Options must be a plain object: ${opts}`);
501
- const { soft = false } = opts;
502
- if (typeof soft !== "boolean") throw new TypeError(`Option "soft" must be a boolean: ${soft}`);
503
- return { soft };
504
- };
505
- const validateErrorOrObject = (value, prefix) => {
506
- if (value === void 0) throw new TypeError(`${prefix} is required.`);
507
- if (!isErrorOrObject(value)) throw new TypeError(`${prefix} must be a plain object or an error: ${value}`);
508
- };
509
- const isErrorOrObject = (value) => isPlainObject(value) || main_default$7(value);
510
-
511
- //#endregion
512
- //#region ../../node_modules/.pnpm/set-error-props@6.0.1/node_modules/set-error-props/build/src/skip.js
513
- const shouldSkipProp = ({ error, props, propName, soft }) => isIgnoredPropName(propName) || !isEnum.call(props, propName) || soft && error[propName] !== void 0;
514
- const isIgnoredPropName = (propName) => propName in CHECK_ERROR || IGNORED_PROPS.has(propName);
515
- const CHECK_ERROR = /* @__PURE__ */ new Error("check");
516
- const IGNORED_PROPS = new Set([
517
- "prototype",
518
- "errors",
519
- "cause"
520
- ]);
521
- const { propertyIsEnumerable: isEnum } = Object.prototype;
522
-
523
- //#endregion
524
- //#region ../../node_modules/.pnpm/set-error-props@6.0.1/node_modules/set-error-props/build/src/main.js
525
- const setErrorProps = (error, props, opts) => {
526
- const { soft } = normalizeOptions(error, props, opts);
527
- for (const propName of Reflect.ownKeys(props)) setErrorProp({
528
- error,
529
- props,
530
- propName,
531
- soft
532
- });
533
- return error;
534
- };
535
- var main_default$3 = setErrorProps;
536
- const setErrorProp = ({ error, props, propName, soft }) => {
537
- if (!shouldSkipProp({
538
- error,
539
- props,
540
- propName,
541
- soft
542
- })) assignProp(error, propName, props[propName]);
543
- };
544
-
545
- //#endregion
546
- //#region ../../node_modules/.pnpm/merge-error-cause@5.0.2/node_modules/merge-error-cause/build/src/set.js
547
- const setErrorProperty = (error, propName, value) => {
548
- Object.defineProperty(error, propName, {
549
- value,
550
- writable: true,
551
- enumerable: false,
552
- configurable: true
553
- });
554
- };
555
-
556
- //#endregion
557
- //#region ../../node_modules/.pnpm/merge-error-cause@5.0.2/node_modules/merge-error-cause/build/src/aggregate.js
558
- const mergeAggregateCauses = (parent, recurse) => {
559
- if (parent.errors === void 0) return;
560
- setErrorProperty(parent, "errors", parent.errors.map((error) => recurse(error).error).filter(Boolean));
561
- };
562
- const mergeAggregateErrors = ({ target, source, parent, child }) => {
563
- if (!hasErrors(target)) {
564
- mergeSourceErrors(target, source);
565
- return;
566
- }
567
- if (hasErrors(source)) setErrorProperty(target, "errors", [...child.errors, ...parent.errors]);
568
- };
569
- const mergeSourceErrors = (target, source) => {
570
- if (source.errors !== void 0) setErrorProperty(target, "errors", source.errors);
571
- };
572
- const hasErrors = (targetOrSource) => targetOrSource.errors !== void 0 && targetOrSource.errors.length !== 0;
573
-
574
- //#endregion
575
- //#region ../../node_modules/.pnpm/set-error-message@3.0.1/node_modules/set-error-message/build/src/args.js
576
- const normalizeArgs = (error, newMessage, currentMessage = error.message) => {
577
- if (typeof newMessage !== "string") throw new TypeError(`newMessage must be a string: ${newMessage}`);
578
- if (typeof currentMessage !== "string") throw new TypeError(`currentMessage must be a string: ${currentMessage}`);
579
- return currentMessage;
580
- };
581
-
582
- //#endregion
583
- //#region ../../node_modules/.pnpm/set-error-message@3.0.1/node_modules/set-error-message/build/src/stack.js
584
- const getStack$1 = ({ name, stack }, newMessage, currentMessage) => currentMessage !== "" && stack.includes(currentMessage) ? replaceMessage({
585
- name,
586
- stack,
587
- newMessage,
588
- currentMessage
589
- }) : insertMessage(name, stack, newMessage);
590
- const replaceMessage = ({ name, stack, newMessage, currentMessage }) => {
591
- const [fromA, to] = getReplacers(name, newMessage, currentMessage).find(([from]) => stack.includes(from));
592
- return stack.replace(fromA, to);
593
- };
594
- const getReplacers = (name, newMessage, currentMessage) => [
595
- [`${name}: ${currentMessage}`, `${name}: ${newMessage}`],
596
- [`: ${currentMessage}`, `: ${newMessage}`],
597
- [`\n${currentMessage}`, `\n${newMessage}`],
598
- [` ${currentMessage}`, ` ${newMessage}`],
599
- [currentMessage, newMessage]
600
- ];
601
- const insertMessage = (name, stack, newMessage) => {
602
- const nameAndColon = `${name}: `;
603
- const newMessageA = newMessage.trimEnd();
604
- if (stack === name || stack.startsWith(`${name}\n`)) return stack.replace(name, `${nameAndColon}${newMessageA}`);
605
- return stack.startsWith(nameAndColon) ? stack.replace(nameAndColon, `${nameAndColon}${newMessageA}\n`) : `${nameAndColon}${newMessageA}\n${stack}`;
606
- };
607
-
608
- //#endregion
609
- //#region ../../node_modules/.pnpm/set-error-message@3.0.1/node_modules/set-error-message/build/src/main.js
610
- const setErrorMessage = (error, newMessage, currentMessage) => {
611
- const errorA = main_default$6(error);
612
- const currentMessageA = normalizeArgs(errorA, newMessage, currentMessage);
613
- setNonEnumProp(errorA, "message", newMessage);
614
- updateStack(errorA, newMessage, currentMessageA);
615
- return errorA;
616
- };
617
- var main_default$2 = setErrorMessage;
618
- const updateStack = (error, newMessage, currentMessage) => {
619
- if (newMessage === currentMessage || !stackIncludesMessage()) return;
620
- setNonEnumProp(error, "stack", getStack$1(error, newMessage, currentMessage));
621
- };
622
- const stackIncludesMessage = () => {
623
- const { stack } = new Error(EXAMPLE_MESSAGE);
624
- return typeof stack === "string" && stack.includes(EXAMPLE_MESSAGE);
625
- };
626
- const EXAMPLE_MESSAGE = "set-error-message test message";
627
- const setNonEnumProp = (error, propName, value) => {
628
- Object.defineProperty(error, propName, {
629
- value,
630
- enumerable: false,
631
- writable: true,
632
- configurable: true
633
- });
634
- };
635
-
636
- //#endregion
637
- //#region ../../node_modules/.pnpm/wrap-error-message@3.0.1/node_modules/wrap-error-message/build/src/main.js
638
- const wrapErrorMessage = (error, newMessage, oldMessage) => {
639
- if (typeof newMessage !== "string") throw new TypeError(`Second argument must be a message string: ${newMessage}`);
640
- const errorA = main_default$6(error);
641
- return main_default$2(errorA, getMessage(newMessage, errorA.message), oldMessage);
642
- };
643
- var main_default$1 = wrapErrorMessage;
644
- const getMessage = (rawNewMessage, rawCurrentMessage) => {
645
- const newMessage = rawNewMessage.trim();
646
- const currentMessage = rawCurrentMessage.trim();
647
- if (newMessage === "") return currentMessage;
648
- if (currentMessage === "") return newMessage;
649
- return concatMessages(newMessage, currentMessage, rawNewMessage);
650
- };
651
- const concatMessages = (newMessage, currentMessage, rawNewMessage) => {
652
- if (!newMessage.endsWith(PREPEND_CHAR)) return `${currentMessage}\n${newMessage}`;
653
- return rawNewMessage.endsWith(PREPEND_NEWLINE_CHAR) ? `${newMessage}\n${currentMessage}` : `${newMessage} ${currentMessage}`;
654
- };
655
- const PREPEND_CHAR = ":";
656
- const PREPEND_NEWLINE_CHAR = "\n";
657
-
658
- //#endregion
659
- //#region ../../node_modules/.pnpm/merge-error-cause@5.0.2/node_modules/merge-error-cause/build/src/message.js
660
- const mergeMessage = ({ parent, child, target, stackError }) => {
661
- const parentMessage = parent.message;
662
- const stackErrorMessage = stackError.message;
663
- target.message = child.message;
664
- return main_default$1(target, parentMessage, stackErrorMessage);
665
- };
666
-
667
- //#endregion
668
- //#region ../../node_modules/.pnpm/merge-error-cause@5.0.2/node_modules/merge-error-cause/build/src/stack.js
669
- const hasStack = (error, stack) => getStack(error) === stack;
670
- const getStack = (error) => typeof error === "object" && error !== null ? error.stack : void 0;
671
- const mergeStack = ({ wrap, target, source, childHasStack }) => {
672
- if (wrap === childHasStack) return target;
673
- setErrorProperty(target, "stack", source.stack);
674
- return source;
675
- };
676
-
677
- //#endregion
678
- //#region ../../node_modules/.pnpm/merge-error-cause@5.0.2/node_modules/merge-error-cause/build/src/wrap.js
679
- const getWrap = (parent) => {
680
- const { wrap, name } = parent;
681
- if (typeof wrap !== "boolean") return name === "Error";
682
- if (Object.hasOwn(parent, "wrap")) delete parent.wrap;
683
- return wrap;
684
- };
685
-
686
- //#endregion
687
- //#region ../../node_modules/.pnpm/merge-error-cause@5.0.2/node_modules/merge-error-cause/build/src/main.js
688
- const mergeErrorCause = (error) => mergeError(error, []).error;
689
- var main_default = mergeErrorCause;
690
- const mergeError = (error, parents) => {
691
- if (parents.includes(error)) return {};
692
- const recurse = (innerError) => mergeError(innerError, [...parents, error]);
693
- const stack = getStack(error);
694
- const errorA = main_default$6(error, { shallow: true });
695
- const parentHasStack = hasStack(errorA, stack);
696
- mergeAggregateCauses(errorA, recurse);
697
- const { parent: errorB, childHasStack } = mergeCause(errorA, recurse);
698
- return {
699
- error: errorB,
700
- errorHasStack: parentHasStack || childHasStack
701
- };
702
- };
703
- const mergeCause = (parent, recurse) => {
704
- const wrap = getWrap(parent);
705
- if (parent.cause === void 0) return {
706
- parent,
707
- childHasStack: false
708
- };
709
- const { error: child, errorHasStack: childHasStack } = recurse(parent.cause);
710
- delete parent.cause;
711
- return {
712
- parent: mergeChild({
713
- parent,
714
- child,
715
- childHasStack,
716
- wrap
717
- }),
718
- childHasStack
719
- };
720
- };
721
- const mergeChild = ({ parent, child, childHasStack, wrap }) => {
722
- if (child === void 0) return parent;
723
- const [target, source] = wrap ? [child, parent] : [parent, child];
724
- const stackError = mergeStack({
725
- wrap,
726
- target,
727
- source,
728
- childHasStack
729
- });
730
- const targetB = mergeMessage({
731
- parent,
732
- child,
733
- target: main_default$5(target, target.constructor, stackError.name),
734
- stackError
735
- });
736
- mergeAggregateErrors({
737
- target: targetB,
738
- source,
739
- parent,
740
- child
741
- });
742
- return main_default$3(targetB, source, { soft: !wrap });
743
- };
744
-
745
- //#endregion
746
- export { main_default$1 as n, main_default as t };
1
+ import{t as isErrorInstance}from"./is-error-instance.mjs";import{t as isPlainObject}from"./is-plain-obj.mjs";const normalizeDescriptors=e=>{CORE_ERROR_PROPS.forEach(t=>{normalizeDescriptor$1(e,t)})},CORE_ERROR_PROPS=[`name`,`message`,`stack`,`cause`,`errors`],normalizeDescriptor$1=(e,t)=>{let n=getDescriptor(e,t);if(n!==void 0){if(isReadonlyGetter(n)){setErrorProperty$1(e,t,e[t]);return}isInvalidDescriptor(n)&&setErrorDescriptor(e,t,n)}},getDescriptor=(e,t)=>{let n=Object.getOwnPropertyDescriptor(e,t);if(n!==void 0)return n;let r=Object.getPrototypeOf(e);return r===null?void 0:getDescriptor(r,t)},isReadonlyGetter=({get:e,set:t})=>e!==void 0&&t===void 0,isInvalidDescriptor=({enumerable:e,writable:t})=>e||!t,setErrorProperty$1=(e,t,n)=>{setErrorDescriptor(e,t,{value:n})},setErrorDescriptor=(e,t,n)=>{Object.defineProperty(e,t,{...n,...`get`in n||`set`in n?{}:{writable:!0},enumerable:!1,configurable:!0})},normalizeAggregate=(e,t)=>{Array.isArray(e.errors)?setErrorProperty$1(e,`errors`,e.errors.filter(isDefined).map(t).filter(Boolean)):isAggregateError(e)?setErrorProperty$1(e,`errors`,[]):e.errors!==void 0&&deleteAggregateErrors(e)},isDefined=e=>e!==void 0,isAggregateError=e=>`AggregateError`in globalThis&&(e.name===`AggregateError`||e instanceof AggregateError),deleteAggregateErrors=e=>{delete e.errors,e.errors!==void 0&&setErrorProperty$1(e,`errors`,[])},normalizeCause=(e,t)=>{if(!(`cause`in e))return;let n=e.cause===void 0?e.cause:t(e.cause);n===void 0?delete e.cause:setErrorProperty$1(e,`cause`,n)},isNonModifiableError=e=>!Object.isExtensible(e)||CORE_ERROR_PROPS.some(t=>isNonConfigurableProp(e,t)||isThrowingProp(e,t)),isNonConfigurableProp=(e,t)=>{let n=Object.getOwnPropertyDescriptor(e,t);return n!==void 0&&!n.configurable},isThrowingProp=(e,t)=>{try{return e[t],!1}catch{return!0}},setStack=e=>{setErrorProperty$1(e,`stack`,getStack$3(e.message,e.name))},getStack$3=(e=``,t=`Error`)=>{let{stack:n}=new(getErrorClass(t))(e);return typeof n==`string`&&n!==``?n:`${t}: ${e}`},getErrorClass=e=>{let t={value:e,enumerable:!1,writable:!0,configurable:!0},n=Object.defineProperty(class extends Error{},`name`,t);return Object.defineProperty(n.prototype,`name`,t),n},copyObject=e=>{let t={};for(let n of getPropsToCopy(e))try{let r=e[n],{enumerable:i,configurable:o,writable:s=!0}=getDescriptor(e,n);Object.defineProperty(t,n,{value:r,enumerable:i,configurable:o,writable:s})}catch{}return t},getPropsToCopy=e=>{let t=getOwnKeys(e);for(let n of CORE_ERROR_PROPS)isInheritedProp(e,n)&&t.push(n);return t},getOwnKeys=e=>{try{return Reflect.ownKeys(e)}catch{return[]}},isInheritedProp=(e,t)=>{try{return t in e&&!Object.hasOwn(e,t)}catch{return!1}},objectifyError=e=>{let{name:t,message:n,stack:r,cause:i,errors:a,...o}=copyObject(e),s=getMessage$1(n,o),c=newError(t,s);return n===s&&assignObjectProps(c,o),Object.entries({name:t,stack:r,cause:i,errors:a}).forEach(([e,t])=>{setNewErrorProperty(c,e,t)}),r===void 0&&setStack(c),c},getMessage$1=(e,t)=>typeof e==`string`&&e!==``?e:truncateMessage(safeJsonStringify(t)),safeJsonStringify=e=>{try{return JSON.stringify(e)}catch{return safeStringify(e)}},safeStringify=e=>{try{return String(e)}catch{return`Invalid error`}},truncateMessage=e=>e.length<MESSAGE_MAX_SIZE?e:`${e.slice(0,MESSAGE_MAX_SIZE)}...`,MESSAGE_MAX_SIZE=1e3,newError=(e,t)=>e===`AggregateError`&&`AggregateError`in globalThis?AggregateError([],t):e in NATIVE_ERRORS?new NATIVE_ERRORS[e](t):Error(t),NATIVE_ERRORS={Error,ReferenceError,TypeError,SyntaxError,RangeError,URIError,EvalError},assignObjectProps=(e,t)=>{for(let n in t)n in e||(e[n]=t[n])},setNewErrorProperty=(e,t,n)=>{n!==void 0&&setErrorProperty$1(e,t,n)},stringifyError=e=>{try{let t=Error(String(e));return setStack(t),t}catch(e){return e}},{toString:objectToString}=Object.prototype,createError=t=>isErrorPlainObj(t)?objectifyError(t):isErrorInstance(t)?isInvalidError(t)?objectifyError(t):t:stringifyError(t),isErrorPlainObj=e=>{try{return isPlainObject(e)}catch{return!1}},isInvalidError=e=>isProxy(e)||isNonModifiableError(e)||hasInvalidConstructor(e),isProxy=e=>{try{return objectToString.call(e)===`[object Object]`}catch{return!0}},hasInvalidConstructor=e=>typeof e.constructor!=`function`||typeof e.constructor.name!=`string`||e.constructor.name===``||e.constructor.prototype!==Object.getPrototypeOf(e),normalizeException=(e,{shallow:t=!1}={})=>recurseException(e,[],t),recurseException=(e,t,n)=>{if(t.includes(e))return;let r=n?identity:r=>recurseException(r,[...t,e],n),i=createError(e);return normalizeProps(i,r),i},identity=e=>e,normalizeProps=(e,t)=>{normalizeName(e),normalizeMessage(e),normalizeStack(e),normalizeCause(e,t),normalizeAggregate(e,t),normalizeDescriptors(e)},normalizeName=e=>{if(isDefinedString$1(e.name))return;let t=Object.getPrototypeOf(e).name;setErrorProperty$1(e,`name`,isDefinedString$1(t)?t:e.constructor.name)},normalizeMessage=e=>{isDefinedString$1(e.message)||setErrorProperty$1(e,`message`,``)},normalizeStack=e=>{isDefinedString$1(e.stack)||setStack(e)},isDefinedString$1=e=>typeof e==`string`&&e!==``,normalizeArgs$1=(e,t,n=e.name)=>{if(validateErrorClass(t),typeof n!=`string`)throw TypeError(`currentName must be a string: ${n}`);return n},validateErrorClass=e=>{if(!isClass(e))throw TypeError(`ErrorClass must be a class: ${e}`);if(!isErrorClass(e.prototype))throw TypeError(`ErrorClass must inherit from Error: ${e}`);if(!hasConstructor(e))throw TypeError(`ErrorClass must be have a valid constructor: ${e}`)},isClass=e=>typeof e==`function`&&typeof e.prototype==`object`&&e.prototype!==null,isErrorClass=e=>e!==null&&(e.name===`Error`||isErrorClass(Object.getPrototypeOf(e))),hasConstructor=e=>typeof e.prototype.constructor==`function`,setNonEnumProp$1=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!1,writable:!0,configurable:!0})},updatePrototype=(e,t)=>{Object.getPrototypeOf(e)!==t.prototype&&(setPrototype(e,t),deleteOwnProperty(e,`constructor`),fixName(e,t))},setPrototype=(e,t)=>{Object.setPrototypeOf(e,t.prototype)},fixName=(e,t)=>{deleteOwnProperty(e,`name`);let n=getClassName(t.prototype);e.name!==n&&setNonEnumProp$1(e,`name`,n)},getClassName=e=>getPrototypeName(e)??getConstructorName(e)??getClassName(Object.getPrototypeOf(e)),getPrototypeName=e=>Object.hasOwn(e,`name`)&&isDefinedString(e.name)?e.name:void 0,getConstructorName=e=>typeof e.constructor==`function`&&isDefinedString(e.constructor.name)?e.constructor.name:void 0,isDefinedString=e=>typeof e==`string`&&e!==``,deleteOwnProperty=(e,t)=>{Object.hasOwn(e,t)&&delete e[t]},updateStack$1=(e,t)=>{shouldUpdateStack(e,t)&&setNonEnumProp$1(e,`stack`,getStack$2(e,t))},shouldUpdateStack=(e,t)=>t!==e.name&&t!==``&&e.stack.includes(t)&&stackIncludesName(),stackIncludesName=()=>{class e extends Error{}let t={value:EXAMPLE_NAME,enumerable:!1,writable:!0,configurable:!0};Object.defineProperty(e,`name`,t),Object.defineProperty(e.prototype,`name`,t);let{stack:n}=new e(``);return typeof n==`string`&&n.includes(EXAMPLE_NAME)},EXAMPLE_NAME=`SetErrorClassError`,getStack$2=({name:e,stack:t},n)=>{if(t.startsWith(`${n}: `))return t.replace(n,e);let[r,i]=getReplacers$1(n,e).find(([e])=>t.includes(e));return t.replace(r,i)},getReplacers$1=(e,t)=>[[`\n${e}: `,`\n${t}: `],[`${e}: `,`${t}: `],[`${e} `,`${t} `],[e,t]],setErrorClass=(e,t,n)=>{let r=normalizeException(e),i=normalizeArgs$1(r,t,n);return updatePrototype(r,t),updateStack$1(r,i),r},mergeDescriptors=(e,t)=>t.configurable===!1?mergeNonConfig(e,t):mergeConfig(e,t),mergeNonConfig=(e,t)=>({...t,...getNonConfigWritable(e,t),...getNonConfigValue(e,t)}),getNonConfigWritable=(e,t)=>t.writable===!0&&e.writable===!1?{writable:!1}:{},getNonConfigValue=(e,t)=>e.hasValue&&`value`in t&&t.writable===!0?{value:e.value}:{},mergeConfig=(e,t)=>{let n=mergeDescriptor(e.enumerable,t.enumerable,!0),r=mergeDescriptor(e.writable,t.writable,!0),i=mergeDescriptor(e.configurable,t.configurable,!0);return{...mergeValue(e,t,r),enumerable:n,configurable:i}},mergeValue=(e,t,n)=>e.hasValue?{value:e.value,writable:n}:!hasGetSet(e)&&!hasGetSet(t)?{value:t.value,writable:n}:{get:mergeDescriptor(e.get,t.get),set:mergeDescriptor(e.set,t.set)},hasGetSet=({get:e,set:t})=>e!==void 0||t!==void 0,mergeDescriptor=(e,t,n)=>e??t??n,normalizeInput=(e,t,n)=>{if(!isAnyObj(e))throw TypeError(`Argument must be an object: ${e}`);if(!isValidKey(t))throw TypeError(`Property key must be a string, a symbol or an integer: ${t}`);return normalizeDescriptor(n)},isAnyObj=e=>typeof e==`object`&&!!e,isValidKey=e=>{let t=typeof e;return t===`string`||t===`symbol`||t===`number`},normalizeDescriptor=e=>{if(!isPlainObject(e))throw TypeError(`Descriptor must be a plain object: ${e}`);let{enumerable:n,writable:r,configurable:i,value:a,get:o,set:s,...c}=e,l=`value`in e;return validateDescriptor({enumerable:n,writable:r,configurable:i,get:o,set:s,unknownProps:c,hasValue:l}),{enumerable:n,writable:r,configurable:i,value:a,get:o,set:s,hasValue:l}},validateDescriptor=({enumerable:e,writable:t,configurable:n,get:r,set:i,unknownProps:a,hasValue:o})=>{validateGetSet(o,r,`get`),validateGetSet(o,i,`set`),validateBoolean(e,`enumerable`),validateBoolean(t,`writable`),validateBoolean(n,`configurable`),validateUnknownProps(a)},validateGetSet=(e,t,n)=>{if(validateFunction(t,n),e&&t!==void 0)throw TypeError(`Descriptor property "value" and "${n}" must not both be defined: ${t}`)},validateFunction=(e,t)=>{if(e!==void 0&&typeof e!=`function`)throw TypeError(`Descriptor property "${t}" must be a function: ${e}`)},validateBoolean=(e,t)=>{if(e!==void 0&&typeof e!=`boolean`)throw TypeError(`Descriptor property "${t}" must be a boolean: ${e}`)},validateUnknownProps=e=>{let[t]=Object.keys(e);if(t!==void 0)throw TypeError(`Unknown descriptor property "${t}": ${e[t]}`)},redefineProperty=(e,t,n)=>(setProperty(e,t,mergeDescriptors(normalizeInput(e,t,n),getCurrentDescriptor(e,t))),e),getCurrentDescriptor=(e,t)=>{let n=Object.getOwnPropertyDescriptor(e,t);if(n!==void 0)return n;let r=Object.getPrototypeOf(e);return r===null?{}:getCurrentDescriptor(r,t)},setProperty=(e,t,n)=>{try{Object.defineProperty(e,t,n)}catch{}},assignProp=(e,t,n)=>{if(n!==void 0)return setProp(e,t,n);try{delete e[t]}catch{}if(e[t]!==void 0)return setProp(e,t)},setProp=(e,t,n)=>{redefineProperty(e,t,{value:n,...getNonEnum(t)})},getNonEnum=e=>typeof e==`string`&&e.startsWith(`_`)?{enumerable:!1}:{},normalizeOptions=(e,n,r={})=>{if(validateErrorOrObject(e,`First argument`),validateErrorOrObject(n,`Second argument`),!isPlainObject(r))throw TypeError(`Options must be a plain object: ${r}`);let{soft:i=!1}=r;if(typeof i!=`boolean`)throw TypeError(`Option "soft" must be a boolean: ${i}`);return{soft:i}},validateErrorOrObject=(e,t)=>{if(e===void 0)throw TypeError(`${t} is required.`);if(!isErrorOrObject(e))throw TypeError(`${t} must be a plain object or an error: ${e}`)},isErrorOrObject=n=>isPlainObject(n)||isErrorInstance(n),shouldSkipProp=({error:e,props:t,propName:n,soft:r})=>isIgnoredPropName(n)||!isEnum.call(t,n)||r&&e[n]!==void 0,isIgnoredPropName=e=>e in CHECK_ERROR||IGNORED_PROPS.has(e),CHECK_ERROR=Error(`check`),IGNORED_PROPS=new Set([`prototype`,`errors`,`cause`]),{propertyIsEnumerable:isEnum}=Object.prototype,setErrorProps=(e,t,n)=>{let{soft:r}=normalizeOptions(e,t,n);for(let n of Reflect.ownKeys(t))setErrorProp({error:e,props:t,propName:n,soft:r});return e},setErrorProp=({error:e,props:t,propName:n,soft:r})=>{shouldSkipProp({error:e,props:t,propName:n,soft:r})||assignProp(e,n,t[n])},setErrorProperty=(e,t,n)=>{Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!1,configurable:!0})},mergeAggregateCauses=(e,t)=>{e.errors!==void 0&&setErrorProperty(e,`errors`,e.errors.map(e=>t(e).error).filter(Boolean))},mergeAggregateErrors=({target:e,source:t,parent:n,child:r})=>{if(!hasErrors(e)){mergeSourceErrors(e,t);return}hasErrors(t)&&setErrorProperty(e,`errors`,[...r.errors,...n.errors])},mergeSourceErrors=(e,t)=>{t.errors!==void 0&&setErrorProperty(e,`errors`,t.errors)},hasErrors=e=>e.errors!==void 0&&e.errors.length!==0,normalizeArgs=(e,t,n=e.message)=>{if(typeof t!=`string`)throw TypeError(`newMessage must be a string: ${t}`);if(typeof n!=`string`)throw TypeError(`currentMessage must be a string: ${n}`);return n},getStack$1=({name:e,stack:t},n,r)=>r!==``&&t.includes(r)?replaceMessage({name:e,stack:t,newMessage:n,currentMessage:r}):insertMessage(e,t,n),replaceMessage=({name:e,stack:t,newMessage:n,currentMessage:r})=>{let[i,a]=getReplacers(e,n,r).find(([e])=>t.includes(e));return t.replace(i,a)},getReplacers=(e,t,n)=>[[`${e}: ${n}`,`${e}: ${t}`],[`: ${n}`,`: ${t}`],[`\n${n}`,`\n${t}`],[` ${n}`,` ${t}`],[n,t]],insertMessage=(e,t,n)=>{let r=`${e}: `,i=n.trimEnd();return t===e||t.startsWith(`${e}\n`)?t.replace(e,`${r}${i}`):t.startsWith(r)?t.replace(r,`${r}${i}\n`):`${r}${i}\n${t}`},setErrorMessage=(e,t,n)=>{let r=normalizeException(e),i=normalizeArgs(r,t,n);return setNonEnumProp(r,`message`,t),updateStack(r,t,i),r},updateStack=(e,t,n)=>{t===n||!stackIncludesMessage()||setNonEnumProp(e,`stack`,getStack$1(e,t,n))},stackIncludesMessage=()=>{let{stack:e}=Error(EXAMPLE_MESSAGE);return typeof e==`string`&&e.includes(EXAMPLE_MESSAGE)},EXAMPLE_MESSAGE=`set-error-message test message`,setNonEnumProp=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!1,writable:!0,configurable:!0})},wrapErrorMessage=(e,t,n)=>{if(typeof t!=`string`)throw TypeError(`Second argument must be a message string: ${t}`);let r=normalizeException(e);return setErrorMessage(r,getMessage(t,r.message),n)},getMessage=(e,t)=>{let n=e.trim(),r=t.trim();return n===``?r:r===``?n:concatMessages(n,r,e)},concatMessages=(e,t,n)=>e.endsWith(PREPEND_CHAR)?n.endsWith(PREPEND_NEWLINE_CHAR)?`${e}\n${t}`:`${e} ${t}`:`${t}\n${e}`,PREPEND_CHAR=`:`,PREPEND_NEWLINE_CHAR=`
2
+ `,mergeMessage=({parent:e,child:t,target:n,stackError:r})=>{let i=e.message,a=r.message;return n.message=t.message,wrapErrorMessage(n,i,a)},hasStack=(e,t)=>getStack(e)===t,getStack=e=>typeof e==`object`&&e?e.stack:void 0,mergeStack=({wrap:e,target:t,source:n,childHasStack:r})=>e===r?t:(setErrorProperty(t,`stack`,n.stack),n),getWrap=e=>{let{wrap:t,name:n}=e;return typeof t==`boolean`?(Object.hasOwn(e,`wrap`)&&delete e.wrap,t):n===`Error`},mergeErrorCause=e=>mergeError(e,[]).error,mergeError=(e,t)=>{if(t.includes(e))return{};let n=n=>mergeError(n,[...t,e]),r=getStack(e),i=normalizeException(e,{shallow:!0}),a=hasStack(i,r);mergeAggregateCauses(i,n);let{parent:o,childHasStack:s}=mergeCause(i,n);return{error:o,errorHasStack:a||s}},mergeCause=(e,t)=>{let n=getWrap(e);if(e.cause===void 0)return{parent:e,childHasStack:!1};let{error:r,errorHasStack:i}=t(e.cause);return delete e.cause,{parent:mergeChild({parent:e,child:r,childHasStack:i,wrap:n}),childHasStack:i}},mergeChild=({parent:e,child:t,childHasStack:n,wrap:r})=>{if(t===void 0)return e;let[i,a]=r?[t,e]:[e,t],o=mergeStack({wrap:r,target:i,source:a,childHasStack:n}),s=mergeMessage({parent:e,child:t,target:setErrorClass(i,i.constructor,o.name),stackError:o});return mergeAggregateErrors({target:s,source:a,parent:e,child:t}),setErrorProps(s,a,{soft:!r})};export{wrapErrorMessage as n,mergeErrorCause as t};