import { j as n } from "../../node_modules/react/jsx-runtime.mjs";
import { useState as u } from "react";
import { useImmer as B } from "../../node_modules/use-immer/dist/use-immer.module.mjs";
import { BitzPickDrawer as I } from "../BitzDrawer/index.mjs";
import K from "../../node_modules/antd/es/input/index.mjs";
import N from "../../node_modules/@ant-design/icons/es/icons/DownOutlined.mjs";
import O from "../../node_modules/antd/es/tabs/index.mjs";
import g from "../../node_modules/antd/es/radio/index.mjs";
const r = { label: "请选择", key: "", value: "" }, M = (t) => {
  var f;
  const [v, m] = u(((f = t.defaultValue) == null ? void 0 : f.join(" / ")) || ""), [x, d] = u(!1), [o, b] = B([{ ...r, children: t.options }]), [h, i] = u(r.label), j = () => {
    d(!1), b([{ ...r, children: t.options }]), i(r.label);
  }, k = () => {
    var s;
    const e = o.slice(1), a = e.map((c) => ({
      label: c.label,
      value: c.value
    })), l = e.map((c) => c.key);
    (s = t.onChange) == null || s.call(t, l, a), d(!1), m(l.join(" / "));
  }, C = (e) => {
    b((a) => {
      const l = o.at(-1), s = a.at(-1);
      if (l) {
        const c = l.children, y = l.label;
        if (c != null && c.find((z) => z.label === y)) {
          s.label = e.label, s.key = e.label, i(e.label);
          return;
        }
      }
      a.push({
        key: e.label,
        label: e.label,
        value: e.label,
        children: e.children ? e.children : s.children
      }), i(e.label);
    });
  }, p = (e) => {
    i(e);
    const a = o.slice(0, o.findIndex((l) => l.label === e) + 1);
    b(a);
  };
  return n.jsxs("div", { className: "bitzCascaderMobileBlock", children: [n.jsx(K, { placeholder: t.placeholder, onClick: () => d(!0), value: v, suffix: n.jsx(N, {}) }), n.jsx(I, { open: x, handleCancel: j, handleOk: k, children: n.jsx(O, { defaultActiveKey: h, activeKey: h, items: o.map((e) => {
    var a;
    return {
      key: e.label,
      label: e.label,
      children: (a = e.children) == null ? void 0 : a.map((l, s) => n.jsxs("div", { className: "item", onClick: () => C(l), children: [n.jsx("span", { children: l.label }), n.jsx("span", { children: l.label === h ? n.jsx(g, { checked: !0 }) : "" })] }, s))
    };
  }), onChange: p }) })] });
}, T = M;
export {
  T as default
};
