import * as i0 from '@angular/core';
import { Component, ChangeDetectionStrategy, ChangeDetectorRef, EventEmitter, Input, Output, Injectable, NgModule } from '@angular/core';
import * as i2 from '@ishop/admin-ui/core';
import { DataService, ModalService, BaseDetailComponent, SortOrder, EditNoteDialogComponent, ServerConfigService, NotificationService, DeletionResult, HistoryEntryType, BaseListComponent, BaseEntityResolver, createResolveData, CanDeactivateDetailGuard, detailBreadcrumb, SharedModule } from '@ishop/admin-ui/core';
import { BehaviorSubject, Subject, forkJoin, from, EMPTY, combineLatest, of, merge as merge$1 } from 'rxjs';
import { switchMap, map, filter, take, shareReplay, merge, startWith, mergeMap, concatMap, distinctUntilChanged, tap, mapTo, debounceTime, takeUntil } from 'rxjs/operators';
import { Validators, FormArray, FormControl, FormBuilder } from '@angular/forms';
import { __rest } from 'tslib';
import * as i1 from '@angular/router';
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
import { marker } from '@biesbjerg/ngx-translate-extract-marker';
import { notNullOrUndefined } from '@ishop/common/lib/shared-utils';
import { SortOrder as SortOrder$1 } from '@ishop/common/lib/generated-shop-types';

class AddCustomerToGroupDialogComponent {
    constructor(dataService) {
        this.dataService = dataService;
        this.selectedCustomerIds = [];
        this.fetchGroupMembers$ = new BehaviorSubject({
            skip: 0,
            take: 10,
            filterTerm: '',
        });
    }
    ngOnInit() {
        const customerResult$ = this.fetchGroupMembers$.pipe(switchMap(({ skip, take, filterTerm }) => {
            return this.dataService.customer
                .getCustomerList(take, skip, filterTerm)
                .mapStream((res) => res.customers);
        }));
        this.customers$ = customerResult$.pipe(map((res) => res.items));
        this.customersTotal$ = customerResult$.pipe(map((res) => res.totalItems));
    }
    cancel() {
        this.resolveWith();
    }
    add() {
        this.resolveWith(this.selectedCustomerIds);
    }
}
AddCustomerToGroupDialogComponent.decorators = [
    { type: Component, args: [{
                selector: 'vdr-add-customer-to-group-dialog',
                template: "<ng-template vdrDialogTitle>\r\n    {{ 'customer.add-customers-to-group-with-name' | translate: {groupName: group.name} }}\r\n</ng-template>\r\n\r\n<vdr-customer-group-member-list\r\n    [members]=\"customers$ | async\"\r\n    [totalItems]=\"customersTotal$ | async\"\r\n    [route]=\"route\"\r\n    [selectedMemberIds]=\"selectedCustomerIds\"\r\n    (fetchParamsChange)=\"fetchGroupMembers$.next($event)\"\r\n    (selectionChange)=\"selectedCustomerIds = $event\"\r\n>\r\n\r\n</vdr-customer-group-member-list>\r\n\r\n<ng-template vdrDialogButtons>\r\n    <button type=\"button\" class=\"btn\" (click)=\"cancel()\">{{ 'common.cancel' | translate }}</button>\r\n    <button type=\"submit\" (click)=\"add()\" [disabled]=\"!selectedCustomerIds.length\" class=\"btn btn-primary\">\r\n        {{ 'customer.add-customers-to-group-with-count' | translate: {count: selectedCustomerIds.length} }}\r\n    </button>\r\n</ng-template>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                styles: [""]
            },] }
];
AddCustomerToGroupDialogComponent.ctorParameters = () => [
    { type: DataService }
];

class AddressDetailDialogComponent {
    constructor(changeDetector) {
        this.changeDetector = changeDetector;
        this.availableCountries = [];
    }
    ngOnInit() {
        this.addressForm.valueChanges.subscribe(() => this.changeDetector.markForCheck());
    }
    cancel() {
        this.resolveWith();
    }
    save() {
        this.resolveWith(this.addressForm);
    }
}
AddressDetailDialogComponent.decorators = [
    { type: Component, args: [{
                selector: 'vdr-address-detail-dialog',
                template: "<ng-template vdrDialogTitle>\r\n    <span *ngIf=\"addressForm.get('streetLine1')?.value as streetLine1\">{{ streetLine1 }},</span>\r\n    <span *ngIf=\"addressForm.get('countryCode')?.value as countryCode\"> {{ countryCode }}</span>\r\n</ng-template>\r\n\r\n<vdr-address-form\r\n    [formGroup]=\"addressForm\"\r\n    [availableCountries]=\"availableCountries\"\r\n    [customFields]=\"customFields\"\r\n></vdr-address-form>\r\n\r\n<ng-template vdrDialogButtons>\r\n    <button type=\"button\" class=\"btn\" (click)=\"cancel()\">{{ 'common.cancel' | translate }}</button>\r\n    <button\r\n        type=\"submit\"\r\n        (click)=\"save()\"\r\n        [disabled]=\"!addressForm.valid || !addressForm.touched\"\r\n        class=\"btn btn-primary\"\r\n    >\r\n        {{ 'common.update' | translate }}\r\n    </button>\r\n</ng-template>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                styles: ["clr-input-container{margin-bottom:12px}"]
            },] }
];
AddressDetailDialogComponent.ctorParameters = () => [
    { type: ChangeDetectorRef }
];

class AddressCardComponent {
    constructor(modalService, changeDetector) {
        this.modalService = modalService;
        this.changeDetector = changeDetector;
        this.availableCountries = [];
        this.editable = true;
        this.setAsDefaultShipping = new EventEmitter();
        this.setAsDefaultBilling = new EventEmitter();
        this.dataDependenciesPopulated = new BehaviorSubject(false);
    }
    ngOnInit() {
        const streetLine1 = this.addressForm.get('streetLine1');
        // Make the address dialog display automatically if there is no address line
        // as is the case when adding a new address.
        if (!streetLine1.value) {
            this.dataDependenciesPopulated
                .pipe(filter(value => value), take(1))
                .subscribe(() => {
                this.editAddress();
            });
        }
    }
    ngOnChanges(changes) {
        if (this.customFields != null && this.availableCountries != null) {
            this.dataDependenciesPopulated.next(true);
        }
    }
    getCountryName(countryCode) {
        if (!this.availableCountries) {
            return '';
        }
        const match = this.availableCountries.find(c => c.code === countryCode);
        return match ? match.name : '';
    }
    setAsDefaultBillingAddress() {
        this.setAsDefaultBilling.emit(this.addressForm.value.id);
        this.addressForm.markAsDirty();
    }
    setAsDefaultShippingAddress() {
        this.setAsDefaultShipping.emit(this.addressForm.value.id);
        this.addressForm.markAsDirty();
    }
    editAddress() {
        this.modalService
            .fromComponent(AddressDetailDialogComponent, {
            locals: {
                addressForm: this.addressForm,
                customFields: this.customFields,
                availableCountries: this.availableCountries,
            },
            size: 'md',
            closable: true,
        })
            .subscribe(() => {
            this.changeDetector.markForCheck();
        });
    }
}
AddressCardComponent.decorators = [
    { type: Component, args: [{
                selector: 'vdr-address-card',
                template: "<div class=\"card\" *ngIf=\"addressForm.value as address\">\r\n    <div class=\"card-header\">\r\n        <div class=\"address-title\">\r\n            <span class=\"street-line\" *ngIf=\"address.streetLine1\">{{ address.streetLine1 }},</span>\r\n            {{ address.countryCode }}\r\n        </div>\r\n        <div class=\"default-controls\">\r\n            <vdr-chip class=\"is-default p8\" *ngIf=\"isDefaultShipping\">\r\n                <clr-icon shape=\"truck\"></clr-icon>\r\n                {{ 'customer.default-shipping-address' | translate }}\r\n            </vdr-chip>\r\n            <vdr-chip class=\"is-default p8\" *ngIf=\"isDefaultBilling\">\r\n                <clr-icon shape=\"credit-card\"></clr-icon>\r\n                {{ 'customer.default-billing-address' | translate }}\r\n            </vdr-chip>\r\n        </div>\r\n    </div>\r\n    <div class=\"card-block\">\r\n        <div class=\"card-text\">\r\n            <vdr-formatted-address [address]=\"address\"></vdr-formatted-address>\r\n        </div>\r\n    </div>\r\n    <div class=\"card-footer\">\r\n        <vdr-entity-info [entity]=\"address\"></vdr-entity-info>\r\n        <ng-container *ngIf=\"editable\">\r\n            <button class=\"btn btn-sm btn-link\" (click)=\"editAddress()\">\r\n                {{ 'common.edit' | translate }}\r\n            </button>\r\n            <vdr-dropdown>\r\n                <button type=\"button\" class=\"btn btn-sm btn-link\" vdrDropdownTrigger>\r\n                    {{ 'common.more' | translate }}\r\n                    <clr-icon shape=\"caret down\"></clr-icon>\r\n                </button>\r\n                <vdr-dropdown-menu>\r\n                    <button\r\n                        vdrDropdownItem\r\n                        class=\"button\"\r\n                        [disabled]=\"isDefaultShipping\"\r\n                        (click)=\"setAsDefaultShippingAddress()\"\r\n                    >\r\n                        {{ 'customer.set-as-default-shipping-address' | translate }}\r\n                    </button>\r\n                    <button\r\n                        vdrDropdownItem\r\n                        class=\"button\"\r\n                        [disabled]=\"isDefaultBilling\"\r\n                        (click)=\"setAsDefaultBillingAddress()\"\r\n                    >\r\n                        {{ 'customer.set-as-default-billing-address' | translate }}\r\n                    </button>\r\n                </vdr-dropdown-menu>\r\n            </vdr-dropdown>\r\n        </ng-container>\r\n    </div>\r\n</div>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                styles: [":host{display:block;max-width:360px}clr-input-container{margin-bottom:12px}.defaul-controls{display:flex}.is-default{margin:0;color:var(--color-success-500)}"]
            },] }
];
AddressCardComponent.ctorParameters = () => [
    { type: ModalService },
    { type: ChangeDetectorRef }
];
AddressCardComponent.propDecorators = {
    addressForm: [{ type: Input }],
    customFields: [{ type: Input }],
    availableCountries: [{ type: Input }],
    isDefaultBilling: [{ type: Input }],
    isDefaultShipping: [{ type: Input }],
    editable: [{ type: Input }],
    setAsDefaultShipping: [{ type: Output }],
    setAsDefaultBilling: [{ type: Output }]
};

class SelectCustomerGroupDialogComponent {
    constructor(dataService) {
        this.dataService = dataService;
        this.selectedGroupIds = [];
    }
    ngOnInit() {
        this.groups$ = this.dataService.customer
            .getCustomerGroupList()
            .mapStream((res) => res.customerGroups.items);
    }
    cancel() {
        this.resolveWith();
    }
    add() {
        this.resolveWith(this.selectedGroupIds);
    }
}
SelectCustomerGroupDialogComponent.decorators = [
    { type: Component, args: [{
                selector: 'vdr-select-customer-group-dialog',
                template: "<ng-template vdrDialogTitle>\r\n    {{ 'customer.add-customer-to-group' | translate }}\r\n</ng-template>\r\n\r\n<ng-select\r\n    [items]=\"groups$ | async\"\r\n    appendTo=\"body\"\r\n    [addTag]=\"false\"\r\n    [multiple]=\"true\"\r\n    bindValue=\"id\"\r\n    [(ngModel)]=\"selectedGroupIds\"\r\n    [clearable]=\"true\"\r\n    [searchable]=\"false\"\r\n>\r\n    <ng-template ng-label-tmp let-item=\"item\" let-clear=\"clear\">\r\n        <span aria-hidden=\"true\" class=\"ng-value-icon left\" (click)=\"clear(item)\"> \u00D7 </span>\r\n        <vdr-chip [colorFrom]=\"item.id\">{{ item.name }}</vdr-chip>\r\n    </ng-template>\r\n    <ng-template ng-option-tmp let-item=\"item\">\r\n        <vdr-chip [colorFrom]=\"item.id\">{{ item.name }}</vdr-chip>\r\n    </ng-template>\r\n</ng-select>\r\n\r\n\r\n<ng-template vdrDialogButtons>\r\n    <button type=\"button\" class=\"btn\" (click)=\"cancel()\">{{ 'common.cancel' | translate }}</button>\r\n    <button type=\"submit\" (click)=\"add()\" [disabled]=\"!selectedGroupIds.length\" class=\"btn btn-primary\">\r\n        {{ 'customer.add-customer-to-groups-with-count' | translate: {count: selectedGroupIds.length} }}\r\n    </button>\r\n</ng-template>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                styles: [""]
            },] }
];
SelectCustomerGroupDialogComponent.ctorParameters = () => [
    { type: DataService }
];

class CustomerDetailComponent extends BaseDetailComponent {
    constructor(route, router, serverConfigService, changeDetector, formBuilder, dataService, modalService, notificationService) {
        super(route, router, serverConfigService, dataService);
        this.changeDetector = changeDetector;
        this.formBuilder = formBuilder;
        this.dataService = dataService;
        this.modalService = modalService;
        this.notificationService = notificationService;
        this.fetchHistory = new Subject();
        this.addressDefaultsUpdated = false;
        this.ordersPerPage = 10;
        this.currentOrdersPage = 1;
        this.orderListUpdates$ = new Subject();
        this.customFields = this.getCustomFieldConfig('Customer');
        this.addressCustomFields = this.getCustomFieldConfig('Address');
        this.detailForm = this.formBuilder.group({
            customer: this.formBuilder.group({
                title: '',
                firstName: ['', Validators.required],
                lastName: ['', Validators.required],
                phoneNumber: '',
                emailAddress: ['', [Validators.required, Validators.email]],
                password: '',
                customFields: this.formBuilder.group(this.customFields.reduce((hash, field) => (Object.assign(Object.assign({}, hash), { [field.name]: '' })), {})),
            }),
            addresses: new FormArray([]),
        });
    }
    ngOnInit() {
        this.init();
        this.availableCountries$ = this.dataService.settings
            .getAvailableCountries()
            .mapSingle(result => result.countries.items)
            .pipe(shareReplay(1));
        const customerWithUpdates$ = this.entity$.pipe(merge(this.orderListUpdates$));
        this.orders$ = customerWithUpdates$.pipe(map(customer => customer.orders.items));
        this.ordersCount$ = this.entity$.pipe(map(customer => customer.orders.totalItems));
        this.history$ = this.fetchHistory.pipe(startWith(null), switchMap(() => {
            return this.dataService.customer
                .getCustomerHistory(this.id, {
                sort: {
                    createdAt: SortOrder.DESC,
                },
            })
                .mapStream(data => { var _a; return (_a = data.customer) === null || _a === void 0 ? void 0 : _a.history.items; });
        }));
    }
    ngOnDestroy() {
        this.destroy();
        this.orderListUpdates$.complete();
    }
    customFieldIsSet(name) {
        return !!this.detailForm.get(['customer', 'customFields', name]);
    }
    getAddressFormControls() {
        const formArray = this.detailForm.get(['addresses']);
        return formArray.controls;
    }
    setDefaultBillingAddressId(id) {
        this.defaultBillingAddressId = id;
        this.addressDefaultsUpdated = true;
    }
    setDefaultShippingAddressId(id) {
        this.defaultShippingAddressId = id;
        this.addressDefaultsUpdated = true;
    }
    addAddress() {
        const addressFormArray = this.detailForm.get('addresses');
        const newAddress = this.formBuilder.group({
            fullName: '',
            company: '',
            streetLine1: ['', Validators.required],
            streetLine2: '',
            city: '',
            province: '',
            postalCode: '',
            countryCode: ['', Validators.required],
            phoneNumber: '',
            defaultShippingAddress: false,
            defaultBillingAddress: false,
        });
        if (this.addressCustomFields.length) {
            const customFieldsGroup = this.formBuilder.group({});
            for (const fieldDef of this.addressCustomFields) {
                customFieldsGroup.addControl(fieldDef.name, new FormControl(''));
            }
            newAddress.addControl('customFields', customFieldsGroup);
        }
        addressFormArray.push(newAddress);
    }
    setOrderItemsPerPage(itemsPerPage) {
        this.ordersPerPage = +itemsPerPage;
        this.fetchOrdersList();
    }
    setOrderCurrentPage(page) {
        this.currentOrdersPage = +page;
        this.fetchOrdersList();
    }
    create() {
        var _a;
        const customerForm = this.detailForm.get('customer');
        if (!customerForm) {
            return;
        }
        const formValue = customerForm.value;
        const customFields = (_a = customerForm.get('customFields')) === null || _a === void 0 ? void 0 : _a.value;
        const customer = {
            title: formValue.title,
            emailAddress: formValue.emailAddress,
            firstName: formValue.firstName,
            lastName: formValue.lastName,
            phoneNumber: formValue.phoneNumber,
            customFields,
        };
        this.dataService.customer
            .createCustomer(customer, formValue.password)
            .subscribe(({ createCustomer }) => {
            switch (createCustomer.__typename) {
                case 'Customer':
                    this.notificationService.success(marker('common.notify-create-success'), {
                        entity: 'Customer',
                    });
                    if (createCustomer.emailAddress && !formValue.password) {
                        this.notificationService.notify({
                            message: marker('customer.email-verification-sent'),
                            translationVars: { emailAddress: formValue.emailAddress },
                            type: 'info',
                            duration: 10000,
                        });
                    }
                    this.detailForm.markAsPristine();
                    this.addressDefaultsUpdated = false;
                    this.changeDetector.markForCheck();
                    this.router.navigate(['../', createCustomer.id], { relativeTo: this.route });
                    break;
                case 'EmailAddressConflictError':
                    this.notificationService.error(createCustomer.message);
            }
        });
    }
    save() {
        this.entity$
            .pipe(take(1), mergeMap(({ id }) => {
            var _a;
            const saveOperations = [];
            const customerForm = this.detailForm.get('customer');
            if (customerForm && customerForm.dirty) {
                const formValue = customerForm.value;
                const customFields = (_a = customerForm.get('customFields')) === null || _a === void 0 ? void 0 : _a.value;
                const customer = {
                    id,
                    title: formValue.title,
                    emailAddress: formValue.emailAddress,
                    firstName: formValue.firstName,
                    lastName: formValue.lastName,
                    phoneNumber: formValue.phoneNumber,
                    customFields,
                };
                saveOperations.push(this.dataService.customer
                    .updateCustomer(customer)
                    .pipe(map(res => res.updateCustomer)));
            }
            const addressFormArray = this.detailForm.get('addresses');
            if ((addressFormArray && addressFormArray.dirty) || this.addressDefaultsUpdated) {
                for (const addressControl of addressFormArray.controls) {
                    if (addressControl.dirty || this.addressDefaultsUpdated) {
                        const address = addressControl.value;
                        const input = {
                            fullName: address.fullName,
                            company: address.company,
                            streetLine1: address.streetLine1,
                            streetLine2: address.streetLine2,
                            city: address.city,
                            province: address.province,
                            postalCode: address.postalCode,
                            countryCode: address.countryCode,
                            phoneNumber: address.phoneNumber,
                            defaultShippingAddress: this.defaultShippingAddressId === address.id,
                            defaultBillingAddress: this.defaultBillingAddressId === address.id,
                            customFields: address.customFields,
                        };
                        if (!address.id) {
                            saveOperations.push(this.dataService.customer
                                .createCustomerAddress(id, input)
                                .pipe(map(res => res.createCustomerAddress)));
                        }
                        else {
                            saveOperations.push(this.dataService.customer
                                .updateCustomerAddress(Object.assign(Object.assign({}, input), { id: address.id }))
                                .pipe(map(res => res.updateCustomerAddress)));
                        }
                    }
                }
            }
            return forkJoin(saveOperations);
        }))
            .subscribe(data => {
            for (const result of data) {
                switch (result.__typename) {
                    case 'Customer':
                    case 'Address':
                        this.notificationService.success(marker('common.notify-update-success'), {
                            entity: 'Customer',
                        });
                        this.detailForm.markAsPristine();
                        this.addressDefaultsUpdated = false;
                        this.changeDetector.markForCheck();
                        this.fetchHistory.next();
                        break;
                    case 'EmailAddressConflictError':
                        this.notificationService.error(result.message);
                        break;
                }
            }
        }, err => {
            this.notificationService.error(marker('common.notify-update-error'), {
                entity: 'Customer',
            });
        });
    }
    addToGroup() {
        this.modalService
            .fromComponent(SelectCustomerGroupDialogComponent, {
            size: 'md',
        })
            .pipe(switchMap(groupIds => (groupIds ? from(groupIds) : EMPTY)), concatMap(groupId => this.dataService.customer.addCustomersToGroup(groupId, [this.id])))
            .subscribe({
            next: res => {
                this.notificationService.success(marker(`customer.add-customers-to-group-success`), {
                    customerCount: 1,
                    groupName: res.addCustomersToGroup.name,
                });
            },
            complete: () => {
                this.dataService.customer.getCustomer(this.id, { take: 0 }).single$.subscribe();
                this.fetchHistory.next();
            },
        });
    }
    removeFromGroup(group) {
        this.modalService
            .dialog({
            title: marker('customer.confirm-remove-customer-from-group'),
            buttons: [
                { type: 'secondary', label: marker('common.cancel') },
                { type: 'danger', label: marker('common.delete'), returnValue: true },
            ],
        })
            .pipe(switchMap(response => response
            ? this.dataService.customer.removeCustomersFromGroup(group.id, [this.id])
            : EMPTY), switchMap(() => this.dataService.customer.getCustomer(this.id, { take: 0 }).single$))
            .subscribe(result => {
            this.notificationService.success(marker(`customer.remove-customers-from-group-success`), {
                customerCount: 1,
                groupName: group.name,
            });
            this.fetchHistory.next();
        });
    }
    addNoteToCustomer({ note }) {
        this.dataService.customer.addNoteToCustomer(this.id, note).subscribe(() => {
            this.fetchHistory.next();
            this.notificationService.success(marker('common.notify-create-success'), {
                entity: 'Note',
            });
        });
    }
    updateNote(entry) {
        this.modalService
            .fromComponent(EditNoteDialogComponent, {
            closable: true,
            locals: {
                displayPrivacyControls: false,
                note: entry.data.note,
            },
        })
            .pipe(switchMap(result => {
            if (result) {
                return this.dataService.customer.updateCustomerNote({
                    noteId: entry.id,
                    note: result.note,
                });
            }
            else {
                return EMPTY;
            }
        }))
            .subscribe(result => {
            this.fetchHistory.next();
            this.notificationService.success(marker('common.notify-update-success'), {
                entity: 'Note',
            });
        });
    }
    deleteNote(entry) {
        return this.modalService
            .dialog({
            title: marker('common.confirm-delete-note'),
            body: entry.data.note,
            buttons: [
                { type: 'secondary', label: marker('common.cancel') },
                { type: 'danger', label: marker('common.delete'), returnValue: true },
            ],
        })
            .pipe(switchMap(res => (res ? this.dataService.customer.deleteCustomerNote(entry.id) : EMPTY)))
            .subscribe(() => {
            this.fetchHistory.next();
            this.notificationService.success(marker('common.notify-delete-success'), {
                entity: 'Note',
            });
        });
    }
    setFormValues(entity) {
        var _a, _b;
        const customerGroup = this.detailForm.get('customer');
        if (customerGroup) {
            customerGroup.patchValue({
                title: entity.title,
                firstName: entity.firstName,
                lastName: entity.lastName,
                phoneNumber: entity.phoneNumber,
                emailAddress: entity.emailAddress,
            });
        }
        if (entity.addresses) {
            const addressesArray = new FormArray([]);
            for (const address of entity.addresses) {
                const _c = address, { customFields } = _c, rest = __rest(_c, ["customFields"]);
                const addressGroup = this.formBuilder.group(Object.assign(Object.assign({}, rest), { countryCode: address.country.code }));
                addressesArray.push(addressGroup);
                if (address.defaultShippingAddress) {
                    this.defaultShippingAddressId = address.id;
                }
                if (address.defaultBillingAddress) {
                    this.defaultBillingAddressId = address.id;
                }
                if (this.addressCustomFields.length) {
                    const customFieldsGroup = this.formBuilder.group({});
                    for (const fieldDef of this.addressCustomFields) {
                        const key = fieldDef.name;
                        const value = (_a = address.customFields) === null || _a === void 0 ? void 0 : _a[key];
                        const control = new FormControl(value);
                        customFieldsGroup.addControl(key, control);
                    }
                    addressGroup.addControl('customFields', customFieldsGroup);
                }
            }
            this.detailForm.setControl('addresses', addressesArray);
        }
        if (this.customFields.length) {
            const customFieldsGroup = this.detailForm.get(['customer', 'customFields']);
            for (const fieldDef of this.customFields) {
                const key = fieldDef.name;
                const value = (_b = entity.customFields) === null || _b === void 0 ? void 0 : _b[key];
                const control = customFieldsGroup.get(key);
                if (control) {
                    control.patchValue(value);
                }
            }
        }
        this.changeDetector.markForCheck();
    }
    /**
     * Refetch the customer with the current order list settings.
     */
    fetchOrdersList() {
        this.dataService.customer
            .getCustomer(this.id, {
            take: this.ordersPerPage,
            skip: (this.currentOrdersPage - 1) * this.ordersPerPage,
        })
            .single$.pipe(map(data => data.customer), filter(notNullOrUndefined))
            .subscribe(result => this.orderListUpdates$.next(result));
    }
}
CustomerDetailComponent.decorators = [
    { type: Component, args: [{
                selector: 'vdr-customer-detail',
                template: "<vdr-action-bar>\r\n    <vdr-ab-left>\r\n        <div class=\"flex clr-align-items-center\">\r\n            <vdr-entity-info [entity]=\"entity$ | async\"></vdr-entity-info>\r\n            <vdr-customer-status-label [customer]=\"entity$ | async\"></vdr-customer-status-label>\r\n            <div class=\"last-login\" *ngIf=\"(entity$ | async)?.user?.lastLogin as lastLogin\" [title]=\"lastLogin | localeDate:'medium'\">\r\n                {{ 'customer.last-login' | translate }}: {{ lastLogin | timeAgo }}\r\n            </div>\r\n        </div>\r\n    </vdr-ab-left>\r\n\r\n    <vdr-ab-right>\r\n        <vdr-action-bar-items locationId=\"customer-detail\"></vdr-action-bar-items>\r\n        <button\r\n            class=\"btn btn-primary\"\r\n            *ngIf=\"isNew$ | async; else updateButton\"\r\n            (click)=\"create()\"\r\n            [disabled]=\"!(addressDefaultsUpdated || (detailForm.valid && detailForm.dirty))\"\r\n        >\r\n            {{ 'common.create' | translate }}\r\n        </button>\r\n        <ng-template #updateButton>\r\n            <button\r\n                *vdrIfPermissions=\"'UpdateCustomer'\"\r\n                class=\"btn btn-primary\"\r\n                (click)=\"save()\"\r\n                [disabled]=\"!(addressDefaultsUpdated || (detailForm.valid && detailForm.dirty))\"\r\n            >\r\n                {{ 'common.update' | translate }}\r\n            </button>\r\n        </ng-template>\r\n    </vdr-ab-right>\r\n</vdr-action-bar>\r\n\r\n<form class=\"form\" [formGroup]=\"detailForm.get('customer')\">\r\n    <vdr-form-field [label]=\"'customer.title' | translate\" for=\"title\" [readOnlyToggle]=\"!(isNew$ | async)\">\r\n        <input id=\"title\" type=\"text\" formControlName=\"title\" />\r\n    </vdr-form-field>\r\n    <vdr-form-field\r\n        [label]=\"'customer.first-name' | translate\"\r\n        for=\"firstName\"\r\n        [readOnlyToggle]=\"!(isNew$ | async)\"\r\n    >\r\n        <input id=\"firstName\" type=\"text\" formControlName=\"firstName\" />\r\n    </vdr-form-field>\r\n    <vdr-form-field\r\n        [label]=\"'customer.last-name' | translate\"\r\n        for=\"lastName\"\r\n        [readOnlyToggle]=\"!(isNew$ | async)\"\r\n    >\r\n        <input id=\"lastName\" type=\"text\" formControlName=\"lastName\" />\r\n    </vdr-form-field>\r\n    <vdr-form-field\r\n        [label]=\"'customer.email-address' | translate\"\r\n        for=\"emailAddress\"\r\n        [readOnlyToggle]=\"!(isNew$ | async)\"\r\n    >\r\n        <input id=\"emailAddress\" type=\"text\" formControlName=\"emailAddress\" />\r\n    </vdr-form-field>\r\n    <vdr-form-field\r\n           [label]=\"'customer.phone-number' | translate\"\r\n           for=\"phoneNumber\"\r\n           [readOnlyToggle]=\"!(isNew$ | async)\"\r\n       >\r\n           <input id=\"phoneNumber\" type=\"text\" formControlName=\"phoneNumber\" />\r\n       </vdr-form-field>\r\n    <vdr-form-field [label]=\"'customer.password' | translate\" for=\"password\" *ngIf=\"isNew$ | async\">\r\n        <input id=\"password\" type=\"password\" formControlName=\"password\" />\r\n    </vdr-form-field>\r\n\r\n    <section formGroupName=\"customFields\" *ngIf=\"customFields.length\">\r\n        <label>{{ 'common.custom-fields' | translate }}</label>\r\n        <ng-container *ngFor=\"let customField of customFields\">\r\n            <vdr-custom-field-control\r\n                *ngIf=\"customFieldIsSet(customField.name)\"\r\n                entityName=\"Customer\"\r\n                [customFieldsFormGroup]=\"detailForm.get(['customer', 'customFields'])\"\r\n                [customField]=\"customField\"\r\n            ></vdr-custom-field-control>\r\n        </ng-container>\r\n    </section>\r\n</form>\r\n\r\n<div class=\"groups\" *ngIf=\"(entity$ | async)?.groups as groups\">\r\n    <label class=\"clr-control-label\">{{ 'customer.customer-groups' | translate }}</label>\r\n    <ng-container *ngIf=\"groups.length; else noGroups\">\r\n        <vdr-chip\r\n            *ngFor=\"let group of groups\"\r\n            [colorFrom]=\"group.id\"\r\n            icon=\"times\"\r\n            (iconClick)=\"removeFromGroup(group)\"\r\n            >{{ group.name }}</vdr-chip\r\n        >\r\n    </ng-container>\r\n    <ng-template #noGroups>\r\n        {{ 'customer.not-a-member-of-any-groups' | translate }}\r\n    </ng-template>\r\n    <div>\r\n        <button class=\"btn btn-sm btn-secondary\" (click)=\"addToGroup()\" *vdrIfPermissions=\"'UpdateCustomerGroup'\">\r\n            <clr-icon shape=\"plus\"></clr-icon>\r\n            {{ 'customer.add-customer-to-group' | translate }}\r\n        </button>\r\n    </div>\r\n</div>\r\n\r\n<div class=\"clr-row\" *ngIf=\"!(isNew$ | async)\">\r\n    <div class=\"clr-col-md-4\">\r\n        <h3>{{ 'customer.addresses' | translate }}</h3>\r\n        <vdr-address-card\r\n            *ngFor=\"let addressForm of getAddressFormControls()\"\r\n            [availableCountries]=\"availableCountries$ | async\"\r\n            [isDefaultBilling]=\"defaultBillingAddressId === addressForm.value.id\"\r\n            [isDefaultShipping]=\"defaultShippingAddressId === addressForm.value.id\"\r\n            [addressForm]=\"addressForm\"\r\n            [customFields]=\"addressCustomFields\"\r\n            [editable]=\"['UpdateCustomer'] | hasPermission\"\r\n            (setAsDefaultBilling)=\"setDefaultBillingAddressId($event)\"\r\n            (setAsDefaultShipping)=\"setDefaultShippingAddressId($event)\"\r\n        ></vdr-address-card>\r\n        <button class=\"btn btn-secondary\" (click)=\"addAddress()\" *vdrIfPermissions=\"'UpdateCustomer'\">\r\n            <clr-icon shape=\"plus\"></clr-icon>\r\n            {{ 'customer.create-new-address' | translate }}\r\n        </button>\r\n    </div>\r\n    <div class=\"clr-col-md-8\">\r\n        <h3>{{ 'customer.orders' | translate }}</h3>\r\n        <vdr-data-table\r\n            [items]=\"orders$ | async\"\r\n            [itemsPerPage]=\"ordersPerPage\"\r\n            [totalItems]=\"ordersCount$ | async\"\r\n            [currentPage]=\"currentOrdersPage\"\r\n            [emptyStateLabel]=\"'customer.no-orders-placed' | translate\"\r\n            (itemsPerPageChange)=\"setOrderItemsPerPage($event)\"\r\n            (pageChange)=\"setOrderCurrentPage($event)\"\r\n        >\r\n            <vdr-dt-column>{{ 'common.code' | translate }}</vdr-dt-column>\r\n            <vdr-dt-column>{{ 'order.state' | translate }}</vdr-dt-column>\r\n            <vdr-dt-column>{{ 'order.total' | translate }}</vdr-dt-column>\r\n            <vdr-dt-column>{{ 'common.updated-at' | translate }}</vdr-dt-column>\r\n            <vdr-dt-column></vdr-dt-column>\r\n            <ng-template let-order=\"item\">\r\n                <td class=\"left\">{{ order.code }}</td>\r\n                <td class=\"left\">{{ order.state }}</td>\r\n                <td class=\"left\">{{ order.total | localeCurrency: order.currencyCode }}</td>\r\n                <td class=\"left\">{{ order.updatedAt | localeDate: 'medium' }}</td>\r\n                <td class=\"right\">\r\n                    <vdr-table-row-action\r\n                        iconShape=\"shopping-cart\"\r\n                        [label]=\"'common.open' | translate\"\r\n                        [linkTo]=\"['/orders/', order.id]\"\r\n                    ></vdr-table-row-action>\r\n                </td>\r\n            </ng-template>\r\n        </vdr-data-table>\r\n    </div>\r\n</div>\r\n<div class=\"clr-row\" *ngIf=\"!(isNew$ | async)\">\r\n    <div class=\"clr-col-md-6\">\r\n        <vdr-customer-history\r\n            [customer]=\"entity$ | async\"\r\n            [history]=\"history$ | async\"\r\n            (addNote)=\"addNoteToCustomer($event)\"\r\n            (updateNote)=\"updateNote($event)\"\r\n            (deleteNote)=\"deleteNote($event)\"\r\n        ></vdr-customer-history>\r\n    </div>\r\n</div>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                styles: [".last-login{margin-left:6px;color:var(--color-grey-500)}"]
            },] }
];
CustomerDetailComponent.ctorParameters = () => [
    { type: ActivatedRoute },
    { type: Router },
    { type: ServerConfigService },
    { type: ChangeDetectorRef },
    { type: FormBuilder },
    { type: DataService },
    { type: ModalService },
    { type: NotificationService }
];

class CustomerGroupDetailDialogComponent {
    cancel() {
        this.resolveWith();
    }
    save() {
        this.resolveWith(this.group.name);
    }
}
CustomerGroupDetailDialogComponent.decorators = [
    { type: Component, args: [{
                selector: 'vdr-customer-group-detail-dialog',
                template: "<ng-template vdrDialogTitle>\r\n    <span *ngIf=\"group.id\">{{ 'customer.update-customer-group' | translate }}</span>\r\n    <span *ngIf=\"!group.id\">{{ 'customer.create-customer-group' | translate }}</span>\r\n</ng-template>\r\n\r\n<vdr-form-field [label]=\"'common.name' | translate\" for=\"name\">\r\n    <input id=\"name\" type=\"text\" [(ngModel)]=\"group.name\" [readonly]=\"!(['CreateCustomerGroup', 'UpdateCustomerGroup'] | hasPermission)\" />\r\n</vdr-form-field>\r\n\r\n<ng-template vdrDialogButtons>\r\n    <button type=\"button\" class=\"btn\" (click)=\"cancel()\">{{ 'common.cancel' | translate }}</button>\r\n    <button type=\"submit\" (click)=\"save()\" [disabled]=\"!group.name\" class=\"btn btn-primary\">\r\n        <span *ngIf=\"group.id\">{{ 'customer.update-customer-group' | translate }}</span>\r\n        <span *ngIf=\"!group.id\">{{ 'customer.create-customer-group' | translate }}</span>\r\n    </button>\r\n</ng-template>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                styles: [""]
            },] }
];

class CustomerGroupListComponent {
    constructor(dataService, notificationService, modalService, route, router) {
        this.dataService = dataService;
        this.notificationService = notificationService;
        this.modalService = modalService;
        this.route = route;
        this.router = router;
        this.selectedCustomerIds = [];
        this.fetchGroupMembers$ = new BehaviorSubject({
            skip: 0,
            take: 0,
            filterTerm: '',
        });
        this.refreshActiveGroupMembers$ = new BehaviorSubject(undefined);
    }
    ngOnInit() {
        this.groups$ = this.dataService.customer
            .getCustomerGroupList()
            .mapStream((data) => data.customerGroups.items);
        const activeGroupId$ = this.route.paramMap.pipe(map((pm) => pm.get('contents')), distinctUntilChanged(), tap(() => (this.selectedCustomerIds = [])));
        this.listIsEmpty$ = this.groups$.pipe(map((groups) => groups.length === 0));
        this.activeGroup$ = combineLatest(this.groups$, activeGroupId$).pipe(map(([groups, activeGroupId]) => {
            if (activeGroupId) {
                return groups.find((g) => g.id === activeGroupId);
            }
        }));
        const membersResult$ = combineLatest(this.activeGroup$, this.fetchGroupMembers$, this.refreshActiveGroupMembers$).pipe(switchMap(([activeGroup, { skip, take, filterTerm }]) => {
            if (activeGroup) {
                return this.dataService.customer
                    .getCustomerGroupWithCustomers(activeGroup.id, {
                    skip,
                    take,
                    filter: {
                        emailAddress: {
                            contains: filterTerm,
                        },
                    },
                })
                    .mapStream((res) => { var _a; return (_a = res.customerGroup) === null || _a === void 0 ? void 0 : _a.customers; });
            }
            else {
                return of(undefined);
            }
        }));
        this.members$ = membersResult$.pipe(map((res) => { var _a; return (_a = res === null || res === void 0 ? void 0 : res.items) !== null && _a !== void 0 ? _a : []; }));
        this.membersTotal$ = membersResult$.pipe(map((res) => { var _a; return (_a = res === null || res === void 0 ? void 0 : res.totalItems) !== null && _a !== void 0 ? _a : 0; }));
    }
    create() {
        this.modalService
            .fromComponent(CustomerGroupDetailDialogComponent, { locals: { group: { name: '' } } })
            .pipe(switchMap((name) => name ? this.dataService.customer.createCustomerGroup({ name, customerIds: [] }) : EMPTY), 
        // refresh list
        switchMap(() => this.dataService.customer.getCustomerGroupList().single$))
            .subscribe(() => {
            this.notificationService.success(marker('common.notify-create-success'), {
                entity: 'CustomerGroup',
            });
        }, (err) => {
            this.notificationService.error(marker('common.notify-create-error'), {
                entity: 'CustomerGroup',
            });
        });
    }
    delete(groupId) {
        this.modalService
            .dialog({
            title: marker('customer.confirm-delete-customer-group'),
            buttons: [
                { type: 'secondary', label: marker('common.cancel') },
                { type: 'danger', label: marker('common.delete'), returnValue: true },
            ],
        })
            .pipe(switchMap((response) => response ? this.dataService.customer.deleteCustomerGroup(groupId) : EMPTY), switchMap((result) => {
            if (result.deleteCustomerGroup.result === DeletionResult.DELETED) {
                // refresh list
                return this.dataService.customer
                    .getCustomerGroupList()
                    .mapSingle(() => ({ errorMessage: false }));
            }
            else {
                return of({ errorMessage: result.deleteCustomerGroup.message });
            }
        }))
            .subscribe((result) => {
            if (typeof result.errorMessage === 'string') {
                this.notificationService.error(result.errorMessage);
            }
            else {
                this.notificationService.success(marker('common.notify-delete-success'), {
                    entity: 'CustomerGroup',
                });
            }
        }, (err) => {
            this.notificationService.error(marker('common.notify-delete-error'), {
                entity: 'CustomerGroup',
            });
        });
    }
    update(group) {
        this.modalService
            .fromComponent(CustomerGroupDetailDialogComponent, { locals: { group } })
            .pipe(switchMap((name) => name ? this.dataService.customer.updateCustomerGroup({ id: group.id, name }) : EMPTY))
            .subscribe(() => {
            this.notificationService.success(marker('common.notify-update-success'), {
                entity: 'CustomerGroup',
            });
        }, (err) => {
            this.notificationService.error(marker('common.notify-update-error'), {
                entity: 'CustomerGroup',
            });
        });
    }
    closeMembers() {
        const params = Object.assign({}, this.route.snapshot.params);
        delete params.contents;
        this.router.navigate(['./', params], { relativeTo: this.route, queryParamsHandling: 'preserve' });
    }
    addToGroup(group) {
        this.modalService
            .fromComponent(AddCustomerToGroupDialogComponent, {
            locals: {
                group,
                route: this.route,
            },
            size: 'md',
            verticalAlign: 'top',
        })
            .pipe(switchMap((customerIds) => customerIds
            ? this.dataService.customer
                .addCustomersToGroup(group.id, customerIds)
                .pipe(mapTo(customerIds))
            : EMPTY))
            .subscribe({
            next: (result) => {
                this.notificationService.success(marker(`customer.add-customers-to-group-success`), {
                    customerCount: result.length,
                    groupName: group.name,
                });
                this.refreshActiveGroupMembers$.next();
                this.selectedCustomerIds = [];
            },
        });
    }
    removeFromGroup(group, customerIds) {
        this.dataService.customer.removeCustomersFromGroup(group.id, customerIds).subscribe({
            complete: () => {
                this.notificationService.success(marker(`customer.remove-customers-from-group-success`), {
                    customerCount: customerIds.length,
                    groupName: group.name,
                });
                this.refreshActiveGroupMembers$.next();
                this.selectedCustomerIds = [];
            },
        });
    }
}
CustomerGroupListComponent.decorators = [
    { type: Component, args: [{
                selector: 'vdr-customer-group-list',
                template: "<vdr-action-bar>\r\n    <vdr-ab-left> </vdr-ab-left>\r\n    <vdr-ab-right>\r\n        <vdr-action-bar-items locationId=\"customer-group-list\"></vdr-action-bar-items>\r\n        <button class=\"btn btn-primary\" *vdrIfPermissions=\"'CreateCustomerGroup'\" (click)=\"create()\">\r\n            <clr-icon shape=\"plus\"></clr-icon>\r\n            {{ 'customer.create-new-customer-group' | translate }}\r\n        </button>\r\n    </vdr-ab-right>\r\n</vdr-action-bar>\r\n<div class=\"group-wrapper\">\r\n    <table class=\"table group-list\" [class.expanded]=\"activeGroup$ | async\" *ngIf=\"!(listIsEmpty$ | async); else emptyPlaceholder\">\r\n        <tbody>\r\n            <tr *ngFor=\"let group of groups$ | async\" [class.active]=\"group.id === (activeGroup$ | async)?.id\">\r\n                <td class=\"left align-middle\"><vdr-entity-info [entity]=\"group\"></vdr-entity-info></td>\r\n                <td class=\"left align-middle\"><vdr-chip [colorFrom]=\"group.id\">{{ group.name }}</vdr-chip></td>\r\n                <td class=\"text-right align-middle\">\r\n                    <a\r\n                        class=\"btn btn-link btn-sm\"\r\n                        [routerLink]=\"['./', { contents: group.id }]\"\r\n                        queryParamsHandling=\"preserve\"\r\n                    >\r\n                        <clr-icon shape=\"view-list\"></clr-icon>\r\n                        {{ 'customer.view-group-members' | translate }}\r\n                    </a>\r\n                </td>\r\n                <td class=\"align-middle\">\r\n                    <button class=\"btn btn-link btn-sm\" (click)=\"update(group)\">\r\n                        <clr-icon shape=\"edit\"></clr-icon>\r\n                        {{ 'common.edit' | translate }}\r\n                    </button>\r\n                </td>\r\n                <td class=\"align-middle\">\r\n                    <vdr-dropdown>\r\n                        <button type=\"button\" class=\"btn btn-link btn-sm\" vdrDropdownTrigger>\r\n                            {{ 'common.actions' | translate }}\r\n                            <clr-icon shape=\"caret down\"></clr-icon>\r\n                        </button>\r\n                        <vdr-dropdown-menu vdrPosition=\"bottom-right\">\r\n                            <button\r\n                                class=\"button\"\r\n                                vdrDropdownItem\r\n                                (click)=\"delete(group.id)\"\r\n                                [disabled]=\"!('DeleteCustomerGroup' | hasPermission)\"\r\n                            >\r\n                                <clr-icon shape=\"trash\" class=\"is-danger\"></clr-icon>\r\n                                {{ 'common.delete' | translate }}\r\n                            </button>\r\n                        </vdr-dropdown-menu>\r\n                    </vdr-dropdown>\r\n                </td>\r\n            </tr>\r\n        </tbody>\r\n    </table>\r\n    <ng-template #emptyPlaceholder>\r\n        <vdr-empty-placeholder></vdr-empty-placeholder>\r\n    </ng-template>\r\n    <div class=\"group-members\" [class.expanded]=\"activeGroup$ | async\">\r\n        <ng-container *ngIf=\"activeGroup$ | async as activeGroup\">\r\n            <div class=\"flex\">\r\n                <div class=\"header-title-row\">\r\n                    {{ activeGroup.name }} ({{ membersTotal$ | async }})\r\n                </div>\r\n                <div class=\"flex-spacer\"></div>\r\n                <button type=\"button\" class=\"close-button\" (click)=\"closeMembers()\">\r\n                    <clr-icon shape=\"close\"></clr-icon>\r\n                </button>\r\n            </div>\r\n            <div class=\"controls\">\r\n                <vdr-dropdown>\r\n                    <button\r\n                        type=\"button\"\r\n                        class=\"btn btn-secondary btn-sm\"\r\n                        vdrDropdownTrigger\r\n                        [disabled]=\"selectedCustomerIds.length === 0\"\r\n                    >\r\n                        {{ 'common.with-selected' | translate }}\r\n                        <clr-icon shape=\"caret down\"></clr-icon>\r\n                    </button>\r\n                    <vdr-dropdown-menu vdrPosition=\"bottom-right\">\r\n                        <button\r\n                            type=\"button\"\r\n                            class=\"delete-button\"\r\n                            (click)=\"removeFromGroup(activeGroup, selectedCustomerIds)\"\r\n                            vdrDropdownItem\r\n                            [disabled]=\"!('UpdateCustomerGroup' | hasPermission)\"\r\n                        >\r\n                            <clr-icon shape=\"trash\" class=\"is-danger\"></clr-icon>\r\n                            {{ 'customer.remove-from-group' | translate }}\r\n                        </button>\r\n                    </vdr-dropdown-menu>\r\n                </vdr-dropdown>\r\n                <button class=\"btn btn-secondary btn-sm\" (click)=\"addToGroup(activeGroup)\">\r\n                    {{ 'customer.add-customers-to-group' | translate: { groupName: activeGroup.name } }}\r\n                </button>\r\n            </div>\r\n            <vdr-customer-group-member-list\r\n                [members]=\"members$ | async\"\r\n                [route]=\"route\"\r\n                [totalItems]=\"membersTotal$ | async\"\r\n                [selectedMemberIds]=\"selectedCustomerIds\"\r\n                (selectionChange)=\"selectedCustomerIds = $event\"\r\n                (fetchParamsChange)=\"fetchGroupMembers$.next($event)\"\r\n            ></vdr-customer-group-member-list>\r\n        </ng-container>\r\n    </div>\r\n</div>\r\n\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                styles: [".group-wrapper{display:flex;height:calc(100% - 50px)}.group-wrapper .group-list{flex:1;overflow:auto;margin-top:0}.group-wrapper .group-list tr.active{background-color:var(--color-component-bg-200)}.group-wrapper .group-list.expanded{width:calc(100% - 40vw)}.group-members{height:100%;width:0;opacity:0;visibility:hidden;overflow:auto;transition:width .3s,opacity .2s .3s,visibility 0s .3s}.group-members.expanded{width:40vw;visibility:visible;opacity:1;padding-left:12px}.group-members .close-button{margin:0;background:none;border:none;cursor:pointer}.group-members ::ng-deep table.table{margin-top:0}.group-members ::ng-deep table.table th{top:0}.group-members .controls{display:flex;justify-content:space-between}vdr-empty-placeholder{flex:1}"]
            },] }
];
CustomerGroupListComponent.ctorParameters = () => [
    { type: DataService },
    { type: NotificationService },
    { type: ModalService },
    { type: ActivatedRoute },
    { type: Router }
];

class CustomerGroupMemberListComponent {
    constructor(router, dataService) {
        this.router = router;
        this.dataService = dataService;
        this.selectedMemberIds = [];
        this.selectionChange = new EventEmitter();
        this.fetchParamsChange = new EventEmitter();
        this.filterTermControl = new FormControl('');
        this.refresh$ = new BehaviorSubject(true);
        this.destroy$ = new Subject();
        this.isMemberSelected = (member) => {
            return -1 < this.selectedMemberIds.indexOf(member.id);
        };
    }
    ngOnInit() {
        this.membersCurrentPage$ = this.route.paramMap.pipe(map((qpm) => qpm.get('membersPage')), map((page) => (!page ? 1 : +page)), startWith(1), distinctUntilChanged());
        this.membersItemsPerPage$ = this.route.paramMap.pipe(map((qpm) => qpm.get('membersPerPage')), map((perPage) => (!perPage ? 10 : +perPage)), startWith(10), distinctUntilChanged());
        const filterTerm$ = this.filterTermControl.valueChanges.pipe(debounceTime(250), tap(() => this.setContentsPageNumber(1)), startWith(''));
        combineLatest(this.membersCurrentPage$, this.membersItemsPerPage$, filterTerm$, this.refresh$)
            .pipe(takeUntil(this.destroy$))
            .subscribe(([currentPage, itemsPerPage, filterTerm]) => {
            const take = itemsPerPage;
            const skip = (currentPage - 1) * itemsPerPage;
            this.fetchParamsChange.emit({
                filterTerm,
                skip,
                take,
            });
        });
    }
    ngOnDestroy() {
        this.destroy$.next();
        this.destroy$.complete();
    }
    setContentsPageNumber(page) {
        this.setParam('membersPage', page);
    }
    setContentsItemsPerPage(perPage) {
        this.setParam('membersPerPage', perPage);
    }
    refresh() {
        this.refresh$.next(true);
    }
    setParam(key, value) {
        this.router.navigate(['./', Object.assign(Object.assign({}, this.route.snapshot.params), { [key]: value })], {
            relativeTo: this.route,
            queryParamsHandling: 'merge',
        });
    }
    areAllSelected() {
        if (this.members) {
            return this.selectedMemberIds.length === this.members.length;
        }
        else {
            return false;
        }
    }
    toggleSelectAll() {
        if (this.areAllSelected()) {
            this.selectionChange.emit([]);
        }
        else {
            this.selectionChange.emit(this.members.map((v) => v.id));
        }
    }
    toggleSelectMember(member) {
        if (this.selectedMemberIds.includes(member.id)) {
            this.selectionChange.emit(this.selectedMemberIds.filter((id) => id !== member.id));
        }
        else {
            this.selectionChange.emit([...this.selectedMemberIds, member.id]);
        }
    }
}
CustomerGroupMemberListComponent.decorators = [
    { type: Component, args: [{
                selector: 'vdr-customer-group-member-list',
                template: "<input\r\n    type=\"text\"\r\n    name=\"searchTerm\"\r\n    [formControl]=\"filterTermControl\"\r\n    [placeholder]=\"'customer.search-customers-by-email' | translate\"\r\n    class=\"search-input\"\r\n/>\r\n\r\n<vdr-data-table\r\n    [items]=\"members\"\r\n    [itemsPerPage]=\"membersItemsPerPage$ | async\"\r\n    [totalItems]=\"totalItems\"\r\n    [currentPage]=\"membersCurrentPage$ | async\"\r\n    (pageChange)=\"setContentsPageNumber($event)\"\r\n    (itemsPerPageChange)=\"setContentsItemsPerPage($event)\"\r\n    [allSelected]=\"areAllSelected()\"\r\n    [isRowSelectedFn]=\"('UpdateCustomerGroup' | hasPermission) && isMemberSelected\"\r\n    (rowSelectChange)=\"toggleSelectMember($event)\"\r\n    (allSelectChange)=\"toggleSelectAll()\"\r\n>\r\n    <vdr-dt-column [expand]=\"true\">{{ 'customer.name' | translate }}</vdr-dt-column>\r\n    <vdr-dt-column [expand]=\"true\">{{ 'customer.email-address' | translate }}</vdr-dt-column>\r\n    <vdr-dt-column></vdr-dt-column>\r\n    <ng-template let-customer=\"item\">\r\n        <td class=\"left align-middle\">\r\n            {{ customer.title }} {{ customer.firstName }} {{ customer.lastName }}\r\n        </td>\r\n        <td class=\"left align-middle\">{{ customer.emailAddress }}</td>\r\n        <td class=\"right align-middle\">\r\n            <vdr-table-row-action\r\n                iconShape=\"edit\"\r\n                [label]=\"'common.edit' | translate\"\r\n                [linkTo]=\"['/customer', 'customers', customer.id]\"\r\n            ></vdr-table-row-action>\r\n        </td>\r\n    </ng-template>\r\n</vdr-data-table>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                styles: [""]
            },] }
];
CustomerGroupMemberListComponent.ctorParameters = () => [
    { type: Router },
    { type: DataService }
];
CustomerGroupMemberListComponent.propDecorators = {
    members: [{ type: Input }],
    totalItems: [{ type: Input }],
    route: [{ type: Input }],
    selectedMemberIds: [{ type: Input }],
    selectionChange: [{ type: Output }],
    fetchParamsChange: [{ type: Output }]
};

class CustomerHistoryComponent {
    constructor() {
        this.addNote = new EventEmitter();
        this.updateNote = new EventEmitter();
        this.deleteNote = new EventEmitter();
        this.note = '';
        this.type = HistoryEntryType;
    }
    getDisplayType(entry) {
        switch (entry.type) {
            case HistoryEntryType.CUSTOMER_VERIFIED:
            case HistoryEntryType.CUSTOMER_EMAIL_UPDATE_VERIFIED:
            case HistoryEntryType.CUSTOMER_PASSWORD_RESET_VERIFIED:
                return 'success';
            case HistoryEntryType.CUSTOMER_REGISTERED:
                return 'muted';
            case HistoryEntryType.CUSTOMER_REMOVED_FROM_GROUP:
                return 'error';
            default:
                return 'default';
        }
    }
    getTimelineIcon(entry) {
        switch (entry.type) {
            case HistoryEntryType.CUSTOMER_REGISTERED:
                return 'user';
            case HistoryEntryType.CUSTOMER_VERIFIED:
                return ['assign-user', 'is-solid'];
            case HistoryEntryType.CUSTOMER_NOTE:
                return 'note';
            case HistoryEntryType.CUSTOMER_ADDED_TO_GROUP:
            case HistoryEntryType.CUSTOMER_REMOVED_FROM_GROUP:
                return 'users';
        }
    }
    isFeatured(entry) {
        switch (entry.type) {
            case HistoryEntryType.CUSTOMER_REGISTERED:
            case HistoryEntryType.CUSTOMER_VERIFIED:
                return true;
            default:
                return false;
        }
    }
    getName(entry) {
        const { administrator } = entry;
        if (administrator) {
            return `${administrator.firstName} ${administrator.lastName}`;
        }
        else {
            return `${this.customer.firstName} ${this.customer.lastName}`;
        }
    }
    addNoteToCustomer() {
        this.addNote.emit({ note: this.note });
        this.note = '';
    }
}
CustomerHistoryComponent.decorators = [
    { type: Component, args: [{
                selector: 'vdr-customer-history',
                template: "<h4>{{ 'customer.customer-history' | translate }}</h4>\r\n<div class=\"entry-list\">\r\n    <vdr-timeline-entry iconShape=\"note\" displayType=\"muted\" *vdrIfPermissions=\"'UpdateCustomer'\">\r\n        <div class=\"note-entry\">\r\n            <textarea [(ngModel)]=\"note\" name=\"note\" class=\"note\"></textarea>\r\n            <button class=\"btn btn-secondary\" [disabled]=\"!note\" (click)=\"addNoteToCustomer()\">\r\n                {{ 'order.add-note' | translate }}\r\n            </button>\r\n        </div>\r\n    </vdr-timeline-entry>\r\n    <vdr-timeline-entry\r\n        *ngFor=\"let entry of history\"\r\n        [displayType]=\"getDisplayType(entry)\"\r\n        [iconShape]=\"getTimelineIcon(entry)\"\r\n        [createdAt]=\"entry.createdAt\"\r\n        [name]=\"getName(entry)\"\r\n        [featured]=\"isFeatured(entry)\"\r\n    >\r\n        <ng-container [ngSwitch]=\"entry.type\">\r\n            <ng-container *ngSwitchCase=\"type.CUSTOMER_REGISTERED\">\r\n                <div class=\"title\">\r\n                    {{ 'customer.history-customer-registered' | translate }}\r\n                </div>\r\n                <ng-container *ngIf=\"entry.data.strategy === 'native'; else namedStrategy\">\r\n                    {{ 'customer.history-using-native-auth-strategy' | translate }}\r\n                </ng-container>\r\n                <ng-template #namedStrategy>\r\n                    {{\r\n                    'customer.history-using-external-auth-strategy'\r\n                        | translate: { strategy: entry.data.strategy }\r\n                    }}\r\n                </ng-template>\r\n            </ng-container>\r\n            <ng-container *ngSwitchCase=\"type.CUSTOMER_VERIFIED\">\r\n                <div class=\"title\">\r\n                    {{ 'customer.history-customer-verified' | translate }}\r\n                </div>\r\n                <ng-container *ngIf=\"entry.data.strategy === 'native'; else namedStrategy\">\r\n                    {{ 'customer.history-using-native-auth-strategy' | translate }}\r\n                </ng-container>\r\n                <ng-template #namedStrategy>\r\n                    {{\r\n                        'customer.history-using-external-auth-strategy'\r\n                            | translate: { strategy: entry.data.strategy }\r\n                    }}\r\n                </ng-template>\r\n            </ng-container>\r\n            <ng-container *ngSwitchCase=\"type.CUSTOMER_DETAIL_UPDATED\">\r\n                <div class=\"flex\">\r\n                    {{ 'customer.history-customer-detail-updated' | translate }}\r\n                    <vdr-history-entry-detail>\r\n                        <vdr-object-tree [value]=\"entry.data.input\"></vdr-object-tree>\r\n                    </vdr-history-entry-detail>\r\n                </div>\r\n            </ng-container>\r\n            <ng-container *ngSwitchCase=\"type.CUSTOMER_ADDED_TO_GROUP\">\r\n                {{\r\n                    'customer.history-customer-added-to-group'\r\n                        | translate: { groupName: entry.data.groupName }\r\n                }}\r\n            </ng-container>\r\n            <ng-container *ngSwitchCase=\"type.CUSTOMER_REMOVED_FROM_GROUP\">\r\n                {{\r\n                    'customer.history-customer-removed-from-group'\r\n                        | translate: { groupName: entry.data.groupName }\r\n                }}\r\n            </ng-container>\r\n            <ng-container *ngSwitchCase=\"type.CUSTOMER_ADDRESS_CREATED\">\r\n                {{ 'customer.history-customer-address-created' | translate }}\r\n                <div class=\"flex\">\r\n                    <div class=\"address-string\">{{ entry.data.address }}</div>\r\n                </div>\r\n            </ng-container>\r\n            <ng-container *ngSwitchCase=\"type.CUSTOMER_ADDRESS_UPDATED\">\r\n                {{ 'customer.history-customer-address-updated' | translate }}\r\n                <div class=\"flex\">\r\n                    <div class=\"address-string\">{{ entry.data.address }}</div>\r\n                    <vdr-history-entry-detail>\r\n                        <vdr-object-tree [value]=\"entry.data.input\"></vdr-object-tree>\r\n                    </vdr-history-entry-detail>\r\n                </div>\r\n            </ng-container>\r\n            <ng-container *ngSwitchCase=\"type.CUSTOMER_ADDRESS_DELETED\">\r\n                {{ 'customer.history-customer-address-deleted' | translate }}\r\n                <div class=\"address-string\">{{ entry.data.address }}</div>\r\n            </ng-container>\r\n            <ng-container *ngSwitchCase=\"type.CUSTOMER_PASSWORD_UPDATED\">\r\n                {{ 'customer.history-customer-password-updated' | translate }}\r\n            </ng-container>\r\n            <ng-container *ngSwitchCase=\"type.CUSTOMER_PASSWORD_RESET_REQUESTED\">\r\n                {{ 'customer.history-customer-password-reset-requested' | translate }}\r\n            </ng-container>\r\n            <ng-container *ngSwitchCase=\"type.CUSTOMER_PASSWORD_RESET_VERIFIED\">\r\n                {{ 'customer.history-customer-password-reset-verified' | translate }}\r\n            </ng-container>\r\n            <ng-container *ngSwitchCase=\"type.CUSTOMER_EMAIL_UPDATE_REQUESTED\">\r\n                <div class=\"flex\">\r\n                    {{ 'customer.history-customer-email-update-requested' | translate }}\r\n                    <vdr-history-entry-detail>\r\n                        <vdr-labeled-data [label]=\"'customer.old-email-address' | translate\">{{\r\n                            entry.data.oldEmailAddress\r\n                        }}</vdr-labeled-data>\r\n                        <vdr-labeled-data [label]=\"'customer.new-email-address' | translate\">{{\r\n                            entry.data.newEmailAddress\r\n                        }}</vdr-labeled-data>\r\n                    </vdr-history-entry-detail>\r\n                </div>\r\n            </ng-container>\r\n            <ng-container *ngSwitchCase=\"type.CUSTOMER_EMAIL_UPDATE_VERIFIED\">\r\n                <div class=\"flex\">\r\n                    {{ 'customer.history-customer-email-update-verified' | translate }}\r\n                    <vdr-history-entry-detail>\r\n                        <vdr-labeled-data [label]=\"'customer.old-email-address' | translate\">{{\r\n                            entry.data.oldEmailAddress\r\n                        }}</vdr-labeled-data>\r\n                        <vdr-labeled-data [label]=\"'customer.new-email-address' | translate\">{{\r\n                            entry.data.newEmailAddress\r\n                        }}</vdr-labeled-data>\r\n                    </vdr-history-entry-detail>\r\n                </div>\r\n            </ng-container>\r\n            <ng-container *ngSwitchCase=\"type.CUSTOMER_NOTE\">\r\n                <div class=\"flex\">\r\n                    <div class=\"note-text\">\r\n                        {{ entry.data.note }}\r\n                    </div>\r\n                    <div class=\"flex-spacer\"></div>\r\n                    <vdr-dropdown>\r\n                        <button class=\"icon-button\" vdrDropdownTrigger>\r\n                            <clr-icon shape=\"ellipsis-vertical\"></clr-icon>\r\n                        </button>\r\n                        <vdr-dropdown-menu vdrPosition=\"bottom-right\">\r\n                            <button\r\n                                class=\"button\"\r\n                                vdrDropdownItem\r\n                                (click)=\"updateNote.emit(entry)\"\r\n                                [disabled]=\"!('UpdateCustomer' | hasPermission)\"\r\n                            >\r\n                                <clr-icon shape=\"edit\"></clr-icon>\r\n                                {{ 'common.edit' | translate }}\r\n                            </button>\r\n                            <div class=\"dropdown-divider\"></div>\r\n                            <button\r\n                                class=\"button\"\r\n                                vdrDropdownItem\r\n                                (click)=\"deleteNote.emit(entry)\"\r\n                                [disabled]=\"!('UpdateCustomer' | hasPermission)\"\r\n                            >\r\n                                <clr-icon shape=\"trash\" class=\"is-danger\"></clr-icon>\r\n                                {{ 'common.delete' | translate }}\r\n                            </button>\r\n                        </vdr-dropdown-menu>\r\n                    </vdr-dropdown>\r\n                </div>\r\n            </ng-container>\r\n        </ng-container>\r\n    </vdr-timeline-entry>\r\n    <vdr-timeline-entry [isLast]=\"true\"></vdr-timeline-entry>\r\n</div>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                styles: [".entry-list{margin-top:24px;margin-left:24px;margin-right:12px}.note-entry{display:flex;align-items:center}.note-entry .note{flex:1}.note-entry button{margin:0}textarea.note{flex:1;height:36px;border-radius:3px;margin-right:6px}.note-text{color:var(--color-text-100);white-space:pre-wrap}.address-string{font-size:smaller;color:var(--color-text-200)}"]
            },] }
];
CustomerHistoryComponent.propDecorators = {
    customer: [{ type: Input }],
    history: [{ type: Input }],
    addNote: [{ type: Output }],
    updateNote: [{ type: Output }],
    deleteNote: [{ type: Output }]
};

class CustomerListComponent extends BaseListComponent {
    constructor(dataService, router, route, modalService, notificationService) {
        super(router, route);
        this.dataService = dataService;
        this.modalService = modalService;
        this.notificationService = notificationService;
        this.emailSearchTerm = new FormControl('');
        this.lastNameSearchTerm = new FormControl('');
        super.setQueryFn((...args) => this.dataService.customer.getCustomerList(...args).refetchOnChannelChange(), data => data.customers, (skip, take) => ({
            options: {
                skip,
                take,
                filter: {
                    emailAddress: {
                        contains: this.emailSearchTerm.value,
                    },
                    lastName: {
                        contains: this.lastNameSearchTerm.value,
                    },
                },
                sort: {
                    createdAt: SortOrder$1.DESC,
                },
            },
        }));
    }
    ngOnInit() {
        super.ngOnInit();
        merge$1(this.emailSearchTerm.valueChanges, this.lastNameSearchTerm.valueChanges)
            .pipe(filter(value => 2 < value.length || value.length === 0), debounceTime(250), takeUntil(this.destroy$))
            .subscribe(() => this.refresh());
    }
    deleteCustomer(customer) {
        return this.modalService
            .dialog({
            title: marker('catalog.confirm-delete-customer'),
            body: `${customer.firstName} ${customer.lastName}`,
            buttons: [
                { type: 'secondary', label: marker('common.cancel') },
                { type: 'danger', label: marker('common.delete'), returnValue: true },
            ],
        })
            .pipe(switchMap(res => (res ? this.dataService.customer.deleteCustomer(customer.id) : EMPTY)))
            .subscribe(() => {
            this.notificationService.success(marker('common.notify-delete-success'), {
                entity: 'Customer',
            });
            this.refresh();
        }, err => {
            this.notificationService.error(marker('common.notify-delete-error'), {
                entity: 'Customer',
            });
        });
    }
}
CustomerListComponent.decorators = [
    { type: Component, args: [{
                selector: 'vdr-customer-list',
                template: "<vdr-action-bar>\r\n    <vdr-ab-left>\r\n        <input\r\n            type=\"text\"\r\n            name=\"emailSearchTerm\"\r\n            [formControl]=\"emailSearchTerm\"\r\n            [placeholder]=\"'customer.search-customers-by-email' | translate\"\r\n            class=\"search-input ml3\"\r\n        />\r\n        <input\r\n            type=\"text\"\r\n            name=\"lastNameSearchTerm\"\r\n            [formControl]=\"lastNameSearchTerm\"\r\n            [placeholder]=\"'customer.search-customers-by-last-name' | translate\"\r\n            class=\"search-input ml3\"\r\n        />\r\n    </vdr-ab-left>\r\n    <vdr-ab-right>\r\n        <vdr-action-bar-items locationId=\"customer-list\"></vdr-action-bar-items>\r\n        <a class=\"btn btn-primary\" [routerLink]=\"['./create']\" *vdrIfPermissions=\"'CreateCustomer'\">\r\n            <clr-icon shape=\"plus\"></clr-icon>\r\n            {{ 'customer.create-new-customer' | translate }}\r\n        </a>\r\n    </vdr-ab-right>\r\n</vdr-action-bar>\r\n\r\n<vdr-data-table\r\n    [items]=\"items$ | async\"\r\n    [itemsPerPage]=\"itemsPerPage$ | async\"\r\n    [totalItems]=\"totalItems$ | async\"\r\n    [currentPage]=\"currentPage$ | async\"\r\n    (pageChange)=\"setPageNumber($event)\"\r\n    (itemsPerPageChange)=\"setItemsPerPage($event)\"\r\n>\r\n    <vdr-dt-column [expand]=\"true\">{{ 'customer.name' | translate }}</vdr-dt-column>\r\n    <vdr-dt-column [expand]=\"true\">{{ 'customer.email-address' | translate }}</vdr-dt-column>\r\n    <vdr-dt-column>{{ 'customer.customer-type' | translate }}</vdr-dt-column>\r\n    <vdr-dt-column></vdr-dt-column>\r\n    <vdr-dt-column></vdr-dt-column>\r\n    <ng-template let-customer=\"item\">\r\n        <td class=\"left align-middle\">\r\n            {{ customer.title }} {{ customer.firstName }} {{ customer.lastName }}\r\n        </td>\r\n        <td class=\"left align-middle\">{{ customer.emailAddress }}</td>\r\n        <td class=\"left align-middle\">\r\n            <vdr-customer-status-label [customer]=\"customer\"></vdr-customer-status-label>\r\n        </td>\r\n        <td class=\"right align-middle\">\r\n            <vdr-table-row-action\r\n                iconShape=\"edit\"\r\n                [label]=\"'common.edit' | translate\"\r\n                [linkTo]=\"['./', customer.id]\"\r\n            ></vdr-table-row-action>\r\n        </td>\r\n        <td>\r\n            <vdr-dropdown>\r\n                <button type=\"button\" class=\"btn btn-link btn-sm\" vdrDropdownTrigger>\r\n                    {{ 'common.actions' | translate }}\r\n                    <clr-icon shape=\"caret down\"></clr-icon>\r\n                </button>\r\n                <vdr-dropdown-menu vdrPosition=\"bottom-right\">\r\n                    <button\r\n                        type=\"button\"\r\n                        class=\"delete-button\"\r\n                        (click)=\"deleteCustomer(customer)\"\r\n                        [disabled]=\"!('DeleteCustomer' | hasPermission)\"\r\n                        vdrDropdownItem\r\n                    >\r\n                        <clr-icon shape=\"trash\" class=\"is-danger\"></clr-icon>\r\n                        {{ 'common.delete' | translate }}\r\n                    </button>\r\n                </vdr-dropdown-menu>\r\n            </vdr-dropdown>\r\n        </td>\r\n    </ng-template>\r\n</vdr-data-table>\r\n",
                styles: [".search-input{margin-top:6px;min-width:300px}"]
            },] }
];
CustomerListComponent.ctorParameters = () => [
    { type: DataService },
    { type: Router },
    { type: ActivatedRoute },
    { type: ModalService },
    { type: NotificationService }
];

class CustomerStatusLabelComponent {
}
CustomerStatusLabelComponent.decorators = [
    { type: Component, args: [{
                selector: 'vdr-customer-status-label',
                template: "<vdr-chip *ngIf=\"customer.user?.id\">\r\n    <ng-container *ngIf=\"customer.user?.verified\">\r\n        <clr-icon shape=\"check-circle\" class=\"verified-user-icon\"></clr-icon>\r\n        {{ 'customer.verified' | translate }}\r\n    </ng-container>\r\n    <ng-container *ngIf=\"!customer.user?.verified\">\r\n        <clr-icon shape=\"check-circle\" class=\"registered-user-icon\"></clr-icon>\r\n        {{ 'customer.registered' | translate }}\r\n    </ng-container>\r\n</vdr-chip>\r\n<vdr-chip *ngIf=\"!customer.user?.id\">{{ 'customer.guest' | translate }}</vdr-chip>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                styles: [".registered-user-icon{color:var(--color-grey-300)}.verified-user-icon{color:var(--color-success-500)}"]
            },] }
];
CustomerStatusLabelComponent.propDecorators = {
    customer: [{ type: Input }]
};

class CustomerResolver extends BaseEntityResolver {
    constructor(router, dataService) {
        super(router, {
            __typename: 'Customer',
            id: '',
            createdAt: '',
            updatedAt: '',
            title: '',
            firstName: '',
            lastName: '',
            emailAddress: '',
            phoneNumber: null,
            addresses: null,
            user: null,
        }, id => dataService.customer.getCustomer(id).mapStream(data => data.customer));
    }
}
CustomerResolver.ɵprov = i0.ɵɵdefineInjectable({ factory: function CustomerResolver_Factory() { return new CustomerResolver(i0.ɵɵinject(i1.Router), i0.ɵɵinject(i2.DataService)); }, token: CustomerResolver, providedIn: "root" });
CustomerResolver.decorators = [
    { type: Injectable, args: [{
                providedIn: 'root',
            },] }
];
CustomerResolver.ctorParameters = () => [
    { type: Router },
    { type: DataService }
];

const ɵ0 = {
    breadcrumb: marker('breadcrumb.customers'),
}, ɵ1 = {
    breadcrumb: customerBreadcrumb,
}, ɵ2 = {
    breadcrumb: marker('breadcrumb.customer-groups'),
};
const customerRoutes = [
    {
        path: 'customers',
        component: CustomerListComponent,
        pathMatch: '',
        data: ɵ0,
    },
    {
        path: 'customers/:id',
        component: CustomerDetailComponent,
        resolve: createResolveData(CustomerResolver),
        canDeactivate: [CanDeactivateDetailGuard],
        data: ɵ1,
    },
    {
        path: 'groups',
        component: CustomerGroupListComponent,
        data: ɵ2,
    },
];
function customerBreadcrumb(data, params) {
    return detailBreadcrumb({
        entity: data.entity,
        id: params.id,
        breadcrumbKey: 'breadcrumb.customers',
        getName: (customer) => `${customer.firstName} ${customer.lastName}`,
        route: 'customers',
    });
}

class CustomerModule {
}
CustomerModule.decorators = [
    { type: NgModule, args: [{
                imports: [SharedModule, RouterModule.forChild(customerRoutes)],
                declarations: [
                    CustomerListComponent,
                    CustomerDetailComponent,
                    CustomerStatusLabelComponent,
                    AddressCardComponent,
                    CustomerGroupListComponent,
                    CustomerGroupDetailDialogComponent,
                    AddCustomerToGroupDialogComponent,
                    CustomerGroupMemberListComponent,
                    SelectCustomerGroupDialogComponent,
                    CustomerHistoryComponent,
                    AddressDetailDialogComponent,
                ],
                exports: [AddressCardComponent],
            },] }
];

// This file was generated by the build-public-api.ts script

/**
 * Generated bundle index. Do not edit.
 */

export { AddCustomerToGroupDialogComponent, AddressCardComponent, AddressDetailDialogComponent, CustomerDetailComponent, CustomerGroupDetailDialogComponent, CustomerGroupListComponent, CustomerGroupMemberListComponent, CustomerHistoryComponent, CustomerListComponent, CustomerModule, CustomerResolver, CustomerStatusLabelComponent, SelectCustomerGroupDialogComponent, customerBreadcrumb, customerRoutes, ɵ0, ɵ1, ɵ2 };
//# sourceMappingURL=ishop-admin-ui-customer.js.map
