import { ChangeDetectionStrategy, Component } from '@angular/core';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { getAppConfig, } from '@vendure/admin-ui/core';
import { summate } from '@vendure/common/lib/shared-utils';
import * as i0 from "@angular/core";
import * as i1 from "@vendure/admin-ui/core";
import * as i2 from "@clr/angular";
import * as i3 from "@angular/common";
import * as i4 from "@angular/forms";
import * as i5 from "@ng-select/ng-select";
import * as i6 from "../line-refunds/line-refunds.component";
import * as i7 from "@ngx-translate/core";
export class RefundOrderDialogComponent {
    constructor(i18nService) {
        this.i18nService = i18nService;
        this.lineQuantities = {};
        this.refundShipping = false;
        this.adjustment = 0;
        this.reasons = getAppConfig().cancellationReasons ?? [
            _('order.refund-reason-customer-request'),
            _('order.refund-reason-not-available'),
        ];
        this.reasons = this.reasons.map(r => this.i18nService.translate(r));
    }
    get refundTotal() {
        const itemTotal = this.order.lines.reduce((total, line) => {
            const lineRef = this.lineQuantities[line.id];
            const refundCount = (lineRef.refund && lineRef.quantity) || 0;
            return total + line.proratedUnitPriceWithTax * refundCount;
        }, 0);
        return itemTotal + (this.refundShipping ? this.order.shippingWithTax : 0) + this.adjustment;
    }
    get settledPaymentsTotal() {
        return this.settledPayments
            .map(payment => {
            const paymentTotal = payment.amount;
            const alreadyRefundedTotal = summate(payment.refunds.filter(r => r.state !== 'Failed'), 'total');
            return paymentTotal - alreadyRefundedTotal;
        })
            .reduce((sum, amount) => sum + amount, 0);
    }
    lineCanBeRefundedOrCancelled(line) {
        const refundedCount = this.order.payments
            ?.reduce((all, payment) => [...all, ...payment.refunds], [])
            .filter(refund => refund.state !== 'Failed')
            .reduce((all, refund) => [...all, ...refund.lines], [])
            .filter(refundLine => refundLine.orderLineId === line.id)
            .reduce((sum, refundLine) => sum + refundLine.quantity, 0) ?? 0;
        return refundedCount < line.quantity;
    }
    ngOnInit() {
        this.lineQuantities = this.order.lines.reduce((result, line) => ({
            ...result,
            [line.id]: {
                quantity: 0,
                refund: false,
                cancel: false,
            },
        }), {});
        this.settledPayments = (this.order.payments || []).filter(p => p.state === 'Settled');
        if (this.settledPayments.length) {
            this.selectedPayment = this.settledPayments[0];
        }
    }
    handleZeroQuantity(line) {
        if (line?.quantity === 0) {
            line.cancel = false;
            line.refund = false;
        }
    }
    isRefunding() {
        const result = Object.values(this.lineQuantities).reduce((isRefunding, line) => isRefunding || (0 < line.quantity && line.refund), false);
        return result;
    }
    isCancelling() {
        const result = Object.values(this.lineQuantities).reduce((isCancelling, line) => isCancelling || (0 < line.quantity && line.cancel), false);
        return result;
    }
    canSubmit() {
        if (this.isRefunding()) {
            return !!(this.selectedPayment &&
                this.reason &&
                0 < this.refundTotal &&
                this.refundTotal <= this.settledPaymentsTotal);
        }
        else if (this.isCancelling()) {
            return !!this.reason;
        }
        return false;
    }
    select() {
        const payment = this.selectedPayment;
        if (payment) {
            const refundLines = this.getOrderLineInput(line => line.refund);
            const cancelLines = this.getOrderLineInput(line => line.cancel);
            this.resolveWith({
                refund: {
                    lines: refundLines,
                    reason: this.reason,
                    shipping: this.refundShipping ? this.order.shippingWithTax : 0,
                    adjustment: this.adjustment,
                    paymentId: payment.id,
                },
                cancel: {
                    lines: cancelLines,
                    orderId: this.order.id,
                    reason: this.reason,
                    cancelShipping: this.refundShipping,
                },
            });
        }
    }
    cancel() {
        this.resolveWith();
    }
    getOrderLineInput(filterFn) {
        return Object.entries(this.lineQuantities)
            .filter(([orderLineId, line]) => 0 < line.quantity && filterFn(line))
            .map(([orderLineId, line]) => ({
            orderLineId,
            quantity: line.quantity,
        }));
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: RefundOrderDialogComponent, deps: [{ token: i1.I18nService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.2", type: RefundOrderDialogComponent, selector: "vdr-refund-order-dialog", ngImport: i0, template: "<ng-template vdrDialogTitle>{{ 'order.refund-and-cancel-order' | translate }}</ng-template>\n\n<div class=\"refund-wrapper\">\n    <div class=\"order-table\">\n        <table class=\"table\">\n            <thead>\n                <tr>\n                    <th></th>\n                    <th>{{ 'order.product-name' | translate }}</th>\n                    <th>{{ 'order.product-sku' | translate }}</th>\n                    <th>{{ 'order.quantity' | translate }}</th>\n                    <th>{{ 'order.unit-price' | translate }}</th>\n                    <th>{{ 'order.prorated-unit-price' | translate }}</th>\n                    <th>{{ 'order.quantity' | translate }}</th>\n                    <th>{{ 'order.refund' | translate }}</th>\n                    <th>{{ 'order.cancel' | translate }}</th>\n                </tr>\n            </thead>\n            <tr *ngFor=\"let line of order.lines\" class=\"order-line\">\n                <td class=\"align-middle thumb\">\n                    <img [src]=\"line.featuredAsset | assetPreview: 'tiny'\" />\n                </td>\n                <td class=\"align-middle name\">{{ line.productVariant.name }}</td>\n                <td class=\"align-middle sku\">{{ line.productVariant.sku }}</td>\n                <td class=\"align-middle quantity\">\n                    {{ line.quantity }}\n                    <vdr-line-refunds [line]=\"line\" [payments]=\"order.payments\"></vdr-line-refunds>\n                </td>\n                <td class=\"align-middle quantity\">\n                    {{ line.unitPriceWithTax | localeCurrency: order.currencyCode }}\n                </td>\n                <td class=\"align-middle quantity\">\n                    <div class=\"prorated-wrapper\">\n                        {{ line.proratedUnitPriceWithTax | localeCurrency: order.currencyCode }}\n                        <ng-container *ngIf=\"line.discounts as discounts\">\n                            <vdr-dropdown *ngIf=\"discounts.length\">\n                                <div class=\"promotions-label\" vdrDropdownTrigger>\n                                    <button class=\"icon-button\"><clr-icon shape=\"info\"></clr-icon></button>\n                                </div>\n                                <vdr-dropdown-menu>\n                                    <div class=\"line-promotion\" *ngFor=\"let discount of discounts\">\n                                        {{ discount.description }}\n                                        <div class=\"promotion-amount\">\n                                            {{\n                                                discount.amount / 100 / line.quantity\n                                                    | number: '1.0-2'\n                                                    | currency: order.currencyCode\n                                            }}\n                                        </div>\n                                    </div>\n                                </vdr-dropdown-menu>\n                            </vdr-dropdown>\n                        </ng-container>\n                    </div>\n                </td>\n                <td class=\"align-middle quantity-col\">\n                    <input\n                        *ngIf=\"lineCanBeRefundedOrCancelled(line)\"\n                        [(ngModel)]=\"lineQuantities[line.id].quantity\"\n                        type=\"number\"\n                        [max]=\"line.quantity\"\n                        min=\"0\"\n                        (input)=\"handleZeroQuantity(lineQuantities[line.id])\"\n                    />\n                </td>\n                <td class=\"align-middle\">\n                    <div class=\"cancel-checkbox-wrapper\">\n                        <input\n                            type=\"checkbox\"\n                            *ngIf=\"lineCanBeRefundedOrCancelled(line)\"\n                            clrCheckbox\n                            [disabled]=\"0 === lineQuantities[line.id].quantity\"\n                            [(ngModel)]=\"lineQuantities[line.id].refund\"\n                        />\n                    </div>\n                </td>\n                <td class=\"align-middle\">\n                    <div class=\"cancel-checkbox-wrapper\">\n                        <input\n                            type=\"checkbox\"\n                            *ngIf=\"lineCanBeRefundedOrCancelled(line)\"\n                            clrCheckbox\n                            [disabled]=\"0 === lineQuantities[line.id].quantity\"\n                            [(ngModel)]=\"lineQuantities[line.id].cancel\"\n                        />\n                    </div>\n                </td>\n            </tr>\n        </table>\n    </div>\n    <div class=\"refund-details mt-4\" [class.faded]=\"!isRefunding() && !isCancelling()\">\n        <div>\n            <label class=\"clr-control-label\">{{ 'order.refund-cancellation-reason' | translate }}</label>\n            <ng-select\n                [disabled]=\"!isRefunding() && !isCancelling()\"\n                [items]=\"reasons\"\n                bindLabel=\"name\"\n                autofocus\n                [placeholder]=\"'order.refund-cancellation-reason-required' | translate\"\n                bindValue=\"id\"\n                [addTag]=\"true\"\n                [(ngModel)]=\"reason\"\n            ></ng-select>\n        </div>\n\n        <div>\n            <clr-select-container>\n                <label>{{ 'order.payment-to-refund' | translate }}</label>\n                <select clrSelect name=\"options\" [(ngModel)]=\"selectedPayment\" [disabled]=\"!isRefunding()\">\n                    <option\n                        *ngFor=\"let payment of settledPayments\"\n                        [ngValue]=\"payment\"\n                        [disabled]=\"payment.state !== 'Settled'\"\n                    >\n                        #{{ payment.id }} {{ payment.method }}:\n                        {{ payment.amount | localeCurrency: order.currencyCode }}\n                    </option>\n                </select>\n            </clr-select-container>\n\n            <clr-checkbox-wrapper>\n                <input type=\"checkbox\" clrCheckbox [(ngModel)]=\"refundShipping\" [disabled]=\"!isRefunding()\" />\n                <label>\n                    {{ 'order.refund-shipping' | translate }} ({{\n                        order.shippingWithTax | localeCurrency: order.currencyCode\n                    }})\n                </label>\n            </clr-checkbox-wrapper>\n            <clr-input-container>\n                <label>{{ 'order.refund-adjustment' | translate }}</label>\n                <vdr-currency-input\n                    clrInput\n                    [disabled]=\"!isRefunding()\"\n                    [currencyCode]=\"order.currencyCode\"\n                    [(ngModel)]=\"adjustment\"\n                ></vdr-currency-input>\n            </clr-input-container>\n            <div class=\"totals\" [class.disabled]=\"!isRefunding()\">\n                <div class=\"order-total\">\n                    {{ 'order.payment-amount' | translate }}:\n                    {{ selectedPayment.amount | localeCurrency: order.currencyCode }}\n                </div>\n                <div class=\"refund-total\">\n                    {{ 'order.refund-total' | translate }}:\n                    {{ refundTotal | localeCurrency: order.currencyCode }}\n                </div>\n                <div class=\"refund-total-error\" *ngIf=\"refundTotal < 0 || settledPaymentsTotal < refundTotal\">\n                    {{\n                        'order.refund-total-error'\n                            | translate\n                                : {\n                                      min: 0 | currency: order.currencyCode,\n                                      max: settledPaymentsTotal | localeCurrency: order.currencyCode\n                                  }\n                    }}\n                </div>\n                <div class=\"refund-total-warning\" *ngIf=\"selectedPayment.amount < refundTotal\">\n                    {{ 'order.refund-total-warning' | translate }}\n                </div>\n            </div>\n        </div>\n    </div>\n</div>\n\n<ng-template vdrDialogButtons>\n    <button type=\"button\" class=\"btn\" (click)=\"cancel()\">{{ 'common.cancel' | translate }}</button>\n    <button type=\"submit\" (click)=\"select()\" [disabled]=\"!canSubmit()\" class=\"btn btn-primary\">\n        <ng-container *ngIf=\"isRefunding(); else cancelling\">\n            {{\n                'order.refund-with-amount'\n                    | translate: { amount: refundTotal | localeCurrency: order.currencyCode }\n            }}\n        </ng-container>\n        <ng-template #cancelling>\n            {{ 'order.cancel-selected-items' | translate }}\n        </ng-template>\n    </button>\n</ng-template>\n", styles: [":host{height:100%;display:flex;min-height:64vh}.refund-wrapper{flex:1;flex-direction:column}.refund-wrapper .order-table{flex:1;overflow-y:auto}.refund-wrapper .order-table table{margin-top:0}.refund-wrapper tr.ignore{color:var(--color-grey-300)}.quantity-col{background-color:var(--color-warning-100)}.cancel-checkbox-wrapper{display:flex;align-items:center;justify-content:center}clr-checkbox-wrapper{margin-top:12px;margin-bottom:12px;display:block}.refund-details{display:flex;justify-content:space-between}.refund-details.faded{opacity:.5}.totals{margin-top:48px}.totals .refund-total{font-size:18px}.totals .refund-total-error{color:var(--color-error-500)}.totals .refund-total-warning{color:var(--color-warning-600);max-width:250px}.totals.disabled{color:var(--color-grey-300)}.prorated-wrapper{display:flex;justify-content:center}.line-promotion{display:flex;justify-content:space-between;font-size:12px;padding:3px 6px}.line-promotion .promotion-amount{margin-inline-start:12px}\n"], dependencies: [{ kind: "directive", type: i2.ClrIconCustomTag, selector: "clr-icon" }, { kind: "directive", type: i2.ClrLabel, selector: "label", inputs: ["for"] }, { kind: "directive", type: i2.ClrCheckbox, selector: "[clrCheckbox],[clrToggle]" }, { kind: "component", type: i2.ClrCheckboxWrapper, selector: "clr-checkbox-wrapper,clr-toggle-wrapper" }, { kind: "directive", type: i2.ClrInput, selector: "[clrInput]" }, { kind: "component", type: i2.ClrInputContainer, selector: "clr-input-container" }, { kind: "directive", type: i2.ClrSelect, selector: "[clrSelect]" }, { kind: "component", type: i2.ClrSelectContainer, selector: "clr-select-container" }, { kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i4.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i4.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i4.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: i4.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { kind: "directive", type: i4.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i4.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.MinValidator, selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]", inputs: ["min"] }, { kind: "directive", type: i4.MaxValidator, selector: "input[type=number][max][formControlName],input[type=number][max][formControl],input[type=number][max][ngModel]", inputs: ["max"] }, { kind: "directive", type: i4.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: i5.NgSelectComponent, selector: "ng-select", inputs: ["bindLabel", "bindValue", "markFirst", "placeholder", "notFoundText", "typeToSearchText", "addTagText", "loadingText", "clearAllText", "appearance", "dropdownPosition", "appendTo", "loading", "closeOnSelect", "hideSelected", "selectOnTab", "openOnEnter", "maxSelectedItems", "groupBy", "groupValue", "bufferAmount", "virtualScroll", "selectableGroup", "selectableGroupAsModel", "searchFn", "trackByFn", "clearOnBackspace", "labelForId", "inputAttrs", "tabIndex", "readonly", "searchWhileComposing", "minTermLength", "editableSearchTerm", "keyDownFn", "typeahead", "multiple", "addTag", "searchable", "clearable", "isOpen", "items", "compareWith", "clearSearchOnAdd", "deselectOnClick"], outputs: ["blur", "focus", "change", "open", "close", "search", "clear", "add", "remove", "scroll", "scrollToEnd"] }, { kind: "component", type: i1.CurrencyInputComponent, selector: "vdr-currency-input", inputs: ["disabled", "readonly", "value", "currencyCode"], outputs: ["valueChange"] }, { kind: "directive", type: i1.FormFieldControlDirective, selector: "input, textarea, select" }, { kind: "directive", type: i1.DialogButtonsDirective, selector: "[vdrDialogButtons]" }, { kind: "directive", type: i1.DialogTitleDirective, selector: "[vdrDialogTitle]" }, { kind: "component", type: i1.DropdownComponent, selector: "vdr-dropdown", inputs: ["manualToggle"] }, { kind: "component", type: i1.DropdownMenuComponent, selector: "vdr-dropdown-menu", inputs: ["vdrPosition", "customClasses"] }, { kind: "directive", type: i1.DropdownTriggerDirective, selector: "[vdrDropdownTrigger]" }, { kind: "component", type: i6.LineRefundsComponent, selector: "vdr-line-refunds", inputs: ["line", "payments"] }, { kind: "pipe", type: i3.DecimalPipe, name: "number" }, { kind: "pipe", type: i3.CurrencyPipe, name: "currency" }, { kind: "pipe", type: i7.TranslatePipe, name: "translate" }, { kind: "pipe", type: i1.AssetPreviewPipe, name: "assetPreview" }, { kind: "pipe", type: i1.LocaleCurrencyPipe, name: "localeCurrency" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: RefundOrderDialogComponent, decorators: [{
            type: Component,
            args: [{ selector: 'vdr-refund-order-dialog', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-template vdrDialogTitle>{{ 'order.refund-and-cancel-order' | translate }}</ng-template>\n\n<div class=\"refund-wrapper\">\n    <div class=\"order-table\">\n        <table class=\"table\">\n            <thead>\n                <tr>\n                    <th></th>\n                    <th>{{ 'order.product-name' | translate }}</th>\n                    <th>{{ 'order.product-sku' | translate }}</th>\n                    <th>{{ 'order.quantity' | translate }}</th>\n                    <th>{{ 'order.unit-price' | translate }}</th>\n                    <th>{{ 'order.prorated-unit-price' | translate }}</th>\n                    <th>{{ 'order.quantity' | translate }}</th>\n                    <th>{{ 'order.refund' | translate }}</th>\n                    <th>{{ 'order.cancel' | translate }}</th>\n                </tr>\n            </thead>\n            <tr *ngFor=\"let line of order.lines\" class=\"order-line\">\n                <td class=\"align-middle thumb\">\n                    <img [src]=\"line.featuredAsset | assetPreview: 'tiny'\" />\n                </td>\n                <td class=\"align-middle name\">{{ line.productVariant.name }}</td>\n                <td class=\"align-middle sku\">{{ line.productVariant.sku }}</td>\n                <td class=\"align-middle quantity\">\n                    {{ line.quantity }}\n                    <vdr-line-refunds [line]=\"line\" [payments]=\"order.payments\"></vdr-line-refunds>\n                </td>\n                <td class=\"align-middle quantity\">\n                    {{ line.unitPriceWithTax | localeCurrency: order.currencyCode }}\n                </td>\n                <td class=\"align-middle quantity\">\n                    <div class=\"prorated-wrapper\">\n                        {{ line.proratedUnitPriceWithTax | localeCurrency: order.currencyCode }}\n                        <ng-container *ngIf=\"line.discounts as discounts\">\n                            <vdr-dropdown *ngIf=\"discounts.length\">\n                                <div class=\"promotions-label\" vdrDropdownTrigger>\n                                    <button class=\"icon-button\"><clr-icon shape=\"info\"></clr-icon></button>\n                                </div>\n                                <vdr-dropdown-menu>\n                                    <div class=\"line-promotion\" *ngFor=\"let discount of discounts\">\n                                        {{ discount.description }}\n                                        <div class=\"promotion-amount\">\n                                            {{\n                                                discount.amount / 100 / line.quantity\n                                                    | number: '1.0-2'\n                                                    | currency: order.currencyCode\n                                            }}\n                                        </div>\n                                    </div>\n                                </vdr-dropdown-menu>\n                            </vdr-dropdown>\n                        </ng-container>\n                    </div>\n                </td>\n                <td class=\"align-middle quantity-col\">\n                    <input\n                        *ngIf=\"lineCanBeRefundedOrCancelled(line)\"\n                        [(ngModel)]=\"lineQuantities[line.id].quantity\"\n                        type=\"number\"\n                        [max]=\"line.quantity\"\n                        min=\"0\"\n                        (input)=\"handleZeroQuantity(lineQuantities[line.id])\"\n                    />\n                </td>\n                <td class=\"align-middle\">\n                    <div class=\"cancel-checkbox-wrapper\">\n                        <input\n                            type=\"checkbox\"\n                            *ngIf=\"lineCanBeRefundedOrCancelled(line)\"\n                            clrCheckbox\n                            [disabled]=\"0 === lineQuantities[line.id].quantity\"\n                            [(ngModel)]=\"lineQuantities[line.id].refund\"\n                        />\n                    </div>\n                </td>\n                <td class=\"align-middle\">\n                    <div class=\"cancel-checkbox-wrapper\">\n                        <input\n                            type=\"checkbox\"\n                            *ngIf=\"lineCanBeRefundedOrCancelled(line)\"\n                            clrCheckbox\n                            [disabled]=\"0 === lineQuantities[line.id].quantity\"\n                            [(ngModel)]=\"lineQuantities[line.id].cancel\"\n                        />\n                    </div>\n                </td>\n            </tr>\n        </table>\n    </div>\n    <div class=\"refund-details mt-4\" [class.faded]=\"!isRefunding() && !isCancelling()\">\n        <div>\n            <label class=\"clr-control-label\">{{ 'order.refund-cancellation-reason' | translate }}</label>\n            <ng-select\n                [disabled]=\"!isRefunding() && !isCancelling()\"\n                [items]=\"reasons\"\n                bindLabel=\"name\"\n                autofocus\n                [placeholder]=\"'order.refund-cancellation-reason-required' | translate\"\n                bindValue=\"id\"\n                [addTag]=\"true\"\n                [(ngModel)]=\"reason\"\n            ></ng-select>\n        </div>\n\n        <div>\n            <clr-select-container>\n                <label>{{ 'order.payment-to-refund' | translate }}</label>\n                <select clrSelect name=\"options\" [(ngModel)]=\"selectedPayment\" [disabled]=\"!isRefunding()\">\n                    <option\n                        *ngFor=\"let payment of settledPayments\"\n                        [ngValue]=\"payment\"\n                        [disabled]=\"payment.state !== 'Settled'\"\n                    >\n                        #{{ payment.id }} {{ payment.method }}:\n                        {{ payment.amount | localeCurrency: order.currencyCode }}\n                    </option>\n                </select>\n            </clr-select-container>\n\n            <clr-checkbox-wrapper>\n                <input type=\"checkbox\" clrCheckbox [(ngModel)]=\"refundShipping\" [disabled]=\"!isRefunding()\" />\n                <label>\n                    {{ 'order.refund-shipping' | translate }} ({{\n                        order.shippingWithTax | localeCurrency: order.currencyCode\n                    }})\n                </label>\n            </clr-checkbox-wrapper>\n            <clr-input-container>\n                <label>{{ 'order.refund-adjustment' | translate }}</label>\n                <vdr-currency-input\n                    clrInput\n                    [disabled]=\"!isRefunding()\"\n                    [currencyCode]=\"order.currencyCode\"\n                    [(ngModel)]=\"adjustment\"\n                ></vdr-currency-input>\n            </clr-input-container>\n            <div class=\"totals\" [class.disabled]=\"!isRefunding()\">\n                <div class=\"order-total\">\n                    {{ 'order.payment-amount' | translate }}:\n                    {{ selectedPayment.amount | localeCurrency: order.currencyCode }}\n                </div>\n                <div class=\"refund-total\">\n                    {{ 'order.refund-total' | translate }}:\n                    {{ refundTotal | localeCurrency: order.currencyCode }}\n                </div>\n                <div class=\"refund-total-error\" *ngIf=\"refundTotal < 0 || settledPaymentsTotal < refundTotal\">\n                    {{\n                        'order.refund-total-error'\n                            | translate\n                                : {\n                                      min: 0 | currency: order.currencyCode,\n                                      max: settledPaymentsTotal | localeCurrency: order.currencyCode\n                                  }\n                    }}\n                </div>\n                <div class=\"refund-total-warning\" *ngIf=\"selectedPayment.amount < refundTotal\">\n                    {{ 'order.refund-total-warning' | translate }}\n                </div>\n            </div>\n        </div>\n    </div>\n</div>\n\n<ng-template vdrDialogButtons>\n    <button type=\"button\" class=\"btn\" (click)=\"cancel()\">{{ 'common.cancel' | translate }}</button>\n    <button type=\"submit\" (click)=\"select()\" [disabled]=\"!canSubmit()\" class=\"btn btn-primary\">\n        <ng-container *ngIf=\"isRefunding(); else cancelling\">\n            {{\n                'order.refund-with-amount'\n                    | translate: { amount: refundTotal | localeCurrency: order.currencyCode }\n            }}\n        </ng-container>\n        <ng-template #cancelling>\n            {{ 'order.cancel-selected-items' | translate }}\n        </ng-template>\n    </button>\n</ng-template>\n", styles: [":host{height:100%;display:flex;min-height:64vh}.refund-wrapper{flex:1;flex-direction:column}.refund-wrapper .order-table{flex:1;overflow-y:auto}.refund-wrapper .order-table table{margin-top:0}.refund-wrapper tr.ignore{color:var(--color-grey-300)}.quantity-col{background-color:var(--color-warning-100)}.cancel-checkbox-wrapper{display:flex;align-items:center;justify-content:center}clr-checkbox-wrapper{margin-top:12px;margin-bottom:12px;display:block}.refund-details{display:flex;justify-content:space-between}.refund-details.faded{opacity:.5}.totals{margin-top:48px}.totals .refund-total{font-size:18px}.totals .refund-total-error{color:var(--color-error-500)}.totals .refund-total-warning{color:var(--color-warning-600);max-width:250px}.totals.disabled{color:var(--color-grey-300)}.prorated-wrapper{display:flex;justify-content:center}.line-promotion{display:flex;justify-content:space-between;font-size:12px;padding:3px 6px}.line-promotion .promotion-amount{margin-inline-start:12px}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.I18nService }]; } });
//# sourceMappingURL=data:application/json;base64, 