@chaos-maker/core 0.5.0 → 0.6.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.
package/dist/sw.mjs CHANGED
@@ -1,7 +1,7 @@
1
- var ce = Object.defineProperty;
2
- var ie = (n, e, t) => e in n ? ce(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var O = (n, e, t) => ie(n, typeof e != "symbol" ? e + "" : e, t);
4
- class de {
1
+ var pe = Object.defineProperty;
2
+ var ge = (n, e, o) => e in n ? pe(n, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : n[e] = o;
3
+ var O = (n, e, o) => ge(n, typeof e != "symbol" ? e + "" : e, o);
4
+ class he {
5
5
  constructor(e = 2e3) {
6
6
  O(this, "listeners", /* @__PURE__ */ new Map());
7
7
  O(this, "log", []);
@@ -9,12 +9,12 @@ class de {
9
9
  O(this, "ruleIds");
10
10
  this.maxLogEntries = e;
11
11
  }
12
- on(e, t) {
13
- this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(t);
12
+ on(e, o) {
13
+ this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(o);
14
14
  }
15
- off(e, t) {
16
- var o;
17
- (o = this.listeners.get(e)) == null || o.delete(t);
15
+ off(e, o) {
16
+ var t;
17
+ (t = this.listeners.get(e)) == null || t.delete(o);
18
18
  }
19
19
  emit(e) {
20
20
  this.log.push(e), this.log.length > this.maxLogEntries && this.log.shift(), this.notify(this.listeners.get(e.type), e), this.notify(this.listeners.get("*"), e);
@@ -34,10 +34,10 @@ class de {
34
34
  * and present in the rule-id map, `detail.ruleType` and `detail.ruleId`
35
35
  * are filled in automatically.
36
36
  */
37
- debug(e, t, o) {
38
- var f;
37
+ debug(e, o, t) {
38
+ var p;
39
39
  if (!this.logger) return;
40
- const s = o ? (f = this.ruleIds) == null ? void 0 : f.get(o) : void 0, p = s ? { ...t, ruleType: s.ruleType, ruleId: s.ruleId } : t, l = this.logger.log(e, p);
40
+ const s = t ? (p = this.ruleIds) == null ? void 0 : p.get(t) : void 0, i = s ? { ...o, ruleType: s.ruleType, ruleId: s.ruleId } : o, l = this.logger.log(e, i);
41
41
  l && this.emit(l);
42
42
  }
43
43
  getLog() {
@@ -46,35 +46,35 @@ class de {
46
46
  clearLog() {
47
47
  this.log = [];
48
48
  }
49
- notify(e, t) {
49
+ notify(e, o) {
50
50
  if (e)
51
- for (const o of e)
51
+ for (const t of e)
52
52
  try {
53
- o(t);
53
+ t(o);
54
54
  } catch {
55
55
  }
56
56
  }
57
57
  }
58
- function pe(n) {
58
+ function be(n) {
59
59
  let e = n | 0;
60
60
  return () => {
61
61
  e = e + 1831565813 | 0;
62
- let t = Math.imul(e ^ e >>> 15, 1 | e);
63
- return t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t, ((t ^ t >>> 14) >>> 0) / 4294967296;
62
+ let o = Math.imul(e ^ e >>> 15, 1 | e);
63
+ return o = o + Math.imul(o ^ o >>> 7, 61 | o) ^ o, ((o ^ o >>> 14) >>> 0) / 4294967296;
64
64
  };
65
65
  }
66
- function fe() {
66
+ function ye() {
67
67
  return Math.random() * 4294967296 >>> 0;
68
68
  }
69
- function re(n) {
70
- const e = n ?? fe();
69
+ function ue(n) {
70
+ const e = n ?? ye();
71
71
  return {
72
- random: pe(e),
72
+ random: be(e),
73
73
  seed: e
74
74
  };
75
75
  }
76
- const z = "default";
77
- class se {
76
+ const J = "default";
77
+ class le {
78
78
  constructor() {
79
79
  O(this, "groups", /* @__PURE__ */ new Map());
80
80
  /**
@@ -93,19 +93,19 @@ class se {
93
93
  * When called with both `explicit: true` and `enabled` set, the existing
94
94
  * group's `enabled` is overwritten; the explicit form is the source of truth.
95
95
  */
96
- ensure(e, t) {
97
- const o = this.groups.get(e);
98
- if (o)
99
- return t != null && t.explicit && (o.explicit = !0), (t == null ? void 0 : t.enabled) !== void 0 && (o.enabled = t.enabled), o;
96
+ ensure(e, o) {
97
+ const t = this.groups.get(e);
98
+ if (t)
99
+ return o != null && o.explicit && (t.explicit = !0), (o == null ? void 0 : o.enabled) !== void 0 && (t.enabled = o.enabled), t;
100
100
  const s = {
101
101
  name: e,
102
- enabled: (t == null ? void 0 : t.enabled) ?? !0,
103
- explicit: (t == null ? void 0 : t.explicit) ?? !1
102
+ enabled: (o == null ? void 0 : o.enabled) ?? !0,
103
+ explicit: (o == null ? void 0 : o.explicit) ?? !1
104
104
  };
105
105
  return this.groups.set(e, s), s;
106
106
  }
107
- setEnabled(e, t) {
108
- this.ensure(e).enabled = t, this.gatedEmitted.clear();
107
+ setEnabled(e, o) {
108
+ this.ensure(e).enabled = o, this.gatedEmitted.clear();
109
109
  }
110
110
  /**
111
111
  * Auto-creates unknown groups on first check (implicit). Rationale:
@@ -115,7 +115,7 @@ class se {
115
115
  * backward compat.
116
116
  */
117
117
  isActive(e) {
118
- return this.ensure(e ?? z).enabled;
118
+ return this.ensure(e ?? J).enabled;
119
119
  }
120
120
  /** True when this group should emit a `rule-group:gated` event right now (first block since last toggle). */
121
121
  shouldEmitGated(e) {
@@ -131,9 +131,9 @@ class se {
131
131
  * - Pass `{ force: true }` to remove anyway. Subsequent `isActive(name)`
132
132
  * calls auto-recreate the group (default-on).
133
133
  */
134
- remove(e, t, o) {
135
- if (e === z) return !1;
136
- if (!(o != null && o.force) && t.has(e))
134
+ remove(e, o, t) {
135
+ if (e === J) return !1;
136
+ if (!(t != null && t.force) && o.has(e))
137
137
  throw new Error(
138
138
  `[chaos-maker] Cannot remove group '${e}': still referenced by one or more rules. Pass { force: true } to override.`
139
139
  );
@@ -147,24 +147,24 @@ class se {
147
147
  }
148
148
  getSnapshot() {
149
149
  const e = {};
150
- for (const t of this.groups.values()) e[t.name] = t.enabled;
150
+ for (const o of this.groups.values()) e[o.name] = o.enabled;
151
151
  return e;
152
152
  }
153
153
  }
154
- function $(n, e) {
154
+ function I(n, e) {
155
155
  return e() < n;
156
156
  }
157
- function q(n, e) {
158
- const t = (e.get(n) ?? 0) + 1;
159
- return e.set(n, t), t;
160
- }
161
157
  function P(n, e) {
158
+ const o = (e.get(n) ?? 0) + 1;
159
+ return e.set(n, o), o;
160
+ }
161
+ function $(n, e) {
162
162
  return n.onNth !== void 0 ? e === n.onNth : n.everyNth !== void 0 ? e % n.everyNth === 0 : n.afterN !== void 0 ? e > n.afterN : !0;
163
163
  }
164
164
  function Z(n, e) {
165
165
  return e === "*" ? !0 : n.includes(e);
166
166
  }
167
- function ge(n, e) {
167
+ function ke(n, e) {
168
168
  switch (e) {
169
169
  case "truncate":
170
170
  return n.slice(0, Math.max(0, Math.floor(n.length / 2)));
@@ -176,125 +176,125 @@ function ge(n, e) {
176
176
  return "<html><body>Unexpected HTML</body></html>";
177
177
  }
178
178
  }
179
- function G(n, e, t, o) {
179
+ function q(n, e, o, t) {
180
180
  if (!e || e.isActive(n.group)) return !0;
181
- const s = n.group ?? z;
182
- return e.shouldEmitGated(s) && t && t.emit({
181
+ const s = n.group ?? J;
182
+ return e.shouldEmitGated(s) && o && o.emit({
183
183
  type: "rule-group:gated",
184
184
  timestamp: Date.now(),
185
185
  applied: !1,
186
- detail: { ...o, groupName: s }
187
- }), t == null || t.debug("rule-skip-group", { ...o, groupName: s }, n), !1;
186
+ detail: { ...t, groupName: s }
187
+ }), o == null || o.debug("rule-skip-group", { ...t, groupName: s }, n), !1;
188
188
  }
189
- function he(n, e) {
190
- var o, s, p, l, f, u, a, E, x, M, L, A, S, d;
191
- const t = (c) => {
189
+ function we(n, e) {
190
+ var t, s, i, l, p, u, a, S, A, M, L, N, T, f;
191
+ const o = (c) => {
192
192
  if (c)
193
- for (const i of c) e(i);
193
+ for (const d of c) e(d);
194
194
  };
195
- t((o = n.network) == null ? void 0 : o.failures), t((s = n.network) == null ? void 0 : s.latencies), t((p = n.network) == null ? void 0 : p.aborts), t((l = n.network) == null ? void 0 : l.corruptions), t((f = n.network) == null ? void 0 : f.cors), t((u = n.ui) == null ? void 0 : u.assaults), t((a = n.websocket) == null ? void 0 : a.drops), t((E = n.websocket) == null ? void 0 : E.delays), t((x = n.websocket) == null ? void 0 : x.corruptions), t((M = n.websocket) == null ? void 0 : M.closes), t((L = n.sse) == null ? void 0 : L.drops), t((A = n.sse) == null ? void 0 : A.delays), t((S = n.sse) == null ? void 0 : S.corruptions), t((d = n.sse) == null ? void 0 : d.closes);
195
+ o((t = n.network) == null ? void 0 : t.failures), o((s = n.network) == null ? void 0 : s.latencies), o((i = n.network) == null ? void 0 : i.aborts), o((l = n.network) == null ? void 0 : l.corruptions), o((p = n.network) == null ? void 0 : p.cors), o((u = n.ui) == null ? void 0 : u.assaults), o((a = n.websocket) == null ? void 0 : a.drops), o((S = n.websocket) == null ? void 0 : S.delays), o((A = n.websocket) == null ? void 0 : A.corruptions), o((M = n.websocket) == null ? void 0 : M.closes), o((L = n.sse) == null ? void 0 : L.drops), o((N = n.sse) == null ? void 0 : N.delays), o((T = n.sse) == null ? void 0 : T.corruptions), o((f = n.sse) == null ? void 0 : f.closes);
196
196
  }
197
- function ae(n) {
198
- const e = n.replace(/#[^\r\n]*/g, " "), t = /\b(?:query|mutation|subscription)\s+([A-Za-z_][A-Za-z0-9_]*)/.exec(e);
199
- return (t == null ? void 0 : t[1]) ?? null;
197
+ function ce(n) {
198
+ const e = n.replace(/#[^\r\n]*/g, " "), o = /\b(?:query|mutation|subscription)\s+([A-Za-z_][A-Za-z0-9_]*)/.exec(e);
199
+ return (o == null ? void 0 : o[1]) ?? null;
200
200
  }
201
- function be(n) {
201
+ function Me(n) {
202
202
  try {
203
203
  return JSON.parse(n);
204
204
  } catch {
205
205
  return;
206
206
  }
207
207
  }
208
- function ue(n) {
208
+ function ie(n) {
209
209
  if (!n || typeof n != "object") return { isGraphQL: !1, operationName: null };
210
210
  if (Array.isArray(n))
211
- return n.length === 0 ? { isGraphQL: !1, operationName: null } : ue(n[0]);
212
- const e = n, t = typeof e.query == "string", o = typeof e.operationName == "string";
213
- return !t && !o ? { isGraphQL: !1, operationName: null } : o && e.operationName.length > 0 ? { isGraphQL: !0, operationName: e.operationName } : t ? { isGraphQL: !0, operationName: ae(e.query) } : { isGraphQL: !0, operationName: null };
211
+ return n.length === 0 ? { isGraphQL: !1, operationName: null } : ie(n[0]);
212
+ const e = n, o = typeof e.query == "string", t = typeof e.operationName == "string";
213
+ return !o && !t ? { isGraphQL: !1, operationName: null } : t && e.operationName.length > 0 ? { isGraphQL: !0, operationName: e.operationName } : o ? { isGraphQL: !0, operationName: ce(e.query) } : { isGraphQL: !0, operationName: null };
214
214
  }
215
- function ye(n) {
215
+ function ve(n) {
216
216
  let e;
217
217
  try {
218
218
  e = new URL(n, "http://_chaos-maker.invalid");
219
219
  } catch {
220
220
  return { kind: "not-graphql" };
221
221
  }
222
- const t = e.searchParams.get("operationName"), o = e.searchParams.get("query");
223
- return t && t.length > 0 ? { kind: "extracted", operationName: t } : o && o.length > 0 ? { kind: "extracted", operationName: ae(o) } : { kind: "not-graphql" };
222
+ const o = e.searchParams.get("operationName"), t = e.searchParams.get("query");
223
+ return o && o.length > 0 ? { kind: "extracted", operationName: o } : t && t.length > 0 ? { kind: "extracted", operationName: ce(t) } : { kind: "not-graphql" };
224
224
  }
225
- function ke(n, e, t, o) {
225
+ function Ce(n, e, o, t) {
226
226
  const s = n.toUpperCase();
227
227
  if (s === "POST") {
228
- if (t !== null) {
229
- const p = be(t);
230
- if (p === void 0) return { kind: "not-graphql" };
231
- const { isGraphQL: l, operationName: f } = ue(p);
232
- return l ? { kind: "extracted", operationName: f } : { kind: "not-graphql" };
228
+ if (o !== null) {
229
+ const i = Me(o);
230
+ if (i === void 0) return { kind: "not-graphql" };
231
+ const { isGraphQL: l, operationName: p } = ie(i);
232
+ return l ? { kind: "extracted", operationName: p } : { kind: "not-graphql" };
233
233
  }
234
- return o ? { kind: "unparseable" } : { kind: "not-graphql" };
234
+ return t ? { kind: "unparseable" } : { kind: "not-graphql" };
235
235
  }
236
- return s === "GET" ? ye(e) : { kind: "not-graphql" };
236
+ return s === "GET" ? ve(e) : { kind: "not-graphql" };
237
237
  }
238
- function we(n, e) {
238
+ function Se(n, e) {
239
239
  return e === null ? !1 : typeof n == "string" ? n === e : ((n.global || n.sticky) && (n.lastIndex = 0), n.test(e));
240
240
  }
241
- function Me(n, e) {
242
- return n ? e.kind === "not-graphql" ? { kind: "no-match" } : e.kind === "unparseable" ? { kind: "unparseable" } : we(n, e.operationName) ? { kind: "match", operationName: e.operationName } : { kind: "no-match" } : e.kind === "extracted" ? { kind: "skip-no-constraint", operationName: e.operationName } : { kind: "skip-no-constraint", operationName: null };
241
+ function Te(n, e) {
242
+ return n ? e.kind === "not-graphql" ? { kind: "no-match" } : e.kind === "unparseable" ? { kind: "unparseable" } : Se(n, e.operationName) ? { kind: "match", operationName: e.operationName } : { kind: "no-match" } : e.kind === "extracted" ? { kind: "skip-no-constraint", operationName: e.operationName } : { kind: "skip-no-constraint", operationName: null };
243
243
  }
244
- function J(n) {
244
+ function K(n) {
245
245
  return typeof Request < "u" && n instanceof Request;
246
246
  }
247
- function ve(n) {
248
- return J(n) ? n.url : n.toString();
247
+ function Ee(n) {
248
+ return K(n) ? n.url : n.toString();
249
249
  }
250
- function Ce(n, e) {
251
- return e != null && e.method ? e.method.toUpperCase() : J(n) ? n.method.toUpperCase() : "GET";
250
+ function Le(n, e) {
251
+ return e != null && e.method ? e.method.toUpperCase() : K(n) ? n.method.toUpperCase() : "GET";
252
252
  }
253
- function Ee(n, e) {
253
+ function Ae(n, e) {
254
254
  if (e != null && e.signal)
255
255
  return e.signal;
256
- if (J(n))
256
+ if (K(n))
257
257
  return n.signal;
258
258
  }
259
- function Se() {
259
+ function Ne() {
260
260
  if (typeof DOMException < "u")
261
261
  return new DOMException("The user aborted a request.", "AbortError");
262
262
  const n = new Error("The user aborted a request.");
263
263
  return n.name = "AbortError", n;
264
264
  }
265
- function Te(n, e) {
265
+ function xe(n, e) {
266
266
  if (!e)
267
267
  return n;
268
- const t = new AbortController(), o = (f) => {
269
- l(), t.signal.aborted || t.abort(f.reason);
270
- }, s = () => o(n), p = () => o(e), l = () => {
271
- n.removeEventListener("abort", s), e.removeEventListener("abort", p);
268
+ const o = new AbortController(), t = (p) => {
269
+ l(), o.signal.aborted || o.abort(p.reason);
270
+ }, s = () => t(n), i = () => t(e), l = () => {
271
+ n.removeEventListener("abort", s), e.removeEventListener("abort", i);
272
272
  };
273
- return n.aborted ? (o(n), t.signal) : e.aborted ? (o(e), t.signal) : (n.addEventListener("abort", s, { once: !0 }), e.addEventListener("abort", p, { once: !0 }), t.signal);
273
+ return n.aborted ? (t(n), o.signal) : e.aborted ? (t(e), o.signal) : (n.addEventListener("abort", s, { once: !0 }), e.addEventListener("abort", i, { once: !0 }), o.signal);
274
274
  }
275
- function Le(n, e) {
275
+ function _e(n, e) {
276
276
  return e ? {
277
277
  ...n ?? {},
278
278
  signal: e
279
279
  } : n;
280
280
  }
281
- async function xe(n, e) {
282
- const t = e == null ? void 0 : e.body;
283
- if (t != null) {
284
- if (typeof t == "string") return { text: t, unparseable: !1 };
285
- if (typeof URLSearchParams < "u" && t instanceof URLSearchParams)
286
- return { text: t.toString(), unparseable: !1 };
287
- if (typeof Blob < "u" && t instanceof Blob) {
288
- if (!(t.type === "" || /json|text|graphql/i.test(t.type))) return { text: null, unparseable: !0 };
281
+ async function Re(n, e) {
282
+ const o = e == null ? void 0 : e.body;
283
+ if (o != null) {
284
+ if (typeof o == "string") return { text: o, unparseable: !1 };
285
+ if (typeof URLSearchParams < "u" && o instanceof URLSearchParams)
286
+ return { text: o.toString(), unparseable: !1 };
287
+ if (typeof Blob < "u" && o instanceof Blob) {
288
+ if (!(o.type === "" || /json|text|graphql/i.test(o.type))) return { text: null, unparseable: !0 };
289
289
  try {
290
- return { text: await t.text(), unparseable: !1 };
290
+ return { text: await o.text(), unparseable: !1 };
291
291
  } catch {
292
292
  return { text: null, unparseable: !0 };
293
293
  }
294
294
  }
295
295
  return { text: null, unparseable: !0 };
296
296
  }
297
- if (J(n)) {
297
+ if (K(n)) {
298
298
  if (n.body === null) return { text: null, unparseable: !1 };
299
299
  try {
300
300
  return { text: await n.clone().text(), unparseable: !1 };
@@ -304,258 +304,258 @@ async function xe(n, e) {
304
304
  }
305
305
  return { text: null, unparseable: !1 };
306
306
  }
307
- function U(n, e, t, o, s) {
307
+ function U(n, e, o, t, s) {
308
308
  n == null || n.emit({
309
309
  type: e,
310
310
  timestamp: Date.now(),
311
311
  applied: !1,
312
- detail: { url: t, method: o, ...s, reason: "graphql-body-unparseable" }
312
+ detail: { url: o, method: t, ...s, reason: "graphql-body-unparseable" }
313
313
  });
314
314
  }
315
- function B(n, e, t, o) {
315
+ function W(n, e, o, t) {
316
316
  if (!Z(e, n.urlPattern)) return { proceed: !1, outcome: null };
317
- if (n.methods && !n.methods.includes(t)) return { proceed: !1, outcome: null };
318
- const s = Me(n.graphqlOperation, o);
317
+ if (n.methods && !n.methods.includes(o)) return { proceed: !1, outcome: null };
318
+ const s = Te(n.graphqlOperation, t);
319
319
  return s.kind === "no-match" ? { proceed: !1, outcome: s } : { proceed: !0, outcome: s };
320
320
  }
321
- function W(n) {
321
+ function B(n) {
322
322
  return n ? n.kind === "match" || n.kind === "skip-no-constraint" ? n.operationName ? { operationName: n.operationName } : {} : {} : {};
323
323
  }
324
- function V(n, e, t, o, s, p) {
324
+ function m(n, e, o, t, s, i) {
325
325
  n == null || n.emit({
326
326
  type: "network:abort",
327
327
  timestamp: Date.now(),
328
328
  applied: s,
329
- detail: { url: t, method: o, timeoutMs: e.timeout, ...W(p) }
329
+ detail: { url: o, method: t, timeoutMs: e.timeout, ...B(i) }
330
330
  });
331
331
  }
332
- function Q(n, e, t, o, s, p) {
332
+ function Q(n, e, o, t, s, i) {
333
333
  n == null || n.emit({
334
334
  type: "network:corruption",
335
335
  timestamp: Date.now(),
336
336
  applied: s,
337
- detail: { url: t, method: o, strategy: e.strategy, ...W(p) }
337
+ detail: { url: o, method: t, strategy: e.strategy, ...B(i) }
338
338
  });
339
339
  }
340
- function Ae(n) {
340
+ function Oe(n) {
341
341
  return n.graphqlOperation !== void 0;
342
342
  }
343
- function Ne(n, e, t, o, s = /* @__PURE__ */ new Map(), p) {
344
- return async (l, f) => {
345
- var k, w, C, T, R;
346
- const u = ve(l), a = Ce(l, f), E = Ee(l, f), x = (() => {
343
+ function Ie(n, e, o, t, s = /* @__PURE__ */ new Map(), i) {
344
+ return async (l, p) => {
345
+ var k, w, C, E, R;
346
+ const u = Ee(l), a = Le(l, p), S = Ae(l, p), A = (() => {
347
347
  const r = [e.failures, e.latencies, e.aborts, e.corruptions, e.cors];
348
348
  for (const b of r)
349
- if (b != null && b.some(Ae)) return !0;
349
+ if (b != null && b.some(Oe)) return !0;
350
350
  return !1;
351
351
  })();
352
352
  let M = { kind: "not-graphql" };
353
- if (x) {
354
- const r = await xe(l, f);
355
- M = ke(a, u, r.text, r.unparseable);
353
+ if (A) {
354
+ const r = await Re(l, p);
355
+ M = Ce(a, u, r.text, r.unparseable);
356
356
  }
357
357
  if (e.cors)
358
358
  for (const r of e.cors) {
359
- o == null || o.debug("rule-evaluating", { url: u, method: a }, r);
360
- const b = B(r, u, a, M);
359
+ t == null || t.debug("rule-evaluating", { url: u, method: a }, r);
360
+ const b = W(r, u, a, M);
361
361
  if (!b.proceed) {
362
- o == null || o.debug("rule-skip-match", { url: u, method: a }, r);
362
+ t == null || t.debug("rule-skip-match", { url: u, method: a }, r);
363
363
  continue;
364
364
  }
365
- o == null || o.debug("rule-matched", { url: u, method: a }, r);
366
- const N = q(r, s);
367
- if (!P(r, N)) {
368
- o == null || o.debug("rule-skip-counting", { url: u, method: a }, r);
365
+ t == null || t.debug("rule-matched", { url: u, method: a }, r);
366
+ const x = P(r, s);
367
+ if (!$(r, x)) {
368
+ t == null || t.debug("rule-skip-counting", { url: u, method: a }, r);
369
369
  continue;
370
370
  }
371
- if (!G(r, p, o, { url: u, method: a })) continue;
372
- const v = $(r.probability, t);
371
+ if (!q(r, i, t, { url: u, method: a })) continue;
372
+ const v = I(r.probability, o);
373
373
  if (((k = b.outcome) == null ? void 0 : k.kind) === "unparseable") {
374
- v && U(o, "network:cors", u, a, {});
374
+ v && U(t, "network:cors", u, a, {});
375
375
  continue;
376
376
  }
377
- if (o == null || o.emit({
377
+ if (t == null || t.emit({
378
378
  type: "network:cors",
379
379
  timestamp: Date.now(),
380
380
  applied: v,
381
- detail: { url: u, method: a, ...W(b.outcome) }
381
+ detail: { url: u, method: a, ...B(b.outcome) }
382
382
  }), !v) {
383
- o == null || o.debug("rule-skip-probability", { url: u, method: a }, r);
383
+ t == null || t.debug("rule-skip-probability", { url: u, method: a }, r);
384
384
  continue;
385
385
  }
386
- o == null || o.debug("rule-applied", { url: u, method: a }, r);
386
+ t == null || t.debug("rule-applied", { url: u, method: a }, r);
387
387
  const _ = new TypeError("Failed to fetch");
388
388
  throw _.stack = "", _;
389
389
  }
390
- let L = null, A = null, S, d, c = !1;
391
- const i = (r) => {
392
- !L || c || (c = !0, d && (clearTimeout(d), d = void 0), V(o, L, u, a, r, A));
390
+ let L = null, N = null, T, f, c = !1;
391
+ const d = (r) => {
392
+ !L || c || (c = !0, f && (clearTimeout(f), f = void 0), m(t, L, u, a, r, N));
393
393
  };
394
394
  if (e.aborts)
395
395
  for (const r of e.aborts) {
396
- o == null || o.debug("rule-evaluating", { url: u, method: a, timeoutMs: r.timeout }, r);
397
- const b = B(r, u, a, M);
396
+ t == null || t.debug("rule-evaluating", { url: u, method: a, timeoutMs: r.timeout }, r);
397
+ const b = W(r, u, a, M);
398
398
  if (!b.proceed) {
399
- o == null || o.debug("rule-skip-match", { url: u, method: a, timeoutMs: r.timeout }, r);
399
+ t == null || t.debug("rule-skip-match", { url: u, method: a, timeoutMs: r.timeout }, r);
400
400
  continue;
401
401
  }
402
- o == null || o.debug("rule-matched", { url: u, method: a, timeoutMs: r.timeout }, r);
403
- const N = q(r, s);
404
- if (!P(r, N)) {
405
- o == null || o.debug("rule-skip-counting", { url: u, method: a, timeoutMs: r.timeout }, r);
402
+ t == null || t.debug("rule-matched", { url: u, method: a, timeoutMs: r.timeout }, r);
403
+ const x = P(r, s);
404
+ if (!$(r, x)) {
405
+ t == null || t.debug("rule-skip-counting", { url: u, method: a, timeoutMs: r.timeout }, r);
406
406
  continue;
407
407
  }
408
- if (!G(r, p, o, { url: u, method: a, timeoutMs: r.timeout })) continue;
409
- const v = $(r.probability, t);
408
+ if (!q(r, i, t, { url: u, method: a, timeoutMs: r.timeout })) continue;
409
+ const v = I(r.probability, o);
410
410
  if (((w = b.outcome) == null ? void 0 : w.kind) === "unparseable") {
411
- v && U(o, "network:abort", u, a, { timeoutMs: r.timeout });
411
+ v && U(t, "network:abort", u, a, { timeoutMs: r.timeout });
412
412
  continue;
413
413
  }
414
414
  if (!v) {
415
- o == null || o.debug("rule-skip-probability", { url: u, method: a, timeoutMs: r.timeout }, r), V(o, r, u, a, !1, b.outcome);
415
+ t == null || t.debug("rule-skip-probability", { url: u, method: a, timeoutMs: r.timeout }, r), m(t, r, u, a, !1, b.outcome);
416
416
  continue;
417
417
  }
418
- o == null || o.debug("rule-applied", { url: u, method: a, timeoutMs: r.timeout }, r), console.warn(`CHAOS: Aborting ${a} ${u} after ${r.timeout || 0}ms`), L = r, A = b.outcome;
418
+ t == null || t.debug("rule-applied", { url: u, method: a, timeoutMs: r.timeout }, r), console.warn(`CHAOS: Aborting ${a} ${u} after ${r.timeout || 0}ms`), L = r, N = b.outcome;
419
419
  const _ = new AbortController();
420
- S = Te(_.signal, E);
421
- const H = () => {
422
- c || (i(!0), _.abort(Se()));
420
+ T = xe(_.signal, S);
421
+ const j = () => {
422
+ c || (d(!0), _.abort(Ne()));
423
423
  };
424
- r.timeout ? d = setTimeout(H, r.timeout) : H();
424
+ r.timeout ? f = setTimeout(j, r.timeout) : j();
425
425
  break;
426
426
  }
427
427
  if (L)
428
428
  try {
429
- const r = await n(l, Le(f, S));
430
- return i(!1), r;
429
+ const r = await n(l, _e(p, T));
430
+ return d(!1), r;
431
431
  } catch (r) {
432
- throw i(!1), r;
432
+ throw d(!1), r;
433
433
  }
434
434
  if (e.failures)
435
435
  for (const r of e.failures) {
436
- o == null || o.debug("rule-evaluating", { url: u, method: a, statusCode: r.statusCode }, r);
437
- const b = B(r, u, a, M);
436
+ t == null || t.debug("rule-evaluating", { url: u, method: a, statusCode: r.statusCode }, r);
437
+ const b = W(r, u, a, M);
438
438
  if (!b.proceed) {
439
- o == null || o.debug("rule-skip-match", { url: u, method: a, statusCode: r.statusCode }, r);
439
+ t == null || t.debug("rule-skip-match", { url: u, method: a, statusCode: r.statusCode }, r);
440
440
  continue;
441
441
  }
442
- o == null || o.debug("rule-matched", { url: u, method: a, statusCode: r.statusCode }, r);
443
- const N = q(r, s);
444
- if (!P(r, N)) {
445
- o == null || o.debug("rule-skip-counting", { url: u, method: a, statusCode: r.statusCode }, r);
442
+ t == null || t.debug("rule-matched", { url: u, method: a, statusCode: r.statusCode }, r);
443
+ const x = P(r, s);
444
+ if (!$(r, x)) {
445
+ t == null || t.debug("rule-skip-counting", { url: u, method: a, statusCode: r.statusCode }, r);
446
446
  continue;
447
447
  }
448
- if (!G(r, p, o, { url: u, method: a, statusCode: r.statusCode })) continue;
449
- const v = $(r.probability, t);
448
+ if (!q(r, i, t, { url: u, method: a, statusCode: r.statusCode })) continue;
449
+ const v = I(r.probability, o);
450
450
  if (((C = b.outcome) == null ? void 0 : C.kind) === "unparseable") {
451
- v && U(o, "network:failure", u, a, { statusCode: r.statusCode });
451
+ v && U(t, "network:failure", u, a, { statusCode: r.statusCode });
452
452
  continue;
453
453
  }
454
- if (o == null || o.emit({
454
+ if (t == null || t.emit({
455
455
  type: "network:failure",
456
456
  timestamp: Date.now(),
457
457
  applied: v,
458
- detail: { url: u, method: a, statusCode: r.statusCode, ...W(b.outcome) }
458
+ detail: { url: u, method: a, statusCode: r.statusCode, ...B(b.outcome) }
459
459
  }), !v) {
460
- o == null || o.debug("rule-skip-probability", { url: u, method: a, statusCode: r.statusCode }, r);
460
+ t == null || t.debug("rule-skip-probability", { url: u, method: a, statusCode: r.statusCode }, r);
461
461
  continue;
462
462
  }
463
- o == null || o.debug("rule-applied", { url: u, method: a, statusCode: r.statusCode }, r), console.warn(`CHAOS: Forcing ${r.statusCode} for ${a} ${u}`);
464
- const _ = r.body ?? JSON.stringify({ error: "Chaos Maker Attack!" }), H = r.headers ?? {};
463
+ t == null || t.debug("rule-applied", { url: u, method: a, statusCode: r.statusCode }, r), console.warn(`CHAOS: Forcing ${r.statusCode} for ${a} ${u}`);
464
+ const _ = r.body ?? JSON.stringify({ error: "Chaos Maker Attack!" }), j = r.headers ?? {};
465
465
  return new Response(_, {
466
466
  status: r.statusCode,
467
467
  statusText: r.statusText ?? "Service Unavailable (Chaos)",
468
- headers: H
468
+ headers: j
469
469
  });
470
470
  }
471
471
  if (e.latencies)
472
472
  for (const r of e.latencies) {
473
- o == null || o.debug("rule-evaluating", { url: u, method: a, delayMs: r.delayMs }, r);
474
- const b = B(r, u, a, M);
473
+ t == null || t.debug("rule-evaluating", { url: u, method: a, delayMs: r.delayMs }, r);
474
+ const b = W(r, u, a, M);
475
475
  if (!b.proceed) {
476
- o == null || o.debug("rule-skip-match", { url: u, method: a, delayMs: r.delayMs }, r);
476
+ t == null || t.debug("rule-skip-match", { url: u, method: a, delayMs: r.delayMs }, r);
477
477
  continue;
478
478
  }
479
- o == null || o.debug("rule-matched", { url: u, method: a, delayMs: r.delayMs }, r);
480
- const N = q(r, s);
481
- if (!P(r, N)) {
482
- o == null || o.debug("rule-skip-counting", { url: u, method: a, delayMs: r.delayMs }, r);
479
+ t == null || t.debug("rule-matched", { url: u, method: a, delayMs: r.delayMs }, r);
480
+ const x = P(r, s);
481
+ if (!$(r, x)) {
482
+ t == null || t.debug("rule-skip-counting", { url: u, method: a, delayMs: r.delayMs }, r);
483
483
  continue;
484
484
  }
485
- if (!G(r, p, o, { url: u, method: a, delayMs: r.delayMs })) continue;
486
- const v = $(r.probability, t);
487
- if (((T = b.outcome) == null ? void 0 : T.kind) === "unparseable") {
488
- v && U(o, "network:latency", u, a, { delayMs: r.delayMs });
485
+ if (!q(r, i, t, { url: u, method: a, delayMs: r.delayMs })) continue;
486
+ const v = I(r.probability, o);
487
+ if (((E = b.outcome) == null ? void 0 : E.kind) === "unparseable") {
488
+ v && U(t, "network:latency", u, a, { delayMs: r.delayMs });
489
489
  continue;
490
490
  }
491
- if (o == null || o.emit({
491
+ if (t == null || t.emit({
492
492
  type: "network:latency",
493
493
  timestamp: Date.now(),
494
494
  applied: v,
495
- detail: { url: u, method: a, delayMs: r.delayMs, ...W(b.outcome) }
495
+ detail: { url: u, method: a, delayMs: r.delayMs, ...B(b.outcome) }
496
496
  }), !v) {
497
- o == null || o.debug("rule-skip-probability", { url: u, method: a, delayMs: r.delayMs }, r);
497
+ t == null || t.debug("rule-skip-probability", { url: u, method: a, delayMs: r.delayMs }, r);
498
498
  continue;
499
499
  }
500
- o == null || o.debug("rule-applied", { url: u, method: a, delayMs: r.delayMs }, r), console.warn(`CHAOS: Adding ${r.delayMs}ms latency to ${a} ${u}`), await new Promise((_) => setTimeout(_, r.delayMs));
500
+ t == null || t.debug("rule-applied", { url: u, method: a, delayMs: r.delayMs }, r), console.warn(`CHAOS: Adding ${r.delayMs}ms latency to ${a} ${u}`), await new Promise((_) => setTimeout(_, r.delayMs));
501
501
  }
502
502
  let g = null, h = null;
503
503
  if (e.corruptions)
504
504
  for (const r of e.corruptions) {
505
- o == null || o.debug("rule-evaluating", { url: u, method: a, strategy: r.strategy }, r);
506
- const b = B(r, u, a, M);
505
+ t == null || t.debug("rule-evaluating", { url: u, method: a, strategy: r.strategy }, r);
506
+ const b = W(r, u, a, M);
507
507
  if (!b.proceed) {
508
- o == null || o.debug("rule-skip-match", { url: u, method: a, strategy: r.strategy }, r);
508
+ t == null || t.debug("rule-skip-match", { url: u, method: a, strategy: r.strategy }, r);
509
509
  continue;
510
510
  }
511
- o == null || o.debug("rule-matched", { url: u, method: a, strategy: r.strategy }, r);
512
- const N = q(r, s);
513
- if (!P(r, N)) {
514
- o == null || o.debug("rule-skip-counting", { url: u, method: a, strategy: r.strategy }, r);
511
+ t == null || t.debug("rule-matched", { url: u, method: a, strategy: r.strategy }, r);
512
+ const x = P(r, s);
513
+ if (!$(r, x)) {
514
+ t == null || t.debug("rule-skip-counting", { url: u, method: a, strategy: r.strategy }, r);
515
515
  continue;
516
516
  }
517
- if (!G(r, p, o, { url: u, method: a, strategy: r.strategy })) continue;
518
- const v = $(r.probability, t);
517
+ if (!q(r, i, t, { url: u, method: a, strategy: r.strategy })) continue;
518
+ const v = I(r.probability, o);
519
519
  if (((R = b.outcome) == null ? void 0 : R.kind) === "unparseable") {
520
- v && U(o, "network:corruption", u, a, { strategy: r.strategy });
520
+ v && U(t, "network:corruption", u, a, { strategy: r.strategy });
521
521
  continue;
522
522
  }
523
523
  if (!v) {
524
- o == null || o.debug("rule-skip-probability", { url: u, method: a, strategy: r.strategy }, r), Q(o, r, u, a, !1, b.outcome);
524
+ t == null || t.debug("rule-skip-probability", { url: u, method: a, strategy: r.strategy }, r), Q(t, r, u, a, !1, b.outcome);
525
525
  continue;
526
526
  }
527
- o == null || o.debug("rule-applied", { url: u, method: a, strategy: r.strategy }, r), g = r, h = b.outcome;
527
+ t == null || t.debug("rule-applied", { url: u, method: a, strategy: r.strategy }, r), g = r, h = b.outcome;
528
528
  break;
529
529
  }
530
530
  let y;
531
531
  try {
532
- y = await n(l, f);
532
+ y = await n(l, p);
533
533
  } catch (r) {
534
- throw g && Q(o, g, u, a, !1, h), r;
534
+ throw g && Q(t, g, u, a, !1, h), r;
535
535
  }
536
536
  if (!g)
537
537
  return y;
538
538
  try {
539
539
  console.warn(`CHAOS: Corrupting response for ${a} ${u} with strategy: ${g.strategy}`);
540
- const r = await y.text(), b = ge(r, g.strategy);
541
- return Q(o, g, u, a, !0, h), new Response(b, {
540
+ const r = await y.text(), b = ke(r, g.strategy);
541
+ return Q(t, g, u, a, !0, h), new Response(b, {
542
542
  status: y.status,
543
543
  statusText: y.statusText,
544
544
  headers: y.headers
545
545
  });
546
546
  } catch (r) {
547
- throw Q(o, g, u, a, !1, h), r;
547
+ throw Q(t, g, u, a, !1, h), r;
548
548
  }
549
549
  };
550
550
  }
551
551
  const X = /* @__PURE__ */ Symbol.for("chaos-maker.websocket.intercepted");
552
- function _e(n, e) {
552
+ function Pe(n, e) {
553
553
  return n === "both" ? !0 : n === e;
554
554
  }
555
- function m(n) {
555
+ function ee(n) {
556
556
  return typeof n == "string" ? "text" : "binary";
557
557
  }
558
- function ee(n, e) {
558
+ function ne(n, e) {
559
559
  switch (e) {
560
560
  case "truncate":
561
561
  return n.slice(0, Math.max(0, Math.floor(n.length / 2)));
@@ -567,7 +567,7 @@ function ee(n, e) {
567
567
  return "<html><body>Unexpected HTML</body></html>";
568
568
  }
569
569
  }
570
- function ne(n, e) {
570
+ function oe(n, e) {
571
571
  if (e === "malformed-json" || e === "wrong-type") return null;
572
572
  if (e === "empty")
573
573
  return typeof Blob < "u" && n instanceof Blob ? new Blob([]) : n instanceof ArrayBuffer ? new ArrayBuffer(0) : new Uint8Array(0);
@@ -575,236 +575,236 @@ function ne(n, e) {
575
575
  return n.slice(0, Math.max(0, Math.floor(n.size / 2)));
576
576
  if (n instanceof ArrayBuffer)
577
577
  return n.slice(0, Math.max(0, Math.floor(n.byteLength / 2)));
578
- const t = n, o = Math.max(0, Math.floor(t.byteLength / 2));
579
- return new Uint8Array(t.buffer.slice(t.byteOffset, t.byteOffset + o));
578
+ const o = n, t = Math.max(0, Math.floor(o.byteLength / 2));
579
+ return new Uint8Array(o.buffer.slice(o.byteOffset, o.byteOffset + t));
580
580
  }
581
- function I(n, e, t, o, s, p, l) {
581
+ function D(n, e, o, t, s, i, l) {
582
582
  if (!n) return null;
583
- for (const f of n) {
584
- if (l == null || l.debug("rule-evaluating", { url: e, direction: t }, f), !Z(e, f.urlPattern)) {
585
- l == null || l.debug("rule-skip-match", { url: e, direction: t }, f);
583
+ for (const p of n) {
584
+ if (l == null || l.debug("rule-evaluating", { url: e, direction: o }, p), !Z(e, p.urlPattern)) {
585
+ l == null || l.debug("rule-skip-match", { url: e, direction: o }, p);
586
586
  continue;
587
587
  }
588
- if (!_e(f.direction, t)) {
589
- l == null || l.debug("rule-skip-match", { url: e, direction: t }, f);
588
+ if (!Pe(p.direction, o)) {
589
+ l == null || l.debug("rule-skip-match", { url: e, direction: o }, p);
590
590
  continue;
591
591
  }
592
- l == null || l.debug("rule-matched", { url: e, direction: t }, f);
593
- const u = q(f, s);
594
- if (!P(f, u)) {
595
- l == null || l.debug("rule-skip-counting", { url: e, direction: t }, f);
592
+ l == null || l.debug("rule-matched", { url: e, direction: o }, p);
593
+ const u = P(p, s);
594
+ if (!$(p, u)) {
595
+ l == null || l.debug("rule-skip-counting", { url: e, direction: o }, p);
596
596
  continue;
597
597
  }
598
- if (G(f, p, l, { url: e, direction: t })) {
599
- if (!$(f.probability, o)) {
600
- l == null || l.debug("rule-skip-probability", { url: e, direction: t }, f);
598
+ if (q(p, i, l, { url: e, direction: o })) {
599
+ if (!I(p.probability, t)) {
600
+ l == null || l.debug("rule-skip-probability", { url: e, direction: o }, p);
601
601
  continue;
602
602
  }
603
- return l == null || l.debug("rule-applied", { url: e, direction: t }, f), f;
603
+ return l == null || l.debug("rule-applied", { url: e, direction: o }, p), p;
604
604
  }
605
605
  }
606
606
  return null;
607
607
  }
608
- function j(n, e, t, o, s) {
608
+ function z(n, e, o, t, s) {
609
609
  n.emit({
610
610
  type: "websocket:drop",
611
611
  timestamp: Date.now(),
612
612
  applied: !0,
613
- detail: { url: e, direction: t, payloadType: o, ...s ? { reason: s } : {} }
613
+ detail: { url: e, direction: o, payloadType: t, ...s ? { reason: s } : {} }
614
614
  });
615
615
  }
616
- function oe(n, e, t, o, s) {
616
+ function te(n, e, o, t, s) {
617
617
  n.emit({
618
618
  type: "websocket:delay",
619
619
  timestamp: Date.now(),
620
620
  applied: !0,
621
- detail: { url: e, direction: t, payloadType: o, delayMs: s }
621
+ detail: { url: e, direction: o, payloadType: t, delayMs: s }
622
622
  });
623
623
  }
624
- function D(n, e, t, o, s, p, l) {
624
+ function G(n, e, o, t, s, i, l) {
625
625
  n.emit({
626
626
  type: "websocket:corrupt",
627
627
  timestamp: Date.now(),
628
- applied: p,
629
- detail: { url: e, direction: t, payloadType: o, strategy: s, ...l ? { reason: l } : {} }
628
+ applied: i,
629
+ detail: { url: e, direction: o, payloadType: t, strategy: s, ...l ? { reason: l } : {} }
630
630
  });
631
631
  }
632
- function Re(n, e, t, o) {
632
+ function $e(n, e, o, t) {
633
633
  n.emit({
634
634
  type: "websocket:close",
635
635
  timestamp: Date.now(),
636
636
  applied: !0,
637
- detail: { url: e, closeCode: t, closeReason: o }
637
+ detail: { url: e, closeCode: o, closeReason: t }
638
638
  });
639
639
  }
640
- function Oe(n, e, t, o, s, p) {
640
+ function qe(n, e, o, t, s, i) {
641
641
  const l = /* @__PURE__ */ new Map();
642
- let f = !0;
643
- const u = (d, c) => {
644
- let i = l.get(d);
645
- i || (i = /* @__PURE__ */ new Set(), l.set(d, i)), i.add(c);
646
- }, a = (d, c) => {
647
- var i;
648
- (i = l.get(d)) == null || i.delete(c);
649
- }, E = (d, c) => {
650
- const i = l.get(d);
651
- if (i) {
652
- for (const g of i)
653
- clearTimeout(g.handle), g.kind === "delay" && j(t, g.url, g.direction, g.payloadType, c);
654
- l.delete(d);
642
+ let p = !0;
643
+ const u = (f, c) => {
644
+ let d = l.get(f);
645
+ d || (d = /* @__PURE__ */ new Set(), l.set(f, d)), d.add(c);
646
+ }, a = (f, c) => {
647
+ var d;
648
+ (d = l.get(f)) == null || d.delete(c);
649
+ }, S = (f, c) => {
650
+ const d = l.get(f);
651
+ if (d) {
652
+ for (const g of d)
653
+ clearTimeout(g.handle), g.kind === "delay" && z(o, g.url, g.direction, g.payloadType, c);
654
+ l.delete(f);
655
655
  }
656
- }, x = (d, c, i) => {
656
+ }, A = (f, c, d) => {
657
657
  const g = new MessageEvent("message", {
658
- data: i,
658
+ data: d,
659
659
  origin: c.origin,
660
660
  lastEventId: c.lastEventId,
661
661
  source: c.source,
662
662
  ports: Array.from(c.ports ?? [])
663
663
  });
664
- g[X] = !0, d.dispatchEvent(g);
665
- }, M = (d, c, i, g) => {
666
- if (!f) return { handled: !1, data: i };
667
- const h = "outbound", y = m(i);
668
- if (I(e.drops, c, h, o, s, p, t))
669
- return j(t, c, h, y), { handled: !0, data: i };
670
- let k = i;
671
- const w = I(e.corruptions, c, h, o, s, p, t);
664
+ g[X] = !0, f.dispatchEvent(g);
665
+ }, M = (f, c, d, g) => {
666
+ if (!p) return { handled: !1, data: d };
667
+ const h = "outbound", y = ee(d);
668
+ if (D(e.drops, c, h, t, s, i, o))
669
+ return z(o, c, h, y), { handled: !0, data: d };
670
+ let k = d;
671
+ const w = D(e.corruptions, c, h, t, s, i, o);
672
672
  if (w)
673
673
  if (y === "text")
674
- k = ee(k, w.strategy), D(t, c, h, y, w.strategy, !0);
674
+ k = ne(k, w.strategy), G(o, c, h, y, w.strategy, !0);
675
675
  else {
676
- const T = ne(k, w.strategy);
677
- T === null ? D(t, c, h, y, w.strategy, !1, "incompatible-payload-type") : (k = T, D(t, c, h, y, w.strategy, !0));
676
+ const E = oe(k, w.strategy);
677
+ E === null ? G(o, c, h, y, w.strategy, !1, "incompatible-payload-type") : (k = E, G(o, c, h, y, w.strategy, !0));
678
678
  }
679
- const C = I(e.delays, c, h, o, s, p, t);
679
+ const C = D(e.delays, c, h, t, s, i, o);
680
680
  if (C) {
681
- oe(t, c, h, y, C.delayMs);
682
- const T = {
681
+ te(o, c, h, y, C.delayMs);
682
+ const E = {
683
683
  kind: "delay",
684
684
  handle: setTimeout(() => {
685
- a(d, T);
686
- try {
687
- g(k);
688
- } catch {
689
- }
685
+ if (a(f, E), !!p)
686
+ try {
687
+ g(k);
688
+ } catch {
689
+ }
690
690
  }, C.delayMs),
691
691
  url: c,
692
692
  direction: h,
693
693
  payloadType: y
694
694
  };
695
- return u(d, T), { handled: !0, data: k };
695
+ return u(f, E), { handled: !0, data: k };
696
696
  }
697
697
  return { handled: !1, data: k };
698
- }, L = (d, c) => {
699
- d.addEventListener("message", (i) => {
700
- const g = i;
701
- if (g[X] || !f) return;
702
- const h = "inbound", y = m(g.data);
703
- if (I(e.drops, c, h, o, s, p, t)) {
704
- g.stopImmediatePropagation(), j(t, c, h, y);
698
+ }, L = (f, c) => {
699
+ f.addEventListener("message", (d) => {
700
+ const g = d;
701
+ if (g[X] || !p) return;
702
+ const h = "inbound", y = ee(g.data);
703
+ if (D(e.drops, c, h, t, s, i, o)) {
704
+ g.stopImmediatePropagation(), z(o, c, h, y);
705
705
  return;
706
706
  }
707
707
  let k = g.data, w = !1;
708
- const C = I(e.corruptions, c, h, o, s, p, t);
708
+ const C = D(e.corruptions, c, h, t, s, i, o);
709
709
  if (C)
710
710
  if (y === "text")
711
- k = ee(k, C.strategy), w = !0, D(t, c, h, y, C.strategy, !0);
711
+ k = ne(k, C.strategy), w = !0, G(o, c, h, y, C.strategy, !0);
712
712
  else {
713
- const R = ne(k, C.strategy);
714
- R === null ? D(t, c, h, y, C.strategy, !1, "incompatible-payload-type") : (k = R, w = !0, D(t, c, h, y, C.strategy, !0));
713
+ const R = oe(k, C.strategy);
714
+ R === null ? G(o, c, h, y, C.strategy, !1, "incompatible-payload-type") : (k = R, w = !0, G(o, c, h, y, C.strategy, !0));
715
715
  }
716
- const T = I(e.delays, c, h, o, s, p, t);
717
- if (T) {
718
- g.stopImmediatePropagation(), oe(t, c, h, y, T.delayMs);
716
+ const E = D(e.delays, c, h, t, s, i, o);
717
+ if (E) {
718
+ g.stopImmediatePropagation(), te(o, c, h, y, E.delayMs);
719
719
  const R = {
720
720
  kind: "delay",
721
721
  handle: setTimeout(() => {
722
- a(d, R), x(d, g, k);
723
- }, T.delayMs),
722
+ a(f, R), p && A(f, g, k);
723
+ }, E.delayMs),
724
724
  url: c,
725
725
  direction: h,
726
726
  payloadType: y
727
727
  };
728
- u(d, R);
728
+ u(f, R);
729
729
  return;
730
730
  }
731
- w && (g.stopImmediatePropagation(), x(d, g, k));
731
+ w && (g.stopImmediatePropagation(), A(f, g, k));
732
732
  });
733
- }, A = (d, c) => {
733
+ }, N = (f, c) => {
734
734
  if (e.closes)
735
- for (const i of e.closes) {
736
- if (t.debug("rule-evaluating", { url: c }, i), !Z(c, i.urlPattern)) {
737
- t.debug("rule-skip-match", { url: c }, i);
735
+ for (const d of e.closes) {
736
+ if (o.debug("rule-evaluating", { url: c }, d), !Z(c, d.urlPattern)) {
737
+ o.debug("rule-skip-match", { url: c }, d);
738
738
  continue;
739
739
  }
740
- t.debug("rule-matched", { url: c }, i);
741
- const g = q(i, s);
742
- if (!P(i, g)) {
743
- t.debug("rule-skip-counting", { url: c }, i);
740
+ o.debug("rule-matched", { url: c }, d);
741
+ const g = P(d, s);
742
+ if (!$(d, g)) {
743
+ o.debug("rule-skip-counting", { url: c }, d);
744
744
  continue;
745
745
  }
746
- if (!G(i, p, t, { url: c })) continue;
747
- if (!$(i.probability, o)) {
748
- t.debug("rule-skip-probability", { url: c }, i);
746
+ if (!q(d, i, o, { url: c })) continue;
747
+ if (!I(d.probability, t)) {
748
+ o.debug("rule-skip-probability", { url: c }, d);
749
749
  continue;
750
750
  }
751
- t.debug("rule-applied", { url: c }, i);
752
- const h = i.code ?? 1e3, y = i.reason ?? "Chaos Maker close", k = i.afterMs ?? 0, w = () => {
753
- if (f) {
754
- E(d, "close-interrupt"), Re(t, c, h, y);
751
+ o.debug("rule-applied", { url: c }, d);
752
+ const h = d.code ?? 1e3, y = d.reason ?? "Chaos Maker close", k = d.afterMs ?? 0, w = () => {
753
+ if (p) {
754
+ S(f, "close-interrupt"), $e(o, c, h, y);
755
755
  try {
756
- d.close(h, y);
756
+ f.close(h, y);
757
757
  } catch {
758
758
  try {
759
- d.close();
759
+ f.close();
760
760
  } catch {
761
761
  }
762
762
  }
763
763
  }
764
764
  };
765
765
  if (k <= 0)
766
- d.readyState === d.OPEN ? w() : d.addEventListener("open", w, { once: !0 });
766
+ f.readyState === f.OPEN ? w() : f.addEventListener("open", w, { once: !0 });
767
767
  else {
768
768
  const C = () => {
769
- const T = {
769
+ const E = {
770
770
  kind: "close",
771
771
  handle: setTimeout(w, k)
772
772
  };
773
- u(d, T);
773
+ u(f, E);
774
774
  };
775
- d.readyState === d.OPEN ? C() : d.addEventListener("open", C, { once: !0 });
775
+ f.readyState === f.OPEN ? C() : f.addEventListener("open", C, { once: !0 });
776
776
  }
777
777
  return;
778
778
  }
779
779
  };
780
- function S(d, c) {
781
- const i = new n(d, c), g = typeof d == "string" ? d : d.toString(), h = i.send.bind(i);
782
- return i.send = function(k) {
783
- const w = M(i, g, k, h);
780
+ function T(f, c) {
781
+ const d = new n(f, c), g = typeof f == "string" ? f : f.toString(), h = d.send.bind(d);
782
+ return d.send = function(k) {
783
+ const w = M(d, g, k, h);
784
784
  w.handled || h(w.data);
785
- }, L(i, g), A(i, g), i;
785
+ }, L(d, g), N(d, g), d;
786
786
  }
787
- Object.defineProperty(S, "prototype", {
787
+ Object.defineProperty(T, "prototype", {
788
788
  value: n.prototype,
789
789
  writable: !1
790
790
  });
791
- for (const d of ["CONNECTING", "OPEN", "CLOSING", "CLOSED"])
792
- S[d] = n[d];
791
+ for (const f of ["CONNECTING", "OPEN", "CLOSING", "CLOSED"])
792
+ T[f] = n[f];
793
793
  return {
794
- Wrapped: S,
794
+ Wrapped: T,
795
795
  uninstall() {
796
- f = !1;
797
- for (const [, d] of l)
798
- for (const c of d)
799
- clearTimeout(c.handle), c.kind === "delay" && j(t, c.url, c.direction, c.payloadType, "stop-during-delay");
796
+ p = !1;
797
+ for (const [, f] of l)
798
+ for (const c of f)
799
+ clearTimeout(c.handle), c.kind === "delay" && z(o, c.url, c.direction, c.payloadType, "stop-during-delay");
800
800
  l.clear();
801
801
  }
802
802
  };
803
803
  }
804
- function $e(n) {
804
+ function De(n) {
805
805
  return n === void 0 ? { enabled: !1 } : typeof n == "boolean" ? { enabled: n } : { enabled: n.enabled };
806
806
  }
807
- const qe = [
807
+ const Ge = [
808
808
  { pick: (n) => {
809
809
  var e;
810
810
  return (e = n.network) == null ? void 0 : e.failures;
@@ -862,23 +862,23 @@ const qe = [
862
862
  return (e = n.sse) == null ? void 0 : e.closes;
863
863
  }, ruleType: "sse-close" }
864
864
  ];
865
- function Pe(n) {
865
+ function Fe(n) {
866
866
  const e = /* @__PURE__ */ new WeakMap();
867
- for (const { pick: t, ruleType: o } of qe) {
868
- const s = t(n);
869
- s && s.forEach((p, l) => {
870
- e.set(p, { ruleType: o, ruleId: `${o}#${l}` });
867
+ for (const { pick: o, ruleType: t } of Ge) {
868
+ const s = o(n);
869
+ s && s.forEach((i, l) => {
870
+ e.set(i, { ruleType: t, ruleId: `${t}#${l}` });
871
871
  });
872
872
  }
873
873
  return e;
874
874
  }
875
- function Ge(n, e) {
876
- const t = [];
877
- return e.ruleId && t.push(`rule=${e.ruleId}`), e.phase && t.push(e.phase), e.method && t.push(e.method), e.url && t.push(e.url), e.statusCode !== void 0 && t.push(`-> ${e.statusCode}`), e.delayMs !== void 0 && t.push(`+${e.delayMs}ms`), e.direction && t.push(e.direction), e.eventType && t.push(`event=${e.eventType}`), e.selector && t.push(`selector=${e.selector}`), e.action && t.push(`action=${e.action}`), e.strategy && t.push(`strategy=${e.strategy}`), e.groupName && t.push(`group=${e.groupName}`), e.reason && t.push(`reason=${e.reason}`), t.length === 0 ? n : `${n}: ${t.join(" ")}`;
875
+ function Ue(n, e) {
876
+ const o = [];
877
+ return e.ruleId && o.push(`rule=${e.ruleId}`), e.phase && o.push(e.phase), e.method && o.push(e.method), e.url && o.push(e.url), e.statusCode !== void 0 && o.push(`-> ${e.statusCode}`), e.delayMs !== void 0 && o.push(`+${e.delayMs}ms`), e.direction && o.push(e.direction), e.eventType && o.push(`event=${e.eventType}`), e.selector && o.push(`selector=${e.selector}`), e.action && o.push(`action=${e.action}`), e.strategy && o.push(`strategy=${e.strategy}`), e.groupName && o.push(`group=${e.groupName}`), e.reason && o.push(`reason=${e.reason}`), o.length === 0 ? n : `${n}: ${o.join(" ")}`;
878
878
  }
879
- class Ie {
880
- constructor(e, t = "page") {
881
- this.opts = e, this.target = t;
879
+ class We {
880
+ constructor(e, o = "page") {
881
+ this.opts = e, this.target = o;
882
882
  }
883
883
  isEnabled() {
884
884
  return this.opts.enabled;
@@ -895,32 +895,74 @@ class Ie {
895
895
  * keeps the public `Logger` API consistent with the `DebugOptions.enabled`
896
896
  * contract for external consumers who instantiate it directly.
897
897
  */
898
- log(e, t) {
898
+ log(e, o) {
899
899
  if (!this.opts.enabled) return null;
900
- const o = { ...t, stage: e }, s = {
900
+ const t = { ...o, stage: e }, s = {
901
901
  type: "debug",
902
902
  timestamp: Date.now(),
903
903
  applied: !1,
904
- detail: o
904
+ detail: t
905
905
  };
906
906
  if (typeof console < "u" && typeof console.debug == "function") {
907
- const p = this.target === "sw" ? "[Chaos SW]" : "[Chaos]";
907
+ const i = this.target === "sw" ? "[Chaos SW]" : "[Chaos]";
908
908
  try {
909
- console.debug(`${p} ${Ge(e, o)}`);
909
+ console.debug(`${i} ${Ue(e, t)}`);
910
910
  } catch {
911
911
  }
912
912
  }
913
913
  return s;
914
914
  }
915
915
  }
916
+ const de = /* @__PURE__ */ Symbol.for("chaos-maker.runtime.patch-kind"), H = /* @__PURE__ */ Symbol.for("chaos-maker.runtime.active-instance");
917
+ function Be(n) {
918
+ return typeof n == "object" && n !== null || typeof n == "function";
919
+ }
920
+ function re(n, e) {
921
+ try {
922
+ Object.defineProperty(n, de, {
923
+ value: e,
924
+ configurable: !0
925
+ });
926
+ } catch {
927
+ }
928
+ return n;
929
+ }
930
+ function se(n) {
931
+ if (Be(n))
932
+ return n[de];
933
+ }
934
+ function He(n) {
935
+ return n[H];
936
+ }
937
+ function je(n, e) {
938
+ try {
939
+ Object.defineProperty(n, H, {
940
+ value: e,
941
+ configurable: !0
942
+ });
943
+ } catch {
944
+ }
945
+ }
946
+ function Qe(n, e) {
947
+ const o = n;
948
+ if (o[H] === e)
949
+ try {
950
+ delete o[H];
951
+ } catch {
952
+ try {
953
+ o[H] = void 0;
954
+ } catch {
955
+ }
956
+ }
957
+ }
916
958
  const Y = /* @__PURE__ */ Symbol.for("chaos-maker.sw.installed");
917
- function De() {
959
+ function ze() {
918
960
  return typeof self < "u" ? self : typeof globalThis < "u" ? globalThis : null;
919
961
  }
920
- function le(n, e) {
921
- const t = n.clients;
922
- !t || typeof t.matchAll != "function" || t.matchAll({ includeUncontrolled: !0 }).then((o) => {
923
- for (const s of o)
962
+ function fe(n, e) {
963
+ const o = n.clients;
964
+ !o || typeof o.matchAll != "function" || o.matchAll({ includeUncontrolled: !0 }).then((t) => {
965
+ for (const s of t)
924
966
  try {
925
967
  s.postMessage(e);
926
968
  } catch {
@@ -928,52 +970,66 @@ function le(n, e) {
928
970
  }).catch(() => {
929
971
  });
930
972
  }
931
- function te(n, e) {
932
- n.running && K(n);
933
- const t = re(e.seed);
934
- n.seed = t.seed, n.random = t.random, n.requestCounters = /* @__PURE__ */ new Map(), n.groups = new se();
935
- for (const s of e.groups ?? [])
936
- n.groups.ensure(s.name, { enabled: s.enabled ?? !0, explicit: !0 });
937
- he(e, (s) => {
938
- s.group && n.groups.ensure(s.group);
939
- }), n.groups.ensure(z, { enabled: !0 });
940
- const o = $e(e.debug);
941
- if (o.enabled ? (n.emitter.setRuleIds(Pe(e)), n.emitter.setLogger(new Ie(o, "sw"))) : (n.emitter.setRuleIds(void 0), n.emitter.setLogger(void 0)), n.emitter.debug("lifecycle", { phase: "sw:config-applied" }), e.network) {
942
- const s = n.target;
943
- typeof s.fetch == "function" && (n.originalFetch = s.fetch, s.fetch = Ne(
944
- n.originalFetch.bind(s),
945
- e.network,
946
- n.random,
947
- n.emitter,
948
- n.requestCounters,
949
- n.groups
973
+ function ae(n, e) {
974
+ n.running && V(n);
975
+ const o = ue(e.seed);
976
+ n.seed = o.seed, n.random = o.random, n.requestCounters = /* @__PURE__ */ new Map(), n.groups = new le();
977
+ for (const i of e.groups ?? [])
978
+ n.groups.ensure(i.name, { enabled: i.enabled ?? !0, explicit: !0 });
979
+ we(e, (i) => {
980
+ i.group && n.groups.ensure(i.group);
981
+ }), n.groups.ensure(J, { enabled: !0 });
982
+ const t = De(e.debug);
983
+ t.enabled ? (n.emitter.setRuleIds(Fe(e)), n.emitter.setLogger(new We(t, "sw"))) : (n.emitter.setRuleIds(void 0), n.emitter.setLogger(void 0));
984
+ const s = He(n.target);
985
+ if (s && s !== n && n.emitter.debug("lifecycle", {
986
+ phase: "sw:config-applied",
987
+ reason: "active-instance-conflict"
988
+ }), se(n.target.fetch) === "fetch" && n.emitter.debug("lifecycle", {
989
+ phase: "sw:config-applied",
990
+ reason: "target-fetch-already-patched"
991
+ }), typeof n.target.WebSocket < "u" && se(n.target.WebSocket) === "websocket" && n.emitter.debug("lifecycle", {
992
+ phase: "sw:config-applied",
993
+ reason: "target-websocket-already-patched"
994
+ }), n.emitter.debug("lifecycle", { phase: "sw:config-applied" }), e.network) {
995
+ const i = n.target;
996
+ typeof i.fetch == "function" && (n.originalFetch = i.fetch, i.fetch = re(
997
+ Ie(
998
+ n.originalFetch.bind(i),
999
+ e.network,
1000
+ n.random,
1001
+ n.emitter,
1002
+ n.requestCounters,
1003
+ n.groups
1004
+ ),
1005
+ "fetch"
950
1006
  ));
951
1007
  }
952
- return e.websocket && typeof n.target.WebSocket < "u" && (n.originalWebSocket = n.target.WebSocket, n.webSocketHandle = Oe(
1008
+ return e.websocket && typeof n.target.WebSocket < "u" && (n.originalWebSocket = n.target.WebSocket, n.webSocketHandle = qe(
953
1009
  n.originalWebSocket,
954
1010
  e.websocket,
955
1011
  n.emitter,
956
1012
  n.random,
957
1013
  n.requestCounters,
958
1014
  n.groups
959
- ), n.target.WebSocket = n.webSocketHandle.Wrapped), n.running = !0, n.seed;
1015
+ ), n.target.WebSocket = re(n.webSocketHandle.Wrapped, "websocket")), n.running = !0, je(n.target, n), n.seed;
960
1016
  }
961
- function K(n) {
962
- !n.running && !n.originalFetch && !n.originalWebSocket || (n.originalFetch && (n.target.fetch = n.originalFetch, n.originalFetch = void 0), n.originalWebSocket && (n.target.WebSocket = n.originalWebSocket, n.originalWebSocket = void 0), n.webSocketHandle && (n.webSocketHandle.uninstall(), n.webSocketHandle = void 0), n.emitter.debug("lifecycle", { phase: "sw:config-stopped" }), n.emitter.setLogger(void 0), n.emitter.setRuleIds(void 0), n.running = !1);
1017
+ function V(n) {
1018
+ !n.running && !n.originalFetch && !n.originalWebSocket || (n.originalFetch && (n.target.fetch = n.originalFetch, n.originalFetch = void 0), n.originalWebSocket && (n.target.WebSocket = n.originalWebSocket, n.originalWebSocket = void 0), n.webSocketHandle && (n.webSocketHandle.uninstall(), n.webSocketHandle = void 0), n.emitter.debug("lifecycle", { phase: "sw:config-stopped" }), n.emitter.setLogger(void 0), n.emitter.setRuleIds(void 0), n.seed = null, n.requestCounters.clear(), Qe(n.target, n), n.running = !1);
963
1019
  }
964
- function F(n, e, t) {
1020
+ function F(n, e, o) {
965
1021
  var s;
966
- const o = (s = e.ports) == null ? void 0 : s[0];
967
- if (o && typeof o.postMessage == "function")
1022
+ const t = (s = e.ports) == null ? void 0 : s[0];
1023
+ if (t && typeof t.postMessage == "function")
968
1024
  try {
969
- o.postMessage(t);
1025
+ t.postMessage(o);
970
1026
  return;
971
1027
  } catch {
972
1028
  }
973
- le(n, t);
1029
+ fe(n, o);
974
1030
  }
975
- function Fe(n = {}) {
976
- const e = De(), t = {
1031
+ function Je(n = {}) {
1032
+ const e = ze(), o = {
977
1033
  isRunning: () => !1,
978
1034
  getSeed: () => null,
979
1035
  getLog: () => [],
@@ -983,28 +1039,28 @@ function Fe(n = {}) {
983
1039
  }
984
1040
  };
985
1041
  if (!e || typeof e.fetch != "function" || typeof e.addEventListener != "function")
986
- return t;
987
- const o = e[Y];
988
- if (o) return o;
989
- const s = new de(n.maxLogEntries ?? 2e3), p = re(0), l = {
1042
+ return o;
1043
+ const t = e[Y];
1044
+ if (t) return t;
1045
+ const s = new he(n.maxLogEntries ?? 2e3), i = ue(0), l = {
990
1046
  target: e,
991
1047
  emitter: s,
992
1048
  running: !1,
993
1049
  seed: null,
994
- random: p.random,
1050
+ random: i.random,
995
1051
  requestCounters: /* @__PURE__ */ new Map(),
996
- groups: new se()
1052
+ groups: new le()
997
1053
  };
998
1054
  s.on("*", (a) => {
999
- le(e, { __chaosMakerSWEvent: !0, event: a });
1055
+ fe(e, { __chaosMakerSWEvent: !0, event: a });
1000
1056
  });
1001
- const f = (a) => {
1002
- const E = a, x = E.data;
1003
- if (!x || typeof x != "object") return;
1004
- const M = x;
1057
+ const p = (a) => {
1058
+ const S = a, A = S.data;
1059
+ if (!A || typeof A != "object") return;
1060
+ const M = A;
1005
1061
  if (M.__chaosMakerConfig) {
1006
- const L = te(l, M.__chaosMakerConfig);
1007
- F(e, E, {
1062
+ const L = ae(l, M.__chaosMakerConfig);
1063
+ F(e, S, {
1008
1064
  __chaosMakerAck: !0,
1009
1065
  seed: L,
1010
1066
  running: l.running
@@ -1012,50 +1068,50 @@ function Fe(n = {}) {
1012
1068
  return;
1013
1069
  }
1014
1070
  if (M.__chaosMakerStop) {
1015
- K(l), F(e, E, {
1071
+ V(l), F(e, S, {
1016
1072
  __chaosMakerAck: !0,
1017
1073
  running: !1
1018
1074
  });
1019
1075
  return;
1020
1076
  }
1021
1077
  if (M.__chaosMakerToggleGroup) {
1022
- const { name: L, enabled: A } = M.__chaosMakerToggleGroup, S = L.trim();
1023
- if (!S) {
1024
- F(e, E, {
1078
+ const { name: L, enabled: N } = M.__chaosMakerToggleGroup, T = L.trim();
1079
+ if (!T) {
1080
+ F(e, S, {
1025
1081
  __chaosMakerAck: !0,
1026
1082
  running: l.running
1027
1083
  });
1028
1084
  return;
1029
1085
  }
1030
- l.groups.setEnabled(S, A), l.emitter.emit({
1031
- type: A ? "rule-group:enabled" : "rule-group:disabled",
1086
+ l.groups.setEnabled(T, N), l.emitter.emit({
1087
+ type: N ? "rule-group:enabled" : "rule-group:disabled",
1032
1088
  timestamp: Date.now(),
1033
1089
  applied: !0,
1034
- detail: { groupName: S }
1035
- }), l.emitter.debug("lifecycle", { phase: "sw:group-toggled", groupName: S, enabled: A }), F(e, E, {
1090
+ detail: { groupName: T }
1091
+ }), l.emitter.debug("lifecycle", { phase: "sw:group-toggled", groupName: T, enabled: N }), F(e, S, {
1036
1092
  __chaosMakerAck: !0,
1037
1093
  running: l.running
1038
1094
  });
1039
1095
  return;
1040
1096
  }
1041
1097
  if (M.__chaosMakerGetLog) {
1042
- F(e, E, {
1098
+ F(e, S, {
1043
1099
  __chaosMakerLog: !0,
1044
1100
  log: s.getLog()
1045
1101
  });
1046
1102
  return;
1047
1103
  }
1048
1104
  if (M.__chaosMakerClearLog) {
1049
- s.clearLog(), F(e, E, {
1105
+ s.clearLog(), F(e, S, {
1050
1106
  __chaosMakerAck: !0,
1051
1107
  running: l.running
1052
1108
  });
1053
1109
  return;
1054
1110
  }
1055
1111
  };
1056
- if (e.addEventListener("message", f), (n.source ?? "message") === "self-global") {
1112
+ if (e.addEventListener("message", p), (n.source ?? "message") === "self-global") {
1057
1113
  const a = e.__CHAOS_CONFIG__;
1058
- a && typeof a == "object" && te(l, a);
1114
+ a && typeof a == "object" && ae(l, a);
1059
1115
  }
1060
1116
  const u = {
1061
1117
  isRunning: () => l.running,
@@ -1063,12 +1119,12 @@ function Fe(n = {}) {
1063
1119
  getLog: () => s.getLog(),
1064
1120
  clearLog: () => s.clearLog(),
1065
1121
  uninstall: () => {
1066
- e.removeEventListener("message", f), K(l), delete e[Y];
1122
+ e.removeEventListener("message", p), V(l), delete e[Y];
1067
1123
  }
1068
1124
  };
1069
1125
  return e[Y] = u, u;
1070
1126
  }
1071
- typeof self < "u" && typeof importScripts == "function" && Fe({ source: "message" });
1127
+ typeof self < "u" && typeof importScripts == "function" && Je({ source: "message" });
1072
1128
  export {
1073
- Fe as installChaosSW
1129
+ Je as installChaosSW
1074
1130
  };