const w = ".rte-content, .editora-content", F = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", te = "__editoraCommandEditorRoot", oe = "rte-approval-workflow-styles", d = "rte-approval-panel", h = "approval", k = "approvalWorkflow", v = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', fe = {
  panelTitle: "Approval Workflow",
  panelAriaLabel: "Approval workflow panel",
  statusLabel: "Status",
  statusDraftText: "Draft",
  statusReviewText: "In Review",
  statusApprovedText: "Approved",
  requestReviewText: "Request Review",
  approveText: "Approve",
  reopenDraftText: "Reopen Draft",
  addCommentText: "Add Comment",
  actorLabel: "Actor",
  actorPlaceholder: "Reviewer name",
  commentLabel: "Comment",
  commentPlaceholder: "Add review note or sign-off context",
  closeText: "Close",
  commentsHeading: "Comments",
  signoffsHeading: "Sign-offs",
  noCommentsText: "No comments yet.",
  noSignoffsText: "No sign-offs yet.",
  summaryPrefix: "Workflow",
  lockedSuffix: "Locked",
  shortcutText: "Shortcuts: Ctrl/Cmd+Alt+Shift+A/R/P/D",
  approveCommentRequiredText: "Approval comment is required."
}, me = {
  draft: "statusDraftText",
  review: "statusReviewText",
  approved: "statusApprovedText"
}, p = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new Set();
let _ = 0, be = 0, re = 0, ae = 0, R = null, g = null, T = null, L = null, S = null;
function c(e) {
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
}
function ve(e) {
  return e.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
}
function le(e) {
  return e === "review" || e === "approved" ? e : "draft";
}
function z(e = {}) {
  var t;
  return {
    defaultStatus: le(e.defaultStatus),
    lockOnApproval: e.lockOnApproval !== !1,
    maxHistoryEntries: Math.max(10, Math.min(500, Number((t = e.maxHistoryEntries) != null ? t : 120))),
    requireCommentOnApprove: !!e.requireCommentOnApprove,
    defaultActor: (e.defaultActor || "system").trim() || "system",
    labels: {
      ...fe,
      ...e.labels || {}
    },
    normalizeText: e.normalizeText || ve
  };
}
function Y(e) {
  return e.closest(F) || e;
}
function K(e) {
  if (!e) return null;
  if (e.matches(w)) return e;
  const t = e.querySelector(w);
  return t instanceof HTMLElement ? t : null;
}
function ge() {
  if (typeof window == "undefined") return null;
  const e = window[te];
  if (!(e instanceof HTMLElement)) return null;
  window[te] = null;
  const t = K(e);
  if (t) return t;
  const o = e.closest(F);
  if (o) {
    const a = K(o);
    if (a) return a;
  }
  return null;
}
function he(e) {
  const t = e.closest("[data-editora-editor]");
  if (t && K(t) === e)
    return t;
  let o = e;
  for (; o; ) {
    if (o.matches(F) && (o === e || K(o) === e))
      return o;
    o = o.parentElement;
  }
  return Y(e);
}
function W(e) {
  return e ? (e.getAttribute("data-theme") || e.getAttribute("theme") || "").toLowerCase() === "dark" ? !0 : e.classList.contains("dark") || e.classList.contains("editora-theme-dark") || e.classList.contains("rte-theme-dark") : !1;
}
function xe(e) {
  const t = Y(e);
  if (W(t)) return !0;
  const o = t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
  return W(o) ? !0 : W(document.documentElement) || W(document.body);
}
function B(e, t) {
  e.classList.remove("rte-approval-theme-dark"), xe(t) && e.classList.add("rte-approval-theme-dark");
}
function ie(e) {
  return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
}
function x(e, t = !0) {
  if (D(), (e == null ? void 0 : e.contentElement) instanceof HTMLElement) return e.contentElement;
  if ((e == null ? void 0 : e.editorElement) instanceof HTMLElement) {
    const n = e.editorElement;
    if (n.matches(w)) return n;
    const l = n.querySelector(w);
    if (l instanceof HTMLElement) return l;
  }
  const o = ge();
  if (o) return o;
  const a = window.getSelection();
  if (a && a.rangeCount > 0) {
    const n = ie(a.getRangeAt(0).startContainer), l = n == null ? void 0 : n.closest(w);
    if (l) return l;
  }
  const r = document.activeElement;
  if (r) {
    if (r.matches(w)) return r;
    const n = r.closest(w);
    if (n) return n;
  }
  return g && g.isConnected ? g : (g && !g.isConnected && (g = null), t ? document.querySelector(w) : null);
}
function D() {
  Array.from(H).forEach((t) => {
    var o;
    t.isConnected || ((o = y.get(t)) == null || o.remove(), y.delete(t), O.delete(t), p.delete(t), I.delete(t), H.delete(t), g === t && (g = null));
  });
}
function we(e) {
  return e ? !!(e.closest(`.${d}`) || e.closest(w) || e.closest(F)) : !1;
}
function ye() {
  const e = window.getSelection();
  if (!e || e.rangeCount === 0) return !1;
  const t = e.getRangeAt(0).startContainer, o = ie(t);
  return !!(o != null && o.closest(w));
}
function C(e, t, o) {
  const a = he(e);
  Array.from(
    a.querySelectorAll(
      `.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`
    )
  ).forEach((n) => {
    n.classList.toggle("active", o), n.setAttribute("aria-pressed", o ? "true" : "false"), n.setAttribute("data-active", o ? "true" : "false");
  });
}
function se(e, t, o) {
  t !== null ? e.setAttribute("contenteditable", t) : e.setAttribute("contenteditable", "true"), o !== null ? e.setAttribute("data-readonly", o) : e.removeAttribute("data-readonly");
}
function X(e) {
  e.dispatchEvent(new Event("input", { bubbles: !0 }));
}
function J(e, t) {
  if (t === e.innerHTML) return;
  const o = window.execEditorCommand || window.executeEditorCommand;
  if (typeof o == "function")
    try {
      o("recordDomTransaction", e, t, e.innerHTML);
    } catch (a) {
    }
}
function Q() {
  return re += 1, `approval-comment-${Date.now().toString(36)}-${re.toString(36)}`;
}
function ke() {
  return ae += 1, `approval-signoff-${Date.now().toString(36)}-${ae.toString(36)}`;
}
function pe(e) {
  return {
    status: e.status,
    locked: e.locked,
    comments: e.comments.map((t) => ({ ...t })),
    signoffs: e.signoffs.map((t) => ({ ...t })),
    updatedAt: e.updatedAt
  };
}
function Ae(e, t) {
  const o = me[e];
  return t.labels[o] || e;
}
function ce(e, t, o) {
  var a, r;
  if (e.setAttribute("data-approval-status", t.status), e.setAttribute("data-approval-locked", t.locked ? "true" : "false"), e.classList.toggle("rte-approval-locked-editor", t.locked), C(e, "toggleApprovalWorkflowPanel", ee(e)), C(e, "requestApprovalReview", t.status === "review"), C(e, "approveDocument", t.status === "approved"), C(e, "reopenDraft", t.status === "draft"), t.status === "approved" && o.lockOnApproval) {
    t.locked || (t.preApprovalContentEditable = e.getAttribute("contenteditable"), t.preApprovalReadonly = e.getAttribute("data-readonly")), e.setAttribute("contenteditable", "false"), e.setAttribute("data-readonly", "true"), t.locked = !0;
    return;
  }
  t.locked = !1, se(
    e,
    (a = t.preApprovalContentEditable) != null ? a : t.originalContentEditable,
    (r = t.preApprovalReadonly) != null ? r : t.originalReadonly
  ), t.preApprovalContentEditable = null, t.preApprovalReadonly = null;
}
function f(e, t) {
  let o = I.get(e);
  return o || (o = {
    status: t.defaultStatus,
    locked: !1,
    comments: [],
    signoffs: [],
    updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
    originalContentEditable: e.getAttribute("contenteditable"),
    originalReadonly: e.getAttribute("data-readonly"),
    preApprovalContentEditable: null,
    preApprovalReadonly: null
  }, I.set(e, o), H.add(e), ce(e, o, t), o);
}
function j(e, t) {
  return e.length <= t ? e : e.slice(e.length - t);
}
function M(e, t) {
  const o = e.querySelector(".rte-approval-live");
  o && (o.textContent = t);
}
function Se(e, t) {
  const o = pe(t);
  e.__approvalWorkflowState = o, e.dispatchEvent(
    new CustomEvent("editora:approval-state-changed", {
      bubbles: !0,
      detail: {
        state: o
      }
    })
  );
}
function q(e) {
  const t = y.get(e);
  if (!t) return;
  const o = p.get(e) || R;
  if (!o) return;
  const a = f(e, o), r = t.querySelector(".rte-approval-summary"), n = t.querySelector('[data-action="request-review"]'), l = t.querySelector('[data-action="approve"]'), s = t.querySelector('[data-action="reopen-draft"]'), u = t.querySelector(".rte-approval-comments-list"), m = t.querySelector(".rte-approval-signoffs-list");
  if (r) {
    const i = Ae(a.status, o);
    r.textContent = `${o.labels.summaryPrefix}: ${i} | Comments: ${a.comments.length} | Sign-offs: ${a.signoffs.length}${a.locked ? ` | ${o.labels.lockedSuffix}` : ""}`;
  }
  n && (n.disabled = a.status !== "draft"), l && (l.disabled = a.status === "approved"), s && (s.disabled = a.status === "draft"), u && (a.comments.length === 0 ? u.innerHTML = `<li class="rte-approval-empty">${c(o.labels.noCommentsText)}</li>` : u.innerHTML = a.comments.slice().reverse().map(
    (i) => `
            <li class="rte-approval-item rte-approval-item-${i.kind}" role="listitem">
              <div class="rte-approval-item-head">
                <span class="rte-approval-item-author">${c(i.author)}</span>
                <time class="rte-approval-item-time" datetime="${c(i.createdAt)}">${c(
      new Date(i.createdAt).toLocaleString()
    )}</time>
              </div>
              <p class="rte-approval-item-message">${c(i.message)}</p>
            </li>
          `
  ).join("")), m && (a.signoffs.length === 0 ? m.innerHTML = `<li class="rte-approval-empty">${c(o.labels.noSignoffsText)}</li>` : m.innerHTML = a.signoffs.slice().reverse().map(
    (i) => `
            <li class="rte-approval-item" role="listitem">
              <div class="rte-approval-item-head">
                <span class="rte-approval-item-author">${c(i.author)}</span>
                <time class="rte-approval-item-time" datetime="${c(i.createdAt)}">${c(
      new Date(i.createdAt).toLocaleString()
    )}</time>
              </div>
              <p class="rte-approval-item-message">${c(i.comment || "Approved")}</p>
            </li>
          `
  ).join(""));
}
function G(e, t, o) {
  t.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), ce(e, t, o), q(e), Se(e, t);
}
function ne(e, t, o, a) {
  e.comments.push({
    id: Q(),
    author: o || t.defaultActor,
    message: a,
    kind: "system",
    createdAt: (/* @__PURE__ */ new Date()).toISOString()
  }), e.comments = j(e.comments, t.maxHistoryEntries);
}
function $(e, t, o, a) {
  const r = f(e, o);
  if (r.status === t) return !1;
  const n = e.innerHTML;
  return r.status = t, t === "review" ? ne(r, o, a, "Review requested.") : t === "draft" && ne(r, o, a, "Returned to draft."), G(e, r, o), X(e), J(e, n), !0;
}
function de(e, t, o, a) {
  const r = a.normalizeText(t);
  if (!r) return !1;
  const n = a.normalizeText(o) || a.defaultActor, l = f(e, a), s = e.innerHTML;
  return l.comments.push({
    id: Q(),
    author: n,
    message: r,
    kind: "comment",
    createdAt: (/* @__PURE__ */ new Date()).toISOString()
  }), l.comments = j(l.comments, a.maxHistoryEntries), G(e, l, a), X(e), J(e, s), !0;
}
function Z(e, t, o, a) {
  const r = t.normalizeText(o) || t.defaultActor, n = t.normalizeText(a);
  if (t.requireCommentOnApprove && !n) return !1;
  const l = f(e, t), s = e.innerHTML;
  return l.status = "approved", l.signoffs.push({
    id: ke(),
    author: r,
    comment: n || void 0,
    createdAt: (/* @__PURE__ */ new Date()).toISOString()
  }), l.signoffs = j(l.signoffs, t.maxHistoryEntries), n && (l.comments.push({
    id: Q(),
    author: r,
    message: n,
    kind: "system",
    createdAt: (/* @__PURE__ */ new Date()).toISOString()
  }), l.comments = j(l.comments, t.maxHistoryEntries)), G(e, l, t), X(e), J(e, s), !0;
}
function N(e, t) {
  return e.querySelector(`[data-field="${t}"]`);
}
function Ee(e) {
  var a, r;
  const t = ((a = N(e, "actor")) == null ? void 0 : a.value) || "", o = ((r = N(e, "comment")) == null ? void 0 : r.value) || "";
  return { actor: t, comment: o };
}
function U(e, t) {
  if (!t.classList.contains("show")) return;
  const a = Y(e).getBoundingClientRect(), r = Math.min(window.innerWidth - 20, 420), n = Math.max(10, window.innerWidth - r - 10), l = Math.min(Math.max(10, a.right - r), n), s = Math.max(10, Math.min(window.innerHeight - 10 - 280, a.top + 12));
  t.style.width = `${r}px`, t.style.left = `${l}px`, t.style.top = `${s}px`, t.style.maxHeight = `${Math.max(280, window.innerHeight - 24)}px`;
}
function $e(e) {
  const t = y.get(e);
  if (t) return t;
  const o = p.get(e) || R || z(), a = `rte-approval-panel-${be++}`, r = document.createElement("section");
  return r.className = d, r.id = a, r.setAttribute("role", "dialog"), r.setAttribute("aria-modal", "false"), r.setAttribute("aria-label", o.labels.panelAriaLabel), r.setAttribute("tabindex", "-1"), r.innerHTML = `
    <header class="rte-approval-header">
      <h2 class="rte-approval-title">${c(o.labels.panelTitle)}</h2>
      <button type="button" class="rte-approval-icon-btn" data-action="close" aria-label="${c(
    o.labels.closeText
  )}">✕</button>
    </header>
    <div class="rte-approval-body">
      <p class="rte-approval-summary" aria-live="polite"></p>

      <div class="rte-approval-controls" role="toolbar" aria-label="Approval actions">
        <button type="button" class="rte-approval-btn" data-action="request-review">${c(
    o.labels.requestReviewText
  )}</button>
        <button type="button" class="rte-approval-btn rte-approval-btn-primary" data-action="approve">${c(
    o.labels.approveText
  )}</button>
        <button type="button" class="rte-approval-btn" data-action="reopen-draft">${c(
    o.labels.reopenDraftText
  )}</button>
      </div>

      <div class="rte-approval-form">
        <label class="rte-approval-label">
          ${c(o.labels.actorLabel)}
          <input type="text" data-field="actor" class="rte-approval-field" autocomplete="off" placeholder="${c(
    o.labels.actorPlaceholder
  )}" />
        </label>
        <label class="rte-approval-label">
          ${c(o.labels.commentLabel)}
          <textarea data-field="comment" class="rte-approval-field" rows="2" placeholder="${c(
    o.labels.commentPlaceholder
  )}"></textarea>
        </label>
        <button type="button" class="rte-approval-btn" data-action="add-comment">${c(
    o.labels.addCommentText
  )}</button>
      </div>

      <section class="rte-approval-section" aria-label="${c(o.labels.commentsHeading)}">
        <h3 class="rte-approval-section-title">${c(o.labels.commentsHeading)}</h3>
        <ul class="rte-approval-comments-list" role="list"></ul>
      </section>

      <section class="rte-approval-section" aria-label="${c(o.labels.signoffsHeading)}">
        <h3 class="rte-approval-section-title">${c(o.labels.signoffsHeading)}</h3>
        <ul class="rte-approval-signoffs-list" role="list"></ul>
      </section>

      <p class="rte-approval-shortcut">${c(o.labels.shortcutText)}</p>
      <span class="rte-approval-live" aria-live="polite"></span>
    </div>
  `, r.addEventListener("click", (n) => {
    const l = n.target;
    if (!l) return;
    const s = l.closest("[data-action]");
    if (!s) return;
    const u = s.getAttribute("data-action") || "", m = p.get(e) || R || o;
    if (p.set(e, m), f(e, m), u === "close") {
      P(e, !0);
      return;
    }
    const i = Ee(r);
    if (u === "request-review") {
      $(e, "review", m, i.actor || m.defaultActor) && M(r, "Status changed to review.");
      return;
    }
    if (u === "reopen-draft") {
      $(e, "draft", m, i.actor || m.defaultActor) && M(r, "Status changed to draft.");
      return;
    }
    if (u === "approve") {
      const b = Z(e, m, i.actor, i.comment);
      if (!b && m.requireCommentOnApprove) {
        M(r, m.labels.approveCommentRequiredText);
        return;
      }
      if (b) {
        const E = N(r, "comment");
        E && (E.value = ""), M(r, "Document approved and signed off.");
      }
      return;
    }
    if (u === "add-comment") {
      if (!de(e, i.comment, i.actor, m)) return;
      const E = N(r, "comment");
      E && (E.value = ""), M(r, "Comment added.");
      return;
    }
  }), r.addEventListener("keydown", (n) => {
    n.key === "Escape" && (n.preventDefault(), P(e, !0));
  }), B(r, e), document.body.appendChild(r), y.set(e, r), O.set(e, !1), q(e), r;
}
function ee(e) {
  return O.get(e) === !0;
}
function A(e) {
  D();
  const t = $e(e);
  y.forEach((o, a) => {
    a !== e && P(a, !1);
  }), t.classList.add("show"), O.set(e, !0), C(e, "toggleApprovalWorkflowPanel", !0), B(t, e), U(e, t), q(e);
}
function P(e, t = !1) {
  const o = y.get(e);
  o && (o.classList.remove("show"), O.set(e, !1), C(e, "toggleApprovalWorkflowPanel", !1), t && e.focus({ preventScroll: !0 }));
}
function ue(e, t) {
  const o = ee(e);
  return (typeof t == "boolean" ? t : !o) ? A(e) : P(e), !0;
}
function V(e) {
  return typeof e.key == "string" ? e.key.toLowerCase() : "";
}
function Ce(e) {
  const t = V(e);
  return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "a";
}
function Te(e) {
  const t = V(e);
  return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "r";
}
function Le(e) {
  const t = V(e);
  return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "p";
}
function Re(e) {
  const t = V(e);
  return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "d";
}
function Me(e) {
  R = e, T || (T = (t) => {
    D();
    const o = t.target, a = o == null ? void 0 : o.closest(w);
    if (!a) return;
    g = a;
    const r = p.get(a) || e;
    p.set(a, r), f(a, r);
    const n = y.get(a);
    n && (B(n, a), U(a, n));
  }, document.addEventListener("focusin", T, !0)), L || (L = (t) => {
    if (t.defaultPrevented) return;
    const o = Ce(t), a = Te(t), r = Le(t), n = Re(t), l = t.key === "Escape";
    if (!l && !o && !a && !r && !n)
      return;
    D();
    const s = t.target, u = !!(s != null && s.closest(`.${d} input, .${d} textarea, .${d} select`));
    if (!we(s) && !ye())
      return;
    const i = x(void 0, !1);
    if (!i) return;
    const b = p.get(i) || R || e;
    p.set(i, b);
    const E = f(i, b);
    if (g = i, l && ee(i)) {
      t.preventDefault(), P(i, !0);
      return;
    }
    if (!u) {
      if (o) {
        t.preventDefault(), t.stopPropagation(), ue(i);
        return;
      }
      if (a) {
        t.preventDefault(), t.stopPropagation(), $(i, "review", b, b.defaultActor) && A(i);
        return;
      }
      if (r) {
        t.preventDefault(), t.stopPropagation(), Z(i, b, b.defaultActor, "Approved via keyboard shortcut.") && A(i);
        return;
      }
      n && (t.preventDefault(), t.stopPropagation(), E.status !== "draft" && $(i, "draft", b, b.defaultActor) && A(i));
    }
  }, document.addEventListener("keydown", L, !0)), S || (S = () => {
    D(), y.forEach((t, o) => {
      !o.isConnected || !t.isConnected || (B(t, o), U(o, t));
    });
  }, window.addEventListener("scroll", S, !0), window.addEventListener("resize", S));
}
function De(e) {
  var o, a;
  const t = I.get(e);
  t && (e.classList.remove("rte-approval-locked-editor"), e.removeAttribute("data-approval-status"), e.removeAttribute("data-approval-locked"), se(
    e,
    (o = t.preApprovalContentEditable) != null ? o : t.originalContentEditable,
    (a = t.preApprovalReadonly) != null ? a : t.originalReadonly
  ));
}
function He() {
  T && (document.removeEventListener("focusin", T, !0), T = null), L && (document.removeEventListener("keydown", L, !0), L = null), S && (window.removeEventListener("scroll", S, !0), window.removeEventListener("resize", S), S = null), y.forEach((e) => e.remove()), y.clear(), H.forEach((e) => De(e)), H.clear(), R = null, g = null;
}
function qe() {
  if (typeof document == "undefined" || document.getElementById(oe)) return;
  const e = document.createElement("style");
  e.id = oe, e.textContent = `
    .rte-toolbar-group-items.${h},
    .editora-toolbar-group-items.${h},
    .rte-toolbar-group-items.${k},
    .editora-toolbar-group-items.${k} {
      display: flex;
      border: 1px solid #ccc;
      border-radius: 3px;
      background: #fff;
    }

    .rte-toolbar-group-items.${h} .rte-toolbar-button,
    .editora-toolbar-group-items.${h} .editora-toolbar-button,
    .rte-toolbar-group-items.${k} .rte-toolbar-button,
    .editora-toolbar-group-items.${k} .editora-toolbar-button {
      border: none;
      border-radius: 0;
      border-right: 1px solid #ccc;
    }

    .rte-toolbar-button[data-command="toggleApprovalWorkflowPanel"].active,
    .editora-toolbar-button[data-command="toggleApprovalWorkflowPanel"].active,
    .rte-toolbar-button[data-command="reopenDraft"].active,
    .editora-toolbar-button[data-command="reopenDraft"].active {
      background-color: #ccc;
    }

    ${v} .rte-toolbar-button[data-command="toggleApprovalWorkflowPanel"].active,
    ${v} .editora-toolbar-button[data-command="toggleApprovalWorkflowPanel"].active,
    ${v} .rte-toolbar-button[data-command="reopenDraft"].active,
    ${v} .editora-toolbar-button[data-command="reopenDraft"].active {
      background: linear-gradient(180deg, #5eaaf6 0%, #4a95de 100%);
    }

    .rte-toolbar-group-items.${h} .rte-toolbar-item:last-child .rte-toolbar-button,
    .editora-toolbar-group-items.${h} .editora-toolbar-item:last-child .editora-toolbar-button,
    .rte-toolbar-group-items.${k} .rte-toolbar-item:last-child .rte-toolbar-button,
    .editora-toolbar-group-items.${k} .editora-toolbar-item:last-child .editora-toolbar-button {
      border-right: none;
    }

    ${v} .rte-toolbar-group-items.${h},
    ${v} .editora-toolbar-group-items.${h},
    ${v} .rte-toolbar-group-items.${k},
    ${v} .editora-toolbar-group-items.${k},
    .${d}.rte-approval-theme-dark {
      border-color: #566275;
    }
    ${v} .rte-toolbar-group-items.${h} .rte-toolbar-button svg,
    ${v} .editora-toolbar-group-items.${h} .editora-toolbar-button svg,
    ${v} .rte-toolbar-group-items.${k} .rte-toolbar-button svg,
    ${v} .editora-toolbar-group-items.${k} .editora-toolbar-button svg
    {
      fill: none;
    }

    ${v} .rte-toolbar-group-items.${h} .rte-toolbar-button,
    ${v} .editora-toolbar-group-items.${h} .editora-toolbar-button
    {
      border-color: #566275;
    }

    .rte-approval-locked-editor {
      background-image: repeating-linear-gradient(
        -45deg,
        rgba(30, 64, 175, 0.04),
        rgba(30, 64, 175, 0.04) 8px,
        rgba(30, 64, 175, 0.08) 8px,
        rgba(30, 64, 175, 0.08) 16px
      );
    }

    .${d} {
      position: fixed;
      z-index: 1500;
      right: 16px;
      top: 16px;
      width: min(420px, calc(100vw - 20px));
      max-height: calc(100vh - 24px);
      display: none;
      flex-direction: column;
      border-radius: 12px;
      border: 1px solid #d1d5db;
      background: #ffffff;
      color: #0f172a;
      box-shadow: 0 18px 38px rgba(15, 23, 42, 0.16);
      overflow: hidden;
    }

    .${d}.show {
      display: flex;
    }

    .${d}.rte-approval-theme-dark {
      background: #0f172a;
      color: #e2e8f0;
      border-color: #334155;
      box-shadow: 0 20px 40px rgba(2, 6, 23, 0.5);
    }

    .rte-approval-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 10px 12px;
      border-bottom: 1px solid #e2e8f0;
      background: #f8fafc;
    }

    .${d}.rte-approval-theme-dark .rte-approval-header {
      border-bottom-color: #334155;
      background: #111827;
    }

    .rte-approval-title {
      margin: 0;
      font-size: 14px;
      font-weight: 700;
    }

    .rte-approval-icon-btn {
      border: 1px solid #cbd5e1;
      background: #ffffff;
      color: #0f172a;
      border-radius: 6px;
      cursor: pointer;
      min-width: 34px;
      min-height: 34px;
      width: 34px;
      height: 34px;
      padding: 0;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 16px;
      line-height: 1;
      font-weight: 600;
    }

    .rte-approval-icon-btn:hover,
    .rte-approval-icon-btn:focus-visible {
      outline: none;
      border-color: #3b82f6;
      box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    }

    .${d}.rte-approval-theme-dark .rte-approval-icon-btn {
      background: #0f172a;
      border-color: #475569;
      color: #e2e8f0;
    }

    .${d}.rte-approval-theme-dark .rte-approval-icon-btn:hover,
    .${d}.rte-approval-theme-dark .rte-approval-icon-btn:focus-visible {
      border-color: #60a5fa;
      box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.24);
    }

    .rte-approval-body {
      display: flex;
      flex-direction: column;
      gap: 10px;
      padding: 12px;
      overflow: auto;
    }

    .rte-approval-summary {
      margin: 0;
      font-size: 12px;
      color: #475569;
    }

    .${d}.rte-approval-theme-dark .rte-approval-summary {
      color: #94a3b8;
    }

    .rte-approval-controls {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
    }

    .rte-approval-btn {
      border: 1px solid #cbd5e1;
      background: #f8fafc;
      color: inherit;
      border-radius: 8px;
      padding: 6px 10px;
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
    }

    .rte-approval-btn:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }

    .rte-approval-btn:hover:not(:disabled),
    .rte-approval-btn:focus-visible:not(:disabled) {
      outline: none;
      border-color: #1d4ed8;
      box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.2);
    }

    .rte-approval-btn-primary {
      background: #1d4ed8;
      border-color: #1d4ed8;
      color: #ffffff;
    }

    .rte-approval-btn-primary:hover:not(:disabled),
    .rte-approval-btn-primary:focus-visible:not(:disabled) {
      background: #1e40af;
      border-color: #1e40af;
    }

    .${d}.rte-approval-theme-dark .rte-approval-btn {
      border-color: #334155;
      background: #0b1220;
      color: #e2e8f0;
    }

    .${d}.rte-approval-theme-dark .rte-approval-btn-primary {
      border-color: #2563eb;
      background: #2563eb;
      color: #ffffff;
    }

    .rte-approval-form {
      display: grid;
      grid-template-columns: 1fr;
      gap: 8px;
      border: 1px solid #e2e8f0;
      border-radius: 10px;
      padding: 8px;
    }

    .${d}.rte-approval-theme-dark .rte-approval-form {
      border-color: #334155;
    }

    .rte-approval-label {
      display: flex;
      flex-direction: column;
      gap: 4px;
      font-size: 12px;
      font-weight: 600;
    }

    .rte-approval-field {
      width: 100%;
      box-sizing: border-box;
      min-height: 30px;
      border-radius: 8px;
      border: 1px solid #cbd5e1;
      background: #ffffff;
      color: inherit;
      font-size: 13px;
      padding: 6px 8px;
    }

    .rte-approval-field:focus-visible {
      outline: none;
      border-color: #1d4ed8;
      box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.2);
    }

    .${d}.rte-approval-theme-dark .rte-approval-field {
      border-color: #334155;
      background: #0b1220;
      color: #e2e8f0;
    }

    .rte-approval-section {
      border: 1px solid #e2e8f0;
      border-radius: 10px;
      padding: 8px;
    }

    .${d}.rte-approval-theme-dark .rte-approval-section {
      border-color: #334155;
    }

    .rte-approval-section-title {
      margin: 0 0 8px;
      font-size: 12px;
      font-weight: 700;
    }

    .rte-approval-comments-list,
    .rte-approval-signoffs-list {
      margin: 0;
      padding: 0;
      list-style: none;
      display: flex;
      flex-direction: column;
      gap: 6px;
      max-height: 150px;
      overflow: auto;
    }

    .rte-approval-item {
      border: 1px solid #dbeafe;
      background: #eff6ff;
      border-radius: 8px;
      padding: 6px;
    }

    .rte-approval-item-comment {
      border-color: #e2e8f0;
      background: #f8fafc;
    }

    .${d}.rte-approval-theme-dark .rte-approval-item {
      border-color: #334155;
      background: #111827;
    }

    .rte-approval-item-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      margin-bottom: 4px;
    }

    .rte-approval-item-author {
      font-size: 12px;
      font-weight: 700;
    }

    .rte-approval-item-time {
      font-size: 11px;
      color: #64748b;
    }

    .${d}.rte-approval-theme-dark .rte-approval-item-time {
      color: #94a3b8;
    }

    .rte-approval-item-message {
      margin: 0;
      font-size: 12px;
      line-height: 1.35;
      white-space: pre-wrap;
    }

    .rte-approval-empty {
      border: 1px dashed #cbd5e1;
      border-radius: 8px;
      padding: 8px;
      font-size: 12px;
      color: #64748b;
    }

    .${d}.rte-approval-theme-dark .rte-approval-empty {
      border-color: #334155;
      color: #94a3b8;
    }

    .rte-approval-shortcut {
      margin: 0;
      font-size: 11px;
      color: #64748b;
    }

    .${d}.rte-approval-theme-dark .rte-approval-shortcut {
      color: #94a3b8;
    }

    .rte-approval-live {
      position: absolute;
      width: 1px;
      height: 1px;
      margin: -1px;
      padding: 0;
      overflow: hidden;
      clip: rect(0 0 0 0);
      border: 0;
    }

    @media (max-width: 768px) {
      .${d} {
        left: 10px !important;
        right: 10px;
        top: 10px !important;
        width: auto !important;
        max-height: calc(100vh - 20px);
      }
    }
  `, document.head.appendChild(e);
}
const Pe = (e = {}) => {
  const t = z(e);
  return qe(), {
    name: "approvalWorkflow",
    toolbar: [
      {
        id: "approvalWorkflowGroup",
        label: "Approval",
        type: "group",
        command: "approvalWorkflow",
        items: [
          {
            id: "approvalWorkflow",
            label: "Approval Workflow",
            command: "toggleApprovalWorkflowPanel",
            shortcut: "Mod-Alt-Shift-a",
            icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4" y="5" width="16" height="14" rx="2.5" stroke="currentColor" stroke-width="1.7"/><path d="M8 10h8M8 14h5" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="m16.5 16 1.8 1.8 3.2-3.2" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>'
          },
          {
            id: "approvalRequestReview",
            label: "Request Review",
            command: "requestApprovalReview",
            shortcut: "Mod-Alt-Shift-r",
            icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><circle cx="11" cy="11" r="6.5" stroke="currentColor" stroke-width="1.7"/><path d="M11 8v3l2 2" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M17.5 17.5 20 20" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/></svg>'
          },
          {
            id: "approvalApprove",
            label: "Approve",
            command: "approveDocument",
            shortcut: "Mod-Alt-Shift-p",
            icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M5 12.5 9.5 17 19 7.5" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><rect x="3.8" y="3.8" width="16.4" height="16.4" rx="3" stroke="currentColor" stroke-width="1.4"/></svg>'
          },
          {
            id: "approvalReopen",
            label: "Reopen Draft",
            command: "reopenDraft",
            shortcut: "Mod-Alt-Shift-d",
            icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M8 8H4v4" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M5 12a7 7 0 1 0 2-4.95" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/></svg>'
          }
        ]
      }
    ],
    commands: {
      approvalWorkflow: (o, a) => {
        const r = x(a);
        if (!r) return !1;
        const n = p.get(r) || t;
        return p.set(r, n), f(r, n), g = r, A(r), q(r), !0;
      },
      toggleApprovalWorkflowPanel: (o, a) => {
        const r = x(a);
        if (!r) return !1;
        const n = p.get(r) || t;
        return p.set(r, n), f(r, n), g = r, ue(r, typeof o == "boolean" ? o : void 0);
      },
      requestApprovalReview: (o, a) => {
        const r = x(a);
        if (!r) return !1;
        const n = p.get(r) || t;
        p.set(r, n), f(r, n);
        const l = $(r, "review", n, n.defaultActor);
        return A(r), l;
      },
      approveDocument: (o, a) => {
        const r = x(a);
        if (!r) return !1;
        const n = p.get(r) || t;
        p.set(r, n), f(r, n);
        const l = typeof o == "object" && o ? String(o.author || "") : n.defaultActor, s = typeof o == "object" && o ? String(o.comment || "") : typeof o == "string" ? o : "", u = Z(r, n, l, s);
        return u && A(r), u;
      },
      reopenDraft: (o, a) => {
        const r = x(a);
        if (!r) return !1;
        const n = p.get(r) || t;
        p.set(r, n), f(r, n);
        const l = $(r, "draft", n, n.defaultActor);
        return l && A(r), l;
      },
      addApprovalComment: (o, a) => {
        const r = x(a);
        if (!r) return !1;
        const n = p.get(r) || t;
        p.set(r, n), f(r, n);
        const l = typeof o == "object" && o ? String(o.author || "") : n.defaultActor, s = typeof o == "object" && o ? String(o.message || "") : typeof o == "string" ? o : "", u = de(r, s, l, n);
        return u && A(r), u;
      },
      setApprovalStatus: (o, a) => {
        const r = x(a);
        if (!r || !o) return !1;
        const n = le(o), l = p.get(r) || t;
        p.set(r, l), f(r, l);
        const s = $(r, n, l, l.defaultActor);
        return s && A(r), s;
      },
      setApprovalWorkflowOptions: (o, a) => {
        const r = x(a);
        if (!r || !o || typeof o != "object") return !1;
        const n = p.get(r) || t, l = z({
          ...n,
          ...o,
          labels: {
            ...n.labels,
            ...o.labels || {}
          },
          normalizeText: o.normalizeText || n.normalizeText
        });
        p.set(r, l);
        const s = f(r, l);
        return G(r, s, l), !0;
      },
      getApprovalWorkflowState: (o, a) => {
        const r = x(a);
        if (!r) return !1;
        const n = p.get(r) || t;
        p.set(r, n);
        const l = f(r, n), s = pe(l);
        if (typeof o == "function")
          try {
            o(s);
          } catch (u) {
          }
        return r.__approvalWorkflowState = s, r.dispatchEvent(
          new CustomEvent("editora:approval-state", {
            bubbles: !0,
            detail: {
              state: s
            }
          })
        ), !0;
      }
    },
    keymap: {
      "Mod-Alt-Shift-a": "toggleApprovalWorkflowPanel",
      "Mod-Alt-Shift-A": "toggleApprovalWorkflowPanel",
      "Mod-Alt-Shift-r": "requestApprovalReview",
      "Mod-Alt-Shift-R": "requestApprovalReview",
      "Mod-Alt-Shift-p": "approveDocument",
      "Mod-Alt-Shift-P": "approveDocument",
      "Mod-Alt-Shift-d": "reopenDraft",
      "Mod-Alt-Shift-D": "reopenDraft"
    },
    init: function(a) {
      _ += 1;
      const r = this && typeof this.__pluginConfig == "object" ? z({ ...t, ...this.__pluginConfig }) : t;
      Me(r);
      const n = x(
        a != null && a.editorElement ? { editorElement: a.editorElement } : void 0,
        !1
      );
      n && (p.set(n, r), f(n, r), g = n, q(n));
    },
    destroy: () => {
      _ = Math.max(0, _ - 1), !(_ > 0) && He();
    }
  };
};
export {
  Pe as ApprovalWorkflowPlugin
};
//# sourceMappingURL=ApprovalWorkflowPlugin.native-BZ6jO-Wj.mjs.map
