UNPKG

@form-create/tdesign

Version:

TDesign 版本低代码表单 | FormCreate 是一个可以通过 JSON 生成具有动态渲染、数据收集、验证和提交功能的低代码表单生成组件。

5,225 lines • 173 kB
/*!
 * FormCreate 低代码表单渲染器
 * @form-create/tdesign v3.3.5
 * (c) 2018-2026 xaboy
 * Github https://github.com/xaboy/form-create
 * Site https://form-create.com/
 * Released under the MIT License.
 */
(function(){"use strict";try{if(typeof document!="undefined"){var r=document.createElement("style");r.appendChild(document.createTextNode('._fc-frame ._fc-files img{width:100%;height:100%;display:inline-block;vertical-align:top}._fc-frame ._fc-upload-cover{opacity:0;position:absolute;inset:0;background:#0009;transition:opacity .3s}._fc-frame ._fc-upload-cover ._fc-frame-icon{color:#fff;font-size:20px;margin:0 2px}._fc-frame ._fc-files:hover ._fc-upload-cover{opacity:1}._fc-frame .t-upload{display:block}._fc-frame ._fc-upload-btn,._fc-frame ._fc-frame-icon{cursor:pointer;font-size:20px;width:20px}._fc-frame._fc-disabled ._fc-upload-btn,._fc-frame._fc-disabled ._fc-frame-icon{cursor:not-allowed!important;color:#999}._fc-frame .t-input-adornment__append ._fc-frame-icon{margin:5px 12px 0}._fc-frame ._fc-upload-btn,._fc-files{display:inline-block;width:112px;height:112px;text-align:center;line-height:112px;border:1px solid #c0ccda;overflow:hidden;background:#fff;position:relative;box-shadow:2px 2px 5px #0000001a;margin-right:4px;box-sizing:border-box}._fc-group{display:flex;min-height:38px;justify-content:center;flex-direction:column;width:100%}._fc-group-disabled ._fc-group-btn,._fc-group-disabled ._fc-group-add{cursor:not-allowed}._fc-group-handle{display:flex;flex-direction:row;position:absolute;bottom:-15px;right:30px;border-radius:15px;border:1px dashed #d9d9d9;padding:3px 8px;background-color:#fff}._fc-group-btn{cursor:pointer}._fc-group-idx{position:absolute;bottom:-15px;left:10px;width:30px;height:30px;display:flex;align-items:center;justify-content:center;background:#eee;border-radius:15px;font-weight:700}._fc-group-handle ._fc-group-btn+._fc-group-btn{margin-left:7px}._fc-group-container{position:relative;display:flex;flex-direction:column;border:1px dashed #d9d9d9;border-radius:5px;margin:5px 5px 25px;padding:20px 20px 25px}._fc-group-arrow{position:relative;width:20px;height:20px}._fc-group-arrow:before{content:"";position:absolute;top:8px;left:5px;width:9px;height:9px;border-left:2px solid #999;border-top:2px solid #999}._fc-group-arrow:before{transform:rotate(45deg)}._fc-group-arrow._fc-group-down{transform:rotate(180deg)}._fc-group-plus-minus{width:20px;height:20px;position:relative;cursor:pointer}._fc-group-plus-minus:before,._fc-group-plus-minus:after{content:"";position:absolute;top:50%;left:50%;width:60%;height:2px;background-color:#409eff;transform:translate(-50%,-50%)}._fc-group-plus-minus:before{transform:translate(-50%,-50%) rotate(90deg)}._fc-group-plus-minus._fc-group-minus:before{display:none}._fc-group-plus-minus._fc-group-minus:after{background-color:#f56c6c}._fc-group-add{cursor:pointer;width:25px;height:25px;border:1px solid rgb(64 158 255 / 50%);border-radius:15px}._fc-group-add._fc-group-plus-minus:before,._fc-group-add._fc-group-plus-minus:after{width:50%}._fc-group._fc-group-card{display:flex;flex-direction:column;width:100%;gap:16px}._fc-group._fc-group-card._fc-group-disabled ._fc-group-btn,._fc-group._fc-group-card._fc-group-disabled ._fc-group-add{cursor:not-allowed;opacity:.5}._fc-group._fc-group-card ._fc-group-container{position:relative;background:#fff;border:1px solid #f0f0f0;border-radius:6px;overflow:hidden;display:flex;flex-direction:column;padding:0;margin:0}._fc-group._fc-group-card ._fc-group-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px 12px;border-bottom:1px solid #f0f0f0;background:#fafafa}._fc-group._fc-group-card ._fc-group-idx{display:flex;align-items:center;justify-content:center;width:24px;height:24px;background:#f0f0f0;color:#666;border-radius:6px;font-size:12px;font-weight:500;margin-right:12px;flex-shrink:0;position:static;border:1px solid #e0e0e0}._fc-group._fc-group-card ._fc-group-title{flex:1;font-size:14px;font-weight:500;color:#000000d9;line-height:1.5715}._fc-group._fc-group-card ._fc-group-handle{display:flex;align-items:center;gap:4px;margin-left:12px;flex-shrink:0;position:static;bottom:auto;right:auto;border-radius:0;border:none;padding:0;background-color:transparent;flex-direction:row}._fc-group._fc-group-card ._fc-group-btn{cursor:pointer;display:flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:4px;border:1px solid #d9d9d9;background:#fff;color:#00000073;position:relative}._fc-group._fc-group-card ._fc-group-btn:hover{color:#1890ff;border-color:#1890ff;background:#f0f8ff}._fc-group._fc-group-card ._fc-group-btn:active{color:#096dd9;border-color:#096dd9}._fc-group._fc-group-card ._fc-group-arrow{position:relative}._fc-group._fc-group-card ._fc-group-arrow:before{content:"";position:absolute;top:50%;left:50%;width:5px;height:5px;border-left:1px solid currentColor;border-top:1px solid currentColor;transform:translate(-50%,-50%) rotate(45deg)}._fc-group._fc-group-card ._fc-group-arrow._fc-group-down{transform:rotate(180deg)}._fc-group._fc-group-card ._fc-group-sort{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;height:24px}._fc-group._fc-group-card ._fc-group-sort:before,._fc-group._fc-group-card ._fc-group-sort:after{content:"";position:absolute;left:50%;width:4px;height:4px;border-left:1px solid currentColor;border-top:1px solid currentColor;transform:translate(-50%)}._fc-group._fc-group-card ._fc-group-sort:before{top:6px;transform:translate(-50%) rotate(45deg)}._fc-group._fc-group-card ._fc-group-sort:after{bottom:6px;transform:translate(-50%) rotate(225deg)}._fc-group._fc-group-card ._fc-group-sort-up,._fc-group._fc-group-card ._fc-group-sort-down{position:absolute;left:0;right:0;height:12px;cursor:pointer;z-index:1}._fc-group._fc-group-card ._fc-group-sort-up{top:0}._fc-group._fc-group-card ._fc-group-sort-down{bottom:0}._fc-group._fc-group-card ._fc-group-sort-up:hover,._fc-group._fc-group-card ._fc-group-sort-down:hover{background:#1890ff1a}._fc-group._fc-group-card ._fc-group-plus-minus{position:relative;background:#409eff;border-color:#409eff;color:#fff;width:24px;height:24px}._fc-group._fc-group-card ._fc-group-plus-minus:hover{background:#66b1ff;border-color:#66b1ff;color:#fff}._fc-group._fc-group-card ._fc-group-plus-minus:before,._fc-group._fc-group-card ._fc-group-plus-minus:after{content:"";position:absolute;top:50%;left:50%;width:8px;height:1px;background-color:currentColor;transform:translate(-50%,-50%)}._fc-group._fc-group-card ._fc-group-plus-minus:before{transform:translate(-50%,-50%) rotate(90deg)}._fc-group._fc-group-card ._fc-group-plus-minus._fc-group-minus{background:#f56c6c;border-color:#f56c6c}._fc-group._fc-group-card ._fc-group-plus-minus._fc-group-minus:hover{background:#f78989;border-color:#f78989}._fc-group._fc-group-card ._fc-group-plus-minus._fc-group-minus:before{display:none}._fc-group._fc-group-card ._fc-group-content{padding:20px}._fc-group._fc-group-card ._fc-group-add{cursor:pointer;display:flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:4px;border:1px solid #d9d9d9;background:#fff;color:#00000073;position:relative}._fc-group._fc-group-card ._fc-group-add:hover{color:#409eff;border-color:#409eff;background:#f0f8ff}._fc-group._fc-group-card ._fc-group-add._fc-group-plus-minus{width:24px;height:24px;background:#409eff;border-color:#409eff;color:#fff}._fc-group._fc-group-card ._fc-group-add._fc-group-plus-minus:hover{background:#66b1ff;border-color:#66b1ff;color:#fff}._fc-group._fc-group-card ._fc-group-add._fc-group-plus-minus:before,._fc-group._fc-group-card ._fc-group-add._fc-group-plus-minus:after{content:"";position:absolute;top:50%;left:50%;width:8px;height:1px;background-color:currentColor;transform:translate(-50%,-50%)}._fc-group._fc-group-card ._fc-group-add._fc-group-plus-minus:before{transform:translate(-50%,-50%) rotate(90deg)}._fc-group._fc-group-card ._fc-group-empty{text-align:center;padding:40px 20px;color:#00000073;font-size:14px}@media (max-width: 768px){._fc-group._fc-group-card ._fc-group-container{margin:0 -8px;border-radius:0;border-left:none;border-right:none}._fc-group._fc-group-card ._fc-group-header{padding:12px 16px 8px}._fc-group._fc-group-card ._fc-group-content{padding:16px}._fc-group._fc-group-card ._fc-group-handle{gap:2px}._fc-group._fc-group-card ._fc-group-btn{width:22px;height:22px}}.form-create{width:100%}.form-create .t-tree .t-tree__icon{line-height:inherit}.form-create.t-form:not(.t-form-inline) .t-form__item:last-of-type{margin-bottom:24px}.form-create .form-create .t-is-error .t-input__extra{color:var(--td-error-color)}.form-create .form-create .t-is-warning .t-input__extra{color:var(--td-warning-color)}.form-create.is-preview .fc-clock,.form-create .fc-none,.form-create.is-preview .t-form__label--required>label:before{display:none!important}.fc-form-footer{margin-top:12px}.form-create.is-numbered{counter-reset:q}.form-create.is-numbered .fc-form-title{counter-increment:q}.form-create.is-numbered .fc-form-title:before{content:counter(q) ". ";color:var(--fc-number-color, inherit);font-weight:600}.form-create.is-numbered.is-number-chinese .fc-form-title:before{content:counter(q,simp-chinese-informal) "、"}')),document.head.appendChild(r)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
var cr = Object.defineProperty, dr = Object.defineProperties;
var hr = Object.getOwnPropertyDescriptors;
var dt = Object.getOwnPropertySymbols;
var pr = Object.prototype.hasOwnProperty, mr = Object.prototype.propertyIsEnumerable;
var ht = (t, e, r) => e in t ? cr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, _ = (t, e) => {
  for (var r in e || (e = {}))
    pr.call(e, r) && ht(t, r, e[r]);
  if (dt)
    for (var r of dt(e))
      mr.call(e, r) && ht(t, r, e[r]);
  return t;
}, T = (t, e) => dr(t, hr(e));
import { openBlock as Me, createElementBlock as Ue, createElementVNode as ve, defineComponent as ge, h as Se, nextTick as A, createVNode as w, resolveComponent as G, mergeProps as Te, markRaw as ie, reactive as W, isVNode as gr, getCurrentInstance as Ze, provide as yr, inject as br, toRefs as pt, onBeforeMount as $r, watchEffect as _r, onMounted as vr, onBeforeUnmount as Cr, onUpdated as wr, watch as N, computed as _e, toRef as Le, withDirectives as Sr, resolveDirective as Fr, ref as Or, createApp as Rr } from "vue";
function z(t) {
  return Array.isArray(t) ? t : [null, void 0, ""].indexOf(t) > -1 ? [] : [t];
}
function jt(t) {
  t = t || /* @__PURE__ */ new Map();
  const e = {
    $on(r, n) {
      const s = t.get(r);
      s && s.push(n) || t.set(r, [n]);
    },
    $once(r, n) {
      n._once = !0, e.$on(r, n);
    },
    $off(r, n) {
      const s = t.get(r);
      s && s.splice(s.indexOf(n) >>> 0, 1);
    },
    $emit(r, ...n) {
      (t.get(r) || []).slice().map((s) => {
        s._once && (e.$off(r, s), delete s._once), s(...n);
      }), (t.get("*") || []).slice().map((s) => {
        s(r, n);
      });
    }
  };
  return e;
}
const qe = (t, e) => {
  const r = t.__vccOpts || t;
  for (const [n, s] of e)
    r[n] = s;
  return r;
}, Vr = {
  name: "IconFolder"
}, Er = {
  xmlns: "http://www.w3.org/2000/svg",
  viewBox: "0 0 32 32"
};
function kr(t, e, r, n, s, i) {
  return Me(), Ue("svg", Er, [...e[0] || (e[0] = [
    ve("path", {
      d: "M26 20h-2v4h-4v2h4v4h2v-4h4v-2h-4z",
      fill: "currentColor"
    }, null, -1),
    ve("path", {
      d: "M28 8H16l-3.4-3.4c-.4-.4-.9-.6-1.4-.6H4c-1.1 0-2 .9-2 2v20c0 1.1.9 2 2 2h14v-2H4V6h7.2l3.4 3.4l.6.6H28v8h2v-8c0-1.1-.9-2-2-2z",
      fill: "currentColor"
    }, null, -1)
  ])]);
}
const Dr = /* @__PURE__ */ qe(Vr, [["render", kr]]), jr = ge({
  name: "IconFile",
  render() {
    return Se(
      "svg",
      {
        style: { width: "20px", fontSize: "20px" },
        viewBox: "0 0 24 24",
        version: "1.1",
        xmlns: "http://www.w3.org/2000/svg"
      },
      Se(
        "g",
        {
          fill: "none",
          stroke: "currentColor",
          "stroke-width": "2",
          "stroke-linecap": "round",
          "stroke-linejoin": "round"
        },
        Se("path", { d: "M14 3v4a1 1 0 0 0 1 1h4" }),
        Se("path", { d: "M17 21H7a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7l5 5v11a2 2 0 0 1-2 2z" })
      )
    );
  }
}), Ar = {
  name: "DeleteOutlined"
}, Pr = {
  height: "1em",
  width: "1em",
  xmlns: "http://www.w3.org/2000/svg",
  viewBox: "0 0 1024 1024"
};
function Ir(t, e, r, n, s, i) {
  return Me(), Ue("svg", Pr, [...e[0] || (e[0] = [
    ve("path", {
      d: "M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z",
      fill: "currentColor"
    }, null, -1)
  ])]);
}
const Br = /* @__PURE__ */ qe(Ar, [["render", Ir]]), Tr = {
  name: "EyeOutlined"
}, Lr = {
  height: "1em",
  width: "1em",
  xmlns: "http://www.w3.org/2000/svg",
  viewBox: "0 0 1024 1024"
};
function Nr(t, e, r, n, s, i) {
  return Me(), Ue("svg", Lr, [...e[0] || (e[0] = [
    ve("path", {
      d: "M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3a60.3 60.3 0 0 0 0 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3c7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766zm-4-430c-97.2 0-176 78.8-176 176s78.8 176 176 176s176-78.8 176-176s-78.8-176-176-176zm0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112s112 50.1 112 112s-50.1 112-112 112z",
      fill: "currentColor"
    }, null, -1)
  ])]);
}
const Mr = /* @__PURE__ */ qe(Tr, [["render", Nr]]), Ur = "fcFrame", qr = /* @__PURE__ */ ge({
  name: Ur,
  props: {
    type: {
      type: String,
      default: "input"
    },
    field: String,
    helper: {
      type: Boolean,
      default: !0
    },
    disabled: {
      type: Boolean,
      default: !1
    },
    src: {
      type: String,
      required: !0
    },
    icon: {
      type: String,
      default: "icon-folder"
    },
    width: {
      type: [Number, String],
      default: "500px"
    },
    height: {
      type: [Number, String],
      default: "370px"
    },
    maxLength: {
      type: Number,
      default: 0
    },
    okBtnText: {
      type: String,
      default: ""
    },
    closeBtnText: {
      type: String,
      default: ""
    },
    modalTitle: String,
    handleIcon: {
      type: [String, Boolean],
      default: void 0
    },
    title: String,
    allowRemove: {
      type: Boolean,
      default: !0
    },
    onOpen: {
      type: Function,
      default: () => {
      }
    },
    onOk: {
      type: Function,
      default: () => {
      }
    },
    onCancel: {
      type: Function,
      default: () => {
      }
    },
    onLoad: {
      type: Function,
      default: () => {
      }
    },
    onBeforeRemove: {
      type: Function,
      default: () => {
      }
    },
    onRemove: {
      type: Function,
      default: () => {
      }
    },
    onHandle: Function,
    modal: {
      type: Object,
      default: () => ({})
    },
    srcKey: [String, Number],
    modelValue: [Array, String, Number, Object],
    previewMask: void 0,
    footer: {
      type: Boolean,
      default: !0
    },
    reload: {
      type: Boolean,
      default: !0
    },
    closeBtn: {
      type: Boolean,
      default: !0
    },
    okBtn: {
      type: Boolean,
      default: !0
    },
    formCreateInject: Object
  },
  emits: ["update:modelValue", "change"],
  components: {
    IconFolder: Dr,
    EyeOutlined: Mr
  },
  data() {
    return {
      fileList: z(this.modelValue),
      previewVisible: !1,
      frameVisible: !1,
      previewImage: "",
      bus: new jt()
    };
  },
  watch: {
    modelValue(t) {
      this.fileList = z(t);
    }
  },
  methods: {
    key(t) {
      return t;
    },
    close() {
      this.closeModal(!0);
    },
    closeModal(t) {
      this.bus.$emit(t ? "$close" : "$ok"), this.reload && (this.bus.$off("$ok"), this.bus.$off("$close")), this.frameVisible = !1;
    },
    handleCancel() {
      this.previewVisible = !1;
    },
    showModal() {
      this.disabled || this.onOpen() === !1 || (this.frameVisible = !0);
    },
    input() {
      const t = this.fileList, e = this.maxLength === 1 ? t[0] || "" : t;
      this.$emit("update:modelValue", e), this.$emit("change", e);
    },
    makeInput() {
      const t = G(this.icon);
      return w(G("t-input-adornment"), {
        append: () => w(t, {
          onClick: this.showModal,
          class: "_fc-frame-icon"
        }, null)
      }, {
        default: () => [w(G("TInput"), {
          readonly: !0,
          clearable: !this.disabled,
          showClearIconOnEmpty: !this.disabled,
          value: this.fileList.map((e) => this.getSrc(e)).toString(),
          onClear: () => {
            this.fileList = [], this.input();
          },
          key: 1
        }, null)]
      });
    },
    makeGroup(t) {
      return (!this.maxLength || this.fileList.length < this.maxLength) && t.push(this.makeBtn()), w("div", {
        key: 2
      }, [t]);
    },
    makeItem(t, e) {
      return w("div", {
        class: "_fc-files",
        key: "3" + t
      }, [e]);
    },
    valid(t) {
      const e = this.formCreateInject.field || this.field;
      if (e && t !== e)
        throw new Error("[frame]无效的字段值");
    },
    makeIcons(t, e) {
      if (this.handleIcon !== !1 || this.allowRemove === !0) {
        const r = [];
        return (this.type !== "file" && this.handleIcon !== !1 || this.type === "file" && this.handleIcon) && r.push(this.makeHandleIcon(t, e)), this.allowRemove && r.push(this.makeRemoveIcon(t, e)), w("div", {
          class: "_fc-upload-cover",
          key: 4
        }, [r]);
      }
    },
    makeHandleIcon(t, e) {
      const r = G(this.handleIcon === !0 || this.handleIcon === void 0 ? "EyeOutlined" : this.handleIcon);
      return w(r, {
        class: "_fc-frame-icon",
        onClick: () => this.handleClick(t),
        key: "5" + e
      }, null);
    },
    makeRemoveIcon(t, e) {
      return w(Br, {
        class: "_fc-frame-icon",
        onClick: () => this.handleRemove(t),
        key: "6" + e
      }, null);
    },
    makeFiles() {
      return this.makeGroup(this.fileList.map((t, e) => this.makeItem(e, [w(jr, {
        size: "20",
        onClick: () => this.handleClick(t)
      }, null), this.makeIcons(t, e)])));
    },
    makeImages() {
      return this.makeGroup(this.fileList.map((t, e) => this.makeItem(e, [w("img", {
        src: this.getSrc(t)
      }, null), this.makeIcons(t, e)])));
    },
    makeBtn() {
      const t = G(this.icon);
      return w("div", {
        class: "_fc-upload-btn",
        onClick: () => this.showModal(),
        key: 7
      }, [w(t, {
        class: "_fc-frame-icon"
      }, null)]);
    },
    handleClick(t) {
      if (this.onHandle)
        return this.onHandle(t);
      this.previewImage = this.getSrc(t), this.previewVisible = !0;
    },
    handleRemove(t) {
      this.disabled || this.onBeforeRemove(t) !== !1 && (this.fileList.splice(this.fileList.indexOf(t), 1), this.input(), this.onRemove(t));
    },
    getSrc(t) {
      return this.srcKey ? t[this.srcKey] : t;
    },
    frameLoad(t) {
      this.onLoad(t);
      try {
        this.helper === !0 && (t.form_create_helper = {
          api: this.formCreateInject.api,
          close: (e) => {
            this.valid(e), this.closeModal();
          },
          set: (e, r) => {
            this.valid(e), this.disabled || (this.$emit("update:modelValue", r), this.$emit("change", r));
          },
          get: (e) => (this.valid(e), this.modelValue),
          onOk: (e) => this.bus.$on("$ok", e),
          onClose: (e) => this.bus.$on("$close", e)
        });
      } catch (e) {
        console.error(e);
      }
    },
    makeFooter() {
      const {
        okBtnText: t,
        closeBtnText: e,
        closeBtn: r,
        okBtn: n,
        footer: s
      } = this.$props, i = [];
      return s && (r && i.push(w(G("TButton"), {
        onClick: () => this.onCancel() !== !1 && this.closeModal(!0)
      }, {
        default: () => [e || this.formCreateInject.t("close") || "关闭"]
      })), n && i.push(w(G("TButton"), {
        theme: "primary",
        onClick: () => this.onOk() !== !1 && this.closeModal()
      }, {
        default: () => [t || this.formCreateInject.t("ok") || "确定"]
      }))), i;
    }
  },
  render() {
    const t = this.type;
    let e;
    t === "input" ? e = this.makeInput() : t === "image" ? e = this.makeImages() : e = this.makeFiles();
    const {
      width: r = "30%",
      height: n,
      src: s,
      title: i,
      modalTitle: o
    } = this.$props;
    return A(() => {
      this.$refs.frame && this.frameLoad(this.$refs.frame.contentWindow || {});
    }), w("div", {
      class: {
        "_fc-frame": !0,
        "_fc-disabled": this.disabled
      }
    }, [e, w(G("TDialog"), {
      mask: this.previewMask,
      header: o,
      visible: this.previewVisible,
      style: "width: 600px;",
      attach: "body",
      "onUpdate:visible": (a) => this.previewVisible = a,
      footer: !1
    }, {
      default: () => [w("img", {
        style: "width: 100%",
        src: this.previewImage,
        key: 1
      }, null)]
    }), w(G("TDialog"), Te(_({
      width: r,
      header: i
    }, this.modal), {
      visible: this.frameVisible,
      attach: "body",
      style: {
        width: r
      },
      onClose: () => this.frameVisible = !1,
      onConfirm: () => this.closeModal(!0),
      key: 2
    }), {
      default: () => [this.frameVisible || !this.reload ? w("iframe", {
        ref: "frame",
        src: s,
        frameborder: "0",
        style: {
          height: n,
          border: "0 none",
          width: "100%"
        }
      }, null) : null],
      action: () => this.makeFooter()
    })]);
  },
  beforeMount() {
    const {
      name: t,
      field: e,
      api: r
    } = this.formCreateInject;
    t && r.on("fc:closeModal:" + t, this.close), e && r.on("fc:closeModal:" + e, this.close);
  },
  beforeUnmount() {
    const {
      name: t,
      field: e,
      api: r
    } = this.formCreateInject;
    t && r.off("fc:closeModal:" + t, this.close), e && r.off("fc:closeModal:" + e, this.close);
  }
}), Hr = "fcUpload";
function mt(t, e) {
  return typeof t == "object" ? t : {
    url: t,
    is_string: !0,
    name: Gr(t),
    status: "success",
    uid: e
  };
}
function gt(t) {
  return T(_({}, t), {
    file: t,
    value: t
  });
}
function Gr(t) {
  return ("" + t).split("/").pop();
}
const zr = /* @__PURE__ */ ge({
  name: Hr,
  inheritAttrs: !1,
  formCreateParser: {
    toFormValue(t) {
      return z(t);
    },
    toValue(t, e) {
      return e.prop.props.limit === 1 ? t[0] || "" : t;
    }
  },
  props: {
    limit: {
      type: Number,
      default: 0
    },
    formCreateInject: Object,
    modelValue: {
      type: [Array, String, Object],
      default: []
    },
    onSuccess: {
      type: Function
    },
    onRemove: {
      type: Function
    },
    name: String,
    requestMethod: Function
  },
  emits: ["update:modelValue", "fc.el"],
  data() {
    return {
      uploadList: z(this.modelValue).map(mt).map(gt)
    };
  },
  watch: {
    modelValue(t) {
      this.uploadList = z(t).map(mt).map(gt);
    }
  },
  methods: {
    handleRemove({
      index: t
    }) {
      this.uploadList.splice(t, 1), this.onRemove && this.onRemove(...arguments), this.input();
    },
    handleSuccess({
      file: t,
      fileList: e
    }) {
      this.uploadList = e, t.status === "success" && this.onSuccess && this.onSuccess(...arguments), this.input();
    },
    input() {
      this.$emit("update:modelValue", this.uploadList.map((t) => t.is_string ? t.url : t.value || t.url).filter((t) => t !== void 0));
    },
    doRequestMethod(t) {
      const e = this.requestMethod;
      if (e)
        return e(t);
      const r = Array.isArray(t) ? t[0] : t, n = (r == null ? void 0 : r.raw) || (r == null ? void 0 : r.file) || r;
      return new Promise((s, i) => {
        var a;
        const o = {
          method: ((a = this.$attrs) == null ? void 0 : a.method) || "post",
          file: n,
          filename: this.name || "file",
          source: "upload",
          onSuccess: (l) => s({
            status: "success",
            response: l
          }),
          onError: (l) => i(l)
        };
        this.formCreateInject.api.fetch(o);
      });
    }
  },
  render() {
    const {
      uploadList: t,
      handleSuccess: e,
      handleRemove: r,
      $slots: n
    } = this;
    return w("div", {
      class: "_fc-upload",
      style: "width: 100%;"
    }, [w(G("t-upload"), Te({
      max: this.limit || void 0,
      theme: "image",
      accept: "image/*",
      modelValue: t,
      name: this.name
    }, this.$attrs, {
      requestMethod: this.doRequestMethod,
      onSuccess: e,
      onRemove: r,
      ref: "el"
    }), n)]);
  },
  mounted() {
    this.$emit("fc.el", this.$refs.el);
  }
}), h = {
  type(t, e) {
    return Object.prototype.toString.call(t) === "[object " + e + "]";
  },
  Undef(t) {
    return t == null;
  },
  Element(t) {
    return typeof t == "object" && t !== null && t.nodeType === 1 && !h.Object(t);
  },
  trueArray(t) {
    return Array.isArray(t) && t.length > 0;
  },
  Function(t) {
    const e = this.getType(t);
    return e === "Function" || e === "AsyncFunction";
  },
  getType(t) {
    const e = Object.prototype.toString.call(t);
    return /^\[object (.*)\]$/.exec(e)[1];
  },
  empty(t) {
    return t == null || Array.isArray(t) && Array.isArray(t) && !t.length ? !0 : typeof t == "string" && !t;
  }
};
["Date", "Object", "String", "Boolean", "Array", "Number"].forEach((t) => {
  h[t] = function(e) {
    return h.type(e, t);
  };
});
function k(t, e) {
  return {}.hasOwnProperty.call(t, e);
}
function U(t, e, r) {
  t[e] = r;
}
function pe(t, e) {
  delete t[e];
}
function Ve(t, e = {}, r) {
  let n = !1;
  for (let s in e)
    if (Object.prototype.hasOwnProperty.call(e, s)) {
      let i = e[s];
      if ((n = Array.isArray(i)) || h.Object(i)) {
        let o = t[s] === void 0;
        if (n)
          n = !1, o && U(t, s, []);
        else if (i._clone && r !== void 0)
          if (r)
            i = i.getRule(), o && U(t, s, {});
          else {
            U(t, s, i._clone());
            continue;
          }
        else
          o && U(t, s, {});
        t[s] = Ve(t[s], i, r);
      } else
        U(t, s, i), h.Undef(i) || (h.Undef(i.__json) || (t[s].__json = i.__json), h.Undef(i.__origin) || (t[s].__origin = i.__origin));
    }
  return r !== void 0 && Array.isArray(t) ? t.filter((s) => !s || !s.__ctrl) : t;
}
function K(t) {
  return Ve({}, { value: t }).value;
}
const xr = Object.assign || function(t) {
  for (let e, r = 1; r < arguments.length; r++)
    for (let n in e = arguments[r], e)
      Object.prototype.hasOwnProperty.call(e, n) && U(t, n, e[n]);
  return t;
};
function C() {
  return xr.apply(this, arguments);
}
function Ye(t) {
  return typeof t != "object" || t === null ? t : t instanceof Array ? [...t] : _({}, t);
}
function se(t, e) {
  var r = null;
  return function(...n) {
    r !== null && clearTimeout(r), r = setTimeout(() => t.call(this, ...n), e);
  };
}
function At(t) {
  return t == null ? "" : typeof t == "object" ? JSON.stringify(t, null, 2) : String(t);
}
function Jr(t) {
  return t && typeof t == "object" && typeof t.then == "function";
}
function Ne(t) {
  return Jr(t) ? t : Promise.resolve(t);
}
function Oe(t) {
  let e = t.replace(/([A-Z])/g, "-$1").toLocaleLowerCase();
  return e.indexOf("-") === 0 && (e = e.substr(1)), e;
}
function Pt(t) {
  return t.replace(t[0], t[0].toLocaleUpperCase());
}
function It(t, e, r) {
  return `[form-create ${t}]: ${e}`;
}
function nt(t, e) {
  console.error(It("err", t));
}
function Wr(t) {
  nt(t.toString()), console.error(t);
}
const et = "[[FORM-CREATE-PREFIX-", tt = "-FORM-CREATE-SUFFIX]]";
function Re(t, e) {
  return JSON.stringify(Ve(Array.isArray(t) ? [] : {}, t, !0), function(r, n) {
    if (!(n && n._isVue === !0)) {
      if (typeof n != "function")
        return n;
      if (n.__json)
        return n.__json;
      if (n.__origin && (n = n.__origin), !n.__emit)
        return et + n + tt;
    }
  }, e);
}
function Je(t) {
  return new Function("return " + t)();
}
function Q(t, e) {
  if (t && h.String(t) && t.length > 4) {
    let r = t.trim(), n = !1;
    try {
      if (r.indexOf(tt) > 0 && r.indexOf(et) === 0)
        r = r.replace(tt, "").replace(et, ""), n = !0;
      else if (r.indexOf("$FN:") === 0)
        r = r.substring(4), n = !0;
      else if (r.indexOf("$EXEC:") === 0)
        r = r.substring(6), n = !0;
      else if (r.indexOf("$GLOBAL:") === 0) {
        const i = r.substring(8);
        return r = function(...o) {
          const a = o[0].api.getGlobalEvent(i);
          if (a)
            return a.call(this, ...o);
        }, r.__json = t, r.__inject = !0, r;
      } else {
        if (r.indexOf("$FNX:") === 0)
          return r = Je(`function($inject){
` + r.substring(5) + `
}`), r.__json = t, r.__inject = !0, r;
        (!e && r.indexOf("function ") === 0 && r !== "function " || !e && r.indexOf("function(") === 0 && r !== "function(") && (n = !0);
      }
      if (!n) return t;
      let s;
      try {
        s = Je(r);
      } catch (i) {
        s = Je("function " + r);
      }
      return s.__json = t, s;
    } catch (s) {
      nt(`解析失败:${r}

err: ${s}`);
      return;
    }
  }
  return t;
}
function Bt(t, e) {
  return JSON.parse(t, function(r, n) {
    return h.Undef(n) || !n.indexOf ? n : Q(n, e);
  });
}
let Kr = 0;
function He() {
  const t = 370 + ++Kr;
  return "F" + Math.random().toString(36).substr(3, 3) + (+`${Date.now()}`).toString(36) + t.toString(36) + "c";
}
function oe(t, e, r) {
  let n = t, s;
  return (e || "").split(".").forEach((i) => {
    s && ((!n[s] || typeof n[s] != "object") && (n[s] = {}), n = n[s]), s = i;
  }), n[s] = r, n;
}
const Qr = "fcGroup", Xr = /* @__PURE__ */ ge({
  name: Qr,
  props: {
    field: String,
    rule: Array,
    expand: Number,
    options: Object,
    button: {
      type: Boolean,
      default: !0
    },
    max: {
      type: Number,
      default: 0
    },
    min: {
      type: Number,
      default: 0
    },
    modelValue: {
      type: Array,
      default: () => []
    },
    defaultValue: Object,
    sortBtn: {
      type: Boolean,
      default: !0
    },
    disabled: {
      type: Boolean,
      default: !1
    },
    syncDisabled: {
      type: Boolean,
      default: !0
    },
    title: {
      type: [String, Function],
      default: null
    },
    type: {
      type: String,
      default: "default"
    },
    onBeforeRemove: {
      type: Function,
      default: () => {
      }
    },
    onBeforeAdd: {
      type: Function,
      default: () => {
      }
    },
    formCreateInject: Object,
    parse: Function
  },
  data() {
    return {
      len: 0,
      cacheRule: {},
      cacheValue: {},
      sort: [],
      form: ie(this.formCreateInject.form.$form())
    };
  },
  emits: ["update:modelValue", "change", "itemMounted", "remove", "add"],
  watch: {
    rule: {
      handler(t, e) {
        Object.keys(this.cacheRule).forEach((r) => {
          const n = this.cacheRule[r];
          if (n.$f) {
            const s = n.$f.formData();
            if (t === e)
              n.$f.deferSyncValue(() => {
                Ve(n.rule, t), n.$f.setValue(s);
              }, !0);
            else {
              const i = n.$f.formData();
              n.$f.once("reloading", () => {
                n.$f.setValue(i);
              }), n.rule = K(t);
            }
          }
        });
      },
      deep: !0
    },
    expand(t) {
      let e = t - this.modelValue.length;
      e > 0 && this.expandRule(e);
    },
    modelValue: {
      handler(t) {
        t = t || [];
        let e = this.sort, r = e.length, n = r - t.length;
        if (n < 0) {
          for (let s = n; s < 0; s++)
            this.addRule(t.length + s, !0);
          for (let s = 0; s < r; s++)
            this.setValue(e[s], t[s]);
        } else {
          if (n > 0)
            for (let s = 0; s < n; s++)
              this.removeRule(e[r - s - 1]);
          t.forEach((s, i) => {
            this.setValue(e[i], t[i]);
          });
        }
      },
      deep: !0
    }
  },
  methods: {
    _value(t) {
      return t && k(t, this.field) ? t[this.field] : t;
    },
    cache(t, e) {
      this.cacheValue[t] = JSON.stringify(e);
    },
    input(t) {
      this.$emit("update:modelValue", t), this.$emit("change", t);
    },
    formData(t, e) {
      const r = this.cacheRule, n = this.sort;
      if (n.filter((i) => r[i] && r[i].$f).length !== n.length)
        return;
      const s = n.map((i) => {
        const o = t === i ? e : _({}, this.cacheRule[i].$f.form), a = this.field ? h.Undef(o[this.field]) ? null : o[this.field] : o;
        return this.cache(i, a), a;
      });
      this.input(s);
    },
    setValue(t, e) {
      const r = this.field;
      r && (e = {
        [r]: this._value(e)
      }), this.cacheValue[t] !== JSON.stringify(r ? e[r] : e) && (this.cacheRule[t].$f && this.cacheRule[t].$f.coverValue(e), this.cache(t, e));
    },
    addRule(t, e) {
      const r = this.formCreateInject.form.copyRules(this.rule || []), n = this.options ? _({}, this.options) : {
        submitBtn: !1,
        resetBtn: !1
      };
      if (this.defaultValue) {
        n.formData || (n.formData = {});
        const s = K(this.defaultValue);
        C(n.formData, this.field ? {
          [this.field]: s
        } : s);
      }
      this.parse && this.parse({
        rule: r,
        options: n,
        index: this.sort.length
      }), this.cacheRule[++this.len] = {
        rule: r,
        options: n
      }, this.sort = Object.keys(this.cacheRule), e && A(() => this.$emit("add", r, Object.keys(this.cacheRule).length - 1));
    },
    add$f(t, e, r) {
      this.cacheRule[e].$f = r, A(() => {
        this.$emit("itemMounted", r, Object.keys(this.cacheRule).indexOf(e));
      });
    },
    removeRule(t, e) {
      const r = Object.keys(this.cacheRule).indexOf(t);
      delete this.cacheRule[t], delete this.cacheValue[t], this.sort = Object.keys(this.cacheRule), e && A(() => this.$emit("remove", r));
    },
    add(t) {
      if (this.disabled || this.onBeforeAdd(this.modelValue) === !1)
        return;
      const e = [...this.modelValue];
      e.push(this.defaultValue ? K(this.defaultValue) : this.field ? null : {}), this.input(e);
    },
    del(t, e) {
      if (this.disabled)
        return;
      const r = () => {
        this.removeRule(e, !0);
        const n = [...this.modelValue];
        n.splice(t, 1), this.input(n);
      };
      Ne(this.onBeforeRemove(this.modelValue, t)).then((n) => {
        n !== !1 && r();
      });
    },
    addIcon(t) {
      return w("div", {
        class: "_fc-group-btn _fc-group-plus-minus",
        onClick: this.add
      }, null);
    },
    delIcon(t, e) {
      return w("div", {
        class: "_fc-group-btn _fc-group-plus-minus _fc-group-minus",
        onClick: () => this.del(t, e)
      }, null);
    },
    sortUpIcon(t) {
      return w("div", {
        class: "_fc-group-btn _fc-group-arrow _fc-group-up",
        onClick: () => this.changeSort(t, -1)
      }, null);
    },
    sortDownIcon(t) {
      return w("div", {
        class: "_fc-group-btn _fc-group-arrow _fc-group-down",
        onClick: () => this.changeSort(t, 1)
      }, null);
    },
    changeSort(t, e) {
      const r = this.sort[t];
      this.sort[t] = this.sort[t + e], this.sort[t + e] = r, this.formCreateInject.subForm(this.sort.map((n) => this.cacheRule[n].$f)), this.formData(0);
    },
    sortIcon(t, e) {
      const r = t > 0, n = t < e - 1, s = [];
      return !r && !n ? s : this.type === "card" && r && n ? (s.push(w("div", {
        class: "_fc-group-btn _fc-group-sort"
      }, [w("div", {
        class: " _fc-group-sort-up",
        onClick: () => this.changeSort(t, -1)
      }, null), w("div", {
        class: " _fc-group-sort-down",
        onClick: () => this.changeSort(t, 1)
      }, null)])), s) : (r && s.push(this.sortUpIcon(t)), n && s.push(this.sortDownIcon(t)), s);
    },
    makeIcon(t, e, r) {
      if (this.$slots.button)
        return this.$slots.button({
          total: t,
          index: e,
          vm: this,
          key: r,
          del: () => this.del(e, r),
          add: this.add
        });
      const n = [];
      if ((!this.max || t < this.max) && t === e + 1 && n.push(this.addIcon(r)), t > this.min && n.push(this.delIcon(e, r)), this.sortBtn) {
        const s = this.sortIcon(e, t);
        s && n.push(...s);
      }
      return n;
    },
    expandRule(t) {
      for (let e = 0; e < t; e++)
        this.modelValue.push(this.field ? null : {});
      this.input([...this.modelValue]);
    },
    getTitle(t, e) {
      return typeof this.title == "function" ? this.title(t, this.modelValue[t], e) : typeof this.title == "string" ? this.title.replace("{index}", t + 1) : !1;
    }
  },
  created() {
    const t = (this.expand || 0) - this.modelValue.length;
    for (let e = 0; e < this.modelValue.length; e++)
      this.addRule(e);
    t > 0 && this.expandRule(t);
  },
  render() {
    const t = this.sort, e = this.button, r = this.form, n = this.disabled, s = this.type === "card", i = t.length === 0 ? this.$slots.default ? this.$slots.default({
      vm: this,
      add: this.add
    }) : w("div", {
      key: "a_def",
      class: "_fc-group-plus-minus _fc-group-add fc-clock",
      onClick: this.add
    }, null) : t.map((o, a) => {
      const {
        rule: l,
        options: u
      } = this.cacheRule[o], f = e && !n ? this.makeIcon(t.length, a, o) : [], d = this.getTitle(a, o);
      return s ? w("div", {
        class: "_fc-group-container",
        key: o
      }, [w("div", {
        class: "_fc-group-header"
      }, [d === !1 ? w("div", {
        class: "_fc-group-idx"
      }, [a + 1]) : null, d !== !1 ? w("div", {
        class: "_fc-group-title"
      }, [d]) : null, w("div", {
        class: "_fc-group-handle fc-clock"
      }, [f.length ? f : null])]), w("div", {
        class: "_fc-group-content"
      }, [w(r, Te({
        key: o
      }, {
        disabled: n,
        "onUpdate:modelValue": (g) => this.formData(o, g),
        "onUpdate:api": (g) => this.add$f(a, o, g),
        inFor: !0,
        modelValue: this.field ? {
          [this.field]: this._value(this.modelValue[a])
        } : this.modelValue[a],
        rule: l,
        option: u,
        extendOption: !0
      }), null)])]) : w("div", {
        class: "_fc-group-container",
        key: o
      }, [w(r, Te({
        key: o
      }, {
        disabled: n,
        "onUpdate:modelValue": (g) => this.formData(o, g),
        "onUpdate:api": (g) => this.add$f(a, o, g),
        inFor: !0,
        modelValue: this.field ? {
          [this.field]: this._value(this.modelValue[a])
        } : this.modelValue[a],
        rule: l,
        option: u,
        extendOption: !0
      }), null), w("div", {
        class: "_fc-group-idx"
      }, [a + 1]), f.length ? w("div", {
        class: "_fc-group-handle fc-clock"
      }, [f]) : null]);
    });
    return w("div", {
      key: "con",
      class: "_fc-group " + (n ? "_fc-group-disabled" : "") + (s ? " _fc-group-card" : "")
    }, [i]);
  }
}), Zr = "fcSubForm", Yr = /* @__PURE__ */ ge({
  name: Zr,
  props: {
    rule: Array,
    options: {
      type: Object,
      default: () => W({
        submitBtn: !1,
        resetBtn: !1
      })
    },
    modelValue: {
      type: Object,
      default: () => ({})
    },
    disabled: {
      type: Boolean,
      default: !1
    },
    syncDisabled: {
      type: Boolean,
      default: !0
    },
    formCreateInject: Object
  },
  data() {
    return {
      cacheValue: {},
      subApi: {},
      form: ie(this.formCreateInject.form.$form())
    };
  },
  emits: ["fc:subform", "update:modelValue", "change", "itemMounted"],
  watch: {
    modelValue(t) {
      this.setValue(t);
    }
  },
  methods: {
    formData(t) {
      this.cacheValue = JSON.stringify(t), this.$emit("update:modelValue", t), this.$emit("change", t);
    },
    setValue(t) {
      const e = JSON.stringify(t);
      this.cacheValue !== e && (this.cacheValue = e, this.subApi.coverValue(t || {}));
    },
    add$f(t) {
      this.subApi = t, A(() => {
        this.$emit("itemMounted", t);
      });
    }
  },
  render() {
    const t = this.form;
    return w(t, {
      disabled: this.disabled,
      "onUpdate:modelValue": this.formData,
      modelValue: this.modelValue,
      "onUpdate:api": this.add$f,
      rule: this.rule,
      option: this.options,
      extendOption: !0
    }, null);
  }
}), en = {
  name: "QuestionCircleOutlined"
}, tn = {
  height: "1em",
  width: "1em",
  xmlns: "http://www.w3.org/2000/svg",
  viewBox: "0 0 1024 1024"
};
function rn(t, e, r, n, s, i) {
  return Me(), Ue("svg", tn, [...e[0] || (e[0] = [
    ve("path", {
      d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z",
      fill: "currentColor"
    }, null, -1),
    ve("path", {
      d: "M623.6 316.7C593.6 290.4 554 276 512 276s-81.6 14.5-111.6 40.7C369.2 344 352 380.7 352 420v7.6c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V420c0-44.1 43.1-80 96-80s96 35.9 96 80c0 31.1-22 59.6-56.1 72.7c-21.2 8.1-39.2 22.3-52.1 40.9c-13.1 19-19.9 41.8-19.9 64.9V620c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8v-22.7a48.3 48.3 0 0 1 30.9-44.8c59-22.7 97.1-74.7 97.1-132.5c.1-39.3-17.1-76-48.3-103.3zM472 732a40 40 0 1 0 80 0a40 40 0 1 0-80 0z",
      fill: "currentColor"
    }, null, -1)
  ])]);
}
const nn = /* @__PURE__ */ qe(en, [["render", rn]]), sn = [
  qr,
  zr,
  Xr,
  Yr,
  nn
], Tt = ["props"], Lt = ["class", "style", "directives"], Nt = ["on", "hook"], ee = (t, e = {}, r = {}) => {
  const n = [...Tt, ...r.normal || []], s = [...Lt, ...r.array || []], i = [...Nt, ...r.functional || []], o = r.props || [];
  return t.reduce((a, l) => {
    for (const u in l)
      if (a[u])
        if (o.indexOf(u) > -1)
          a[u] = ee([l[u]], a[u]);
        else if (n.indexOf(u) > -1)
          a[u] = _(_({}, a[u]), l[u]);
        else if (s.indexOf(u) > -1) {
          const f = a[u] instanceof Array ? a[u] : [a[u]], d = l[u] instanceof Array ? l[u] : [l[u]];
          a[u] = [...f, ...d];
        } else if (i.indexOf(u) > -1)
          for (const f in l[u])
            if (a[u][f]) {
              const d = a[u][f] instanceof Array ? a[u][f] : [a[u][f]], g = l[u][f] instanceof Array ? l[u][f] : [l[u][f]];
              a[u][f] = [...d, ...g];
            } else
              a[u][f] = l[u][f];
        else if (u === "hook")
          for (let f in l[u])
            a[u][f] ? a[u][f] = on(a[u][f], l[u][f]) : a[u][f] = l[u][f];
        else
          a[u] = l[u];
      else
        n.indexOf(u) > -1 || i.indexOf(u) > -1 || o.indexOf(u) > -1 ? a[u] = _({}, l[u]) : s.indexOf(u) > -1 ? a[u] = l[u] instanceof Array ? [...l[u]] : typeof l[u] == "object" ? _({}, l[u]) : l[u] : a[u] = l[u];
    return a;
  }, e);
}, on = (t, e) => function() {
  t && t.apply(this, arguments), e && e.apply(this, arguments);
}, Mt = ["type", "slot", "ignore", "emitPrefix", "value", "name", "native", "hidden", "display", "inject", "options", "emit", "link", "prefix", "suffix", "update", "sync", "optionsTo", "key", "slotUpdate", "computed", "preview", "component", "cache", "modelEmit"], it = ["validate", "children", "control"], st = ["effect", "deep", "renderSlots"];
function Ut() {
  return [...Mt, ...Tt, ...Lt, ...Nt, ...it, ...st];
}
function L(t) {
  const e = t.replace(/(-[a-z])/g, function(r) {
    return r.replace("-", "").toLocaleUpperCase();
  });
  return qt(e);
}
function qt(t) {
  return t.replace(t[0], t[0].toLowerCase());
}
function rt(t, e) {
  return {
    value: t,
    enumerable: !1,
    configurable: !1,
    writable: !0
  };
}
function Ht(t, e) {
  return Gt([t], e || !1)[0];
}
function Gt(t, e) {
  return Ve([], [...t], e || !1);
}
const an = { array: it, normal: st };
function te(t, e) {
  return ee(Array.isArray(e) ? e : [e], t, an), t;
}
function yt(t) {
  const e = h.Function(t.getRule) ? t.getRule() : t;
  return e.type || (e.type = "input"), e;
}
function ln(t, e) {
  return t ? (Object.keys(e || {}).forEach((r) => {
    e[r] && (t[r] = te(t[r] || {}, e[r]));
  }), t) : e;
}
function zt(t, e) {
  Object.defineProperties(t, Object.keys(e).reduce((r, n) => (r[n] = {
    get() {
      return e[n]();
    }
  }, r), {}));
}
function J(t) {
  return t.__fc__ || (t.__origin__ ? t.__origin__.__fc__ : null);
}
function F(t, e) {
  try {
    e = t();
  } catch (r) {
    Wr(r);
  }
  return e;
}
function Ae() {
  const t = {}, e = (r) => r || "default";
  return {
    setSlot(r, n) {
      r = e(r), !(!n || Array.isArray(n) && n.length) && (t[r] || (t[r] = []), t[r].push(n));
    },
    getSlot(r, n) {
      r = e(r);
      const s = [];
      return (t[r] || []).forEach((i) => {
        if (Array.isArray(i))
          s.push(...i);
        else if (h.Function(i)) {
          const o = i(...n || []);
          Array.isArray(o) ? s.push(...o) : s.push(o);
        } else h.Undef(i) || s.push(i);
      }), s;
    },
    getSlots() {
      const r = {};
      return Object.keys(t).forEach((n) => {
        r[n] = (...s) => this.getSlot(n, s);
      }), r;
    },
    slotLen(r) {
      return r = e(r), t[r] ? t[r].length : 0;
    },
    mergeBag(r) {
      if (!r) return this;
      const n = h.Function(r.getSlots) ? r.getSlots() : r;
      return Array.isArray(r) || gr(r) ? this.setSlot(void 0, () => r) : Object.keys(n).forEach((s) => {
        this.setSlot(s, n[s]);
      }), this;
    }
  };
}
function bt(t) {
  const e = _({}, t.props || {});
  return Object.keys(t.on || {}).forEach((r) => {
    r.indexOf("-") > 0 && (r = L(r));
    const n = `on${Pt(r)}`;
    Array.isArray(e[n]) ? e[n] = [...e[n], t.on[r]] : e[n] ? e[n] = [e[n], t.on[r]] : e[n] = t.on[r];
  }), e.key = t.key, e.ref = t.ref, e.class = t.class, e.id = t.id, e.style = t.style, e.slot && delete e.slot, e;
}
function Pe(t, e) {
  return Object.setPrototypeOf(t, e), t;
}
const $t = (t, e) => typeof t == "string" ? String(e) : typeof t == "number" ? Number(e) : e, me = {
  "==": (t, e) => JSON.stringify(t) === JSON.stringify($t(t, e)),
  "!=": (t, e) => !me["=="](t, e),
  ">": (t, e) => t > e,
  ">=": (t, e) => t >= e,
  "<": (t, e) => t < e,
  "<=": (t, e) => t <= e,
  on(t, e) {
    return t && t.indexOf && t.indexOf($t(t[0], e)) > -1;
  },
  notOn(t, e) {
    return !me.on(t, e);
  },
  in(t, e) {
    return e && e.indexOf && e.indexOf(t) > -1;
  },
  notIn(t, e) {
    return !me.in(t, e);
  },
  between(t, e) {
    return t > e[0] && t < e[1];
  },
  notBetween(t, e) {
    return t < e[0] || t > e[1];
  },
  empty(t) {
    return h.empty(t);
  },
  notEmpty(t) {
    return !h.empty(t);
  },
  pattern(t, e) {
    return new RegExp(e, "g").test(t);
  }
};
function I(t, e) {
  return (Array.isArray(e) ? e : (e || "").split(".")).forEach((r) => {
    t != null && (t = t[r]);
  }), t;
}
function un(t) {
  const e = /{{\s*(.*?)\s*}}/g;
  let r;
  const n = {};
  for (; (r = e.exec(t)) !== null; )
    r[1] && (n[r[1]] = !0);
  return Object.keys(n);
}
function _t(t) {
  let e = t.split("."), r = [], n = "";
  return e.forEach((s, i) => {
    i === 0 ? n = s : n += "." + s, r.push(n);
  }), r.join(" && ");
}
function xt(t) {
  const e = [];
  let r = "", n = 0;
  for (let s = 0; s < t.length; s++) {
    const i = t[s];
    i === "[" ? (n === 0 && r && (e.push({ type: "key", value: r }), r = ""), n++, r += i) : i === "]" ? (n--, r += i, n === 0 && (e.push({
      type: "bracket",
      value: xt(r.slice(1, -1))
    }), r = "")) : i === "." && n === 0 ? r && (e.push({ type: "key", value: r }), r = "") : r += i;
  }
  return r && e.push({ type: "key", value: r }), e.map((s) => s.type === "key" ? { key: s.value } : { children: s.value });
}
const Be = (t, e) => {
  if (!(!t || t === e)) {
    if (t.props.formCreateInject)
      return t.props.formCreateInject;
    if (t.parent)
      return Be(t.parent, e);
  }
};
function fn() {
  return typeof document != "undefined" && typeof document.createElement == "function" && document.head != null;
}
function cn(t, e, r) {
  return ge({
    name: "FormCreate" + (t.isMobile ? "Mobile" : ""),
    components: e,
    directives: r,
    props: {
      rule: {
        type: Array,
        required: !0,
        default: () => []
      },
      option: {
        type: Object,
        default: () => ({})
      },
      extendOption: Boolean,
      driver: [String, Object],
      modelValue: Object,
      disabled: {
        type: Boolean,
        default: void 0
      },
      preview: {
        type: Boolean,
        default: void 0
      },
      index: [String, Number],
      api: Object,
      locale: [String, Object],
      t: Function,
      name: String,
      subForm: {
        type: Boolean,
        default: !0
      },
      inFor: Boolean
    },
    emits: ["update:api", "update:modelValue", "mounted", "beforeUnmount", "submit", "reset", "change", "emit-event", "control", "remove-rule", "remove-field", "sync", "reload", "repeat-field", "update", "validate-field-fail", "validate-fail", "created"],
    render() {
      return this.fc.render();
    },
    setup(n) {
      const s = Ze();
      yr("parentFC", s);
      const i = br("parentFC", null);
      let o = i;
      if (i)
        for (; o.setupState.parent; )
          o = o.setupState.parent;
      else
        o = s;
      const { rule: a, modelValue: l, subForm: u, inFor: f } = pt(n), d = W({
        ctxInject: {},
        destroyed: !1,
        isShow: !0,
        unique: 1,
        renderRule: [...a.value || []]
      });
      let g = JSON.stringify(l.value || {});
      const p = new t(s), b = p.api(), v = f.value, O = () => {
        if (i) {
          const E = Be(s, i);
          if (E) {
            let D;
            v ? (D = z(E.getSubForm()), D.push(b)) : D = b, E.subForm(D);
          }
        }
      }, Z = () => {
        const E = Be(s, i);
        if (E)
          if (v) {
            const D = z(E.getSubForm()), H = D.indexOf(b);
            H > -1 && D.splice(H, 1);
          } else
            E.subForm();
      };
      let P = null;
      $r(() => {
        fn() && _r(() => {
          let E = "";
          const D = n.option && n.option.globalClass || {};
          Object.keys(D).forEach((H) => {
            let $e = "";
            D[H].style && Object.keys(D[H].style).forEach((Ee) => {
              $e += Oe(Ee) + ":" + D[H].style[Ee] + ";";
            }), D[H].content && ($e += D[H].content + ";"), $e && (E += `.${H}{${$e}}`);
          }), n.option && n.option.style && (E += n.option.style), P || (P = document.createElement("style"), P.type = "text/css", document.head.appendChild(P)), P.innerHTML = E || "";
        });
      });
      const B = se(() => {
        p.bus.$emit("$loadData.$topForm");
      }, 100), ye = se(function() {
        p.bus.$emit("$loadData.$scopeForm");
      }, 100), Ge = se(() => {
        p.bus.$emit("$loadData.$form");
      }, 100), be = (E) => {
        p.bus.$emit("change-$form." + E);
      };
      return vr(() => {
        i && (b.top.bus.$on("$loadData.$form", B), b.top.bus.$on("change", be)), b !== b.scope && b.scope.bus.$on("$loadData.$scopeForm", ye), p.mounted();
      }), Cr(() => {
        i && (b.top.bus.$off("$loadData.$form", B), b.top.bus.$off("change", be)), b !== b.scope && b.scope.bus.$off("$loadData.$scopeForm", ye), Z(), d.destroyed = !0, p.unmount(), P && P.parentNode && P.parentNode.removeChild(P);
      }), wr(() => {
        p.updated();
      }), O(), N(() => n.option, () => {
        p.initOptions(), b.refresh();
      }, { deep: !0, flush: "sync" }), N(() => [...a.value], (E) => {
        p.$handle.isBreakWatch() || E.length === d.renderRule.length && E.every((D) => d.renderRule.indexOf(D) > -1) || (p.$handle.updateAppendData(), p.$handle.reloadRule(a.value), s.setupState.renderRule());
      }), N(() => [n.disabled, n.preview], () => {
        b.refresh();
      }), N(l, (E) => {
        Re(E || {}) !== g && (b.config.forceCoverValue ? b.coverValue(E || {}) : b.setValue(E || {}));
      }, { deep: !0, flush: "post" }), N(() => n.index, () => {
        b.coverValue({}), p.$handle.updateAppendData(), A(() => {
          A(() => {
            b.clearValidateState();
          });
        });
      }, { flush: "sync" }), T(_({
        fc: ie(p),
        parent: i && ie(i),
        top: ie(o),
        fapi: ie(b)
      }, pt(d)), {
        getGroupInject: () => Be(s, i),
        refresh() {
          ++d.unique;
        },
        renderRule() {
          d.renderRule = [...a.value || []];
        },
        updateValue(E) {
          if (d.destroyed) return;
          const D = Re(E);
          g !== D && (g = D, s.emit("update:modelValue", E), A(() => {
            Ge(), i ? u.value || ye() : (B(), ye());
          }));
        }
      });
    },
    created() {
      const n = Ze();
      n.emit("update:api", n.setupState.fapi), n.setupState.fc.init();
    }
  });
}
function Jt() {
  return {
    props: {},
    on: {},
    options: [],
    children: [],
    hidden: !1,
    display: !0,
    value: void 0
  };
}
function q(t, e) {
  return (r, n, s, i = {}) => {
    const o = new ot(t, r, n, s, i);
    return e && (h.Function(e) ? e(o) : o.props(e)), o;
  };
}
function ot(t, e, r, n, s) {
  this._data = C(Jt(), { type: t, title: e, field: r, value: n, props: s || {} }), this.event = this.on;
}
C(ot.prototype, {
  getRule() {
    return this._data;
  },
  setProp(t, e) {
    return U(this._data, t, e), this;
  },
  modelField(t) {
    return this._data.modelField = t, this;
  },
  _clone() {
    const t = new this.constructor();
    return t._data = Ht(this._data), t;
  }
});
function Wt(t) {
  t.forEach((e) => {
    ot.prototype[e] = function(r) {
      return te(this._data, { [e]: arguments.length < 2 ? r : { [r]: arguments[1] } }), this;
    };
  });
}
Wt(Ut());
const dn = q("");
function hn(t, e, r) {
  let n = dn("", e);
  return n._data.type = t, n._data.title = r, n;
}
function pn() {
  return {
    create: hn,
    factory: q
  };
}
function mn(t, e, r) {
  const n = `fail to ${t} ${r.status}'`, s = new Error(n);
  return s.status = r.status, s.url = t, s;
}
function vt(t) {
  const e = t.responseText || t.response;
  if (!e)
    return e;
  try {
    return JSON.parse(e);
  } catch (r) {
    return e;
  }
}
function Kt(t) {
  if (typeof XMLHttpRequest == "undefined")
    return;
  const e = new XMLHttpRequest();
  let r = t.action || "";
  if (e.upload && t.onProgress && e.upload.addEventListener("progress", (i) => {
    i.percent = i.total > 0 ? i.loaded / i.total * 100 : 0, t.onProgress(i);
  }), t.query) {
    const i = h.String(t.query) ? t.query : Object.keys(t.query).reduce((a, l) => (a[l] = t.query[l] === null || t.query[l] === void 0 ? "" : t.query[l], a), {}), o = new URLSearchParams(i).toString();
    o && (r.includes("?") ? r += `&${o}` : r += `?${o}`);
  }
  e.onerror = function(o) {
    t.onError(o);
  }, e.onload = function() {
    if (e.status < 200 || e.status >= 300)
      return t.onError(mn(r, t, e), vt(e));
    t.onSuccess(vt(e));
  }, e.open(t.method || "get", r, !0);
  let n;
  (t.data || t.file) && (t.file || (t.dataType || "").toLowerCase() !== "json" ? (n = new FormData(), Object.keys(t.data || {}).map((i) => {
    n.append(i, t.data[i]);
  })) : (n = JSON.stringify(t.data || {}), e.setRequestHeader("content-type", "application/json"))), t.file && n.append(t.filename, t.file, t.file.name), t.withCredentials && "withCredentials" in e && (e.withCredentials = !0);
  const s = t.headers || {};
  Object.keys(s).forEach((i) => {
    s[i] != null && e.setRequestHeader(i, s[i]);
  }), e.send(n);
}
function Ct(t, e, r) {
  return new Promise((n, s) => {
    (e || Kt)(T(_({}, t), {
      onSuccess(i) {
        let o = (l) => l;
        const a = Q(t.parse);
        h.Function(a) ? o = a : a && h.String(a) && (o = (l) => I(l, a)), Ne(o(i, t.targetRule, r)).then((l) => {
          n(l);
        });
      },
      onError(i) {
        s(i);
      }
    }));
  });
}
function Ce(t) {
  return K(t);
}
function gn(t) {
  function e(i) {
    return h.Undef(i) ? i = t.fields() : Array.isArray(i) || (i = [i]), i;
  }
  function r(i, o, a) {
    h.Undef(i) ? i = Object.keys(_(_({}, t.fieldCtx), t.nameCtx)) : Array.isArray(i) || (i = [i]), i.forEach((l) => {
      const u = t.fieldCtx[l] || t.nameCtx[l];
      u && u.forEach((f) => {
        U(f.rule, o, a), t.$render.clearCache(f);
      });
    });
  }
  function n() {
    const i = t.subForm;
    return Object.keys(i).reduce((o, a) => {
      const l = i[a];
      return l && (Array.isArray(l) ? o.push(...l) : o.push(l)), o;
    }, []);
  }
  const s = {
    get isScope() {
      return t.vm.props.subForm === !1;
    },
    get isPreview() {
      return t.preview;
    },
    get config() {
      return t.options;
    },
    set config(i) {
      t.fc.options.value = i;
    },
    get options() {
      return t.options;
    },
    set options(i) {
      t.fc.options.value = i;
    },
    get form() {
      return t.form;
    },
    get rule() {
      return t.rules;
    },
    get parent() {
      return t.vm.setupState.parent && t.vm.setupState.parent.setupState.fapi;
    },
    get top() {
      return s.parent ? s.parent.top : s;
    },
    get scope() {
      let i = t.vm;
      for (; i && i.setupState.fapi; )
        if (i.props.subForm)
          i = i.setupState.parent;
        else
          return i.setupState.fapi;
      return s.top;
    },
    get children() {
      return n();
    },
    get siblings() {
      const i = t.vm.setupState.getGroupInject();
      if (i) {
        const o = i.getSubForm();
        if (Array.isArray(o))
          return [...o];
      }
    },
    get index() {
      const i = s.siblings;
      if (i) {
        const o = i.indexOf(s);
        return o > -1 ? o : void 0;
      }
    },
    get formulas() {
      return _({}, t.fc.formulas);
    },
    formData(i) {
      if (i == null || typeof i == "boolean") {
        const o = {};
        return Object.keys(t.form).forEach((a) => {
          (i === !0 || t.ignoreFields.indexOf(a) === -1) && (o[a] = Ce(t.form[a]));
        }), o;
      } else
        return e(i).reduce((o, a) => (o[a] = s.getValue(a), o), {});
    },
    getValue(i) {
      const o = t.getFieldCtx(i);
      return o ? Ce(o.rule.value) : t.options.appendValue !== !1 && k(t.appendData, i) ? Ce(t.appendData[i]) : void 0;
    },
    coverValue(i) {
      const o = _({}, i || {});
      t.deferSyncValue(() => {
        t.appendData = {}, s.fields().forEach((a) => {
          const l = t.fieldCtx[a];
          if (l) {
            const u = k(i, a);
            l.forEach((f) => {
              f.rule.value = u ? i[a] : void 0;
            }), delete o[a];
          }
        }), C(t.appendData, o);
      }, !0);
    },
    setValue(i) {
      let o = i;
      arguments.length >= 2 && (o = { [i]: arguments[1] }), t.deferSyncValue(() => {
        Object.keys(o).forEach((a) => {
          const l = t.fieldCtx[a];
          if (!l) return t.appendData[a] = o[a];
          l.forEach((u) => {
            u.rule.value = o[a];
          });
        });
      }, !0);
    },
    removeField(i) {
      const o = t.getCtx(i);
      return t.deferSyncValue(() => {
        t.getCtxs(i).forEach((a) => {
          a.rm();
        });
      }, !0), o ? o.origin : void 0;
    },
    removeRule(i) {
      const o = i && J(i);
      if (o)
        return o.rm(), o.origin;
    },
    fields: () => t.fields(),
    append: (i, o, a) => {
      let l = t.sort.length - 1, u;
      const f = t.getCtx(o);
      if (f)
        if (a) {
          if (u = f.getPending("children", f.rule.children), !Array.isArray(u)) return;
          l = f.rule.children.length - 1;
        } else
          l = f.root.indexOf(f.origin), u = f.root;
      else u = t.rules;
      u.splice(l + 1, 0, i);
    },
    prepend: (i, o, a) => {
      let l = 0, u;
      const f = t.getCtx(o);
      if (f)
        if (a) {
          if (u = f.getPending("children", f.rule.children), !Array.isArray(u)) return;
        } else
          l = f.root.indexOf(f.origin), u = f.root;
      else u = t.rules;
      u.splice(l, 0, i);
    },
    hidden(i, o) {
      r(o, "hidden", !!i), t.refresh();
    },
    hiddenStatus(i) {
      const o = t.getCtx(i);
      if (o)
        return !!o.rule.hidden;
    },
    display(i, o) {
      r(o, "display", !!i), t.refresh();
    },
    displayStatus(i) {
      const o = t.getCtx(i);
      if (o)
        return !!o.rule.display;
    },
    disabled(i, o) {
      e(o).forEach((a) => {
        t.getCtxs(a).forEach((l) => {
          U(l.rule.props, "disabled", !!i);
        });
      }), t.refresh();
    },
    all(i) {
      return Object.keys(t.ctxs).map((o) => {
        const a = t.ctxs[o];
        return i ? a.origin : a.rule;
      });
    },
    model(i) {
      return t.fields().reduce((o, a) => {
        const l = t.fieldCtx[a][0];
        return o[a] = i ? l.origin : l.rule, o;
      }, {});
    },
    component(i) {
      return Object.keys(t.nameCtx).reduce((o, a) => {
        const l = t.nameCtx[a].map((u) => i ? u.origin : u.rule);
        return o[a] = l.length === 1 ? l[0] : l, o;
      }, {});
    },
    bind() {
      return s.form;
    },
    reload: (i) => {
      t.reloadRule(i);
    },
    updateOptions(i) {
      t.fc.updateOptions(i), s.refresh();
    },
    onSubmit(i) {
      s.updateOptions({ onSubmit: i });
    },
    sync: (i) => {
      if (Array.isArray(i)) {
        i.forEach((a) => s.sync(a));
        return;
      }
      let o = h.Object(i) ? J(i) : t.getCtxs(i);
      o && (o = Array.isArray(o) ? o : [o], o.forEach((a) => {
        if (!a.deleted) {
          const l = t.subForm[a.id];
          l && (Array.isArray(l) ? l.forEach((u) => {
            u.refresh();
          }) : l && l.refresh()), t.$render.clearCache(a);
        }
      }), t.refresh());
    },
    refresh: () => {
      n().forEach((i) => {
        i.refresh();
      }), t.$render.clearCacheAll(), t.refresh();
    },
    refreshOptions() {
      t.$manager.updateOptions(t.options), s.refresh();
    },
    hideForm: (i) => {
      t.vm.setupState.isShow = !i;
    },
    changeStatus: () => t.changeStatus,
    clearChangeStatus: () => {
      t.changeStatus = !1;
    },
    updateRule(i, o) {
      t.getCtxs(i).forEach((a) => {
        C(a.rule, o);
      });
    },
    updateRules(i) {
      Object.keys(i).forEach((o) => {
        s.updateRule(o, i[o]);
      });
    },
    mergeRule: (i, o) => {
      t.getCtxs(i).forEach((a) => {
        te(a.rule, o);
      });
    },
    mergeRules(i) {
      Object.keys(i).forEach((o) => {
        s.mergeRule(o, i[o]);
      });
    },
    getRule: (i, o) => {
      const a = t.getCtx(i);
      if (a)
        return o ? a.origin : a.rule;
    },
    findType(i, o) {
      let a;
      return Object.keys(t.ctxs).forEach((l) => {
        const u = t.ctxs[l];
        u.rule.type === i && (a = o ? u.origin : u.rule);
      }), a;
    },
    findTypes(i, o) {
      let a = [];
      return Object.keys(t.ctxs).forEach((l) => {
        const u = t.ctxs[l];
        u.rule.type === i && a.push(o ? u.origin : u.rule);
      }), a;
    },
    getRenderRule: (i) => {
      const o = t.getCtx(i);
      if (o)
        return o.prop;
    },
    getRefRule: (i) => {
      const o = t.getCtxs(i);
      if (o) {
        const a = o.map((l) => l.rule);
        return a.length === 1 ? a[0] : a;
      }
    },
    setEffect(i, o, a) {
      const l = t.getCtx(i);
      l && o && (o[0] === "$" && (o = o.substr(1)), k(l.rule, "$" + o) && U(l.rule, "$" + o, a), k(l.rule, "effect") || (l.rule.effect = {}), U(l.rule.effect, o, a));
    },
    clearEffectData(i, o) {
      const a = t.getCtx(i);
      a && (o && o[0] === "$" && (o = o.substr(1)), a.clearEffectData(o), s.sync(i));
    },
    updateValidate(i, o, a) {
      a ? s.mergeRule(i, { validate: o }) : r(i, "validate", o);
    },
    updateValidates(i, o) {
      Object.keys(i).forEach((a) => {
        s.updateValidate(a, i[a], o);
      });
    },
    refreshValidate() {
      s.refresh();
    },
    resetFields(i) {
      e(i).forEach((o) => {
        t.getCtxs(o).forEach((a) => {
          t.$render.clearCache(a), a.rule.value = Ce(a.defaultValue);
        });
      }), A(() => {
        A(() => {
          A(() => {
            s.clearValidateState(i);
          });
        });
      }), i == null && (h.Function(t.options.onReset) && F(() => t.options.onReset(s)), t.vm.emit("reset", s));
    },
    method(i, o) {
      const a = s.el(i);
      if (!a || !a[o])
        throw new Error(It("err", `${o} 方法不存在`));
      return (...l) => a[o](...l);
    },
    exec(i, o, ...a) {
      return F(() => s.method(i, o)(...a));
    },
    toJson(i) {
      return Re(s.rule, i);
    },
    trigger(i, o, ...a) {
      const l = s.el(i);
      l && l.$emit(o, ...a);
    },
    el(i) {
      const o = t.getCtx(i);
      if (o) return o.el || t.vm.refs[o.ref];
    },
    scrollTo(i, o = { block: "center", inline: "nearest", behavior: "smooth" }) {
      const a = s.el(i);
      if (!a) return;
      const l = a.$el !== void 0 ? a.$el : a;
      if (!l) return;
      const u = l.nodeType === 1 ? l : l.firstElementChild;
      u && typeof u.scrollIntoView == "function" && u.scrollIntoView(o);
    },
    focus(i) {
      const o = s.el(i);
      if (!o) return;
      const a = (d) => !d || typeof d.focus != "function" ? !1 : (F(() => d.focus()), !0);
      if (a(o)) return;
      const l = o.$el !== void 0 ? o.$el : o;
      if (a(l)) return;
      const u = l && (l.nodeType === 1 ? l : l.firstElementChild);
      if (a(u) || !u || !u.querySelector) return;
      const f = u.querySelector('input:not([type=hidden]):not([disabled]),textarea:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])');
      a(f);
    },
    closeModal: (i) => {
      t.bus.$emit("fc:closeModal:" + i);
    },
    getSubForm(i) {
      const o = t.getCtx(i);
      return o ? t.subForm[o.id] : void 0;
    },
    getChildrenRuleList(i) {
      const o = typeof i == "object", a = o ? J(i) : t.getCtx(i), l = a ? a.rule : o ? i : s.getRule(i);
      if (!l)
        return [];
      const u = [];
      return ((d) => {
        d && d.forEach((g) => {
          typeof g == "object" && (g.field && u.push(g), u.push(...s.getChildrenRuleList(g)));
        });
      })(a ? a.loadChildrenPending() : l.children), u;
    },
    getParentRule(i) {
      return (typeof i == "object" ? J(i) : t.getCtx(i)).parent.rule;
    },
    getParentSubRule(i) {
      const a = typeof i == "object" ? J(i) : t.getCtx(i);
      if (a) {
        const l = a.getParentGroup();
        if (l)
          return l.rule;
      }
    },
    getChildrenFormData(i, o) {
      return s.getChildrenRuleList(i).reduce((l, u) => ((u.ignore !== !0 || o === !0) && (l[u.field] = Ce(u.value)), l), {});
    },
    setChildrenFormData(i, o, a) {
      const l = s.getChildrenRuleList(i);
      t.deferSyncValue(() => {
        l.forEach((u) => {
          k(o, u.field) ? u.value = o[u.field] : a && (u.value = void 0);
        });
      });
    },
    getGlobalEvent(i) {
      let o = s.options.globalEvent[i];
      if (o)
        return typeof o == "object" && (o = o.handle), Q(o);
    },
    getGlobalData(i) {
      return new Promise((o, a) => {
        let l = s.options.globalData[i];
        l ? l.type === "fetch" ? s.fetch(l).then((u) => {
          o(u);
        }).catch(a) : o(l.data) : o(t.fc.loadData[i]);
      });
    },
    emitGlobalEvent(i, ...o) {
      const a = s.getGlobalEvent(i);
      if (a) {
        const l = t.getInjectData({}, void 0);
        return l.args = [...o], o.unshift(l), a.apply(null, o);
      }
    },
    setGlobalData(i, o) {
      s.setData("$globalData." + i, o);
    },
    setGlobalVar(i, o) {
      s.setData("$var." + i, o);
    },
    renderRule(i, o, a) {
      const u = typeof i == "object" ? J(i) : t.getCtx(i);
      return u ? t.$render.createRuleVnode(u, o, a) : void 0;
    },
    renderChildren(i, o, a) {
      const u = typeof i == "object" ? J(i) : t.getCtx(i);
      return u ? t.$render.createChildrenVnodes(u, o, a) : void 0;
    },
    nextTick(i) {
      t.bus.$once("next-tick", i), t.refresh();
    },
    nextRefresh(i) {
      t.nextRefresh(), i && F(i);
    },
    deferSyncValue(i, o) {
      t.deferSyncValue(i, o);
    },
    emit(i, ...o) {
      t.vm.emitsOptions && !t.vm.emitsOptions[i] && (t.vm.emitsOptions[i] = null), t.vm.emit(i, ...o);
    },
    bus: t.bus,
    getCurrentFormRule() {
      var i;
      return (i = t.vm.setupState.getGroupInject()) == null ? void 0 : i.rule;
    },
    fetch(i) {
      return new Promise((o, a) => {
        let l = _({}, i);
        l = t.loadFetchVar(l);
        const u = (f) => {
          F(() => l.onError && l.onError(f)), a(f);
        };
        t.beforeFetch(l).then(() => Ct(l, t.fc.create.fetch, s).then((f) => {
          F(() => l.onSuccess && l.onSuccess(f)), o(f);
        }).catch((f) => {
          u(f);
        })).catch((f) => {
          u(f);
        });
      });
    },
    watchFetch(i, o, a, l) {
      return t.fc.watchLoadData((u, f) => {
        let d = _({}, i);
        if (d = t.loadFetchVar(d, u), l && l(d, f) === !1)
          return;
        const g = (p) => {
          F(() => d.onError && d.onError(p)), a && a(p);
        };
        t.beforeFetch(d).then(() => Ct(d, t.fc.create.fetch, s).then((p) => {
          F(() => d.onSuccess && d.onSuccess(p)), o && o(p, f);
        }).catch((p) => {
          g(p);
        })).catch((p) => {
          g(p);
        });
      }, i.wait == null ? 1e3 : i.wait);
    },
    getData(i, o) {
      return t.fc.get ? t.fc.get(i, o) : t.fc.getLoadData(i, o);
    },
    watchData(i) {
      return t.fc.watchLoadData((o, a) => {
        F(() => i(o, a));
      });
    },
    setData(i, o, a) {
      return t.fc.setData(i, o, a);
    },
    refreshData(i) {
      return t.fc.refreshData(i);
    },
    t(i, o) {
      return t.fc.t(i, o);
    },
    getLocale() {
      return t.fc.getLocale();
    },
    helper: {
      tidyFields: e,
      props: r
    }
  };
  return ["on", "once", "off"].forEach((i) => {
    s[i] = function(...o) {
      t.bus[`$${i}`](...o);
    };
  }), s.changeValue = s.changeField = s.setValue, s;
}
function yn(t) {
  C(t.prototype, {
    initCache() {
      this.clearCacheAll();
    },
    clearCache(e) {
      if (!e.rule.cache) {
        if (!this.cache[e.id]) {
          e.parent && this.clearCache(e.parent);
          return;
        }
        (this.cache[e.id].use === !0 || this.cache[e.id].parent) && this.$handle.refresh(), this.cache[e.id].parent && this.clearCache(this.cache[e.id].parent), this.cache[e.id] = null;
      }
    },
    clearCacheAll() {
      this.cache = {};
    },
    setCache(e, r, n) {
      this.cache[e.id] = {
        vnode: r,
        use: !1,
        parent: n,
        slot: e.rule.slot
      };
    },
    getCache(e) {
      const r = this.cache[e.id];
      if (r)
        return r.use = !0, r.vnode;
    }
  });
}
function bn(t) {
  C(t.prototype, {
    initRender() {
      this.cacheConfig = {};
    },
    getTypeSlot(e) {
      const r = (n) => {
        if (n) {
          let s;
          return e.rule.field && (s = n.slots["field-" + Oe(e.rule.field)] || n.slots["field-" + e.rule.field]), s || (s = n.slots["type-" + Oe(e.type)] || n.slots["type-" + e.type]), s || r(n.setupState.parent);
        }
      };
      return r(this.vm);
    },
    render() {
      if (!this.vm.setupState.isShow)
        return;
      this.$manager.beforeRender(), this.applyShowNumber(this.$manager.rule);
      const e = Ae();
      return this.sort.forEach((r) => {
        this.renderSlot(e, this.$handle.ctxs[r]);
      }), this.$manager.render(e);
    },
    applyShowNumber(e) {
      const r = this.$handle.options || {};
      if (!r.showNumber || !e)
        return;
      e.class = this.mergeClass(e.class, "is-numbered"), r.showNumber === "chinese" && (e.class = this.mergeClass(e.class, "is-number-chinese"));
      const n = r.numberColor, s = (r.form || {}).style;
      if (!n) {
        e.style = s;
        return;
      }
      h.String(s) ? e.style = `${s};--fc-number-color:${n}` : Array.isArray(s) ? e.style = s.concat({ "--fc-number-color": n }) : e.style = T(_({}, s || {}), { "--fc-number-color": n });
    },
    renderSlot(e, r, n) {
      if (this.isFragment(r)) {
        r.initProp(), this.mergeGlobal(r), r.initNone();
        const s = this.renderChildren(r.loadChildrenPending(), r), i = s.default;
        i && e.setSlot(r.rule.slot, () => i()), delete s.default, e.mergeBag(s);
      } else
        e.setSlot(r.rule.slot, this.renderCtx(r, n));
    },
    mergeGlobal(e) {
      if (!this.$handle.options.global) return;
      const { trueType: n, originType: s, type: i } = e;
      this.cacheConfig[n] || (this.cacheConfig[n] = _e(() => {
        const o = this.$handle.options.global;
        return te({}, [o["*"] || o.default || {}, o[s] || o[i] || {}]);
      })), e.prop = te({}, [this.cacheConfig[e.trueType].value, e.prop]);
    },
    setOptions(e) {
      const r = e.loadPending({ key: "options", origin: e.prop.options, def: [] });
      e.prop.options = r, e.prop.optionsTo && r && oe(e.prop, e.prop.optionsTo, r);
    },
    deepSet(e) {
      const r = e.prop.deep;
      r && Object.keys(r).sort((n, s) => n.length < s.length ? -1 : 1).forEach((n) => {
        oe(e.prop, n, r[n]);
      });
    },
    parseSide(e, r) {
      return h.Object(e) ? te({ props: { formCreateInject: r.prop.props.formCreateInject } }, e) : e;
    },
    renderSides(e, r, n) {
      const s = r[n ? "rule" : "prop"];
      return [this.renderRule(this.parseSide(s.prefix, r)), e, this.renderRule(this.parseSide(s.suffix, r))];
    },
    renderId(e, r) {
      const n = this.$handle[r === "field" ? "fieldCtx" : "nameCtx"][e];
      return n ? n.map((s) => this.renderCtx(s, s.parent)) : void 0;
    },
    renderCtx(e, r) {
      try {
        if (e.type === "hidden") return;
        const n = e.rule;
        if (this.force || !this.cache[e.id] || this.cache[e.id].slot !== n.slot) {
          let s;
          e.initProp(), this.mergeGlobal(e), e.initNone(), this.$manager.tidyRule(e), this.deepSet(e), this.setOptions(e), this.ctxProp(e);
          let i = e.prop;
          i.preview = !!(i.preview != null ? i.preview : this.$handle.preview), i.props.formCreateInject = this.injectProp(e);
          let o = i.cache !== !1;
          const a = i.preview;
          if (i.hidden) {
            this.setCache(e, void 0, r);
            return;
          }
          s = (...l) => {
            var b, v;
            const u = {
              rule: n,
              prop: i,
              preview: a,
              api: this.$handle.api,
              model: i.model || {},
              slotValue: l
            };
            l.length && n.slotUpdate && F(() => n.slotUpdate(u));
            let f = {};
            const d = e.loadChildrenPending();
            e.parser.renderChildren ? f = e.parser.renderChildren(d, e) : e.parser.loadChildren !== !1 && (f = this.renderChildren(d, e)), Object.keys(i.renderSlots || {}).forEach((O) => {
              f[O] = (...Z) => {
                if (h.Function(i.renderSlots[O]))
                  return F(() => i.renderSlots[O](...Z));
                const P = this.parseSide(i.renderSlots[O], e);
                return this.renderRule(P);
              };
            });
            const g = this.getTypeSlot(e);
            let p;
            return g ? (u.children = f, p = g(u)) : p = a ? e.parser.preview(Ye(f), e) : e.parser.render(Ye(f), e), p = this.renderSides(p, e), (b = i.title) != null && b.show && (i.wrap = _({ show: !0 }, i.wrap || {}), i.native || (i.native = !1)), (!(!e.input && h.Undef(i.native)) || ((v = i.col) == null ? void 0 : v.show) === !0) && i.native !== !0 && (this.fc.targetFormDriver("updateWrap", e), p = this.$manager.makeWrap(e, p)), e.none && (Array.isArray(p) ? p = p.map((O) => !O || !O.__v_isVNode ? O : this.none(O)) : p = this.none(p)), o && this.setCache(e, () => this.stable(p), r), p;
          }, this.setCache(e, s, r);
        }
        return (...s) => {
          const i = this.getCache(e);
          if (i)
            return i(...s);
          if (this.cache[e.id])
            return;
          const o = this.renderCtx(e, e.parent);
          if (o)
            return o();
        };
      } catch (n) {
        console.error(n);
        return;
      }
    },
    none(e) {
      if (e)
        return e.props.class = this.mergeClass(e.props.class, "fc-none"), e;
    },
    mergeClass(e, r) {
      if (Array.isArray(e))
        e.push(r);
      else
        return e ? [e, r] : r;
      return e;
    },
    stable(e) {
      return (Array.isArray(e) ? e : [e]).forEach((n) => {
        n && n.__v_isVNode && n.children && typeof n.children == "object" && (n.children.$stable = !0, this.stable(n.children));
      }), e;
    },
    getModelField(e) {
      return e.prop.modelField || e.parser.modelField || this.fc.modelFields[this.vNode.aliasMap[e.type]] || this.fc.modelFields[e.type] || this.fc.modelFields[e.originType] || "modelValue";
    },
    isFragment(e) {
      return e.type === "fragment" || e.type === "template";
    },
    injectProp(e) {
      const r = this.vm.setupState;
      r.ctxInject[e.id] || (r.ctxInject[e.id] = {
        api: this.$handle.api,
        form: this.fc.create,
        subForm: (s) => {
          this.$handle.addSubForm(e, s);
        },
        getSubForm: () => this.$handle.subForm[e.id],
        slots: () => this.vm.setupState.top.slots,
        getWrap: () => this.vm.refs[e.wrapRef],
        options: [],
        children: [],
        preview: !1,
        id: e.id,
        field: e.field,
        rule: e.rule,
        input: e.input,
        t: (...s) => this.$handle.api.t(...s),
        updateValue: (s) => {
          this.$handle.onUpdateValue(e, s);
        }
      });
      const n = r.ctxInject[e.id];
      return C(n, {
        preview: e.prop.preview,
        options: e.prop.options,
        children: e.loadChildrenPending()
      }), n;
    },
    //事件回调挂在 ctx 上复用,避免 cache miss 时换新函数逼迫子组件更新
    ensureCtxHandlers(e) {
      if (e.handlers)
        return e.handlers;
      const r = this;
      return e.handlers = {
        vnodeMounted(n) {
          n.el.__rule__ = e.rule, r.onMounted(e, n.el);
        },
        vnodeBeforeUnmount() {
          r.$handle.effect(e, "beforeUnmount"), r.$handle.targetHook(e, "beforeUnmount");
        },
        fcUpdateValue(n) {
          r.$handle.onUpdateValue(e, n);
        },
        fcEl(n) {
          e.exportEl = n, n && ((n.$el || n).__rule__ = e.rule);
        },
        modelCallback(n) {
          r.tmpInput && r.tmpInput(e.field, n, e.rule), r.onInput(e, n);
        },
        modelEmit() {
          r.onEmitInput(e);
        }
      }, e.handlers;
    },
    ctxProp(e) {
      const { ref: r, key: n, rule: s } = e;
      this.$manager.mergeProp(e), e.parser.mergeProp(e);
      const i = this.ensureCtxHandlers(e), o = [
        {
          ref: r,
          key: s.key || `${n}fc`,
          slot: void 0,
          on: {
            vnodeMounted: i.vnodeMounted,
            vnodeBeforeUnmount: i.vnodeBeforeUnmount,
            "fc.updateValue": i.fcUpdateValue,
            "fc.el": i.fcEl
          }
        }
      ];
      if (e.input) {
        this.vm.props.disabled === !0 && (e.prop.props.disabled = !0);
        const a = this.getModelField(e), l = {
          callback: i.modelCallback,
          modelField: a,
          value: this.$handle.getFormData(e)
        };
        o.push({
          on: _({
            [`update:${a}`]: l.callback
          }, e.prop.modelEmit ? {
            [e.prop.modelEmit]: i.modelEmit
          } : {}),
          props: {
            [a]: l.value
          }
        }), e.prop.model = l;
      }
      return ee(o, e.prop), e.prop;
    },
    onMounted(e, r) {
      e.el = this.vm.refs[e.ref] || r, e.parser.mounted(e), this.$handle.effect(e, "mounted"), this.$handle.targetHook(e, "mounted");
    },
    onInput(e, r) {
      if (e.prop.modelEmit) {
        this.$handle.onBaseInput(e, r);
        return;
      }
      this.$handle.onInput(e, r);
    },
    onEmitInput(e) {
      this.$handle.setValue(e, e.parser.toValue(e.modelValue, e), e.modelValue);
    },
    renderChildren(e, r) {
      if (!h.trueArray(e)) return {};
      const n = Ae();
      return e.map((s) => {
        if (s) {
          if (h.String(s) || h.Number(s)) return n.setSlot(null, `${s}`);
          if (s.__fc__)
            return this.renderSlot(n, s.__fc__, r);
          s.type && A(() => {
            this.$handle.loadChildren(e, r), this.$handle.refresh();
          });
        }
      }), n.getSlots();
    },
    defaultRender(e, r) {
      const n = e.prop;
      return n.component ? typeof n.component == "string" ? this.vNode.make(n.component, n, r) : this.vNode.makeComponent(n.component, n, r) : this.vNode[e.type] ? this.vNode[e.type](n, r) : this.vNode[e.originType] ? this.vNode[e.originType](n, r) : this.vNode.make(qt(n.type), n, r);
    },
    createChildrenVnodes(e, r, n) {
      this.force = n !== !1, this.tmpInput = r;
      const s = this.renderChildren(e.rule.children, e);
      return this.force = !1, this.tmpInput = null, s;
    },
    createRuleVnode(e, r, n) {
      this.force = n !== !1, this.tmpInput = r;
      const s = Ae();
      return this.renderSlot(s, e, e.parent), this.force = !1, this.tmpInput = null, s.getSlots();
    },
    renderRule(e, r, n) {
      if (!e) return;
      if (h.String(e) || h.Number(e)) return `${e}`;
      let s;
      if (n)
        s = e.type;
      else if (s = e.is, e.type) {
        s = L(e.type);
        const a = this.vNode.aliasMap[s];
        a && (s = L(a));
      }
      if (!s) return;
      const i = Ae();
      h.trueArray(e.children) && e.children.forEach((a) => {
        a && i.setSlot(a == null ? void 0 : a.slot, () => this.renderRule(a));
      });
      const o = _({}, e);
      return delete o.type, delete o.is, this.vNode.make(s, o, i.mergeBag(r).getSlots());
    }
  });
}
let $n = 1;
function at(t) {
  C(this, {
    $handle: t,
    fc: t.fc,
    vm: t.vm,
    $manager: t.$manager,
    vNode: new t.fc.CreateNode(t),
    force: !1,
    tmpInput: null,
    id: $n++
  }), zt(this, {
    options() {
      return t.options;
    },
    sort() {
      return t.sort;
    }
  }), this.initCache(), this.initRender();
}
yn(at);
bn(at);
function _n(t) {
  C(t.prototype, {
    parseInjectEvent(e, r) {
      const n = e.inject || this.options.injectEvent;
      return this.parseEventLst(e, r, n);
    },
    parseEventLst(e, r, n, s) {
      return Object.keys(r).forEach((i) => {
        const o = this.parseEvent(e, r[i], n, s);
        o && (r[i] = o);
      }), r;
    },
    parseEvent(e, r, n, s) {
      if (h.Function(r) && (n !== !1 && !h.Undef(n) || r.__inject))
        return this.inject(e, r, n);
      if (!s && Array.isArray(r) && r[0] && (h.String(r[0]) || h.Function(r[0])))
        return this.parseEventLst(e, r, n, !0);
      if (h.String(r)) {
        const i = Q(r);
        if (i && r !== i)
          return i.__inject ? this.parseEvent(e, i, n, !0) : i;
      }
    },
    parseEmit(e) {
      let r = {}, n = e.rule, { emitPrefix: s, field: i, name: o, inject: a } = n, l = n.emit || [];
      return h.trueArray(l) && l.forEach((u) => {
        if (!u) return;
        let f, d = s || i || o;
        if (h.Object(u) && (f = u.inject, u = u.name, d = u.prefix || d), d) {
          const g = Oe(`${d}-${u}`), p = (...b) => {
            this.vm.emitsOptions && !this.vm.emitsOptions[g] && (this.vm.emitsOptions[g] = null), this.vm.emit(g, ...b), this.vm.emit("emit-event", g, ...b), this.bus.$emit(g, ...b);
          };
          if (p.__emit = !0, !f && a === !1)
            r[L(u)] = p;
          else {
            let b = f || a || this.options.injectEvent;
            r[L(u)] = h.Undef(b) ? p : this.inject(n, p, b);
          }
        }
      }), e.computed.on = r, r;
    },
    getInjectData(e, r) {
      const n = e.__fc__ && e.__fc__.$api, s = e.__fc__ && e.__fc__.$handle.vm || this.vm, { option: i, rule: o } = s.props;
      return {
        $f: n || this.api,
        api: n || this.api,
        rule: o,
        self: e.__origin__,
        option: i,
        inject: r
      };
    },
    inject(e, r, n) {
      if (r.__origin) {
        if (this.watching && !this.loading)
          return r;
        r = r.__origin;
      }
      const s = this, i = function(...o) {
        const a = s.getInjectData(e, n);
        return a.args = [...o], o.unshift(a), r.apply(this, o);
      };
      return i.__origin = r, i.__json = r.__json, i;
    },
    loadStrVar(e, r, n) {
      if (e && typeof e == "string" && e.indexOf("{{") > -1 && e.indexOf("}}") > -1) {
        const s = e, i = un(e), o = (u) => {
          let f = !1, d;
          if (n && u.indexOf("$form.") === 0) {
            const g = u.split(".");
            g.shift(), k(n.value, g[0]) && (f = !0, d = r ? r({
              id: "$form." + g[0] + "_" + n.rule.__fc__.id,
              getValue: () => I(n.value, g)
            }) : I(n.value, g));
          }
          return f || (d = r ? r(u) : this.fc.getLoadData(u)), d;
        }, a = (u) => {
          const f = [];
          u.forEach((g) => {
            g.key ? f.push(g.key) : g.children && f.push(a(g.children));
          });
          let d = !1;
          return f.forEach((g, p) => {
            g != null && (g.indexOf("'") === 0 || g.indexOf('"') === 0) && (f[p] = g.slice(1, -1), d = !0);
          }), f.length === 1 && (d || !isNaN(Number(f[0]))) ? f[0] : o(f.join("."));
        };
        let l;
        if (i.forEach((u) => {
          const f = u.split("||"), d = f[0].trim();
          if (d) {
            const g = (f[1] || "").trim(), p = xt(d);
            let b = F(() => a(p));
            (b == null || b === "") && f.length > 1 && (b = g), l = b, e = e.replaceAll(`{{${u}}}`, b == null ? "" : b);
          }
        }), i.length === 1 && s === `{{${i[0]}}}`)
          return l;
      }
      return e;
    },
    loadFetchVar(e, r, n) {
      let s;
      n && n.__fc__ && (s = n.__fc__.getParentGroup()), !s && e.targetRule && e.targetRule.__fc__ && (s = e.targetRule.__fc__.getParentGroup());
      const i = (o) => this.loadStrVar(o, r, s ? { rule: n, value: this.subRuleData[s.id] || {} } : null);
      return e.action = i(e.action || ""), ["headers", "data", "query"].forEach((o) => {
        if (e[o]) {
          const a = Array.isArray(e[o]) ? [] : {};
          Object.keys(e[o]).forEach((l) => {
            a[i(l)] = i(e[o][l]);
          }), e[o] = a;
        }
      }), e;
    }
  });
}
const wt = ["hook:updated", "hook:mounted"];
function vn(t) {
  C(t.prototype, {
    usePage() {
      const e = this.options.page;
      if (!e) return;
      let r = 25, n = Cn(this.rules);
      h.Object(e) && (e.first && (r = parseInt(e.first, 10) || r), e.limit && (n = parseInt(e.limit, 10) || n)), C(this, {
        first: r,
        limit: n,
        pageEnd: this.rules.length <= r
      }), this.bus.$on("page-end", () => this.vm.emit("page-end", this.api)), this.pageLoad();
    },
    pageLoad() {
      const e = () => {
        this.pageEnd ? (this.bus.$off(wt, e), this.bus.$emit("page-end")) : (this.first += this.limit, this.pageEnd = this.rules.length <= this.first, this.loadRule(), this.refresh());
      };
      this.bus.$on(wt, e);
    }
  });
}
function Cn(t) {
  return t.length < 31 ? 31 : Math.ceil(t.length / 3);
}
function wn(t) {
  C(t.prototype, {
    clearNextTick() {
      this.nextTick && clearTimeout(this.nextTick), this.nextTick = null;
    },
    bindNextTick(e) {
      this.clearNextTick(), this.nextTick = setTimeout(() => {
        e(), this.nextTick = null;
      }, 10);
    },
    render() {
      return ++this.loadedId, this.vm.setupState.unique > 0 ? this.$render.render() : (this.vm.setupState.unique = 1, []);
    }
  });
}
function Sn(t) {
  Object.defineProperties(t.origin, {
    __fc__: rt(ie(t))
  }), t.rule !== t.origin && Object.defineProperties(t.rule, {
    __fc__: rt(ie(t))
  });
}
function Qt(t, e, r) {
  const n = He(), s = !!e.field;
  C(this, {
    id: n,
    ref: n,
    wrapRef: n + "fi",
    rule: e,
    origin: e.__origin__ || e,
    name: e.name,
    pending: {},
    none: !1,
    watch: [],
    linkOn: [],
    root: [],
    ctrlRule: [],
    children: [],
    parent: null,
    group: e.subRule ? this : null,
    cacheConfig: null,
    prop: _({}, e),
    computed: {},
    payload: {},
    refRule: {},
    handlers: null,
    input: s,
    el: void 0,
    exportEl: void 0,
    defaultValue: s ? K(r) : void 0,
    field: e.field || void 0
  }), this.updateKey(), Sn(this), this.update(t, !0);
}
C(Qt.prototype, {
  getParentGroup() {
    let t = this.parent;
    for (; t; ) {
      if (t.group)
        return t;
      t = t.parent;
    }
  },
  loadChildrenPending() {
    const t = this.rule.children || [];
    return Array.isArray(t) ? t : this.loadPending({
      key: "children",
      origin: t,
      def: [],
      onLoad: (e) => {
        this.$handle && this.$handle.loadChildren(e, this);
      },
      onUpdate: (e, r) => {
        this.$handle && (e === r ? this.$handle.loadChildren(e, this) : this.$handle.updateChildren(this, e, r));
      },
      onReload: (e) => {
        this.$handle ? this.$handle.updateChildren(this, [], e) : delete this.pending.children;
      }
    });
  },
  loadPending(t) {
    const { key: e, origin: r, def: n, onLoad: s, onReload: i, onUpdate: o } = t;
    if (this.pending[e] && this.pending[e].origin === r)
      return this.getPending(e, n);
    delete this.pending[e];
    let a = r;
    if (h.Function(r)) {
      let l = F(() => r({
        rule: this.rule,
        api: this.$api,
        update: (u) => {
          const f = u || n, d = this.getPending(e, n);
          this.setPending(e, r, f), o && o(f, d);
        },
        reload: () => {
          const u = this.getPending(e, n);
          delete this.pending[e], i && i(u), this.$api && this.$api.sync(this.rule);
        }
      }));
      l && h.Function(l.then) ? (l.then((u) => {
        const f = u || n;
        this.setPending(e, r, f), s && s(f), this.$api && this.$api.sync(this.rule);
      }).catch((u) => {
        console.error(u);
      }), a = n, this.setPending(e, r, a)) : (a = l || n, this.setPending(e, r, a), s && s(a));
    }
    return a;
  },
  getPending(t, e) {
    return this.pending[t] && this.pending[t].value || e;
  },
  setPending(t, e, r) {
    this.pending[t] = {
      origin: e,
      value: W(r)
    };
  },
  effectData(t) {
    return this.payload[t] || (this.payload[t] = {}), this.payload[t];
  },
  clearEffectData(t) {
    t === void 0 ? this.payload = {} : delete this.payload[t];
  },
  updateKey(t) {
    this.key = He(), t && this.parent && this.parent.updateKey(t);
  },
  updateType() {
    this.originType = this.rule.type, this.type = L(this.rule.type), this.trueType = this.$handle.getType(this.originType);
  },
  setParser(t) {
    this.parser = t, t.init(this);
  },
  initProp() {
    var e, r, n;
    const t = _({}, this.rule);
    delete t.children, delete t.validate, this.prop = te({}, [t, ...Object.keys(this.payload).map((s) => this.payload[s]), this.computed]), t.col && ((e = t.col) == null ? void 0 : e.show) !== !1 && (this.prop.col.show = !0), this.prop.validate = [...((n = (r = this.refRule) == null ? void 0 : r.__$validate) == null ? void 0 : n.value) || [], ...this.prop.validate || []];
  },
  initNone() {
    this.none = !(h.Undef(this.prop.display) || this.prop.display);
  },
  hasHidden() {
    return !!this.rule.hidden || (this.parent ? this.parent.hasHidden() : !1);
  },
  injectValidate() {
    return this.prop.validate;
  },
  check(t) {
    return this.vm === t.vm;
  },
  unwatch() {
    this.watch.forEach((t) => t()), this.watch = [], Object.keys(this.refRule).forEach((t) => {
      t.indexOf("__$") !== 0 && delete this.refRule[t];
    });
  },
  unlink() {
    this.linkOn.forEach((t) => t()), this.linkOn = [];
  },
  link() {
    this.unlink(), this.$handle.appendLink(this);
  },
  watchTo() {
    this.$handle.watchCtx(this);
  },
  delete() {
    this.unwatch(), this.unlink(), this.rmCtrl(), this.parent && this.parent.children.splice(this.parent.children.indexOf(this) >>> 0, 1), C(this, {
      deleted: !0,
      computed: {},
      parent: null,
      children: [],
      cacheConfig: null,
      none: !1,
      handlers: null,
      //rule.__fc__ 是不可配置的强引用,ctx 往往比表单活得更久,
      //这里必须主动释放 DOM,否则已卸载的节点会一直被规则树持有
      el: void 0,
      exportEl: void 0
    });
  },
  rmCtrl() {
    this.ctrlRule.forEach((t) => t.__fc__ && t.__fc__.rm()), this.ctrlRule = [];
  },
  rm() {
    const t = () => {
      let e = this.root.indexOf(this.origin);
      e > -1 && (this.root.splice(e, 1), this.$handle && this.$handle.refresh());
    };
    if (this.deleted) {
      t();
      return;
    }
    this.$handle.noWatch(() => {
      this.$handle.deferSyncValue(() => {
        this.rmCtrl(), t(), this.$handle.rmCtx(this), C(this, {
          root: []
        });
      }, this.input);
    });
  },
  update(t, e) {
    C(this, {
      deleted: !1,
      $handle: t,
      $render: t.$render,
      $api: t.api,
      vm: t.vm,
      vNode: t.$render.vNode,
      updated: !1,
      cacheValue: this.rule.value
    }), !e && this.unwatch(), this.watchTo(), this.link(), this.updateType();
  }
});
function Fn(t) {
  C(t.prototype, {
    nextRefresh(e) {
      const r = this.loadedId;
      A(() => {
        r === this.loadedId && (e ? e() : this.refresh());
      });
    },
    parseRule(e) {
      const r = yt(e);
      return Object.defineProperties(r, {
        __origin__: rt(e)
      }), On(r), this.appendValue(r), [r, r.prefix, r.suffix].forEach((n) => {
        n && this.loadFn(n, r);
      }), this.loadCtrl(r), r.update && (r.update = Q(r.update)), r;
    },
    loadFn(e, r) {
      ["on", "props", "deep"].forEach((n) => {
        e[n] && this.parseInjectEvent(r, e[n]);
      });
    },
    loadCtrl(e) {
      e.control && e.control.forEach((r) => {
        r.handle && (r.handle = Q(r.handle));
      });
    },
    syncProp(e) {
      const r = e.rule;
      h.trueArray(r.sync) && ee([{
        on: r.sync.reduce((n, s) => (n[typeof s == "object" && s.event || `update:${s}`] = (i) => {
          r.props[typeof s == "object" && s.prop || s] = i, this.vm.emit("sync", s, i, r, this.fapi);
        }, n), {})
      }], e.computed);
    },
    loadRule() {
      this.cycleLoad = !1, this.loading = !0, this.pageEnd && this.bus.$emit("load-start"), this.deferSyncValue(() => {
        if (this._loadRule(this.rules), this.loading = !1, this.cycleLoad && this.pageEnd)
          return this.loadRule();
        this.syncForm(), this.pageEnd && this.bus.$emit("load-end"), this.vm.setupState.renderRule();
      });
    },
    loadChildren(e, r) {
      if (this.cycleLoad = !1, this.loading = !0, this.bus.$emit("load-start"), this._loadRule(e, r), this.loading = !1, this.cycleLoad)
        return this.loadRule();
      this.syncForm(), this.bus.$emit("load-end"), this.$render.clearCache(r);
    },
    _loadRule(e, r) {
      const n = (o) => {
        let a = e[o - 1];
        if (!a || !a.__fc__)
          return o > 0 ? n(o - 1) : -1;
        let l = this.sort.indexOf(a.__fc__.id);
        return l > -1 ? l : n(o - 1);
      }, s = (o, a) => {
        h.trueArray(o) && this._loadRule(o, a);
      }, i = e.map((o, a) => {
        if (r && !h.Object(o) || !this.pageEnd && !r && a >= this.first) return;
        if (o.__fc__ && o.__fc__.root === e && this.ctxs[o.__fc__.id])
          return s(o.__fc__.loadChildrenPending(), o.__fc__), o.__fc__;
        let l = yt(o);
        const u = () => !!(l.field && this.fieldCtx[l.field] && this.fieldCtx[l.field][0] !== o.__fc__);
        this.fc.targetFormDriver("loadRule", { rule: l, api: this.api }, this.fc), this.ruleEffect(l, "init", { repeat: u() }), u() && this.vm.emit("repeat-field", o, this.api);
        let f, d = !1, g = !!o.__fc__, p = l.value;
        if (g) {
          if (f = o.__fc__, p = f.defaultValue, f.deleted) {
            if (St(f))
              return;
            f.update(this);
          } else if (!f.check(this)) {
            if (St(f))
              return;
            e[a] = o = o._clone ? o._clone() : Bt(Re(o)), f = null, d = !0;
          }
        }
        if (f)
          f.originType !== f.rule.type && f.updateType(), this.bindParser(f), this.appendValue(f.rule), f.parent && f.parent !== r && this.rmSubRuleData(f);
        else {
          const O = this.parseRule(o);
          f = new Qt(this, O, p), this.bindParser(f);
        }
        this.parseEmit(f), this.syncProp(f), f.parent = r || null, f.root = e, this.setCtx(f), !d && !g && (this.effect(f, "load"), this.targetHook(f, "load")), this.effect(f, "created");
        const b = f.loadChildrenPending();
        if (f.parser.loadChildren === !1 || s(b, f), !r) {
          const O = n(a);
          O > -1 || !a ? this.sort.splice(O + 1, 0, f.id) : this.sort.push(f.id);
        }
        const v = f.rule;
        return f.updated || (f.updated = !0, h.Function(v.update) && this.bus.$once("load-end", () => {
          this.refreshUpdate(f, v.value, "init");
        }), this.effect(f, "loaded")), this.refreshControl(f) && (this.cycleLoad = !0), f;
      }).filter((o) => !!o);
      r && (r.children = i);
    },
    refreshControl(e) {
      return e.input && e.rule.control && this.useCtrl(e);
    },
    useCtrl(e) {
      const r = Rn(e), n = [], s = this.api;
      if (!r.length) return !1;
      for (let a = 0; a < r.length; a++) {
        const l = r[a], u = l.handle || function(d) {
          return (me[l.condition || "=="] || me["=="])(d, l.value);
        };
        if (!h.trueArray(l.rule)) continue;
        const f = T(_({}, l), {
          valid: F(() => u(e.rule.value, s)),
          ctrl: Vn(e, l.rule),
          isHidden: h.String(l.rule[0])
        });
        f.valid && f.ctrl || !f.valid && !f.ctrl && !f.isHidden || n.push(f);
      }
      if (!n.length) return !1;
      const i = [];
      let o = !1;
      return this.deferSyncValue(() => {
        n.reverse().forEach(({ isHidden: a, valid: l, rule: u, prepend: f, append: d, child: g, ctrl: p, method: b }) => {
          if (a) {
            l ? e.ctrlRule.push({
              __ctrl: !0,
              children: u,
              valid: l
            }) : p && e.ctrlRule.splice(e.ctrlRule.indexOf(p) >>> 0, 1), i[l ? "push" : "unshift"](() => {
              b === "disabled" || b === "enabled" ? this.api.disabled(!l, u) : b === "display" || b === "show" ? this.api.display(l, u) : b === "required" ? (u.forEach((v) => {
                this.api.setEffect(v, "required", l);
              }), l || this.api.clearValidateState(u)) : b === "if" ? this.api.hidden(!l, u) : this.api.hidden(!l, u);
            });
            return;
          }
          if (l) {
            o = !0;
            const v = {
              type: "fragment",
              native: !0,
              __ctrl: !0,
              children: u
            };
            e.ctrlRule.push(v), this.bus.$once("load-start", () => {
              f ? s.prepend(v, f, g) : d || g ? s.append(v, d || e.id, g) : e.root.splice(e.root.indexOf(e.origin) + 1, 0, v);
            });
          } else {
            e.ctrlRule.splice(e.ctrlRule.indexOf(p), 1);
            const v = J(p);
            v && v.rm();
          }
        });
      }), i.length && (this.loading ? i.length && this.bus.$once("load-end", () => {
        i.forEach((a) => a());
      }) : i.length && A(() => {
        i.forEach((a) => a());
      })), this.vm.emit("control", e.origin, this.api), this.effect(e, "control"), o;
    },
    reloadRule(e) {
      return this._reloadRule(e);
    },
    _reloadRule(e) {
      e || (e = this.rules);
      const r = _({}, this.ctxs);
      this.clearNextTick(), this.initData(e), this.fc.rules = e, this.deferSyncValue(() => {
        this.bus.$once("load-end", () => {
          Object.keys(r).filter((n) => this.ctxs[n] === void 0).forEach((n) => this.rmCtx(r[n])), this.$render.clearCacheAll();
        }), this.reloading = !0, this.loadRule(), this.reloading = !1, this.refresh(), this.bus.$emit("reloading", this.api);
      }), this.bus.$off("next-tick", this.nextReload), this.bus.$once("next-tick", this.nextReload), this.bus.$emit("update", this.api);
    },
    //todo 组件生成全部通过 alias
    refresh() {
      this.vm.setupState.refresh();
    }
  });
}
function On(t) {
  const e = Jt();
  return Object.keys(e).forEach((r) => {
    k(t, r) || (t[r] = e[r]);
  }), t;
}
function Rn(t) {
  const e = t.rule.control || [];
  return h.Object(e) ? [e] : e;
}
function Vn(t, e) {
  for (let r = 0; r < t.ctrlRule.length; r++) {
    const n = t.ctrlRule[r];
    if (n.children === e)
      return n;
  }
}
function St(t) {
  return !!t.rule.__ctrl;
}
function En(t) {
  C(t.prototype, {
    setValue(e, r, n, s) {
      e.deleted || (e.rule.value = r, this.changeStatus = !0, this.setFormData(e, n), this.$render.clearCache(e), this.nextRefresh(), this.syncValue(), this.valueChange(e, r), this.vm.emit("change", e.field, r, e.origin, this.api, s || !1), this.effect(e, "value"), this.targetHook(e, "value", { value: r }), this.emitEvent("change", e.field, r, {
        rule: e.origin,
        api: this.api,
        setFlag: s || !1
      }), s && A(() => {
        A(() => {
          A(() => {
            this.api.clearValidateState(e.id);
          });
        });
      }), this.$manager.fieldChange(e, r, n, s));
    },
    onInput(e, r) {
      let n;
      e.input && (this.isQuote(e, n = e.parser.toValue(r, e)) || this.isChange(e, r)) && this.setValue(e, n, r);
    },
    onUpdateValue(e, r) {
      this.deferSyncValue(() => {
        const n = e.getParentGroup(), s = n ? this.subRuleData[n.id] : null, i = {};
        Object.keys(r || {}).forEach((o) => {
          s && k(s, o) ? i[o] = r[o] : k(this.api.form, o) ? this.api.form[o] = r[o] : this.api.top !== this.api && k(this.api.top.form, o) && (this.api.top.form[o] = r[o]);
        }), Object.keys(i).length && this.api.setChildrenFormData(n.rule, i);
      });
    },
    onBaseInput(e, r) {
      this.setFormData(e, r), this.$render.clearCache(e), this.nextRefresh();
    },
    setFormData(e, r) {
      e.modelValue = r;
      const n = e.getParentGroup();
      n && (this.subRuleData[n.id] || (this.subRuleData[n.id] = {}), this.subRuleData[n.id][e.field] = e.rule.value), U(this.formData, e.id, r);
    },
    rmSubRuleData(e) {
      const r = e.getParentGroup();
      r && this.subRuleData[r.id] && delete this.subRuleData[r.id][e.field];
    },
    getFormData(e) {
      return this.formData[e.id];
    },
    syncForm() {
      const e = W({}), r = this.fields(), n = [];
      this.options.appendValue !== !1 && Object.keys(this.appendData).reduce((s, i) => (r.indexOf(i) === -1 && (s[i] = Le(this.appendData, i)), s), e), r.reduce((s, i) => {
        let o = (this.fieldCtx[i] || []).filter((a) => !this.isIgnore(a))[0];
        return o || (o = this.fieldCtx[i][0], n.push(i)), s[i] = Le(o.rule, "value"), s;
      }, e), this.form = e, this.ignoreFields = n, this.syncValue();
    },
    isIgnore(e) {
      return e.rule.ignore === !0 || (e.rule.ignore === "hidden" || this.options.ignoreHiddenFields) && e.hasHidden();
    },
    appendValue(e) {
      (!e.field || !k(this.appendData, e.field)) && (!h.Undef(e.value) || !this.options.forceCoverValue) || (e.value = this.appendData[e.field], delete this.appendData[e.field]);
    },
    addSubForm(e, r) {
      this.subForm[e.id] = r;
    },
    deferSyncValue(e, r) {
      this.deferSyncFn || (this.deferSyncFn = e), this.deferSyncFn.sync || (this.deferSyncFn.sync = r), F(e), this.deferSyncFn === e && (this.deferSyncFn = null, e.sync && this.syncForm());
    },
    syncValue() {
      if (this.deferSyncFn)
        return this.deferSyncFn.sync = !0;
      const e = {};
      Object.keys(this.form).forEach((r) => {
        this.ignoreFields.indexOf(r) === -1 && (e[r] = this.form[r]);
      }), this.vm.setupState.updateValue(e);
    },
    isChange(e, r) {
      const n = this.getFormData(e);
      if (n === r)
        return !1;
      const s = typeof n;
      return s === typeof r && (s === "string" || s === "boolean" || s === "number" && Number.isFinite(n) && Number.isFinite(r)) ? !0 : JSON.stringify(n, Ft) !== JSON.stringify(r, Ft);
    },
    isQuote(e, r) {
      return (r instanceof Function || h.Object(r) || Array.isArray(r)) && r === e.rule.value;
    },
    refreshUpdate(e, r, n, s) {
      if (h.Function(e.rule.update)) {
        const i = F(() => e.rule.update(r, e.origin, this.api, {
          origin: n || "change",
          linkField: s
        }));
        if (i === void 0) return;
        e.rule.hidden = i === !0;
      }
    },
    valueChange(e, r) {
      this.refreshRule(e, r), this.bus.$emit("change-" + e.field, r);
    },
    refreshRule(e, r, n, s) {
      this.refreshControl(e) && (this.$render.clearCacheAll(), this.loadRule(), this.bus.$emit("update", this.api), this.refresh()), this.refreshUpdate(e, r, n, s);
    },
    appendLink(e) {
      const r = e.rule.link;
      h.trueArray(r) && r.forEach((n) => {
        const s = () => this.refreshRule(e, e.rule.value, "link", n);
        this.bus.$on("change-" + n, s), e.linkOn.push(() => this.bus.$off("change-" + n, s));
      });
    },
    fields() {
      return Object.keys(this.fieldCtx);
    }
  });
}
function Ft(t, e) {
  return typeof e == "function" ? "" + e : e;
}
const Fe = {
  init(t) {
  },
  toFormValue(t, e) {
    return t;
  },
  toValue(t, e) {
    return t;
  },
  mounted(t) {
  },
  render(t, e) {
    return e.$handle.fc.renderDriver && e.$handle.fc.renderDriver.defaultRender ? e.$handle.fc.renderDriver.defaultRender(e, t) : e.$render.defaultRender(e, t);
  },
  preview(t, e) {
    return e.$handle.fc.renderDriver && e.$handle.fc.renderDriver.defaultPreview ? e.$handle.fc.renderDriver.defaultPreview(e, t) : this.render(t, e);
  },
  mergeProp(t) {
  }
}, kn = ["field", "value", "vm", "template", "name", "config", "control", "inject", "sync", "payload", "optionsTo", "update", "slotUpdate", "computed", "component", "cache"], we = Symbol("oldValue"), Dn = ["$condition", "$variableVal", "$val", "$form", "$scope", "$group", "$rule"], jn = ["$formulas", "$form", "$scope", "$group", "$rule", "$api"], Ie = /* @__PURE__ */ new Map(), An = 1e3;
function Ot(t, e) {
  const r = t.join(",") + "|" + e;
  let n = Ie.get(r);
  return n || (Ie.size >= An && Ie.clear(), n = new Function(...t, e), Ie.set(r, n)), n;
}
function Pn(t) {
  C(t.prototype, {
    //computed 更新原先各自 setTimeout(0),N 个字段同时联动就会拆成 N 个宏任务,
    //Vue 在任务之间各 flush 一次,render 被放大 N 倍。
    //这里改成按入队顺序在同一个宏任务里串行执行,并在 flush 期间继续吞掉级联入队,
    //相对顺序与原先一致,只是把中间多余的渲染合并掉。
    scheduleComputedUpdate(e) {
      (this._computedQueue || (this._computedQueue = [])).push(e), !(this._computedFlushing || this._computedScheduled) && (this._computedScheduled = !0, setTimeout(() => {
        this._computedScheduled = !1, this._computedFlushing = !0;
        try {
          const r = this._computedQueue || [];
          this._computedQueue = [];
          for (let n = 0; n < r.length; n++)
            F(r[n]), this._computedQueue && this._computedQueue.length && (r.push(...this._computedQueue), this._computedQueue = []);
        } finally {
          this._computedFlushing = !1;
        }
      }));
    },
    getCtx(e) {
      return this.getFieldCtx(e) || this.getNameCtx(e)[0] || this.ctxs[e];
    },
    getCtxs(e) {
      return this.fieldCtx[e] || this.nameCtx[e] || (this.ctxs[e] ? [this.ctxs[e]] : []);
    },
    setIdCtx(e, r, n) {
      const s = `${n}Ctx`;
      this[s][r] ? this[s][r].push(e) : this[s][r] = [e];
    },
    rmIdCtx(e, r, n) {
      const s = `${n}Ctx`, i = this[s][r];
      if (!i) return !1;
      const o = i.splice(i.indexOf(e) >>> 0, 1).length > 0;
      return i.length || delete this[s][r], o;
    },
    getFieldCtx(e) {
      return (this.fieldCtx[e] || [])[0];
    },
    getNameCtx(e) {
      return this.nameCtx[e] || [];
    },
    setCtx(e) {
      let { id: r, field: n, name: s, rule: i } = e;
      this.ctxs[r] = e, s && this.setIdCtx(e, s, "name"), e.input && (this.setIdCtx(e, n, "field"), this.setFormData(e, e.parser.toFormValue(i.value, e)), this.isMounted && !this.reloading && this.vm.emit("change", e.field, i.value, e.origin, this.api, !1, !0));
    },
    getParser(e) {
      const r = this.fc.parsers, n = this.fc.renderDriver;
      if (n) {
        const s = n.parsers || {}, i = s[e.originType] || s[L(e.type)] || s[e.trueType];
        if (i)
          return i;
      }
      return r[e.originType] || r[L(e.type)] || r[e.trueType] || Fe;
    },
    bindParser(e) {
      e.setParser(this.getParser(e));
    },
    getType(e) {
      const r = this.fc.CreateNode.aliasMap, n = r[e] || r[L(e)] || e;
      return L(n);
    },
    noWatch(e) {
      this.noWatchFn || (this.noWatchFn = e), F(e), this.noWatchFn === e && (this.noWatchFn = null);
    },
    watchCtx(e) {
      const r = Ut().filter((o) => o[0] !== "_" && o[0] !== "$" && kn.indexOf(o) === -1), n = {}, s = (o, a, l) => (u, f) => {
        let d = a.value;
        if (!this.isBreakWatch()) {
          if (l && e.parser.loadChildren === !1) {
            this.$render.clearCache(e), this.nextRefresh();
            return;
          }
          if (this.watching = !0, A(() => {
            this.targetHook(e, "watch", { key: o, oldValue: f, newValue: d });
          }), o === "hidden" && !!d != !!f && A(() => {
            this.targetHook(e, "hidden", { value: d });
          }), o === "ignore" && e.input || o === "hidden" && (e.rule.ignore === "hidden" || this.options.ignoreHiddenFields))
            this.syncForm();
          else if (o === "link") {
            e.link();
            return;
          } else ["props", "on", "deep"].indexOf(o) > -1 ? (this.parseInjectEvent(e.rule, d || {}), o === "props" && e.input && this.setFormData(e, e.parser.toFormValue(e.rule.value, e))) : o === "emit" ? this.parseEmit(e) : ["prefix", "suffix"].indexOf(o) > -1 ? d && this.loadFn(d, e.rule) : o === "type" ? (e.updateType(), this.bindParser(e)) : l && (h.Function(f) && (f = e.getPending("children", [])), h.Function(d) && (d = e.loadChildrenPending()), this.updateChildren(e, d, f));
          this.$render.clearCache(e), this.refresh(), this.watching = !1;
        }
      }, i = (o, a) => {
        if (n[o]) return;
        n[o] = !0;
        const l = e.refRule[o], u = o === "children", f = s(o, l, u);
        e.watch.push(N(u ? () => h.Function(l.value) ? l.value : [...l.value || []] : () => l.value, f, { deep: !u, sync: u })), a && f(l.value, void 0);
      };
      if (r.forEach((o) => {
        e.refRule[o] = Le(e.rule, o), k(e.rule, o) && i(o);
      }), e.watch.push(N(() => Object.keys(e.rule).join("|"), () => {
        r.forEach((o) => {
          !n[o] && k(e.rule, o) && i(o, !0);
        });
      })), e.refRule.__$title = _e(() => {
        let o = (typeof e.rule.title == "object" ? e.rule.title.title : e.rule.title) || "";
        if (o) {
          const a = o.match(/^\{\{\s*\$t\.(.+)\s*\}\}$/);
          a && (o = this.api.t(a[1]));
        }
        return o;
      }), e.refRule.__$info = _e(() => {
        let o = (typeof e.rule.info == "object" ? e.rule.info.info : e.rule.info) || "";
        if (o) {
          const a = o.match(/^\{\{\s*\$t\.(.+)\s*\}\}$/);
          a && (o = this.api.t(a[1]));
        }
        return o;
      }), e.refRule.__$validate = _e(() => {
        const o = (a) => {
          var u, f;
          const l = a.match(/^\{\{\s*\$t\.(.+)\s*\}\}$/);
          return l ? this.api.t(l[1], { title: (f = (u = e.refRule) == null ? void 0 : u.__$title) == null ? void 0 : f.value }) : a;
        };
        return z(e.rule.validate).map((a) => {
          const l = _({}, a);
          if (l.message && (l.message = o(l.message)), h.Function(l.validator)) {
            const u = e;
            l.validator = function(...f) {
              return a.validator.call({
                that: this,
                id: u.id,
                field: u.field,
                rule: u.rule,
                api: u.$handle.api
              }, ...f);
            };
          }
          if (l.adapter) {
            if (typeof l.error == "object") {
              const u = _({}, l.error);
              Object.keys(u).forEach((f) => {
                u[f] = o(u[f]);
              }), l.error = u;
            }
            return this.adapterValidate(l, e);
          }
          return l;
        });
      }), e.input) {
        const o = Le(e.rule, "value");
        e.watch.push(N(() => o.value, () => {
          let a = e.parser.toFormValue(o.value, e);
          this.isChange(e, a) && this.setValue(e, o.value, a, !0);
        }));
      }
      this.bus.$once("load-end", () => {
        let o = e.rule.computed;
        o && (typeof o != "object" && (o = { value: o }), Object.keys(o).forEach((a) => {
          const l = _e(() => {
            const f = o[a];
            if (!f) return;
            const d = this.compute(e, f);
            return (f.linkage || f.linkageVariable) && d === we ? we : d;
          }), u = (f) => {
            a === "value" ? this.onInput(e, f) : a[0] === "$" ? this.api.setEffect(e.id, a, f) : oe(e.rule, a, f);
          };
          (a === "value" ? [void 0, null, ""].indexOf(e.rule.value) > -1 : l.value !== I(e.rule, a)) && u(l.value), e.watch.push(N(l, (f) => {
            f !== we && this.scheduleComputedUpdate(() => u(f));
          }, { deep: !0 }));
        }));
      }), this.watchEffect(e);
    },
    adapterValidate(e, r) {
      const n = (s, i) => {
        if ((e.beforeValidate && F(() => e.beforeValidate({
          value: s,
          api: this.api,
          validate: e,
          rule: r.rule
        }))) === !1)
          i();
        else {
          const a = this.validator(r, s, e);
          if (a) {
            let l = "";
            typeof e.error == "object" && (l = e.error[a] || e.error.default), !l && typeof e.message == "string" && (l = e.message), l || (l = this.getValidateMessage(r, { key: a, rule: e[a] })), i(l);
          } else if (e.validator) {
            const l = e.validator && F(() => e.validator(s, i));
            l && h.Function(l.then) && l.then(() => i()).catch((u) => i(u));
          } else
            i();
        }
      };
      return this.$manager.adapterValidate({
        required: e.required,
        message: e.message,
        trigger: e.trigger
      }, n);
    },
    getValidateMessage(e, r) {
      var s, i;
      const n = Array.isArray(r.rule) ? r.rule.join(",") : "" + r.rule;
      return this.api.t(r.key === "required" ? r.key : "validate." + r.key, {
        [r.key]: n,
        title: (i = (s = e.refRule) == null ? void 0 : s.__$title) == null ? void 0 : i.value
      });
    },
    validator(e, r, n) {
      if (h.empty(r))
        return n.required ? "required" : void 0;
      for (const [i, o] of Object.entries(n))
        switch (i) {
          case "len":
          case "maxLen":
          case "minLen":
            const a = (b) => i === "len" ? b === o : i === "maxLen" ? b <= o : b >= o;
            if (Array.isArray(r)) {
              if (!a(r.length))
                return i;
            } else {
              if (typeof r == "object")
                return i;
              if (!a(("" + r).length))
                return i;
            }
            break;
          case "pattern":
            if (!(typeof o == "string" ? new RegExp(o) : o).test("" + r))
              return i;
            break;
          case "uppercase":
            if (o && (typeof r != "string" || !/^[A-Z]*$/.test(r)))
              return i;
            break;
          case "lowercase":
            if (o && (typeof r != "string" || !/^[a-z]*$/.test(r)))
              return i;
            break;
          case "min":
          case "max":
          case "positive":
          case "negative":
          case "integer":
          case "number":
            const u = Number(r);
            if (Number.isNaN(u) || i === "min" && u < o || i === "max" && u > o || i === "positive" && u <= 0 || i === "negative" && u >= 0 || i === "integer" && !Number.isInteger(u))
              return i;
            break;
          case "equal":
            if (r !== o)
              return i;
            break;
          case "enum":
            if (Array.isArray(o) && !o.includes(r))
              return i;
            break;
          case "hasKeys":
            if (typeof r != "object" || Array.isArray(o) && o.some((b) => !(b in r)))
              return i;
            break;
          case "email":
            if (!/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test("" + r))
              return i;
            break;
          case "url":
            if (!new RegExp(
              "^(?!mailto:)(?:(?:http|https|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$",
              "i"
            ).test("" + r))
              return i;
            break;
          case "ip":
            if (!/^(2(5[0-5]{1}|[0-4]\d{1})|[0-1]?\d{1,2})(\.(2(5[0-5]{1}|[0-4]\d{1})|[0-1]?\d{1,2})){3}$/.test("" + r))
              return i;
            break;
          case "phone":
            if (!/^(?:(?:\+|00)86)?1[3-9]\d{9}$/.test("" + r))
              return i;
            break;
          case "computed":
            if (!this.compute(e, o))
              return i;
            break;
        }
    },
    compute(e, r) {
      let n;
      if (typeof r == "object") {
        const s = e.getParentGroup(), i = (a) => {
          if (a = Array.isArray(a) ? { mode: "AND", group: a } : a, !h.trueArray(a.group))
            return !0;
          const l = a.mode === "OR";
          let u = !0;
          for (let f = 0; f < a.group.length; f++) {
            const d = a.group[f];
            let g, p = null, b = null;
            if (d.variable)
              b = this.fc.getLoadData(d.variable);
            else if (d.field)
              p = _t(d.field || "");
            else if (!d.mode)
              return !0;
            let v = d.compare;
            if (v && (v = _t(v || "")), d.mode ? g = i(d) : me[d.condition] ? h.Function(d.handler) ? g = F(() => d.handler(this.api, e.rule)) : g = F(() => Ot(Dn, `with($form){with($scope){with(this){with($group){ return $condition['${d.condition}'](${d.variable ? "$variableVal" : p}, ${v || "$val"}); }}}}`).call(this.api.form, me, b, d.value, this.api.top.form, this.api.top === this.api.scope ? {} : this.api.scope.form, s ? this.subRuleData[s.id] || {} : {}, e.rule)) : g = !1, l && g)
              return !0;
            l || (u = u && g);
          }
          return l ? !1 : u;
        };
        let o = i(r);
        return o = r.invert === !0 ? !o : o, r.linkage ? o ? F(() => this.computeValue(r.linkage, e, s), void 0) : we : r.linkageVariable ? o ? F(() => this.fc.getLoadData(r.linkageVariable), void 0) : we : o;
      } else if (h.Function(r))
        n = () => r(this.api.form, this.api, e.rule);
      else {
        const s = e.getParentGroup();
        n = () => this.computeValue(r, e, s);
      }
      return F(n, void 0);
    },
    computeValue(e, r, n) {
      const s = this, i = Object.keys(this.fc.formulas).reduce((o, a) => (o[a] = function(...l) {
        return s.fc.formulas[a].call({
          that: this,
          rule: r.rule,
          api: s.api,
          fc: s.fc
        }, ...l);
      }, o), {});
      return F(() => Ot(jn, `with($form){with($scope){with(this){with($group){with($formulas){ return ${e} }}}}}`).call(this.api.form, i, this.api.top.form, this.api.top === this.api.scope ? {} : this.api.scope.form, n ? this.subRuleData[n.id] || {} : {}, r.rule, this.api), void 0);
    },
    updateChildren(e, r, n) {
      this.deferSyncValue(() => {
        n && n.forEach((s) => {
          (r || []).indexOf(s) === -1 && s && !h.String(s) && s.__fc__ && s.__fc__.parent === e && this.rmCtx(s.__fc__);
        }), h.trueArray(r) && (this.loadChildren(r, e), this.bus.$emit("update", this.api));
      });
    },
    rmSub(e) {
      h.trueArray(e) && e.forEach((r) => {
        r && r.__fc__ && this.rmCtx(r.__fc__);
      });
    },
    rmCtx(e) {
      if (e.deleted) return;
      const { id: r, field: n, input: s, name: i } = e;
      pe(this.ctxs, r), pe(this.formData, r), pe(this.subForm, r), pe(this.vm.setupState.ctxInject, r);
      const o = e.getParentGroup();
      o && this.subRuleData[o.id] && pe(this.subRuleData[o.id], n), e.group && pe(this.subRuleData, r), s && this.rmIdCtx(e, n, "field"), i && this.rmIdCtx(e, i, "name"), s && !k(this.fieldCtx, n) && pe(this.form, n), this.deferSyncValue(() => {
        if (!this.reloading) {
          if (e.parser.loadChildren !== !1) {
            const l = e.getPending("children", e.rule.children);
            h.trueArray(l) && l.forEach((u) => u && u.__fc__ && this.rmCtx(u.__fc__));
          }
          e.root === this.rules && this.vm.setupState.renderRule();
        }
      }, s);
      const a = this.sort.indexOf(r);
      return a > -1 && this.sort.splice(a, 1), this.$render.clearCache(e), e.delete(), this.effect(e, "deleted"), this.targetHook(e, "deleted"), s && !this.fieldCtx[n] && this.vm.emit("remove-field", n, e.rule, this.api), e.rule.__ctrl || this.vm.emit("remove-rule", e.rule, this.api), e;
    }
  });
}
function In(t) {
  C(t.prototype, {
    mounted() {
      const e = () => {
        this.isMounted = !0, this.lifecycle("mounted");
      };
      this.pageEnd ? e() : this.bus.$once("page-end", e);
    },
    lifecycle(e) {
      this.fc.targetFormDriver(e, this.api, this.fc), this.vm.emit(e, this.api), this.emitEvent(e, this.api);
    },
    emitEvent(e, ...r) {
      const n = this.options[e] || this.options[L("on-" + e)];
      if (n) {
        const s = Q(n);
        h.Function(s) && F(() => s(...r));
      }
      this.bus.$emit(e, ...r);
    },
    targetHook(e, r, n) {
      var l, u, f, d;
      let s = (u = (l = e.prop) == null ? void 0 : l.hook) == null ? void 0 : u[r], i = (g, p) => {
        g && (g = Array.isArray(g) ? g : [g], g.forEach((b) => {
          F(() => b(T(_({ args: Object.values(n || {}) }, n || {}), { self: e.rule, rule: e.rule, parent: p == null ? void 0 : p.rule, $f: this.api, api: this.api, option: this.vm.props.option })));
        }));
      };
      i(s);
      let o = "deep" + Pt(r), a = e.parent;
      for (; a; ) {
        let g = (d = (f = a.prop) == null ? void 0 : f.hook) == null ? void 0 : d[o];
        i(g, a), a = a.parent;
      }
    }
  });
}
function Bn(t) {
  C(t.prototype, {
    useProvider() {
      const e = this.fc.providers;
      Object.keys(e).forEach((r) => {
        let n = e[r];
        h.Function(n) && (n = n(this.fc)), n._c = Ln(n), this.onEffect(n, r), this.providers[r] = n;
      });
    },
    onEffect(e, r) {
      const n = [];
      (e._c || ["*"]).forEach((s) => {
        const i = s === "*" ? "*" : this.getType(s);
        n.indexOf(i) > -1 || (n.push(i), this.bus.$on(`p:${r || e.name}:${i}:${e.input ? 1 : 0}`, (o, a) => {
          e[o] && e[o](...a);
        }));
      }), e._used = n;
    },
    watchEffect(e) {
      let r = {
        required: () => {
          var n, s;
          return (k(e.rule, "$required") ? e.rule.$required : (s = (n = e.rule) == null ? void 0 : n.effect) == null ? void 0 : s.required) || !1;
        }
      };
      Object.keys(e.rule.effect || {}).forEach((n) => {
        r[n] = () => e.rule.effect[n];
      }), Object.keys(e.rule).forEach((n) => {
        n[0] === "$" && (r[n.substr(1)] = () => e.rule[n]);
      }), Object.keys(r).forEach((n) => {
        e.watch.push(N(r[n], (s) => {
          this.effect(e, "watch", { [n]: s });
        }, { deep: !0 }));
      });
    },
    ruleEffect(e, r, n) {
      this.emitEffect({
        rule: e,
        input: !!e.field,
        type: this.getType(e.type)
      }, r, n);
    },
    effect(e, r, n) {
      this.emitEffect({
        rule: e.rule,
        input: e.input,
        type: e.trueType,
        ctx: e,
        custom: n
      }, r);
    },
    getEffect(e, r) {
      if (k(e, "$" + r))
        return e["$" + r];
      if (k(e, "effect") && k(e.effect, r))
        return e.effect[r];
    },
    emitEffect({ ctx: e, rule: r, input: n, type: s, custom: i }, o, a) {
      if (!s || ["fcFragment", "fragment"].indexOf(s) > -1) return;
      const l = i || Object.keys(r).reduce((u, f) => (f[0] === "$" && (u[f.substr(1)] = r[f]), u), _({}, r.effect || {}));
      Object.keys(l).forEach((u) => {
        const f = this.providers[u];
        if (!f || f.input && !n) return;
        let d;
        if (!f._c)
          d = "*";
        else if (f._used.indexOf(s) > -1)
          d = s;
        else
          return;
        const g = _({ value: l[u], getValue: () => this.getEffect(r, u) }, a || {});
        e && (g.getProp = () => e.effectData(u), g.clearProp = () => e.clearEffectData(u), g.mergeProp = (p) => te(g.getProp(), [p]), g.id = e.id), this.bus.$emit(`p:${u}:${d}:${f.input ? 1 : 0}`, o, [g, r, this.api]);
      });
    }
  });
}
function Tn(t) {
  return t.filter(function(e, r, n) {
    return n.indexOf(e, 0) === r;
  });
}
function Ln(t) {
  const e = t.components;
  if (Array.isArray(e)) {
    const r = Tn(e.filter((n) => n !== "*"));
    return r.length ? r : !1;
  } else return h.String(e) ? [e] : !1;
}
function X(t) {
  zt(this, {
    options() {
      return t.options.value || {};
    },
    bus() {
      return t.bus;
    },
    preview() {
      return t.vm.props.preview != null ? t.vm.props.preview : t.vm.setupState.parent && t.vm.setupState.parent.props.preview != null ? t.vm.setupState.parent.props.preview : t.options.value.preview || !1;
    }
  }), C(this, {
    fc: t,
    vm: t.vm,
    watching: !1,
    loading: !1,
    reloading: !1,
    noWatchFn: null,
    deferSyncFn: null,
    isMounted: !1,
    formData: W({}),
    subRuleData: W({}),
    subForm: {},
    form: W({}),
    appendData: {},
    ignoreFields: [],
    providers: {},
    cycleLoad: null,
    loadedId: 1,
    nextTick: null,
    changeStatus: !1,
    pageEnd: !0,
    nextReload: () => {
      this.lifecycle("reload");
    }
  }), this.initData(t.rules), this.$manager = new t.manager(this), this.$render = new at(this), this.api = t.extendApiFn.reduce((e, r) => {
    const n = F(() => r(e, this));
    return n && n !== e && C(e, n), e;
  }, gn(this));
}
C(X.prototype, {
  initData(t) {
    C(this, {
      ctxs: {},
      fieldCtx: {},
      nameCtx: {},
      sort: [],
      rules: t
    });
  },
  init() {
    this.updateAppendData(), this.useProvider(), this.usePage(), this.loadRule(), this.$manager.__init(), this.lifecycle("created");
  },
  updateAppendData() {
    this.appendData = _(_(_({}, K(this.options.formData || {})), this.fc.vm.props.modelValue || {}), this.appendData);
  },
  isBreakWatch() {
    return this.loading || this.noWatchFn || this.reloading;
  },
  globalBeforeFetch(t) {
    return new Promise((e, r) => {
      const n = this.options.beforeFetch && F(() => this.options.beforeFetch(t, { api: this.api }));
      n && h.Function(n.then) ? n.then(e).catch(r) : e();
    });
  },
  beforeFetch(t) {
    return new Promise((e, r) => {
      const n = t && t.beforeFetch && F(() => t.beforeFetch(t, { api: this.api }));
      n && h.Function(n.then) ? n.then(e).catch(r) : n === !1 ? r() : e();
    }).then(() => this.globalBeforeFetch(t));
  },
  beforeSubmit(t) {
    return new Promise((e, r) => {
      const n = this.options.beforeSubmit && F(() => this.options.beforeSubmit(t, { api: this.api }));
      n && h.Function(n.then) ? n.then(e).catch(r) : n === !1 ? r() : e();
    });
  }
});
_n(X);
vn(X);
wn(X);
Fn(X);
En(X);
Pn(X);
In(X);
Bn(X);
const Nn = "fcFragment", We = ge({
  name: Nn,
  inheritAttrs: !1,
  props: ["vnode"],
  render() {
    return this.vnode;
  }
});
function Mn(t) {
  return Object.keys(t).map((e) => {
    const r = t[e], n = Fr(e);
    if (n)
      return [
        n,
        r.value,
        r.arg,
        r.modifiers
      ];
  }).filter((e) => !!e);
}
function Rt(t, e) {
  let r = t.directives;
  return r ? (Array.isArray(r) || (r = [r]), Sr(e, r.reduce((n, s) => n.concat(Mn(s)), []))) : e;
}
function Un() {
  const t = {};
  function e(r) {
    this.vm = r.vm, this.handle = r;
  }
  return C(e.prototype, {
    make(r, n, s) {
      return Rt(n, this.h(r, bt(n), s));
    },
    makeComponent(r, n, s) {
      try {
        return Rt(n, w(r, bt(n), s));
      } catch (i) {
        return console.error(i), w("");
      }
    },
    h(r, n, s) {
      const o = (this.vm || Ze()).appContext.config.isNativeTag(r), a = this.handle.fc.prop.components[r];
      !a && o && delete n.formCreateInject;
      try {
        return w(a || (o ? r : G(r)), n, s);
      } catch (l) {
        return console.error(l), w("");
      }
    },
    aliasMap: t
  }), C(e, {
    aliasMap: t,
    alias(r, n) {
      t[r] = n;
    },
    use(r) {
      Object.keys(r).forEach((n) => {
        const s = Oe(n), i = At(n).toLocaleLowerCase(), o = r[n];
        e.alias(n, o), [n, s, i].forEach((a) => {
          e.prototype[a] = function(l, u) {
            return this.make(t[n] || a, l, u);
          };
        });
      });
    }
  }), e;
}
function qn(t) {
  class e extends Xt {
  }
  return Object.assign(e.prototype, t), e;
}
function Xt(t) {
  C(this, {
    $handle: t,
    vm: t.vm,
    options: {},
    ref: "fcForm",
    mergeOptionsRule: {
      normal: ["form", "row", "info", "submitBtn", "resetBtn"]
    }
  }), this.updateKey(), this.init();
}
C(Xt.prototype, {
  __init() {
    this.$render = this.$handle.$render, this.$r = (...t) => this.$render.renderRule(...t);
  },
  updateKey() {
    this.key = He();
  },
  //TODO interface
  init() {
  },
  update() {
  },
  beforeRender() {
  },
  form() {
    return this.vm.refs[this.ref];
  },
  adapterValidate(t, e) {
    return t.validator = (r, n, s) => e(n, s), t;
  },
  getSlot(t) {
    const e = (r) => {
      if (r) {
        let n = r.slots[t];
        return n || e(r.setupState.parent);
      }
    };
    return e(this.vm);
  },
  mergeOptions(t, e) {
    return ee(t.map((r) => this.tidyOptions(r)), e, this.mergeOptionsRule);
  },
  updateOptions(t) {
    this.$handle.fc.targetFormDriver("updateOptions", t, { handle: this.$handle, api: this.$handle.api }), this.options = this.mergeOptions([t], this.getDefaultOptions()), this.update();
  },
  tidyOptions(t) {
    return t;
  },
  tidyRule(t) {
  },
  mergeProp(t) {
  },
  getDefaultOptions() {
    return {};
  },
  fieldChange(t, e, r, n) {
  },
  render(t) {
  }
});
const Hn = function(t) {
  const e = {
    name: "loadData",
    _fn: [],
    loaded(r, n, s) {
      this.deleted(r), A(() => {
        let i = z(r.getValue());
        const o = [];
        i.forEach((a) => {
          if (a && (a.attr || a.template || a.handler)) {
            let l = (d) => {
              let g;
              n && n.__fc__ && (g = n.__fc__.getParentGroup());
              let p;
              a.template ? p = t.$handle.loadStrVar(a.template, d, g ? { rule: n, value: t.$handle.subRuleData[g.id] || {} } : null) : a.handler && h.Function(a.handler) ? p = a.handler(d, n, s) : p = t.$handle.loadStrVar(`{{${a.attr}}}`, d, g ? { rule: n, value: t.$handle.subRuleData[g.id] || {} } : null), (p == null || p === "") && a.default != null && (p = a.default), a.copy !== !1 && (p = K(p));
              const b = a.modify ? n : r.getProp();
              a.to === "child" ? b.children ? b.children[0] = p : b.children = [p] : oe(b, a.to || "options", p), s.sync(n);
            }, u = (d) => l(d);
            const f = t.watchLoadData(u);
            l = se(l, a.wait || 300), a.watch !== !1 ? o.push(f) : f();
          }
        }), this._fn[r.id] = o;
      });
    },
    deleted(r) {
      this._fn[r.id] && (this._fn[r.id].forEach((n) => {
        n();
      }), delete this._fn[r.id]), r.clearProp();
    }
  };
  return e.watch = e.loaded, e;
}, Gn = function(t) {
  const e = {
    name: "t",
    _fn: [],
    loaded(r, n, s) {
      this.deleted(r);
      let i = r.getValue() || {};
      const o = [];
      Object.keys(i).forEach((a) => {
        const l = i[a];
        if (l) {
          const u = typeof l == "object";
          let f = (p) => {
            let b = t.t(u ? l.attr : l, u ? l.params : null, p);
            const v = u && l.modify ? n : r.getProp();
            a === "child" ? v.children ? v.children[0] = b : v.children = [b] : oe(v, a, b), s.sync(n);
          }, d = (p) => f(p);
          const g = t.watchLoadData(d);
          f = se(f, l.wait || 300), l.watch !== !1 ? o.push(g) : g();
        }
      }), this._fn[r.id] = o;
    },
    deleted(r) {
      this._fn[r.id] && (this._fn[r.id].forEach((n) => {
        n();
      }), delete this._fn[r.id]), r.clearProp();
    }
  };
  return e.watch = e.loaded, e;
}, Zt = {
  name: "componentValidate",
  load(t, e, r) {
    let n = t.getValue();
    if (!n || n.method === !1)
      t.clearProp(), r.clearValidateState([e.field]);
    else {
      h.Object(n) || (n = { method: n });
      const s = n.method, i = T(_({}, n), {
        validator(...o) {
          const a = J(e);
          if (a)
            return r.exec(a.id, h.String(s) ? s : "formCreateValidate", ...o, {
              attr: t,
              rule: e,
              api: r
            });
        }
      });
      delete i.method, t.getProp().validate = [i];
    }
  },
  watch(...t) {
    Zt.load(...t);
  }
}, zn = function(t) {
  function e(s) {
    return h.String(s) && (s = {
      action: s,
      to: "options"
    }), s;
  }
  function r(s, i, o) {
    let a = s.value;
    n.deleted(s), h.Function(a) && (a = a(i, o)), a = e(a);
    const l = (d) => {
      d === void 0 ? s.clearProp() : oe(s.getProp(), a.to || "options", d), d != null && a && a.key && t.$handle.options.globalData[a.key] && t.fetchCache.set(t.$handle.options.globalData[a.key], { status: !0, data: d }), o.sync(i);
    };
    if (!a || !a.action && !a.key) {
      l(void 0);
      return;
    }
    a = K(a), a.to || (a.to = "options");
    const u = a.onError, f = () => {
      if (!s.getValue())
        return s.clearProp(), o.sync(i), !0;
    };
    n._fn[s.id] = t.watchLoadData(se((d, g) => {
      if (g && a.watch === !1)
        return n._fn[s.id]();
      if (a.key) {
        t.targetRule = i;
        const v = d("$globalData." + a.key);
        if (delete t.targetRule, v) {
          if (f()) return;
          l(v);
        }
        return;
      }
      const p = t.$handle.loadFetchVar(K(a), d, i), b = T(_({
        headers: {}
      }, p), {
        onSuccess(v, O) {
          if (f()) return;
          let Z = (B) => O ? B : k(B, "data") ? B.data : B;
          const P = Q(p.parse);
          h.Function(P) ? Z = P : P && h.String(P) && (Z = (B) => I(B, P)), Ne(Z(v, i, o)).then((B) => {
            l(B);
          });
        },
        onError(v) {
          l(void 0), !f() && (u || ((O) => nt(O.message || "fetch fail " + p.action)))(v, i, o);
        }
      });
      t.$handle.beforeFetch(b, { rule: i, api: o }).then(() => {
        if (h.Function(p.action)) {
          Ne(p.action(i, o)).then((v) => {
            b.onSuccess(v, !0);
          }).catch((v) => {
            b.onError(v);
          });
          return;
        }
        F(() => t.create.fetch(b, { inject: s, rule: i, api: o }));
      }).catch((v) => {
      });
    }, a.wait || 600));
  }
  const n = {
    name: "fetch",
    _fn: [],
    loaded(...s) {
      r(...s);
    },
    watch(...s) {
      r(...s);
    },
    deleted(s) {
      this._fn[s.id] && (this._fn[s.id](), delete this._fn[s.id]), s.clearProp();
    }
  };
  return n;
}, xn = {
  fetch: zn,
  loadData: Hn,
  t: Gn,
  componentValidate: Zt
}, Jn = "html", Wn = {
  name: Jn,
  loadChildren: !1,
  render(t, e) {
    return e.prop.props.innerHTML = t.default(), e.vNode.make(e.prop.props.tag || "div", e.prop);
  },
  renderChildren(t) {
    return {
      default: () => t.filter((e) => h.String(e)).join("")
    };
  }
};
function Kn(t) {
  t = t + "=";
  const r = decodeURIComponent(document.cookie).split(";");
  for (let n = 0; n < r.length; n++) {
    let s = r[n];
    for (; s.charAt(0) === " "; )
      s = s.substring(1);
    if (s.indexOf(t) === 0) {
      s = s.substring(t.length, s.length);
      try {
        return JSON.parse(s);
      } catch (i) {
        return s;
      }
    }
  }
  return null;
}
function Qn(t) {
  const e = localStorage.getItem(t);
  if (e)
    try {
      return JSON.parse(e);
    } catch (r) {
      return e;
    }
  return null;
}
function Xn(t) {
  const e = sessionStorage.getItem(t);
  if (e)
    try {
      return JSON.parse(e);
    } catch (r) {
      return e;
    }
  return null;
}
function lt(t, e) {
  if (!e)
    return null;
  const r = e.split(".");
  let n = t(r.shift());
  return r.length ? n == null ? null : I(n, r) : n;
}
function Zn(t) {
  return lt(Kn, t);
}
function Yn(t) {
  return lt(Qn, t);
}
function ei(t) {
  return lt(Xn, t);
}
const ti = {
  en: {
    required: "{title} is required",
    validate: {
      url: "{title} is not a valid url",
      email: "{title} is not a valid email",
      ip: "{title} {title} is not a valid ip",
      phone: "{title} {title} is not a valid phone",
      pattern: "{title} does not match pattern {pattern}",
      uppercase: "{title} must be all uppercase",
      lowercase: "{title} must be all lowercased",
      positive: "{title} is not a positive number",
      negative: "{title} is not a negative number",
      equal: "{title} is not equal to {equal}",
      min: "{title} cannot be less than {min}",
      max: "{title} cannot be greater than {max}",
      enum: "{title} must be one of {enum}",
      hasKeys: "{title} does not contain required fields {hasKeys}",
      minLen: "{title} must be at least {minLen}",
      maxLen: "{title} cannot be longer than {maxLen}",
      len: "{title} must be exactly {len}",
      integer: "{title} is not an integer",
      number: "{title} is not an number"
    }
  },
  "zh-cn": {
    required: "{title}不能为空",
    validate: {
      url: "{title}不是有效的 url 地址",
      email: "{title}不是有效的邮箱地址",
      ip: "{title}不是有效的 IP 地址",
      phone: "{title}不是正确的手机号",
      pattern: "{title}必须匹配 {pattern}",
      uppercase: "{title}必须全大写",
      lowercase: "{title}必须全小写",
      positive: "{title}不是正数",
      negative: "{title}不是负数",
      equal: "{title}必须等于 {equal}",
      min: "{title}必须大于等于 {min}",
      max: "{title}必须小于等于 {max}",
      enum: "{title}必须是 {enum} 之一",
      hasKeys: "{title}必须包含 {hasKeys} 字段",
      minLen: "{title}长度必须大于 {minLen}",
      maxLen: "{title}长度必须小于 {maxLen}",
      len: "{title}长度必须为 {len}",
      integer: "{title}必须为整数",
      number: "{title}必须为数字"
    }
  }
};
function ri(t, e) {
  let r;
  return arguments.length === 2 ? (r = arguments[1], e = r[t]) : r = arguments[2], { id: e, prop: r };
}
function Ke() {
  return ri("name", ...arguments);
}
function ni(t) {
  const e = t.key || [], r = t.array || [], n = t.normal || [];
  Mt.push(...e), it.push(...r), st.push(...n), Wt([...e, ...r, ...n]);
}
let ii = 1;
const M = {}, Vt = Symbol("defValue");
function Yt(t) {
  const e = {
    [We.name]: We
  }, r = {}, n = {}, s = {}, i = {}, o = [], a = [], l = [
    t.extendApi
  ], u = _({}, xn), f = pn();
  let d = { global: {} };
  const g = t.isMobile === !0, p = W({
    $mobile: g
  }), b = Un(), v = {}, O = {};
  ni(t.attrs || {});
  function Z(c) {
    const m = M[c];
    if (Array.isArray(m))
      return m.map((y) => y.api());
    if (m)
      return m.api();
  }
  function P(c) {
    o.push(c);
  }
  function B() {
    const c = Ke(...arguments);
    c.id && c.prop && (n[c.id] = c.prop);
  }
  function ye() {
    const c = Ke(...arguments);
    c.id && c.prop && (u[c.id] = h.Function(c.prop) ? c.prop : T(_({}, c.prop), {
      name: c.id
    }));
  }
  function Ge(c) {
    b.use(c);
  }
  function be(c) {
    if (arguments.length === 0)
      return Fe;
    if (typeof c == "string" && arguments.length === 1)
      return r[L(c)];
    const m = Ke(...arguments);
    if (!m.id || !m.prop) return Fe;
    const y = L(m.id), $ = m.prop, S = $.merge === !0 ? r[y] : void 0;
    r[y] = Pe($, S || Fe), f[y] = q(y), $.maker && C(f, $.maker);
  }
  function E(c, m) {
    let y;
    if (h.String(c)) {
      if (y = c, m === void 0)
        return e[y];
    } else
      y = c.displayName || c.name, m = c;
    if (!y || !m) return;
    const $ = L(y);
    e[y] = m, e[$] = m, delete b.aliasMap[y], delete b.aliasMap[$], delete r[y], delete r[$], m.formCreateParser && be(y, m.formCreateParser);
  }
  function D() {
    return cn(xe, e, n);
  }
  function H(c, m) {
    const y = D();
    return Rr({
      data() {
        return W({
          rule: c,
          option: m
        });
      },
      render() {
        return Se(y, _({ ref: "fc" }, this.$data));
      }
    });
  }
  function $e() {
    return We;
  }
  function Ee(c, m) {
    return h.Function(c.install) ? c.install(re, m) : h.Function(c) && c(re, m), this;
  }
  function re(c, m) {
    let y = H(c, m || {});
    o.forEach((j) => {
      F(() => j(re, y));
    });
    const $ = document.createElement("div");
    return ((m == null ? void 0 : m.el) || document.body).appendChild($), y.mount($).$refs.fc.fapi;
  }
  Pe(re, O);
  function rr(c) {
    let m = _({}, t);
    return c ? m.inherit = {
      components: e,
      parsers: r,
      directives: n,
      modelFields: s,
      providers: u,
      useApps: o,
      maker: f,
      formulas: v,
      loadData: p
    } : delete m.inherit, Yt(m);
  }
  function nr(c, m) {
    s[c] = m;
  }
  function ir(c, m) {
    v[c] = m;
  }
  function sr(c, m) {
    const y = i[c] || {}, $ = y.parsers || {};
    m.parsers && Object.keys(m.parsers).forEach((S) => {
      $[S] = Pe(m.parsers[S], Fe);
    }), m.name = c, i[c] = T(_(_({}, y), m), { parsers: $ });
  }
  function ke(c) {
    c && Object.keys(M).forEach((m) => {
      (Array.isArray(M[m]) ? M[m] : [M[m]]).forEach(($) => {
        $.bus.$emit("$loadData." + c);
      });
    });
  }
  function ze(c, m) {
    oe(p, c, m), ke(c);
  }
  function De(c, m) {
    const y = (...$) => F(() => m(...$));
    y._driver = !0, ze(c, y);
  }
  function ft(c, m) {
    const y = (c || "").split(".");
    c = y.shift();
    const $ = y.join(".");
    if (k(p, c) || (p[c] = Vt), p[c] !== Vt) {
      let S = p[c];
      return S && S._driver ? S = S($) : y.length && (S = I(S, y)), S == null || S === "" ? m : S;
    } else
      return m;
  }
  function or(c) {
    l.push(c);
  }
  function ar(c) {
    delete p[c], ke(c);
  }
  function lr(c, m) {
    a.push({ name: c, callback: m });
  }
  function xe(c) {
    C(this, {
      id: ii++,
      create: re,
      vm: c,
      manager: qn(t.manager),
      parsers: r,
      providers: u,
      modelFields: s,
      formulas: v,
      isMobile: g,
      rules: c.props.rule,
      name: c.props.name || He(),
      inFor: c.props.inFor,
      prop: {
        components: e,
        directives: n
      },
      get: null,
      drivers: i,
      renderDriver: null,
      refreshData: ke,
      loadData: p,
      CreateNode: b,
      bus: new jt(),
      //使用 Set 保存,停止侦听时可以自行摘除,避免长期运行下无限堆积
      unwatch: /* @__PURE__ */ new Set(),
      options: Or({}),
      extendApiFn: l,
      fetchCache: /* @__PURE__ */ new WeakMap(),
      tmpData: W({})
    }), this.unwatch.push = this.unwatch.add, a.forEach((m) => {
      this.bus.$on(m.name, m.callback);
    }), A(() => {
      N(this.options, () => {
        this.$handle.$manager.updateOptions(this.options.value), this.api().refresh();
      }, { deep: !0 });
    }), C(c.appContext.components, e), C(c.appContext.directives, n), this.$handle = new X(this), this.name && (this.inFor ? (M[this.name] || (M[this.name] = []), M[this.name].push(this)) : M[this.name] = this);
  }
  xe.isMobile = g, C(xe.prototype, {
    init() {
      this.isSub() && this.unwatch.add(N(() => this.vm.setupState.parent.setupState.fc.options.value, () => {
        this.initOptions(), this.$handle.api.refresh();
      }, { deep: !0, flush: "sync" })), this.vm.props.driver && (this.renderDriver = typeof this.vm.props.driver == "object" ? this.vm.props.driver : this.drivers[this.vm.props.driver]), !this.renderDriver && this.vm.setupState.parent && (this.renderDriver = this.vm.setupState.parent.setupState.fc.renderDriver), this.renderDriver || (this.renderDriver = this.drivers.default), this.initOptions(), this.$handle.init();
    },
    targetFormDriver(c, ...m) {
      if (this.bus.$emit(c, ...m), this.renderDriver && this.renderDriver[c])
        return F(() => this.renderDriver[c](...m));
    },
    t(c, m, y) {
      let $ = y ? y("$t." + c) : this.globalLanguageDriver(c);
      return $ == null && ($ = ""), $ && m && Object.keys(m).forEach((S) => {
        const j = new RegExp(`{${S}}`, "g");
        $ = $.replace(j, m[S]);
      }), $;
    },
    globalDataDriver(c) {
      let m = c.split(".");
      const y = m.shift(), $ = this.options.value.globalData && this.options.value.globalData[y];
      if ($) {
        if ($.type === "static")
          return I($.data, m);
        {
          let S;
          const j = this.fetchCache.get($);
          if (j) {
            if (j.status && (S = I(j.data, m)), !j.loading)
              return S;
            j.loading = !1, this.fetchCache.set($, j);
          } else
            this.fetchCache.set($, { status: !1 });
          const V = se(() => {
            fe();
            const x = this.fetchCache.get($);
            this.options.value.globalData && Object.values(this.options.value.globalData).indexOf($) !== -1 ? (x && (x.loading = !0, this.fetchCache.set($, x)), this.bus.$emit("$loadData.$globalData." + y)) : this.fetchCache.delete($);
          }, $.wait || 600), le = (x) => {
            this.fetchCache.set($, { status: !0, data: x }), this.bus.$emit("$loadData.$globalData." + y);
          }, ue = (x, ce) => {
            if (ce && $.watch === !1)
              return fe();
            if (ce) {
              V();
              return;
            }
            const de = this.$handle.loadFetchVar(Ye($), x);
            de.targetRule = this.targetRule, this.$handle.api.fetch(de).then((ne) => {
              le(ne);
            }).catch((ne) => {
              le(null);
            });
          }, fe = this.watchLoadData(ue);
          return $.watch === !1 && fe(), S;
        }
      }
    },
    getLocale() {
      let c = this.vm.setupState.top.props.locale;
      return c && typeof c == "object" ? c.name : typeof c == "string" ? c : "zh-cn";
    },
    globalLanguageDriver(c) {
      let m = this.vm.setupState.top.props.t, y = this.vm.setupState.top.props.locale, $;
      if (m && ($ = F(() => m(c))), $ == null && y && typeof y == "object" && ($ = I(y, c)), $ == null) {
        const S = this.options.value.language || {}, j = this.getLocale();
        $ = I(S[j] || {}, c), $ == null && ($ = I(ti[j] || {}, c));
      }
      return $;
    },
    globalVarDriver(c) {
      let m = c.split(".");
      const y = m.shift(), $ = this.options.value.globalVariable && this.options.value.globalVariable[y];
      if ($) {
        const S = h.Function($) ? $ : Q($.handle);
        if (S) {
          let j = S((...V) => this.$handle.api.getData(...V), this.$handle.api);
          return I(j, m);
        }
      }
    },
    setData(c, m, y) {
      y ? ze(c, m) : (oe(this.vm.setupState.top.setupState.fc.tmpData, c, m), this.bus.$emit("$loadData." + c));
    },
    getLoadData(c, m) {
      let y = null;
      if (c != null) {
        let $ = c.split(".");
        const S = $.shift();
        if (y = I(this.vm.setupState.top.setupState.fc.tmpData, c), y != null)
          return y;
        if (S === "$topForm")
          y = this.$handle.api.top.formData(!0);
        else if (S === "$scopeForm")
          y = this.$handle.api.scope.formData(!0);
        else if (S === "$form")
          y = this.$handle.api.formData(!0);
        else if (S === "$options")
          y = this.options.value;
        else if (S === "$globalData")
          y = this.globalDataDriver($.join(".")), $ = [];
        else if (S === "$var")
          y = this.globalVarDriver($.join(".")), $ = [];
        else if (S === "$locale")
          y = this.getLocale(), $ = [];
        else if (S === "$t")
          y = this.globalLanguageDriver($.join(".")), $ = [];
        else {
          if (S === "$preview")
            return this.$handle.preview;
          y = ft(c), $ = [];
        }
        y && $.length && (y = I(y, $));
      }
      return y == null || y === "" ? m : y;
    },
    watchLoadData(c, m) {
      let y = {};
      const $ = (V) => {
        this.get || (this.get = S), F(() => {
          c(S, V);
        }), this.get === S && (this.get = void 0);
      }, S = (V, le) => {
        let ue;
        if (typeof V == "object" && (ue = V.getValue, V = V.id), y[V])
          return y[V].val;
        const fe = _e(() => ue ? ue() : this.getLoadData(V, le)), x = V.split("."), ce = x.shift(), de = x.shift() || "", ne = se(() => {
          const he = ue ? ue() : this.getLoadData(V, le);
          if (y[V])
            ((he instanceof Function || h.Object(he) || Array.isArray(he)) && he === y[V].val || JSON.stringify(he) !== JSON.stringify(y[V].val)) && (y[V].val = he, $(!0));
          else return;
        }, m || 0), fr = N(fe, (he) => {
          ne();
        });
        return this.bus.$on("$loadData." + ce, ne), de && this.bus.$on("$loadData." + ce + "." + de, ne), y[V] = {
          fn: () => {
            this.bus.$off("$loadData." + ce, ne), de && this.bus.$off("$loadData." + ce + "." + de, ne), fr();
          },
          val: fe.value
        }, fe.value;
      };
      $(!1);
      const j = () => {
        Object.keys(y).forEach((V) => y[V].fn()), y = {}, this.unwatch.delete(j);
      };
      return this.unwatch.add(j), j;
    },
    isSub() {
      return this.vm.setupState.parent && this.vm.props.extendOption;
    },
    initOptions() {
      this.options.value = {};
      let c = _({
        formData: {},
        submitBtn: {},
        resetBtn: {},
        globalEvent: {},
        globalData: {}
      }, K(d));
      const m = this.isSub();
      m && (c = this.mergeOptions(c, this.vm.setupState.parent.setupState.fc.options.value || {}, !0)), c = this.mergeOptions(c, this.vm.props.option);
      const y = this.api();
      this.targetFormDriver("initOptions", c, { api: y, isSubForm: m }), this.updateOptions(c);
    },
    mergeOptions(c, m, y) {
      return m = _({}, m || {}), y && ["page", "onSubmit", "onReset", "onCreated", "onChange", "onMounted", "mounted", "beforeUnmount", "beforeSubmit", "onBeforeUnmount", "onReload", "reload", "formData", "el", "globalClass", "style"].forEach(($) => {
        delete m[$];
      }), m.global && (c.global = ln(c.global, m.global), delete m.global), this.$handle.$manager.mergeOptions([m], c), c;
    },
    updateOptions(c) {
      this.options.value = this.mergeOptions(this.options.value, c), this.$handle.$manager.updateOptions(this.options.value), this.bus.$emit("$loadData.$options");
    },
    api() {
      return this.$handle.api;
    },
    render() {
      return this.$handle.render();
    },
    mounted() {
      this.$handle.mounted();
    },
    unmount() {
      if (F(() => this.$handle.lifecycle("beforeUnmount")), this.name)
        if (this.inFor) {
          const c = M[this.name].indexOf(this);
          M[this.name].splice(c, 1);
        } else
          delete M[this.name];
      a.forEach((c) => {
        this.bus.$off(c.name, c.callback);
      }), this.tmpData = {}, [...this.unwatch].forEach((c) => c()), this.unwatch.clear(), this.$handle.reloadRule([]);
    },
    updated() {
      this.$handle.bindNextTick(() => this.bus.$emit("next-tick", this.$handle.api));
    }
  });
  function ct(c) {
    C(c, {
      version: t.version,
      ui: t.ui,
      isMobile: g,
      extendApi: or,
      getData: ft,
      setDataDriver: De,
      setData: ze,
      removeData: ar,
      refreshData: ke,
      maker: f,
      component: E,
      directive: B,
      setModelField: nr,
      setFormula: ir,
      setDriver: sr,
      register: ye,
      $vnode: $e,
      parser: be,
      use: Ee,
      factory: rr,
      componentAlias: Ge,
      copyRule: Ht,
      copyRules: Gt,
      mergeRule: te,
      fetch: Kt,
      $form: D,
      parseFn: Q,
      parseJson: Bt,
      toJson: Re,
      useApp: P,
      getApi: Z,
      on: lr
    });
  }
  function ur(c) {
    C(c, {
      create: re,
      install(m, y) {
        d = _(_({}, d), y || {});
        const $ = `_installedFormCreate${g ? "Mobile" : ""}_${t.ui}`;
        if (m[$] === !0) return;
        m[$] = !0;
        const S = function(V, le = {}) {
          return re(V, le);
        };
        ct(S), m.config.globalProperties.$formCreate = S;
        const j = D();
        m.component(j.name, j), o.forEach((V) => {
          F(() => V(c, m));
        });
      }
    });
  }
  if (ct(O), ur(O), De("$cookie", Zn), De("$localStorage", Yn), De("$sessionStorage", ei), b.use({ fragment: "fcFragment" }), t.install && re.use(t), P((c, m) => {
    m.mixin({
      props: ["formCreateInject"],
      emits: ["fc.updateValue", "fc.el"]
    });
  }), be(Wn), t.inherit) {
    const c = t.inherit;
    c.components && C(e, c.components), c.parsers && C(r, c.parsers), c.directives && C(n, c.directives), c.modelFields && C(s, c.modelFields), c.providers && C(u, c.providers), c.useApps && C(o, c.useApps), c.maker && C(f, c.maker), c.loadData && C(p, c.loadData), c.formulas && C(v, c.formulas);
  }
  const je = D();
  return Pe(je, O), Object.defineProperties(je, {
    fetch: {
      get() {
        return O.fetch;
      },
      set(c) {
        O.fetch = c;
      }
    }
  }), je.util = O, je;
}
const Qe = "hidden", si = {
  name: Qe,
  maker: {
    [Qe]: (t, e) => q(Qe)("", t, e)
  },
  render() {
    return [];
  }
}, Et = "slider", oi = {
  name: Et,
  maker: {
    sliderRange: q(Et, { range: !0 })
  },
  toFormValue(t, e) {
    let r = Array.isArray(t), n = e.prop.props, s = n.min || 0, i;
    return n.range === !0 ? i = r ? t : [s, parseFloat(t) || s] : i = r ? parseFloat(t[0]) || s : parseFloat(t), i;
  }
}, ai = {
  name: "FcRow",
  render(t, e) {
    return e.vNode.col({ props: { span: 12 } }, {
      default: () => [
        e.vNode.row(e.prop, t)
      ]
    });
  }
}, ut = {
  name: "checkbox",
  mergeProp(t) {
    const e = t.prop.props;
    k(e, "options") || (e.options = t.prop.options || []);
  }
}, li = "select", ui = T(_({}, ut), {
  name: li,
  toFormValue(t, e) {
    return e.prop.props.multiple && !Array.isArray(t) ? z(t) : t;
  }
}), fi = T(_({}, ut), {
  name: "radio"
}), ci = {
  name: "tree",
  mergeProp(t) {
    t.prop.props.checkable = !0;
  }
}, di = [
  si,
  fi,
  ut,
  ci,
  oi,
  ai,
  ui
], R = "t", hi = {
  button: R + "Button",
  icon: R + "Icon",
  slider: R + "Slider",
  upload: "fcUpload",
  cascader: R + "Cascader",
  autoComplete: R + "AutoComplete",
  auto: R + "AutoComplete",
  popup: R + "Popup",
  tooltip: R + "Tooltip",
  colorPicker: R + "ColorPicker",
  dateRangePicker: R + "DateRangePicker",
  datePicker: R + "DatePicker",
  timePicker: R + "TimePicker",
  timeRangePicker: R + "TimeRangePicker",
  switch: R + "Switch",
  select: R + "Select",
  checkbox: R + "CheckboxGroup",
  radio: R + "RadioGroup",
  inputNumber: R + "InputNumber",
  number: R + "InputNumber",
  input: R + "Input",
  rate: R + "Rate",
  rangeInput: R + "RangeInput",
  tagInput: R + "TagInput",
  textarea: R + "Textarea",
  formItem: R + "FormItem",
  form: R + "Form",
  frame: "fcFrame",
  col: R + "Col",
  row: R + "Row",
  treeSelect: R + "TreeSelect",
  transfer: R + "Transfer",
  tree: R + "Tree",
  group: "fcGroup",
  array: "fcGroup",
  object: "fcSubForm",
  subForm: "fcSubForm"
};
function pi() {
  return {
    form: {
      layout: "vertical",
      labelAlign: "right",
      labelWidth: "125px"
    },
    row: {
      show: !0,
      gutter: 0
    },
    submitBtn: {
      theme: "primary",
      loading: !1,
      disabled: !1,
      innerText: "",
      show: !0,
      col: void 0,
      click: void 0
    },
    resetBtn: {
      theme: "default",
      loading: !1,
      disabled: !1,
      innerText: "",
      show: !1,
      col: void 0,
      click: void 0
    }
  };
}
function kt(t, e) {
  k(t, e) && h.String(t[e]) && (t[e] = { [e]: t[e], show: !0 });
}
function Y(t) {
  return t === !1;
}
function mi(t, e) {
  k(t, e) && !h.Object(t[e]) && (t[e] = { show: !!t[e] });
}
function Xe(t) {
  const e = _({}, t);
  return delete e.children, e;
}
const gi = {
  validate(t) {
    return new Promise((e, r) => {
      const n = this.form();
      if (n)
        return n.validate(t).then((s) => {
          s === !0 ? e(s) : r(s);
        }).catch((s) => {
        });
      e(!0);
    });
  },
  validateField(t) {
    return this.validate({ fields: [t] });
  },
  clearValidateState(t) {
    const e = this.form();
    if (e)
      return e.clearValidate(t);
  },
  tidyOptions(t) {
    return ["submitBtn", "resetBtn", "row", "info", "wrap", "col", "title"].forEach((e) => {
      mi(t, e);
    }), t;
  },
  tidyRule({ prop: t }) {
    return kt(t, "title"), kt(t, "info"), t;
  },
  mergeProp(t) {
    const e = {
      info: {
        type: "popup",
        placement: "top-left",
        showArrow: !0,
        icon: "QuestionCircleOutlined"
      },
      title: {},
      col: { span: 12 },
      wrap: {}
    };
    ["info", "wrap", "col", "title"].forEach((r) => {
      t.prop[r] = ee([this.options[r] || {}, t.prop[r] || {}], e[r]);
    });
  },
  getDefaultOptions() {
    return pi();
  },
  adapterValidate(t, e) {
    return t.validator = (r) => new Promise((n) => e(r, (i) => {
      n(i ? { message: i } : { result: !0 });
    })), t;
  },
  update() {
    const t = this.options.form;
    this.rule = {
      props: _({}, t),
      on: {
        submit: (e) => {
          e.preventDefault && e.preventDefault();
        }
      },
      style: t.style,
      type: "form"
    };
  },
  beforeRender() {
    const { key: t, ref: e, $handle: r } = this, n = this.options.form;
    C(this.rule, { key: t, ref: e, class: [n.className, n.class, "form-create", this.$handle.preview ? "is-preview" : ""] }), C(this.rule.props, {
      data: r.formData
    });
  },
  render(t) {
    return t.slotLen() && !this.$handle.preview && t.setSlot(void 0, () => this.makeFormBtn()), this.$r(this.rule, Y(this.options.row.show) ? t.getSlots() : [this.makeRow(t)]);
  },
  makeWrap(t, e) {
    const r = t.prop, n = `${this.key}${t.key}`, s = r.col, i = this.isTitle(r) && r.wrap.title !== !1, o = !(s != null && s.labelWidth) && !i ? 0 : s == null ? void 0 : s.labelWidth, { layout: a, col: l } = this.rule.props, u = r.wrap.class;
    delete r.wrap.class, delete r.wrap.title;
    let f;
    return (h.Undef(r.wrap.show) ? !t.input : Y(r.wrap.show)) ? f = e : f = this.$r(ee([r.wrap, {
      props: T(_({
        labelWidth: o === void 0 ? o : At(o)
      }, Xe(r.wrap || {})), {
        name: t.id,
        rules: r.validate,
        label: i ? () => this.makeInfo(r, n, t) : void 0
      }),
      class: this.$render.mergeClass(u || r.className, "fc-form-item"),
      key: `${n}fi`,
      ref: t.wrapRef,
      type: "formItem"
    }]), { default: () => e }), a === "inline" || Y(l) || Y(s.show) ? f : this.makeCol(r, n, [f]);
  },
  isTitle(t) {
    if (this.options.form.title === !1) return !1;
    const e = t.title;
    return !(!e.title && !e.native || Y(e.show));
  },
  makeInfo(t, e, r) {
    var u, f, d, g, p, b;
    const n = _({}, t.title), s = _({}, t.info), i = this.options.form, o = this.getSlot("title"), a = [o ? o({ title: (f = (u = r.refRule) == null ? void 0 : u.__$title) == null ? void 0 : f.value, rule: r.rule, options: this.options }) : ((g = (d = r.refRule) == null ? void 0 : d.__$title) == null ? void 0 : g.value) + (i.labelSuffix || i["label-suffix"] || "")];
    if (!Y(s.show) && (s.info || s.native) && !Y(s.icon)) {
      const v = {
        type: s.type || "popup",
        props: Xe(s),
        key: `${e}pop`
      };
      delete v.props.icon, delete v.props.show, delete v.props.info, delete v.props.align, delete v.props.native;
      const O = "content";
      s.info && !k(v.props, O) && (v.props[O] = (b = (p = r.refRule) == null ? void 0 : p.__$info) == null ? void 0 : b.value), a[s.align !== "left" ? "unshift" : "push"](this.$r(ee([s, v]), {
        [n.slot || "default"]: () => this.$r({
          type: s.icon === !0 ? "QuestionCircleOutlined" : s.icon || "",
          key: `${e}i`
        })
      }));
    }
    const l = ee([n, {
      props: Xe(n),
      key: `${e}tit`,
      class: "fc-form-title",
      type: n.type || "span",
      on: {
        click: (...v) => {
          this.$handle.targetHook(r, "titleClick", { args: v });
        }
      }
    }]);
    return delete l.props.show, delete l.props.title, delete l.props.native, this.$r(l, a);
  },
  makeCol(t, e, r) {
    const n = _({}, t.col);
    return delete n.show, this.$r({
      class: this.$render.mergeClass(n.class, "fc-form-col"),
      type: "col",
      props: n || { span: 12 },
      key: `${e}col`
    }, r);
  },
  makeRow(t) {
    const e = this.options.row || {};
    return this.$r({
      type: "row",
      props: e,
      class: this.$render.mergeClass(e.class, "fc-form-row"),
      key: `${this.key}row`
    }, t);
  },
  makeFormBtn() {
    let t = [];
    if (Y(this.options.submitBtn.show) || t.push(this.makeSubmitBtn()), Y(this.options.resetBtn.show) || t.push(this.makeResetBtn()), !t.length)
      return;
    const e = this.$r({
      type: "formItem",
      class: "fc-form-item",
      props: {
        label: this.rule.props.layout === "inline" ? "" : " "
      },
      key: `${this.key}fb`
    }, t);
    return this.rule.props.layout === "inline" ? e : this.$r({
      type: "col",
      class: "fc-form-col fc-form-footer",
      props: { span: 12 },
      key: `${this.key}fc`
    }, [e]);
  },
  makeResetBtn() {
    const t = _({}, this.options.resetBtn), e = t.innerText || this.$handle.api.t("reset") || "重置";
    return delete t.innerText, delete t.click, delete t.col, delete t.show, this.$r({
      type: "button",
      props: t,
      class: "fc-reset-btn",
      style: { width: t.width, marginLeft: "10px" },
      on: {
        click: () => {
          const r = this.$handle.api;
          this.options.resetBtn.click ? this.options.resetBtn.click(r) : r.resetFields();
        }
      },
      key: `${this.key}b2`
    }, [e]);
  },
  makeSubmitBtn() {
    const t = _({}, this.options.submitBtn), e = t.innerText || this.$handle.api.t("submit") || "提交";
    return delete t.innerText, delete t.click, delete t.col, delete t.show, this.$r({
      type: "button",
      props: t,
      class: "fc-submit-btn",
      style: { width: t.width },
      on: {
        click: () => {
          const r = this.$handle.api;
          this.options.submitBtn.click ? this.options.submitBtn.click(r) : r.submit().catch(() => {
          });
        }
      },
      key: `${this.key}b1`
    }, [e]);
  }
}, ae = {};
yi(ae);
bi(ae);
$i(ae);
_i(ae);
vi(ae);
Ci(ae);
function yi(t) {
  ["group", "tree", "treeSelect", "switch", "upload", "cascader", "autoComplete", "rangeInput", "transfer", "tagInput", "colorPicker", "datePicker", "dateRangePicker", "timePicker", "timeRangePicker", "textarea", "input", "frame", "inputNumber"].forEach((e) => {
    t[e] = q(e);
  }), t.auto = t.autoComplete, t.number = t.inputNumber, t.color = t.colorPicker, t.date = t.datePicker, t.dateRange = t.dateRangePicker, t.time = t.timePicker, t.timeRange = t.timeRangePicker, t.tag = t.tagInput;
}
function bi(t) {
  t.treeSelectMultiple = q("treeSelect", { multiple: !0 });
}
function $i(t) {
  ["password", "url", "text", "tel"].reduce((e, r) => (e[r] = q("input", { type: r }), e), t);
}
function _i(t) {
  const e = "select", r = "multiple";
  t.selectMultiple = q(e, { [r]: !0 }), t.selectOne = q(e, { [r]: !1 });
}
function vi(t) {
  const e = "upload", r = {
    image: ["image", 0],
    file: ["file", 0],
    uploadFileOne: ["file", 1],
    uploadImageOne: ["image", 1]
  };
  Object.keys(r).reduce((n, s) => (n[s] = q(e, (i) => i.props({ uploadType: r[s][0], max: r[s][1] })), n), t), t.uploadImage = t.image, t.uploadFile = t.file;
}
function Ci(t) {
  const e = {
    frameInputs: ["input", 0],
    frameFiles: ["file", 0],
    frameImages: ["image", 0],
    frameInputOne: ["input", 1],
    frameFileOne: ["file", 1],
    frameImageOne: ["image", 1]
  };
  return Object.keys(e).reduce((r, n) => (r[n] = q("frame", (s) => s.props({ type: e[n][0], maxLength: e[n][1] })), r), t), t.frameInput = t.frameInputs, t.frameFile = t.frameFiles, t.frameImage = t.frameImages, t;
}
function Dt(t, e) {
  return h.Boolean(t) ? t = { show: t } : !h.Undef(t) && !h.Object(t) && (t = { show: e }), t;
}
function wi(t, e) {
  return {
    formEl() {
      return e.$manager.form();
    },
    wrapEl(r) {
      const n = e.getFieldCtx(r);
      if (n)
        return e.vm.refs[n.wrapRef];
    },
    validate(r) {
      return new Promise((n, s) => {
        const i = t.children, o = [e.$manager.validate()];
        i.filter((a) => !a.isScope).forEach((a) => {
          o.push(a.validate());
        }), Promise.all(o).then(() => {
          n(!0), r && r(!0);
        }).catch((a) => {
          s(a), r && r(a), e.vm.emit("validate-fail", a, { api: t }), e.emitEvent("validate-fail", a, { api: t });
        });
      });
    },
    validateField(r, n) {
      return new Promise((s, i) => {
        const a = typeof r == "object" ? J(r) : e.getCtx(r);
        if (!a) {
          s(null), n && n(null);
          return;
        }
        const l = e.subForm[a.id], u = [e.$manager.validateField(a.id)];
        z(l).filter((f) => !f.isScope).forEach((f) => {
          u.push(f.validate());
        }), Promise.all(u).then(() => {
          s(!0), n && n(!0);
        }).catch((f) => {
          i(f), n && n(f), e.vm.emit("validate-field-fail", f, { field: r, api: t });
        });
      });
    },
    validateFields(r, n) {
      return new Promise((s, i) => {
        Array.isArray(r) || (r = [r]);
        const o = r.map((a) => t.validateField(a));
        Promise.all(o).then(() => {
          s(null), n && n(null);
        }).catch((a) => {
          i(a), n && n(a);
        });
      });
    },
    clearValidateState(r, n = !0) {
      let s = [];
      t.helper.tidyFields(r).forEach((i) => {
        n && this.clearSubValidateState(i), r && (s = s.concat(e.getCtxs(i).map((o) => o.id)));
      }), r && s.length ? e.$manager.clearValidateState(s) : r || e.$manager.clearValidateState();
    },
    clearSubValidateState(r) {
      t.helper.tidyFields(r).forEach((n) => {
        e.getCtxs(n).forEach((s) => {
          const i = e.subForm[s.id];
          i && (Array.isArray(i) ? i.forEach((o) => {
            o.clearValidateState();
          }) : i && i.clearValidateState());
        });
      });
    },
    btn: {
      loading: (r = !0) => {
        t.submitBtnProps({ loading: !!r });
      },
      disabled: (r = !0) => {
        t.submitBtnProps({ disabled: !!r });
      },
      show: (r = !0) => {
        t.submitBtnProps({ show: !!r });
      }
    },
    resetBtn: {
      loading: (r = !0) => {
        t.resetBtnProps({ loading: !!r });
      },
      disabled: (r = !0) => {
        t.resetBtnProps({ disabled: !!r });
      },
      show: (r = !0) => {
        t.resetBtnProps({ show: !!r });
      }
    },
    submitBtnProps: (r = {}) => {
      let n = Dt(e.options.submitBtn, !0);
      C(n, r), e.options.submitBtn = n, t.refreshOptions();
    },
    resetBtnProps: (r = {}) => {
      let n = Dt(e.options.resetBtn, !1);
      C(n, r), e.options.resetBtn = n, t.refreshOptions();
    },
    submit(r, n) {
      return new Promise((s, i) => {
        (e.options.validateOnSubmit === !1 ? Promise.resolve() : t.validate()).then(() => {
          let a = t.formData();
          e.beforeSubmit(a).then(() => {
            h.Function(r) && F(() => r(a, t)), h.Function(e.options.onSubmit) && F(() => e.options.onSubmit(a, t)), e.vm.emit("submit", a, t), s(a);
          }).catch((l) => {
          });
        }).catch((...a) => {
          h.Function(n) && F(() => n(t, ...a)), i(...a);
        });
      });
    }
  };
}
const er = {
  name: "required",
  load(t, e, r) {
    const n = Si(t.getValue());
    let s;
    if (n.required === !1)
      t.clearProp(), r.clearValidateState([e.field]);
    else {
      const i = _({
        trigger: "change",
        validator(a) {
          return o(), !h.empty(a);
        }
      }, n), o = () => {
        var l;
        const a = (l = e.__fc__.refRule.__$title) == null ? void 0 : l.value;
        if (s !== a)
          if (s = a, !n.message)
            i.message = r.t("required", { title: a }) || a + (r.getLocale() === "en" ? " is required" : "不能为空");
          else {
            const u = n.message.match(/^\{\{\s*\$t\.(.+)\s*\}\}$/);
            u && (i.message = r.t(u[1], { title: a }));
          }
      };
      o(), t.getProp().validate = [i];
    }
    r.sync(e);
  },
  watch(...t) {
    er.load(...t);
  }
};
function Si(t) {
  return h.Boolean(t) ? { required: t } : h.String(t) ? { message: t } : h.Undef(t) ? { required: !1 } : h.Function(t) ? { asyncValidator: t } : h.Object(t) ? t : {};
}
function Fi(t) {
  t.componentAlias(hi), sn.forEach((e) => {
    t.component(e.name, e);
  }), t.register(er), di.forEach((e) => {
    t.parser(e);
  }), Object.keys(ae).forEach((e) => {
    t.maker[e] = ae[e];
  });
}
function Oi() {
  return Yt({
    ui: "tdesign",
    version: "3.3.5",
    manager: gi,
    extendApi: wi,
    install: Fi,
    attrs: {
      normal: ["col", "wrap"],
      array: ["className"],
      key: ["title", "info"]
    }
  });
}
const tr = Oi();
typeof window != "undefined" && (window.formCreate = tr);
const Ei = tr.maker;
export {
  tr as default,
  Ei as maker
};