@spotify-confidence/openfeature-server-provider-local 0.0.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.
@@ -0,0 +1,2185 @@
1
+ import { createRequire } from "node:module";
2
+ import fs from "node:fs/promises";
3
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
4
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
5
+ let NullValue = /* @__PURE__ */ function(NullValue$1) {
6
+ NullValue$1[NullValue$1["NULL_VALUE"] = 0] = "NULL_VALUE";
7
+ NullValue$1[NullValue$1["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
8
+ return NullValue$1;
9
+ }({});
10
+ function nullValueFromJSON(object) {
11
+ switch (object) {
12
+ case 0:
13
+ case "NULL_VALUE": return NullValue.NULL_VALUE;
14
+ case -1:
15
+ case "UNRECOGNIZED":
16
+ default: return NullValue.UNRECOGNIZED;
17
+ }
18
+ }
19
+ function nullValueToJSON(object) {
20
+ switch (object) {
21
+ case NullValue.NULL_VALUE: return "NULL_VALUE";
22
+ case NullValue.UNRECOGNIZED:
23
+ default: return "UNRECOGNIZED";
24
+ }
25
+ }
26
+ function createBaseStruct() {
27
+ return { fields: {} };
28
+ }
29
+ const Struct = {
30
+ encode(message, writer = new BinaryWriter()) {
31
+ Object.entries(message.fields).forEach(([key, value]) => {
32
+ if (value !== void 0) Struct_FieldsEntry.encode({
33
+ key,
34
+ value
35
+ }, writer.uint32(10).fork()).join();
36
+ });
37
+ return writer;
38
+ },
39
+ decode(input, length) {
40
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
41
+ const end = length === void 0 ? reader.len : reader.pos + length;
42
+ const message = createBaseStruct();
43
+ while (reader.pos < end) {
44
+ const tag = reader.uint32();
45
+ switch (tag >>> 3) {
46
+ case 1: {
47
+ if (tag !== 10) break;
48
+ const entry1 = Struct_FieldsEntry.decode(reader, reader.uint32());
49
+ if (entry1.value !== void 0) message.fields[entry1.key] = entry1.value;
50
+ continue;
51
+ }
52
+ }
53
+ if ((tag & 7) === 4 || tag === 0) break;
54
+ reader.skip(tag & 7);
55
+ }
56
+ return message;
57
+ },
58
+ fromJSON(object) {
59
+ return { fields: isObject$1(object.fields) ? Object.entries(object.fields).reduce((acc, [key, value]) => {
60
+ acc[key] = value;
61
+ return acc;
62
+ }, {}) : {} };
63
+ },
64
+ toJSON(message) {
65
+ const obj = {};
66
+ if (message.fields) {
67
+ const entries = Object.entries(message.fields);
68
+ if (entries.length > 0) {
69
+ obj.fields = {};
70
+ entries.forEach(([k, v]) => {
71
+ obj.fields[k] = v;
72
+ });
73
+ }
74
+ }
75
+ return obj;
76
+ },
77
+ create(base) {
78
+ return Struct.fromPartial(base ?? {});
79
+ },
80
+ fromPartial(object) {
81
+ const message = createBaseStruct();
82
+ message.fields = Object.entries(object.fields ?? {}).reduce((acc, [key, value]) => {
83
+ if (value !== void 0) acc[key] = value;
84
+ return acc;
85
+ }, {});
86
+ return message;
87
+ },
88
+ wrap(object) {
89
+ const struct = createBaseStruct();
90
+ if (object !== void 0) for (const key of Object.keys(object)) struct.fields[key] = object[key];
91
+ return struct;
92
+ },
93
+ unwrap(message) {
94
+ const object = {};
95
+ if (message.fields) for (const key of Object.keys(message.fields)) object[key] = message.fields[key];
96
+ return object;
97
+ }
98
+ };
99
+ function createBaseStruct_FieldsEntry() {
100
+ return {
101
+ key: "",
102
+ value: void 0
103
+ };
104
+ }
105
+ const Struct_FieldsEntry = {
106
+ encode(message, writer = new BinaryWriter()) {
107
+ if (message.key !== "") writer.uint32(10).string(message.key);
108
+ if (message.value !== void 0) Value.encode(Value.wrap(message.value), writer.uint32(18).fork()).join();
109
+ return writer;
110
+ },
111
+ decode(input, length) {
112
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
113
+ const end = length === void 0 ? reader.len : reader.pos + length;
114
+ const message = createBaseStruct_FieldsEntry();
115
+ while (reader.pos < end) {
116
+ const tag = reader.uint32();
117
+ switch (tag >>> 3) {
118
+ case 1:
119
+ if (tag !== 10) break;
120
+ message.key = reader.string();
121
+ continue;
122
+ case 2:
123
+ if (tag !== 18) break;
124
+ message.value = Value.unwrap(Value.decode(reader, reader.uint32()));
125
+ continue;
126
+ }
127
+ if ((tag & 7) === 4 || tag === 0) break;
128
+ reader.skip(tag & 7);
129
+ }
130
+ return message;
131
+ },
132
+ fromJSON(object) {
133
+ return {
134
+ key: isSet$3(object.key) ? globalThis.String(object.key) : "",
135
+ value: isSet$3(object?.value) ? object.value : void 0
136
+ };
137
+ },
138
+ toJSON(message) {
139
+ const obj = {};
140
+ if (message.key !== "") obj.key = message.key;
141
+ if (message.value !== void 0) obj.value = message.value;
142
+ return obj;
143
+ },
144
+ create(base) {
145
+ return Struct_FieldsEntry.fromPartial(base ?? {});
146
+ },
147
+ fromPartial(object) {
148
+ const message = createBaseStruct_FieldsEntry();
149
+ message.key = object.key ?? "";
150
+ message.value = object.value ?? void 0;
151
+ return message;
152
+ }
153
+ };
154
+ function createBaseValue() {
155
+ return {
156
+ nullValue: void 0,
157
+ numberValue: void 0,
158
+ stringValue: void 0,
159
+ boolValue: void 0,
160
+ structValue: void 0,
161
+ listValue: void 0
162
+ };
163
+ }
164
+ const Value = {
165
+ encode(message, writer = new BinaryWriter()) {
166
+ if (message.nullValue !== void 0) writer.uint32(8).int32(message.nullValue);
167
+ if (message.numberValue !== void 0) writer.uint32(17).double(message.numberValue);
168
+ if (message.stringValue !== void 0) writer.uint32(26).string(message.stringValue);
169
+ if (message.boolValue !== void 0) writer.uint32(32).bool(message.boolValue);
170
+ if (message.structValue !== void 0) Struct.encode(Struct.wrap(message.structValue), writer.uint32(42).fork()).join();
171
+ if (message.listValue !== void 0) ListValue.encode(ListValue.wrap(message.listValue), writer.uint32(50).fork()).join();
172
+ return writer;
173
+ },
174
+ decode(input, length) {
175
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
176
+ const end = length === void 0 ? reader.len : reader.pos + length;
177
+ const message = createBaseValue();
178
+ while (reader.pos < end) {
179
+ const tag = reader.uint32();
180
+ switch (tag >>> 3) {
181
+ case 1:
182
+ if (tag !== 8) break;
183
+ message.nullValue = reader.int32();
184
+ continue;
185
+ case 2:
186
+ if (tag !== 17) break;
187
+ message.numberValue = reader.double();
188
+ continue;
189
+ case 3:
190
+ if (tag !== 26) break;
191
+ message.stringValue = reader.string();
192
+ continue;
193
+ case 4:
194
+ if (tag !== 32) break;
195
+ message.boolValue = reader.bool();
196
+ continue;
197
+ case 5:
198
+ if (tag !== 42) break;
199
+ message.structValue = Struct.unwrap(Struct.decode(reader, reader.uint32()));
200
+ continue;
201
+ case 6:
202
+ if (tag !== 50) break;
203
+ message.listValue = ListValue.unwrap(ListValue.decode(reader, reader.uint32()));
204
+ continue;
205
+ }
206
+ if ((tag & 7) === 4 || tag === 0) break;
207
+ reader.skip(tag & 7);
208
+ }
209
+ return message;
210
+ },
211
+ fromJSON(object) {
212
+ return {
213
+ nullValue: isSet$3(object.nullValue) ? nullValueFromJSON(object.nullValue) : void 0,
214
+ numberValue: isSet$3(object.numberValue) ? globalThis.Number(object.numberValue) : void 0,
215
+ stringValue: isSet$3(object.stringValue) ? globalThis.String(object.stringValue) : void 0,
216
+ boolValue: isSet$3(object.boolValue) ? globalThis.Boolean(object.boolValue) : void 0,
217
+ structValue: isObject$1(object.structValue) ? object.structValue : void 0,
218
+ listValue: globalThis.Array.isArray(object.listValue) ? [...object.listValue] : void 0
219
+ };
220
+ },
221
+ toJSON(message) {
222
+ const obj = {};
223
+ if (message.nullValue !== void 0) obj.nullValue = nullValueToJSON(message.nullValue);
224
+ if (message.numberValue !== void 0) obj.numberValue = message.numberValue;
225
+ if (message.stringValue !== void 0) obj.stringValue = message.stringValue;
226
+ if (message.boolValue !== void 0) obj.boolValue = message.boolValue;
227
+ if (message.structValue !== void 0) obj.structValue = message.structValue;
228
+ if (message.listValue !== void 0) obj.listValue = message.listValue;
229
+ return obj;
230
+ },
231
+ create(base) {
232
+ return Value.fromPartial(base ?? {});
233
+ },
234
+ fromPartial(object) {
235
+ const message = createBaseValue();
236
+ message.nullValue = object.nullValue ?? void 0;
237
+ message.numberValue = object.numberValue ?? void 0;
238
+ message.stringValue = object.stringValue ?? void 0;
239
+ message.boolValue = object.boolValue ?? void 0;
240
+ message.structValue = object.structValue ?? void 0;
241
+ message.listValue = object.listValue ?? void 0;
242
+ return message;
243
+ },
244
+ wrap(value) {
245
+ const result = createBaseValue();
246
+ if (value === null) result.nullValue = NullValue.NULL_VALUE;
247
+ else if (typeof value === "boolean") result.boolValue = value;
248
+ else if (typeof value === "number") result.numberValue = value;
249
+ else if (typeof value === "string") result.stringValue = value;
250
+ else if (globalThis.Array.isArray(value)) result.listValue = value;
251
+ else if (typeof value === "object") result.structValue = value;
252
+ else if (typeof value !== "undefined") throw new globalThis.Error("Unsupported any value type: " + typeof value);
253
+ return result;
254
+ },
255
+ unwrap(message) {
256
+ if (message.stringValue !== void 0) return message.stringValue;
257
+ else if (message?.numberValue !== void 0) return message.numberValue;
258
+ else if (message?.boolValue !== void 0) return message.boolValue;
259
+ else if (message?.structValue !== void 0) return message.structValue;
260
+ else if (message?.listValue !== void 0) return message.listValue;
261
+ else if (message?.nullValue !== void 0) return null;
262
+ }
263
+ };
264
+ function createBaseListValue() {
265
+ return { values: [] };
266
+ }
267
+ const ListValue = {
268
+ encode(message, writer = new BinaryWriter()) {
269
+ for (const v of message.values) Value.encode(Value.wrap(v), writer.uint32(10).fork()).join();
270
+ return writer;
271
+ },
272
+ decode(input, length) {
273
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
274
+ const end = length === void 0 ? reader.len : reader.pos + length;
275
+ const message = createBaseListValue();
276
+ while (reader.pos < end) {
277
+ const tag = reader.uint32();
278
+ switch (tag >>> 3) {
279
+ case 1:
280
+ if (tag !== 10) break;
281
+ message.values.push(Value.unwrap(Value.decode(reader, reader.uint32())));
282
+ continue;
283
+ }
284
+ if ((tag & 7) === 4 || tag === 0) break;
285
+ reader.skip(tag & 7);
286
+ }
287
+ return message;
288
+ },
289
+ fromJSON(object) {
290
+ return { values: globalThis.Array.isArray(object?.values) ? [...object.values] : [] };
291
+ },
292
+ toJSON(message) {
293
+ const obj = {};
294
+ if (message.values?.length) obj.values = message.values;
295
+ return obj;
296
+ },
297
+ create(base) {
298
+ return ListValue.fromPartial(base ?? {});
299
+ },
300
+ fromPartial(object) {
301
+ const message = createBaseListValue();
302
+ message.values = object.values?.map((e) => e) || [];
303
+ return message;
304
+ },
305
+ wrap(array) {
306
+ const result = createBaseListValue();
307
+ result.values = array ?? [];
308
+ return result;
309
+ },
310
+ unwrap(message) {
311
+ if (message?.hasOwnProperty("values") && globalThis.Array.isArray(message.values)) return message.values;
312
+ else return message;
313
+ }
314
+ };
315
+ function isObject$1(value) {
316
+ return typeof value === "object" && value !== null;
317
+ }
318
+ function isSet$3(value) {
319
+ return value !== null && value !== void 0;
320
+ }
321
+ let ResolveReason = /* @__PURE__ */ function(ResolveReason$1) {
322
+ ResolveReason$1[ResolveReason$1["RESOLVE_REASON_UNSPECIFIED"] = 0] = "RESOLVE_REASON_UNSPECIFIED";
323
+ ResolveReason$1[ResolveReason$1["RESOLVE_REASON_MATCH"] = 1] = "RESOLVE_REASON_MATCH";
324
+ ResolveReason$1[ResolveReason$1["RESOLVE_REASON_NO_SEGMENT_MATCH"] = 2] = "RESOLVE_REASON_NO_SEGMENT_MATCH";
325
+ ResolveReason$1[ResolveReason$1["RESOLVE_REASON_NO_TREATMENT_MATCH"] = 3] = "RESOLVE_REASON_NO_TREATMENT_MATCH";
326
+ ResolveReason$1[ResolveReason$1["RESOLVE_REASON_FLAG_ARCHIVED"] = 4] = "RESOLVE_REASON_FLAG_ARCHIVED";
327
+ ResolveReason$1[ResolveReason$1["RESOLVE_REASON_TARGETING_KEY_ERROR"] = 5] = "RESOLVE_REASON_TARGETING_KEY_ERROR";
328
+ ResolveReason$1[ResolveReason$1["RESOLVE_REASON_ERROR"] = 6] = "RESOLVE_REASON_ERROR";
329
+ ResolveReason$1[ResolveReason$1["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
330
+ return ResolveReason$1;
331
+ }({});
332
+ function resolveReasonFromJSON(object) {
333
+ switch (object) {
334
+ case 0:
335
+ case "RESOLVE_REASON_UNSPECIFIED": return ResolveReason.RESOLVE_REASON_UNSPECIFIED;
336
+ case 1:
337
+ case "RESOLVE_REASON_MATCH": return ResolveReason.RESOLVE_REASON_MATCH;
338
+ case 2:
339
+ case "RESOLVE_REASON_NO_SEGMENT_MATCH": return ResolveReason.RESOLVE_REASON_NO_SEGMENT_MATCH;
340
+ case 3:
341
+ case "RESOLVE_REASON_NO_TREATMENT_MATCH": return ResolveReason.RESOLVE_REASON_NO_TREATMENT_MATCH;
342
+ case 4:
343
+ case "RESOLVE_REASON_FLAG_ARCHIVED": return ResolveReason.RESOLVE_REASON_FLAG_ARCHIVED;
344
+ case 5:
345
+ case "RESOLVE_REASON_TARGETING_KEY_ERROR": return ResolveReason.RESOLVE_REASON_TARGETING_KEY_ERROR;
346
+ case 6:
347
+ case "RESOLVE_REASON_ERROR": return ResolveReason.RESOLVE_REASON_ERROR;
348
+ case -1:
349
+ case "UNRECOGNIZED":
350
+ default: return ResolveReason.UNRECOGNIZED;
351
+ }
352
+ }
353
+ function resolveReasonToJSON(object) {
354
+ switch (object) {
355
+ case ResolveReason.RESOLVE_REASON_UNSPECIFIED: return "RESOLVE_REASON_UNSPECIFIED";
356
+ case ResolveReason.RESOLVE_REASON_MATCH: return "RESOLVE_REASON_MATCH";
357
+ case ResolveReason.RESOLVE_REASON_NO_SEGMENT_MATCH: return "RESOLVE_REASON_NO_SEGMENT_MATCH";
358
+ case ResolveReason.RESOLVE_REASON_NO_TREATMENT_MATCH: return "RESOLVE_REASON_NO_TREATMENT_MATCH";
359
+ case ResolveReason.RESOLVE_REASON_FLAG_ARCHIVED: return "RESOLVE_REASON_FLAG_ARCHIVED";
360
+ case ResolveReason.RESOLVE_REASON_TARGETING_KEY_ERROR: return "RESOLVE_REASON_TARGETING_KEY_ERROR";
361
+ case ResolveReason.RESOLVE_REASON_ERROR: return "RESOLVE_REASON_ERROR";
362
+ case ResolveReason.UNRECOGNIZED:
363
+ default: return "UNRECOGNIZED";
364
+ }
365
+ }
366
+ function createBaseResolveFlagsRequest() {
367
+ return {
368
+ flags: [],
369
+ evaluationContext: void 0,
370
+ clientSecret: "",
371
+ apply: false
372
+ };
373
+ }
374
+ const ResolveFlagsRequest = {
375
+ encode(message, writer = new BinaryWriter()) {
376
+ for (const v of message.flags) writer.uint32(10).string(v);
377
+ if (message.evaluationContext !== void 0) Struct.encode(Struct.wrap(message.evaluationContext), writer.uint32(18).fork()).join();
378
+ if (message.clientSecret !== "") writer.uint32(26).string(message.clientSecret);
379
+ if (message.apply !== false) writer.uint32(32).bool(message.apply);
380
+ return writer;
381
+ },
382
+ decode(input, length) {
383
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
384
+ const end = length === void 0 ? reader.len : reader.pos + length;
385
+ const message = createBaseResolveFlagsRequest();
386
+ while (reader.pos < end) {
387
+ const tag = reader.uint32();
388
+ switch (tag >>> 3) {
389
+ case 1:
390
+ if (tag !== 10) break;
391
+ message.flags.push(reader.string());
392
+ continue;
393
+ case 2:
394
+ if (tag !== 18) break;
395
+ message.evaluationContext = Struct.unwrap(Struct.decode(reader, reader.uint32()));
396
+ continue;
397
+ case 3:
398
+ if (tag !== 26) break;
399
+ message.clientSecret = reader.string();
400
+ continue;
401
+ case 4:
402
+ if (tag !== 32) break;
403
+ message.apply = reader.bool();
404
+ continue;
405
+ }
406
+ if ((tag & 7) === 4 || tag === 0) break;
407
+ reader.skip(tag & 7);
408
+ }
409
+ return message;
410
+ },
411
+ fromJSON(object) {
412
+ return {
413
+ flags: globalThis.Array.isArray(object?.flags) ? object.flags.map((e) => globalThis.String(e)) : [],
414
+ evaluationContext: isObject(object.evaluationContext) ? object.evaluationContext : void 0,
415
+ clientSecret: isSet$2(object.clientSecret) ? globalThis.String(object.clientSecret) : "",
416
+ apply: isSet$2(object.apply) ? globalThis.Boolean(object.apply) : false
417
+ };
418
+ },
419
+ toJSON(message) {
420
+ const obj = {};
421
+ if (message.flags?.length) obj.flags = message.flags;
422
+ if (message.evaluationContext !== void 0) obj.evaluationContext = message.evaluationContext;
423
+ if (message.clientSecret !== "") obj.clientSecret = message.clientSecret;
424
+ if (message.apply !== false) obj.apply = message.apply;
425
+ return obj;
426
+ },
427
+ create(base) {
428
+ return ResolveFlagsRequest.fromPartial(base ?? {});
429
+ },
430
+ fromPartial(object) {
431
+ const message = createBaseResolveFlagsRequest();
432
+ message.flags = object.flags?.map((e) => e) || [];
433
+ message.evaluationContext = object.evaluationContext ?? void 0;
434
+ message.clientSecret = object.clientSecret ?? "";
435
+ message.apply = object.apply ?? false;
436
+ return message;
437
+ }
438
+ };
439
+ function createBaseResolveFlagsResponse() {
440
+ return {
441
+ resolvedFlags: [],
442
+ resolveToken: new Uint8Array(0),
443
+ resolveId: ""
444
+ };
445
+ }
446
+ const ResolveFlagsResponse = {
447
+ encode(message, writer = new BinaryWriter()) {
448
+ for (const v of message.resolvedFlags) ResolvedFlag.encode(v, writer.uint32(10).fork()).join();
449
+ if (message.resolveToken.length !== 0) writer.uint32(18).bytes(message.resolveToken);
450
+ if (message.resolveId !== "") writer.uint32(26).string(message.resolveId);
451
+ return writer;
452
+ },
453
+ decode(input, length) {
454
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
455
+ const end = length === void 0 ? reader.len : reader.pos + length;
456
+ const message = createBaseResolveFlagsResponse();
457
+ while (reader.pos < end) {
458
+ const tag = reader.uint32();
459
+ switch (tag >>> 3) {
460
+ case 1:
461
+ if (tag !== 10) break;
462
+ message.resolvedFlags.push(ResolvedFlag.decode(reader, reader.uint32()));
463
+ continue;
464
+ case 2:
465
+ if (tag !== 18) break;
466
+ message.resolveToken = reader.bytes();
467
+ continue;
468
+ case 3:
469
+ if (tag !== 26) break;
470
+ message.resolveId = reader.string();
471
+ continue;
472
+ }
473
+ if ((tag & 7) === 4 || tag === 0) break;
474
+ reader.skip(tag & 7);
475
+ }
476
+ return message;
477
+ },
478
+ fromJSON(object) {
479
+ return {
480
+ resolvedFlags: globalThis.Array.isArray(object?.resolvedFlags) ? object.resolvedFlags.map((e) => ResolvedFlag.fromJSON(e)) : [],
481
+ resolveToken: isSet$2(object.resolveToken) ? bytesFromBase64$1(object.resolveToken) : new Uint8Array(0),
482
+ resolveId: isSet$2(object.resolveId) ? globalThis.String(object.resolveId) : ""
483
+ };
484
+ },
485
+ toJSON(message) {
486
+ const obj = {};
487
+ if (message.resolvedFlags?.length) obj.resolvedFlags = message.resolvedFlags.map((e) => ResolvedFlag.toJSON(e));
488
+ if (message.resolveToken.length !== 0) obj.resolveToken = base64FromBytes$1(message.resolveToken);
489
+ if (message.resolveId !== "") obj.resolveId = message.resolveId;
490
+ return obj;
491
+ },
492
+ create(base) {
493
+ return ResolveFlagsResponse.fromPartial(base ?? {});
494
+ },
495
+ fromPartial(object) {
496
+ const message = createBaseResolveFlagsResponse();
497
+ message.resolvedFlags = object.resolvedFlags?.map((e) => ResolvedFlag.fromPartial(e)) || [];
498
+ message.resolveToken = object.resolveToken ?? new Uint8Array(0);
499
+ message.resolveId = object.resolveId ?? "";
500
+ return message;
501
+ }
502
+ };
503
+ function createBaseResolvedFlag() {
504
+ return {
505
+ flag: "",
506
+ variant: "",
507
+ value: void 0,
508
+ reason: 0
509
+ };
510
+ }
511
+ const ResolvedFlag = {
512
+ encode(message, writer = new BinaryWriter()) {
513
+ if (message.flag !== "") writer.uint32(10).string(message.flag);
514
+ if (message.variant !== "") writer.uint32(18).string(message.variant);
515
+ if (message.value !== void 0) Struct.encode(Struct.wrap(message.value), writer.uint32(26).fork()).join();
516
+ if (message.reason !== 0) writer.uint32(40).int32(message.reason);
517
+ return writer;
518
+ },
519
+ decode(input, length) {
520
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
521
+ const end = length === void 0 ? reader.len : reader.pos + length;
522
+ const message = createBaseResolvedFlag();
523
+ while (reader.pos < end) {
524
+ const tag = reader.uint32();
525
+ switch (tag >>> 3) {
526
+ case 1:
527
+ if (tag !== 10) break;
528
+ message.flag = reader.string();
529
+ continue;
530
+ case 2:
531
+ if (tag !== 18) break;
532
+ message.variant = reader.string();
533
+ continue;
534
+ case 3:
535
+ if (tag !== 26) break;
536
+ message.value = Struct.unwrap(Struct.decode(reader, reader.uint32()));
537
+ continue;
538
+ case 5:
539
+ if (tag !== 40) break;
540
+ message.reason = reader.int32();
541
+ continue;
542
+ }
543
+ if ((tag & 7) === 4 || tag === 0) break;
544
+ reader.skip(tag & 7);
545
+ }
546
+ return message;
547
+ },
548
+ fromJSON(object) {
549
+ return {
550
+ flag: isSet$2(object.flag) ? globalThis.String(object.flag) : "",
551
+ variant: isSet$2(object.variant) ? globalThis.String(object.variant) : "",
552
+ value: isObject(object.value) ? object.value : void 0,
553
+ reason: isSet$2(object.reason) ? resolveReasonFromJSON(object.reason) : 0
554
+ };
555
+ },
556
+ toJSON(message) {
557
+ const obj = {};
558
+ if (message.flag !== "") obj.flag = message.flag;
559
+ if (message.variant !== "") obj.variant = message.variant;
560
+ if (message.value !== void 0) obj.value = message.value;
561
+ if (message.reason !== 0) obj.reason = resolveReasonToJSON(message.reason);
562
+ return obj;
563
+ },
564
+ create(base) {
565
+ return ResolvedFlag.fromPartial(base ?? {});
566
+ },
567
+ fromPartial(object) {
568
+ const message = createBaseResolvedFlag();
569
+ message.flag = object.flag ?? "";
570
+ message.variant = object.variant ?? "";
571
+ message.value = object.value ?? void 0;
572
+ message.reason = object.reason ?? 0;
573
+ return message;
574
+ }
575
+ };
576
+ function createBaseSetResolverStateRequest() {
577
+ return {
578
+ state: new Uint8Array(0),
579
+ accountId: ""
580
+ };
581
+ }
582
+ const SetResolverStateRequest = {
583
+ encode(message, writer = new BinaryWriter()) {
584
+ if (message.state.length !== 0) writer.uint32(10).bytes(message.state);
585
+ if (message.accountId !== "") writer.uint32(18).string(message.accountId);
586
+ return writer;
587
+ },
588
+ decode(input, length) {
589
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
590
+ const end = length === void 0 ? reader.len : reader.pos + length;
591
+ const message = createBaseSetResolverStateRequest();
592
+ while (reader.pos < end) {
593
+ const tag = reader.uint32();
594
+ switch (tag >>> 3) {
595
+ case 1:
596
+ if (tag !== 10) break;
597
+ message.state = reader.bytes();
598
+ continue;
599
+ case 2:
600
+ if (tag !== 18) break;
601
+ message.accountId = reader.string();
602
+ continue;
603
+ }
604
+ if ((tag & 7) === 4 || tag === 0) break;
605
+ reader.skip(tag & 7);
606
+ }
607
+ return message;
608
+ },
609
+ fromJSON(object) {
610
+ return {
611
+ state: isSet$2(object.state) ? bytesFromBase64$1(object.state) : new Uint8Array(0),
612
+ accountId: isSet$2(object.accountId) ? globalThis.String(object.accountId) : ""
613
+ };
614
+ },
615
+ toJSON(message) {
616
+ const obj = {};
617
+ if (message.state.length !== 0) obj.state = base64FromBytes$1(message.state);
618
+ if (message.accountId !== "") obj.accountId = message.accountId;
619
+ return obj;
620
+ },
621
+ create(base) {
622
+ return SetResolverStateRequest.fromPartial(base ?? {});
623
+ },
624
+ fromPartial(object) {
625
+ const message = createBaseSetResolverStateRequest();
626
+ message.state = object.state ?? new Uint8Array(0);
627
+ message.accountId = object.accountId ?? "";
628
+ return message;
629
+ }
630
+ };
631
+ function createBaseResolveWithStickyRequest() {
632
+ return {
633
+ resolveRequest: void 0,
634
+ materializationsPerUnit: {},
635
+ failFastOnSticky: false
636
+ };
637
+ }
638
+ const ResolveWithStickyRequest = {
639
+ encode(message, writer = new BinaryWriter()) {
640
+ if (message.resolveRequest !== void 0) ResolveFlagsRequest.encode(message.resolveRequest, writer.uint32(10).fork()).join();
641
+ Object.entries(message.materializationsPerUnit).forEach(([key, value]) => {
642
+ ResolveWithStickyRequest_MaterializationsPerUnitEntry.encode({
643
+ key,
644
+ value
645
+ }, writer.uint32(18).fork()).join();
646
+ });
647
+ if (message.failFastOnSticky !== false) writer.uint32(24).bool(message.failFastOnSticky);
648
+ return writer;
649
+ },
650
+ decode(input, length) {
651
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
652
+ const end = length === void 0 ? reader.len : reader.pos + length;
653
+ const message = createBaseResolveWithStickyRequest();
654
+ while (reader.pos < end) {
655
+ const tag = reader.uint32();
656
+ switch (tag >>> 3) {
657
+ case 1:
658
+ if (tag !== 10) break;
659
+ message.resolveRequest = ResolveFlagsRequest.decode(reader, reader.uint32());
660
+ continue;
661
+ case 2: {
662
+ if (tag !== 18) break;
663
+ const entry2 = ResolveWithStickyRequest_MaterializationsPerUnitEntry.decode(reader, reader.uint32());
664
+ if (entry2.value !== void 0) message.materializationsPerUnit[entry2.key] = entry2.value;
665
+ continue;
666
+ }
667
+ case 3:
668
+ if (tag !== 24) break;
669
+ message.failFastOnSticky = reader.bool();
670
+ continue;
671
+ }
672
+ if ((tag & 7) === 4 || tag === 0) break;
673
+ reader.skip(tag & 7);
674
+ }
675
+ return message;
676
+ },
677
+ fromJSON(object) {
678
+ return {
679
+ resolveRequest: isSet$2(object.resolveRequest) ? ResolveFlagsRequest.fromJSON(object.resolveRequest) : void 0,
680
+ materializationsPerUnit: isObject(object.materializationsPerUnit) ? Object.entries(object.materializationsPerUnit).reduce((acc, [key, value]) => {
681
+ acc[key] = MaterializationMap.fromJSON(value);
682
+ return acc;
683
+ }, {}) : {},
684
+ failFastOnSticky: isSet$2(object.failFastOnSticky) ? globalThis.Boolean(object.failFastOnSticky) : false
685
+ };
686
+ },
687
+ toJSON(message) {
688
+ const obj = {};
689
+ if (message.resolveRequest !== void 0) obj.resolveRequest = ResolveFlagsRequest.toJSON(message.resolveRequest);
690
+ if (message.materializationsPerUnit) {
691
+ const entries = Object.entries(message.materializationsPerUnit);
692
+ if (entries.length > 0) {
693
+ obj.materializationsPerUnit = {};
694
+ entries.forEach(([k, v]) => {
695
+ obj.materializationsPerUnit[k] = MaterializationMap.toJSON(v);
696
+ });
697
+ }
698
+ }
699
+ if (message.failFastOnSticky !== false) obj.failFastOnSticky = message.failFastOnSticky;
700
+ return obj;
701
+ },
702
+ create(base) {
703
+ return ResolveWithStickyRequest.fromPartial(base ?? {});
704
+ },
705
+ fromPartial(object) {
706
+ const message = createBaseResolveWithStickyRequest();
707
+ message.resolveRequest = object.resolveRequest !== void 0 && object.resolveRequest !== null ? ResolveFlagsRequest.fromPartial(object.resolveRequest) : void 0;
708
+ message.materializationsPerUnit = Object.entries(object.materializationsPerUnit ?? {}).reduce((acc, [key, value]) => {
709
+ if (value !== void 0) acc[key] = MaterializationMap.fromPartial(value);
710
+ return acc;
711
+ }, {});
712
+ message.failFastOnSticky = object.failFastOnSticky ?? false;
713
+ return message;
714
+ }
715
+ };
716
+ function createBaseResolveWithStickyRequest_MaterializationsPerUnitEntry() {
717
+ return {
718
+ key: "",
719
+ value: void 0
720
+ };
721
+ }
722
+ const ResolveWithStickyRequest_MaterializationsPerUnitEntry = {
723
+ encode(message, writer = new BinaryWriter()) {
724
+ if (message.key !== "") writer.uint32(10).string(message.key);
725
+ if (message.value !== void 0) MaterializationMap.encode(message.value, writer.uint32(18).fork()).join();
726
+ return writer;
727
+ },
728
+ decode(input, length) {
729
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
730
+ const end = length === void 0 ? reader.len : reader.pos + length;
731
+ const message = createBaseResolveWithStickyRequest_MaterializationsPerUnitEntry();
732
+ while (reader.pos < end) {
733
+ const tag = reader.uint32();
734
+ switch (tag >>> 3) {
735
+ case 1:
736
+ if (tag !== 10) break;
737
+ message.key = reader.string();
738
+ continue;
739
+ case 2:
740
+ if (tag !== 18) break;
741
+ message.value = MaterializationMap.decode(reader, reader.uint32());
742
+ continue;
743
+ }
744
+ if ((tag & 7) === 4 || tag === 0) break;
745
+ reader.skip(tag & 7);
746
+ }
747
+ return message;
748
+ },
749
+ fromJSON(object) {
750
+ return {
751
+ key: isSet$2(object.key) ? globalThis.String(object.key) : "",
752
+ value: isSet$2(object.value) ? MaterializationMap.fromJSON(object.value) : void 0
753
+ };
754
+ },
755
+ toJSON(message) {
756
+ const obj = {};
757
+ if (message.key !== "") obj.key = message.key;
758
+ if (message.value !== void 0) obj.value = MaterializationMap.toJSON(message.value);
759
+ return obj;
760
+ },
761
+ create(base) {
762
+ return ResolveWithStickyRequest_MaterializationsPerUnitEntry.fromPartial(base ?? {});
763
+ },
764
+ fromPartial(object) {
765
+ const message = createBaseResolveWithStickyRequest_MaterializationsPerUnitEntry();
766
+ message.key = object.key ?? "";
767
+ message.value = object.value !== void 0 && object.value !== null ? MaterializationMap.fromPartial(object.value) : void 0;
768
+ return message;
769
+ }
770
+ };
771
+ function createBaseMaterializationMap() {
772
+ return { infoMap: {} };
773
+ }
774
+ const MaterializationMap = {
775
+ encode(message, writer = new BinaryWriter()) {
776
+ Object.entries(message.infoMap).forEach(([key, value]) => {
777
+ MaterializationMap_InfoMapEntry.encode({
778
+ key,
779
+ value
780
+ }, writer.uint32(10).fork()).join();
781
+ });
782
+ return writer;
783
+ },
784
+ decode(input, length) {
785
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
786
+ const end = length === void 0 ? reader.len : reader.pos + length;
787
+ const message = createBaseMaterializationMap();
788
+ while (reader.pos < end) {
789
+ const tag = reader.uint32();
790
+ switch (tag >>> 3) {
791
+ case 1: {
792
+ if (tag !== 10) break;
793
+ const entry1 = MaterializationMap_InfoMapEntry.decode(reader, reader.uint32());
794
+ if (entry1.value !== void 0) message.infoMap[entry1.key] = entry1.value;
795
+ continue;
796
+ }
797
+ }
798
+ if ((tag & 7) === 4 || tag === 0) break;
799
+ reader.skip(tag & 7);
800
+ }
801
+ return message;
802
+ },
803
+ fromJSON(object) {
804
+ return { infoMap: isObject(object.infoMap) ? Object.entries(object.infoMap).reduce((acc, [key, value]) => {
805
+ acc[key] = MaterializationInfo.fromJSON(value);
806
+ return acc;
807
+ }, {}) : {} };
808
+ },
809
+ toJSON(message) {
810
+ const obj = {};
811
+ if (message.infoMap) {
812
+ const entries = Object.entries(message.infoMap);
813
+ if (entries.length > 0) {
814
+ obj.infoMap = {};
815
+ entries.forEach(([k, v]) => {
816
+ obj.infoMap[k] = MaterializationInfo.toJSON(v);
817
+ });
818
+ }
819
+ }
820
+ return obj;
821
+ },
822
+ create(base) {
823
+ return MaterializationMap.fromPartial(base ?? {});
824
+ },
825
+ fromPartial(object) {
826
+ const message = createBaseMaterializationMap();
827
+ message.infoMap = Object.entries(object.infoMap ?? {}).reduce((acc, [key, value]) => {
828
+ if (value !== void 0) acc[key] = MaterializationInfo.fromPartial(value);
829
+ return acc;
830
+ }, {});
831
+ return message;
832
+ }
833
+ };
834
+ function createBaseMaterializationMap_InfoMapEntry() {
835
+ return {
836
+ key: "",
837
+ value: void 0
838
+ };
839
+ }
840
+ const MaterializationMap_InfoMapEntry = {
841
+ encode(message, writer = new BinaryWriter()) {
842
+ if (message.key !== "") writer.uint32(10).string(message.key);
843
+ if (message.value !== void 0) MaterializationInfo.encode(message.value, writer.uint32(18).fork()).join();
844
+ return writer;
845
+ },
846
+ decode(input, length) {
847
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
848
+ const end = length === void 0 ? reader.len : reader.pos + length;
849
+ const message = createBaseMaterializationMap_InfoMapEntry();
850
+ while (reader.pos < end) {
851
+ const tag = reader.uint32();
852
+ switch (tag >>> 3) {
853
+ case 1:
854
+ if (tag !== 10) break;
855
+ message.key = reader.string();
856
+ continue;
857
+ case 2:
858
+ if (tag !== 18) break;
859
+ message.value = MaterializationInfo.decode(reader, reader.uint32());
860
+ continue;
861
+ }
862
+ if ((tag & 7) === 4 || tag === 0) break;
863
+ reader.skip(tag & 7);
864
+ }
865
+ return message;
866
+ },
867
+ fromJSON(object) {
868
+ return {
869
+ key: isSet$2(object.key) ? globalThis.String(object.key) : "",
870
+ value: isSet$2(object.value) ? MaterializationInfo.fromJSON(object.value) : void 0
871
+ };
872
+ },
873
+ toJSON(message) {
874
+ const obj = {};
875
+ if (message.key !== "") obj.key = message.key;
876
+ if (message.value !== void 0) obj.value = MaterializationInfo.toJSON(message.value);
877
+ return obj;
878
+ },
879
+ create(base) {
880
+ return MaterializationMap_InfoMapEntry.fromPartial(base ?? {});
881
+ },
882
+ fromPartial(object) {
883
+ const message = createBaseMaterializationMap_InfoMapEntry();
884
+ message.key = object.key ?? "";
885
+ message.value = object.value !== void 0 && object.value !== null ? MaterializationInfo.fromPartial(object.value) : void 0;
886
+ return message;
887
+ }
888
+ };
889
+ function createBaseMaterializationInfo() {
890
+ return {
891
+ unitInInfo: false,
892
+ ruleToVariant: {}
893
+ };
894
+ }
895
+ const MaterializationInfo = {
896
+ encode(message, writer = new BinaryWriter()) {
897
+ if (message.unitInInfo !== false) writer.uint32(8).bool(message.unitInInfo);
898
+ Object.entries(message.ruleToVariant).forEach(([key, value]) => {
899
+ MaterializationInfo_RuleToVariantEntry.encode({
900
+ key,
901
+ value
902
+ }, writer.uint32(18).fork()).join();
903
+ });
904
+ return writer;
905
+ },
906
+ decode(input, length) {
907
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
908
+ const end = length === void 0 ? reader.len : reader.pos + length;
909
+ const message = createBaseMaterializationInfo();
910
+ while (reader.pos < end) {
911
+ const tag = reader.uint32();
912
+ switch (tag >>> 3) {
913
+ case 1:
914
+ if (tag !== 8) break;
915
+ message.unitInInfo = reader.bool();
916
+ continue;
917
+ case 2: {
918
+ if (tag !== 18) break;
919
+ const entry2 = MaterializationInfo_RuleToVariantEntry.decode(reader, reader.uint32());
920
+ if (entry2.value !== void 0) message.ruleToVariant[entry2.key] = entry2.value;
921
+ continue;
922
+ }
923
+ }
924
+ if ((tag & 7) === 4 || tag === 0) break;
925
+ reader.skip(tag & 7);
926
+ }
927
+ return message;
928
+ },
929
+ fromJSON(object) {
930
+ return {
931
+ unitInInfo: isSet$2(object.unitInInfo) ? globalThis.Boolean(object.unitInInfo) : false,
932
+ ruleToVariant: isObject(object.ruleToVariant) ? Object.entries(object.ruleToVariant).reduce((acc, [key, value]) => {
933
+ acc[key] = String(value);
934
+ return acc;
935
+ }, {}) : {}
936
+ };
937
+ },
938
+ toJSON(message) {
939
+ const obj = {};
940
+ if (message.unitInInfo !== false) obj.unitInInfo = message.unitInInfo;
941
+ if (message.ruleToVariant) {
942
+ const entries = Object.entries(message.ruleToVariant);
943
+ if (entries.length > 0) {
944
+ obj.ruleToVariant = {};
945
+ entries.forEach(([k, v]) => {
946
+ obj.ruleToVariant[k] = v;
947
+ });
948
+ }
949
+ }
950
+ return obj;
951
+ },
952
+ create(base) {
953
+ return MaterializationInfo.fromPartial(base ?? {});
954
+ },
955
+ fromPartial(object) {
956
+ const message = createBaseMaterializationInfo();
957
+ message.unitInInfo = object.unitInInfo ?? false;
958
+ message.ruleToVariant = Object.entries(object.ruleToVariant ?? {}).reduce((acc, [key, value]) => {
959
+ if (value !== void 0) acc[key] = globalThis.String(value);
960
+ return acc;
961
+ }, {});
962
+ return message;
963
+ }
964
+ };
965
+ function createBaseMaterializationInfo_RuleToVariantEntry() {
966
+ return {
967
+ key: "",
968
+ value: ""
969
+ };
970
+ }
971
+ const MaterializationInfo_RuleToVariantEntry = {
972
+ encode(message, writer = new BinaryWriter()) {
973
+ if (message.key !== "") writer.uint32(10).string(message.key);
974
+ if (message.value !== "") writer.uint32(18).string(message.value);
975
+ return writer;
976
+ },
977
+ decode(input, length) {
978
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
979
+ const end = length === void 0 ? reader.len : reader.pos + length;
980
+ const message = createBaseMaterializationInfo_RuleToVariantEntry();
981
+ while (reader.pos < end) {
982
+ const tag = reader.uint32();
983
+ switch (tag >>> 3) {
984
+ case 1:
985
+ if (tag !== 10) break;
986
+ message.key = reader.string();
987
+ continue;
988
+ case 2:
989
+ if (tag !== 18) break;
990
+ message.value = reader.string();
991
+ continue;
992
+ }
993
+ if ((tag & 7) === 4 || tag === 0) break;
994
+ reader.skip(tag & 7);
995
+ }
996
+ return message;
997
+ },
998
+ fromJSON(object) {
999
+ return {
1000
+ key: isSet$2(object.key) ? globalThis.String(object.key) : "",
1001
+ value: isSet$2(object.value) ? globalThis.String(object.value) : ""
1002
+ };
1003
+ },
1004
+ toJSON(message) {
1005
+ const obj = {};
1006
+ if (message.key !== "") obj.key = message.key;
1007
+ if (message.value !== "") obj.value = message.value;
1008
+ return obj;
1009
+ },
1010
+ create(base) {
1011
+ return MaterializationInfo_RuleToVariantEntry.fromPartial(base ?? {});
1012
+ },
1013
+ fromPartial(object) {
1014
+ const message = createBaseMaterializationInfo_RuleToVariantEntry();
1015
+ message.key = object.key ?? "";
1016
+ message.value = object.value ?? "";
1017
+ return message;
1018
+ }
1019
+ };
1020
+ function createBaseResolveWithStickyResponse() {
1021
+ return {
1022
+ success: void 0,
1023
+ missingMaterializations: void 0
1024
+ };
1025
+ }
1026
+ const ResolveWithStickyResponse = {
1027
+ encode(message, writer = new BinaryWriter()) {
1028
+ if (message.success !== void 0) ResolveWithStickyResponse_Success.encode(message.success, writer.uint32(10).fork()).join();
1029
+ if (message.missingMaterializations !== void 0) ResolveWithStickyResponse_MissingMaterializations.encode(message.missingMaterializations, writer.uint32(18).fork()).join();
1030
+ return writer;
1031
+ },
1032
+ decode(input, length) {
1033
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1034
+ const end = length === void 0 ? reader.len : reader.pos + length;
1035
+ const message = createBaseResolveWithStickyResponse();
1036
+ while (reader.pos < end) {
1037
+ const tag = reader.uint32();
1038
+ switch (tag >>> 3) {
1039
+ case 1:
1040
+ if (tag !== 10) break;
1041
+ message.success = ResolveWithStickyResponse_Success.decode(reader, reader.uint32());
1042
+ continue;
1043
+ case 2:
1044
+ if (tag !== 18) break;
1045
+ message.missingMaterializations = ResolveWithStickyResponse_MissingMaterializations.decode(reader, reader.uint32());
1046
+ continue;
1047
+ }
1048
+ if ((tag & 7) === 4 || tag === 0) break;
1049
+ reader.skip(tag & 7);
1050
+ }
1051
+ return message;
1052
+ },
1053
+ fromJSON(object) {
1054
+ return {
1055
+ success: isSet$2(object.success) ? ResolveWithStickyResponse_Success.fromJSON(object.success) : void 0,
1056
+ missingMaterializations: isSet$2(object.missingMaterializations) ? ResolveWithStickyResponse_MissingMaterializations.fromJSON(object.missingMaterializations) : void 0
1057
+ };
1058
+ },
1059
+ toJSON(message) {
1060
+ const obj = {};
1061
+ if (message.success !== void 0) obj.success = ResolveWithStickyResponse_Success.toJSON(message.success);
1062
+ if (message.missingMaterializations !== void 0) obj.missingMaterializations = ResolveWithStickyResponse_MissingMaterializations.toJSON(message.missingMaterializations);
1063
+ return obj;
1064
+ },
1065
+ create(base) {
1066
+ return ResolveWithStickyResponse.fromPartial(base ?? {});
1067
+ },
1068
+ fromPartial(object) {
1069
+ const message = createBaseResolveWithStickyResponse();
1070
+ message.success = object.success !== void 0 && object.success !== null ? ResolveWithStickyResponse_Success.fromPartial(object.success) : void 0;
1071
+ message.missingMaterializations = object.missingMaterializations !== void 0 && object.missingMaterializations !== null ? ResolveWithStickyResponse_MissingMaterializations.fromPartial(object.missingMaterializations) : void 0;
1072
+ return message;
1073
+ }
1074
+ };
1075
+ function createBaseResolveWithStickyResponse_Success() {
1076
+ return {
1077
+ response: void 0,
1078
+ updates: []
1079
+ };
1080
+ }
1081
+ const ResolveWithStickyResponse_Success = {
1082
+ encode(message, writer = new BinaryWriter()) {
1083
+ if (message.response !== void 0) ResolveFlagsResponse.encode(message.response, writer.uint32(10).fork()).join();
1084
+ for (const v of message.updates) ResolveWithStickyResponse_MaterializationUpdate.encode(v, writer.uint32(18).fork()).join();
1085
+ return writer;
1086
+ },
1087
+ decode(input, length) {
1088
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1089
+ const end = length === void 0 ? reader.len : reader.pos + length;
1090
+ const message = createBaseResolveWithStickyResponse_Success();
1091
+ while (reader.pos < end) {
1092
+ const tag = reader.uint32();
1093
+ switch (tag >>> 3) {
1094
+ case 1:
1095
+ if (tag !== 10) break;
1096
+ message.response = ResolveFlagsResponse.decode(reader, reader.uint32());
1097
+ continue;
1098
+ case 2:
1099
+ if (tag !== 18) break;
1100
+ message.updates.push(ResolveWithStickyResponse_MaterializationUpdate.decode(reader, reader.uint32()));
1101
+ continue;
1102
+ }
1103
+ if ((tag & 7) === 4 || tag === 0) break;
1104
+ reader.skip(tag & 7);
1105
+ }
1106
+ return message;
1107
+ },
1108
+ fromJSON(object) {
1109
+ return {
1110
+ response: isSet$2(object.response) ? ResolveFlagsResponse.fromJSON(object.response) : void 0,
1111
+ updates: globalThis.Array.isArray(object?.updates) ? object.updates.map((e) => ResolveWithStickyResponse_MaterializationUpdate.fromJSON(e)) : []
1112
+ };
1113
+ },
1114
+ toJSON(message) {
1115
+ const obj = {};
1116
+ if (message.response !== void 0) obj.response = ResolveFlagsResponse.toJSON(message.response);
1117
+ if (message.updates?.length) obj.updates = message.updates.map((e) => ResolveWithStickyResponse_MaterializationUpdate.toJSON(e));
1118
+ return obj;
1119
+ },
1120
+ create(base) {
1121
+ return ResolveWithStickyResponse_Success.fromPartial(base ?? {});
1122
+ },
1123
+ fromPartial(object) {
1124
+ const message = createBaseResolveWithStickyResponse_Success();
1125
+ message.response = object.response !== void 0 && object.response !== null ? ResolveFlagsResponse.fromPartial(object.response) : void 0;
1126
+ message.updates = object.updates?.map((e) => ResolveWithStickyResponse_MaterializationUpdate.fromPartial(e)) || [];
1127
+ return message;
1128
+ }
1129
+ };
1130
+ function createBaseResolveWithStickyResponse_MissingMaterializations() {
1131
+ return { items: [] };
1132
+ }
1133
+ const ResolveWithStickyResponse_MissingMaterializations = {
1134
+ encode(message, writer = new BinaryWriter()) {
1135
+ for (const v of message.items) ResolveWithStickyResponse_MissingMaterializationItem.encode(v, writer.uint32(10).fork()).join();
1136
+ return writer;
1137
+ },
1138
+ decode(input, length) {
1139
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1140
+ const end = length === void 0 ? reader.len : reader.pos + length;
1141
+ const message = createBaseResolveWithStickyResponse_MissingMaterializations();
1142
+ while (reader.pos < end) {
1143
+ const tag = reader.uint32();
1144
+ switch (tag >>> 3) {
1145
+ case 1:
1146
+ if (tag !== 10) break;
1147
+ message.items.push(ResolveWithStickyResponse_MissingMaterializationItem.decode(reader, reader.uint32()));
1148
+ continue;
1149
+ }
1150
+ if ((tag & 7) === 4 || tag === 0) break;
1151
+ reader.skip(tag & 7);
1152
+ }
1153
+ return message;
1154
+ },
1155
+ fromJSON(object) {
1156
+ return { items: globalThis.Array.isArray(object?.items) ? object.items.map((e) => ResolveWithStickyResponse_MissingMaterializationItem.fromJSON(e)) : [] };
1157
+ },
1158
+ toJSON(message) {
1159
+ const obj = {};
1160
+ if (message.items?.length) obj.items = message.items.map((e) => ResolveWithStickyResponse_MissingMaterializationItem.toJSON(e));
1161
+ return obj;
1162
+ },
1163
+ create(base) {
1164
+ return ResolveWithStickyResponse_MissingMaterializations.fromPartial(base ?? {});
1165
+ },
1166
+ fromPartial(object) {
1167
+ const message = createBaseResolveWithStickyResponse_MissingMaterializations();
1168
+ message.items = object.items?.map((e) => ResolveWithStickyResponse_MissingMaterializationItem.fromPartial(e)) || [];
1169
+ return message;
1170
+ }
1171
+ };
1172
+ function createBaseResolveWithStickyResponse_MissingMaterializationItem() {
1173
+ return {
1174
+ unit: "",
1175
+ rule: "",
1176
+ readMaterialization: ""
1177
+ };
1178
+ }
1179
+ const ResolveWithStickyResponse_MissingMaterializationItem = {
1180
+ encode(message, writer = new BinaryWriter()) {
1181
+ if (message.unit !== "") writer.uint32(10).string(message.unit);
1182
+ if (message.rule !== "") writer.uint32(18).string(message.rule);
1183
+ if (message.readMaterialization !== "") writer.uint32(26).string(message.readMaterialization);
1184
+ return writer;
1185
+ },
1186
+ decode(input, length) {
1187
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1188
+ const end = length === void 0 ? reader.len : reader.pos + length;
1189
+ const message = createBaseResolveWithStickyResponse_MissingMaterializationItem();
1190
+ while (reader.pos < end) {
1191
+ const tag = reader.uint32();
1192
+ switch (tag >>> 3) {
1193
+ case 1:
1194
+ if (tag !== 10) break;
1195
+ message.unit = reader.string();
1196
+ continue;
1197
+ case 2:
1198
+ if (tag !== 18) break;
1199
+ message.rule = reader.string();
1200
+ continue;
1201
+ case 3:
1202
+ if (tag !== 26) break;
1203
+ message.readMaterialization = reader.string();
1204
+ continue;
1205
+ }
1206
+ if ((tag & 7) === 4 || tag === 0) break;
1207
+ reader.skip(tag & 7);
1208
+ }
1209
+ return message;
1210
+ },
1211
+ fromJSON(object) {
1212
+ return {
1213
+ unit: isSet$2(object.unit) ? globalThis.String(object.unit) : "",
1214
+ rule: isSet$2(object.rule) ? globalThis.String(object.rule) : "",
1215
+ readMaterialization: isSet$2(object.readMaterialization) ? globalThis.String(object.readMaterialization) : ""
1216
+ };
1217
+ },
1218
+ toJSON(message) {
1219
+ const obj = {};
1220
+ if (message.unit !== "") obj.unit = message.unit;
1221
+ if (message.rule !== "") obj.rule = message.rule;
1222
+ if (message.readMaterialization !== "") obj.readMaterialization = message.readMaterialization;
1223
+ return obj;
1224
+ },
1225
+ create(base) {
1226
+ return ResolveWithStickyResponse_MissingMaterializationItem.fromPartial(base ?? {});
1227
+ },
1228
+ fromPartial(object) {
1229
+ const message = createBaseResolveWithStickyResponse_MissingMaterializationItem();
1230
+ message.unit = object.unit ?? "";
1231
+ message.rule = object.rule ?? "";
1232
+ message.readMaterialization = object.readMaterialization ?? "";
1233
+ return message;
1234
+ }
1235
+ };
1236
+ function createBaseResolveWithStickyResponse_MaterializationUpdate() {
1237
+ return {
1238
+ unit: "",
1239
+ writeMaterialization: "",
1240
+ rule: "",
1241
+ variant: ""
1242
+ };
1243
+ }
1244
+ const ResolveWithStickyResponse_MaterializationUpdate = {
1245
+ encode(message, writer = new BinaryWriter()) {
1246
+ if (message.unit !== "") writer.uint32(10).string(message.unit);
1247
+ if (message.writeMaterialization !== "") writer.uint32(18).string(message.writeMaterialization);
1248
+ if (message.rule !== "") writer.uint32(26).string(message.rule);
1249
+ if (message.variant !== "") writer.uint32(34).string(message.variant);
1250
+ return writer;
1251
+ },
1252
+ decode(input, length) {
1253
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1254
+ const end = length === void 0 ? reader.len : reader.pos + length;
1255
+ const message = createBaseResolveWithStickyResponse_MaterializationUpdate();
1256
+ while (reader.pos < end) {
1257
+ const tag = reader.uint32();
1258
+ switch (tag >>> 3) {
1259
+ case 1:
1260
+ if (tag !== 10) break;
1261
+ message.unit = reader.string();
1262
+ continue;
1263
+ case 2:
1264
+ if (tag !== 18) break;
1265
+ message.writeMaterialization = reader.string();
1266
+ continue;
1267
+ case 3:
1268
+ if (tag !== 26) break;
1269
+ message.rule = reader.string();
1270
+ continue;
1271
+ case 4:
1272
+ if (tag !== 34) break;
1273
+ message.variant = reader.string();
1274
+ continue;
1275
+ }
1276
+ if ((tag & 7) === 4 || tag === 0) break;
1277
+ reader.skip(tag & 7);
1278
+ }
1279
+ return message;
1280
+ },
1281
+ fromJSON(object) {
1282
+ return {
1283
+ unit: isSet$2(object.unit) ? globalThis.String(object.unit) : "",
1284
+ writeMaterialization: isSet$2(object.writeMaterialization) ? globalThis.String(object.writeMaterialization) : "",
1285
+ rule: isSet$2(object.rule) ? globalThis.String(object.rule) : "",
1286
+ variant: isSet$2(object.variant) ? globalThis.String(object.variant) : ""
1287
+ };
1288
+ },
1289
+ toJSON(message) {
1290
+ const obj = {};
1291
+ if (message.unit !== "") obj.unit = message.unit;
1292
+ if (message.writeMaterialization !== "") obj.writeMaterialization = message.writeMaterialization;
1293
+ if (message.rule !== "") obj.rule = message.rule;
1294
+ if (message.variant !== "") obj.variant = message.variant;
1295
+ return obj;
1296
+ },
1297
+ create(base) {
1298
+ return ResolveWithStickyResponse_MaterializationUpdate.fromPartial(base ?? {});
1299
+ },
1300
+ fromPartial(object) {
1301
+ const message = createBaseResolveWithStickyResponse_MaterializationUpdate();
1302
+ message.unit = object.unit ?? "";
1303
+ message.writeMaterialization = object.writeMaterialization ?? "";
1304
+ message.rule = object.rule ?? "";
1305
+ message.variant = object.variant ?? "";
1306
+ return message;
1307
+ }
1308
+ };
1309
+ function bytesFromBase64$1(b64) {
1310
+ if (globalThis.Buffer) return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
1311
+ else {
1312
+ const bin = globalThis.atob(b64);
1313
+ const arr = new Uint8Array(bin.length);
1314
+ for (let i = 0; i < bin.length; ++i) arr[i] = bin.charCodeAt(i);
1315
+ return arr;
1316
+ }
1317
+ }
1318
+ function base64FromBytes$1(arr) {
1319
+ if (globalThis.Buffer) return globalThis.Buffer.from(arr).toString("base64");
1320
+ else {
1321
+ const bin = [];
1322
+ arr.forEach((byte) => {
1323
+ bin.push(globalThis.String.fromCharCode(byte));
1324
+ });
1325
+ return globalThis.btoa(bin.join(""));
1326
+ }
1327
+ }
1328
+ function isObject(value) {
1329
+ return typeof value === "object" && value !== null;
1330
+ }
1331
+ function isSet$2(value) {
1332
+ return value !== null && value !== void 0;
1333
+ }
1334
+ const NOOP_LOG_FN = () => {};
1335
+ const debugBackend = loadDebug();
1336
+ const logger = new class LoggerImpl {
1337
+ childLoggers = /* @__PURE__ */ new Map();
1338
+ debug = NOOP_LOG_FN;
1339
+ info = NOOP_LOG_FN;
1340
+ warn = NOOP_LOG_FN;
1341
+ error = NOOP_LOG_FN;
1342
+ constructor(name) {
1343
+ this.name = name;
1344
+ this.configure();
1345
+ }
1346
+ async configure() {
1347
+ const debug = await debugBackend;
1348
+ if (!debug) return;
1349
+ const debugFn = this.debug = (debug(this.name + ":debug"));
1350
+ const infoFn = this.info = (debug(this.name + ":info"));
1351
+ const warnFn = this.warn = (debug(this.name + ":warn"));
1352
+ const errorFn = this.error = (debug(this.name + ":error"));
1353
+ switch (true) {
1354
+ case debugFn.enabled: infoFn.enabled = true;
1355
+ case infoFn.enabled: warnFn.enabled = true;
1356
+ case warnFn.enabled: errorFn.enabled = true;
1357
+ }
1358
+ }
1359
+ getLogger(name) {
1360
+ let child = (this.childLoggers.get(name));
1361
+ if (!child) {
1362
+ child = new LoggerImpl(this.name + ":" + name);
1363
+ this.childLoggers.set(name, child);
1364
+ }
1365
+ return child;
1366
+ }
1367
+ }("cnfd");
1368
+ async function loadDebug() {
1369
+ try {
1370
+ const { default: debug } = await import("debug");
1371
+ return debug;
1372
+ } catch (e) {
1373
+ return null;
1374
+ }
1375
+ }
1376
+ let TimeUnit = /* @__PURE__ */ function(TimeUnit$1) {
1377
+ TimeUnit$1[TimeUnit$1["SECOND"] = 1e3] = "SECOND";
1378
+ TimeUnit$1[TimeUnit$1["MINUTE"] = 6e4] = "MINUTE";
1379
+ TimeUnit$1[TimeUnit$1["HOUR"] = 36e5] = "HOUR";
1380
+ TimeUnit$1[TimeUnit$1["DAY"] = 864e5] = "DAY";
1381
+ return TimeUnit$1;
1382
+ }({});
1383
+ function scheduleWithFixedInterval(operation, intervalMs, opt = {}) {
1384
+ const maxConcurrent = opt.maxConcurrent ?? 1;
1385
+ const ac = new AbortController();
1386
+ let nextRunTimeoutId = 0;
1387
+ let lastRunTime = 0;
1388
+ let concurrent = 0;
1389
+ const run = async () => {
1390
+ lastRunTime = Date.now();
1391
+ nextRunTimeoutId = portableSetTimeout(run, intervalMs);
1392
+ if (concurrent >= maxConcurrent) return;
1393
+ concurrent++;
1394
+ try {
1395
+ await operation(ac.signal);
1396
+ } catch (e) {
1397
+ logger.warn("scheduleWithFixedInterval failure:", e);
1398
+ }
1399
+ concurrent--;
1400
+ if (Date.now() - lastRunTime > intervalMs && nextRunTimeoutId != 0) {
1401
+ clearTimeout(nextRunTimeoutId);
1402
+ run();
1403
+ }
1404
+ };
1405
+ nextRunTimeoutId = portableSetTimeout(run, intervalMs);
1406
+ const stop = () => {
1407
+ clearTimeout(nextRunTimeoutId);
1408
+ nextRunTimeoutId = 0;
1409
+ ac.abort();
1410
+ };
1411
+ opt.signal?.addEventListener("abort", stop);
1412
+ return stop;
1413
+ }
1414
+ function timeoutSignal(milliseconds) {
1415
+ const ac = new AbortController();
1416
+ portableSetTimeout(() => {
1417
+ ac.abort(/* @__PURE__ */ new Error("Timeout"));
1418
+ }, milliseconds, { unref: false });
1419
+ return ac.signal;
1420
+ }
1421
+ function portableSetTimeout(callback, milliseconds, opt = {}) {
1422
+ const timeout = setTimeout(callback, milliseconds);
1423
+ if (opt.unref && typeof timeout === "object" && timeout !== null && "unref" in timeout && typeof timeout.unref === "function") timeout.unref();
1424
+ return Number(timeout);
1425
+ }
1426
+ function abortableSleep(milliseconds, signal) {
1427
+ if (signal?.aborted) return Promise.reject(signal.reason);
1428
+ if (milliseconds <= 0) return Promise.resolve();
1429
+ if (milliseconds === Infinity) return signal ? promiseSignal(signal) : new Promise(() => {});
1430
+ return new Promise((resolve, reject) => {
1431
+ let timeout;
1432
+ const onTimeout = () => {
1433
+ cleanup();
1434
+ resolve();
1435
+ };
1436
+ const onAbort = () => {
1437
+ cleanup();
1438
+ reject(signal?.reason);
1439
+ };
1440
+ const cleanup = () => {
1441
+ clearTimeout(timeout);
1442
+ signal?.removeEventListener("abort", onAbort);
1443
+ };
1444
+ signal?.addEventListener("abort", onAbort);
1445
+ timeout = portableSetTimeout(onTimeout, milliseconds);
1446
+ });
1447
+ }
1448
+ function promiseSignal(signal) {
1449
+ if (signal.aborted) return Promise.reject(signal.reason);
1450
+ return new Promise((_, reject) => {
1451
+ signal.addEventListener("abort", () => {
1452
+ reject(signal.reason);
1453
+ }, { once: true });
1454
+ });
1455
+ }
1456
+ function abortablePromise(promise, signal) {
1457
+ return signal ? Promise.race([promise, promiseSignal(signal)]) : promise;
1458
+ }
1459
+ const logger$1 = logger.getLogger("fetch");
1460
+ let Fetch;
1461
+ (function(_Fetch) {
1462
+ function create(middleware, sink = fetch) {
1463
+ return middleware.reduceRight((next, middleware$1) => middleware$1(next), sink);
1464
+ }
1465
+ _Fetch.create = create;
1466
+ })(Fetch || (Fetch = {}));
1467
+ let FetchMiddleware;
1468
+ (function(_FetchMiddleware) {
1469
+ function compose(outer, inner) {
1470
+ return (next) => outer(inner(next));
1471
+ }
1472
+ _FetchMiddleware.compose = compose;
1473
+ })(FetchMiddleware || (FetchMiddleware = {}));
1474
+ function withTimeout(timeoutMs) {
1475
+ return (next) => (url, init = {}) => {
1476
+ const signal = timeoutSignal$1(timeoutMs, init.signal);
1477
+ return next(url, {
1478
+ ...init,
1479
+ signal
1480
+ });
1481
+ };
1482
+ }
1483
+ function withStallTimeout(stallTimeoutMs) {
1484
+ return (next) => async (url, init = {}) => {
1485
+ const ac = new AbortController();
1486
+ const signal = init.signal ? AbortSignal.any([ac.signal, init.signal]) : ac.signal;
1487
+ const abort = () => {
1488
+ ac.abort(/* @__PURE__ */ new Error(`The operation timed out after not receiving data for ${stallTimeoutMs}ms`));
1489
+ };
1490
+ let timeoutId = portableSetTimeout(abort, stallTimeoutMs);
1491
+ const resp = await next(url, {
1492
+ ...init,
1493
+ signal
1494
+ });
1495
+ clearTimeout(timeoutId);
1496
+ if (resp.body) {
1497
+ const chunks = [];
1498
+ timeoutId = portableSetTimeout(abort, stallTimeoutMs);
1499
+ for await (const chunk of resp.body) {
1500
+ chunks.push(chunk);
1501
+ clearTimeout(timeoutId);
1502
+ timeoutId = portableSetTimeout(abort, stallTimeoutMs);
1503
+ }
1504
+ return new Response(new Blob(chunks), {
1505
+ status: resp.status,
1506
+ statusText: resp.statusText,
1507
+ headers: resp.headers
1508
+ });
1509
+ }
1510
+ return resp;
1511
+ };
1512
+ }
1513
+ function withRetry(opts) {
1514
+ const maxAttempts = opts?.maxAttempts ?? 6;
1515
+ const baseInterval = opts?.baseInterval ?? 250;
1516
+ const maxInterval = opts?.maxInterval ?? 3e4;
1517
+ const backoff = opts?.backoff ?? 2;
1518
+ const jitter = opts?.jitter ?? .1;
1519
+ return (next) => async (url, { body, signal,...init } = {}) => {
1520
+ const cloneBody = await bodyRepeater(body);
1521
+ let attempts = 0;
1522
+ let deadline = 0;
1523
+ const calculateDeadline = () => {
1524
+ const delay = (1 + 2 * Math.random() * jitter - jitter) * Math.min(maxInterval, baseInterval * Math.pow(backoff, attempts));
1525
+ return Date.now() + delay;
1526
+ };
1527
+ const onSuccess = async (resp) => {
1528
+ const { status, statusText } = resp;
1529
+ if (status !== 408 && status !== 429 && status < 500 || attempts >= maxAttempts) return resp;
1530
+ logger$1.debug("withRetry %s failed attempt %d with %d %s", url, attempts - 1, status, statusText);
1531
+ const serverDelay = parseRetryAfter(resp.headers.get("Retry-After"), baseInterval, maxInterval);
1532
+ await abortableSleep(serverDelay ?? deadline - Date.now(), signal);
1533
+ return doTry();
1534
+ };
1535
+ const onError = async (error) => {
1536
+ logger$1.debug("withRetry %s failed attempt %d with %s", url, attempts - 1, error);
1537
+ if (signal?.aborted || attempts >= maxAttempts) throw error;
1538
+ await abortableSleep(deadline - Date.now(), signal);
1539
+ return doTry();
1540
+ };
1541
+ const doTry = () => {
1542
+ let attemptSignal = signal;
1543
+ deadline = calculateDeadline();
1544
+ attempts++;
1545
+ if (opts?.abortAtInterval) attemptSignal = timeoutSignal$1(deadline - Date.now(), signal);
1546
+ return next(url, {
1547
+ body: cloneBody(),
1548
+ signal: attemptSignal,
1549
+ ...init
1550
+ }).then(onSuccess, onError);
1551
+ };
1552
+ return doTry();
1553
+ };
1554
+ }
1555
+ function withAuth(tokenProvider, signal) {
1556
+ let renewTimeout = 0;
1557
+ let current = null;
1558
+ signal?.addEventListener("abort", () => {
1559
+ clearTimeout(renewTimeout);
1560
+ });
1561
+ const renewToken = () => {
1562
+ logger$1.debug("withAuth renewing token");
1563
+ clearTimeout(renewTimeout);
1564
+ current = tokenProvider().then(([token, expiry]) => {
1565
+ logger$1.debug("withAuth renew success %s", expiry && expiry.valueOf() - Date.now());
1566
+ if (expiry) {
1567
+ const ttl = expiry.valueOf() - Date.now();
1568
+ renewTimeout = portableSetTimeout(renewToken, .8 * ttl);
1569
+ }
1570
+ return token;
1571
+ }).catch((e) => {
1572
+ current = null;
1573
+ throw e;
1574
+ });
1575
+ };
1576
+ const fetchWithToken = async (fetch$1, url, init) => {
1577
+ const token = await abortablePromise(current, init.signal);
1578
+ const headers = new Headers(init.headers);
1579
+ headers.set("Authorization", `Bearer ${token}`);
1580
+ return fetch$1(url, {
1581
+ ...init,
1582
+ headers
1583
+ });
1584
+ };
1585
+ return (next) => async (url, init = {}) => {
1586
+ const bodyClone = await bodyRepeater(init.body);
1587
+ if (!current) renewToken();
1588
+ const currentBeforeFetch = current;
1589
+ let resp = await fetchWithToken(next, url, {
1590
+ ...init,
1591
+ body: bodyClone()
1592
+ });
1593
+ if (resp.status === 401) {
1594
+ if (current === currentBeforeFetch) renewToken();
1595
+ resp = await fetchWithToken(next, url, {
1596
+ ...init,
1597
+ body: bodyClone()
1598
+ });
1599
+ }
1600
+ return resp;
1601
+ };
1602
+ }
1603
+ function withRouter(routes) {
1604
+ const hasOnlyOneStar = (s) => s.split("*").length - 1 === 1;
1605
+ const compile = (pattern) => {
1606
+ if (pattern.length >= 2 && pattern[0] === "^" && pattern[pattern.length - 1] === "$") {
1607
+ const rx = new RegExp(pattern);
1608
+ return (url) => rx.test(url);
1609
+ }
1610
+ if (pattern === "*") return (_) => true;
1611
+ if (pattern.includes("|")) {
1612
+ const predicates = pattern.split("|").map(compile);
1613
+ return (url) => predicates.some((pred) => pred(url));
1614
+ }
1615
+ if (pattern.startsWith("*") && hasOnlyOneStar(pattern)) {
1616
+ const suffix = pattern.slice(1);
1617
+ return (url) => url.endsWith(suffix);
1618
+ }
1619
+ if (pattern.endsWith("*") && hasOnlyOneStar(pattern)) {
1620
+ const prefix = pattern.slice(0, -1);
1621
+ return (url) => url.startsWith(prefix);
1622
+ }
1623
+ if (pattern.includes("*")) throw new Error(`withRouter unsupported pattern "${pattern}". Only single leading or trailing * (or * alone) supported.`);
1624
+ return (url) => url === pattern;
1625
+ };
1626
+ const preCompiled = Object.entries(routes).map(([pattern, middlewares]) => {
1627
+ return [compile(pattern), middlewares];
1628
+ });
1629
+ return (next) => {
1630
+ const table = preCompiled.map(([predicate, middlewares]) => {
1631
+ const fetch$1 = Fetch.create(middlewares, next);
1632
+ return [predicate, fetch$1];
1633
+ });
1634
+ return async (url, init = {}) => {
1635
+ const match = table.find(([pred]) => pred(url));
1636
+ if (!match) {
1637
+ logger$1.info("withRouter no route matched %s, falling through", url);
1638
+ return next(url, init);
1639
+ }
1640
+ return match[1](url, init);
1641
+ };
1642
+ };
1643
+ }
1644
+ function withResponse(factory) {
1645
+ return (_next) => factory;
1646
+ }
1647
+ const fetchLogger = logger$1;
1648
+ function withLogging(logger$2 = fetchLogger) {
1649
+ return (next) => async (url, init) => {
1650
+ const start = Date.now();
1651
+ const resp = await next(url, init);
1652
+ const duration = Date.now() - start;
1653
+ logger$2.info("%s %s (%i) %dms", (init?.method ?? "get").toUpperCase(), url.split("?", 1)[0], resp.status, duration);
1654
+ return resp;
1655
+ };
1656
+ }
1657
+ async function bodyRepeater(body) {
1658
+ if (body instanceof ReadableStream) {
1659
+ const blob = await new Response(body).blob();
1660
+ return () => blob.stream();
1661
+ }
1662
+ return () => body;
1663
+ }
1664
+ function parseRetryAfter(retryAfterValue, min = 0, max = Number.MAX_SAFE_INTEGER) {
1665
+ if (retryAfterValue) {
1666
+ let delay = Number(retryAfterValue) * 1e3;
1667
+ if (Number.isNaN(delay)) delay = Date.parse(retryAfterValue) - Date.now();
1668
+ if (Number.isFinite(delay) && delay > 0) return Math.max(min, Math.min(delay, max));
1669
+ }
1670
+ }
1671
+ function timeoutSignal$1(delay, signal) {
1672
+ const ac = new AbortController();
1673
+ portableSetTimeout(() => ac.abort(/* @__PURE__ */ new Error(`Operation timed out after ${delay}ms`)), delay);
1674
+ return signal ? AbortSignal.any([signal, ac.signal]) : ac.signal;
1675
+ }
1676
+ const DEFAULT_STATE_INTERVAL = 3e4;
1677
+ const DEFAULT_FLUSH_INTERVAL = 1e4;
1678
+ var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
1679
+ metadata = { name: "ConfidenceServerProviderLocal" };
1680
+ status = "NOT_READY";
1681
+ main = new AbortController();
1682
+ fetch;
1683
+ flushInterval;
1684
+ stateEtag = null;
1685
+ constructor(resolver$1, options) {
1686
+ this.resolver = resolver$1;
1687
+ this.options = options;
1688
+ this.flushInterval = options.flushInterval ?? DEFAULT_FLUSH_INTERVAL;
1689
+ const withConfidenceAuth = withAuth(async () => {
1690
+ const { accessToken, expiresIn } = await this.fetchToken();
1691
+ return [accessToken, new Date(Date.now() + 1e3 * expiresIn)];
1692
+ }, this.main.signal);
1693
+ const withFastRetry = FetchMiddleware.compose(withRetry({
1694
+ maxAttempts: Infinity,
1695
+ baseInterval: 300,
1696
+ maxInterval: 5 * TimeUnit.SECOND
1697
+ }), withTimeout(5 * TimeUnit.SECOND));
1698
+ this.fetch = Fetch.create([withRouter({
1699
+ "https://iam.confidence.dev/v1/oauth/token": [withFastRetry],
1700
+ "https://storage.googleapis.com/*": [withRetry({
1701
+ maxAttempts: Infinity,
1702
+ baseInterval: 500,
1703
+ maxInterval: DEFAULT_STATE_INTERVAL
1704
+ }), withStallTimeout(500)],
1705
+ "https://flags.confidence.dev/*|https://resolver.confidence.dev/*": [withConfidenceAuth, withRouter({
1706
+ "*/v1/resolverState:resolverStateUri": [withFastRetry],
1707
+ "*/v1/flags:resolve": [withRetry({
1708
+ maxAttempts: 3,
1709
+ baseInterval: 100
1710
+ }), withTimeout(3 * TimeUnit.SECOND)],
1711
+ "*/v1/flagLogs:write": [withRetry({
1712
+ maxAttempts: 3,
1713
+ baseInterval: 500
1714
+ }), withTimeout(5 * TimeUnit.SECOND)]
1715
+ })],
1716
+ "*": [withResponse((url) => {
1717
+ throw new Error(`Unknown route ${url}`);
1718
+ })]
1719
+ }), withLogging()], options.fetch ?? fetch);
1720
+ }
1721
+ async initialize(context) {
1722
+ const signal = this.main.signal;
1723
+ const initialUpdateSignal = AbortSignal.any([signal, timeoutSignal(this.options.initializeTimeout ?? DEFAULT_STATE_INTERVAL)]);
1724
+ try {
1725
+ await this.updateState(initialUpdateSignal);
1726
+ scheduleWithFixedInterval((signal$1) => this.flush(signal$1), this.flushInterval, {
1727
+ maxConcurrent: 3,
1728
+ signal
1729
+ });
1730
+ scheduleWithFixedInterval((signal$1) => this.updateState(signal$1), DEFAULT_STATE_INTERVAL, { signal });
1731
+ this.status = "READY";
1732
+ } catch (e) {
1733
+ this.status = "ERROR";
1734
+ throw e;
1735
+ }
1736
+ }
1737
+ async onClose() {
1738
+ await this.flush(timeoutSignal(3e3));
1739
+ this.main.abort();
1740
+ }
1741
+ async evaluate(flagKey, defaultValue, context) {
1742
+ const [flagName, ...path] = flagKey.split(".");
1743
+ const stickyRequest = {
1744
+ resolveRequest: {
1745
+ flags: [`flags/${flagName}`],
1746
+ evaluationContext: ConfidenceServerProviderLocal.convertEvaluationContext(context),
1747
+ apply: true,
1748
+ clientSecret: this.options.flagClientSecret
1749
+ },
1750
+ materializationsPerUnit: {},
1751
+ failFastOnSticky: true
1752
+ };
1753
+ const response = await this.resolveWithStickyInternal(stickyRequest);
1754
+ return this.extractValue(response.resolvedFlags[0], flagName, path, defaultValue);
1755
+ }
1756
+ async resolveWithStickyInternal(request) {
1757
+ const response = this.resolver.resolveWithSticky(request);
1758
+ if (response.success && response.success.response) {
1759
+ const { response: flagsResponse } = response.success;
1760
+ return flagsResponse;
1761
+ }
1762
+ if (response.missingMaterializations) return await this.remoteResolve(request.resolveRequest);
1763
+ throw new Error("Invalid response: resolve result not set");
1764
+ }
1765
+ async remoteResolve(request) {
1766
+ const resp = await this.fetch("https://resolver.confidence.dev/v1/flags:resolve", {
1767
+ method: "POST",
1768
+ headers: { "Content-Type": "application/json" },
1769
+ body: JSON.stringify(ResolveFlagsRequest.toJSON(request))
1770
+ });
1771
+ if (!resp.ok) throw new Error(`Remote resolve failed: ${resp.status} ${resp.statusText}`);
1772
+ const json = await resp.json();
1773
+ return ResolveFlagsResponse.fromJSON(json);
1774
+ }
1775
+ extractValue(flag, flagName, path, defaultValue) {
1776
+ if (!flag) return {
1777
+ value: defaultValue,
1778
+ reason: "ERROR",
1779
+ errorCode: "FLAG_NOT_FOUND"
1780
+ };
1781
+ if (flag.reason !== ResolveReason.RESOLVE_REASON_MATCH) return {
1782
+ value: defaultValue,
1783
+ reason: ConfidenceServerProviderLocal.convertReason(flag.reason)
1784
+ };
1785
+ let value = flag.value;
1786
+ for (const step of path) {
1787
+ if (typeof value !== "object" || value === null || !hasKey(value, step)) return {
1788
+ value: defaultValue,
1789
+ reason: "ERROR",
1790
+ errorCode: "TYPE_MISMATCH"
1791
+ };
1792
+ value = value[step];
1793
+ }
1794
+ if (!isAssignableTo(value, defaultValue)) return {
1795
+ value: defaultValue,
1796
+ reason: "ERROR",
1797
+ errorCode: "TYPE_MISMATCH"
1798
+ };
1799
+ return {
1800
+ value,
1801
+ reason: "MATCH",
1802
+ variant: flag.variant
1803
+ };
1804
+ }
1805
+ async updateState(signal) {
1806
+ const { signedUri, account } = await this.fetchResolveStateUri(signal);
1807
+ const headers = new Headers();
1808
+ if (this.stateEtag) headers.set("If-None-Match", this.stateEtag);
1809
+ const resp = await this.fetch(signedUri, {
1810
+ headers,
1811
+ signal
1812
+ });
1813
+ if (resp.status === 304) return;
1814
+ if (!resp.ok) throw new Error(`Failed to fetch state: ${resp.status} ${resp.statusText}`);
1815
+ this.stateEtag = resp.headers.get("etag");
1816
+ const state = new Uint8Array(await resp.arrayBuffer());
1817
+ this.resolver.setResolverState({
1818
+ accountId: account,
1819
+ state
1820
+ });
1821
+ }
1822
+ async flush(signal) {
1823
+ const writeFlagLogRequest = this.resolver.flushLogs();
1824
+ if (writeFlagLogRequest.length == 0) return;
1825
+ await this.fetch("https://resolver.confidence.dev/v1/flagLogs:write", {
1826
+ method: "post",
1827
+ signal,
1828
+ headers: { "Content-Type": "application/x-protobuf" },
1829
+ body: writeFlagLogRequest
1830
+ });
1831
+ }
1832
+ async fetchResolveStateUri(signal) {
1833
+ const resp = await this.fetch("https://flags.confidence.dev/v1/resolverState:resolverStateUri", { signal });
1834
+ if (!resp.ok) throw new Error("Failed to get resolve state url");
1835
+ return resp.json();
1836
+ }
1837
+ async fetchToken() {
1838
+ const resp = await this.fetch("https://iam.confidence.dev/v1/oauth/token", {
1839
+ method: "POST",
1840
+ headers: { "Content-Type": "application/json" },
1841
+ body: JSON.stringify({
1842
+ clientId: this.options.apiClientId,
1843
+ clientSecret: this.options.apiClientSecret,
1844
+ grantType: "client_credentials"
1845
+ })
1846
+ });
1847
+ if (!resp.ok) throw new Error("Failed to fetch access token");
1848
+ return resp.json();
1849
+ }
1850
+ static convertReason(reason) {
1851
+ switch (reason) {
1852
+ case ResolveReason.RESOLVE_REASON_ERROR: return "ERROR";
1853
+ case ResolveReason.RESOLVE_REASON_FLAG_ARCHIVED: return "FLAG_ARCHIVED";
1854
+ case ResolveReason.RESOLVE_REASON_MATCH: return "MATCH";
1855
+ case ResolveReason.RESOLVE_REASON_NO_SEGMENT_MATCH: return "NO_SEGMENT_MATCH";
1856
+ case ResolveReason.RESOLVE_REASON_TARGETING_KEY_ERROR: return "TARGETING_KEY_ERROR";
1857
+ case ResolveReason.RESOLVE_REASON_NO_TREATMENT_MATCH: return "NO_TREATMENT_MATCH";
1858
+ default: return "UNSPECIFIED";
1859
+ }
1860
+ }
1861
+ static convertEvaluationContext({ targetingKey: targeting_key,...rest }) {
1862
+ return {
1863
+ targeting_key,
1864
+ ...rest
1865
+ };
1866
+ }
1867
+ resolveBooleanEvaluation(flagKey, defaultValue, context) {
1868
+ return Promise.resolve(this.evaluate(flagKey, defaultValue, context));
1869
+ }
1870
+ resolveNumberEvaluation(flagKey, defaultValue, context) {
1871
+ return Promise.resolve(this.evaluate(flagKey, defaultValue, context));
1872
+ }
1873
+ resolveObjectEvaluation(flagKey, defaultValue, context) {
1874
+ return Promise.resolve(this.evaluate(flagKey, defaultValue, context));
1875
+ }
1876
+ resolveStringEvaluation(flagKey, defaultValue, context) {
1877
+ return Promise.resolve(this.evaluate(flagKey, defaultValue, context));
1878
+ }
1879
+ };
1880
+ function hasKey(obj, key) {
1881
+ return key in obj;
1882
+ }
1883
+ function isAssignableTo(value, schema) {
1884
+ if (typeof schema !== typeof value) return false;
1885
+ if (typeof value === "object" && typeof schema === "object") {
1886
+ if (schema === null) return value === null;
1887
+ if (Array.isArray(schema)) {
1888
+ if (!Array.isArray(value)) return false;
1889
+ if (schema.length == 0) return true;
1890
+ return value.every((item) => isAssignableTo(item, schema[0]));
1891
+ }
1892
+ for (const [key, schemaValue] of Object.entries(schema)) {
1893
+ if (!hasKey(value, key)) return false;
1894
+ if (!isAssignableTo(value[key], schemaValue)) return false;
1895
+ }
1896
+ }
1897
+ return true;
1898
+ }
1899
+ function createBaseVoid() {
1900
+ return {};
1901
+ }
1902
+ const Void = {
1903
+ encode(_, writer = new BinaryWriter()) {
1904
+ return writer;
1905
+ },
1906
+ decode(input, length) {
1907
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1908
+ const end = length === void 0 ? reader.len : reader.pos + length;
1909
+ const message = createBaseVoid();
1910
+ while (reader.pos < end) {
1911
+ const tag = reader.uint32();
1912
+ switch (tag >>> 3) {}
1913
+ if ((tag & 7) === 4 || tag === 0) break;
1914
+ reader.skip(tag & 7);
1915
+ }
1916
+ return message;
1917
+ },
1918
+ fromJSON(_) {
1919
+ return {};
1920
+ },
1921
+ toJSON(_) {
1922
+ return {};
1923
+ },
1924
+ create(base) {
1925
+ return Void.fromPartial(base ?? {});
1926
+ },
1927
+ fromPartial(_) {
1928
+ return createBaseVoid();
1929
+ }
1930
+ };
1931
+ function createBaseRequest() {
1932
+ return { data: new Uint8Array(0) };
1933
+ }
1934
+ const Request = {
1935
+ encode(message, writer = new BinaryWriter()) {
1936
+ if (message.data.length !== 0) writer.uint32(10).bytes(message.data);
1937
+ return writer;
1938
+ },
1939
+ decode(input, length) {
1940
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1941
+ const end = length === void 0 ? reader.len : reader.pos + length;
1942
+ const message = createBaseRequest();
1943
+ while (reader.pos < end) {
1944
+ const tag = reader.uint32();
1945
+ switch (tag >>> 3) {
1946
+ case 1:
1947
+ if (tag !== 10) break;
1948
+ message.data = reader.bytes();
1949
+ continue;
1950
+ }
1951
+ if ((tag & 7) === 4 || tag === 0) break;
1952
+ reader.skip(tag & 7);
1953
+ }
1954
+ return message;
1955
+ },
1956
+ fromJSON(object) {
1957
+ return { data: isSet$1(object.data) ? bytesFromBase64(object.data) : new Uint8Array(0) };
1958
+ },
1959
+ toJSON(message) {
1960
+ const obj = {};
1961
+ if (message.data.length !== 0) obj.data = base64FromBytes(message.data);
1962
+ return obj;
1963
+ },
1964
+ create(base) {
1965
+ return Request.fromPartial(base ?? {});
1966
+ },
1967
+ fromPartial(object) {
1968
+ const message = createBaseRequest();
1969
+ message.data = object.data ?? new Uint8Array(0);
1970
+ return message;
1971
+ }
1972
+ };
1973
+ function createBaseResponse() {
1974
+ return {
1975
+ data: void 0,
1976
+ error: void 0
1977
+ };
1978
+ }
1979
+ const Response$1 = {
1980
+ encode(message, writer = new BinaryWriter()) {
1981
+ if (message.data !== void 0) writer.uint32(10).bytes(message.data);
1982
+ if (message.error !== void 0) writer.uint32(18).string(message.error);
1983
+ return writer;
1984
+ },
1985
+ decode(input, length) {
1986
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1987
+ const end = length === void 0 ? reader.len : reader.pos + length;
1988
+ const message = createBaseResponse();
1989
+ while (reader.pos < end) {
1990
+ const tag = reader.uint32();
1991
+ switch (tag >>> 3) {
1992
+ case 1:
1993
+ if (tag !== 10) break;
1994
+ message.data = reader.bytes();
1995
+ continue;
1996
+ case 2:
1997
+ if (tag !== 18) break;
1998
+ message.error = reader.string();
1999
+ continue;
2000
+ }
2001
+ if ((tag & 7) === 4 || tag === 0) break;
2002
+ reader.skip(tag & 7);
2003
+ }
2004
+ return message;
2005
+ },
2006
+ fromJSON(object) {
2007
+ return {
2008
+ data: isSet$1(object.data) ? bytesFromBase64(object.data) : void 0,
2009
+ error: isSet$1(object.error) ? globalThis.String(object.error) : void 0
2010
+ };
2011
+ },
2012
+ toJSON(message) {
2013
+ const obj = {};
2014
+ if (message.data !== void 0) obj.data = base64FromBytes(message.data);
2015
+ if (message.error !== void 0) obj.error = message.error;
2016
+ return obj;
2017
+ },
2018
+ create(base) {
2019
+ return Response$1.fromPartial(base ?? {});
2020
+ },
2021
+ fromPartial(object) {
2022
+ const message = createBaseResponse();
2023
+ message.data = object.data ?? void 0;
2024
+ message.error = object.error ?? void 0;
2025
+ return message;
2026
+ }
2027
+ };
2028
+ function bytesFromBase64(b64) {
2029
+ if (globalThis.Buffer) return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
2030
+ else {
2031
+ const bin = globalThis.atob(b64);
2032
+ const arr = new Uint8Array(bin.length);
2033
+ for (let i = 0; i < bin.length; ++i) arr[i] = bin.charCodeAt(i);
2034
+ return arr;
2035
+ }
2036
+ }
2037
+ function base64FromBytes(arr) {
2038
+ if (globalThis.Buffer) return globalThis.Buffer.from(arr).toString("base64");
2039
+ else {
2040
+ const bin = [];
2041
+ arr.forEach((byte) => {
2042
+ bin.push(globalThis.String.fromCharCode(byte));
2043
+ });
2044
+ return globalThis.btoa(bin.join(""));
2045
+ }
2046
+ }
2047
+ function isSet$1(value) {
2048
+ return value !== null && value !== void 0;
2049
+ }
2050
+ function createBaseTimestamp() {
2051
+ return {
2052
+ seconds: 0,
2053
+ nanos: 0
2054
+ };
2055
+ }
2056
+ const Timestamp = {
2057
+ encode(message, writer = new BinaryWriter()) {
2058
+ if (message.seconds !== 0) writer.uint32(8).int64(message.seconds);
2059
+ if (message.nanos !== 0) writer.uint32(16).int32(message.nanos);
2060
+ return writer;
2061
+ },
2062
+ decode(input, length) {
2063
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2064
+ const end = length === void 0 ? reader.len : reader.pos + length;
2065
+ const message = createBaseTimestamp();
2066
+ while (reader.pos < end) {
2067
+ const tag = reader.uint32();
2068
+ switch (tag >>> 3) {
2069
+ case 1:
2070
+ if (tag !== 8) break;
2071
+ message.seconds = longToNumber(reader.int64());
2072
+ continue;
2073
+ case 2:
2074
+ if (tag !== 16) break;
2075
+ message.nanos = reader.int32();
2076
+ continue;
2077
+ }
2078
+ if ((tag & 7) === 4 || tag === 0) break;
2079
+ reader.skip(tag & 7);
2080
+ }
2081
+ return message;
2082
+ },
2083
+ fromJSON(object) {
2084
+ return {
2085
+ seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0,
2086
+ nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0
2087
+ };
2088
+ },
2089
+ toJSON(message) {
2090
+ const obj = {};
2091
+ if (message.seconds !== 0) obj.seconds = Math.round(message.seconds);
2092
+ if (message.nanos !== 0) obj.nanos = Math.round(message.nanos);
2093
+ return obj;
2094
+ },
2095
+ create(base) {
2096
+ return Timestamp.fromPartial(base ?? {});
2097
+ },
2098
+ fromPartial(object) {
2099
+ const message = createBaseTimestamp();
2100
+ message.seconds = object.seconds ?? 0;
2101
+ message.nanos = object.nanos ?? 0;
2102
+ return message;
2103
+ }
2104
+ };
2105
+ function longToNumber(int64) {
2106
+ const num = globalThis.Number(int64.toString());
2107
+ if (num > globalThis.Number.MAX_SAFE_INTEGER) throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
2108
+ if (num < globalThis.Number.MIN_SAFE_INTEGER) throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
2109
+ return num;
2110
+ }
2111
+ function isSet(value) {
2112
+ return value !== null && value !== void 0;
2113
+ }
2114
+ var WasmResolver = class WasmResolver {
2115
+ exports;
2116
+ imports;
2117
+ constructor() {
2118
+ this.imports = { wasm_msg: { wasm_msg_host_current_time: () => {
2119
+ const epochMillisecond = Date.now();
2120
+ const seconds = Math.floor(epochMillisecond / 1e3);
2121
+ const nanos = (epochMillisecond - 1e3 * seconds) * 1e6;
2122
+ return this.transferRequest({
2123
+ seconds,
2124
+ nanos
2125
+ }, Timestamp);
2126
+ } } };
2127
+ }
2128
+ resolveWithSticky(request) {
2129
+ const reqPtr = this.transferRequest(request, ResolveWithStickyRequest);
2130
+ const resPtr = this.exports.wasm_msg_guest_resolve_with_sticky(reqPtr);
2131
+ return this.consumeResponse(resPtr, ResolveWithStickyResponse);
2132
+ }
2133
+ setResolverState(request) {
2134
+ const reqPtr = this.transferRequest(request, SetResolverStateRequest);
2135
+ const resPtr = this.exports.wasm_msg_guest_set_resolver_state(reqPtr);
2136
+ this.consumeResponse(resPtr, Void);
2137
+ }
2138
+ flushLogs() {
2139
+ const resPtr = this.exports.wasm_msg_guest_flush_logs(0);
2140
+ const { data, error } = this.consume(resPtr, Response$1);
2141
+ if (error) throw new Error(error);
2142
+ return data;
2143
+ }
2144
+ transferRequest(value, codec) {
2145
+ const data = codec.encode(value).finish();
2146
+ return this.transfer({ data }, Request);
2147
+ }
2148
+ consumeResponse(ptr, codec) {
2149
+ const { data, error } = this.consume(ptr, Response$1);
2150
+ if (error) throw new Error(error);
2151
+ return codec.decode(data);
2152
+ }
2153
+ transfer(data, codec) {
2154
+ const encoded = codec.encode(data).finish();
2155
+ const ptr = this.exports.wasm_msg_alloc(encoded.length);
2156
+ this.viewBuffer(ptr).set(encoded);
2157
+ return ptr;
2158
+ }
2159
+ consume(ptr, codec) {
2160
+ const data = this.viewBuffer(ptr);
2161
+ const res = codec.decode(data.slice());
2162
+ this.free(ptr);
2163
+ return res;
2164
+ }
2165
+ viewBuffer(ptr) {
2166
+ const size = new DataView(this.exports.memory.buffer).getUint32(ptr - 4, true);
2167
+ return new Uint8Array(this.exports.memory.buffer, ptr, size - 4);
2168
+ }
2169
+ free(ptr) {
2170
+ this.exports.wasm_msg_free(ptr);
2171
+ }
2172
+ static async load(module$1) {
2173
+ const wasmResolver = new WasmResolver();
2174
+ wasmResolver.exports = (await WebAssembly.instantiate(module$1, wasmResolver.imports)).exports;
2175
+ return wasmResolver;
2176
+ }
2177
+ };
2178
+ const wasmPath = __require.resolve("./confidence_resolver.wasm");
2179
+ const buffer = await fs.readFile(wasmPath);
2180
+ const module = await WebAssembly.compile(buffer);
2181
+ const resolver = await WasmResolver.load(module);
2182
+ function createConfidenceServerProvider(options) {
2183
+ return new ConfidenceServerProviderLocal(resolver, options);
2184
+ }
2185
+ export { createConfidenceServerProvider };