Files
ff-dist/dist/common/main-Bg4ZfEi1.js
2026-05-22 14:02:24 +08:00

1567 lines
110 KiB
JavaScript

var Or = Object.defineProperty;
var wn = (t) => {
throw TypeError(t);
};
var Rr = (t, e, n) => e in t ? Or(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
var O = (t, e, n) => Rr(t, typeof e != "symbol" ? e + "" : e, n), bn = (t, e, n) => e.has(t) || wn("Cannot " + n);
var c = (t, e, n) => (bn(t, e, "read from private field"), n ? n.call(t) : e.get(t)), P = (t, e, n) => e.has(t) ? wn("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), K = (t, e, n, r) => (bn(t, e, "write to private field"), r ? r.call(t, n) : e.set(t, n), n);
var Cn = (t, e, n, r) => ({
set _(i) {
K(t, e, i, n);
},
get _() {
return c(t, e, r);
}
});
import { jsx as m, jsxs as L } from "react/jsx-runtime";
import E, { useEffect as q, useState as I, useCallback as H, useRef as _, useContext as he, useMemo as U, useId as Dt, isValidElement as Fr, useLayoutEffect as jr } from "react";
import me from "pathe";
import b from "prop-types";
import j from "classnames";
import { useNotification as Ar } from "rc-notification";
import f from "lodash";
import ae, { Field as Qt, FieldContext as Ln } from "rc-field-form";
import { useMountedState as Ir, useDeepCompareEffect as Zt, useUpdateEffect as Mn, usePrevious as Vn } from "react-use";
import { _ as kn, M as It, N as tt, b as De, i as zt, c as Lr, S as Mr } from "./vender-hQk7ADWo.js";
import Vr from "rc-util/lib/hooks/useMergedState";
import Dn from "immutability-helper";
import { Space as Dr, Form as wt, Input as zr, Button as Ct, Pagination as Br, Tree as Wr, Breadcrumb as Ur, Empty as Bt, Table as Sn, Popover as qr, Popconfirm as Kr, Tooltip as Jr } from "antd";
import { useMergedState as _r } from "rc-util";
import { generatePath as Hr, useInRouterContext as zn, useParams as Yr, useLocation as Gr, createBrowserRouter as Xr, Navigate as Qr } from "react-router-dom";
import Zr from "rc-drawer";
import ei from "rc-dialog";
import * as En from "react-is";
var Je, rt, _e, xe, ze, Be;
class Bn {
constructor(e, n) {
P(this, Je, /* @__PURE__ */ new Map());
P(this, rt, !0);
P(this, _e, []);
P(this, xe);
P(this, ze, () => c(this, xe));
P(this, Be, () => Promise.resolve());
O(this, "get", (...e) => new Promise((n, r) => {
const i = JSON.stringify(e);
if (c(this, Je).has(i)) return n(c(this, Be).call(this, c(this, xe), ...e));
if (c(this, xe) === void 0) c(this, _e).push([e, n, r]), c(this, rt) && (K(this, rt, !1), Promise.resolve(typeof c(this, ze) == "function" ? c(this, ze).call(this) : c(this, ze)).then((o) => K(this, xe, o || null)).finally(() => {
c(this, _e).forEach(([o, a, s]) => {
try {
const l = c(this, Be).call(this, c(this, xe), ...o);
c(this, Je).set(JSON.stringify(o), l), a(l);
} catch (l) {
s(l);
}
}), c(this, _e).length = 0;
}));
else {
const o = c(this, Be).call(this, c(this, xe), ...e);
c(this, Je).set(i, o), n(o);
}
}));
K(this, Be, n), K(this, ze, e);
}
}
Je = new WeakMap(), rt = new WeakMap(), _e = new WeakMap(), xe = new WeakMap(), ze = new WeakMap(), Be = new WeakMap();
const vo = () => m("div", { children: "Empty" }), ht = E.createContext({ ele: {}, mount: () => {
}, unmount: () => {
} }), te = ({ rootClassName: t, className: e, children: n, actions: r, title: i, subTitle: o, extras: a, style: s = {} }) => {
const { mount: l, unmount: d } = E.useContext(ht);
return te.Action({ children: r }), te.Title({ children: i }), te.SubTitle({ children: o }), te.Extra({ children: a }), q(() => (l("rootClassName", t), () => d(t)), [t]), m("div", { className: j("ff-container", e), style: s, children: n });
}, yt = (t) => ({ children: e, className: n }) => {
const { mount: r, unmount: i } = E.useContext(ht);
return q(() => (e && r(t, E.createElement("div", { key: `ff-${t}`, className: j(`ff-popup-${t}`, n) }, e)), () => i(t)), [n, e]), null;
};
te.Action = yt("actions"), te.Title = yt("title"), te.SubTitle = yt("sub-title"), te.Extra = yt("extras"), te.propTypes = { className: b.string, style: b.object, title: b.any, subTitle: b.any, actions: b.any, extras: b.any };
const No = () => m(te, { className: "ff-loading", children: L("div", { className: "loader", children: [L("div", { className: "square", children: [m("span", {}), m("span", {}), m("span", {})] }), L("div", { className: "square", children: [m("span", {}), m("span", {}), m("span", {})] }), L("div", { className: "square", children: [m("span", {}), m("span", {}), m("span", {})] }), L("div", { className: "square", children: [m("span", {}), m("span", {}), m("span", {})] })] }) }), To = () => m("div", { children: "NotFound" }), Wn = ({ children: t }) => {
const [e, n] = I({}), r = H((o, a) => n((s) => ({ ...s, [o]: a })), []), i = H((o) => n((a) => ({ ...a, [o]: void 0 })), []);
return typeof (t == null ? void 0 : t.type) == "string" ? t : m(ht.Provider, { value: { ele: e, mount: r, unmount: i }, children: E.cloneElement(t, { className: e.rootClassName, title: e.title, subTitle: e["sub-title"], actions: e.actions, extras: e.extras }) });
};
Wn.propTypes = { children: b.element.isRequired };
const $n = { close: ["M563.8 512l262.5-312.9c4.4-5.2 0.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9c-4.4 5.2-0.7 13.1 6.1 13.1h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"], check: ["M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474c-6.1-7.7-15.3-12.2-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1 0.4-12.8-6.3-12.8z"], info: ["M512 224m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0Z", "M544 392h-64c-4.4 0-8 3.6-8 8v464c0 4.4 3.6 8 8 8h64c4.4 0 8-3.6 8-8V400c0-4.4-3.6-8-8-8z"] }, en = ({ type: t, props: e }) => m("i", { ...e, children: m("svg", { viewBox: "0 0 1024 1024", width: "1em", height: "1em", fill: "currentColor", children: ($n[t] || $n.info).map((n, r) => m("path", { d: n }, r)) }) }), Un = ({ className: t, content: e, icon: n, $close: r }) => L(E.Fragment, { children: [n && m("div", { className: j("ff-notification-icon", t), children: m(en, { type: n }) }), e] }), ti = ({}) => m(te, { children: "Confirm" });
var Oe, He;
const fe = class fe {
constructor() {
P(this, He, /* @__PURE__ */ new Map());
O(this, "init", (e) => K(this, He, new Map(e)));
O(this, "check", (e) => !c(this, He).has(e) || c(this, He).get(e));
if (c(fe, Oe)) return c(fe, Oe);
}
};
Oe = new WeakMap(), He = new WeakMap(), P(fe, Oe, null), O(fe, "getInstance", () => (c(fe, Oe) || K(fe, Oe, new fe()), c(fe, Oe)));
let Wt = fe;
const qn = Wt.getInstance(), ni = (t, e, n = "children") => {
if (f.isEmpty(t)) return {};
const r = f.find(t, ["value", e]);
if (!f.isEmpty(r)) return r;
const i = t.length;
for (let o = 0; o < i; o++) {
const { [n]: a } = t[o], s = ni(a, e, n);
if (!f.isEmpty(s)) return s;
}
return {};
}, Kn = (t = "Input", e = "@pkg/ff/grid-layout-forms") => t != null && t.startsWith("@") || t != null && t.startsWith("blob:") ? t : `${e}/${t}`;
var Re, it;
const ye = class ye {
constructor() {
P(this, it, null);
O(this, "init", (e) => K(this, it, e));
O(this, "get", (e, n) => f.get(c(this, it), e, n));
if (c(ye, Re)) return c(ye, Re);
}
};
Re = new WeakMap(), it = new WeakMap(), P(ye, Re, null), O(ye, "getInstance", () => (c(ye, Re) || K(ye, Re, new ye()), c(ye, Re)));
let Ut = ye;
const qe = Ut.getInstance();
var Ye, Et, ot, at, $t;
const Te = class Te {
constructor(...e) {
P(this, ot, []);
P(this, at, (e) => {
var n;
for (let r of e) Array.isArray(r[0]) ? c(this, at).call(this, r) : c(this, ot).push(c(n = Te, Et).call(n, r[0], r[1]));
});
O(this, "toValue", async (e, n = null) => {
const r = { getValue: () => e, getRecord: () => n };
let i = e;
for (const o of c(this, ot)) try {
const a = await o;
if (typeof a != "function") {
console.warn("middleware is not a function, skip:", a);
continue;
}
i = await a.call(r, i);
} catch (a) {
console.error("middleware error, skip:", a);
}
return i;
});
O(this, "toRender", (e, n, r = null) => E.createElement(c(this, $t), { value: e, record: n }, r));
P(this, $t, ({ value: e, record: n, children: r }) => {
const [i, o] = I(r), a = Ir();
return Zt(() => {
o(r), this.toValue(e, n).then((s) => a() && o(s)).catch((s) => a() && o(`${s}`));
}, [e, n]), i;
});
c(this, at).call(this, e);
}
};
Ye = new WeakMap(), Et = new WeakMap(), ot = new WeakMap(), at = new WeakMap(), $t = new WeakMap(), P(Te, Ye, null), P(Te, Et, f.memoize((e, n) => {
if (typeof e == "function") return e(n);
if (typeof e == "string") return le.getWidgetComponent(e).then((r) => {
var i;
return ((i = r.default) == null ? void 0 : i.call(r, n)) || ((o) => o);
});
throw new TypeError("middleware must be a string or a function");
}, (...e) => {
var n;
return c(Te, Ye) || K(Te, Ye, Oi()), c(n = Te, Ye).call(n, ...e);
}));
let kt = Te;
const ce = E.createContext({ listCode: "", classNames: {}, getBase62params: (t, e) => {
}, getSelectedRows: () => [], onReload: () => {
}, onClickCallback: () => {
}, onConditionChange: () => {
}, onTabChange: () => {
}, onSiderChange: () => {
}, onKeywordChange: () => {
}, onPageChange: () => {
}, onPageSizeChange: () => {
}, reload: () => {
}, setPage: () => {
}, setPageSize: () => {
}, setTab: () => {
}, setSider: () => {
}, setKeyword: () => {
}, setCondition: () => {
} }), xn = ({ className: t, record: e, column: n, ...r }) => {
if (n != null && n.editableByJs && (n != null && n.uuid)) {
const { formSetting: i = { primaryKey: "id" }, widgetSetting: o = {}, widgetContainerSetting: a = {} } = (n == null ? void 0 : n.editableByJsSetting) || {};
return m(R.Popover, { widget: Jn, widgetData: { record: e, column: n }, widgetSetting: { widgetSetting: o, formSetting: i }, widgetContainerProps: { title: n != null && n.title ? `${n.title} - 编辑` : "编辑", ...a, width: (a == null ? void 0 : a.width) || 260, arrow: !0 }, children: m("td", { className: j("ff-data-list-cell-editable", t), ...r }) });
}
return m("td", { className: t, ...r });
}, Jn = ({ record: t, column: e, $close: n, $setting: r }) => {
const i = _(Ni(f.get(t, e == null ? void 0 : e.dataIndex))), { listCode: o, onClickCallback: a } = he(ce), [s] = ae.useForm(), { formSetting: l, widgetSetting: d } = r, { primaryKey: u = "id", help: p, validators: h } = l || {}, g = () => {
s.setFieldsValue({ value: f.get(t, e == null ? void 0 : e.dataIndex), __PROPS__: t });
};
return Ot(() => g(), [t, e == null ? void 0 : e.dataIndex, o]), m(te, { actions: L(E.Fragment, { children: [m(R, { size: "small", onClick: g, children: "重置" }), L(Dr.Compact, { block: !0, children: [m(R, { size: "small", widget: n, children: "取消" }), m(R, { type: "primary", size: "small", widget: () => s.validateFields().then(({ value: y }) => {
const w = f.get(t, u.substring(u.indexOf(".") + 1));
if (!w) throw "获取更新主键失败!";
z.put(`/api/${o}-storeBy-${e == null ? void 0 : e.uuid}/${w}`, { value: y }).msg(() => a(2, t)).then(n);
}).catch(console.warn), children: "保存" })] })] }), children: L(ae, { form: s, children: [m(rn, { label: "", code: "value", type: i.current, widget: e == null ? void 0 : e.editableByJs, help: p, extras: d, validators: h }), m(Qt, { noStyle: !0, name: ["__PROPS__"], children: () => {
} })] }) });
};
Jn.displayName = "DataListCellEditableContainer";
const ri = (t) => function(e) {
return t(e, getRecord());
}, ii = async ({ widgetByJs: t, widgetByJsSetting: e }) => {
const n = await le.getWidgetComponent(t).then((r) => r.default || ((i) => i));
return function(r) {
return m(n, { value: r, $setting: e });
};
}, oi = (t, e = {}) => U(() => {
var n;
return (n = t == null ? void 0 : t.filter(Boolean)) == null ? void 0 : n.map(({ widgetByJs: r, widgetByJsSetting: i, middlewares: o, ...a }, s) => {
const l = (d) => ({ record: d, column: a });
return o || (o = []), r && o.push([ii, { widgetByJs: r, widgetByJsSetting: i }]), o.length > 0 ? (a != null && a.render && o.push([ri, a.render]), { ...a, onCell: l, render: (d, u) => new kt(o).toRender(d, u, "-") }) : { ...a, onCell: l };
});
}, [t, e]), ai = (t = {}) => U(() => {
var e;
return t.body ?? (t.body = { cell: xn }), (e = t.body).cell ?? (e.cell = xn), t;
}, [t]), Oo = (t) => {
const [e, n] = I({});
return q(() => {
let r = !1;
return t && z.get(`/api/_/${t}`).then((i) => f.pick(i, ["uuid", "name", "code", "resource", "marginX", "marginY", "cols", "rowHeight", "primaryKey", "columns", "itemOperations", "batchOperations", "isConditionFormLayout", "layout", "tabs", "pageSize", "layoutConfig", "selectionType"])).then((i) => !r && n(i)), () => r = !0;
}, [t]), e;
}, Ro = (t, e = {}) => {
const [n, r] = I({ dataSource: [] });
return mt(() => {
let i = !1;
return t && z.get(`/api/${t}/${z.encode({ page: 1, ...e })}`).then((o) => !i && r(o)), () => i = !0;
}, [t, e]), n;
}, _n = (t = [], e = /* @__PURE__ */ new Map(), n = "id", r) => {
const i = H(r ? (o) => f.get(o, n, f.get(o, [r, n])) : (o) => f.get(o, n), [n, r]);
return H((o) => t == null ? void 0 : t.filter((a) => !a.uuid || !e.has(a.uuid) || e.get(a.uuid).some((s) => s == i(o))), [t, e, i]);
}, qt = (t = [], e = /* @__PURE__ */ new Map(), n = [], r = "id", i) => {
const o = H(i ? (a) => f.get(a, r, f.get(a, [i, r])) : (a) => f.get(a, r), [r, i]);
return U(() => {
if (f.isEmpty(t) || !t.some(({ uuid: s }) => qn.check(s))) return !1;
if (f.isEmpty(e) || f.isEmpty(n)) return !0;
const a = n.map((s) => o(s));
return t.some(({ uuid: s }) => !s || !e.has(s) || e.get(s).some((l) => a.some((d) => d == l)));
}, [t, n, e, o]);
}, si = (t, e, n = "id", r = null) => {
const i = Tt(), o = _(!1), a = _(t.dataSource), s = _(t.itemOperationsAccess);
return q(() => (a.current = t.dataSource, s.current = t.itemOperationsAccess, () => o.current = !1), [t.dataSource, t.itemOperationsAccess]), o.current && (t.dataSource = a.current, t.itemOperationsAccess = s.current), [t, (l = 0, d = null) => {
var u, p;
if (o.current = !1, l === 1) return (u = t.onReload) == null ? void 0 : u.call(t);
if (l === 2) {
const h = f.get(d, "__PARENT_ID__", ""), g = f.get(d, n, f.get(d, [r, n], "")), y = f.findIndex(a.current, ["__PARENT_ID__", h]), w = f.findIndex(y > -1 ? f.get(a.current, [y, "children"]) : a.current, [n, g]);
if (w === -1) return (p = t.onReload) == null ? void 0 : p.call(t);
Promise.all([z.get(`/api/${e}/detail/${g}`), z.post(`/api/${e}/list-operations-access`, { ids: g })]).then(([C, S]) => {
const x = f.get(a.current, y > -1 ? [y, "children", w, "children"] : [w, "children"]);
a.current = Dn(a.current, y > -1 ? { [y]: { children: { $splice: [[w, 1, { ...C, children: x }]] } } } : { $splice: [[w, 1, { ...C, children: x }]] });
const k = new Map(S);
s.current.forEach(($, F) => {
var A;
(A = k.get(F)) != null && A.some((T) => T == g) || s.current.set(F, $.filter((T) => T !== g));
}), k.forEach(($, F) => {
s.current.has(F) ? s.current.set(F, f.uniq([...s.current.get(F) || [], ...$])) : s.current.set(F, $);
});
}).then(() => {
o.current = !0, i();
});
}
}];
}, li = (t, e) => {
const n = Tt(), r = _(e), i = _(/* @__PURE__ */ new Map()), o = _([]), a = f.throttle((l) => {
o.current = [], z.list(t, f.pick({ ...r.current, ...l }, ["tab", "page", "pageSize", "condition", "sider", "keyword"])).then(({ keyword: d, condition: u, total: p, tab: h, sider: g, page: y, pageSize: w, operationsAccess: C, dataSource: S }) => {
r.current = { tab: h, condition: u, sider: g, keyword: d, total: p, pageSize: w, page: S != null && S.length ? y : 1 }, o.current = S, i.current = new Map(C), n();
});
}, 380, { leading: !1, trailing: !0 });
Ot(() => {
o.current = [], t && a(e);
}, [t, e]);
const s = U(() => f.pick(r.current, ["total", "tab", "page", "pageSize", "condition", "sider", "keyword"]), [r.current]);
return Object.assign(s, { onTabChange: (l) => a({ tab: l, page: 1 }), onPageChange: (l, d) => a({ page: l, pageSize: d }), onPageSizeChange: (l) => a({ pageSize: l, page: 1 }), onConditionChange: (l, d) => a({ keyword: d, condition: Dn(r.current.condition || {}, { $merge: l || {} }), page: 1 }), onSiderChange: (l) => a({ sider: l, page: 1 }), onKeywordChange: (l) => a({ keyword: l, page: 1 }), itemOperationsAccess: i.current, dataSource: o.current, onReload: a, payload: e == null ? void 0 : e.payload });
}, ci = ({ listCode: t, className: e, layouts: n = {}, dataSource: r, isPaginate: i, isItemOperations: o, isBatchOperations: a, batchOperations: s, itemOperations: l, itemOperationsAccess: d, resource: u, primaryKey: p, title: h, itemGridLayout: g, $setting: y, tabs: w, isConditionFormLayout: C, isTreeSider: S, treeSiderConfig: x, rowSelection: k }) => {
const { classNames: $, onClickCallback: F } = he(ce), A = f.pick(y, ["column", "colWidth", "beforeRender", "afterRender", "style", "itemMargin", "containerPadding"]), T = y == null ? void 0 : y.isMarkSelected, N = _n(l, d, p, u), V = H((v, M, D) => m(di, { isMarkSelected: T, className: j("ff-data-list-framework-item", $ == null ? void 0 : $.item), operations: o ? N(M) : [], data: u ? { [u]: M } : M, children: v, onClickCallback: F }), [T, u, p, o, F, l, d]);
return L("div", { className: j("ff-data-list-framework", e), children: [m(n.sider, { isTreeSider: S, ...x }), L("div", { className: j("ff-data-list-container", $ == null ? void 0 : $.container), children: [m(n.filter, { isConditionFormLayout: C }), m(n.toolbar, { title: h, tabs: w }), m($i, { ...A, ...g, rowSelection: k, empty: m(n.empty, { className: $ == null ? void 0 : $.empty }), primaryKey: p, itemRender: V, dataSource: r }), m(n.footer, { isPaginate: i, isOperations: a, operations: s })] })] });
}, di = ({ className: t, operations: e, children: n, data: r, onClickCallback: i, onSelect: o, isMarkSelected: a, isSelected: s }) => L("div", { className: j("data-list-grid-layout-item", { "is-mark-selected": a, "is-selected": s }, t), onClick: o, children: [m("div", { className: "data-list-grid-layout-item-container", children: n }), !!(e != null && e.length) && m("div", { className: "data-list-grid-layout-item-actions", children: e.map((l) => m("span", { className: "data-list-grid-layout-item-action", children: m(R.Link, { uuid: l.uuid, type: l.type, name: l.name, widget: l.widget, widgetType: l.widgetType, widgetProps: l.widgetProps, widgetSetting: l.widgetSetting, widgetContainerProps: l.widgetContainerSetting, data: r, confirm: l.confirm, onAfterClick: (d) => d !== !1 && (i == null ? void 0 : i(l.isRefresh, r)) }, l.uuid || Dt()) }, (l == null ? void 0 : l.uuid) || Dt())) })] }), ui = ({ listCode: t, className: e, layouts: n = {}, dataSource: r, columns: i, isItemOperations: o, isBatchOperations: a, batchOperations: s, itemOperations: l, itemOperationsAccess: d, resource: u, primaryKey: p, title: h, tabs: g, isPaginate: y, rowSelection: w, isTreeSider: C, treeSiderConfig: S, isConditionFormLayout: x, ...k }) => {
const { classNames: $, onClickCallback: F } = he(ce), A = _n(l, d, p, u), T = qt(l, d, r, p, u);
return L("div", { className: j("ff-data-table-framework", e), children: [m(n.sider, { isTreeSider: C, ...S }), L("div", { className: j("ff-data-table-container", $ == null ? void 0 : $.container), children: [m(n.filter, { isConditionFormLayout: x }), m(n.toolbar, { title: h, tabs: g }), m(wi, { ...k, primaryKey: p, className: "ff-data-table-content", columns: i, dataSource: r, rowSelection: w, operationRender: T ? (N) => {
var V;
return m("div", { className: "ff-data-table-actions", children: (V = A(N)) == null ? void 0 : V.map((v, M) => m(R.Link, { size: "small", uuid: v.uuid, type: v.type, name: v.name, widget: v.widget, widgetType: v.widgetType, widgetProps: v.widgetProps, widgetData: v.widgetData, widgetSetting: v.widgetSetting, widgetContainerProps: v.widgetContainerSetting, data: N, confirm: v.confirm, onAfterClick: (D) => D !== !1 && (F == null ? void 0 : F(v.isRefresh, N)) }, v.uuid || M)) });
} : null }), m(n.footer, { isPaginate: y, isOperations: a, operations: s })] })] });
}, tn = (t = [], e, n = null) => {
var r;
return (r = f.sortBy(t, ["y", "x"])) == null ? void 0 : r.map(({ i, x: o, y: a, w: s, h: l, field: { boxStyle: d, ...u } = {} }, p) => m("div", { className: "grid-layout-item", style: Hn(o, a, s, l, d), children: m(e, { ...u, basicForm: n }) }, i ?? p));
}, Hn = (t, e, n, r, i = {}, o = 0) => {
const a = { "--grid-layout-h": `${r}`, "--grid-layout-w": `${n}`, "--grid-layout-x": `${t}`, "--grid-layout-y": `${e}`, "--grid-layout-row-height-offset": "0px" };
return i != null && i.autoHeight ? a.height = "fit-content" : a["--grid-layout-row"] = `${r}`, i != null && i.alignItems && (a["--grid-layout-box-align-items"] = i.alignItems), i != null && i.justifyContent && (a["--grid-layout-box-justify-content"] = i.justifyContent), a["--grid-layout-box-margin"] = Pn(i == null ? void 0 : i.marginTop, i == null ? void 0 : i.marginRight, i == null ? void 0 : i.marginBottom, i == null ? void 0 : i.marginLeft), a["--grid-layout-box-padding"] = Pn(i == null ? void 0 : i.paddingTop, i == null ? void 0 : i.paddingRight, i == null ? void 0 : i.paddingBottom, i == null ? void 0 : i.paddingLeft), o && (a.height = `${o}px`), a;
}, Pn = (t, e, n, r) => `${t || 0}px ${e || 0}px ${n || 0}px ${r || 0}px`, Fo = (t = "Text", e = "@pkg/ff/grid-layouts") => t != null && t.startsWith("@") || t != null && t.startsWith("blob:") ? t : `${e}/${t}`, Yn = (t) => Object.keys(t).reduce((e, n) => (/^on[A-Z]/.test(n) && (e[n] = t[n]), e), {}), Gn = ({ className: t, isConditionFormLayout: e }) => {
var h, g;
const [n, r] = I({}), { listCode: i, onKeywordChange: o, onConditionChange: a, getBase62params: s, classNames: l } = E.useContext(ce), { keyword: d, condition: u } = (s == null ? void 0 : s()) || {}, [p] = wt.useForm();
return q(() => {
i && e && z.get(`/api/_/${i}/list-condition-form-layout`).then(({ resource: y, marginX: w, marginY: C, rowHeight: S, cols: x, fields: k }) => {
r({ resource: y, itemMargin: [w, C], rowHeight: S, cols: x, fields: k });
}).catch(() => r({}));
}, [i, e]), q(() => {
p.setFieldsValue({ keyword: d, ...u });
}, [JSON.stringify([d, u])]), m("div", { className: j("ff-data-list-filter", l.filter, t), children: m(wt, { form: p, layout: "vertical", autoComplete: "off", onFinish: ((h = n.fields) == null ? void 0 : h.length) > 1 ? (y) => a({ [n.resource]: y[n.resource] }, y.keyword) : () => {
}, onValuesChange: (y) => {
f.isEmpty(f.omit(y, ["keyword"])) || p.submit();
}, children: ((g = n.fields) == null ? void 0 : g.length) > 1 ? m(on, { ...n, children: m(pi, { onReset: () => {
const { keyword: y, condition: w } = s("init") || {};
p.setFieldsValue({ keyword: y, ...w });
} }) }) : m("div", { className: "ff-data-list-filter-default-form ff-grid-layout-form", children: m("div", { className: "grid-layout-item", style: Hn(20, 0, 5, 2), children: m(wt.Item, { name: ["keyword"], children: m(zr.Search, { allowClear: !0, enterButton: "搜索", placeholder: "多关键字 | 分割", onSearch: (y) => o(y) }) }) }) }) }) });
}, pi = ({ cols: t, fields: e, onReset: n }) => {
const [r, i] = I(!1), o = U(() => e == null ? void 0 : e.toReversed().some((a) => a.y > 1 || a.x + a.w >= t - 5), [t, e]);
return L(wt.Item, { label: " ", style: { "--item-span": 5 }, className: j("ff-data-list-filter-actions", { expanded: r }), children: [m(Ct, { onClick: n, children: "重置" }), m(Ct, { type: "primary", htmlType: "submit", children: "查询" }), o && m(R.Link, { className: "ff-data-list-filter-expanded-button", widget: () => i((a) => !a), type: "primary", name: r ? "关闭" : "展开", icon: r ? "icon-up" : "icon-down", iconPosition: "end" })] });
};
Gn.reservedFields = [{ x: 0, y: 0, h: 3, w: 5, field: { isVirtual: !0, widgetPrefix: "@pkg/ff/grid-layout-forms", widget: "Input", code: "keyword", label: "关键字", placeholder: "多关键字 | 分割", extras: { prefix: "icon-search" } } }];
const gi = ({ className: t, operations: e, isOperations: n, isPaginate: r }) => {
const { onPageChange: i, onPageSizeChange: o, onClickCallback: a, getBase62params: s } = E.useContext(ce), { total: l, page: d, pageSize: u } = (s == null ? void 0 : s()) || {};
return n && !f.isEmpty(e) || r ? L("div", { className: j("ff-data-list-footer", t), children: [m("div", { className: "ff-data-list-actions", children: e == null ? void 0 : e.map((p, h) => m(R, { uuid: p.uuid, type: p.type, name: p.name, widget: p.widget, widgetType: p.widgetType, widgetProps: p.widgetProps, widgetData: p.widgetData, widgetSetting: p.widgetSetting, widgetContainerProps: p.widgetContainerSetting, onAfterClick: (g) => g !== !1 && (a == null ? void 0 : a(p.isRefresh, null)) }, p.uuid || h)) }), r && m(Br, { size: "small", total: l, pageSize: u, showSizeChanger: !1, showTotal: (p) => `${d} 页 / 总共 ${p}`, onChange: i, onShowSizeChange: o })] }) : null;
}, hi = [{ title: "parent 1", key: "0-0", children: [{ title: "parent 1-0", key: "0-0-0", disabled: !0, children: [{ title: "leaf", key: "0-0-0-0", disableCheckbox: !0 }, { title: "leaf", key: "0-0-0-1" }] }, { title: "parent 1-1", key: "0-0-1", children: [{ title: m("span", { style: { color: "#1677ff" }, children: "sss" }), key: "0-0-1-0" }] }] }], mi = ({ className: t, width: e = 280, isTreeSider: n }) => {
const { classNames: r } = he(ce);
return n ? m(Wr.DirectoryTree, { className: j("ff-data-list-sider", r.sider, t), style: { "--sider-width": e }, showLine: !0, showIcon: !1, treeData: hi }) : null;
}, fi = ({ className: t, title: e, tabs: n }) => {
const { getBase62params: r, onTabChange: i, onReload: o, classNames: a } = he(ce), { tab: s } = (r == null ? void 0 : r()) || {}, [l, d] = _r((n == null ? void 0 : n[0].value) ?? (n == null ? void 0 : n[0].code), { value: s, onChange: i });
return L("div", { className: j("ff-data-list-toolbar", a.toolbar, t), children: [m("div", { className: "ff-data-list-title", children: e }), m(Ur, { className: "ff-data-list-tabs", itemRender: ({ label: u, code: p, value: h }) => m("span", { onClick: () => d(h ?? p), className: j("ff-data-list-tab", { active: (h ?? p) == l }), children: u }), items: n }), L("div", { className: "ff-data-list-actions", children: [m(R.Link, { icon: "icon-reload", widget: () => o() }), m(R.Link, { icon: "icon-setting" })] })] });
}, yi = ({ className: t, ...e }) => m(Bt, { className: j(t, "ff-data-list-empty"), image: Bt.PRESENTED_IMAGE_SIMPLE, ...e }), Xn = ({ isItemGridLayout: t, theme: e, themeProps: n, onClickCallback: r, onReload: i, listCode: o, total: a = 0, page: s = 0, onPageChange: l, pageSize: d = 30, onPageSizeChange: u, tab: p, onTabChange: h, keyword: g, onKeywordChange: y, condition: w, onConditionChange: C, sider: S, onSiderChange: x, layouts: k, classNames: $ = {}, payload: F = {}, dataSource: A = [], rowSelection: T, getSelectedRows: N, primaryKey: V, ...v }) => {
const [M, D] = I(), B = N ?? (() => A), X = H((W, de) => {
const Y = { tab: p, page: s, pageSize: d, keyword: g, sider: S, condition: w, total: a, payload: F };
return W && W != "init" ? f.get(Y, W, de) : Y;
}, [JSON.stringify(w), JSON.stringify(F), p, s, d, g, S, a]), se = U(() => {
let W = { sider: mi, filter: Gn, footer: gi, toolbar: fi, empty: yi };
k === !1 ? W = { sider: null, filter: null, footer: null, toolbar: null, empty: null } : f.isPlainObject(k) && (W = Object.assign({}, W, k));
for (const de in W) if (W[de]) {
if (Fr(W[de])) {
const Y = W[de];
W[de] = (Ft) => E.cloneElement(Y, Ft);
}
} else W[de] = () => m(E.Fragment, {});
return W;
}, [k]);
return q(() => {
e ? le.getWidgetComponent(e).then((W) => {
if (!W) throw `${e} not found`;
return W;
}).catch((W) => ({ default: () => `${W}` })).then((W) => D(E.createElement(W.default, { ...v, layouts: se, $setting: n }))) : D(m(t ? ci : ui, { ...v, layouts: se, $setting: n }));
}, [e, n]), m(ce.Provider, { value: { classNames: $, listCode: o, onClickCallback: r, onReload: i, getBase62params: X, onPageChange: l, onPageSizeChange: u, onTabChange: h, onSiderChange: x, onKeywordChange: y, onConditionChange: C, setPage: l, setPageSize: u, setTab: h, setSider: x, setKeyword: y, setCondition: C, getSelectedRows: B }, children: M && E.cloneElement(M, { dataSource: A, primaryKey: V, rowSelection: T, ...v }) });
};
Xn.propTypes = { classNames: b.exact({ sider: b.string, filter: b.string, footer: b.string, toolbar: b.string, container: b.string, content: b.string, item: b.string, empty: b.string }), layouts: b.oneOfType([b.exact({ sider: b.oneOfType([b.elementType, b.element]), filter: b.oneOfType([b.elementType, b.element]), footer: b.oneOfType([b.elementType, b.element]), toolbar: b.oneOfType([b.elementType, b.element]), empty: b.oneOfType([b.elementType, b.element]) }), b.bool]) };
var Fe, Pe, We, xt;
const we = class we {
constructor() {
P(this, Pe, null);
P(this, We, /* @__PURE__ */ new Map());
P(this, xt, () => {
if (c(this, Pe)) return c(this, Pe).port.postMessage({ command: "status", data: [] });
K(this, Pe, new SharedWorker(new URL("/ff-worker/res-ws.js", self.location))), c(this, Pe).port.onmessage = (e) => {
var n, r;
(n = e.data) != null && n.uuid ? c(this, We).forEach((i, o) => {
var a;
(i == "*" || (a = i == null ? void 0 : i.includes) != null && a.call(i, e.data.uuid)) && o(e.data);
}) : ((r = e.data) == null ? void 0 : r.readyState) == WebSocket.CLOSED && z.get("/api/user-api-token").then(({ token: i, expire_at: o }) => {
c(this, Pe).port.postMessage({ command: "initWs", data: [`ws${f.trimStart(z.appUrl, "http")}api/user-resource-status-ws?token=${i}`] });
});
}, c(this, Pe).port.postMessage({ command: "status", data: [] });
});
O(this, "subscribe", (e, n = []) => (n ? Array.isArray(n) && n.length == 0 ? n = "*" : Array.isArray(n) || (n = [n].flat()) : n = "*", c(this, We).set(e, n), c(this, We).size == 1 && c(this, xt).call(this), () => this.unsubscribe(e)));
O(this, "unsubscribe", (e) => c(this, We).delete(e));
if (c(we, Fe)) return c(we, Fe);
}
};
Fe = new WeakMap(), Pe = new WeakMap(), We = new WeakMap(), xt = new WeakMap(), P(we, Fe, null), O(we, "getInstance", () => (c(we, Fe) || K(we, Fe, new we()), c(we, Fe)));
let Kt = we;
const Qn = Kt.getInstance(), nn = E.forwardRef(({ listCode: t, base62params: e, className: n, theme: r, themeProps: i, layouts: o, classNames: a, onSelectionChange: s, defaultSelectedRowKeys: l, selectedRowKeys: d, onDataSourceChange: u }, p) => {
const [{ resource: h, primaryKey: g, batchOperations: y = [], itemOperations: w = [], columns: C = [], isConditionFormLayout: S = !1, isTreeSider: x, treeSiderConfig: k, theme: $, themeConfig: F, isItemGridLayout: A, itemGridLayout: { themeConfig: T, ...N } = {}, title: V, isPaginate: v, tabs: M, selectionType: D }, B] = I({ isItemGridLayout: !1, itemGridLayout: {} }), X = li(t, e), [{ dataSource: se, itemOperationsAccess: W, condition: de, tab: Y, keyword: Ft, page: cn, total: dn, pageSize: un, sider: gr, onConditionChange: hr, onTabChange: mr, onKeywordChange: fr, onPageChange: yr, onPageSizeChange: wr, onSiderChange: br, onReload: jt, payload: Cr }, pn] = si(X, t, g, h), kr = kn(u);
Mn(() => {
kr(se, { page: cn, pageSize: un, total: dn });
}, [se]);
const [gn, Sr] = Vr([], { defaultValue: l ?? [], value: d }), [hn, Er] = I([]), mn = H(() => D ? hn : se, [D, hn, se]), $r = qt(w, W, se, g), xr = qt(y);
q(() => {
let Q = null;
return t && z.get(`/api/_/${t}`).resp(({ data: Ve, res: At }) => {
Ve != null && Ve.isDynamicRefresh && (Q = Qn.subscribe(() => jt(), At)), B(Ve);
}).catch(() => B({})), () => Q == null ? void 0 : Q();
}, [t]), E.useImperativeHandle(p, () => ({ onReload: jt, onClickCallback: pn, getSelectedRows: mn }));
const fn = kn((Q, Ve) => {
Er((At) => {
const yn = new Map(At.map((ue) => [ue == null ? void 0 : ue[g], ue]));
return Ve.forEach((ue) => yn.set(ue == null ? void 0 : ue[g], ue)), Q.map((ue) => yn.get(ue)).filter(Boolean);
}), Sr(Q), s == null || s(Q, Ve);
}), Pr = U(() => D ? { type: D, columnWidth: 80, selectedRowKeys: gn, onChange: fn } : void 0, [D, gn, fn]), vr = U(() => f.merge({}, F, i), [F, i]), Nr = U(() => w == null ? void 0 : w.map((Q) => f.isEmpty(Q == null ? void 0 : Q.confirm) ? Q : { ...Q, confirm: Object.assign({}, Q.confirm, { getPopupContainer: () => document.body }) }), [w]), Tr = U(() => ({ ...N, themeProps: T }), [N, T]);
return m(Xn, { listCode: t, title: V, classNames: a, layouts: o, resource: h, primaryKey: g, theme: r || $, themeProps: vr, isTreeSider: x, treeSiderConfig: k, isPaginate: v, rowSelection: Pr, getSelectedRows: mn, tabs: M, isItemOperations: $r, itemOperations: Nr, isBatchOperations: xr, batchOperations: y, isItemGridLayout: A, columns: C, itemGridLayout: Tr, isConditionFormLayout: S, itemOperationsAccess: W, dataSource: se, onConditionChange: hr, onTabChange: mr, onKeywordChange: fr, onPageChange: yr, onPageSizeChange: wr, onSiderChange: br, condition: de, tab: Y, keyword: Ft, page: cn, total: dn, pageSize: un, sider: gr, payload: Cr, className: j("ff-data-list-helper", n), onReload: jt, onClickCallback: pn });
}), Zn = (t, e, n = !0) => n !== !0 && n-- <= 0 ? [] : f.isArray(t) && !f.isEmpty(t) ? t.reduce((r, i) => (Reflect.has(i, e) && Reflect.has(i, "children") && r.push(i[e]), Reflect.has(i, "children") && !f.isEmpty(i.children) ? r.concat(Zn(i.children, e, n)) : r), []) : [], wi = ({ className: t, primaryKey: e, columns: n = [], dataSource: r = [], operationRender: i, operationWidth: o = 180, components: a = {}, rowSelection: s, ...l }) => {
const { classNames: d } = he(ce), u = _(null), p = _(null), [h, g] = I([]), [y, w] = I({ width: 0, height: 0 });
q(() => {
g(Zn(r, e));
}, [r, e]), jr(() => {
const k = new ResizeObserver(() => {
var $;
w({ width: (($ = u.current) == null ? void 0 : $.nativeElement.querySelector(".ant-table-body").scrollWidth) || p.current.offsetWidth, height: p.current.offsetHeight });
});
return p.current && k.observe(p.current), () => {
p.current && k.unobserve(p.current);
};
}, []);
const C = U(() => {
if (!(y != null && y.width) || !(n != null && n.length)) return n;
const k = (s ? s.columnWidth ?? 32 : 0) + (i ? o : 0), $ = n.reduce((T, N) => T + (N != null && N.isWidthFixed && N.width ? N.width : 0), 0), F = n.filter((T) => !(T != null && T.isWidthFixed)).reduce((T, N) => T + ((N == null ? void 0 : N.width) ?? 100), 0);
if ($ + F + k >= y.width) return n;
const A = y.width - $ - k;
return n.map((T) => T != null && T.isWidthFixed ? T : { ...T, width: Math.floor(A * ((T == null ? void 0 : T.width) ?? 100) / F) });
}, [n, y.width, s, i, o]), S = oi(C), x = ai(a);
return m("div", { ref: p, className: j("ff-data-list-table", d.content, t), children: y.height ? m(Sn, { bordered: !0, ...l, components: x, ref: u, rowKey: (k) => (k == null ? void 0 : k[e]) ?? Math.random(), rowSelection: s, columns: (() => {
var $, F;
const k = [...S ?? []];
return s && k.splice((F = ($ = k[0]) == null ? void 0 : $.key) != null && F.startsWith("__") ? 1 : 0, 0, Sn.SELECTION_COLUMN), i && k.push({ title: "操作", align: "center", fixed: "right", width: `${Math.ceil(o / y.width * 100).toFixed(2)}%`, render: (A, T, N) => i(T, N) }), k;
})(), dataSource: r, size: "middle", scroll: { x: "max-content", y: y.height - 50 }, pagination: !1, expandable: { defaultExpandAllRows: !0, expandRowByClick: !0, onExpandedRowsChange: g, expandedRowKeys: h } }) : null });
}, bi = "RC_FORM_INTERNAL_HOOKS", Ci = (t) => {
const [e, n] = E.useState({ items: [] });
return q(() => {
t && z.get(`/api/_/${t}`).then(({ uuid: r, code: i, name: o, resource: a, primaryKey: s, marginX: l, marginY: d, cols: u, rowHeight: p, fields: h, theme: g, themeSetting: y, groups: w }) => ({ uuid: r, code: i, name: o, resource: a, primaryKey: s, marginX: l, marginY: d, cols: u, rowHeight: p, theme: g, themeProps: y, groups: w, items: h })).then(n);
}, [t]), e;
}, ki = (t, { initialValue: e, initialValueLanguage: n, convertJs: r, convertJsSetting: i, type: o = "string" }, a = null) => {
const s = _(!1), l = he(Ln), [d, u] = I(), [p, h] = I(n != "javascript" && t ? l.getFieldValue(t) : void 0), { registerWatch: g } = l.getInternalHooks(bi) || {};
return q(() => g == null ? void 0 : g((y, w, C) => {
if (!s.current) return;
const S = f.get(w, t);
f.isEqual(S, p) || h(ge(S, o));
}), [p]), q(() => {
n == "javascript" && e ? Me.exec(e, {}, { getFieldValueForBasicForm: (y) => a ? a.getFieldValue(y) : l.getFieldValue(y), getFieldValue: (y) => l.getFieldValue(y) }).then((y) => h(ge(y, o))).catch((y) => notification.error({ message: `布局数据错误: ${JSON.stringify(y)}` })).finally(() => s.current = !0) : (e && h(ge(e ?? l.getFieldValue(t), o)), s.current = !0);
}, [e, n]), mt(() => {
s.current && r && new kt([r, i]).toValue(p, l.getFieldsValue(!0)).then(u).catch((y) => {
u(y), console.error("布局数据转换错误: ", y, r);
});
}, [p, r, i]), [d ?? p, p];
}, jo = (t, e, n = null) => U(() => tn(t, e, n), [t]), er = (t, e, n = {}, r = {}, i = {}, o = null) => {
const a = he(Ln), s = Tt(), l = _(!0), d = _([]), [u, p] = I(e), [h, g] = I(), y = ae.useWatch((w) => JSON.stringify(f.pick(w, d.current)), a) || "{}";
return Ot(() => {
t && Me.exec(t, n, { ...r, getFieldValueForBasicForm: (w) => i ? i.getFieldValue(w) : null, getFieldValue: f.wrap(a.getFieldValue, (w, C) => (d.current.some((S) => f.isEqual(S, C)) || (d.current.push(C), s()), w == null ? void 0 : w(C))), isFieldTouched: a.isFieldTouched, isFieldsTouched: a.isFieldsTouched }).then((w) => {
l.current && (p(w), g(null));
}).catch((w) => {
l.current && (p(e), g(w));
});
}, [t, y, a, n, r]), q(() => () => l.current = !1, []), t ? [o ? ge(u, o) : u, h] : [o ? ge(e, o) : e, null];
}, Si = ({ widget: t, widgetPrefix: e = "@pkg/ff/grid-layouts", basicForm: n, ...r }) => {
const i = t != null && t.startsWith("@") || t != null && t.startsWith("blob:") ? t : `${e}/${t}`, [o, a] = I();
return q(() => {
i && le.getWidgetComponent(i).then(({ defaultProps: s = {}, default: l }) => ({ default: Ei(l, s, n) })).catch((s) => ({ default: () => `${s}` })).then((s) => a(E.createElement(s.default, r)));
}, [i]), o;
}, Ei = (t, e = {}, n = null) => (r) => {
const { code: i, label: o, extras: a, isVirtual: s, initialValue: l, initialValueLanguage: d, convertJs: u, convertJsSetting: p, value: h, ...g } = f.merge({}, e, r), [y, w] = ki(s ? null : i, { initialValue: l, initialValueLanguage: d, convertJs: u, convertJsSetting: p, type: (g == null ? void 0 : g.type) || "string" }, n), C = U(() => {
const k = Object.keys((e == null ? void 0 : e.extras) || {});
return f.over([f.partialRight(f.pick, k), f.partialRight(f.omit, k)]);
}, [e == null ? void 0 : e.extras]), [S, x] = C(g);
return m(t, { ...x, value: y, rawValue: w, $setting: Object.assign({}, a, S) });
}, tr = ({ theme: t, basicForm: e, items: n = [{ key: "default", label: "默认" }], fields: r = [], itemRender: i, chunks: o = [], children: a, $setting: s = {}, ...l }) => {
const [d, u] = I();
q(() => {
t ? le.getWidgetComponent(t).then((h) => {
if (!(h != null && h.default)) throw "not found";
return h;
}).catch((h) => ({ default: () => `${t} ${h}` })).then((h) => u(E.createElement(h.default, {}))) : u(null);
}, [t]);
const p = U(() => n == null ? void 0 : n.map((h) => ({ ...h, children: i(h, r == null ? void 0 : r.filter((g) => !(g != null && g.group) && h.key == "default" || g.group == h.key), h.key == "default" ? a : null) })).concat(o), [n, a, o]);
return d && E.cloneElement(d, { items: p, basicForm: e, $setting: { ...s, ...l } });
}, nr = ({ name: t, form: e = null, basicForm: n = null, style: r = {}, className: i, cols: o = 12, rowHeight: a = 21, containerPadding: s = [0, 0], itemMargin: l = [4, 0], formProps: d = {}, formFields: u = [], fields: p = [], data: h, theme: g, themeProps: y = {}, groups: w = [{ key: "default", label: "默认" }], children: C, ...S }) => {
const [x] = ae.useForm(e), k = U(() => [{ name: "__PROPS__", value: d }].concat(u), [d, u]);
mt(() => (x.setFieldsValue(h), () => x.resetFields()), [h]);
const $ = (F, A, T) => {
const N = tn(A, Si, n), V = Yn(S);
return L("div", { ...V, className: j("ff-grid-layout", i), style: { ...r, "--grid-layout-item-margin-y": `${(l == null ? void 0 : l[0]) || 0}px`, "--grid-layout-item-margin-x": `${(l == null ? void 0 : l[1]) || 0}px`, "--grid-layout-container-padding-y": `${(s == null ? void 0 : s[0]) || 0}px`, "--grid-layout-container-padding-x": `${(s == null ? void 0 : s[1]) || 0}px`, "--grid-layout-cols": o, "--grid-layout-row-height": `${a}px` }, children: [N, T && E.cloneElement(T, { cols: o, rowHeight: a, itemMargin: l, containerPadding: s, fields: A, basicForm: n })] });
};
return m(ae, { ...S, fields: k, form: x, component: !1, children: g ? m(tr, { ...y, items: w, theme: g, itemRender: $, fields: p, children: C, basicForm: n }) : $(0, p, C) });
}, Ao = /* @__PURE__ */ ((t) => function({ code: e, data: n, ...r }) {
const { uuid: i, resource: o, items: a, hides: s, rowHeight: l, marginX: d, marginY: u, cols: p, theme: h, themeProps: g, groups: y } = Ci(e) || {}, w = U(() => [{ name: "__RESOURCE__", value: o }, { name: "__LAYOUT_KEY__", value: e }, { name: "__LAYOUT_UUID__", value: i }], [e, i, o]);
return o && m(t, { name: e, theme: h, themeProps: g, groups: y, ...r, fields: a, formFields: w, rowHeight: l, cols: p, itemMargin: [d, u], data: o ? { [o]: n } : n });
})(nr), $i = ({ column: t = 0, colWidth: e = 0, cols: n, rowHeight: r, itemMargin: i, containerPadding: o, fields: a, primaryKey: s, dataSource: l, beforeRender: d = null, afterRender: u = null, itemClassName: p, itemRender: h = ($, F, A) => $, empty: g = m(Bt, { description: null }), className: y, style: w = {}, theme: C, themeProps: S = {}, groups: x = [{ key: "default", label: "默认" }], rowSelection: k }) => {
const { classNames: $ } = he(ce), F = H((N) => {
if (!k) return;
const { selectedRowKeys: V = [], onChange: v, type: M = "checkbox" } = k, D = N == null ? void 0 : N[s];
let B;
B = M === "radio" ? [D] : V.includes(D) ? V.filter((X) => X !== D) : [...V, D], v == null || v(B, l.filter((X) => B.includes(X == null ? void 0 : X[s])));
}, [k, s, l]), A = U(() => m(nr, { groups: x, theme: C, themeProps: S, cols: n, rowHeight: r, itemMargin: i, containerPadding: o, fields: a, className: p }), [a, n, r, i, o, x, C, S]), T = f.isEmpty(l);
return L("div", { className: j("ff-data-list-content", $.content, y), style: Object.assign({}, w, t && { "--col-num": t }, e && { "--col-width": e }), children: [d == null ? void 0 : d(l), T ? g : l.map((N, V) => {
var B;
const v = (N == null ? void 0 : N[s]) ?? V, M = `${v}-${Ti(N)}`, D = h(E.cloneElement(A, { data: N }), N, V);
return E.cloneElement(D, { key: M, ...k && { isSelected: (B = k == null ? void 0 : k.selectedRowKeys) == null ? void 0 : B.includes(v), onSelect: () => F(N) } });
}), u == null ? void 0 : u(l)] });
}, xi = ({ component: t, $props: e }) => {
const { base62params: n } = Nt(e, {});
return m(te, { children: m(nn, { listCode: t, base62params: z.decode(n) }) });
}, Io = () => m(rr, {}), rr = () => "Empty", Pi = ({ component: t, $setting: e, $props: n }) => {
const [r, i] = I(), [o, a] = lr(n);
return q(() => {
if (!t) return i(m(rr, { description: null }));
le.getWidgetComponent(t).catch((s) => ({ default: () => `${s}` })).then((s) => E.createElement(s.default, { $setting: e })).then(i);
}, [t]), r ? E.cloneElement(r, { ...o, $setProps: a }) : null;
}, Lo = () => "NotFoundPage";
var je, pe, Ae, ke, st, lt;
const be = class be {
constructor() {
P(this, pe, /* @__PURE__ */ new Map());
P(this, Ae, {});
P(this, ke, null);
O(this, "init", (e, n) => {
K(this, pe, e), K(this, Ae, n);
});
O(this, "get", (e) => (c(this, pe).has(e) || (e = Array.from(c(this, pe).keys()).find((n) => c(this, pe).get(n).uri === e)), c(this, pe).get(e) || {}));
O(this, "redirect", (e, n, r = {}) => {
var y;
const { uri: i, type: o, widgetProps: a } = this.get(e) || {}, { router: s, query: l, ...d } = n || {}, u = Object.assign({}, d, s), p = Object.assign({}, d, l);
o == "list" && (u.base62params = z.encode(u != null && u.base62params ? u.base62params : u));
let h = Hr(i || e, u);
const g = new URLSearchParams();
for (const w in a || {}) ((y = a[w]) == null ? void 0 : y.type) == "query" && Object.has(p, w) && g.append(w, JSON.stringify(p[w]));
return g.size > 0 && (h = `${h}?${g.toString()}`), r != null && r.isOpenWindow ? window.open(h) : c(this, ke).navigate(h, { replace: !!(r != null && r.isReplaceRouteHistory) });
});
O(this, "getMenus", (e) => {
var n;
return ((n = c(this, Ae)) == null ? void 0 : n[e]) || [];
});
O(this, "findMenuPathByUuid", (e) => {
let n = [];
for (const r in c(this, Ae)) if (n = c(this, st).call(this, c(this, Ae)[r], e, [r]), n.length > 1) return n;
return n;
});
O(this, "getMenusByRouteUuid", (e) => c(this, lt).call(this, e, Object.values(c(this, Ae)).flat()));
P(this, st, (e, n, r = []) => {
if (f.isEmpty(e)) return r;
for (const { uuid: i, children: o } of e) {
if (i == n) return r.concat(i);
if (!f.isEmpty(o)) return r.concat(i, c(this, st).call(this, o, n));
}
return r;
});
P(this, lt, (e, n) => {
var i;
let r = [];
for (const o of n) o.widgetType == "redirect" && (o.uuid == e || o.widget == e ? r.push(o) : (i = o.children) != null && i.length && (r = r.concat(c(this, lt).call(this, e, o.children))));
return r;
});
O(this, "getCurrentMenu", () => {
const { uuid: e } = this.getCurrentRoute() || {};
if (!e) return;
const n = this.getMenusByRouteUuid(e);
return f.isEmpty(n) ? void 0 : n[0];
});
O(this, "getCurrentRoute", (e = 0) => {
var r;
const n = (r = c(this, ke).state.matches[c(this, ke).state.matches.length - 1 - e]) == null ? void 0 : r.route;
if (!n) return null;
for (let [i, o] of c(this, pe)) if (o.uri === n.path) return o;
return null;
});
O(this, "getPageParams", (e) => {
var a, s;
const { location: n = {}, matches: r = [] } = ((a = c(this, ke)) == null ? void 0 : a.state) || {}, i = { ...((s = r[r.length - 1]) == null ? void 0 : s.params) || {} }, o = n.search;
return o && new URLSearchParams(o).forEach((l, d) => {
i[d] = l;
}), e ? f.get(i, e) : i;
});
O(this, "usePageParams", (e) => {
var r;
let n = zn() ? { ...Yr(), ...Object.fromEntries(new URLSearchParams(((r = Gr()) == null ? void 0 : r.search) ?? "")) } : this.getPageParams();
return e ? f.get(n, e) : n;
});
O(this, "createBrowserRouter", (e = {}) => {
if (c(this, pe).size == 0) return null;
if (c(this, ke)) return c(this, ke);
const n = qe.get("Common.WEBSITE_DEFAULT_THEME", "@pkg/ff/frameworks/DefaultTheme"), r = qe.get(le.checkUserToken() ? "Common.WEBSITE_LOGIN_REDIRECT" : "Common.WEBSITE_DEFAULT", "/index"), i = { [n]: 0 }, o = (s, l) => () => Promise.all([le.getWidgetComponent(s), Nt(l)]).then(([d, u]) => [d.default || function() {
return `${s}`;
}, u]).then(([d, u]) => ({ Component: () => E.createElement(Wn, {}, E.createElement(d, { $setting: u })) })), a = Array.from(c(this, pe).values()).reduce((s, { uuid: l, uri: d, name: u, type: p, component: h, widgetSetting: g, widgetProps: y, isLogin: w, isLayout: C, extra: S }) => {
let x = {}, k = 0;
switch (p) {
case "list":
x.element = E.createElement(xi, { component: h, $props: y });
break;
case "fsdpf-component":
x.element = E.createElement(Pi, { key: h, component: h, $setting: g, $props: y });
}
const $ = (S == null ? void 0 : S.theme) ?? (S == null ? void 0 : S.layout);
if ($) {
const F = (S == null ? void 0 : S.themeProps) ?? (S == null ? void 0 : S.layoutProps);
if (!i[$]) return i[$] = s.length, [...s, { path: "/", lazy: o($, F), children: [{ path: d, ...x }] }];
k = i[$];
}
return C && k > -1 ? (s[k].children.push({ path: d, ...x }), s) : [...s, { path: d, ...x }];
}, [{ path: "/", lazy: o(n, {}), children: [] }]);
return a.push({ index: !0, element: E.createElement(vi, { to: r, replace: !0 }) }), K(this, ke, Xr(a, e));
});
if (c(be, je)) return c(be, je);
}
};
je = new WeakMap(), pe = new WeakMap(), Ae = new WeakMap(), ke = new WeakMap(), st = new WeakMap(), lt = new WeakMap(), P(be, je, null), O(be, "getInstance", () => (c(be, je) || K(be, je, new be()), c(be, je)));
let Jt = be;
const vi = ({ to: t, replace: e }) => zn() ? E.createElement(Qr, { to: t, replace: e }) : (window.document.location = t, "redirect"), oe = Jt.getInstance(), Ke = new Worker(new URL("/ff-worker/index.js", self.location)), vn = { generateUUID: () => Fi(), getConfigure: (t) => qe.get(t), route: { redirect: (...t) => oe.redirect(...t), getPageParams: (...t) => oe.getPageParams(...t), getCurrentRoute: () => oe.getCurrentRoute() }, popup: { notification: (...t) => ie.notification(...t), success: (...t) => ie.success(...t), error: (...t) => ie.error(...t), form: (...t) => ie.form(...t), modal: (...t) => ie.modal(...t), confirm: (...t) => ie.confirm(...t) } };
var Pt, Ge, Ie;
const J = class J {
constructor() {
O(this, "exec", (e, n = {}, r = {}, i = "") => new Promise((o, a) => {
if (!/^(?!\s*(\/\/|\/\*|\*)).*?\S+/m.test(e)) return o();
const s = Cn(J, Pt)._++;
c(J, Ge).set(s, r), J.mQueue.set(s, [o, a]), Ke.postMessage({ id: s, session: i, category: "eval", method: e, args: n });
}));
O(this, "clear", (e) => Ke.postMessage({ session: e, category: "clear" }));
if (c(J, Ie)) return c(J, Ie);
Promise.resolve().then(() => ao).then((e) => {
vn.http = e.http;
}), Ke.addEventListener("message", ({ data: { id: e, task_id: n, method: r, args: i, category: o, data: a, error: s, session: l } }) => {
if (o === "eval" && J.mQueue.has(e)) s !== null ? J.mQueue.get(e)[1](s) : J.mQueue.get(e)[0](a), c(J, Ge).delete(e), J.mQueue.delete(e);
else if (o === "util") try {
const d = f.get(vn, r.split("/")) || f.get(c(J, Ge).get(n), r.split("/"));
if (!f.isFunction(d)) throw `${r} not found`;
Promise.resolve(Reflect.apply(d, void 0, i)).then((u) => {
Ke.postMessage({ id: e, task_id: n, category: o, method: r, args: i, session: l, data: u, error: null });
}).catch((u) => {
Ke.postMessage({ id: e, task_id: n, category: o, method: r, args: i, session: l, data: null, error: u });
});
} catch (d) {
Ke.postMessage({ id: e, task_id: n, category: o, method: r, args: i, session: l, data: null, error: d });
}
}, !1);
}
};
Pt = new WeakMap(), Ge = new WeakMap(), Ie = new WeakMap(), O(J, "mQueue", /* @__PURE__ */ new Map()), P(J, Pt, 0), P(J, Ge, /* @__PURE__ */ new Map()), P(J, Ie, null), O(J, "getInstance", () => (c(J, Ie) || K(J, Ie, new J()), c(J, Ie)));
let _t = J;
const Me = _t.getInstance(), Nn = { null2json: (t) => Object.create(), null2array: (t) => [], null2number: (t) => 0, null2bool: (t) => !1, null2string: (t) => "", null2integer: (t) => 0, null2float: (t) => 0, string2json: (t) => t ? JSON.parse(t) : "{}", string2array: (t) => t.substr(0, 1) === "[" && t.substr(-1) === "]" ? JSON.parse(t) : t.split(","), string2number: (t) => t == "" ? 0 : +t, string2integer: (t) => t == "" ? 0 : +t, string2float: (t) => t == "" ? 0 : +t, string2bool: (t) => {
switch (`${t}`.toLowerCase()) {
case "0":
case "false":
case "[]":
case "{}":
return !1;
}
return !!t;
}, string2string: (t) => t, json2json: (t) => t, json2array: (t) => t ? Object.values(t) : [], json2number: (t) => Object.keys(t).length, json2integer: (t) => Object.keys(t).length, json2float: (t) => Object.keys(t).length, json2bool: (t) => Object.keys(t).length > 0, json2string: (t) => t ? JSON.stringify(t) : "", array2json: (t) => ({ ...t }), array2array: (t) => t, array2number: (t) => t.length, array2integer: (t) => t.length, array2float: (t) => t.length, array2bool: (t) => t.length > 0, array2string: (t) => JSON.stringify(t), number2json: (t) => ({}), number2array: (t) => [t], number2number: (t) => t, number2integer: (t) => t, number2float: (t) => t, number2bool: (t) => !!t, number2string: (t) => t.toString(), boolean2json: (t) => ({}), boolean2array: (t) => [], boolean2number: (t) => +t, boolean2integer: (t) => +t, boolean2float: (t) => +t, boolean2bool: (t) => t, boolean2string: (t) => t ? "true" : "false" }, ge = (t, e) => {
let n = "string";
n = Array.isArray(t) ? "array" : typeof t, f.isObject(t) && (n = "json");
const r = `${n}2${e}`;
return Reflect.has(Nn, r) ? Nn[r](t) : t;
}, Ni = (t) => t === null ? "null" : Array.isArray(t) ? "array" : typeof t == "object" ? "json" : typeof t == "boolean" ? "bool" : typeof t == "string" ? "string" : typeof t == "number" ? Number.isInteger(t) ? "integer" : "float" : typeof t, Nt = (t = {}, e = {}, n = {}, r = "") => ir(t, (i, o) => o === "type" && i === "code") ? or(t, e, n, r) : ar(t, e, r), ir = (t, e = () => !1) => f.some(t, (n) => !!f.some(n, e) || (f.isEmpty(n) || !f.isPlainObject(n) && !f.isArray(n) ? void 0 : ir(n, e))), or = async (t = {}, e = {}, n = {}, r = "") => {
let i = /* @__PURE__ */ Object.create(null);
for (let o in t) {
let a;
if (Reflect.has(t[o], "type") && ["code", "field", "router", "query", "string"].includes(t[o].type)) {
const { type: s, value: l = "", default: d = r } = t[o];
switch (s) {
case "code":
try {
a = await Me.exec(l, e, n);
} catch (u) {
console.error("getWidgetPropsData", u);
}
break;
case "field":
a = f.get(e, l) ?? f.get(e, l.substring(l.indexOf(".") + 1));
break;
case "router":
case "query":
a = oe.getPageParams(l);
break;
case "string":
a = l;
}
a ?? (a = d);
} else a = await or(t[o], e, n, r);
f.set(i, o, a);
}
return i;
}, ar = (t = {}, e = {}, n = "") => Object.keys(t || {}).reduce((r, i) => {
if (f.isPlainObject(t[i])) {
let o;
if (Reflect.has(t[i], "type") && ["field", "router", "query", "string"].includes(t[i].type)) {
const { type: a, value: s = "", default: l = n } = t[i];
switch (a) {
case "field":
o = f.get(e, s) ?? f.get(e, s.substring(s.indexOf(".") + 1));
break;
case "router":
case "query":
o = oe.getPageParams(s);
break;
case "string":
o = s;
}
o ?? (o = l);
} else o = ar(t[i], e, n);
f.set(r, i, o);
}
return r;
}, {}), Lt = (t, e) => t && typeof t == "object" ? Array.isArray(t) ? t.map((n) => Lt(n, e)) : Object.keys(t).reduce((n, r) => (e[r] ? n[e[r]] = Lt(t[r], e) : n[r] = Lt(t[r], e), n), {}) : t, Mo = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
const e = 16 * Math.random() | 0;
return (t === "x" ? e : 3 & e | 8).toString(16);
}), Vo = (t) => {
var e, n;
return t ? (n = (e = t.match(/^@pkg(?:[^\/]*\/){3}(?<name>[^\/]+)/)) == null ? void 0 : e.groups) == null ? void 0 : n.name : "";
}, Do = (t) => {
var e, n;
return t ? (n = (e = t.match(/^@pkg(?:[^\/]*\/){2}(?<category>[^\/]+)/)) == null ? void 0 : e.groups) == null ? void 0 : n.category : "";
}, zo = (t) => {
var e, n;
return t ? (n = (e = t.match(/^@pkg(?:[^\/]*\/){1}(?<owner>[^\/]+)/)) == null ? void 0 : e.groups) == null ? void 0 : n.owner : "";
}, Ti = (t, e = 32, n = "auto") => {
const r = Ht(t), i = n === "auto" ? "x64" : n;
if (e === 32) return It.x86.hash32(r).toString();
if (e === 128) return i === "x64" ? It.x64.hash128(r) : It.x86.hash128(r);
throw new Error("bits 只能是 32 或 128");
}, Ht = (t) => t == null ? "null" : typeof t == "string" ? t : typeof t == "number" || typeof t == "boolean" ? String(t) : typeof t == "function" ? t.toString() : Array.isArray(t) ? "[" + t.map(Ht).join(",") + "]" : typeof t == "object" ? "{" + Object.keys(t).sort().map((e) => `${e}:${Ht(t[e])}`).join(",") + "}" : String(t), Oi = () => {
let t = 1;
const e = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new Map();
return (...r) => r.length === 0 ? "" : r.map((i) => {
return String((o = i) === null || typeof o != "object" && typeof o != "function" ? (n.has(o) || n.set(o, t++), n.get(o)) : (e.has(o) || e.set(o, t++), e.get(o)));
var o;
}).join("::");
}, Ri = (t) => {
if (!t || typeof t != "string" || t.startsWith("/") || t.startsWith("./") || t.startsWith("../")) return !1;
try {
let e = t.startsWith("//") ? `http:${t}` : t;
return e.includes("://") || e.startsWith("//") || (e = `http://${e}`), !!new URL(e).hostname;
} catch {
return !1;
}
}, Bo = (t, e = "") => {
if (!t || typeof t != "string" || Ri(t)) return t;
let n = e;
return !n && typeof window < "u" && window.location && (n = `${window.location.protocol}//${window.location.host}`), t.startsWith("/") ? n ? `${n}${t}` : t : n ? `${n}/${t}` : t;
}, Fi = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : typeof crypto < "u" && crypto.getRandomValues ? "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (t) => (+t ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +t / 4).toString(16)) : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
const e = 16 * Math.random() | 0;
return (t === "x" ? e : 3 & e | 8).toString(16);
}), Tt = () => {
const t = _(!0), [, e] = E.useReducer((n) => n + 1, 0);
return q(() => () => t.current = !1, []), () => t.current && e();
}, Wo = (t) => {
const [e, n] = I(t), r = _(null), i = H((o, a) => {
r.current = a, n(o);
}, []);
return q(() => {
r.current && (r.current(e), r.current = null);
}, [e]), [e, i];
}, mt = (t = (r) => {
}, e, n = f.isEqual) => {
const r = E.useRef();
n(e, r.current) || (r.current = f.cloneDeep(e)), E.useEffect(t, [r.current]);
}, Ot = mt, sr = (t, e = "string") => {
var n;
if (!Array.isArray(t)) return t;
for (let r = 0; r < t.length; r++) t[r].value = ge((n = t[r]) == null ? void 0 : n.value, e), t[r] && Reflect.has(t[r], "children") && (t[r].children = sr(t[r].children, e));
return t;
}, Uo = (t, e = "json", n = "string", r, i = null) => {
const [o] = ae.useForm(r), [a, s] = I([{ label: "无", value: "", disabled: !0 }]), l = _([]), d = ae.useWatch((u) => l.current.length === 0 ? null : f.pick(u, l.current), o) || null;
return q(() => {
Array.isArray(t) ? s(t) : e === "javascript" && t ? Me.exec(t, {}, { getFieldValue: (u) => (l.current.includes(u) || l.current.push(u), o.getFieldValue(u)), getFieldValueForBasicForm: (u) => (l.current.includes(u) || l.current.push(u), i ? i.getFieldValue(u) : o.getFieldValue(u)) }).then((u) => {
s(ge(u, "array"));
}).catch((u) => console.error("useOptions", u)) : t && s(ge(t, "array"));
}, [t, e, d]), sr(a, n);
}, qo = (t) => {
const [e, n] = I(), r = { type: "GET" };
if (typeof t == "string" ? r.url = t : f.isPlainObject(t) && Object.assign(r, t), !(r != null && r.url)) throw "url is required";
const i = (o) => z.request(r, !1).resp((a) => (console.log("useSubscribeRequest", o), n(a), a));
return mt(() => {
let o = null;
return i().then((a) => {
o = Qn.subscribe(f.throttle(i, 180, { leading: !1, trailing: !0 }), a.res);
}), () => o == null ? void 0 : o();
}, r), e;
}, ji = (t, e) => H((n) => {
const r = {};
for (const [i, o] of Object.entries(n)) {
const a = t == null ? void 0 : t[i];
if ((a == null ? void 0 : a.type) === "router" || (a == null ? void 0 : a.type) === "query") {
const s = oe.getCurrentRoute();
s != null && s.uuid && oe.redirect(s.uuid, { ...oe.getPageParams(), [a.type]: { [a.value || i]: o } }, { isReplaceRouteHistory: !0 });
} else r[i] = o;
}
Object.keys(r).length > 0 && e(r);
}, [t, e]), lr = (t, e = {}, n = {}, r = []) => {
const [i, o] = I({}), [a, s] = I({}), l = Vn(a), d = oe.usePageParams();
Zt(() => {
Promise.resolve(Nt(t, e, n)).then(s);
}, [t, e, d, ...r]), Mn(() => {
const h = l ?? {}, g = Object.keys({ ...h, ...a }).reduce((y, w) => (h[w] !== a[w] && (y[w] = a[w]), y), {});
Object.keys(g).length > 0 && o((y) => ({ ...y, ...g }));
}, [a]);
const u = ji(t, (h) => {
o((g) => ({ ...g, ...h }));
}), p = U(() => Object.fromEntries(Object.entries(i).filter(([h, g]) => g !== a[h])), [i, a]);
return [i, u, p];
}, Ai = (t) => {
const [e, n] = E.useState({ items: [], hides: [] });
return E.useEffect(() => {
t && z.get(`/api/_/${t}`).then(({ pk: r, uuid: i, code: o, resource: a, align: s, cols: l, rowHeight: d, marginX: u, marginY: p, listenChangeFields: h, listenChangeFieldsFunc: g, fields: y, theme: w, themeSetting: C, groups: S }) => ({ pk: r, uuid: i, code: o, resource: a, align: s, cols: l, rowHeight: d, marginX: u, marginY: p, theme: w, themeProps: C, groups: S, listenChangeFields: h, listenChangeFieldsFunc: g, ...y.reduce((x, k) => {
var $;
return ($ = k == null ? void 0 : k.field) != null && $.hidden ? x.hides.push(k == null ? void 0 : k.field) : x.items.push(k), x;
}, { items: [], hides: [] }) })).then(n);
}, [t]), e;
}, Ii = ({ max: t = 0, min: e = 0, type: n = "", message: r, pattern: i, required: o = !1, validator: a } = {}, s, l) => {
const [d, u] = I([]);
return q(() => {
const p = [];
if (o) {
let h = l;
switch (l) {
case "number":
case "string":
case "array":
break;
case "bool":
h = "boolean";
break;
case "json":
h = "object";
}
p.push({ type: h, required: !0, whitespace: !0, message: "该项必填" });
}
switch (n) {
case "string":
p.push({ type: n, max: t, min: e, message: r || (e && t ? `字符必须在 ${e} ~ ${t} 之间` : `${t ? "最多能有" : "最少要有"} ${e || t} 个字符`) });
break;
case "pattern":
p.push({ type: "string", pattern: i, message: r });
break;
case "validator":
a && p.push(({ getFieldValue: h }) => ({ validator: async (g, y) => {
const w = await Me.exec(a, { value: y, fieldName: s }, { getFieldValue: h });
return f.isString(w) && w ? Promise.reject(w) : f.isBoolean(w) && !w ? Promise.reject(r) : Promise.resolve();
} }));
}
u(p);
}, [t, e, n, r, i, o, a]), d;
}, Li = (t, e, n) => {
const [r, i] = I(null);
return q(() => {
const { initDataUri: o = `/api/${t}`, initDataMethod: a = "GET" } = n || {};
e && z.request({ method: a, url: f.trimEnd(`${o}/${e}`, "/") }).then((s) => {
i(s);
});
}, [t, e, n]), r;
}, Mi = (t, e, n) => H((r, i = { serialize: (o) => o, onSuccess: () => {
}, onFail: (o) => (o == null ? void 0 : o.errorFields) && ie.error("请先完善表单信息", { duration: 2e3 }) }) => {
const o = r.getFieldValue("__RESOURCE__"), { submitDataUri: a = `/api/${t}`, submitDataMethod: s = "POST" } = n || {};
return r.validateFields().then((l) => o ? f.pick(l, [o]) : l).then(i.serialize).then((l) => z.request({ method: s, url: f.trimEnd(`${a}/${e || ""}`, "/"), data: l }).msg(i.onSuccess)).catch(i.onFail);
}, [t, e, n]), Vi = (t, e, n, r) => {
const i = Li(e, n, r);
q(() => {
i ? t.setFieldsValue(i) : t.resetFields();
}, [t, i]);
const o = Mi(e, n, r);
return f.partial(o, t);
}, Di = (t, e, n = [], r = {}) => {
const i = _({}), o = _(), a = f.debounce(Tt(), 180), s = ["disabled", "required"], l = (h, g) => {
s.includes(h) && (i.current[h] = g), a();
}, d = U(() => ({ setDisabled: (h) => l("disabled", h), setRequired: (h) => l("required", h), getDisabled: () => i.current.disabled, getRequired: () => i.current.required }), [e]), [u, p] = er(e, -1, {}, d, r);
if (!p && o.current != u && (u >= 0 || !f.isEmpty(n == null ? void 0 : n[u]))) {
o.current = u;
const { widget: h, widgetPrefix: g, props: y } = n == null ? void 0 : n[u];
t = Kn(h, g), i.current = f.merge(y, f.pick(i.current, s));
}
return [t, i.current];
}, Tn = (t) => t === void 0 || t === !1 ? "" : (Array.isArray(t) ? t : [t]).join("_"), Ko = ({ value: t, onChange: e }, n = null) => {
const r = _(), [i] = ae.useForm(n), o = _({});
return Ot(() => {
f.isEqual(r.current, t) || i.setFieldsValue(t);
}, [t]), q(() => () => i.resetFields(), []), [U(() => i.__INTERNAL__ ? i : { ...i, __INTERNAL__: { itemRef: (a) => (s) => {
const l = Tn(a);
s ? o.current[l] = s : delete o.current[l];
} }, scrollToField: (a, s = {}) => {
console.warn("useMergedFormValuesChange scrollToField not work, unreferenced antd form");
}, focusField: (a) => {
console.warn("useMergedFormValuesChange focusField not work, unreferenced antd form");
}, getFieldInstance: (a) => {
const s = Tn(a);
return o.current[s];
} }, [i]), (a, s) => {
r.current = s, e == null || e(s);
}];
}, rn = ({ widget: t = "Input", widgetPrefix: e = "@pkg/ff/grid-layout-forms", widgetDecorator: n, subWidgets: r = [], basicForm: i, ...o }) => {
const a = Kn(t, e), [s, l] = Di(a, n, r, i), [d, u] = I();
return q(() => {
s && le.getWidgetComponent(s).then(({ defaultProps: p = {}, default: h }) => ({ default: zi(h, p, i) })).catch((p) => ({ default: () => `${p}` })).then((p) => u(E.createElement(p.default, o)));
}, [s]), d && E.cloneElement(d, { ...o, ...l });
}, zi = (t, e = {}, n = null) => (r) => {
const { type: i, code: o, label: a, noStyle: s, style: l, placeholder: d, required: u = !1, extras: p, validators: h, help: g, isVirtual: y, $isReserved: w, initialValue: C, initialValueLanguage: S, ...x } = f.omit(f.merge({}, e, r), ["convertJs", "convertJsSetting", "widget", "widgetPerfix", "widgetDecorator", "subWidgets", "boxStyle"]), k = Ii(Object.assign({}, h, u ? { required: !0 } : {}), o, i), $ = U(() => {
const V = Object.keys((e == null ? void 0 : e.extras) || {});
return f.over([f.partialRight(f.pick, V), f.partialRight(f.omit, V)]);
}, [e == null ? void 0 : e.extras]), [F, A] = $(x), T = { label: a, noStyle: s, style: l, colon: !1, layout: "vertical" }, N = H((V) => V == null ? void 0 : ge(V, i), [i]);
return m(Qt, { name: o, rules: k, initialValue: N(C), normalize: N, children: (V, v, M) => {
var D;
return m(t, { type: i, rcform: M, basicForm: n, itemProps: { validateStatus: v.errors.length > 0 ? "error" : "success", tooltip: g || null, help: v.errors.length > 0 ? v.errors.join("、") : null, required: ((D = k == null ? void 0 : k[0]) == null ? void 0 : D.required) || !1, ...T }, fieldProps: { placeholder: d, ...A, ...V }, $setting: Object.assign({}, p, F) });
} });
}, on = ({ name: t, form: e = null, basicForm: n = null, style: r = {}, className: i, cols: o = 24, rowHeight: a = 16, itemMargin: s = [8, 16], containerPadding: l = [0, 0], fields: d = [], hides: u = [], primaryKey: p = 0, formProps: h = {}, formFields: g = [], listenChangeFields: y, listenChangeFieldsFunc: w, onValuesChange: C, theme: S, themeProps: x = {}, groups: k = [{ key: "default", label: "默认" }], children: $, ...F }) => {
const [A] = ae.useForm(e), T = H((v, M) => {
C == null || C(v, M), w && Array.isArray(y) && Me.exec(w, { changedValues: v, allValues: M }, { getFieldValue: A.getFieldValue, setFieldValue: A.setFieldValue, setFieldsValue: A.setFieldsValue, isFieldTouched: A.isFieldTouched, isFieldsTouched: A.isFieldsTouched }).catch((D) => console.error("onFormValuesChange", t, D));
}, [t, A, C, y, w]), N = U(() => [{ name: "__PROPS__", value: h }, { name: "__PRIMARY_KEY__", value: p }].concat(g), [p, h, g]), V = (v, M, D) => {
const B = tn(M, rn, n), X = Yn(F);
return L("div", { ...X, className: j("ff-grid-layout-form", i), style: { ...r, "--grid-layout-item-margin-x": `${(s == null ? void 0 : s[0]) ?? 8}px`, "--grid-layout-item-margin-y": `${(s == null ? void 0 : s[1]) ?? 16}px`, "--grid-layout-container-padding-y": `${(l == null ? void 0 : l[0]) || 0}px`, "--grid-layout-container-padding-x": `${(l == null ? void 0 : l[1]) || 0}px`, "--grid-layout-cols": o, "--grid-layout-row-height": `${a}px` }, children: [B, D && E.cloneElement(D, { cols: o, rowHeight: a, itemMargin: s, containerPadding: l, fields: M, basicForm: n })] });
};
return L(ae, { ...F, form: A, fields: N, onValuesChange: T, children: [S ? m(tr, { ...x, items: k, theme: S, itemRender: V, fields: d, children: $, basicForm: n }) : V(0, d, $), u == null ? void 0 : u.map((v) => {
var M;
return m(Qt, { name: v.code, children: m(Bi, { form: A, basicForm: n, name: v.code, type: v.type, initialValue: v.initialValue, initialValueLanguage: (M = v.extras) == null ? void 0 : M.initialValueLanguage }) }, JSON.stringify(v.code));
})] });
}, Bi = ({ type: t, initialValue: e, initialValueLanguage: n, onChange: r, basicForm: i }) => {
const [o, a] = er(n == "javascript" && e, n == "javascript" ? void 0 : e, {}, {}, i);
return q(() => {
n == "javascript" ? r(ge(o, t)) : e && r(ge(e, t));
}, [t, e, o]), null;
};
on.propTypes = { fields: b.array, hides: b.array };
const Wi = /* @__PURE__ */ ((t) => ({ code: e, isPreview: n = !1, ...r }) => {
const { align: i, autoComplete: o, resource: a, items: s, hides: l, rowHeight: d, marginX: u, marginY: p, cols: h, listenChangeFields: g, listenChangeFieldsFunc: y, pk: w, uuid: C, theme: S, themeProps: x, groups: k } = Ai(e), $ = U(() => [{ name: "__PK__", value: w }, { name: "__RESOURCE__", value: a }, { name: "__LAYOUT_KEY__", value: e }, { name: "__LAYOUT_UUID__", value: C }], [w, e, C, a]);
return m(t, { name: e, autoComplete: o, theme: S, themeProps: x, groups: k, ...r, formFields: $, listenChangeFields: g, listenChangeFieldsFunc: y, fields: s, hides: l, cols: h, rowHeight: d, itemMargin: [u, p] });
})(on), cr = ({ $setting: t, $close: e, extras: n, code: r, primaryKey: i, ...o }) => {
const [a] = ae.useForm(), s = Vi(a, r, i, t);
return m(te, { actions: L(E.Fragment, { children: [m(R, { name: (t == null ? void 0 : t.okText) || "保存", type: "primary", widget: () => s({ onSuccess: e }) }), m(R, { name: (t == null ? void 0 : t.cancelText) || "取消", widget: () => e(!1) })] }), extras: n, children: m(Wi, { form: a, code: r, primaryKey: i, ...o }) });
}, On = /* @__PURE__ */ new Set(), Yt = (t = [], e = 0) => {
const n = t[e];
if (n.length && !On.has(n)) {
const r = document.createElement("script");
r.setAttribute("src", n), r.setAttribute("data-namespace", n), t.length > e + 1 && (r.onload = () => {
Yt(t, e + 1);
}, r.onerror = () => {
Yt(t, e + 1);
}), On.add(n), document.body.appendChild(r);
}
}, St = ({ className: t, type: e, style: n = {}, ...r }) => m("span", { role: "img", className: j("ff-iconfont", t), style: n, ...r, children: m("svg", { style: { width: "1em", height: "1em", fill: "currentColor", overflow: "hidden" }, viewBox: "0 0 1024 1024", children: m("use", { xlinkHref: `#${e}` }) }) });
St.propTypes = { className: b.string, type: b.string.isRequired, style: b.object }, St.init = Yt;
const Ui = (t, e, n, r) => oe.redirect(n, e, r), qi = (t, e = {}, n, r = {}) => {
var o;
const i = (o = r.router) == null ? void 0 : o.reduce((a, [s, l, d]) => {
const u = f.get(e, ["router", s]);
if (!u && u !== 0 && l) throw `请传入 ${d}`;
return `${a}/${u}`;
}, `/api/${n}`);
return z.del(i, e.param).msg();
}, Rn = (t, e, n, { status: { loading: r, disabled: i }, setStatus: o, listFn: a }) => {
const s = { loading: (l) => l === void 0 ? r : o((d) => ({ ...d, loading: l })), disabled: (l) => l === void 0 ? i : o((d) => ({ ...d, disabled: l })), list: a };
return f.isFunction(n) ? n.call(null, e, s) : f.isString(n) && n ? Me.exec(n, e, s) : null;
}, Fn = (t, e, n, r, i) => f.isString(n) && n ? le.getWidgetComponent(n).then(({ default: o }) => ie.modal(o, { ...e, $setting: r }, i != null && i.title ? { ...i, title: f.template(i.title)(t) } : i)).catch((o) => {
ie.error(n, { content: o.toString() });
}) : ie.modal(n, { ...e, $setting: r }, i != null && i.title ? { ...i, title: f.template(i.title)(t) } : i), Ki = (t, e, n, r, i) => ie.modal(cr, { ...e, $setting: r, code: n }, i != null && i.title ? { ...i, title: f.template(i.title)(t) } : i), Ji = (t, e, n, r, i) => ie.modal(nn, { base62params: e, $setting: r, listCode: n }, i != null && i.title ? { ...i, title: f.template(i.title)(t) } : i), _i = ({ widget: t, widgetType: e, widgetData: n, widgetProps: r, widgetSetting: i, widgetContainerProps: o }, { onAfterClick: a, onBeforeClick: s } = {}) => {
const l = he(ce), [d, u] = I({ leading: !0, trailing: !1 }), p = U(() => {
switch (e) {
case "redirect":
return f.partialRight(Ui, t, i);
case "func":
return f.partialRight(Rn, (i == null ? void 0 : i.code) ?? t, { status: d, setStatus: u, listFn: l });
case "component":
case "fsdpf-component":
return f.partialRight(Fn, t, i, o);
case "grid-layout-form":
return f.partialRight(Ki, t, i, o);
case "data-list":
return f.partialRight(Ji, t, i, o);
case "destroy":
return f.partialRight(qi, t, i, o);
default:
if (sn(t) || E.isValidElement(t)) return f.partialRight(Fn, t, i, o);
if (f.isFunction(t)) return f.partialRight(Rn, (i == null ? void 0 : i.code) || t, { status: d, setStatus: u });
}
return (...h) => console.error("useButton unknown widgetType", e, ...h);
}, [t, e, l.getBase62params, l.getSelectedRows]);
return [f.debounce((h) => (s == null || s(h), Promise.resolve(Nt(r, h, { list: l })).then((g) => p(h, { ...n, ...g })).then((g) => a == null ? void 0 : a(g)).catch(console.error)), 300, { leading: !0, trailing: !1 }), d];
}, dr = ({ type: t, name: e, className: n, icon: r, iconPosition: i, size: o }, a = "default") => U(() => {
const s = { type: "primary", className: j("ff-button", n), iconPosition: i, size: o };
return t === "danger" ? s.danger = !0 : t === "default" && (s.type = t), a === "link" || a === "dashed" ? (s.type = a, t === "default" && (s.className = j(s.className, "ff-default"))) : a !== "circle" && a !== "round" || (s.shape = a), r && (s.icon = m(St, { type: r })), e && (s.children = e), s;
}, [a, t, n, r, i]), Rt = ({ data: t, widget: e, widgetType: n = "fsdpf-component", widgetData: r, widgetProps: i, widgetSetting: o, widgetContainerProps: a, onAfterClick: s, onBeforeClick: l, children: d, extras: u }) => {
const p = he(ce), [h, g] = I(!1), [y, w] = I("hover"), [C, S] = lr(i, t, { list: p }, [p.getBase62params, p.getSelectedRows]), [x, k] = I(), { placement: $, align: F, zIndex: A, arrow: T = { pointAtCenter: !0 }, getPopupContainer: N, isPopupMountBodyContainer: V = !0, ...v } = a || {};
q(() => {
n == "grid-layout-form" ? k(E.createElement(cr, { ...r, $setting: o, code: e })) : n == "data-list" ? k(E.createElement(nn, { base62params: t, $setting: o, listCode: e })) : f.isString(e) ? le.getWidgetComponent(e).then(({ default: B }) => {
k(E.createElement(B, { ...r, $setting: o }));
}).catch((B) => k(B.toString())) : E.isValidElement(e) ? k(E.cloneElement(e, { ...r, $setting: o })) : (sn(e) || f.isFunction(e) && ["component", "fsdpf-component"].includes(n)) && k(E.createElement(e, { ...r, $setting: o }));
}, [e, n, r]);
const M = (B, X = !1) => (g(B), !B && w("hover"), B ? l == null ? void 0 : l(C) : s == null ? void 0 : s(X)), D = (B) => {
g(!0), w("click");
};
return m(qr, { zIndex: A, placement: $, onPopupClick: D, onClick: D, open: h, align: F, arrow: T, trigger: y, getPopupContainer: N || V ? void 0 : (B) => B, content: m(Hi, { ...v, extras: u, children: x && E.cloneElement(x, { ...C, $setProps: S, $close: (B) => M(!1, B) }) }), children: d, onOpenChange: M });
}, Hi = ({ title: t, className: e, classNames: n, children: r, extras: i, width: o, height: a, ...s }) => {
const [l, d] = I({}), u = H((y, w) => d((C) => ({ ...C, [y]: w })), []), p = H((y) => d((w) => ({ ...w, [y]: void 0 })), []), h = t ? E.createElement("div", { className: "ff-popup-title" }, t) : l == null ? void 0 : l.title, g = i ?? E.createElement("div", { className: "ff-popup-reserved-extras" }, i);
return m(ht.Provider, { value: { ele: l, mount: u, unmount: p }, children: L("div", { className: j("ff-popup ff-popover", e, l.rootClassName), style: { width: o ?? 260, height: a }, ...s, children: [L("div", { className: j("ff-popup-header", "ff-popover-header", n == null ? void 0 : n.header), children: [h, l == null ? void 0 : l["sub-title"]] }), m("div", { className: j("ff-popup-body", "ff-popover-body", n == null ? void 0 : n.body), children: r }), L("div", { className: j("ff-popup-footer", "ff-popover-footer", n == null ? void 0 : n.footer), children: [g, l == null ? void 0 : l.extras, l == null ? void 0 : l.actions] })] }) });
};
Rt.propTypes = { widgetType: b.oneOf(["fsdpf-component", "grid-layout-form", "data-list"]) };
const ft = (t) => function({ className: e, variant: n, children: r, name: i, icon: o, type: a = "default", iconPosition: s = "start", noAuthType: l, onAfterClick: d, onBeforeClick: u, data: p, loading: h, disabled: g, tooltip: y, confirm: w, widget: C = () => {
}, widgetType: S, widgetData: x, widgetProps: k, widgetSetting: $, widgetContainerProps: F, ...A }) {
const { mode: T, ...N } = F || {}, V = dr({ className: e, name: i, type: a, icon: o, iconPosition: s }, n ?? t), v = m(Ct, { ...V, ...A, children: r || i });
if (T === "popover" && !["destroy", "redirect", "func"].includes(S)) return m(Rt, { data: p, widget: C, widgetType: S, widgetData: x, widgetProps: k, widgetSetting: $, widgetContainerProps: N, onAfterClick: d, onBeforeClick: u, children: v });
const M = f.isEmpty(y) || !y.enabled ? {} : y, D = f.isEmpty(w) ? { enabled: !1 } : Object.assign({ enabled: !0 }, w), [B, X] = I(!1), [se, { disabled: W, loading: de }] = _i({ widget: C, widgetType: S, widgetData: x, widgetProps: k, widgetSetting: $, widgetContainerProps: N }, { onAfterClick: d, onBeforeClick: u });
return m(Kr, { okText: "确定", cancelText: "取消", getPopupContainer: (Y) => Y, ...D, disabled: W || g, open: B, onOpenChange: (Y) => {
if (!Y) return X(Y);
D.enabled ? X(Y) : se(p);
}, onConfirm: (Y) => {
se(p, Y);
}, onClick: (Y) => {
Y.stopPropagation();
}, children: m(Jr, { getPopupContainer: (Y) => Y, ...M, title: B ? null : M == null ? void 0 : M.title, trigger: ["hover", "click"], children: E.cloneElement(v, { loading: de || h, disabled: W || g }) }) });
}, R = ft("default");
R.propTypes = { type: b.oneOf(["primary", "default", "danger", ""]), size: b.oneOf(["large", "middle", "small"]), name: b.string, icon: b.string, iconPosition: b.oneOf(["start", "end"]), data: b.any, widget: b.any, widgetType: b.oneOf(["destroy", "redirect", "func", "component", "fsdpf-component", "grid-layout-form", "grid-layout", "data-list"]), widgetData: b.object, widgetProps: b.object, widgetSetting: b.object, widgetContainerProps: b.object, tooltip: b.exact({ title: b.string.isRequired, placement: b.oneOf(["top", "left", "right", "bottom", "topLeft", "topRight", "bottomLeft", "bottomRight", "leftTop", "leftBottom", "rightTop", "rightBottom"]), enabled: b.oneOfType([b.bool, b.number]), getPopupContainer: b.func }), confirm: b.exact({ title: b.string.isRequired, cancelText: b.string, okText: b.string, okType: b.oneOf(["primary", "default", "danger", ""]), placement: b.oneOf(["top", "left", "right", "bottom", "topLeft", "topRight", "bottomLeft", "bottomRight", "leftTop", "leftBottom", "rightTop", "rightBottom"]), enabled: b.oneOfType([b.bool, b.number]), getPopupContainer: b.func, arrow: b.oneOfType([b.bool, b.exact({ pointAtCenter: b.bool })]) }) };
const Yi = ft("link"), Gi = ft("circle"), Xi = ft("round"), Qi = ft("dashed"), jn = ({ options: t = [], triggerWeights: e = ["grid-layout-form", "grid-layout", "fsdpf-component", "print"], onAfterClick: n = (g, y, w) => {
}, onBeforeClick: r = (g, y, w) => {
}, labelVariant: i = "link", labelSize: o, labelRender: a, btnVariant: s, btnSize: l, btnRender: d = (g, y) => m(R, { ...g, data: y }, g.uuid || Dt()), widgetContainerProps: u = {}, children: p, data: h }) => {
if (f.isEmpty(t)) return p;
const [g, y] = U(() => (t || []).reduce((C, S) => {
const x = e.indexOf(S.widgetType);
return x === -1 ? C[1].push(S) : C[0] ? x < e.indexOf(C[0].widgetType) ? (C[1].push(C[0]), C[0] = S) : C[1].push(S) : C[0] = S, C;
}, [null, []]), [t, e]);
a ? p = a(g, h) || p : p || (p = m(Ct, { ...dr(Object.assign(g != null && g.name || g != null && g.icon ? {} : { icon: "icon-location" }, g, { size: o }), i) }));
const w = y.map((C) => d(Object.assign({ uuid: C.uuid, type: C.type, name: C.name, widget: C.widget, widgetType: C.widgetType, widgetProps: C.widgetProps, widgetData: C.widgetData, widgetSetting: C.widgetSetting, widgetContainerProps: C.widgetContainerSetting, confirm: C.confirm, onAfterClick: f.partialRight(n, C, h), onBeforeClick: f.partialRight(r, C, h) }, { size: l, variant: s }), h));
return m(Rt, { widget: g == null ? void 0 : g.widget, widgetType: g == null ? void 0 : g.widgetType, widgetProps: g == null ? void 0 : g.widgetProps, widgetSetting: g == null ? void 0 : g.widgetSetting, widgetContainerProps: Object.assign({}, u, g == null ? void 0 : g.widgetContainerProps), data: h, widgetData: g == null ? void 0 : g.widgetData, extras: w, onAfterClick: f.partialRight(n, g, h), onBeforeClick: f.partialRight(r, g, h), children: p });
};
jn.propTypes = { triggerWeights: b.array, options: b.arrayOf(b.shape({ ...R.propTypes, widgetType: R.propTypes.widgetType.isRequired })), btnSize: R.propTypes.size, btnRender: b.func, btnVariant: b.oneOf(["", "default", "link", "circle", "round", "dashed"]), labelVariant: b.oneOf(["", "default", "link", "circle", "round", "dashed"]), labelRender: b.func, labelSize: R.propTypes.size, onAfterClick: b.func, onBeforeClick: b.func, widgetContainerProps: R.propTypes.widgetContainerProps, data: R.propTypes.data }, R.Link = Yi, R.Link.defaultProps = R.defaultProps, R.Link.propTypes = R.propTypes, R.Circle = Gi, R.Circle.defaultProps = R.defaultProps, R.Circle.propTypes = R.propTypes, R.Round = Xi, R.Round.defaultProps = R.defaultProps, R.Round.propTypes = R.propTypes, R.Dashed = Qi, R.Dashed.defaultProps = R.defaultProps, R.Dashed.propTypes = R.propTypes, R.Popover = Rt, R.GroupPopover = jn;
const Zi = ({ fields: t, formProps: e, $close: n }) => {
const [r] = ae.useForm(), i = U(() => [{ name: "__PROPS__", value: e }], [e]);
return m(te, { actions: L(E.Fragment, { children: [m(R, { name: "取消", widget: () => n(!1) }), m(R, { name: "确定", type: "primary", widget: () => r.validateFields(!0).then(n) })] }), children: m(ae, { fields: i, form: r, className: "ff-modal-form", children: t == null ? void 0 : t.map(({ code: o, ...a }) => m(rn, { code: o, ...a }, o)) }) });
}, eo = ({ className: t, classNames: e, $close: n, children: r, title: i, subTitle: o, actions: a, extras: s, ...l }) => L(Zr, { ...l, prefixCls: "ff-drawer", className: j("ff-popup", t), maskMotion: { motionAppear: !0, motionName: "mask-motion" }, motion: (d) => ({ motionAppear: !0, motionName: `panel-motion-${d}` }), children: [L("div", { className: j("ff-popup-header", "ff-drawer-header", e == null ? void 0 : e.header), children: [m("button", { "aria-label": "Close", className: j("ff-popup-close", "ff-drawer-close", e == null ? void 0 : e.close), onClick: l.onClose, children: m(en, { type: "close" }) }), i, o] }), m("div", { className: j("ff-popup-body", "ff-drawer-body", e == null ? void 0 : e.body), children: r }), L("div", { className: j("ff-popup-footer", "ff-drawer-footer", e == null ? void 0 : e.footer), children: [s, a] })] }), to = ({ className: t, classNames: e, $close: n, $event: r, children: i, title: o, subTitle: a, actions: s, extras: l, placement: d, ...u }) => {
const p = (r == null ? void 0 : r.pageX) === void 0 ? { animation: null, maskAnimation: null, mousePosition: { x: null, y: null } } : { animation: "zoom", maskAnimation: "fade", mousePosition: { x: r == null ? void 0 : r.pageX, y: r == null ? void 0 : r.pageY } };
return m(ei, { ...u, ...p, prefixCls: "ff-modal", modalRender: () => L("div", { className: j("ff-modal-content ff-popup", t), children: [L("div", { className: j("ff-popup-header", "ff-modal-header", e == null ? void 0 : e.header), children: [m("button", { "aria-label": "Close", className: j("ff-popup-close", "ff-modal-close", e == null ? void 0 : e.close), onClick: u.onClose, children: m(en, { type: "close" }) }), o, a] }), m("div", { className: j("ff-popup-body", "ff-modal-body", e == null ? void 0 : e.body), children: i }), L("div", { className: j("ff-popup-footer", "ff-modal-footer", e == null ? void 0 : e.footer), children: [l, s] })] }) });
}, ur = ({ placement: t, $close: e, $event: n, children: r, title: i, ...o }) => {
const [a, s] = I({}), [l, d] = I(!0), u = H((y, w) => s((C) => ({ ...C, [y]: w })), []), p = H((y) => s((w) => ({ ...w, [y]: void 0 })), []);
let h = { ...o, className: a.rootClassName, title: a.title || i && E.createElement("div", { className: j("ff-popup-title") }, i), subTitle: a["sub-title"], actions: a.actions, extras: a.extras, children: r, $close: e, $event: n, onClose: () => d(!1) };
const g = () => {
e(!1);
};
return m(ht.Provider, { value: { ele: a, mount: u, unmount: p }, children: t && t !== "center" ? m(eo, { ...h, placement: t, open: l, afterOpenChange: (y) => !y && g() }) : m(to, { ...h, visible: l, afterClose: g }) });
};
ur.propTypes = { placement: b.oneOf(["center", "left", "top", "right", "bottom"]) };
const no = ({ widget: t, widgetProps: e, $close: n, onSetProps: r }) => {
const [i, o] = I(e || {}), a = Vn(e);
Zt(() => {
const l = a ?? {}, d = e ?? {}, u = Object.keys({ ...l, ...d }).reduce((p, h) => (l[h] !== d[h] && (p[h] = d[h]), p), {});
Object.keys(u).length > 0 && o((p) => ({ ...p, ...u }));
}, [e]);
const s = H((l) => {
o((d) => ({ ...d, ...l })), r == null || r(l);
}, [r]);
return E.isValidElement(t) ? E.cloneElement(t, { ...i, $close: n, $setProps: s }) : t != null && t.name || En.isForwardRef(t) || (t == null ? void 0 : t.$$typeof) === En.ForwardRef ? E.createElement(t, { ...i, $close: n, $setProps: s }) : t;
}, re = () => {
const [t, e] = Ar({ maxCount: 6, motion: { motionName: "ff-notification-fade", motionAppear: !0, motionEnter: !0, motionLeave: !0, onLeaveStart: (o) => {
const { offsetHeight: a } = o;
return { height: a };
}, onLeaveActive: () => ({ height: 0, opacity: 0, margin: 0 }) }, prefixCls: "ff-notification" }), [, n] = E.useReducer((o) => o + 1, 0);
q(() => {
re.$onClick = r, re.$queue.forEach(([o, a, s], l, d) => {
i([a, s], ...o), delete d[l];
});
}, []);
const r = (o, a = {}, s = {}) => new Promise((l, d) => i([l, d], o, a, s)), i = ([o, a], s, l = {}, d = {}) => {
const u = re.$index++, p = (y) => ((w, C) => (re.$popups.delete(w), n(), C == null ? void 0 : C()))(u, () => o(y));
if (s === Un) return t.open({ ...d, key: u, content: E.createElement(s, { ...l, $close: () => t.close(u) }) });
const { $setProps: h, ...g } = l;
re.$popups.set(u, E.createElement(ur, { maskClosable: !1, $event: g == null ? void 0 : g.$event, ...d, key: u, $close: p }, E.createElement(no, { widget: s, widgetProps: g, $close: p, onSetProps: h }))), n();
};
return L(E.Fragment, { children: [Array.from(re.$popups).map(([o, a]) => a), e] });
};
re.$popups = /* @__PURE__ */ new Map(), re.$index = 0, re.$queue = [], re.$onClick = (...t) => new Promise((e, n) => {
re.$queue.push([t, e, n]);
});
const An = (t, e, n = {}) => re.$onClick(t, e, n), Mt = (t, { showProgress: e, duration: n, ...r } = { duration: 1.5 }) => re.$onClick(Un, { content: t, ...r }, { showProgress: e, duration: n }), ie = { modal: An, confirm: (t, e = {}) => re.$onClick(ti, { content: t, ...e }, { placement: "center" }), form: (t, e = {}, n = {}) => An(Zi, { formProps: n, fields: t }, { placement: "center", ...e }).then((r) => {
if (r === !1) throw !1;
return r;
}), notification: Mt, success: (t, e = { duration: 1.5 }) => Mt(t, { ...e, className: "ff-notification-success", icon: "check" }), error: (t, e = { duration: 1.5 }) => Mt(t, { ...e, className: "ff-notification-error", icon: "close" }) };
tt.configure({ showSpinner: !1 });
const pr = () => {
const t = window.localStorage.getItem(bt);
return Object.freeze({ Platform: "web", SaaS: window.localStorage.getItem("SaaS"), Authorization: t ? `Bearer ${t} ` : void 0 });
};
De.interceptors.request.use((t) => (Object.assign(t.headers, pr()), tt.inc(), t), (t) => (tt.done(), Promise.reject({ code: -1, msg: t }))), De.interceptors.response.use(({ data: t, headers: e }) => (tt.done(), { ...t, res: e == null ? void 0 : e.res }), function(t) {
return tt.done(), Promise.reject(t.message);
}), window.addEventListener("unhandledrejection", zt.onUnhandledRejection), zt.onMsg = (t, e) => ie[[0, 1].includes(t) ? "success" : "error"](e).then(() => t === 20300 && oe.redirect(qe.get("Common.WEBSITE_LOGIN_PAGE")));
var Xe, Ue, Qe;
const Z = class Z {
constructor() {
O(this, "appUrl", "");
P(this, Xe, null);
return c(Z, Ue) || (K(Z, Qe, new zt()), K(Z, Ue, new Proxy(this, { get(e, n) {
if (n in e) {
const r = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e), n);
return r != null && r.get ? Reflect.get(e, n, e) : typeof e[n] == "function" ? e[n].bind(e) : e[n];
}
return c(Z, Qe)[n];
} }))), c(Z, Ue);
}
init(e, n, r) {
De.defaults.baseURL = this.appUrl = r, De.defaults.timeout = 15e3, c(Z, Qe).init(e, n, De);
}
get driver() {
return De;
}
get headers() {
return pr();
}
mock(e = {}) {
return c(this, Xe) ?? K(this, Xe, new Lr(De, { onNoMatch: "passthrough", ...e }));
}
unmock() {
var e;
(e = c(this, Xe)) == null || e.restore(), K(this, Xe, null);
}
};
Xe = new WeakMap(), Ue = new WeakMap(), Qe = new WeakMap(), P(Z, Ue), P(Z, Qe), O(Z, "getInstance", () => c(Z, Ue) ?? K(Z, Ue, new Z()));
let Gt = Z;
const z = Gt.getInstance();
class an extends Error {
constructor(e, n) {
super(n), Error.captureStackTrace && Error.captureStackTrace(this, an), !n instanceof nt && (this.name = `${e} Error Runtime`);
}
}
class nt extends Error {
constructor(e, ...n) {
super(...n), Error.captureStackTrace && Error.captureStackTrace(this, nt), this.name = `${e} Not Found`;
}
}
const Vt = "mine", bt = "token";
var Le, Ze;
const Ce = class Ce {
constructor() {
P(this, Ze, /* @__PURE__ */ new Map());
O(this, "setVendor", (e, n) => c(this, Ze).set(e, new Bn(n, async (r, i) => {
var a, s;
if (!(r != null && r.default)) throw "@pkg not found";
let o = () => i;
switch ("function") {
case typeof (o = (a = r.default) == null ? void 0 : a[`./${i}/index.jsx`]):
case typeof (o = (s = r.default) == null ? void 0 : s[`./${i}/index.js`]):
return o();
}
throw new nt(i);
})));
O(this, "getWidgetComponent", async (e) => {
if (!e) throw "getWidgetComponent widget is required";
if (e != null && e.startsWith("blob:") || e != null && e.startsWith("http:") || e != null && e.startsWith("https:")) return await import(e);
const [, n] = e == null ? void 0 : e.split("@pkg/");
if (!n) throw new nt(e);
try {
return c(this, Ze).has("pkg") ? await c(this, Ze).get("pkg").get(n) : await import(`${z.appUrl}/api/pkg-import/web?name=${e}`);
} catch (r) {
throw new an(e, r);
}
});
O(this, "getRoutes", () => z.get("/api/my-router").then((e) => [...e, { uuid: "data-list-setting", isLayout: !0, uri: "/data-list-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/DataListSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "grid-layout-setting", isLayout: !0, uri: "/grid-layout-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/GridLayoutSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "grid-layout-form-setting", isLayout: !0, uri: "/grid-layout-form-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/GridLayoutFormSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "resource-api-setting", isLayout: !0, uri: "/resource-api-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/ResourceApiSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "charts-setting", isLayout: !0, uri: "/resource-api-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/ChartsSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "fsm-setting", isLayout: !0, uri: "/fsm-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/FsmSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "component-setting", isLayout: !0, uri: "/component-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/ComponentSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "login", uri: "/login", name: "登录", type: "fsdpf-component", isLogin: !1, component: "@pkg/ff/components/Login" }, { uuid: "not-found", uri: "*", name: "Not Found", type: "fsdpf-component", isLogin: !1, component: "@pkg/ff/components/NotFound" }].map(({ uuid: n, ...r }) => [n, { uuid: n, ...r }])).then((e) => new Map(e)));
O(this, "getMenus", () => z.get("/api/my-menu"));
O(this, "getConfigure", () => z.get("api/init-configure"));
O(this, "getWidgetOperationAuth", () => z.get("/api/init-widget-operation-auth").then((e) => e.reduce((n, { uuid: r, auth: i }) => [...n, [r, i]], [])));
O(this, "getPhoneNumber", (e) => z.get(`/api/user-wx-phone-number/${e}`));
O(this, "getUserToken", () => {
const e = window.localStorage.getItem(bt);
if (!e) return "";
const n = e.split(".");
if (!Array.isArray(n) || n.length !== 3) throw "登录令牌无效!";
const { iat: r } = JSON.parse(window.atob(n[1]));
if (Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - r > 2592e3) throw "登录令牌已过期, 请重新登录!";
return e;
});
O(this, "checkUserToken", () => {
try {
return !!this.getUserToken();
} catch {
return !1;
}
});
O(this, "getUserInfo", (e = !0) => {
var n;
try {
const r = this.getUserToken();
if (!r) return Promise.resolve(null);
const { iat: i } = JSON.parse(window.atob((n = r == null ? void 0 : r.split(".")) == null ? void 0 : n[1])), { iat: o, ...a } = z.decode(window.localStorage.getItem(Vt) || "", {});
return o === i ? Promise.resolve(a) : z.get("/api/mine-info").then(({ User: s = null }) => (window.localStorage.setItem(Vt, z.encode({ ...s, iat: i })), s));
} catch (r) {
console.error(r), e && ie.error("请登录").then(this.logout);
}
return Promise.resolve(null);
});
O(this, "login", (e, n, r = {}) => z.post("/api/user-token", { username: e, passwd: Mr.hash(n), platform: "web", ...r }).then(({ token: i }) => (window.localStorage.setItem(bt, i), i)).then(async (i) => (await this.initAppEnv(), i)));
O(this, "logout", (e) => (window.localStorage.removeItem(Vt), window.localStorage.removeItem(bt), e == null ? void 0 : e()));
O(this, "initAppEnv", async () => {
const [e, n, r, i] = await Promise.all([this.getWidgetOperationAuth(), this.getRoutes(), this.getMenus(), this.getConfigure()]);
return qn.init(e), qe.init(i), oe.init(n, r), St.init(qe.get("Common.ICONFONT")), { widgetOperationAuth: e, routes: n, menus: r, configures: i };
});
if (c(Ce, Le)) return c(Ce, Le);
}
};
Le = new WeakMap(), Ze = new WeakMap(), P(Ce, Le, null), O(Ce, "getInstance", () => (c(Ce, Le) || K(Ce, Le, new Ce()), c(Ce, Le)));
let Xt = Ce;
const le = Xt.getInstance(), ro = E.createContext({ user: {}, initUser: () => {
}, initUserComplete: !1 }), io = E.createContext({ set: () => {
}, get: () => {
}, assign: () => {
}, currentRoute: () => {
} }), sn = (t) => {
if (!t) return !1;
if (t.prototype instanceof E.Component || t.$$typeof) return !0;
if (typeof t == "function") {
const e = t.displayName || t.name;
return !e || /^[A-Z]/.test(e);
}
return !1;
}, oo = (t, e) => {
if (!t || typeof window > "u") return;
let n = document.querySelector(`style[ff-style-token="${e}"]`);
return n ? (n.innerHTML = t, t) : (n = document.createElement("style"), n.setAttribute("ff-style-token", e), n.setAttribute("type", "text/css"), n.innerHTML = t, document.head.appendChild(n), t);
}, ao = Object.freeze(Object.defineProperty({ __proto__: null, AppContext: ro, AppGlobalParamsContext: io, cache: Bn, configure: qe, default: le, func: Me, http: z, insertStyle: oo, isReactComponent: sn, route: oe }, Symbol.toStringTag, { value: "Module" }));
var ve, et, Ne, Se, Ee, ne, ee, G, $e, ct, dt, ut, pt, vt, gt;
const ln = class ln {
constructor(e, n = "/") {
P(this, ve, "/");
P(this, et, /* @__PURE__ */ new Set());
P(this, Ne, (e) => {
for (const n of c(this, et)) try {
n(e);
} catch (r) {
console.error("Error in VirtualFS event listener:", r);
}
});
P(this, Se, (e) => {
const n = Date.now();
if (e && (e.lastModified = n), c(this, ve) != "/") {
const r = c(this, G).call(this, c(this, ve));
r && (r.lastModified = n);
}
this.root.lastModified = n;
});
P(this, Ee, (e) => {
let n = me.normalize(e);
return n.startsWith("/") || (n = "/" + n), n.length > 1 && n.endsWith("/") && (n = n.slice(0, -1)), n;
});
P(this, ne, (e) => {
const n = me.join(c(this, ve), e);
return c(this, Ee).call(this, n);
});
P(this, ee, (e) => {
if (!e || typeof e != "string") return !1;
const n = c(this, Ee).call(this, e);
return !n.includes("..") && n.startsWith("/");
});
P(this, G, (e) => {
var o;
const n = c(this, Ee).call(this, e);
if (n === "/") return this.root;
const r = n.split("/").filter((a) => a);
let i = this.root;
for (const a of r) {
if (i.type !== "dir") return null;
const s = (o = i.children) == null ? void 0 : o.find((l) => l.name === a);
if (!s) return null;
i = s;
}
return i;
});
P(this, $e, (e) => {
const n = c(this, Ee).call(this, e), r = me.basename(n), i = me.dirname(n);
return { parent: c(this, G).call(this, i), name: r };
});
P(this, ct, (e, n, r) => r === !1 ? e : r === "root" ? e.map((i) => me.join(n, i)) : r === !0 || r === "working" ? e.map((i) => me.relative(c(this, ve), me.join(n, i))) : e);
P(this, dt, async (e, n, r, i = "") => {
const o = [], a = c(this, G).call(this, e);
if (!a || a.type !== "dir") return o;
const s = a.children;
for (const l of s) {
const d = l.name, u = e === "/" ? `/${d}` : `${e}/${d}`, p = i ? `${i}/${d}` : d;
try {
if (l.type === "file") n(r ? p : d) && o.push(p);
else if (l.type === "dir" && r) {
const h = await c(this, dt).call(this, u, n, r, p);
o.push(...h);
}
} catch {
continue;
}
}
return o;
});
P(this, ut, async (e, n, r, i = "") => {
const o = [], a = Array.isArray(n) ? n : [n], s = c(this, G).call(this, e);
if (!s || s.type !== "dir") return o;
if (!r) {
for (const d of a) if (c(this, pt).call(this, d)) {
const u = await c(this, vt).call(this, e, d);
o.push(...u);
} else {
const u = me.join(e, d), p = c(this, Ee).call(this, u);
c(this, G).call(this, p) && o.push(d);
}
return o;
}
const l = s.children;
for (const d of l) {
const u = d.name, p = e === "/" ? `/${u}` : `${e}/${u}`, h = i ? `${i}/${u}` : u;
try {
if (d.type === "file") for (const g of a) {
let y = !1;
if (y = c(this, pt).call(this, g) ? c(this, gt).call(this, u, g) : u === g, y) {
o.push(h);
break;
}
}
else if (d.type === "dir") {
const g = await c(this, ut).call(this, p, n, r, h);
o.push(...g);
}
} catch {
continue;
}
}
return o;
});
P(this, pt, (e) => /[*?[\]{}]/.test(e));
P(this, vt, async (e, n) => {
const r = [], i = c(this, G).call(this, e);
if (!i || i.type !== "dir") return r;
const o = i.children.map((a) => a.name);
for (const a of o) c(this, gt).call(this, a, n) && r.push(a);
return r;
});
P(this, gt, (e, n) => {
const r = n.replace(/\./g, "\\.").replace(/\*/g, ".*").replace(/\?/g, ".").replace(/\{([^}]+)\}/g, (i, o) => "(" + o.split(",").join("|") + ")");
return new RegExp(`^${r}$`).test(e);
});
var r, i, o;
K(this, ve, n), this.root = { name: "/", type: "dir", children: [], lastModified: Date.now() }, Array.isArray(e) ? this.root.children = e : e && typeof e == "object" && (e.name && e.name !== "/" ? this.root.children.push(e) : (this.root = e, (r = this.root).name ?? (r.name = "/"), (i = this.root).children ?? (i.children = []), (o = this.root).lastModified ?? (o.lastModified = Date.now())));
}
async stat(e) {
const n = c(this, ne).call(this, e);
if (!c(this, ee).call(this, n)) throw new Error(`EINVAL: invalid path '${e}'`);
const r = c(this, G).call(this, n);
if (!r) throw new Error(`ENOENT: no such file or directory, stat '${e}'`);
return { isFile: () => r.type === "file", isDirectory: () => r.type === "dir", lastModified: r.lastModified };
}
async dir(e) {
const n = c(this, ne).call(this, e);
if (!c(this, ee).call(this, n)) throw new Error(`EINVAL: invalid path '${e}'`);
const r = c(this, G).call(this, n);
if (!r) throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);
if (r.type !== "dir") throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);
return r.children.map((i) => i.name);
}
async readFile(e) {
const n = c(this, ne).call(this, e);
if (!c(this, ee).call(this, n)) throw new Error(`EINVAL: invalid path '${e}'`);
const r = c(this, G).call(this, n);
if (!r) throw new Error(`ENOENT: no such file or directory, open '${e}'`);
if (r.type !== "file") throw new Error("EISDIR: illegal operation on a directory, read");
return r.content || "";
}
async writeFile(e, n) {
const r = c(this, ne).call(this, e);
if (!c(this, ee).call(this, r)) throw new Error(`EINVAL: invalid path '${e}'`);
const { parent: i, name: o } = c(this, $e).call(this, r);
if (!i) throw new Error(`ENOENT: no such file or directory, open '${e}'`);
if (i.type !== "dir") throw new Error("ENOTDIR: not a directory");
const a = i.children.findIndex((d) => d.name === o), s = a >= 0, l = { name: o, type: "file", content: n, lastModified: Date.now() };
s ? i.children[a] = l : i.children.push(l), c(this, Se).call(this, i), c(this, Ne).call(this, { action: s ? "update" : "create", path: r, type: "file", timestamp: Date.now() });
}
async mkdir(e, n = {}) {
const r = c(this, ne).call(this, e);
if (!c(this, ee).call(this, r)) throw new Error(`EINVAL: invalid path '${e}'`);
const { recursive: i } = n;
if (i) {
const o = r.split("/").filter((s) => s);
let a = "/";
for (const s of o)
if (a = me.join(a, s), !c(this, G).call(this, a)) {
const { parent: l, name: d } = c(this, $e).call(this, a);
if (l && l.type === "dir") {
const u = { name: d, type: "dir", children: [], lastModified: Date.now() };
l.children.push(u), c(this, Se).call(this, l), c(this, Ne).call(this, { action: "create", path: c(this, Ee).call(this, a), type: "dir", timestamp: Date.now() });
}
}
} else {
const { parent: o, name: a } = c(this, $e).call(this, r);
if (!o) throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);
if (o.type !== "dir") throw new Error("ENOTDIR: not a directory");
if (o.children.find((l) => l.name === a)) throw new Error(`EEXIST: file already exists, mkdir '${e}'`);
const s = { name: a, type: "dir", children: [], lastModified: Date.now() };
o.children.push(s), c(this, Se).call(this, o), c(this, Ne).call(this, { action: "create", path: r, type: "dir", timestamp: Date.now() });
}
}
async unlink(e) {
const n = c(this, ne).call(this, e);
if (!c(this, ee).call(this, n)) throw new Error(`EINVAL: invalid path '${e}'`);
const { parent: r, name: i } = c(this, $e).call(this, n);
if (!r) throw new Error(`ENOENT: no such file or directory, unlink '${e}'`);
const o = r.children.findIndex((a) => a.name === i);
if (o < 0) throw new Error(`ENOENT: no such file or directory, unlink '${e}'`);
if (r.children[o].type !== "file") throw new Error(`EISDIR: illegal operation on a directory, unlink '${e}'`);
r.children.splice(o, 1), c(this, Se).call(this, r), c(this, Ne).call(this, { action: "delete", path: n, type: "file", timestamp: Date.now() });
}
async rmdir(e, n = {}) {
const r = c(this, ne).call(this, e);
if (!c(this, ee).call(this, r)) throw new Error(`EINVAL: invalid path '${e}'`);
const { parent: i, name: o } = c(this, $e).call(this, r);
if (!i) throw new Error(`ENOENT: no such file or directory, rmdir '${e}'`);
const a = i.children.findIndex((l) => l.name === o);
if (a < 0) throw new Error(`ENOENT: no such file or directory, rmdir '${e}'`);
const s = i.children[a];
if (s.type !== "dir") throw new Error(`ENOTDIR: not a directory, rmdir '${e}'`);
if (!n.recursive && s.children.length > 0) throw new Error(`ENOTEMPTY: directory not empty, rmdir '${e}'`);
i.children.splice(a, 1), c(this, Se).call(this, i), c(this, Ne).call(this, { action: "delete", path: r, type: "dir", timestamp: Date.now() });
}
async rename(e, n) {
const r = c(this, ne).call(this, e), i = c(this, ne).call(this, n);
if (!c(this, ee).call(this, r)) throw new Error(`EINVAL: invalid path '${e}'`);
if (!c(this, ee).call(this, i)) throw new Error(`EINVAL: invalid path '${n}'`);
if (!c(this, G).call(this, r)) throw new Error(`ENOENT: no such file or directory, rename '${e}' -> '${n}'`);
const { parent: o, name: a } = c(this, $e).call(this, r), { parent: s, name: l } = c(this, $e).call(this, i);
if (!s) throw new Error(`ENOENT: no such file or directory, rename '${e}' -> '${n}'`);
if (c(this, G).call(this, i)) throw new Error(`EEXIST: file already exists, rename '${e}' -> '${n}'`);
const d = o.children.findIndex((p) => p.name === a), u = { ...o.children[d], name: l, lastModified: Date.now() };
o.children.splice(d, 1), s.children.push(u), c(this, Se).call(this, o), o !== s && c(this, Se).call(this, s), c(this, Ne).call(this, { action: "rename", path: i, oldPath: r, type: u.type, timestamp: Date.now() });
}
async exists(e) {
const n = c(this, ne).call(this, e);
return c(this, ee).call(this, n) ? c(this, G).call(this, n) !== null : !1;
}
getLastModified() {
return this.root.lastModified;
}
subscribe(e) {
if (typeof e != "function") throw new Error("Callback must be a function");
return c(this, et).add(e), () => {
c(this, et).delete(e);
};
}
getWorkingDirectory() {
return c(this, ve);
}
scope(e = "/") {
const n = c(this, Ee).call(this, e);
if (!c(this, ee).call(this, n)) throw new Error(`EINVAL: invalid path '${e}'`);
const r = c(this, G).call(this, n);
if (!r) throw new Error(`ENOENT: no such file or directory '${e}'`);
if (r.type !== "dir") throw new Error(`ENOTDIR: not a directory '${e}'`);
return r.children ?? (r.children = []), r.lastModified ?? (r.lastModified = Date.now()), new ln(this.root, n);
}
async findFiles(e, n, r = {}) {
const i = c(this, ne).call(this, e);
if (!c(this, ee).call(this, i)) throw new Error(`EINVAL: invalid path '${e}'`);
const o = c(this, G).call(this, i);
if (!o) throw new Error(`ENOENT: no such file or directory '${e}'`);
if (o.type !== "dir") throw new Error(`ENOTDIR: not a directory '${e}'`);
const { recursive: a = !1, fullPath: s = !1 } = r;
if (typeof n == "function") {
const d = await c(this, dt).call(this, i, n, a);
return c(this, ct).call(this, d, i, s);
}
const l = await c(this, ut).call(this, i, n, a);
return c(this, ct).call(this, l, i, s);
}
};
ve = new WeakMap(), et = new WeakMap(), Ne = new WeakMap(), Se = new WeakMap(), Ee = new WeakMap(), ne = new WeakMap(), ee = new WeakMap(), G = new WeakMap(), $e = new WeakMap(), ct = new WeakMap(), dt = new WeakMap(), ut = new WeakMap(), pt = new WeakMap(), vt = new WeakMap(), gt = new WeakMap();
let In = ln;
const so = async (t, e = "/", n = "") => {
try {
const r = await t.stat(e), i = e === "/" ? "/" : me.basename(e), o = { title: i, key: n ? `${n}${e}` : e, isLeaf: r.isFile() };
if (r.isDirectory()) {
const a = await t.dir(e);
if (a.length > 0) {
o.children = [];
const s = [], l = [];
for (const d of a) {
const u = e === "/" ? `/${d}` : `${e}/${d}`;
try {
(await t.stat(u)).isDirectory() ? s.push(d) : l.push(d);
} catch (p) {
console.warn(`Failed to stat ${u}:`, p.message);
}
}
s.sort(), l.sort();
for (const d of [...s, ...l]) {
const u = e === "/" ? `/${d}` : `${e}/${d}`;
try {
const p = await so(t, u, n);
o.children.push(p);
} catch (p) {
console.warn(`Failed to process ${u}:`, p.message);
}
}
}
}
return o;
} catch {
return null;
}
};
export {
Bo as $,
ai as A,
Oo as B,
Ro as C,
kt as D,
_n as E,
qt as F,
Ao as G,
bi as H,
si as I,
li as J,
xi as K,
Pi as L,
Io as M,
Lo as N,
ge as O,
Ni as P,
Nt as Q,
Qn as R,
ir as S,
Lt as T,
Mo as U,
Vo as V,
Do as W,
zo as X,
Ti as Y,
Oi as Z,
Ri as _,
Kn as a,
Fi as a0,
Tt as a1,
Wo as a2,
mt as a3,
Ot as a4,
Uo as a5,
qo as a6,
ji as a7,
lr as a8,
Wi as a9,
Bn as aA,
qe as aB,
Me as aC,
oe as aD,
ro as aE,
io as aF,
In as aG,
so as aH,
no as aI,
on as aa,
rn as ab,
cr as ac,
Ai as ad,
Ii as ae,
Li as af,
Mi as ag,
Vi as ah,
Di as ai,
Ko as aj,
St as ak,
R as al,
qn as am,
_i as an,
te as ao,
ht as ap,
Wn as aq,
re as ar,
ie as as,
vo as at,
No as au,
To as av,
le as aw,
sn as ax,
oo as ay,
z as az,
Hn as b,
Fo as c,
Yn as d,
tn as e,
Zn as f,
ni as g,
nr as h,
Si as i,
tr as j,
ki as k,
jo as l,
er as m,
Xn as n,
Gn as o,
fi as p,
mi as q,
gi as r,
nn as s,
ce as t,
Ci as u,
wi as v,
$i as w,
ci as x,
ui as y,
oi as z
};