import { hL as y, dN as m, gY as M, dH as S, il as C, im as k, bD as P, io as T, ip as A, iq as h, dT as D, gD as _, V as $, hc as N, bk as B, r as g, a4 as b, cZ as L, d as O, c as W, o as j, X as H, w as V, i as F, j as G, l as w, __tla as __tla_0 } from "./index-9PRMimni.js";
import { p as E, g as z } from "./helper-ByM4DLer.js";
import { _ as R } from "./list-table.vue-BMAnwqtG.js";
let ue, ie;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    function U(n, e) {
        var o = n.length;
        for(n.sort(e); o--;)n[o] = n[o].value;
        return n;
    }
    function X(n, e) {
        if (n !== e) {
            var o = n !== void 0, a = n === null, c = n === n, t = y(n), r = e !== void 0, l = e === null, s = e === e, i = y(e);
            if (!l && !i && !t && n > e || t && r && s && !l && !i || a && r && s || !o && s || !c) return 1;
            if (!a && !t && !i && n < e || i && o && c && !a && !t || l && o && c || !r && c || !s) return -1;
        }
        return 0;
    }
    function q(n, e, o) {
        for(var a = -1, c = n.criteria, t = e.criteria, r = c.length, l = o.length; ++a < r;){
            var s = X(c[a], t[a]);
            if (s) {
                if (a >= l) return s;
                var i = o[a];
                return s * (i == "desc" ? -1 : 1);
            }
        }
        return n.index - e.index;
    }
    function Y(n, e, o) {
        e.length ? e = m(e, function(t) {
            return M(t) ? function(r) {
                return S(r, t.length === 1 ? t[0] : t);
            } : t;
        }) : e = [
            C
        ];
        var a = -1;
        e = m(e, k(P));
        var c = T(n, function(t, r, l) {
            var s = m(e, function(i) {
                return i(t);
            });
            return {
                criteria: s,
                index: ++a,
                value: t
            };
        });
        return U(c, function(t, r) {
            return q(t, r, o);
        });
    }
    var Z = A(function(n, e) {
        if (n == null) return [];
        var o = e.length;
        return o > 1 && h(n, e[0], e[1]) ? e = [] : o > 2 && h(e[0], e[1], e[2]) && (e = [
            e[0]
        ]), Y(n, D(e), []);
    });
    function J(n, e) {
        const a = _(`${n}-${e}-01`).daysInMonth(), c = [];
        for(let t = 1; t <= a; t++){
            const r = _(`${n}-${e}-${t}`);
            c.push({
                year: r.year(),
                month: e,
                day: r.date(),
                week: r.format("dddd")
            });
        }
        return c;
    }
    let K, Q, x, v, f, I, ee, u, d, ne, te, re;
    ({ t: K } = $());
    Q = B();
    x = L();
    v = z();
    f = await N();
    I = f && f.length > 0 ? f[0].id : 0;
    ie = ()=>({
            infoSchemas: [
                {
                    field: "vesselId",
                    component: "NSelect",
                    componentProps: {
                        disabled: !0,
                        options: f,
                        defaultValue: I,
                        "label-field": Q.getLocale === "en" ? "shipNameEn" : "shipName",
                        "value-field": "id"
                    },
                    label: K("operation.vesselRuleMapping.vessel"),
                    giProps: {
                        span: 1
                    }
                },
                {
                    field: "rankId",
                    component: "NSelect",
                    componentProps: {
                        options: []
                    },
                    label: "Rank",
                    giProps: {
                        span: 1
                    }
                },
                {
                    field: "date",
                    component: "NDatePicker",
                    componentProps: {
                        type: "month"
                    },
                    label: "Date",
                    giProps: {
                        span: 1
                    }
                },
                {
                    field: "rankId",
                    component: "NSelect",
                    componentProps: {
                        options: []
                    },
                    label: "Seafarer",
                    giProps: {
                        span: 1
                    }
                },
                {
                    field: "btnGroup",
                    giProps: {
                        span: 2
                    },
                    slot: "btnGroupSlotName"
                }
            ]
        });
    ee = {
        Monday: "Mon",
        Tuesday: "Tues",
        Wednesday: "Wed",
        Thursday: "Thu",
        Friday: "Fri",
        Saturday: "Sat",
        Sunday: "Sun"
    };
    u = 52;
    d = (n)=>[
            0,
            1,
            2,
            u - 1
        ].includes(n) ? `field_${n}` : v[n];
    ne = ()=>Object.fromEntries(new Array(u).fill(0).map((n, e)=>e === u - 1 ? [
                d(e),
                "Total Hrs."
            ] : e === 2 ? [
                d(e),
                "Data"
            ] : [
                d(e),
                ""
            ]));
    te = (n)=>n === 0 ? 40 : n === 1 ? 80 : n === 2 ? 100 : n === u - 1 ? 120 : 25;
    re = (n)=>{
        const e = g(n.yearMonth), o = b(()=>{
            const t = e.value.split("-")[0], r = e.value.split("-")[1], l = J(t, r);
            return Z(l.map((s)=>({
                    field_2: `${s.day}-${ee[s.week]}`
                })), "day");
        }), a = [
            ...new Array(u).fill(0).map((t, r)=>({
                    field: d(r),
                    title: "",
                    width: te(r),
                    headerStyle: {
                        textAlign: "center"
                    },
                    style: {
                        bgColor: (s)=>{
                            const { row: i } = s;
                            return i === 0 ? "#d8f5e7" : "#fff";
                        },
                        textAlign: "center"
                    },
                    cellType: oe
                }))
        ];
        return {
            options: b(()=>({
                    showHeader: !1,
                    records: [
                        ne(),
                        ...o.value
                    ],
                    columnResizeMode: "none",
                    customMergeCell: (t, r, l)=>{
                        let s = {};
                        return new Array(24).fill(0).some((i, p)=>r === 0 && (t === p * 2 + 3 || t === p * 2 + 4) ? (s = {
                                text: E(String(p), 2, "0"),
                                range: {
                                    start: {
                                        col: p * 2 + 3,
                                        row: 0
                                    },
                                    end: {
                                        col: p * 2 + 4,
                                        row: 0
                                    }
                                }
                            }, !0) : !1), s;
                    },
                    select: {
                        disableSelect (t, r, l) {
                            return r === 0 || [
                                0,
                                1,
                                2,
                                u - 1
                            ].includes(t) ? (x.warning("禁止选中"), !0) : !1;
                        },
                        outsideClickDeselect: !0
                    },
                    theme: {
                        selectionStyle: {
                            cellBorderColor: "#ffcc00"
                        }
                    },
                    frozenRowCount: 1,
                    columns: a
                })),
            columns: a
        };
    };
    function oe(n) {
        const { col: e, row: o } = n;
        return e === 0 && o !== 0 ? "checkbox" : e === 1 && o !== 0 ? "switch" : "text";
    }
    let ae;
    ae = {
        class: "proCard mt-3 h-[500px]"
    };
    ue = O({
        __name: "list",
        setup (n) {
            const { options: e } = re({
                yearMonth: "2025-11"
            }), o = g(e), a = g();
            function c(t) {
                const { col: r, row: l } = t;
                console.log("handleMouseenterCell --> args", t, a.value);
            }
            return (t, r)=>{
                const l = H;
                return j(), W(l, null, {
                    default: V(()=>[
                            F("div", ae, [
                                G(w(R), {
                                    options: w(o),
                                    onMouseenterCell: c,
                                    ref_key: "tableRef",
                                    ref: a
                                }, null, 8, [
                                    "options"
                                ])
                            ])
                        ]),
                    _: 1
                });
            };
        }
    });
});
export { ue as _, ie as c, __tla };
