import { Component, Input } from '@angular/core';
import { MatomoService } from '@aztrix/helpers';
import { SettingsService } from '@aztrix/sdk';
import { AbstractSettingButton } from '../abstract-setting-button';
import * as i0 from "@angular/core";
import * as i1 from "@aztrix/sdk";
import * as i2 from "@aztrix/helpers";
import * as i3 from "@angular/common";
import * as i4 from "../../account-button/account-button.component";
import * as i5 from "@angular/material/slide-toggle";
import * as i6 from "@aztrix/translate";
export class AnalyticsSettingButtonComponent extends AbstractSettingButton {
    constructor(_settings, _matomoService) {
        super();
        this._settings = _settings;
        this._matomoService = _matomoService;
    }
    toggle() {
        this._settings
            .updateAccountSettings({
            ...this.settings,
            collectAnalytics: !this.settings?.collectAnalytics,
        })
            .subscribe((settings) => {
            this.settings = settings;
            if (settings?.collectAnalytics) {
                this._matomoService.setConsentGiven();
            }
            else {
                this._matomoService.removeConsentGiven();
            }
        });
    }
    stopPropagation(event) {
        event.stopPropagation();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AnalyticsSettingButtonComponent, deps: [{ token: i1.SettingsService }, { token: i2.MatomoService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: AnalyticsSettingButtonComponent, selector: "ax-analytics-setting-button", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0, template: "<ax-account-button\n  [title]=\"'settings.privacy.analytics.title' | translate\"\n  [hint]=\"'settings.privacy.analytics.explanation' | translate\"\n  [type]=\"type\"\n  [color]=\"color\"\n  [loading]=\"_loading\"\n  [postIcon]=\"''\"\n  icon=\"cookie-cog-outline\"\n  (click)=\"toggle()\"\n>\n  <mat-slide-toggle\n    *ngIf=\"settings\"\n    [checked]=\"settings.collectAnalytics\"\n    class=\"post\"\n    color=\"primary\"\n    (click)=\"stopPropagation($event)\"\n  ></mat-slide-toggle>\n</ax-account-button>\n", styles: [".post{pointer-events:none}\n"], dependencies: [{ kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i4.AccountButtonComponent, selector: "ax-account-button", inputs: ["title", "hint", "color", "postIcon"] }, { kind: "component", type: i5.MatSlideToggle, selector: "mat-slide-toggle", inputs: ["name", "id", "labelPosition", "aria-label", "aria-labelledby", "aria-describedby", "required", "color", "disabled", "disableRipple", "tabIndex", "checked", "hideIcon"], outputs: ["change", "toggleChange"], exportAs: ["matSlideToggle"] }, { kind: "pipe", type: i6.TranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AnalyticsSettingButtonComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-analytics-setting-button', template: "<ax-account-button\n  [title]=\"'settings.privacy.analytics.title' | translate\"\n  [hint]=\"'settings.privacy.analytics.explanation' | translate\"\n  [type]=\"type\"\n  [color]=\"color\"\n  [loading]=\"_loading\"\n  [postIcon]=\"''\"\n  icon=\"cookie-cog-outline\"\n  (click)=\"toggle()\"\n>\n  <mat-slide-toggle\n    *ngIf=\"settings\"\n    [checked]=\"settings.collectAnalytics\"\n    class=\"post\"\n    color=\"primary\"\n    (click)=\"stopPropagation($event)\"\n  ></mat-slide-toggle>\n</ax-account-button>\n", styles: [".post{pointer-events:none}\n"] }]
        }], ctorParameters: () => [{ type: i1.SettingsService }, { type: i2.MatomoService }], propDecorators: { settings: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW5hbHl0aWNzLXNldHRpbmctYnV0dG9uLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL2xpYnMvY29tcG9uZW50cy9hY2NvdW50L2FjY291bnQtc2V0dGluZ3MvYW5hbHl0aWNzLXNldHRpbmctYnV0dG9uL2FuYWx5dGljc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