import { _ as J } 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 N } from "./BasicForm-dL_oCSPM.js";
import { m as T } from "./vesselEquipmentDetails-CJeqdW1Z.js";
import { c as V, __tla as __tla_0 } from "./schemas-Dz7LnyWK.js";
import { u as q } from "./account-C850CBTF.js";
import { d as E, V as O, r as $, h as z, o as G, j as n, w as c, l as m, aH as H, B as I, p as L, A as Z, cZ as K, __tla as __tla_1 } from "./index-9PRMimni.js";
import { u as Q } from "./useModal-CO65vga3.js";
import { u as U } from "./useForm-CKmgcynv.js";
let ne;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })()
]).then(async ()=>{
    ne = E({
        __name: "AddAttachmentModal",
        props: {
            selectedJobPlanParams: {}
        },
        emits: [
            "success"
        ],
        setup (h, { expose: g, emit: R }) {
            const b = h, F = R, { t: l } = O(), v = K(), a = $(), { attachmentFormSchemas: w } = V(), [x, { openModal: B, closeModal: M, setSubLoading: r, setProps: P }] = Q({
                title: "",
                width: 800
            }), [y, { submit: A, validate: i }] = U({
                gridProps: {
                    cols: 1
                },
                layout: "horizontal",
                labelPlacement: "left",
                schemas: w,
                showActionButtonGroup: !1
            });
            async function S(e) {
                P({
                    title: e
                }), B();
            }
            async function k() {
                const e = await A();
                if (!e) {
                    r(!1);
                    return;
                }
                try {
                    await T({
                        ...e,
                        attachmentName: m(a)?.originalFileName,
                        ...b.selectedJobPlanParams || {}
                    }), v.success(l("common.optionsAddSuccessText")), M(), r(!1), F("success");
                } catch  {
                    r(!1);
                }
            }
            async function C(e, o, t) {
                const s = new FormData;
                s.append("file", e.file?.file);
                try {
                    a.value = await q(s), o[t] = a.value?.name, i([
                        t
                    ]), e.onFinish();
                } catch  {
                    e.onError(), u(o, t);
                }
            }
            function u(e, o) {
                a.value = {}, e[o] = "", i([
                    o
                ]);
            }
            return g({
                handleOpenModal: S
            }), (e, o)=>{
                const t = I, s = H, p = N, D = J;
                return G(), z("template", null, [
                    n(D, {
                        ref: "modalRef",
                        onRegister: m(x),
                        onOnOk: k
                    }, {
                        default: c(()=>[
                                n(p, {
                                    ref: "formRef",
                                    onRegister: m(y)
                                }, {
                                    fileCode: c(({ model: f, field: d })=>[
                                            n(s, {
                                                max: 1,
                                                "custom-request": (_)=>C(_, f, d),
                                                onRemove: (_)=>u(f, d)
                                            }, {
                                                default: c(()=>[
                                                        n(t, null, {
                                                            default: c(()=>[
                                                                    L(Z(m(l)("common.uploadText")), 1)
                                                                ]),
                                                            _: 1
                                                        })
                                                    ]),
                                                _: 2
                                            }, 1032, [
                                                "custom-request",
                                                "onRemove"
                                            ])
                                        ]),
                                    _: 1
                                }, 8, [
                                    "onRegister"
                                ])
                            ]),
                        _: 1
                    }, 8, [
                        "onRegister"
                    ])
                ]);
            };
        }
    });
});
export { ne as _, __tla };
