(function(){"use strict";try{if(typeof document<"u"){var o=document.createElement("style");o.appendChild(document.createTextNode('.pl-log-view{--log-background: var(--bg-base-light);--contour-color: var(--txt-01);--contour-border-width: 1px;--label-offset-left-x: 8px;--label-offset-right-x: 8px;--border-color-log-view: var(--border-color-div-grey);height:100%;max-height:calc(100% - var(--contour-offset));max-width:calc(100% - var(--contour-offset));border-radius:6px;background:var(--log-background);display:flex;position:relative;min-height:44px;padding-right:40px}.pl-log-view__contour{position:absolute;top:0;left:0;right:0;bottom:0;border-radius:var(--border-radius-control);border-width:var(--contour-border-width);border-color:var(--border-color-log-view);border-style:solid;box-shadow:none;z-index:0;pointer-events:none}.pl-log-view label{display:flex;align-items:center;gap:4px;position:absolute;top:0;transform:translateY(-60%);left:var(--label-offset-left-x);padding:0 4px;max-width:calc(100% - 16px);overflow:hidden;white-space:pre;text-overflow:ellipsis;cursor:inherit;color:var(--label-color);font-size:12px;font-weight:500;border-bottom-right-radius:4px;border-bottom-left-radius:4px;background:var(--bg-elevated-01)}.pl-log-view label>span{overflow:hidden;white-space:pre;text-overflow:ellipsis}.pl-log-view.has-error{--log-background: linear-gradient(90deg, #FFEBEB 0%, #FFFFFF 100%);--border-color-log-view: var(--border-color-error)}.pl-log-view__copy{position:absolute;top:12px;right:12px;cursor:pointer;--icon-color: var(--ic-02)}.pl-log-view__copy>*:hover{--icon-color: var(--txt-01)}.pl-log-view__content{margin:12px;max-height:100%;max-width:100%;flex:1;color:var(--txt-01);font-feature-settings:"ss11" on,"ss15" on,"ss17" on;font-family:var(--font-family-monospace);white-space:pre;font-size:14px;font-weight:400;line-height:20px;--thumb-color: var(--ic-02);overflow-y:auto;overflow-x:auto}.pl-log-view__content::-webkit-scrollbar{width:var(--scrollbar-width, 6px);height:5px;background-color:transparent;display:block}.pl-log-view__content::-webkit-scrollbar-thumb{background:var(--thumb-color);border-radius:5px}.pl-log-view__content::-webkit-scrollbar-thumb:hover{--thumb-color: var(--border-color-focus)}.pl-log-view__error{margin:12px;max-height:100%;max-width:100%;flex:1;color:var(--txt-01);font-feature-settings:"ss11" on,"ss15" on,"ss17" on;font-family:var(--font-family-monospace);white-space:pre;font-size:14px;font-weight:400;line-height:20px;--thumb-color: var(--ic-02);overflow-y:auto;overflow-x:auto}.pl-log-view__error::-webkit-scrollbar{width:var(--scrollbar-width, 6px);height:5px;background-color:transparent;display:block}.pl-log-view__error::-webkit-scrollbar-thumb{background:var(--thumb-color);border-radius:5px}.pl-log-view__error::-webkit-scrollbar-thumb:hover{--thumb-color: var(--border-color-focus)}')),document.head.appendChild(o)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
import { defineComponent as F, useSlots as L, ref as s, computed as c, watch as P, createElementBlock as u, openBlock as l, normalizeClass as x, createCommentVNode as f, createVNode as p, createElementVNode as C, createBlock as b, toDisplayString as d, unref as r, withCtx as a, renderSlot as R, createTextVNode as S } from "vue";
import T from "../PlIcon24/PlIcon24.vue.js";

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