'use strict';

var index = require('./index-p7cvUYAE.js');
var payoutsListParamsState = require('./payouts-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');
var utils = require('./utils-CYONRFR6.js');
require('./config-state-BIgGhhe9.js');
var Plaid = require('./Plaid-CPESyiiV.js');
require('./Pagination-Dediz133.js');
require('./Business-oBifyXkW.js');
require('./index-W-zoNiyM.js');
require('./dinero-BwNN_k7x.js');

const JustifiPayoutsListFilters = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.setParamsOnChange = (name, value) => {
            payoutsListParamsState.filterParams[name] = value;
        };
        this.handleDateInput = (name, value) => {
            const utcDate = utils.convertToUTC(value, { setEndOfDay: true });
            this.setParamsOnChange(name, utcDate);
        };
    }
    componentWillLoad() {
        const propsToSet = {
            status: this.status,
            created_after: this.createdAfter,
            created_before: this.createdBefore
        };
        Object.entries(propsToSet).forEach(([key, value]) => {
            if (value) {
                payoutsListParamsState.propsParams[key] = value;
            }
        });
    }
    get statusOptions() {
        return [
            { label: 'All', value: '' },
            { label: Plaid.PayoutStatusesSafeNames.paid, value: 'paid' },
            { label: Plaid.PayoutStatusesSafeNames.failed, value: 'failed' },
            { label: Plaid.PayoutStatusesSafeNames.forwarded, value: 'forwarded' },
            { label: Plaid.PayoutStatusesSafeNames.scheduled, value: 'scheduled' },
            { label: Plaid.PayoutStatusesSafeNames.in_transit, value: 'in_transit' },
            { label: Plaid.PayoutStatusesSafeNames.canceled, value: 'canceled' }
        ];
    }
    render() {
        const filterMenuParams = Object.assign({}, payoutsListParamsState.filterParams);
        return (index.h(styledHost.StyledHost, { key: '4047a84518ef07a3e9d22f3d6866452dcdd7bab3' }, index.h("table-filters-menu", { key: 'a1db3d5c8c0bdc44ea7d9dc35f0c460b4b5930ab', params: filterMenuParams, clearParams: payoutsListParamsState.clearParams, part: parts.filterMenu }, index.h("div", { key: '0d8e8244eb9516a97914942e1e0836dd8ab53639', class: "grid-cols-2 gap-3 p-1" }, index.h("div", { key: '47021850703e8ab104b287b4efa93693272c435b', class: "p-2" }, index.h("form-control-select", { key: 'f0312f36bc05c4fa6d4e7841624f8d977cdec6c1', name: "status", label: "Status", options: this.statusOptions, inputHandler: this.setParamsOnChange, defaultValue: this.status || payoutsListParamsState.filterParams.status || '', disabled: !!this.status, part: parts.filterParam })), index.h("div", { key: '211ac119c8172aa4e626b7344b25a1df26019aa8', class: "p-2" }, index.h("form-control-date", { key: '168757bdc92bf54e076d4d5aff63f8a04de65464', name: "created_after", label: "Created After", inputHandler: this.handleDateInput, defaultValue: utils.convertToLocal(this.createdAfter, { showInputDate: true }) ||
                utils.convertToLocal(payoutsListParamsState.filterParams.created_after, { showInputDate: true }), disabled: !!this.createdAfter, part: parts.filterParam })), index.h("div", { key: '43aa8054ba063b70eadfff7240908329f47d1c02', class: "p-2" }, index.h("form-control-date", { key: '16a86a41c301dd32a6d46067c32d1316c80ceb5d', name: "created_before", label: "Created Before", inputHandler: this.handleDateInput, defaultValue: utils.convertToLocal(this.createdBefore, { showInputDate: true }) ||
                utils.convertToLocal(payoutsListParamsState.filterParams.created_before, { showInputDate: true }), disabled: !!this.createdBefore, part: parts.filterParam }))))));
    }
};

exports.justifi_payouts_list_filters = JustifiPayoutsListFilters;
