{"version":3,"file":"order-bucket-keys.cjs","sources":["../../../../components/data-view/utils/order-bucket-keys.tsx"],"sourcesContent":["/**\n * Bucket key standing in for a null/undefined/empty grouping value. `groupData`\n * already keys that bucket by the empty string; Timeline lanes map their `null`\n * lane key onto it so both share the ordering rule below.\n */\nexport const EMPTY_BUCKET_KEY = '';\n\n/**\n * Order bucket keys for a grouped renderer: declared keys first in the order\n * they are declared, then everything undeclared in first-seen order, then the\n * empty bucket last.\n *\n * `keys` arrives in first-seen order (a `Map`'s key order, which is insertion\n * order), and only keys that are actually present are emitted — a declared\n * value with no rows produces no section and no lane, so ordering never\n * conjures empty bands. The empty bucket is pinned last regardless of where it\n * appears in `order`, so a declared list doesn't have to mention it.\n *\n * Shared by `groupData`, which passes the grouped field's declared `groupOrder`,\n * and by `packLanesBySortValue`, which passes nothing — timeline lanes follow\n * the active sort, so only the empty-bucket-last half of the rule applies\n * there. One field that is both grouped and sorted can therefore rank its\n * sections and its lanes differently; that's the documented contract of\n * `lanePacking=\"one-per-sort-value\"`, not an oversight.\n */\nexport function orderBucketKeys(keys: string[], order?: string[]): string[] {\n  const hasEmpty = keys.includes(EMPTY_BUCKET_KEY);\n  const present = new Set(keys);\n  present.delete(EMPTY_BUCKET_KEY);\n\n  const ordered: string[] = [];\n  if (order) {\n    for (const key of order) {\n      if (!present.has(key)) continue;\n      present.delete(key);\n      ordered.push(key);\n    }\n  }\n  // Undeclared keys keep first-seen order — `keys`, not the Set, drives this.\n  for (const key of keys) {\n    if (!present.has(key)) continue;\n    present.delete(key);\n    ordered.push(key);\n  }\n  if (hasEmpty) ordered.push(EMPTY_BUCKET_KEY);\n  return ordered;\n}\n"],"names":[],"mappings":";;AAAA;;;;AAIG;AACI,MAAM,gBAAgB,GAAG,GAAG;AAEnC;;;;;;;;;;;;;;;;;AAiBG;AACa,SAAA,eAAe,CAAC,IAAc,EAAE,KAAgB,EAAA;IAC9D,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AACjD,IAAA,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;AAC9B,IAAA,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAEjC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,KAAK,EAAE;AACT,QAAA,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE;AACvB,YAAA,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;gBAAE,SAAS;AAChC,YAAA,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AACpB,YAAA,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACnB;KACF;;AAED,IAAA,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;AACtB,QAAA,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAS;AAChC,QAAA,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AACpB,QAAA,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACnB;AACD,IAAA,IAAI,QAAQ;AAAE,QAAA,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;AAC7C,IAAA,OAAO,OAAO,CAAC;AACjB;;;;;"}