cask "firefox" do
  version "121.0"

  language "af" do
    sha256 "a54269e4465d7dcfd2666ab2bbbcfa5367243455a664b45f9d8571405c51bdba"
    "af"
  end
  language "ar" do
    sha256 "1a5e10a0864bfe0c5750436f6a6eb000b084c529d7233042cc8b4a0cc743c0cd"
    "ar"
  end
  language "be" do
    sha256 "a681c23038b565f20cc4bc707cfae4065139e0497a729730ae2778e3c5772492"
    "be"
  end
  language "bg" do
    sha256 "d006abc9cd68b969ebb9a5700f1577ca06f2172ee2aab66f9d2003ff2fe0d9b4"
    "bg"
  end
  language "bn" do
    sha256 "5833e5d4d0e2be59c7a09de242fda82676a67b9db64919534806bde72b8733e8"
    "bn"
  end
  language "ca" do
    sha256 "39971b3fe8977de887c51e9dd6e2ddff23a2e235107b31fbf15a66c1653c807e"
    "ca"
  end
  language "cs" do
    sha256 "483bfea3e1742fce2829bf62dd805c0ab2f2ab3ed6c7e8b22331e9c01e83adb6"
    "cs"
  end
  language "de" do
    sha256 "1bfcf16c16aa43dca89e4425790f2aa18c8f0373204ec98bf12187fe2f6d7f40"
    "de"
  end
  language "en-CA" do
    sha256 "47fd22ccf3a728e3a333c97ed0748998301acafcede91035c82eebb4f4c323ac"
    "en-CA"
  end
  language "en-GB" do
    sha256 "c74cdbb0f8b5ae7655bd4b648690e2b989415b03418ecd2ca5a95ca432482a43"
    "en-GB"
  end
  language "en", default: true do
    sha256 "e146d313859c2c558a5132ae9e87aef682f8295033fa51dea65260086974e9cc"
    "en-US"
  end
  language "eo" do
    sha256 "add0b1904acfb7281d30a6e678807cba46aab1a48959025048eeff820f95866c"
    "eo"
  end
  language "es-AR" do
    sha256 "020c484e17ae6d8880188ac3199295363480c26541ec01dc7642b9291ffdae03"
    "es-AR"
  end
  language "es-CL" do
    sha256 "482837612fb30e8f8186017422db14a79cf06e266a9d4df472505c37023426eb"
    "es-CL"
  end
  language "es-ES" do
    sha256 "1a02aaae4954bf2228f555e313a306f3a3393248953997b752fee01b16cba190"
    "es-ES"
  end
  language "fa" do
    sha256 "ad7fda54632026a383d9e0b475b95e2a8136b367cd0f790110a4ee3e37608a15"
    "fa"
  end
  language "ff" do
    sha256 "44463e694bd5f93923382d763b7554683e6870b7c079ab736e441126416f307c"
    "ff"
  end
  language "fi" do
    sha256 "1abace0da3eb8104a4c7645aab9cbc8632e63dda0c862940d3ac46ed60aa3658"
    "fi"
  end
  language "fr" do
    sha256 "5ff069d9e7e04881b02eb630c5b5ab5c5dd2b479ce4dc0fef4ae831c144dcc0d"
    "fr"
  end
  language "gl" do
    sha256 "8a8208039336d0018ce4557c565ea1b062c846760fb5322e46ef20656424be6e"
    "gl"
  end
  language "gn" do
    sha256 "1d400bb4a4b63cf3813e750b9cbd622f2912e11d33ec4433101c29820ddeabfe"
    "gn"
  end
  language "gu" do
    sha256 "e5f044ca035604b6f2823df95e9e06b1f9ff554e2352ce5b9dbf51bb64d68ff0"
    "gu-IN"
  end
  language "he" do
    sha256 "b9c2ee8565449ae62d4e6e380b6a2e652cd82e6e4ef99bb357c6988cc35971ba"
    "he"
  end
  language "hi" do
    sha256 "8756f028c99edefb721d90258ba002f825c4fe5d98926e8aec77e97b322980f0"
    "hi-IN"
  end
  language "in" do
    sha256 "8756f028c99edefb721d90258ba002f825c4fe5d98926e8aec77e97b322980f0"
    "hi-IN"
  end
  language "it" do
    sha256 "e04cb9e852325a64e63672962297cc238507a8bda18ca0a58fd18316812977f2"
    "it"
  end
  language "ja" do
    sha256 "c28ea63f8c11c5d7757b20632f0e4e66b043d9bc0132dbefc5bb664767e1bdb5"
    "ja-JP-mac"
  end
  language "ka" do
    sha256 "3cde3c3afae6d4ac328af515cae277192308efa934d6ba59474a2a0f860085d3"
    "ka"
  end
  language "ko" do
    sha256 "983a34f676da05c0b3497ef989d1828b1b5b26967419e53dddc84bc2f925f31b"
    "ko"
  end
  language "mr" do
    sha256 "ec48d584c8c3ef708ac4352405c1e82494457bf0dce5a8d23713efaa9de34e57"
    "mr"
  end
  language "my" do
    sha256 "268b90b6032f1bb24afafa7b08c50fdb60e0b8cf07f026c91fe6340a58f99e3e"
    "my"
  end
  language "ne" do
    sha256 "3d3bb906e421f3d7ca3c8549d9b1a564dcb9a862f6ae05c54cc693454bb1db51"
    "ne-NP"
  end
  language "nl" do
    sha256 "58272d2560b938383e33f776f8b3d2d1751b992bb68f2e33f4e2141538da3c76"
    "nl"
  end
  language "pa-IN" do
    sha256 "b84f4b642b4f4ee3e9ea6abf92c43af33b1198d7e3d21f68dd6e6013abd7d757"
    "pa-IN"
  end
  language "pl" do
    sha256 "c4dc70fd94f01ec39a70e83280cd9be2d83a4a72c7aededdc4ccf4189e13d0fb"
    "pl"
  end
  language "pt-BR" do
    sha256 "ab2e00495b8677c7655a29a4c8524cbe44dcf2a8cc9cad8445792c0df4501440"
    "pt-BR"
  end
  language "pt" do
    sha256 "87bae63d772c86bd345fdf232ecae9d32a66d8a510233e438e525d5c6bc7d99d"
    "pt-PT"
  end
  language "ru" do
    sha256 "bcffa8201365588a8ca29819b4049a06e81733634f2be3ccd1d63a3740a24861"
    "ru"
  end
  language "si" do
    sha256 "a635e2e3e8d160da5dd629129edb1dfaa19efb7142fd951e300465bbef8762a4"
    "si"
  end
  language "sq" do
    sha256 "b457dc8b7719493ed06e1d2c79663fe8b0b6b2ac2f6faa37f01464de6544ff71"
    "sq"
  end
  language "sr" do
    sha256 "8b525d6972642edb1715efd94c33576f8057edc2aeba81bd17ceab5cc7045325"
    "sr"
  end
  language "sv" do
    sha256 "1af0eadcd6a9525f1830dcd8fa0fabdc59422893a99695d7976bffeb47ae0e3e"
    "sv-SE"
  end
  language "ta" do
    sha256 "a828853dc13f08552ef53adc19d4debd073d5da903d242695ab4ea766e9ba41f"
    "ta"
  end
  language "te" do
    sha256 "6b8e235fffc4b3011c3b2b138a4ea78536ebd5fb99506dc2e1b2bc0eeff122da"
    "te"
  end
  language "th" do
    sha256 "7403857326e65f3d3d9e2e7da65b45d4c4f18e6f860b0c0b7d3d95991b5fe28b"
    "th"
  end
  language "tl" do
    sha256 "a6ccb56ea2a98d08a14cf6786aef4fca04e954831b780f85ff59638ac5db240a"
    "tl"
  end
  language "tr" do
    sha256 "78d94cc3ef759b3ee41f5ab9b96590b3f0341ae98a30dc763e50fef5a5a30f33"
    "tr"
  end
  language "uk" do
    sha256 "4c0d136e7fe08d9867554ba6b0ae35d026a8ecc9377a605ede8769c34e9a0df7"
    "uk"
  end
  language "ur" do
    sha256 "4ec30a0b4193ed4a829048db84d71854573f0ce83eccd1de837788fe13cd626e"
    "ur"
  end
  language "zh-TW" do
    sha256 "18119699edfa32ed07f4dee4fcb93c85ab61526132d32b4ccae3dd36d1544a3d"
    "zh-TW"
  end
  language "zh" do
    sha256 "d46523ddf9fa4b0a51f0056b8abb0af88306ecd6e272008fdb27fe813d47b390"
    "zh-CN"
  end

  url "https://download-installer.cdn.mozilla.net/pub/firefox/releases/#{version}/mac/#{language}/Firefox%20#{version}.dmg",
      verified: "download-installer.cdn.mozilla.net/pub/firefox/releases/"
  name "Mozilla Firefox"
  desc "Web browser"
  homepage "https://www.mozilla.org/firefox/"

  livecheck do
    url "https://download.mozilla.org/?product=firefox-latest-ssl&os=osx"
    strategy :header_match
  end

  auto_updates true
  conflicts_with cask: [
    "homebrew/cask-versions/firefox-beta",
    "homebrew/cask-versions/firefox-cn",
    "homebrew/cask-versions/firefox-esr",
  ]
  depends_on macos: ">= :catalina"

  app "Firefox.app"
  # shim script (https://github.com/Homebrew/homebrew-cask/issues/18809)
  shimscript = "#{staged_path}/firefox.wrapper.sh"
  binary shimscript, target: "firefox"

  preflight do
    File.write shimscript, <<~EOS
      #!/bin/bash
      exec '#{appdir}/Firefox.app/Contents/MacOS/firefox' "$@"
    EOS
  end

  uninstall quit: "org.mozilla.firefox"

  zap trash: [
        "~/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ApplicationRecentDocuments/org.mozilla.firefox.sfl*",
        "~/Library/Application Support/CrashReporter/firefox_*",
        "~/Library/Application Support/Firefox",
        "~/Library/Caches/Firefox",
        "~/Library/Caches/Mozilla/updates/Applications/Firefox",
        "~/Library/Caches/org.mozilla.crashreporter",
        "~/Library/Caches/org.mozilla.firefox",
        "~/Library/Preferences/org.mozilla.crashreporter.plist",
        "~/Library/Preferences/org.mozilla.firefox.plist",
        "~/Library/Saved Application State/org.mozilla.firefox.savedState",
        "~/Library/WebKit/org.mozilla.firefox",
        "/Library/Logs/DiagnosticReports/firefox_*",
      ],
      rmdir: [
        "~/Library/Application Support/Mozilla", #  May also contain non-Firefox data
        "~/Library/Caches/Mozilla/updates/Applications",
        "~/Library/Caches/Mozilla/updates",
        "~/Library/Caches/Mozilla",
      ]
end
