import { __decorate, __metadata } from "tslib";
import { Component, Input } from '@angular/core';
import { AccountSettingsRepresentation, SettingsService } from '@aztrix/sdk';
import { UntilDestroy } from '@ngneat/until-destroy';
import { AbstractSettingButton } from '../abstract-setting-button';
import * as i0 from "@angular/core";
import * as i1 from "@aztrix/sdk";
import * as i2 from "@angular/common";
import * as i3 from "../../account-button/account-button.component";
import * as i4 from "@angular/material/slide-toggle";
import * as i5 from "@aztrix/helpers";
let NewsletterSettingButtonComponent = class NewsletterSettingButtonComponent extends AbstractSettingButton {
    constructor(_settings) {
        super();
        this._settings = _settings;
    }
    toggle() {
        this._settings
            .updateAccountSettings({
            ...this.settings,
            newsletterAccepted: !this.settings.newsletterAccepted,
        })
            .subscribe((settings) => {
            this.settings = settings;
        });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: NewsletterSettingButtonComponent, deps: [{ token: i1.SettingsService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.11", type: NewsletterSettingButtonComponent, selector: "ax-newsletter-setting-button", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0, template: "<ax-account-button\n  [title]=\"'settings.account.description' | translate\"\n  [hint]=\"hint\"\n  [type]=\"type\"\n  [color]=\"color\"\n  [loading]=\"_loading\"\n  [postIcon]=\"''\"\n  icon=\"email-outline\"\n  (click)=\"toggle()\"\n>\n  <mat-slide-toggle\n    *ngIf=\"settings\"\n    [checked]=\"settings.newsletterAccepted\"\n    class=\"post\"\n    color=\"primary\"\n  ></mat-slide-toggle>\n</ax-account-button>\n", styles: [".post{pointer-events:none}\n"], dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.AccountButtonComponent, selector: "ax-account-button", inputs: ["title", "hint", "color", "postIcon"] }, { kind: "component", type: i4.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: i5.TranslatePipe, name: "translate" }] }); }
};
NewsletterSettingButtonComponent = __decorate([
    UntilDestroy(),
    __metadata("design:paramtypes", [SettingsService])
], NewsletterSettingButtonComponent);
export { NewsletterSettingButtonComponent };
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: NewsletterSettingButtonComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-newsletter-setting-button', template: "<ax-account-button\n  [title]=\"'settings.account.description' | translate\"\n  [hint]=\"hint\"\n  [type]=\"type\"\n  [color]=\"color\"\n  [loading]=\"_loading\"\n  [postIcon]=\"''\"\n  icon=\"email-outline\"\n  (click)=\"toggle()\"\n>\n  <mat-slide-toggle\n    *ngIf=\"settings\"\n    [checked]=\"settings.newsletterAccepted\"\n    class=\"post\"\n    color=\"primary\"\n  ></mat-slide-toggle>\n</ax-account-button>\n", styles: [".post{pointer-events:none}\n"] }]
        }], ctorParameters: () => [{ type: i1.SettingsService }], propDecorators: { settings: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmV3c2xldHRlci1zZXR0aW5nLWJ1dHRvbi5jb21wb25lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9saWJzL2NvbXBvbmVudHMvYWNjb3VudC9hY2NvdW50LXNldHRpbmdzL25ld3NsZXR0ZXItc2V0dGluZy1idXR0b24vbmV3c2xldHRlci1zZXR0aW5nLWJ1dHRvbi5jb21wb25lbnQudHMiLCIuLi8uLi8uLi8uLi8uLi8uLi8uLi9saWJzL2NvbXBvbmVudHMvYWNjb3VudC9hY2NvdW50LXNldHRpb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