var T = Object.defineProperty;
var N = (e, s, t) => s in e ? T(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
var l = (e, s, t) => (N(e, typeof s != "symbol" ? s + "" : s, t), t);
import { GridFieldColumnController as C, GridRowController as V, WFStepTraceViewController as P } from "@ibiz-template/controller";
import { defineComponent as m, computed as f, h as a, getCurrentInstance as b, ref as p } from "vue";
import { useNamespace as d, useViewController as x, usePropsWatch as g, useWFStepTraceViewController as S, useWFDynaEditView3Controller as I, useEditView3Controller as F } from "@ibiz-template/vue-util";
import { colorBlend as E, IBizContext as L } from "@ibiz-template/core";
import { ViewMode as v } from "@ibiz-template/runtime";
import { ViewType as D } from "@ibiz-template/model";
const W = m({
  name: "CodeListGridColumn",
  props: {
    controller: {
      type: C,
      required: !0
    },
    row: {
      type: V,
      required: !0
    }
  },
  setup(e) {
    const s = d("grid-field-column"), t = f(() => {
      var i;
      if (e.controller.model.source.cLConvertMode !== "FRONT")
        return [];
      const n = e.row.data[e.controller.model.codeName];
      return ((i = e.controller.codeListItems) == null ? void 0 : i.length) && n ? n.split(",").map((w) => {
        const y = e.controller.codeListItems.find((h) => h.value === w);
        if (y) {
          const h = y.color || "#515a6e";
          return {
            text: y.text,
            colorStyle: s.cssVarBlock({
              color: h,
              "border-color": h,
              "bg-color": E(h, "#fff")
            })
          };
        }
      }).filter(Boolean) : [];
    }), r = (n) => {
      e.controller.isLinkColumn && e.controller.openLinkView(e.row, n);
    }, o = f(() => {
      let n = "";
      switch (e.controller.model.align) {
        case "LEFT":
          n = "flex-start";
          break;
        case "RIGHT":
          n = "flex-end";
          break;
        default:
          n = "center";
          break;
      }
      return s.cssVarBlock({
        "justify-content": n
      });
    });
    return {
      ns: s,
      alignStyle: o,
      selectedItems: t,
      onCellClick: r
    };
  },
  render() {
    const e = this.controller, s = this.row.data[e.model.codeName];
    return a("div", {
      class: [this.ns.b(), e.isLinkColumn && this.ns.m("link-column")],
      style: this.alignStyle,
      on: {
        click: this.onCellClick
      }
    }, [this.selectedItems.length > 0 ? this.selectedItems.map((t) => a("span", {
      class: this.ns.e("code-list-item"),
      style: t.colorStyle
    }, [t.text])) : a("span", {
      class: this.ns.e("text")
    }, [s])]);
  }
});
class O extends P {
  constructor() {
    super(...arguments);
    l(this, "imgSrc");
  }
  async getUIData() {
    const t = new L(this.params, this.context), r = await this.entityService.wf.getWFProcessDiagram(t), o = new Blob([r.data]);
    this.imgSrc = URL.createObjectURL(o);
  }
}
const j = m({
  name: "PresetWFChartView",
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    },
    deName: {
      type: String,
      required: !0
    }
  },
  setup(e) {
    const s = d("preset-wf-chart-view"), {
      proxy: t
    } = b(), r = x(t, (o, n) => new O(e.modelPath, o, n));
    return g(t, "deName", r.setDeName.bind(r)), {
      c: r,
      ns: s
    };
  },
  render() {
    return a("div", {
      class: this.ns.b()
    }, [a("img", {
      attrs: {
        src: this.c.imgSrc
      }
    })]);
  }
});
const z = m({
  name: "WFToolbar",
  props: {
    wfLinks: {
      type: Array,
      required: !0
    }
  },
  setup(e, {
    emit: s
  }) {
    return {
      ns: d("wf-toolbar"),
      handleClick: async (o, n) => {
        s("wf-link-click", o, n);
      }
    };
  },
  render() {
    const e = this.wfLinks || [];
    return a("div", {
      class: `${this.ns.b()}`
    }, [e.length > 0 && e.map((s) => {
      const t = s.sequenceFlowName == "\u9A73\u56DE" || s.sequenceFlowName == "\u53D6\u6D88";
      return a("div", {
        key: s.sequenceFlowId,
        class: [this.ns.e("item"), t ? this.ns.em("item", "reject") : ""]
      }, [a("i-button", {
        attrs: {
          title: s.sequenceFlowName
        },
        on: {
          click: (r) => this.handleClick(s, r)
        }
      }, [s.sequenceFlowName || ""])]);
    })]);
  }
});
class q {
  constructor() {
    l(this, "component", j);
  }
}
class _ {
  constructor() {
    l(this, "component", W);
  }
  async createController(s, t) {
    const r = new C(s, t);
    return await r.init(), r;
  }
}
class G {
  constructor() {
    l(this, "component", "IndexView");
  }
}
const k = m({
  name: "WFStepTraceGrid",
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    },
    deName: {
      type: String,
      required: !0
    }
  },
  setup(e) {
    const {
      proxy: s
    } = b(), t = S(s, e.modelPath);
    g(s, "deName", t.setDeName.bind(t));
    const r = d("wf-step-trace-grid"), o = p([]);
    t.nerve.self.evt.on("mounted", () => {
      var i;
      !t.data || (i = t.data.usertasks) == null || i.forEach((u) => {
        u.identitylinks.length > 0 || (u.comments.length > 0 && u.comments.forEach((c) => {
          o.value.push({
            nodeName: u.userTaskName,
            personName: c.authorName,
            time: c.time,
            content: c.type,
            comment: c.fullMessage
          });
        }), o.value.sort((c, w) => Date.parse(w.time) - Date.parse(c.time)));
      });
    });
    const n = p([{
      title: "\u5904\u7406\u73AF\u8282",
      key: "nodeName",
      width: 180,
      resizable: !0
    }, {
      title: "\u5904\u7406\u4EBA",
      key: "personName",
      width: 180,
      resizable: !0
    }, {
      title: "\u5904\u7406\u65F6\u95F4",
      key: "time",
      width: 180,
      resizable: !0
    }, {
      title: "\u5904\u7406\u5185\u5BB9",
      key: "content",
      width: 180,
      resizable: !0
    }, {
      title: "\u5904\u7406\u610F\u89C1",
      key: "comment"
    }]);
    return {
      c: t,
      ns: r,
      gridData: o,
      columns: n
    };
  },
  render() {
    return a("div", {
      class: this.ns.b()
    }, [a("div", {
      class: this.ns.e("title")
    }, ["\u5BA1\u6279\u4FE1\u606F"]), a("i-table", {
      attrs: {
        "disabled-hover": !0,
        columns: this.columns,
        data: this.gridData
      },
      class: this.ns.e("grid")
    })]);
  }
}), B = m({
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    }
  },
  setup(e) {
    const {
      proxy: s
    } = b(), t = I(s, e.modelPath), r = d(`view-${D.DE_WF_DYNA_EDIT_VIEW3}`.toLowerCase()), o = p(["mainForm"]);
    return {
      c: t,
      ns: r,
      onTabClick: (i) => {
        o.value.includes(i) || o.value.push(i);
      },
      lazyList: o
    };
  },
  render(e) {
    const s = [];
    if (this.c.complete) {
      const {
        activeForm: t
      } = this.c;
      t && this.c.providers[t.name] && s.push(e(this.c.providers[t.name].component, {
        props: {
          modelData: t,
          context: this.c.context,
          params: this.c.params
        },
        style: {
          height: "auto"
        },
        on: {
          neuronInit: this.c.nerve.onNeuronInit("form")
        }
      }));
    }
    if (this.c.complete && this.c.model.drTab.pages[0]) {
      const t = this.c.model.drTab.pages[0], r = this.c.drPages[t.source.name];
      s.push(e(k, {
        attrs: {
          context: r.context,
          params: r.params,
          deName: this.c.model.appEntity.source.codeName,
          modal: this.modal,
          modelPath: t.embedView.source.modelPath
        }
      }));
    }
    return e("view-base", {
      attrs: {
        controller: this.c
      },
      scopedSlots: {
        toolbar: () => this.c.complete ? [this.c.wfLinks.length > 0 && e("wf-toolbar", {
          attrs: {
            wfLinks: this.c.wfLinks
          },
          on: {
            "wf-link-click": (t) => {
              this.c.onLinkClick(t);
            }
          }
        })] : null
      }
    }, [this.c.complete && e("i-tabs", {
      class: [this.ns.be("", "tab")],
      attrs: {
        name: this.c.model.drTab.source.name
      },
      on: {
        "on-click": this.onTabClick
      }
    }, [e("i-tab-pane", {
      class: this.ns.be("", "tab-item"),
      attrs: {
        tab: this.c.model.drTab.source.name,
        label: this.c.model.drTab.source.editItemCaption,
        name: "mainForm"
      }
    }, [s]), this.c.model.drTab.pages.map((t) => {
      const r = this.c.drPages[t.source.name];
      return e("i-tab-pane", {
        class: this.ns.be("", "tab-item"),
        attrs: {
          tab: this.c.model.drTab.source.name,
          disabled: this.c.isNewData,
          label: t.source.caption,
          name: t.source.name
        }
      }, [!this.c.isNewData && this.lazyList.includes(t.source.name) && e("ViewShell", {
        props: {
          context: r.context,
          params: r.params,
          modal: {
            mode: v.EMBED
          },
          modelPath: t.embedView.source.modelPath,
          deName: this.c.model.appEntity.source.codeName
        },
        on: {
          neuronInit: this.c.nerve.onNeuronInit(t.source.name)
        },
        key: r.key
      })]);
    })])]);
  }
});
class M {
  constructor() {
    l(this, "component", B);
  }
}
const R = m({
  name: "SyEditView3",
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    }
  },
  setup(e) {
    const {
      proxy: s
    } = b(), t = F(s, e.modelPath), r = d("view-deeditview3"), o = p(["mainForm"]);
    return {
      c: t,
      ns: r,
      onTabClick: (i) => {
        o.value.includes(i) || o.value.push(i);
      },
      lazyList: o
    };
  },
  render(e) {
    return e("view-base", {
      attrs: {
        controller: this.c
      }
    }, [this.c.complete && e("i-tabs", {
      class: [this.ns.be("", "tab")],
      attrs: {
        name: this.c.model.drTab.source.name
      },
      on: {
        "on-click": this.onTabClick
      }
    }, [e("i-tab-pane", {
      class: this.ns.be("", "tab-item"),
      attrs: {
        tab: this.c.model.drTab.source.name,
        label: this.c.model.drTab.source.editItemCaption,
        name: "mainForm"
      }
    }, [e("edit-form-control", {
      attrs: {
        modelData: this.c.model.form,
        context: this.c.context,
        params: this.c.params
      },
      style: {
        height: "auto"
      },
      on: {
        neuronInit: this.c.nerve.onNeuronInit(this.c.model.form.source.name)
      }
    }), e(k, {
      attrs: {
        context: this.c.drPages[this.c.model.drTab.pages[0].source.name].context,
        params: this.c.drPages[this.c.model.drTab.pages[0].source.name].params,
        deName: this.c.model.appEntity.source.codeName,
        modal: this.modal,
        modelPath: this.c.model.drTab.pages[0].embedView.source.modelPath
      }
    })]), this.c.model.drTab.pages.map((s) => {
      const t = this.c.drPages[s.source.name];
      if (!!t)
        return e("i-tab-pane", {
          class: this.ns.be("", "tab-item"),
          attrs: {
            tab: this.c.model.drTab.source.name,
            disabled: this.c.isNewData,
            label: s.source.caption,
            name: s.source.name
          }
        }, [!this.c.isNewData && this.lazyList.includes(s.source.name) && e("ViewShell", {
          props: {
            context: t.context,
            params: t.params,
            modal: {
              mode: v.EMBED
            },
            modelPath: s.embedView.source.modelPath,
            deName: this.c.model.appEntity.source.codeName
          },
          on: {
            neuronInit: this.c.nerve.onNeuronInit(s.source.name)
          },
          key: t.key
        })]);
    })])]);
  }
});
class U {
  constructor() {
    l(this, "component", R);
  }
}
const X = {
  mateUrl: import.meta.url,
  install(e) {
    ibiz.config.enableDataInfoBar = !1, e.component("WfToolbar", z), ibiz.register.view.register(
      "VIEW_CUSTOM_SyWebIndexView",
      new G()
    ), ibiz.register.view.register(
      "VIEW_CUSTOM_PresetWFChartView",
      new q()
    ), ibiz.register.gridColumn.register(
      "GRID_COLRENDER_CodeListGridColumn",
      new _()
    ), ibiz.register.view.register(
      "VIEW_CUSTOM_SyWfDynaEditView3",
      new M()
    ), ibiz.register.view.register(
      "VIEW_CUSTOM_SyEditView3",
      new U()
    );
  }
};
export {
  X as default
};
