@carddb/browser 0.4.2 → 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);}},M=class extends y{constructor(e="Invalid or missing API key",t){super(e,t),this.name="AuthenticationError";}},K=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;}},Bt=class extends y{constructor(e="Resource not found",t){super(e,t),this.name="NotFoundError";}},J=class extends y{errors;constructor(e="Validation error",t={}){super(e,t.response),this.name="ValidationError",this.errors=t.errors??[];}},$=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";}},G=class extends x{constructor(e="Request timed out",t){super(e,t),this.name="TimeoutError";}},O=class extends y{status;constructor(e="Server error",t={}){super(e,t.response),this.name="ServerError",this.status=t.status??null;}},Mt=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 Jt(e){return {eq:e}}function Gt(e){return {neq:e}}function Ot(e){return {gt:e}}function Nt(e){return {gte:e}}function jt(e){return {lt:e}}function Ht(e){return {lte:e}}function Yt(e){return {in:e}}function zt(e){return {nin:e}}function Wt(e){return {contains:e}}function Xt(e){return {like:e}}function Qt(e){return {ilike:e}}function Zt(){return {is_null:true}}function er(){return {is_null:false}}var Ae=class oe{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 oe;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 U(e){if(e!==void 0){if(typeof e=="function"){let t=new Ae;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 A=`
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
- `,Q=`
14
+ `,te=`
15
15
  file {
16
- ${A}
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
- `,Ee=4;function ue(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
- ${ue(e-1)}
124
+ ${he(e-1)}
125
125
  }`:""}
126
- `}var D=`
126
+ `}var S=`
127
127
  schema {
128
128
  fields {
129
- ${ue(Ee)}
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
- `,le=`
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
- `,xe=`
179
+ `,Ke=`
180
180
  pricing {
181
181
  productId
182
182
  prices {
@@ -188,11 +188,11 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
188
188
  directLowPrice
189
189
  }
190
190
  }
191
- `;function k(e={}){return `
191
+ `;function b(e={}){return `
192
192
  id
193
193
  datasetId
194
194
  data
195
- ${e.includePricing?xe:""}
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 E=k(),N=`
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
- `,F=`
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
- ${E}
228
+ ${C}
229
229
  }
230
- `,de=`
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
- `,R=`
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
- `,j=`
247
+ `,z=`
248
248
  deckId
249
249
  valid
250
250
  blockers {
251
- ${R}
251
+ ${U}
252
252
  }
253
253
  warnings {
254
- ${R}
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
- ${de}
265
+ ${fe}
266
266
  }
267
267
  checkedAt
268
- `,Z=`
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}
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
338
+ checkedAt
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
- `,C=`
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
- ${de}
388
+ ${fe}
298
389
  }
299
390
  sectionDefinitions {
300
- ${N}
391
+ ${A}
301
392
  }
302
393
  publishedByAccountId
303
394
  publishedByApiApplicationId
304
395
  createdAt
305
396
  entries {
306
- ${F}
397
+ ${B}
307
398
  }
308
- `,ee=`
399
+ `,se=`
309
400
  id
310
401
  deckId
311
402
  accountId
@@ -313,34 +404,12 @@ 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
- `,te=`
317
- id
318
- deckId
319
- label
320
- expiresAt
321
- revokedAt
322
- lastUsedAt
323
- createdAt
324
- updatedAt
325
- `,re=`
326
- id
327
- deckId
328
- apiApplicationId
329
- label
330
- readMode
331
- allowedOrigins
332
- externalSubject
333
- expiresAt
334
- revokedAt
335
- lastUsedAt
336
- createdAt
337
- updatedAt
338
- `,P=`
407
+ `,ie=`
339
408
  id
340
- deckId
341
409
  apiApplicationId
342
410
  label
343
- readModes
411
+ allowedScopes
412
+ allowedRepresentations
344
413
  maxTokenLifetimeSeconds
345
414
  directSigningAlg
346
415
  directSigningKeyId
@@ -349,19 +418,21 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
349
418
  revokedAt
350
419
  createdAt
351
420
  updatedAt
352
- `,Te=`
421
+ `,Le=`
353
422
  id
354
- deckId
355
423
  apiApplicationId
356
424
  issuerId
357
- readMode
425
+ deckId
426
+ gameId
358
427
  externalSubject
428
+ scopes
429
+ representation
359
430
  expiresAt
360
431
  revokedAt
361
432
  lastUsedAt
362
433
  createdAt
363
434
  updatedAt
364
- `,H=`
435
+ `,W=`
365
436
  lineNumber
366
437
  raw
367
438
  datasetKey
@@ -373,14 +444,14 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
373
444
  sortOrder
374
445
  display
375
446
  record {
376
- ${E}
447
+ ${C}
377
448
  }
378
- `,he=`
449
+ `,pe=`
379
450
  lineNumber
380
451
  raw
381
452
  code
382
453
  message
383
- `,Y=`
454
+ `,X=`
384
455
  lineNumber
385
456
  raw
386
457
  datasetKey
@@ -389,7 +460,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
389
460
  section
390
461
  code
391
462
  message
392
- `,z=`
463
+ `,Q=`
393
464
  lineNumber
394
465
  raw
395
466
  datasetKey
@@ -401,7 +472,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
401
472
  identifier
402
473
  display
403
474
  }
404
- `,I=`
475
+ `,k=`
405
476
  id
406
477
  gameId
407
478
  key
@@ -415,39 +486,39 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
415
486
  isArchived
416
487
  createdAt
417
488
  updatedAt
418
- `,ye=`
489
+ `,me=`
419
490
  formatId
420
491
  key
421
492
  name
422
493
  confidence
423
494
  reason
424
- `,qe=`
495
+ `,_e=`
425
496
  detection {
426
- ${ye}
497
+ ${me}
427
498
  }
428
499
  entries {
429
- ${H}
500
+ ${W}
430
501
  }
431
502
  parseErrors {
432
- ${he}
503
+ ${pe}
433
504
  }
434
505
  unmatched {
435
- ${Y}
506
+ ${X}
436
507
  }
437
508
  ambiguous {
438
- ${z}
509
+ ${Q}
439
510
  }
440
- `,Re=`
511
+ `,Be=`
441
512
  entries {
442
- ${H}
513
+ ${W}
443
514
  }
444
515
  unmatched {
445
- ${Y}
516
+ ${X}
446
517
  }
447
518
  ambiguous {
448
- ${z}
519
+ ${Q}
449
520
  }
450
- `,Ce=`
521
+ `,Me=`
451
522
  deckId
452
523
  format
453
524
  text
@@ -482,10 +553,10 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
482
553
  sourceUrl
483
554
  metadata
484
555
  sectionDefinitions {
485
- ${N}
556
+ ${A}
486
557
  }
487
558
  latestPublishedVersion {
488
- ${C}
559
+ ${V}
489
560
  }
490
561
  publishedAt
491
562
  draftRevision
@@ -499,25 +570,25 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
499
570
  ${p}
500
571
  }
501
572
  entries {
502
- ${F}
573
+ ${B}
503
574
  }
504
- `,se=`
575
+ `,ae=`
505
576
  deck {
506
577
  ${u}
507
578
  }
508
579
  retainedAppAccess
509
- `,Ke=`
580
+ `,Je=`
510
581
  deck {
511
582
  ${u}
512
583
  }
513
584
  copiedFromDeckId
514
585
  retainedAppAccess
515
- `,Ue=`
586
+ `,Oe=`
516
587
  id
517
588
  name
518
589
  description
519
590
  revokedAt
520
- `,L=`
591
+ `,M=`
521
592
  id
522
593
  deckId
523
594
  deck {
@@ -525,7 +596,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
525
596
  }
526
597
  apiApplicationId
527
598
  apiApplication {
528
- ${Ue}
599
+ ${Oe}
529
600
  }
530
601
  role
531
602
  grantSource
@@ -535,37 +606,37 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
535
606
  revokedAt
536
607
  createdAt
537
608
  updatedAt
538
- `,Fe=`
609
+ `,Ge=`
539
610
  deck {
540
611
  ${u}
541
612
  }
542
613
  version {
543
- ${C}
614
+ ${V}
544
615
  }
545
616
  validation {
546
- ${j}
617
+ ${z}
547
618
  }
548
619
  blockers {
549
- ${R}
620
+ ${U}
550
621
  }
551
622
  warnings {
552
- ${R}
623
+ ${U}
553
624
  }
554
- `,V=`
625
+ `,J=`
555
626
  deck {
556
627
  ${u}
557
628
  }
558
629
  entry {
559
- ${F}
630
+ ${B}
560
631
  }
561
- `,fe=`
632
+ `,ge=`
562
633
  deck {
563
634
  ${u}
564
635
  }
565
636
  entries {
566
- ${F}
637
+ ${B}
567
638
  }
568
- `,Pe=fe,Le=`
639
+ `,Ne=ge,je=`
569
640
  deck {
570
641
  ${u}
571
642
  }
@@ -574,27 +645,27 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
574
645
  replace
575
646
  format
576
647
  importFormat {
577
- ${I}
648
+ ${k}
578
649
  }
579
650
  detection {
580
- ${ye}
651
+ ${me}
581
652
  }
582
653
  entries {
583
- ${H}
654
+ ${W}
584
655
  }
585
656
  parseErrors {
586
- ${he}
657
+ ${pe}
587
658
  }
588
659
  unmatched {
589
- ${Y}
660
+ ${X}
590
661
  }
591
662
  ambiguous {
592
- ${z}
663
+ ${Q}
593
664
  }
594
665
  validation {
595
- ${j}
666
+ ${z}
596
667
  }
597
- `,ie=`
668
+ `,ne=`
598
669
  resolvedLinks {
599
670
  field
600
671
  linkFieldKey
@@ -605,7 +676,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
605
676
  data
606
677
  }
607
678
  }
608
- `,pe=`
679
+ `,Ie=`
609
680
  datasetKey
610
681
  index
611
682
  errors {
@@ -613,45 +684,45 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
613
684
  message
614
685
  details
615
686
  }
616
- `,Ve=`
687
+ `,He=`
617
688
  total
618
689
  inserted
619
690
  updated
620
691
  skipped
621
692
  failed
622
- `,me=`
693
+ `,$e=`
623
694
  inserted {
624
- ${E}
695
+ ${C}
625
696
  }
626
697
  updated {
627
- ${E}
698
+ ${C}
628
699
  }
629
700
  skipped
630
701
  errors {
631
- ${pe}
702
+ ${Ie}
632
703
  }
633
704
  createdFields {
634
- ${le}
705
+ ${ye}
635
706
  }
636
707
  stats {
637
- ${Ve}
708
+ ${He}
638
709
  }
639
- `,ge=`
710
+ `,be=`
640
711
  fileId
641
712
  filename
642
713
  file {
643
- ${A}
714
+ ${x}
644
715
  }
645
- `,b=`
716
+ `,v=`
646
717
  id
647
718
  publisherId
648
719
  publisher {
649
- ${g}
720
+ ${I}
650
721
  }
651
722
  datasetId
652
723
  dataset {
653
724
  ${m}
654
- ${D}
725
+ ${S}
655
726
  }
656
727
  accountId
657
728
  status
@@ -667,14 +738,14 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
667
738
  skippedCount
668
739
  failedCount
669
740
  createdFields {
670
- ${le}
741
+ ${ye}
671
742
  }
672
743
  errors {
673
- ${pe}
744
+ ${Ie}
674
745
  }
675
746
  errorMessage
676
747
  assets {
677
- ${ge}
748
+ ${be}
678
749
  }
679
750
  startedAt
680
751
  completedAt
@@ -685,7 +756,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
685
756
  imagesPending
686
757
  imagesCompleted
687
758
  imagesFailed
688
- `,_e=`
759
+ `,Ye=`
689
760
  id
690
761
  importJobId
691
762
  level
@@ -695,24 +766,24 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
695
766
  fieldKey
696
767
  details
697
768
  createdAt
698
- `,Be=`
769
+ `,ze=`
699
770
  job {
700
- ${b}
771
+ ${v}
701
772
  }
702
773
  dryRunResult {
703
- ${me}
774
+ ${$e}
704
775
  }
705
- `,Me=`
776
+ `,We=`
706
777
  target
707
778
  recordId
708
779
  identifier
709
780
  status
710
781
  message
711
- `,_=`
782
+ `,O=`
712
783
  id
713
784
  publisherId
714
785
  publisher {
715
- ${g}
786
+ ${I}
716
787
  }
717
788
  datasetId
718
789
  dataset {
@@ -732,7 +803,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
732
803
  blockedCount
733
804
  failedCount
734
805
  results {
735
- ${Me}
806
+ ${We}
736
807
  }
737
808
  errorMessage
738
809
  startedAt
@@ -765,12 +836,12 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
765
836
  targetFieldType
766
837
  sampleValues
767
838
  status
768
- `,B=`
839
+ `,N=`
769
840
  datasetKey
770
841
  field
771
842
  message
772
843
  severity
773
- `,Je=`
844
+ `,Xe=`
774
845
  datasetKey
775
846
  datasetName
776
847
  datasetId
@@ -780,15 +851,15 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
780
851
  ${ke}
781
852
  }
782
853
  warnings {
783
- ${B}
854
+ ${N}
784
855
  }
785
856
  canProceed
786
857
  sampleRecords
787
858
  availableDatasets {
788
859
  ${m}
789
- ${D}
860
+ ${S}
790
861
  }
791
- `,Ge=`
862
+ `,Qe=`
792
863
  datasets {
793
864
  datasetKey
794
865
  datasetName
@@ -799,16 +870,16 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
799
870
  ${ke}
800
871
  }
801
872
  warnings {
802
- ${B}
873
+ ${N}
803
874
  }
804
875
  sampleRecords
805
876
  }
806
877
  importOrder
807
878
  warnings {
808
- ${B}
879
+ ${N}
809
880
  }
810
881
  canProceed
811
- `,Oe=`
882
+ `,Ze=`
812
883
  datasetKey
813
884
  datasetId
814
885
  datasetName
@@ -819,11 +890,11 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
819
890
  skippedCount
820
891
  failedCount
821
892
  errorMessage
822
- `,v=`
893
+ `,w=`
823
894
  id
824
895
  publisherId
825
896
  publisher {
826
- ${g}
897
+ ${I}
827
898
  }
828
899
  gameId
829
900
  game {
@@ -835,14 +906,14 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
835
906
  onConflict
836
907
  fileId
837
908
  assets {
838
- ${ge}
909
+ ${be}
839
910
  }
840
911
  totalDatasets
841
912
  completedDatasets
842
913
  progress
843
914
  importOrder
844
915
  datasetStatuses {
845
- ${Oe}
916
+ ${Ze}
846
917
  }
847
918
  errorMessage
848
919
  startedAt
@@ -862,11 +933,11 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
862
933
  linkBuildingCompletedDatasets
863
934
  linkBuildingProcessedRecords
864
935
  linkBuildingTotalRecords
865
- `,S=`
936
+ `,q=`
866
937
  id
867
938
  publisherId
868
939
  publisher {
869
- ${g}
940
+ ${I}
870
941
  }
871
942
  datasetId
872
943
  dataset {
@@ -888,13 +959,13 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
888
959
  createdAt
889
960
  updatedAt
890
961
  lastCheckpointIndex
891
- `,Ne=`
962
+ `,et=`
892
963
  recordId
893
964
  rank
894
965
  score
895
966
  confidence
896
967
  reasons
897
- `,je=`
968
+ `,tt=`
898
969
  configured
899
970
  url
900
971
  latestDeliveryId
@@ -905,7 +976,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
905
976
  deliveredAt
906
977
  lastStatusCode
907
978
  lastError
908
- `,He=`
979
+ `,rt=`
909
980
  featureVersion
910
981
  candidateCount
911
982
  confidenceScore
@@ -918,7 +989,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
918
989
  details
919
990
  }
920
991
  timings
921
- `,ae=`
992
+ `,ce=`
922
993
  jobId
923
994
  status
924
995
  publisherSlug
@@ -934,14 +1005,14 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
934
1005
  confidence
935
1006
  }
936
1007
  candidates {
937
- ${Ne}
1008
+ ${et}
938
1009
  }
939
1010
  extracted
940
1011
  metrics {
941
- ${He}
1012
+ ${rt}
942
1013
  }
943
1014
  webhook {
944
- ${je}
1015
+ ${tt}
945
1016
  }
946
1017
  error {
947
1018
  code
@@ -951,7 +1022,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
951
1022
  updatedAt
952
1023
  startedAt
953
1024
  completedAt
954
- `,Ye=`
1025
+ `,st=`
955
1026
  publisherSlug
956
1027
  gameKey
957
1028
  datasetKey
@@ -1000,7 +1071,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
1000
1071
  code
1001
1072
  region
1002
1073
  message
1003
- `,ze=`
1074
+ `,it=`
1004
1075
  id
1005
1076
  key
1006
1077
  label
@@ -1013,7 +1084,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
1013
1084
  isRequired
1014
1085
  weight
1015
1086
  config
1016
- `,q=`
1087
+ `,F=`
1017
1088
  id
1018
1089
  key
1019
1090
  name
@@ -1029,11 +1100,11 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
1029
1100
  notes
1030
1101
  config
1031
1102
  regions {
1032
- ${ze}
1103
+ ${it}
1033
1104
  }
1034
1105
  createdAt
1035
1106
  updatedAt
1036
- `,We=`
1107
+ `,at=`
1037
1108
  key
1038
1109
  label
1039
1110
  semanticType
@@ -1044,7 +1115,7 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
1044
1115
  source
1045
1116
  status
1046
1117
  confidence
1047
- `,Xe=`
1118
+ `,nt=`
1048
1119
  id
1049
1120
  key
1050
1121
  name
@@ -1071,25 +1142,25 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
1071
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:`
1072
1143
  query SearchPublishers${i} {
1073
1144
  searchPublishers${n} {
1074
- ${d(g)}
1145
+ ${d(I)}
1075
1146
  }
1076
1147
  }
1077
1148
  `,variables:t}},fetchPublisherById(){return {query:`
1078
1149
  query FetchPublisher($id: UUID!) {
1079
1150
  fetchPublisher(id: $id) {
1080
- ${g}
1151
+ ${I}
1081
1152
  }
1082
1153
  }
1083
1154
  `}},fetchPublisherBySlug(){return {query:`
1084
1155
  query FetchPublisher($slug: String!) {
1085
1156
  fetchPublisher(slug: $slug) {
1086
- ${g}
1157
+ ${I}
1087
1158
  }
1088
1159
  }
1089
1160
  `}},fetchPublishers(){return {query:`
1090
1161
  query FetchPublishers($slugs: [String!]!) {
1091
1162
  fetchPublishers(slugs: $slugs) {
1092
- ${g}
1163
+ ${I}
1093
1164
  }
1094
1165
  }
1095
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:`
@@ -1150,14 +1221,14 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
1150
1221
  query FetchDataset($id: UUID!) {
1151
1222
  fetchDataset(id: $id) {
1152
1223
  ${m}
1153
- ${D}
1224
+ ${S}
1154
1225
  }
1155
1226
  }
1156
1227
  `}},fetchDatasetByKeys(){return {query:`
1157
1228
  query FetchDataset($publisherSlug: String!, $gameKey: String!, $datasetKey: String!) {
1158
1229
  fetchDataset(publisherSlug: $publisherSlug, gameKey: $gameKey, datasetKey: $datasetKey) {
1159
1230
  ${m}
1160
- ${D}
1231
+ ${S}
1161
1232
  }
1162
1233
  }
1163
1234
  `}},fetchDatasets(){return {query:`
@@ -1170,18 +1241,18 @@ var y=class ne extends Error{response;constructor(t,r){super(t),this.name="CardD
1170
1241
  query Datasets(${s.join(", ")}) {
1171
1242
  datasets(${r.join(", ")}) {
1172
1243
  ${d(`${m}
1173
- ${D}`)}
1244
+ ${S}`)}
1174
1245
  }
1175
1246
  }
1176
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:`
1177
1248
  query Dataset(${s.join(", ")}) {
1178
1249
  dataset(${r.join(", ")}) {
1179
1250
  ${m}
1180
- ${D}
1251
+ ${S}
1181
1252
  }
1182
1253
  }
1183
- `,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=k({includePricing:e.includePricing}),c=i?`${n}
1184
- ${ie}`: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:`
1185
1256
  query SearchRecords(${s.join(", ")}) {
1186
1257
  searchRecords(${r.join(", ")}) {
1187
1258
  ${d(c)}
@@ -1190,35 +1261,35 @@ ${ie}`:n;return {query:`
1190
1261
  `,variables:t}},fetchRecordById(e={}){return {query:`
1191
1262
  query FetchRecord($id: UUID!) {
1192
1263
  fetchRecord(id: $id) {
1193
- ${k(e)}
1264
+ ${b(e)}
1194
1265
  }
1195
1266
  }
1196
1267
  `}},fetchRecordByIdentifier(e={}){return {query:`
1197
1268
  query FetchRecordByIdentifier($publisherSlug: String!, $gameKey: String!, $datasetKey: String!, $identifier: String!) {
1198
1269
  fetchRecordByIdentifier(publisherSlug: $publisherSlug, gameKey: $gameKey, datasetKey: $datasetKey, identifier: $identifier) {
1199
- ${k(e)}
1270
+ ${b(e)}
1200
1271
  }
1201
1272
  }
1202
1273
  `}},fetchRecordsByIdentifier(e={}){return {query:`
1203
1274
  query FetchRecordsByIdentifier($publisherSlug: String!, $gameKey: String!, $datasetKey: String!, $identifiers: [String!]!) {
1204
1275
  fetchRecordsByIdentifier(publisherSlug: $publisherSlug, gameKey: $gameKey, datasetKey: $datasetKey, identifiers: $identifiers) {
1205
- ${k(e)}
1276
+ ${b(e)}
1206
1277
  }
1207
1278
  }
1208
1279
  `}},fetchRecords(e={}){return {query:`
1209
1280
  query FetchRecords($ids: [UUID!]!) {
1210
1281
  fetchRecords(ids: $ids) {
1211
- ${k(e)}
1282
+ ${b(e)}
1212
1283
  }
1213
1284
  }
1214
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:`
1215
1286
  query DatasetRecords(${s.join(", ")}) {
1216
1287
  datasetRecords(${r.join(", ")}) {
1217
- ${d(E)}
1288
+ ${d(C)}
1218
1289
  }
1219
1290
  }
1220
- `,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=k({includePricing:e.includePricing}),c=i?`${n}
1221
- ${ie}`: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:`
1222
1293
  query DatasetRecord(${s.join(", ")}) {
1223
1294
  datasetRecord(${r.join(", ")}) {
1224
1295
  ${c}
@@ -1227,141 +1298,141 @@ ${ie}`:n;return {query:`
1227
1298
  `,variables:t}},upsertDatasetRecords(){return {query:`
1228
1299
  mutation DatasetRecordsUpsert($input: DatasetRecordsUpsertInput!) {
1229
1300
  datasetRecordsUpsert(input: $input) {
1230
- ${Be}
1301
+ ${ze}
1231
1302
  }
1232
1303
  }
1233
1304
  `}},deleteDatasetRecords(){return {query:`
1234
1305
  mutation DatasetRecordsDelete($input: DatasetRecordsDeleteInput!) {
1235
1306
  datasetRecordsDelete(input: $input) {
1236
- ${_}
1307
+ ${O}
1237
1308
  }
1238
1309
  }
1239
1310
  `}},datasetRecordDeleteJob(){return {query:`
1240
1311
  query DatasetRecordDeleteJob($id: UUID!) {
1241
1312
  datasetRecordDeleteJob(id: $id) {
1242
- ${_}
1313
+ ${O}
1243
1314
  }
1244
1315
  }
1245
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:`
1246
1317
  query DatasetRecordDeleteJobs(${s.join(", ")}) {
1247
1318
  datasetRecordDeleteJobs(${r.join(", ")}) {
1248
- ${d(_)}
1319
+ ${d(O)}
1249
1320
  }
1250
1321
  }
1251
1322
  `,variables:t}},datasetImportPreview(){return {query:`
1252
1323
  query DatasetImportPreview($input: DatasetImportPreviewInput!) {
1253
1324
  datasetImportPreview(input: $input) {
1254
- ${Je}
1325
+ ${Xe}
1255
1326
  }
1256
1327
  }
1257
1328
  `}},datasetImportValidate(){return {query:`
1258
1329
  query DatasetImportValidate($input: DatasetImportValidateInput!) {
1259
1330
  datasetImportValidate(input: $input) {
1260
- ${me}
1331
+ ${$e}
1261
1332
  }
1262
1333
  }
1263
1334
  `}},datasetImportFromFile(){return {query:`
1264
1335
  mutation DatasetImportFromFile($input: DatasetImportFromFileInput!) {
1265
1336
  datasetImportFromFile(input: $input) {
1266
- ${b}
1337
+ ${v}
1267
1338
  }
1268
1339
  }
1269
1340
  `}},datasetImportFromPayload(){return {query:`
1270
1341
  mutation DatasetImportFromPayload($input: DatasetImportFromPayloadInput!) {
1271
1342
  datasetImportFromPayload(input: $input) {
1272
- ${b}
1343
+ ${v}
1273
1344
  }
1274
1345
  }
1275
1346
  `}},datasetImportFromUrl(){return {query:`
1276
1347
  mutation DatasetImportFromUrl($input: DatasetImportFromUrlInput!) {
1277
1348
  datasetImportFromUrl(input: $input) {
1278
- ${b}
1349
+ ${v}
1279
1350
  }
1280
1351
  }
1281
1352
  `}},importJob(){return {query:`
1282
1353
  query ImportJob($id: UUID!) {
1283
1354
  importJob(id: $id) {
1284
- ${b}
1355
+ ${v}
1285
1356
  }
1286
1357
  }
1287
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:`
1288
1359
  query ImportJobs(${s.join(", ")}) {
1289
1360
  importJobs(${r.join(", ")}) {
1290
- ${d(b)}
1361
+ ${d(v)}
1291
1362
  }
1292
1363
  }
1293
1364
  `,variables:t}},importJobCancel(){return {query:`
1294
1365
  mutation ImportJobCancel($id: UUID!) {
1295
1366
  importJobCancel(id: $id) {
1296
- ${b}
1367
+ ${v}
1297
1368
  }
1298
1369
  }
1299
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:`
1300
1371
  query ImportJobLogs(${i.join(", ")}) {
1301
1372
  importJob(${r.join(", ")}) {
1302
1373
  logs${n} {
1303
- ${d(_e)}
1374
+ ${d(Ye)}
1304
1375
  }
1305
1376
  }
1306
1377
  }
1307
1378
  `,variables:t}},gameImportPreview(){return {query:`
1308
1379
  query GameImportPreview($input: GameImportPreviewInput!) {
1309
1380
  gameImportPreview(input: $input) {
1310
- ${Ge}
1381
+ ${Qe}
1311
1382
  }
1312
1383
  }
1313
1384
  `}},gameImportFromFile(){return {query:`
1314
1385
  mutation GameImportFromFile($input: GameImportFromFileInput!) {
1315
1386
  gameImportFromFile(input: $input) {
1316
- ${v}
1387
+ ${w}
1317
1388
  }
1318
1389
  }
1319
1390
  `}},gameImportFromPayload(){return {query:`
1320
1391
  mutation GameImportFromPayload($input: GameImportFromPayloadInput!) {
1321
1392
  gameImportFromPayload(input: $input) {
1322
- ${v}
1393
+ ${w}
1323
1394
  }
1324
1395
  }
1325
1396
  `}},gameImportFromUrl(){return {query:`
1326
1397
  mutation GameImportFromUrl($input: GameImportFromUrlInput!) {
1327
1398
  gameImportFromUrl(input: $input) {
1328
- ${v}
1399
+ ${w}
1329
1400
  }
1330
1401
  }
1331
1402
  `}},gameImportJob(){return {query:`
1332
1403
  query GameImportJob($id: UUID!) {
1333
1404
  gameImportJob(id: $id) {
1334
- ${v}
1405
+ ${w}
1335
1406
  }
1336
1407
  }
1337
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:`
1338
1409
  query GameImportJobs(${s.join(", ")}) {
1339
1410
  gameImportJobs(${r.join(", ")}) {
1340
- ${d(v)}
1411
+ ${d(w)}
1341
1412
  }
1342
1413
  }
1343
1414
  `,variables:t}},gameImportJobCancel(){return {query:`
1344
1415
  mutation GameImportJobCancel($id: UUID!) {
1345
1416
  gameImportJobCancel(id: $id) {
1346
- ${v}
1417
+ ${w}
1347
1418
  }
1348
1419
  }
1349
1420
  `}},file(){return {query:`
1350
1421
  query File($id: UUID!) {
1351
1422
  file(id: $id) {
1352
- ${A}
1423
+ ${x}
1353
1424
  }
1354
1425
  }
1355
1426
  `}},fileUploadRequest(){return {query:`
1356
1427
  mutation FileUploadRequest($input: FileUploadInput!) {
1357
1428
  fileUploadRequest(input: $input) {
1358
- ${Q}
1429
+ ${te}
1359
1430
  }
1360
1431
  }
1361
1432
  `}},fileUploadConfirm(){return {query:`
1362
1433
  mutation FileUploadConfirm($id: UUID!) {
1363
1434
  fileUploadConfirm(id: $id) {
1364
- ${A}
1435
+ ${x}
1365
1436
  }
1366
1437
  }
1367
1438
  `}},fileDelete(){return {query:`
@@ -1371,20 +1442,20 @@ ${ie}`:n;return {query:`
1371
1442
  `}},createScanUploadSession(){return {query:`
1372
1443
  mutation CreateScanUploadSession($input: CreateScanUploadSessionInput!) {
1373
1444
  createScanUploadSession(input: $input) {
1374
- ${Q}
1445
+ ${te}
1375
1446
  }
1376
1447
  }
1377
1448
  `}},confirmScanUpload(){return {query:`
1378
1449
  mutation ConfirmScanUpload($input: ConfirmScanUploadInput!) {
1379
1450
  confirmScanUpload(input: $input) {
1380
- ${A}
1451
+ ${x}
1381
1452
  }
1382
1453
  }
1383
1454
  `}},createScanJob(){return {query:`
1384
1455
  mutation CreateScanJob($input: CreateScanJobInput!) {
1385
1456
  createScanJob(input: $input) {
1386
1457
  job {
1387
- ${ae}
1458
+ ${ce}
1388
1459
  }
1389
1460
  created
1390
1461
  }
@@ -1392,7 +1463,7 @@ ${ie}`:n;return {query:`
1392
1463
  `}},scanJob(){return {query:`
1393
1464
  query ScanJob($id: UUID!) {
1394
1465
  scanJob(id: $id) {
1395
- ${ae}
1466
+ ${ce}
1396
1467
  }
1397
1468
  }
1398
1469
  `}},submitScanFeedback(){return {query:`
@@ -1412,14 +1483,14 @@ ${ie}`:n;return {query:`
1412
1483
  `}},scanMetrics(){return {query:`
1413
1484
  query ScanMetrics($input: ScanMetricsInput!) {
1414
1485
  scanMetrics(input: $input) {
1415
- ${Ye}
1486
+ ${st}
1416
1487
  }
1417
1488
  }
1418
1489
  `}},resolveScanTemplate(){return {query:`
1419
1490
  query ResolveScanTemplate($input: ResolveScanTemplateInput!) {
1420
1491
  resolveScanTemplate(input: $input) {
1421
1492
  template {
1422
- ${q}
1493
+ ${F}
1423
1494
  }
1424
1495
  warnings {
1425
1496
  ${T}
@@ -1430,7 +1501,7 @@ ${ie}`:n;return {query:`
1430
1501
  query ScanTemplates($input: ScanTemplatesInput!) {
1431
1502
  scanTemplates(input: $input) {
1432
1503
  templates {
1433
- ${q}
1504
+ ${F}
1434
1505
  }
1435
1506
  }
1436
1507
  }
@@ -1438,7 +1509,7 @@ ${ie}`:n;return {query:`
1438
1509
  mutation CreateScanTemplate($input: SaveScanTemplateInput!) {
1439
1510
  createScanTemplate(input: $input) {
1440
1511
  template {
1441
- ${q}
1512
+ ${F}
1442
1513
  }
1443
1514
  warnings {
1444
1515
  ${T}
@@ -1449,7 +1520,7 @@ ${ie}`:n;return {query:`
1449
1520
  mutation UpdateScanTemplate($id: UUID!, $input: SaveScanTemplateInput!) {
1450
1521
  updateScanTemplate(id: $id, input: $input) {
1451
1522
  template {
1452
- ${q}
1523
+ ${F}
1453
1524
  }
1454
1525
  warnings {
1455
1526
  ${T}
@@ -1463,7 +1534,7 @@ ${ie}`:n;return {query:`
1463
1534
  ${T}
1464
1535
  }
1465
1536
  regions {
1466
- ${We}
1537
+ ${at}
1467
1538
  }
1468
1539
  message
1469
1540
  }
@@ -1471,37 +1542,131 @@ ${ie}`:n;return {query:`
1471
1542
  `}},gameScanRegions(){return {query:`
1472
1543
  query GameScanRegions($publisherSlug: String!, $gameKey: String!, $includeInactive: Boolean) {
1473
1544
  gameScanRegions(publisherSlug: $publisherSlug, gameKey: $gameKey, includeInactive: $includeInactive) {
1474
- ${Xe}
1545
+ ${nt}
1475
1546
  }
1476
1547
  }
1477
1548
  `}},exportJob(){return {query:`
1478
1549
  query ExportJob($id: UUID!) {
1479
1550
  exportJob(id: $id) {
1480
- ${S}
1551
+ ${q}
1481
1552
  }
1482
1553
  }
1483
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:`
1484
1555
  query ExportJobs(${s.join(", ")}) {
1485
1556
  exportJobs(${r.join(", ")}) {
1486
- ${d(S)}
1557
+ ${d(q)}
1487
1558
  }
1488
1559
  }
1489
1560
  `,variables:t}},datasetExport(){return {query:`
1490
1561
  mutation DatasetExport($input: DatasetExportInput!) {
1491
1562
  datasetExport(input: $input) {
1492
- ${S}
1563
+ ${q}
1493
1564
  }
1494
1565
  }
1495
1566
  `}},exportJobCancel(){return {query:`
1496
1567
  mutation ExportJobCancel($id: UUID!) {
1497
1568
  exportJobCancel(id: $id) {
1498
- ${S}
1569
+ ${q}
1499
1570
  }
1500
1571
  }
1501
1572
  `}},exportJobRefreshUrl(){return {query:`
1502
1573
  mutation ExportJobRefreshUrl($id: UUID!) {
1503
1574
  exportJobRefreshUrl(id: $id) {
1504
- ${S}
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}
1628
+ }
1629
+ }
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}
1505
1670
  }
1506
1671
  }
1507
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:`
@@ -1535,8 +1700,8 @@ ${ie}`:n;return {query:`
1535
1700
  }
1536
1701
  }
1537
1702
  `}},deckById(){return {query:`
1538
- query Deck($id: UUID!) {
1539
- deck(id: $id) {
1703
+ query Deck($id: UUID!, $readState: DeckReadState!, $version: DeckPublishedVersionSelector) {
1704
+ deck(id: $id, readState: $readState, version: $version) {
1540
1705
  ${u}
1541
1706
  }
1542
1707
  }
@@ -1565,129 +1730,93 @@ ${ie}`:n;return {query:`
1565
1730
  }
1566
1731
  }
1567
1732
  `}},deckByExternalRef(){return {query:`
1568
- query DeckByExternalRef($externalRef: String!) {
1569
- deckByExternalRef(externalRef: $externalRef) {
1733
+ query DeckByExternalRef($externalRef: String!, $readState: DeckReadState!, $version: DeckPublishedVersionSelector) {
1734
+ deckByExternalRef(externalRef: $externalRef, readState: $readState, version: $version) {
1570
1735
  ${u}
1571
1736
  }
1572
1737
  }
1573
1738
  `}},deckVersion(){return {query:`
1574
1739
  query DeckVersion($id: UUID!) {
1575
1740
  deckVersion(id: $id) {
1576
- ${C}
1741
+ ${V}
1577
1742
  }
1578
1743
  }
1579
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:`
1580
1745
  query DeckVersions(${s.join(", ")}) {
1581
1746
  deckVersions(${r.join(", ")}) {
1582
- ${d(C)}
1583
- }
1584
- }
1585
- `,variables:t}},deckPreview(){return {query:`
1586
- query DeckPreview($token: String!) {
1587
- deckPreview(token: $token) {
1588
- ${u}
1589
- }
1590
- }
1591
- `}},deckEmbed(){return {query:`
1592
- query DeckEmbed($token: String!) {
1593
- deckEmbed(token: $token) {
1594
- ${u}
1747
+ ${d(V)}
1595
1748
  }
1596
1749
  }
1597
- `}},deckAccess(){return {query:`
1598
- query DeckAccess($token: String!) {
1599
- deckAccess(token: $token) {
1600
- ${u}
1601
- }
1602
- }
1603
- `}},deckDraftDiff(){return {query:`
1750
+ `,variables:t}},deckDraftDiff(){return {query:`
1604
1751
  query DeckDraftDiff($id: UUID!) {
1605
1752
  deckDraftDiff(id: $id) {
1606
- ${Z}
1753
+ ${re}
1607
1754
  }
1608
1755
  }
1609
1756
  `}},deckVersionDiff(){return {query:`
1610
1757
  query DeckVersionDiff($fromVersionId: UUID!, $toVersionId: UUID!) {
1611
1758
  deckVersionDiff(fromVersionId: $fromVersionId, toVersionId: $toVersionId) {
1612
- ${Z}
1759
+ ${re}
1613
1760
  }
1614
1761
  }
1615
1762
  `}},deckHydrateEntries(){return {query:`
1616
1763
  query DeckHydrateEntries($input: DeckHydrateEntriesInput!) {
1617
1764
  deckHydrateEntries(input: $input) {
1618
- ${Re}
1765
+ ${Be}
1619
1766
  }
1620
1767
  }
1621
1768
  `}},deckExport(){return {query:`
1622
1769
  query DeckExport($id: UUID!, $format: DeckExportFormat!) {
1623
1770
  deckExport(id: $id, format: $format) {
1624
- ${Ce}
1771
+ ${Me}
1625
1772
  }
1626
1773
  }
1627
1774
  `}},deckValidate(){return {query:`
1628
1775
  query DeckValidate($id: UUID!, $input: DeckValidateInput) {
1629
1776
  deckValidate(id: $id, input: $input) {
1630
- ${j}
1777
+ ${z}
1631
1778
  }
1632
1779
  }
1633
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:`
1634
1781
  query DeckSectionDefinitions${i} {
1635
1782
  deckSectionDefinitions${n} {
1636
- ${N}
1783
+ ${A}
1637
1784
  }
1638
1785
  }
1639
1786
  `,variables:t}},deckCollaborators(){return {query:`
1640
1787
  query DeckCollaborators($deckId: UUID!) {
1641
1788
  deckCollaborators(deckId: $deckId) {
1642
- ${ee}
1643
- }
1644
- }
1645
- `}},deckEmbedTokens(){return {query:`
1646
- query DeckEmbedTokens($deckId: UUID!) {
1647
- deckEmbedTokens(deckId: $deckId) {
1648
- ${re}
1649
- }
1650
- }
1651
- `}},deckAccessTokenIssuers(){return {query:`
1652
- query DeckAccessTokenIssuers($deckId: UUID!) {
1653
- deckAccessTokenIssuers(deckId: $deckId) {
1654
- ${P}
1789
+ ${se}
1655
1790
  }
1656
1791
  }
1657
1792
  `}},deckApiApplicationAccesses(){return {query:`
1658
1793
  query DeckApiApplicationAccesses($deckId: UUID!, $includeRevoked: Boolean) {
1659
1794
  deckApiApplicationAccesses(deckId: $deckId, includeRevoked: $includeRevoked) {
1660
- ${L}
1795
+ ${M}
1661
1796
  }
1662
1797
  }
1663
1798
  `}},myDeckApiApplicationAccesses(){return {query:`
1664
1799
  query MyDeckApiApplicationAccesses($applicationId: UUID) {
1665
1800
  myDeckApiApplicationAccesses(applicationId: $applicationId) {
1666
- ${L}
1801
+ ${M}
1667
1802
  }
1668
1803
  }
1669
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:`
1670
1805
  query DeckImportFormats${i} {
1671
1806
  deckImportFormats${n} {
1672
- ${d(I)}
1807
+ ${d(k)}
1673
1808
  }
1674
1809
  }
1675
1810
  `,variables:t}},deckImportFormat(){return {query:`
1676
1811
  query DeckImportFormat($id: UUID, $gameId: UUID, $key: String) {
1677
1812
  deckImportFormat(id: $id, gameId: $gameId, key: $key) {
1678
- ${I}
1813
+ ${k}
1679
1814
  }
1680
1815
  }
1681
1816
  `}},deckImportFormatTest(){return {query:`
1682
1817
  query DeckImportFormatTest($input: DeckImportFormatTestInput!) {
1683
1818
  deckImportFormatTest(input: $input) {
1684
- ${qe}
1685
- }
1686
- }
1687
- `}},deckPreviewTokens(){return {query:`
1688
- query DeckPreviewTokens($deckId: UUID!) {
1689
- deckPreviewTokens(deckId: $deckId) {
1690
- ${te}
1819
+ ${_e}
1691
1820
  }
1692
1821
  }
1693
1822
  `}},createDeck(){return {query:`
@@ -1727,61 +1856,61 @@ ${ie}`:n;return {query:`
1727
1856
  `}},addDeckEntry(){return {query:`
1728
1857
  mutation DeckEntryAdd($input: DeckEntryAddInput!) {
1729
1858
  deckEntryAdd(input: $input) {
1730
- ${V}
1859
+ ${J}
1731
1860
  }
1732
1861
  }
1733
1862
  `}},updateDeckEntry(){return {query:`
1734
1863
  mutation DeckEntryUpdate($id: UUID!, $input: DeckEntryUpdateInput!) {
1735
1864
  deckEntryUpdate(id: $id, input: $input) {
1736
- ${V}
1865
+ ${J}
1737
1866
  }
1738
1867
  }
1739
1868
  `}},removeDeckEntry(){return {query:`
1740
1869
  mutation DeckEntryRemove($id: UUID!, $expectedDraftRevision: Int!) {
1741
1870
  deckEntryRemove(id: $id, expectedDraftRevision: $expectedDraftRevision) {
1742
- ${V}
1871
+ ${J}
1743
1872
  }
1744
1873
  }
1745
1874
  `}},reorderDeckEntries(){return {query:`
1746
1875
  mutation DeckEntryReorder($deckId: UUID!, $input: DeckEntryReorderInput!) {
1747
1876
  deckEntryReorder(deckId: $deckId, input: $input) {
1748
- ${fe}
1877
+ ${ge}
1749
1878
  }
1750
1879
  }
1751
1880
  `}},replaceDeckEntries(){return {query:`
1752
1881
  mutation DeckEntriesReplace($deckId: UUID!, $input: DeckEntriesReplaceInput!) {
1753
1882
  deckEntriesReplace(deckId: $deckId, input: $input) {
1754
- ${Pe}
1883
+ ${Ne}
1755
1884
  }
1756
1885
  }
1757
1886
  `}},importDeck(){return {query:`
1758
1887
  mutation DeckImport($input: DeckImportInput!) {
1759
1888
  deckImport(input: $input) {
1760
- ${Le}
1889
+ ${je}
1761
1890
  }
1762
1891
  }
1763
1892
  `}},createDeckImportFormat(){return {query:`
1764
1893
  mutation DeckImportFormatCreate($input: DeckImportFormatCreateInput!) {
1765
1894
  deckImportFormatCreate(input: $input) {
1766
- ${I}
1895
+ ${k}
1767
1896
  }
1768
1897
  }
1769
1898
  `}},updateDeckImportFormat(){return {query:`
1770
1899
  mutation DeckImportFormatUpdate($id: UUID!, $input: DeckImportFormatUpdateInput!) {
1771
1900
  deckImportFormatUpdate(id: $id, input: $input) {
1772
- ${I}
1901
+ ${k}
1773
1902
  }
1774
1903
  }
1775
1904
  `}},archiveDeckImportFormat(){return {query:`
1776
1905
  mutation DeckImportFormatArchive($id: UUID!) {
1777
1906
  deckImportFormatArchive(id: $id) {
1778
- ${I}
1907
+ ${k}
1779
1908
  }
1780
1909
  }
1781
1910
  `}},unarchiveDeckImportFormat(){return {query:`
1782
1911
  mutation DeckImportFormatUnarchive($id: UUID!) {
1783
1912
  deckImportFormatUnarchive(id: $id) {
1784
- ${I}
1913
+ ${k}
1785
1914
  }
1786
1915
  }
1787
1916
  `}},upsertDeckByExternalRef(){return {query:`
@@ -1797,25 +1926,25 @@ ${ie}`:n;return {query:`
1797
1926
  `}},claimDeck(){return {query:`
1798
1927
  mutation DeckClaim($id: UUID!, $input: DeckClaimInput!) {
1799
1928
  deckClaim(id: $id, input: $input) {
1800
- ${se}
1929
+ ${ae}
1801
1930
  }
1802
1931
  }
1803
1932
  `}},transferDeckOwnership(){return {query:`
1804
1933
  mutation DeckTransferOwnership($id: UUID!, $input: DeckTransferOwnershipInput!) {
1805
1934
  deckTransferOwnership(id: $id, input: $input) {
1806
- ${se}
1935
+ ${ae}
1807
1936
  }
1808
1937
  }
1809
1938
  `}},copyDeck(){return {query:`
1810
1939
  mutation DeckCopy($id: UUID!, $input: DeckCopyInput!) {
1811
1940
  deckCopy(id: $id, input: $input) {
1812
- ${Ke}
1941
+ ${Je}
1813
1942
  }
1814
1943
  }
1815
1944
  `}},publishDeck(){return {query:`
1816
1945
  mutation DeckPublish($id: UUID!, $input: DeckPublishInput!) {
1817
1946
  deckPublish(id: $id, input: $input) {
1818
- ${Fe}
1947
+ ${Ge}
1819
1948
  }
1820
1949
  }
1821
1950
  `}},removeInvalidDeckEntries(){return {query:`
@@ -1827,99 +1956,53 @@ ${ie}`:n;return {query:`
1827
1956
  `}},upsertDeckCollaborator(){return {query:`
1828
1957
  mutation DeckCollaboratorUpsert($deckId: UUID!, $accountId: UUID!, $role: DeckCollaboratorRole!) {
1829
1958
  deckCollaboratorUpsert(deckId: $deckId, accountId: $accountId, role: $role) {
1830
- ${ee}
1959
+ ${se}
1831
1960
  }
1832
1961
  }
1833
1962
  `}},removeDeckCollaborator(){return {query:`
1834
1963
  mutation DeckCollaboratorRemove($deckId: UUID!, $accountId: UUID!) {
1835
1964
  deckCollaboratorRemove(deckId: $deckId, accountId: $accountId)
1836
1965
  }
1837
- `}},createDeckPreviewToken(){return {query:`
1838
- mutation DeckPreviewTokenCreate($input: DeckPreviewTokenCreateInput!) {
1839
- deckPreviewTokenCreate(input: $input) {
1840
- token
1841
- previewToken {
1842
- ${te}
1843
- }
1844
- }
1845
- }
1846
- `}},revokeDeckPreviewToken(){return {query:`
1847
- mutation DeckPreviewTokenRevoke($id: UUID!) {
1848
- deckPreviewTokenRevoke(id: $id)
1849
- }
1850
- `}},createDeckEmbedToken(){return {query:`
1851
- mutation DeckEmbedTokenCreate($input: DeckEmbedTokenCreateInput!) {
1852
- deckEmbedTokenCreate(input: $input) {
1853
- token
1854
- embedToken {
1855
- ${re}
1856
- }
1857
- }
1858
- }
1859
- `}},revokeDeckEmbedToken(){return {query:`
1860
- mutation DeckEmbedTokenRevoke($id: UUID!) {
1861
- deckEmbedTokenRevoke(id: $id)
1862
- }
1863
- `}},createDeckAccessTokenIssuer(){return {query:`
1864
- mutation DeckAccessTokenIssuerCreate($input: DeckAccessTokenIssuerCreateInput!) {
1865
- deckAccessTokenIssuerCreate(input: $input) {
1866
- ${P}
1966
+ `}},createDeckTokenIssuer(){return {query:`
1967
+ mutation DeckTokenIssuerCreate($input: DeckTokenIssuerCreateInput!) {
1968
+ deckTokenIssuerCreate(input: $input) {
1969
+ ${ie}
1867
1970
  }
1868
1971
  }
1869
- `}},revokeDeckAccessTokenIssuer(){return {query:`
1870
- mutation DeckAccessTokenIssuerRevoke($id: UUID!) {
1871
- deckAccessTokenIssuerRevoke(id: $id)
1972
+ `}},revokeDeckTokenIssuer(){return {query:`
1973
+ mutation DeckTokenIssuerRevoke($id: UUID!) {
1974
+ deckTokenIssuerRevoke(id: $id)
1872
1975
  }
1873
- `}},revokeDeckAccessTokenIssuerSigningKey(){return {query:`
1874
- mutation DeckAccessTokenIssuerSigningKeyRevoke($id: UUID!) {
1875
- deckAccessTokenIssuerSigningKeyRevoke(id: $id) {
1876
- ${P}
1976
+ `}},revokeDeckTokenIssuerSigningKey(){return {query:`
1977
+ mutation DeckTokenIssuerSigningKeyRevoke($id: UUID!) {
1978
+ deckTokenIssuerSigningKeyRevoke(id: $id) {
1979
+ ${ie}
1877
1980
  }
1878
1981
  }
1879
- `}},exchangeDeckAccessToken(){return {query:`
1880
- mutation DeckAccessTokenExchange($input: DeckAccessTokenExchangeInput!) {
1881
- deckAccessTokenExchange(input: $input) {
1982
+ `}},exchangeDeckToken(){return {query:`
1983
+ mutation DeckTokenExchange($input: DeckTokenExchangeInput!) {
1984
+ deckTokenExchange(input: $input) {
1882
1985
  token
1883
- accessToken {
1884
- ${Te}
1986
+ deckToken {
1987
+ ${Le}
1885
1988
  }
1886
1989
  }
1887
1990
  }
1888
- `}},exchangeDeckSessionToken(){return {query:`
1889
- mutation DeckSessionTokenExchange($input: DeckSessionTokenExchangeInput!) {
1890
- deckSessionTokenExchange(input: $input) {
1891
- token
1892
- sessionToken {
1893
- id
1894
- accountId
1895
- apiApplicationId
1896
- gameId
1897
- environment
1898
- externalSubject
1899
- scopes
1900
- expiresAt
1901
- revokedAt
1902
- lastUsedAt
1903
- createdAt
1904
- updatedAt
1905
- }
1906
- }
1907
- }
1908
- `}},grantDeckApiApplicationAccess(){return {query:`
1991
+ `}},revokeDeckToken(){return {query:`
1992
+ mutation DeckTokenRevoke($id: UUID!) {
1993
+ deckTokenRevoke(id: $id)
1994
+ }
1995
+ `}},grantDeckApiApplicationAccess(){return {query:`
1909
1996
  mutation DeckApiApplicationAccessGrant($input: DeckAPIApplicationAccessGrantInput!) {
1910
1997
  deckApiApplicationAccessGrant(input: $input) {
1911
- ${L}
1998
+ ${M}
1912
1999
  }
1913
2000
  }
1914
2001
  `}},revokeDeckApiApplicationAccess(){return {query:`
1915
2002
  mutation DeckApiApplicationAccessRevoke($deckId: UUID!, $apiApplicationId: UUID!) {
1916
2003
  deckApiApplicationAccessRevoke(deckId: $deckId, apiApplicationId: $apiApplicationId)
1917
2004
  }
1918
- `}},revokeDeckAccessToken(){return {query:`
1919
- mutation DeckAccessTokenRevoke($id: UUID!) {
1920
- deckAccessTokenRevoke(id: $id)
1921
- }
1922
- `}},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}},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}},deckPreviewTokenCreateVariables(e){return {input:e}},deckEmbedTokenCreateVariables(e){return {input:e}},deckAccessTokenIssuerCreateVariables(e){return {input:e}},deckAccessTokenExchangeVariables(e){return {input:e}},deckSessionTokenExchangeVariables(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:`
1923
2006
  query FetchMe {
1924
2007
  fetchMe {
1925
2008
  application {
@@ -1941,6 +2024,6 @@ ${ie}`:n;return {query:`
1941
2024
  }
1942
2025
  }
1943
2026
  }
1944
- `}}},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 Qe="https://carddb.dev/query",Ze=3e4,et=1e4,tt=300,rt=3,st=2,it=1e3,at=3e4,nt=class Ie{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??Qe,this.timeout=t.timeout??Ze,this.openTimeout=t.openTimeout??et,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??rt,this.retryOnNetworkError=t.retryOnNetworkError??true,this.maxNetworkRetries=t.maxNetworkRetries??st,this.retryBaseDelay=t.retryBaseDelay??it,this.retryMaxDelay=t.retryMaxDelay??at,this.cache=t.cache,this.cacheTtl=t.cacheTtl??tt,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 $(`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 $(`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 $(`${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 Ie({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})}},be="0.4.1";function ct(){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?ot(navigator.userAgent):{name:"unknown",version:"unknown"}}function ot(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 ut(){let e=ct();return `CardDB-SDK/js/${be} (${e.name}/${e.version})`}function fr(){return be}var $e=null;function lt(){return $e}var dt=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 K&&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 O&&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 x||e instanceof G}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":ut(),...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 G("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 M("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 O(`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 M(s,t);case "RATE_LIMITED":throw new K(s,{response:t});case "NOT_FOUND":throw new y(s,t);case "VALIDATION_ERROR":case "BAD_USER_INPUT":throw new J(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,i=parseInt(e.headers.get("X-RateLimit-Reset")??"",10)||null,n=i?new Date(i*1e3):null,c=await this.parseBody(e);throw new K("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 J(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;$e={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 ht(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 yt(e,t){let r=e.get(t);return r}async function ft(e,t,r,s){let i=e.set(t,r,s);i instanceof Promise&&await i;}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 i=r.cache??!!this.config.cache,n=this.config.cache;if(!i||!n)return s();let c=await yt(n,e);if(c!==null)return c;let o=await s();if(o!=null){let h=this.config.cacheTtlFor(t);await ft(n,e,o,h);}return o}cacheKey(e,t,r){return ht(e,t,r)}},pt=class extends f{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)}},mt=class extends f{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??[]})}},gt=class extends f{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??[]})}},kt=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}=a.fetchDeckById();return (await this.connection.execute(s,{id:e})).fetchDeck??null})}async get(e,t={}){let r=this.cacheKey("decks","get",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckById();return (await this.connection.execute(s,{id:e})).deck??null})}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=this.cacheKey("decks","getByExternalRef",{externalRef:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckByExternalRef();return (await this.connection.execute(s,{externalRef:e})).deckByExternalRef??null})}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 preview(e,t={}){let r=this.cacheKey("decks","preview",{token:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckPreview();return (await this.connection.execute(s,{token:e})).deckPreview??null})}async embed(e,t={}){let r=this.cacheKey("decks","embed",{token:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckEmbed();return (await this.connection.execute(s,{token:e})).deckEmbed??null})}async access(e,t={}){let r=this.cacheKey("decks","access",{token:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckAccess();return (await this.connection.execute(s,{token:e})).deckAccess??null})}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 listPreviewTokens(e,t={}){let r=this.cacheKey("decks","listPreviewTokens",{deckId:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckPreviewTokens();return (await this.connection.execute(s,{deckId:e})).deckPreviewTokens})}async listEmbedTokens(e,t={}){let r=this.cacheKey("decks","listEmbedTokens",{deckId:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckEmbedTokens();return (await this.connection.execute(s,{deckId:e})).deckEmbedTokens})}async listAccessTokenIssuers(e,t={}){let r=this.cacheKey("decks","listAccessTokenIssuers",{deckId:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckAccessTokenIssuers();return (await this.connection.execute(s,{deckId:e})).deckAccessTokenIssuers})}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 createPreviewToken(e){let{query:t}=a.createDeckPreviewToken(),r=a.deckPreviewTokenCreateVariables(e);return (await this.connection.execute(t,r)).deckPreviewTokenCreate}async revokePreviewToken(e){let{query:t}=a.revokeDeckPreviewToken();return !!(await this.connection.execute(t,{id:e})).deckPreviewTokenRevoke}async createEmbedToken(e){let{query:t}=a.createDeckEmbedToken(),r=a.deckEmbedTokenCreateVariables(e);return (await this.connection.execute(t,r)).deckEmbedTokenCreate}async revokeEmbedToken(e){let{query:t}=a.revokeDeckEmbedToken();return !!(await this.connection.execute(t,{id:e})).deckEmbedTokenRevoke}async createAccessTokenIssuer(e){let{query:t}=a.createDeckAccessTokenIssuer(),r=a.deckAccessTokenIssuerCreateVariables(e);return (await this.connection.execute(t,r)).deckAccessTokenIssuerCreate}async revokeAccessTokenIssuer(e){let{query:t}=a.revokeDeckAccessTokenIssuer();return !!(await this.connection.execute(t,{id:e})).deckAccessTokenIssuerRevoke}async revokeAccessTokenIssuerSigningKey(e){let{query:t}=a.revokeDeckAccessTokenIssuerSigningKey();return (await this.connection.execute(t,{id:e})).deckAccessTokenIssuerSigningKeyRevoke}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 exchangeAccessToken(e){this.config.requireSecretCredential("decks.exchangeAccessToken");let{query:t}=a.exchangeDeckAccessToken(),r=a.deckAccessTokenExchangeVariables(e);return (await this.connection.execute(t,r)).deckAccessTokenExchange}async exchangeSessionToken(e){this.config.requireSecretCredential("decks.exchangeSessionToken");let{query:t}=a.exchangeDeckSessionToken(),r=a.deckSessionTokenExchangeVariables(e);return (await this.connection.execute(t,r)).deckSessionTokenExchange}async revokeAccessToken(e){this.config.requireSecretCredential("decks.revokeAccessToken");let{query:t}=a.revokeDeckAccessToken();return !!(await this.connection.execute(t,{id:e})).deckAccessTokenRevoke}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=It(n,s,e.identifierField);return e.entries.map(o=>({...o,record:c.get(o.identifier)??null}))}};function It(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 bt=class extends f{constructor(e,t){super(e,t);}async list(e){let t=U(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=U(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??[]})}},$t=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: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=U(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),w=await this.withCache(h,"records",t,async()=>(await this.connection.execute(c,o)).searchRecords);return new l(w,{nextPageLoader:async X=>this.searchRuleRecords(e,{...t,after:X})})}},vt=class extends f{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}},Dt=class extends f{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??wt());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 wt(){return {totalCount:0,pageInfo:{hasNextPage:false,hasPreviousPage:false,startCursor:null,endCursor:null},edges:[]}}var St=class extends f{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));}}},At=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}=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??xt(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 Et(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 Et(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 xt(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 qt=class extends f{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(;;){Kt(t.signal);let o=await this.getJob(e,{cache:false});if(!o)throw new Error(`Scan job '${e}' was not found`);if(Rt(o.status))return o;let h=Date.now()-n,w=r-h;if(w<=0)throw new Error(`Timed out waiting for scan job '${e}'`);await Ct(Math.min(c,w)),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=Ut(),r=await t.importKey("raw",ve(e.secret),{name:"HMAC",hash:"SHA-256"},false,["sign"]),s=await t.sign("HMAC",r,Ft(e.body)),i=`sha256=${Pt(new Uint8Array(s))}`;return Lt(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 Rt(e){let t=e.toLowerCase();return t==="completed"||t==="failed"||t==="cancelled"}async function Ct(e){return new Promise(t=>setTimeout(t,e))}function Kt(e){if(e&&(e.throwIfAborted&&e.throwIfAborted(),e.aborted))throw new Error("Scan job polling aborted")}function Ut(){let t=globalThis.crypto?.subtle;if(!t)throw new Error("Web Crypto HMAC support is not available in this runtime");return t}function Ft(e){return typeof e=="string"?ve(e):e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function ve(e){return new TextEncoder().encode(e)}function Pt(e){return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}function Lt(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 Vt=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}=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:_t(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 _t(e){let t={...e};return delete t.id,t}var De=class we{config;connection;publishers;games;datasets;records;decks;rules;importFormats;imports;exports;files;scans;scanTemplates;constructor(t={}){this.config=new nt(t),this.connection=new dt(this.config),this.publishers=new pt(this.connection,this.config),this.games=new mt(this.connection,this.config),this.datasets=new gt(this.connection,this.config),this.records=new bt(this.connection,this.config),this.decks=new kt(this.connection,this.config),this.rules=new $t(this.connection,this.config),this.importFormats=new vt(this.connection,this.config),this.imports=new Dt(this.connection,this.config),this.exports=new St(this.connection,this.config),this.files=new At(this.connection,this.config),this.scans=new qt(this.connection,this.config),this.scanTemplates=new Vt(this.connection,this.config);}async me(){let{query:t}=a.fetchMe();return (await this.connection.execute(t)).fetchMe??null}getRateLimitInfo(){return lt()}withConfig(t){let r=this.config.merge(t);return new we({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 W=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 Se=class extends De{constructor(t={}){if("apiKey"in t&&t.apiKey!==void 0)throw new $("apiKey is not accepted in browsers; use publishableKey or accessToken");if("secretKey"in t&&t.secretKey!==void 0)throw new $("secretKey is server-only; use publishableKey or accessToken in browsers");super(t);}};
1945
- export{M as AuthenticationError,f as BaseResource,W as BrowserCache,Se as CardDBClient,y as CardDBError,l as Collection,nt as Configuration,dt as Connection,x as ConnectionError,tt as DEFAULT_CACHE_TTL,Qe as DEFAULT_ENDPOINT,st as DEFAULT_MAX_NETWORK_RETRIES,rt as DEFAULT_MAX_RETRIES,et as DEFAULT_OPEN_TIMEOUT,it as DEFAULT_RETRY_BASE_DELAY,at as DEFAULT_RETRY_MAX_DELAY,Ze as DEFAULT_TIMEOUT,gt as DatasetsResource,kt as DecksResource,St as ExportsResource,At as FilesResource,Ae as FilterBuilder,mt as GamesResource,ce as GraphQLError,vt as ImportFormatsResource,Dt as ImportsResource,Mt as LinkResolutionError,Bt as NotFoundError,pt as PublishersResource,a as QueryBuilder,K as RateLimitError,bt as RecordsResource,$ as RestrictedError,$t as RulesResource,Vt as ScanTemplatesResource,qt as ScansResource,O as ServerError,G as TimeoutError,J as ValidationError,ht as cacheKey,Wt as contains,Jt as eq,lt as getRateLimitInfo,fr as getSDKVersion,ut as getUserAgent,Ot as gt,Nt as gte,Qt as ilike,er as isNotNull,Zt as isNull,Xt as like,jt as lt,Ht as lte,Gt as neq,zt as notWithin,yt as readCache,U as resolveFilter,Yt as within,ft 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
1946
2029
  //# sourceMappingURL=index.js.map