import {WordRotatorBaseSite} from "./WordRotatorBaseSite";
import {Helper, InitPromise} from "../../../../../js/lib/pwa-lib";
import {Matomo} from "../../../../../js/lib/pwa-assets";

export class PrivacyPolicySite extends WordRotatorBaseSite {
    constructor(siteManager) {
        super(siteManager, "html/application/privacyPolicy.html", "privacyPolicy");
    }

    onFirstStart() {
        let trackSwitch =this.findBy("#track-switch");

        trackSwitch.addEventListener("change", function (e) {
            Matomo.setTrack(this.checked === true);
            e.stopPropagation();
            e.preventDefault();
        });
        super.onFirstStart();
    }

    onStart(args) {
        let trackSwitch =this.findBy("#track-switch");
        let shouldTrack = (Helper.nonNull(localStorage.getItem("matomoShouldTrack"), "1") === "1");
        trackSwitch.checked = shouldTrack;

        Matomo.update("Privacy Policy Site");
        return super.onStart(args);
    }
}

InitPromise.addPromise(app => {
    app.addDeepLink("privacyPolicy", PrivacyPolicySite);
});