let c = null;
const b = () => {
  c || (c = document.createElement("style"), c.textContent = `
    .rte-page-break {
      display: block;
      position: relative;
      height: 12px;
      margin: 8px 0;
      background: linear-gradient(90deg, #ccc 0%, transparent 100%);
      border-top: 2px dashed #999;
      border-bottom: none;
      cursor: pointer;
      user-select: none;
      transition: all 0.2s ease;
      outline: none;
      -webkit-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
    }

    .rte-page-break::before {
      content: '⎙ PAGE BREAK';
      position: absolute;
      top: -12px;
      left: 0;
      font-size: 10px;
      font-weight: bold;
      color: #666;
      background: white;
      padding: 2px 6px;
      letter-spacing: 0.5px;
      opacity: 0.7;
      pointer-events: none;
    }

    .rte-page-break:hover {
      background: linear-gradient(90deg, #999 0%, transparent 100%);
      border-top-color: #666;
      box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
    }

    .rte-page-break:hover::before {
      opacity: 1;
      color: #333;
    }

    .rte-page-break:focus,
    .rte-page-break:focus-visible,
    .rte-page-break-selected {
      outline: 2px solid #0066cc;
      outline-offset: -2px;
      border-top-color: #0066cc;
      background: linear-gradient(90deg, #0066cc 0%, transparent 100%);
    }

    .rte-page-break * {
      user-select: none;
    }

    @media print {
      .rte-page-break {
        display: block;
        height: 0;
        margin: 0;
        background: none;
        border: none;
        page-break-after: always;
      }

      .rte-page-break::before {
        display: none;
      }
    }
  `, document.head.appendChild(c));
}, u = (e) => {
  const i = ["SPAN", "A", "STRONG", "EM", "B", "I", "U", "SUP", "SUB", "CODE"];
  let n = e.nodeType === Node.TEXT_NODE ? e.parentElement : e;
  for (; n && !n.hasAttribute("contenteditable"); ) {
    if (i.includes(n.tagName))
      return !0;
    n = n.parentElement;
  }
  return !1;
}, m = (e) => {
  const i = ["DIV", "P", "BLOCKQUOTE", "PRE", "H1", "H2", "H3", "H4", "H5", "H6", "LI", "TD", "TH"];
  let n = e;
  for (; n; ) {
    if (n.nodeType === Node.ELEMENT_NODE) {
      const s = n;
      if (i.includes(s.tagName))
        return s;
    }
    n = n.parentNode;
  }
  return null;
}, k = (e) => {
  let i = e.nextElementSibling;
  for (; i && i.classList.contains("rte-page-break"); )
    i.remove(), i = e.nextElementSibling;
  let n = e.previousElementSibling;
  for (; n && n.classList.contains("rte-page-break"); ) {
    const s = n;
    n = n.previousElementSibling, s.remove();
  }
}, f = () => {
  var p, d;
  const e = window.getSelection();
  if (!e || e.rangeCount === 0) return !1;
  const n = e.getRangeAt(0).commonAncestorContainer;
  if (u(n))
    return console.warn("Page breaks cannot be inserted in inline contexts"), !1;
  const s = m(n);
  if (!s)
    return console.warn("No block element found for page break insertion"), !1;
  const t = document.createElement("div");
  t.className = "rte-page-break", t.setAttribute("data-page-break", "true"), t.setAttribute("data-type", "page-break"), t.setAttribute("contenteditable", "false"), t.setAttribute("tabindex", "0"), t.setAttribute("role", "separator"), t.setAttribute("aria-label", "Page break"), t.addEventListener("click", (r) => {
    r.preventDefault(), r.stopPropagation(), t.focus();
    const a = document.createRange();
    a.selectNode(t), e.removeAllRanges(), e.addRange(a);
  }), t.addEventListener("keydown", (r) => {
    if (r.key === "Delete" || r.key === "Backspace") {
      r.preventDefault();
      const a = t.nextElementSibling || t.previousElementSibling;
      if (t.remove(), a) {
        const o = document.createRange();
        o.selectNode(a), e.removeAllRanges(), e.addRange(o);
      }
    } else if (r.key === "ArrowDown" || r.key === "ArrowRight") {
      r.preventDefault();
      const a = t.nextElementSibling;
      if (a) {
        const o = document.createRange();
        o.setStart(a, 0), o.collapse(!0), e.removeAllRanges(), e.addRange(o);
      }
    } else if (r.key === "ArrowUp" || r.key === "ArrowLeft") {
      r.preventDefault();
      const a = t.previousElementSibling;
      if (a) {
        const o = document.createRange();
        o.selectNodeContents(a), o.collapse(!1), e.removeAllRanges(), e.addRange(o);
      }
    }
  }), (p = s.parentNode) == null || p.insertBefore(t, s.nextSibling), k(t);
  const l = document.createRange(), g = t.nextSibling;
  if (g)
    l.setStart(g, 0);
  else {
    const r = document.createElement("p");
    r.innerHTML = "<br>", (d = t.parentNode) == null || d.insertBefore(r, t.nextSibling), l.setStart(r, 0);
  }
  return l.collapse(!0), e.removeAllRanges(), e.addRange(l), !0;
}, C = () => (b(), {
  name: "pageBreak",
  toolbar: [
    {
      label: "Page Break",
      command: "insertPageBreak",
      icon: '<svg fill="#000000" width="24px" height="24px" viewBox="0 0 14 14" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"><path d="M1,6 L3,6 C3.55228475,6 4,6.44771525 4,7 C4,7.55228475 3.55228475,8 3,8 L1,8 C0.44771525,8 0,7.55228475 0,7 C0,6.44771525 0.44771525,6 1,6 Z M11,6 L13,6 C13.5522847,6 14,6.44771525 14,7 C14,7.55228475 13.5522847,8 13,8 L11,8 C10.4477153,8 10,7.55228475 10,7 C10,6.44771525 10.4477153,6 11,6 Z M6,6 L8,6 C8.55228475,6 9,6.44771525 9,7 C9,7.55228475 8.55228475,8 8,8 L6,8 C5.44771525,8 5,7.55228475 5,7 C5,6.44771525 5.44771525,6 6,6 Z M0,1 C0,0.44771525 0.44771525,-2.26485497e-13 1,-2.26485497e-13 C1.55228475,-2.26485497e-13 2,0.44771525 2,1 L2,3.0142458 L12,3.0142458 L12,1 C12,0.44771525 12.4477153,-2.26485497e-13 13,-2.26485497e-13 C13.5522847,-2.26485497e-13 14,0.44771525 14,1 L14,3.0142458 C14,4.1188153 13.1045695,5.0142458 12,5.0142458 L2,5.0142458 C0.8954305,5.0142458 0,4.1188153 0,3.0142458 L0,1 Z M0,13.0142458 L0,11 C0,9.8954305 0.8954305,9 2,9 L12,9 C13.1045695,9 14,9.8954305 14,11 L14,13.0142458 C14,13.5665305 13.5522847,14.0142458 13,14.0142458 C12.4477153,14.0142458 12,13.5665305 12,13.0142458 L12,11 L2,11 L2,13.0142458 C2,13.5665305 1.55228475,14.0142458 1,14.0142458 C0.44771525,14.0142458 0,13.5665305 0,13.0142458 Z"></path></g></svg>',
      shortcut: "Mod-Enter"
    }
  ],
  commands: {
    insertPageBreak: f
  },
  keymap: {
    "Mod-Enter": "insertPageBreak"
  }
});
export {
  C as PageBreakPlugin
};
//# sourceMappingURL=PageBreakPlugin.native-DDjcDyRW.mjs.map
