{"version":3,"sources":["jsdelivr-header.js","/npm/emoji-picker-element@1.29.1/src/database/utils/assertNonEmptyString.js","/npm/emoji-picker-element@1.29.1/src/database/utils/assertNumber.js","/npm/emoji-picker-element@1.29.1/src/database/constants.js","/npm/emoji-picker-element@1.29.1/src/database/utils/uniqEmoji.js","/npm/emoji-picker-element@1.29.1/src/shared/uniqBy.js","/npm/emoji-picker-element@1.29.1/src/database/databaseLifecycle.js","/npm/emoji-picker-element@1.29.1/src/database/migrations.js","/npm/emoji-picker-element@1.29.1/src/database/utils/extractTokens.js","/npm/emoji-picker-element@1.29.1/src/database/utils/normalizeTokens.js","/npm/emoji-picker-element@1.29.1/src/database/utils/transformEmojiData.js","/npm/emoji-picker-element@1.29.1/src/database/idbUtil.js","/npm/emoji-picker-element@1.29.1/src/database/utils/findCommonMembers.js","/npm/emoji-picker-element@1.29.1/src/database/utils/minBy.js","/npm/emoji-picker-element@1.29.1/src/database/idbInterface.js","/npm/emoji-picker-element@1.29.1/src/database/utils/trie.js","/npm/emoji-picker-element@1.29.1/src/database/utils/assertCustomEmojis.js","/npm/emoji-picker-element@1.29.1/src/database/customEmojiIndex.js","/npm/emoji-picker-element@1.29.1/src/database/utils/cleanEmoji.js","/npm/emoji-picker-element@1.29.1/src/database/utils/warnETag.js","/npm/emoji-picker-element@1.29.1/src/database/utils/assertEmojiData.js","/npm/emoji-picker-element@1.29.1/src/database/utils/ajax.js","/npm/emoji-picker-element@1.29.1/src/database/utils/requiredKeys.js","/npm/emoji-picker-element@1.29.1/node_modules/.pnpm/blob-util@2.0.2/node_modules/blob-util/dist/blob-util.es.js","/npm/emoji-picker-element@1.29.1/src/database/utils/jsonChecksum.js","/npm/emoji-picker-element@1.29.1/src/database/dataLoading.js","/npm/emoji-picker-element@1.29.1/src/database/Database.js","/npm/emoji-picker-element@1.29.1/src/picker/groups.js","/npm/emoji-picker-element@1.29.1/src/picker/utils/requestIdleCallback.js","/npm/emoji-picker-element@1.29.1/src/picker/utils/hasZwj.js","/npm/emoji-picker-element@1.29.1/bin/versionsAndTestEmoji.js","/npm/emoji-picker-element@1.29.1/src/picker/constants.js","/npm/emoji-picker-element@1.29.1/src/picker/utils/testColorEmojiSupported.js","/npm/emoji-picker-element@1.29.1/src/picker/utils/determineEmojiSupportLevel.js","/npm/emoji-picker-element@1.29.1/src/picker/utils/emojiSupport.js","/npm/emoji-picker-element@1.29.1/src/picker/utils/applySkinTone.js","/npm/emoji-picker-element@1.29.1/src/picker/utils/halt.js","/npm/emoji-picker-element@1.29.1/src/picker/utils/incrementOrDecrement.js","/npm/emoji-picker-element@1.29.1/src/picker/utils/summarizeEmojisForUI.js","/npm/emoji-picker-element@1.29.1/src/picker/utils/resizeObserverAction.js","/npm/emoji-picker-element@1.29.1/src/picker/utils/calculateTextWidth.js","/npm/emoji-picker-element@1.29.1/src/picker/utils/checkZwjSupport.js","/npm/emoji-picker-element@1.29.1/src/picker/utils/requestPostAnimationFrame.js","/npm/emoji-picker-element@1.29.1/src/picker/utils/resetScrollTopIfPossible.js","/npm/emoji-picker-element@1.29.1/src/picker/components/Picker/utils.js","/npm/emoji-picker-element@1.29.1/src/picker/components/Picker/framework.js","/npm/emoji-picker-element@1.29.1/src/shared/uniq.js","/npm/emoji-picker-element@1.29.1/src/picker/components/Picker/PickerTemplate.js","/npm/emoji-picker-element@1.29.1/src/picker/components/Picker/reactivity.js","/npm/emoji-picker-element@1.29.1/src/picker/utils/arraysAreEqualByFunction.js","/npm/emoji-picker-element@1.29.1/src/picker/utils/intersectionObserverAction.js","/npm/emoji-picker-element@1.29.1/src/picker/components/Picker/Picker.js","/npm/emoji-picker-element@1.29.1/src/picker/utils/requestAnimationFrame.js","/npm/emoji-picker-element@1.29.1/src/picker/utils/queueMicrotask.js","/npm/emoji-picker-element@1.29.1/src/shared/constants.js","/npm/emoji-picker-element@1.29.1/src/picker/i18n/en.js","/npm/emoji-picker-element@1.29.1/src/picker/styles/picker.scss","/npm/emoji-picker-element@1.29.1/src/picker/PickerElement.js"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A,QAAA,cAAA,EAAA,IAA2B,EAAO,gBAE1B,kBAAf,EAAoB,WAAA,KAE9B,CAEM,IAAA,CAAA,EAAM,GACR,KAAA,KAAA,GAAA,EACF,KAAA,M,wBAGE,CAAK,SAAC,cAAsB,SAAO,IACrC,KAAA,UAEF,CAEA,SAAA,GACI,MAAC,SAAA,aAAA,YAAA,KAAA,KAEC,GAAe,EAAM,YAAA,EAAA,gBACrB,KAAO,KAAI,WAAsB,IAAA,EAAA,CAAA,SAAA,eAEvC,ChDlvBO,QAAA,G,QoDrBQ,KAAA,aAEf,EAGA,MAAE,GAAA,GAEF,IAAE,MAAA,KAAiB,GACjB,GAAW,GAAU,CACrB,GAAA,GAMS,MALT,aAAA,GAGF,KAAa,YAEF,KAAA,KAAA,EACX,EACI,GAAA,CAAQ,GACK,gBAAA,EACb,UAAA,MAAA,yBAEJ,KAAA,KAAc,EAAA,EACd,GAQA,SAAI,GAAkB,GAEtB,aAAA,IACA,OAAA,eAAA,EAAA,eAAA,IAAA,EAAA,QAAA,eAAA,UCjCA,CD0BA,OAAI,iBAA8B,GAAA,UAAA,IEjBnB,eAAA,IAAA,iBACb,eAAuB,OAAA,eAAA,W","file":"/npm/emoji-picker-element@1.29.1/index.js/+esm","sourceRoot":"","sourcesContent":["/**\n * Bundled by jsDelivr using Rollup v2.79.2 and Terser v5.39.0.\n * Original file: /npm/emoji-picker-element@1.29.1/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","export function assertNonEmptyString (str) {\n  if (typeof str !== 'string' || !str) {\n    throw new Error('expected a non-empty string, got: ' + str)\n  }\n}\n","export function assertNumber (number) {\n  if (typeof number !== 'number') {\n    throw new Error('expected a number, got: ' + number)\n  }\n}\n","export const DB_VERSION_CURRENT = 1\nexport const DB_VERSION_INITIAL = 1\nexport const STORE_EMOJI = 'emoji'\nexport const STORE_KEYVALUE = 'keyvalue'\nexport const STORE_FAVORITES = 'favorites'\nexport const FIELD_TOKENS = 'tokens'\nexport const INDEX_TOKENS = 'tokens'\nexport const FIELD_UNICODE = 'unicode'\nexport const INDEX_COUNT = 'count'\nexport const FIELD_GROUP = 'group'\nexport const FIELD_ORDER = 'order'\nexport const INDEX_GROUP_AND_ORDER = 'group-order'\nexport const KEY_ETAG = 'eTag'\nexport const KEY_URL = 'url'\nexport const KEY_PREFERRED_SKINTONE = 'skinTone'\nexport const MODE_READONLY = 'readonly'\nexport const MODE_READWRITE = 'readwrite'\nexport const INDEX_SKIN_UNICODE = 'skinUnicodes'\nexport const FIELD_SKIN_UNICODE = 'skinUnicodes'\n\nexport const DEFAULT_DATA_SOURCE = 'https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json'\nexport const DEFAULT_LOCALE = 'en'\n","import { uniqBy } from '../../shared/uniqBy'\n\nexport function uniqEmoji (emojis) {\n  return uniqBy(emojis, _ => _.unicode)\n}\n","// like lodash's uniqBy but much smaller\nexport function uniqBy (arr, func) {\n  const set = new Set()\n  const res = []\n  for (const item of arr) {\n    const key = func(item)\n    if (!set.has(key)) {\n      set.add(key)\n      res.push(item)\n    }\n  }\n  return res\n}\n","import { initialMigration } from './migrations'\nimport { DB_VERSION_INITIAL, DB_VERSION_CURRENT } from './constants'\n\nexport const openIndexedDBRequests = {}\nconst databaseCache = {}\nconst onCloseListeners = {}\n\nfunction handleOpenOrDeleteReq (resolve, reject, req) {\n  // These things are almost impossible to test with fakeIndexedDB sadly\n  /* istanbul ignore next */\n  req.onerror = () => reject(req.error)\n  /* istanbul ignore next */\n  req.onblocked = () => reject(new Error('IDB blocked'))\n  req.onsuccess = () => resolve(req.result)\n}\n\nasync function createDatabase (dbName) {\n  performance.mark('createDatabase')\n  const db = await new Promise((resolve, reject) => {\n    const req = indexedDB.open(dbName, DB_VERSION_CURRENT)\n    openIndexedDBRequests[dbName] = req\n    req.onupgradeneeded = e => {\n      // Technically there is only one version, so we don't need this `if` check\n      // But if an old version of the JS is in another browser tab\n      // and it gets upgraded in the future and we have a new DB version, well...\n      // better safe than sorry.\n      /* istanbul ignore else */\n      if (e.oldVersion < DB_VERSION_INITIAL) {\n        initialMigration(req.result)\n      }\n    }\n    handleOpenOrDeleteReq(resolve, reject, req)\n  })\n  // Handle abnormal closes, e.g. \"delete database\" in chrome dev tools.\n  // No need for removeEventListener, because once the DB can no longer\n  // fire \"close\" events, it will auto-GC.\n  db.onclose = () => closeDatabase(dbName)\n  performance.measure('createDatabase', 'createDatabase')\n  return db\n}\n\nexport function openDatabase (dbName) {\n  if (!databaseCache[dbName]) {\n    databaseCache[dbName] = createDatabase(dbName)\n  }\n  return databaseCache[dbName]\n}\n\nexport function dbPromise (db, storeName, readOnlyOrReadWrite, cb) {\n  return new Promise((resolve, reject) => {\n    // Use relaxed durability because neither the emoji data nor the favorites/preferred skin tone\n    // are really irreplaceable data. IndexedDB is just a cache in this case.\n    const txn = db.transaction(storeName, readOnlyOrReadWrite, { durability: 'relaxed' })\n    const store = typeof storeName === 'string'\n      ? txn.objectStore(storeName)\n      : storeName.map(name => txn.objectStore(name))\n    let res\n    cb(store, txn, (result) => {\n      res = result\n    })\n\n    txn.oncomplete = () => resolve(res)\n    /* istanbul ignore next */\n    txn.onerror = () => reject(txn.error)\n  })\n}\n\nexport function closeDatabase (dbName) {\n  // close any open requests\n  const req = openIndexedDBRequests[dbName]\n  const db = req && req.result\n  if (db) {\n    db.close()\n    const listeners = onCloseListeners[dbName]\n    /* istanbul ignore else */\n    if (listeners) {\n      for (const listener of listeners) {\n        listener()\n      }\n    }\n  }\n  delete openIndexedDBRequests[dbName]\n  delete databaseCache[dbName]\n  delete onCloseListeners[dbName]\n}\n\nexport function deleteDatabase (dbName) {\n  return new Promise((resolve, reject) => {\n    // close any open requests\n    closeDatabase(dbName)\n    const req = indexedDB.deleteDatabase(dbName)\n    handleOpenOrDeleteReq(resolve, reject, req)\n  })\n}\n\n// The \"close\" event occurs during an abnormal shutdown, e.g. a user clearing their browser data.\n// However, it doesn't occur with the normal \"close\" event, so we handle that separately.\n// https://www.w3.org/TR/IndexedDB/#close-a-database-connection\nexport function addOnCloseListener (dbName, listener) {\n  let listeners = onCloseListeners[dbName]\n  if (!listeners) {\n    listeners = onCloseListeners[dbName] = []\n  }\n  listeners.push(listener)\n}\n","import {\n  FIELD_GROUP, FIELD_ORDER, FIELD_UNICODE,\n  FIELD_TOKENS,\n  INDEX_GROUP_AND_ORDER,\n  STORE_EMOJI,\n  STORE_KEYVALUE,\n  STORE_FAVORITES,\n  INDEX_TOKENS, INDEX_COUNT, INDEX_SKIN_UNICODE, FIELD_SKIN_UNICODE\n} from './constants'\n\nfunction initialMigration (db) {\n  function createObjectStore (name, keyPath, indexes) {\n    const store = keyPath\n      ? db.createObjectStore(name, { keyPath })\n      : db.createObjectStore(name)\n    if (indexes) {\n      for (const [indexName, [keyPath, multiEntry]] of Object.entries(indexes)) {\n        store.createIndex(indexName, keyPath, { multiEntry })\n      }\n    }\n    return store\n  }\n\n  createObjectStore(STORE_KEYVALUE)\n  createObjectStore(STORE_EMOJI, /* keyPath */ FIELD_UNICODE, {\n    [INDEX_TOKENS]: [FIELD_TOKENS, /* multiEntry */ true],\n    [INDEX_GROUP_AND_ORDER]: [[FIELD_GROUP, FIELD_ORDER]],\n    [INDEX_SKIN_UNICODE]: [FIELD_SKIN_UNICODE, /* multiEntry */ true]\n  })\n  createObjectStore(STORE_FAVORITES, undefined, {\n    [INDEX_COUNT]: ['']\n  })\n}\n\nexport { initialMigration }\n","// list of emoticons that don't match a simple \\W+ regex\n// extracted using:\n// require('emoji-picker-element-data/en/emojibase/data.json').map(_ => _.emoticon).filter(Boolean).filter(_ => !/^\\W+$/.test(_))\nconst irregularEmoticons = new Set([\n  ':D', 'XD', \":'D\", 'O:)',\n  ':X', ':P', ';P', 'XP',\n  ':L', ':Z', ':j', '8D',\n  'XO', '8)', ':B', ':O',\n  ':S', \":'o\", 'Dx', 'X(',\n  'D:', ':C', '>0)', ':3',\n  '</3', '<3', '\\\\M/', ':E',\n  '8#'\n])\n\nexport function extractTokens (str) {\n  return str\n    .split(/[\\s_]+/)\n    .map(word => {\n      if (!word.match(/\\w/) || irregularEmoticons.has(word)) {\n        // for pure emoticons like :) or :-), just leave them as-is\n        return word.toLowerCase()\n      }\n\n      return word\n        .replace(/[)(:,]/g, '')\n        .replace(/’/g, \"'\")\n        .toLowerCase()\n    }).filter(Boolean)\n}\n","import { MIN_SEARCH_TEXT_LENGTH } from '../../shared/constants'\n\n// This is an extra step in addition to extractTokens(). The difference here is that we expect\n// the input to have already been run through extractTokens(). This is useful for cases like\n// emoticons, where we don't want to do any tokenization (because it makes no sense to split up\n// \">:)\" by the colon) but we do want to lowercase it to have consistent search results, so that\n// the user can type ':P' or ':p' and still get the same result.\nexport function normalizeTokens (str) {\n  return str\n    .filter(Boolean)\n    .map(_ => _.toLowerCase())\n    .filter(_ => _.length >= MIN_SEARCH_TEXT_LENGTH)\n}\n","import { extractTokens } from './extractTokens'\nimport { normalizeTokens } from './normalizeTokens'\n\n// Transform emoji data for storage in IDB\nexport function transformEmojiData (emojiData) {\n  performance.mark('transformEmojiData')\n  const res = emojiData.map(({ annotation, emoticon, group, order, shortcodes, skins, tags, emoji, version }) => {\n    const tokens = [...new Set(\n      normalizeTokens([\n        ...(shortcodes || []).map(extractTokens).flat(),\n        ...(tags || []).map(extractTokens).flat(),\n        ...extractTokens(annotation),\n        emoticon\n      ])\n    )].sort()\n    const res = {\n      annotation,\n      group,\n      order,\n      tags,\n      tokens,\n      unicode: emoji,\n      version\n    }\n    if (emoticon) {\n      res.emoticon = emoticon\n    }\n    if (shortcodes) {\n      res.shortcodes = shortcodes\n    }\n    if (skins) {\n      res.skinTones = []\n      res.skinUnicodes = []\n      res.skinVersions = []\n      for (const { tone, emoji, version } of skins) {\n        res.skinTones.push(tone)\n        res.skinUnicodes.push(emoji)\n        res.skinVersions.push(version)\n      }\n    }\n    return res\n  })\n  performance.measure('transformEmojiData', 'transformEmojiData')\n  return res\n}\n","// helper functions that help compress the code better\n\nfunction callStore (store, method, key, cb) {\n  store[method](key).onsuccess = e => (cb && cb(e.target.result))\n}\n\nexport function getIDB (store, key, cb) {\n  callStore(store, 'get', key, cb)\n}\n\nexport function getAllIDB (store, key, cb) {\n  callStore(store, 'getAll', key, cb)\n}\n\nexport function commit (txn) {\n  /* istanbul ignore else */\n  if (txn.commit) {\n    txn.commit()\n  }\n}\n","// return an array of results representing all items that are found in each one of the arrays\n//\nimport { minBy } from './minBy'\n\nexport function findCommonMembers (arrays, uniqByFunc) {\n  const shortestArray = minBy(arrays, _ => _.length)\n  const results = []\n  for (const item of shortestArray) {\n    // if this item is included in every array in the intermediate results, add it to the final results\n    if (!arrays.some(array => array.findIndex(_ => uniqByFunc(_) === uniqByFunc(item)) === -1)) {\n      results.push(item)\n    }\n  }\n  return results\n}\n","// like lodash's minBy\nexport function minBy (array, func) {\n  let minItem = array[0]\n  for (let i = 1; i < array.length; i++) {\n    const item = array[i]\n    if (func(minItem) > func(item)) {\n      minItem = item\n    }\n  }\n  return minItem\n}\n","import { dbPromise } from './databaseLifecycle'\nimport {\n  INDEX_COUNT,\n  INDEX_GROUP_AND_ORDER, INDEX_SKIN_UNICODE, INDEX_TOKENS, KEY_ETAG, KEY_URL,\n  MODE_READONLY, MODE_READWRITE,\n  STORE_EMOJI, STORE_FAVORITES,\n  STORE_KEYVALUE\n} from './constants'\nimport { transformEmojiData } from './utils/transformEmojiData'\nimport { extractTokens } from './utils/extractTokens'\nimport { commit, getAllIDB, getIDB } from './idbUtil'\nimport { findCommonMembers } from './utils/findCommonMembers'\nimport { normalizeTokens } from './utils/normalizeTokens'\n\nexport async function isEmpty (db) {\n  return !(await get(db, STORE_KEYVALUE, KEY_URL))\n}\n\nexport async function hasData (db, url, eTag) {\n  const [oldETag, oldUrl] = await Promise.all([KEY_ETAG, KEY_URL]\n    .map(key => get(db, STORE_KEYVALUE, key)))\n  return (oldETag === eTag && oldUrl === url)\n}\n\nasync function doFullDatabaseScanForSingleResult (db, predicate) {\n  // This batching algorithm is just a perf improvement over a basic\n  // cursor. The BATCH_SIZE is an estimate of what would give the best\n  // perf for doing a full DB scan (worst case).\n  //\n  // Mini-benchmark for determining the best batch size:\n  //\n  // PERF=1 pnpm build:rollup && pnpm test:adhoc\n  //\n  // (async () => {\n  //   performance.mark('start')\n  //   await $('emoji-picker').database.getEmojiByShortcode('doesnotexist')\n  //   performance.measure('total', 'start')\n  //   console.log(performance.getEntriesByName('total').slice(-1)[0].duration)\n  // })()\n  const BATCH_SIZE = 50 // Typically around 150ms for 6x slowdown in Chrome for above benchmark\n  return dbPromise(db, STORE_EMOJI, MODE_READONLY, (emojiStore, txn, cb) => {\n    let lastKey\n\n    const processNextBatch = () => {\n      emojiStore.getAll(lastKey && IDBKeyRange.lowerBound(lastKey, true), BATCH_SIZE).onsuccess = e => {\n        const results = e.target.result\n        for (const result of results) {\n          lastKey = result.unicode\n          if (predicate(result)) {\n            return cb(result)\n          }\n        }\n        if (results.length < BATCH_SIZE) {\n          return cb()\n        }\n        processNextBatch()\n      }\n    }\n    processNextBatch()\n  })\n}\n\nexport async function loadData (db, emojiData, url, eTag) {\n  performance.mark('loadData')\n  try {\n    const transformedData = transformEmojiData(emojiData)\n    await dbPromise(db, [STORE_EMOJI, STORE_KEYVALUE], MODE_READWRITE, ([emojiStore, metaStore], txn) => {\n      let oldETag\n      let oldUrl\n      let todo = 0\n\n      function checkFetched () {\n        if (++todo === 2) { // 2 requests made\n          onFetched()\n        }\n      }\n\n      function onFetched () {\n        if (oldETag === eTag && oldUrl === url) {\n          // check again within the transaction to guard against concurrency, e.g. multiple browser tabs\n          return\n        }\n        // delete old data\n        emojiStore.clear()\n        // insert new data\n        for (const data of transformedData) {\n          emojiStore.put(data)\n        }\n        metaStore.put(eTag, KEY_ETAG)\n        metaStore.put(url, KEY_URL)\n        commit(txn)\n        performance.mark('commitAllData')\n      }\n\n      getIDB(metaStore, KEY_ETAG, result => {\n        oldETag = result\n        checkFetched()\n      })\n\n      getIDB(metaStore, KEY_URL, result => {\n        oldUrl = result\n        checkFetched()\n      })\n    })\n    performance.measure('commitAllData', 'commitAllData')\n  } finally {\n    performance.measure('loadData', 'loadData')\n  }\n}\n\nexport async function getEmojiByGroup (db, group) {\n  return dbPromise(db, STORE_EMOJI, MODE_READONLY, (emojiStore, txn, cb) => {\n    const range = IDBKeyRange.bound([group, 0], [group + 1, 0], false, true)\n    getAllIDB(emojiStore.index(INDEX_GROUP_AND_ORDER), range, cb)\n  })\n}\n\nexport async function getEmojiBySearchQuery (db, query) {\n  const tokens = normalizeTokens(extractTokens(query))\n\n  if (!tokens.length) {\n    return []\n  }\n\n  return dbPromise(db, STORE_EMOJI, MODE_READONLY, (emojiStore, txn, cb) => {\n    // get all results that contain all tokens (i.e. an AND query)\n    const intermediateResults = []\n\n    const checkDone = () => {\n      if (intermediateResults.length === tokens.length) {\n        onDone()\n      }\n    }\n\n    const onDone = () => {\n      const results = findCommonMembers(intermediateResults, _ => _.unicode)\n      cb(results.sort((a, b) => a.order < b.order ? -1 : 1))\n    }\n\n    for (let i = 0; i < tokens.length; i++) {\n      const token = tokens[i]\n      const range = i === tokens.length - 1\n        ? IDBKeyRange.bound(token, token + '\\uffff', false, true) // treat last token as a prefix search\n        : IDBKeyRange.only(token) // treat all other tokens as an exact match\n      getAllIDB(emojiStore.index(INDEX_TOKENS), range, result => {\n        intermediateResults.push(result)\n        checkDone()\n      })\n    }\n  })\n}\n\n// This could have been implemented as an IDB index on shortcodes, but it seemed wasteful to do that\n// when we can already query by tokens and this will give us what we're looking for 99.9% of the time\nexport async function getEmojiByShortcode (db, shortcode) {\n  const emojis = await getEmojiBySearchQuery(db, shortcode)\n\n  // In very rare cases (e.g. the shortcode \"v\" as in \"v for victory\"), we cannot search because\n  // there are no usable tokens (too short in this case). In that case, we have to do an inefficient\n  // full-database scan, which I believe is an acceptable tradeoff for not having to have an extra\n  // index on shortcodes.\n\n  if (!emojis.length) {\n    const predicate = _ => ((_.shortcodes || []).includes(shortcode.toLowerCase()))\n    return (await doFullDatabaseScanForSingleResult(db, predicate)) || null\n  }\n\n  return emojis.filter(_ => {\n    const lowerShortcodes = (_.shortcodes || []).map(_ => _.toLowerCase())\n    return lowerShortcodes.includes(shortcode.toLowerCase())\n  })[0] || null\n}\n\nexport async function getEmojiByUnicode (db, unicode) {\n  return dbPromise(db, STORE_EMOJI, MODE_READONLY, (emojiStore, txn, cb) => (\n    getIDB(emojiStore, unicode, result => {\n      if (result) {\n        return cb(result)\n      }\n      getIDB(emojiStore.index(INDEX_SKIN_UNICODE), unicode, result => cb(result || null))\n    })\n  ))\n}\n\nexport function get (db, storeName, key) {\n  return dbPromise(db, storeName, MODE_READONLY, (store, txn, cb) => (\n    getIDB(store, key, cb)\n  ))\n}\n\nexport function set (db, storeName, key, value) {\n  return dbPromise(db, storeName, MODE_READWRITE, (store, txn) => {\n    store.put(value, key)\n    commit(txn)\n  })\n}\n\nexport function incrementFavoriteEmojiCount (db, unicode) {\n  return dbPromise(db, STORE_FAVORITES, MODE_READWRITE, (store, txn) => (\n    getIDB(store, unicode, result => {\n      store.put((result || 0) + 1, unicode)\n      commit(txn)\n    })\n  ))\n}\n\nexport function getTopFavoriteEmoji (db, customEmojiIndex, limit) {\n  if (limit === 0) {\n    return []\n  }\n  return dbPromise(db, [STORE_FAVORITES, STORE_EMOJI], MODE_READONLY, ([favoritesStore, emojiStore], txn, cb) => {\n    const results = []\n    favoritesStore.index(INDEX_COUNT).openCursor(undefined, 'prev').onsuccess = e => {\n      const cursor = e.target.result\n      if (!cursor) { // no more results\n        return cb(results)\n      }\n\n      function addResult (result) {\n        results.push(result)\n        if (results.length === limit) {\n          return cb(results) // done, reached the limit\n        }\n        cursor.continue()\n      }\n\n      const unicodeOrName = cursor.primaryKey\n      const custom = customEmojiIndex.byName(unicodeOrName)\n      if (custom) {\n        return addResult(custom)\n      }\n      // This could be done in parallel (i.e. make the cursor and the get()s parallelized),\n      // but my testing suggests it's not actually faster.\n      getIDB(emojiStore, unicodeOrName, emoji => {\n        if (emoji) {\n          return addResult(emoji)\n        }\n        // emoji not found somehow, ignore (may happen if custom emoji change)\n        cursor.continue()\n      })\n    }\n  })\n}\n","// trie data structure for prefix searches\n// loosely based on https://github.com/nolanlawson/substring-trie\n\nconst CODA_MARKER = '' // marks the end of the string\n\nexport function trie (arr, itemToTokens) {\n  const map = new Map()\n  for (const item of arr) {\n    const tokens = itemToTokens(item)\n    for (const token of tokens) {\n      let currentMap = map\n      for (let i = 0; i < token.length; i++) {\n        const char = token.charAt(i)\n        let nextMap = currentMap.get(char)\n        if (!nextMap) {\n          nextMap = new Map()\n          currentMap.set(char, nextMap)\n        }\n        currentMap = nextMap\n      }\n      let valuesAtCoda = currentMap.get(CODA_MARKER)\n      if (!valuesAtCoda) {\n        valuesAtCoda = []\n        currentMap.set(CODA_MARKER, valuesAtCoda)\n      }\n      valuesAtCoda.push(item)\n    }\n  }\n\n  const search = (query, exact) => {\n    let currentMap = map\n    for (let i = 0; i < query.length; i++) {\n      const char = query.charAt(i)\n      const nextMap = currentMap.get(char)\n      if (nextMap) {\n        currentMap = nextMap\n      } else {\n        return []\n      }\n    }\n\n    if (exact) {\n      const results = currentMap.get(CODA_MARKER)\n      return results || []\n    }\n\n    const results = []\n    // traverse\n    const queue = [currentMap]\n    while (queue.length) {\n      const currentMap = queue.shift()\n      const entriesSortedByKey = [...currentMap.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1)\n      for (const [key, value] of entriesSortedByKey) {\n        if (key === CODA_MARKER) { // CODA_MARKER always comes first; it's the empty string\n          results.push(...value)\n        } else {\n          queue.push(value)\n        }\n      }\n    }\n    return results\n  }\n\n  return search\n}\n","const requiredKeys = [\n  'name',\n  'url'\n]\n\nexport function assertCustomEmojis (customEmojis) {\n  const isArray = customEmojis && Array.isArray(customEmojis)\n  const firstItemIsFaulty = isArray &&\n    customEmojis.length &&\n    (!customEmojis[0] || requiredKeys.some(key => !(key in customEmojis[0])))\n  if (!isArray || firstItemIsFaulty) {\n    throw new Error('Custom emojis are in the wrong format')\n  }\n}\n","import { trie } from './utils/trie'\nimport { extractTokens } from './utils/extractTokens'\nimport { assertCustomEmojis } from './utils/assertCustomEmojis'\nimport { findCommonMembers } from './utils/findCommonMembers'\n\nexport function customEmojiIndex (customEmojis) {\n  assertCustomEmojis(customEmojis)\n\n  const sortByName = (a, b) => a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1\n\n  //\n  // all()\n  //\n  const all = customEmojis.sort(sortByName)\n\n  //\n  // search()\n  //\n  const emojiToTokens = emoji => {\n    const set = new Set()\n    if (emoji.shortcodes) {\n      for (const shortcode of emoji.shortcodes) {\n        for (const token of extractTokens(shortcode)) {\n          set.add(token)\n        }\n      }\n    }\n    return set\n  }\n  const searchTrie = trie(customEmojis, emojiToTokens)\n  const searchByExactMatch = _ => searchTrie(_, true)\n  const searchByPrefix = _ => searchTrie(_, false)\n\n  // Search by query for custom emoji. Similar to how we do this in IDB, the last token\n  // is treated as a prefix search, but every other one is treated as an exact match.\n  // Then we AND the results together\n  const search = query => {\n    const tokens = extractTokens(query)\n    const intermediateResults = tokens.map((token, i) => (\n      (i < tokens.length - 1 ? searchByExactMatch : searchByPrefix)(token)\n    ))\n    return findCommonMembers(intermediateResults, _ => _.name).sort(sortByName)\n  }\n\n  //\n  // byShortcode, byName\n  //\n  const shortcodeToEmoji = new Map()\n  const nameToEmoji = new Map()\n  for (const customEmoji of customEmojis) {\n    nameToEmoji.set(customEmoji.name.toLowerCase(), customEmoji)\n    for (const shortcode of (customEmoji.shortcodes || [])) {\n      shortcodeToEmoji.set(shortcode.toLowerCase(), customEmoji)\n    }\n  }\n\n  const byShortcode = shortcode => shortcodeToEmoji.get(shortcode.toLowerCase())\n  const byName = name => nameToEmoji.get(name.toLowerCase())\n\n  return {\n    all,\n    search,\n    byShortcode,\n    byName\n  }\n}\n","const isFirefoxContentScript = typeof wrappedJSObject !== 'undefined'\n\n// remove some internal implementation details, i.e. the \"tokens\" array on the emoji object\n// essentially, convert the emoji from the version stored in IDB to the version used in-memory\nexport function cleanEmoji (emoji) {\n  if (!emoji) {\n    return emoji\n  }\n  // if inside a Firefox content script, need to clone the emoji object to prevent Firefox from complaining about\n  // cross-origin object. See: https://github.com/nolanlawson/emoji-picker-element/issues/356\n  /* istanbul ignore if */\n  if (isFirefoxContentScript) {\n    emoji = structuredClone(emoji)\n  }\n  delete emoji.tokens\n  if (emoji.skinTones) {\n    const len = emoji.skinTones.length\n    emoji.skins = Array(len)\n    for (let i = 0; i < len; i++) {\n      emoji.skins[i] = {\n        tone: emoji.skinTones[i],\n        unicode: emoji.skinUnicodes[i],\n        version: emoji.skinVersions[i]\n      }\n    }\n    delete emoji.skinTones\n    delete emoji.skinUnicodes\n    delete emoji.skinVersions\n  }\n  return emoji\n}\n","export function warnETag (eTag) {\n  if (!eTag) {\n    console.warn('emoji-picker-element is more efficient if the dataSource server exposes an ETag header.')\n  }\n}\n","import { requiredKeys } from './requiredKeys'\n\nexport function assertEmojiData (emojiData) {\n  if (!emojiData ||\n    !Array.isArray(emojiData) ||\n    !emojiData[0] ||\n    (typeof emojiData[0] !== 'object') ||\n    requiredKeys.some(key => (!(key in emojiData[0])))) {\n    throw new Error('Emoji data is in the wrong format')\n  }\n}\n","import { warnETag } from './warnETag'\nimport { assertEmojiData } from './assertEmojiData'\n\nfunction assertStatus (response, dataSource) {\n  if (Math.floor(response.status / 100) !== 2) {\n    throw new Error('Failed to fetch: ' + dataSource + ':  ' + response.status)\n  }\n}\n\nexport async function getETag (dataSource) {\n  performance.mark('getETag')\n  const response = await fetch(dataSource, { method: 'HEAD' })\n  assertStatus(response, dataSource)\n  const eTag = response.headers.get('etag')\n  warnETag(eTag)\n  performance.measure('getETag', 'getETag')\n  return eTag\n}\n\nexport async function getETagAndData (dataSource) {\n  performance.mark('getETagAndData')\n  const response = await fetch(dataSource)\n  assertStatus(response, dataSource)\n  const eTag = response.headers.get('etag')\n  warnETag(eTag)\n  const emojiData = await response.json()\n  assertEmojiData(emojiData)\n  performance.measure('getETagAndData', 'getETagAndData')\n  return [eTag, emojiData]\n}\n","export const requiredKeys = [\n  'annotation',\n  'emoji',\n  'group',\n  'order',\n  'version'\n]\n","// TODO: including these in blob-util.ts causes typedoc to generate docs for them,\n// even with --excludePrivate ¯\\_(ツ)_/¯\n/** @private */\nfunction loadImage(src, crossOrigin) {\n    return new Promise(function (resolve, reject) {\n        var img = new Image();\n        if (crossOrigin) {\n            img.crossOrigin = crossOrigin;\n        }\n        img.onload = function () {\n            resolve(img);\n        };\n        img.onerror = reject;\n        img.src = src;\n    });\n}\n/** @private */\nfunction imgToCanvas(img) {\n    var canvas = document.createElement('canvas');\n    canvas.width = img.width;\n    canvas.height = img.height;\n    // copy the image contents to the canvas\n    var context = canvas.getContext('2d');\n    context.drawImage(img, 0, 0, img.width, img.height, 0, 0, img.width, img.height);\n    return canvas;\n}\n\n/* global Promise, Image, Blob, FileReader, atob, btoa,\n   BlobBuilder, MSBlobBuilder, MozBlobBuilder, WebKitBlobBuilder, webkitURL */\n/**\n * Shim for\n * [`new Blob()`](https://developer.mozilla.org/en-US/docs/Web/API/Blob.Blob)\n * to support\n * [older browsers that use the deprecated `BlobBuilder` API](http://caniuse.com/blob).\n *\n * Example:\n *\n * ```js\n * var myBlob = blobUtil.createBlob(['hello world'], {type: 'text/plain'});\n * ```\n *\n * @param parts - content of the Blob\n * @param properties - usually `{type: myContentType}`,\n *                           you can also pass a string for the content type\n * @returns Blob\n */\nfunction createBlob(parts, properties) {\n    parts = parts || [];\n    properties = properties || {};\n    if (typeof properties === 'string') {\n        properties = { type: properties }; // infer content type\n    }\n    try {\n        return new Blob(parts, properties);\n    }\n    catch (e) {\n        if (e.name !== 'TypeError') {\n            throw e;\n        }\n        var Builder = typeof BlobBuilder !== 'undefined'\n            ? BlobBuilder : typeof MSBlobBuilder !== 'undefined'\n            ? MSBlobBuilder : typeof MozBlobBuilder !== 'undefined'\n            ? MozBlobBuilder : WebKitBlobBuilder;\n        var builder = new Builder();\n        for (var i = 0; i < parts.length; i += 1) {\n            builder.append(parts[i]);\n        }\n        return builder.getBlob(properties.type);\n    }\n}\n/**\n * Shim for\n * [`URL.createObjectURL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL.createObjectURL)\n * to support browsers that only have the prefixed\n * `webkitURL` (e.g. Android <4.4).\n *\n * Example:\n *\n * ```js\n * var myUrl = blobUtil.createObjectURL(blob);\n * ```\n *\n * @param blob\n * @returns url\n */\nfunction createObjectURL(blob) {\n    return (typeof URL !== 'undefined' ? URL : webkitURL).createObjectURL(blob);\n}\n/**\n * Shim for\n * [`URL.revokeObjectURL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL.revokeObjectURL)\n * to support browsers that only have the prefixed\n * `webkitURL` (e.g. Android <4.4).\n *\n * Example:\n *\n * ```js\n * blobUtil.revokeObjectURL(myUrl);\n * ```\n *\n * @param url\n */\nfunction revokeObjectURL(url) {\n    return (typeof URL !== 'undefined' ? URL : webkitURL).revokeObjectURL(url);\n}\n/**\n * Convert a `Blob` to a binary string.\n *\n * Example:\n *\n * ```js\n * blobUtil.blobToBinaryString(blob).then(function (binaryString) {\n *   // success\n * }).catch(function (err) {\n *   // error\n * });\n * ```\n *\n * @param blob\n * @returns Promise that resolves with the binary string\n */\nfunction blobToBinaryString(blob) {\n    return new Promise(function (resolve, reject) {\n        var reader = new FileReader();\n        var hasBinaryString = typeof reader.readAsBinaryString === 'function';\n        reader.onloadend = function () {\n            var result = reader.result || '';\n            if (hasBinaryString) {\n                return resolve(result);\n            }\n            resolve(arrayBufferToBinaryString(result));\n        };\n        reader.onerror = reject;\n        if (hasBinaryString) {\n            reader.readAsBinaryString(blob);\n        }\n        else {\n            reader.readAsArrayBuffer(blob);\n        }\n    });\n}\n/**\n * Convert a base64-encoded string to a `Blob`.\n *\n * Example:\n *\n * ```js\n * var blob = blobUtil.base64StringToBlob(base64String);\n * ```\n * @param base64 - base64-encoded string\n * @param type - the content type (optional)\n * @returns Blob\n */\nfunction base64StringToBlob(base64, type) {\n    var parts = [binaryStringToArrayBuffer(atob(base64))];\n    return type ? createBlob(parts, { type: type }) : createBlob(parts);\n}\n/**\n * Convert a binary string to a `Blob`.\n *\n * Example:\n *\n * ```js\n * var blob = blobUtil.binaryStringToBlob(binaryString);\n * ```\n *\n * @param binary - binary string\n * @param type - the content type (optional)\n * @returns Blob\n */\nfunction binaryStringToBlob(binary, type) {\n    return base64StringToBlob(btoa(binary), type);\n}\n/**\n * Convert a `Blob` to a binary string.\n *\n * Example:\n *\n * ```js\n * blobUtil.blobToBase64String(blob).then(function (base64String) {\n *   // success\n * }).catch(function (err) {\n *   // error\n * });\n * ```\n *\n * @param blob\n * @returns Promise that resolves with the binary string\n */\nfunction blobToBase64String(blob) {\n    return blobToBinaryString(blob).then(btoa);\n}\n/**\n * Convert a data URL string\n * (e.g. `'data:image/png;base64,iVBORw0KG...'`)\n * to a `Blob`.\n *\n * Example:\n *\n * ```js\n * var blob = blobUtil.dataURLToBlob(dataURL);\n * ```\n *\n * @param dataURL - dataURL-encoded string\n * @returns Blob\n */\nfunction dataURLToBlob(dataURL) {\n    var type = dataURL.match(/data:([^;]+)/)[1];\n    var base64 = dataURL.replace(/^[^,]+,/, '');\n    var buff = binaryStringToArrayBuffer(atob(base64));\n    return createBlob([buff], { type: type });\n}\n/**\n * Convert a `Blob` to a data URL string\n * (e.g. `'data:image/png;base64,iVBORw0KG...'`).\n *\n * Example:\n *\n * ```js\n * var dataURL = blobUtil.blobToDataURL(blob);\n * ```\n *\n * @param blob\n * @returns Promise that resolves with the data URL string\n */\nfunction blobToDataURL(blob) {\n    return blobToBase64String(blob).then(function (base64String) {\n        return 'data:' + blob.type + ';base64,' + base64String;\n    });\n}\n/**\n * Convert an image's `src` URL to a data URL by loading the image and painting\n * it to a `canvas`.\n *\n * Note: this will coerce the image to the desired content type, and it\n * will only paint the first frame of an animated GIF.\n *\n * Examples:\n *\n * ```js\n * blobUtil.imgSrcToDataURL('http://mysite.com/img.png').then(function (dataURL) {\n *   // success\n * }).catch(function (err) {\n *   // error\n * });\n * ```\n *\n * ```js\n * blobUtil.imgSrcToDataURL('http://some-other-site.com/img.jpg', 'image/jpeg',\n *                          'Anonymous', 1.0).then(function (dataURL) {\n *   // success\n * }).catch(function (err) {\n *   // error\n * });\n * ```\n *\n * @param src - image src\n * @param type - the content type (optional, defaults to 'image/png')\n * @param crossOrigin - for CORS-enabled images, set this to\n *                                         'Anonymous' to avoid \"tainted canvas\" errors\n * @param quality - a number between 0 and 1 indicating image quality\n *                                     if the requested type is 'image/jpeg' or 'image/webp'\n * @returns Promise that resolves with the data URL string\n */\nfunction imgSrcToDataURL(src, type, crossOrigin, quality) {\n    type = type || 'image/png';\n    return loadImage(src, crossOrigin).then(imgToCanvas).then(function (canvas) {\n        return canvas.toDataURL(type, quality);\n    });\n}\n/**\n * Convert a `canvas` to a `Blob`.\n *\n * Examples:\n *\n * ```js\n * blobUtil.canvasToBlob(canvas).then(function (blob) {\n *   // success\n * }).catch(function (err) {\n *   // error\n * });\n * ```\n *\n * Most browsers support converting a canvas to both `'image/png'` and `'image/jpeg'`. You may\n * also want to try `'image/webp'`, which will work in some browsers like Chrome (and in other browsers, will just fall back to `'image/png'`):\n *\n * ```js\n * blobUtil.canvasToBlob(canvas, 'image/webp').then(function (blob) {\n *   // success\n * }).catch(function (err) {\n *   // error\n * });\n * ```\n *\n * @param canvas - HTMLCanvasElement\n * @param type - the content type (optional, defaults to 'image/png')\n * @param quality - a number between 0 and 1 indicating image quality\n *                                     if the requested type is 'image/jpeg' or 'image/webp'\n * @returns Promise that resolves with the `Blob`\n */\nfunction canvasToBlob(canvas, type, quality) {\n    if (typeof canvas.toBlob === 'function') {\n        return new Promise(function (resolve) {\n            canvas.toBlob(resolve, type, quality);\n        });\n    }\n    return Promise.resolve(dataURLToBlob(canvas.toDataURL(type, quality)));\n}\n/**\n * Convert an image's `src` URL to a `Blob` by loading the image and painting\n * it to a `canvas`.\n *\n * Note: this will coerce the image to the desired content type, and it\n * will only paint the first frame of an animated GIF.\n *\n * Examples:\n *\n * ```js\n * blobUtil.imgSrcToBlob('http://mysite.com/img.png').then(function (blob) {\n *   // success\n * }).catch(function (err) {\n *   // error\n * });\n * ```\n *\n * ```js\n * blobUtil.imgSrcToBlob('http://some-other-site.com/img.jpg', 'image/jpeg',\n *                          'Anonymous', 1.0).then(function (blob) {\n *   // success\n * }).catch(function (err) {\n *   // error\n * });\n * ```\n *\n * @param src - image src\n * @param type - the content type (optional, defaults to 'image/png')\n * @param crossOrigin - for CORS-enabled images, set this to\n *                                         'Anonymous' to avoid \"tainted canvas\" errors\n * @param quality - a number between 0 and 1 indicating image quality\n *                                     if the requested type is 'image/jpeg' or 'image/webp'\n * @returns Promise that resolves with the `Blob`\n */\nfunction imgSrcToBlob(src, type, crossOrigin, quality) {\n    type = type || 'image/png';\n    return loadImage(src, crossOrigin).then(imgToCanvas).then(function (canvas) {\n        return canvasToBlob(canvas, type, quality);\n    });\n}\n/**\n * Convert an `ArrayBuffer` to a `Blob`.\n *\n * Example:\n *\n * ```js\n * var blob = blobUtil.arrayBufferToBlob(arrayBuff, 'audio/mpeg');\n * ```\n *\n * @param buffer\n * @param type - the content type (optional)\n * @returns Blob\n */\nfunction arrayBufferToBlob(buffer, type) {\n    return createBlob([buffer], type);\n}\n/**\n * Convert a `Blob` to an `ArrayBuffer`.\n *\n * Example:\n *\n * ```js\n * blobUtil.blobToArrayBuffer(blob).then(function (arrayBuff) {\n *   // success\n * }).catch(function (err) {\n *   // error\n * });\n * ```\n *\n * @param blob\n * @returns Promise that resolves with the `ArrayBuffer`\n */\nfunction blobToArrayBuffer(blob) {\n    return new Promise(function (resolve, reject) {\n        var reader = new FileReader();\n        reader.onloadend = function () {\n            var result = reader.result || new ArrayBuffer(0);\n            resolve(result);\n        };\n        reader.onerror = reject;\n        reader.readAsArrayBuffer(blob);\n    });\n}\n/**\n * Convert an `ArrayBuffer` to a binary string.\n *\n * Example:\n *\n * ```js\n * var myString = blobUtil.arrayBufferToBinaryString(arrayBuff)\n * ```\n *\n * @param buffer - array buffer\n * @returns binary string\n */\nfunction arrayBufferToBinaryString(buffer) {\n    var binary = '';\n    var bytes = new Uint8Array(buffer);\n    var length = bytes.byteLength;\n    var i = -1;\n    while (++i < length) {\n        binary += String.fromCharCode(bytes[i]);\n    }\n    return binary;\n}\n/**\n * Convert a binary string to an `ArrayBuffer`.\n *\n * ```js\n * var myBuffer = blobUtil.binaryStringToArrayBuffer(binaryString)\n * ```\n *\n * @param binary - binary string\n * @returns array buffer\n */\nfunction binaryStringToArrayBuffer(binary) {\n    var length = binary.length;\n    var buf = new ArrayBuffer(length);\n    var arr = new Uint8Array(buf);\n    var i = -1;\n    while (++i < length) {\n        arr[i] = binary.charCodeAt(i);\n    }\n    return buf;\n}\n\nexport { createBlob, createObjectURL, revokeObjectURL, blobToBinaryString, base64StringToBlob, binaryStringToBlob, blobToBase64String, dataURLToBlob, blobToDataURL, imgSrcToDataURL, canvasToBlob, imgSrcToBlob, arrayBufferToBlob, blobToArrayBuffer, arrayBufferToBinaryString, binaryStringToArrayBuffer };\n","import { binaryStringToArrayBuffer, arrayBufferToBinaryString } from 'blob-util'\n\n// generate a checksum based on the stringified JSON\nexport async function jsonChecksum (object) {\n  performance.mark('jsonChecksum')\n  const inString = JSON.stringify(object)\n  let inBuffer = binaryStringToArrayBuffer(inString)\n  /* istanbul ignore else */\n  if (import.meta.env.MODE === 'test') {\n    // Issue with ArrayBuffer in jsdom https://github.com/vitest-dev/vitest/issues/5365\n    inBuffer = Buffer.from(new Uint8Array(inBuffer))\n  }\n\n  // this does not need to be cryptographically secure, SHA-1 is fine\n  const outBuffer = await crypto.subtle.digest('SHA-1', inBuffer)\n  const outBinString = arrayBufferToBinaryString(outBuffer)\n  const res = btoa(outBinString)\n  performance.measure('jsonChecksum', 'jsonChecksum')\n  return res\n}\n","import { getETag, getETagAndData } from './utils/ajax'\nimport { jsonChecksum } from './utils/jsonChecksum'\nimport { hasData, loadData } from './idbInterface'\n\nasync function doCheckForUpdates (db, dataSource) {\n  // just do a simple HEAD request first to see if the eTags match\n  let emojiData\n  let eTag = await getETag(dataSource)\n  if (!eTag) { // work around lack of ETag/Access-Control-Expose-Headers\n    const eTagAndData = await getETagAndData(dataSource)\n    eTag = eTagAndData[0]\n    emojiData = eTagAndData[1]\n    if (!eTag) {\n      eTag = await jsonChecksum(emojiData)\n    }\n  }\n  if (await hasData(db, dataSource, eTag)) {\n    console.log('Database already populated')\n  } else {\n    console.log('Database update available')\n    if (!emojiData) {\n      const eTagAndData = await getETagAndData(dataSource)\n      emojiData = eTagAndData[1]\n    }\n    await loadData(db, emojiData, dataSource, eTag)\n  }\n}\n\nexport async function loadDataForFirstTime (db, dataSource) {\n  let [eTag, emojiData] = await getETagAndData(dataSource)\n  if (!eTag) {\n    // Handle lack of support for ETag or Access-Control-Expose-Headers\n    // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers#Browser_compatibility\n    eTag = await jsonChecksum(emojiData)\n  }\n\n  await loadData(db, emojiData, dataSource, eTag)\n}\n\nexport async function checkForUpdates (db, dataSource) {\n  try {\n    await doCheckForUpdates(db, dataSource)\n  } catch (err) {\n    // Checking for updates is not a critical operation, and it can fail if e.g. the picker is quickly removed and\n    // re-added to the DOM. In those cases, we may get an IndexedDB InvalidStateError because we are attempting to close\n    // the database connection, possibly while another request is inflight. So there's effectively no way to prevent\n    // InvalidStateErrors unless we were to carefully sequence our IndexedDB operations. Much more simply, we can just\n    // ignore IndexedDB InvalidStateErrors here and give users one less useless error message in their console.\n    if (err.name !== 'InvalidStateError') {\n      throw err\n    }\n  }\n}\n","import { assertNonEmptyString } from './utils/assertNonEmptyString'\nimport { assertNumber } from './utils/assertNumber'\nimport {\n  DEFAULT_DATA_SOURCE,\n  DEFAULT_LOCALE,\n  KEY_PREFERRED_SKINTONE,\n  STORE_KEYVALUE\n} from './constants'\nimport { uniqEmoji } from './utils/uniqEmoji'\nimport {\n  closeDatabase,\n  deleteDatabase,\n  addOnCloseListener,\n  openDatabase\n} from './databaseLifecycle'\nimport {\n  isEmpty, getEmojiByGroup,\n  getEmojiBySearchQuery, getEmojiByShortcode, getEmojiByUnicode,\n  get, set, getTopFavoriteEmoji, incrementFavoriteEmojiCount\n} from './idbInterface'\nimport { customEmojiIndex } from './customEmojiIndex'\nimport { cleanEmoji } from './utils/cleanEmoji'\nimport { loadDataForFirstTime, checkForUpdates } from './dataLoading'\n\nexport default class Database {\n  constructor ({ dataSource = DEFAULT_DATA_SOURCE, locale = DEFAULT_LOCALE, customEmoji = [] } = {}) {\n    this.dataSource = dataSource\n    this.locale = locale\n    this._dbName = `emoji-picker-element-${this.locale}`\n    this._db = undefined\n    this._lazyUpdate = undefined\n    this._custom = customEmojiIndex(customEmoji)\n\n    this._clear = this._clear.bind(this)\n    this._ready = this._init()\n  }\n\n  async _init () {\n    const db = this._db = await openDatabase(this._dbName)\n\n    addOnCloseListener(this._dbName, this._clear)\n    const dataSource = this.dataSource\n    const empty = await isEmpty(db)\n\n    if (empty) {\n      await loadDataForFirstTime(db, dataSource)\n    } else { // offline-first - do an update asynchronously\n      this._lazyUpdate = checkForUpdates(db, dataSource)\n    }\n  }\n\n  async ready () {\n    const checkReady = async () => {\n      if (!this._ready) {\n        this._ready = this._init()\n      }\n      return this._ready\n    }\n    await checkReady()\n    // There's a possibility of a race condition where the element gets added, removed, and then added again\n    // with a particular timing, which would set the _db to undefined.\n    // We *could* do a while loop here, but that seems excessive and could lead to an infinite loop.\n    if (!this._db) {\n      await checkReady()\n    }\n  }\n\n  async getEmojiByGroup (group) {\n    assertNumber(group)\n    await this.ready()\n    return uniqEmoji(await getEmojiByGroup(this._db, group)).map(cleanEmoji)\n  }\n\n  async getEmojiBySearchQuery (query) {\n    assertNonEmptyString(query)\n    await this.ready()\n    const customs = this._custom.search(query)\n    const natives = uniqEmoji(await getEmojiBySearchQuery(this._db, query)).map(cleanEmoji)\n    return [\n      ...customs,\n      ...natives\n    ]\n  }\n\n  async getEmojiByShortcode (shortcode) {\n    assertNonEmptyString(shortcode)\n    await this.ready()\n    const custom = this._custom.byShortcode(shortcode)\n    if (custom) {\n      return custom\n    }\n    return cleanEmoji(await getEmojiByShortcode(this._db, shortcode))\n  }\n\n  async getEmojiByUnicodeOrName (unicodeOrName) {\n    assertNonEmptyString(unicodeOrName)\n    await this.ready()\n    const custom = this._custom.byName(unicodeOrName)\n    if (custom) {\n      return custom\n    }\n    return cleanEmoji(await getEmojiByUnicode(this._db, unicodeOrName))\n  }\n\n  async getPreferredSkinTone () {\n    await this.ready()\n    return (await get(this._db, STORE_KEYVALUE, KEY_PREFERRED_SKINTONE)) || 0\n  }\n\n  async setPreferredSkinTone (skinTone) {\n    assertNumber(skinTone)\n    await this.ready()\n    return set(this._db, STORE_KEYVALUE, KEY_PREFERRED_SKINTONE, skinTone)\n  }\n\n  async incrementFavoriteEmojiCount (unicodeOrName) {\n    assertNonEmptyString(unicodeOrName)\n    await this.ready()\n    return incrementFavoriteEmojiCount(this._db, unicodeOrName)\n  }\n\n  async getTopFavoriteEmoji (limit) {\n    assertNumber(limit)\n    await this.ready()\n    return (await getTopFavoriteEmoji(this._db, this._custom, limit)).map(cleanEmoji)\n  }\n\n  set customEmoji (customEmojis) {\n    this._custom = customEmojiIndex(customEmojis)\n  }\n\n  get customEmoji () {\n    return this._custom.all\n  }\n\n  async _shutdown () {\n    await this.ready() // reopen if we've already been closed/deleted\n    try {\n      await this._lazyUpdate // allow any lazy updates to process before closing/deleting\n    } catch (err) { /* ignore network errors (offline-first) */ }\n  }\n\n  // clear references to IDB, e.g. during a close event\n  _clear () {\n    console.log('_clear database', this._dbName)\n    // We don't need to call removeEventListener or remove the manual \"close\" listeners.\n    // The memory leak tests prove this is unnecessary. It's because:\n    // 1) IDBDatabases that can no longer fire \"close\" automatically have listeners GCed\n    // 2) we clear the manual close listeners in databaseLifecycle.js.\n    this._db = this._ready = this._lazyUpdate = undefined\n  }\n\n  async close () {\n    await this._shutdown()\n    await closeDatabase(this._dbName)\n  }\n\n  async delete () {\n    await this._shutdown()\n    await deleteDatabase(this._dbName)\n  }\n}\n","// via https://unpkg.com/browse/emojibase-data@6.0.0/meta/groups.json\nexport const allGroups = [\n  [-1, '✨', 'custom'],\n  [0, '😀', 'smileys-emotion'],\n  [1, '👋', 'people-body'],\n  [3, '🐱', 'animals-nature'],\n  [4, '🍎', 'food-drink'],\n  [5, '🏠️', 'travel-places'],\n  [6, '⚽', 'activities'],\n  [7, '📝', 'objects'],\n  [8, '⛔️', 'symbols'],\n  [9, '🏁', 'flags']\n].map(([id, emoji, name]) => ({ id, emoji, name }))\n\nexport const groups = allGroups.slice(1)\n","/* istanbul ignore next */\nconst rIC = typeof requestIdleCallback === 'function' ? requestIdleCallback : setTimeout\n\nexport { rIC as requestIdleCallback }\n","// check for ZWJ (zero width joiner) character\nexport function hasZwj (emoji) {\n  return emoji.unicode.includes('\\u200d')\n}\n","// Find one good representative emoji from each version to test by checking its color.\n// Ideally it should have color in the center. For some inspiration, see:\n// https://about.gitlab.com/blog/2018/05/30/journey-in-native-unicode-emoji/\n//\n// Note that for certain versions (12.1, 13.1), there is no point in testing them explicitly, because\n// all the emoji from this version are compound-emoji from previous versions. So they would pass a color\n// test, even in browsers that display them as double emoji. (E.g. \"face in clouds\" might render as\n// \"face without mouth\" plus \"fog\".) These emoji can only be filtered using the width test,\n// which happens in checkZwjSupport.js.\nexport const versionsAndTestEmoji = {\n  '🫪': 17, // distorted face\n  '🫩': 16, // face with bags under eyes\n  '🫨': 15.1, // shaking head, technically from v15 but see note above\n  '🫠': 14,\n  '🥲': 13.1, // smiling face with tear, technically from v13 but see note above\n  '🥻': 12.1, // sari, technically from v12 but see note above\n  '🥰': 11,\n  '🤩': 5,\n  '👱‍♀️': 4,\n  '🤣': 3,\n  '👁️‍🗨️': 2,\n  '😀': 1,\n  '😐️': 0.7,\n  '😃': 0.6\n}\n","export const TIMEOUT_BEFORE_LOADING_MESSAGE = 1000 // 1 second\nexport const DEFAULT_SKIN_TONE_EMOJI = '🖐️'\nexport const DEFAULT_NUM_COLUMNS = 8\n\n// Based on https://fivethirtyeight.com/features/the-100-most-used-emojis/ and\n// https://blog.emojipedia.org/facebook-reveals-most-and-least-used-emojis/ with\n// a bit of my own curation. (E.g. avoid the \"OK\" gesture because of connotations:\n// https://emojipedia.org/ok-hand/)\nexport const MOST_COMMONLY_USED_EMOJI = [\n  '😊',\n  '😒',\n  '❤️',\n  '👍️',\n  '😍',\n  '😂',\n  '😭',\n  '☺️',\n  '😔',\n  '😩',\n  '😏',\n  '💕',\n  '🙌',\n  '😘'\n]\n\n// It's important to list Twemoji Mozilla before everything else, because Mozilla bundles their\n// own font on some platforms (notably Windows and Linux as of this writing). Typically, Mozilla\n// updates faster than the underlying OS, and we don't want to render older emoji in one font and\n// newer emoji in another font:\n// https://github.com/nolanlawson/emoji-picker-element/pull/268#issuecomment-1073347283\nexport const FONT_FAMILY = '\"Twemoji Mozilla\",\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",' +\n  '\"Noto Color Emoji\",\"EmojiOne Color\",\"Android Emoji\",sans-serif'\n\n/* istanbul ignore next */\nexport const DEFAULT_CATEGORY_SORTING = (a, b) => a < b ? -1 : a > b ? 1 : 0\n","// Test if an emoji is supported by rendering it to canvas and checking that the color is not black\n// See https://about.gitlab.com/blog/2018/05/30/journey-in-native-unicode-emoji/\n// and https://www.npmjs.com/package/if-emoji for inspiration\n// This implementation is largely borrowed from if-emoji, adding the font-family\n\n/* istanbul ignore file */\n\nimport { FONT_FAMILY } from '../constants'\nimport { versionsAndTestEmoji } from '../../../bin/versionsAndTestEmoji'\n\n// only used in jest/vitest tests\nlet simulateCanvasError = false\nexport function setSimulateCanvasError (value) {\n  simulateCanvasError = value\n}\nlet simulateOldBrowser = false\nexport function setSimulateOldBrowser (value) {\n  simulateOldBrowser = value\n}\n\nconst getTextFeature = (text, color) => {\n  const canvas = document.createElement('canvas')\n  canvas.width = canvas.height = 1\n\n  const ctx = canvas.getContext('2d', {\n    // Improves the performance of `getImageData()`\n    // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/getContextAttributes#willreadfrequently\n    willReadFrequently: true\n  })\n  ctx.textBaseline = 'top'\n  ctx.font = `100px ${FONT_FAMILY}`\n  ctx.fillStyle = color\n  ctx.scale(0.01, 0.01)\n  ctx.fillText(text, 0, 0)\n\n  return ctx.getImageData(0, 0, 1, 1).data\n}\n\nconst compareFeatures = (feature1, feature2) => {\n  const feature1Str = [...feature1].join(',')\n  const feature2Str = [...feature2].join(',')\n  // This is RGBA, so for 0,0,0, we are checking that the first RGB is not all zeroes.\n  // Most of the time when unsupported this is 0,0,0,0, but on Chrome on Mac it is\n  // 0,0,0,61 - there is a transparency here.\n  return feature1Str === feature2Str && !feature1Str.startsWith('0,0,0,')\n}\n\nexport function testColorEmojiSupported (text) {\n  if (import.meta.env.MODE === 'test') {\n    if (simulateCanvasError) {\n      throw new Error('canvas error')\n    } else if (simulateOldBrowser) {\n      return Object.entries(versionsAndTestEmoji)\n        .filter(([emoji, version]) => version < 12)\n        .map(([emoji]) => emoji)\n        .includes(text)\n    }\n    return true // avoid using canvas in jest/vitest\n  }\n  // Render white and black and then compare them to each other and ensure they're the same\n  // color, and neither one is black. This shows that the emoji was rendered in color.\n  const feature1 = getTextFeature(text, '#000')\n  const feature2 = getTextFeature(text, '#fff')\n  return feature1 && feature2 && compareFeatures(feature1, feature2)\n}\n","// rather than check every emoji ever, which would be expensive, just check some representatives from the\n// different emoji releases to determine what the font supports\nimport { versionsAndTestEmoji } from '../../../bin/versionsAndTestEmoji'\nimport { testColorEmojiSupported } from './testColorEmojiSupported'\n\nexport function determineEmojiSupportLevel () {\n  performance.mark('determineEmojiSupportLevel')\n  const entries = Object.entries(versionsAndTestEmoji)\n  try {\n    // start with latest emoji and work backwards\n    for (const [emoji, version] of entries) {\n      if (testColorEmojiSupported(emoji)) {\n        return version\n      }\n    }\n  } catch (e) { // canvas error\n    console.log('Ignoring canvas error', e)\n  } finally {\n    performance.measure('determineEmojiSupportLevel', 'determineEmojiSupportLevel')\n  }\n  // In case of an error, be generous and just assume all emoji are supported (e.g. for canvas errors\n  // due to anti-fingerprinting add-ons). Better to show some gray boxes than nothing at all.\n  return entries[0][1] // first one in the list is the most recent version\n}\n","import { determineEmojiSupportLevel } from './determineEmojiSupportLevel'\nimport { requestIdleCallback } from './requestIdleCallback.js'\n\n// Check which emojis we know for sure aren't supported, based on Unicode version level\nlet promise\nexport const detectEmojiSupportLevel = () => {\n  if (!promise) {\n    // Delay so it can run while the IDB database is being created by the browser (on another thread).\n    // This helps especially with first load – we want to start pre-populating the database on the main thread,\n    // and then wait for IDB to commit everything, and while waiting we run this check.\n    promise = new Promise(resolve => (\n      requestIdleCallback(() => (\n        resolve(determineEmojiSupportLevel()) // delay so ideally this can run while IDB is first populating\n      ))\n    ))\n\n    /* istanbul ignore else */\n    if (import.meta.env.MODE !== 'production') {\n      promise.then(emojiSupportLevel => {\n        console.log('emoji support level', emojiSupportLevel)\n      })\n    }\n  }\n  return promise\n}\n// determine which emojis containing ZWJ (zero width joiner) characters\n// are supported (rendered as one glyph) rather than unsupported (rendered as two or more glyphs)\nexport const supportedZwjEmojis = new Map()\n","const VARIATION_SELECTOR = '\\ufe0f'\nconst SKINTONE_MODIFIER = '\\ud83c'\nconst ZWJ = '\\u200d'\nconst LIGHT_SKIN_TONE = 0x1F3FB\nconst LIGHT_SKIN_TONE_MODIFIER = 0xdffb\n\n// TODO: this is a naive implementation, we can improve it later\n// It's only used for the skintone picker, so as long as people don't customize with\n// really exotic emoji then it should work fine\nexport function applySkinTone (str, skinTone) {\n  if (skinTone === 0) {\n    return str\n  }\n  const zwjIndex = str.indexOf(ZWJ)\n  if (zwjIndex !== -1) {\n    return str.substring(0, zwjIndex) +\n      String.fromCodePoint(LIGHT_SKIN_TONE + skinTone - 1) +\n      str.substring(zwjIndex)\n  }\n  if (str.endsWith(VARIATION_SELECTOR)) {\n    str = str.substring(0, str.length - 1)\n  }\n  return str + SKINTONE_MODIFIER + String.fromCodePoint(LIGHT_SKIN_TONE_MODIFIER + skinTone - 1)\n}\n","export function halt (event) {\n  event.preventDefault()\n  event.stopPropagation()\n}\n","// Implementation left/right or up/down navigation, circling back when you\n// reach the start/end of the list\nexport function incrementOrDecrement (decrement, val, arr) {\n  val += (decrement ? -1 : 1)\n  if (val < 0) {\n    val = arr.length - 1\n  } else if (val >= arr.length) {\n    val = 0\n  }\n  return val\n}\n","// We don't need all the data on every emoji, and there are specific things we need\n// for the UI, so build a \"view model\" from the emoji object we got from the database\n\nexport function summarizeEmojisForUI (emojis, emojiSupportLevel) {\n  const toSimpleSkinsMap = skins => {\n    const res = {}\n    for (const skin of skins) {\n      // ignore arrays like [1, 2] with multiple skin tones\n      // also ignore variants that are in an unsupported emoji version\n      // (these do exist - variants from a different version than their base emoji)\n      if (typeof skin.tone === 'number' && skin.version <= emojiSupportLevel) {\n        res[skin.tone] = skin.unicode\n      }\n    }\n    return res\n  }\n\n  return emojis.map(({ unicode, skins, shortcodes, url, name, category, annotation }) => ({\n    unicode,\n    name,\n    shortcodes,\n    url,\n    category,\n    annotation,\n    id: unicode || name,\n    skins: skins && toSimpleSkinsMap(skins)\n  }))\n}\n","// \"Svelte action\"-like utility to detect layout changes via ResizeObserver.\n// If ResizeObserver is unsupported, we just use rAF once and don't bother to update.\n\nimport { requestAnimationFrame } from './requestAnimationFrame'\n\nexport let resizeObserverSupported = typeof ResizeObserver === 'function'\n\n// only used in jest/vitest tests\nexport const resetResizeObserverSupported = () => {\n  resizeObserverSupported = typeof ResizeObserver === 'function'\n}\n\nexport function resizeObserverAction (node, abortSignal, onUpdate) {\n  let resizeObserver\n  if (resizeObserverSupported) {\n    resizeObserver = new ResizeObserver(onUpdate)\n    resizeObserver.observe(node)\n  } else { // just run once, don't bother trying to track it\n    requestAnimationFrame(onUpdate)\n  }\n\n  // cleanup function (called on destroy)\n  abortSignal.addEventListener('abort', () => {\n    if (resizeObserver) {\n      console.log('ResizeObserver destroyed')\n      resizeObserver.disconnect()\n    }\n  })\n}\n","// get the width of the text inside of a DOM node, via https://stackoverflow.com/a/59525891/680742\nexport function calculateTextWidth (node) {\n  // skip running this in jest/vitest because we don't need to check for emoji support in that environment\n  /* istanbul ignore else */\n  if (import.meta.env.MODE === 'test') {\n    return 1\n  } else {\n    const range = document.createRange()\n    range.selectNode(node.firstChild)\n    return range.getBoundingClientRect().width\n  }\n}\n","import { calculateTextWidth } from './calculateTextWidth'\nimport { supportedZwjEmojis } from './emojiSupport'\nimport { BASELINE_EMOJI } from './baselineEmoji.js'\n\nlet baselineEmojiWidth\nlet fallbackNode\n\n// only used in tests\nlet simulateBrowserNotSupportingZWJEmoji = false\nexport function setSimulateBrowserNotSupportingZWJEmoji (value) {\n  simulateBrowserNotSupportingZWJEmoji = value\n}\n\nfunction calculateTextWidthWithFallback (unicode, domNode, baselineEmojiNode) {\n  const result = calculateTextWidth(domNode)\n  /* istanbul ignore if */\n  if (result === 0) {\n    // If result is 0 then very likely the emoji-picker has `display:none` or equivalent. In that case, we fall back to\n    // cloning the baseline emoji, putting that in the `document.body`, and measuring that instead. This is a perf hit,\n    // but it's better than mistakenly filtering emoji: https://github.com/nolanlawson/emoji-picker-element/issues/514\n    console.log('Picker is hidden, using fallback node for width calculation', unicode)\n    if (!fallbackNode) {\n      fallbackNode = baselineEmojiNode.cloneNode(true)\n      // We have to copy styles because we're copying from an element in the shadow DOM to the light DOM\n      // We can't use the shadow DOM because it's likely the entire picker is `display:none`\n      const styles = getComputedStyle(baselineEmojiNode)\n      // probably don't need display/align-items/justify-content but let's play it safe\n      for (const prop of ['font-family', 'line-height', 'width', 'height', 'font-size', 'display', 'align-items', 'justify-content']) {\n        // set `!important` just in case some global styles might try to overwrite this\n        fallbackNode.style.setProperty(prop, styles.getPropertyValue(prop), 'important')\n      }\n    }\n    try {\n      document.body.appendChild(fallbackNode)\n      fallbackNode.firstChild.nodeValue = unicode\n      return calculateTextWidth(fallbackNode)\n    } finally {\n      // avoid actually rendering the test emoji\n      fallbackNode.remove()\n    }\n  }\n  return result\n}\n\n/**\n * Check if the given emojis containing ZWJ characters are supported by the current browser (don't render\n * as double characters) and return true if all are supported.\n * @param zwjEmojisToCheck\n * @param baselineEmojiNode\n * @param emojiToDomNode\n */\nexport function checkZwjSupport (zwjEmojisToCheck, baselineEmojiNode, emojiToDomNode) {\n  performance.mark('checkZwjSupport')\n  let allSupported = true\n  for (const emoji of zwjEmojisToCheck) {\n    const domNode = emojiToDomNode(emoji)\n    // sanity check to make sure the node is defined properly\n    /* istanbul ignore if */\n    if (!domNode) {\n      // This is a race condition that can occur when the component is unmounted/remounted\n      // It doesn't really matter what we do here since the old context is not going to render anymore.\n      // Just bail out of emoji support detection and return `allSupported=true` since the rendering context is gone\n      continue\n    }\n    if (typeof baselineEmojiWidth === 'undefined') { // calculate the baseline emoji width only once\n      baselineEmojiWidth = calculateTextWidthWithFallback(BASELINE_EMOJI, baselineEmojiNode, baselineEmojiNode)\n    }\n    const emojiWidth = calculateTextWidthWithFallback(emoji.unicode, domNode, baselineEmojiNode)\n    // On Windows, some supported emoji are ~50% bigger than the baseline emoji, but what we really want to guard\n    // against are the ones that are 2x the size, because those are truly broken (person with red hair = person with\n    // floating red wig, black cat = cat with black square, polar bear = bear with snowflake, etc.)\n    // So here we set the threshold at 1.8 times the size of the baseline emoji.\n    const supported = !simulateBrowserNotSupportingZWJEmoji && emojiWidth / 1.8 < baselineEmojiWidth\n    supportedZwjEmojis.set(emoji.unicode, supported)\n\n    if (!supported) {\n      allSupported = false\n      console.log('Filtered unsupported ZWJ emoji', emoji.unicode, emojiWidth, baselineEmojiWidth)\n    }\n\n    /* istanbul ignore next */\n    if (supported && emojiWidth !== baselineEmojiWidth) {\n      console.log('Allowed borderline ZWJ emoji', emoji.unicode, emojiWidth, baselineEmojiWidth)\n    }\n  }\n  performance.measure('checkZwjSupport', 'checkZwjSupport')\n  return allSupported\n}\n","// Measure after style/layout are complete\n// See https://github.com/andrewiggins/afterframe\n\nimport { requestAnimationFrame } from './requestAnimationFrame'\n\nexport const requestPostAnimationFrame = callback => {\n  requestAnimationFrame(() => {\n    setTimeout(callback)\n  })\n}\n","// Note we put this in its own function outside Picker.js to avoid Svelte doing an invalidation on the \"setter\" here.\n// At best the invalidation is useless, at worst it can cause infinite loops:\n// https://github.com/nolanlawson/emoji-picker-element/pull/180\n// https://github.com/sveltejs/svelte/issues/6521\n// Also note tabpanelElement can be null if the element is disconnected immediately after connected\nexport function resetScrollTopIfPossible (element) {\n  /* istanbul ignore else */\n  if (element) { // Makes me nervous not to have this `if` guard\n    element.scrollTop = 0\n    console.log('reset scrollTop to 0')\n  } else {\n    console.log('could not reset scrollTop')\n  }\n}\n","export function getFromMap (cache, key, func) {\n  let cached = cache.get(key)\n  if (!cached) {\n    cached = func()\n    cache.set(key, cached)\n  }\n  return cached\n}\n\nexport function toString (value) {\n  return '' + value\n}\n\nexport function parseTemplate (htmlString) {\n  const template = document.createElement('template')\n  template.innerHTML = htmlString\n\n  /* istanbul ignore next */\n  if (import.meta.env.MODE !== 'production') {\n    if (template.content.children.length !== 1) {\n      throw new Error('only 1 child allowed for now')\n    }\n  }\n  return template\n}\n","import { getFromMap, parseTemplate, toString } from './utils.js'\n\nconst parseCache = new WeakMap()\nconst domInstancesCache = new WeakMap()\n// This needs to be a symbol because it needs to be different from any possible output of a key function\nconst unkeyedSymbol = Symbol('un-keyed')\n\n// for debugging\n/* istanbul ignore else */\nif (import.meta.env.MODE !== 'production') {\n  window.parseCache = parseCache\n  window.domInstancesCache = domInstancesCache\n}\n\n// Not supported in Safari <=13\nconst hasReplaceChildren = 'replaceChildren' in Element.prototype\nfunction replaceChildren (parentNode, newChildren) {\n  /* istanbul ignore else */\n  if (hasReplaceChildren) {\n    parentNode.replaceChildren(...newChildren)\n  } else { // minimal polyfill for Element.prototype.replaceChildren\n    parentNode.innerHTML = ''\n    parentNode.append(...newChildren)\n  }\n}\n\nfunction doChildrenNeedRerender (parentNode, newChildren) {\n  let oldChild = parentNode.firstChild\n  let oldChildrenCount = 0\n  // iterate using firstChild/nextSibling because browsers use a linked list under the hood\n  while (oldChild) {\n    const newChild = newChildren[oldChildrenCount]\n    // check if the old child and new child are the same\n    if (newChild !== oldChild) {\n      return true\n    }\n    oldChild = oldChild.nextSibling\n    oldChildrenCount++\n  }\n  /* istanbul ignore if */\n  if (import.meta.env.MODE !== 'production' && oldChildrenCount !== parentNode.children.length) {\n    throw new Error('parentNode.children.length is different from oldChildrenCount, it should not be')\n  }\n  // if new children length is different from old, we must re-render\n  return oldChildrenCount !== newChildren.length\n}\n\nfunction patchChildren (newChildren, instanceBinding) {\n  const { targetNode } = instanceBinding\n  let { targetParentNode } = instanceBinding\n\n  let needsRerender = false\n\n  if (targetParentNode) { // already rendered once\n    needsRerender = doChildrenNeedRerender(targetParentNode, newChildren)\n  } else { // first render of list\n    needsRerender = true\n    instanceBinding.targetNode = undefined // placeholder node not needed anymore, free memory\n    instanceBinding.targetParentNode = targetParentNode = targetNode.parentNode\n  }\n  // avoid re-rendering list if the dom nodes are exactly the same before and after\n  if (needsRerender) {\n    replaceChildren(targetParentNode, newChildren)\n  }\n}\n\nfunction patch (expressions, instanceBindings) {\n  for (const instanceBinding of instanceBindings) {\n    const {\n      targetNode,\n      currentExpression,\n      binding: {\n        expressionIndex,\n        attributeName,\n        attributeValuePre,\n        attributeValuePost\n      }\n    } = instanceBinding\n\n    const expression = expressions[expressionIndex]\n\n    if (import.meta.env.MODE !== 'production' && expression === null && (attributeValuePre || attributeValuePost)) {\n      throw new Error('framework does not support null expressions with attribute pre/post')\n    }\n    if (import.meta.env.MODE !== 'production' && expression === undefined) {\n      throw new Error('framework does not support undefined expressions - use null to explicitly remove')\n    }\n\n    if (currentExpression === expression) {\n      // no need to update, same as before\n      continue\n    }\n\n    instanceBinding.currentExpression = expression\n\n    if (attributeName) { // attribute replacement\n      if (expression === null) {\n        // null is treated as a special case by the framework - we don't render an attribute at all in this case\n        targetNode.removeAttribute(attributeName)\n      } else {\n        // attribute value is not null; set a new attribute\n        const newValue = attributeValuePre + toString(expression) + attributeValuePost\n        targetNode.setAttribute(attributeName, newValue)\n      }\n    } else { // text node / child element / children replacement\n      let newNode\n      if (Array.isArray(expression)) { // array of DOM elements produced by tag template literals\n        patchChildren(expression, instanceBinding)\n      } else if (expression instanceof Element) { // html tag template returning a DOM element\n        newNode = expression\n        /* istanbul ignore if */\n        if (import.meta.env.MODE !== 'production' && newNode === targetNode) {\n          // it seems impossible for the framework to get into this state, may as well assert on it\n          // worst case scenario is we lose focus if we call replaceWith on the same node\n          throw new Error('the newNode and targetNode are the same, this should never happen')\n        }\n        targetNode.replaceWith(newNode)\n      } else { // primitive - string, number, etc\n        // nodeValue is faster than textContent supposedly https://www.youtube.com/watch?v=LY6y3HbDVmg\n        // note we may be replacing the value in a placeholder text node\n        targetNode.nodeValue = toString(expression)\n      }\n      if (newNode) {\n        instanceBinding.targetNode = newNode\n      }\n    }\n  }\n}\n\nfunction parse (tokens) {\n  let htmlString = ''\n\n  let withinTag = false\n  let withinAttribute = false\n  let elementIndexCounter = -1 // depth-first traversal order\n\n  const elementsToBindings = new Map()\n  const elementIndexes = []\n\n  let skipTokenChars = 0\n  for (let i = 0, len = tokens.length; i < len; i++) {\n    const token = tokens[i]\n    htmlString += token.slice(skipTokenChars)\n\n    if (i === len - 1) {\n      break // no need to process characters - no more expressions to be found\n    }\n\n    for (let j = 0; j < token.length; j++) {\n      const char = token.charAt(j)\n      switch (char) {\n        case '<': {\n          const nextChar = token.charAt(j + 1)\n          /* istanbul ignore if */\n          if (import.meta.env.MODE !== 'production' && !/[/a-z]/.test(nextChar)) {\n            // we don't need to support comments ('<!') because we always use html-minify-literals\n            // also we don't support '<' inside tags, e.g. '<div> 2 < 3 </div>'\n            throw new Error('framework currently only supports a < followed by / or a-z')\n          }\n          if (nextChar === '/') { // closing tag\n            // leaving an element\n            elementIndexes.pop()\n          } else { // not a closing tag\n            withinTag = true\n            elementIndexes.push(++elementIndexCounter)\n          }\n          break\n        }\n        case '>': {\n          withinTag = false\n          withinAttribute = false\n          break\n        }\n        case '=': {\n          /* istanbul ignore if */\n          if (import.meta.env.MODE !== 'production' && !withinTag) {\n            // we don't currently support '=' anywhere but inside a tag, e.g.\n            // we don't support '<div>2 + 2 = 4</div>'\n            throw new Error('framework currently does not support = anywhere but inside a tag')\n          }\n          withinAttribute = true\n          break\n        }\n      }\n    }\n\n    const elementIndex = elementIndexes[elementIndexes.length - 1]\n    const bindings = getFromMap(elementsToBindings, elementIndex, () => [])\n\n    let attributeName\n    let attributeValuePre\n    let attributeValuePost\n    if (withinAttribute) {\n      // I never use single-quotes for attribute values in HTML, so just support double-quotes or no-quotes\n      const attributePreMatch = /(\\S+)=\"?([^\"=]*)$/.exec(token)\n      attributeName = attributePreMatch[1]\n      attributeValuePre = attributePreMatch[2]\n      const attributePostMatch = /^([^\">]*)(\"?)/.exec(tokens[i + 1])\n      attributeValuePost = attributePostMatch[1]\n      // Optimization: remove the attribute itself, so we don't create a default attribute which is either empty or just\n      // the \"pre\" text, e.g. `<div foo>` or `<div foo=\"prefix\">`. It will be replaced by the expression anyway.\n      htmlString = htmlString.slice(0, -1 * attributePreMatch[0].length)\n      skipTokenChars = attributePostMatch[0].length\n    } else {\n      skipTokenChars = 0\n    }\n\n    const binding = {\n      attributeName,\n      attributeValuePre,\n      attributeValuePost,\n      expressionIndex: i\n    }\n\n    /* istanbul ignore else */\n    if (import.meta.env.MODE !== 'production') {\n      // remind myself that this object is supposed to be immutable\n      Object.freeze(binding)\n    }\n\n    bindings.push(binding)\n\n    if (!withinTag && !withinAttribute) {\n      // Add a placeholder text node, so we can find it later. Note we only support one dynamic child text node\n      htmlString += ' '\n    }\n  }\n\n  const template = parseTemplate(htmlString)\n\n  return {\n    template,\n    elementsToBindings\n  }\n}\n\nfunction applyBindings (bindings, element, instanceBindings) {\n  for (let i = 0; i < bindings.length; i++) {\n    const binding = bindings[i]\n\n    const targetNode = binding.attributeName\n      ? element // attribute binding, just use the element itself\n      : element.firstChild // not an attribute binding, so has a placeholder text node\n\n    /* istanbul ignore if */\n    if (import.meta.env.MODE !== 'production') {\n      // We only support exactly one placeholder text node inside an element, which simplifies\n      // the implementation a lot. Also, minify-html-literals should handle any whitespace\n      // around the expression, so we should only ever see e.g. `<div>${expr}</div>`\n      if (\n        !binding.attributeName &&\n          !(element.childNodes.length === 1 && element.childNodes[0].nodeType === Node.TEXT_NODE)\n      ) {\n        throw new Error('framework only supports exactly one dynamic child text node')\n      }\n\n      if (!targetNode) {\n        throw new Error('targetNode should not be undefined')\n      }\n    }\n\n    const instanceBinding = {\n      binding,\n      targetNode,\n      targetParentNode: undefined,\n      currentExpression: undefined\n    }\n\n    /* istanbul ignore else */\n    if (import.meta.env.MODE !== 'production') {\n      // remind myself that this object is supposed to be monomorphic (for better JS engine perf)\n      Object.seal(instanceBinding)\n    }\n\n    instanceBindings.push(instanceBinding)\n  }\n}\n\nfunction traverseAndSetupBindings (rootElement, elementsToBindings) {\n  const instanceBindings = []\n\n  let topLevelBindings\n  if (elementsToBindings.size === 1 && (topLevelBindings = elementsToBindings.get(0))) {\n    // Optimization for the common case where there's only one element and one binding\n    // Skip creating a TreeWalker entirely and just handle the root DOM element\n    applyBindings(topLevelBindings, rootElement, instanceBindings)\n  } else {\n    // traverse dom\n    const treeWalker = document.createTreeWalker(rootElement, NodeFilter.SHOW_ELEMENT)\n\n    let element = rootElement\n    let elementIndex = -1\n    do {\n      const bindings = elementsToBindings.get(++elementIndex)\n      if (bindings) {\n        applyBindings(bindings, element, instanceBindings)\n      }\n    } while ((element = treeWalker.nextNode()))\n  }\n\n  return instanceBindings\n}\n\nfunction parseHtml (tokens) {\n  // All templates and bound expressions are unique per tokens array\n  const { template, elementsToBindings } = getFromMap(parseCache, tokens, () => parse(tokens))\n\n  // When we parseHtml, we always return a fresh DOM instance ready to be updated\n  const dom = template.cloneNode(true).content.firstElementChild\n  const instanceBindings = traverseAndSetupBindings(dom, elementsToBindings)\n\n  return function updateDomInstance (expressions) {\n    patch(expressions, instanceBindings)\n    return dom\n  }\n}\n\nexport function createFramework (state) {\n  const domInstances = getFromMap(domInstancesCache, state, () => new Map())\n  let domInstanceCacheKey = unkeyedSymbol\n\n  function html (tokens, ...expressions) {\n    // Each unique lexical usage of map() is considered unique due to the html`` tagged template call it makes,\n    // which has lexically unique tokens. The unkeyed symbol is just used for html`` usage outside of a map().\n    const domInstancesForTokens = getFromMap(domInstances, tokens, () => new Map())\n    const updateDomInstance = getFromMap(domInstancesForTokens, domInstanceCacheKey, () => parseHtml(tokens))\n\n    return updateDomInstance(expressions) // update with expressions\n  }\n\n  function map (array, callback, keyFunction) {\n    return array.map((item, index) => {\n      const originalCacheKey = domInstanceCacheKey\n      domInstanceCacheKey = keyFunction(item)\n      try {\n        return callback(item, index)\n      } finally {\n        domInstanceCacheKey = originalCacheKey\n      }\n    })\n  }\n\n  return { map, html }\n}\n","// like lodash's uniq\nimport { uniqBy } from './uniqBy'\n\nexport function uniq (arr) {\n  return uniqBy(arr, _ => _)\n}\n","import { createFramework } from './framework.js'\nimport { BASELINE_EMOJI } from '../../utils/baselineEmoji.js'\n\nexport function render (container, state, helpers, events, actions, refs, abortSignal, actionContext, firstRender) {\n  const { labelWithSkin, titleForEmoji, unicodeWithSkin } = helpers\n  const { html, map } = createFramework(state)\n\n  function emojiList (emojis, searchMode, prefix) {\n    return map(emojis, (emoji, i) => {\n      return html`\n      <button role=\"${searchMode ? 'option' : 'menuitem'}\"\n              aria-selected=${searchMode ? i === state.activeSearchItem : null}\n              aria-label=\"${labelWithSkin(emoji, state.currentSkinTone)}\"\n              title=\"${titleForEmoji(emoji)}\"\n              class=\"${\n                'emoji' +\n                (searchMode && i === state.activeSearchItem ? ' active' : '') +\n                (emoji.unicode ? '' : ' custom-emoji')\n              }\"\n              id=${`${prefix}-${emoji.id}`}\n              style=${emoji.unicode ? null : `--custom-emoji-background: url(${JSON.stringify(emoji.url)})`}\n      >\n        ${\n        emoji.unicode\n          ? unicodeWithSkin(emoji, state.currentSkinTone)\n          : ''\n      }\n      </button>\n    `\n      // It's important for the cache key to be unique based on the prefix, because the framework caches based on the\n      // unique tokens + cache key, and the same emoji may be used in the tab as well as in the fav bar\n    }, emoji => `${prefix}-${emoji.id}`)\n  }\n\n  const section = () => {\n    return html`\n      <section\n        data-ref=\"rootElement\"\n        class=\"picker\"\n        aria-label=\"${state.i18n.regionLabel}\"\n        style=\"${state.pickerStyle || ''}\">\n        <!-- using a spacer div because this allows us to cover up the skintone picker animation -->\n        <div class=\"pad-top\"></div>\n         <div class=\"search-row\">\n        <div class=\"search-wrapper\">\n          <!-- no need for aria-haspopup=listbox, it's the default for role=combobox\n               https://www.w3.org/TR/2017/NOTE-wai-aria-practices-1.1-20171214/examples/combobox/aria1.1pattern/listbox-combo.html\n               -->\n          <input\n            id=\"search\"\n            class=\"search\"\n            type=\"search\"\n            role=\"combobox\"\n            enterkeyhint=\"search\"\n            placeholder=\"${state.i18n.searchLabel}\"\n            autocapitalize=\"none\"\n            autocomplete=\"off\"\n            spellcheck=\"true\"\n            aria-expanded=\"${!!(state.searchMode && state.currentEmojis.length)}\"\n            aria-controls=\"search-results\"\n            aria-describedby=\"search-description\"\n            aria-autocomplete=\"list\"\n            aria-activedescendant=${state.activeSearchItemId ? `emo-${state.activeSearchItemId}` : null}\n            data-ref=\"searchElement\"\n            data-on-input=\"onSearchInput\"\n            data-on-keydown=\"onSearchKeydown\"\n          ></input>\n          <label class=\"sr-only\" for=\"search\">${state.i18n.searchLabel}</label>\n          <span id=\"search-description\" class=\"sr-only\">${state.i18n.searchDescription}</span>\n        </div>\n        <!-- For the pattern used for the skintone dropdown, see:\n        https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/\n        The one case where we deviate from the example is that we move focus from the button to the\n        listbox. (The example uses a combobox, so it's not exactly the same.) This was tested in NVDA and VoiceOver. -->\n        <div class=\"skintone-button-wrapper ${state.skinTonePickerExpandedAfterAnimation ? 'expanded' : ''}\">\n        <button id=\"skintone-button\"\n                class=\"emoji ${state.skinTonePickerExpanded ? 'hide-focus' : ''}\"\n                aria-label=\"${state.skinToneButtonLabel}\"\n                title=\"${state.skinToneButtonLabel}\"\n                aria-describedby=\"skintone-description\"\n                aria-haspopup=\"listbox\"\n                aria-expanded=\"${state.skinTonePickerExpanded}\"\n                aria-controls=\"skintone-list\"\n                data-on-click=\"onClickSkinToneButton\">\n          ${state.skinToneButtonText || ''}\n        </button>\n      </div>\n      <span id=\"skintone-description\" class=\"sr-only\">${state.i18n.skinToneDescription}</span>\n      <div\n        data-ref=\"skinToneDropdown\"\n        id=\"skintone-list\"\n        class=\"skintone-list hide-focus ${state.skinTonePickerExpanded ? '' : 'hidden no-animate'}\"\n        style=\"transform:translateY(${state.skinTonePickerExpanded ? 0 : 'calc(-1 * var(--num-skintones) * var(--total-emoji-size))'})\"\n        role=\"listbox\"\n        aria-label=\"${state.i18n.skinTonesLabel}\"\n        aria-activedescendant=\"skintone-${state.activeSkinTone}\"\n        aria-hidden=\"${!state.skinTonePickerExpanded}\"\n        tabIndex=\"-1\"\n        data-on-focusout=\"onSkinToneOptionsFocusOut\"\n        data-on-click=\"onSkinToneOptionsClick\"\n        data-on-keydown=\"onSkinToneOptionsKeydown\"\n        data-on-keyup=\"onSkinToneOptionsKeyup\">\n        ${\n    map(state.skinTones, (skinTone, i) => {\n    return html`\n        <div id=\"skintone-${i}\"\n             class=\"emoji ${i === state.activeSkinTone ? 'active' : ''}\"\n             aria-selected=\"${i === state.activeSkinTone}\"\n             role=\"option\"\n             title=\"${state.i18n.skinTones[i]}\"\n             aria-label=\"${state.i18n.skinTones[i]}\">\n          ${skinTone}\n        </div>\n      `\n    }, skinTone => skinTone)\n        }\n      </div>\n      </div>\n        <!-- this is interactive because of keydown; it doesn't really need focus -->\n        <div class=\"nav\"\n             role=\"tablist\"\n             style=\"grid-template-columns: repeat(${state.groups.length}, 1fr)\"\n             aria-label=\"${state.i18n.categoriesLabel}\"\n             data-on-keydown=\"onNavKeydown\"\n             data-on-click=\"onNavClick\"\n        >\n          ${\n            map(state.groups, (group) => {\n              return html`\n        <button role=\"tab\"\n                class=\"nav-button\"\n                aria-controls=\"tab-${group.id}\"\n                aria-label=\"${state.i18n.categories[group.name]}\"\n                aria-selected=\"${!state.searchMode && state.currentGroup.id === group.id}\"\n                title=\"${state.i18n.categories[group.name]}\"\n                data-group-id=${group.id}\n        >\n          <div class=\"nav-emoji emoji\">\n            ${group.emoji}\n          </div>\n        </button>\n      `\n            }, group => group.id)\n          }\n        </div>\n        <div class=\"indicator-wrapper\">\n          <!-- Note we cannot test RTL in Jest because of lack of getComputedStyle() -->\n          <div class=\"indicator\"\n               style=\"transform: translateX(${(/* istanbul ignore next */ (state.isRtl ? -1 : 1)) * state.currentGroupIndex * 100}%)\">\n          </div>\n        </div>\n\n        <div class=\"message ${state.message ? '' : 'gone'}\"\n             role=\"alert\"\n             aria-live=\"polite\">\n          ${state.message || ''}\n        </div>\n\n        <!--The tabindex=0 is so people can scroll up and down with the keyboard. The element has a role and a label, so I\n        feel it's appropriate to have the tabindex.\n        This on:click is a delegated click listener -->\n        <div data-ref=\"tabpanelElement\" \n             class=\"tabpanel ${(!state.databaseLoaded || state.message) ? 'gone' : ''}\"\n             role=\"${state.searchMode ? 'region' : 'tabpanel'}\"\n             aria-label=\"${state.searchMode ? state.i18n.searchResultsLabel : state.i18n.categories[state.currentGroup.name]}\"\n             id=${state.searchMode ? null : `tab-${state.currentGroup.id}`}\n             tabIndex=\"0\"\n             data-on-click=\"onEmojiClick\"\n        >\n          <div data-action=\"calculateEmojiGridStyle\">\n            ${\n              map(state.currentEmojisWithCategories, (emojiWithCategory, i) => {\n                return html`\n        <!-- wrapper div so there's one top level element for this loop -->\n        <div>\n          <div\n            id=\"menu-label-${i}\"\n            class=\"category ${state.currentEmojisWithCategories.length === 1 && state.currentEmojisWithCategories[0].category === '' ? 'gone' : ''}\"\n            aria-hidden=\"true\">\n            <!-- This logic is a bit complicated in order to avoid a flash of the word \"Custom\" while switching\n                 from a tabpanel with custom emoji to a regular group. I.e. we don't want it to suddenly flash\n                 from \"Custom\" to \"Smileys and emoticons\" when you click the second nav button. The easiest\n                 way to repro this is to add an artificial delay to the IndexedDB operations. -->\n            ${\n                  state.searchMode\n                    ? state.i18n.searchResultsLabel\n                    : (\n                      emojiWithCategory.category\n                        ? emojiWithCategory.category\n                        : (\n                          state.currentEmojisWithCategories.length > 1\n                            ? state.i18n.categories.custom\n                            : state.i18n.categories[state.currentGroup.name]\n                        )\n                    )\n                }\n          </div>\n            <!--\n              Improve performance in custom emoji by using \\`content-visibility: auto\\` on emoji categories.\n              The \\`--num-rows\\` is used in these calculations to contain the intrinsic height.\n              Note that we only enable this for:\n                - categories beyond the first one\n                - non-search mode \n                - custom emoji group (id -1)\n              We only need the optimization for large lists of custom emoji (issue #444). Enabling it for non-custom\n              emoji causes a bug in Firefox (issue #453). We also don't do it for the first category because this \n              causes blank emoji rendering when switching tabs or searching and un-searching. (Plus it's kind of \n              pointless to do \\`content-visibility: auto\\` for the first category, since it's immediately shown.)\n            -->\n          <div class=\"emoji-menu ${i !== 0 && !state.searchMode && state.currentGroup.id === -1 ? 'visibility-auto' : ''}\"\n               style=${`--num-rows: ${Math.ceil(emojiWithCategory.emojis.length / state.numColumns)}`}\n               data-action=\"updateOnIntersection\"\n               role=\"${state.searchMode ? 'listbox' : 'menu'}\"\n               aria-labelledby=\"menu-label-${i}\"\n               id=${state.searchMode ? 'search-results' : null}\n          >\n            ${\n              emojiList(emojiWithCategory.emojis, state.searchMode, /* prefix */ 'emo')\n            }\n          </div>\n        </div>\n      `\n              }, emojiWithCategory => emojiWithCategory.category)\n            }\n          </div>\n        </div>\n        <!-- This on:click is a delegated click listener -->\n        <div class=\"favorites onscreen emoji-menu ${state.message ? 'gone' : ''}\"\n             role=\"menu\"\n             aria-label=\"${state.i18n.favoritesLabel}\"\n             data-on-click=\"onEmojiClick\">\n          ${\n            emojiList(state.currentFavorites, /* searchMode */ false, /* prefix */ 'fav')\n          }\n        </div>\n        <!-- This serves as a baseline emoji for measuring against and determining emoji support -->\n        <!-- it must match BASELINE_EMOJI in baselineEmoji.js - inlined to avoid unnecessary templating perf tax -->\n        <button data-ref=\"baselineEmoji\" aria-hidden=\"true\" tabindex=\"-1\" class=\"abs-pos hidden emoji baseline-emoji\">\n          😀\n        </button>\n      </section>\n    `\n  }\n\n  const rootDom = section()\n\n  // helper for traversing the dom, finding elements by an attribute, and getting the attribute value\n  const forElementWithAttribute = (attributeName, callback) => {\n    for (const element of container.querySelectorAll(`[${attributeName}]`)) {\n      callback(element, element.getAttribute(attributeName))\n    }\n  }\n\n  if (firstRender) { // not a re-render\n    container.appendChild(rootDom)\n\n    // we only bind events/refs once - there is no need to find them again given this component structure\n\n    // bind events\n    for (const eventName of ['click', 'focusout', 'input', 'keydown', 'keyup']) {\n      forElementWithAttribute(`data-on-${eventName}`, (element, listenerName) => {\n        element.addEventListener(eventName, events[listenerName])\n      })\n    }\n\n    // find refs\n    forElementWithAttribute('data-ref', (element, ref) => {\n      refs[ref] = element\n    })\n\n    // destroy/abort logic\n    abortSignal.addEventListener('abort', () => {\n      container.removeChild(rootDom)\n    })\n  }\n\n  // set up actions - these are re-bound on every render\n  forElementWithAttribute('data-action', (element, action) => {\n    let boundActions = actionContext.get(action)\n    if (!boundActions) {\n      actionContext.set(action, (boundActions = new WeakSet()))\n    }\n\n    // avoid applying the same action to the same element multiple times\n    if (!boundActions.has(element)) {\n      boundActions.add(element)\n      actions[action](element)\n    }\n  })\n}\n","import { queueMicrotask } from '../../utils/queueMicrotask.js'\n\nexport function createState (abortSignal) {\n  let destroyed = false\n  let currentObserver\n\n  const propsToObservers = new Map()\n  const dirtyObservers = new Set()\n\n  let queued\n\n  let recursionDepth = 0\n  const MAX_RECURSION_DEPTH = 30\n\n  const flush = () => {\n    if (destroyed) {\n      return\n    }\n    /* istanbul ignore if */\n    if (import.meta.env.MODE !== 'production' && recursionDepth === MAX_RECURSION_DEPTH) {\n      throw new Error('max recursion depth, you probably didn\\'t mean to do this')\n    }\n    const observersToRun = [...dirtyObservers]\n    dirtyObservers.clear() // clear before running to force any new updates to run in another tick of the loop\n    try {\n      for (const observer of observersToRun) {\n        observer()\n      }\n    } finally {\n      queued = false\n      if (dirtyObservers.size) { // new updates, queue another one\n        recursionDepth++\n        queued = true\n        queueMicrotask(flush)\n      }\n    }\n  }\n\n  const state = new Proxy({}, {\n    get (target, prop) {\n      if (currentObserver) {\n        let observers = propsToObservers.get(prop)\n        if (!observers) {\n          observers = new Set()\n          propsToObservers.set(prop, observers)\n        }\n        observers.add(currentObserver)\n      }\n      return target[prop]\n    },\n    set (target, prop, newValue) {\n      if (target[prop] !== newValue) {\n        target[prop] = newValue\n        const observers = propsToObservers.get(prop)\n        if (observers) {\n          for (const observer of observers) {\n            dirtyObservers.add(observer)\n          }\n          if (!queued) {\n            recursionDepth = 0\n            queued = true\n            queueMicrotask(flush)\n          }\n        }\n      }\n      return true\n    }\n  })\n\n  const createEffect = (callback) => {\n    const runnable = () => {\n      const oldObserver = currentObserver\n      currentObserver = runnable\n      try {\n        return callback()\n      } finally {\n        currentObserver = oldObserver\n      }\n    }\n    return runnable()\n  }\n\n  // for debugging\n  /* istanbul ignore else */\n  if (import.meta.env.MODE !== 'production') {\n    window.state = state\n  }\n\n  // destroy logic\n  abortSignal.addEventListener('abort', () => {\n    destroyed = true\n\n    /* istanbul ignore else */\n    if (import.meta.env.MODE !== 'production') {\n      delete window.state\n    }\n  })\n\n  return {\n    state,\n    createEffect\n  }\n}\n","// Compare two arrays, with a function called on each item in the two arrays that returns true if the items are equal\nexport function arraysAreEqualByFunction (left, right, areEqualFunc) {\n  if (left.length !== right.length) {\n    return false\n  }\n  for (let i = 0; i < left.length; i++) {\n    if (!areEqualFunc(left[i], right[i])) {\n      return false\n    }\n  }\n  return true\n}\n","const intersectionObserverCache = new WeakMap()\n\nexport function intersectionObserverAction (node, abortSignal, listener) {\n  /* istanbul ignore else */\n  if (import.meta.env.MODE === 'test') {\n    // jsdom doesn't support intersection observer; just fake it\n    listener([{ target: node, isIntersecting: true }])\n  } else {\n    // The scroll root is always `.tabpanel`\n    const root = node.closest('.tabpanel')\n\n    let observer = intersectionObserverCache.get(root)\n    if (!observer) {\n      // TODO: replace this with the contentvisibilityautostatechange event when all supported browsers support it.\n      // For now we use IntersectionObserver because it has better cross-browser support, and it would be bad for\n      // old Safari versions if they eagerly downloaded all custom emoji all at once.\n      observer = new IntersectionObserver(listener, {\n        root,\n        // trigger if we are 1/2 scroll container height away so that the images load a bit quicker while scrolling\n        rootMargin: '50% 0px 50% 0px',\n        // trigger if any part of the emoji grid is intersecting\n        threshold: 0\n      })\n\n      // avoid creating a new IntersectionObserver for every category; just use one for the whole root\n      intersectionObserverCache.set(root, observer)\n\n      // assume that the abortSignal is always the same for this root node; just add one event listener\n      abortSignal.addEventListener('abort', () => {\n        console.log('IntersectionObserver destroyed')\n        observer.disconnect()\n      })\n    }\n\n    observer.observe(node)\n  }\n}\n","/* eslint-disable prefer-const,no-labels,no-inner-declarations */\nimport { groups as defaultGroups, allGroups as groupsWithCustom } from '../../groups'\nimport { MIN_SEARCH_TEXT_LENGTH, NUM_SKIN_TONES } from '../../../shared/constants'\nimport { requestIdleCallback } from '../../utils/requestIdleCallback'\nimport { hasZwj } from '../../utils/hasZwj'\nimport { detectEmojiSupportLevel, supportedZwjEmojis } from '../../utils/emojiSupport'\nimport { applySkinTone } from '../../utils/applySkinTone'\nimport { halt } from '../../utils/halt'\nimport { incrementOrDecrement } from '../../utils/incrementOrDecrement'\nimport {\n  DEFAULT_NUM_COLUMNS,\n  MOST_COMMONLY_USED_EMOJI,\n  TIMEOUT_BEFORE_LOADING_MESSAGE\n} from '../../constants'\nimport { uniqBy } from '../../../shared/uniqBy'\nimport { summarizeEmojisForUI } from '../../utils/summarizeEmojisForUI'\nimport { resizeObserverAction } from '../../utils/resizeObserverAction.js'\nimport { checkZwjSupport } from '../../utils/checkZwjSupport'\nimport { requestPostAnimationFrame } from '../../utils/requestPostAnimationFrame'\nimport { requestAnimationFrame } from '../../utils/requestAnimationFrame'\nimport { uniq } from '../../../shared/uniq'\nimport { resetScrollTopIfPossible } from '../../utils/resetScrollTopIfPossible.js'\nimport { render } from './PickerTemplate.js'\nimport { createState } from './reactivity.js'\nimport { arraysAreEqualByFunction } from '../../utils/arraysAreEqualByFunction.js'\nimport { intersectionObserverAction } from '../../utils/intersectionObserverAction.js'\n\n// constants\nconst EMPTY_ARRAY = []\n\nconst { assign } = Object\n\nexport function createRoot (shadowRoot, props) {\n  const refs = {}\n  const abortController = new AbortController()\n  const abortSignal = abortController.signal\n  const { state, createEffect } = createState(abortSignal)\n  const actionContext = new Map()\n\n  // initial state\n  assign(state, {\n    skinToneEmoji: undefined,\n    i18n: undefined,\n    database: undefined,\n    customEmoji: undefined,\n    customCategorySorting: undefined,\n    emojiVersion: undefined\n  })\n\n  // public props\n  assign(state, props)\n\n  // private props\n  assign(state, {\n    initialLoad: true,\n    currentEmojis: [],\n    currentEmojisWithCategories: [],\n    rawSearchText: '',\n    searchText: '',\n    searchMode: false,\n    activeSearchItem: -1,\n    message: undefined,\n    skinTonePickerExpanded: false,\n    skinTonePickerExpandedAfterAnimation: false,\n    currentSkinTone: 0,\n    activeSkinTone: 0,\n    skinToneButtonText: undefined,\n    pickerStyle: undefined,\n    skinToneButtonLabel: '',\n    skinTones: [],\n    currentFavorites: [],\n    defaultFavoriteEmojis: undefined,\n    numColumns: DEFAULT_NUM_COLUMNS,\n    isRtl: false,\n    currentGroupIndex: 0,\n    groups: defaultGroups,\n    databaseLoaded: false,\n    activeSearchItemId: undefined\n  })\n\n  //\n  // Update the current group based on the currentGroupIndex\n  //\n  createEffect(() => {\n    if (state.currentGroup !== state.groups[state.currentGroupIndex]) {\n      state.currentGroup = state.groups[state.currentGroupIndex]\n    }\n  })\n\n  //\n  // Utils/helpers\n  //\n\n  const focus = id => {\n    shadowRoot.getElementById(id).focus()\n  }\n\n  const emojiToDomNode = emoji => shadowRoot.getElementById(`emo-${emoji.id}`)\n\n  // fire a custom event that crosses the shadow boundary\n  const fireEvent = (name, detail) => {\n    refs.rootElement.dispatchEvent(new CustomEvent(name, {\n      detail,\n      bubbles: true,\n      composed: true\n    }))\n  }\n\n  //\n  // Comparison utils\n  //\n\n  const compareEmojiArrays = (a, b) => a.id === b.id\n\n  const compareCurrentEmojisWithCategories = (a, b) => {\n    const { category: aCategory, emojis: aEmojis } = a\n    const { category: bCategory, emojis: bEmojis } = b\n\n    if (aCategory !== bCategory) {\n      return false\n    }\n\n    return arraysAreEqualByFunction(aEmojis, bEmojis, compareEmojiArrays)\n  }\n\n  //\n  // Update utils to avoid excessive re-renders\n  //\n\n  // avoid excessive re-renders by checking the value before setting\n  const updateCurrentEmojis = (newEmojis) => {\n    if (!arraysAreEqualByFunction(state.currentEmojis, newEmojis, compareEmojiArrays)) {\n      state.currentEmojis = newEmojis\n    }\n  }\n\n  // avoid excessive re-renders\n  const updateSearchMode = (newSearchMode) => {\n    if (state.searchMode !== newSearchMode) {\n      state.searchMode = newSearchMode\n    }\n  }\n\n  // avoid excessive re-renders\n  const updateCurrentEmojisWithCategories = (newEmojisWithCategories) => {\n    if (!arraysAreEqualByFunction(state.currentEmojisWithCategories, newEmojisWithCategories, compareCurrentEmojisWithCategories)) {\n      state.currentEmojisWithCategories = newEmojisWithCategories\n    }\n  }\n\n  // Helpers used by PickerTemplate\n\n  const unicodeWithSkin = (emoji, currentSkinTone) => (\n    (currentSkinTone && emoji.skins && emoji.skins[currentSkinTone]) || emoji.unicode\n  )\n\n  const labelWithSkin = (emoji, currentSkinTone) => (\n    uniq([\n      (emoji.name || unicodeWithSkin(emoji, currentSkinTone)),\n      emoji.annotation,\n      ...(emoji.shortcodes || EMPTY_ARRAY)\n    ].filter(Boolean)).join(', ')\n  )\n\n  const titleForEmoji = (emoji) => (\n    emoji.annotation || (emoji.shortcodes || EMPTY_ARRAY).join(', ')\n  )\n\n  const helpers = {\n    labelWithSkin, titleForEmoji, unicodeWithSkin\n  }\n  const events = {\n    onClickSkinToneButton,\n    onEmojiClick,\n    onNavClick,\n    onNavKeydown,\n    onSearchKeydown,\n    onSkinToneOptionsClick,\n    onSkinToneOptionsFocusOut,\n    onSkinToneOptionsKeydown,\n    onSkinToneOptionsKeyup,\n    onSearchInput\n  }\n  const actions = {\n    calculateEmojiGridStyle,\n    updateOnIntersection\n  }\n\n  let firstRender = true\n  createEffect(() => {\n    render(shadowRoot, state, helpers, events, actions, refs, abortSignal, actionContext, firstRender)\n    firstRender = false\n  })\n\n  //\n  // Determine the emoji support level (in requestIdleCallback)\n  //\n\n  // mount logic\n  if (!state.emojiVersion) {\n    detectEmojiSupportLevel().then(level => {\n      // Can't actually test emoji support in Jest/Vitest/JSDom, emoji never render in color in Cairo\n      /* istanbul ignore next */\n      if (!level) {\n        state.message = state.i18n.emojiUnsupportedMessage\n      }\n    })\n  }\n\n  //\n  // Set or update the database object\n  //\n\n  createEffect(() => {\n    // show a Loading message if it takes a long time, or show an error if there's a network/IDB error\n    async function handleDatabaseLoading () {\n      let showingLoadingMessage = false\n      const timeoutHandle = setTimeout(() => {\n        showingLoadingMessage = true\n        state.message = state.i18n.loadingMessage\n      }, TIMEOUT_BEFORE_LOADING_MESSAGE)\n      try {\n        await state.database.ready()\n        state.databaseLoaded = true // eslint-disable-line no-unused-vars\n      } catch (err) {\n        console.error(err)\n        state.message = state.i18n.networkErrorMessage\n      } finally {\n        clearTimeout(timeoutHandle)\n        if (showingLoadingMessage) { // Seems safer than checking the i18n string, which may change\n          showingLoadingMessage = false\n          state.message = '' // eslint-disable-line no-unused-vars\n        }\n      }\n    }\n\n    if (state.database) {\n      /* no await */\n      handleDatabaseLoading()\n    }\n  })\n\n  //\n  // Global styles for the entire picker\n  //\n\n  createEffect(() => {\n    state.pickerStyle = `\n      --num-groups: ${state.groups.length}; \n      --indicator-opacity: ${state.searchMode ? 0 : 1}; \n      --num-skintones: ${NUM_SKIN_TONES};`\n  })\n\n  //\n  // Set or update the customEmoji\n  //\n\n  createEffect(() => {\n    if (state.customEmoji && state.database) {\n      console.log('updating custom emoji')\n      updateCustomEmoji() // re-run whenever customEmoji change\n    }\n  })\n\n  createEffect(() => {\n    if (state.customEmoji && state.customEmoji.length) {\n      if (state.groups !== groupsWithCustom) { // don't update unnecessarily\n        state.groups = groupsWithCustom\n      }\n    } else if (state.groups !== defaultGroups) {\n      if (state.currentGroupIndex) {\n        // If the current group is anything other than \"custom\" (which is first), decrement.\n        // This fixes the odd case where you set customEmoji, then pick a category, then unset customEmoji\n        state.currentGroupIndex--\n      }\n      state.groups = defaultGroups\n    }\n  })\n\n  //\n  // Set or update the preferred skin tone\n  //\n\n  createEffect(() => {\n    async function updatePreferredSkinTone () {\n      if (state.databaseLoaded) {\n        state.currentSkinTone = await state.database.getPreferredSkinTone()\n      }\n    }\n\n    /* no await */ updatePreferredSkinTone()\n  })\n\n  createEffect(() => {\n    console.log('setting skinTones')\n    state.skinTones = Array(NUM_SKIN_TONES).fill().map((_, i) => applySkinTone(state.skinToneEmoji, i))\n  })\n\n  createEffect(() => {\n    console.log('setting skinToneButtonText')\n    state.skinToneButtonText = state.skinTones[state.currentSkinTone]\n  })\n\n  createEffect(() => {\n    state.skinToneButtonLabel = state.i18n.skinToneLabel.replace('{skinTone}', state.i18n.skinTones[state.currentSkinTone])\n  })\n\n  //\n  // Set or update the favorites emojis\n  //\n\n  createEffect(() => {\n    async function updateDefaultFavoriteEmojis () {\n      const { database } = state\n      const favs = (await Promise.all(MOST_COMMONLY_USED_EMOJI.map(unicode => (\n        database.getEmojiByUnicodeOrName(unicode)\n      )))).filter(Boolean) // filter because in Jest/Vitest tests we don't have all the emoji in the DB\n      state.defaultFavoriteEmojis = favs\n    }\n\n    if (state.databaseLoaded) {\n      /* no await */ updateDefaultFavoriteEmojis()\n    }\n  })\n\n  function updateCustomEmoji () {\n    // Certain effects have an implicit dependency on customEmoji since it affects the database\n    // Getting it here on the state ensures this effect re-runs when customEmoji change.\n    const { customEmoji, database } = state\n    const databaseCustomEmoji = customEmoji || EMPTY_ARRAY\n    if (database.customEmoji !== databaseCustomEmoji) {\n      // Avoid setting this if the customEmoji have _not_ changed, because the setter triggers a re-computation of the\n      // `customEmojiIndex`. Note we don't bother with deep object changes.\n      database.customEmoji = databaseCustomEmoji\n    }\n  }\n\n  createEffect(() => {\n    async function updateFavorites () {\n      console.log('updateFavorites')\n      updateCustomEmoji() // re-run whenever customEmoji change\n      const { database, defaultFavoriteEmojis, numColumns } = state\n      const dbFavorites = await database.getTopFavoriteEmoji(numColumns)\n      const favorites = await summarizeEmojis(uniqBy([\n        ...dbFavorites,\n        ...defaultFavoriteEmojis\n      ], _ => (_.unicode || _.name)).slice(0, numColumns))\n      state.currentFavorites = favorites\n    }\n\n    if (state.databaseLoaded && state.defaultFavoriteEmojis) {\n      /* no await */ updateFavorites()\n    }\n  })\n\n  //\n  // Re-run whenever the emoji grid changes size, and re-calc style/layout-related state variables:\n  // 1) Re-calculate the --num-columns var because it may have changed\n  // 2) Re-calculate whether we're in RTL mode or not.\n  //\n  // The benefit of doing this in one place is to align with rAF/ResizeObserver\n  // and do all the calculations in one go. RTL vs LTR is not strictly layout-related,\n  // but since we're already reading the style here, and since it's already aligned with\n  // the rAF loop, this is the most appropriate place to do it perf-wise.\n  //\n\n  function calculateEmojiGridStyle (node) {\n    resizeObserverAction(node, abortSignal, () => {\n      /* istanbul ignore next */\n      if (import.meta.env.MODE !== 'test') { // jsdom throws errors for this kind of fancy stuff\n        // read all the style/layout calculations we need to make\n        const style = getComputedStyle(refs.rootElement)\n        const newNumColumns = parseInt(style.getPropertyValue('--num-columns'), 10)\n        const newIsRtl = style.getPropertyValue('direction') === 'rtl'\n\n        // write to state variables\n        state.numColumns = newNumColumns\n        state.isRtl = newIsRtl\n      }\n    })\n  }\n\n  // Re-run whenever the custom emoji in a category are shown/hidden. This is an optimization that simulates\n  // what we'd get from `<img loading=lazy>` but without rendering an `<img>`.\n  function updateOnIntersection (node) {\n    intersectionObserverAction(node, abortSignal, (entries) => {\n      for (const { target, isIntersecting } of entries) {\n        target.classList.toggle('onscreen', isIntersecting)\n      }\n    })\n  }\n\n  //\n  // Set or update the currentEmojis. Check for invalid ZWJ renderings\n  // (i.e. double emoji).\n  //\n\n  createEffect(() => {\n    async function updateEmojis () {\n      console.log('updateEmojis')\n      const { searchText, currentGroup, databaseLoaded, customEmoji } = state\n      if (!databaseLoaded) {\n        state.currentEmojis = []\n        state.searchMode = false\n      } else if (searchText.length >= MIN_SEARCH_TEXT_LENGTH) {\n        const newEmojis = await getEmojisBySearchQuery(searchText)\n        if (state.searchText === searchText) { // if the situation changes asynchronously, do not update\n          updateCurrentEmojis(newEmojis)\n          updateSearchMode(true)\n        }\n      } else { // database is loaded and we're not in search mode, so we're in normal category mode\n        const { id: currentGroupId } = currentGroup\n        // avoid race condition where currentGroupId is -1 and customEmoji is undefined/empty\n        if (currentGroupId !== -1 || (customEmoji && customEmoji.length)) {\n          const newEmojis = await getEmojisByGroup(currentGroupId)\n          if (state.currentGroup.id === currentGroupId) { // if the situation changes asynchronously, do not update\n            updateCurrentEmojis(newEmojis)\n            updateSearchMode(false)\n          }\n        }\n      }\n    }\n\n    /* no await */ updateEmojis()\n  })\n\n  const resetScrollTopInRaf = () => {\n    requestAnimationFrame(() => resetScrollTopIfPossible(refs.tabpanelElement))\n  }\n\n  // Some emojis have their ligatures rendered as two or more consecutive emojis\n  // We want to treat these the same as unsupported emojis, so we compare their\n  // widths against the baseline widths and remove them as necessary\n  createEffect(() => {\n    const { currentEmojis, emojiVersion } = state\n    const zwjEmojisToCheck = currentEmojis\n      .filter(emoji => emoji.unicode) // filter custom emoji\n      .filter(emoji => hasZwj(emoji) && !supportedZwjEmojis.has(emoji.unicode))\n    if (!emojiVersion && zwjEmojisToCheck.length) {\n      // render now, check their length later\n      updateCurrentEmojis(currentEmojis)\n      requestAnimationFrame(() => checkZwjSupportAndUpdate(zwjEmojisToCheck))\n    } else {\n      const newEmojis = emojiVersion ? currentEmojis : currentEmojis.filter(isZwjSupported)\n      updateCurrentEmojis(newEmojis)\n      // Reset scroll top to 0 when emojis change\n      resetScrollTopInRaf()\n    }\n  })\n\n  function checkZwjSupportAndUpdate (zwjEmojisToCheck) {\n    const allSupported = checkZwjSupport(zwjEmojisToCheck, refs.baselineEmoji, emojiToDomNode)\n    if (allSupported) {\n      // Even if all emoji are supported, we still need to reset the scroll top to 0 when emojis change\n      resetScrollTopInRaf()\n    } else {\n      console.log('Not all ZWJ emoji are supported, forcing re-render')\n      // Force update. We only do this if there are any unsupported ZWJ characters since otherwise,\n      // for browsers that support all emoji, it would be an unnecessary extra re-render.\n      state.currentEmojis = [...state.currentEmojis]\n    }\n  }\n\n  function isZwjSupported (emoji) {\n    return !emoji.unicode || !hasZwj(emoji) || supportedZwjEmojis.get(emoji.unicode)\n  }\n\n  async function filterEmojisByVersion (emojis) {\n    const emojiSupportLevel = state.emojiVersion || await detectEmojiSupportLevel()\n    // !version corresponds to custom emoji\n    return emojis.filter(({ version }) => !version || version <= emojiSupportLevel)\n  }\n\n  async function summarizeEmojis (emojis) {\n    return summarizeEmojisForUI(emojis, state.emojiVersion || await detectEmojiSupportLevel())\n  }\n\n  async function getEmojisByGroup (group) {\n    console.log('getEmojiByGroup', group)\n    // -1 is custom emoji\n    const emoji = group === -1 ? state.customEmoji : await state.database.getEmojiByGroup(group)\n    return summarizeEmojis(await filterEmojisByVersion(emoji))\n  }\n\n  async function getEmojisBySearchQuery (query) {\n    return summarizeEmojis(await filterEmojisByVersion(await state.database.getEmojiBySearchQuery(query)))\n  }\n\n  createEffect(() => {\n    // consider initialLoad to be complete when the first tabpanel and favorites are rendered\n    /* istanbul ignore next */\n    if (import.meta.env.MODE !== 'production' || import.meta.env.PERF) {\n      if (state.currentEmojis.length && state.currentFavorites.length && state.initialLoad) {\n        state.initialLoad = false\n        requestPostAnimationFrame(() => performance.measure('initialLoad', 'initialLoad'))\n      }\n    }\n  })\n\n  //\n  // Derive currentEmojisWithCategories from currentEmojis. This is always done even if there\n  // are no categories, because it's just easier to code the HTML this way.\n  //\n\n  createEffect(() => {\n    function calculateCurrentEmojisWithCategories () {\n      const { searchMode, currentEmojis } = state\n      if (searchMode) {\n        return [\n          {\n            category: '',\n            emojis: currentEmojis\n          }\n        ]\n      }\n      const categoriesToEmoji = new Map()\n      for (const emoji of currentEmojis) {\n        const category = emoji.category || ''\n        let emojis = categoriesToEmoji.get(category)\n        if (!emojis) {\n          emojis = []\n          categoriesToEmoji.set(category, emojis)\n        }\n        emojis.push(emoji)\n      }\n      return [...categoriesToEmoji.entries()]\n        .map(([category, emojis]) => ({ category, emojis }))\n        .sort((a, b) => state.customCategorySorting(a.category, b.category))\n    }\n\n    const newEmojisWithCategories = calculateCurrentEmojisWithCategories()\n    updateCurrentEmojisWithCategories(newEmojisWithCategories)\n  })\n\n  //\n  // Handle active search item (i.e. pressing up or down while searching)\n  //\n\n  createEffect(() => {\n    state.activeSearchItemId = state.activeSearchItem !== -1 && state.currentEmojis[state.activeSearchItem].id\n  })\n\n  //\n  // Handle user input on the search input\n  //\n\n  createEffect(() => {\n    const { rawSearchText } = state\n    requestIdleCallback(() => {\n      state.searchText = (rawSearchText || '').trim() // defer to avoid input delays, plus we can trim here\n      state.activeSearchItem = -1\n    })\n  })\n\n  function onSearchKeydown (event) {\n    if (!state.searchMode || !state.currentEmojis.length) {\n      return\n    }\n\n    const goToNextOrPrevious = (previous) => {\n      halt(event)\n      state.activeSearchItem = incrementOrDecrement(previous, state.activeSearchItem, state.currentEmojis)\n    }\n\n    switch (event.key) {\n      case 'ArrowDown':\n        return goToNextOrPrevious(false)\n      case 'ArrowUp':\n        return goToNextOrPrevious(true)\n      case 'Enter':\n        if (state.activeSearchItem === -1) {\n          // focus the first option in the list since the list must be non-empty at this point (it's verified above)\n          state.activeSearchItem = 0\n        } else { // there is already an active search item\n          halt(event)\n          return clickEmoji(state.currentEmojis[state.activeSearchItem].id)\n        }\n    }\n  }\n\n  //\n  // Handle user input on nav\n  //\n\n  function onNavClick (event) {\n    const { target } = event\n    const closestTarget = target.closest('.nav-button')\n    /* istanbul ignore if */\n    if (!closestTarget) {\n      return // This should never happen, but makes me nervous not to have it\n    }\n    const groupId = parseInt(closestTarget.dataset.groupId, 10)\n    refs.searchElement.value = '' // clear search box input\n    state.rawSearchText = ''\n    state.searchText = ''\n    state.activeSearchItem = -1\n    state.currentGroupIndex = state.groups.findIndex(_ => _.id === groupId)\n  }\n\n  function onNavKeydown (event) {\n    const { target, key } = event\n\n    const doFocus = el => {\n      if (el) {\n        halt(event)\n        el.focus()\n      }\n    }\n\n    switch (key) {\n      case 'ArrowLeft':\n        return doFocus(target.previousElementSibling)\n      case 'ArrowRight':\n        return doFocus(target.nextElementSibling)\n      case 'Home':\n        return doFocus(target.parentElement.firstElementChild)\n      case 'End':\n        return doFocus(target.parentElement.lastElementChild)\n    }\n  }\n\n  async function getDetailForClickEvent (unicodeOrName) {\n    const emoji = await state.database.getEmojiByUnicodeOrName(unicodeOrName)\n    const emojiSummary = [...state.currentEmojis, ...state.currentFavorites]\n      .find(_ => (_.id === unicodeOrName))\n    const skinTonedUnicode = emojiSummary.unicode && unicodeWithSkin(emojiSummary, state.currentSkinTone)\n    await state.database.incrementFavoriteEmojiCount(unicodeOrName)\n    return {\n      emoji,\n      skinTone: state.currentSkinTone,\n      ...(skinTonedUnicode && { unicode: skinTonedUnicode }),\n      ...(emojiSummary.name && { name: emojiSummary.name })\n    }\n  }\n\n  //\n  // Handle user input on an emoji\n  //\n  async function clickEmoji (unicodeOrName) {\n    const promiseForDetail = getDetailForClickEvent(unicodeOrName)\n    // sync event to work around a safari bug: https://bugs.webkit.org/show_bug.cgi?id=222262\n    fireEvent('emoji-click-sync', promiseForDetail)\n    // async event for most normal use cases that don't need to work around the safari bug\n    fireEvent('emoji-click', await promiseForDetail)\n  }\n\n  function onEmojiClick (event) {\n    const { target } = event\n    /* istanbul ignore if */\n    if (!target.classList.contains('emoji')) {\n      // This should never happen, but makes me nervous not to have it\n      return\n    }\n    halt(event)\n    const id = target.id.substring(4) // replace 'emo-' or 'fav-' prefix\n\n    /* no await */ clickEmoji(id)\n  }\n\n  //\n  // Handle user input on the skintone picker\n  //\n\n  function changeSkinTone (skinTone) {\n    state.currentSkinTone = skinTone\n    state.skinTonePickerExpanded = false\n    focus('skintone-button')\n    fireEvent('skin-tone-change', { skinTone })\n    /* no await */ state.database.setPreferredSkinTone(skinTone)\n  }\n\n  function onSkinToneOptionsClick (event) {\n    const { target: { id } } = event\n    const match = id && id.match(/^skintone-(\\d)/) // skintone option format\n    /* istanbul ignore if */\n    if (!match) { // not a skintone option\n      return // This should never happen, but makes me nervous not to have it\n    }\n    halt(event)\n    const skinTone = parseInt(match[1], 10) // remove 'skintone-' prefix\n    changeSkinTone(skinTone)\n  }\n\n  function onClickSkinToneButton (event) {\n    state.skinTonePickerExpanded = !state.skinTonePickerExpanded\n    state.activeSkinTone = state.currentSkinTone\n    // this should always be true, since the button is obscured by the listbox, so this `if` is just to be sure\n    if (state.skinTonePickerExpanded) {\n      halt(event)\n      requestAnimationFrame(() => focus('skintone-list'))\n    }\n  }\n\n  // To make the animation nicer, change the z-index of the skintone picker button\n  // *after* the animation has played. This makes it appear that the picker box\n  // is expanding \"below\" the button\n  createEffect(() => {\n    if (state.skinTonePickerExpanded) {\n      refs.skinToneDropdown.addEventListener('transitionend', () => {\n        state.skinTonePickerExpandedAfterAnimation = true // eslint-disable-line no-unused-vars\n      }, { once: true })\n    } else {\n      state.skinTonePickerExpandedAfterAnimation = false // eslint-disable-line no-unused-vars\n    }\n  })\n\n  function onSkinToneOptionsKeydown (event) {\n    // this should never happen, but makes me nervous not to have it\n    /* istanbul ignore if */\n    if (!state.skinTonePickerExpanded) {\n      return\n    }\n    const changeActiveSkinTone = async nextSkinTone => {\n      halt(event)\n      state.activeSkinTone = nextSkinTone\n    }\n\n    switch (event.key) {\n      case 'ArrowUp':\n        return changeActiveSkinTone(incrementOrDecrement(true, state.activeSkinTone, state.skinTones))\n      case 'ArrowDown':\n        return changeActiveSkinTone(incrementOrDecrement(false, state.activeSkinTone, state.skinTones))\n      case 'Home':\n        return changeActiveSkinTone(0)\n      case 'End':\n        return changeActiveSkinTone(state.skinTones.length - 1)\n      case 'Enter':\n        // enter on keydown, space on keyup. this is just how browsers work for buttons\n        // https://lists.w3.org/Archives/Public/w3c-wai-ig/2019JanMar/0086.html\n        halt(event)\n        return changeSkinTone(state.activeSkinTone)\n      case 'Escape':\n        halt(event)\n        state.skinTonePickerExpanded = false\n        return focus('skintone-button')\n    }\n  }\n\n  function onSkinToneOptionsKeyup (event) {\n    // this should never happen, but makes me nervous not to have it\n    /* istanbul ignore if */\n    if (!state.skinTonePickerExpanded) {\n      return\n    }\n    switch (event.key) {\n      case ' ':\n        // enter on keydown, space on keyup. this is just how browsers work for buttons\n        // https://lists.w3.org/Archives/Public/w3c-wai-ig/2019JanMar/0086.html\n        halt(event)\n        return changeSkinTone(state.activeSkinTone)\n    }\n  }\n\n  async function onSkinToneOptionsFocusOut (event) {\n    // On blur outside of the skintone listbox, collapse the skintone picker.\n    const { relatedTarget } = event\n    // The `else` should never happen, but makes me nervous not to have it\n    /* istanbul ignore else */\n    if (!relatedTarget || relatedTarget.id !== 'skintone-list') {\n      state.skinTonePickerExpanded = false\n    }\n  }\n\n  function onSearchInput (event) {\n    state.rawSearchText = event.target.value\n  }\n\n  return {\n    $set (newState) {\n      assign(state, newState)\n    },\n    $destroy () {\n      abortController.abort()\n      console.log('Component destroyed')\n    }\n  }\n}\n","// import rAF from one place so that the bundle size is a bit smaller\nconst rAF = requestAnimationFrame\n\nexport { rAF as requestAnimationFrame }\n","/* istanbul ignore next */\nconst qM = typeof queueMicrotask === 'function' ? queueMicrotask : callback => Promise.resolve().then(callback)\nexport { qM as queueMicrotask }\n","export const MIN_SEARCH_TEXT_LENGTH = 2\nexport const NUM_SKIN_TONES = 6\n","export default {\n  categoriesLabel: 'Categories',\n  emojiUnsupportedMessage: 'Your browser does not support color emoji.',\n  favoritesLabel: 'Favorites',\n  loadingMessage: 'Loading…',\n  networkErrorMessage: 'Could not load emoji.',\n  regionLabel: 'Emoji picker',\n  searchDescription: 'When search results are available, press up or down to select and enter to choose.',\n  searchLabel: 'Search',\n  searchResultsLabel: 'Search results',\n  skinToneDescription: 'When expanded, press up or down to select and enter to choose.',\n  skinToneLabel: 'Choose a skin tone (currently {skinTone})',\n  skinTonesLabel: 'Skin tones',\n  skinTones: [\n    'Default',\n    'Light',\n    'Medium-Light',\n    'Medium',\n    'Medium-Dark',\n    'Dark'\n  ],\n  categories: {\n    custom: 'Custom',\n    'smileys-emotion': 'Smileys and emoticons',\n    'people-body': 'People and body',\n    'animals-nature': 'Animals and nature',\n    'food-drink': 'Food and drink',\n    'travel-places': 'Travel and places',\n    activities: 'Activities',\n    objects: 'Objects',\n    symbols: 'Symbols',\n    flags: 'Flags'\n  }\n}\n","@use './global' as *;\n@use './mixins' as *;\n\n// These z-indexes are used to manage the skintone picker animation and make it look nicer.\n// The skintone picker should appear to expand \"behind\" the skintone button.\n$skintoneZIndex1: 1;\n$skintoneZIndex2: 2;\n$skintoneZIndex3: 3;\n\n// skintone picker\n\n.skintone-button-wrapper {\n  background: var(--background);\n  z-index: $skintoneZIndex3;\n}\n\n.skintone-button-wrapper.expanded {\n  z-index: $skintoneZIndex1; // place behind the skintone dropdown after the listbox has animated\n}\n\n.skintone-list {\n  position: absolute;\n  inset-inline-end: 0;\n  top: 0;\n  z-index: $skintoneZIndex2;\n  overflow: visible;\n  background: var(--background);\n  border-bottom: var(--border-size) solid var(--border-color);\n  border-radius: 0 0 var(--skintone-border-radius) var(--skintone-border-radius);\n  will-change: transform;\n  transition: transform 0.2s ease-in-out;\n  transform-origin: center 0;\n\n  @media (prefers-reduced-motion: reduce) {\n    // We still want the transition event to fire, so we can listen for the transitionend event\n    // but unfortunately transition: none would just eliminate this entirely. So just make it\n    // effectively instant. I found 0.001s looks best in Firefox (avoids a jerky split-second animation)\n    // while still fixing WebKit (which doesn't work if you set 0s or transition-delay: -1s or other hacks).\n    // see also: https://github.com/jensimmons/cssremedy/issues/11\n    transition-duration: 0.001s;\n  }\n\n  // TODO: remove this when old iOS Safari drops out of usage: https://caniuse.com/css-logical-props\n  // For now, we don't support RTL in old versions of iOS\n  @supports not (inset-inline-end: 0) {\n    right: 0;\n  }\n\n  &.no-animate {\n    transition: none;\n  }\n}\n\n\n// tab panel\n\n.tabpanel {\n  @include scrollbar-gutter-stable; // avoid emojis shifting during search, when scrollbar may disappear\n  -webkit-overflow-scrolling: touch; // fix iOS scrolling\n  will-change: transform; // fix \"repaints on scroll\" warning in Chrome https://crbug.com/514303\n  min-height: 0;\n  flex: 1;\n  contain: content;\n}\n\n.emoji-menu {\n  display: grid;\n  grid-template-columns: repeat(var(--num-columns), var(--total-emoji-size));\n  justify-content: space-around;\n  align-items: flex-start;\n  width: 100%;\n\n  // Improve performance in custom emoji by using `content-visibility: auto` on every category\n  &.visibility-auto {\n    content-visibility: auto;\n    contain-intrinsic-size:\n      // width\n      calc(var(--num-columns) * var(--total-emoji-size))\n      // height\n      calc(var(--num-rows) * var(--total-emoji-size));\n  }\n}\n\n.category {\n  padding: var(--emoji-padding);\n  font-size: var(--category-font-size);\n  color: var(--category-font-color);\n}\n\n// emoji\n\nbutton.emoji,\n.emoji {\n  font-size: var(--emoji-size);\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  border-radius: 100%;\n  height: var(--total-emoji-size);\n  width: var(--total-emoji-size);\n  line-height: 1;\n  overflow: hidden;\n  font-family: var(--emoji-font-family);\n  cursor: pointer;\n\n  // see https://css-tricks.com/solving-sticky-hover-states-with-media-hover-hover/\n  @media(hover: hover) and (pointer: fine) {\n    &:hover {\n      background: var(--button-hover-background);\n    }\n  }\n\n  &:active,\n  &.active {\n    background: var(--button-active-background);\n  }\n}\n\n// Don't eagerly download the images while the custom emoji is offscreen\n.onscreen .custom-emoji::after {\n  content: '';\n  width: var(--emoji-size);\n  height: var(--emoji-size);\n  background-repeat: no-repeat;\n  background-position: center center;\n  background-size: contain;\n  background-image: var(--custom-emoji-background);\n}\n\n// nav\n\n.nav {\n  display: grid;\n  justify-content: space-between;\n  align-items: center;\n  contain: content;\n}\n\n.nav-button {\n  display: flex;\n  justify-content: center;\n  align-items: center;\n}\n\n.nav-emoji {\n  font-size: var(--category-emoji-size);\n  width: var(--total-category-emoji-size);\n  height: var(--total-category-emoji-size);\n}\n\n// indicator\n\n.indicator-wrapper {\n  display: flex;\n  border-bottom: 1px solid var(--border-color);\n}\n\n.indicator {\n  $opacityAnim: 0.1s;\n  $transformAnim: 0.25s;\n  width: calc(100% / var(--num-groups));\n  height: var(--indicator-height);\n  opacity: var(--indicator-opacity);\n  background-color: var(--indicator-color);\n  will-change: transform, opacity;\n  transition: opacity #{$opacityAnim} linear, transform #{$transformAnim} ease-in-out;\n\n  @media (prefers-reduced-motion: reduce) {\n    will-change: opacity;\n    transition: opacity #{$opacityAnim} linear;\n  }\n}\n\n// search\n\n.pad-top {\n  width: 100%;\n  height: var(--emoji-padding);\n  z-index: $skintoneZIndex3;\n  background: var(--background);\n}\n\n.search-row {\n  display: flex;\n  align-items: center;\n  position: relative;\n  padding-inline-start: var(--emoji-padding);\n  padding-bottom: var(--emoji-padding);\n}\n\n.search-wrapper {\n  flex: 1;\n  min-width: 0;\n}\n\ninput.search {\n  padding: var(--input-padding);\n  border-radius: var(--input-border-radius);\n  border: var(--input-border-size) solid var(--input-border-color);\n  background: var(--background);\n  color: var(--input-font-color);\n  width: 100%;\n  font-size: var(--input-font-size);\n  line-height: var(--input-line-height);\n\n  &::placeholder {\n    color: var(--input-placeholder-color);\n  }\n}\n\n// favorites\n\n.favorites {\n  @include scrollbar-gutter-stable; // line up favorites with the tabpanel\n  display: flex;\n  flex-direction: row;\n  border-top: var(--border-size) solid var(--border-color);\n  contain: content;\n}\n\n// unsupported warning\n\n.message {\n  padding: var(--emoji-padding);\n}\n","import { createRoot } from './components/Picker/Picker.js'\nimport { DEFAULT_DATA_SOURCE, DEFAULT_LOCALE } from '../database/constants'\nimport { DEFAULT_CATEGORY_SORTING, DEFAULT_SKIN_TONE_EMOJI, FONT_FAMILY } from './constants'\nimport enI18n from './i18n/en.js'\nimport Database from './ImportedDatabase'\nimport { queueMicrotask } from './utils/queueMicrotask.js'\nimport baseStyles from './styles/picker.scss'\n\nconst PROPS = [\n  'customEmoji',\n  'customCategorySorting',\n  'database',\n  'dataSource',\n  'i18n',\n  'locale',\n  'skinToneEmoji',\n  'emojiVersion'\n]\n\n// Styles injected ourselves, so we can declare the FONT_FAMILY variable in one place\nconst EXTRA_STYLES = `:host{--emoji-font-family:${FONT_FAMILY}}`\n\nexport default class PickerElement extends HTMLElement {\n  constructor (props) {\n    performance.mark('initialLoad')\n    super()\n    this.attachShadow({ mode: 'open' })\n    const style = document.createElement('style')\n    style.textContent = baseStyles + EXTRA_STYLES\n    this.shadowRoot.appendChild(style)\n    this._ctx = {\n      // Set defaults\n      locale: DEFAULT_LOCALE,\n      dataSource: DEFAULT_DATA_SOURCE,\n      skinToneEmoji: DEFAULT_SKIN_TONE_EMOJI,\n      customCategorySorting: DEFAULT_CATEGORY_SORTING,\n      customEmoji: null,\n      i18n: enI18n,\n      emojiVersion: null,\n      ...props\n    }\n    // Handle properties set before the element was upgraded\n    for (const prop of PROPS) {\n      if (prop !== 'database' && Object.prototype.hasOwnProperty.call(this, prop)) {\n        this._ctx[prop] = this[prop]\n        delete this[prop]\n      }\n    }\n    this._dbFlush() // wait for a flush before creating the db, in case the user calls e.g. a setter or setAttribute\n  }\n\n  connectedCallback () {\n    rescueElementPrototype(this)\n    // The _cmp may be defined if the component was immediately disconnected and then reconnected. In that case,\n    // do nothing (preserve the state)\n    if (!this._cmp) {\n      this._cmp = createRoot(this.shadowRoot, this._ctx)\n    }\n  }\n\n  disconnectedCallback () {\n    rescueElementPrototype(this)\n    // Check in a microtask if the element is still connected. If so, treat this as a \"move\" rather than a disconnect\n    // Inspired by Vue: https://vuejs.org/guide/extras/web-components.html#building-custom-elements-with-vue\n    queueMicrotask(() => {\n      // this._cmp may be defined if connect-disconnect-connect-disconnect occurs synchronously\n      if (!this.isConnected && this._cmp) {\n        this._cmp.$destroy()\n        this._cmp = undefined\n\n        const { database } = this._ctx\n        database.close()\n          // only happens if the database failed to load in the first place, so we don't care\n          .catch(err => console.error(err))\n      }\n    })\n  }\n\n  static get observedAttributes () {\n    return ['locale', 'data-source', 'skin-tone-emoji', 'emoji-version'] // complex objects aren't supported, also use kebab-case\n  }\n\n  attributeChangedCallback (attrName, oldValue, newValue) {\n    this._set(\n      // convert from kebab-case to camelcase\n      // see https://github.com/sveltejs/svelte/issues/3852#issuecomment-665037015\n      attrName.replace(/-([a-z])/g, (_, up) => up.toUpperCase()),\n      // convert string attribute to float if necessary\n      attrName === 'emoji-version' ? parseFloat(newValue) : newValue\n    )\n  }\n\n  _set (prop, newValue) {\n    this._ctx[prop] = newValue\n    if (this._cmp) {\n      this._cmp.$set({ [prop]: newValue })\n    }\n    if (['locale', 'dataSource'].includes(prop)) {\n      this._dbFlush()\n    }\n  }\n\n  _dbCreate () {\n    const { locale, dataSource, database } = this._ctx\n    // only create a new database if we really need to\n    if (!database || database.locale !== locale || database.dataSource !== dataSource) {\n      this._set('database', new Database({ locale, dataSource }))\n    }\n  }\n\n  // Update the Database in one microtask if the locale/dataSource change. We do one microtask\n  // so we don't create two Databases if e.g. both the locale and the dataSource change\n  _dbFlush () {\n    queueMicrotask(() => (\n      this._dbCreate()\n    ))\n  }\n}\n\nconst definitions = {}\n\nfor (const prop of PROPS) {\n  definitions[prop] = {\n    get () {\n      if (prop === 'database') {\n        // in rare cases, the microtask may not be flushed yet, so we need to instantiate the DB\n        // now if the user is asking for it\n        this._dbCreate()\n      }\n      return this._ctx[prop]\n    },\n    set (val) {\n      if (prop === 'database') {\n        throw new Error('database is read-only')\n      }\n      this._set(prop, val)\n    }\n  }\n}\n\nObject.defineProperties(PickerElement.prototype, definitions)\n\n// See https://jakearchibald.com/2025/firefox-custom-elements-iframes-bug/\n// TODO: remove when the Firefox bug is fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=1502814\nexport function rescueElementPrototype (element) {\n  /* istanbul ignore if */\n  if (!(element instanceof PickerElement)) {\n    Object.setPrototypeOf(element, customElements.get(element.tagName.toLowerCase()).prototype)\n  }\n}\n\n/* istanbul ignore else */\nif (!customElements.get('emoji-picker')) { // if already defined, do nothing (e.g. same script imported twice)\n  customElements.define('emoji-picker', PickerElement)\n}\n"]}