@carddb/browser 0.4.5 → 0.4.6

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.
@@ -1,4 +1,4 @@
1
- var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardDBError",this.response=r,Error.captureStackTrace&&Error.captureStackTrace(this,ne);}},G=class extends y{constructor(e="Invalid or missing API key",t){super(e,t),this.name="AuthenticationError";}},U=class extends y{retryAfter;limit;remaining;resetAt;constructor(e="Rate limit exceeded",t={}){super(e,t.response),this.name="RateLimitError",this.retryAfter=t.retryAfter??null,this.limit=t.limit??null,this.remaining=t.remaining??null,this.resetAt=t.resetAt??null;}},Gt=class extends y{constructor(e="Resource not found",t){super(e,t),this.name="NotFoundError";}},F=class extends y{errors;constructor(e="Validation error",t={}){super(e,t.response),this.name="ValidationError",this.errors=t.errors??[];}},v=class extends y{constructor(e,t){super(e,t),this.name="RestrictedError";}},ce=class extends y{errors;constructor(e="GraphQL error",t={}){super(e,t.response),this.name="GraphQLError",this.errors=t.errors??[];}},x=class extends y{constructor(e="Connection error",t){super(e,t),this.name="ConnectionError";}},O=class extends x{constructor(e="Request timed out",t){super(e,t),this.name="TimeoutError";}},N=class extends y{status;constructor(e="Server error",t={}){super(e,t.response),this.name="ServerError",this.status=t.status??null;}},Ot=class extends y{failures;partialResults;constructor(e="Some links could not be resolved",t={}){super(e,t.response),this.name="LinkResolutionError",this.failures=t.failures??[],this.partialResults=t.partialResults;}getFailuresForField(e){return this.failures.filter(t=>t.field===e)}hasFailuresForField(e){return this.failures.some(t=>t.field===e)}};function Nt(e){return {eq:e}}function jt(e){return {neq:e}}function Ht(e){return {gt:e}}function Yt(e){return {gte:e}}function zt(e){return {lt:e}}function Wt(e){return {lte:e}}function Xt(e){return {in:e}}function Qt(e){return {nin:e}}function Zt(e){return {contains:e}}function er(e){return {like:e}}function tr(e){return {ilike:e}}function rr(){return {is_null:true}}function sr(){return {is_null:false}}var Ee=class oe{conditions=[];orGroups=[];where(t,r){if(typeof t=="string")this.conditions.push({[t]:r});else for(let[s,a]of Object.entries(t))this.conditions.push({[s]:a});return this}any(t){let r=new oe;t(r);let s=r.getConditions();return s.length>0&&this.orGroups.push({$or:s}),this}whereLink(t,r){let s={};for(let[a,n]of Object.entries(r))s[a]=n;return this.conditions.push({[`${t}._link`]:s}),this}whereAny(t,r){let s={};for(let[a,n]of Object.entries(r))s[a]=n;return this.conditions.push({[`${t}._any`]:s}),this}getConditions(){return this.conditions}build(){let t=[...this.conditions,...this.orGroups];return t.length===0?{}:t.length===1?t[0]:{$and:t}}};function P(e){if(e!==void 0){if(typeof e=="function"){let t=new Ee;e(t);let r=t.build();return Object.keys(r).length>0?r:void 0}return Object.keys(e).length>0?e:void 0}}var Re=new Set(["metadata","annotations"]);function I(e){return ue(e,"input")}function ue(e,t){if(!M(e))return e;let r={};for(let[s,a]of Object.entries(e)){let n=`${t}.${s}`;Re.has(s)?r[s]=xe(a,n):s==="entries"&&Array.isArray(a)?r[s]=a.map((c,o)=>ue(c,`${n}[${o}]`)):r[s]=a;}return r}function xe(e,t){if(e==null||M(e))return e;if(typeof e=="string")try{let r=JSON.parse(e);if(M(r))return r}catch{}throw new F(`${t} must be a JSON object`)}function M(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var E=`
1
+ var f=class oe extends Error{response;constructor(t,r){super(t),this.name="CardDBError",this.response=r,Error.captureStackTrace&&Error.captureStackTrace(this,oe);}},j=class extends f{constructor(e="Invalid or missing API key",t){super(e,t),this.name="AuthenticationError";}},P=class extends f{retryAfter;limit;remaining;resetAt;constructor(e="Rate limit exceeded",t={}){super(e,t.response),this.name="RateLimitError",this.retryAfter=t.retryAfter??null,this.limit=t.limit??null,this.remaining=t.remaining??null,this.resetAt=t.resetAt??null;}},Wt=class extends f{constructor(e="Resource not found",t){super(e,t),this.name="NotFoundError";}},L=class extends f{errors;constructor(e="Validation error",t={}){super(e,t.response),this.name="ValidationError",this.errors=t.errors??[];}},D=class extends f{constructor(e,t){super(e,t),this.name="RestrictedError";}},ue=class extends f{errors;constructor(e="GraphQL error",t={}){super(e,t.response),this.name="GraphQLError",this.errors=t.errors??[];}},K=class extends f{constructor(e="Connection error",t){super(e,t),this.name="ConnectionError";}},H=class extends K{constructor(e="Request timed out",t){super(e,t),this.name="TimeoutError";}},Y=class extends f{status;constructor(e="Server error",t={}){super(e,t.response),this.name="ServerError",this.status=t.status??null;}},Xt=class extends f{failures;partialResults;constructor(e="Some links could not be resolved",t={}){super(e,t.response),this.name="LinkResolutionError",this.failures=t.failures??[],this.partialResults=t.partialResults;}getFailuresForField(e){return this.failures.filter(t=>t.field===e)}hasFailuresForField(e){return this.failures.some(t=>t.field===e)}};function Qt(e){return {eq:e}}function Zt(e){return {neq:e}}function er(e){return {gt:e}}function tr(e){return {gte:e}}function rr(e){return {lt:e}}function sr(e){return {lte:e}}function ir(e){return {in:e}}function ar(e){return {nin:e}}function nr(e){return {contains:e}}function cr(e){return {like:e}}function or(e){return {ilike:e}}function ur(){return {is_null:true}}function lr(){return {is_null:false}}var qe=class le{conditions=[];orGroups=[];where(t,r){if(typeof t=="string")this.conditions.push({[t]:r});else for(let[s,i]of Object.entries(t))this.conditions.push({[s]:i});return this}any(t){let r=new le;t(r);let s=r.getConditions();return s.length>0&&this.orGroups.push({$or:s}),this}whereLink(t,r){let s={};for(let[i,n]of Object.entries(r))s[i]=n;return this.conditions.push({[`${t}._link`]:s}),this}whereAny(t,r){let s={};for(let[i,n]of Object.entries(r))s[i]=n;return this.conditions.push({[`${t}._any`]:s}),this}getConditions(){return this.conditions}build(){let t=[...this.conditions,...this.orGroups];return t.length===0?{}:t.length===1?t[0]:{$and:t}}};function _(e){if(e!==void 0){if(typeof e=="function"){let t=new qe;e(t);let r=t.build();return Object.keys(r).length>0?r:void 0}return Object.keys(e).length>0?e:void 0}}var xe=new Set(["metadata","annotations"]);function $(e){return de(e,"input")}function de(e,t){if(!G(e))return e;let r={};for(let[s,i]of Object.entries(e)){let n=`${t}.${s}`;xe.has(s)?r[s]=Ce(i,n):s==="entries"&&Array.isArray(i)?r[s]=i.map((c,o)=>de(c,`${n}[${o}]`)):r[s]=i;}return r}function Ce(e,t){if(e==null||G(e))return e;if(typeof e=="string")try{let r=JSON.parse(e);if(G(r))return r}catch{}throw new L(`${t} must be a JSON object`)}function G(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var x=`
2
2
  id
3
3
  createdAt
4
4
  updatedAt
@@ -11,13 +11,13 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
11
11
  entityType
12
12
  entityId
13
13
  url
14
- `,Z=`
14
+ `,te=`
15
15
  file {
16
- ${E}
16
+ ${x}
17
17
  }
18
18
  uploadUrl
19
19
  expiresAt
20
- `,g=`
20
+ `,I=`
21
21
  id
22
22
  name
23
23
  slug
@@ -88,7 +88,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
88
88
  key
89
89
  name
90
90
  }
91
- `,qe=4;function le(e){return `
91
+ `,Ue=4;function he(e){return `
92
92
  key
93
93
  label
94
94
  description
@@ -121,12 +121,12 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
121
121
  isUnique
122
122
  ${e>0?`
123
123
  nestedFields {
124
- ${le(e-1)}
124
+ ${he(e-1)}
125
125
  }`:""}
126
- `}var w=`
126
+ `}var S=`
127
127
  schema {
128
128
  fields {
129
- ${le(qe)}
129
+ ${he(Ue)}
130
130
  }
131
131
  filterableFields
132
132
  searchableFields
@@ -142,7 +142,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
142
142
  isArray
143
143
  }
144
144
  }
145
- `,de=`
145
+ `,ye=`
146
146
  id
147
147
  objectTypeId
148
148
  key
@@ -176,7 +176,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
176
176
  parentFieldId
177
177
  createdAt
178
178
  updatedAt
179
- `,Ce=`
179
+ `,Ke=`
180
180
  pricing {
181
181
  productId
182
182
  prices {
@@ -192,7 +192,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
192
192
  id
193
193
  datasetId
194
194
  data
195
- ${e.includePricing?Ce:""}
195
+ ${e.includePricing?Ke:""}
196
196
  createdAt
197
197
  updatedAt
198
198
  dataset {
@@ -202,7 +202,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
202
202
  gameId
203
203
  publisherId
204
204
  }
205
- `}var R=b(),j=`
205
+ `}var C=b(),A=`
206
206
  key
207
207
  label
208
208
  description
@@ -214,7 +214,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
214
214
  excludedFromDeckSize
215
215
  legalCardTypes
216
216
  metadata
217
- `,L=`
217
+ `,B=`
218
218
  id
219
219
  datasetId
220
220
  recordId
@@ -225,9 +225,9 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
225
225
  annotations
226
226
  display
227
227
  record {
228
- ${R}
228
+ ${C}
229
229
  }
230
- `,he=`
230
+ `,fe=`
231
231
  rulesetId
232
232
  rulesetVersionId
233
233
  rulesetVersionLabel
@@ -235,7 +235,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
235
235
  cardDatasetVersionId
236
236
  validatedAt
237
237
  validationResultSummary
238
- `,T=`
238
+ `,U=`
239
239
  code
240
240
  severity
241
241
  message
@@ -244,14 +244,14 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
244
244
  datasetId
245
245
  identifier
246
246
  metadata
247
- `,H=`
247
+ `,z=`
248
248
  deckId
249
249
  valid
250
250
  blockers {
251
- ${T}
251
+ ${U}
252
252
  }
253
253
  warnings {
254
- ${T}
254
+ ${U}
255
255
  }
256
256
  affectedEntries {
257
257
  entryId
@@ -262,17 +262,108 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
262
262
  quantity
263
263
  }
264
264
  validatedAgainst {
265
- ${he}
265
+ ${fe}
266
+ }
267
+ checkedAt
268
+ `,g=`
269
+ id
270
+ rulesetId
271
+ versionLabel
272
+ status
273
+ rules
274
+ sectionDefinitions {
275
+ ${A}
276
+ }
277
+ cardDatasetId
278
+ cardDatasetVersionId
279
+ sourceDatasetId
280
+ sourceDatasetVersionId
281
+ sourceDatasetRecordId
282
+ sourceRecordIdentifier
283
+ rulesFingerprint
284
+ effectiveAt
285
+ changelog
286
+ createdByAccountId
287
+ publishedByAccountId
288
+ publishedAt
289
+ supersededAt
290
+ createdAt
291
+ updatedAt
292
+ `,E=`
293
+ id
294
+ gameId
295
+ game {
296
+ id
297
+ key
298
+ name
299
+ }
300
+ key
301
+ name
302
+ description
303
+ tags
304
+ sortOrder
305
+ currentVersionId
306
+ currentVersion {
307
+ ${g}
266
308
  }
309
+ archivedAt
310
+ isArchived
311
+ createdAt
312
+ updatedAt
313
+ `,Te=`
314
+ rulesetId
315
+ rulesetVersionId
316
+ rulesetKey
317
+ rulesetVersionLabel
318
+ rules
319
+ sections {
320
+ ${A}
321
+ }
322
+ `,Fe=`
323
+ deckId
324
+ title
325
+ slug
326
+ state
327
+ hasUnpublishedChanges
328
+ valid
329
+ blockerCount
330
+ warningCount
331
+ affectedEntryCount
332
+ issues {
333
+ ${U}
334
+ }
335
+ `,Ve=`
336
+ rulesetId
337
+ rulesetVersionId
267
338
  checkedAt
268
- `,ee=`
339
+ affectedDeckCount
340
+ invalidDeckCount
341
+ blockerCount
342
+ warningCount
343
+ results {
344
+ ${Fe}
345
+ }
346
+ `,Pe=`
347
+ sourceDatasetId
348
+ sourceDatasetVersionId
349
+ sourceDatasetRecordId
350
+ sourceRecordIdentifier
351
+ rules
352
+ sectionDefinitions {
353
+ ${A}
354
+ }
355
+ rulesFingerprint
356
+ summary
357
+ sectionCount
358
+ copyLimitCount
359
+ `,re=`
269
360
  deckId
270
361
  fromVersionId
271
362
  toVersionId
272
363
  toDraftRevision
273
364
  hasChanges
274
365
  diff
275
- `,K=`
366
+ `,V=`
276
367
  id
277
368
  deckId
278
369
  versionNumber
@@ -294,18 +385,18 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
294
385
  validatedAt
295
386
  validationSummary
296
387
  validatedAgainst {
297
- ${he}
388
+ ${fe}
298
389
  }
299
390
  sectionDefinitions {
300
- ${j}
391
+ ${A}
301
392
  }
302
393
  publishedByAccountId
303
394
  publishedByApiApplicationId
304
395
  createdAt
305
396
  entries {
306
- ${L}
397
+ ${B}
307
398
  }
308
- `,te=`
399
+ `,se=`
309
400
  id
310
401
  deckId
311
402
  accountId
@@ -313,7 +404,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
313
404
  createdByAccountId
314
405
  createdAt
315
406
  updatedAt
316
- `,re=`
407
+ `,ie=`
317
408
  id
318
409
  apiApplicationId
319
410
  label
@@ -327,7 +418,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
327
418
  revokedAt
328
419
  createdAt
329
420
  updatedAt
330
- `,Te=`
421
+ `,Le=`
331
422
  id
332
423
  apiApplicationId
333
424
  issuerId
@@ -341,7 +432,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
341
432
  lastUsedAt
342
433
  createdAt
343
434
  updatedAt
344
- `,Y=`
435
+ `,W=`
345
436
  lineNumber
346
437
  raw
347
438
  datasetKey
@@ -353,14 +444,14 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
353
444
  sortOrder
354
445
  display
355
446
  record {
356
- ${R}
447
+ ${C}
357
448
  }
358
- `,ye=`
449
+ `,pe=`
359
450
  lineNumber
360
451
  raw
361
452
  code
362
453
  message
363
- `,z=`
454
+ `,X=`
364
455
  lineNumber
365
456
  raw
366
457
  datasetKey
@@ -369,7 +460,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
369
460
  section
370
461
  code
371
462
  message
372
- `,W=`
463
+ `,Q=`
373
464
  lineNumber
374
465
  raw
375
466
  datasetKey
@@ -395,39 +486,39 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
395
486
  isArchived
396
487
  createdAt
397
488
  updatedAt
398
- `,fe=`
489
+ `,me=`
399
490
  formatId
400
491
  key
401
492
  name
402
493
  confidence
403
494
  reason
404
- `,Ke=`
495
+ `,_e=`
405
496
  detection {
406
- ${fe}
497
+ ${me}
407
498
  }
408
499
  entries {
409
- ${Y}
500
+ ${W}
410
501
  }
411
502
  parseErrors {
412
- ${ye}
503
+ ${pe}
413
504
  }
414
505
  unmatched {
415
- ${z}
506
+ ${X}
416
507
  }
417
508
  ambiguous {
418
- ${W}
509
+ ${Q}
419
510
  }
420
- `,Ue=`
511
+ `,Be=`
421
512
  entries {
422
- ${Y}
513
+ ${W}
423
514
  }
424
515
  unmatched {
425
- ${z}
516
+ ${X}
426
517
  }
427
518
  ambiguous {
428
- ${W}
519
+ ${Q}
429
520
  }
430
- `,Fe=`
521
+ `,Me=`
431
522
  deckId
432
523
  format
433
524
  text
@@ -462,10 +553,10 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
462
553
  sourceUrl
463
554
  metadata
464
555
  sectionDefinitions {
465
- ${j}
556
+ ${A}
466
557
  }
467
558
  latestPublishedVersion {
468
- ${K}
559
+ ${V}
469
560
  }
470
561
  publishedAt
471
562
  draftRevision
@@ -479,25 +570,25 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
479
570
  ${p}
480
571
  }
481
572
  entries {
482
- ${L}
573
+ ${B}
483
574
  }
484
- `,se=`
575
+ `,ae=`
485
576
  deck {
486
577
  ${u}
487
578
  }
488
579
  retainedAppAccess
489
- `,Pe=`
580
+ `,Je=`
490
581
  deck {
491
582
  ${u}
492
583
  }
493
584
  copiedFromDeckId
494
585
  retainedAppAccess
495
- `,Le=`
586
+ `,Oe=`
496
587
  id
497
588
  name
498
589
  description
499
590
  revokedAt
500
- `,V=`
591
+ `,M=`
501
592
  id
502
593
  deckId
503
594
  deck {
@@ -505,7 +596,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
505
596
  }
506
597
  apiApplicationId
507
598
  apiApplication {
508
- ${Le}
599
+ ${Oe}
509
600
  }
510
601
  role
511
602
  grantSource
@@ -515,37 +606,37 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
515
606
  revokedAt
516
607
  createdAt
517
608
  updatedAt
518
- `,Ve=`
609
+ `,Ge=`
519
610
  deck {
520
611
  ${u}
521
612
  }
522
613
  version {
523
- ${K}
614
+ ${V}
524
615
  }
525
616
  validation {
526
- ${H}
617
+ ${z}
527
618
  }
528
619
  blockers {
529
- ${T}
620
+ ${U}
530
621
  }
531
622
  warnings {
532
- ${T}
623
+ ${U}
533
624
  }
534
- `,B=`
625
+ `,J=`
535
626
  deck {
536
627
  ${u}
537
628
  }
538
629
  entry {
539
- ${L}
630
+ ${B}
540
631
  }
541
- `,pe=`
632
+ `,ge=`
542
633
  deck {
543
634
  ${u}
544
635
  }
545
636
  entries {
546
- ${L}
637
+ ${B}
547
638
  }
548
- `,Be=pe,_e=`
639
+ `,Ne=ge,je=`
549
640
  deck {
550
641
  ${u}
551
642
  }
@@ -557,24 +648,24 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
557
648
  ${k}
558
649
  }
559
650
  detection {
560
- ${fe}
651
+ ${me}
561
652
  }
562
653
  entries {
563
- ${Y}
654
+ ${W}
564
655
  }
565
656
  parseErrors {
566
- ${ye}
657
+ ${pe}
567
658
  }
568
659
  unmatched {
569
- ${z}
660
+ ${X}
570
661
  }
571
662
  ambiguous {
572
- ${W}
663
+ ${Q}
573
664
  }
574
665
  validation {
575
- ${H}
666
+ ${z}
576
667
  }
577
- `,ae=`
668
+ `,ne=`
578
669
  resolvedLinks {
579
670
  field
580
671
  linkFieldKey
@@ -585,7 +676,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
585
676
  data
586
677
  }
587
678
  }
588
- `,me=`
679
+ `,Ie=`
589
680
  datasetKey
590
681
  index
591
682
  errors {
@@ -593,45 +684,45 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
593
684
  message
594
685
  details
595
686
  }
596
- `,Me=`
687
+ `,He=`
597
688
  total
598
689
  inserted
599
690
  updated
600
691
  skipped
601
692
  failed
602
- `,ge=`
693
+ `,$e=`
603
694
  inserted {
604
- ${R}
695
+ ${C}
605
696
  }
606
697
  updated {
607
- ${R}
698
+ ${C}
608
699
  }
609
700
  skipped
610
701
  errors {
611
- ${me}
702
+ ${Ie}
612
703
  }
613
704
  createdFields {
614
- ${de}
705
+ ${ye}
615
706
  }
616
707
  stats {
617
- ${Me}
708
+ ${He}
618
709
  }
619
- `,Ie=`
710
+ `,be=`
620
711
  fileId
621
712
  filename
622
713
  file {
623
- ${E}
714
+ ${x}
624
715
  }
625
- `,$=`
716
+ `,v=`
626
717
  id
627
718
  publisherId
628
719
  publisher {
629
- ${g}
720
+ ${I}
630
721
  }
631
722
  datasetId
632
723
  dataset {
633
724
  ${m}
634
- ${w}
725
+ ${S}
635
726
  }
636
727
  accountId
637
728
  status
@@ -647,14 +738,14 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
647
738
  skippedCount
648
739
  failedCount
649
740
  createdFields {
650
- ${de}
741
+ ${ye}
651
742
  }
652
743
  errors {
653
- ${me}
744
+ ${Ie}
654
745
  }
655
746
  errorMessage
656
747
  assets {
657
- ${Ie}
748
+ ${be}
658
749
  }
659
750
  startedAt
660
751
  completedAt
@@ -665,7 +756,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
665
756
  imagesPending
666
757
  imagesCompleted
667
758
  imagesFailed
668
- `,Je=`
759
+ `,Ye=`
669
760
  id
670
761
  importJobId
671
762
  level
@@ -675,24 +766,24 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
675
766
  fieldKey
676
767
  details
677
768
  createdAt
678
- `,Ge=`
769
+ `,ze=`
679
770
  job {
680
- ${$}
771
+ ${v}
681
772
  }
682
773
  dryRunResult {
683
- ${ge}
774
+ ${$e}
684
775
  }
685
- `,Oe=`
776
+ `,We=`
686
777
  target
687
778
  recordId
688
779
  identifier
689
780
  status
690
781
  message
691
- `,_=`
782
+ `,O=`
692
783
  id
693
784
  publisherId
694
785
  publisher {
695
- ${g}
786
+ ${I}
696
787
  }
697
788
  datasetId
698
789
  dataset {
@@ -712,14 +803,14 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
712
803
  blockedCount
713
804
  failedCount
714
805
  results {
715
- ${Oe}
806
+ ${We}
716
807
  }
717
808
  errorMessage
718
809
  startedAt
719
810
  completedAt
720
811
  createdAt
721
812
  updatedAt
722
- `,be=`
813
+ `,ke=`
723
814
  sourceField
724
815
  targetField
725
816
  targetFieldLabel
@@ -745,30 +836,30 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
745
836
  targetFieldType
746
837
  sampleValues
747
838
  status
748
- `,J=`
839
+ `,N=`
749
840
  datasetKey
750
841
  field
751
842
  message
752
843
  severity
753
- `,Ne=`
844
+ `,Xe=`
754
845
  datasetKey
755
846
  datasetName
756
847
  datasetId
757
848
  exists
758
849
  recordCount
759
850
  fieldMappings {
760
- ${be}
851
+ ${ke}
761
852
  }
762
853
  warnings {
763
- ${J}
854
+ ${N}
764
855
  }
765
856
  canProceed
766
857
  sampleRecords
767
858
  availableDatasets {
768
859
  ${m}
769
- ${w}
860
+ ${S}
770
861
  }
771
- `,je=`
862
+ `,Qe=`
772
863
  datasets {
773
864
  datasetKey
774
865
  datasetName
@@ -776,19 +867,19 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
776
867
  exists
777
868
  recordCount
778
869
  fieldMappings {
779
- ${be}
870
+ ${ke}
780
871
  }
781
872
  warnings {
782
- ${J}
873
+ ${N}
783
874
  }
784
875
  sampleRecords
785
876
  }
786
877
  importOrder
787
878
  warnings {
788
- ${J}
879
+ ${N}
789
880
  }
790
881
  canProceed
791
- `,He=`
882
+ `,Ze=`
792
883
  datasetKey
793
884
  datasetId
794
885
  datasetName
@@ -799,11 +890,11 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
799
890
  skippedCount
800
891
  failedCount
801
892
  errorMessage
802
- `,D=`
893
+ `,w=`
803
894
  id
804
895
  publisherId
805
896
  publisher {
806
- ${g}
897
+ ${I}
807
898
  }
808
899
  gameId
809
900
  game {
@@ -815,14 +906,14 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
815
906
  onConflict
816
907
  fileId
817
908
  assets {
818
- ${Ie}
909
+ ${be}
819
910
  }
820
911
  totalDatasets
821
912
  completedDatasets
822
913
  progress
823
914
  importOrder
824
915
  datasetStatuses {
825
- ${He}
916
+ ${Ze}
826
917
  }
827
918
  errorMessage
828
919
  startedAt
@@ -842,11 +933,11 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
842
933
  linkBuildingCompletedDatasets
843
934
  linkBuildingProcessedRecords
844
935
  linkBuildingTotalRecords
845
- `,A=`
936
+ `,q=`
846
937
  id
847
938
  publisherId
848
939
  publisher {
849
- ${g}
940
+ ${I}
850
941
  }
851
942
  datasetId
852
943
  dataset {
@@ -868,13 +959,13 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
868
959
  createdAt
869
960
  updatedAt
870
961
  lastCheckpointIndex
871
- `,Ye=`
962
+ `,et=`
872
963
  recordId
873
964
  rank
874
965
  score
875
966
  confidence
876
967
  reasons
877
- `,ze=`
968
+ `,tt=`
878
969
  configured
879
970
  url
880
971
  latestDeliveryId
@@ -885,7 +976,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
885
976
  deliveredAt
886
977
  lastStatusCode
887
978
  lastError
888
- `,We=`
979
+ `,rt=`
889
980
  featureVersion
890
981
  candidateCount
891
982
  confidenceScore
@@ -898,7 +989,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
898
989
  details
899
990
  }
900
991
  timings
901
- `,ie=`
992
+ `,ce=`
902
993
  jobId
903
994
  status
904
995
  publisherSlug
@@ -914,14 +1005,14 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
914
1005
  confidence
915
1006
  }
916
1007
  candidates {
917
- ${Ye}
1008
+ ${et}
918
1009
  }
919
1010
  extracted
920
1011
  metrics {
921
- ${We}
1012
+ ${rt}
922
1013
  }
923
1014
  webhook {
924
- ${ze}
1015
+ ${tt}
925
1016
  }
926
1017
  error {
927
1018
  code
@@ -931,7 +1022,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
931
1022
  updatedAt
932
1023
  startedAt
933
1024
  completedAt
934
- `,Xe=`
1025
+ `,st=`
935
1026
  publisherSlug
936
1027
  gameKey
937
1028
  datasetKey
@@ -976,11 +1067,11 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
976
1067
  correctedFeedback
977
1068
  feedbackAccuracy
978
1069
  }
979
- `,q=`
1070
+ `,T=`
980
1071
  code
981
1072
  region
982
1073
  message
983
- `,Qe=`
1074
+ `,it=`
984
1075
  id
985
1076
  key
986
1077
  label
@@ -993,7 +1084,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
993
1084
  isRequired
994
1085
  weight
995
1086
  config
996
- `,C=`
1087
+ `,F=`
997
1088
  id
998
1089
  key
999
1090
  name
@@ -1009,11 +1100,11 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
1009
1100
  notes
1010
1101
  config
1011
1102
  regions {
1012
- ${Qe}
1103
+ ${it}
1013
1104
  }
1014
1105
  createdAt
1015
1106
  updatedAt
1016
- `,Ze=`
1107
+ `,at=`
1017
1108
  key
1018
1109
  label
1019
1110
  semanticType
@@ -1024,7 +1115,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
1024
1115
  source
1025
1116
  status
1026
1117
  confidence
1027
- `,et=`
1118
+ `,nt=`
1028
1119
  id
1029
1120
  key
1030
1121
  name
@@ -1048,32 +1139,32 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
1048
1139
  ${e}
1049
1140
  }
1050
1141
  }
1051
- `}var i={searchPublishers(e={}){let t={},r=[],s=[];e.search!==void 0&&(s.push("$search: String"),r.push("search: $search"),t.search=e.search),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let a=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1052
- query SearchPublishers${a} {
1142
+ `}var a={searchPublishers(e={}){let t={},r=[],s=[];e.search!==void 0&&(s.push("$search: String"),r.push("search: $search"),t.search=e.search),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1143
+ query SearchPublishers${i} {
1053
1144
  searchPublishers${n} {
1054
- ${d(g)}
1145
+ ${d(I)}
1055
1146
  }
1056
1147
  }
1057
1148
  `,variables:t}},fetchPublisherById(){return {query:`
1058
1149
  query FetchPublisher($id: UUID!) {
1059
1150
  fetchPublisher(id: $id) {
1060
- ${g}
1151
+ ${I}
1061
1152
  }
1062
1153
  }
1063
1154
  `}},fetchPublisherBySlug(){return {query:`
1064
1155
  query FetchPublisher($slug: String!) {
1065
1156
  fetchPublisher(slug: $slug) {
1066
- ${g}
1157
+ ${I}
1067
1158
  }
1068
1159
  }
1069
1160
  `}},fetchPublishers(){return {query:`
1070
1161
  query FetchPublishers($slugs: [String!]!) {
1071
1162
  fetchPublishers(slugs: $slugs) {
1072
- ${g}
1163
+ ${I}
1073
1164
  }
1074
1165
  }
1075
- `}},searchGames(e={}){let t={},r=[],s=[];e.publisherSlug!==void 0&&(s.push("$publisherSlug: String"),r.push("publisherSlug: $publisherSlug"),t.publisherSlug=e.publisherSlug),e.search!==void 0&&(s.push("$search: String"),r.push("search: $search"),t.search=e.search),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let a=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1076
- query SearchGames${a} {
1166
+ `}},searchGames(e={}){let t={},r=[],s=[];e.publisherSlug!==void 0&&(s.push("$publisherSlug: String"),r.push("publisherSlug: $publisherSlug"),t.publisherSlug=e.publisherSlug),e.search!==void 0&&(s.push("$search: String"),r.push("search: $search"),t.search=e.search),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1167
+ query SearchGames${i} {
1077
1168
  searchGames${n} {
1078
1169
  ${d(p)}
1079
1170
  }
@@ -1120,8 +1211,8 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
1120
1211
  ${p}
1121
1212
  }
1122
1213
  }
1123
- `}},searchDatasets(e={}){let t={},r=[],s=[];e.publisherSlug!==void 0&&(s.push("$publisherSlug: String"),r.push("publisherSlug: $publisherSlug"),t.publisherSlug=e.publisherSlug),e.gameKey!==void 0&&(s.push("$gameKey: String"),r.push("gameKey: $gameKey"),t.gameKey=e.gameKey),e.search!==void 0&&(s.push("$search: String"),r.push("search: $search"),t.search=e.search),e.purpose!==void 0&&(s.push("$purpose: DatasetPurpose"),r.push("purpose: $purpose"),t.purpose=e.purpose),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let a=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1124
- query SearchDatasets${a} {
1214
+ `}},searchDatasets(e={}){let t={},r=[],s=[];e.publisherSlug!==void 0&&(s.push("$publisherSlug: String"),r.push("publisherSlug: $publisherSlug"),t.publisherSlug=e.publisherSlug),e.gameKey!==void 0&&(s.push("$gameKey: String"),r.push("gameKey: $gameKey"),t.gameKey=e.gameKey),e.search!==void 0&&(s.push("$search: String"),r.push("search: $search"),t.search=e.search),e.purpose!==void 0&&(s.push("$purpose: DatasetPurpose"),r.push("purpose: $purpose"),t.purpose=e.purpose),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1215
+ query SearchDatasets${i} {
1125
1216
  searchDatasets${n} {
1126
1217
  ${d(m)}
1127
1218
  }
@@ -1130,14 +1221,14 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
1130
1221
  query FetchDataset($id: UUID!) {
1131
1222
  fetchDataset(id: $id) {
1132
1223
  ${m}
1133
- ${w}
1224
+ ${S}
1134
1225
  }
1135
1226
  }
1136
1227
  `}},fetchDatasetByKeys(){return {query:`
1137
1228
  query FetchDataset($publisherSlug: String!, $gameKey: String!, $datasetKey: String!) {
1138
1229
  fetchDataset(publisherSlug: $publisherSlug, gameKey: $gameKey, datasetKey: $datasetKey) {
1139
1230
  ${m}
1140
- ${w}
1231
+ ${S}
1141
1232
  }
1142
1233
  }
1143
1234
  `}},fetchDatasets(){return {query:`
@@ -1150,18 +1241,18 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
1150
1241
  query Datasets(${s.join(", ")}) {
1151
1242
  datasets(${r.join(", ")}) {
1152
1243
  ${d(`${m}
1153
- ${w}`)}
1244
+ ${S}`)}
1154
1245
  }
1155
1246
  }
1156
1247
  `,variables:t}},dataset(e){let t={},r=[],s=[];return e.id!==void 0&&(s.push("$id: UUID"),r.push("id: $id"),t.id=e.id),e.publisherId!==void 0&&(s.push("$publisherId: UUID"),r.push("publisherId: $publisherId"),t.publisherId=e.publisherId),e.gameId!==void 0&&(s.push("$gameId: UUID"),r.push("gameId: $gameId"),t.gameId=e.gameId),e.datasetKey!==void 0&&(s.push("$datasetKey: String"),r.push("datasetKey: $datasetKey"),t.datasetKey=e.datasetKey),{query:`
1157
1248
  query Dataset(${s.join(", ")}) {
1158
1249
  dataset(${r.join(", ")}) {
1159
1250
  ${m}
1160
- ${w}
1251
+ ${S}
1161
1252
  }
1162
1253
  }
1163
- `,variables:t}},searchRecords(e){let t={publisherSlug:e.publisherSlug,gameKey:e.gameKey,datasetKey:e.datasetKey},r=["publisherSlug: $publisherSlug","gameKey: $gameKey","datasetKey: $datasetKey"],s=["$publisherSlug: String!","$gameKey: String!","$datasetKey: String!"];e.filter!==void 0&&(s.push("$filter: JSON"),r.push("filter: $filter"),t.filter=e.filter),e.search!==void 0&&(s.push("$search: String"),r.push("search: $search"),t.search=e.search),e.orderBy!==void 0&&(s.push("$orderBy: String"),r.push("orderBy: $orderBy"),t.orderBy=e.orderBy),e.resolveLinks!==void 0&&(s.push("$resolveLinks: [String!]"),r.push("resolveLinks: $resolveLinks"),t.resolveLinks=e.resolveLinks),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),e.validateSchema!==void 0&&(s.push("$validateSchema: Boolean"),r.push("validateSchema: $validateSchema"),t.validateSchema=e.validateSchema);let a=e.resolveLinks&&e.resolveLinks.length>0,n=b({includePricing:e.includePricing}),c=a?`${n}
1164
- ${ae}`:n;return {query:`
1254
+ `,variables:t}},searchRecords(e){let t={publisherSlug:e.publisherSlug,gameKey:e.gameKey,datasetKey:e.datasetKey},r=["publisherSlug: $publisherSlug","gameKey: $gameKey","datasetKey: $datasetKey"],s=["$publisherSlug: String!","$gameKey: String!","$datasetKey: String!"];e.filter!==void 0&&(s.push("$filter: JSON"),r.push("filter: $filter"),t.filter=e.filter),e.search!==void 0&&(s.push("$search: String"),r.push("search: $search"),t.search=e.search),e.orderBy!==void 0&&(s.push("$orderBy: String"),r.push("orderBy: $orderBy"),t.orderBy=e.orderBy),e.resolveLinks!==void 0&&(s.push("$resolveLinks: [String!]"),r.push("resolveLinks: $resolveLinks"),t.resolveLinks=e.resolveLinks),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),e.validateSchema!==void 0&&(s.push("$validateSchema: Boolean"),r.push("validateSchema: $validateSchema"),t.validateSchema=e.validateSchema);let i=e.resolveLinks&&e.resolveLinks.length>0,n=b({includePricing:e.includePricing}),c=i?`${n}
1255
+ ${ne}`:n;return {query:`
1165
1256
  query SearchRecords(${s.join(", ")}) {
1166
1257
  searchRecords(${r.join(", ")}) {
1167
1258
  ${d(c)}
@@ -1194,11 +1285,11 @@ ${ae}`:n;return {query:`
1194
1285
  `}},listDatasetRecords(e){let t={datasetId:e.datasetId},r=["datasetId: $datasetId"],s=["$datasetId: UUID!"];return e.filter!==void 0&&(s.push("$filter: JSON"),r.push("filter: $filter"),t.filter=e.filter),e.orderBy!==void 0&&(s.push("$orderBy: DatasetRecordOrderByInput"),r.push("orderBy: $orderBy"),t.orderBy=e.orderBy),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),e.last!==void 0&&(s.push("$last: Int"),r.push("last: $last"),t.last=e.last),e.before!==void 0&&(s.push("$before: String"),r.push("before: $before"),t.before=e.before),e.validateSchema!==void 0&&(s.push("$validateSchema: Boolean"),r.push("validateSchema: $validateSchema"),t.validateSchema=e.validateSchema),{query:`
1195
1286
  query DatasetRecords(${s.join(", ")}) {
1196
1287
  datasetRecords(${r.join(", ")}) {
1197
- ${d(R)}
1288
+ ${d(C)}
1198
1289
  }
1199
1290
  }
1200
- `,variables:t}},datasetRecord(e){let t={},r=[],s=[];e.id!==void 0&&(s.push("$id: UUID"),r.push("id: $id"),t.id=e.id),e.datasetId!==void 0&&(s.push("$datasetId: UUID"),r.push("datasetId: $datasetId"),t.datasetId=e.datasetId),e.identifier!==void 0&&(s.push("$identifier: String"),r.push("identifier: $identifier"),t.identifier=e.identifier),e.publisherSlug!==void 0&&(s.push("$publisherSlug: String"),r.push("publisherSlug: $publisherSlug"),t.publisherSlug=e.publisherSlug),e.gameKey!==void 0&&(s.push("$gameKey: String"),r.push("gameKey: $gameKey"),t.gameKey=e.gameKey),e.datasetKey!==void 0&&(s.push("$datasetKey: String"),r.push("datasetKey: $datasetKey"),t.datasetKey=e.datasetKey),e.recordId!==void 0&&(s.push("$recordId: UUID"),r.push("recordId: $recordId"),t.recordId=e.recordId),e.resolveLinks!==void 0&&(s.push("$resolveLinks: [String!]"),r.push("resolveLinks: $resolveLinks"),t.resolveLinks=e.resolveLinks),e.validateSchema!==void 0&&(s.push("$validateSchema: Boolean"),r.push("validateSchema: $validateSchema"),t.validateSchema=e.validateSchema);let a=e.resolveLinks&&e.resolveLinks.length>0,n=b({includePricing:e.includePricing}),c=a?`${n}
1201
- ${ae}`:n;return {query:`
1291
+ `,variables:t}},datasetRecord(e){let t={},r=[],s=[];e.id!==void 0&&(s.push("$id: UUID"),r.push("id: $id"),t.id=e.id),e.datasetId!==void 0&&(s.push("$datasetId: UUID"),r.push("datasetId: $datasetId"),t.datasetId=e.datasetId),e.identifier!==void 0&&(s.push("$identifier: String"),r.push("identifier: $identifier"),t.identifier=e.identifier),e.publisherSlug!==void 0&&(s.push("$publisherSlug: String"),r.push("publisherSlug: $publisherSlug"),t.publisherSlug=e.publisherSlug),e.gameKey!==void 0&&(s.push("$gameKey: String"),r.push("gameKey: $gameKey"),t.gameKey=e.gameKey),e.datasetKey!==void 0&&(s.push("$datasetKey: String"),r.push("datasetKey: $datasetKey"),t.datasetKey=e.datasetKey),e.recordId!==void 0&&(s.push("$recordId: UUID"),r.push("recordId: $recordId"),t.recordId=e.recordId),e.resolveLinks!==void 0&&(s.push("$resolveLinks: [String!]"),r.push("resolveLinks: $resolveLinks"),t.resolveLinks=e.resolveLinks),e.validateSchema!==void 0&&(s.push("$validateSchema: Boolean"),r.push("validateSchema: $validateSchema"),t.validateSchema=e.validateSchema);let i=e.resolveLinks&&e.resolveLinks.length>0,n=b({includePricing:e.includePricing}),c=i?`${n}
1292
+ ${ne}`:n;return {query:`
1202
1293
  query DatasetRecord(${s.join(", ")}) {
1203
1294
  datasetRecord(${r.join(", ")}) {
1204
1295
  ${c}
@@ -1207,141 +1298,141 @@ ${ae}`:n;return {query:`
1207
1298
  `,variables:t}},upsertDatasetRecords(){return {query:`
1208
1299
  mutation DatasetRecordsUpsert($input: DatasetRecordsUpsertInput!) {
1209
1300
  datasetRecordsUpsert(input: $input) {
1210
- ${Ge}
1301
+ ${ze}
1211
1302
  }
1212
1303
  }
1213
1304
  `}},deleteDatasetRecords(){return {query:`
1214
1305
  mutation DatasetRecordsDelete($input: DatasetRecordsDeleteInput!) {
1215
1306
  datasetRecordsDelete(input: $input) {
1216
- ${_}
1307
+ ${O}
1217
1308
  }
1218
1309
  }
1219
1310
  `}},datasetRecordDeleteJob(){return {query:`
1220
1311
  query DatasetRecordDeleteJob($id: UUID!) {
1221
1312
  datasetRecordDeleteJob(id: $id) {
1222
- ${_}
1313
+ ${O}
1223
1314
  }
1224
1315
  }
1225
1316
  `}},datasetRecordDeleteJobs(e){let t={publisherId:e.publisherId},r=["publisherId: $publisherId"],s=["$publisherId: UUID!"];return e.datasetId!==void 0&&(s.push("$datasetId: UUID"),r.push("datasetId: $datasetId"),t.datasetId=e.datasetId),e.status!==void 0&&(s.push("$status: DatasetRecordDeleteJobStatus"),r.push("status: $status"),t.status=e.status),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),{query:`
1226
1317
  query DatasetRecordDeleteJobs(${s.join(", ")}) {
1227
1318
  datasetRecordDeleteJobs(${r.join(", ")}) {
1228
- ${d(_)}
1319
+ ${d(O)}
1229
1320
  }
1230
1321
  }
1231
1322
  `,variables:t}},datasetImportPreview(){return {query:`
1232
1323
  query DatasetImportPreview($input: DatasetImportPreviewInput!) {
1233
1324
  datasetImportPreview(input: $input) {
1234
- ${Ne}
1325
+ ${Xe}
1235
1326
  }
1236
1327
  }
1237
1328
  `}},datasetImportValidate(){return {query:`
1238
1329
  query DatasetImportValidate($input: DatasetImportValidateInput!) {
1239
1330
  datasetImportValidate(input: $input) {
1240
- ${ge}
1331
+ ${$e}
1241
1332
  }
1242
1333
  }
1243
1334
  `}},datasetImportFromFile(){return {query:`
1244
1335
  mutation DatasetImportFromFile($input: DatasetImportFromFileInput!) {
1245
1336
  datasetImportFromFile(input: $input) {
1246
- ${$}
1337
+ ${v}
1247
1338
  }
1248
1339
  }
1249
1340
  `}},datasetImportFromPayload(){return {query:`
1250
1341
  mutation DatasetImportFromPayload($input: DatasetImportFromPayloadInput!) {
1251
1342
  datasetImportFromPayload(input: $input) {
1252
- ${$}
1343
+ ${v}
1253
1344
  }
1254
1345
  }
1255
1346
  `}},datasetImportFromUrl(){return {query:`
1256
1347
  mutation DatasetImportFromUrl($input: DatasetImportFromUrlInput!) {
1257
1348
  datasetImportFromUrl(input: $input) {
1258
- ${$}
1349
+ ${v}
1259
1350
  }
1260
1351
  }
1261
1352
  `}},importJob(){return {query:`
1262
1353
  query ImportJob($id: UUID!) {
1263
1354
  importJob(id: $id) {
1264
- ${$}
1355
+ ${v}
1265
1356
  }
1266
1357
  }
1267
1358
  `}},importJobs(e){let t={publisherId:e.publisherId},r=["publisherId: $publisherId"],s=["$publisherId: UUID!"];return e.datasetId!==void 0&&(s.push("$datasetId: UUID"),r.push("datasetId: $datasetId"),t.datasetId=e.datasetId),e.status!==void 0&&(s.push("$status: ImportJobStatus"),r.push("status: $status"),t.status=e.status),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),{query:`
1268
1359
  query ImportJobs(${s.join(", ")}) {
1269
1360
  importJobs(${r.join(", ")}) {
1270
- ${d($)}
1361
+ ${d(v)}
1271
1362
  }
1272
1363
  }
1273
1364
  `,variables:t}},importJobCancel(){return {query:`
1274
1365
  mutation ImportJobCancel($id: UUID!) {
1275
1366
  importJobCancel(id: $id) {
1276
- ${$}
1367
+ ${v}
1277
1368
  }
1278
1369
  }
1279
- `}},importJobLogs(e){let t={importJobId:e.importJobId},r=["id: $importJobId"],s=[],a=["$importJobId: UUID!"];e.level!==void 0&&(a.push("$level: ImportLogLevel"),s.push("level: $level"),t.level=e.level),e.datasetKey!==void 0&&(a.push("$datasetKey: String"),s.push("datasetKey: $datasetKey"),t.datasetKey=e.datasetKey),e.first!==void 0&&(a.push("$first: Int"),s.push("first: $first"),t.first=e.first),e.after!==void 0&&(a.push("$after: String"),s.push("after: $after"),t.after=e.after);let n=s.length>0?`(${s.join(", ")})`:"";return {query:`
1280
- query ImportJobLogs(${a.join(", ")}) {
1370
+ `}},importJobLogs(e){let t={importJobId:e.importJobId},r=["id: $importJobId"],s=[],i=["$importJobId: UUID!"];e.level!==void 0&&(i.push("$level: ImportLogLevel"),s.push("level: $level"),t.level=e.level),e.datasetKey!==void 0&&(i.push("$datasetKey: String"),s.push("datasetKey: $datasetKey"),t.datasetKey=e.datasetKey),e.first!==void 0&&(i.push("$first: Int"),s.push("first: $first"),t.first=e.first),e.after!==void 0&&(i.push("$after: String"),s.push("after: $after"),t.after=e.after);let n=s.length>0?`(${s.join(", ")})`:"";return {query:`
1371
+ query ImportJobLogs(${i.join(", ")}) {
1281
1372
  importJob(${r.join(", ")}) {
1282
1373
  logs${n} {
1283
- ${d(Je)}
1374
+ ${d(Ye)}
1284
1375
  }
1285
1376
  }
1286
1377
  }
1287
1378
  `,variables:t}},gameImportPreview(){return {query:`
1288
1379
  query GameImportPreview($input: GameImportPreviewInput!) {
1289
1380
  gameImportPreview(input: $input) {
1290
- ${je}
1381
+ ${Qe}
1291
1382
  }
1292
1383
  }
1293
1384
  `}},gameImportFromFile(){return {query:`
1294
1385
  mutation GameImportFromFile($input: GameImportFromFileInput!) {
1295
1386
  gameImportFromFile(input: $input) {
1296
- ${D}
1387
+ ${w}
1297
1388
  }
1298
1389
  }
1299
1390
  `}},gameImportFromPayload(){return {query:`
1300
1391
  mutation GameImportFromPayload($input: GameImportFromPayloadInput!) {
1301
1392
  gameImportFromPayload(input: $input) {
1302
- ${D}
1393
+ ${w}
1303
1394
  }
1304
1395
  }
1305
1396
  `}},gameImportFromUrl(){return {query:`
1306
1397
  mutation GameImportFromUrl($input: GameImportFromUrlInput!) {
1307
1398
  gameImportFromUrl(input: $input) {
1308
- ${D}
1399
+ ${w}
1309
1400
  }
1310
1401
  }
1311
1402
  `}},gameImportJob(){return {query:`
1312
1403
  query GameImportJob($id: UUID!) {
1313
1404
  gameImportJob(id: $id) {
1314
- ${D}
1405
+ ${w}
1315
1406
  }
1316
1407
  }
1317
1408
  `}},gameImportJobs(e){let t={gameId:e.gameId},r=["gameId: $gameId"],s=["$gameId: UUID!"];return e.status!==void 0&&(s.push("$status: ImportJobStatus"),r.push("status: $status"),t.status=e.status),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),{query:`
1318
1409
  query GameImportJobs(${s.join(", ")}) {
1319
1410
  gameImportJobs(${r.join(", ")}) {
1320
- ${d(D)}
1411
+ ${d(w)}
1321
1412
  }
1322
1413
  }
1323
1414
  `,variables:t}},gameImportJobCancel(){return {query:`
1324
1415
  mutation GameImportJobCancel($id: UUID!) {
1325
1416
  gameImportJobCancel(id: $id) {
1326
- ${D}
1417
+ ${w}
1327
1418
  }
1328
1419
  }
1329
1420
  `}},file(){return {query:`
1330
1421
  query File($id: UUID!) {
1331
1422
  file(id: $id) {
1332
- ${E}
1423
+ ${x}
1333
1424
  }
1334
1425
  }
1335
1426
  `}},fileUploadRequest(){return {query:`
1336
1427
  mutation FileUploadRequest($input: FileUploadInput!) {
1337
1428
  fileUploadRequest(input: $input) {
1338
- ${Z}
1429
+ ${te}
1339
1430
  }
1340
1431
  }
1341
1432
  `}},fileUploadConfirm(){return {query:`
1342
1433
  mutation FileUploadConfirm($id: UUID!) {
1343
1434
  fileUploadConfirm(id: $id) {
1344
- ${E}
1435
+ ${x}
1345
1436
  }
1346
1437
  }
1347
1438
  `}},fileDelete(){return {query:`
@@ -1351,20 +1442,20 @@ ${ae}`:n;return {query:`
1351
1442
  `}},createScanUploadSession(){return {query:`
1352
1443
  mutation CreateScanUploadSession($input: CreateScanUploadSessionInput!) {
1353
1444
  createScanUploadSession(input: $input) {
1354
- ${Z}
1445
+ ${te}
1355
1446
  }
1356
1447
  }
1357
1448
  `}},confirmScanUpload(){return {query:`
1358
1449
  mutation ConfirmScanUpload($input: ConfirmScanUploadInput!) {
1359
1450
  confirmScanUpload(input: $input) {
1360
- ${E}
1451
+ ${x}
1361
1452
  }
1362
1453
  }
1363
1454
  `}},createScanJob(){return {query:`
1364
1455
  mutation CreateScanJob($input: CreateScanJobInput!) {
1365
1456
  createScanJob(input: $input) {
1366
1457
  job {
1367
- ${ie}
1458
+ ${ce}
1368
1459
  }
1369
1460
  created
1370
1461
  }
@@ -1372,7 +1463,7 @@ ${ae}`:n;return {query:`
1372
1463
  `}},scanJob(){return {query:`
1373
1464
  query ScanJob($id: UUID!) {
1374
1465
  scanJob(id: $id) {
1375
- ${ie}
1466
+ ${ce}
1376
1467
  }
1377
1468
  }
1378
1469
  `}},submitScanFeedback(){return {query:`
@@ -1392,17 +1483,17 @@ ${ae}`:n;return {query:`
1392
1483
  `}},scanMetrics(){return {query:`
1393
1484
  query ScanMetrics($input: ScanMetricsInput!) {
1394
1485
  scanMetrics(input: $input) {
1395
- ${Xe}
1486
+ ${st}
1396
1487
  }
1397
1488
  }
1398
1489
  `}},resolveScanTemplate(){return {query:`
1399
1490
  query ResolveScanTemplate($input: ResolveScanTemplateInput!) {
1400
1491
  resolveScanTemplate(input: $input) {
1401
1492
  template {
1402
- ${C}
1493
+ ${F}
1403
1494
  }
1404
1495
  warnings {
1405
- ${q}
1496
+ ${T}
1406
1497
  }
1407
1498
  }
1408
1499
  }
@@ -1410,7 +1501,7 @@ ${ae}`:n;return {query:`
1410
1501
  query ScanTemplates($input: ScanTemplatesInput!) {
1411
1502
  scanTemplates(input: $input) {
1412
1503
  templates {
1413
- ${C}
1504
+ ${F}
1414
1505
  }
1415
1506
  }
1416
1507
  }
@@ -1418,10 +1509,10 @@ ${ae}`:n;return {query:`
1418
1509
  mutation CreateScanTemplate($input: SaveScanTemplateInput!) {
1419
1510
  createScanTemplate(input: $input) {
1420
1511
  template {
1421
- ${C}
1512
+ ${F}
1422
1513
  }
1423
1514
  warnings {
1424
- ${q}
1515
+ ${T}
1425
1516
  }
1426
1517
  }
1427
1518
  }
@@ -1429,10 +1520,10 @@ ${ae}`:n;return {query:`
1429
1520
  mutation UpdateScanTemplate($id: UUID!, $input: SaveScanTemplateInput!) {
1430
1521
  updateScanTemplate(id: $id, input: $input) {
1431
1522
  template {
1432
- ${C}
1523
+ ${F}
1433
1524
  }
1434
1525
  warnings {
1435
- ${q}
1526
+ ${T}
1436
1527
  }
1437
1528
  }
1438
1529
  }
@@ -1440,10 +1531,10 @@ ${ae}`:n;return {query:`
1440
1531
  mutation PreviewScanTemplate($input: PreviewScanTemplateInput!) {
1441
1532
  previewScanTemplate(input: $input) {
1442
1533
  warnings {
1443
- ${q}
1534
+ ${T}
1444
1535
  }
1445
1536
  regions {
1446
- ${Ze}
1537
+ ${at}
1447
1538
  }
1448
1539
  message
1449
1540
  }
@@ -1451,59 +1542,153 @@ ${ae}`:n;return {query:`
1451
1542
  `}},gameScanRegions(){return {query:`
1452
1543
  query GameScanRegions($publisherSlug: String!, $gameKey: String!, $includeInactive: Boolean) {
1453
1544
  gameScanRegions(publisherSlug: $publisherSlug, gameKey: $gameKey, includeInactive: $includeInactive) {
1454
- ${et}
1545
+ ${nt}
1455
1546
  }
1456
1547
  }
1457
1548
  `}},exportJob(){return {query:`
1458
1549
  query ExportJob($id: UUID!) {
1459
1550
  exportJob(id: $id) {
1460
- ${A}
1551
+ ${q}
1461
1552
  }
1462
1553
  }
1463
1554
  `}},exportJobs(e){let t={publisherId:e.publisherId},r=["publisherId: $publisherId"],s=["$publisherId: UUID!"];return e.gameId!==void 0&&(s.push("$gameId: UUID"),r.push("gameId: $gameId"),t.gameId=e.gameId),e.datasetId!==void 0&&(s.push("$datasetId: UUID"),r.push("datasetId: $datasetId"),t.datasetId=e.datasetId),e.status!==void 0&&(s.push("$status: ExportJobStatus"),r.push("status: $status"),t.status=e.status),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),{query:`
1464
1555
  query ExportJobs(${s.join(", ")}) {
1465
1556
  exportJobs(${r.join(", ")}) {
1466
- ${d(A)}
1557
+ ${d(q)}
1467
1558
  }
1468
1559
  }
1469
1560
  `,variables:t}},datasetExport(){return {query:`
1470
1561
  mutation DatasetExport($input: DatasetExportInput!) {
1471
1562
  datasetExport(input: $input) {
1472
- ${A}
1563
+ ${q}
1473
1564
  }
1474
1565
  }
1475
1566
  `}},exportJobCancel(){return {query:`
1476
1567
  mutation ExportJobCancel($id: UUID!) {
1477
1568
  exportJobCancel(id: $id) {
1478
- ${A}
1569
+ ${q}
1479
1570
  }
1480
1571
  }
1481
1572
  `}},exportJobRefreshUrl(){return {query:`
1482
1573
  mutation ExportJobRefreshUrl($id: UUID!) {
1483
1574
  exportJobRefreshUrl(id: $id) {
1484
- ${A}
1575
+ ${q}
1576
+ }
1577
+ }
1578
+ `}},rulesets(e){let t={gameId:e.gameId},r=["gameId: $gameId"],s=["$gameId: UUID!"];return e.includeArchived!==void 0&&(s.push("$includeArchived: Boolean"),r.push("includeArchived: $includeArchived"),t.includeArchived=e.includeArchived),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),{query:`
1579
+ query Rulesets(${s.join(", ")}) {
1580
+ rulesets(${r.join(", ")}) {
1581
+ ${d(E)}
1582
+ }
1583
+ }
1584
+ `,variables:t}},publicRulesets(e){let t={gameId:e.gameId},r=["gameId: $gameId"],s=["$gameId: UUID!"];return e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),{query:`
1585
+ query PublicRulesets(${s.join(", ")}) {
1586
+ publicRulesets(${r.join(", ")}) {
1587
+ ${d(E)}
1588
+ }
1589
+ }
1590
+ `,variables:t}},ruleset(e){let t={},r=[],s=[];return e.id!==void 0&&(s.push("$id: UUID"),r.push("id: $id"),t.id=e.id),e.gameId!==void 0&&(s.push("$gameId: UUID"),r.push("gameId: $gameId"),t.gameId=e.gameId),e.key!==void 0&&(s.push("$key: String"),r.push("key: $key"),t.key=e.key),{query:`
1591
+ query Ruleset(${s.join(", ")}) {
1592
+ ruleset(${r.join(", ")}) {
1593
+ ${E}
1594
+ }
1595
+ }
1596
+ `,variables:t}},rulesetVersions(e){let t={rulesetId:e.rulesetId},r=["rulesetId: $rulesetId"],s=["$rulesetId: UUID!"];return e.status!==void 0&&(s.push("$status: RulesetVersionStatus"),r.push("status: $status"),t.status=e.status),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),{query:`
1597
+ query RulesetVersions(${s.join(", ")}) {
1598
+ rulesetVersions(${r.join(", ")}) {
1599
+ ${d(g)}
1600
+ }
1601
+ }
1602
+ `,variables:t}},rulesetVersion(){return {query:`
1603
+ query RulesetVersion($id: UUID!) {
1604
+ rulesetVersion(id: $id) {
1605
+ ${g}
1606
+ }
1607
+ }
1608
+ `}},rulesetValidationRules(){return {query:`
1609
+ query RulesetValidationRules($gameId: UUID!, $rulesetKey: String!, $rulesetVersionId: UUID) {
1610
+ rulesetValidationRules(gameId: $gameId, rulesetKey: $rulesetKey, rulesetVersionId: $rulesetVersionId)
1611
+ }
1612
+ `}},deckValidationRules(){return {query:`
1613
+ query DeckValidationRules($gameId: UUID!, $rulesetKey: String!, $rulesetVersionId: UUID) {
1614
+ deckValidationRules(gameId: $gameId, rulesetKey: $rulesetKey, rulesetVersionId: $rulesetVersionId) {
1615
+ ${Te}
1616
+ }
1617
+ }
1618
+ `}},rulesetVersionDraftImportPreview(){return {query:`
1619
+ query RulesetVersionDraftImportPreview($rulesetId: UUID!, $input: RulesetVersionDraftImportFromDatasetRecordInput!) {
1620
+ rulesetVersionDraftImportPreview(rulesetId: $rulesetId, input: $input) {
1621
+ ${Pe}
1622
+ }
1623
+ }
1624
+ `}},rulesetValidationImpact(e){let t={rulesetVersionId:e.rulesetVersionId},r=["rulesetVersionId: $rulesetVersionId"],s=["$rulesetVersionId: UUID!"];return e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),{query:`
1625
+ query RulesetValidationImpact(${s.join(", ")}) {
1626
+ rulesetValidationImpact(${r.join(", ")}) {
1627
+ ${Ve}
1485
1628
  }
1486
1629
  }
1487
- `}},listMyDecks(e={}){let t={},r=[],s=[];e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),e.includeArchived!==void 0&&(s.push("$includeArchived: Boolean"),r.push("includeArchived: $includeArchived"),t.includeArchived=e.includeArchived);let a=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1488
- query MyDecks${a} {
1630
+ `,variables:t}},createRuleset(){return {query:`
1631
+ mutation RulesetCreate($input: RulesetCreateInput!) {
1632
+ rulesetCreate(input: $input) {
1633
+ ${E}
1634
+ }
1635
+ }
1636
+ `}},updateRuleset(){return {query:`
1637
+ mutation RulesetUpdate($id: UUID!, $input: RulesetUpdateInput!) {
1638
+ rulesetUpdate(id: $id, input: $input) {
1639
+ ${E}
1640
+ }
1641
+ }
1642
+ `}},createRulesetVersionDraft(){return {query:`
1643
+ mutation RulesetVersionDraftCreate($rulesetId: UUID!, $input: RulesetVersionDraftCreateInput!) {
1644
+ rulesetVersionDraftCreate(rulesetId: $rulesetId, input: $input) {
1645
+ ${g}
1646
+ }
1647
+ }
1648
+ `}},importRulesetVersionDraftFromDatasetRecord(){return {query:`
1649
+ mutation RulesetVersionDraftImportFromDatasetRecord($rulesetId: UUID!, $input: RulesetVersionDraftImportFromDatasetRecordInput!) {
1650
+ rulesetVersionDraftImportFromDatasetRecord(rulesetId: $rulesetId, input: $input) {
1651
+ ${g}
1652
+ }
1653
+ }
1654
+ `}},updateRulesetVersionDraft(){return {query:`
1655
+ mutation RulesetVersionDraftUpdate($id: UUID!, $input: RulesetVersionDraftUpdateInput!) {
1656
+ rulesetVersionDraftUpdate(id: $id, input: $input) {
1657
+ ${g}
1658
+ }
1659
+ }
1660
+ `}},publishRulesetVersion(){return {query:`
1661
+ mutation RulesetVersionPublish($id: UUID!, $input: RulesetVersionPublishInput) {
1662
+ rulesetVersionPublish(id: $id, input: $input) {
1663
+ ${g}
1664
+ }
1665
+ }
1666
+ `}},activateRulesetVersion(){return {query:`
1667
+ mutation RulesetVersionActivate($id: UUID!) {
1668
+ rulesetVersionActivate(id: $id) {
1669
+ ${g}
1670
+ }
1671
+ }
1672
+ `}},listMyDecks(e={}){let t={},r=[],s=[];e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),e.includeArchived!==void 0&&(s.push("$includeArchived: Boolean"),r.push("includeArchived: $includeArchived"),t.includeArchived=e.includeArchived);let i=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1673
+ query MyDecks${i} {
1489
1674
  myDecks${n} {
1490
1675
  ${d(u)}
1491
1676
  }
1492
1677
  }
1493
- `,variables:t}},viewerDecks(e={}){let t={},r=[],s=[];e.filter!==void 0&&(s.push("$filter: ViewerDecksFilterInput"),r.push("filter: $filter"),t.filter=e.filter),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let a=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1494
- query ViewerDecks${a} {
1678
+ `,variables:t}},viewerDecks(e={}){let t={},r=[],s=[];e.filter!==void 0&&(s.push("$filter: ViewerDecksFilterInput"),r.push("filter: $filter"),t.filter=e.filter),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1679
+ query ViewerDecks${i} {
1495
1680
  viewerDecks${n} {
1496
1681
  ${d(u)}
1497
1682
  }
1498
1683
  }
1499
- `,variables:t}},appDecks(e={}){let t={},r=[],s=[];e.filter!==void 0&&(s.push("$filter: AppDecksFilterInput"),r.push("filter: $filter"),t.filter=e.filter),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let a=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1500
- query AppDecks${a} {
1684
+ `,variables:t}},appDecks(e={}){let t={},r=[],s=[];e.filter!==void 0&&(s.push("$filter: AppDecksFilterInput"),r.push("filter: $filter"),t.filter=e.filter),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1685
+ query AppDecks${i} {
1501
1686
  appDecks${n} {
1502
1687
  ${d(u)}
1503
1688
  }
1504
1689
  }
1505
- `,variables:t}},publicDecks(e={}){let t={},r=[],s=[];e.filter!==void 0&&(s.push("$filter: PublicDecksFilterInput"),r.push("filter: $filter"),t.filter=e.filter),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let a=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1506
- query PublicDecks${a} {
1690
+ `,variables:t}},publicDecks(e={}){let t={},r=[],s=[];e.filter!==void 0&&(s.push("$filter: PublicDecksFilterInput"),r.push("filter: $filter"),t.filter=e.filter),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1691
+ query PublicDecks${i} {
1507
1692
  publicDecks${n} {
1508
1693
  ${d(u)}
1509
1694
  }
@@ -1553,71 +1738,71 @@ ${ae}`:n;return {query:`
1553
1738
  `}},deckVersion(){return {query:`
1554
1739
  query DeckVersion($id: UUID!) {
1555
1740
  deckVersion(id: $id) {
1556
- ${K}
1741
+ ${V}
1557
1742
  }
1558
1743
  }
1559
1744
  `}},deckVersions(e={}){let t={},r=["deckId: $deckId"],s=["$deckId: UUID!"];return e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),{query:`
1560
1745
  query DeckVersions(${s.join(", ")}) {
1561
1746
  deckVersions(${r.join(", ")}) {
1562
- ${d(K)}
1747
+ ${d(V)}
1563
1748
  }
1564
1749
  }
1565
1750
  `,variables:t}},deckDraftDiff(){return {query:`
1566
1751
  query DeckDraftDiff($id: UUID!) {
1567
1752
  deckDraftDiff(id: $id) {
1568
- ${ee}
1753
+ ${re}
1569
1754
  }
1570
1755
  }
1571
1756
  `}},deckVersionDiff(){return {query:`
1572
1757
  query DeckVersionDiff($fromVersionId: UUID!, $toVersionId: UUID!) {
1573
1758
  deckVersionDiff(fromVersionId: $fromVersionId, toVersionId: $toVersionId) {
1574
- ${ee}
1759
+ ${re}
1575
1760
  }
1576
1761
  }
1577
1762
  `}},deckHydrateEntries(){return {query:`
1578
1763
  query DeckHydrateEntries($input: DeckHydrateEntriesInput!) {
1579
1764
  deckHydrateEntries(input: $input) {
1580
- ${Ue}
1765
+ ${Be}
1581
1766
  }
1582
1767
  }
1583
1768
  `}},deckExport(){return {query:`
1584
1769
  query DeckExport($id: UUID!, $format: DeckExportFormat!) {
1585
1770
  deckExport(id: $id, format: $format) {
1586
- ${Fe}
1771
+ ${Me}
1587
1772
  }
1588
1773
  }
1589
1774
  `}},deckValidate(){return {query:`
1590
1775
  query DeckValidate($id: UUID!, $input: DeckValidateInput) {
1591
1776
  deckValidate(id: $id, input: $input) {
1592
- ${H}
1777
+ ${z}
1593
1778
  }
1594
1779
  }
1595
- `}},deckSectionDefinitions(e={}){let t={},r=[],s=[];e.publisherSlug!==void 0&&(s.push("$publisherSlug: String"),r.push("publisherSlug: $publisherSlug"),t.publisherSlug=e.publisherSlug),e.gameKey!==void 0&&(s.push("$gameKey: String"),r.push("gameKey: $gameKey"),t.gameKey=e.gameKey),e.gameId!==void 0&&(s.push("$gameId: UUID"),r.push("gameId: $gameId"),t.gameId=e.gameId),e.rulesetKey!==void 0&&(s.push("$rulesetKey: String"),r.push("rulesetKey: $rulesetKey"),t.rulesetKey=e.rulesetKey),e.rulesetVersionId!==void 0&&(s.push("$rulesetVersionId: UUID"),r.push("rulesetVersionId: $rulesetVersionId"),t.rulesetVersionId=e.rulesetVersionId);let a=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1596
- query DeckSectionDefinitions${a} {
1780
+ `}},deckSectionDefinitions(e={}){let t={},r=[],s=[];e.publisherSlug!==void 0&&(s.push("$publisherSlug: String"),r.push("publisherSlug: $publisherSlug"),t.publisherSlug=e.publisherSlug),e.gameKey!==void 0&&(s.push("$gameKey: String"),r.push("gameKey: $gameKey"),t.gameKey=e.gameKey),e.gameId!==void 0&&(s.push("$gameId: UUID"),r.push("gameId: $gameId"),t.gameId=e.gameId),e.rulesetKey!==void 0&&(s.push("$rulesetKey: String"),r.push("rulesetKey: $rulesetKey"),t.rulesetKey=e.rulesetKey),e.rulesetVersionId!==void 0&&(s.push("$rulesetVersionId: UUID"),r.push("rulesetVersionId: $rulesetVersionId"),t.rulesetVersionId=e.rulesetVersionId);let i=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1781
+ query DeckSectionDefinitions${i} {
1597
1782
  deckSectionDefinitions${n} {
1598
- ${j}
1783
+ ${A}
1599
1784
  }
1600
1785
  }
1601
1786
  `,variables:t}},deckCollaborators(){return {query:`
1602
1787
  query DeckCollaborators($deckId: UUID!) {
1603
1788
  deckCollaborators(deckId: $deckId) {
1604
- ${te}
1789
+ ${se}
1605
1790
  }
1606
1791
  }
1607
1792
  `}},deckApiApplicationAccesses(){return {query:`
1608
1793
  query DeckApiApplicationAccesses($deckId: UUID!, $includeRevoked: Boolean) {
1609
1794
  deckApiApplicationAccesses(deckId: $deckId, includeRevoked: $includeRevoked) {
1610
- ${V}
1795
+ ${M}
1611
1796
  }
1612
1797
  }
1613
1798
  `}},myDeckApiApplicationAccesses(){return {query:`
1614
1799
  query MyDeckApiApplicationAccesses($applicationId: UUID) {
1615
1800
  myDeckApiApplicationAccesses(applicationId: $applicationId) {
1616
- ${V}
1801
+ ${M}
1617
1802
  }
1618
1803
  }
1619
- `}},deckImportFormats(e){let t={},r=[],s=[];e.publisherId!==void 0&&(s.push("$publisherId: UUID"),r.push("publisherId: $publisherId"),t.publisherId=e.publisherId),e.gameId!==void 0&&(s.push("$gameId: UUID"),r.push("gameId: $gameId"),t.gameId=e.gameId),e.includeArchived!==void 0&&(s.push("$includeArchived: Boolean"),r.push("includeArchived: $includeArchived"),t.includeArchived=e.includeArchived),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let a=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1620
- query DeckImportFormats${a} {
1804
+ `}},deckImportFormats(e){let t={},r=[],s=[];e.publisherId!==void 0&&(s.push("$publisherId: UUID"),r.push("publisherId: $publisherId"),t.publisherId=e.publisherId),e.gameId!==void 0&&(s.push("$gameId: UUID"),r.push("gameId: $gameId"),t.gameId=e.gameId),e.includeArchived!==void 0&&(s.push("$includeArchived: Boolean"),r.push("includeArchived: $includeArchived"),t.includeArchived=e.includeArchived),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1805
+ query DeckImportFormats${i} {
1621
1806
  deckImportFormats${n} {
1622
1807
  ${d(k)}
1623
1808
  }
@@ -1631,7 +1816,7 @@ ${ae}`:n;return {query:`
1631
1816
  `}},deckImportFormatTest(){return {query:`
1632
1817
  query DeckImportFormatTest($input: DeckImportFormatTestInput!) {
1633
1818
  deckImportFormatTest(input: $input) {
1634
- ${Ke}
1819
+ ${_e}
1635
1820
  }
1636
1821
  }
1637
1822
  `}},createDeck(){return {query:`
@@ -1671,37 +1856,37 @@ ${ae}`:n;return {query:`
1671
1856
  `}},addDeckEntry(){return {query:`
1672
1857
  mutation DeckEntryAdd($input: DeckEntryAddInput!) {
1673
1858
  deckEntryAdd(input: $input) {
1674
- ${B}
1859
+ ${J}
1675
1860
  }
1676
1861
  }
1677
1862
  `}},updateDeckEntry(){return {query:`
1678
1863
  mutation DeckEntryUpdate($id: UUID!, $input: DeckEntryUpdateInput!) {
1679
1864
  deckEntryUpdate(id: $id, input: $input) {
1680
- ${B}
1865
+ ${J}
1681
1866
  }
1682
1867
  }
1683
1868
  `}},removeDeckEntry(){return {query:`
1684
1869
  mutation DeckEntryRemove($id: UUID!, $expectedDraftRevision: Int!) {
1685
1870
  deckEntryRemove(id: $id, expectedDraftRevision: $expectedDraftRevision) {
1686
- ${B}
1871
+ ${J}
1687
1872
  }
1688
1873
  }
1689
1874
  `}},reorderDeckEntries(){return {query:`
1690
1875
  mutation DeckEntryReorder($deckId: UUID!, $input: DeckEntryReorderInput!) {
1691
1876
  deckEntryReorder(deckId: $deckId, input: $input) {
1692
- ${pe}
1877
+ ${ge}
1693
1878
  }
1694
1879
  }
1695
1880
  `}},replaceDeckEntries(){return {query:`
1696
1881
  mutation DeckEntriesReplace($deckId: UUID!, $input: DeckEntriesReplaceInput!) {
1697
1882
  deckEntriesReplace(deckId: $deckId, input: $input) {
1698
- ${Be}
1883
+ ${Ne}
1699
1884
  }
1700
1885
  }
1701
1886
  `}},importDeck(){return {query:`
1702
1887
  mutation DeckImport($input: DeckImportInput!) {
1703
1888
  deckImport(input: $input) {
1704
- ${_e}
1889
+ ${je}
1705
1890
  }
1706
1891
  }
1707
1892
  `}},createDeckImportFormat(){return {query:`
@@ -1741,25 +1926,25 @@ ${ae}`:n;return {query:`
1741
1926
  `}},claimDeck(){return {query:`
1742
1927
  mutation DeckClaim($id: UUID!, $input: DeckClaimInput!) {
1743
1928
  deckClaim(id: $id, input: $input) {
1744
- ${se}
1929
+ ${ae}
1745
1930
  }
1746
1931
  }
1747
1932
  `}},transferDeckOwnership(){return {query:`
1748
1933
  mutation DeckTransferOwnership($id: UUID!, $input: DeckTransferOwnershipInput!) {
1749
1934
  deckTransferOwnership(id: $id, input: $input) {
1750
- ${se}
1935
+ ${ae}
1751
1936
  }
1752
1937
  }
1753
1938
  `}},copyDeck(){return {query:`
1754
1939
  mutation DeckCopy($id: UUID!, $input: DeckCopyInput!) {
1755
1940
  deckCopy(id: $id, input: $input) {
1756
- ${Pe}
1941
+ ${Je}
1757
1942
  }
1758
1943
  }
1759
1944
  `}},publishDeck(){return {query:`
1760
1945
  mutation DeckPublish($id: UUID!, $input: DeckPublishInput!) {
1761
1946
  deckPublish(id: $id, input: $input) {
1762
- ${Ve}
1947
+ ${Ge}
1763
1948
  }
1764
1949
  }
1765
1950
  `}},removeInvalidDeckEntries(){return {query:`
@@ -1771,7 +1956,7 @@ ${ae}`:n;return {query:`
1771
1956
  `}},upsertDeckCollaborator(){return {query:`
1772
1957
  mutation DeckCollaboratorUpsert($deckId: UUID!, $accountId: UUID!, $role: DeckCollaboratorRole!) {
1773
1958
  deckCollaboratorUpsert(deckId: $deckId, accountId: $accountId, role: $role) {
1774
- ${te}
1959
+ ${se}
1775
1960
  }
1776
1961
  }
1777
1962
  `}},removeDeckCollaborator(){return {query:`
@@ -1781,7 +1966,7 @@ ${ae}`:n;return {query:`
1781
1966
  `}},createDeckTokenIssuer(){return {query:`
1782
1967
  mutation DeckTokenIssuerCreate($input: DeckTokenIssuerCreateInput!) {
1783
1968
  deckTokenIssuerCreate(input: $input) {
1784
- ${re}
1969
+ ${ie}
1785
1970
  }
1786
1971
  }
1787
1972
  `}},revokeDeckTokenIssuer(){return {query:`
@@ -1791,7 +1976,7 @@ ${ae}`:n;return {query:`
1791
1976
  `}},revokeDeckTokenIssuerSigningKey(){return {query:`
1792
1977
  mutation DeckTokenIssuerSigningKeyRevoke($id: UUID!) {
1793
1978
  deckTokenIssuerSigningKeyRevoke(id: $id) {
1794
- ${re}
1979
+ ${ie}
1795
1980
  }
1796
1981
  }
1797
1982
  `}},exchangeDeckToken(){return {query:`
@@ -1799,7 +1984,7 @@ ${ae}`:n;return {query:`
1799
1984
  deckTokenExchange(input: $input) {
1800
1985
  token
1801
1986
  deckToken {
1802
- ${Te}
1987
+ ${Le}
1803
1988
  }
1804
1989
  }
1805
1990
  }
@@ -1810,14 +1995,14 @@ ${ae}`:n;return {query:`
1810
1995
  `}},grantDeckApiApplicationAccess(){return {query:`
1811
1996
  mutation DeckApiApplicationAccessGrant($input: DeckAPIApplicationAccessGrantInput!) {
1812
1997
  deckApiApplicationAccessGrant(input: $input) {
1813
- ${V}
1998
+ ${M}
1814
1999
  }
1815
2000
  }
1816
2001
  `}},revokeDeckApiApplicationAccess(){return {query:`
1817
2002
  mutation DeckApiApplicationAccessRevoke($deckId: UUID!, $apiApplicationId: UUID!) {
1818
2003
  deckApiApplicationAccessRevoke(deckId: $deckId, apiApplicationId: $apiApplicationId)
1819
2004
  }
1820
- `}},deckCreateVariables(e){return {input:I(e)}},deckUpdateVariables(e,t){return {id:e,input:I(t)}},deckEntryAddVariables(e){return {input:I(e)}},deckEntryUpdateVariables(e,t){return {id:e,input:I(t)}},deckEntryRemoveVariables(e,t){return {id:e,expectedDraftRevision:t}},deckEntryReorderVariables(e,t){return {deckId:e,input:t}},deckEntriesReplaceVariables(e,t){return {deckId:e,input:I(t)}},deckImportVariables(e){return {input:e}},deckImportFormatCreateVariables(e){return {input:e}},deckImportFormatUpdateVariables(e,t){return {id:e,input:t}},deckImportFormatTestVariables(e){return {input:e}},deckUpsertByExternalRefVariables(e){return {input:I(e)}},deckReadVariables(e,t,r){return {id:e,readState:t,version:r}},deckExternalRefReadVariables(e,t,r){return {externalRef:e,readState:t,version:r}},deckClaimVariables(e,t){return {id:e,input:t}},deckTransferOwnershipVariables(e,t){return {id:e,input:t}},deckCopyVariables(e,t){return {id:e,input:t}},deckPublishVariables(e,t){return {id:e,input:t}},deckValidateVariables(e,t){return t===void 0?{id:e}:{id:e,input:t}},deckRemoveInvalidEntriesVariables(e,t){return {id:e,input:t}},deckHydrateEntriesVariables(e){return {input:I(e)}},deckExportVariables(e,t){return {id:e,format:t}},deckVersionDiffVariables(e,t){return {fromVersionId:e,toVersionId:t}},deckCollaboratorVariables(e,t,r){return r===void 0?{deckId:e,accountId:t}:{deckId:e,accountId:t,role:r}},deckTokenIssuerCreateVariables(e){return {input:e}},deckTokenExchangeVariables(e){return {input:e}},deckApiApplicationAccessesVariables(e,t){return t===void 0?{deckId:e}:{deckId:e,includeRevoked:t}},myDeckApiApplicationAccessesVariables(e){return e===void 0?{}:{applicationId:e}},deckApiApplicationAccessGrantVariables(e){return {input:e}},deckApiApplicationAccessRevokeVariables(e,t){return {deckId:e,apiApplicationId:t}},gameCreateVariables(e){return {input:e}},gameUpdateVariables(e,t){return {id:e,input:t}},datasetImportPreviewVariables(e){return {input:e}},datasetImportValidateVariables(e){return {input:e}},datasetImportFromFileVariables(e){return {input:e}},datasetImportFromPayloadVariables(e){return {input:e}},datasetImportFromUrlVariables(e){return {input:e}},gameImportPreviewVariables(e){return {input:e}},gameImportFromFileVariables(e){return {input:e}},gameImportFromPayloadVariables(e){return {input:e}},gameImportFromUrlVariables(e){return {input:e}},datasetRecordsUpsertVariables(e){return {input:e}},datasetRecordsDeleteVariables(e){return {input:e}},fileUploadRequestVariables(e){return {input:e}},createScanUploadSessionVariables(e){return {input:e}},confirmScanUploadVariables(e){return {input:e}},createScanJobVariables(e){return {input:e}},submitScanFeedbackVariables(e){return {input:e}},scanMetricsVariables(e){return {input:e}},resolveScanTemplateVariables(e){return {input:e}},scanTemplatesVariables(e){return {input:e}},createScanTemplateVariables(e){return {input:e}},updateScanTemplateVariables(e,t){return {id:e,input:t}},previewScanTemplateVariables(e){return {input:e}},gameScanRegionsVariables(e,t,r){return r===void 0?{publisherSlug:e,gameKey:t}:{publisherSlug:e,gameKey:t,includeInactive:r}},datasetExportVariables(e){return {input:e}},fetchMe(){return {query:`
2005
+ `}},rulesetValidationRulesVariables(e,t,r){return r===void 0?{gameId:e,rulesetKey:t}:{gameId:e,rulesetKey:t,rulesetVersionId:r}},rulesetVersionDraftImportPreviewVariables(e,t){return {rulesetId:e,input:t}},rulesetCreateVariables(e){return {input:e}},rulesetUpdateVariables(e,t){return {id:e,input:t}},rulesetVersionDraftCreateVariables(e,t){return {rulesetId:e,input:t}},rulesetVersionDraftImportFromDatasetRecordVariables(e,t){return {rulesetId:e,input:t}},rulesetVersionDraftUpdateVariables(e,t){return {id:e,input:t}},rulesetVersionPublishVariables(e,t){return t===void 0?{id:e}:{id:e,input:t}},deckCreateVariables(e){return {input:$(e)}},deckUpdateVariables(e,t){return {id:e,input:$(t)}},deckEntryAddVariables(e){return {input:$(e)}},deckEntryUpdateVariables(e,t){return {id:e,input:$(t)}},deckEntryRemoveVariables(e,t){return {id:e,expectedDraftRevision:t}},deckEntryReorderVariables(e,t){return {deckId:e,input:t}},deckEntriesReplaceVariables(e,t){return {deckId:e,input:$(t)}},deckImportVariables(e){return {input:e}},deckImportFormatCreateVariables(e){return {input:e}},deckImportFormatUpdateVariables(e,t){return {id:e,input:t}},deckImportFormatTestVariables(e){return {input:e}},deckUpsertByExternalRefVariables(e){return {input:$(e)}},deckReadVariables(e,t,r){return {id:e,readState:t,version:r}},deckExternalRefReadVariables(e,t,r){return {externalRef:e,readState:t,version:r}},deckClaimVariables(e,t){return {id:e,input:t}},deckTransferOwnershipVariables(e,t){return {id:e,input:t}},deckCopyVariables(e,t){return {id:e,input:t}},deckPublishVariables(e,t){return {id:e,input:t}},deckValidateVariables(e,t){return t===void 0?{id:e}:{id:e,input:t}},deckRemoveInvalidEntriesVariables(e,t){return {id:e,input:t}},deckHydrateEntriesVariables(e){return {input:$(e)}},deckExportVariables(e,t){return {id:e,format:t}},deckVersionDiffVariables(e,t){return {fromVersionId:e,toVersionId:t}},deckCollaboratorVariables(e,t,r){return r===void 0?{deckId:e,accountId:t}:{deckId:e,accountId:t,role:r}},deckTokenIssuerCreateVariables(e){return {input:e}},deckTokenExchangeVariables(e){return {input:e}},deckApiApplicationAccessesVariables(e,t){return t===void 0?{deckId:e}:{deckId:e,includeRevoked:t}},myDeckApiApplicationAccessesVariables(e){return e===void 0?{}:{applicationId:e}},deckApiApplicationAccessGrantVariables(e){return {input:e}},deckApiApplicationAccessRevokeVariables(e,t){return {deckId:e,apiApplicationId:t}},gameCreateVariables(e){return {input:e}},gameUpdateVariables(e,t){return {id:e,input:t}},datasetImportPreviewVariables(e){return {input:e}},datasetImportValidateVariables(e){return {input:e}},datasetImportFromFileVariables(e){return {input:e}},datasetImportFromPayloadVariables(e){return {input:e}},datasetImportFromUrlVariables(e){return {input:e}},gameImportPreviewVariables(e){return {input:e}},gameImportFromFileVariables(e){return {input:e}},gameImportFromPayloadVariables(e){return {input:e}},gameImportFromUrlVariables(e){return {input:e}},datasetRecordsUpsertVariables(e){return {input:e}},datasetRecordsDeleteVariables(e){return {input:e}},fileUploadRequestVariables(e){return {input:e}},createScanUploadSessionVariables(e){return {input:e}},confirmScanUploadVariables(e){return {input:e}},createScanJobVariables(e){return {input:e}},submitScanFeedbackVariables(e){return {input:e}},scanMetricsVariables(e){return {input:e}},resolveScanTemplateVariables(e){return {input:e}},scanTemplatesVariables(e){return {input:e}},createScanTemplateVariables(e){return {input:e}},updateScanTemplateVariables(e,t){return {id:e,input:t}},previewScanTemplateVariables(e){return {input:e}},gameScanRegionsVariables(e,t,r){return r===void 0?{publisherSlug:e,gameKey:t}:{publisherSlug:e,gameKey:t,includeInactive:r}},datasetExportVariables(e){return {input:e}},fetchMe(){return {query:`
1821
2006
  query FetchMe {
1822
2007
  fetchMe {
1823
2008
  application {
@@ -1839,6 +2024,6 @@ ${ae}`:n;return {query:`
1839
2024
  }
1840
2025
  }
1841
2026
  }
1842
- `}}},l=class{totalCount;pageInfo;items;nextPageLoader;constructor(e,t={}){this.totalCount=e.totalCount,this.pageInfo=e.pageInfo,this.items=e.edges.map(r=>t.itemTransformer?t.itemTransformer(r.node):r.node),this.nextPageLoader=t.nextPageLoader;}get hasNextPage(){return this.pageInfo.hasNextPage}get hasPreviousPage(){return this.pageInfo.hasPreviousPage}get endCursor(){return this.pageInfo.endCursor}get startCursor(){return this.pageInfo.startCursor}get length(){return this.items.length}get isEmpty(){return this.items.length===0}get first(){return this.items[0]}get last(){return this.items[this.items.length-1]}async nextPage(){if(!this.hasNextPage)return null;if(!this.nextPageLoader)throw new Error("No next page loader configured");return this.endCursor?this.nextPageLoader(this.endCursor):null}async*[Symbol.asyncIterator](){let e=this;for(;e;){for(let t of e.items)yield t;if(!e.hasNextPage)break;e=await e.nextPage();}}async forEach(e){let t=0;for await(let r of this)await e(r,t++);}async map(e){let t=[],r=0;for await(let s of this)t.push(await e(s,r++));return t}async filter(e){let t=[],r=0;for await(let s of this)await e(s,r++)&&t.push(s);return t}async find(e){let t=0;for await(let r of this)if(await e(r,t++))return r}async take(e){let t=[];for await(let r of this){if(t.length>=e)break;t.push(r);}return t}async toArray(){let e=[];for await(let t of this)e.push(t);return e}async*batches(){let e=this;for(;e&&(e.items.length>0&&(yield e.items),!!e.hasNextPage);)e=await e.nextPage();}each(){return this}};var tt="https://carddb.dev/query",rt=3e4,st=1e4,at=300,it=3,nt=2,ct=1e3,ot=3e4,ut=class ke{apiKey;publishableKey;secretKey;accessToken;legacyApiKey;environment;endpoint;timeout;openTimeout;defaultPublisher;defaultGame;allowedPublishers;allowedGames;logger;logLevel;retryOnRateLimit;maxRetries;retryOnNetworkError;maxNetworkRetries;retryBaseDelay;retryMaxDelay;cache;cacheTtl;cacheTtls;constructor(t={}){this.legacyApiKey=t.apiKey,this.publishableKey=t.publishableKey,this.secretKey=t.secretKey,this.accessToken=t.accessToken,this.apiKey=t.apiKey??t.publishableKey??t.secretKey,this.environment=t.environment,this.endpoint=t.endpoint??tt,this.timeout=t.timeout??rt,this.openTimeout=t.openTimeout??st,this.defaultPublisher=t.defaultPublisher,this.defaultGame=t.defaultGame,this.allowedPublishers=t.allowedPublishers,this.allowedGames=t.allowedGames,this.logger=t.logger,this.logLevel=t.logLevel??"info",this.retryOnRateLimit=t.retryOnRateLimit??false,this.maxRetries=t.maxRetries??it,this.retryOnNetworkError=t.retryOnNetworkError??true,this.maxNetworkRetries=t.maxNetworkRetries??nt,this.retryBaseDelay=t.retryBaseDelay??ct,this.retryMaxDelay=t.retryMaxDelay??ot,this.cache=t.cache,this.cacheTtl=t.cacheTtl??at,this.cacheTtls=t.cacheTtls??{};}calculateRetryDelay(t){let r=this.retryBaseDelay*Math.pow(2,t),s=Math.min(r,this.retryMaxDelay),a=s*.25*(Math.random()*2-1);return Math.round(s+a)}cacheTtlFor(t){return this.cacheTtls[t]??this.cacheTtl}resolvePublisher(t){return t??this.defaultPublisher}resolveGame(t){return t??this.defaultGame}validatePublisher(t){if(this.allowedPublishers&&!this.allowedPublishers.includes(t))throw new v(`Publisher '${t}' is not in the allowed publishers list`)}validateGame(t,r){if(!this.allowedGames)return;let s=this.allowedGames[t];if(s&&!s.includes(r))throw new v(`Game '${r}' is not allowed for publisher '${t}'`)}validateAccess(t,r){t&&(this.validatePublisher(t),r&&this.validateGame(t,r));}requireSecretCredential(t){if(!(!this.accessToken&&(this.legacyApiKey||this.secretKey&&!this.publishableKey)))throw new v(`${t} requires a server-side secretKey or legacy apiKey credential`)}requestApiKey(){return this.legacyApiKey??this.publishableKey??this.secretKey}configApiKey(){return this.legacyApiKey}shouldLog(t){let r={debug:0,info:1,warn:2,error:3};return r[t]>=r[this.logLevel]}merge(t){return new ke({apiKey:t.apiKey??this.legacyApiKey,publishableKey:t.publishableKey??this.publishableKey,secretKey:t.secretKey??this.secretKey,accessToken:t.accessToken??this.accessToken,environment:t.environment??this.environment,endpoint:t.endpoint??this.endpoint,timeout:t.timeout??this.timeout,openTimeout:t.openTimeout??this.openTimeout,defaultPublisher:t.defaultPublisher??this.defaultPublisher,defaultGame:t.defaultGame??this.defaultGame,allowedPublishers:t.allowedPublishers??this.allowedPublishers,allowedGames:t.allowedGames??this.allowedGames,logger:t.logger??this.logger,logLevel:t.logLevel??this.logLevel,retryOnRateLimit:t.retryOnRateLimit??this.retryOnRateLimit,maxRetries:t.maxRetries??this.maxRetries,retryOnNetworkError:t.retryOnNetworkError??this.retryOnNetworkError,maxNetworkRetries:t.maxNetworkRetries??this.maxNetworkRetries,retryBaseDelay:t.retryBaseDelay??this.retryBaseDelay,retryMaxDelay:t.retryMaxDelay??this.retryMaxDelay,cache:t.cache??this.cache,cacheTtl:t.cacheTtl??this.cacheTtl,cacheTtls:t.cacheTtls??this.cacheTtls})}},$e="0.4.1";function lt(){if(typeof globalThis<"u"&&"Bun"in globalThis){let e=globalThis.Bun&&typeof globalThis.Bun=="object"&&globalThis.Bun.version;return {name:"bun",version:typeof e=="string"?e:"unknown"}}if(typeof globalThis<"u"&&"Deno"in globalThis){let e=globalThis.Deno&&typeof globalThis.Deno=="object"&&globalThis.Deno.version&&typeof globalThis.Deno.version=="object"&&globalThis.Deno.version.deno;return {name:"deno",version:typeof e=="string"?e:"unknown"}}return typeof process<"u"&&process.versions&&process.versions.node?{name:"node",version:process.versions.node}:typeof navigator<"u"&&navigator.userAgent?dt(navigator.userAgent):{name:"unknown",version:"unknown"}}function dt(e){let t=e.match(/Edg\/(\d+(?:\.\d+)*)/);if(t)return {name:"edge",version:t[1]};let r=e.match(/Chrome\/(\d+(?:\.\d+)*)/);if(r&&!e.includes("Edg/"))return {name:"chrome",version:r[1]};let s=e.match(/Firefox\/(\d+(?:\.\d+)*)/);if(s)return {name:"firefox",version:s[1]};let a=e.match(/Version\/(\d+(?:\.\d+)*).*Safari/);return a?{name:"safari",version:a[1]}:{name:"browser",version:"unknown"}}function ht(){let e=lt();return `CardDB-SDK/js/${$e} (${e.name}/${e.version})`}function gr(){return $e}var ve=null;function yt(){return ve}var ft=class{config;constructor(e){this.config=e;}async execute(e,t={}){let r=this.extractOperationName(e),s=0,a=0;for(;;)try{let n=Date.now();this.logRequest(r,t);let c=await this.fetch(e,t),o=Date.now()-n,h=await this.handleResponse(c);return this.logResponse(r,o),h}catch(n){if(n instanceof U&&this.config.retryOnRateLimit&&s<this.config.maxRetries){s++;let c=n.retryAfter??60;this.logRateLimitRetry(r,s,c),await this.sleep(c*1e3);continue}if(this.isRetryableNetworkError(n)&&this.config.retryOnNetworkError&&a<this.config.maxNetworkRetries){let c=this.config.calculateRetryDelay(a);this.logNetworkRetry(r,a+1,c,n),a++,await this.sleep(c);continue}if(n instanceof N&&this.config.retryOnNetworkError&&a<this.config.maxNetworkRetries){let c=this.config.calculateRetryDelay(a);this.logNetworkRetry(r,a+1,c,n),a++,await this.sleep(c);continue}throw n}}isRetryableNetworkError(e){return e instanceof x||e instanceof O}async fetch(e,t){let r=new AbortController,s=setTimeout(()=>r.abort(),this.config.timeout),a=this.config.requestApiKey();try{return await fetch(this.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","User-Agent":ht(),...this.config.accessToken?{Authorization:`Bearer ${this.config.accessToken}`}:{},...!this.config.accessToken&&a?{"X-API-Key":a}:{}},body:JSON.stringify({query:e,variables:t}),signal:r.signal})}catch(n){throw n instanceof Error?n.name==="AbortError"?(this.logError("Request timed out"),new O("Request timed out")):(this.logError(`Connection failed: ${n.message}`),new x(`Connection failed: ${n.message}`)):new x("Connection failed")}finally{clearTimeout(s);}}async handleResponse(e){switch(this.extractRateLimitInfo(e),e.status){case 200:return this.handleSuccessResponse(e);case 401:throw new G("Invalid or missing API key");case 429:return this.handleRateLimitResponse(e);default:if(e.status>=400&&e.status<500)return this.handleClientError(e);if(e.status>=500){let t=await this.parseBody(e);throw new N(`Server error (${e.status})`,{status:e.status,response:t})}throw new y(`Unexpected response status: ${e.status}`)}}async handleSuccessResponse(e){let t=await this.parseBody(e);return t.errors&&t.errors.length>0&&this.handleGraphQLErrors(t.errors,t),t.data??{}}handleGraphQLErrors(e,t){let r=e[0],s=r.message||"GraphQL error";switch(r.extensions?.code){case "UNAUTHENTICATED":throw new G(s,t);case "RATE_LIMITED":throw new U(s,{response:t});case "NOT_FOUND":throw new y(s,t);case "VALIDATION_ERROR":case "BAD_USER_INPUT":throw new F(s,{errors:e,response:t});default:throw new ce(s,{errors:e,response:t})}}async handleRateLimitResponse(e){let t=parseInt(e.headers.get("Retry-After")??"60",10),r=parseInt(e.headers.get("X-RateLimit-Limit")??"",10)||null,s=parseInt(e.headers.get("X-RateLimit-Remaining")??"",10)||null,a=parseInt(e.headers.get("X-RateLimit-Reset")??"",10)||null,n=a?new Date(a*1e3):null,c=await this.parseBody(e);throw new U("Rate limit exceeded",{retryAfter:t,limit:r,remaining:s,resetAt:n,response:c})}async handleClientError(e){let t=await this.parseBody(e),r=t.errors?.[0]?.message??`Client error (${e.status})`;throw new F(r,{response:t})}async parseBody(e){try{return await e.json()}catch{return {raw:await e.text()}}}extractRateLimitInfo(e){let t=parseInt(e.headers.get("X-RateLimit-Limit")??"",10)||null,r=parseInt(e.headers.get("X-RateLimit-Remaining")??"",10)||null,s=parseInt(e.headers.get("X-RateLimit-Reset")??"",10)||null;ve={limit:t,remaining:r,reset:s};}extractOperationName(e){let t=e.match(/(?:query|mutation)\s+(\w+)/);return t?t[1]:"Unknown"}sleep(e){return new Promise(t=>setTimeout(t,e))}logRequest(e,t){!this.config.logger||!this.config.shouldLog("debug")||this.config.logger.debug(`[CardDB] Executing ${e}`,{variables:t});}logResponse(e,t){!this.config.logger||!this.config.shouldLog("info")||this.config.logger.info(`[CardDB] ${e} completed in ${t}ms`);}logRateLimitRetry(e,t,r){!this.config.logger||!this.config.shouldLog("warn")||this.config.logger.warn(`[CardDB] Rate limited on ${e}, retry ${t}/${this.config.maxRetries} after ${r}s`);}logNetworkRetry(e,t,r,s){if(!this.config.logger||!this.config.shouldLog("warn"))return;let a=s instanceof Error?s.name:"Unknown";this.config.logger.warn(`[CardDB] ${a} on ${e}, retry ${t}/${this.config.maxNetworkRetries} after ${r}ms`);}logError(e){!this.config.logger||!this.config.shouldLog("error")||this.config.logger.error(`[CardDB] ${e}`);}};function pt(e,t,r){let s=Object.entries(r).filter(([,a])=>a!==void 0).sort(([a],[n])=>a.localeCompare(n)).map(([a,n])=>`${a}=${JSON.stringify(n)}`).join("&");return `carddb:${e}:${t}:${s}`}async function mt(e,t){let r=e.get(t);return r}async function gt(e,t,r,s){let a=e.set(t,r,s);a instanceof Promise&&await a;}var f=class{connection;config;constructor(e,t){this.connection=e,this.config=t;}resolvePublisher(e){let t=this.config.resolvePublisher(e);if(!t)throw new Error("publisher_slug is required (no default configured)");return t}resolveGame(e){let t=this.config.resolveGame(e);if(!t)throw new Error("game_key is required (no default configured)");return t}validateAccess(e,t){this.config.validateAccess(e,t);}async withCache(e,t,r,s){let a=r.cache??!!this.config.cache,n=this.config.cache;if(!a||!n)return s();let c=await mt(n,e);if(c!==null)return c;let o=await s();if(o!=null){let h=this.config.cacheTtlFor(t);await gt(n,e,o,h);}return o}cacheKey(e,t,r){return pt(e,t,r)}},It=class extends f{constructor(e,t){super(e,t);}async search(e={}){let{query:t,variables:r}=i.searchPublishers({search:e.search,first:e.first,after:e.after}),s=this.cacheKey("publishers","search",r),a=await this.withCache(s,"publishers",e,async()=>(await this.connection.execute(t,r)).searchPublishers);return new l(a,{nextPageLoader:async n=>this.search({...e,after:n})})}async get(e,t={}){let r=this.isUUID(e),s=this.cacheKey("publishers","get",{[r?"id":"slug"]:e});return this.withCache(s,"publishers",t,async()=>{if(r){let{query:a}=i.fetchPublisherById();return (await this.connection.execute(a,{id:e})).fetchPublisher??null}else {let{query:a}=i.fetchPublisherBySlug();return (await this.connection.execute(a,{slug:e})).fetchPublisher??null}})}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("publishers","getMany",{slugs:e});return this.withCache(r,"publishers",t,async()=>{let{query:s}=i.fetchPublishers();return (await this.connection.execute(s,{slugs:e})).fetchPublishers??[]})}isUUID(e){return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}},bt=class extends f{constructor(e,t){super(e,t);}async list(e,t={}){let{query:r,variables:s}=i.listGames({publisherId:e,first:t.first,after:t.after,includeArchived:t.includeArchived}),a=this.cacheKey("games","list",s),n=await this.withCache(a,"games",t,async()=>(await this.connection.execute(r,s)).games);return new l(n,{nextPageLoader:async c=>this.list(e,{...t,after:c})})}async getByKey(e){let t=this.cacheKey("games","getByKey",{publisherId:e.publisherId,publisherSlug:e.publisherSlug,gameKey:e.gameKey});return this.withCache(t,"games",e,async()=>{let{query:r,variables:s}=i.game(e);return (await this.connection.execute(r,s)).game??null})}async getBySlug(e){let t=this.cacheKey("games","getBySlug",{publisherId:e.publisherId,publisherSlug:e.publisherSlug,gameSlug:e.gameSlug});return this.withCache(t,"games",e,async()=>{let{query:r,variables:s}=i.game(e);return (await this.connection.execute(r,s)).game??null})}async create(e){this.config.requireSecretCredential("games.create");let{query:t}=i.createGame();return (await this.connection.execute(t,i.gameCreateVariables(e))).gameCreate}async update(e,t){this.config.requireSecretCredential("games.update");let{query:r}=i.updateGame();return (await this.connection.execute(r,i.gameUpdateVariables(e,t))).gameUpdate}async getRegions(e={}){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=i.gameScanRegionsVariables(t,r,e.includeInactive),a=this.cacheKey("games","getRegions",s);return this.withCache(a,"games",e,async()=>{let{query:n}=i.gameScanRegions();return (await this.connection.execute(n,s)).gameScanRegions??[]})}async search(e={}){let t=this.config.resolvePublisher(e.publisherSlug);t&&this.validateAccess(t);let{query:r,variables:s}=i.searchGames({publisherSlug:t,search:e.search,first:e.first,after:e.after}),a=this.cacheKey("games","search",s),n=await this.withCache(a,"games",e,async()=>(await this.connection.execute(r,s)).searchGames);return new l(n,{nextPageLoader:async c=>this.search({...e,after:c})})}async get(e,t,r){if(typeof t=="string"){let s=e,a=t,n=r??{};this.validateAccess(s,a);let c=this.cacheKey("games","getByKeys",{publisherSlug:s,gameKey:a});return this.withCache(c,"games",n,async()=>{let{query:o}=i.fetchGameByKeys();return (await this.connection.execute(o,{publisherSlug:s,gameKey:a})).fetchGame??null})}else {let s=e,a=t??{},n=this.cacheKey("games","get",{id:s});return this.withCache(n,"games",a,async()=>{let{query:c}=i.fetchGameById();return (await this.connection.execute(c,{id:s})).fetchGame??null})}}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("games","getMany",{ids:e});return this.withCache(r,"games",t,async()=>{let{query:s}=i.fetchGames();return (await this.connection.execute(s,{ids:e})).fetchGames??[]})}},kt=class extends f{constructor(e,t){super(e,t);}async list(e,t={}){let{query:r,variables:s}=i.listDatasets({publisherId:e,gameId:t.gameId,includeArchived:t.includeArchived,purpose:t.purpose,first:t.first,after:t.after}),a=this.cacheKey("datasets","list",s),n=await this.withCache(a,"datasets",t,async()=>(await this.connection.execute(r,s)).datasets);return new l(n,{nextPageLoader:async c=>this.list(e,{...t,after:c})})}async getByKey(e){let t=this.cacheKey("datasets","getByKey",{publisherId:e.publisherId,gameId:e.gameId,datasetKey:e.datasetKey});return this.withCache(t,"datasets",e,async()=>{let{query:r,variables:s}=i.dataset(e);return (await this.connection.execute(r,s)).dataset??null})}async getSchema(e){return (typeof e=="string"?await this.withCache(this.cacheKey("datasets","getSchema",{id:e}),"datasets",{},async()=>{let{query:r,variables:s}=i.dataset({id:e});return (await this.connection.execute(r,s)).dataset??null}):await this.getByKey(e))?.schema??null}async search(e={}){let t=this.config.resolvePublisher(e.publisherSlug),r=this.config.resolveGame(e.gameKey);t&&this.validateAccess(t,r);let{query:s,variables:a}=i.searchDatasets({publisherSlug:t,gameKey:r,search:e.search,purpose:e.purpose,first:e.first,after:e.after}),n=this.cacheKey("datasets","search",a),c=await this.withCache(n,"datasets",e,async()=>(await this.connection.execute(s,a)).searchDatasets);return new l(c,{nextPageLoader:async o=>this.search({...e,after:o})})}async get(e,t,r,s){if(typeof t=="string"&&typeof r=="string"){let a=e,n=t,c=s??{};this.validateAccess(a,n);let o=this.cacheKey("datasets","getByKeys",{publisherSlug:a,gameKey:n,datasetKey:r});return this.withCache(o,"datasets",c,async()=>{let{query:h}=i.fetchDatasetByKeys();return (await this.connection.execute(h,{publisherSlug:a,gameKey:n,datasetKey:r})).fetchDataset??null})}else {let a=e,n=t??{},c=this.cacheKey("datasets","get",{id:a});return this.withCache(c,"datasets",n,async()=>{let{query:o}=i.fetchDatasetById();return (await this.connection.execute(o,{id:a})).fetchDataset??null})}}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("datasets","getMany",{ids:e});return this.withCache(r,"datasets",t,async()=>{let{query:s}=i.fetchDatasets();return (await this.connection.execute(s,{ids:e})).fetchDatasets??[]})}},$t=class extends f{constructor(e,t){super(e,t);}async fetch(e,t={}){let r=this.cacheKey("decks","fetch",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=i.fetchDeckById();return (await this.connection.execute(s,{id:e})).fetchDeck??null})}async get(e,t){let r=i.deckReadVariables(e,t.readState,t.version),s=this.cacheKey("decks","get",r);return this.withCache(s,"decks",t,async()=>{let{query:a}=i.deckById();return (await this.connection.execute(a,r)).deck??null})}async getDraft(e,t={}){return this.get(e,{...t,readState:"DRAFT"})}async getPublished(e,t={}){return this.get(e,{...t,readState:"PUBLISHED",version:t.version})}async fetchMine(e,t={}){let r=this.cacheKey("decks","fetchMine",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=i.myDeck();return (await this.connection.execute(s,{id:e})).myDeck??null})}async fetchBySlug(e,t,r,s={}){let a=this.cacheKey("decks","fetchBySlug",{publisherSlug:e,gameKey:t,slug:r});return this.withCache(a,"decks",s,async()=>{let{query:n}=i.fetchDeckBySlug();return (await this.connection.execute(n,{publisherSlug:e,gameKey:t,slug:r})).fetchDeckBySlug??null})}async getBySlug(e,t,r,s={}){let a=this.cacheKey("decks","getBySlug",{publisherSlug:e,gameKey:t,slug:r});return this.withCache(a,"decks",s,async()=>{let{query:n}=i.deckBySlug();return (await this.connection.execute(n,{publisherSlug:e,gameKey:t,slug:r})).deckBySlug??null})}async fetchByExternalRef(e,t={}){let r=this.cacheKey("decks","fetchByExternalRef",{externalRef:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=i.fetchDeckByExternalRef();return (await this.connection.execute(s,{externalRef:e})).fetchDeckByExternalRef??null})}async getByExternalRef(e,t){let r=i.deckExternalRefReadVariables(e,t.readState,t.version),s=this.cacheKey("decks","getByExternalRef",r);return this.withCache(s,"decks",t,async()=>{let{query:a}=i.deckByExternalRef();return (await this.connection.execute(a,r)).deckByExternalRef??null})}async getDraftByExternalRef(e,t={}){return this.getByExternalRef(e,{...t,readState:"DRAFT"})}async getPublishedByExternalRef(e,t={}){return this.getByExternalRef(e,{...t,readState:"PUBLISHED",version:t.version})}async listMine(e={}){let{query:t,variables:r}=i.listMyDecks({first:e.first,after:e.after,includeArchived:e.includeArchived}),s=this.cacheKey("decks","listMine",r),a=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).myDecks);return new l(a,{nextPageLoader:async n=>this.listMine({...e,after:n})})}async listViewer(e={}){let{query:t,variables:r}=i.viewerDecks({filter:e.filter,first:e.first,after:e.after}),s=this.cacheKey("decks","listViewer",r),a=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).viewerDecks);return new l(a,{nextPageLoader:async n=>this.listViewer({...e,after:n})})}async listApp(e={}){this.config.requireSecretCredential("decks.listApp");let{query:t,variables:r}=i.appDecks({filter:e.filter,first:e.first,after:e.after}),s=this.cacheKey("decks","listApp",r),a=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).appDecks);return new l(a,{nextPageLoader:async n=>this.listApp({...e,after:n})})}async listPublic(e={}){let{query:t,variables:r}=i.publicDecks({filter:e.filter,first:e.first,after:e.after}),s=this.cacheKey("decks","listPublic",r),a=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).publicDecks);return new l(a,{nextPageLoader:async n=>this.listPublic({...e,after:n})})}async fetchVersion(e,t={}){let r=this.cacheKey("decks","fetchVersion",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=i.deckVersion();return (await this.connection.execute(s,{id:e})).deckVersion??null})}async listVersions(e,t={}){let{query:r,variables:s}=i.deckVersions({first:t.first,after:t.after}),a={deckId:e,...s},n=this.cacheKey("decks","listVersions",a),c=await this.withCache(n,"decks",t,async()=>(await this.connection.execute(r,a)).deckVersions);return new l(c,{nextPageLoader:async o=>this.listVersions(e,{...t,after:o})})}async draftDiff(e,t={}){let r=this.cacheKey("decks","draftDiff",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=i.deckDraftDiff();return (await this.connection.execute(s,{id:e})).deckDraftDiff})}async versionDiff(e,t,r={}){let s=i.deckVersionDiffVariables(e,t),a=this.cacheKey("decks","versionDiff",s);return this.withCache(a,"decks",r,async()=>{let{query:n}=i.deckVersionDiff();return (await this.connection.execute(n,s)).deckVersionDiff})}async validate(e,t,r={}){let s=i.deckValidateVariables(e,t),a=this.cacheKey("decks","validate",s);return this.withCache(a,"decks",r,async()=>{let{query:n}=i.deckValidate();return (await this.connection.execute(n,s)).deckValidate})}async hydrateDeckEntries(e,t={}){let r=i.deckHydrateEntriesVariables(e),s=this.cacheKey("decks","hydrateDeckEntries",r);return this.withCache(s,"decks",t,async()=>{let{query:a}=i.deckHydrateEntries();return (await this.connection.execute(a,r)).deckHydrateEntries})}async exportDeck(e,t="SIMPLE_TEXT",r={}){let s=i.deckExportVariables(e,t),a=this.cacheKey("decks","exportDeck",s);return this.withCache(a,"decks",r,async()=>{let{query:n}=i.deckExport();return (await this.connection.execute(n,s)).deckExport})}async sectionDefinitions(e={}){let{query:t,variables:r}=i.deckSectionDefinitions({publisherSlug:e.publisherSlug,gameKey:e.gameKey,gameId:e.gameId,rulesetKey:e.rulesetKey,rulesetVersionId:e.rulesetVersionId}),s=this.cacheKey("decks","sectionDefinitions",r);return this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).deckSectionDefinitions)}async listCollaborators(e,t={}){let r=this.cacheKey("decks","listCollaborators",{deckId:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=i.deckCollaborators();return (await this.connection.execute(s,{deckId:e})).deckCollaborators})}async listApiApplicationAccesses(e,t={}){let r=i.deckApiApplicationAccessesVariables(e,t.includeRevoked),s=this.cacheKey("decks","listApiApplicationAccesses",r);return this.withCache(s,"decks",t,async()=>{let{query:a}=i.deckApiApplicationAccesses();return (await this.connection.execute(a,r)).deckApiApplicationAccesses})}async listMyApiApplicationAccesses(e={}){let t=i.myDeckApiApplicationAccessesVariables(e.applicationId),r=this.cacheKey("decks","listMyApiApplicationAccesses",t);return this.withCache(r,"decks",e,async()=>{let{query:s}=i.myDeckApiApplicationAccesses();return (await this.connection.execute(s,t)).myDeckApiApplicationAccesses})}async create(e){let{query:t}=i.createDeck(),r=i.deckCreateVariables(e);return (await this.connection.execute(t,r)).deckCreate}async update(e,t){let{query:r}=i.updateDeck(),s=i.deckUpdateVariables(e,t);return (await this.connection.execute(r,s)).deckUpdate}async updateMetadata(e,t){return this.update(e,t)}async upsertByExternalRef(e){this.config.requireSecretCredential("decks.upsertByExternalRef");let{query:t}=i.upsertDeckByExternalRef(),r=i.deckUpsertByExternalRefVariables(e);return (await this.connection.execute(t,r)).deckUpsertByExternalRef}async claim(e,t){let{query:r}=i.claimDeck(),s=i.deckClaimVariables(e,t);return (await this.connection.execute(r,s)).deckClaim}async transferOwnership(e,t){let{query:r}=i.transferDeckOwnership(),s=i.deckTransferOwnershipVariables(e,t);return (await this.connection.execute(r,s)).deckTransferOwnership}async copy(e,t){let{query:r}=i.copyDeck(),s=i.deckCopyVariables(e,t);return (await this.connection.execute(r,s)).deckCopy}async addEntry(e){let{query:t}=i.addDeckEntry(),r=i.deckEntryAddVariables(e);return (await this.connection.execute(t,r)).deckEntryAdd}async updateEntry(e,t){let{query:r}=i.updateDeckEntry(),s=i.deckEntryUpdateVariables(e,t);return (await this.connection.execute(r,s)).deckEntryUpdate}async removeEntry(e,t){let{query:r}=i.removeDeckEntry(),s=i.deckEntryRemoveVariables(e,t);return (await this.connection.execute(r,s)).deckEntryRemove}async reorderEntries(e,t){let{query:r}=i.reorderDeckEntries(),s=i.deckEntryReorderVariables(e,t);return (await this.connection.execute(r,s)).deckEntryReorder}async replaceEntries(e,t){let{query:r}=i.replaceDeckEntries(),s=i.deckEntriesReplaceVariables(e,t);return (await this.connection.execute(r,s)).deckEntriesReplace}async importDeck(e){let{query:t}=i.importDeck(),r=i.deckImportVariables(e);return (await this.connection.execute(t,r)).deckImport}async listImportFormats(e,t={}){let{query:r,variables:s}=i.deckImportFormats({gameId:e,includeArchived:t.includeArchived,first:t.first,after:t.after}),a=this.cacheKey("decks","listImportFormats",s),n=await this.withCache(a,"decks",t,async()=>(await this.connection.execute(r,s)).deckImportFormats);return new l(n,{nextPageLoader:async c=>this.listImportFormats(e,{...t,after:c})})}async fetchImportFormat(e,t={}){let r=this.cacheKey("decks","fetchImportFormat",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=i.deckImportFormat();return (await this.connection.execute(s,{id:e})).deckImportFormat??null})}async testImportFormat(e){let{query:t}=i.deckImportFormatTest(),r=i.deckImportFormatTestVariables(e);return (await this.connection.execute(t,r)).deckImportFormatTest}async createImportFormat(e){let{query:t}=i.createDeckImportFormat(),r=i.deckImportFormatCreateVariables(e);return (await this.connection.execute(t,r)).deckImportFormatCreate}async updateImportFormat(e,t){let{query:r}=i.updateDeckImportFormat(),s=i.deckImportFormatUpdateVariables(e,t);return (await this.connection.execute(r,s)).deckImportFormatUpdate}async archiveImportFormat(e){let{query:t}=i.archiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatArchive}async unarchiveImportFormat(e){let{query:t}=i.unarchiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatUnarchive}async delete(e){let{query:t}=i.deleteDeck();return !!(await this.connection.execute(t,{id:e})).deckDelete}async archive(e){let{query:t}=i.archiveDeck();return (await this.connection.execute(t,{id:e})).deckArchive}async restore(e){let{query:t}=i.restoreDeck();return (await this.connection.execute(t,{id:e})).deckRestore}async unpublish(e){let{query:t}=i.unpublishDeck();return (await this.connection.execute(t,{id:e})).deckUnpublish}async publish(e,t){let{query:r}=i.publishDeck(),s=i.deckPublishVariables(e,t);return (await this.connection.execute(r,s)).deckPublish}async removeInvalidEntries(e,t){let{query:r}=i.removeInvalidDeckEntries(),s=i.deckRemoveInvalidEntriesVariables(e,t);return (await this.connection.execute(r,s)).deckRemoveInvalidEntries}async upsertCollaborator(e,t,r){let{query:s}=i.upsertDeckCollaborator(),a=i.deckCollaboratorVariables(e,t,r);return (await this.connection.execute(s,a)).deckCollaboratorUpsert}async removeCollaborator(e,t){let{query:r}=i.removeDeckCollaborator(),s=i.deckCollaboratorVariables(e,t);return !!(await this.connection.execute(r,s)).deckCollaboratorRemove}async createTokenIssuer(e){this.config.requireSecretCredential("decks.createTokenIssuer");let{query:t}=i.createDeckTokenIssuer(),r=i.deckTokenIssuerCreateVariables(e);return (await this.connection.execute(t,r)).deckTokenIssuerCreate}async revokeTokenIssuer(e){this.config.requireSecretCredential("decks.revokeTokenIssuer");let{query:t}=i.revokeDeckTokenIssuer();return !!(await this.connection.execute(t,{id:e})).deckTokenIssuerRevoke}async revokeTokenIssuerSigningKey(e){this.config.requireSecretCredential("decks.revokeTokenIssuerSigningKey");let{query:t}=i.revokeDeckTokenIssuerSigningKey();return (await this.connection.execute(t,{id:e})).deckTokenIssuerSigningKeyRevoke}async grantApiApplicationAccess(e){let{query:t}=i.grantDeckApiApplicationAccess(),r=i.deckApiApplicationAccessGrantVariables(e);return (await this.connection.execute(t,r)).deckApiApplicationAccessGrant}async revokeApiApplicationAccess(e,t){let{query:r}=i.revokeDeckApiApplicationAccess(),s=i.deckApiApplicationAccessRevokeVariables(e,t);return !!(await this.connection.execute(r,s)).deckApiApplicationAccessRevoke}async exchangeToken(e){this.config.requireSecretCredential("decks.exchangeToken");let{query:t}=i.exchangeDeckToken(),r=i.deckTokenExchangeVariables(e);return (await this.connection.execute(t,r)).deckTokenExchange}async revokeToken(e){this.config.requireSecretCredential("decks.revokeToken");let{query:t}=i.revokeDeckToken();return !!(await this.connection.execute(t,{id:e})).deckTokenRevoke}async hydrateEntries(e){if(e.entries.length===0)return [];let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=e.entries.map(o=>o.identifier),a=this.cacheKey("decks","hydrateEntries",{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:s}),n=await this.withCache(a,"decks",e,async()=>{let{query:o}=i.fetchRecordsByIdentifier();return (await this.connection.execute(o,{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:s})).fetchRecordsByIdentifier}),c=vt(n,s,e.identifierField);return e.entries.map(o=>({...o,record:c.get(o.identifier)??null}))}};function vt(e,t,r){let s=new Set(t),a=new Map;for(let n of e){let c=r?n.data[r]:Object.values(n.data).find(h=>s.has(String(h)));if(c==null)continue;let o=String(c);s.has(o)&&(a.set(o,n),s.delete(o));}return a}var Dt=class extends f{constructor(e,t){super(e,t);}async list(e){let t=P(e.filter),{query:r,variables:s}=i.listDatasetRecords({datasetId:e.datasetId,filter:t,orderBy:e.orderBy,first:e.first,after:e.after,last:e.last,before:e.before,validateSchema:e.validateSchema}),a=this.cacheKey("records","list",s),n=await this.withCache(a,"records",e,async()=>(await this.connection.execute(r,s)).datasetRecords);return new l(n,{nextPageLoader:async c=>this.list({...e,after:c})})}async getByDatasetIdentifier(e){let t=this.cacheKey("records","getByDatasetIdentifier",{datasetId:e.datasetId,identifier:e.identifier,includePricing:e.includePricing??false});return this.withCache(t,"records",e,async()=>{let{query:r,variables:s}=i.datasetRecord({datasetId:e.datasetId,identifier:e.identifier,includePricing:e.includePricing});return (await this.connection.execute(r,s)).datasetRecord??null})}async upsertBatch(e){this.config.requireSecretCredential("records.upsertBatch");let{query:t}=i.upsertDatasetRecords();return (await this.connection.execute(t,i.datasetRecordsUpsertVariables(e))).datasetRecordsUpsert}async deleteBatch(e){this.config.requireSecretCredential("records.deleteBatch");let{query:t}=i.deleteDatasetRecords();return (await this.connection.execute(t,i.datasetRecordsDeleteVariables(e))).datasetRecordsDelete}async getDeleteJob(e,t={}){let r=this.cacheKey("records","getDeleteJob",{id:e});return this.withCache(r,"records",t,async()=>{let{query:s}=i.datasetRecordDeleteJob();return (await this.connection.execute(s,{id:e})).datasetRecordDeleteJob??null})}async listDeleteJobs(e,t={}){let{query:r,variables:s}=i.datasetRecordDeleteJobs({publisherId:e,datasetId:t.datasetId,status:t.status,first:t.first,after:t.after}),a=this.cacheKey("records","listDeleteJobs",s),n=await this.withCache(a,"records",t,async()=>(await this.connection.execute(r,s)).datasetRecordDeleteJobs);return new l(n,{nextPageLoader:async c=>this.listDeleteJobs(e,{...t,after:c})})}async waitForDeleteJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,a=Date.now();for(;;){let n=await this.getDeleteJob(e,{cache:false});if(!n)throw new Error(`Delete job '${e}' was not found`);if(n.status==="COMPLETED"||n.status==="FAILED")return n;if(Date.now()-a>=s)throw new Error(`Timed out waiting for delete job '${e}'`);await new Promise(c=>setTimeout(c,r));}}async search(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=P(e.filter),{query:a,variables:n}=i.searchRecords({publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,filter:s,search:e.search,orderBy:e.orderBy,resolveLinks:e.resolveLinks,first:e.first,after:e.after,validateSchema:e.validateSchema,includePricing:e.includePricing}),c=this.cacheKey("records","search",{...n,includePricing:e.includePricing??false}),o=await this.withCache(c,"records",e,async()=>(await this.connection.execute(a,n)).searchRecords);return new l(o,{nextPageLoader:async h=>this.search({...e,after:h})})}async get(e,t={}){let r=this.cacheKey("records","get",{id:e,includePricing:t.includePricing??false});return this.withCache(r,"records",t,async()=>{let{query:s}=i.fetchRecordById({includePricing:t.includePricing});return (await this.connection.execute(s,{id:e})).fetchRecord??null})}async getByIdentifier(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=this.cacheKey("records","getByIdentifier",{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifier:e.identifier,includePricing:e.includePricing??false});return this.withCache(s,"records",e,async()=>{let{query:a}=i.fetchRecordByIdentifier({includePricing:e.includePricing});return (await this.connection.execute(a,{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifier:e.identifier})).fetchRecordByIdentifier??null})}async getManyByIdentifier(e){if(e.identifiers.length===0)return [];let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=this.cacheKey("records","getManyByIdentifier",{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:e.identifiers,includePricing:e.includePricing??false});return this.withCache(s,"records",e,async()=>{let{query:a}=i.fetchRecordsByIdentifier({includePricing:e.includePricing});return (await this.connection.execute(a,{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:e.identifiers})).fetchRecordsByIdentifier??[]})}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("records","getMany",{ids:e,includePricing:t.includePricing??false});return this.withCache(r,"records",t,async()=>{let{query:s}=i.fetchRecords({includePricing:t.includePricing});return (await this.connection.execute(s,{ids:e})).fetchRecords??[]})}},wt=class extends f{constructor(e,t){super(e,t);}async datasets(e={}){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let{query:s,variables:a}=i.searchDatasets({publisherSlug:t,gameKey:r,search:e.search,purpose:"RULES",first:e.first,after:e.after}),n=this.cacheKey("rules","datasets",a),c=await this.withCache(n,"datasets",e,async()=>(await this.connection.execute(s,a)).searchDatasets);return new l(c,{nextPageLoader:async o=>this.datasets({...e,after:o})})}async list(e={}){return this.searchRuleRecords("rules",e)}async formats(e={}){return this.searchRuleRecords(e.datasetKey??"formats",e)}async searchRuleRecords(e,t){let r=this.resolvePublisher(t.publisherSlug),s=this.resolveGame(t.gameKey),a=t.datasetKey??e;this.validateAccess(r,s);let n=P(t.filter),{query:c,variables:o}=i.searchRecords({publisherSlug:r,gameKey:s,datasetKey:a,filter:n,search:t.search,orderBy:t.orderBy,resolveLinks:t.resolveLinks,first:t.first,after:t.after,validateSchema:t.validateSchema}),h=this.cacheKey("rules","records",o),S=await this.withCache(h,"records",t,async()=>(await this.connection.execute(c,o)).searchRecords);return new l(S,{nextPageLoader:async Q=>this.searchRuleRecords(e,{...t,after:Q})})}},St=class extends f{constructor(e,t){super(e,t);}async list(e){let{query:t,variables:r}=i.deckImportFormats({publisherId:e.publisherId,gameId:e.gameId,includeArchived:e.includeArchived,first:e.first,after:e.after}),s=this.cacheKey("importFormats","list",r),a=await this.withCache(s,"importFormats",e,async()=>(await this.connection.execute(t,r)).deckImportFormats);return new l(a,{nextPageLoader:async n=>this.list({...e,after:n})})}async get(e,t={}){let r=this.cacheKey("importFormats","get",{id:e});return this.withCache(r,"importFormats",t,async()=>{let{query:s}=i.deckImportFormat();return (await this.connection.execute(s,{id:e})).deckImportFormat??null})}async getByKey(e){let t=this.cacheKey("importFormats","getByKey",{gameId:e.gameId,formatKey:e.key});return this.withCache(t,"importFormats",e,async()=>{let{query:r}=i.deckImportFormat();return (await this.connection.execute(r,{gameId:e.gameId,key:e.key})).deckImportFormat??null})}async test(e){let{query:t}=i.deckImportFormatTest();return (await this.connection.execute(t,i.deckImportFormatTestVariables(e))).deckImportFormatTest}async create(e){this.config.requireSecretCredential("importFormats.create");let{query:t}=i.createDeckImportFormat();return (await this.connection.execute(t,i.deckImportFormatCreateVariables(e))).deckImportFormatCreate}async update(e,t){this.config.requireSecretCredential("importFormats.update");let{query:r}=i.updateDeckImportFormat();return (await this.connection.execute(r,i.deckImportFormatUpdateVariables(e,t))).deckImportFormatUpdate}async archive(e){this.config.requireSecretCredential("importFormats.archive");let{query:t}=i.archiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatArchive}async unarchive(e){this.config.requireSecretCredential("importFormats.unarchive");let{query:t}=i.unarchiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatUnarchive}},At=class extends f{constructor(e,t){super(e,t);}async preview(e){let{query:t}=i.datasetImportPreview();return (await this.connection.execute(t,i.datasetImportPreviewVariables(e))).datasetImportPreview}async validate(e){let{query:t}=i.datasetImportValidate();return (await this.connection.execute(t,i.datasetImportValidateVariables(e))).datasetImportValidate}async run(e){if(this.config.requireSecretCredential("imports.run"),"fileId"in e&&e.fileId){let{query:s}=i.datasetImportFromFile();return (await this.connection.execute(s,i.datasetImportFromFileVariables(e))).datasetImportFromFile}if("sourceUrl"in e&&e.sourceUrl){let{query:s}=i.datasetImportFromUrl();return (await this.connection.execute(s,i.datasetImportFromUrlVariables(e))).datasetImportFromUrl}let{query:t}=i.datasetImportFromPayload();return (await this.connection.execute(t,i.datasetImportFromPayloadVariables(e))).datasetImportFromPayload}async getJob(e,t={}){let r=this.cacheKey("imports","getJob",{id:e});return this.withCache(r,"imports",t,async()=>{let{query:s}=i.importJob();return (await this.connection.execute(s,{id:e})).importJob??null})}async listJobs(e,t={}){let{query:r,variables:s}=i.importJobs({publisherId:e,datasetId:t.datasetId,status:t.status,first:t.first,after:t.after}),a=this.cacheKey("imports","listJobs",s),n=await this.withCache(a,"imports",t,async()=>(await this.connection.execute(r,s)).importJobs);return new l(n,{nextPageLoader:async c=>this.listJobs(e,{...t,after:c})})}async cancelJob(e){this.config.requireSecretCredential("imports.cancelJob");let{query:t}=i.importJobCancel();return (await this.connection.execute(t,{id:e})).importJobCancel}async listJobLogs(e,t={}){let{query:r,variables:s}=i.importJobLogs({importJobId:e,level:t.level,datasetKey:t.datasetKey,first:t.first,after:t.after}),a=this.cacheKey("imports","listJobLogs",s),n=await this.withCache(a,"imports",t,async()=>(await this.connection.execute(r,s)).importJob?.logs??Et());return new l(n,{nextPageLoader:async c=>this.listJobLogs(e,{...t,after:c})})}async waitForJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,a=Date.now();for(;;){let n=await this.getJob(e,{cache:false});if(!n)throw new Error(`Import job '${e}' was not found`);if(n.status==="COMPLETED"||n.status==="FAILED")return n;if(Date.now()-a>=s)throw new Error(`Timed out waiting for import job '${e}'`);await new Promise(c=>setTimeout(c,r));}}async previewGame(e){let{query:t}=i.gameImportPreview();return (await this.connection.execute(t,i.gameImportPreviewVariables(e))).gameImportPreview}async runGame(e){if(this.config.requireSecretCredential("imports.runGame"),"fileId"in e&&e.fileId){let{query:s}=i.gameImportFromFile();return (await this.connection.execute(s,i.gameImportFromFileVariables(e))).gameImportFromFile}if("sourceUrl"in e&&e.sourceUrl){let{query:s}=i.gameImportFromUrl();return (await this.connection.execute(s,i.gameImportFromUrlVariables(e))).gameImportFromUrl}let{query:t}=i.gameImportFromPayload();return (await this.connection.execute(t,i.gameImportFromPayloadVariables(e))).gameImportFromPayload}async getGameJob(e,t={}){let r=this.cacheKey("imports","getGameJob",{id:e});return this.withCache(r,"imports",t,async()=>{let{query:s}=i.gameImportJob();return (await this.connection.execute(s,{id:e})).gameImportJob??null})}async listGameJobs(e,t={}){let{query:r,variables:s}=i.gameImportJobs({gameId:e,status:t.status,first:t.first,after:t.after}),a=this.cacheKey("imports","listGameJobs",s),n=await this.withCache(a,"imports",t,async()=>(await this.connection.execute(r,s)).gameImportJobs);return new l(n,{nextPageLoader:async c=>this.listGameJobs(e,{...t,after:c})})}async cancelGameJob(e){this.config.requireSecretCredential("imports.cancelGameJob");let{query:t}=i.gameImportJobCancel();return (await this.connection.execute(t,{id:e})).gameImportJobCancel}async waitForGameJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,a=Date.now();for(;;){let n=await this.getGameJob(e,{cache:false});if(!n)throw new Error(`Game import job '${e}' was not found`);if(n.status==="COMPLETED"||n.status==="FAILED")return n;if(Date.now()-a>=s)throw new Error(`Timed out waiting for game import job '${e}'`);await new Promise(c=>setTimeout(c,r));}}};function Et(){return {totalCount:0,pageInfo:{hasNextPage:false,hasPreviousPage:false,startCursor:null,endCursor:null},edges:[]}}var Rt=class extends f{constructor(e,t){super(e,t);}async run(e){this.config.requireSecretCredential("exports.run");let{query:t}=i.datasetExport();return (await this.connection.execute(t,i.datasetExportVariables(e))).datasetExport}async create(e){return this.run(e)}async getJob(e,t={}){let r=this.cacheKey("exports","getJob",{id:e});return this.withCache(r,"exports",t,async()=>{let{query:s}=i.exportJob();return (await this.connection.execute(s,{id:e})).exportJob??null})}async listJobs(e,t={}){let{query:r,variables:s}=i.exportJobs({publisherId:e,gameId:t.gameId,datasetId:t.datasetId,status:t.status,first:t.first,after:t.after}),a=this.cacheKey("exports","listJobs",s),n=await this.withCache(a,"exports",t,async()=>(await this.connection.execute(r,s)).exportJobs);return new l(n,{nextPageLoader:async c=>this.listJobs(e,{...t,after:c})})}async refreshUrl(e){let{query:t}=i.exportJobRefreshUrl();return (await this.connection.execute(t,{id:e})).exportJobRefreshUrl}async cancel(e){this.config.requireSecretCredential("exports.cancel");let{query:t}=i.exportJobCancel();return (await this.connection.execute(t,{id:e})).exportJobCancel}async waitForJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,a=Date.now();for(;;){let n=await this.getJob(e,{cache:false});if(!n)throw new Error(`Export job '${e}' was not found`);if(n.status==="COMPLETED"||n.status==="FAILED")return n;if(Date.now()-a>=s)throw new Error(`Timed out waiting for export job '${e}'`);await new Promise(c=>setTimeout(c,r));}}},xt=class extends f{constructor(e,t){super(e,t);}async get(e,t={}){let r=this.cacheKey("files","get",{id:e});return this.withCache(r,"files",t,async()=>{let{query:s}=i.file();return (await this.connection.execute(s,{id:e})).file??null})}async requestUpload(e){this.config.requireSecretCredential("files.requestUpload");let{query:t}=i.fileUploadRequest();return (await this.connection.execute(t,i.fileUploadRequestVariables(e))).fileUploadRequest}async confirmUpload(e){this.config.requireSecretCredential("files.confirmUpload");let{query:t}=i.fileUploadConfirm();return (await this.connection.execute(t,{id:e})).fileUploadConfirm}async upload(e){let t=e.size??Ct(e.body);if(!t||t<=0)throw new Error("files.upload requires a positive size or a body with an inferable size");let r=await this.requestUpload({filename:e.filename,contentType:e.contentType,size:t,isPublic:e.isPublic??false,entityType:e.entityType??Tt(e.purpose),entityId:e.entityId,publisherId:e.publisherId,datasetId:e.datasetId});return await qt(r.uploadUrl,e.contentType,e.body),this.confirmUpload(r.file.id)}async delete(e){this.config.requireSecretCredential("files.delete");let{query:t}=i.fileDelete();return !!(await this.connection.execute(t,{id:e})).fileDelete}};async function qt(e,t,r){let s=globalThis.fetch;if(!s)throw new Error("files.upload requires a runtime with fetch support");let a=await s(e,{method:"PUT",headers:{"Content-Type":t},body:r});if(!a.ok){let n=await a.text().catch(()=>"");throw new Error(`File upload failed with ${a.status} ${a.statusText}${n?`: ${n}`:""}`)}}function Ct(e){if(typeof e=="string")return new TextEncoder().encode(e).byteLength;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return e.byteLength;let t=e;if(typeof t?.size=="number")return t.size;if(typeof t?.byteLength=="number")return t.byteLength;if(typeof t?.length=="number")return t.length}function Tt(e){if(!(!e||e==="scan_image"))return e==="import"?"import":e==="scan_template_example"?"scan_template_example":e}var Kt=class extends f{constructor(e,t){super(e,t);}async createUploadSession(e){let t=this.resolveCreateUploadSessionInput(e),{query:r}=i.createScanUploadSession();return (await this.connection.execute(r,i.createScanUploadSessionVariables(t))).createScanUploadSession}async confirmUpload(e){let t=this.resolveConfirmUploadInput(e),{query:r}=i.confirmScanUpload();return (await this.connection.execute(r,i.confirmScanUploadVariables(t))).confirmScanUpload}async createJob(e){let t=this.resolveCreateJobInput(e),{query:r}=i.createScanJob();return (await this.connection.execute(r,i.createScanJobVariables(t))).createScanJob}async getJob(e,t={}){let r=this.cacheKey("scans","getJob",{id:e});return this.withCache(r,"scans",t,async()=>{let{query:s}=i.scanJob();return (await this.connection.execute(s,{id:e})).scanJob??null})}async pollJob(e,t={}){let r=t.timeoutMs??3e5,s=Math.max(t.backoffFactor??1.5,1),a=t.maxIntervalMs??1e4,n=Date.now(),c=Math.max(t.intervalMs??1e3,1);for(;;){Pt(t.signal);let o=await this.getJob(e,{cache:false});if(!o)throw new Error(`Scan job '${e}' was not found`);if(Ut(o.status))return o;let h=Date.now()-n,S=r-h;if(S<=0)throw new Error(`Timed out waiting for scan job '${e}'`);await Ft(Math.min(c,S)),c=Math.min(Math.ceil(c*s),a);}}async submitFeedback(e){let{query:t}=i.submitScanFeedback();return (await this.connection.execute(t,i.submitScanFeedbackVariables(e))).submitScanFeedback}async metrics(e){let t=this.resolveMetricsInput(e),{query:r}=i.scanMetrics();return (await this.connection.execute(r,i.scanMetricsVariables(t))).scanMetrics}async verifyWebhookSignature(e){let t=Lt(),r=await t.importKey("raw",De(e.secret),{name:"HMAC",hash:"SHA-256"},false,["sign"]),s=await t.sign("HMAC",r,Vt(e.body)),a=`sha256=${Bt(new Uint8Array(s))}`;return _t(e.signature.trim().toLowerCase(),a)}resolveCreateJobInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}resolveCreateUploadSessionInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}resolveConfirmUploadInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}resolveMetricsInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}};function Ut(e){let t=e.toLowerCase();return t==="completed"||t==="failed"||t==="cancelled"}async function Ft(e){return new Promise(t=>setTimeout(t,e))}function Pt(e){if(e&&(e.throwIfAborted&&e.throwIfAborted(),e.aborted))throw new Error("Scan job polling aborted")}function Lt(){let t=globalThis.crypto?.subtle;if(!t)throw new Error("Web Crypto HMAC support is not available in this runtime");return t}function Vt(e){return typeof e=="string"?De(e):e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function De(e){return new TextEncoder().encode(e)}function Bt(e){return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}function _t(e,t){let r=Math.max(e.length,t.length),s=e.length^t.length;for(let a=0;a<r;a++)s|=(e.charCodeAt(a)||0)^(t.charCodeAt(a)||0);return s===0}var Mt=class extends f{constructor(e,t){super(e,t);}async resolve(e){let t=this.resolveTemplateScope(e),r=this.cacheKey("scanTemplates","resolve",{...t});return this.withCache(r,"scanTemplates",e,async()=>{let{query:s}=i.resolveScanTemplate();return (await this.connection.execute(s,i.resolveScanTemplateVariables(t))).resolveScanTemplate})}async list(e){let t=this.resolveListScope(e),r=this.cacheKey("scanTemplates","list",{...t});return this.withCache(r,"scanTemplates",e,async()=>{let{query:s}=i.scanTemplates();return (await this.connection.execute(s,i.scanTemplatesVariables(t))).scanTemplates?.templates??[]})}async create(e){this.config.requireSecretCredential("scanTemplates.create");let t=this.resolveSaveInput(e),{query:r}=i.createScanTemplate();return (await this.connection.execute(r,i.createScanTemplateVariables(t))).createScanTemplate}async update(e,t){this.config.requireSecretCredential("scanTemplates.update");let r=typeof e=="string"?e:e.id,s=typeof e=="string"?t:Jt(e);if(!s)throw new Error("scan template input is required");let a=this.resolveSaveInput(s),{query:n}=i.updateScanTemplate();return (await this.connection.execute(n,i.updateScanTemplateVariables(r,a))).updateScanTemplate}async preview(e){let t=this.resolvePreviewInput(e),{query:r}=i.previewScanTemplate();return (await this.connection.execute(r,i.previewScanTemplateVariables(t))).previewScanTemplate}resolveTemplateScope(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,templateId:e.templateId}}resolveListScope(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,includeArchived:e.includeArchived}}resolveSaveInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}resolvePreviewInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}};function Jt(e){let t={...e};return delete t.id,t}var we=class Se{config;connection;publishers;games;datasets;records;decks;rules;importFormats;imports;exports;files;scans;scanTemplates;constructor(t={}){this.config=new ut(t),this.connection=new ft(this.config),this.publishers=new It(this.connection,this.config),this.games=new bt(this.connection,this.config),this.datasets=new kt(this.connection,this.config),this.records=new Dt(this.connection,this.config),this.decks=new $t(this.connection,this.config),this.rules=new wt(this.connection,this.config),this.importFormats=new St(this.connection,this.config),this.imports=new At(this.connection,this.config),this.exports=new Rt(this.connection,this.config),this.files=new xt(this.connection,this.config),this.scans=new Kt(this.connection,this.config),this.scanTemplates=new Mt(this.connection,this.config);}async me(){let{query:t}=i.fetchMe();return (await this.connection.execute(t)).fetchMe??null}getRateLimitInfo(){return yt()}withConfig(t){let r=this.config.merge(t);return new Se({apiKey:r.configApiKey(),publishableKey:r.publishableKey,secretKey:r.secretKey,accessToken:r.accessToken,environment:r.environment,endpoint:r.endpoint,timeout:r.timeout,openTimeout:r.openTimeout,defaultPublisher:r.defaultPublisher,defaultGame:r.defaultGame,allowedPublishers:r.allowedPublishers,allowedGames:r.allowedGames,logger:r.logger,logLevel:r.logLevel,retryOnRateLimit:r.retryOnRateLimit,maxRetries:r.maxRetries,retryOnNetworkError:r.retryOnNetworkError,maxNetworkRetries:r.maxNetworkRetries,retryBaseDelay:r.retryBaseDelay,retryMaxDelay:r.retryMaxDelay,cache:r.cache,cacheTtl:r.cacheTtl,cacheTtls:r.cacheTtls})}};var X=class{storage;prefix;constructor(t={}){let r=t.storage??"localStorage";this.storage=r==="sessionStorage"?globalThis.sessionStorage:globalThis.localStorage,this.prefix=t.prefix??"carddb:";}get(t){try{let r=this.storage.getItem(this.prefix+t);if(!r)return null;let s=JSON.parse(r);return s.expiresAt!==null&&Date.now()>s.expiresAt?(this.storage.removeItem(this.prefix+t),null):s.value}catch{return this.storage.removeItem(this.prefix+t),null}}set(t,r,s){try{let a={value:r,expiresAt:s!==void 0?Date.now()+s*1e3:null};this.storage.setItem(this.prefix+t,JSON.stringify(a));}catch(a){console.warn("[CardDB] Failed to write to cache:",a);}}delete(t){this.storage.removeItem(this.prefix+t);}clear(){let t=[];for(let r=0;r<this.storage.length;r++){let s=this.storage.key(r);s&&s.startsWith(this.prefix)&&t.push(s);}for(let r of t)this.storage.removeItem(r);}has(t){return this.get(t)!==null}get size(){let t=0;for(let r=0;r<this.storage.length;r++){let s=this.storage.key(r);s&&s.startsWith(this.prefix)&&t++;}return t}cleanup(){let t=Date.now(),r=[];for(let s=0;s<this.storage.length;s++){let a=this.storage.key(s);if(a&&a.startsWith(this.prefix))try{let n=this.storage.getItem(a);if(n){let c=JSON.parse(n);c.expiresAt!==null&&t>c.expiresAt&&r.push(a);}}catch{r.push(a);}}for(let s of r)this.storage.removeItem(s);}};var Ae=class extends we{constructor(t={}){if("apiKey"in t&&t.apiKey!==void 0)throw new v("apiKey is not accepted in browsers; use publishableKey or accessToken");if("secretKey"in t&&t.secretKey!==void 0)throw new v("secretKey is server-only; use publishableKey or accessToken in browsers");super(t);}};
1843
- export{G as AuthenticationError,f as BaseResource,X as BrowserCache,Ae as CardDBClient,y as CardDBError,l as Collection,ut as Configuration,ft as Connection,x as ConnectionError,at as DEFAULT_CACHE_TTL,tt as DEFAULT_ENDPOINT,nt as DEFAULT_MAX_NETWORK_RETRIES,it as DEFAULT_MAX_RETRIES,st as DEFAULT_OPEN_TIMEOUT,ct as DEFAULT_RETRY_BASE_DELAY,ot as DEFAULT_RETRY_MAX_DELAY,rt as DEFAULT_TIMEOUT,kt as DatasetsResource,$t as DecksResource,Rt as ExportsResource,xt as FilesResource,Ee as FilterBuilder,bt as GamesResource,ce as GraphQLError,St as ImportFormatsResource,At as ImportsResource,Ot as LinkResolutionError,Gt as NotFoundError,It as PublishersResource,i as QueryBuilder,U as RateLimitError,Dt as RecordsResource,v as RestrictedError,wt as RulesResource,Mt as ScanTemplatesResource,Kt as ScansResource,N as ServerError,O as TimeoutError,F as ValidationError,pt as cacheKey,Zt as contains,Nt as eq,yt as getRateLimitInfo,gr as getSDKVersion,ht as getUserAgent,Ht as gt,Yt as gte,tr as ilike,sr as isNotNull,rr as isNull,er as like,zt as lt,Wt as lte,jt as neq,Qt as notWithin,mt as readCache,P as resolveFilter,Xt as within,gt as writeCache};//# sourceMappingURL=index.js.map
2027
+ `}}},l=class{totalCount;pageInfo;items;nextPageLoader;constructor(e,t={}){this.totalCount=e.totalCount,this.pageInfo=e.pageInfo,this.items=e.edges.map(r=>t.itemTransformer?t.itemTransformer(r.node):r.node),this.nextPageLoader=t.nextPageLoader;}get hasNextPage(){return this.pageInfo.hasNextPage}get hasPreviousPage(){return this.pageInfo.hasPreviousPage}get endCursor(){return this.pageInfo.endCursor}get startCursor(){return this.pageInfo.startCursor}get length(){return this.items.length}get isEmpty(){return this.items.length===0}get first(){return this.items[0]}get last(){return this.items[this.items.length-1]}async nextPage(){if(!this.hasNextPage)return null;if(!this.nextPageLoader)throw new Error("No next page loader configured");return this.endCursor?this.nextPageLoader(this.endCursor):null}async*[Symbol.asyncIterator](){let e=this;for(;e;){for(let t of e.items)yield t;if(!e.hasNextPage)break;e=await e.nextPage();}}async forEach(e){let t=0;for await(let r of this)await e(r,t++);}async map(e){let t=[],r=0;for await(let s of this)t.push(await e(s,r++));return t}async filter(e){let t=[],r=0;for await(let s of this)await e(s,r++)&&t.push(s);return t}async find(e){let t=0;for await(let r of this)if(await e(r,t++))return r}async take(e){let t=[];for await(let r of this){if(t.length>=e)break;t.push(r);}return t}async toArray(){let e=[];for await(let t of this)e.push(t);return e}async*batches(){let e=this;for(;e&&(e.items.length>0&&(yield e.items),!!e.hasNextPage);)e=await e.nextPage();}each(){return this}};var ct="https://carddb.dev/query",ot=3e4,ut=1e4,lt=300,dt=3,ht=2,yt=1e3,ft=3e4,pt=class ve{apiKey;publishableKey;secretKey;accessToken;legacyApiKey;environment;endpoint;timeout;openTimeout;defaultPublisher;defaultGame;allowedPublishers;allowedGames;logger;logLevel;retryOnRateLimit;maxRetries;retryOnNetworkError;maxNetworkRetries;retryBaseDelay;retryMaxDelay;cache;cacheTtl;cacheTtls;constructor(t={}){this.legacyApiKey=t.apiKey,this.publishableKey=t.publishableKey,this.secretKey=t.secretKey,this.accessToken=t.accessToken,this.apiKey=t.apiKey??t.publishableKey??t.secretKey,this.environment=t.environment,this.endpoint=t.endpoint??ct,this.timeout=t.timeout??ot,this.openTimeout=t.openTimeout??ut,this.defaultPublisher=t.defaultPublisher,this.defaultGame=t.defaultGame,this.allowedPublishers=t.allowedPublishers,this.allowedGames=t.allowedGames,this.logger=t.logger,this.logLevel=t.logLevel??"info",this.retryOnRateLimit=t.retryOnRateLimit??false,this.maxRetries=t.maxRetries??dt,this.retryOnNetworkError=t.retryOnNetworkError??true,this.maxNetworkRetries=t.maxNetworkRetries??ht,this.retryBaseDelay=t.retryBaseDelay??yt,this.retryMaxDelay=t.retryMaxDelay??ft,this.cache=t.cache,this.cacheTtl=t.cacheTtl??lt,this.cacheTtls=t.cacheTtls??{};}calculateRetryDelay(t){let r=this.retryBaseDelay*Math.pow(2,t),s=Math.min(r,this.retryMaxDelay),i=s*.25*(Math.random()*2-1);return Math.round(s+i)}cacheTtlFor(t){return this.cacheTtls[t]??this.cacheTtl}resolvePublisher(t){return t??this.defaultPublisher}resolveGame(t){return t??this.defaultGame}validatePublisher(t){if(this.allowedPublishers&&!this.allowedPublishers.includes(t))throw new D(`Publisher '${t}' is not in the allowed publishers list`)}validateGame(t,r){if(!this.allowedGames)return;let s=this.allowedGames[t];if(s&&!s.includes(r))throw new D(`Game '${r}' is not allowed for publisher '${t}'`)}validateAccess(t,r){t&&(this.validatePublisher(t),r&&this.validateGame(t,r));}requireSecretCredential(t){if(!(!this.accessToken&&(this.legacyApiKey||this.secretKey&&!this.publishableKey)))throw new D(`${t} requires a server-side secretKey or legacy apiKey credential`)}requestApiKey(){return this.legacyApiKey??this.publishableKey??this.secretKey}configApiKey(){return this.legacyApiKey}shouldLog(t){let r={debug:0,info:1,warn:2,error:3};return r[t]>=r[this.logLevel]}merge(t){return new ve({apiKey:t.apiKey??this.legacyApiKey,publishableKey:t.publishableKey??this.publishableKey,secretKey:t.secretKey??this.secretKey,accessToken:t.accessToken??this.accessToken,environment:t.environment??this.environment,endpoint:t.endpoint??this.endpoint,timeout:t.timeout??this.timeout,openTimeout:t.openTimeout??this.openTimeout,defaultPublisher:t.defaultPublisher??this.defaultPublisher,defaultGame:t.defaultGame??this.defaultGame,allowedPublishers:t.allowedPublishers??this.allowedPublishers,allowedGames:t.allowedGames??this.allowedGames,logger:t.logger??this.logger,logLevel:t.logLevel??this.logLevel,retryOnRateLimit:t.retryOnRateLimit??this.retryOnRateLimit,maxRetries:t.maxRetries??this.maxRetries,retryOnNetworkError:t.retryOnNetworkError??this.retryOnNetworkError,maxNetworkRetries:t.maxNetworkRetries??this.maxNetworkRetries,retryBaseDelay:t.retryBaseDelay??this.retryBaseDelay,retryMaxDelay:t.retryMaxDelay??this.retryMaxDelay,cache:t.cache??this.cache,cacheTtl:t.cacheTtl??this.cacheTtl,cacheTtls:t.cacheTtls??this.cacheTtls})}},De="0.4.1";function mt(){if(typeof globalThis<"u"&&"Bun"in globalThis){let e=globalThis.Bun&&typeof globalThis.Bun=="object"&&globalThis.Bun.version;return {name:"bun",version:typeof e=="string"?e:"unknown"}}if(typeof globalThis<"u"&&"Deno"in globalThis){let e=globalThis.Deno&&typeof globalThis.Deno=="object"&&globalThis.Deno.version&&typeof globalThis.Deno.version=="object"&&globalThis.Deno.version.deno;return {name:"deno",version:typeof e=="string"?e:"unknown"}}return typeof process<"u"&&process.versions&&process.versions.node?{name:"node",version:process.versions.node}:typeof navigator<"u"&&navigator.userAgent?gt(navigator.userAgent):{name:"unknown",version:"unknown"}}function gt(e){let t=e.match(/Edg\/(\d+(?:\.\d+)*)/);if(t)return {name:"edge",version:t[1]};let r=e.match(/Chrome\/(\d+(?:\.\d+)*)/);if(r&&!e.includes("Edg/"))return {name:"chrome",version:r[1]};let s=e.match(/Firefox\/(\d+(?:\.\d+)*)/);if(s)return {name:"firefox",version:s[1]};let i=e.match(/Version\/(\d+(?:\.\d+)*).*Safari/);return i?{name:"safari",version:i[1]}:{name:"browser",version:"unknown"}}function It(){let e=mt();return `CardDB-SDK/js/${De} (${e.name}/${e.version})`}function wr(){return De}var we=null;function $t(){return we}var bt=class{config;constructor(e){this.config=e;}async execute(e,t={}){let r=this.extractOperationName(e),s=0,i=0;for(;;)try{let n=Date.now();this.logRequest(r,t);let c=await this.fetch(e,t),o=Date.now()-n,h=await this.handleResponse(c);return this.logResponse(r,o),h}catch(n){if(n instanceof P&&this.config.retryOnRateLimit&&s<this.config.maxRetries){s++;let c=n.retryAfter??60;this.logRateLimitRetry(r,s,c),await this.sleep(c*1e3);continue}if(this.isRetryableNetworkError(n)&&this.config.retryOnNetworkError&&i<this.config.maxNetworkRetries){let c=this.config.calculateRetryDelay(i);this.logNetworkRetry(r,i+1,c,n),i++,await this.sleep(c);continue}if(n instanceof Y&&this.config.retryOnNetworkError&&i<this.config.maxNetworkRetries){let c=this.config.calculateRetryDelay(i);this.logNetworkRetry(r,i+1,c,n),i++,await this.sleep(c);continue}throw n}}isRetryableNetworkError(e){return e instanceof K||e instanceof H}async fetch(e,t){let r=new AbortController,s=setTimeout(()=>r.abort(),this.config.timeout),i=this.config.requestApiKey();try{return await fetch(this.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","User-Agent":It(),...this.config.accessToken?{Authorization:`Bearer ${this.config.accessToken}`}:{},...!this.config.accessToken&&i?{"X-API-Key":i}:{}},body:JSON.stringify({query:e,variables:t}),signal:r.signal})}catch(n){throw n instanceof Error?n.name==="AbortError"?(this.logError("Request timed out"),new H("Request timed out")):(this.logError(`Connection failed: ${n.message}`),new K(`Connection failed: ${n.message}`)):new K("Connection failed")}finally{clearTimeout(s);}}async handleResponse(e){switch(this.extractRateLimitInfo(e),e.status){case 200:return this.handleSuccessResponse(e);case 401:throw new j("Invalid or missing API key");case 429:return this.handleRateLimitResponse(e);default:if(e.status>=400&&e.status<500)return this.handleClientError(e);if(e.status>=500){let t=await this.parseBody(e);throw new Y(`Server error (${e.status})`,{status:e.status,response:t})}throw new f(`Unexpected response status: ${e.status}`)}}async handleSuccessResponse(e){let t=await this.parseBody(e);return t.errors&&t.errors.length>0&&this.handleGraphQLErrors(t.errors,t),t.data??{}}handleGraphQLErrors(e,t){let r=e[0],s=r.message||"GraphQL error";switch(r.extensions?.code){case "UNAUTHENTICATED":throw new j(s,t);case "RATE_LIMITED":throw new P(s,{response:t});case "NOT_FOUND":throw new f(s,t);case "VALIDATION_ERROR":case "BAD_USER_INPUT":throw new L(s,{errors:e,response:t});default:throw new ue(s,{errors:e,response:t})}}async handleRateLimitResponse(e){let t=parseInt(e.headers.get("Retry-After")??"60",10),r=parseInt(e.headers.get("X-RateLimit-Limit")??"",10)||null,s=parseInt(e.headers.get("X-RateLimit-Remaining")??"",10)||null,i=parseInt(e.headers.get("X-RateLimit-Reset")??"",10)||null,n=i?new Date(i*1e3):null,c=await this.parseBody(e);throw new P("Rate limit exceeded",{retryAfter:t,limit:r,remaining:s,resetAt:n,response:c})}async handleClientError(e){let t=await this.parseBody(e),r=t.errors?.[0]?.message??`Client error (${e.status})`;throw new L(r,{response:t})}async parseBody(e){try{return await e.json()}catch{return {raw:await e.text()}}}extractRateLimitInfo(e){let t=parseInt(e.headers.get("X-RateLimit-Limit")??"",10)||null,r=parseInt(e.headers.get("X-RateLimit-Remaining")??"",10)||null,s=parseInt(e.headers.get("X-RateLimit-Reset")??"",10)||null;we={limit:t,remaining:r,reset:s};}extractOperationName(e){let t=e.match(/(?:query|mutation)\s+(\w+)/);return t?t[1]:"Unknown"}sleep(e){return new Promise(t=>setTimeout(t,e))}logRequest(e,t){!this.config.logger||!this.config.shouldLog("debug")||this.config.logger.debug(`[CardDB] Executing ${e}`,{variables:t});}logResponse(e,t){!this.config.logger||!this.config.shouldLog("info")||this.config.logger.info(`[CardDB] ${e} completed in ${t}ms`);}logRateLimitRetry(e,t,r){!this.config.logger||!this.config.shouldLog("warn")||this.config.logger.warn(`[CardDB] Rate limited on ${e}, retry ${t}/${this.config.maxRetries} after ${r}s`);}logNetworkRetry(e,t,r,s){if(!this.config.logger||!this.config.shouldLog("warn"))return;let i=s instanceof Error?s.name:"Unknown";this.config.logger.warn(`[CardDB] ${i} on ${e}, retry ${t}/${this.config.maxNetworkRetries} after ${r}ms`);}logError(e){!this.config.logger||!this.config.shouldLog("error")||this.config.logger.error(`[CardDB] ${e}`);}};function kt(e,t,r){let s=Object.entries(r).filter(([,i])=>i!==void 0).sort(([i],[n])=>i.localeCompare(n)).map(([i,n])=>`${i}=${JSON.stringify(n)}`).join("&");return `carddb:${e}:${t}:${s}`}async function vt(e,t){let r=e.get(t);return r}async function Dt(e,t,r,s){let i=e.set(t,r,s);i instanceof Promise&&await i;}var y=class{connection;config;constructor(e,t){this.connection=e,this.config=t;}resolvePublisher(e){let t=this.config.resolvePublisher(e);if(!t)throw new Error("publisher_slug is required (no default configured)");return t}resolveGame(e){let t=this.config.resolveGame(e);if(!t)throw new Error("game_key is required (no default configured)");return t}validateAccess(e,t){this.config.validateAccess(e,t);}async withCache(e,t,r,s){let i=r.cache??!!this.config.cache,n=this.config.cache;if(!i||!n)return s();let c=await vt(n,e);if(c!==null)return c;let o=await s();if(o!=null){let h=this.config.cacheTtlFor(t);await Dt(n,e,o,h);}return o}cacheKey(e,t,r){return kt(e,t,r)}},wt=class extends y{constructor(e,t){super(e,t);}async search(e={}){let{query:t,variables:r}=a.searchPublishers({search:e.search,first:e.first,after:e.after}),s=this.cacheKey("publishers","search",r),i=await this.withCache(s,"publishers",e,async()=>(await this.connection.execute(t,r)).searchPublishers);return new l(i,{nextPageLoader:async n=>this.search({...e,after:n})})}async get(e,t={}){let r=this.isUUID(e),s=this.cacheKey("publishers","get",{[r?"id":"slug"]:e});return this.withCache(s,"publishers",t,async()=>{if(r){let{query:i}=a.fetchPublisherById();return (await this.connection.execute(i,{id:e})).fetchPublisher??null}else {let{query:i}=a.fetchPublisherBySlug();return (await this.connection.execute(i,{slug:e})).fetchPublisher??null}})}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("publishers","getMany",{slugs:e});return this.withCache(r,"publishers",t,async()=>{let{query:s}=a.fetchPublishers();return (await this.connection.execute(s,{slugs:e})).fetchPublishers??[]})}isUUID(e){return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}},St=class extends y{constructor(e,t){super(e,t);}async list(e,t={}){let{query:r,variables:s}=a.listGames({publisherId:e,first:t.first,after:t.after,includeArchived:t.includeArchived}),i=this.cacheKey("games","list",s),n=await this.withCache(i,"games",t,async()=>(await this.connection.execute(r,s)).games);return new l(n,{nextPageLoader:async c=>this.list(e,{...t,after:c})})}async getByKey(e){let t=this.cacheKey("games","getByKey",{publisherId:e.publisherId,publisherSlug:e.publisherSlug,gameKey:e.gameKey});return this.withCache(t,"games",e,async()=>{let{query:r,variables:s}=a.game(e);return (await this.connection.execute(r,s)).game??null})}async getBySlug(e){let t=this.cacheKey("games","getBySlug",{publisherId:e.publisherId,publisherSlug:e.publisherSlug,gameSlug:e.gameSlug});return this.withCache(t,"games",e,async()=>{let{query:r,variables:s}=a.game(e);return (await this.connection.execute(r,s)).game??null})}async create(e){this.config.requireSecretCredential("games.create");let{query:t}=a.createGame();return (await this.connection.execute(t,a.gameCreateVariables(e))).gameCreate}async update(e,t){this.config.requireSecretCredential("games.update");let{query:r}=a.updateGame();return (await this.connection.execute(r,a.gameUpdateVariables(e,t))).gameUpdate}async getRegions(e={}){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=a.gameScanRegionsVariables(t,r,e.includeInactive),i=this.cacheKey("games","getRegions",s);return this.withCache(i,"games",e,async()=>{let{query:n}=a.gameScanRegions();return (await this.connection.execute(n,s)).gameScanRegions??[]})}async search(e={}){let t=this.config.resolvePublisher(e.publisherSlug);t&&this.validateAccess(t);let{query:r,variables:s}=a.searchGames({publisherSlug:t,search:e.search,first:e.first,after:e.after}),i=this.cacheKey("games","search",s),n=await this.withCache(i,"games",e,async()=>(await this.connection.execute(r,s)).searchGames);return new l(n,{nextPageLoader:async c=>this.search({...e,after:c})})}async get(e,t,r){if(typeof t=="string"){let s=e,i=t,n=r??{};this.validateAccess(s,i);let c=this.cacheKey("games","getByKeys",{publisherSlug:s,gameKey:i});return this.withCache(c,"games",n,async()=>{let{query:o}=a.fetchGameByKeys();return (await this.connection.execute(o,{publisherSlug:s,gameKey:i})).fetchGame??null})}else {let s=e,i=t??{},n=this.cacheKey("games","get",{id:s});return this.withCache(n,"games",i,async()=>{let{query:c}=a.fetchGameById();return (await this.connection.execute(c,{id:s})).fetchGame??null})}}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("games","getMany",{ids:e});return this.withCache(r,"games",t,async()=>{let{query:s}=a.fetchGames();return (await this.connection.execute(s,{ids:e})).fetchGames??[]})}},At=class extends y{constructor(e,t){super(e,t);}async list(e,t={}){let{query:r,variables:s}=a.listDatasets({publisherId:e,gameId:t.gameId,includeArchived:t.includeArchived,purpose:t.purpose,first:t.first,after:t.after}),i=this.cacheKey("datasets","list",s),n=await this.withCache(i,"datasets",t,async()=>(await this.connection.execute(r,s)).datasets);return new l(n,{nextPageLoader:async c=>this.list(e,{...t,after:c})})}async getByKey(e){let t=this.cacheKey("datasets","getByKey",{publisherId:e.publisherId,gameId:e.gameId,datasetKey:e.datasetKey});return this.withCache(t,"datasets",e,async()=>{let{query:r,variables:s}=a.dataset(e);return (await this.connection.execute(r,s)).dataset??null})}async getSchema(e){return (typeof e=="string"?await this.withCache(this.cacheKey("datasets","getSchema",{id:e}),"datasets",{},async()=>{let{query:r,variables:s}=a.dataset({id:e});return (await this.connection.execute(r,s)).dataset??null}):await this.getByKey(e))?.schema??null}async search(e={}){let t=this.config.resolvePublisher(e.publisherSlug),r=this.config.resolveGame(e.gameKey);t&&this.validateAccess(t,r);let{query:s,variables:i}=a.searchDatasets({publisherSlug:t,gameKey:r,search:e.search,purpose:e.purpose,first:e.first,after:e.after}),n=this.cacheKey("datasets","search",i),c=await this.withCache(n,"datasets",e,async()=>(await this.connection.execute(s,i)).searchDatasets);return new l(c,{nextPageLoader:async o=>this.search({...e,after:o})})}async get(e,t,r,s){if(typeof t=="string"&&typeof r=="string"){let i=e,n=t,c=s??{};this.validateAccess(i,n);let o=this.cacheKey("datasets","getByKeys",{publisherSlug:i,gameKey:n,datasetKey:r});return this.withCache(o,"datasets",c,async()=>{let{query:h}=a.fetchDatasetByKeys();return (await this.connection.execute(h,{publisherSlug:i,gameKey:n,datasetKey:r})).fetchDataset??null})}else {let i=e,n=t??{},c=this.cacheKey("datasets","get",{id:i});return this.withCache(c,"datasets",n,async()=>{let{query:o}=a.fetchDatasetById();return (await this.connection.execute(o,{id:i})).fetchDataset??null})}}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("datasets","getMany",{ids:e});return this.withCache(r,"datasets",t,async()=>{let{query:s}=a.fetchDatasets();return (await this.connection.execute(s,{ids:e})).fetchDatasets??[]})}},Rt=class extends y{constructor(e,t){super(e,t);}async fetch(e,t={}){let r=this.cacheKey("decks","fetch",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.fetchDeckById();return (await this.connection.execute(s,{id:e})).fetchDeck??null})}async get(e,t){let r=a.deckReadVariables(e,t.readState,t.version),s=this.cacheKey("decks","get",r);return this.withCache(s,"decks",t,async()=>{let{query:i}=a.deckById();return (await this.connection.execute(i,r)).deck??null})}async getDraft(e,t={}){return this.get(e,{...t,readState:"DRAFT"})}async getPublished(e,t={}){return this.get(e,{...t,readState:"PUBLISHED",version:t.version})}async fetchMine(e,t={}){let r=this.cacheKey("decks","fetchMine",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.myDeck();return (await this.connection.execute(s,{id:e})).myDeck??null})}async fetchBySlug(e,t,r,s={}){let i=this.cacheKey("decks","fetchBySlug",{publisherSlug:e,gameKey:t,slug:r});return this.withCache(i,"decks",s,async()=>{let{query:n}=a.fetchDeckBySlug();return (await this.connection.execute(n,{publisherSlug:e,gameKey:t,slug:r})).fetchDeckBySlug??null})}async getBySlug(e,t,r,s={}){let i=this.cacheKey("decks","getBySlug",{publisherSlug:e,gameKey:t,slug:r});return this.withCache(i,"decks",s,async()=>{let{query:n}=a.deckBySlug();return (await this.connection.execute(n,{publisherSlug:e,gameKey:t,slug:r})).deckBySlug??null})}async fetchByExternalRef(e,t={}){let r=this.cacheKey("decks","fetchByExternalRef",{externalRef:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.fetchDeckByExternalRef();return (await this.connection.execute(s,{externalRef:e})).fetchDeckByExternalRef??null})}async getByExternalRef(e,t){let r=a.deckExternalRefReadVariables(e,t.readState,t.version),s=this.cacheKey("decks","getByExternalRef",r);return this.withCache(s,"decks",t,async()=>{let{query:i}=a.deckByExternalRef();return (await this.connection.execute(i,r)).deckByExternalRef??null})}async getDraftByExternalRef(e,t={}){return this.getByExternalRef(e,{...t,readState:"DRAFT"})}async getPublishedByExternalRef(e,t={}){return this.getByExternalRef(e,{...t,readState:"PUBLISHED",version:t.version})}async listMine(e={}){let{query:t,variables:r}=a.listMyDecks({first:e.first,after:e.after,includeArchived:e.includeArchived}),s=this.cacheKey("decks","listMine",r),i=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).myDecks);return new l(i,{nextPageLoader:async n=>this.listMine({...e,after:n})})}async listViewer(e={}){let{query:t,variables:r}=a.viewerDecks({filter:e.filter,first:e.first,after:e.after}),s=this.cacheKey("decks","listViewer",r),i=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).viewerDecks);return new l(i,{nextPageLoader:async n=>this.listViewer({...e,after:n})})}async listApp(e={}){this.config.requireSecretCredential("decks.listApp");let{query:t,variables:r}=a.appDecks({filter:e.filter,first:e.first,after:e.after}),s=this.cacheKey("decks","listApp",r),i=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).appDecks);return new l(i,{nextPageLoader:async n=>this.listApp({...e,after:n})})}async listPublic(e={}){let{query:t,variables:r}=a.publicDecks({filter:e.filter,first:e.first,after:e.after}),s=this.cacheKey("decks","listPublic",r),i=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).publicDecks);return new l(i,{nextPageLoader:async n=>this.listPublic({...e,after:n})})}async fetchVersion(e,t={}){let r=this.cacheKey("decks","fetchVersion",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckVersion();return (await this.connection.execute(s,{id:e})).deckVersion??null})}async listVersions(e,t={}){let{query:r,variables:s}=a.deckVersions({first:t.first,after:t.after}),i={deckId:e,...s},n=this.cacheKey("decks","listVersions",i),c=await this.withCache(n,"decks",t,async()=>(await this.connection.execute(r,i)).deckVersions);return new l(c,{nextPageLoader:async o=>this.listVersions(e,{...t,after:o})})}async draftDiff(e,t={}){let r=this.cacheKey("decks","draftDiff",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckDraftDiff();return (await this.connection.execute(s,{id:e})).deckDraftDiff})}async versionDiff(e,t,r={}){let s=a.deckVersionDiffVariables(e,t),i=this.cacheKey("decks","versionDiff",s);return this.withCache(i,"decks",r,async()=>{let{query:n}=a.deckVersionDiff();return (await this.connection.execute(n,s)).deckVersionDiff})}async validate(e,t,r={}){let s=a.deckValidateVariables(e,t),i=this.cacheKey("decks","validate",s);return this.withCache(i,"decks",r,async()=>{let{query:n}=a.deckValidate();return (await this.connection.execute(n,s)).deckValidate})}async hydrateDeckEntries(e,t={}){let r=a.deckHydrateEntriesVariables(e),s=this.cacheKey("decks","hydrateDeckEntries",r);return this.withCache(s,"decks",t,async()=>{let{query:i}=a.deckHydrateEntries();return (await this.connection.execute(i,r)).deckHydrateEntries})}async exportDeck(e,t="SIMPLE_TEXT",r={}){let s=a.deckExportVariables(e,t),i=this.cacheKey("decks","exportDeck",s);return this.withCache(i,"decks",r,async()=>{let{query:n}=a.deckExport();return (await this.connection.execute(n,s)).deckExport})}async sectionDefinitions(e={}){let{query:t,variables:r}=a.deckSectionDefinitions({publisherSlug:e.publisherSlug,gameKey:e.gameKey,gameId:e.gameId,rulesetKey:e.rulesetKey,rulesetVersionId:e.rulesetVersionId}),s=this.cacheKey("decks","sectionDefinitions",r);return this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).deckSectionDefinitions)}async listCollaborators(e,t={}){let r=this.cacheKey("decks","listCollaborators",{deckId:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckCollaborators();return (await this.connection.execute(s,{deckId:e})).deckCollaborators})}async listApiApplicationAccesses(e,t={}){let r=a.deckApiApplicationAccessesVariables(e,t.includeRevoked),s=this.cacheKey("decks","listApiApplicationAccesses",r);return this.withCache(s,"decks",t,async()=>{let{query:i}=a.deckApiApplicationAccesses();return (await this.connection.execute(i,r)).deckApiApplicationAccesses})}async listMyApiApplicationAccesses(e={}){let t=a.myDeckApiApplicationAccessesVariables(e.applicationId),r=this.cacheKey("decks","listMyApiApplicationAccesses",t);return this.withCache(r,"decks",e,async()=>{let{query:s}=a.myDeckApiApplicationAccesses();return (await this.connection.execute(s,t)).myDeckApiApplicationAccesses})}async create(e){let{query:t}=a.createDeck(),r=a.deckCreateVariables(e);return (await this.connection.execute(t,r)).deckCreate}async update(e,t){let{query:r}=a.updateDeck(),s=a.deckUpdateVariables(e,t);return (await this.connection.execute(r,s)).deckUpdate}async updateMetadata(e,t){return this.update(e,t)}async upsertByExternalRef(e){this.config.requireSecretCredential("decks.upsertByExternalRef");let{query:t}=a.upsertDeckByExternalRef(),r=a.deckUpsertByExternalRefVariables(e);return (await this.connection.execute(t,r)).deckUpsertByExternalRef}async claim(e,t){let{query:r}=a.claimDeck(),s=a.deckClaimVariables(e,t);return (await this.connection.execute(r,s)).deckClaim}async transferOwnership(e,t){let{query:r}=a.transferDeckOwnership(),s=a.deckTransferOwnershipVariables(e,t);return (await this.connection.execute(r,s)).deckTransferOwnership}async copy(e,t){let{query:r}=a.copyDeck(),s=a.deckCopyVariables(e,t);return (await this.connection.execute(r,s)).deckCopy}async addEntry(e){let{query:t}=a.addDeckEntry(),r=a.deckEntryAddVariables(e);return (await this.connection.execute(t,r)).deckEntryAdd}async updateEntry(e,t){let{query:r}=a.updateDeckEntry(),s=a.deckEntryUpdateVariables(e,t);return (await this.connection.execute(r,s)).deckEntryUpdate}async removeEntry(e,t){let{query:r}=a.removeDeckEntry(),s=a.deckEntryRemoveVariables(e,t);return (await this.connection.execute(r,s)).deckEntryRemove}async reorderEntries(e,t){let{query:r}=a.reorderDeckEntries(),s=a.deckEntryReorderVariables(e,t);return (await this.connection.execute(r,s)).deckEntryReorder}async replaceEntries(e,t){let{query:r}=a.replaceDeckEntries(),s=a.deckEntriesReplaceVariables(e,t);return (await this.connection.execute(r,s)).deckEntriesReplace}async importDeck(e){let{query:t}=a.importDeck(),r=a.deckImportVariables(e);return (await this.connection.execute(t,r)).deckImport}async listImportFormats(e,t={}){let{query:r,variables:s}=a.deckImportFormats({gameId:e,includeArchived:t.includeArchived,first:t.first,after:t.after}),i=this.cacheKey("decks","listImportFormats",s),n=await this.withCache(i,"decks",t,async()=>(await this.connection.execute(r,s)).deckImportFormats);return new l(n,{nextPageLoader:async c=>this.listImportFormats(e,{...t,after:c})})}async fetchImportFormat(e,t={}){let r=this.cacheKey("decks","fetchImportFormat",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckImportFormat();return (await this.connection.execute(s,{id:e})).deckImportFormat??null})}async testImportFormat(e){let{query:t}=a.deckImportFormatTest(),r=a.deckImportFormatTestVariables(e);return (await this.connection.execute(t,r)).deckImportFormatTest}async createImportFormat(e){let{query:t}=a.createDeckImportFormat(),r=a.deckImportFormatCreateVariables(e);return (await this.connection.execute(t,r)).deckImportFormatCreate}async updateImportFormat(e,t){let{query:r}=a.updateDeckImportFormat(),s=a.deckImportFormatUpdateVariables(e,t);return (await this.connection.execute(r,s)).deckImportFormatUpdate}async archiveImportFormat(e){let{query:t}=a.archiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatArchive}async unarchiveImportFormat(e){let{query:t}=a.unarchiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatUnarchive}async delete(e){let{query:t}=a.deleteDeck();return !!(await this.connection.execute(t,{id:e})).deckDelete}async archive(e){let{query:t}=a.archiveDeck();return (await this.connection.execute(t,{id:e})).deckArchive}async restore(e){let{query:t}=a.restoreDeck();return (await this.connection.execute(t,{id:e})).deckRestore}async unpublish(e){let{query:t}=a.unpublishDeck();return (await this.connection.execute(t,{id:e})).deckUnpublish}async publish(e,t){let{query:r}=a.publishDeck(),s=a.deckPublishVariables(e,t);return (await this.connection.execute(r,s)).deckPublish}async removeInvalidEntries(e,t){let{query:r}=a.removeInvalidDeckEntries(),s=a.deckRemoveInvalidEntriesVariables(e,t);return (await this.connection.execute(r,s)).deckRemoveInvalidEntries}async upsertCollaborator(e,t,r){let{query:s}=a.upsertDeckCollaborator(),i=a.deckCollaboratorVariables(e,t,r);return (await this.connection.execute(s,i)).deckCollaboratorUpsert}async removeCollaborator(e,t){let{query:r}=a.removeDeckCollaborator(),s=a.deckCollaboratorVariables(e,t);return !!(await this.connection.execute(r,s)).deckCollaboratorRemove}async createTokenIssuer(e){this.config.requireSecretCredential("decks.createTokenIssuer");let{query:t}=a.createDeckTokenIssuer(),r=a.deckTokenIssuerCreateVariables(e);return (await this.connection.execute(t,r)).deckTokenIssuerCreate}async revokeTokenIssuer(e){this.config.requireSecretCredential("decks.revokeTokenIssuer");let{query:t}=a.revokeDeckTokenIssuer();return !!(await this.connection.execute(t,{id:e})).deckTokenIssuerRevoke}async revokeTokenIssuerSigningKey(e){this.config.requireSecretCredential("decks.revokeTokenIssuerSigningKey");let{query:t}=a.revokeDeckTokenIssuerSigningKey();return (await this.connection.execute(t,{id:e})).deckTokenIssuerSigningKeyRevoke}async grantApiApplicationAccess(e){let{query:t}=a.grantDeckApiApplicationAccess(),r=a.deckApiApplicationAccessGrantVariables(e);return (await this.connection.execute(t,r)).deckApiApplicationAccessGrant}async revokeApiApplicationAccess(e,t){let{query:r}=a.revokeDeckApiApplicationAccess(),s=a.deckApiApplicationAccessRevokeVariables(e,t);return !!(await this.connection.execute(r,s)).deckApiApplicationAccessRevoke}async exchangeToken(e){this.config.requireSecretCredential("decks.exchangeToken");let{query:t}=a.exchangeDeckToken(),r=a.deckTokenExchangeVariables(e);return (await this.connection.execute(t,r)).deckTokenExchange}async revokeToken(e){this.config.requireSecretCredential("decks.revokeToken");let{query:t}=a.revokeDeckToken();return !!(await this.connection.execute(t,{id:e})).deckTokenRevoke}async hydrateEntries(e){if(e.entries.length===0)return [];let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=e.entries.map(o=>o.identifier),i=this.cacheKey("decks","hydrateEntries",{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:s}),n=await this.withCache(i,"decks",e,async()=>{let{query:o}=a.fetchRecordsByIdentifier();return (await this.connection.execute(o,{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:s})).fetchRecordsByIdentifier}),c=Et(n,s,e.identifierField);return e.entries.map(o=>({...o,record:c.get(o.identifier)??null}))}};function Et(e,t,r){let s=new Set(t),i=new Map;for(let n of e){let c=r?n.data[r]:Object.values(n.data).find(h=>s.has(String(h)));if(c==null)continue;let o=String(c);s.has(o)&&(i.set(o,n),s.delete(o));}return i}var qt=class extends y{constructor(e,t){super(e,t);}async list(e){let t=_(e.filter),{query:r,variables:s}=a.listDatasetRecords({datasetId:e.datasetId,filter:t,orderBy:e.orderBy,first:e.first,after:e.after,last:e.last,before:e.before,validateSchema:e.validateSchema}),i=this.cacheKey("records","list",s),n=await this.withCache(i,"records",e,async()=>(await this.connection.execute(r,s)).datasetRecords);return new l(n,{nextPageLoader:async c=>this.list({...e,after:c})})}async getByDatasetIdentifier(e){let t=this.cacheKey("records","getByDatasetIdentifier",{datasetId:e.datasetId,identifier:e.identifier,includePricing:e.includePricing??false});return this.withCache(t,"records",e,async()=>{let{query:r,variables:s}=a.datasetRecord({datasetId:e.datasetId,identifier:e.identifier,includePricing:e.includePricing});return (await this.connection.execute(r,s)).datasetRecord??null})}async upsertBatch(e){this.config.requireSecretCredential("records.upsertBatch");let{query:t}=a.upsertDatasetRecords();return (await this.connection.execute(t,a.datasetRecordsUpsertVariables(e))).datasetRecordsUpsert}async deleteBatch(e){this.config.requireSecretCredential("records.deleteBatch");let{query:t}=a.deleteDatasetRecords();return (await this.connection.execute(t,a.datasetRecordsDeleteVariables(e))).datasetRecordsDelete}async getDeleteJob(e,t={}){let r=this.cacheKey("records","getDeleteJob",{id:e});return this.withCache(r,"records",t,async()=>{let{query:s}=a.datasetRecordDeleteJob();return (await this.connection.execute(s,{id:e})).datasetRecordDeleteJob??null})}async listDeleteJobs(e,t={}){let{query:r,variables:s}=a.datasetRecordDeleteJobs({publisherId:e,datasetId:t.datasetId,status:t.status,first:t.first,after:t.after}),i=this.cacheKey("records","listDeleteJobs",s),n=await this.withCache(i,"records",t,async()=>(await this.connection.execute(r,s)).datasetRecordDeleteJobs);return new l(n,{nextPageLoader:async c=>this.listDeleteJobs(e,{...t,after:c})})}async waitForDeleteJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,i=Date.now();for(;;){let n=await this.getDeleteJob(e,{cache:false});if(!n)throw new Error(`Delete job '${e}' was not found`);if(n.status==="COMPLETED"||n.status==="FAILED")return n;if(Date.now()-i>=s)throw new Error(`Timed out waiting for delete job '${e}'`);await new Promise(c=>setTimeout(c,r));}}async search(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=_(e.filter),{query:i,variables:n}=a.searchRecords({publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,filter:s,search:e.search,orderBy:e.orderBy,resolveLinks:e.resolveLinks,first:e.first,after:e.after,validateSchema:e.validateSchema,includePricing:e.includePricing}),c=this.cacheKey("records","search",{...n,includePricing:e.includePricing??false}),o=await this.withCache(c,"records",e,async()=>(await this.connection.execute(i,n)).searchRecords);return new l(o,{nextPageLoader:async h=>this.search({...e,after:h})})}async get(e,t={}){let r=this.cacheKey("records","get",{id:e,includePricing:t.includePricing??false});return this.withCache(r,"records",t,async()=>{let{query:s}=a.fetchRecordById({includePricing:t.includePricing});return (await this.connection.execute(s,{id:e})).fetchRecord??null})}async getByIdentifier(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=this.cacheKey("records","getByIdentifier",{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifier:e.identifier,includePricing:e.includePricing??false});return this.withCache(s,"records",e,async()=>{let{query:i}=a.fetchRecordByIdentifier({includePricing:e.includePricing});return (await this.connection.execute(i,{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifier:e.identifier})).fetchRecordByIdentifier??null})}async getManyByIdentifier(e){if(e.identifiers.length===0)return [];let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=this.cacheKey("records","getManyByIdentifier",{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:e.identifiers,includePricing:e.includePricing??false});return this.withCache(s,"records",e,async()=>{let{query:i}=a.fetchRecordsByIdentifier({includePricing:e.includePricing});return (await this.connection.execute(i,{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:e.identifiers})).fetchRecordsByIdentifier??[]})}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("records","getMany",{ids:e,includePricing:t.includePricing??false});return this.withCache(r,"records",t,async()=>{let{query:s}=a.fetchRecords({includePricing:t.includePricing});return (await this.connection.execute(s,{ids:e})).fetchRecords??[]})}},xt=class extends y{constructor(e,t){super(e,t);}async datasets(e={}){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let{query:s,variables:i}=a.searchDatasets({publisherSlug:t,gameKey:r,search:e.search,purpose:"RULES",first:e.first,after:e.after}),n=this.cacheKey("rules","datasets",i),c=await this.withCache(n,"datasets",e,async()=>(await this.connection.execute(s,i)).searchDatasets);return new l(c,{nextPageLoader:async o=>this.datasets({...e,after:o})})}async list(e={}){return this.searchRuleRecords("rules",e)}async formats(e={}){return this.searchRuleRecords(e.datasetKey??"formats",e)}async searchRuleRecords(e,t){let r=this.resolvePublisher(t.publisherSlug),s=this.resolveGame(t.gameKey),i=t.datasetKey??e;this.validateAccess(r,s);let n=_(t.filter),{query:c,variables:o}=a.searchRecords({publisherSlug:r,gameKey:s,datasetKey:i,filter:n,search:t.search,orderBy:t.orderBy,resolveLinks:t.resolveLinks,first:t.first,after:t.after,validateSchema:t.validateSchema}),h=this.cacheKey("rules","records",o),R=await this.withCache(h,"records",t,async()=>(await this.connection.execute(c,o)).searchRecords);return new l(R,{nextPageLoader:async ee=>this.searchRuleRecords(e,{...t,after:ee})})}},Ct=class extends y{constructor(e,t){super(e,t);}async list(e,t={}){let{query:r,variables:s}=a.rulesets({gameId:e,includeArchived:t.includeArchived,first:t.first,after:t.after}),i=this.cacheKey("rulesets","list",s),n=await this.withCache(i,"rulesets",t,async()=>(await this.connection.execute(r,s)).rulesets);return new l(n,{nextPageLoader:async c=>this.list(e,{...t,after:c})})}async listPublic(e,t={}){let{query:r,variables:s}=a.publicRulesets({gameId:e,first:t.first,after:t.after}),i=this.cacheKey("rulesets","listPublic",s),n=await this.withCache(i,"rulesets",t,async()=>(await this.connection.execute(r,s)).publicRulesets);return new l(n,{nextPageLoader:async c=>this.listPublic(e,{...t,after:c})})}async get(e,t={}){let r={id:e},s=this.cacheKey("rulesets","get",r);return this.withCache(s,"rulesets",t,async()=>{let{query:i,variables:n}=a.ruleset({id:e});return (await this.connection.execute(i,n)).ruleset??null})}async getByKey(e){let t={gameId:e.gameId,key:e.key},r=this.cacheKey("rulesets","getByKey",t);return this.withCache(r,"rulesets",e,async()=>{let{query:s,variables:i}=a.ruleset({gameId:e.gameId,key:e.key});return (await this.connection.execute(s,i)).ruleset??null})}async versions(e,t={}){let{query:r,variables:s}=a.rulesetVersions({rulesetId:e,status:t.status,first:t.first,after:t.after}),i=this.cacheKey("rulesets","versions",s),n=await this.withCache(i,"rulesets",t,async()=>(await this.connection.execute(r,s)).rulesetVersions);return new l(n,{nextPageLoader:async c=>this.versions(e,{...t,after:c})})}async getVersion(e,t={}){let r=this.cacheKey("rulesets","getVersion",{id:e});return this.withCache(r,"rulesets",t,async()=>{let{query:s}=a.rulesetVersion();return (await this.connection.execute(s,{id:e})).rulesetVersion??null})}async validationRules(e,t,r={}){let s=a.rulesetValidationRulesVariables(e,t,r.rulesetVersionId),i=this.cacheKey("rulesets","validationRules",s);return this.withCache(i,"rulesets",r,async()=>{let{query:n}=a.rulesetValidationRules();return (await this.connection.execute(n,s)).rulesetValidationRules??null})}async deckValidationRules(e,t,r={}){let s=a.rulesetValidationRulesVariables(e,t,r.rulesetVersionId),i=this.cacheKey("rulesets","deckValidationRules",s);return this.withCache(i,"rulesets",r,async()=>{let{query:n}=a.deckValidationRules();return (await this.connection.execute(n,s)).deckValidationRules??null})}async previewImport(e,t){let{query:r}=a.rulesetVersionDraftImportPreview(),s=a.rulesetVersionDraftImportPreviewVariables(e,t);return (await this.connection.execute(r,s)).rulesetVersionDraftImportPreview}async validationImpact(e,t={}){let{query:r,variables:s}=a.rulesetValidationImpact({rulesetVersionId:e,first:t.first}),i=this.cacheKey("rulesets","validationImpact",s);return this.withCache(i,"rulesets",t,async()=>(await this.connection.execute(r,s)).rulesetValidationImpact)}async create(e){this.config.requireSecretCredential("rulesets.create");let{query:t}=a.createRuleset();return (await this.connection.execute(t,a.rulesetCreateVariables(e))).rulesetCreate}async update(e,t){this.config.requireSecretCredential("rulesets.update");let{query:r}=a.updateRuleset();return (await this.connection.execute(r,a.rulesetUpdateVariables(e,t))).rulesetUpdate}async createDraft(e,t){this.config.requireSecretCredential("rulesets.createDraft");let{query:r}=a.createRulesetVersionDraft();return (await this.connection.execute(r,a.rulesetVersionDraftCreateVariables(e,t))).rulesetVersionDraftCreate}async importDraftFromDatasetRecord(e,t){this.config.requireSecretCredential("rulesets.importDraftFromDatasetRecord");let{query:r}=a.importRulesetVersionDraftFromDatasetRecord();return (await this.connection.execute(r,a.rulesetVersionDraftImportFromDatasetRecordVariables(e,t))).rulesetVersionDraftImportFromDatasetRecord}async updateDraft(e,t){this.config.requireSecretCredential("rulesets.updateDraft");let{query:r}=a.updateRulesetVersionDraft();return (await this.connection.execute(r,a.rulesetVersionDraftUpdateVariables(e,t))).rulesetVersionDraftUpdate}async publishVersion(e,t){this.config.requireSecretCredential("rulesets.publishVersion");let{query:r}=a.publishRulesetVersion();return (await this.connection.execute(r,a.rulesetVersionPublishVariables(e,t))).rulesetVersionPublish}async activateVersion(e){this.config.requireSecretCredential("rulesets.activateVersion");let{query:t}=a.activateRulesetVersion();return (await this.connection.execute(t,{id:e})).rulesetVersionActivate}},Ut=class extends y{constructor(e,t){super(e,t);}async list(e){let{query:t,variables:r}=a.deckImportFormats({publisherId:e.publisherId,gameId:e.gameId,includeArchived:e.includeArchived,first:e.first,after:e.after}),s=this.cacheKey("importFormats","list",r),i=await this.withCache(s,"importFormats",e,async()=>(await this.connection.execute(t,r)).deckImportFormats);return new l(i,{nextPageLoader:async n=>this.list({...e,after:n})})}async get(e,t={}){let r=this.cacheKey("importFormats","get",{id:e});return this.withCache(r,"importFormats",t,async()=>{let{query:s}=a.deckImportFormat();return (await this.connection.execute(s,{id:e})).deckImportFormat??null})}async getByKey(e){let t=this.cacheKey("importFormats","getByKey",{gameId:e.gameId,formatKey:e.key});return this.withCache(t,"importFormats",e,async()=>{let{query:r}=a.deckImportFormat();return (await this.connection.execute(r,{gameId:e.gameId,key:e.key})).deckImportFormat??null})}async test(e){let{query:t}=a.deckImportFormatTest();return (await this.connection.execute(t,a.deckImportFormatTestVariables(e))).deckImportFormatTest}async create(e){this.config.requireSecretCredential("importFormats.create");let{query:t}=a.createDeckImportFormat();return (await this.connection.execute(t,a.deckImportFormatCreateVariables(e))).deckImportFormatCreate}async update(e,t){this.config.requireSecretCredential("importFormats.update");let{query:r}=a.updateDeckImportFormat();return (await this.connection.execute(r,a.deckImportFormatUpdateVariables(e,t))).deckImportFormatUpdate}async archive(e){this.config.requireSecretCredential("importFormats.archive");let{query:t}=a.archiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatArchive}async unarchive(e){this.config.requireSecretCredential("importFormats.unarchive");let{query:t}=a.unarchiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatUnarchive}},Kt=class extends y{constructor(e,t){super(e,t);}async preview(e){let{query:t}=a.datasetImportPreview();return (await this.connection.execute(t,a.datasetImportPreviewVariables(e))).datasetImportPreview}async validate(e){let{query:t}=a.datasetImportValidate();return (await this.connection.execute(t,a.datasetImportValidateVariables(e))).datasetImportValidate}async run(e){if(this.config.requireSecretCredential("imports.run"),"fileId"in e&&e.fileId){let{query:s}=a.datasetImportFromFile();return (await this.connection.execute(s,a.datasetImportFromFileVariables(e))).datasetImportFromFile}if("sourceUrl"in e&&e.sourceUrl){let{query:s}=a.datasetImportFromUrl();return (await this.connection.execute(s,a.datasetImportFromUrlVariables(e))).datasetImportFromUrl}let{query:t}=a.datasetImportFromPayload();return (await this.connection.execute(t,a.datasetImportFromPayloadVariables(e))).datasetImportFromPayload}async getJob(e,t={}){let r=this.cacheKey("imports","getJob",{id:e});return this.withCache(r,"imports",t,async()=>{let{query:s}=a.importJob();return (await this.connection.execute(s,{id:e})).importJob??null})}async listJobs(e,t={}){let{query:r,variables:s}=a.importJobs({publisherId:e,datasetId:t.datasetId,status:t.status,first:t.first,after:t.after}),i=this.cacheKey("imports","listJobs",s),n=await this.withCache(i,"imports",t,async()=>(await this.connection.execute(r,s)).importJobs);return new l(n,{nextPageLoader:async c=>this.listJobs(e,{...t,after:c})})}async cancelJob(e){this.config.requireSecretCredential("imports.cancelJob");let{query:t}=a.importJobCancel();return (await this.connection.execute(t,{id:e})).importJobCancel}async listJobLogs(e,t={}){let{query:r,variables:s}=a.importJobLogs({importJobId:e,level:t.level,datasetKey:t.datasetKey,first:t.first,after:t.after}),i=this.cacheKey("imports","listJobLogs",s),n=await this.withCache(i,"imports",t,async()=>(await this.connection.execute(r,s)).importJob?.logs??Tt());return new l(n,{nextPageLoader:async c=>this.listJobLogs(e,{...t,after:c})})}async waitForJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,i=Date.now();for(;;){let n=await this.getJob(e,{cache:false});if(!n)throw new Error(`Import job '${e}' was not found`);if(n.status==="COMPLETED"||n.status==="FAILED")return n;if(Date.now()-i>=s)throw new Error(`Timed out waiting for import job '${e}'`);await new Promise(c=>setTimeout(c,r));}}async previewGame(e){let{query:t}=a.gameImportPreview();return (await this.connection.execute(t,a.gameImportPreviewVariables(e))).gameImportPreview}async runGame(e){if(this.config.requireSecretCredential("imports.runGame"),"fileId"in e&&e.fileId){let{query:s}=a.gameImportFromFile();return (await this.connection.execute(s,a.gameImportFromFileVariables(e))).gameImportFromFile}if("sourceUrl"in e&&e.sourceUrl){let{query:s}=a.gameImportFromUrl();return (await this.connection.execute(s,a.gameImportFromUrlVariables(e))).gameImportFromUrl}let{query:t}=a.gameImportFromPayload();return (await this.connection.execute(t,a.gameImportFromPayloadVariables(e))).gameImportFromPayload}async getGameJob(e,t={}){let r=this.cacheKey("imports","getGameJob",{id:e});return this.withCache(r,"imports",t,async()=>{let{query:s}=a.gameImportJob();return (await this.connection.execute(s,{id:e})).gameImportJob??null})}async listGameJobs(e,t={}){let{query:r,variables:s}=a.gameImportJobs({gameId:e,status:t.status,first:t.first,after:t.after}),i=this.cacheKey("imports","listGameJobs",s),n=await this.withCache(i,"imports",t,async()=>(await this.connection.execute(r,s)).gameImportJobs);return new l(n,{nextPageLoader:async c=>this.listGameJobs(e,{...t,after:c})})}async cancelGameJob(e){this.config.requireSecretCredential("imports.cancelGameJob");let{query:t}=a.gameImportJobCancel();return (await this.connection.execute(t,{id:e})).gameImportJobCancel}async waitForGameJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,i=Date.now();for(;;){let n=await this.getGameJob(e,{cache:false});if(!n)throw new Error(`Game import job '${e}' was not found`);if(n.status==="COMPLETED"||n.status==="FAILED")return n;if(Date.now()-i>=s)throw new Error(`Timed out waiting for game import job '${e}'`);await new Promise(c=>setTimeout(c,r));}}};function Tt(){return {totalCount:0,pageInfo:{hasNextPage:false,hasPreviousPage:false,startCursor:null,endCursor:null},edges:[]}}var Ft=class extends y{constructor(e,t){super(e,t);}async run(e){this.config.requireSecretCredential("exports.run");let{query:t}=a.datasetExport();return (await this.connection.execute(t,a.datasetExportVariables(e))).datasetExport}async create(e){return this.run(e)}async getJob(e,t={}){let r=this.cacheKey("exports","getJob",{id:e});return this.withCache(r,"exports",t,async()=>{let{query:s}=a.exportJob();return (await this.connection.execute(s,{id:e})).exportJob??null})}async listJobs(e,t={}){let{query:r,variables:s}=a.exportJobs({publisherId:e,gameId:t.gameId,datasetId:t.datasetId,status:t.status,first:t.first,after:t.after}),i=this.cacheKey("exports","listJobs",s),n=await this.withCache(i,"exports",t,async()=>(await this.connection.execute(r,s)).exportJobs);return new l(n,{nextPageLoader:async c=>this.listJobs(e,{...t,after:c})})}async refreshUrl(e){let{query:t}=a.exportJobRefreshUrl();return (await this.connection.execute(t,{id:e})).exportJobRefreshUrl}async cancel(e){this.config.requireSecretCredential("exports.cancel");let{query:t}=a.exportJobCancel();return (await this.connection.execute(t,{id:e})).exportJobCancel}async waitForJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,i=Date.now();for(;;){let n=await this.getJob(e,{cache:false});if(!n)throw new Error(`Export job '${e}' was not found`);if(n.status==="COMPLETED"||n.status==="FAILED")return n;if(Date.now()-i>=s)throw new Error(`Timed out waiting for export job '${e}'`);await new Promise(c=>setTimeout(c,r));}}},Vt=class extends y{constructor(e,t){super(e,t);}async get(e,t={}){let r=this.cacheKey("files","get",{id:e});return this.withCache(r,"files",t,async()=>{let{query:s}=a.file();return (await this.connection.execute(s,{id:e})).file??null})}async requestUpload(e){this.config.requireSecretCredential("files.requestUpload");let{query:t}=a.fileUploadRequest();return (await this.connection.execute(t,a.fileUploadRequestVariables(e))).fileUploadRequest}async confirmUpload(e){this.config.requireSecretCredential("files.confirmUpload");let{query:t}=a.fileUploadConfirm();return (await this.connection.execute(t,{id:e})).fileUploadConfirm}async upload(e){let t=e.size??Lt(e.body);if(!t||t<=0)throw new Error("files.upload requires a positive size or a body with an inferable size");let r=await this.requestUpload({filename:e.filename,contentType:e.contentType,size:t,isPublic:e.isPublic??false,entityType:e.entityType??_t(e.purpose),entityId:e.entityId,publisherId:e.publisherId,datasetId:e.datasetId});return await Pt(r.uploadUrl,e.contentType,e.body),this.confirmUpload(r.file.id)}async delete(e){this.config.requireSecretCredential("files.delete");let{query:t}=a.fileDelete();return !!(await this.connection.execute(t,{id:e})).fileDelete}};async function Pt(e,t,r){let s=globalThis.fetch;if(!s)throw new Error("files.upload requires a runtime with fetch support");let i=await s(e,{method:"PUT",headers:{"Content-Type":t},body:r});if(!i.ok){let n=await i.text().catch(()=>"");throw new Error(`File upload failed with ${i.status} ${i.statusText}${n?`: ${n}`:""}`)}}function Lt(e){if(typeof e=="string")return new TextEncoder().encode(e).byteLength;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return e.byteLength;let t=e;if(typeof t?.size=="number")return t.size;if(typeof t?.byteLength=="number")return t.byteLength;if(typeof t?.length=="number")return t.length}function _t(e){if(!(!e||e==="scan_image"))return e==="import"?"import":e==="scan_template_example"?"scan_template_example":e}var Bt=class extends y{constructor(e,t){super(e,t);}async createUploadSession(e){let t=this.resolveCreateUploadSessionInput(e),{query:r}=a.createScanUploadSession();return (await this.connection.execute(r,a.createScanUploadSessionVariables(t))).createScanUploadSession}async confirmUpload(e){let t=this.resolveConfirmUploadInput(e),{query:r}=a.confirmScanUpload();return (await this.connection.execute(r,a.confirmScanUploadVariables(t))).confirmScanUpload}async createJob(e){let t=this.resolveCreateJobInput(e),{query:r}=a.createScanJob();return (await this.connection.execute(r,a.createScanJobVariables(t))).createScanJob}async getJob(e,t={}){let r=this.cacheKey("scans","getJob",{id:e});return this.withCache(r,"scans",t,async()=>{let{query:s}=a.scanJob();return (await this.connection.execute(s,{id:e})).scanJob??null})}async pollJob(e,t={}){let r=t.timeoutMs??3e5,s=Math.max(t.backoffFactor??1.5,1),i=t.maxIntervalMs??1e4,n=Date.now(),c=Math.max(t.intervalMs??1e3,1);for(;;){Ot(t.signal);let o=await this.getJob(e,{cache:false});if(!o)throw new Error(`Scan job '${e}' was not found`);if(Mt(o.status))return o;let h=Date.now()-n,R=r-h;if(R<=0)throw new Error(`Timed out waiting for scan job '${e}'`);await Jt(Math.min(c,R)),c=Math.min(Math.ceil(c*s),i);}}async submitFeedback(e){let{query:t}=a.submitScanFeedback();return (await this.connection.execute(t,a.submitScanFeedbackVariables(e))).submitScanFeedback}async metrics(e){let t=this.resolveMetricsInput(e),{query:r}=a.scanMetrics();return (await this.connection.execute(r,a.scanMetricsVariables(t))).scanMetrics}async verifyWebhookSignature(e){let t=Gt(),r=await t.importKey("raw",Se(e.secret),{name:"HMAC",hash:"SHA-256"},false,["sign"]),s=await t.sign("HMAC",r,Nt(e.body)),i=`sha256=${jt(new Uint8Array(s))}`;return Ht(e.signature.trim().toLowerCase(),i)}resolveCreateJobInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}resolveCreateUploadSessionInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}resolveConfirmUploadInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}resolveMetricsInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}};function Mt(e){let t=e.toLowerCase();return t==="completed"||t==="failed"||t==="cancelled"}async function Jt(e){return new Promise(t=>setTimeout(t,e))}function Ot(e){if(e&&(e.throwIfAborted&&e.throwIfAborted(),e.aborted))throw new Error("Scan job polling aborted")}function Gt(){let t=globalThis.crypto?.subtle;if(!t)throw new Error("Web Crypto HMAC support is not available in this runtime");return t}function Nt(e){return typeof e=="string"?Se(e):e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Se(e){return new TextEncoder().encode(e)}function jt(e){return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}function Ht(e,t){let r=Math.max(e.length,t.length),s=e.length^t.length;for(let i=0;i<r;i++)s|=(e.charCodeAt(i)||0)^(t.charCodeAt(i)||0);return s===0}var Yt=class extends y{constructor(e,t){super(e,t);}async resolve(e){let t=this.resolveTemplateScope(e),r=this.cacheKey("scanTemplates","resolve",{...t});return this.withCache(r,"scanTemplates",e,async()=>{let{query:s}=a.resolveScanTemplate();return (await this.connection.execute(s,a.resolveScanTemplateVariables(t))).resolveScanTemplate})}async list(e){let t=this.resolveListScope(e),r=this.cacheKey("scanTemplates","list",{...t});return this.withCache(r,"scanTemplates",e,async()=>{let{query:s}=a.scanTemplates();return (await this.connection.execute(s,a.scanTemplatesVariables(t))).scanTemplates?.templates??[]})}async create(e){this.config.requireSecretCredential("scanTemplates.create");let t=this.resolveSaveInput(e),{query:r}=a.createScanTemplate();return (await this.connection.execute(r,a.createScanTemplateVariables(t))).createScanTemplate}async update(e,t){this.config.requireSecretCredential("scanTemplates.update");let r=typeof e=="string"?e:e.id,s=typeof e=="string"?t:zt(e);if(!s)throw new Error("scan template input is required");let i=this.resolveSaveInput(s),{query:n}=a.updateScanTemplate();return (await this.connection.execute(n,a.updateScanTemplateVariables(r,i))).updateScanTemplate}async preview(e){let t=this.resolvePreviewInput(e),{query:r}=a.previewScanTemplate();return (await this.connection.execute(r,a.previewScanTemplateVariables(t))).previewScanTemplate}resolveTemplateScope(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,templateId:e.templateId}}resolveListScope(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,includeArchived:e.includeArchived}}resolveSaveInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}resolvePreviewInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}};function zt(e){let t={...e};return delete t.id,t}var Ae=class Re{config;connection;publishers;games;datasets;records;decks;rules;rulesets;importFormats;imports;exports;files;scans;scanTemplates;constructor(t={}){this.config=new pt(t),this.connection=new bt(this.config),this.publishers=new wt(this.connection,this.config),this.games=new St(this.connection,this.config),this.datasets=new At(this.connection,this.config),this.records=new qt(this.connection,this.config),this.decks=new Rt(this.connection,this.config),this.rules=new xt(this.connection,this.config),this.rulesets=new Ct(this.connection,this.config),this.importFormats=new Ut(this.connection,this.config),this.imports=new Kt(this.connection,this.config),this.exports=new Ft(this.connection,this.config),this.files=new Vt(this.connection,this.config),this.scans=new Bt(this.connection,this.config),this.scanTemplates=new Yt(this.connection,this.config);}async me(){let{query:t}=a.fetchMe();return (await this.connection.execute(t)).fetchMe??null}getRateLimitInfo(){return $t()}withConfig(t){let r=this.config.merge(t);return new Re({apiKey:r.configApiKey(),publishableKey:r.publishableKey,secretKey:r.secretKey,accessToken:r.accessToken,environment:r.environment,endpoint:r.endpoint,timeout:r.timeout,openTimeout:r.openTimeout,defaultPublisher:r.defaultPublisher,defaultGame:r.defaultGame,allowedPublishers:r.allowedPublishers,allowedGames:r.allowedGames,logger:r.logger,logLevel:r.logLevel,retryOnRateLimit:r.retryOnRateLimit,maxRetries:r.maxRetries,retryOnNetworkError:r.retryOnNetworkError,maxNetworkRetries:r.maxNetworkRetries,retryBaseDelay:r.retryBaseDelay,retryMaxDelay:r.retryMaxDelay,cache:r.cache,cacheTtl:r.cacheTtl,cacheTtls:r.cacheTtls})}};var Z=class{storage;prefix;constructor(t={}){let r=t.storage??"localStorage";this.storage=r==="sessionStorage"?globalThis.sessionStorage:globalThis.localStorage,this.prefix=t.prefix??"carddb:";}get(t){try{let r=this.storage.getItem(this.prefix+t);if(!r)return null;let s=JSON.parse(r);return s.expiresAt!==null&&Date.now()>s.expiresAt?(this.storage.removeItem(this.prefix+t),null):s.value}catch{return this.storage.removeItem(this.prefix+t),null}}set(t,r,s){try{let i={value:r,expiresAt:s!==void 0?Date.now()+s*1e3:null};this.storage.setItem(this.prefix+t,JSON.stringify(i));}catch(i){console.warn("[CardDB] Failed to write to cache:",i);}}delete(t){this.storage.removeItem(this.prefix+t);}clear(){let t=[];for(let r=0;r<this.storage.length;r++){let s=this.storage.key(r);s&&s.startsWith(this.prefix)&&t.push(s);}for(let r of t)this.storage.removeItem(r);}has(t){return this.get(t)!==null}get size(){let t=0;for(let r=0;r<this.storage.length;r++){let s=this.storage.key(r);s&&s.startsWith(this.prefix)&&t++;}return t}cleanup(){let t=Date.now(),r=[];for(let s=0;s<this.storage.length;s++){let i=this.storage.key(s);if(i&&i.startsWith(this.prefix))try{let n=this.storage.getItem(i);if(n){let c=JSON.parse(n);c.expiresAt!==null&&t>c.expiresAt&&r.push(i);}}catch{r.push(i);}}for(let s of r)this.storage.removeItem(s);}};var Ee=class extends Ae{constructor(t={}){if("apiKey"in t&&t.apiKey!==void 0)throw new D("apiKey is not accepted in browsers; use publishableKey or accessToken");if("secretKey"in t&&t.secretKey!==void 0)throw new D("secretKey is server-only; use publishableKey or accessToken in browsers");super(t);}};
2028
+ export{j as AuthenticationError,y as BaseResource,Z as BrowserCache,Ee as CardDBClient,f as CardDBError,l as Collection,pt as Configuration,bt as Connection,K as ConnectionError,lt as DEFAULT_CACHE_TTL,ct as DEFAULT_ENDPOINT,ht as DEFAULT_MAX_NETWORK_RETRIES,dt as DEFAULT_MAX_RETRIES,ut as DEFAULT_OPEN_TIMEOUT,yt as DEFAULT_RETRY_BASE_DELAY,ft as DEFAULT_RETRY_MAX_DELAY,ot as DEFAULT_TIMEOUT,At as DatasetsResource,Rt as DecksResource,Ft as ExportsResource,Vt as FilesResource,qe as FilterBuilder,St as GamesResource,ue as GraphQLError,Ut as ImportFormatsResource,Kt as ImportsResource,Xt as LinkResolutionError,Wt as NotFoundError,wt as PublishersResource,a as QueryBuilder,P as RateLimitError,qt as RecordsResource,D as RestrictedError,xt as RulesResource,Ct as RulesetsResource,Yt as ScanTemplatesResource,Bt as ScansResource,Y as ServerError,H as TimeoutError,L as ValidationError,kt as cacheKey,nr as contains,Qt as eq,$t as getRateLimitInfo,wr as getSDKVersion,It as getUserAgent,er as gt,tr as gte,or as ilike,lr as isNotNull,ur as isNull,cr as like,rr as lt,sr as lte,Zt as neq,ar as notWithin,vt as readCache,_ as resolveFilter,ir as within,Dt as writeCache};//# sourceMappingURL=index.js.map
1844
2029
  //# sourceMappingURL=index.js.map