var V = Object.defineProperty;
var k = (e, s, t) => s in e ? V(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
var l = (e, s, t) => (k(e, typeof s != "symbol" ? s + "" : s, t), t);
import { GridFieldColumnController as C, GridRowController as P, WFStepTraceViewController as T } from "@ibiz-template/controller";
import { defineComponent as u, computed as f, h as a, getCurrentInstance as b, ref as p } from "vue";
import { useNamespace as h, useViewController as x, usePropsWatch as g, useWFStepTraceViewController as S, useWFDynaEditView3Controller as N, useEditView3Controller as I } from "@ibiz-template/vue-util";
import { colorBlend as E, IBizContext as F } from "@ibiz-template/core";
import { ViewType as L } from "@ibiz-template/model";
const D = u({
  name: "CodeListGridColumn",
  props: {
    controller: {
      type: C,
      required: !0
    },
    row: {
      type: P,
      required: !0
    }
  },
  setup(e) {
    const s = h("grid-field-column"), t = f(() => {
      var n;
      if (e.controller.model.source.cLConvertMode !== "FRONT")
        return [];
      const i = e.row.data[e.controller.model.codeName];
      return ((n = e.controller.codeListItems) == null ? void 0 : n.length) && i ? i.split(",").map((w) => {
        const y = e.controller.codeListItems.find((d) => d.value === w);
        if (y) {
          const d = y.color || "#515a6e";
          return {
            text: y.text,
            colorStyle: s.cssVarBlock({
              color: d,
              "border-color": d,
              "bg-color": E(d, "#fff")
            })
          };
        }
      }).filter(Boolean) : [];
    }), r = (i) => {
      e.controller.isLinkColumn && e.controller.openLinkView(e.row, i);
    }, o = f(() => {
      let i = "";
      switch (e.controller.model.align) {
        case "LEFT":
          i = "flex-start";
          break;
        case "RIGHT":
          i = "flex-end";
          break;
        default:
          i = "center";
          break;
      }
      return s.cssVarBlock({
        "justify-content": i
      });
    });
    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 W extends T {
  constructor() {
    super(...arguments);
    l(this, "imgSrc");
  }
  async getUIData() {
    const t = new F(this.params, this.context), r = await this.entityService.wf.getWFProcessDiagram(t), o = new Blob([r.data]);
    this.imgSrc = URL.createObjectURL(o);
  }
}
const O = u({
  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 = h("preset-wf-chart-view"), {
      proxy: t
    } = b(), r = x(t, (o, i) => new W(e.modelPath, o, i));
    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
      }
    })]);
  }
});
class j {
  constructor() {
    l(this, "component", O);
  }
}
class _ {
  constructor() {
    l(this, "component", D);
  }
  async createController(s, t) {
    const r = new C(s, t);
    return await r.init(), r;
  }
}
class z {
  constructor() {
    l(this, "component", "IndexView");
  }
}
const v = u({
  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 = h("wf-step-trace-grid"), o = p([]);
    t.nerve.self.evt.on("mounted", () => {
      var n;
      !t.data || (n = t.data.usertasks) == null || n.forEach((m) => {
        m.identitylinks.length > 0 || (m.comments.length > 0 && m.comments.forEach((c) => {
          o.value.push({
            nodeName: m.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 i = 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: i
    };
  },
  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")
    })]);
  }
}), G = u({
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    }
  },
  setup(e) {
    const {
      proxy: s
    } = b(), t = N(s, e.modelPath), r = h(`view-${L.DE_WF_DYNA_EDIT_VIEW3}`.toLowerCase()), o = p(["mainForm"]);
    return {
      c: t,
      ns: r,
      onTabClick: (n) => {
        o.value.includes(n) || o.value.push(n);
      },
      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(v, {
        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: this.modal,
          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 q {
  constructor() {
    l(this, "component", G);
  }
}
const R = u({
  name: "SyEditView3",
  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 = h("view-deeditview3"), o = p(["mainForm"]);
    return {
      c: t,
      ns: r,
      onTabClick: (n) => {
        o.value.includes(n) || o.value.push(n);
      },
      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(v, {
      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: this.modal,
            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 J = {
  mateUrl: import.meta.url,
  install(e) {
    ibiz.register.view.register(
      "VIEW_CUSTOM_SyWebIndexView",
      new z()
    ), ibiz.register.view.register(
      "VIEW_CUSTOM_PresetWFChartView",
      new j()
    ), ibiz.register.gridColumn.register(
      "GRID_COLRENDER_CodeListGridColumn",
      new _()
    ), ibiz.register.view.register(
      "VIEW_CUSTOM_SyWfDynaEditView3",
      new q()
    ), ibiz.register.view.register(
      "VIEW_CUSTOM_SyEditView3",
      new U()
    );
  }
};
export {
  J as default
};
