import e from "../PlTooltip/PlTooltip.js";
import "../PlTooltip/index.js";
import { downloadContent as t } from "../../helpers/downloadContent.js";
import n from "../PlIcon24/PlIcon24.js";
import "../PlIcon24/index.js";
import r from "../../utils/DoubleContour.js";
import { useLabelNotch as i } from "../../utils/useLabelNotch.js";
import "../PlMaskIcon24/index.js";
import './pl-log-view.css';/* empty css            */
import { useLogHandle as a } from "./useLogHandle.js";
import { computed as o, createBlock as s, createCommentVNode as c, createElementBlock as l, createElementVNode as u, createTextVNode as d, createVNode as f, defineComponent as p, normalizeClass as m, openBlock as h, ref as g, renderSlot as _, toDisplayString as v, unref as y, useSlots as b, watch as x, withCtx as S } from "vue";
import { okOptional as C, tapIf as w } from "@milaboratories/helpers";
var T = { key: 0 }, E = { class: "pl-log-view__copy" }, D = {
	key: 1,
	class: "pl-log-view__error"
}, O = /* @__PURE__ */ p({
	name: "PlLogView",
	props: {
		value: {},
		valueToCopy: {},
		logHandle: {},
		progressPrefix: {},
		error: {},
		output: {},
		maxRetries: {},
		mockPlatforma: {},
		label: {},
		disableAutoScroll: { type: Boolean },
		downloadFilename: {}
	},
	setup(p) {
		let O = (e) => {
			if (e && e.ok === !1) return e.errors.join("\n");
		}, k = b(), A = p, j = a(A), M = g(!0), N = g(), P = g(), F = o(() => j.value?.error ?? A.error ?? O(A.output)), I = o(() => j.value?.lines ?? A.value ?? C(A.output)), L = o(() => {
			if (A.valueToCopy) return A.valueToCopy;
			if (I.value && typeof I.value == "string") return I.value;
		}), R = g(!1);
		i(P);
		let z = o(() => R.value ? "clipboard-copied" : "clipboard"), B = () => {
			R.value = !0, setTimeout(() => {
				R.value = !1;
			}, 1200);
			let e = L.value;
			e !== void 0 && navigator.clipboard.writeText(e);
		}, V = (e) => {
			let n = L.value;
			n !== void 0 && t([n, "text/plain"], e);
		}, H = () => {
			A.disableAutoScroll || w(N.value, (e) => {
				M.value && e.scrollTo(e.scrollLeft, e.scrollHeight);
			});
		};
		x(I, () => {
			requestAnimationFrame(() => {
				H();
			});
		}, { immediate: !0 });
		let U = (e) => {
			let t = e.target;
			M.value = t.scrollTop + 20 >= t.scrollHeight - t.offsetHeight;
		};
		return (t, i) => (h(), l("div", {
			ref_key: "root",
			ref: P,
			class: m(["pl-log-view", { "has-error": F.value }])
		}, [
			p.label ? (h(), l("label", T, [u("span", null, v(p.label), 1), y(k).tooltip ? (h(), s(y(e), {
				key: 0,
				class: "info",
				position: "top"
			}, {
				tooltip: S(() => [_(t.$slots, "tooltip")]),
				_: 3
			})) : c("", !0)])) : c("", !0),
			f(r, { class: "pl-log-view__contour" }),
			u("div", E, [f(y(e), {
				"close-delay": 800,
				position: "top"
			}, {
				tooltip: S(() => [d(v(R.value ? "copied" : "copy"), 1)]),
				default: S(() => [f(y(n), {
					title: "Copy content",
					name: z.value,
					onClick: B
				}, null, 8, ["name"])]),
				_: 1
			}), p.downloadFilename ? (h(), s(y(e), {
				key: 0,
				"close-delay": 800,
				position: "top"
			}, {
				tooltip: S(() => [...i[1] ||= [d("download", -1)]]),
				default: S(() => [f(y(n), {
					name: "download",
					onClick: i[0] ||= () => V(p.downloadFilename)
				})]),
				_: 1
			})) : c("", !0)]),
			F.value ? (h(), l("div", D, v(F.value), 1)) : (h(), l("div", {
				key: 2,
				ref_key: "contentRef",
				ref: N,
				class: "pl-log-view__content",
				onScroll: U
			}, v(I.value), 545))
		], 2));
	}
});
export { O as default };

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