import { _ as V, __tla as __tla_0 } from "./CustomCard.vue_vue_type_script_setup_true_lang-374ERk20.js";
import { _ as W } from "./CustomTable.vue_vue_type_script_setup_true_lang-CVzOsXR0.js";
import { u as z } from "./useECharts-XZ1IwN24.js";
import { c as H } from "./columns-1dSLzo5A.js";
import { r as M, s as O, t as Z } from "./workbench-DEgqNpqd.js";
import { d as $, e as G, bk as j, dW as J, r as p, ay as C, l as a, ac as y, c as I, o as S, w as K, D as x, h as Q, __tla as __tla_1 } from "./index-9PRMimni.js";
import "./BasicForm-dL_oCSPM.js";
import "./Render.vue_vue_type_script_lang-DKUYY0Zw.js";
import "./SingleImageUpload-CNx4b9eC.js";
import "./ImageUpload.vue_vue_type_style_index_0_scoped_cb086928_lang-D-28kXvw.js";
import "./componentSetting-DVhNDBTO.js";
import "./ImageUpload-DUsnro3W.js";
import "./vuedraggable.umd-Co2xEC3p.js";
import "./BasicUpload.vue_vue_type_style_index_0_scoped_a4d0e930_lang-DxRbtP01.js";
import "./tabsView-BXskTdVh.js";
import "./BasicForm.vue_vue_type_style_index_0_scoped_b9e995ec_lang-CEvcLwxD.js";
import "./propTypes-CebMRUpe.js";
import "./BasicSelect-C_uwzMkE.js";
import "./BasicSelect.vue_vue_type_style_index_0_scoped_772d51cc_lang-Brp6PjEU.js";
import "./dictionary-BRse4lkf.js";
import "./index-DkvzUEqh.js";
import "./index-kKnqLkWM.js";
import "./AutoComplete-Dv1Bqed4.js";
import "./TreeSelect-BZh2DeCh.js";
import "./useForm-CKmgcynv.js";
import "./usePageCache-DluHn7Yy.js";
import "./Flex-CTSf12gq.js";
import "./useTimeout-BxFilWvD.js";
import "./tslib.es6-CSJU3tT9.js";
import "./index-DatBjkM3.js";
import "./dateUtil-BtafrT1f.js";
import "./format-DgF6KtHk.js";
import "./helper-D9DF1oLX.js";
import "./find-D_h_aJYR.js";
import "./findIndex-BgUIH3i1.js";
import "./toInteger-DQeH-nF-.js";
import "./includes-DdMWPj0t.js";
let Et;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })()
]).then(async ()=>{
    Et = $({
        __name: "SparePartsStockStatus",
        props: {
            componentItem: {},
            isEditable: {
                type: Boolean
            },
            searchParams: {},
            refreshComponent: {
                type: Boolean
            },
            defaultCurrentComponent: {
                default: "chart"
            },
            defaultShowTransition: {
                type: Boolean,
                default: !0
            },
            useSource: {}
        },
        setup (w) {
            const s = w, l = G(), u = j(), b = J(), g = p(), k = p(), { setOptions: P, disposeInstance: T, resizeFn: v, getInstance: d } = z(k), i = p(), o = p(s.defaultCurrentComponent), L = p(s.defaultShowTransition), { sparePartsStockStatusColumns: _ } = H();
            C(()=>s.refreshComponent, (t)=>{
                t && h();
            }, {
                immediate: !0
            }), C(()=>s.isEditable, ()=>{
                o.value === "chart" && v();
            });
            function h() {
                o.value === "table" ? B(!0) : o.value === "chart" && (s.useSource === "myFleet" ? N() : R());
            }
            async function N() {
                let t = {}, n = [], m = [], c = null;
                const e = async (F)=>{
                    t = await Z({
                        shipId: s.searchParams?.shipIds,
                        ...i.value || {},
                        parentCode: F
                    }), c = t?.grandParentCode, n = (t?.productInfos || []).map((r)=>r?.productName), m = (t.seriesList || []).map((r)=>({
                            type: "bar",
                            stack: "total",
                            emphasis: {
                                focus: "series"
                            },
                            showBackground: !0,
                            barMaxWidth: 30,
                            name: r?.[u.getLocale === "en" ? "stateNameEn" : "stateName"],
                            data: r?.countList || []
                        })), await y(), await P({
                        tooltip: {
                            trigger: "axis",
                            axisPointer: {
                                type: "shadow"
                            }
                        },
                        title: {
                            show: !!c,
                            text: "<Back",
                            left: "10",
                            top: "0",
                            triggerEvent: !0,
                            textStyle: {
                                color: a(b)?.textColor3,
                                fontSize: 14,
                                fontWeight: 400
                            }
                        },
                        xAxis: {
                            type: "category",
                            data: n
                        },
                        yAxis: {
                            type: "value",
                            minInterval: 1
                        },
                        grid: {
                            top: 30,
                            right: "6%"
                        },
                        dataZoom: [
                            {
                                type: "slider",
                                start: 10,
                                end: 90,
                                moveHandleSize: 10,
                                height: 20
                            }
                        ],
                        series: m
                    }), d()?.off("click"), d()?.on("click", function(r) {
                        if (r.componentType === "series") {
                            const f = (t?.productInfos || [])[r.dataIndex];
                            f?.hasSubProduct ? e(f?.productCode) : l.push({
                                name: "sparePartsStock",
                                query: {
                                    shipId: s.searchParams?.shipIds,
                                    productCode: f?.productCode,
                                    statusId: (t?.seriesList || [])[r.seriesIndex || 0]?.statusId
                                }
                            });
                        } else r.componentType === "title" && e(c);
                    });
                };
                await e(0);
            }
            async function R() {
                const t = await M({
                    ...s.searchParams || {},
                    ...a(i) || {}
                }), n = (t.shipList || []).map((e)=>e?.[u.getLocale === "en" ? "shipNameEn" : "shipName"]), m = (t.seriesList || []).map((e)=>({
                        type: "bar",
                        stack: "total",
                        emphasis: {
                            focus: "series"
                        },
                        showBackground: !0,
                        barMaxWidth: 30,
                        name: e?.[u.getLocale === "en" ? "stateNameEn" : "stateName"],
                        data: e?.countList || []
                    })), c = {
                    tooltip: {
                        trigger: "axis",
                        axisPointer: {
                            type: "shadow"
                        }
                    },
                    xAxis: {
                        type: "category",
                        data: n
                    },
                    yAxis: {
                        type: "value",
                        minInterval: 1
                    },
                    grid: {
                        top: 30,
                        right: "6%"
                    },
                    dataZoom: [
                        {
                            type: "slider",
                            start: 10,
                            end: 90,
                            moveHandleSize: 10,
                            height: 20
                        }
                    ],
                    series: m
                };
                y(()=>{
                    P(c), d()?.on("click", function(e) {
                        e.componentType === "series" && l.push({
                            name: "sparePartsStock",
                            query: {
                                shipId: (t.shipList || [])[e.dataIndex]?.shipId
                            }
                        });
                    });
                });
            }
            function B(t) {
                y(()=>{
                    g.value?.handleGetData(t);
                });
            }
            function A(t) {
                return {
                    style: "cursor: pointer",
                    onClick: ()=>{
                        l.push({
                            name: "sparePartsStock",
                            query: {
                                partNumber: t.partNumber,
                                shipId: t.shipId
                            }
                        });
                    }
                };
            }
            function E() {
                const t = s.searchParams?.shipIds?.toString()?.split(",");
                let n = "";
                t?.length === 1 && (n = t[0]), l.push({
                    name: "sparePartsStock",
                    query: {
                        criticalToSafety: 1,
                        shipId: n
                    }
                });
            }
            function D(t) {
                i.value = t, h();
            }
            function q(t) {
                o.value = t, o.value === "chart" && T(), h();
            }
            return (t, n)=>(S(), I(V, {
                    componentItem: t.componentItem,
                    currentComponent: a(o),
                    cardParams: a(i),
                    searchParams: t.searchParams,
                    showTransition: a(L),
                    onFilter: D,
                    onShowAll: E,
                    onTransition: q
                }, {
                    default: K(()=>[
                            a(o) === "table" ? (S(), I(W, {
                                key: 0,
                                ref_key: "basicTableRef",
                                ref: g,
                                columns: a(_),
                                request: a(O),
                                params: {
                                    ...t.searchParams || {},
                                    ...a(i) || {},
                                    criticalToSafety: 1
                                },
                                "row-props": A
                            }, null, 8, [
                                "columns",
                                "request",
                                "params"
                            ])) : x("", !0),
                            a(o) === "chart" ? (S(), Q("div", {
                                key: 1,
                                ref_key: "chartRef",
                                ref: k,
                                class: "w-full h-full"
                            }, null, 512)) : x("", !0)
                        ]),
                    _: 1
                }, 8, [
                    "componentItem",
                    "currentComponent",
                    "cardParams",
                    "searchParams",
                    "showTransition"
                ]));
        }
    });
});
export { Et as default, __tla };
