import { defineComponent, ref, watch, resolveComponent, createElementBlock, openBlock, normalizeClass, unref, createVNode, withCtx } from 'vue';
import '../../../utils/index.mjs';
import { Form } from 'ant-design-vue';
import './components/cron-modal.vue.mjs';
import './config/index.mjs';
import { createNamespace } from '../../../utils/create-namespace.mjs';
import _sfc_main$1 from './components/cron-modal.vue2.mjs';
import { cronExpressionBuilderEmits, cronExpressionBuilderProps } from './config/cron-expression-builder.mjs';

"use strict";
var _sfc_main = /* @__PURE__ */ defineComponent({
  ...{ name: "LlCronExpressionBuilder" },
  __name: "cron-expression-builder",
  props: cronExpressionBuilderProps,
  emits: cronExpressionBuilderEmits,
  setup(__props, { emit: __emit }) {
    const bem = createNamespace("cron-expression-builder");
    const props = __props;
    const emits = __emit;
    const editCronValue = ref(props.value);
    const formItemContext = Form.useInjectFormItemContext();
    const modalRef = ref();
    watch(
      () => props.value,
      (newVal) => {
        if (newVal !== editCronValue.value) {
          editCronValue.value = newVal;
        }
      }
    );
    function showConfigModal() {
      if (props.disabled) return;
      modalRef.value?.openModal();
    }
    function handleSubmit() {
      emits("change", editCronValue.value);
      emits("update:value", editCronValue.value);
      formItemContext.onFieldChange();
    }
    return (_ctx, _cache) => {
      const _component_ll_icon = resolveComponent("ll-icon");
      const _component_a_input = resolveComponent("a-input");
      return openBlock(), createElementBlock(
        "div",
        {
          class: normalizeClass(unref(bem).b())
        },
        [
          createVNode(_component_a_input, {
            value: _ctx.value,
            "onUpdate:value": _cache[0] || (_cache[0] = ($event) => _ctx.value = $event),
            readonly: "",
            placeholder: _ctx.placeholder,
            bordered: _ctx.bordered,
            disabled: _ctx.disabled,
            onClick: showConfigModal
          }, {
            suffix: withCtx(() => [
              createVNode(_component_ll_icon, { "icon-name": "icon-cron" })
            ]),
            _: 1
            /* STABLE */
          }, 8, ["value", "placeholder", "bordered", "disabled"]),
          createVNode(_sfc_main$1, {
            ref_key: "modalRef",
            ref: modalRef,
            value: editCronValue.value,
            "onUpdate:value": _cache[1] || (_cache[1] = ($event) => editCronValue.value = $event),
            "exe-start-time": _ctx.exeStartTime,
            "hide-year": _ctx.hideYear,
            remote: _ctx.remote,
            "hide-second": _ctx.hideSecond,
            onOk: handleSubmit
          }, null, 8, ["value", "exe-start-time", "hide-year", "remote", "hide-second"])
        ],
        2
        /* CLASS */
      );
    };
  }
});

export { _sfc_main as default };
//# sourceMappingURL=cron-expression-builder.vue2.mjs.map
