var s = Object.defineProperty;
var i = (r, e, t) => e in r ? s(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
var o = (r, e, t) => (i(r, typeof e != "symbol" ? e + "" : e, t), t);
import { defineComponent as c, getCurrentInstance as a } from "vue";
import { useViewController as l } from "@ibiz-template/vue-util";
import { Neuron as h, ViewNerve as u, ViewController as d } from "@ibiz-template/controller";
class p extends h {
}
class m extends u {
  constructor() {
    super(...arguments);
    o(this, "chart");
  }
  createNeuron() {
    return new p(this.bindAbility());
  }
  inclusive(t) {
    return t === "chart" || super.inclusive(t);
  }
  connect(t, n) {
    super.connect(t, n), t === "chart" && (this.chart = n, this.chart.evt.on("destroyed", () => {
      this.chart = void 0;
    }));
  }
  destroy() {
    super.destroy(), this.chart = void 0;
  }
}
class v extends d {
  createNerve() {
    return new m(this);
  }
  async onInit() {
    await super.onInit();
    const { chart: e } = this.model;
    e && (this.providers[e.name] = await ibiz.register.control.get(e)), this.nerve.self.evt.on("mounted", () => {
      this.model.source.loadDefault && this.load();
    });
  }
  /**
   * 视图加载方法
   *
   * @return {*}  {Promise<IData[]>}
   * @memberof ChartViewController
   */
  async load() {
    const { chart: e } = this.nerve;
    return e.call.load();
  }
}
function f(r, e) {
  return l(
    r,
    (t, n) => new v(e, t, n)
  );
}
const V = c({
  props: {
    context: Object,
    params: {
      type: Object,
      default: () => ({})
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    }
  },
  setup(r) {
    const {
      proxy: e
    } = a();
    return {
      c: f(e, r.modelPath)
    };
  },
  render(r) {
    let e = null;
    if (this.c.complete) {
      const {
        chart: t
      } = this.c.model;
      this.c.providers[t.name] && (e = r(this.c.providers[t.name].component, {
        props: {
          modelData: t,
          context: this.c.context,
          params: this.c.params
        },
        on: {
          neuronInit: this.c.nerve.onNeuronInit(t.name)
        }
      }));
    }
    return r("view-base", {
      attrs: {
        controller: this.c
      }
    }, [e]);
  }
});
export {
  V as default
};
