Files
ff-dist/common/main.js
T

1626 lines
111 KiB
JavaScript

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