import { r as registerInstance, h } from './index-CV0Pyo1O.js';
import { l as lodashExports } from './lodash-BF_QgjtL.js';
import { f as filterParams, p as propsParams, c as clearParams } from './terminal-orders-list-params-state-CiGfmyWW.js';
import { f as filterMenu, a as filterParam } from './parts-CPKMvyV_.js';
import { S as StyledHost } from './styled-host-D84RBv1W.js';
import './event-types-CZfYo5-1.js';
import './config-state-kKn89dp1.js';
import { c as convertToUTC, a as convertToLocal } from './utils-C25uIOK0.js';
import { T as TerminalOrderStatus, f as TerminalOrderType } from './Plaid-DxSkT8pY.js';
import './Pagination-CLHwhyvu.js';
import './Business-BcNb9bVO.js';
import './_commonjsHelpers-BFTU3MAI.js';
import './index-cDVGjRkU.js';
import './dinero-HXpYMWUU.js';

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

export { JustifiTerminalOrdersListFilters as justifi_terminal_orders_list_filters };
