/* This Source Code Form is subject to the terms of the Creative Commons
 * Attribution-NonCommercial-ShareAlike International License, v. 4.0.
 * If a copy of the CC BY-NC-SA 4.0 was not distributed with this
 * file, You can obtain one at http://creativecommons.org/licenses/by-nc-sa/4.0/
 * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. */

/* this does nothing on its own — it requires searchModeIndicatorIcons.uc.js.
when you switch to a one-off search engine in the urlbar, or otherwise enable
search mode, this changes the identity icon to one matching the search engine. I
recommend using this addon to add new search engines:
https://addons.mozilla.org/en-US/firefox/addon/add-custom-search-engine */

/* for search engines I haven't added icons for, use a search glass icon. if you
want to request an icon for a search engine you use, send me the engine name
(the name that shows up in the identity box label when you enter search mode
with it) and the URL to the search engine so I can find a suitable icon and set
a rule for it. */
#urlbar[searchmode=""][pageproxystate="invalid"] #identity-box > #identity-icon-box,
#urlbar[searchmode=""][pageproxystate="valid"] #identity-box > #identity-icon-box,
#urlbar[searchmode=""] #identity-icon-box,
#urlbar[pageproxystate="invalid"] #identity-box > #identity-icon-box[engine]:not([engine="Other"]),
#urlbar[pageproxystate="valid"] #identity-box > #identity-icon-box[engine]:not([engine="Other"]),
#urlbar #identity-icon-box[engine]:not([engine="Other"]) {
  > #identity-icon {
    list-style-image: var(--search-engine-icon, url(chrome://userchrome/content/search-glass.svg)) !important;
  }
}

#identity-icon-box {
  /* built-in history, tabs, bookmarks pseudo-engines */
  &[engine="History"] {
    --search-engine-icon: url(chrome://userchrome/content/skin/history.svg) !important;
  }

  &[engine="Tabs"] {
    --search-engine-icon: url(chrome://userchrome/content/skin/tab.svg) !important;
  }

  &[engine="Bookmarks"] {
    --search-engine-icon: url(chrome://userchrome/content/skin/bookmark.svg) !important;
  }

  &[engine="Actions"] {
    --search-engine-icon: url(chrome://browser/skin/quickactions.svg) !important;
  }

  /* for google */
  &[engine="Google"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/google.svg) !important;
  }

  /* duckduckgo */
  &[engine="DuckDuckGo"],
  &[engine="DuckDuckGo Search"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/duckduckgo.svg) !important;
  }

  /* bing */
  &[engine="Bing"],
  &[engine="Bing Search"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/bing.svg) !important;
  }

  /* kagi */
  &[engine="Kagi"],
  &[engine="Kagi Search"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/kagi.svg) !important;
  }

  &[engine="Kagi Translate"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/kagitranslate.svg) !important;
  }

  /* baidu */
  &[engine="Baidu"],
  &[engine="Baidu Search"],
  &[engine="百度"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/baidu.svg) !important;
  }

  /* google images */
  &[engine="Google Images"],
  &[engine="Kagi Images"] {
    --search-engine-icon: url(chrome://userchrome/content/notifications/canvas.svg) !important;
  }

  /* youtube */
  &[engine="YouTube"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/youtube.svg) !important;
  }

  /* etc... */
  &[engine="Google Translate"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/googletranslate.svg) !important;
  }

  &[engine="GitHub"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/github.svg) !important;
  }

  &[engine^="Wikipedia"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/wikipedia.svg) !important;
  }

  &[engine="Wiktionary"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/wiktionary.svg) !important;
  }

  &[engine="Amazon"],
  &[engine="Amazon.com"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/amazon.svg) !important;
  }

  &[engine="DoorDash"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/doordash.svg) !important;
  }

  &[engine="eBay"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/ebay.svg) !important;
  }

  &[engine="Netflix"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/netflix.svg) !important;
  }

  &[engine="Google Maps"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/googlemaps.svg) !important;
  }

  &[engine="Google Drive"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/googledrive.svg) !important;
  }

  &[engine="Gmail"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/gmail.svg) !important;
  }

  &[engine="Gatherer"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/gatherer.svg) !important;
  }

  &[engine="Scryfall"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/scryfall.svg) !important;
  }

  &[engine="Goatbots"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/cards.svg) !important;
  }

  &[engine="MTGO Traders"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/swordshield.svg) !important;
  }

  &[engine="Searchfox"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/searchfox.svg) !important;
  }

  &[engine="Bugzilla"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/bugzilla.svg) !important;
  }

  &[engine="MDN Web Docs"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/mdnwebdocs.svg) !important;
  }

  &[engine="Reelgood"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/reelgood.svg) !important;
  }

  &[engine="Brave"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/brave.svg) !important;
  }

  &[engine="Firefox Add-ons"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/firefoxadd-ons.svg) !important;
  }

  &[engine="Etsy"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/etsy.svg) !important;
  }

  &[engine="Library Genesis"] {
    --search-engine-icon: url(chrome://userchrome/content/engines/librarygenesis.svg) !important;
  }
}

/* replace the contextMenuMods.uc.js icons for built-in engines */
.searchmenuitem[engine-id="google"] {
  --engine-icon: url(chrome://userchrome/content/engines/google.svg) !important;
}

.searchmenuitem[engine-id="ddg"] {
  --engine-icon: url(chrome://userchrome/content/engines/duckduckgo.svg) !important;
}
