{ lib, config, pkgs, ... }:

let
  cfg = config.snowhawk.firefox;
in
{
  options.snowhawk.firefox = {
    enable = lib.mkEnableOption "firefox home-manager module";
  };

  config = lib.mkIf cfg.enable {
    programs.firefox = {
      enable = true;
      package = pkgs.firefox;

      profiles.default = {
        isDefault = true;
        path = "x56262ch.default";
        userChrome = /* css */ ''
          #main-window[tabsintitlebar="true"]:not([extradragspace="true"]) #TabsToolbar > .toolbar-items {
            opacity: 0;
            pointer-events: none;
          }

          #main-window:not([tabsintitlebar="true"]) #TabsToolbar {
              visibility: collapse !important;
          }

          #titlebar {display: none !important;}
          #main-window {-moz-appearance:none !important;}

          #sidebar-box[sidebarcommand="treestyletab_piro_sakura_ne_jp-sidebar-action"] #sidebar-header {
            display: none;
          }
        '';
      };
      profiles.alt = {
        id = 1;
        path = "05fb1no8.casualypurple";
        userChrome = config.programs.firefox.profiles.default.userChrome;
      };
    };

    home.packages = with pkgs; [
      (writeShellScriptBin "alt-firefox" ''
        ${lib.getExe config.programs.firefox.package} -P "alt"
      '')
    ];
  };
}