@flesh-and-blood/search 5.3.1 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,9 +11,10 @@ export declare const FilterCategory: {
11
11
  readonly Artist: "artist";
12
12
  readonly Banned: "banned";
13
13
  readonly Bond: "bond";
14
- readonly Chain: "chain";
15
14
  readonly Class: "class";
16
15
  readonly Cost: "cost";
16
+ readonly CreatedBy: "createdby";
17
+ readonly Creates: "creates";
17
18
  readonly Defense: "defense";
18
19
  readonly Flow: "flow";
19
20
  readonly Foiling: "foiling";
@@ -168,8 +169,9 @@ export interface FilterToPropertyMapping extends CardPropertyMapping {
168
169
  * It is not the set of spellings the parse accepts, which is wider, since
169
170
  * the foiling, treatment, rarity, legality and meta resolvers each take
170
171
  * abbreviations of their own. A filter reading free text (`artist`, `name`,
171
- * `text`, `typetext`), a card name (`chain`, `references`, `referencedby`),
172
- * a set identifier (`print`), a date (`year`) or a number carries none.
172
+ * `text`, `typetext`), a card name or group (`creates`, `createdby`,
173
+ * `references`, `referencedby`), a set identifier (`print`), a date
174
+ * (`year`) or a number carries none.
173
175
  */
174
176
  vocabulary?: readonly string[];
175
177
  }
@@ -274,12 +276,6 @@ export declare const filtersToCardPropertyMappings: {
274
276
  isArray: true;
275
277
  partialMatch: true;
276
278
  };
277
- chain: {
278
- category: "chain";
279
- canonicalAlias: string;
280
- kind: "partialMatch";
281
- property: "n/a";
282
- };
283
279
  co: {
284
280
  category: "cost";
285
281
  canonicalAlias: string;
@@ -298,6 +294,18 @@ export declare const filtersToCardPropertyMappings: {
298
294
  isNumber: true;
299
295
  partialMatch: true;
300
296
  };
297
+ createdby: {
298
+ category: "createdby";
299
+ canonicalAlias: string;
300
+ kind: "partialMatch";
301
+ property: "n/a";
302
+ };
303
+ creates: {
304
+ category: "creates";
305
+ canonicalAlias: string;
306
+ kind: "partialMatch";
307
+ property: "n/a";
308
+ };
301
309
  color: {
302
310
  category: "pitch";
303
311
  canonicalAlias: string;
@@ -457,6 +465,18 @@ export declare const filtersToCardPropertyMappings: {
457
465
  specialProperty: "specialLife";
458
466
  isNumber: true;
459
467
  };
468
+ madeby: {
469
+ category: "createdby";
470
+ canonicalAlias: string;
471
+ kind: "partialMatch";
472
+ property: "n/a";
473
+ };
474
+ makes: {
475
+ category: "creates";
476
+ canonicalAlias: string;
477
+ kind: "partialMatch";
478
+ property: "n/a";
479
+ };
460
480
  meta: {
461
481
  category: "is";
462
482
  canonicalAlias: string;
@@ -23,9 +23,10 @@ const FilterCategory = {
23
23
  Artist: "artist",
24
24
  Banned: "banned",
25
25
  Bond: "bond",
26
- Chain: "chain",
27
26
  Class: "class",
28
27
  Cost: "cost",
28
+ CreatedBy: "createdby",
29
+ Creates: "creates",
29
30
  Defense: "defense",
30
31
  Flow: "flow",
31
32
  Foiling: "foiling",
@@ -102,12 +103,6 @@ const bondFilter = {
102
103
  property: "bonds",
103
104
  isArray: true
104
105
  };
105
- const chainFilter = {
106
- category: FilterCategory.Chain,
107
- canonicalAlias: "chain",
108
- kind: FilterKind.PartialMatch,
109
- property: NO_CARD_PROPERTY
110
- };
111
106
  const classFilter = {
112
107
  category: FilterCategory.Class,
113
108
  canonicalAlias: "c",
@@ -126,6 +121,18 @@ const costFilter = {
126
121
  isNumber: true,
127
122
  partialMatch: true
128
123
  };
124
+ const createdByFilter = {
125
+ category: FilterCategory.CreatedBy,
126
+ canonicalAlias: "createdby",
127
+ kind: FilterKind.PartialMatch,
128
+ property: NO_CARD_PROPERTY
129
+ };
130
+ const createsFilter = {
131
+ category: FilterCategory.Creates,
132
+ canonicalAlias: "creates",
133
+ kind: FilterKind.PartialMatch,
134
+ property: NO_CARD_PROPERTY
135
+ };
129
136
  const defenseFilter = {
130
137
  category: FilterCategory.Defense,
131
138
  canonicalAlias: "d",
@@ -358,9 +365,10 @@ const filtersToCardPropertyMappings = {
358
365
  bonds: bondFilter,
359
366
  c: classFilter,
360
367
  class: classFilter,
361
- chain: chainFilter,
362
368
  co: costFilter,
363
369
  cost: costFilter,
370
+ createdby: createdByFilter,
371
+ creates: createsFilter,
364
372
  color: pitchFilter,
365
373
  d: defenseFilter,
366
374
  def: defenseFilter,
@@ -381,6 +389,8 @@ const filtersToCardPropertyMappings = {
381
389
  hero: legalFilter,
382
390
  li: lifeFilter,
383
391
  life: lifeFilter,
392
+ madeby: createdByFilter,
393
+ makes: createsFilter,
384
394
  meta: metaFilter,
385
395
  n: nameFilter,
386
396
  name: nameFilter,
@@ -4,8 +4,7 @@ import {
4
4
  Rarity,
5
5
  Release,
6
6
  setIdentifierToSetMappings,
7
- Treatment,
8
- Type
7
+ Treatment
9
8
  } from "@flesh-and-blood/types";
10
9
  import {
11
10
  FilterCategory,
@@ -15,11 +14,6 @@ import {
15
14
  } from "./filterMappings.js";
16
15
  import { getNormalizedFilterValue, getTextWithoutMarkup } from "./helpers.js";
17
16
  import { getMetaFilterResolution } from "./metaFilters.js";
18
- import {
19
- getCardsByName,
20
- getCardsReferencedBy,
21
- getCardsReferencing
22
- } from "./searchIndex.js";
23
17
  const getSharedModifier = (filterValues) => {
24
18
  const [firstValue] = filterValues;
25
19
  const firstModifier = firstValue?.modifier;
@@ -401,55 +395,28 @@ const cardIdentifierFilter = {
401
395
  isString: true,
402
396
  isNormalized: true
403
397
  };
404
- const CHAIN_EXPANSION_LIMIT = 20;
405
- const getChainedCardIdentifiers = (index, names) => {
406
- const cardIdentifiers = /* @__PURE__ */ new Set();
407
- const cardsToExpand = [];
408
- const namesToExpand = /* @__PURE__ */ new Set();
409
- const unresolvedValues = [];
410
- const addToChain = (card) => {
411
- cardIdentifiers.add(card.cardIdentifier);
412
- if (!namesToExpand.has(card.name)) {
413
- namesToExpand.add(card.name);
414
- cardsToExpand.push(card);
415
- }
416
- };
417
- const addRelatedCardToChain = (card) => {
418
- if (!card.types.includes(Type.Hero)) {
419
- addToChain(card);
420
- }
421
- };
422
- for (const name of names) {
423
- const seedCards = getCardsByName(index, name);
424
- for (const seedCard of seedCards) {
425
- addToChain(seedCard);
426
- }
427
- if (seedCards.length === 0) {
428
- unresolvedValues.push(name);
429
- }
398
+ const getCardsByNameOrGroup = (index, value) => {
399
+ let cards = index.getCardsByExactName(value);
400
+ if (cards.length === 0) {
401
+ cards = index.getCardsByGroup(value);
430
402
  }
431
- let expansions = 0;
432
- while (expansions < cardsToExpand.length && expansions <= CHAIN_EXPANSION_LIMIT) {
433
- const cardToExpand = cardsToExpand[expansions];
434
- for (const referencedCard of getCardsReferencedBy(index, cardToExpand)) {
435
- addRelatedCardToChain(referencedCard);
436
- }
437
- const isSeed = expansions === 0;
438
- if (isSeed) {
439
- for (const referencingCard of getCardsReferencing(index, cardToExpand)) {
440
- addRelatedCardToChain(referencingCard);
441
- }
442
- }
443
- expansions++;
403
+ if (cards.length === 0) {
404
+ cards = index.getCardsByName(value);
444
405
  }
445
- return { cardIdentifiers, unresolvedValues };
406
+ return cards;
446
407
  };
447
- const getRelatedCardIdentifiers = (index, name, isNamedByFilter) => {
408
+ const getRelatedCardIdentifiers = (index, value, readRelation) => {
448
409
  const relatedCardIdentifiers = /* @__PURE__ */ new Set();
449
- for (const namedCard of getCardsByName(index, name)) {
450
- const cardsInRelation = isNamedByFilter ? getCardsReferencedBy(index, namedCard) : getCardsReferencing(index, namedCard);
451
- for (const relatedCard of cardsInRelation) {
452
- relatedCardIdentifiers.add(relatedCard.cardIdentifier);
410
+ for (const card of getCardsByNameOrGroup(index, value)) {
411
+ for (const relatedCard of readRelation(index, card.cardIdentifier)) {
412
+ const isCycleAdded = relatedCardIdentifiers.has(
413
+ relatedCard.cardIdentifier
414
+ );
415
+ if (!isCycleAdded) {
416
+ for (const pitch of index.getPitchCycle(relatedCard.cardIdentifier)) {
417
+ relatedCardIdentifiers.add(pitch.cardIdentifier);
418
+ }
419
+ }
453
420
  }
454
421
  }
455
422
  return relatedCardIdentifiers;
@@ -482,11 +449,15 @@ const getCardIdentifiersFilter = (cardIdentifiers, isExcluded) => ({
482
449
  isExcluded,
483
450
  isOr: true
484
451
  });
485
- const getRelationResolution = ({ filterValues, isAnd, isExcluded }, getCardIdentifiersFromValue) => {
452
+ const getRelationResolver = (readRelation) => ({ filterValues, isAnd, isExcluded }, { index }) => {
486
453
  const cardIdentifiersByValue = [];
487
454
  const unresolvedValues = [];
488
455
  for (const { value } of filterValues) {
489
- const cardIdentifiers = getCardIdentifiersFromValue(value);
456
+ const cardIdentifiers = getRelatedCardIdentifiers(
457
+ index,
458
+ value,
459
+ readRelation
460
+ );
490
461
  cardIdentifiersByValue.push(cardIdentifiers);
491
462
  if (cardIdentifiers.size === 0) {
492
463
  unresolvedValues.push(value);
@@ -502,38 +473,39 @@ const getRelationResolution = ({ filterValues, isAnd, isExcluded }, getCardIdent
502
473
  unresolvedValues
503
474
  };
504
475
  };
505
- const getChainResolution = (term, { index }) => {
506
- const { cardIdentifiers, unresolvedValues } = getChainedCardIdentifiers(
507
- index,
508
- term.filterValues.map(({ value }) => value)
509
- );
510
- return {
511
- appliedFilters: [
512
- getCardIdentifiersFilter(cardIdentifiers, term.isExcluded)
513
- ],
514
- unresolvedValues
515
- };
516
- };
517
- const getReferencedByResolution = (term, { index }) => getRelationResolution(
518
- term,
519
- (value) => getRelatedCardIdentifiers(index, value, true)
520
- );
521
- const getReferencesResolution = (term, { index }) => getRelationResolution(
522
- term,
523
- (value) => getRelatedCardIdentifiers(index, value, false)
524
- );
525
476
  const resolverByFilterCategory = /* @__PURE__ */ new Map([
526
477
  [FilterCategory.Artist, getArtistResolution],
527
478
  [FilterCategory.Banned, getLegalityResolution],
528
- [FilterCategory.Chain, getChainResolution],
479
+ [
480
+ FilterCategory.CreatedBy,
481
+ getRelationResolver(
482
+ (index, cardIdentifier) => index.getCreates(cardIdentifier)
483
+ )
484
+ ],
485
+ [
486
+ FilterCategory.Creates,
487
+ getRelationResolver(
488
+ (index, cardIdentifier) => index.getCreatedBy(cardIdentifier)
489
+ )
490
+ ],
529
491
  [FilterCategory.Foiling, getFoilingResolution],
530
492
  [FilterCategory.Is, getMetaResolution],
531
493
  [FilterCategory.Legal, getLegalityResolution],
532
494
  [FilterCategory.Pitch, getPitchResolution],
533
495
  [FilterCategory.Print, getPrintResolution],
534
496
  [FilterCategory.Rarity, getRarityResolution],
535
- [FilterCategory.ReferencedBy, getReferencedByResolution],
536
- [FilterCategory.References, getReferencesResolution],
497
+ [
498
+ FilterCategory.ReferencedBy,
499
+ getRelationResolver(
500
+ (index, cardIdentifier) => index.getReferences(cardIdentifier)
501
+ )
502
+ ],
503
+ [
504
+ FilterCategory.References,
505
+ getRelationResolver(
506
+ (index, cardIdentifier) => index.getReferencedBy(cardIdentifier)
507
+ )
508
+ ],
537
509
  [FilterCategory.Set, getSetResolution],
538
510
  [FilterCategory.Treatment, getTreatmentResolution]
539
511
  ]);
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var Kt=Object.create;var le=Object.defineProperty;var _t=Object.getOwnPropertyDescriptor;var $t=Object.getOwnPropertyNames;var zt=Object.getPrototypeOf,Gt=Object.prototype.hasOwnProperty;var Wt=(e,t)=>{for(var r in t)le(e,r,{get:t[r],enumerable:!0})},Ye=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of $t(t))!Gt.call(e,a)&&a!==r&&le(e,a,{get:()=>t[a],enumerable:!(s=_t(t,a))||s.enumerable});return e};var Yt=(e,t,r)=>(r=e!=null?Kt(zt(e)):{},Ye(t||!e||!e.__esModule?le(r,"default",{value:e,enumerable:!0}):r,e)),qt=e=>Ye(le({},"__esModule",{value:!0}),e);var Ls={};Wt(Ls,{FilterCategory:()=>l,FilterKind:()=>m,FilterProperty:()=>G,MARKUP:()=>Me,NO_CARD_PROPERTY:()=>K,PUNCTUATION:()=>k,RARITY_VALUES_MAPPING:()=>De,aliasesByFilterCategory:()=>J,availableExclusions:()=>_,availableModifiers:()=>Se,default:()=>Ht,filterCard:()=>jt,filtersToCardPropertyMappings:()=>Z,getCardsByName:()=>ye,getCardsReferencedBy:()=>Ce,getCardsReferencing:()=>me,getCatalogueIndex:()=>we,getCleanText:()=>B,getEscapedForRegExp:()=>X,getExcludedMetaFilters:()=>Ie,getFilterCategory:()=>re,getFilterMapping:()=>ge,getFilterTokenSpansForKey:()=>us,getFilterValue:()=>je,getIncompleteFilterToken:()=>He,getIsExcludedToken:()=>ps,getIsValueInFilterVocabulary:()=>ke,getKeywordsAndAppliedFiltersFromText:()=>Bs,getMetaFilterResolution:()=>se,getMetaFilters:()=>fr,getNormalizedFilterValue:()=>V,getNormalizedText:()=>z,getParsedQuery:()=>ie,getQueryFilterToken:()=>Fe,getQueryTokenSpans:()=>he,getQuotedValue:()=>fs,getResolvedFilterKey:()=>Qe,getSuggestedFilterKey:()=>Ve,getTextWithoutMarkup:()=>q,getTokensReferencedByCards:()=>Os,getUnquotedValue:()=>Te,getValuePartsFromFilterValue:()=>Ot,getValuesFromFilterValue:()=>Ue,multiWordShorthands:()=>_e,shorthands:()=>Ke,singleWordShorthands:()=>$e});module.exports=qt(Ls);var xe=require("@flesh-and-blood/types"),We=Yt(require("fuse.js"),1);var k=/[!"#$%&'’(),./:;<=>?@[\]^_`|~]/g,Me=/\*/g;var T=require("@flesh-and-blood/types");var B=e=>z(e.toLowerCase().trim().replace(k,"")),z=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,""),V=e=>e.toLowerCase().replace(k,""),q=e=>e.replace(Me,""),X=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&");var l={Arcane:"arcane",Artist:"artist",Banned:"banned",Bond:"bond",Chain:"chain",Class:"class",Cost:"cost",Defense:"defense",Flow:"flow",Foiling:"foiling",Fusion:"fusion",Intellect:"intellect",Is:"is",Keyword:"keyword",Legal:"legal",Life:"life",Name:"name",Pitch:"pitch",Power:"power",Print:"print",Rarity:"rarity",ReferencedBy:"referencedby",References:"references",Set:"set",Shorthand:"shorthand",Specialization:"specialization",Subtype:"subtype",Talent:"talent",Text:"text",Trait:"trait",Treatment:"treatment",Type:"type",TypeText:"typetext",Year:"year"},m={Comparator:"comparator",ExactMatch:"exactMatch",PartialMatch:"partialMatch"},Se=[">=",">","<=","<"],_=["!","-"],K="n/a",gt=[...Object.values(T.Format),...Object.values(T.Hero)],Xt={category:l.Arcane,canonicalAlias:"arcane",kind:m.Comparator,property:"arcane",specialProperty:"specialArcane",isNumber:!0,partialMatch:!0},be={category:l.Artist,canonicalAlias:"art",kind:m.PartialMatch,property:"artists",isArray:!0,partialMatch:!0},qe={category:l.Banned,canonicalAlias:"banned",kind:m.ExactMatch,vocabulary:gt,property:K,isMeta:!0},Xe={category:l.Bond,canonicalAlias:"bond",kind:m.ExactMatch,vocabulary:Object.values(T.Bond),property:"bonds",isArray:!0},Zt={category:l.Chain,canonicalAlias:"chain",kind:m.PartialMatch,property:K},Ze={category:l.Class,canonicalAlias:"c",kind:m.PartialMatch,vocabulary:Object.values(T.Class),property:"classes",isArray:!0,partialMatch:!0},Je={category:l.Cost,canonicalAlias:"co",kind:m.Comparator,property:"cost",specialProperty:"specialCost",isNumber:!0,partialMatch:!0},te={category:l.Defense,canonicalAlias:"d",kind:m.Comparator,property:"defense",specialProperty:"specialDefense",isNumber:!0},et={category:l.Flow,canonicalAlias:"flow",kind:m.ExactMatch,vocabulary:Object.values(T.Flow),property:"flows",isArray:!0},tt={category:l.Foiling,canonicalAlias:"foil",kind:m.ExactMatch,vocabulary:Object.values(T.Foiling),nestedProperty:"foiling",property:"printings",isArray:!0},rt={category:l.Fusion,canonicalAlias:"f",kind:m.ExactMatch,vocabulary:Object.values(T.Fusion),property:"fusions",isArray:!0},st={category:l.Intellect,canonicalAlias:"i",kind:m.Comparator,property:"intellect",isNumber:!0},at={category:l.Keyword,canonicalAlias:"k",kind:m.ExactMatch,vocabulary:Object.values(T.Keyword),property:"keywords",isArray:!0},Ae={category:l.Legal,canonicalAlias:"l",kind:m.ExactMatch,vocabulary:gt,property:K,isMeta:!0},it={category:l.Life,canonicalAlias:"li",kind:m.Comparator,property:"life",specialProperty:"specialLife",isNumber:!0},nt={category:l.Is,canonicalAlias:"is",kind:m.ExactMatch,vocabulary:Object.values(T.Meta),property:"meta",isArray:!0},ot={category:l.Name,canonicalAlias:"name",kind:m.PartialMatch,property:"name",isString:!0,partialMatch:!0},Pe={category:l.Pitch,canonicalAlias:"p",kind:m.Comparator,property:"pitch",isNumber:!0},de={category:l.Power,canonicalAlias:"pwr",kind:m.Comparator,property:"power",specialProperty:"specialPower",isNumber:!0},ce={category:l.Print,canonicalAlias:"print",kind:m.PartialMatch,property:"setIdentifiers",isArray:!0,partialMatch:!0},lt={category:l.Rarity,canonicalAlias:"r",kind:m.ExactMatch,vocabulary:Object.values(T.Rarity),property:K,isMeta:!0},Jt={category:l.ReferencedBy,canonicalAlias:"referencedby",kind:m.PartialMatch,property:K},er={category:l.References,canonicalAlias:"references",kind:m.PartialMatch,property:K},dt={category:l.Set,canonicalAlias:"s",kind:m.PartialMatch,vocabulary:Object.values(T.Release),property:"sets",isArray:!0,partialMatch:!0},ve={category:l.Shorthand,canonicalAlias:"short",kind:m.PartialMatch,vocabulary:Object.values(T.Shorthand),property:"shorthands",isArray:!0,partialMatch:!0},pe={category:l.Specialization,canonicalAlias:"sp",kind:m.PartialMatch,vocabulary:Object.values(T.Hero),property:"specializations",isArray:!0,partialMatch:!0},ct={category:l.Subtype,canonicalAlias:"st",kind:m.ExactMatch,vocabulary:Object.values(T.Subtype),property:"subtypes",isArray:!0},pt={category:l.Type,canonicalAlias:"t",kind:m.ExactMatch,vocabulary:Object.values(T.Type),property:"types",isArray:!0},Re={category:l.Talent,canonicalAlias:"tal",kind:m.ExactMatch,vocabulary:Object.values(T.Talent),property:"talents",isArray:!0},tr={category:l.Text,canonicalAlias:"text",kind:m.PartialMatch,property:"functionalText",hasMarkup:!0,isString:!0,partialMatch:!0},rr={category:l.Trait,canonicalAlias:"trait",kind:m.PartialMatch,vocabulary:Object.values(T.Trait),property:"traits",isArray:!0,partialMatch:!0},ut={category:l.TypeText,canonicalAlias:"x",kind:m.PartialMatch,property:"typeText",isString:!0,partialMatch:!0},ue={category:l.Treatment,canonicalAlias:"treatment",kind:m.ExactMatch,vocabulary:Object.values(T.Treatment),nestedProperty:"treatments",property:"printings",isArray:!0,isNestedPropertyArray:!0},sr={category:l.Year,canonicalAlias:"year",kind:m.PartialMatch,property:"firstReleaseDate",isString:!0,partialMatch:!0},Z={arcane:Xt,a:be,artist:be,art:be,attack:de,b:te,block:te,banned:qe,bond:Xe,bonds:Xe,c:Ze,class:Ze,chain:Zt,co:Je,cost:Je,color:Pe,d:te,def:te,defense:te,flow:et,flows:et,f:rt,fusion:rt,foil:tt,foiling:tt,i:st,intellect:st,is:nt,k:at,keyword:at,l:Ae,legal:Ae,hero:Ae,li:it,life:it,meta:nt,n:ot,name:ot,p:Pe,pitch:Pe,pwr:de,pow:de,power:de,print:ce,printing:ce,printings:ce,prints:ce,r:lt,rarity:lt,referencedby:Jt,references:er,rf:qe,s:dt,set:dt,short:ve,shorthand:ve,shorthands:ve,sp:pe,spec:pe,specialization:pe,specializations:pe,st:ct,subtype:ct,t:pt,type:pt,tal:Re,talent:Re,talents:Re,text:tr,trait:rr,treat:ue,treatment:ue,var:ue,variation:ue,x:ut,typetext:ut,year:sr},ar=new Map(Object.entries(Z)),ge=e=>ar.get(e.toLowerCase()),re=e=>ge(e)?.category,ir=()=>{let e=Object.create(null);for(let[t,{category:r}]of Object.entries(Z)){let s=e[r];s?s.push(t):e[r]=[t]}return e},J=ir(),nr=()=>{let e=new Map,t=new Set,r=Object.values(Z);for(let s of r){let{vocabulary:a}=s;if(a&&!t.has(s)){t.add(s);for(let i of a){let n=V(i),o=e.get(n);o?o.push(s):e.set(n,[s])}}}return e},ft=nr(),ke=(e,t)=>!!ft.get(V(t))?.some(r=>r.category===e),or=(e,t)=>{let r=[],s=!0;for(let a of t){let i=(ft.get(V(a))||[]).filter(n=>n.category!==e);r=s?i:r.filter(n=>i.includes(n)),s=!1}return r},Ve=(e,t)=>{let r=or(e,t),[s]=r;return r.length===1?s.canonicalAlias:void 0};var ae=require("@flesh-and-blood/types");var d=require("@flesh-and-blood/types");var E=require("@flesh-and-blood/types");var G={BannedFormats:"bannedFormats",LegalFormats:"legalFormats",LegalHeroes:"legalHeroes"},fe=Array.from(Array(50).keys()).map(e=>`${e}`),lr=[{format:E.Format.ClassicConstructed,nicknames:["cc","classic"]},{format:E.Format.LivingLegend,nicknames:["cc ll","classic constructed ll","ll cc","ll","living legend"]},{format:E.Format.SilverAge,nicknames:["sage"]},{format:E.Format.GoldenAge,nicknames:["gage"]},{format:E.Format.UltimatePitFight,nicknames:["upf"]}],dr=Object.values(E.Format).map(e=>{let t=lr.find(({format:s})=>s===e),r=e.toLowerCase().replaceAll(k,"");return t?{...t,format:r}:{format:r}}),cr=Object.values(E.Hero).map(B),yt=e=>e.replaceAll(" ",""),pr=(e,t)=>{let r=yt(e),s,a=[];for(let n of t){let o=yt(n);o===r?s=n:o.startsWith(r)&&a.push(n)}let i=a.length===1;return s??(i?a[0]:void 0)},mt=["common","rare","super rare","majestic","legendary","fabled"],ur=({modifier:e,value:t})=>{let r=[],s=e==="<"||e==="<=",a=e===">="||e==="<=",i=s?[...mt].reverse():mt,n=!1;for(let o of i)n?r.push(o):o===t&&(n=!0,a&&r.push(o));return r},gr=(e,t)=>{let r=[];for(let s of e)s.modifier?r.push(...ur(s)):r.push(s.value);return{filterToPropertyMapping:{nestedProperty:"rarity",property:"printings",isArray:!0},isExcluded:t,isOr:!0,values:r}},Ct=(e,t,r,s)=>{let a=new Set([...cr,...r.map(B)]),i=[],n=[],o=[],c=[];for(let{value:p}of e){let g=dr.find(({format:f,nicknames:C})=>f===p||!!C&&C.includes(p));if(g)n.push(g.format);else{let f=pr(p,a);f?o.push(f):c.push(p)}}return n.length>0&&i.push({filterToPropertyMapping:{property:s,isArray:!0},values:n,isOr:!0,isExcluded:t}),o.length>0&&i.push({filterToPropertyMapping:{property:G.LegalHeroes,isArray:!0},values:o,isOr:!0,isExcluded:t}),{appliedFilters:i,unresolvedValues:c}},se=(e,t,{additionalHeroes:r=[],isExcluded:s=!1}={})=>{let a=re(e),i={appliedFilters:[],unresolvedValues:[]};return a===l.Legal?i=Ct(t,s,r,G.LegalFormats):a===l.Banned?i=Ct(t,s,r,G.BannedFormats):a===l.Rarity&&(i={appliedFilters:[gr(t,s)],unresolvedValues:[]}),i},fr=(e,t,r,s,a,i)=>se(r,s.map(n=>({modifier:a,value:n})),{additionalHeroes:i,isExcluded:e}).appliedFilters,yr=[{filterToPropertyMapping:{property:"cost",isNumber:!0},isExcluded:!0,values:fe},{filterToPropertyMapping:{property:"specialCost",isString:!0,partialMatch:!0},isExcluded:!0,values:["*","x"]},{filterToPropertyMapping:{property:"types",isArray:!0,partialMatch:!0},isExcluded:!0,values:["equipment","hero","placeholder","token","weapon"]}],mr=[{filterToPropertyMapping:{property:"defense",isNumber:!0},isExcluded:!0,values:fe},{filterToPropertyMapping:{property:"specialDefense",isString:!0,partialMatch:!0},isExcluded:!0,values:["*","x"]},{filterToPropertyMapping:{property:"types",isArray:!0,partialMatch:!0},isExcluded:!0,values:["hero","placeholder","token","weapon"]}],Cr=[{filterToPropertyMapping:{property:"pitch",isNumber:!0},isExcluded:!0,values:fe},{filterToPropertyMapping:{property:"types",isArray:!0,partialMatch:!0},isExcluded:!0,values:["equipment","hero","placeholder","token","weapon"]},{filterToPropertyMapping:{property:"isCardBack",isBoolean:!0},isExcluded:!0,values:["true"]}],hr=[{filterToPropertyMapping:{property:"power",isNumber:!0},isExcluded:!0,values:fe},{filterToPropertyMapping:{property:"specialPower",isString:!0,partialMatch:!0},isExcluded:!0,values:["*","x"]},{filterToPropertyMapping:{property:"types",isArray:!0,partialMatch:!0},isExcluded:!0,values:["equipment","hero","placeholder","token"]}],Fr=[{filterToPropertyMapping:{property:"talents",isArray:!0},isExcluded:!0,values:Object.values(E.Talent).map(e=>e.toLowerCase())}],Tr=[{filterToPropertyMapping:{property:"classes",isArray:!0},isExcluded:!0,values:Object.values(E.Class).map(e=>e.toLowerCase())}],xr=[{category:l.Class,filters:Tr},{category:l.Cost,filters:yr},{category:l.Defense,filters:mr},{category:l.Pitch,filters:Cr},{category:l.Power,filters:hr},{category:l.Talent,filters:Fr}],Mr=()=>{let e=new Map;for(let{category:t,filters:r}of xr)for(let s of J[t])for(let a of _)e.set(`${a}${s}`,r);return e},br=Mr(),Ie=e=>{let t=[],r=br.get(e);return r&&t.push(...r),t};var W=require("@flesh-and-blood/types");var Ar=3,Pr=e=>{let t=z(e.toLowerCase()).replace(/[^a-z\s-]/g,""),r=new Set;for(let s of[/[\s-]+/,/\s+/]){let a="";for(let i of t.split(s)){let n=i.replaceAll("-","");n&&(a+=n[0])}a.length>=Ar&&r.add(a)}return[...r]},ht=e=>B(e).replaceAll("-",""),Ft=(e,t,r)=>{let s=e.get(t);s?s.push(r):e.set(t,[r])},Tt=new WeakMap,j=Object.freeze([]),vr=Number.MAX_SAFE_INTEGER,xt=(e,t)=>{let r=new Map;for(let s of e)for(let a of t(s)||[]){let i=r.get(a);i?i.push(s):r.set(a,[s])}return r},Rr=e=>{let t=new Map;for(let r of e){let s=r.types.includes(W.Type.Hero)&&!r.isCardBack,a=s?W.CardRole.Hero:(0,W.getCardRole)(r);if(s||a!==W.CardRole.Hero){let n=t.get(a);n?n.push(r):t.set(a,[r])}}return t},Sr=e=>{let t,r,s,a,i,n,o,c=()=>{if(!t){let u=new Map,y=new Map,h=[],F=new Map,M=0;for(let w of e){u.set(w.cardIdentifier,w),y.set(w.cardIdentifier,M),M++;let S=B(w.name),Y=F.get(S);Y?Y.push(w):(F.set(S,[w]),h.push(S))}t={cardByCardIdentifier:u,corpusPositionByCardIdentifier:y,cleanedNames:h,pitchCycleByCleanedName:F}}return t},p=u=>{let{corpusPositionByCardIdentifier:y}=c(),h=({cardIdentifier:F})=>y.get(F)??vr;return[...u].sort((F,M)=>h(F)-h(M))},g=u=>c().cardByCardIdentifier.get(u),f=u=>{let{cardByCardIdentifier:y}=c(),h=[];for(let F of u||[]){let M=y.get(F);M&&h.push(M)}return p(h)},C=u=>{let y=new Map;return h=>{let F=y.get(h);if(!F){let M=g(h),w=f(M&&u(M)),S=w.length>0;F=S?w:j,S&&y.set(h,F)}return F}},b=u=>{let{pitchCycleByCleanedName:y}=c(),h=g(u);return h?y.get(B(h.name))??j:j},D=u=>{let{cleanedNames:y,pitchCycleByCleanedName:h}=c(),F=B(u),M=h.get(F);if(!M&&F.length>0){let S=y.find(Y=>Y.includes(F));S&&(M=h.get(S))}return M??j},I=u=>{let{pitchCycleByCleanedName:y}=c();return y.get(B(u))??j},P=u=>{if(!n){n=new Map;for(let y of e)for(let h of y.nicknames??[])Ft(n,ht(h),y)}return n.get(ht(u))??j},O=u=>{if(!o){o=new Map;for(let y of e)for(let h of Pr(y.name))Ft(o,h,y)}return o.get(u)??j},N=()=>{if(!i){let u=new Set;for(let y of e)for(let h of y.artists)u.add(h);i=[...u].sort((y,h)=>y.localeCompare(h,"en",{sensitivity:"base"}))}return i},Q=C(({oppositeSideCardIdentifiers:u})=>u),U=C(({referencedCards:u})=>u),$=u=>(r||(r=xt(e,({referencedCards:y})=>y)),r.get(u)??j),H=C(({createdExtras:u})=>u);return{cards:e,getCard:g,getPitchCycle:b,getCardsByName:D,getCardsByExactName:I,getCardsByNickname:P,getCardsByInitials:O,getArtists:N,getOppositeSide:Q,getReferences:U,getReferencedBy:$,getCreates:H,getCreatedBy:u=>(s||(s=xt(e,({createdExtras:y})=>y)),s.get(u)??j),getCreatedClosure:u=>{let y=new Map,h=new Set,F=[...u];for(let M of F)if(!h.has(M)){h.add(M);for(let S of H(M))y.set(S.cardIdentifier,S),F.push(S.cardIdentifier)}return p([...y.values()])},getByRole:u=>(a||(a=Rr(e)),a.get(u)??j),getCardsInCorpusOrder:p}},we=e=>{let t=Tt.get(e);return t||(t=Sr(e),Tt.set(e,t)),t},Ee=(e,t)=>e.getPitchCycle(t.cardIdentifier),ye=(e,t)=>e.getCardsByName(t),Mt=(e,t)=>{let r=new Map;for(let s of t)for(let a of Ee(e,s))r.set(a.cardIdentifier,a);return e.getCardsInCorpusOrder([...r.values()])},me=(e,t)=>{let r=[];for(let s of Ee(e,t))r.push(...e.getReferencedBy(s.cardIdentifier));return Mt(e,r)},Ce=(e,t)=>{let r=[];for(let s of Ee(e,t))r.push(...e.getReferences(s.cardIdentifier));return Mt(e,r)};var kr=e=>{let[t]=e,r=t?.modifier;return e.every(({modifier:a})=>a===r)?r:void 0},Be=({filterValues:e,isAnd:t,isExcluded:r,mapping:s})=>{let a=[];for(let{value:i}of e)a.push(s.hasMarkup?q(i):i);return{filterToPropertyMapping:s,filterValues:e,isAnd:t,isExcluded:r,isOr:!t&&a.length>1,modifier:kr(e),values:a}},vt=({isAnd:e,isExcluded:t,mapping:r},s)=>({filterToPropertyMapping:r,isAnd:e,isExcluded:t,isOr:!e&&s.length>1,values:s}),Vr=({category:e,filterValues:t,mapping:r})=>{let s=[];if(r.kind===m.ExactMatch&&!!r.vocabulary)for(let{value:i}of t)ke(e,i)||s.push(i);return s},Ir=e=>({appliedFilters:[Be(e)],unresolvedValues:Vr(e)}),Oe=({isExcluded:e},t,r)=>e?void 0:{[t]:r},Rt=(e,t)=>({appliedFilters:[Be(e)],attributes:Oe(e,t,e.filterValues.map(({value:r})=>r)),unresolvedValues:[]}),wr=e=>Rt(e,"artists"),Er=e=>Rt(e,"prints"),Le=(e,t,r)=>{let s=[],a=[],i=[];for(let{value:n}of e.filterValues){let o=r(n);if(o.length>0)for(let c of o)s.push(c),a.push(V(c));else i.push(n)}return{appliedFilters:[vt(e,a)],attributes:Oe(e,t,s),canonicalValues:a,unresolvedValues:i}},Nr=new Map(Object.entries({purple:4,blue:3,yellow:2,red:1,white:0})),Br=e=>{let t=[],r=[];for(let{modifier:s,value:a}of e.filterValues){let i=Nr.get(a),n=i===void 0?a:`${i}`;t.push({modifier:s,value:n}),r.push(n)}return{appliedFilters:[Be({...e,filterValues:t})],canonicalValues:r,unresolvedValues:[]}},Ne=new Map;for(let e of Object.values(d.Release)){let t=V(e),r=Ne.get(t);if(r===void 0)Ne.set(t,e);else throw new Error(`${r} and ${e} are one name as a filter reads it, so a set filter naming it could reach either`)}var bt=(e,t)=>{let r=e.get(t);return r?[r]:[]},Or=(e,t)=>{let r=[()=>bt(Ne,e),()=>bt(d.setIdentifierToSetMappings,e),()=>Object.values(d.Release).filter(a=>a.toLowerCase().includes(e)),()=>{let a=t.find(i=>V(i)===e);return a?[a]:[]}],s=[];for(let a of r)s.length===0&&s.push(...a());return s},Lr=(e,{additionalSets:t})=>Le(e,"releases",r=>Or(r,t)),Dr=new Map(Object.entries({r:d.Foiling.Rainbow,rf:d.Foiling.Rainbow,rainbow:d.Foiling.Rainbow,c:d.Foiling.Cold,cf:d.Foiling.Cold,cold:d.Foiling.Cold,g:d.Foiling.Gold,gf:d.Foiling.Gold,gold:d.Foiling.Gold})),Qr=e=>{let t=Dr.get(e);return t?[t]:[]},Hr=e=>Le(e,"foilings",Qr),St=new Map(Object.entries({aa:d.Treatment.AA,alt:d.Treatment.AA,"alt art":d.Treatment.AA,ab:d.Treatment.AB,"alt border":d.Treatment.AB,at:d.Treatment.AT,"alt text":d.Treatment.AT,ea:d.Treatment.EA,extended:d.Treatment.EA,"extended art":d.Treatment.EA,fa:d.Treatment.FA,full:d.Treatment.FA,"full art":d.Treatment.FA}));for(let e of Object.values(d.Treatment))St.set(e.toLowerCase(),e);var jr=new Map(Object.entries(d.Treatment)),Ur=e=>{let t=St.get(e)||jr.get(e.toUpperCase());return t?[t]:[]},Kr=e=>Le(e,"treatments",Ur),De=new Map(Object.entries({b:d.Rarity.Basic,c:d.Rarity.Common,f:d.Rarity.Fabled,l:d.Rarity.Legendary,m:d.Rarity.Majestic,p:d.Rarity.Promo,r:d.Rarity.Rare,s:d.Rarity.SuperRare,t:d.Rarity.Token,v:d.Rarity.Marvel})),_r=e=>De.get(e)||Object.values(d.Rarity).find(t=>t.toLowerCase()===e),$r=(e,{additionalHeroes:t})=>{let r=[],s=[],a=[],i=[];for(let{modifier:o,value:c}of e.filterValues){let p=_r(c);p?(r.push(p),s.push(p.toLowerCase()),a.push({modifier:o,value:p.toLowerCase()})):(i.push(c),a.push({modifier:o,value:c}))}let{appliedFilters:n}=se(e.key,a,{additionalHeroes:t,isExcluded:e.isExcluded});return{appliedFilters:n,attributes:Oe(e,"rarities",r),canonicalValues:s,unresolvedValues:i}},At=({filterValues:e,isExcluded:t,key:r},{additionalHeroes:s})=>{let{appliedFilters:a,unresolvedValues:i}=se(r,e,{additionalHeroes:s,isExcluded:t}),n=[];for(let{values:o}of a)n.push(...o);return{appliedFilters:a,canonicalValues:n,unresolvedValues:i}},zr=["unique"],Gr=["preview","spoiler","unreleased"],Wr=["released"],Pt={property:"firstReleaseDate",isDate:!0},Yr=new Map(Object.entries({dual:d.Meta.DualClass,exp:d.Meta.Expansion,expansion:d.Meta.Expansion,rainbow:d.Meta.Rainbow,reprint:d.Meta.Reprint,reprints:d.Meta.Reprint})),qr=e=>{let t=[],r=[];for(let a of e){let i=Yr.get(a);i?t.push(i):r.push(a)}let s=[];if(t.length===0){let a=new Set;for(let i of Object.values(d.Meta)){let n=!1;for(let o of r)i.toLowerCase().includes(o)&&(n=!0,a.add(o));n&&t.push(i)}for(let i of r)a.has(i)||s.push(i)}else s.push(...r);return{unresolvedValues:s,values:t}},Xr=(e,{today:t})=>{let{filterValues:r,isAnd:s,isExcluded:a}=e,i=[],n=[],o=[],c=[],p=[];for(let{value:P}of r)zr.includes(P)?n.push(P):Gr.includes(P)?o.push(P):Wr.includes(P)?c.push(P):p.push(P);let g=!s&&r.length>1;n.length>0&&i.push({filterToPropertyMapping:Z.is,values:[V(d.Meta.Reprint)],isAnd:s,isOr:g,isExcluded:!a}),o.length>0&&i.push({filterToPropertyMapping:Pt,values:[t],isAnd:s,isOr:g,isExcluded:a}),c.length>0&&i.push({filterToPropertyMapping:Pt,values:[t],isAnd:s,isOr:g,isExcluded:!a});let{unresolvedValues:f,values:C}=qr(p),b=[...n,...o,...c,...C.map(V)];(p.length>0||i.length===0)&&i.push(vt(e,C.map(V)));let I=C.includes(d.Meta.Expansion)&&!a;return{appliedFilters:i,attributes:I?{isExpansionSlot:I}:void 0,canonicalValues:b,unresolvedValues:f}},Zr={property:"cardIdentifier",isString:!0,isNormalized:!0},Jr=20,es=(e,t)=>{let r=new Set,s=[],a=new Set,i=[],n=p=>{r.add(p.cardIdentifier),a.has(p.name)||(a.add(p.name),s.push(p))},o=p=>{p.types.includes(d.Type.Hero)||n(p)};for(let p of t){let g=ye(e,p);for(let f of g)n(f);g.length===0&&i.push(p)}let c=0;for(;c<s.length&&c<=Jr;){let p=s[c];for(let f of Ce(e,p))o(f);if(c===0)for(let f of me(e,p))o(f);c++}return{cardIdentifiers:r,unresolvedValues:i}},kt=(e,t,r)=>{let s=new Set;for(let a of ye(e,t)){let i=r?Ce(e,a):me(e,a);for(let n of i)s.add(n.cardIdentifier)}return s},ts=(e,t)=>{let r=new Set,[s=new Set,...a]=e;if(t)for(let i of s)a.every(o=>o.has(i))&&r.add(i);else for(let i of e)for(let n of i)r.add(n);return r},Vt=(e,t)=>({filterToPropertyMapping:Zr,values:[...e],valuesSet:e,isExcluded:t,isOr:!0}),It=({filterValues:e,isAnd:t,isExcluded:r},s)=>{let a=[],i=[];for(let{value:n}of e){let o=s(n);a.push(o),o.size===0&&i.push(n)}return{appliedFilters:[Vt(ts(a,t),r)],unresolvedValues:i}},rs=(e,{index:t})=>{let{cardIdentifiers:r,unresolvedValues:s}=es(t,e.filterValues.map(({value:a})=>a));return{appliedFilters:[Vt(r,e.isExcluded)],unresolvedValues:s}},ss=(e,{index:t})=>It(e,r=>kt(t,r,!0)),as=(e,{index:t})=>It(e,r=>kt(t,r,!1)),is=new Map([[l.Artist,wr],[l.Banned,At],[l.Chain,rs],[l.Foiling,Hr],[l.Is,Xr],[l.Legal,At],[l.Pitch,Br],[l.Print,Er],[l.Rarity,$r],[l.ReferencedBy,ss],[l.References,as],[l.Set,Lr],[l.Treatment,Kr]]),wt=(e,t)=>(is.get(e.category)||Ir)(e,t);var Nt=_.map(X).join(""),ns=/(?:[^\s"]+|"[^"]*(?:"|$))+/g,os=new RegExp(`^([${Nt}])?([A-Za-z]+):(.+)$`),ls=new RegExp(`^([${Nt}])?([A-Za-z]+):$`),ds=",",Et="+",cs='"',Bt=e=>{let t=[],r=!1,s="",a=!1;for(let i of e)i===cs?(a=!a,s+=i):!a&&(i===ds||i===Et)?(r=r||i===Et,s&&t.push(s),s=""):s+=i;return s&&t.push(s),{isAndList:r,parts:t}},he=e=>{let t=[];for(let r of e.matchAll(ns))t.push({end:r.index+r[0].length,start:r.index,token:r[0]});return t},ps=e=>_.some(t=>e.startsWith(t)),Fe=e=>{let t=e.match(os),r;if(t){let[,s,a,i]=t;r={isAndList:Bt(i).isAndList,isExcluded:!!s,key:a,valueText:i}}return r},He=e=>{let t=e.match(ls),r;return t&&(r={isAndList:!1,isExcluded:!!t[1],key:t[2],valueText:""}),r},je=e=>{let t=e.trim(),r=Se.find(s=>t.startsWith(s));return{modifier:r,value:r?t.slice(r.length).trim():t}},Qe=e=>re(e)??e.toLowerCase(),us=(e,t)=>{let r=Qe(t),s=[];for(let{end:a,start:i,token:n}of he(e)){let o=Fe(n);o&&Qe(o.key)===r&&s.push({...o,end:a,start:i,token:n})}return s},Ot=e=>Bt(e).parts,Te=e=>e.replace(/^"|"$/g,""),Ue=e=>{let t=[];for(let r of Ot(e)){let s=Te(r);s&&t.push(s)}return t},gs=/[\s,:+"]/,fs=e=>{let t=e.replaceAll('"',"");return gs.test(e)?`"${t}"`:t};var L=require("@flesh-and-blood/types"),Ke=[{description:"Attack actions",expanded:["st:attack"],filters:{subtypes:[L.Subtype.Attack]},isCardProperty:!1,shorthands:["AA"]},{description:"Arcane barrier",expanded:['k:"arcane barrier"'],filters:{keywords:[L.Keyword.ArcaneBarrier]},isCardProperty:!1,shorthands:["AB"]},{description:"Attack reactions",expanded:['t:"attack reaction"'],filters:{types:[L.Type.AttackReaction]},isCardProperty:!1,shorthands:["AR"]},{description:"Defense reactions",expanded:['t:"defense reaction"'],filters:{types:[L.Type.DefenseReaction]},isCardProperty:!1,shorthands:["DR"]},{description:"Gain life",expanded:["gain {h}"],filters:{functionalText:"gain {h}"},isCardProperty:!1,shorthands:["Gain life","Gains life"]},{description:"Go again",expanded:['k:"go again"'],filters:{keywords:[L.Keyword.GoAgain]},isCardProperty:!1,shorthands:["GA"]},{description:"Non-attack actions",expanded:["t:action","st:non-attack"],filters:{subtypes:[L.Subtype.NonAttack],types:[L.Type.Action]},isCardProperty:!1,shorthands:["NAA"]},{description:"Plus defense",expanded:["+ {d}"],filters:{functionalText:"+ {d}"},isCardProperty:!1,shorthands:["Pump defense","Pumps defense","Buff defense","Buffs defense"]},{description:"Spellvoid",expanded:['k:"spellvoid"'],filters:{keywords:[L.Keyword.Spellvoid]},isCardProperty:!1,shorthands:["SV"]}],_e=Ke.filter(({shorthands:e})=>e.some(t=>t.includes(" "))).map(e=>({...e,shorthands:e.shorthands.filter(t=>t.includes(" ")).map(t=>t.toLowerCase()).sort((t,r)=>r.length-t.length)})),$e=Ke.filter(({shorthands:e})=>e.some(t=>!t.includes(" "))).map(e=>({...e,shorthands:e.shorthands.filter(t=>!t.includes(" ")).map(t=>t.toLowerCase()).sort((t,r)=>r.length-t.length)}));var ys=["\u201C","\u201D"],ms=[{text:ae.Release.ClassicBattlesRhinarDorinthea.toLowerCase(),override:ae.Release.ClassicBattlesRhinarDorinthea.toLowerCase().replaceAll(k,"")}],ze=new Map([...ae.setToSetIdentifierMappings].map(([e,t])=>[e.toLowerCase(),t])),Cs=[...J[l.Set],...J[l.Print]],hs=_.map(X).join(""),Fs=[...ze.keys()].sort((e,t)=>t.length-e.length).map(X).join("|"),Ts=new RegExp(`(?<=^|\\s)([${hs}]?(?:${Cs.join("|")}):(?:[^\\s]*[,+])?"?)(${Fs})(?="?(?:[,+]|\\s|$))`,"g"),xs=(e,t)=>{let r=e.trim().toLowerCase();for(let i of ys)r=r.replaceAll(i,'"');for(let{expanded:i,shorthands:n}of _e)for(let o of n)if(r.includes(o)){r=r.replace(o,i.join(" "));break}r=r.replace(Ts,(i,n,o)=>{let c=ze.get(o);return c?`${n}${c[0]}`:i});let s=ze.get(r),a=t.getCardsByExactName(r).length>0;s&&!a&&(r=`set:${s[0]}`);for(let{override:i,text:n}of ms)r.includes(n)&&(r=r.replace(n,i));return r},Ms=e=>{let t=$e.find(({shorthands:s})=>s.includes(e)),r=!!t&&!t.isCardProperty;return{isExpanded:r,tokens:r?t.expanded:[e]}},bs=e=>{let t=[];for(let{end:r,start:s,token:a}of he(e)){let{isExpanded:i,tokens:n}=Ms(a);for(let o of n)t.push({end:r,isExpanded:i,start:s,token:o})}return t},As=e=>{let t=[];for(let r of e){let{modifier:s,value:a}=je(r),i=V(a);i&&t.push({modifier:s,value:i})}return t},Ps=(e,t,r)=>{let s={key:e,reason:"value",values:r},a=Ve(t,r);return a&&(s.suggestedKey=a),s},vs=()=>{let e=new Date,t=`${e.getMonth()+1}`.padStart(2,"0"),r=`${e.getDate()}`.padStart(2,"0");return`${e.getFullYear()}-${t}-${r}`},ie=(e,t,{additionalHeroes:r=[],additionalSets:s=[],today:a=vs()}={})=>{let i=xs(e,t),n={additionalHeroes:r,additionalSets:s,index:t,today:a},o=[],c={artists:[],foilings:[],isExpansionSlot:!1,prints:[],rarities:[],releases:[],treatments:[]},p=[],g=[],f=[];for(let C of bs(i)){let b=Fe(C.token)||He(C.token);if(b){let{isAndList:D,isExcluded:I,key:P,valueText:O}=b,N=ge(P),Q=N?.category,U=Ue(O),$=As(U),H={...C,canonicalValues:$.map(({value:x})=>x),category:Q,filterValues:$,isAnd:D,isExcluded:I,isFilter:!0,isResolved:!0,key:P};if(U.length>0)if(N&&Q){let x=U;if($.length>0){let v=wt({category:Q,filterValues:$,isAnd:H.isAnd,isExcluded:I,key:P,mapping:N},n);o.push(...v.appliedFilters),v.canonicalValues&&(H.canonicalValues=v.canonicalValues),v.attributes&&Object.assign(c,v.attributes),x=v.unresolvedValues}x.length>0&&(H.isResolved=!1,f.push(Ps(P,Q,x)))}else H.isResolved=!1,f.push({key:P,reason:"key",values:[]});g.push(H)}else{let{end:D,start:I,token:P}=C;g.push({end:D,isFilter:!1,start:I,token:P});let O=Te(C.token),N=Ie(O);N.length>0?o.push(...N):O&&p.push(O.replace(k,""))}}return{appliedFilters:o,attributes:c,keywords:p,nodes:g,text:i,unresolvedFilters:f}};var A=require("@flesh-and-blood/types"),Lt={artists:["Hoodwill"],cardIdentifier:"fangs-a-lot-blue",classes:[A.Class.Generic],defaultImage:"FNG000",firstReleaseDate:"2022-06-02",functionalText:"If Fangs A Lot is put into your banished zone from your graveyard, instead put it into your hand.",legalFormats:[],legalHeroes:[A.Hero.Kayo,A.Hero.Levia,A.Hero.Rhinar],printings:[{artists:["Hoodwill"],identifier:"FNG000",image:"FNG000",print:"FNG000",rarity:A.Rarity.Rare,set:A.Release.Promos},{artists:["Hoodwill"],identifier:"FNG000",image:"FNG000_Marvel",print:`FNG000-${A.Treatment.FA}`,rarity:A.Rarity.Marvel,set:A.Release.Promos,treatments:[A.Treatment.FA]}],name:"Fangs A Lot",rarities:[A.Rarity.Rare,A.Rarity.Marvel],rarity:A.Rarity.Rare,sets:[A.Release.Promos],setIdentifiers:["FNG000"],specialImage:"FNG000_Marvel",subtypes:[A.Subtype.Attack],types:[A.Type.Action],typeText:"Generic Action - Attack"},Dt=[{keyword:Lt.name.toLowerCase(),card:Lt}];var Rs={getFn:(e,t)=>{let r=We.default.config.getFn(e,t),s=r;if(Array.isArray(r))s=r.map(a=>{let i=typeof a=="string"?a:a.v;return z(i.replace(k,""))});else if(r){let a=z(r).replace(k,"");s=t.includes("functionalText")?q(a):a}return s},ignoreLocation:!0,includeScore:!0,keys:[{name:"name",weight:10},{name:"functionalText",weight:6},{name:"shorthands",weight:4},{name:"setIdentifiers",weight:2},{name:"traits",weight:4},{name:"typeText",weight:6}],threshold:.15,useExtendedSearch:!0},Ge=class{constructor(t,r=[],s=[]){this.getFuse=()=>(this.fuse||(this.fuse=new We.default(this.cards,Rs)),this.fuse);this.getPoolCards=t=>{this.poolCardByCardIdentifier||(this.poolCardByCardIdentifier=new Map(this.cards.map(s=>[s.cardIdentifier,s])));let r=[];for(let{cardIdentifier:s}of t){let a=this.poolCardByCardIdentifier.get(s);a&&r.push(a)}return r};this.search=(t,r)=>{let s,a,{appliedFilters:i,attributes:n,keywords:o,unresolvedFilters:c}=ie(t,this.index,{additionalHeroes:this.additionalHeroes,additionalSets:this.additionalSets}),p=o.join(" "),g=r?Dt.filter(x=>x.keyword===p):[],f=x=>i.length>0?x.filter(v=>v&&jt(v,i)):x;if(g.length>0)s=f(g.map(({card:x})=>x));else if(o.length){let x=B(p),v=this.getPoolCards(this.index.getCardsByNickname(x)),R=new Map;for(let F of[...this.getPoolCards(this.index.getCardsByExactName(x)),...v])R.set(F.cardIdentifier,F);let u=this.getFuse().search(p).map(F=>F.item).filter(({cardIdentifier:F})=>!R.has(F));s=f([...R.values(),...u]),s.some(F=>v.includes(F))&&(a={kind:"nickname",text:x}),s.length===0&&o.length===1&&(s=f(this.getPoolCards(this.index.getCardsByInitials(x))),s.length>0&&(a={kind:"initials",text:x}))}else s=f([...this.cards]);if(!(o.length>0&&a?.kind!=="initials")){let x="";if(n.releases.length===1){let u=xe.setToSetIdentifierMappings.get(n.releases[0]);u?.length&&(x=u[0].toUpperCase())}if(!x&&n.prints.length===1){let u=n.prints[0];xe.setIdentifierToSetMappings.has(u)&&(x=u.toUpperCase())}x?s.sort((u,y)=>{let h=u.setIdentifiers.find(M=>M.includes(x))?.replace(x,""),F=y.setIdentifiers.find(M=>M.includes(x))?.replace(x,"");return h&&F?h.localeCompare(F):-1}):s.sort((u,y)=>u.name===y.name?`${u.pitch}`.localeCompare(`${y.pitch}`):u.name.localeCompare(y.name))}let b=[],{artists:D,isExpansionSlot:I,foilings:P,prints:O,rarities:N,releases:Q,treatments:U}=n;(D.length>0||I||P.length>0||O.length>0||N.length>0||Q.length>0||U.length>0)&&(b=s.map(x=>{let v=x.printings.filter(R=>{let u=!!R.image,y=D.length===0||D.some(ee=>R.artists.find(Ut=>Ut.replace(k,"").toLowerCase().includes(ee))),h=!I||I===R.isExpansionSlot,F=P.length===0||!!R.foiling&&P.includes(R.foiling),M=O.length===0||O.some(ee=>R.identifier.includes(ee.toUpperCase())),w=N.length===0||N.includes(R.rarity),S=Q.length===0||Q.includes(R.set),Y=U.length===0||R.treatments?.some(ee=>U.includes(ee));return u&&y&&h&&F&&M&&w&&S&&Y});return{...x,matchingPrintings:v}}));let H=b.length>0?b:s;return{alias:a,appliedFilters:i,attributes:n,keywords:o,searchResults:H,unresolvedFilters:c}};let a=Array.isArray(r)?{additionalHeroes:r,additionalSets:s}:r;this.additionalHeroes=a.additionalHeroes||[],this.additionalSets=a.additionalSets||[],this.cards=[...t],this.index=a.index||we(t)}},Ht=Ge,jt=(e,t)=>{let r=!0;for(let s of t){let{isNumber:a,isString:i,isArray:n,isBoolean:o,isDate:c}=s.filterToPropertyMapping;s.isOptional||(a?r=r&&Ss(e,s):i?r=r&&ks(e,s):n?r=r&&Vs(e,s,t):o?r=r&&Is(e,s):c&&(r=r&&ws(e,s)))}return r},Qt=(e,t,r)=>{let s=parseInt(t),a;switch(r){case">=":a=e>=s;break;case">":a=e>s;break;case"<=":a=e<=s;break;case"<":a=e<s;break;default:a=e===s}return a},Ss=(e,t)=>{let{filterValues:r,values:s,modifier:a,isExcluded:i,filterToPropertyMapping:{partialMatch:n}}=t,o=!0;if(oe(t,e)){let c=ne(e,t),p;if(c!=null&&!isNaN(c)){let g=parseInt(c);p=r?r.some(({modifier:f,value:C})=>Qt(g,C,f)):s.some(f=>Qt(g,f,a))}else{let g=Ns(e,t)?.toLowerCase();p=n?s.some(f=>!!g?.includes(f)):s.some(f=>g===f)}o=i?!p:p}return o},ks=(e,t)=>{if(oe(t,e)){let{values:r,valuesSet:s,isAnd:a,isExcluded:i,filterToPropertyMapping:{hasMarkup:n,isNormalized:o,partialMatch:c}}=t,p=ne(e,t),g=o?p:p?.replaceAll(k,"").toLowerCase(),f=n&&g?q(g):g;if(c){let C=a?r?.every(b=>f?.includes(b)):r?.some(b=>f?.includes(b));return i?!C:C}else{let C;return a?C=r?.every(b=>f===b):s?C=s.has(f):C=r?.some(b=>f===b),i?!C:C}}else return!0},Vs=(e,t,r)=>{if(oe(t,e)){let{values:s,isAnd:a,isExcluded:i,filterToPropertyMapping:{partialMatch:n}}=t,o=Es(e,t,r).map(c=>c?.replaceAll(k,""));if(n){let c=a?s.every(g=>o?.some(f=>f?.toLowerCase().includes(g))):s.some(g=>o?.some(f=>f?.toLowerCase().includes(g))),p=o.length===0;return i?!c||p:c}else{let c=a?s.every(p=>o?.some(g=>g?.toLowerCase()===p)):s.some(p=>o?.some(g=>g?.toLowerCase()===p));return i?!c:c}}else return!0},Is=(e,t)=>{if(oe(t,e)){let{isExcluded:r}=t,s=ne(e,t);return r?!s:s}else return!0},ws=(e,t)=>{if(oe(t,e)){let{values:r,isExcluded:s}=t,a=ne(e,t),i=r?.some(n=>a>n);return s?!i:i}else return!0},ne=(e,t)=>{let{filterToPropertyMapping:{property:r}}=t,s;return r!==K&&(s=e[r]),s},Es=(e,t,r)=>{let{filterToPropertyMapping:{isNestedPropertyArray:s,nestedProperty:a}}=t,i=[],n=Object.keys(e.legalOverrides||{}).length>0,o=t.filterToPropertyMapping.property===G.LegalHeroes,c=r.find(({filterToPropertyMapping:g})=>g.property===G.LegalFormats);if(n&&o&&!!c){let g=new Set;for(let{format:f,heroes:C}of e.legalOverrides||[])if(c.values.includes(f.toLowerCase()))for(let b of C)g.add(b);i=Array.from(g)}if(i.length===0)if(a){let g=new Set;for(let f of e.printings){let C=f[a];if(s){if(Array.isArray(C))for(let b of C)g.add(b)}else C&&typeof C=="string"&&g.add(C)}i=Array.from(g)}else{let g=ne(e,t);if(Array.isArray(g))for(let f of g)typeof f=="string"&&i.push(f)}return i},Ns=(e,t)=>{let{filterToPropertyMapping:{specialProperty:r}}=t,s;return r&&(s=e[r]),s},oe=({cardTypes:e},{types:t,subtypes:r})=>!e||e?.some(s=>t.map(a=>a.toLowerCase()).includes(s.toLowerCase())||r.map(a=>a.toLowerCase()).includes(s.toLowerCase()));var Bs=(e,t,r=[],s=[],a)=>{let{appliedFilters:i,attributes:n,keywords:o}=ie(e,t,{additionalHeroes:r,additionalSets:s,today:a});return{appliedFilters:i,attributes:n,keywords:o}};var Os=(e,t)=>{let r=new Set;for(let a of e)for(let i of a.createdExtras||[])r.add(i);let s=[];for(let a of t)r.has(a.cardIdentifier)&&s.push(a);return s};0&&(module.exports={FilterCategory,FilterKind,FilterProperty,MARKUP,NO_CARD_PROPERTY,PUNCTUATION,RARITY_VALUES_MAPPING,aliasesByFilterCategory,availableExclusions,availableModifiers,filterCard,filtersToCardPropertyMappings,getCardsByName,getCardsReferencedBy,getCardsReferencing,getCatalogueIndex,getCleanText,getEscapedForRegExp,getExcludedMetaFilters,getFilterCategory,getFilterMapping,getFilterTokenSpansForKey,getFilterValue,getIncompleteFilterToken,getIsExcludedToken,getIsValueInFilterVocabulary,getKeywordsAndAppliedFiltersFromText,getMetaFilterResolution,getMetaFilters,getNormalizedFilterValue,getNormalizedText,getParsedQuery,getQueryFilterToken,getQueryTokenSpans,getQuotedValue,getResolvedFilterKey,getSuggestedFilterKey,getTextWithoutMarkup,getTokensReferencedByCards,getUnquotedValue,getValuePartsFromFilterValue,getValuesFromFilterValue,multiWordShorthands,shorthands,singleWordShorthands});
1
+ "use strict";var Qt=Object.create;var de=Object.defineProperty;var Ht=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var Ut=Object.getPrototypeOf,Kt=Object.prototype.hasOwnProperty;var _t=(e,t)=>{for(var r in t)de(e,r,{get:t[r],enumerable:!0})},Ye=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of jt(t))!Kt.call(e,s)&&s!==r&&de(e,s,{get:()=>t[s],enumerable:!(a=Ht(t,s))||a.enumerable});return e};var Gt=(e,t,r)=>(r=e!=null?Qt(Ut(e)):{},Ye(t||!e||!e.__esModule?de(r,"default",{value:e,enumerable:!0}):r,e)),$t=e=>Ye(de({},"__esModule",{value:!0}),e);var wa={};_t(wa,{FilterCategory:()=>l,FilterKind:()=>m,FilterProperty:()=>q,MARKUP:()=>Me,NO_CARD_PROPERTY:()=>K,PUNCTUATION:()=>S,RARITY_VALUES_MAPPING:()=>Oe,aliasesByFilterCategory:()=>te,availableExclusions:()=>z,availableModifiers:()=>ke,default:()=>Ot,filterCard:()=>Lt,filtersToCardPropertyMappings:()=>ee,getCardsByName:()=>Ta,getCatalogueIndex:()=>$e,getCleanText:()=>O,getEscapedForRegExp:()=>J,getExcludedMetaFilters:()=>we,getFilterCategory:()=>ae,getFilterMapping:()=>ye,getFilterTokenSpansForKey:()=>ea,getFilterValue:()=>Qe,getIncompleteFilterToken:()=>De,getIsExcludedToken:()=>Jr,getIsValueInFilterVocabulary:()=>Se,getKeywordsAndAppliedFiltersFromText:()=>Sa,getMetaFilterResolution:()=>se,getMetaFilters:()=>dr,getNormalizedFilterValue:()=>w,getNormalizedText:()=>Y,getParsedQuery:()=>ne,getQueryFilterToken:()=>he,getQueryTokenSpans:()=>Ce,getQuotedValue:()=>ra,getResolvedFilterKey:()=>Le,getSuggestedFilterKey:()=>Ve,getTextWithoutMarkup:()=>Z,getTokensReferencedByCards:()=>Va,getUnquotedValue:()=>Fe,getValuePartsFromFilterValue:()=>Vt,getValuesFromFilterValue:()=>He,multiWordShorthands:()=>Ue,shorthands:()=>je,singleWordShorthands:()=>Ke});module.exports=$t(wa);var xe=require("@flesh-and-blood/types"),We=Gt(require("fuse.js"),1);var S=/[!"#$%&'’(),./:;<=>?@[\]^_`|~]/g,Me=/\*/g;var h=require("@flesh-and-blood/types");var O=e=>Y(e.toLowerCase().trim().replace(S,"")),Y=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,""),w=e=>e.toLowerCase().replace(S,""),Z=e=>e.replace(Me,""),J=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&");var l={Arcane:"arcane",Artist:"artist",Banned:"banned",Bond:"bond",Class:"class",Cost:"cost",CreatedBy:"createdby",Creates:"creates",Defense:"defense",Flow:"flow",Foiling:"foiling",Fusion:"fusion",Intellect:"intellect",Is:"is",Keyword:"keyword",Legal:"legal",Life:"life",Name:"name",Pitch:"pitch",Power:"power",Print:"print",Rarity:"rarity",ReferencedBy:"referencedby",References:"references",Set:"set",Shorthand:"shorthand",Specialization:"specialization",Subtype:"subtype",Talent:"talent",Text:"text",Trait:"trait",Treatment:"treatment",Type:"type",TypeText:"typetext",Year:"year"},m={Comparator:"comparator",ExactMatch:"exactMatch",PartialMatch:"partialMatch"},ke=[">=",">","<=","<"],z=["!","-"],K="n/a",ft=[...Object.values(h.Format),...Object.values(h.Hero)],zt={category:l.Arcane,canonicalAlias:"arcane",kind:m.Comparator,property:"arcane",specialProperty:"specialArcane",isNumber:!0,partialMatch:!0},Ae={category:l.Artist,canonicalAlias:"art",kind:m.PartialMatch,property:"artists",isArray:!0,partialMatch:!0},qe={category:l.Banned,canonicalAlias:"banned",kind:m.ExactMatch,vocabulary:ft,property:K,isMeta:!0},Xe={category:l.Bond,canonicalAlias:"bond",kind:m.ExactMatch,vocabulary:Object.values(h.Bond),property:"bonds",isArray:!0},Ze={category:l.Class,canonicalAlias:"c",kind:m.PartialMatch,vocabulary:Object.values(h.Class),property:"classes",isArray:!0,partialMatch:!0},Je={category:l.Cost,canonicalAlias:"co",kind:m.Comparator,property:"cost",specialProperty:"specialCost",isNumber:!0,partialMatch:!0},et={category:l.CreatedBy,canonicalAlias:"createdby",kind:m.PartialMatch,property:K},tt={category:l.Creates,canonicalAlias:"creates",kind:m.PartialMatch,property:K},re={category:l.Defense,canonicalAlias:"d",kind:m.Comparator,property:"defense",specialProperty:"specialDefense",isNumber:!0},rt={category:l.Flow,canonicalAlias:"flow",kind:m.ExactMatch,vocabulary:Object.values(h.Flow),property:"flows",isArray:!0},at={category:l.Foiling,canonicalAlias:"foil",kind:m.ExactMatch,vocabulary:Object.values(h.Foiling),nestedProperty:"foiling",property:"printings",isArray:!0},st={category:l.Fusion,canonicalAlias:"f",kind:m.ExactMatch,vocabulary:Object.values(h.Fusion),property:"fusions",isArray:!0},it={category:l.Intellect,canonicalAlias:"i",kind:m.Comparator,property:"intellect",isNumber:!0},nt={category:l.Keyword,canonicalAlias:"k",kind:m.ExactMatch,vocabulary:Object.values(h.Keyword),property:"keywords",isArray:!0},be={category:l.Legal,canonicalAlias:"l",kind:m.ExactMatch,vocabulary:ft,property:K,isMeta:!0},ot={category:l.Life,canonicalAlias:"li",kind:m.Comparator,property:"life",specialProperty:"specialLife",isNumber:!0},lt={category:l.Is,canonicalAlias:"is",kind:m.ExactMatch,vocabulary:Object.values(h.Meta),property:"meta",isArray:!0},dt={category:l.Name,canonicalAlias:"name",kind:m.PartialMatch,property:"name",isString:!0,partialMatch:!0},Pe={category:l.Pitch,canonicalAlias:"p",kind:m.Comparator,property:"pitch",isNumber:!0},ce={category:l.Power,canonicalAlias:"pwr",kind:m.Comparator,property:"power",specialProperty:"specialPower",isNumber:!0},pe={category:l.Print,canonicalAlias:"print",kind:m.PartialMatch,property:"setIdentifiers",isArray:!0,partialMatch:!0},ct={category:l.Rarity,canonicalAlias:"r",kind:m.ExactMatch,vocabulary:Object.values(h.Rarity),property:K,isMeta:!0},Wt={category:l.ReferencedBy,canonicalAlias:"referencedby",kind:m.PartialMatch,property:K},Yt={category:l.References,canonicalAlias:"references",kind:m.PartialMatch,property:K},pt={category:l.Set,canonicalAlias:"s",kind:m.PartialMatch,vocabulary:Object.values(h.Release),property:"sets",isArray:!0,partialMatch:!0},ve={category:l.Shorthand,canonicalAlias:"short",kind:m.PartialMatch,vocabulary:Object.values(h.Shorthand),property:"shorthands",isArray:!0,partialMatch:!0},ue={category:l.Specialization,canonicalAlias:"sp",kind:m.PartialMatch,vocabulary:Object.values(h.Hero),property:"specializations",isArray:!0,partialMatch:!0},ut={category:l.Subtype,canonicalAlias:"st",kind:m.ExactMatch,vocabulary:Object.values(h.Subtype),property:"subtypes",isArray:!0},gt={category:l.Type,canonicalAlias:"t",kind:m.ExactMatch,vocabulary:Object.values(h.Type),property:"types",isArray:!0},Re={category:l.Talent,canonicalAlias:"tal",kind:m.ExactMatch,vocabulary:Object.values(h.Talent),property:"talents",isArray:!0},qt={category:l.Text,canonicalAlias:"text",kind:m.PartialMatch,property:"functionalText",hasMarkup:!0,isString:!0,partialMatch:!0},Xt={category:l.Trait,canonicalAlias:"trait",kind:m.PartialMatch,vocabulary:Object.values(h.Trait),property:"traits",isArray:!0,partialMatch:!0},yt={category:l.TypeText,canonicalAlias:"x",kind:m.PartialMatch,property:"typeText",isString:!0,partialMatch:!0},ge={category:l.Treatment,canonicalAlias:"treatment",kind:m.ExactMatch,vocabulary:Object.values(h.Treatment),nestedProperty:"treatments",property:"printings",isArray:!0,isNestedPropertyArray:!0},Zt={category:l.Year,canonicalAlias:"year",kind:m.PartialMatch,property:"firstReleaseDate",isString:!0,partialMatch:!0},ee={arcane:zt,a:Ae,artist:Ae,art:Ae,attack:ce,b:re,block:re,banned:qe,bond:Xe,bonds:Xe,c:Ze,class:Ze,co:Je,cost:Je,createdby:et,creates:tt,color:Pe,d:re,def:re,defense:re,flow:rt,flows:rt,f:st,fusion:st,foil:at,foiling:at,i:it,intellect:it,is:lt,k:nt,keyword:nt,l:be,legal:be,hero:be,li:ot,life:ot,madeby:et,makes:tt,meta:lt,n:dt,name:dt,p:Pe,pitch:Pe,pwr:ce,pow:ce,power:ce,print:pe,printing:pe,printings:pe,prints:pe,r:ct,rarity:ct,referencedby:Wt,references:Yt,rf:qe,s:pt,set:pt,short:ve,shorthand:ve,shorthands:ve,sp:ue,spec:ue,specialization:ue,specializations:ue,st:ut,subtype:ut,t:gt,type:gt,tal:Re,talent:Re,talents:Re,text:qt,trait:Xt,treat:ge,treatment:ge,var:ge,variation:ge,x:yt,typetext:yt,year:Zt},Jt=new Map(Object.entries(ee)),ye=e=>Jt.get(e.toLowerCase()),ae=e=>ye(e)?.category,er=()=>{let e=Object.create(null);for(let[t,{category:r}]of Object.entries(ee)){let a=e[r];a?a.push(t):e[r]=[t]}return e},te=er(),tr=()=>{let e=new Map,t=new Set,r=Object.values(ee);for(let a of r){let{vocabulary:s}=a;if(s&&!t.has(a)){t.add(a);for(let i of s){let n=w(i),o=e.get(n);o?o.push(a):e.set(n,[a])}}}return e},mt=tr(),Se=(e,t)=>!!mt.get(w(t))?.some(r=>r.category===e),rr=(e,t)=>{let r=[],a=!0;for(let s of t){let i=(mt.get(w(s))||[]).filter(n=>n.category!==e);r=a?i:r.filter(n=>i.includes(n)),a=!1}return r},Ve=(e,t)=>{let r=rr(e,t),[a]=r;return r.length===1?a.canonicalAlias:void 0};var ie=require("@flesh-and-blood/types");var d=require("@flesh-and-blood/types");var N=require("@flesh-and-blood/types");var q={BannedFormats:"bannedFormats",LegalFormats:"legalFormats",LegalHeroes:"legalHeroes"},fe=Array.from(Array(50).keys()).map(e=>`${e}`),ar=[{format:N.Format.ClassicConstructed,nicknames:["cc","classic"]},{format:N.Format.LivingLegend,nicknames:["cc ll","classic constructed ll","ll cc","ll","living legend"]},{format:N.Format.SilverAge,nicknames:["sage"]},{format:N.Format.GoldenAge,nicknames:["gage"]},{format:N.Format.UltimatePitFight,nicknames:["upf"]}],sr=Object.values(N.Format).map(e=>{let t=ar.find(({format:a})=>a===e),r=e.toLowerCase().replaceAll(S,"");return t?{...t,format:r}:{format:r}}),ir=Object.values(N.Hero).map(O),Ct=e=>e.replaceAll(" ",""),nr=(e,t)=>{let r=Ct(e),a,s=[];for(let n of t){let o=Ct(n);o===r?a=n:o.startsWith(r)&&s.push(n)}let i=s.length===1;return a??(i?s[0]:void 0)},ht=["common","rare","super rare","majestic","legendary","fabled"],or=({modifier:e,value:t})=>{let r=[],a=e==="<"||e==="<=",s=e===">="||e==="<=",i=a?[...ht].reverse():ht,n=!1;for(let o of i)n?r.push(o):o===t&&(n=!0,s&&r.push(o));return r},lr=(e,t)=>{let r=[];for(let a of e)a.modifier?r.push(...or(a)):r.push(a.value);return{filterToPropertyMapping:{nestedProperty:"rarity",property:"printings",isArray:!0},isExcluded:t,isOr:!0,values:r}},Ft=(e,t,r,a)=>{let s=new Set([...ir,...r.map(O)]),i=[],n=[],o=[],p=[];for(let{value:f}of e){let u=sr.find(({format:y,nicknames:F})=>y===f||!!F&&F.includes(f));if(u)n.push(u.format);else{let y=nr(f,s);y?o.push(y):p.push(f)}}return n.length>0&&i.push({filterToPropertyMapping:{property:a,isArray:!0},values:n,isOr:!0,isExcluded:t}),o.length>0&&i.push({filterToPropertyMapping:{property:q.LegalHeroes,isArray:!0},values:o,isOr:!0,isExcluded:t}),{appliedFilters:i,unresolvedValues:p}},se=(e,t,{additionalHeroes:r=[],isExcluded:a=!1}={})=>{let s=ae(e),i={appliedFilters:[],unresolvedValues:[]};return s===l.Legal?i=Ft(t,a,r,q.LegalFormats):s===l.Banned?i=Ft(t,a,r,q.BannedFormats):s===l.Rarity&&(i={appliedFilters:[lr(t,a)],unresolvedValues:[]}),i},dr=(e,t,r,a,s,i)=>se(r,a.map(n=>({modifier:s,value:n})),{additionalHeroes:i,isExcluded:e}).appliedFilters,cr=[{filterToPropertyMapping:{property:"cost",isNumber:!0},isExcluded:!0,values:fe},{filterToPropertyMapping:{property:"specialCost",isString:!0,partialMatch:!0},isExcluded:!0,values:["*","x"]},{filterToPropertyMapping:{property:"types",isArray:!0,partialMatch:!0},isExcluded:!0,values:["equipment","hero","placeholder","token","weapon"]}],pr=[{filterToPropertyMapping:{property:"defense",isNumber:!0},isExcluded:!0,values:fe},{filterToPropertyMapping:{property:"specialDefense",isString:!0,partialMatch:!0},isExcluded:!0,values:["*","x"]},{filterToPropertyMapping:{property:"types",isArray:!0,partialMatch:!0},isExcluded:!0,values:["hero","placeholder","token","weapon"]}],ur=[{filterToPropertyMapping:{property:"pitch",isNumber:!0},isExcluded:!0,values:fe},{filterToPropertyMapping:{property:"types",isArray:!0,partialMatch:!0},isExcluded:!0,values:["equipment","hero","placeholder","token","weapon"]},{filterToPropertyMapping:{property:"isCardBack",isBoolean:!0},isExcluded:!0,values:["true"]}],gr=[{filterToPropertyMapping:{property:"power",isNumber:!0},isExcluded:!0,values:fe},{filterToPropertyMapping:{property:"specialPower",isString:!0,partialMatch:!0},isExcluded:!0,values:["*","x"]},{filterToPropertyMapping:{property:"types",isArray:!0,partialMatch:!0},isExcluded:!0,values:["equipment","hero","placeholder","token"]}],yr=[{filterToPropertyMapping:{property:"talents",isArray:!0},isExcluded:!0,values:Object.values(N.Talent).map(e=>e.toLowerCase())}],fr=[{filterToPropertyMapping:{property:"classes",isArray:!0},isExcluded:!0,values:Object.values(N.Class).map(e=>e.toLowerCase())}],mr=[{category:l.Class,filters:fr},{category:l.Cost,filters:cr},{category:l.Defense,filters:pr},{category:l.Pitch,filters:ur},{category:l.Power,filters:gr},{category:l.Talent,filters:yr}],Cr=()=>{let e=new Map;for(let{category:t,filters:r}of mr)for(let a of te[t])for(let s of z)e.set(`${s}${a}`,r);return e},hr=Cr(),we=e=>{let t=[],r=hr.get(e);return r&&t.push(...r),t};var Fr=e=>{let[t]=e,r=t?.modifier;return e.every(({modifier:s})=>s===r)?r:void 0},Ee=({filterValues:e,isAnd:t,isExcluded:r,mapping:a})=>{let s=[];for(let{value:i}of e)s.push(a.hasMarkup?Z(i):i);return{filterToPropertyMapping:a,filterValues:e,isAnd:t,isExcluded:r,isOr:!t&&s.length>1,modifier:Fr(e),values:s}},At=({isAnd:e,isExcluded:t,mapping:r},a)=>({filterToPropertyMapping:r,isAnd:e,isExcluded:t,isOr:!e&&a.length>1,values:a}),Tr=({category:e,filterValues:t,mapping:r})=>{let a=[];if(r.kind===m.ExactMatch&&!!r.vocabulary)for(let{value:i}of t)Se(e,i)||a.push(i);return a},xr=e=>({appliedFilters:[Ee(e)],unresolvedValues:Tr(e)}),Ne=({isExcluded:e},t,r)=>e?void 0:{[t]:r},bt=(e,t)=>({appliedFilters:[Ee(e)],attributes:Ne(e,t,e.filterValues.map(({value:r})=>r)),unresolvedValues:[]}),Mr=e=>bt(e,"artists"),Ar=e=>bt(e,"prints"),Be=(e,t,r)=>{let a=[],s=[],i=[];for(let{value:n}of e.filterValues){let o=r(n);if(o.length>0)for(let p of o)a.push(p),s.push(w(p));else i.push(n)}return{appliedFilters:[At(e,s)],attributes:Ne(e,t,a),canonicalValues:s,unresolvedValues:i}},br=new Map(Object.entries({purple:4,blue:3,yellow:2,red:1,white:0})),Pr=e=>{let t=[],r=[];for(let{modifier:a,value:s}of e.filterValues){let i=br.get(s),n=i===void 0?s:`${i}`;t.push({modifier:a,value:n}),r.push(n)}return{appliedFilters:[Ee({...e,filterValues:t})],canonicalValues:r,unresolvedValues:[]}},Ie=new Map;for(let e of Object.values(d.Release)){let t=w(e),r=Ie.get(t);if(r===void 0)Ie.set(t,e);else throw new Error(`${r} and ${e} are one name as a filter reads it, so a set filter naming it could reach either`)}var Tt=(e,t)=>{let r=e.get(t);return r?[r]:[]},vr=(e,t)=>{let r=[()=>Tt(Ie,e),()=>Tt(d.setIdentifierToSetMappings,e),()=>Object.values(d.Release).filter(s=>s.toLowerCase().includes(e)),()=>{let s=t.find(i=>w(i)===e);return s?[s]:[]}],a=[];for(let s of r)a.length===0&&a.push(...s());return a},Rr=(e,{additionalSets:t})=>Be(e,"releases",r=>vr(r,t)),kr=new Map(Object.entries({r:d.Foiling.Rainbow,rf:d.Foiling.Rainbow,rainbow:d.Foiling.Rainbow,c:d.Foiling.Cold,cf:d.Foiling.Cold,cold:d.Foiling.Cold,g:d.Foiling.Gold,gf:d.Foiling.Gold,gold:d.Foiling.Gold})),Sr=e=>{let t=kr.get(e);return t?[t]:[]},Vr=e=>Be(e,"foilings",Sr),Pt=new Map(Object.entries({aa:d.Treatment.AA,alt:d.Treatment.AA,"alt art":d.Treatment.AA,ab:d.Treatment.AB,"alt border":d.Treatment.AB,at:d.Treatment.AT,"alt text":d.Treatment.AT,ea:d.Treatment.EA,extended:d.Treatment.EA,"extended art":d.Treatment.EA,fa:d.Treatment.FA,full:d.Treatment.FA,"full art":d.Treatment.FA}));for(let e of Object.values(d.Treatment))Pt.set(e.toLowerCase(),e);var wr=new Map(Object.entries(d.Treatment)),Ir=e=>{let t=Pt.get(e)||wr.get(e.toUpperCase());return t?[t]:[]},Er=e=>Be(e,"treatments",Ir),Oe=new Map(Object.entries({b:d.Rarity.Basic,c:d.Rarity.Common,f:d.Rarity.Fabled,l:d.Rarity.Legendary,m:d.Rarity.Majestic,p:d.Rarity.Promo,r:d.Rarity.Rare,s:d.Rarity.SuperRare,t:d.Rarity.Token,v:d.Rarity.Marvel})),Nr=e=>Oe.get(e)||Object.values(d.Rarity).find(t=>t.toLowerCase()===e),Br=(e,{additionalHeroes:t})=>{let r=[],a=[],s=[],i=[];for(let{modifier:o,value:p}of e.filterValues){let f=Nr(p);f?(r.push(f),a.push(f.toLowerCase()),s.push({modifier:o,value:f.toLowerCase()})):(i.push(p),s.push({modifier:o,value:p}))}let{appliedFilters:n}=se(e.key,s,{additionalHeroes:t,isExcluded:e.isExcluded});return{appliedFilters:n,attributes:Ne(e,"rarities",r),canonicalValues:a,unresolvedValues:i}},xt=({filterValues:e,isExcluded:t,key:r},{additionalHeroes:a})=>{let{appliedFilters:s,unresolvedValues:i}=se(r,e,{additionalHeroes:a,isExcluded:t}),n=[];for(let{values:o}of s)n.push(...o);return{appliedFilters:s,canonicalValues:n,unresolvedValues:i}},Or=["unique"],Lr=["preview","spoiler","unreleased"],Dr=["released"],Mt={property:"firstReleaseDate",isDate:!0},Qr=new Map(Object.entries({dual:d.Meta.DualClass,exp:d.Meta.Expansion,expansion:d.Meta.Expansion,rainbow:d.Meta.Rainbow,reprint:d.Meta.Reprint,reprints:d.Meta.Reprint})),Hr=e=>{let t=[],r=[];for(let s of e){let i=Qr.get(s);i?t.push(i):r.push(s)}let a=[];if(t.length===0){let s=new Set;for(let i of Object.values(d.Meta)){let n=!1;for(let o of r)i.toLowerCase().includes(o)&&(n=!0,s.add(o));n&&t.push(i)}for(let i of r)s.has(i)||a.push(i)}else a.push(...r);return{unresolvedValues:a,values:t}},jr=(e,{today:t})=>{let{filterValues:r,isAnd:a,isExcluded:s}=e,i=[],n=[],o=[],p=[],f=[];for(let{value:b}of r)Or.includes(b)?n.push(b):Lr.includes(b)?o.push(b):Dr.includes(b)?p.push(b):f.push(b);let u=!a&&r.length>1;n.length>0&&i.push({filterToPropertyMapping:ee.is,values:[w(d.Meta.Reprint)],isAnd:a,isOr:u,isExcluded:!s}),o.length>0&&i.push({filterToPropertyMapping:Mt,values:[t],isAnd:a,isOr:u,isExcluded:s}),p.length>0&&i.push({filterToPropertyMapping:Mt,values:[t],isAnd:a,isOr:u,isExcluded:!s});let{unresolvedValues:y,values:F}=Hr(f),x=[...n,...o,...p,...F.map(w)];(f.length>0||i.length===0)&&i.push(At(e,F.map(w)));let I=F.includes(d.Meta.Expansion)&&!s;return{appliedFilters:i,attributes:I?{isExpansionSlot:I}:void 0,canonicalValues:x,unresolvedValues:y}},Ur={property:"cardIdentifier",isString:!0,isNormalized:!0},Kr=(e,t)=>{let r=e.getCardsByExactName(t);return r.length===0&&(r=e.getCardsByGroup(t)),r.length===0&&(r=e.getCardsByName(t)),r},_r=(e,t,r)=>{let a=new Set;for(let s of Kr(e,t))for(let i of r(e,s.cardIdentifier))if(!a.has(i.cardIdentifier))for(let o of e.getPitchCycle(i.cardIdentifier))a.add(o.cardIdentifier);return a},Gr=(e,t)=>{let r=new Set,[a=new Set,...s]=e;if(t)for(let i of a)s.every(o=>o.has(i))&&r.add(i);else for(let i of e)for(let n of i)r.add(n);return r},$r=(e,t)=>({filterToPropertyMapping:Ur,values:[...e],valuesSet:e,isExcluded:t,isOr:!0}),me=e=>({filterValues:t,isAnd:r,isExcluded:a},{index:s})=>{let i=[],n=[];for(let{value:o}of t){let p=_r(s,o,e);i.push(p),p.size===0&&n.push(o)}return{appliedFilters:[$r(Gr(i,r),a)],unresolvedValues:n}},zr=new Map([[l.Artist,Mr],[l.Banned,xt],[l.CreatedBy,me((e,t)=>e.getCreates(t))],[l.Creates,me((e,t)=>e.getCreatedBy(t))],[l.Foiling,Vr],[l.Is,jr],[l.Legal,xt],[l.Pitch,Pr],[l.Print,Ar],[l.Rarity,Br],[l.ReferencedBy,me((e,t)=>e.getReferences(t))],[l.References,me((e,t)=>e.getReferencedBy(t))],[l.Set,Rr],[l.Treatment,Er]]),vt=(e,t)=>(zr.get(e.category)||xr)(e,t);var kt=z.map(J).join(""),Wr=/(?:[^\s"]+|"[^"]*(?:"|$))+/g,Yr=new RegExp(`^([${kt}])?([A-Za-z]+):(.+)$`),qr=new RegExp(`^([${kt}])?([A-Za-z]+):$`),Xr=",",Rt="+",Zr='"',St=e=>{let t=[],r=!1,a="",s=!1;for(let i of e)i===Zr?(s=!s,a+=i):!s&&(i===Xr||i===Rt)?(r=r||i===Rt,a&&t.push(a),a=""):a+=i;return a&&t.push(a),{isAndList:r,parts:t}},Ce=e=>{let t=[];for(let r of e.matchAll(Wr))t.push({end:r.index+r[0].length,start:r.index,token:r[0]});return t},Jr=e=>z.some(t=>e.startsWith(t)),he=e=>{let t=e.match(Yr),r;if(t){let[,a,s,i]=t;r={isAndList:St(i).isAndList,isExcluded:!!a,key:s,valueText:i}}return r},De=e=>{let t=e.match(qr),r;return t&&(r={isAndList:!1,isExcluded:!!t[1],key:t[2],valueText:""}),r},Qe=e=>{let t=e.trim(),r=ke.find(a=>t.startsWith(a));return{modifier:r,value:r?t.slice(r.length).trim():t}},Le=e=>ae(e)??e.toLowerCase(),ea=(e,t)=>{let r=Le(t),a=[];for(let{end:s,start:i,token:n}of Ce(e)){let o=he(n);o&&Le(o.key)===r&&a.push({...o,end:s,start:i,token:n})}return a},Vt=e=>St(e).parts,Fe=e=>e.replace(/^"|"$/g,""),He=e=>{let t=[];for(let r of Vt(e)){let a=Fe(r);a&&t.push(a)}return t},ta=/[\s,:+"]/,ra=e=>{let t=e.replaceAll('"',"");return ta.test(e)?`"${t}"`:t};var D=require("@flesh-and-blood/types"),je=[{description:"Attack actions",expanded:["st:attack"],filters:{subtypes:[D.Subtype.Attack]},isCardProperty:!1,shorthands:["AA"]},{description:"Arcane barrier",expanded:['k:"arcane barrier"'],filters:{keywords:[D.Keyword.ArcaneBarrier]},isCardProperty:!1,shorthands:["AB"]},{description:"Attack reactions",expanded:['t:"attack reaction"'],filters:{types:[D.Type.AttackReaction]},isCardProperty:!1,shorthands:["AR"]},{description:"Defense reactions",expanded:['t:"defense reaction"'],filters:{types:[D.Type.DefenseReaction]},isCardProperty:!1,shorthands:["DR"]},{description:"Gain life",expanded:["gain {h}"],filters:{functionalText:"gain {h}"},isCardProperty:!1,shorthands:["Gain life","Gains life"]},{description:"Go again",expanded:['k:"go again"'],filters:{keywords:[D.Keyword.GoAgain]},isCardProperty:!1,shorthands:["GA"]},{description:"Non-attack actions",expanded:["t:action","st:non-attack"],filters:{subtypes:[D.Subtype.NonAttack],types:[D.Type.Action]},isCardProperty:!1,shorthands:["NAA"]},{description:"Plus defense",expanded:["+ {d}"],filters:{functionalText:"+ {d}"},isCardProperty:!1,shorthands:["Pump defense","Pumps defense","Buff defense","Buffs defense"]},{description:"Spellvoid",expanded:['k:"spellvoid"'],filters:{keywords:[D.Keyword.Spellvoid]},isCardProperty:!1,shorthands:["SV"]}],Ue=je.filter(({shorthands:e})=>e.some(t=>t.includes(" "))).map(e=>({...e,shorthands:e.shorthands.filter(t=>t.includes(" ")).map(t=>t.toLowerCase()).sort((t,r)=>r.length-t.length)})),Ke=je.filter(({shorthands:e})=>e.some(t=>!t.includes(" "))).map(e=>({...e,shorthands:e.shorthands.filter(t=>!t.includes(" ")).map(t=>t.toLowerCase()).sort((t,r)=>r.length-t.length)}));var aa=["\u201C","\u201D"],sa=[{text:ie.Release.ClassicBattlesRhinarDorinthea.toLowerCase(),override:ie.Release.ClassicBattlesRhinarDorinthea.toLowerCase().replaceAll(S,"")}],_e=new Map([...ie.setToSetIdentifierMappings].map(([e,t])=>[e.toLowerCase(),t])),ia=[...te[l.Set],...te[l.Print]],na=z.map(J).join(""),oa=[..._e.keys()].sort((e,t)=>t.length-e.length).map(J).join("|"),la=new RegExp(`(?<=^|\\s)([${na}]?(?:${ia.join("|")}):(?:[^\\s]*[,+])?"?)(${oa})(?="?(?:[,+]|\\s|$))`,"g"),da=(e,t)=>{let r=e.trim().toLowerCase();for(let i of aa)r=r.replaceAll(i,'"');for(let{expanded:i,shorthands:n}of Ue)for(let o of n)if(r.includes(o)){r=r.replace(o,i.join(" "));break}r=r.replace(la,(i,n,o)=>{let p=_e.get(o);return p?`${n}${p[0]}`:i});let a=_e.get(r),s=t.getCardsByExactName(r).length>0;a&&!s&&(r=`set:${a[0]}`);for(let{override:i,text:n}of sa)r.includes(n)&&(r=r.replace(n,i));return r},ca=e=>{let t=Ke.find(({shorthands:a})=>a.includes(e)),r=!!t&&!t.isCardProperty;return{isExpanded:r,tokens:r?t.expanded:[e]}},pa=e=>{let t=[];for(let{end:r,start:a,token:s}of Ce(e)){let{isExpanded:i,tokens:n}=ca(s);for(let o of n)t.push({end:r,isExpanded:i,start:a,token:o})}return t},ua=e=>{let t=[];for(let r of e){let{modifier:a,value:s}=Qe(r),i=w(s);i&&t.push({modifier:a,value:i})}return t},ga=(e,t,r)=>{let a={key:e,reason:"value",values:r},s=Ve(t,r);return s&&(a.suggestedKey=s),a},ya=()=>{let e=new Date,t=`${e.getMonth()+1}`.padStart(2,"0"),r=`${e.getDate()}`.padStart(2,"0");return`${e.getFullYear()}-${t}-${r}`},ne=(e,t,{additionalHeroes:r=[],additionalSets:a=[],today:s=ya()}={})=>{let i=da(e,t),n={additionalHeroes:r,additionalSets:a,index:t,today:s},o=[],p={artists:[],foilings:[],isExpansionSlot:!1,prints:[],rarities:[],releases:[],treatments:[]},f=[],u=[],y=[];for(let F of pa(i)){let x=he(F.token)||De(F.token);if(x){let{isAndList:H,isExcluded:I,key:b,valueText:L}=x,B=ye(b),j=B?.category,_=He(L),W=ua(_),G={...F,canonicalValues:W.map(({value:T})=>T),category:j,filterValues:W,isAnd:H,isExcluded:I,isFilter:!0,isResolved:!0,key:b};if(_.length>0)if(B&&j){let T=_;if(W.length>0){let v=vt({category:j,filterValues:W,isAnd:G.isAnd,isExcluded:I,key:b,mapping:B},n);o.push(...v.appliedFilters),v.canonicalValues&&(G.canonicalValues=v.canonicalValues),v.attributes&&Object.assign(p,v.attributes),T=v.unresolvedValues}T.length>0&&(G.isResolved=!1,y.push(ga(b,j,T)))}else G.isResolved=!1,y.push({key:b,reason:"key",values:[]});u.push(G)}else{let{end:H,start:I,token:b}=F;u.push({end:H,isFilter:!1,start:I,token:b});let L=Fe(F.token),B=we(L);B.length>0?o.push(...B):L&&f.push(L.replace(S,""))}}return{appliedFilters:o,attributes:p,keywords:f,nodes:u,text:i,unresolvedFilters:y}};var A=require("@flesh-and-blood/types"),wt={artists:["Hoodwill"],cardIdentifier:"fangs-a-lot-blue",classes:[A.Class.Generic],defaultImage:"FNG000",firstReleaseDate:"2022-06-02",functionalText:"If Fangs A Lot is put into your banished zone from your graveyard, instead put it into your hand.",legalFormats:[],legalHeroes:[A.Hero.Kayo,A.Hero.Levia,A.Hero.Rhinar],printings:[{artists:["Hoodwill"],identifier:"FNG000",image:"FNG000",print:"FNG000",rarity:A.Rarity.Rare,set:A.Release.Promos},{artists:["Hoodwill"],identifier:"FNG000",image:"FNG000_Marvel",print:`FNG000-${A.Treatment.FA}`,rarity:A.Rarity.Marvel,set:A.Release.Promos,treatments:[A.Treatment.FA]}],name:"Fangs A Lot",rarities:[A.Rarity.Rare,A.Rarity.Marvel],rarity:A.Rarity.Rare,sets:[A.Release.Promos],setIdentifiers:["FNG000"],specialImage:"FNG000_Marvel",subtypes:[A.Subtype.Attack],types:[A.Type.Action],typeText:"Generic Action - Attack"},It=[{keyword:wt.name.toLowerCase(),card:wt}];var X=require("@flesh-and-blood/types");var fa=3,ma=e=>{let t=Y(e.toLowerCase()).replace(/[^a-z\s-]/g,""),r=new Set;for(let a of[/[\s-]+/,/\s+/]){let s="";for(let i of t.split(a)){let n=i.replaceAll("-","");n&&(s+=n[0])}s.length>=fa&&r.add(s)}return[...r]},Te=e=>O(e).replaceAll("-",""),Ge=(e,t,r)=>{let a=e.get(t);a?a.push(r):e.set(t,[r])},Et=new WeakMap,Q=Object.freeze([]),Ca=Number.MAX_SAFE_INTEGER,Nt=(e,t)=>{let r=new Map;for(let a of e)for(let s of t(a)||[]){let i=r.get(s);i?i.push(a):r.set(s,[a])}return r},ha=e=>{let t=new Map;for(let r of e){let a=r.types.includes(X.Type.Hero)&&!r.isCardBack,s=a?X.CardRole.Hero:(0,X.getCardRole)(r);if(a||s!==X.CardRole.Hero){let n=t.get(s);n?n.push(r):t.set(s,[r])}}return t},Fa=e=>{let t,r,a,s,i,n,o,p,f=()=>{if(!t){let g=new Map,c=new Map,C=[],M=new Map,P=0;for(let E of e){g.set(E.cardIdentifier,E),c.set(E.cardIdentifier,P),P++;let V=O(E.name),U=M.get(V);U?U.push(E):(M.set(V,[E]),C.push(V))}t={cardByCardIdentifier:g,corpusPositionByCardIdentifier:c,cleanedNames:C,pitchCycleByCleanedName:M}}return t},u=g=>{let{corpusPositionByCardIdentifier:c}=f(),C=({cardIdentifier:M})=>c.get(M)??Ca;return[...g].sort((M,P)=>C(M)-C(P))},y=g=>f().cardByCardIdentifier.get(g),F=g=>{let{cardByCardIdentifier:c}=f(),C=[];for(let M of g||[]){let P=c.get(M);P&&C.push(P)}return u(C)},x=g=>{let c=new Map;return C=>{let M=c.get(C);if(!M){let P=y(C),E=F(P&&g(P)),V=E.length>0;M=V?E:Q,V&&c.set(C,M)}return M}},H=g=>{let{pitchCycleByCleanedName:c}=f(),C=y(g);return C?c.get(O(C.name))??Q:Q},I=g=>{let{cleanedNames:c,pitchCycleByCleanedName:C}=f(),M=O(g),P=C.get(M);if(!P&&M.length>0){let V=c.find(U=>U.includes(M));V&&(P=C.get(V))}return P??Q},b=g=>{let{pitchCycleByCleanedName:c}=f();return c.get(O(g))??Q},L=g=>{if(!n){n=new Map;for(let c of e)for(let C of c.nicknames??[])Ge(n,Te(C),c)}return n.get(Te(g))??Q},B=g=>{if(!o){o=new Map;for(let c of e)for(let C of[...c.types,...c.subtypes,...c.traits??[]])Ge(o,Te(C),c)}return o.get(Te(g))??Q},j=g=>{if(!p){p=new Map;for(let c of e)for(let C of ma(c.name))Ge(p,C,c)}return p.get(g)??Q},_=()=>{if(!i){let g=new Set;for(let c of e)for(let C of c.artists)g.add(C);i=[...g].sort((c,C)=>c.localeCompare(C,"en",{sensitivity:"base"}))}return i},W=x(({oppositeSideCardIdentifiers:g})=>g),G=x(({referencedCards:g})=>g),T=g=>(r||(r=Nt(e,({referencedCards:c})=>c)),r.get(g)??Q),v=x(({createdExtras:g})=>g);return{cards:e,getCard:y,getPitchCycle:H,getCardsByName:I,getCardsByExactName:b,getCardsByNickname:L,getCardsByGroup:B,getCardsByInitials:j,getArtists:_,getOppositeSide:W,getReferences:G,getReferencedBy:T,getCreates:v,getCreatedBy:g=>(a||(a=Nt(e,({createdExtras:c})=>c)),a.get(g)??Q),getCreatedClosure:g=>{let c=new Map,C=new Set,M=[...g];for(let P of M)if(!C.has(P)){C.add(P);for(let V of v(P))c.set(V.cardIdentifier,V),M.push(V.cardIdentifier)}return u([...c.values()])},getByRole:g=>(s||(s=ha(e)),s.get(g)??Q),getCardsInCorpusOrder:u}},$e=e=>{let t=Et.get(e);return t||(t=Fa(e),Et.set(e,t)),t},Ta=(e,t)=>e.getCardsByName(t);var xa={getFn:(e,t)=>{let r=We.default.config.getFn(e,t),a=r;if(Array.isArray(r))a=r.map(s=>{let i=typeof s=="string"?s:s.v;return Y(i.replace(S,""))});else if(r){let s=Y(r).replace(S,"");a=t.includes("functionalText")?Z(s):s}return a},ignoreLocation:!0,includeScore:!0,keys:[{name:"name",weight:10},{name:"functionalText",weight:6},{name:"shorthands",weight:4},{name:"setIdentifiers",weight:2},{name:"traits",weight:4},{name:"typeText",weight:6}],threshold:.15,useExtendedSearch:!0},ze=class{constructor(t,r=[],a=[]){this.getFuse=()=>(this.fuse||(this.fuse=new We.default(this.cards,xa)),this.fuse);this.getPoolCards=t=>{this.poolCardByCardIdentifier||(this.poolCardByCardIdentifier=new Map(this.cards.map(a=>[a.cardIdentifier,a])));let r=[];for(let{cardIdentifier:a}of t){let s=this.poolCardByCardIdentifier.get(a);s&&r.push(s)}return r};this.search=(t,r)=>{let a,s,{appliedFilters:i,attributes:n,keywords:o,unresolvedFilters:p}=ne(t,this.index,{additionalHeroes:this.additionalHeroes,additionalSets:this.additionalSets}),f=o.join(" "),u=r?It.filter(T=>T.keyword===f):[],y=T=>i.length>0?T.filter(v=>v&&Lt(v,i)):T;if(u.length>0)a=y(u.map(({card:T})=>T));else if(o.length){let T=O(f),v=this.getPoolCards(this.index.getCardsByNickname(T)),k=new Map;for(let c of[...this.getPoolCards(this.index.getCardsByExactName(T)),...v])k.set(c.cardIdentifier,c);let R=this.getFuse().search(f).map(c=>c.item).filter(({cardIdentifier:c})=>!k.has(c));a=y([...k.values(),...R]),a.some(c=>v.includes(c))&&(s={kind:"nickname",text:T}),a.length===0&&o.length===1&&(a=y(this.getPoolCards(this.index.getCardsByInitials(T))),a.length>0&&(s={kind:"initials",text:T}))}else a=y([...this.cards]);if(!(o.length>0&&s?.kind!=="initials")){let T="";if(n.releases.length===1){let R=xe.setToSetIdentifierMappings.get(n.releases[0]);R?.length&&(T=R[0].toUpperCase())}if(!T&&n.prints.length===1){let R=n.prints[0];xe.setIdentifierToSetMappings.has(R)&&(T=R.toUpperCase())}T?a.sort((R,$)=>{let g=R.setIdentifiers.find(C=>C.includes(T))?.replace(T,""),c=$.setIdentifiers.find(C=>C.includes(T))?.replace(T,"");return g&&c?g.localeCompare(c):-1}):a.sort((R,$)=>R.name===$.name?`${R.pitch}`.localeCompare(`${$.pitch}`):R.name.localeCompare($.name))}let x=[],{artists:H,isExpansionSlot:I,foilings:b,prints:L,rarities:B,releases:j,treatments:_}=n;(H.length>0||I||b.length>0||L.length>0||B.length>0||j.length>0||_.length>0)&&(x=a.map(T=>{let v=T.printings.filter(k=>{let R=!!k.image,$=H.length===0||H.some(U=>k.artists.find(Dt=>Dt.replace(S,"").toLowerCase().includes(U))),g=!I||I===k.isExpansionSlot,c=b.length===0||!!k.foiling&&b.includes(k.foiling),C=L.length===0||L.some(U=>k.identifier.includes(U.toUpperCase())),M=B.length===0||B.includes(k.rarity),P=j.length===0||j.includes(k.set),E=_.length===0||k.treatments?.some(U=>_.includes(U));return R&&$&&g&&c&&C&&M&&P&&E});return{...T,matchingPrintings:v}}));let G=x.length>0?x:a;return{alias:s,appliedFilters:i,attributes:n,keywords:o,searchResults:G,unresolvedFilters:p}};let s=Array.isArray(r)?{additionalHeroes:r,additionalSets:a}:r;this.additionalHeroes=s.additionalHeroes||[],this.additionalSets=s.additionalSets||[],this.cards=[...t],this.index=s.index||$e(t)}},Ot=ze,Lt=(e,t)=>{let r=!0;for(let a of t){let{isNumber:s,isString:i,isArray:n,isBoolean:o,isDate:p}=a.filterToPropertyMapping;a.isOptional||(s?r=r&&Ma(e,a):i?r=r&&Aa(e,a):n?r=r&&ba(e,a,t):o?r=r&&Pa(e,a):p&&(r=r&&va(e,a)))}return r},Bt=(e,t,r)=>{let a=parseInt(t),s;switch(r){case">=":s=e>=a;break;case">":s=e>a;break;case"<=":s=e<=a;break;case"<":s=e<a;break;default:s=e===a}return s},Ma=(e,t)=>{let{filterValues:r,values:a,modifier:s,isExcluded:i,filterToPropertyMapping:{partialMatch:n}}=t,o=!0;if(le(t,e)){let p=oe(e,t),f;if(p!=null&&!isNaN(p)){let u=parseInt(p);f=r?r.some(({modifier:y,value:F})=>Bt(u,F,y)):a.some(y=>Bt(u,y,s))}else{let u=ka(e,t)?.toLowerCase();f=n?a.some(y=>!!u?.includes(y)):a.some(y=>u===y)}o=i?!f:f}return o},Aa=(e,t)=>{if(le(t,e)){let{values:r,valuesSet:a,isAnd:s,isExcluded:i,filterToPropertyMapping:{hasMarkup:n,isNormalized:o,partialMatch:p}}=t,f=oe(e,t),u=o?f:f?.replaceAll(S,"").toLowerCase(),y=n&&u?Z(u):u;if(p){let F=s?r?.every(x=>y?.includes(x)):r?.some(x=>y?.includes(x));return i?!F:F}else{let F;return s?F=r?.every(x=>y===x):a?F=a.has(y):F=r?.some(x=>y===x),i?!F:F}}else return!0},ba=(e,t,r)=>{if(le(t,e)){let{values:a,isAnd:s,isExcluded:i,filterToPropertyMapping:{partialMatch:n}}=t,o=Ra(e,t,r).map(p=>p?.replaceAll(S,""));if(n){let p=s?a.every(u=>o?.some(y=>y?.toLowerCase().includes(u))):a.some(u=>o?.some(y=>y?.toLowerCase().includes(u))),f=o.length===0;return i?!p||f:p}else{let p=s?a.every(f=>o?.some(u=>u?.toLowerCase()===f)):a.some(f=>o?.some(u=>u?.toLowerCase()===f));return i?!p:p}}else return!0},Pa=(e,t)=>{if(le(t,e)){let{isExcluded:r}=t,a=oe(e,t);return r?!a:a}else return!0},va=(e,t)=>{if(le(t,e)){let{values:r,isExcluded:a}=t,s=oe(e,t),i=r?.some(n=>s>n);return a?!i:i}else return!0},oe=(e,t)=>{let{filterToPropertyMapping:{property:r}}=t,a;return r!==K&&(a=e[r]),a},Ra=(e,t,r)=>{let{filterToPropertyMapping:{isNestedPropertyArray:a,nestedProperty:s}}=t,i=[],n=Object.keys(e.legalOverrides||{}).length>0,o=t.filterToPropertyMapping.property===q.LegalHeroes,p=r.find(({filterToPropertyMapping:u})=>u.property===q.LegalFormats);if(n&&o&&!!p){let u=new Set;for(let{format:y,heroes:F}of e.legalOverrides||[])if(p.values.includes(y.toLowerCase()))for(let x of F)u.add(x);i=Array.from(u)}if(i.length===0)if(s){let u=new Set;for(let y of e.printings){let F=y[s];if(a){if(Array.isArray(F))for(let x of F)u.add(x)}else F&&typeof F=="string"&&u.add(F)}i=Array.from(u)}else{let u=oe(e,t);if(Array.isArray(u))for(let y of u)typeof y=="string"&&i.push(y)}return i},ka=(e,t)=>{let{filterToPropertyMapping:{specialProperty:r}}=t,a;return r&&(a=e[r]),a},le=({cardTypes:e},{types:t,subtypes:r})=>!e||e?.some(a=>t.map(s=>s.toLowerCase()).includes(a.toLowerCase())||r.map(s=>s.toLowerCase()).includes(a.toLowerCase()));var Sa=(e,t,r=[],a=[],s)=>{let{appliedFilters:i,attributes:n,keywords:o}=ne(e,t,{additionalHeroes:r,additionalSets:a,today:s});return{appliedFilters:i,attributes:n,keywords:o}};var Va=(e,t)=>{let r=new Set;for(let s of e)for(let i of s.createdExtras||[])r.add(i);let a=[];for(let s of t)r.has(s.cardIdentifier)&&a.push(s);return a};0&&(module.exports={FilterCategory,FilterKind,FilterProperty,MARKUP,NO_CARD_PROPERTY,PUNCTUATION,RARITY_VALUES_MAPPING,aliasesByFilterCategory,availableExclusions,availableModifiers,filterCard,filtersToCardPropertyMappings,getCardsByName,getCatalogueIndex,getCleanText,getEscapedForRegExp,getExcludedMetaFilters,getFilterCategory,getFilterMapping,getFilterTokenSpansForKey,getFilterValue,getIncompleteFilterToken,getIsExcludedToken,getIsValueInFilterVocabulary,getKeywordsAndAppliedFiltersFromText,getMetaFilterResolution,getMetaFilters,getNormalizedFilterValue,getNormalizedText,getParsedQuery,getQueryFilterToken,getQueryTokenSpans,getQuotedValue,getResolvedFilterKey,getSuggestedFilterKey,getTextWithoutMarkup,getTokensReferencedByCards,getUnquotedValue,getValuePartsFromFilterValue,getValuesFromFilterValue,multiWordShorthands,shorthands,singleWordShorthands});
@@ -1,4 +1,4 @@
1
- import { Card, CardRole, DoubleSidedCard } from "@flesh-and-blood/types";
1
+ import { CardRole, DoubleSidedCard } from "@flesh-and-blood/types";
2
2
  /**
3
3
  * Everything a corpus can be asked about its cards: lookups, the relations the
4
4
  * cards carry, and what each card is for. Every relation is identifier-level,
@@ -28,6 +28,11 @@ export interface CatalogueIndex<CardType extends DoubleSidedCard = DoubleSidedCa
28
28
  getCardsByExactName: (name: string) => readonly CardType[];
29
29
  /** Every card carrying the nickname, matched whole, hyphens ignored. */
30
30
  getCardsByNickname: (nickname: string) => readonly CardType[];
31
+ /**
32
+ * Every card carrying the type, subtype or trait, matched whole, hyphens
33
+ * ignored.
34
+ */
35
+ getCardsByGroup: (group: string) => readonly CardType[];
31
36
  /**
32
37
  * Every card whose name has the initials, in corpus order, counting a
33
38
  * hyphenated word both as one word and as the words the hyphens join.
@@ -72,7 +77,3 @@ export interface CatalogueIndex<CardType extends DoubleSidedCard = DoubleSidedCa
72
77
  export declare const getCatalogueIndex: <CardType extends DoubleSidedCard = DoubleSidedCard>(cards: readonly CardType[]) => CatalogueIndex<CardType>;
73
78
  /** {@link CatalogueIndex.getCardsByName}, as a free function over an index. */
74
79
  export declare const getCardsByName: (index: CatalogueIndex, name: string) => readonly DoubleSidedCard[];
75
- /** The cards naming the card, at every pitch of both. */
76
- export declare const getCardsReferencing: (index: CatalogueIndex, card: Card) => DoubleSidedCard[];
77
- /** The cards the card names, at every pitch of both. */
78
- export declare const getCardsReferencedBy: (index: CatalogueIndex, card: Card) => DoubleSidedCard[];
@@ -25,7 +25,7 @@ const getInitialsOfName = (name) => {
25
25
  }
26
26
  return [...initialsOfName];
27
27
  };
28
- const getNicknameKey = (nickname) => getCleanText(nickname).replaceAll("-", "");
28
+ const getHyphenFreeKey = (text) => getCleanText(text).replaceAll("-", "");
29
29
  const addToCardList = (cardsByKey, key, card) => {
30
30
  const cardsForKey = cardsByKey.get(key);
31
31
  if (cardsForKey) {
@@ -75,6 +75,7 @@ const getNewCatalogueIndex = (cards) => {
75
75
  let cardsByRole;
76
76
  let artists;
77
77
  let cardsByNicknameKey;
78
+ let cardsByGroup;
78
79
  let cardsByInitials;
79
80
  const getCardLookups = () => {
80
81
  if (!cardLookups) {
@@ -169,11 +170,30 @@ const getNewCatalogueIndex = (cards) => {
169
170
  cardsByNicknameKey = /* @__PURE__ */ new Map();
170
171
  for (const card of cards) {
171
172
  for (const cardNickname of card.nicknames ?? []) {
172
- addToCardList(cardsByNicknameKey, getNicknameKey(cardNickname), card);
173
+ addToCardList(
174
+ cardsByNicknameKey,
175
+ getHyphenFreeKey(cardNickname),
176
+ card
177
+ );
173
178
  }
174
179
  }
175
180
  }
176
- return cardsByNicknameKey.get(getNicknameKey(nickname)) ?? noCards;
181
+ return cardsByNicknameKey.get(getHyphenFreeKey(nickname)) ?? noCards;
182
+ };
183
+ const getCardsByGroup = (group) => {
184
+ if (!cardsByGroup) {
185
+ cardsByGroup = /* @__PURE__ */ new Map();
186
+ for (const card of cards) {
187
+ for (const cardGroup of [
188
+ ...card.types,
189
+ ...card.subtypes,
190
+ ...card.traits ?? []
191
+ ]) {
192
+ addToCardList(cardsByGroup, getHyphenFreeKey(cardGroup), card);
193
+ }
194
+ }
195
+ }
196
+ return cardsByGroup.get(getHyphenFreeKey(group)) ?? noCards;
177
197
  };
178
198
  const getCardsByInitials = (initials) => {
179
199
  if (!cardsByInitials) {
@@ -257,6 +277,7 @@ const getNewCatalogueIndex = (cards) => {
257
277
  getCardsByName: getCardsByName2,
258
278
  getCardsByExactName,
259
279
  getCardsByNickname,
280
+ getCardsByGroup,
260
281
  getCardsByInitials,
261
282
  getArtists,
262
283
  getOppositeSide,
@@ -277,34 +298,8 @@ const getCatalogueIndex = (cards) => {
277
298
  }
278
299
  return catalogueIndex;
279
300
  };
280
- const getPitchCycleOfCard = (index, card) => index.getPitchCycle(card.cardIdentifier);
281
301
  const getCardsByName = (index, name) => index.getCardsByName(name);
282
- const getCardsWithPitchSiblings = (index, cards) => {
283
- const cardByCardIdentifier = /* @__PURE__ */ new Map();
284
- for (const card of cards) {
285
- for (const pitch of getPitchCycleOfCard(index, card)) {
286
- cardByCardIdentifier.set(pitch.cardIdentifier, pitch);
287
- }
288
- }
289
- return index.getCardsInCorpusOrder([...cardByCardIdentifier.values()]);
290
- };
291
- const getCardsReferencing = (index, card) => {
292
- const referencingCards = [];
293
- for (const pitch of getPitchCycleOfCard(index, card)) {
294
- referencingCards.push(...index.getReferencedBy(pitch.cardIdentifier));
295
- }
296
- return getCardsWithPitchSiblings(index, referencingCards);
297
- };
298
- const getCardsReferencedBy = (index, card) => {
299
- const referencedCards = [];
300
- for (const pitch of getPitchCycleOfCard(index, card)) {
301
- referencedCards.push(...index.getReferences(pitch.cardIdentifier));
302
- }
303
- return getCardsWithPitchSiblings(index, referencedCards);
304
- };
305
302
  export {
306
303
  getCardsByName,
307
- getCardsReferencedBy,
308
- getCardsReferencing,
309
304
  getCatalogueIndex
310
305
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@flesh-and-blood/search",
3
3
  "description": "TypeScript search engine for Flesh and Blood cards",
4
- "version": "5.3.1",
4
+ "version": "5.4.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "main": "dist/index.cjs",
@@ -47,7 +47,7 @@
47
47
  "@flesh-and-blood/types": "^5.0.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@flesh-and-blood/cards": "^5.3.1",
50
+ "@flesh-and-blood/cards": "^5.4.0",
51
51
  "@flesh-and-blood/types": "^5.3.0",
52
52
  "@types/node": "^26.6.3",
53
53
  "esbuild": "^0.28.2",
@@ -75,5 +75,5 @@
75
75
  "FAB",
76
76
  "FABTCG"
77
77
  ],
78
- "gitHead": "43349d8a88ac6e277f32c20b5cf36f373efb45e5"
78
+ "gitHead": "b9859b97493dfa6b6d0990be6b19341ec54a315e"
79
79
  }