import e from "../PlErrorAlert/PlErrorAlert.js";
import "../PlErrorAlert/index.js";
import { Fragment as t, computed as n, createBlock as r, createCommentVNode as i, createElementBlock as a, defineComponent as o, onBeforeUpdate as s, onErrorCaptured as c, openBlock as l, ref as u, renderSlot as d, unref as f } from "vue";
import { isErrorLike as p, tryDo as m } from "@milaboratories/helpers";
var h = /* @__PURE__ */ o({
	__name: "PlErrorBoundary",
	setup(o, { expose: h }) {
		let g = (e) => {
			if (e != null) return p(e) ? e.stack == null || e.stack.length === 0 ? e.message : e.stack.includes(e.message) ? e.stack : e.message + "\n" + e.stack : m(() => JSON.stringify(e, null, 4), () => e.toString());
		}, _ = u(null), v = n(() => _.value?.error), y = n(() => g(v.value));
		function b() {
			_.value = null;
		}
		let x = u(null);
		return s(() => {
			_.value !== null && x.value && b();
		}), c((e, t) => (_.value = {
			title: t?.$?.type?.name ?? void 0,
			error: e
		}, !1)), h({
			error: v,
			reset: b
		}), (n, o) => (l(), a(t, null, [d(n.$slots, "default"), v.value ? (l(), r(f(e), {
			key: 0,
			ref_key: "errorAlert",
			ref: x,
			message: y.value,
			title: _.value?.title
		}, null, 8, ["message", "title"])) : i("", !0)], 64));
	}
});
export { h as default };

//# sourceMappingURL=PlErrorBoundary.vue2.js.map