cask "parallels@15" do
  version "15.1.5-47309"
  sha256 "94df473f7bddfd1371f78fd32d7f7bb16e5c9a1d1b39751bed77c992b6d3013e"

  url "https://download.parallels.com/desktop/v#{version.major}/#{version}/ParallelsDesktop-#{version}.dmg"
  name "Parallels Desktop"
  desc "Desktop virtualization software"
  homepage "https://www.parallels.com/products/desktop/"

  deprecate! date: "2024-09-11", because: :discontinued
  disable! date: "2025-09-11", because: :discontinued

  auto_updates true
  conflicts_with cask: [
    "parallels",
    "parallels@14",
    "parallels@16",
    "parallels@17",
    "parallels@18",
    "parallels@19",
    "parallels@20",
  ]
  depends_on :macos

  app "Parallels Desktop.app"

  preflight_steps do
    run "chflags", args: ["nohidden", "{{staged_path}}/Parallels Desktop.app"]
    run "xattr", args: ["-d", "com.apple.FinderInfo", "{{staged_path}}/Parallels Desktop.app"]
  end

  postflight_steps do
    run "Parallels Desktop.app/Contents/MacOS/inittool", args: ["init"], base: :appdir, sudo: true
  end

  uninstall_preflight_steps do
    set_ownership "Parallels Desktop.app", base: :appdir
  end

  uninstall signal: ["TERM", "com.parallels.desktop.console"],
            delete: [
              "/usr/local/bin/prl_convert",
              "/usr/local/bin/prl_disk_tool",
              "/usr/local/bin/prl_perf_ctl",
              "/usr/local/bin/prlcore2dmp",
              "/usr/local/bin/prlctl",
              "/usr/local/bin/prlexec",
              "/usr/local/bin/prlsrvctl",
            ]

  zap trash: [
    "~/.parallels_settings",
    "~/Library/Caches/com.apple.helpd/Generated/com.parallels.desktop.console.help*",
    "~/Library/Caches/com.parallels.desktop.console",
    "~/Library/Caches/Parallels Software/Parallels Desktop",
    "~/Library/Logs/parallels.log",
    "~/Library/Parallels/Parallels Desktop",
    "~/Library/Preferences/com.parallels.desktop.console.LSSharedFileList.plist",
    "~/Library/Preferences/com.parallels.desktop.console.plist",
    "~/Library/Preferences/com.parallels.Parallels Desktop Events.plist",
    "~/Library/Preferences/com.parallels.Parallels Desktop Statistics.plist",
    "~/Library/Preferences/com.parallels.Parallels Desktop.plist",
    "~/Library/Preferences/com.parallels.Parallels.plist",
    "~/Library/Preferences/com.parallels.PDInfo.plist",
  ]

  caveats do
    requires_rosetta
  end
end
