'use strict';

var index = require('./index-p7cvUYAE.js');
var lodash = require('./lodash-C4mGy21w.js');
var terminalOrdersListParamsState = require('./terminal-orders-list-params-state-vGJZ6Oe2.js');
var parts = require('./parts-BXshb_S-.js');
var styledHost = require('./styled-host-Ch0-dxF-.js');
require('./event-types-YOY5TKUN.js');
require('./config-state-BIgGhhe9.js');
var utils = require('./utils-CYONRFR6.js');
var Plaid = require('./Plaid-CPESyiiV.js');
require('./Pagination-Dediz133.js');
require('./Business-oBifyXkW.js');
require('./_commonjsHelpers-BJu3ubxk.js');
require('./index-W-zoNiyM.js');
require('./dinero-BwNN_k7x.js');

const JustifiTerminalOrdersListFilters = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.setParamsOnChange = (name, value) => {
            terminalOrdersListParamsState.filterParams[name] = value;
        };
        this.handleDateInput = (name, value) => {
            const utcDate = utils.convertToUTC(value, { setExactTime: true });
            this.setParamsOnChange(name, utcDate);
        };
    }
    componentWillLoad() {
        this.debouncedSetParamsOnChange = lodash.lodashExports.debounce(this.setParamsOnChange, 300);
        const propsToSet = {
            order_status: this.orderStatus,
            order_type: this.orderType,
            created_after: this.createdAfter,
            created_before: this.createdBefore,
            company_name: this.companyName
        };
        Object.entries(propsToSet).forEach(([key, value]) => {
            if (value) {
                terminalOrdersListParamsState.propsParams[key] = value;
            }
        });
    }
    get terminalOrderStatusOptions() {
        return [
            { label: 'All', value: '' },
            { label: 'Created', value: Plaid.TerminalOrderStatus.created },
            { label: 'Completed', value: Plaid.TerminalOrderStatus.completed },
            { label: 'Submitted', value: Plaid.TerminalOrderStatus.submitted },
            { label: 'In Progress', value: Plaid.TerminalOrderStatus.in_progress },
            { label: 'On Hold', value: Plaid.TerminalOrderStatus.on_hold },
            { label: 'Canceled', value: Plaid.TerminalOrderStatus.canceled }
        ];
    }
    get terminalOrderTypeOptions() {
        return [
            { label: 'All', value: '' },
            { label: 'Boarding Only', value: Plaid.TerminalOrderType.boardingOnly },
            { label: 'Boarding Shipping', value: Plaid.TerminalOrderType.boardingShipping },
        ];
    }
    render() {
        const filterMenuParams = Object.assign({}, terminalOrdersListParamsState.filterParams);
        return (index.h(styledHost.StyledHost, { key: '287baf0a2de1287195105adbebd501d2bccd21d7' }, index.h("table-filters-menu", { key: 'b0112de1075f459780d01528f017780c9ceedb18', params: filterMenuParams, clearParams: terminalOrdersListParamsState.clearParams, part: parts.filterMenu }, index.h("div", { key: 'f9acabaf7d2edbe4eabb81edc92b2378ef563012', class: "grid-cols-2 gap-3 p-1" }, index.h("div", { key: 'e76d3b3771b8084fc5f6bf32fac2c75c3da87abb', class: "p-2" }, index.h("form-control-select", { key: '9c687e7202a310500e85d3cbce29268ac04cdd4a', name: "order_status", label: "Order Status", options: this.terminalOrderStatusOptions, inputHandler: this.setParamsOnChange, defaultValue: this.orderStatus || terminalOrdersListParamsState.filterParams.order_status || '', disabled: !!this.orderStatus, part: parts.filterParam })), index.h("div", { key: '345ebc972663899a456a7a660863cd81a9770a87', class: "p-2" }, index.h("form-control-select", { key: '26879377755e826a1d1f236ab5e54a22415451e8', name: "order_type", label: "Order Type", options: this.terminalOrderTypeOptions, inputHandler: this.setParamsOnChange, defaultValue: this.orderType || terminalOrdersListParamsState.filterParams.order_type || '', disabled: !!this.orderType, part: parts.filterParam })), index.h("div", { key: '2a7df2b8c9a3bfbbd76cca1a732c01521b08dd34', class: "p-2" }, index.h("form-control-date", { key: '3fbceb80eaf7ae48e02221961317d8c77ec2c5a5', name: "created_after", label: "Created After", inputHandler: this.handleDateInput, defaultValue: utils.convertToLocal(this.createdAfter, { showInputDateTime: true }) ||
                utils.convertToLocal(terminalOrdersListParamsState.filterParams.created_after, { showInputDateTime: true }), showTime: true, disabled: !!this.createdAfter, part: parts.filterParam })), index.h("div", { key: '4c3c59ab54215591c5b0eb9a26c45a0265e48d96', class: "p-2" }, index.h("form-control-date", { key: 'aea46abb41595c0cc5d82edd0f1f09425c0a1701', name: "created_before", label: "Created Before", inputHandler: this.handleDateInput, defaultValue: utils.convertToLocal(this.createdBefore, { showInputDateTime: true }) ||
                utils.convertToLocal(terminalOrdersListParamsState.filterParams.created_before, { showInputDateTime: true }), showTime: true, disabled: !!this.createdBefore, part: parts.filterParam })), index.h("div", { key: 'e83af454cde29c12fcd6e2e37093bf70fd03718c', class: "p-2" }, index.h("form-control-text", { key: '3c5fe84b5883b7df6247ed1eba1a15871cb882b5', name: "company_name", label: "Company Name", inputHandler: this.debouncedSetParamsOnChange, defaultValue: this.companyName || terminalOrdersListParamsState.filterParams.company_name, disabled: !!this.companyName, part: parts.filterParam }))))));
    }
};

exports.justifi_terminal_orders_list_filters = JustifiTerminalOrdersListFilters;
