import { _ as y } from "./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";
import "./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";
import { B as v } from "./BasicForm-dL_oCSPM.js";
import { u as P } from "./useForm-CKmgcynv.js";
import { u as A } from "./useTags-C1thGhjF.js";
import { d as S, V, r as j, c as I, o as O, l as a, w as G, j as $, cZ as z, ac as D, gS as E, __tla as __tla_0 } from "./index-9PRMimni.js";
import { c as L, __tla as __tla_1 } from "./index.vue_vue_type_style_index_0_scoped_b974e5ec_lang-_0QwzFKM.js";
import { u as N } from "./useModal-CO65vga3.js";
import { h as r } from "./has-CjqcrIOV.js";
let Y;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })()
]).then(async ()=>{
    Y = S({
        __name: "index",
        props: {
            closeTabBack: {
                type: Boolean,
                default: !1
            },
            subModuleCode: {
                type: Boolean,
                default: !0
            }
        },
        emits: [
            "success"
        ],
        setup (c, { expose: l, emit: i }) {
            const n = c, { t: s } = V(), u = i, m = z(), { approvalSchemas: d } = L(), f = j(), { closeCurrent: p } = A();
            function h() {
                try {
                    p();
                } catch (o) {
                    console.warn("Error closing tab:", o);
                }
            }
            const [b, { validate: g, getFieldsValue: M, setFieldsValue: _, setProps: x }] = P({
                gridProps: {
                    cols: 1
                },
                layout: "horizontal",
                showActionButtonGroup: !1,
                schemas: d,
                labelWidth: "100"
            }), [B, { openModal: k, closeModal: F, setProps: R, setSubLoading: t }] = N({
                title: s("common.optionsReturnText"),
                subBtuText: s("common.okText"),
                cancelText: s("common.cancelText"),
                width: 650
            });
            async function T(o) {
                const e = [];
                if (r(o, "busId") || e.push("busId"), r(o, "moduleCode") || e.push("moduleCode"), !r(o, "subModuleCode") && n.subModuleCode && e.push("subModuleCode"), e.length > 0) {
                    m.error(s("common.missingFields") + `: ${e.join(", ")}`);
                    return;
                }
                k(), D(()=>{
                    _(o);
                });
            }
            async function C() {
                try {
                    const o = await g(), e = M();
                    if (!o) {
                        t(!1);
                        return;
                    }
                    if (await E(e), t(!1), u("success"), F(), n.closeTabBack) return;
                    h();
                } catch  {
                    t(!1);
                }
            }
            return l({
                showModal: T,
                setModalProps: R,
                setFormProps: x
            }), (o, e)=>{
                const w = y;
                return O(), I(w, {
                    ref: "modalRef",
                    onRegister: a(B),
                    class: "basicModal basicFormModal",
                    onOnOk: C
                }, {
                    default: G(()=>[
                            $(a(v), {
                                ref_key: "contentFromRef",
                                ref: f,
                                onRegister: a(b)
                            }, null, 8, [
                                "onRegister"
                            ])
                        ]),
                    _: 1
                }, 8, [
                    "onRegister"
                ]);
            };
        }
    });
});
export { Y as _, __tla };
