import { ChangeDetectionStrategy, Component } from '@angular/core';
import { Validators } from '@angular/forms';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { CHANNEL_FRAGMENT, getCustomFieldsDefaults, Permission, TypedBaseDetailComponent, } from '@vendure/admin-ui/core';
import { DEFAULT_CHANNEL_CODE } from '@vendure/common/lib/shared-constants';
import { gql } from 'apollo-angular';
import { map, mergeMap, take } from 'rxjs/operators';
import * as i0 from "@angular/core";
import * as i1 from "@vendure/admin-ui/core";
import * as i2 from "@angular/forms";
import * as i3 from "@clr/angular";
import * as i4 from "@angular/common";
import * as i5 from "@ngx-translate/core";
export const GET_CHANNEL_DETAIL = gql `
    query GetChannelDetail($id: ID!) {
        channel(id: $id) {
            ...Channel
        }
    }
    ${CHANNEL_FRAGMENT}
`;
export class ChannelDetailComponent extends TypedBaseDetailComponent {
    constructor(serverConfigService, changeDetector, dataService, formBuilder, notificationService) {
        super();
        this.serverConfigService = serverConfigService;
        this.changeDetector = changeDetector;
        this.dataService = dataService;
        this.formBuilder = formBuilder;
        this.notificationService = notificationService;
        this.DEFAULT_CHANNEL_CODE = DEFAULT_CHANNEL_CODE;
        this.customFields = this.getCustomFieldConfig('Channel');
        this.detailForm = this.formBuilder.group({
            code: ['', Validators.required],
            token: ['', Validators.required],
            pricesIncludeTax: [false],
            availableLanguageCodes: [[]],
            availableCurrencyCodes: [[]],
            defaultCurrencyCode: [''],
            defaultShippingZoneId: ['', Validators.required],
            defaultLanguageCode: [undefined],
            defaultTaxZoneId: ['', Validators.required],
            sellerId: ['', Validators.required],
            customFields: this.formBuilder.group(getCustomFieldsDefaults(this.customFields)),
        });
        this.updatePermission = [Permission.SuperAdmin, Permission.UpdateChannel, Permission.CreateChannel];
    }
    ngOnInit() {
        this.init();
        // this.zones$ = this.dataService.settings.getZones({ take: 100 }).mapSingle(data => data.zones.items);
        // TODO: make this lazy-loaded autocomplete
        this.sellers$ = this.dataService.settings.getSellerList().mapSingle(data => data.sellers.items);
        this.availableLanguageCodes$ = this.serverConfigService.getAvailableLanguages();
    }
    ngOnDestroy() {
        this.destroy();
    }
    saveButtonEnabled() {
        return this.detailForm.dirty && this.detailForm.valid;
    }
    create() {
        if (!this.detailForm.dirty) {
            return;
        }
        const { code, token, defaultLanguageCode, pricesIncludeTax, defaultCurrencyCode, defaultShippingZoneId, defaultTaxZoneId, customFields, sellerId, } = this.detailForm.value;
        if (!code ||
            !token ||
            !defaultLanguageCode ||
            !defaultCurrencyCode ||
            !defaultShippingZoneId ||
            !defaultTaxZoneId) {
            return;
        }
        const input = {
            code,
            token,
            defaultLanguageCode,
            pricesIncludeTax: !!pricesIncludeTax,
            defaultCurrencyCode,
            defaultShippingZoneId,
            defaultTaxZoneId,
            customFields,
            sellerId,
        };
        this.dataService.settings
            .createChannel(input)
            .pipe(mergeMap(({ createChannel }) => this.dataService.auth.currentUser().single$.pipe(map(({ me }) => ({
            me,
            createChannel,
        })))), mergeMap(({ me, createChannel }) => 
        // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
        this.dataService.client.updateUserChannels(me.channels).pipe(map(() => createChannel))))
            .subscribe(data => {
            switch (data.__typename) {
                case 'Channel':
                    this.notificationService.success(_('common.notify-create-success'), {
                        entity: 'Channel',
                    });
                    this.detailForm.markAsPristine();
                    this.changeDetector.markForCheck();
                    this.router.navigate(['../', data.id], { relativeTo: this.route });
                    break;
                case 'LanguageNotAvailableError':
                    this.notificationService.error(data.message);
                    break;
            }
        });
    }
    save() {
        if (!this.detailForm.dirty) {
            return;
        }
        const formValue = this.detailForm.value;
        this.entity$
            .pipe(take(1), mergeMap(channel => {
            const input = {
                id: channel.id,
                code: formValue.code,
                token: formValue.token,
                pricesIncludeTax: formValue.pricesIncludeTax,
                availableLanguageCodes: formValue.availableLanguageCodes,
                availableCurrencyCodes: formValue.availableCurrencyCodes,
                defaultCurrencyCode: formValue.defaultCurrencyCode,
                defaultShippingZoneId: formValue.defaultShippingZoneId,
                defaultLanguageCode: formValue.defaultLanguageCode,
                defaultTaxZoneId: formValue.defaultTaxZoneId,
                customFields: formValue.customFields,
                sellerId: formValue.sellerId,
            };
            return this.dataService.settings.updateChannel(input);
        }))
            .subscribe(({ updateChannel }) => {
            switch (updateChannel.__typename) {
                case 'Channel':
                    this.notificationService.success(_('common.notify-update-success'), {
                        entity: 'Channel',
                    });
                    this.detailForm.markAsPristine();
                    this.changeDetector.markForCheck();
                    break;
                case 'LanguageNotAvailableError':
                    this.notificationService.error(updateChannel.message);
            }
        });
    }
    /**
     * Update the form values when the entity changes.
     */
    setFormValues(entity, languageCode) {
        this.detailForm.patchValue({
            code: entity.code,
            token: entity.token || this.generateToken(),
            pricesIncludeTax: entity.pricesIncludeTax,
            availableLanguageCodes: entity.availableLanguageCodes,
            availableCurrencyCodes: entity.availableCurrencyCodes,
            defaultCurrencyCode: entity.defaultCurrencyCode,
            defaultShippingZoneId: entity.defaultShippingZone?.id ?? '',
            defaultLanguageCode: entity.defaultLanguageCode,
            defaultTaxZoneId: entity.defaultTaxZone?.id ?? '',
            sellerId: entity.seller?.id ?? '',
        });
        if (this.customFields.length) {
            this.setCustomFieldFormValues(this.customFields, this.detailForm.get(['customFields']), entity);
        }
        if (entity.code === DEFAULT_CHANNEL_CODE) {
            const codeControl = this.detailForm.get('code');
            if (codeControl) {
                codeControl.disable();
            }
        }
    }
    generateToken() {
        return Array.from(crypto.getRandomValues(new Uint8Array(10)))
            .map(b => b.toString(16).padStart(2, '0'))
            .join('');
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: ChannelDetailComponent, deps: [{ token: i1.ServerConfigService }, { token: i0.ChangeDetectorRef }, { token: i1.DataService }, { token: i2.FormBuilder }, { token: i1.NotificationService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.2", type: ChannelDetailComponent, selector: "vdr-channel-detail", usesInheritance: true, ngImport: i0, template: "<vdr-page-block>\n    <vdr-action-bar>\n        <vdr-ab-left></vdr-ab-left>\n\n        <vdr-ab-right>\n            <vdr-action-bar-items locationId=\"channel-detail\"></vdr-action-bar-items>\n            <button\n                class=\"btn btn-primary\"\n                *ngIf=\"isNew$ | async; else updateButton\"\n                (click)=\"create()\"\n                [disabled]=\"!saveButtonEnabled()\"\n            >\n                {{ 'common.create' | translate }}\n            </button>\n            <ng-template #updateButton>\n                <button\n                    class=\"btn btn-primary\"\n                    (click)=\"save()\"\n                    *vdrIfPermissions=\"['SuperAdmin', 'UpdateChannel']\"\n                    [disabled]=\"!saveButtonEnabled()\"\n                >\n                    {{ 'common.update' | translate }}\n                </button>\n            </ng-template>\n        </vdr-ab-right>\n    </vdr-action-bar>\n</vdr-page-block>\n\n<form class=\"form\" [formGroup]=\"detailForm\">\n    <vdr-page-detail-layout>\n        <vdr-page-detail-sidebar>\n            <vdr-card *ngIf=\"entity$ | async as entity\">\n                <vdr-page-entity-info [entity]=\"entity\" />\n            </vdr-card>\n        </vdr-page-detail-sidebar>\n        <vdr-page-block>\n            <vdr-card>\n                <div class=\"form-grid\">\n                    <vdr-form-field\n                        class=\"form-grid-span\"\n                        *ngIf=\"entity?.code !== DEFAULT_CHANNEL_CODE\"\n                        [label]=\"'common.code' | translate\"\n                        for=\"code\"\n                    >\n                        <input\n                            id=\"code\"\n                            type=\"text\"\n                            [readonly]=\"!(updatePermission | hasPermission)\"\n                            formControlName=\"code\"\n                        />\n                    </vdr-form-field>\n                    <vdr-form-item\n                        class=\"form-grid-span\"\n                        *ngIf=\"entity?.code === DEFAULT_CHANNEL_CODE\"\n                        [label]=\"'common.code' | translate\"\n                    >\n                        {{ entity?.code | channelCodeToLabel | translate }}\n                    </vdr-form-item>\n                    <vdr-form-field [label]=\"'settings.channel-token' | translate\" for=\"token\">\n                        <input\n                            id=\"token\"\n                            type=\"text\"\n                            [readonly]=\"!(updatePermission | hasPermission)\"\n                            formControlName=\"token\"\n                        />\n                    </vdr-form-field>\n\n                    <vdr-form-field [label]=\"'common.seller' | translate\" for=\"sellerId\">\n                        <select\n                            name=\"sellerId\"\n                            formControlName=\"sellerId\"\n                            [vdrDisabled]=\"!(updatePermission | hasPermission)\"\n                        >\n                            <option selected value style=\"display: none\"></option>\n                            <option *ngFor=\"let seller of sellers$ | async\" [value]=\"seller.id\">\n                                {{ seller.name }}\n                            </option>\n                        </select>\n                    </vdr-form-field>\n                    <vdr-form-field\n                        [label]=\"'common.available-languages' | translate\"\n                        for=\"availableLanguageCodes\"\n                    >\n                        <vdr-language-code-selector\n                            formControlName=\"availableLanguageCodes\"\n                            [languageCodes]=\"availableLanguageCodes$ | async\"\n                        ></vdr-language-code-selector>\n                    </vdr-form-field>\n                    <vdr-form-field\n                        [label]=\"'common.available-currencies' | translate\"\n                        for=\"availableCurrencyCodes\"\n                    >\n                        <vdr-currency-code-selector\n                            formControlName=\"availableCurrencyCodes\"\n                        ></vdr-currency-code-selector>\n                    </vdr-form-field>\n                </div>\n            </vdr-card>\n            <vdr-card [title]=\"'settings.defaults' | translate\">\n                <div class=\"form-grid\">\n                    <vdr-form-field [label]=\"'settings.default-currency' | translate\" for=\"defaultTaxZoneId\">\n                        <select\n                            name=\"defaultCurrencyCode\"\n                            formControlName=\"defaultCurrencyCode\"\n                            [vdrDisabled]=\"!(updatePermission | hasPermission)\"\n                        >\n                            <option\n                                *ngFor=\"let code of detailForm.value.availableCurrencyCodes\"\n                                [value]=\"code\"\n                            >\n                                {{ code | localeCurrencyName }}\n                            </option>\n                        </select>\n                    </vdr-form-field>\n                    <vdr-form-field [label]=\"'common.default-language' | translate\" for=\"defaultLanguage\">\n                        <select\n                            name=\"defaultLanguageCode\"\n                            formControlName=\"defaultLanguageCode\"\n                            [vdrDisabled]=\"!(updatePermission | hasPermission)\"\n                        >\n                            <option\n                                *ngFor=\"let languageCode of detailForm.value.availableLanguageCodes\"\n                                [value]=\"languageCode\"\n                            >\n                                {{ languageCode | localeLanguageName }} ({{ languageCode | uppercase }})\n                            </option>\n                        </select>\n                    </vdr-form-field>\n                    <div>\n                        <vdr-form-field\n                            [label]=\"'settings.default-tax-zone' | translate\"\n                            for=\"defaultTaxZoneId\"\n                        >\n                            <vdr-zone-selector\n                                formControlName=\"defaultTaxZoneId\"\n                                [vdrDisabled]=\"!(updatePermission | hasPermission)\"\n                            ></vdr-zone-selector>\n                        </vdr-form-field>\n                        <clr-alert\n                            *ngIf=\"detailForm.value.code && !detailForm.value.defaultTaxZoneId\"\n                            clrAlertType=\"danger\"\n                            [clrAlertClosable]=\"false\"\n                        >\n                            <clr-alert-item>\n                                <span class=\"alert-text\">\n                                    {{ 'error.no-default-tax-zone-set' | translate }}\n                                </span>\n                            </clr-alert-item>\n                        </clr-alert>\n                    </div>\n\n                    <div>\n                        <vdr-form-field\n                            [label]=\"'settings.default-shipping-zone' | translate\"\n                            for=\"defaultShippingZoneId\"\n                        >\n                            <vdr-zone-selector\n                                name=\"defaultShippingZoneId\"\n                                formControlName=\"defaultShippingZoneId\"\n                                [vdrDisabled]=\"!(updatePermission | hasPermission)\"\n                            ></vdr-zone-selector>\n                        </vdr-form-field>\n                        <clr-alert\n                            *ngIf=\"detailForm.value.code && !detailForm.value.defaultShippingZoneId\"\n                            clrAlertType=\"warning\"\n                            [clrAlertClosable]=\"false\"\n                        >\n                            <clr-alert-item>\n                                <span class=\"alert-text\">\n                                    {{ 'error.no-default-shipping-zone-set' | translate }}\n                                </span>\n                            </clr-alert-item>\n                        </clr-alert>\n                    </div>\n                    <vdr-form-field\n                        [label]=\"'settings.prices-include-tax' | translate\"\n                        for=\"pricesIncludeTax\"\n                    >\n                        <clr-toggle-wrapper>\n                            <input\n                                type=\"checkbox\"\n                                clrToggle\n                                id=\"pricesIncludeTax\"\n                                formControlName=\"pricesIncludeTax\"\n                                [vdrDisabled]=\"!(updatePermission | hasPermission)\"\n                            />\n                        </clr-toggle-wrapper>\n                    </vdr-form-field>\n                </div>\n            </vdr-card>\n            <vdr-card\n                formGroupName=\"customFields\"\n                *ngIf=\"customFields.length\"\n                [title]=\"'common.custom-fields' | translate\"\n            >\n                <vdr-tabbed-custom-fields\n                    entityName=\"Channel\"\n                    [customFields]=\"customFields\"\n                    [customFieldsFormGroup]=\"detailForm.get('customFields')\"\n                ></vdr-tabbed-custom-fields>\n            </vdr-card>\n            <vdr-custom-detail-component-host\n                locationId=\"channel-detail\"\n                [entity$]=\"entity$\"\n                [detailForm]=\"detailForm\"\n            ></vdr-custom-detail-component-host>\n        </vdr-page-block>\n    </vdr-page-detail-layout>\n</form>\n", styles: ["clr-alert{max-width:30rem;margin-bottom:12px}\n"], dependencies: [{ kind: "component", type: i3.ClrAlert, selector: "clr-alert", inputs: ["clrAlertSizeSmall", "clrAlertClosable", "clrAlertAppLevel", "clrCloseButtonAriaLabel", "clrAlertType", "clrAlertIcon", "clrAlertClosed"], outputs: ["clrAlertClosedChange"] }, { kind: "component", type: i3.ClrAlertItem, selector: "clr-alert-item" }, { kind: "directive", type: i3.ClrAlertText, selector: ".alert-text" }, { kind: "directive", type: i3.ClrCheckbox, selector: "[clrCheckbox],[clrToggle]" }, { kind: "component", type: i3.ClrCheckboxWrapper, selector: "clr-checkbox-wrapper,clr-toggle-wrapper" }, { kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i2.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i2.FormGroupName, selector: "[formGroupName]", inputs: ["formGroupName"] }, { kind: "component", type: i1.ActionBarComponent, selector: "vdr-action-bar" }, { kind: "component", type: i1.ActionBarLeftComponent, selector: "vdr-ab-left", inputs: ["grow"] }, { kind: "component", type: i1.ActionBarRightComponent, selector: "vdr-ab-right", inputs: ["grow"] }, { kind: "component", type: i1.FormFieldComponent, selector: "vdr-form-field", inputs: ["label", "for", "tooltip", "errors", "readOnlyToggle"] }, { kind: "directive", type: i1.FormFieldControlDirective, selector: "input, textarea, select" }, { kind: "component", type: i1.FormItemComponent, selector: "vdr-form-item", inputs: ["label", "tooltip"] }, { kind: "directive", type: i1.IfPermissionsDirective, selector: "[vdrIfPermissions]", inputs: ["vdrIfPermissions", "vdrIfPermissionsElse"] }, { kind: "component", type: i1.ActionBarItemsComponent, selector: "vdr-action-bar-items", inputs: ["locationId"] }, { kind: "directive", type: i1.DisabledDirective, selector: "[vdrDisabled]", inputs: ["vdrDisabled"] }, { kind: "component", type: i1.TabbedCustomFieldsComponent, selector: "vdr-tabbed-custom-fields", inputs: ["entityName", "customFields", "customFieldsFormGroup", "readonly", "compact", "showLabel"] }, { kind: "component", type: i1.CustomDetailComponentHostComponent, selector: "vdr-custom-detail-component-host", inputs: ["locationId", "entity$", "detailForm"] }, { kind: "component", type: i1.PageBlockComponent, selector: "vdr-page-block" }, { kind: "component", type: i1.PageEntityInfoComponent, selector: "vdr-page-entity-info", inputs: ["entity"] }, { kind: "component", type: i1.PageDetailLayoutComponent, selector: "vdr-page-detail-layout" }, { kind: "component", type: i1.PageDetailSidebarComponent, selector: "vdr-page-detail-sidebar" }, { kind: "component", type: i1.CardComponent, selector: "vdr-card", inputs: ["title", "paddingX"] }, { kind: "component", type: i1.ZoneSelectorComponent, selector: "vdr-zone-selector", inputs: ["readonly", "transformControlValueAccessorValue"], outputs: ["selectedValuesChange"] }, { kind: "component", type: i1.CurrencyCodeSelectorComponent, selector: "vdr-currency-code-selector" }, { kind: "component", type: i1.LanguageCodeSelectorComponent, selector: "vdr-language-code-selector", inputs: ["languageCodes"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }, { kind: "pipe", type: i4.UpperCasePipe, name: "uppercase" }, { kind: "pipe", type: i5.TranslatePipe, name: "translate" }, { kind: "pipe", type: i1.LocaleCurrencyNamePipe, name: "localeCurrencyName" }, { kind: "pipe", type: i1.HasPermissionPipe, name: "hasPermission" }, { kind: "pipe", type: i1.ChannelLabelPipe, name: "channelCodeToLabel" }, { kind: "pipe", type: i1.LocaleLanguageNamePipe, name: "localeLanguageName" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: ChannelDetailComponent, decorators: [{
            type: Component,
            args: [{ selector: 'vdr-channel-detail', changeDetection: ChangeDetectionStrategy.OnPush, template: "<vdr-page-block>\n    <vdr-action-bar>\n        <vdr-ab-left></vdr-ab-left>\n\n        <vdr-ab-right>\n            <vdr-action-bar-items locationId=\"channel-detail\"></vdr-action-bar-items>\n            <button\n                class=\"btn btn-primary\"\n                *ngIf=\"isNew$ | async; else updateButton\"\n                (click)=\"create()\"\n                [disabled]=\"!saveButtonEnabled()\"\n            >\n                {{ 'common.create' | translate }}\n            </button>\n            <ng-template #updateButton>\n                <button\n                    class=\"btn btn-primary\"\n                    (click)=\"save()\"\n                    *vdrIfPermissions=\"['SuperAdmin', 'UpdateChannel']\"\n                    [disabled]=\"!saveButtonEnabled()\"\n                >\n                    {{ 'common.update' | translate }}\n                </button>\n            </ng-template>\n        </vdr-ab-right>\n    </vdr-action-bar>\n</vdr-page-block>\n\n<form class=\"form\" [formGroup]=\"detailForm\">\n    <vdr-page-detail-layout>\n        <vdr-page-detail-sidebar>\n            <vdr-card *ngIf=\"entity$ | async as entity\">\n                <vdr-page-entity-info [entity]=\"entity\" />\n            </vdr-card>\n        </vdr-page-detail-sidebar>\n        <vdr-page-block>\n            <vdr-card>\n                <div class=\"form-grid\">\n                    <vdr-form-field\n                        class=\"form-grid-span\"\n                        *ngIf=\"entity?.code !== DEFAULT_CHANNEL_CODE\"\n                        [label]=\"'common.code' | translate\"\n                        for=\"code\"\n                    >\n                        <input\n                            id=\"code\"\n                            type=\"text\"\n                            [readonly]=\"!(updatePermission | hasPermission)\"\n                            formControlName=\"code\"\n                        />\n                    </vdr-form-field>\n                    <vdr-form-item\n                        class=\"form-grid-span\"\n                        *ngIf=\"entity?.code === DEFAULT_CHANNEL_CODE\"\n                        [label]=\"'common.code' | translate\"\n                    >\n                        {{ entity?.code | channelCodeToLabel | translate }}\n                    </vdr-form-item>\n                    <vdr-form-field [label]=\"'settings.channel-token' | translate\" for=\"token\">\n                        <input\n                            id=\"token\"\n                            type=\"text\"\n                            [readonly]=\"!(updatePermission | hasPermission)\"\n                            formControlName=\"token\"\n                        />\n                    </vdr-form-field>\n\n                    <vdr-form-field [label]=\"'common.seller' | translate\" for=\"sellerId\">\n                        <select\n                            name=\"sellerId\"\n                            formControlName=\"sellerId\"\n                            [vdrDisabled]=\"!(updatePermission | hasPermission)\"\n                        >\n                            <option selected value style=\"display: none\"></option>\n                            <option *ngFor=\"let seller of sellers$ | async\" [value]=\"seller.id\">\n                                {{ seller.name }}\n                            </option>\n                        </select>\n                    </vdr-form-field>\n                    <vdr-form-field\n                        [label]=\"'common.available-languages' | translate\"\n                        for=\"availableLanguageCodes\"\n                    >\n                        <vdr-language-code-selector\n                            formControlName=\"availableLanguageCodes\"\n                            [languageCodes]=\"availableLanguageCodes$ | async\"\n                        ></vdr-language-code-selector>\n                    </vdr-form-field>\n                    <vdr-form-field\n                        [label]=\"'common.available-currencies' | translate\"\n                        for=\"availableCurrencyCodes\"\n                    >\n                        <vdr-currency-code-selector\n                            formControlName=\"availableCurrencyCodes\"\n                        ></vdr-currency-code-selector>\n                    </vdr-form-field>\n                </div>\n            </vdr-card>\n            <vdr-card [title]=\"'settings.defaults' | translate\">\n                <div class=\"form-grid\">\n                    <vdr-form-field [label]=\"'settings.default-currency' | translate\" for=\"defaultTaxZoneId\">\n                        <select\n                            name=\"defaultCurrencyCode\"\n                            formControlName=\"defaultCurrencyCode\"\n                            [vdrDisabled]=\"!(updatePermission | hasPermission)\"\n                        >\n                            <option\n                                *ngFor=\"let code of detailForm.value.availableCurrencyCodes\"\n                                [value]=\"code\"\n                            >\n                                {{ code | localeCurrencyName }}\n                            </option>\n                        </select>\n                    </vdr-form-field>\n                    <vdr-form-field [label]=\"'common.default-language' | translate\" for=\"defaultLanguage\">\n                        <select\n                            name=\"defaultLanguageCode\"\n                            formControlName=\"defaultLanguageCode\"\n                            [vdrDisabled]=\"!(updatePermission | hasPermission)\"\n                        >\n                            <option\n                                *ngFor=\"let languageCode of detailForm.value.availableLanguageCodes\"\n                                [value]=\"languageCode\"\n                            >\n                                {{ languageCode | localeLanguageName }} ({{ languageCode | uppercase }})\n                            </option>\n                        </select>\n                    </vdr-form-field>\n                    <div>\n                        <vdr-form-field\n                            [label]=\"'settings.default-tax-zone' | translate\"\n                            for=\"defaultTaxZoneId\"\n                        >\n                            <vdr-zone-selector\n                                formControlName=\"defaultTaxZoneId\"\n                                [vdrDisabled]=\"!(updatePermission | hasPermission)\"\n                            ></vdr-zone-selector>\n                        </vdr-form-field>\n                        <clr-alert\n                            *ngIf=\"detailForm.value.code && !detailForm.value.defaultTaxZoneId\"\n                            clrAlertType=\"danger\"\n                            [clrAlertClosable]=\"false\"\n                        >\n                            <clr-alert-item>\n                                <span class=\"alert-text\">\n                                    {{ 'error.no-default-tax-zone-set' | translate }}\n                                </span>\n                            </clr-alert-item>\n                        </clr-alert>\n                    </div>\n\n                    <div>\n                        <vdr-form-field\n                            [label]=\"'settings.default-shipping-zone' | translate\"\n                            for=\"defaultShippingZoneId\"\n                        >\n                            <vdr-zone-selector\n                                name=\"defaultShippingZoneId\"\n                                formControlName=\"defaultShippingZoneId\"\n                                [vdrDisabled]=\"!(updatePermission | hasPermission)\"\n                            ></vdr-zone-selector>\n                        </vdr-form-field>\n                        <clr-alert\n                            *ngIf=\"detailForm.value.code && !detailForm.value.defaultShippingZoneId\"\n                            clrAlertType=\"warning\"\n                            [clrAlertClosable]=\"false\"\n                        >\n                            <clr-alert-item>\n                                <span class=\"alert-text\">\n                                    {{ 'error.no-default-shipping-zone-set' | translate }}\n                                </span>\n                            </clr-alert-item>\n                        </clr-alert>\n                    </div>\n                    <vdr-form-field\n                        [label]=\"'settings.prices-include-tax' | translate\"\n                        for=\"pricesIncludeTax\"\n                    >\n                        <clr-toggle-wrapper>\n                            <input\n                                type=\"checkbox\"\n                                clrToggle\n                                id=\"pricesIncludeTax\"\n                                formControlName=\"pricesIncludeTax\"\n                                [vdrDisabled]=\"!(updatePermission | hasPermission)\"\n                            />\n                        </clr-toggle-wrapper>\n                    </vdr-form-field>\n                </div>\n            </vdr-card>\n            <vdr-card\n                formGroupName=\"customFields\"\n                *ngIf=\"customFields.length\"\n                [title]=\"'common.custom-fields' | translate\"\n            >\n                <vdr-tabbed-custom-fields\n                    entityName=\"Channel\"\n                    [customFields]=\"customFields\"\n                    [customFieldsFormGroup]=\"detailForm.get('customFields')\"\n                ></vdr-tabbed-custom-fields>\n            </vdr-card>\n            <vdr-custom-detail-component-host\n                locationId=\"channel-detail\"\n                [entity$]=\"entity$\"\n                [detailForm]=\"detailForm\"\n            ></vdr-custom-detail-component-host>\n        </vdr-page-block>\n    </vdr-page-detail-layout>\n</form>\n", styles: ["clr-alert{max-width:30rem;margin-bottom:12px}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.ServerConfigService }, { type: i0.ChangeDetectorRef }, { type: i1.DataService }, { type: i2.FormBuilder }, { type: i1.NotificationService }]; } });
//# sourceMappingURL=data:application/json;base64, 