/**  
 * @since Last modified: 2024-09-10 11:20:41
 * @see {@link https://codepen.io/axui/pen/yLwbrvm|demo @ codepen}
 * @example
 * ax.Dropdown('#id');
 */
import getEl from '../utils/getEl';
import extend from '../utils/extend';
import isEmpty from '../utils/isEmpty';
import instance from '../utils/instance';
import preventDft from '../utils/preventDft';
import { T_el, T_fn, T_fn_obj, T_obj, T_required, T_sel } from '../../../types/ax';
import contains from '../utils/contains';
import getEls from '../utils/getEls';
import getContent from '../utils/getContent';
import getDataType from '../utils/getDataType';
import Position from './Position';
import createFooter from '../utils/createFooter';
import renderTpl from '../utils/renderTpl';
import tplToEl from '../utils/tplToEl';
import isMobi from '../utils/isMobi';
import style from '../utils/style';
import easeHeight from '../utils/easeHeight';
import PubBase from './PubBase';
import pipe from '../utils/pipe';
import PubListen from './PubListen';
import PubUpdate from './PubUpdate';
import PubCommon from './PubCommon';
import Hover from './Hover';
import createTools from '../utils/createTools';
import ax from '../ax';
import classes from '../utils/classes';
import deepClone from '../utils/deepClone';
import validTools from '../utils/validTools';
import formTools from '../utils/formTools';
import { T_popup } from '../../../types/popup';
import elState from '../utils/elState';
import { T_footer, T_btn_ft } from '../../../types/utils';
import delay from '../utils/delay';
import setContent from '../utils/setContent';
import optDropdown from '../options/optDropdown';
import prefix from '../global/prefix';
import alias from '../global/alias';
import { T_dropdown } from '../../../types/dropdown';
import Popup from './Popup';
import isNull from '../utils/isNull';
import bulletinTools from '../utils/bulletinTools';
import config from '../global/config';
class Dropdown extends Popup {
    options: any;
    constructor(elem: T_sel, options: T_popup = {}, initial: boolean = config.initial) {
        options?.tools === true ? options.tools = { enable: true, placement: 'outside' } : !options?.tools ? (options as T_obj).tools = { enable: false, placement: 'outside' } : null;
       /*  let footChildren = [
            {
                name: 'close'
            },
            {
                name: 'cancel',
                event: 'prevent',
            }, {
                name: 'confirm',
                event: 'prevent',
            },
        ];
        if (options?.footer === true) {
            options.footer = { enable: true, children: footChildren }
        } else if (options?.footer === false) {
            (options as T_obj).footer = { enable: false }
        } else if (isNull(options?.footer)) {
            (options as T_obj).footer = { children: footChildren };
        } */
        isNull(options.size) ? (options as T_obj).size = 'md' : null;
        isNull(options?.placement) ? (options as T_obj).placement = 'bottom-start' : null;
        isNull(options?.trigger) ? (options as T_obj).trigger = 'click' : null;
        isNull(options?.in) ? (options as T_obj).in = 'slideDown' : null;
        isNull(options?.out) ? (options as T_obj).out = 'slideUp' : null;
        super(elem, options, initial);
        this.on('init', () => {
            this.mainEl.classList.add(`${prefix}dropdown`);
            this.initList();
        });
        this.on('show', () => {
            this.checkTargetChecked();
        });
    }
}
export default Dropdown;
