var f = Object.defineProperty;
var g = (e, t, r) => t in e ? f(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
var l = (e, t, r) => (g(e, typeof t != "symbol" ? t + "" : t, r), r);
import { GridFieldColumnController as u, GridRowController as p, WFStepTraceViewController as I } from "@ibiz-template/controller";
import { defineComponent as C, computed as m, h as c, getCurrentInstance as V } from "vue";
import { useNamespace as w, useViewController as b, usePropsWatch as y } from "@ibiz-template/vue-util";
import { colorBlend as L, IBizContext as x } from "@ibiz-template/core";
class S {
  constructor() {
    l(this, "compName", "VIEWCUSTOMPresetWFChartView");
  }
}
class W {
  constructor() {
    l(this, "compName", "GRIDCOLRENDERCodeListGridColumn");
  }
  async createController(t, r) {
    const n = new u(t, r);
    return await n.init(), n;
  }
}
class P {
  constructor() {
    l(this, "compName", "IndexView");
  }
}
const R = C({
  name: "CodeListGridColumn",
  props: {
    controller: {
      type: u,
      required: !0
    },
    row: {
      type: p,
      required: !0
    }
  },
  setup(e) {
    const t = w("grid-field-column"), r = m(() => {
      var d;
      if (e.controller.model.source.cLConvertMode !== "FRONT")
        return [];
      const o = e.row.data[e.controller.model.codeName];
      return ((d = e.controller.codeListItems) == null ? void 0 : d.length) && o ? o.split(",").map((h) => {
        const a = e.controller.codeListItems.find((i) => i.value === h);
        if (a) {
          const i = a.color || "#515a6e";
          return {
            text: a.text,
            colorStyle: t.cssVarBlock({
              color: i,
              "border-color": i,
              "bg-color": L(i, "#fff")
            })
          };
        }
      }).filter(Boolean) : [];
    }), n = (o) => {
      e.controller.isLinkColumn && e.controller.openLinkView(e.row, o);
    }, s = m(() => {
      let o = "";
      switch (e.controller.model.align) {
        case "LEFT":
          o = "flex-start";
          break;
        case "RIGHT":
          o = "flex-end";
          break;
        default:
          o = "center";
          break;
      }
      return t.cssVarBlock({
        "justify-content": o
      });
    });
    return {
      ns: t,
      alignStyle: s,
      selectedItems: r,
      onCellClick: n
    };
  },
  render() {
    const e = this.controller, t = this.row.data[e.model.codeName];
    return c("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((r) => c("span", {
      class: this.ns.e("code-list-item"),
      style: r.colorStyle
    }, [r.text])) : c("span", {
      class: this.ns.e("text")
    }, [t])]);
  }
});
class v extends I {
  constructor() {
    super(...arguments);
    l(this, "imgSrc");
  }
  async getUIData() {
    const r = new x(this.params, this.context), n = await this.entityService.wf.getWFProcessDiagram(r), s = new Blob([n.data]);
    this.imgSrc = URL.createObjectURL(s);
  }
}
const F = C({
  name: "PresetWFChartView",
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    },
    deName: {
      type: String,
      required: !0
    }
  },
  setup(e) {
    const t = w("preset-wf-chart-view"), {
      proxy: r
    } = V(), n = b(r, (s, o) => new v(e.modelPath, s, o));
    return y(r, "deName", n.setDeName.bind(n)), {
      c: n,
      ns: t
    };
  },
  render() {
    return c("div", {
      class: this.ns.b()
    }, [c("img", {
      attrs: {
        src: this.c.imgSrc
      }
    })]);
  }
}), U = {
  mateUrl: import.meta.url,
  install(e) {
    ibiz.register.view.register(
      "VIEW_CUSTOM_SyWebIndexView",
      new P()
    ), e.component("VIEWCUSTOMPresetWFChartView", F), ibiz.register.view.register(
      "VIEW_CUSTOM_PresetWFChartView",
      new S()
    ), e.component("GRIDCOLRENDERCodeListGridColumn", R), ibiz.register.gridColumn.register(
      "GRID_COLRENDER_CodeListGridColumn",
      new W()
    );
  }
};
export {
  U as default
};
