Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@editora/plugins

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@editora/plugins - npm Package Compare versions

Comparing version
1.0.12
to
1.0.13
+1
dist/inlineFormatting-DOYOJdnD.js
"use strict";const u="data-editora-selection-marker";function w(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function f(t){return t?t.getAttribute("contenteditable")==="true"?t:t.querySelector('[contenteditable="true"]'):null}function y(t){if(t?.contentElement instanceof HTMLElement)return t.contentElement;const e=f(t?.editorElement??null);if(e)return e;const n=typeof window<"u"?window.__editoraCommandEditorRoot:null,o=n instanceof HTMLElement?f(n):null;if(o)return o;const i=window.getSelection();if(i&&i.rangeCount>0){const l=w(i.getRangeAt(0).startContainer)?.closest('.rte-content, .editora-content, [contenteditable="true"]');if(l instanceof HTMLElement)return l}const r=document.activeElement;if(r instanceof HTMLElement){const c=r.closest('.rte-content, .editora-content, [contenteditable="true"]');if(c instanceof HTMLElement)return c}return document.querySelector('.rte-content, .editora-content, [contenteditable="true"]')}function p(t){const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const n=e.getRangeAt(0);return t.contains(n.startContainer)&&t.contains(n.endContainer)}function E(t){const e=document.createElement("span");return e.setAttribute(u,t),e.style.display="inline-block",e.style.width="0",e.style.height="0",e.style.overflow="hidden",e.style.lineHeight="0",e.appendChild(document.createTextNode("\uFEFF")),e}function R(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);if(!t.contains(n.startContainer)||!t.contains(n.endContainer))return null;const o=n.collapsed,i=E("start"),r=o?null:E("end"),c=n.cloneRange();if(r){const a=c.cloneRange();a.collapse(!1),a.insertNode(r)}const l=c.cloneRange();return l.collapse(!0),l.insertNode(i),()=>{const a=window.getSelection(),s=document.createRange(),d=t.querySelector(`[${u}="start"]`),m=t.querySelector(`[${u}="end"]`);if(!a||!d){t.querySelectorAll(`[${u}]`).forEach(g=>g.remove());return}o||!m?(s.setStartBefore(d),s.collapse(!0)):(s.setStartAfter(d),s.setEndBefore(m)),a.removeAllRanges(),a.addRange(s),d.remove(),m?.remove()}}function S(t,e,n){if(e!==n){if(typeof window.execEditorCommand=="function"){window.execEditorCommand("recordDomTransaction",t,e,n);return}if(typeof window.executeEditorCommand=="function")try{window.executeEditorCommand("recordDomTransaction",{editor:t,beforeHTML:e,afterHTML:n})}catch{}}}function b(t){const e=y(t.context);if(!e)return!1;const n=e.innerHTML;p(e)&&e.focus({preventScroll:!0});let o=!1;try{o=document.execCommand(t.command,!1)}catch{o=!1}const i=e.innerHTML;if(t.normalize&&i!==n){const c=R(e);t.normalize(e),c?.()}const r=e.innerHTML;return n!==r&&(S(e,n,r),e.dispatchEvent(new Event("input",{bubbles:!0}))),o!==!1||n!==r}exports.applyInlineFormatting=b;
const u = "data-editora-selection-marker";
function w(t) {
return t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null;
}
function m(t) {
return t ? t.getAttribute("contenteditable") === "true" ? t : t.querySelector('[contenteditable="true"]') : null;
}
function y(t) {
if (t?.contentElement instanceof HTMLElement) return t.contentElement;
const e = m(t?.editorElement ?? null);
if (e) return e;
const n = typeof window < "u" ? window.__editoraCommandEditorRoot : null, o = n instanceof HTMLElement ? m(n) : null;
if (o) return o;
const a = window.getSelection();
if (a && a.rangeCount > 0) {
const l = w(a.getRangeAt(0).startContainer)?.closest('.rte-content, .editora-content, [contenteditable="true"]');
if (l instanceof HTMLElement) return l;
}
const r = document.activeElement;
if (r instanceof HTMLElement) {
const c = r.closest('.rte-content, .editora-content, [contenteditable="true"]');
if (c instanceof HTMLElement) return c;
}
return document.querySelector('.rte-content, .editora-content, [contenteditable="true"]');
}
function R(t) {
const e = window.getSelection();
if (!e || e.rangeCount === 0) return !1;
const n = e.getRangeAt(0);
return t.contains(n.startContainer) && t.contains(n.endContainer);
}
function E(t) {
const e = document.createElement("span");
return e.setAttribute(u, t), e.style.display = "inline-block", e.style.width = "0", e.style.height = "0", e.style.overflow = "hidden", e.style.lineHeight = "0", e.appendChild(document.createTextNode("\uFEFF")), e;
}
function S(t) {
const e = window.getSelection();
if (!e || e.rangeCount === 0) return null;
const n = e.getRangeAt(0);
if (!t.contains(n.startContainer) || !t.contains(n.endContainer))
return null;
const o = n.collapsed, a = E("start"), r = o ? null : E("end"), c = n.cloneRange();
if (r) {
const i = c.cloneRange();
i.collapse(!1), i.insertNode(r);
}
const l = c.cloneRange();
return l.collapse(!0), l.insertNode(a), () => {
const i = window.getSelection(), s = document.createRange(), d = t.querySelector(
`[${u}="start"]`
), f = t.querySelector(
`[${u}="end"]`
);
if (!i || !d) {
t.querySelectorAll(`[${u}]`).forEach((g) => g.remove());
return;
}
o || !f ? (s.setStartBefore(d), s.collapse(!0)) : (s.setStartAfter(d), s.setEndBefore(f)), i.removeAllRanges(), i.addRange(s), d.remove(), f?.remove();
};
}
function b(t, e, n) {
if (e !== n) {
if (typeof window.execEditorCommand == "function") {
window.execEditorCommand("recordDomTransaction", t, e, n);
return;
}
if (typeof window.executeEditorCommand == "function")
try {
window.executeEditorCommand("recordDomTransaction", { editor: t, beforeHTML: e, afterHTML: n });
} catch {
}
}
}
function p(t) {
const e = y(t.context);
if (!e) return !1;
const n = e.innerHTML;
R(e) && e.focus({ preventScroll: !0 });
let o = !1;
try {
o = document.execCommand(t.command, !1);
} catch {
o = !1;
}
const a = e.innerHTML;
if (t.normalize && a !== n) {
const c = S(e);
t.normalize(e), c?.();
}
const r = e.innerHTML;
return n !== r && (b(e, n, r), e.dispatchEvent(new Event("input", { bubbles: !0 }))), o !== !1 || n !== r;
}
export {
p as a
};
+14
-14

@@ -1,2 +0,2 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const w=".rte-content, .editora-content",F="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",ee="__editoraCommandEditorRoot",te="rte-approval-workflow-styles",d="rte-approval-panel",h="approval",y="approvalWorkflow",g=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',ue={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."},fe={draft:"statusDraftText",review:"statusReviewText",approved:"statusApprovedText"},s=new WeakMap,I=new WeakMap,k=new Map,O=new WeakMap,H=new Set;let _=0,me=0,oe=0,re=0,R=null,v=null,T=null,L=null,S=null;function p(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function be(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function ne(e){return e==="review"||e==="approved"?e:"draft"}function z(e={}){return{defaultStatus:ne(e.defaultStatus),lockOnApproval:e.lockOnApproval!==!1,maxHistoryEntries:Math.max(10,Math.min(500,Number(e.maxHistoryEntries??120))),requireCommentOnApprove:!!e.requireCommentOnApprove,defaultActor:(e.defaultActor||"system").trim()||"system",labels:{...ue,...e.labels||{}},normalizeText:e.normalizeText||be}}function U(e){return e.closest(F)||e}function B(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>"u")return null;const e=window[ee];if(!(e instanceof HTMLElement))return null;window[ee]=null;const t=B(e);if(t)return t;const o=e.closest(F);if(o){const n=B(o);if(n)return n}return null}function ve(e){const t=e.closest("[data-editora-editor]");if(t&&B(t)===e)return t;let o=e;for(;o;){if(o.matches(F)&&(o===e||B(o)===e))return o;o=o.parentElement}return U(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 he(e){const t=U(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 K(e,t){e.classList.remove("rte-approval-theme-dark"),he(t)&&e.classList.add("rte-approval-theme-dark")}function le(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function x(e,t=!0){if(D(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const a=e.editorElement;if(a.matches(w))return a;const l=a.querySelector(w);if(l instanceof HTMLElement)return l}const o=ge();if(o)return o;const n=window.getSelection();if(n&&n.rangeCount>0){const l=le(n.getRangeAt(0).startContainer)?.closest(w);if(l)return l}const r=document.activeElement;if(r){if(r.matches(w))return r;const a=r.closest(w);if(a)return a}return v&&v.isConnected?v:(v&&!v.isConnected&&(v=null),t?document.querySelector(w):null)}function D(){Array.from(H).forEach(t=>{t.isConnected||(k.get(t)?.remove(),k.delete(t),O.delete(t),s.delete(t),I.delete(t),H.delete(t),v===t&&(v=null))})}function xe(e){return e?!!(e.closest(`.${d}`)||e.closest(w)||e.closest(F)):!1}function we(){const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const t=e.getRangeAt(0).startContainer;return!!le(t)?.closest(w)}function C(e,t,o){const n=ve(e);Array.from(n.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(a=>{a.classList.toggle("active",o),a.setAttribute("aria-pressed",o?"true":"false"),a.setAttribute("data-active",o?"true":"false")})}function ie(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 Y(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function X(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{}}function J(){return oe+=1,`approval-comment-${Date.now().toString(36)}-${oe.toString(36)}`}function ke(){return re+=1,`approval-signoff-${Date.now().toString(36)}-${re.toString(36)}`}function se(e){return{status:e.status,locked:e.locked,comments:e.comments.map(t=>({...t})),signoffs:e.signoffs.map(t=>({...t})),updatedAt:e.updatedAt}}function ye(e,t){const o=fe[e];return t.labels[o]||e}function ce(e,t,o){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",Z(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,ie(e,t.preApprovalContentEditable??t.originalContentEditable,t.preApprovalReadonly??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: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 Ae(e,t){const o=se(t);e.__approvalWorkflowState=o,e.dispatchEvent(new CustomEvent("editora:approval-state-changed",{bubbles:!0,detail:{state:o}}))}function P(e){const t=k.get(e);if(!t)return;const o=s.get(e)||R;if(!o)return;const n=f(e,o),r=t.querySelector(".rte-approval-summary"),a=t.querySelector('[data-action="request-review"]'),l=t.querySelector('[data-action="approve"]'),c=t.querySelector('[data-action="reopen-draft"]'),u=t.querySelector(".rte-approval-comments-list"),m=t.querySelector(".rte-approval-signoffs-list");if(r){const i=ye(n.status,o);r.textContent=`${o.labels.summaryPrefix}: ${i} | Comments: ${n.comments.length} | Sign-offs: ${n.signoffs.length}${n.locked?` | ${o.labels.lockedSuffix}`:""}`}a&&(a.disabled=n.status!=="draft"),l&&(l.disabled=n.status==="approved"),c&&(c.disabled=n.status==="draft"),u&&(n.comments.length===0?u.innerHTML=`<li class="rte-approval-empty">${p(o.labels.noCommentsText)}</li>`:u.innerHTML=n.comments.slice().reverse().map(i=>`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});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",g=':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"},s=new WeakMap,I=new WeakMap,y=new Map,O=new WeakMap,H=new Set;let _=0,be=0,re=0,ae=0,R=null,v=null,T=null,L=null,S=null;function p(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ge(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function le(e){return e==="review"||e==="approved"?e:"draft"}function z(e={}){return{defaultStatus:le(e.defaultStatus),lockOnApproval:e.lockOnApproval!==!1,maxHistoryEntries:Math.max(10,Math.min(500,Number(e.maxHistoryEntries??120))),requireCommentOnApprove:!!e.requireCommentOnApprove,defaultActor:(e.defaultActor||"system").trim()||"system",labels:{...fe,...e.labels||{}},normalizeText:e.normalizeText||ge}}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 ve(){if(typeof window>"u")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 n=K(o);if(n)return n}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?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const a=e.editorElement;if(a.matches(w))return a;const l=a.querySelector(w);if(l instanceof HTMLElement)return l}const o=ve();if(o)return o;const n=window.getSelection();if(n&&n.rangeCount>0){const l=ie(n.getRangeAt(0).startContainer)?.closest(w);if(l)return l}const r=document.activeElement;if(r){if(r.matches(w))return r;const a=r.closest(w);if(a)return a}return v&&v.isConnected?v:(v&&!v.isConnected&&(v=null),t?document.querySelector(w):null)}function D(){Array.from(H).forEach(t=>{t.isConnected||(y.get(t)?.remove(),y.delete(t),O.delete(t),s.delete(t),I.delete(t),H.delete(t),v===t&&(v=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;return!!ie(t)?.closest(w)}function C(e,t,o){const n=he(e);Array.from(n.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(a=>{a.classList.toggle("active",o),a.setAttribute("aria-pressed",o?"true":"false"),a.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{}}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 ce(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 pe(e,t,o){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,t.preApprovalContentEditable??t.originalContentEditable,t.preApprovalReadonly??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:new Date().toISOString(),originalContentEditable:e.getAttribute("contenteditable"),originalReadonly:e.getAttribute("data-readonly"),preApprovalContentEditable:null,preApprovalReadonly:null},I.set(e,o),H.add(e),pe(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=ce(t);e.__approvalWorkflowState=o,e.dispatchEvent(new CustomEvent("editora:approval-state-changed",{bubbles:!0,detail:{state:o}}))}function P(e){const t=y.get(e);if(!t)return;const o=s.get(e)||R;if(!o)return;const n=f(e,o),r=t.querySelector(".rte-approval-summary"),a=t.querySelector('[data-action="request-review"]'),l=t.querySelector('[data-action="approve"]'),c=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(n.status,o);r.textContent=`${o.labels.summaryPrefix}: ${i} | Comments: ${n.comments.length} | Sign-offs: ${n.signoffs.length}${n.locked?` | ${o.labels.lockedSuffix}`:""}`}a&&(a.disabled=n.status!=="draft"),l&&(l.disabled=n.status==="approved"),c&&(c.disabled=n.status==="draft"),u&&(n.comments.length===0?u.innerHTML=`<li class="rte-approval-empty">${p(o.labels.noCommentsText)}</li>`:u.innerHTML=n.comments.slice().reverse().map(i=>`
<li class="rte-approval-item rte-approval-item-${i.kind}" role="listitem">

@@ -17,3 +17,3 @@ <div class="rte-approval-item-head">

</li>
`).join(""))}function G(e,t,o){t.updatedAt=new Date().toISOString(),ce(e,t,o),P(e),Ae(e,t)}function ae(e,t,o,n){e.comments.push({id:J(),author:o||t.defaultActor,message:n,kind:"system",createdAt:new Date().toISOString()}),e.comments=j(e.comments,t.maxHistoryEntries)}function E(e,t,o,n){const r=f(e,o);if(r.status===t)return!1;const a=e.innerHTML;return r.status=t,t==="review"?ae(r,o,n,"Review requested."):t==="draft"&&ae(r,o,n,"Returned to draft."),G(e,r,o),Y(e),X(e,a),!0}function pe(e,t,o,n){const r=n.normalizeText(t);if(!r)return!1;const a=n.normalizeText(o)||n.defaultActor,l=f(e,n),c=e.innerHTML;return l.comments.push({id:J(),author:a,message:r,kind:"comment",createdAt:new Date().toISOString()}),l.comments=j(l.comments,n.maxHistoryEntries),G(e,l,n),Y(e),X(e,c),!0}function Q(e,t,o,n){const r=t.normalizeText(o)||t.defaultActor,a=t.normalizeText(n);if(t.requireCommentOnApprove&&!a)return!1;const l=f(e,t),c=e.innerHTML;return l.status="approved",l.signoffs.push({id:ke(),author:r,comment:a||void 0,createdAt:new Date().toISOString()}),l.signoffs=j(l.signoffs,t.maxHistoryEntries),a&&(l.comments.push({id:J(),author:r,message:a,kind:"system",createdAt:new Date().toISOString()}),l.comments=j(l.comments,t.maxHistoryEntries)),G(e,l,t),Y(e),X(e,c),!0}function N(e,t){return e.querySelector(`[data-field="${t}"]`)}function Se(e){const t=N(e,"actor")?.value||"",o=N(e,"comment")?.value||"";return{actor:t,comment:o}}function V(e,t){if(!t.classList.contains("show"))return;const n=U(e).getBoundingClientRect(),r=Math.min(window.innerWidth-20,420),a=Math.max(10,window.innerWidth-r-10),l=Math.min(Math.max(10,n.right-r),a),c=Math.max(10,Math.min(window.innerHeight-10-280,n.top+12));t.style.width=`${r}px`,t.style.left=`${l}px`,t.style.top=`${c}px`,t.style.maxHeight=`${Math.max(280,window.innerHeight-24)}px`}function $e(e){const t=k.get(e);if(t)return t;const o=s.get(e)||R||z(),n=`rte-approval-panel-${me++}`,r=document.createElement("section");return r.className=d,r.id=n,r.setAttribute("role","dialog"),r.setAttribute("aria-modal","false"),r.setAttribute("aria-label",o.labels.panelAriaLabel),r.setAttribute("tabindex","-1"),r.innerHTML=`
`).join(""))}function G(e,t,o){t.updatedAt=new Date().toISOString(),pe(e,t,o),P(e),Se(e,t)}function ne(e,t,o,n){e.comments.push({id:Q(),author:o||t.defaultActor,message:n,kind:"system",createdAt:new Date().toISOString()}),e.comments=j(e.comments,t.maxHistoryEntries)}function $(e,t,o,n){const r=f(e,o);if(r.status===t)return!1;const a=e.innerHTML;return r.status=t,t==="review"?ne(r,o,n,"Review requested."):t==="draft"&&ne(r,o,n,"Returned to draft."),G(e,r,o),X(e),J(e,a),!0}function de(e,t,o,n){const r=n.normalizeText(t);if(!r)return!1;const a=n.normalizeText(o)||n.defaultActor,l=f(e,n),c=e.innerHTML;return l.comments.push({id:Q(),author:a,message:r,kind:"comment",createdAt:new Date().toISOString()}),l.comments=j(l.comments,n.maxHistoryEntries),G(e,l,n),X(e),J(e,c),!0}function Z(e,t,o,n){const r=t.normalizeText(o)||t.defaultActor,a=t.normalizeText(n);if(t.requireCommentOnApprove&&!a)return!1;const l=f(e,t),c=e.innerHTML;return l.status="approved",l.signoffs.push({id:ke(),author:r,comment:a||void 0,createdAt:new Date().toISOString()}),l.signoffs=j(l.signoffs,t.maxHistoryEntries),a&&(l.comments.push({id:Q(),author:r,message:a,kind:"system",createdAt:new Date().toISOString()}),l.comments=j(l.comments,t.maxHistoryEntries)),G(e,l,t),X(e),J(e,c),!0}function N(e,t){return e.querySelector(`[data-field="${t}"]`)}function Ee(e){const t=N(e,"actor")?.value||"",o=N(e,"comment")?.value||"";return{actor:t,comment:o}}function U(e,t){if(!t.classList.contains("show"))return;const n=Y(e).getBoundingClientRect(),r=Math.min(window.innerWidth-20,420),a=Math.max(10,window.innerWidth-r-10),l=Math.min(Math.max(10,n.right-r),a),c=Math.max(10,Math.min(window.innerHeight-10-280,n.top+12));t.style.width=`${r}px`,t.style.left=`${l}px`,t.style.top=`${c}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=s.get(e)||R||z(),n=`rte-approval-panel-${be++}`,r=document.createElement("section");return r.className=d,r.id=n,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">

@@ -57,7 +57,7 @@ <h2 class="rte-approval-title">${p(o.labels.panelTitle)}</h2>

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

@@ -71,4 +71,4 @@ border: 1px solid #ccc;

.editora-toolbar-group-items.${h} .editora-toolbar-button,
.rte-toolbar-group-items.${y} .rte-toolbar-button,
.editora-toolbar-group-items.${y} .editora-toolbar-button {
.rte-toolbar-group-items.${k} .rte-toolbar-button,
.editora-toolbar-group-items.${k} .editora-toolbar-button {
border: none;

@@ -95,4 +95,4 @@ border-radius: 0;

.editora-toolbar-group-items.${h} .editora-toolbar-item:last-child .editora-toolbar-button,
.rte-toolbar-group-items.${y} .rte-toolbar-item:last-child .rte-toolbar-button,
.editora-toolbar-group-items.${y} .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;

@@ -103,4 +103,4 @@ }

${g} .editora-toolbar-group-items.${h},
${g} .rte-toolbar-group-items.${y},
${g} .editora-toolbar-group-items.${y},
${g} .rte-toolbar-group-items.${k},
${g} .editora-toolbar-group-items.${k},
.${d}.rte-approval-theme-dark {

@@ -111,4 +111,4 @@ border-color: #566275;

${g} .editora-toolbar-group-items.${h} .editora-toolbar-button svg,
${g} .rte-toolbar-group-items.${y} .rte-toolbar-button svg,
${g} .editora-toolbar-group-items.${y} .editora-toolbar-button svg
${g} .rte-toolbar-group-items.${k} .rte-toolbar-button svg,
${g} .editora-toolbar-group-items.${k} .editora-toolbar-button svg
{

@@ -453,2 +453,2 @@ fill: none;

}
`,document.head.appendChild(e)}const Pe=(e={})=>{const t=z(e);return He(),{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,n)=>{const r=x(n);if(!r)return!1;const a=s.get(r)||t;return s.set(r,a),f(r,a),v=r,A(r),P(r),!0},toggleApprovalWorkflowPanel:(o,n)=>{const r=x(n);if(!r)return!1;const a=s.get(r)||t;return s.set(r,a),f(r,a),v=r,de(r,typeof o=="boolean"?o:void 0)},requestApprovalReview:(o,n)=>{const r=x(n);if(!r)return!1;const a=s.get(r)||t;s.set(r,a),f(r,a);const l=E(r,"review",a,a.defaultActor);return A(r),l},approveDocument:(o,n)=>{const r=x(n);if(!r)return!1;const a=s.get(r)||t;s.set(r,a),f(r,a);const l=typeof o=="object"&&o?String(o.author||""):a.defaultActor,c=typeof o=="object"&&o?String(o.comment||""):typeof o=="string"?o:"",u=Q(r,a,l,c);return u&&A(r),u},reopenDraft:(o,n)=>{const r=x(n);if(!r)return!1;const a=s.get(r)||t;s.set(r,a),f(r,a);const l=E(r,"draft",a,a.defaultActor);return l&&A(r),l},addApprovalComment:(o,n)=>{const r=x(n);if(!r)return!1;const a=s.get(r)||t;s.set(r,a),f(r,a);const l=typeof o=="object"&&o?String(o.author||""):a.defaultActor,c=typeof o=="object"&&o?String(o.message||""):typeof o=="string"?o:"",u=pe(r,c,l,a);return u&&A(r),u},setApprovalStatus:(o,n)=>{const r=x(n);if(!r||!o)return!1;const a=ne(o),l=s.get(r)||t;s.set(r,l),f(r,l);const c=E(r,a,l,l.defaultActor);return c&&A(r),c},setApprovalWorkflowOptions:(o,n)=>{const r=x(n);if(!r||!o||typeof o!="object")return!1;const a=s.get(r)||t,l=z({...a,...o,labels:{...a.labels,...o.labels||{}},normalizeText:o.normalizeText||a.normalizeText});s.set(r,l);const c=f(r,l);return G(r,c,l),!0},getApprovalWorkflowState:(o,n)=>{const r=x(n);if(!r)return!1;const a=s.get(r)||t;s.set(r,a);const l=f(r,a),c=se(l);if(typeof o=="function")try{o(c)}catch{}return r.__approvalWorkflowState=c,r.dispatchEvent(new CustomEvent("editora:approval-state",{bubbles:!0,detail:{state:c}})),!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(n){_+=1;const r=this&&typeof this.__pluginConfig=="object"?z({...t,...this.__pluginConfig}):t;Re(r);const a=x(n?.editorElement?{editorElement:n.editorElement}:void 0,!1);a&&(s.set(a,r),f(a,r),v=a,P(a))},destroy:()=>{_=Math.max(0,_-1),!(_>0)&&De()}}};exports.ApprovalWorkflowPlugin=Pe;
`,document.head.appendChild(e)}const qe=(e={})=>{const t=z(e);return Pe(),{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,n)=>{const r=x(n);if(!r)return!1;const a=s.get(r)||t;return s.set(r,a),f(r,a),v=r,A(r),P(r),!0},toggleApprovalWorkflowPanel:(o,n)=>{const r=x(n);if(!r)return!1;const a=s.get(r)||t;return s.set(r,a),f(r,a),v=r,ue(r,typeof o=="boolean"?o:void 0)},requestApprovalReview:(o,n)=>{const r=x(n);if(!r)return!1;const a=s.get(r)||t;s.set(r,a),f(r,a);const l=$(r,"review",a,a.defaultActor);return A(r),l},approveDocument:(o,n)=>{const r=x(n);if(!r)return!1;const a=s.get(r)||t;s.set(r,a),f(r,a);const l=typeof o=="object"&&o?String(o.author||""):a.defaultActor,c=typeof o=="object"&&o?String(o.comment||""):typeof o=="string"?o:"",u=Z(r,a,l,c);return u&&A(r),u},reopenDraft:(o,n)=>{const r=x(n);if(!r)return!1;const a=s.get(r)||t;s.set(r,a),f(r,a);const l=$(r,"draft",a,a.defaultActor);return l&&A(r),l},addApprovalComment:(o,n)=>{const r=x(n);if(!r)return!1;const a=s.get(r)||t;s.set(r,a),f(r,a);const l=typeof o=="object"&&o?String(o.author||""):a.defaultActor,c=typeof o=="object"&&o?String(o.message||""):typeof o=="string"?o:"",u=de(r,c,l,a);return u&&A(r),u},setApprovalStatus:(o,n)=>{const r=x(n);if(!r||!o)return!1;const a=le(o),l=s.get(r)||t;s.set(r,l),f(r,l);const c=$(r,a,l,l.defaultActor);return c&&A(r),c},setApprovalWorkflowOptions:(o,n)=>{const r=x(n);if(!r||!o||typeof o!="object")return!1;const a=s.get(r)||t,l=z({...a,...o,labels:{...a.labels,...o.labels||{}},normalizeText:o.normalizeText||a.normalizeText});s.set(r,l);const c=f(r,l);return G(r,c,l),!0},getApprovalWorkflowState:(o,n)=>{const r=x(n);if(!r)return!1;const a=s.get(r)||t;s.set(r,a);const l=f(r,a),c=ce(l);if(typeof o=="function")try{o(c)}catch{}return r.__approvalWorkflowState=c,r.dispatchEvent(new CustomEvent("editora:approval-state",{bubbles:!0,detail:{state:c}})),!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(n){_+=1;const r=this&&typeof this.__pluginConfig=="object"?z({...t,...this.__pluginConfig}):t;Me(r);const a=x(n?.editorElement?{editorElement:n.editorElement}:void 0,!1);a&&(s.set(a,r),f(a,r),v=a,P(a))},destroy:()=>{_=Math.max(0,_-1),!(_>0)&&He()}}};exports.ApprovalWorkflowPlugin=qe;

@@ -1,2 +0,2 @@

const w = ".rte-content, .editora-content", F = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", ee = "__editoraCommandEditorRoot", te = "rte-approval-workflow-styles", d = "rte-approval-panel", h = "approval", y = "approvalWorkflow", g = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', ue = {
const w = ".rte-content, .editora-content", F = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", et = "__editoraCommandEditorRoot", ot = "rte-approval-workflow-styles", d = "rte-approval-panel", h = "approval", k = "approvalWorkflow", g = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', ft = {
panelTitle: "Approval Workflow",

@@ -25,50 +25,50 @@ panelAriaLabel: "Approval workflow panel",

approveCommentRequiredText: "Approval comment is required."
}, fe = {
}, mt = {
draft: "statusDraftText",
review: "statusReviewText",
approved: "statusApprovedText"
}, s = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), k = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new Set();
let _ = 0, me = 0, oe = 0, re = 0, R = null, v = null, T = null, L = null, S = null;
function p(e) {
return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
}, s = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new Set();
let _ = 0, bt = 0, rt = 0, at = 0, R = null, v = null, T = null, L = null, S = null;
function p(t) {
return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
}
function be(e) {
return e.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
function gt(t) {
return t.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
}
function ne(e) {
return e === "review" || e === "approved" ? e : "draft";
function lt(t) {
return t === "review" || t === "approved" ? t : "draft";
}
function z(e = {}) {
function z(t = {}) {
return {
defaultStatus: ne(e.defaultStatus),
lockOnApproval: e.lockOnApproval !== !1,
maxHistoryEntries: Math.max(10, Math.min(500, Number(e.maxHistoryEntries ?? 120))),
requireCommentOnApprove: !!e.requireCommentOnApprove,
defaultActor: (e.defaultActor || "system").trim() || "system",
defaultStatus: lt(t.defaultStatus),
lockOnApproval: t.lockOnApproval !== !1,
maxHistoryEntries: Math.max(10, Math.min(500, Number(t.maxHistoryEntries ?? 120))),
requireCommentOnApprove: !!t.requireCommentOnApprove,
defaultActor: (t.defaultActor || "system").trim() || "system",
labels: {
...ue,
...e.labels || {}
...ft,
...t.labels || {}
},
normalizeText: e.normalizeText || be
normalizeText: t.normalizeText || gt
};
}
function U(e) {
return e.closest(F) || e;
function Y(t) {
return t.closest(F) || t;
}
function B(e) {
if (!e) return null;
if (e.matches(w)) return e;
const t = e.querySelector(w);
return t instanceof HTMLElement ? t : null;
function K(t) {
if (!t) return null;
if (t.matches(w)) return t;
const e = t.querySelector(w);
return e instanceof HTMLElement ? e : null;
}
function ge() {
function vt() {
if (typeof window > "u") return null;
const e = window[ee];
if (!(e instanceof HTMLElement)) return null;
window[ee] = null;
const t = B(e);
if (t) return t;
const o = e.closest(F);
const t = window[et];
if (!(t instanceof HTMLElement)) return null;
window[et] = null;
const e = K(t);
if (e) return e;
const o = t.closest(F);
if (o) {
const n = B(o);
const n = K(o);
if (n) return n;

@@ -78,33 +78,33 @@ }

}
function ve(e) {
const t = e.closest("[data-editora-editor]");
if (t && B(t) === e)
return t;
let o = e;
function ht(t) {
const e = t.closest("[data-editora-editor]");
if (e && K(e) === t)
return e;
let o = t;
for (; o; ) {
if (o.matches(F) && (o === e || B(o) === e))
if (o.matches(F) && (o === t || K(o) === t))
return o;
o = o.parentElement;
}
return U(e);
return Y(t);
}
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 W(t) {
return t ? (t.getAttribute("data-theme") || t.getAttribute("theme") || "").toLowerCase() === "dark" ? !0 : t.classList.contains("dark") || t.classList.contains("editora-theme-dark") || t.classList.contains("rte-theme-dark") : !1;
}
function he(e) {
const t = U(e);
if (W(t)) return !0;
const o = t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
function xt(t) {
const e = Y(t);
if (W(e)) return !0;
const o = e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
return W(o) ? !0 : W(document.documentElement) || W(document.body);
}
function K(e, t) {
e.classList.remove("rte-approval-theme-dark"), he(t) && e.classList.add("rte-approval-theme-dark");
function B(t, e) {
t.classList.remove("rte-approval-theme-dark"), xt(e) && t.classList.add("rte-approval-theme-dark");
}
function le(e) {
return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
function it(t) {
return t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null;
}
function x(e, t = !0) {
if (D(), e?.contentElement instanceof HTMLElement) return e.contentElement;
if (e?.editorElement instanceof HTMLElement) {
const a = e.editorElement;
function x(t, e = !0) {
if (D(), t?.contentElement instanceof HTMLElement) return t.contentElement;
if (t?.editorElement instanceof HTMLElement) {
const a = t.editorElement;
if (a.matches(w)) return a;

@@ -114,7 +114,7 @@ const l = a.querySelector(w);

}
const o = ge();
const o = vt();
if (o) return o;
const n = window.getSelection();
if (n && n.rangeCount > 0) {
const l = le(n.getRangeAt(0).startContainer)?.closest(w);
const l = it(n.getRangeAt(0).startContainer)?.closest(w);
if (l) return l;

@@ -128,23 +128,23 @@ }

}
return v && v.isConnected ? v : (v && !v.isConnected && (v = null), t ? document.querySelector(w) : null);
return v && v.isConnected ? v : (v && !v.isConnected && (v = null), e ? document.querySelector(w) : null);
}
function D() {
Array.from(H).forEach((t) => {
t.isConnected || (k.get(t)?.remove(), k.delete(t), O.delete(t), s.delete(t), I.delete(t), H.delete(t), v === t && (v = null));
Array.from(H).forEach((e) => {
e.isConnected || (y.get(e)?.remove(), y.delete(e), O.delete(e), s.delete(e), I.delete(e), H.delete(e), v === e && (v = null));
});
}
function xe(e) {
return e ? !!(e.closest(`.${d}`) || e.closest(w) || e.closest(F)) : !1;
function wt(t) {
return t ? !!(t.closest(`.${d}`) || t.closest(w) || t.closest(F)) : !1;
}
function we() {
const e = window.getSelection();
if (!e || e.rangeCount === 0) return !1;
const t = e.getRangeAt(0).startContainer;
return !!le(t)?.closest(w);
function yt() {
const t = window.getSelection();
if (!t || t.rangeCount === 0) return !1;
const e = t.getRangeAt(0).startContainer;
return !!it(e)?.closest(w);
}
function C(e, t, o) {
const n = ve(e);
function C(t, e, o) {
const n = ht(t);
Array.from(
n.querySelectorAll(
`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`
`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`
)

@@ -155,51 +155,51 @@ ).forEach((a) => {

}
function ie(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 st(t, e, o) {
e !== null ? t.setAttribute("contenteditable", e) : t.setAttribute("contenteditable", "true"), o !== null ? t.setAttribute("data-readonly", o) : t.removeAttribute("data-readonly");
}
function Y(e) {
e.dispatchEvent(new Event("input", { bubbles: !0 }));
function X(t) {
t.dispatchEvent(new Event("input", { bubbles: !0 }));
}
function X(e, t) {
if (t === e.innerHTML) return;
function J(t, e) {
if (e === t.innerHTML) return;
const o = window.execEditorCommand || window.executeEditorCommand;
if (typeof o == "function")
try {
o("recordDomTransaction", e, t, e.innerHTML);
o("recordDomTransaction", t, e, t.innerHTML);
} catch {
}
}
function J() {
return oe += 1, `approval-comment-${Date.now().toString(36)}-${oe.toString(36)}`;
function Q() {
return rt += 1, `approval-comment-${Date.now().toString(36)}-${rt.toString(36)}`;
}
function ke() {
return re += 1, `approval-signoff-${Date.now().toString(36)}-${re.toString(36)}`;
function kt() {
return at += 1, `approval-signoff-${Date.now().toString(36)}-${at.toString(36)}`;
}
function se(e) {
function ct(t) {
return {
status: e.status,
locked: e.locked,
comments: e.comments.map((t) => ({ ...t })),
signoffs: e.signoffs.map((t) => ({ ...t })),
updatedAt: e.updatedAt
status: t.status,
locked: t.locked,
comments: t.comments.map((e) => ({ ...e })),
signoffs: t.signoffs.map((e) => ({ ...e })),
updatedAt: t.updatedAt
};
}
function ye(e, t) {
const o = fe[e];
return t.labels[o] || e;
function At(t, e) {
const o = mt[t];
return e.labels[o] || t;
}
function ce(e, t, o) {
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", Z(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;
function pt(t, e, o) {
if (t.setAttribute("data-approval-status", e.status), t.setAttribute("data-approval-locked", e.locked ? "true" : "false"), t.classList.toggle("rte-approval-locked-editor", e.locked), C(t, "toggleApprovalWorkflowPanel", tt(t)), C(t, "requestApprovalReview", e.status === "review"), C(t, "approveDocument", e.status === "approved"), C(t, "reopenDraft", e.status === "draft"), e.status === "approved" && o.lockOnApproval) {
e.locked || (e.preApprovalContentEditable = t.getAttribute("contenteditable"), e.preApprovalReadonly = t.getAttribute("data-readonly")), t.setAttribute("contenteditable", "false"), t.setAttribute("data-readonly", "true"), e.locked = !0;
return;
}
t.locked = !1, ie(
e,
t.preApprovalContentEditable ?? t.originalContentEditable,
t.preApprovalReadonly ?? t.originalReadonly
), t.preApprovalContentEditable = null, t.preApprovalReadonly = null;
e.locked = !1, st(
t,
e.preApprovalContentEditable ?? e.originalContentEditable,
e.preApprovalReadonly ?? e.originalReadonly
), e.preApprovalContentEditable = null, e.preApprovalReadonly = null;
}
function f(e, t) {
let o = I.get(e);
function f(t, e) {
let o = I.get(t);
return o || (o = {
status: t.defaultStatus,
status: e.defaultStatus,
locked: !1,

@@ -209,18 +209,18 @@ comments: [],

updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
originalContentEditable: e.getAttribute("contenteditable"),
originalReadonly: e.getAttribute("data-readonly"),
originalContentEditable: t.getAttribute("contenteditable"),
originalReadonly: t.getAttribute("data-readonly"),
preApprovalContentEditable: null,
preApprovalReadonly: null
}, I.set(e, o), H.add(e), ce(e, o, t), o);
}, I.set(t, o), H.add(t), pt(t, o, e), o);
}
function j(e, t) {
return e.length <= t ? e : e.slice(e.length - t);
function j(t, e) {
return t.length <= e ? t : t.slice(t.length - e);
}
function M(e, t) {
const o = e.querySelector(".rte-approval-live");
o && (o.textContent = t);
function M(t, e) {
const o = t.querySelector(".rte-approval-live");
o && (o.textContent = e);
}
function Ae(e, t) {
const o = se(t);
e.__approvalWorkflowState = o, e.dispatchEvent(
function St(t, e) {
const o = ct(e);
t.__approvalWorkflowState = o, t.dispatchEvent(
new CustomEvent("editora:approval-state-changed", {

@@ -234,10 +234,10 @@ bubbles: !0,

}
function q(e) {
const t = k.get(e);
if (!t) return;
const o = s.get(e) || R;
function q(t) {
const e = y.get(t);
if (!e) return;
const o = s.get(t) || R;
if (!o) return;
const n = f(e, o), r = t.querySelector(".rte-approval-summary"), a = t.querySelector('[data-action="request-review"]'), l = t.querySelector('[data-action="approve"]'), c = t.querySelector('[data-action="reopen-draft"]'), u = t.querySelector(".rte-approval-comments-list"), m = t.querySelector(".rte-approval-signoffs-list");
const n = f(t, o), r = e.querySelector(".rte-approval-summary"), a = e.querySelector('[data-action="request-review"]'), l = e.querySelector('[data-action="approve"]'), c = e.querySelector('[data-action="reopen-draft"]'), u = e.querySelector(".rte-approval-comments-list"), m = e.querySelector(".rte-approval-signoffs-list");
if (r) {
const i = ye(n.status, o);
const i = At(n.status, o);
r.textContent = `${o.labels.summaryPrefix}: ${i} | Comments: ${n.comments.length} | Sign-offs: ${n.signoffs.length}${n.locked ? ` | ${o.labels.lockedSuffix}` : ""}`;

@@ -271,26 +271,26 @@ }

}
function G(e, t, o) {
t.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), ce(e, t, o), q(e), Ae(e, t);
function G(t, e, o) {
e.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), pt(t, e, o), q(t), St(t, e);
}
function ae(e, t, o, n) {
e.comments.push({
id: J(),
author: o || t.defaultActor,
function nt(t, e, o, n) {
t.comments.push({
id: Q(),
author: o || e.defaultActor,
message: n,
kind: "system",
createdAt: (/* @__PURE__ */ new Date()).toISOString()
}), e.comments = j(e.comments, t.maxHistoryEntries);
}), t.comments = j(t.comments, e.maxHistoryEntries);
}
function E(e, t, o, n) {
const r = f(e, o);
if (r.status === t) return !1;
const a = e.innerHTML;
return r.status = t, t === "review" ? ae(r, o, n, "Review requested.") : t === "draft" && ae(r, o, n, "Returned to draft."), G(e, r, o), Y(e), X(e, a), !0;
function $(t, e, o, n) {
const r = f(t, o);
if (r.status === e) return !1;
const a = t.innerHTML;
return r.status = e, e === "review" ? nt(r, o, n, "Review requested.") : e === "draft" && nt(r, o, n, "Returned to draft."), G(t, r, o), X(t), J(t, a), !0;
}
function pe(e, t, o, n) {
const r = n.normalizeText(t);
function dt(t, e, o, n) {
const r = n.normalizeText(e);
if (!r) return !1;
const a = n.normalizeText(o) || n.defaultActor, l = f(e, n), c = e.innerHTML;
const a = n.normalizeText(o) || n.defaultActor, l = f(t, n), c = t.innerHTML;
return l.comments.push({
id: J(),
id: Q(),
author: a,

@@ -300,15 +300,15 @@ message: r,

createdAt: (/* @__PURE__ */ new Date()).toISOString()
}), l.comments = j(l.comments, n.maxHistoryEntries), G(e, l, n), Y(e), X(e, c), !0;
}), l.comments = j(l.comments, n.maxHistoryEntries), G(t, l, n), X(t), J(t, c), !0;
}
function Q(e, t, o, n) {
const r = t.normalizeText(o) || t.defaultActor, a = t.normalizeText(n);
if (t.requireCommentOnApprove && !a) return !1;
const l = f(e, t), c = e.innerHTML;
function Z(t, e, o, n) {
const r = e.normalizeText(o) || e.defaultActor, a = e.normalizeText(n);
if (e.requireCommentOnApprove && !a) return !1;
const l = f(t, e), c = t.innerHTML;
return l.status = "approved", l.signoffs.push({
id: ke(),
id: kt(),
author: r,
comment: a || void 0,
createdAt: (/* @__PURE__ */ new Date()).toISOString()
}), l.signoffs = j(l.signoffs, t.maxHistoryEntries), a && (l.comments.push({
id: J(),
}), l.signoffs = j(l.signoffs, e.maxHistoryEntries), a && (l.comments.push({
id: Q(),
author: r,

@@ -318,20 +318,20 @@ message: a,

createdAt: (/* @__PURE__ */ new Date()).toISOString()
}), l.comments = j(l.comments, t.maxHistoryEntries)), G(e, l, t), Y(e), X(e, c), !0;
}), l.comments = j(l.comments, e.maxHistoryEntries)), G(t, l, e), X(t), J(t, c), !0;
}
function N(e, t) {
return e.querySelector(`[data-field="${t}"]`);
function N(t, e) {
return t.querySelector(`[data-field="${e}"]`);
}
function Se(e) {
const t = N(e, "actor")?.value || "", o = N(e, "comment")?.value || "";
return { actor: t, comment: o };
function Et(t) {
const e = N(t, "actor")?.value || "", o = N(t, "comment")?.value || "";
return { actor: e, comment: o };
}
function V(e, t) {
if (!t.classList.contains("show")) return;
const n = U(e).getBoundingClientRect(), r = Math.min(window.innerWidth - 20, 420), a = Math.max(10, window.innerWidth - r - 10), l = Math.min(Math.max(10, n.right - r), a), c = Math.max(10, Math.min(window.innerHeight - 10 - 280, n.top + 12));
t.style.width = `${r}px`, t.style.left = `${l}px`, t.style.top = `${c}px`, t.style.maxHeight = `${Math.max(280, window.innerHeight - 24)}px`;
function U(t, e) {
if (!e.classList.contains("show")) return;
const n = Y(t).getBoundingClientRect(), r = Math.min(window.innerWidth - 20, 420), a = Math.max(10, window.innerWidth - r - 10), l = Math.min(Math.max(10, n.right - r), a), c = Math.max(10, Math.min(window.innerHeight - 10 - 280, n.top + 12));
e.style.width = `${r}px`, e.style.left = `${l}px`, e.style.top = `${c}px`, e.style.maxHeight = `${Math.max(280, window.innerHeight - 24)}px`;
}
function $e(e) {
const t = k.get(e);
if (t) return t;
const o = s.get(e) || R || z(), n = `rte-approval-panel-${me++}`, r = document.createElement("section");
function $t(t) {
const e = y.get(t);
if (e) return e;
const o = s.get(t) || R || z(), n = `rte-approval-panel-${bt++}`, r = document.createElement("section");
return r.className = d, r.id = n, r.setAttribute("role", "dialog"), r.setAttribute("aria-modal", "false"), r.setAttribute("aria-label", o.labels.panelAriaLabel), r.setAttribute("tabindex", "-1"), r.innerHTML = `

@@ -395,18 +395,18 @@ <header class="rte-approval-header">

if (!c) return;
const u = c.getAttribute("data-action") || "", m = s.get(e) || R || o;
if (s.set(e, m), f(e, m), u === "close") {
P(e, !0);
const u = c.getAttribute("data-action") || "", m = s.get(t) || R || o;
if (s.set(t, m), f(t, m), u === "close") {
P(t, !0);
return;
}
const i = Se(r);
const i = Et(r);
if (u === "request-review") {
E(e, "review", m, i.actor || m.defaultActor) && M(r, "Status changed to review.");
$(t, "review", m, i.actor || m.defaultActor) && M(r, "Status changed to review.");
return;
}
if (u === "reopen-draft") {
E(e, "draft", m, i.actor || m.defaultActor) && M(r, "Status changed to draft.");
$(t, "draft", m, i.actor || m.defaultActor) && M(r, "Status changed to draft.");
return;
}
if (u === "approve") {
const b = Q(e, m, i.actor, i.comment);
const b = Z(t, m, i.actor, i.comment);
if (!b && m.requireCommentOnApprove) {

@@ -417,4 +417,4 @@ M(r, m.labels.approveCommentRequiredText);

if (b) {
const $ = N(r, "comment");
$ && ($.value = ""), M(r, "Document approved and signed off.");
const E = N(r, "comment");
E && (E.value = ""), M(r, "Document approved and signed off.");
}

@@ -424,71 +424,74 @@ return;

if (u === "add-comment") {
if (!pe(e, i.comment, i.actor, m)) return;
const $ = N(r, "comment");
$ && ($.value = ""), M(r, "Comment added.");
if (!dt(t, i.comment, i.actor, m)) return;
const E = N(r, "comment");
E && (E.value = ""), M(r, "Comment added.");
return;
}
}), r.addEventListener("keydown", (a) => {
a.key === "Escape" && (a.preventDefault(), P(e, !0));
}), K(r, e), document.body.appendChild(r), k.set(e, r), O.set(e, !1), q(e), r;
a.key === "Escape" && (a.preventDefault(), P(t, !0));
}), B(r, t), document.body.appendChild(r), y.set(t, r), O.set(t, !1), q(t), r;
}
function Z(e) {
return O.get(e) === !0;
function tt(t) {
return O.get(t) === !0;
}
function A(e) {
function A(t) {
D();
const t = $e(e);
k.forEach((o, n) => {
n !== e && P(n, !1);
}), t.classList.add("show"), O.set(e, !0), C(e, "toggleApprovalWorkflowPanel", !0), K(t, e), V(e, t), q(e);
const e = $t(t);
y.forEach((o, n) => {
n !== t && P(n, !1);
}), e.classList.add("show"), O.set(t, !0), C(t, "toggleApprovalWorkflowPanel", !0), B(e, t), U(t, e), q(t);
}
function P(e, t = !1) {
const o = k.get(e);
o && (o.classList.remove("show"), O.set(e, !1), C(e, "toggleApprovalWorkflowPanel", !1), t && e.focus({ preventScroll: !0 }));
function P(t, e = !1) {
const o = y.get(t);
o && (o.classList.remove("show"), O.set(t, !1), C(t, "toggleApprovalWorkflowPanel", !1), e && t.focus({ preventScroll: !0 }));
}
function de(e, t) {
const o = Z(e);
return (typeof t == "boolean" ? t : !o) ? A(e) : P(e), !0;
function ut(t, e) {
const o = tt(t);
return (typeof e == "boolean" ? e : !o) ? A(t) : P(t), !0;
}
function Ee(e) {
const t = e.key.toLowerCase();
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "a";
function V(t) {
return typeof t.key == "string" ? t.key.toLowerCase() : "";
}
function Ce(e) {
const t = e.key.toLowerCase();
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "r";
function Ct(t) {
const e = V(t);
return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "a";
}
function Te(e) {
const t = e.key.toLowerCase();
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "p";
function Tt(t) {
const e = V(t);
return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "r";
}
function Le(e) {
const t = e.key.toLowerCase();
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "d";
function Lt(t) {
const e = V(t);
return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "p";
}
function Re(e) {
R = e, T || (T = (t) => {
function Rt(t) {
const e = V(t);
return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "d";
}
function Mt(t) {
R = t, T || (T = (e) => {
D();
const n = t.target?.closest(w);
const n = e.target?.closest(w);
if (!n) return;
v = n;
const r = s.get(n) || e;
const r = s.get(n) || t;
s.set(n, r), f(n, r);
const a = k.get(n);
a && (K(a, n), V(n, a));
}, document.addEventListener("focusin", T, !0)), L || (L = (t) => {
if (t.defaultPrevented) return;
const o = Ee(t), n = Ce(t), r = Te(t), a = Le(t), l = t.key === "Escape";
const a = y.get(n);
a && (B(a, n), U(n, a));
}, document.addEventListener("focusin", T, !0)), L || (L = (e) => {
if (e.defaultPrevented) return;
const o = Ct(e), n = Tt(e), r = Lt(e), a = Rt(e), l = e.key === "Escape";
if (!l && !o && !n && !r && !a)
return;
D();
const c = t.target, u = !!c?.closest(`.${d} input, .${d} textarea, .${d} select`);
if (!xe(c) && !we())
const c = e.target, u = !!c?.closest(`.${d} input, .${d} textarea, .${d} select`);
if (!wt(c) && !yt())
return;
const i = x(void 0, !1);
if (!i) return;
const b = s.get(i) || R || e;
const b = s.get(i) || R || t;
s.set(i, b);
const $ = f(i, b);
if (v = i, l && Z(i)) {
t.preventDefault(), P(i, !0);
const E = f(i, b);
if (v = i, l && tt(i)) {
e.preventDefault(), P(i, !0);
return;

@@ -498,40 +501,40 @@ }

if (o) {
t.preventDefault(), t.stopPropagation(), de(i);
e.preventDefault(), e.stopPropagation(), ut(i);
return;
}
if (n) {
t.preventDefault(), t.stopPropagation(), E(i, "review", b, b.defaultActor) && A(i);
e.preventDefault(), e.stopPropagation(), $(i, "review", b, b.defaultActor) && A(i);
return;
}
if (r) {
t.preventDefault(), t.stopPropagation(), Q(i, b, b.defaultActor, "Approved via keyboard shortcut.") && A(i);
e.preventDefault(), e.stopPropagation(), Z(i, b, b.defaultActor, "Approved via keyboard shortcut.") && A(i);
return;
}
a && (t.preventDefault(), t.stopPropagation(), $.status !== "draft" && E(i, "draft", b, b.defaultActor) && A(i));
a && (e.preventDefault(), e.stopPropagation(), E.status !== "draft" && $(i, "draft", b, b.defaultActor) && A(i));
}
}, document.addEventListener("keydown", L, !0)), S || (S = () => {
D(), k.forEach((t, o) => {
!o.isConnected || !t.isConnected || (K(t, o), V(o, t));
D(), y.forEach((e, o) => {
!o.isConnected || !e.isConnected || (B(e, o), U(o, e));
});
}, window.addEventListener("scroll", S, !0), window.addEventListener("resize", S));
}
function Me(e) {
const t = I.get(e);
t && (e.classList.remove("rte-approval-locked-editor"), e.removeAttribute("data-approval-status"), e.removeAttribute("data-approval-locked"), ie(
e,
t.preApprovalContentEditable ?? t.originalContentEditable,
t.preApprovalReadonly ?? t.originalReadonly
function Dt(t) {
const e = I.get(t);
e && (t.classList.remove("rte-approval-locked-editor"), t.removeAttribute("data-approval-status"), t.removeAttribute("data-approval-locked"), st(
t,
e.preApprovalContentEditable ?? e.originalContentEditable,
e.preApprovalReadonly ?? e.originalReadonly
));
}
function De() {
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), k.forEach((e) => e.remove()), k.clear(), H.forEach((e) => Me(e)), H.clear(), R = null, v = null;
function Ht() {
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((t) => t.remove()), y.clear(), H.forEach((t) => Dt(t)), H.clear(), R = null, v = null;
}
function He() {
if (typeof document > "u" || document.getElementById(te)) return;
const e = document.createElement("style");
e.id = te, e.textContent = `
function qt() {
if (typeof document > "u" || document.getElementById(ot)) return;
const t = document.createElement("style");
t.id = ot, t.textContent = `
.rte-toolbar-group-items.${h},
.editora-toolbar-group-items.${h},
.rte-toolbar-group-items.${y},
.editora-toolbar-group-items.${y} {
.rte-toolbar-group-items.${k},
.editora-toolbar-group-items.${k} {
display: flex;

@@ -545,4 +548,4 @@ border: 1px solid #ccc;

.editora-toolbar-group-items.${h} .editora-toolbar-button,
.rte-toolbar-group-items.${y} .rte-toolbar-button,
.editora-toolbar-group-items.${y} .editora-toolbar-button {
.rte-toolbar-group-items.${k} .rte-toolbar-button,
.editora-toolbar-group-items.${k} .editora-toolbar-button {
border: none;

@@ -569,4 +572,4 @@ border-radius: 0;

.editora-toolbar-group-items.${h} .editora-toolbar-item:last-child .editora-toolbar-button,
.rte-toolbar-group-items.${y} .rte-toolbar-item:last-child .rte-toolbar-button,
.editora-toolbar-group-items.${y} .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;

@@ -577,4 +580,4 @@ }

${g} .editora-toolbar-group-items.${h},
${g} .rte-toolbar-group-items.${y},
${g} .editora-toolbar-group-items.${y},
${g} .rte-toolbar-group-items.${k},
${g} .editora-toolbar-group-items.${k},
.${d}.rte-approval-theme-dark {

@@ -585,4 +588,4 @@ border-color: #566275;

${g} .editora-toolbar-group-items.${h} .editora-toolbar-button svg,
${g} .rte-toolbar-group-items.${y} .rte-toolbar-button svg,
${g} .editora-toolbar-group-items.${y} .editora-toolbar-button svg
${g} .rte-toolbar-group-items.${k} .rte-toolbar-button svg,
${g} .editora-toolbar-group-items.${k} .editora-toolbar-button svg
{

@@ -927,7 +930,7 @@ fill: none;

}
`, document.head.appendChild(e);
`, document.head.appendChild(t);
}
const qe = (e = {}) => {
const t = z(e);
return He(), {
const Pt = (t = {}) => {
const e = z(t);
return qt(), {
name: "approvalWorkflow",

@@ -976,3 +979,3 @@ toolbar: [

if (!r) return !1;
const a = s.get(r) || t;
const a = s.get(r) || e;
return s.set(r, a), f(r, a), v = r, A(r), q(r), !0;

@@ -983,4 +986,4 @@ },

if (!r) return !1;
const a = s.get(r) || t;
return s.set(r, a), f(r, a), v = r, de(r, typeof o == "boolean" ? o : void 0);
const a = s.get(r) || e;
return s.set(r, a), f(r, a), v = r, ut(r, typeof o == "boolean" ? o : void 0);
},

@@ -990,5 +993,5 @@ requestApprovalReview: (o, n) => {

if (!r) return !1;
const a = s.get(r) || t;
const a = s.get(r) || e;
s.set(r, a), f(r, a);
const l = E(r, "review", a, a.defaultActor);
const l = $(r, "review", a, a.defaultActor);
return A(r), l;

@@ -999,5 +1002,5 @@ },

if (!r) return !1;
const a = s.get(r) || t;
const a = s.get(r) || e;
s.set(r, a), f(r, a);
const l = typeof o == "object" && o ? String(o.author || "") : a.defaultActor, c = typeof o == "object" && o ? String(o.comment || "") : typeof o == "string" ? o : "", u = Q(r, a, l, c);
const l = typeof o == "object" && o ? String(o.author || "") : a.defaultActor, c = typeof o == "object" && o ? String(o.comment || "") : typeof o == "string" ? o : "", u = Z(r, a, l, c);
return u && A(r), u;

@@ -1008,5 +1011,5 @@ },

if (!r) return !1;
const a = s.get(r) || t;
const a = s.get(r) || e;
s.set(r, a), f(r, a);
const l = E(r, "draft", a, a.defaultActor);
const l = $(r, "draft", a, a.defaultActor);
return l && A(r), l;

@@ -1017,5 +1020,5 @@ },

if (!r) return !1;
const a = s.get(r) || t;
const a = s.get(r) || e;
s.set(r, a), f(r, a);
const l = typeof o == "object" && o ? String(o.author || "") : a.defaultActor, c = typeof o == "object" && o ? String(o.message || "") : typeof o == "string" ? o : "", u = pe(r, c, l, a);
const l = typeof o == "object" && o ? String(o.author || "") : a.defaultActor, c = typeof o == "object" && o ? String(o.message || "") : typeof o == "string" ? o : "", u = dt(r, c, l, a);
return u && A(r), u;

@@ -1026,5 +1029,5 @@ },

if (!r || !o) return !1;
const a = ne(o), l = s.get(r) || t;
const a = lt(o), l = s.get(r) || e;
s.set(r, l), f(r, l);
const c = E(r, a, l, l.defaultActor);
const c = $(r, a, l, l.defaultActor);
return c && A(r), c;

@@ -1035,3 +1038,3 @@ },

if (!r || !o || typeof o != "object") return !1;
const a = s.get(r) || t, l = z({
const a = s.get(r) || e, l = z({
...a,

@@ -1052,5 +1055,5 @@ ...o,

if (!r) return !1;
const a = s.get(r) || t;
const a = s.get(r) || e;
s.set(r, a);
const l = f(r, a), c = se(l);
const l = f(r, a), c = ct(l);
if (typeof o == "function")

@@ -1083,4 +1086,4 @@ try {

_ += 1;
const r = this && typeof this.__pluginConfig == "object" ? z({ ...t, ...this.__pluginConfig }) : t;
Re(r);
const r = this && typeof this.__pluginConfig == "object" ? z({ ...e, ...this.__pluginConfig }) : e;
Mt(r);
const a = x(

@@ -1093,3 +1096,3 @@ n?.editorElement ? { editorElement: n.editorElement } : void 0,

destroy: () => {
_ = Math.max(0, _ - 1), !(_ > 0) && De();
_ = Math.max(0, _ - 1), !(_ > 0) && Ht();
}

@@ -1099,3 +1102,3 @@ };

export {
qe as ApprovalWorkflowPlugin
Pt as ApprovalWorkflowPlugin
};

@@ -1,1 +0,1 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=()=>({name:"blockquote",nodes:{blockquote:{content:"block+",group:"block",parseDOM:[{tag:"blockquote"}],toDOM:()=>["blockquote",0]}},toolbar:[{label:"Quote",command:"toggleBlockquote",icon:'<svg fill="#000000" height="24px" width="24px" version="1.1" id="Icons" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" xml:space="preserve"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <g> <path d="M13,11c0.6,0,1-0.4,1-1s-0.4-1-1-1c-5,0-9,4-9,9c0,2.8,2.2,5,5,5s5-2.2,5-5s-2.2-5-5-5c-0.3,0-0.7,0-1,0.1 C9.3,11.8,11,11,13,11z"></path> <path d="M23,13c-0.3,0-0.7,0-1,0.1c1.3-1.3,3-2.1,5-2.1c0.6,0,1-0.4,1-1s-0.4-1-1-1c-5,0-9,4-9,9c0,2.8,2.2,5,5,5s5-2.2,5-5 S25.8,13,23,13z"></path> </g> </g></svg>',shortcut:"Mod-Shift-9"}],commands:{toggleBlockquote:()=>{const o=window.getSelection();if(!o||o.rangeCount===0)return!1;let e=o.anchorNode,t=!1;for(;e&&e!==document.body;){if(e.nodeName==="BLOCKQUOTE"){t=!0;break}e=e.parentNode}return t?document.execCommand("formatBlock",!1,"p"):document.execCommand("formatBlock",!1,"blockquote"),!0}},keymap:{"Mod-Shift-9":"toggleBlockquote"}});exports.BlockquotePlugin=l;
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d='.rte-content, .editora-content, [contenteditable="true"]',L="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",T=["p","div","h1","h2","h3","h4","h5","h6","ul","ol","blockquote","pre","table"].join(",");function E(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function w(e){const t=e?.contentElement;if(t instanceof HTMLElement)return t;const n=e?.editorElement;if(n instanceof HTMLElement){const c=n.querySelector(d);if(c instanceof HTMLElement)return c;if(n.getAttribute("contenteditable")==="true")return n}const o=window.getSelection();if(o&&o.rangeCount>0){const c=E(o.getRangeAt(0).startContainer),i=c?.closest(d);if(i instanceof HTMLElement)return i;const f=c?.closest(L)?.querySelector(d);if(f instanceof HTMLElement)return f}const s=document.activeElement?.closest(d);return s instanceof HTMLElement?s:document.querySelector(d)}function B(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return!e.contains(n.startContainer)||!e.contains(n.endContainer)?null:n}function C(e,t){let n=E(t);if(!n||n===e||!e.contains(n))return null;for(;n.parentElement&&n.parentElement!==e;)n=n.parentElement;if(n.parentElement!==e)return null;if(n.matches(T))return n;const o=n.closest(T);return o instanceof HTMLElement&&o.parentElement===e?o:n}function N(e,t){if(typeof e.intersectsNode=="function")try{return e.intersectsNode(t)}catch{return!1}const n=document.createRange();return n.selectNode(t),e.compareBoundaryPoints(Range.END_TO_START,n)<0&&e.compareBoundaryPoints(Range.START_TO_END,n)>0}function b(e,t){const n=C(e,t.startContainer),o=C(e,t.endContainer);if(!n)return[];if(!o||n===o)return[n];const s=Array.from(e.children).filter(c=>c instanceof HTMLElement).filter(c=>N(t,c));return s.length>0?s:[n]}function k(e,t){const o=E(t)?.closest("blockquote");return o instanceof HTMLQuoteElement&&e.contains(o)?o:null}function v(e){return e.tagName!=="P"||e.attributes.length>0||(e.textContent||"").trim()!==""?!1:!e.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function M(e){Array.from(e.children).forEach(t=>{v(t)&&t.remove()})}function p(e){M(e);const t=e.parentNode;if(!t)return;Array.from(e.childNodes).forEach(o=>{t.insertBefore(o,e)}),t.removeChild(e)}function y(e){return e.nodeType===Node.TEXT_NODE&&(e.textContent||"").trim()===""}function S(e){const t=Array.from(e.childNodes).filter(o=>!y(o));if(t.length!==1)return null;const n=t[0];return n instanceof HTMLQuoteElement?n:null}function R(e){const t=document.createElement("blockquote");return Array.from(e.childNodes).filter(o=>!y(o)).forEach(o=>{t.appendChild(o)}),t.childNodes.length||(t.innerHTML="<br>"),e.appendChild(t),t}function q(e,t){const n=Array.from(e.querySelectorAll("li")).filter(r=>r instanceof HTMLLIElement&&N(t,r)),o=new Set(n);return n.filter(r=>{let s=r.parentElement?.closest("li");for(;s;){if(o.has(s))return!1;s=s.parentElement?.closest("li")}return!0})}function m(e){const t=window.getSelection();if(!t)return;const n=document.createRange(),o=e instanceof HTMLElement&&e.querySelector("p,li,h1,h2,h3,h4,h5,h6")||e;n.selectNodeContents(o),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}function O(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function x(e,t,n){const o=window.execEditorCommand;if(typeof o=="function"){o("recordDomTransaction",e,t,n);return}const r=window.executeEditorCommand;typeof r=="function"&&r("recordDomTransaction",{editor:e,beforeHTML:t,afterHTML:n})}function A(e){const t=w(e);if(!t)return!1;const n=B(t);if(!n)return!1;const o=t.innerHTML,r=k(t,n.startContainer),s=k(t,n.endContainer),c=q(t,n),i=b(t,n),h=i.length>0&&i.every(l=>l.tagName==="BLOCKQUOTE");if(r&&r===s){const l=r.firstChild||r;p(r),m(l)}else if(c.length>0){const l=c.map(S);if(l.every(Boolean)){const u=l[0]?.firstChild||c[0];l.forEach(a=>{a&&p(a)}),m(u)}else{const u=c[0];c.forEach(a=>{S(a)||R(a)}),m(u)}}else if(h){const l=i[0].firstChild||i[0];i.forEach(p),m(l)}else{const l=i.filter(a=>a.tagName!=="BLOCKQUOTE");if(l.length===0)return!1;const g=document.createElement("blockquote"),u=l[0];u.parentNode?.insertBefore(g,u),l.forEach(a=>{g.appendChild(a)}),m(g)}const f=t.innerHTML;return o===f?!1:(x(t,o,f),O(t),!0)}const _=()=>({name:"blockquote",nodes:{blockquote:{content:"block+",group:"block",parseDOM:[{tag:"blockquote"}],toDOM:()=>["blockquote",0]}},toolbar:[{label:"Quote",command:"toggleBlockquote",icon:'<svg fill="#000000" height="24px" width="24px" version="1.1" id="Icons" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" xml:space="preserve"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <g> <path d="M13,11c0.6,0,1-0.4,1-1s-0.4-1-1-1c-5,0-9,4-9,9c0,2.8,2.2,5,5,5s5-2.2,5-5s-2.2-5-5-5c-0.3,0-0.7,0-1,0.1 C9.3,11.8,11,11,13,11z"></path> <path d="M23,13c-0.3,0-0.7,0-1,0.1c1.3-1.3,3-2.1,5-2.1c0.6,0,1-0.4,1-1s-0.4-1-1-1c-5,0-9,4-9,9c0,2.8,2.2,5,5,5s5-2.2,5-5 S25.8,13,23,13z"></path> </g> </g></svg>',shortcut:"Mod-Shift-9"}],commands:{toggleBlockquote:(e,t)=>A(t)},keymap:{"Mod-Shift-9":"toggleBlockquote"}});exports.BlockquotePlugin=_;

@@ -1,2 +0,176 @@

const c = () => ({
const d = '.rte-content, .editora-content, [contenteditable="true"]', w = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", T = [
"p",
"div",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"ul",
"ol",
"blockquote",
"pre",
"table"
].join(",");
function E(e) {
return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
}
function y(e) {
const t = e?.contentElement;
if (t instanceof HTMLElement) return t;
const n = e?.editorElement;
if (n instanceof HTMLElement) {
const c = n.querySelector(d);
if (c instanceof HTMLElement) return c;
if (n.getAttribute("contenteditable") === "true") return n;
}
const o = window.getSelection();
if (o && o.rangeCount > 0) {
const c = E(o.getRangeAt(0).startContainer), i = c?.closest(d);
if (i instanceof HTMLElement) return i;
const f = c?.closest(w)?.querySelector(d);
if (f instanceof HTMLElement) return f;
}
const s = document.activeElement?.closest(d);
return s instanceof HTMLElement ? s : document.querySelector(d);
}
function B(e) {
const t = window.getSelection();
if (!t || t.rangeCount === 0) return null;
const n = t.getRangeAt(0);
return !e.contains(n.startContainer) || !e.contains(n.endContainer) ? null : n;
}
function C(e, t) {
let n = E(t);
if (!n || n === e || !e.contains(n)) return null;
for (; n.parentElement && n.parentElement !== e; )
n = n.parentElement;
if (n.parentElement !== e) return null;
if (n.matches(T)) return n;
const o = n.closest(T);
return o instanceof HTMLElement && o.parentElement === e ? o : n;
}
function S(e, t) {
if (typeof e.intersectsNode == "function")
try {
return e.intersectsNode(t);
} catch {
return !1;
}
const n = document.createRange();
return n.selectNode(t), e.compareBoundaryPoints(Range.END_TO_START, n) < 0 && e.compareBoundaryPoints(Range.START_TO_END, n) > 0;
}
function b(e, t) {
const n = C(e, t.startContainer), o = C(e, t.endContainer);
if (!n) return [];
if (!o || n === o) return [n];
const s = Array.from(e.children).filter(
(c) => c instanceof HTMLElement
).filter((c) => S(t, c));
return s.length > 0 ? s : [n];
}
function k(e, t) {
const o = E(t)?.closest("blockquote");
return o instanceof HTMLQuoteElement && e.contains(o) ? o : null;
}
function v(e) {
return e.tagName !== "P" || e.attributes.length > 0 || (e.textContent || "").trim() !== "" ? !1 : !e.querySelector("img, video, table, iframe, hr, pre, ul, ol");
}
function R(e) {
Array.from(e.children).forEach((t) => {
v(t) && t.remove();
});
}
function p(e) {
R(e);
const t = e.parentNode;
if (!t) return;
Array.from(e.childNodes).forEach((o) => {
t.insertBefore(o, e);
}), t.removeChild(e);
}
function L(e) {
return e.nodeType === Node.TEXT_NODE && (e.textContent || "").trim() === "";
}
function N(e) {
const t = Array.from(e.childNodes).filter((o) => !L(o));
if (t.length !== 1) return null;
const n = t[0];
return n instanceof HTMLQuoteElement ? n : null;
}
function M(e) {
const t = document.createElement("blockquote");
return Array.from(e.childNodes).filter((o) => !L(o)).forEach((o) => {
t.appendChild(o);
}), t.childNodes.length || (t.innerHTML = "<br>"), e.appendChild(t), t;
}
function x(e, t) {
const n = Array.from(e.querySelectorAll("li")).filter(
(r) => r instanceof HTMLLIElement && S(t, r)
), o = new Set(n);
return n.filter((r) => {
let s = r.parentElement?.closest("li");
for (; s; ) {
if (o.has(s)) return !1;
s = s.parentElement?.closest("li");
}
return !0;
});
}
function m(e) {
const t = window.getSelection();
if (!t) return;
const n = document.createRange(), o = e instanceof HTMLElement && e.querySelector("p,li,h1,h2,h3,h4,h5,h6") || e;
n.selectNodeContents(o), n.collapse(!0), t.removeAllRanges(), t.addRange(n);
}
function q(e) {
e.dispatchEvent(new Event("input", { bubbles: !0 }));
}
function O(e, t, n) {
const o = window.execEditorCommand;
if (typeof o == "function") {
o("recordDomTransaction", e, t, n);
return;
}
const r = window.executeEditorCommand;
typeof r == "function" && r("recordDomTransaction", { editor: e, beforeHTML: t, afterHTML: n });
}
function A(e) {
const t = y(e);
if (!t) return !1;
const n = B(t);
if (!n) return !1;
const o = t.innerHTML, r = k(t, n.startContainer), s = k(t, n.endContainer), c = x(t, n), i = b(t, n), h = i.length > 0 && i.every((l) => l.tagName === "BLOCKQUOTE");
if (r && r === s) {
const l = r.firstChild || r;
p(r), m(l);
} else if (c.length > 0) {
const l = c.map(N);
if (l.every(Boolean)) {
const u = l[0]?.firstChild || c[0];
l.forEach((a) => {
a && p(a);
}), m(u);
} else {
const u = c[0];
c.forEach((a) => {
N(a) || M(a);
}), m(u);
}
} else if (h) {
const l = i[0].firstChild || i[0];
i.forEach(p), m(l);
} else {
const l = i.filter((a) => a.tagName !== "BLOCKQUOTE");
if (l.length === 0) return !1;
const g = document.createElement("blockquote"), u = l[0];
u.parentNode?.insertBefore(g, u), l.forEach((a) => {
g.appendChild(a);
}), m(g);
}
const f = t.innerHTML;
return o === f ? !1 : (O(t, o, f), q(t), !0);
}
const H = () => ({
name: "blockquote",

@@ -26,15 +200,3 @@ // Schema definition for blockquote node

*/
toggleBlockquote: () => {
const e = window.getSelection();
if (!e || e.rangeCount === 0) return !1;
let o = e.anchorNode, t = !1;
for (; o && o !== document.body; ) {
if (o.nodeName === "BLOCKQUOTE") {
t = !0;
break;
}
o = o.parentNode;
}
return t ? document.execCommand("formatBlock", !1, "p") : document.execCommand("formatBlock", !1, "blockquote"), !0;
}
toggleBlockquote: (e, t) => A(t)
},

@@ -47,3 +209,3 @@ // Keyboard shortcuts

export {
c as BlockquotePlugin
H as BlockquotePlugin
};

@@ -1,2 +0,2 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=".rte-content, .editora-content",fe="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",ye="__editoraCommandEditorRoot",he="rte-blocks-library-styles",d="rte-blocks-library-panel",E="blocks-library",C="blocksLibrary",$=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Pe=80,Be=new Set(["script","style","meta","link","object","embed","iframe"]),De=/^(https?:|mailto:|tel:|#|\/)/i,Oe=/^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i,Ne={panelTitle:"Blocks Library",panelAriaLabel:"Blocks library panel",searchLabel:"Search blocks",searchPlaceholder:"Search by name, category, or keyword",categoryLabel:"Category",allCategoriesText:"All categories",recentHeading:"Recent inserts",insertText:"Insert Selected",closeText:"Close",noResultsText:"No matching blocks found.",summaryPrefix:"Blocks",loadingText:"Loading blocks...",loadErrorText:"Unable to load blocks right now.",readonlyMessage:"Editor is read-only. Block insertion is disabled.",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+B (panel), Ctrl/Cmd+Alt+Shift+L (insert last)",helperText:"Use Arrow keys to move through blocks, Enter to insert, Esc to close.",lastInsertedPrefix:"Last inserted",resultsListLabel:"Block results"},b=new WeakMap,J=new WeakMap,w=new WeakMap,I=new WeakMap,O=new WeakMap,j=new WeakMap,W=new WeakMap,z=new WeakMap,q=new WeakMap,te=new WeakMap,x=new Map,U=new WeakMap,oe=new Set;let X=0,Ke=0,ke=0,M=null,y=null,_=null,P=null,A=null,D=null;function m(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function je(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function We(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function ce(e){const t=e.trim();return t&&(De.test(t)||Oe.test(t))?t:""}function xe(e){let t=e;return Be.forEach(r=>{const o=new RegExp(`<${r}[\\s\\S]*?>[\\s\\S]*?<\\/${r}>`,"gi"),l=new RegExp(`<${r}\\b[^>]*\\/?>`,"gi");t=t.replace(o,"").replace(l,"")}),t=t.replace(/\son\w+=(\"[^\"]*\"|'[^']*'|[^\s>]+)/gi,"").replace(/\s(xmlns|xml:[^=\s>]+)\s*=\s*(\"[^\"]*\"|'[^']*'|[^\s>]+)/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*("|\')\s*(?:javascript:|vbscript:|data:text\/html)[^"']*\2/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*(?:javascript:|vbscript:|data:text\/html)[^\s>]*/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*("([^"]*)"|'([^']*)')/gi,(r,o,l,n,a)=>{const s=typeof n=="string"&&n.length>0?n:a||"",i=ce(s);if(!i)return"";const c=l.startsWith('"')?'"':"'";return` ${o}=${c}${i}${c}`}).replace(/\s(href|src|xlink:href)\s*=\s*([^\s>]+)/gi,(r,o,l)=>{const n=ce(l);return n?` ${o}="${n}"`:""}).replace(/\sstyle\s*=\s*("([^"]*)"|'([^']*)')/gi,(r,o,l,n)=>{const a=typeof l=="string"&&l.length>0?l:n||"";if(/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(a))return"";const s=o.startsWith('"')?'"':"'";return` style=${s}${a}${s}`}).trim(),t}function Fe(e){if(!e)return"";if(typeof document>"u")return xe(e);const t=document.createElement("template");t.innerHTML=e;const r=t.content;return!r||typeof r.querySelectorAll!="function"?xe(e):(Array.from(r.querySelectorAll("*")).forEach(l=>{const n=l.tagName.toLowerCase();if(Be.has(n)){l.remove();return}Array.from(l.attributes).forEach(s=>{const i=s.name.toLowerCase(),c=s.value;if(i.startsWith("on")){l.removeAttribute(s.name);return}if(i==="style"){/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(c)&&l.removeAttribute(s.name);return}if(i==="href"||i==="src"||i==="xlink:href"){const u=ce(c);if(!u){l.removeAttribute(s.name);return}u!==c&&l.setAttribute(s.name,u)}})}),t.innerHTML.trim())}function ne(e){return e.trim().toLowerCase()}function Ge(e){if(!e)return"";if(typeof document>"u")return e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim();const t=document.createElement("template");t.innerHTML=e;const r=t.content;return!r||typeof r.textContent!="string"?e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim():r.textContent.replace(/\s+/g," ").trim()}function Ce(e,t){if(!Array.isArray(e)||e.length===0)return[];const r=new Set,o=[];return e.forEach(l=>{const n=t.normalizeText(l.label||""),a=t.sanitizeBlockHtml(l.html||"",l).trim();if(!n||!a)return;const s=t.normalizeText(l.category||"General")||"General",i=ne(s);let u=We(t.normalizeText(l.id||n))||`block-${ke++}`;for(;r.has(u);)u=`${u}-${ke++}`;r.add(u);const f=(l.tags||[]).map(H=>t.normalizeText(H)).filter(Boolean),g=(l.keywords||[]).map(H=>t.normalizeText(H)).filter(Boolean),h=t.normalizeText(l.description||""),R=Ge(a),V=[n,h,s,...f,...g,R].join(" ").toLowerCase();o.push({id:u,label:n,html:a,description:h,category:s,categoryKey:i,tags:f,keywords:g,previewText:R,searchBlob:V})}),o}function Q(e={}){const t=e.normalizeText||je,r=e.sanitizeBlockHtml||Fe,o={blocks:[],defaultCategory:t(e.defaultCategory||""),maxResults:Math.max(4,Math.min(300,Number(e.maxResults??80))),maxRecentBlocks:Math.max(1,Math.min(20,Number(e.maxRecentBlocks??6))),debounceMs:Math.max(0,Math.min(700,Number(e.debounceMs??90))),cacheTtlMs:Math.max(0,Number(e.cacheTtlMs??6e4)),labels:{...Ne,...e.labels||{}},normalizeText:t,sanitizeBlockHtml:r,getBlocks:typeof e.getBlocks=="function"?e.getBlocks:void 0};return o.blocks=Ce(e.blocks,o),o}function Ue(e){return{blocks:e.blocks.map(t=>({id:t.id,label:t.label,html:t.html,description:t.description||void 0,category:t.category||void 0,tags:t.tags.length?[...t.tags]:void 0,keywords:t.keywords.length?[...t.keywords]:void 0})),defaultCategory:e.defaultCategory,maxResults:e.maxResults,maxRecentBlocks:e.maxRecentBlocks,debounceMs:e.debounceMs,cacheTtlMs:e.cacheTtlMs,labels:{...e.labels},normalizeText:e.normalizeText,sanitizeBlockHtml:e.sanitizeBlockHtml,getBlocks:e.getBlocks}}function le(e){return e.closest(fe)||e}function G(e){if(!e)return null;if(e.matches(v))return e;const t=e.querySelector(v);return t instanceof HTMLElement?t:null}function Ve(){if(typeof window>"u")return null;const e=window[ye];if(!(e instanceof HTMLElement))return null;window[ye]=null;const t=G(e);if(t)return t;const r=e.closest(fe);if(r){const l=G(r);if(l)return l}const o=e.closest(v);return o instanceof HTMLElement?o:null}function Ye(e){const t=e.closest("[data-editora-editor]");if(t&&G(t)===e)return t;let r=e;for(;r;){if(r.matches(fe)&&(r===e||G(r)===e))return r;r=r.parentElement}return le(e)}function $e(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function ee(){Array.from(oe).forEach(t=>{t.isConnected||ge(t)})}function S(e,t=!0,r=!0){if(ee(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const a=G(e.editorElement);if(a)return a}const o=Ve();if(o)return o;const l=window.getSelection();if(l&&l.rangeCount>0){const s=$e(l.getRangeAt(0).startContainer)?.closest(v);if(s)return s}const n=document.activeElement;if(n){if(n.matches(v))return n;const a=n.closest(v);if(a)return a}if(r){if(y&&y.isConnected)return y;y&&!y.isConnected&&(y=null)}return t?document.querySelector(v):null}function Xe(e){const t=e.target;if(t){const o=t.closest(v);if(o)return o}const r=window.getSelection();if(r&&r.rangeCount>0){const l=$e(r.getRangeAt(0).startContainer)?.closest(v);if(l)return l}return null}function Z(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 Ze(e){const t=le(e);if(Z(t))return!0;const r=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return Z(r)?!0:Z(document.documentElement)||Z(document.body)}function re(e,t){e.classList.remove("rte-blocks-library-theme-dark"),Ze(t)&&e.classList.add("rte-blocks-library-theme-dark")}function Se(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function we(e,t,r){const o=Ye(e);Array.from(o.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(n=>{n.classList.toggle("active",r),n.setAttribute("data-active",r?"true":"false"),n.setAttribute("aria-pressed",r?"true":"false")})}function Ee(e,t){const r=e.querySelector(".rte-blocks-library-live");r&&(r.textContent=t)}function se(e){const t=Re(e);if(t)try{q.set(e,t.cloneRange())}catch{}}function Te(e){const t=q.get(e);if(!t)return null;if(!e.isConnected)return q.delete(e),null;try{const r=t.cloneRange();return e.contains(r.commonAncestorContainer)?r:(q.delete(e),null)}catch{return q.delete(e),null}}function Je(e){const t=Te(e);return t?(He(e,t),!0):!1}function Qe(e){if(te.has(e))return;const t=()=>{const r=window.getSelection();if(!r||r.rangeCount===0)return;const o=r.getRangeAt(0);e.contains(o.commonAncestorContainer)&&se(e)};e.addEventListener("keyup",t),e.addEventListener("mouseup",t),e.addEventListener("touchend",t),te.set(e,t)}function et(e){const t=te.get(e);t&&(e.removeEventListener("keyup",t),e.removeEventListener("mouseup",t),e.removeEventListener("touchend",t),te.delete(e))}function k(e,t){b.has(e)||b.set(e,t),I.has(e)||(I.set(e,t.blocks),O.set(e,Date.now()));let r=w.get(e);return r||(r={query:"",category:t.defaultCategory?ne(t.defaultCategory):"all",selectedBlockId:null,recentBlockIds:[],lastInsertedBlockId:null,loading:!1,loadError:null,totalMatches:0,visibleMatches:0,filterCache:new Map,debounceTimer:null},w.set(e,r)),oe.add(e),Qe(e),r}function Me(e){const t=w.get(e);!t||t.debounceTimer===null||(window.clearTimeout(t.debounceTimer),t.debounceTimer=null)}function ge(e){Me(e),et(e),q.delete(e);const t=W.get(e);t&&(t.abort(),W.delete(e)),j.delete(e),z.delete(e),x.get(e)?.remove(),x.delete(e),U.delete(e),b.delete(e),J.delete(e),w.delete(e),I.delete(e),O.delete(e),oe.delete(e),y===e&&(y=null)}function tt(e){for(let t=0;t<e.length;t+=1){const r=e[t];if(!(r.type!=="childList"||r.removedNodes.length===0))for(let o=0;o<r.removedNodes.length;o+=1){const l=r.removedNodes[o];if(l.nodeType!==Node.ELEMENT_NODE)continue;const n=l;if(n.matches?.(v)||n.matches?.(`.${d}`)||n.querySelector?.(v)||n.querySelector?.(`.${d}`))return!0}}return!1}function pe(e){return U.get(e)===!0}function ue(e,t){if(!t.classList.contains("show"))return;const r=le(e).getBoundingClientRect(),o=Math.min(window.innerWidth-20,420),l=Math.max(10,window.innerWidth-o-10),n=Math.min(Math.max(10,r.right-o),l),a=Math.max(10,Math.min(window.innerHeight-10,r.top+12));t.style.width=`${o}px`,t.style.left=`${n}px`,t.style.top=`${a}px`,t.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function ae(e){return I.get(e)||b.get(e)?.blocks||[]}function rt(e,t){const r=new Map;ae(e).forEach(l=>{r.has(l.categoryKey)||r.set(l.categoryKey,l.category)});const o=Array.from(r.entries()).sort((l,n)=>l[1].localeCompare(n[1])).map(([l,n])=>({value:l,label:n}));return[{value:"all",label:t.labels.allCategoriesText},...o]}function Ae(e,t){const r=k(e,t),o=ae(e),l=r.query.trim().toLowerCase(),n=r.category||"all",a=`${l}|${n}|${t.maxResults}`,s=r.filterCache.get(a);if(s){const u=new Map(o.map(g=>[g.id,g])),f=s.ids.map(g=>u.get(g)).filter(Boolean);return r.totalMatches=s.total,r.visibleMatches=f.length,f}const i=[];let c=0;for(let u=0;u<o.length;u+=1){const f=o[u];n!=="all"&&f.categoryKey!==n||l&&!f.searchBlob.includes(l)||(c+=1,i.length<t.maxResults&&i.push(f))}if(r.totalMatches=c,r.visibleMatches=i.length,r.filterCache.set(a,{ids:i.map(u=>u.id),total:c}),r.filterCache.size>Pe){const u=r.filterCache.keys().next().value;typeof u=="string"&&r.filterCache.delete(u)}return i}function ot(e,t){const r=w.get(e);if(!r)return;if(t.length===0){r.selectedBlockId=null;return}t.some(l=>l.id===r.selectedBlockId)||(r.selectedBlockId=t[0].id)}function N(e){const t=w.get(e);we(e,"toggleBlocksLibraryPanel",pe(e)),we(e,"insertLastBlockSnippet",!!t?.lastInsertedBlockId)}function L(e){const t=x.get(e),r=b.get(e)||M,o=w.get(e);if(!t||!r||!o)return;re(t,e);const l=t.querySelector(".rte-blocks-library-title");l&&(l.textContent=r.labels.panelTitle);const n=t.querySelector('[data-action="close"]');n&&(n.setAttribute("aria-label",r.labels.closeText),n.textContent="✕");const a=t.querySelector(".rte-blocks-library-search-label");a&&(a.textContent=r.labels.searchLabel);const s=t.querySelector('[data-field="query"]');s&&(s.setAttribute("placeholder",r.labels.searchPlaceholder),s.value!==o.query&&(s.value=o.query));const i=t.querySelector(".rte-blocks-library-category-label");i&&(i.textContent=r.labels.categoryLabel);const c=t.querySelector('[data-field="category"]');if(c){const B=rt(e,r);c.innerHTML=B.map(p=>`<option value="${m(p.value)}">${m(p.label)}</option>`).join(""),B.some(p=>p.value===o.category)||(o.category="all"),c.value=o.category}const u=t.querySelector(".rte-blocks-library-helper");u&&(u.textContent=r.labels.helperText);const f=t.querySelector('.rte-blocks-library-list[role="listbox"]');f&&f.setAttribute("aria-label",r.labels.resultsListLabel);const g=t.querySelector(".rte-blocks-library-shortcut");g&&(g.textContent=r.labels.shortcutText);const h=t.querySelector('[data-action="insert-selected"]');if(h){h.textContent=r.labels.insertText;const B=!Se(e)&&!!o.selectedBlockId;h.disabled=!B,h.setAttribute("aria-disabled",B?"false":"true")}const R=t.querySelector(".rte-blocks-library-empty"),V=t.querySelector(".rte-blocks-library-list"),H=Ae(e,r);ot(e,H);const Y=t.querySelector(".rte-blocks-library-status");if(Y&&(o.loading?Y.textContent=r.labels.loadingText:o.loadError?Y.textContent=o.loadError:Y.textContent=`${r.labels.summaryPrefix}: ${o.visibleMatches}/${o.totalMatches}`),V){const B=new Set(o.recentBlockIds);V.innerHTML=H.map(p=>{const ie=o.selectedBlockId===p.id,qe=p.tags.length?` • ${p.tags.join(", ")}`:"",_e=B.has(p.id),me=p.previewText.slice(0,180);return`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=".rte-content, .editora-content",fe="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",ye="__editoraCommandEditorRoot",he="rte-blocks-library-styles",d="rte-blocks-library-panel",E="blocks-library",C="blocksLibrary",$=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',De=80,Be=new Set(["script","style","meta","link","object","embed","iframe"]),Oe=/^(https?:|mailto:|tel:|#|\/)/i,Ke=/^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i,Ne={panelTitle:"Blocks Library",panelAriaLabel:"Blocks library panel",searchLabel:"Search blocks",searchPlaceholder:"Search by name, category, or keyword",categoryLabel:"Category",allCategoriesText:"All categories",recentHeading:"Recent inserts",insertText:"Insert Selected",closeText:"Close",noResultsText:"No matching blocks found.",summaryPrefix:"Blocks",loadingText:"Loading blocks...",loadErrorText:"Unable to load blocks right now.",readonlyMessage:"Editor is read-only. Block insertion is disabled.",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+B (panel), Ctrl/Cmd+Alt+Shift+L (insert last)",helperText:"Use Arrow keys to move through blocks, Enter to insert, Esc to close.",lastInsertedPrefix:"Last inserted",resultsListLabel:"Block results"},b=new WeakMap,J=new WeakMap,w=new WeakMap,I=new WeakMap,O=new WeakMap,j=new WeakMap,W=new WeakMap,z=new WeakMap,q=new WeakMap,te=new WeakMap,x=new Map,U=new WeakMap,oe=new Set;let X=0,je=0,ke=0,M=null,y=null,_=null,P=null,A=null,D=null;function m(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function We(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function Fe(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function ce(e){const t=e.trim();return t&&(Oe.test(t)||Ke.test(t))?t:""}function xe(e){let t=e;return Be.forEach(r=>{const o=new RegExp(`<${r}[\\s\\S]*?>[\\s\\S]*?<\\/${r}>`,"gi"),l=new RegExp(`<${r}\\b[^>]*\\/?>`,"gi");t=t.replace(o,"").replace(l,"")}),t=t.replace(/\son\w+=(\"[^\"]*\"|'[^']*'|[^\s>]+)/gi,"").replace(/\s(xmlns|xml:[^=\s>]+)\s*=\s*(\"[^\"]*\"|'[^']*'|[^\s>]+)/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*("|\')\s*(?:javascript:|vbscript:|data:text\/html)[^"']*\2/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*(?:javascript:|vbscript:|data:text\/html)[^\s>]*/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*("([^"]*)"|'([^']*)')/gi,(r,o,l,n,a)=>{const s=typeof n=="string"&&n.length>0?n:a||"",i=ce(s);if(!i)return"";const c=l.startsWith('"')?'"':"'";return` ${o}=${c}${i}${c}`}).replace(/\s(href|src|xlink:href)\s*=\s*([^\s>]+)/gi,(r,o,l)=>{const n=ce(l);return n?` ${o}="${n}"`:""}).replace(/\sstyle\s*=\s*("([^"]*)"|'([^']*)')/gi,(r,o,l,n)=>{const a=typeof l=="string"&&l.length>0?l:n||"";if(/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(a))return"";const s=o.startsWith('"')?'"':"'";return` style=${s}${a}${s}`}).trim(),t}function Ge(e){if(!e)return"";if(typeof document>"u")return xe(e);const t=document.createElement("template");t.innerHTML=e;const r=t.content;return!r||typeof r.querySelectorAll!="function"?xe(e):(Array.from(r.querySelectorAll("*")).forEach(l=>{const n=l.tagName.toLowerCase();if(Be.has(n)){l.remove();return}Array.from(l.attributes).forEach(s=>{const i=s.name.toLowerCase(),c=s.value;if(i.startsWith("on")){l.removeAttribute(s.name);return}if(i==="style"){/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(c)&&l.removeAttribute(s.name);return}if(i==="href"||i==="src"||i==="xlink:href"){const u=ce(c);if(!u){l.removeAttribute(s.name);return}u!==c&&l.setAttribute(s.name,u)}})}),t.innerHTML.trim())}function ne(e){return e.trim().toLowerCase()}function Ue(e){if(!e)return"";if(typeof document>"u")return e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim();const t=document.createElement("template");t.innerHTML=e;const r=t.content;return!r||typeof r.textContent!="string"?e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim():r.textContent.replace(/\s+/g," ").trim()}function Ce(e,t){if(!Array.isArray(e)||e.length===0)return[];const r=new Set,o=[];return e.forEach(l=>{const n=t.normalizeText(l.label||""),a=t.sanitizeBlockHtml(l.html||"",l).trim();if(!n||!a)return;const s=t.normalizeText(l.category||"General")||"General",i=ne(s);let u=Fe(t.normalizeText(l.id||n))||`block-${ke++}`;for(;r.has(u);)u=`${u}-${ke++}`;r.add(u);const f=(l.tags||[]).map(H=>t.normalizeText(H)).filter(Boolean),g=(l.keywords||[]).map(H=>t.normalizeText(H)).filter(Boolean),h=t.normalizeText(l.description||""),R=Ue(a),V=[n,h,s,...f,...g,R].join(" ").toLowerCase();o.push({id:u,label:n,html:a,description:h,category:s,categoryKey:i,tags:f,keywords:g,previewText:R,searchBlob:V})}),o}function Q(e={}){const t=e.normalizeText||We,r=e.sanitizeBlockHtml||Ge,o={blocks:[],defaultCategory:t(e.defaultCategory||""),maxResults:Math.max(4,Math.min(300,Number(e.maxResults??80))),maxRecentBlocks:Math.max(1,Math.min(20,Number(e.maxRecentBlocks??6))),debounceMs:Math.max(0,Math.min(700,Number(e.debounceMs??90))),cacheTtlMs:Math.max(0,Number(e.cacheTtlMs??6e4)),labels:{...Ne,...e.labels||{}},normalizeText:t,sanitizeBlockHtml:r,getBlocks:typeof e.getBlocks=="function"?e.getBlocks:void 0};return o.blocks=Ce(e.blocks,o),o}function Ve(e){return{blocks:e.blocks.map(t=>({id:t.id,label:t.label,html:t.html,description:t.description||void 0,category:t.category||void 0,tags:t.tags.length?[...t.tags]:void 0,keywords:t.keywords.length?[...t.keywords]:void 0})),defaultCategory:e.defaultCategory,maxResults:e.maxResults,maxRecentBlocks:e.maxRecentBlocks,debounceMs:e.debounceMs,cacheTtlMs:e.cacheTtlMs,labels:{...e.labels},normalizeText:e.normalizeText,sanitizeBlockHtml:e.sanitizeBlockHtml,getBlocks:e.getBlocks}}function le(e){return e.closest(fe)||e}function G(e){if(!e)return null;if(e.matches(v))return e;const t=e.querySelector(v);return t instanceof HTMLElement?t:null}function Ye(){if(typeof window>"u")return null;const e=window[ye];if(!(e instanceof HTMLElement))return null;window[ye]=null;const t=G(e);if(t)return t;const r=e.closest(fe);if(r){const l=G(r);if(l)return l}const o=e.closest(v);return o instanceof HTMLElement?o:null}function Xe(e){const t=e.closest("[data-editora-editor]");if(t&&G(t)===e)return t;let r=e;for(;r;){if(r.matches(fe)&&(r===e||G(r)===e))return r;r=r.parentElement}return le(e)}function $e(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function ee(){Array.from(oe).forEach(t=>{t.isConnected||ge(t)})}function S(e,t=!0,r=!0){if(ee(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const a=G(e.editorElement);if(a)return a}const o=Ye();if(o)return o;const l=window.getSelection();if(l&&l.rangeCount>0){const s=$e(l.getRangeAt(0).startContainer)?.closest(v);if(s)return s}const n=document.activeElement;if(n){if(n.matches(v))return n;const a=n.closest(v);if(a)return a}if(r){if(y&&y.isConnected)return y;y&&!y.isConnected&&(y=null)}return t?document.querySelector(v):null}function Ze(e){const t=e.target;if(t){const o=t.closest(v);if(o)return o}const r=window.getSelection();if(r&&r.rangeCount>0){const l=$e(r.getRangeAt(0).startContainer)?.closest(v);if(l)return l}return null}function Z(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 Je(e){const t=le(e);if(Z(t))return!0;const r=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return Z(r)?!0:Z(document.documentElement)||Z(document.body)}function re(e,t){e.classList.remove("rte-blocks-library-theme-dark"),Je(t)&&e.classList.add("rte-blocks-library-theme-dark")}function Se(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function we(e,t,r){const o=Xe(e);Array.from(o.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(n=>{n.classList.toggle("active",r),n.setAttribute("data-active",r?"true":"false"),n.setAttribute("aria-pressed",r?"true":"false")})}function Ee(e,t){const r=e.querySelector(".rte-blocks-library-live");r&&(r.textContent=t)}function se(e){const t=Re(e);if(t)try{q.set(e,t.cloneRange())}catch{}}function Te(e){const t=q.get(e);if(!t)return null;if(!e.isConnected)return q.delete(e),null;try{const r=t.cloneRange();return e.contains(r.commonAncestorContainer)?r:(q.delete(e),null)}catch{return q.delete(e),null}}function Qe(e){const t=Te(e);return t?(He(e,t),!0):!1}function et(e){if(te.has(e))return;const t=()=>{const r=window.getSelection();if(!r||r.rangeCount===0)return;const o=r.getRangeAt(0);e.contains(o.commonAncestorContainer)&&se(e)};e.addEventListener("keyup",t),e.addEventListener("mouseup",t),e.addEventListener("touchend",t),te.set(e,t)}function tt(e){const t=te.get(e);t&&(e.removeEventListener("keyup",t),e.removeEventListener("mouseup",t),e.removeEventListener("touchend",t),te.delete(e))}function k(e,t){b.has(e)||b.set(e,t),I.has(e)||(I.set(e,t.blocks),O.set(e,Date.now()));let r=w.get(e);return r||(r={query:"",category:t.defaultCategory?ne(t.defaultCategory):"all",selectedBlockId:null,recentBlockIds:[],lastInsertedBlockId:null,loading:!1,loadError:null,totalMatches:0,visibleMatches:0,filterCache:new Map,debounceTimer:null},w.set(e,r)),oe.add(e),et(e),r}function Me(e){const t=w.get(e);!t||t.debounceTimer===null||(window.clearTimeout(t.debounceTimer),t.debounceTimer=null)}function ge(e){Me(e),tt(e),q.delete(e);const t=W.get(e);t&&(t.abort(),W.delete(e)),j.delete(e),z.delete(e),x.get(e)?.remove(),x.delete(e),U.delete(e),b.delete(e),J.delete(e),w.delete(e),I.delete(e),O.delete(e),oe.delete(e),y===e&&(y=null)}function rt(e){for(let t=0;t<e.length;t+=1){const r=e[t];if(!(r.type!=="childList"||r.removedNodes.length===0))for(let o=0;o<r.removedNodes.length;o+=1){const l=r.removedNodes[o];if(l.nodeType!==Node.ELEMENT_NODE)continue;const n=l;if(n.matches?.(v)||n.matches?.(`.${d}`)||n.querySelector?.(v)||n.querySelector?.(`.${d}`))return!0}}return!1}function pe(e){return U.get(e)===!0}function ue(e,t){if(!t.classList.contains("show"))return;const r=le(e).getBoundingClientRect(),o=Math.min(window.innerWidth-20,420),l=Math.max(10,window.innerWidth-o-10),n=Math.min(Math.max(10,r.right-o),l),a=Math.max(10,Math.min(window.innerHeight-10,r.top+12));t.style.width=`${o}px`,t.style.left=`${n}px`,t.style.top=`${a}px`,t.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function ae(e){return I.get(e)||b.get(e)?.blocks||[]}function ot(e,t){const r=new Map;ae(e).forEach(l=>{r.has(l.categoryKey)||r.set(l.categoryKey,l.category)});const o=Array.from(r.entries()).sort((l,n)=>l[1].localeCompare(n[1])).map(([l,n])=>({value:l,label:n}));return[{value:"all",label:t.labels.allCategoriesText},...o]}function Ae(e,t){const r=k(e,t),o=ae(e),l=r.query.trim().toLowerCase(),n=r.category||"all",a=`${l}|${n}|${t.maxResults}`,s=r.filterCache.get(a);if(s){const u=new Map(o.map(g=>[g.id,g])),f=s.ids.map(g=>u.get(g)).filter(Boolean);return r.totalMatches=s.total,r.visibleMatches=f.length,f}const i=[];let c=0;for(let u=0;u<o.length;u+=1){const f=o[u];n!=="all"&&f.categoryKey!==n||l&&!f.searchBlob.includes(l)||(c+=1,i.length<t.maxResults&&i.push(f))}if(r.totalMatches=c,r.visibleMatches=i.length,r.filterCache.set(a,{ids:i.map(u=>u.id),total:c}),r.filterCache.size>De){const u=r.filterCache.keys().next().value;typeof u=="string"&&r.filterCache.delete(u)}return i}function nt(e,t){const r=w.get(e);if(!r)return;if(t.length===0){r.selectedBlockId=null;return}t.some(l=>l.id===r.selectedBlockId)||(r.selectedBlockId=t[0].id)}function K(e){const t=w.get(e);we(e,"toggleBlocksLibraryPanel",pe(e)),we(e,"insertLastBlockSnippet",!!t?.lastInsertedBlockId)}function L(e){const t=x.get(e),r=b.get(e)||M,o=w.get(e);if(!t||!r||!o)return;re(t,e);const l=t.querySelector(".rte-blocks-library-title");l&&(l.textContent=r.labels.panelTitle);const n=t.querySelector('[data-action="close"]');n&&(n.setAttribute("aria-label",r.labels.closeText),n.textContent="✕");const a=t.querySelector(".rte-blocks-library-search-label");a&&(a.textContent=r.labels.searchLabel);const s=t.querySelector('[data-field="query"]');s&&(s.setAttribute("placeholder",r.labels.searchPlaceholder),s.value!==o.query&&(s.value=o.query));const i=t.querySelector(".rte-blocks-library-category-label");i&&(i.textContent=r.labels.categoryLabel);const c=t.querySelector('[data-field="category"]');if(c){const B=ot(e,r);c.innerHTML=B.map(p=>`<option value="${m(p.value)}">${m(p.label)}</option>`).join(""),B.some(p=>p.value===o.category)||(o.category="all"),c.value=o.category}const u=t.querySelector(".rte-blocks-library-helper");u&&(u.textContent=r.labels.helperText);const f=t.querySelector('.rte-blocks-library-list[role="listbox"]');f&&f.setAttribute("aria-label",r.labels.resultsListLabel);const g=t.querySelector(".rte-blocks-library-shortcut");g&&(g.textContent=r.labels.shortcutText);const h=t.querySelector('[data-action="insert-selected"]');if(h){h.textContent=r.labels.insertText;const B=!Se(e)&&!!o.selectedBlockId;h.disabled=!B,h.setAttribute("aria-disabled",B?"false":"true")}const R=t.querySelector(".rte-blocks-library-empty"),V=t.querySelector(".rte-blocks-library-list"),H=Ae(e,r);nt(e,H);const Y=t.querySelector(".rte-blocks-library-status");if(Y&&(o.loading?Y.textContent=r.labels.loadingText:o.loadError?Y.textContent=o.loadError:Y.textContent=`${r.labels.summaryPrefix}: ${o.visibleMatches}/${o.totalMatches}`),V){const B=new Set(o.recentBlockIds);V.innerHTML=H.map(p=>{const ie=o.selectedBlockId===p.id,_e=p.tags.length?` • ${p.tags.join(", ")}`:"",Pe=B.has(p.id),me=p.previewText.slice(0,180);return`
<li class="rte-blocks-library-item-wrapper" role="presentation">

@@ -14,5 +14,5 @@ <button

<span class="rte-blocks-library-item-label">${m(p.label)}</span>
${_e?`<span class="rte-blocks-library-recent-pill">${m(r.labels.recentHeading)}</span>`:""}
${Pe?`<span class="rte-blocks-library-recent-pill">${m(r.labels.recentHeading)}</span>`:""}
</span>
<span class="rte-blocks-library-item-meta">${m(p.category)}${m(qe)}</span>
<span class="rte-blocks-library-item-meta">${m(p.category)}${m(_e)}</span>
${p.description?`<span class="rte-blocks-library-item-description">${m(p.description)}</span>`:""}

@@ -22,3 +22,3 @@ ${me?`<span class="rte-blocks-library-item-preview">${m(me)}</span>`:""}

</li>
`}).join("")}R&&(R.hidden=H.length>0,R.textContent=r.labels.noResultsText);const K=t.querySelector(".rte-blocks-library-last-inserted");if(K)if(o.lastInsertedBlockId){const B=ae(e).find(p=>p.id===o.lastInsertedBlockId);B?(K.hidden=!1,K.textContent=`${r.labels.lastInsertedPrefix}: ${B.label}`):K.hidden=!0}else K.hidden=!0;t.setAttribute("aria-label",r.labels.panelAriaLabel)}function T(e,t=!1){const r=x.get(e);r&&(r.classList.remove("show"),U.set(e,!1),N(e),t&&(e.focus({preventScroll:!0}),Je(e)))}function nt(e){e.querySelector(".rte-blocks-library-item.active")?.focus()}function ve(e,t){const r=b.get(e)||M;if(!r)return;const o=w.get(e);if(!o)return;const l=Ae(e,r);if(l.length===0)return;const a=(Math.max(0,l.findIndex(i=>i.id===o.selectedBlockId))+t+l.length)%l.length;o.selectedBlockId=l[a].id,L(e);const s=x.get(e);s&&nt(s)}function de(e){const t=ct(e);se(e),x.forEach((o,l)=>{l!==e&&T(l,!1)}),t.classList.add("show"),U.set(e,!0),L(e),ue(e,t),N(e),t.querySelector('[data-field="query"]')?.focus(),be(e,!1)}function Ie(e,t){const r=pe(e);return(typeof t=="boolean"?t:!r)?de(e):T(e,!1),!0}function Re(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=t.getRangeAt(0);return e.contains(r.commonAncestorContainer)?r:null}function He(e,t){if(!e.isConnected)return;const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(t))}function Le(e,t,r){const o=t.cloneRange();if(!e.contains(o.commonAncestorContainer))return!1;o.deleteContents();const l=document.createElement("template");l.innerHTML=r;const n=l.content;if(!n)return!1;const a=n.lastChild;if(o.insertNode(n),a){const s=document.createRange();s.setStartAfter(a),s.collapse(!0),He(e,s)}return se(e),!0}function lt(e,t){e.focus({preventScroll:!0});const r=Te(e);if(r&&Le(e,r,t))return!0;try{if(document.execCommand("insertHTML",!1,t))return se(e),!0}catch{}const o=Re(e);return o?Le(e,o,t):!1}function st(e,t){if(t===e.innerHTML)return;const r=window.execEditorCommand||window.executeEditorCommand;if(typeof r=="function")try{r("recordDomTransaction",e,t,e.innerHTML)}catch{}}function at(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function F(e,t){const r=b.get(e)||M;if(!r)return!1;const o=k(e,r),l=x.get(e);if(Se(e))return l&&Ee(l,r.labels.readonlyMessage),!1;const n=ae(e).find(i=>i.id===t);if(!n)return!1;const a=e.innerHTML;return lt(e,n.html)?(o.lastInsertedBlockId=n.id,o.selectedBlockId=n.id,o.recentBlockIds=[n.id,...o.recentBlockIds.filter(i=>i!==n.id)].slice(0,r.maxRecentBlocks),st(e,a),at(e),N(e),e.dispatchEvent(new CustomEvent("editora:blocks-library-insert",{bubbles:!0,detail:{blockId:n.id,label:n.label,category:n.category}})),L(e),l&&Ee(l,`${r.labels.lastInsertedPrefix}: ${n.label}`),!0):!1}function ze(e){const t=w.get(e);return t?.lastInsertedBlockId?F(e,t.lastInsertedBlockId):!1}function it(e){const t=b.get(e)||M;if(!t)return;const r=w.get(e);if(!r)return;Me(e);const o=()=>{r.debounceTimer=null,r.filterCache.clear(),L(e)};if(t.debounceMs<=0){o();return}r.debounceTimer=window.setTimeout(o,t.debounceMs)}function ct(e){const t=x.get(e);if(t)return t;const r=b.get(e)||M||Q(),o=k(e,r),l=`rte-blocks-library-panel-${Ke++}`,n=`${l}-query`,a=`${l}-category`,s=document.createElement("section");return s.className=d,s.id=l,s.setAttribute("role","dialog"),s.setAttribute("aria-modal","false"),s.setAttribute("aria-label",r.labels.panelAriaLabel),s.innerHTML=`
`}).join("")}R&&(R.hidden=H.length>0,R.textContent=r.labels.noResultsText);const N=t.querySelector(".rte-blocks-library-last-inserted");if(N)if(o.lastInsertedBlockId){const B=ae(e).find(p=>p.id===o.lastInsertedBlockId);B?(N.hidden=!1,N.textContent=`${r.labels.lastInsertedPrefix}: ${B.label}`):N.hidden=!0}else N.hidden=!0;t.setAttribute("aria-label",r.labels.panelAriaLabel)}function T(e,t=!1){const r=x.get(e);r&&(r.classList.remove("show"),U.set(e,!1),K(e),t&&(e.focus({preventScroll:!0}),Qe(e)))}function lt(e){e.querySelector(".rte-blocks-library-item.active")?.focus()}function ve(e,t){const r=b.get(e)||M;if(!r)return;const o=w.get(e);if(!o)return;const l=Ae(e,r);if(l.length===0)return;const a=(Math.max(0,l.findIndex(i=>i.id===o.selectedBlockId))+t+l.length)%l.length;o.selectedBlockId=l[a].id,L(e);const s=x.get(e);s&&lt(s)}function de(e){const t=ut(e);se(e),x.forEach((o,l)=>{l!==e&&T(l,!1)}),t.classList.add("show"),U.set(e,!0),L(e),ue(e,t),K(e),t.querySelector('[data-field="query"]')?.focus(),be(e,!1)}function Ie(e,t){const r=pe(e);return(typeof t=="boolean"?t:!r)?de(e):T(e,!1),!0}function Re(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=t.getRangeAt(0);return e.contains(r.commonAncestorContainer)?r:null}function He(e,t){if(!e.isConnected)return;const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(t))}function Le(e,t,r){const o=t.cloneRange();if(!e.contains(o.commonAncestorContainer))return!1;o.deleteContents();const l=document.createElement("template");l.innerHTML=r;const n=l.content;if(!n)return!1;const a=n.lastChild;if(o.insertNode(n),a){const s=document.createRange();s.setStartAfter(a),s.collapse(!0),He(e,s)}return se(e),!0}function st(e,t){e.focus({preventScroll:!0});const r=Te(e);if(r&&Le(e,r,t))return!0;try{if(document.execCommand("insertHTML",!1,t))return se(e),!0}catch{}const o=Re(e);return o?Le(e,o,t):!1}function at(e,t){if(t===e.innerHTML)return;const r=window.execEditorCommand||window.executeEditorCommand;if(typeof r=="function")try{r("recordDomTransaction",e,t,e.innerHTML)}catch{}}function it(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function F(e,t){const r=b.get(e)||M;if(!r)return!1;const o=k(e,r),l=x.get(e);if(Se(e))return l&&Ee(l,r.labels.readonlyMessage),!1;const n=ae(e).find(i=>i.id===t);if(!n)return!1;const a=e.innerHTML;return st(e,n.html)?(o.lastInsertedBlockId=n.id,o.selectedBlockId=n.id,o.recentBlockIds=[n.id,...o.recentBlockIds.filter(i=>i!==n.id)].slice(0,r.maxRecentBlocks),at(e,a),it(e),K(e),e.dispatchEvent(new CustomEvent("editora:blocks-library-insert",{bubbles:!0,detail:{blockId:n.id,label:n.label,category:n.category}})),L(e),l&&Ee(l,`${r.labels.lastInsertedPrefix}: ${n.label}`),!0):!1}function ze(e){const t=w.get(e);return t?.lastInsertedBlockId?F(e,t.lastInsertedBlockId):!1}function ct(e){const t=b.get(e)||M;if(!t)return;const r=w.get(e);if(!r)return;Me(e);const o=()=>{r.debounceTimer=null,r.filterCache.clear(),L(e)};if(t.debounceMs<=0){o();return}r.debounceTimer=window.setTimeout(o,t.debounceMs)}function ut(e){const t=x.get(e);if(t)return t;const r=b.get(e)||M||Q(),o=k(e,r),l=`rte-blocks-library-panel-${je++}`,n=`${l}-query`,a=`${l}-category`,s=document.createElement("section");return s.className=d,s.id=l,s.setAttribute("role","dialog"),s.setAttribute("aria-modal","false"),s.setAttribute("aria-label",r.labels.panelAriaLabel),s.innerHTML=`
<header class="rte-blocks-library-header">

@@ -46,3 +46,3 @@ <h2 class="rte-blocks-library-title">${m(r.labels.panelTitle)}</h2>

<div class="rte-blocks-library-live" aria-live="polite" aria-atomic="true"></div>
`,s.addEventListener("click",i=>{const c=i.target,u=c?.closest("[data-action]");if(u){const h=u.getAttribute("data-action");if(h==="close"){T(e,!0);return}if(h==="insert-selected"){if(!o.selectedBlockId)return;F(e,o.selectedBlockId)&&T(e,!0)}return}const f=c?.closest("[data-block-id]");if(!f)return;const g=f.getAttribute("data-block-id");g&&(o.selectedBlockId=g,L(e),i.detail>=2&&F(e,g)&&T(e,!0))}),s.addEventListener("input",i=>{const c=i.target;!(c instanceof HTMLInputElement)||c.getAttribute("data-field")!=="query"||(o.query=r.normalizeText(c.value).toLowerCase(),o.filterCache.clear(),it(e))}),s.addEventListener("change",i=>{const c=i.target;!(c instanceof HTMLSelectElement)||c.getAttribute("data-field")!=="category"||(o.category=ne(c.value||"all")||"all",o.filterCache.clear(),L(e))}),s.addEventListener("keydown",i=>{if(i.key==="Escape"){i.preventDefault(),T(e,!0);return}if(i.key==="ArrowDown"){i.preventDefault(),ve(e,1);return}if(i.key==="ArrowUp"){i.preventDefault(),ve(e,-1);return}if(i.key==="Enter"){if(!i.target?.matches('[data-field="query"], [data-field="category"], [data-block-id]')||!o.selectedBlockId)return;i.preventDefault(),F(e,o.selectedBlockId)&&T(e,!0)}}),re(s,e),document.body.appendChild(s),x.set(e,s),U.set(e,!1),L(e),s}function ut(e){const t=w.get(e);return{query:t?.query||"",category:t?.category||"all",selectedBlockId:t?.selectedBlockId||null,totalMatches:t?.totalMatches||0,visibleMatches:t?.visibleMatches||0,recentBlockIds:t?.recentBlockIds?[...t.recentBlockIds]:[],lastInsertedBlockId:t?.lastInsertedBlockId||null,loading:t?.loading===!0,loadError:t?.loadError||null}}async function be(e,t){const r=b.get(e)||M;if(!r||typeof r.getBlocks!="function")return;const o=k(e,r),l=O.get(e)||0;if(!t&&r.cacheTtlMs>0&&Date.now()-l<r.cacheTtlMs)return;const n=j.get(e);if(n&&!t)return n;const a=W.get(e);a&&a.abort(),t&&n&&j.delete(e);const s=new AbortController;W.set(e,s);const i=(z.get(e)||0)+1;z.set(e,i),o.loading=!0,o.loadError=null,L(e);const c=Promise.resolve().then(async()=>{const u={editor:e,editorRoot:le(e),signal:s.signal},f=await r.getBlocks?.(u);if(s.signal.aborted||z.get(e)!==i)return;const g=Ce(f||[],r);I.set(e,g),O.set(e,Date.now());const h=w.get(e);h&&(h.loading=!1,h.loadError=null,h.filterCache.clear())}).catch(()=>{if(s.signal.aborted||z.get(e)!==i)return;const u=w.get(e);u&&(u.loading=!1,u.loadError=r.labels.loadErrorText)}).finally(()=>{z.get(e)===i&&(j.delete(e),W.delete(e)),L(e)});return j.set(e,c),c}function dt(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="b"}function bt(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="l"}function ft(e){M=e,_||(_=t=>{ee();const o=t.target?.closest(v);if(!o)return;const l=b.get(o)||e;k(o,l),b.set(o,l),y=o,N(o);const n=x.get(o);n&&(re(n,o),ue(o,n),L(o))},document.addEventListener("focusin",_,!0)),P||(P=t=>{if(t.defaultPrevented)return;const r=`.${d} input, .${d} textarea, .${d} select`,o=t.target;if(o?.closest(r)){if(t.key==="Escape"){const a=o.closest(`.${d}`),s=Array.from(x.entries()).find(([,i])=>i===a);s&&(t.preventDefault(),T(s[0],!0))}return}const l=Xe(t);if(!l)return;const n=b.get(l)||M||e;if(k(l,n),b.set(l,n),y=l,t.key==="Escape"&&pe(l)){t.preventDefault(),T(l,!0);return}if(dt(t)){t.preventDefault(),t.stopPropagation(),Ie(l);return}bt(t)&&(t.preventDefault(),t.stopPropagation(),ze(l))},document.addEventListener("keydown",P,!0)),A||(A=()=>{ee(),x.forEach((t,r)=>{!r.isConnected||!t.isConnected||(re(t,r),ue(r,t))})},window.addEventListener("scroll",A,!0),window.addEventListener("resize",A)),!D&&typeof MutationObserver<"u"&&document.body&&(D=new MutationObserver(t=>{tt(t)&&ee()}),D.observe(document.body,{childList:!0,subtree:!0}))}function gt(){_&&(document.removeEventListener("focusin",_,!0),_=null),P&&(document.removeEventListener("keydown",P,!0),P=null),A&&(window.removeEventListener("scroll",A,!0),window.removeEventListener("resize",A),A=null),D&&(D.disconnect(),D=null),x.forEach(t=>t.remove()),x.clear(),Array.from(oe).forEach(t=>ge(t)),M=null,y=null}function pt(){if(typeof document>"u"||document.getElementById(he))return;const e=document.createElement("style");e.id=he,e.textContent=`
`,s.addEventListener("click",i=>{const c=i.target,u=c?.closest("[data-action]");if(u){const h=u.getAttribute("data-action");if(h==="close"){T(e,!0);return}if(h==="insert-selected"){if(!o.selectedBlockId)return;F(e,o.selectedBlockId)&&T(e,!0)}return}const f=c?.closest("[data-block-id]");if(!f)return;const g=f.getAttribute("data-block-id");g&&(o.selectedBlockId=g,L(e),i.detail>=2&&F(e,g)&&T(e,!0))}),s.addEventListener("input",i=>{const c=i.target;!(c instanceof HTMLInputElement)||c.getAttribute("data-field")!=="query"||(o.query=r.normalizeText(c.value).toLowerCase(),o.filterCache.clear(),ct(e))}),s.addEventListener("change",i=>{const c=i.target;!(c instanceof HTMLSelectElement)||c.getAttribute("data-field")!=="category"||(o.category=ne(c.value||"all")||"all",o.filterCache.clear(),L(e))}),s.addEventListener("keydown",i=>{if(i.key==="Escape"){i.preventDefault(),T(e,!0);return}if(i.key==="ArrowDown"){i.preventDefault(),ve(e,1);return}if(i.key==="ArrowUp"){i.preventDefault(),ve(e,-1);return}if(i.key==="Enter"){if(!i.target?.matches('[data-field="query"], [data-field="category"], [data-block-id]')||!o.selectedBlockId)return;i.preventDefault(),F(e,o.selectedBlockId)&&T(e,!0)}}),re(s,e),document.body.appendChild(s),x.set(e,s),U.set(e,!1),L(e),s}function dt(e){const t=w.get(e);return{query:t?.query||"",category:t?.category||"all",selectedBlockId:t?.selectedBlockId||null,totalMatches:t?.totalMatches||0,visibleMatches:t?.visibleMatches||0,recentBlockIds:t?.recentBlockIds?[...t.recentBlockIds]:[],lastInsertedBlockId:t?.lastInsertedBlockId||null,loading:t?.loading===!0,loadError:t?.loadError||null}}async function be(e,t){const r=b.get(e)||M;if(!r||typeof r.getBlocks!="function")return;const o=k(e,r),l=O.get(e)||0;if(!t&&r.cacheTtlMs>0&&Date.now()-l<r.cacheTtlMs)return;const n=j.get(e);if(n&&!t)return n;const a=W.get(e);a&&a.abort(),t&&n&&j.delete(e);const s=new AbortController;W.set(e,s);const i=(z.get(e)||0)+1;z.set(e,i),o.loading=!0,o.loadError=null,L(e);const c=Promise.resolve().then(async()=>{const u={editor:e,editorRoot:le(e),signal:s.signal},f=await r.getBlocks?.(u);if(s.signal.aborted||z.get(e)!==i)return;const g=Ce(f||[],r);I.set(e,g),O.set(e,Date.now());const h=w.get(e);h&&(h.loading=!1,h.loadError=null,h.filterCache.clear())}).catch(()=>{if(s.signal.aborted||z.get(e)!==i)return;const u=w.get(e);u&&(u.loading=!1,u.loadError=r.labels.loadErrorText)}).finally(()=>{z.get(e)===i&&(j.delete(e),W.delete(e)),L(e)});return j.set(e,c),c}function qe(e){return typeof e.key=="string"?e.key.toLowerCase():""}function bt(e){const t=qe(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="b"}function ft(e){const t=qe(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="l"}function gt(e){M=e,_||(_=t=>{ee();const o=t.target?.closest(v);if(!o)return;const l=b.get(o)||e;k(o,l),b.set(o,l),y=o,K(o);const n=x.get(o);n&&(re(n,o),ue(o,n),L(o))},document.addEventListener("focusin",_,!0)),P||(P=t=>{if(t.defaultPrevented)return;const r=`.${d} input, .${d} textarea, .${d} select`,o=t.target;if(o?.closest(r)){if(t.key==="Escape"){const a=o.closest(`.${d}`),s=Array.from(x.entries()).find(([,i])=>i===a);s&&(t.preventDefault(),T(s[0],!0))}return}const l=Ze(t);if(!l)return;const n=b.get(l)||M||e;if(k(l,n),b.set(l,n),y=l,t.key==="Escape"&&pe(l)){t.preventDefault(),T(l,!0);return}if(bt(t)){t.preventDefault(),t.stopPropagation(),Ie(l);return}ft(t)&&(t.preventDefault(),t.stopPropagation(),ze(l))},document.addEventListener("keydown",P,!0)),A||(A=()=>{ee(),x.forEach((t,r)=>{!r.isConnected||!t.isConnected||(re(t,r),ue(r,t))})},window.addEventListener("scroll",A,!0),window.addEventListener("resize",A)),!D&&typeof MutationObserver<"u"&&document.body&&(D=new MutationObserver(t=>{rt(t)&&ee()}),D.observe(document.body,{childList:!0,subtree:!0}))}function pt(){_&&(document.removeEventListener("focusin",_,!0),_=null),P&&(document.removeEventListener("keydown",P,!0),P=null),A&&(window.removeEventListener("scroll",A,!0),window.removeEventListener("resize",A),A=null),D&&(D.disconnect(),D=null),x.forEach(t=>t.remove()),x.clear(),Array.from(oe).forEach(t=>ge(t)),M=null,y=null}function mt(){if(typeof document>"u"||document.getElementById(he))return;const e=document.createElement("style");e.id=he,e.textContent=`
.rte-toolbar-group-items.${E},

@@ -445,2 +445,2 @@ .editora-toolbar-group-items.${E},

}
`,document.head.appendChild(e)}const mt=(e={})=>{const t=Q(e),r=new Set;return pt(),{name:"blocksLibrary",toolbar:[{id:"blocksLibraryGroup",label:"Blocks Library",type:"group",command:"blocksLibrary",items:[{id:"blocksLibraryPanel",label:"Blocks Library Panel",command:"toggleBlocksLibraryPanel",shortcut:"Mod-Alt-Shift-b",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4" y="5" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="13" y="5" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="4" y="13" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="13" y="13" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/></svg>'},{id:"insertLastBlockSnippet",label:"Insert Last Block",command:"insertLastBlockSnippet",shortcut:"Mod-Alt-Shift-l",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M7 5.5h10a1.5 1.5 0 0 1 1.5 1.5v10A1.5 1.5 0 0 1 17 18.5H7A1.5 1.5 0 0 1 5.5 17V7A1.5 1.5 0 0 1 7 5.5Z" stroke="currentColor" stroke-width="1.6"/><path d="M12 8.5v7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M8.5 12h7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'}]}],commands:{blocksLibrary:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),y=n,de(n),!0},openBlocksLibraryPanel:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),y=n,de(n),!0},toggleBlocksLibraryPanel:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),y=n,Ie(n,typeof o=="boolean"?o:void 0)},insertBlockSnippet:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;k(n,a),b.set(n,a);const s=typeof o=="string"?o:o?.id;return s?(y=n,F(n,s)):!1},insertLastBlockSnippet:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),y=n,ze(n)},refreshBlocksLibraryData:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),be(n,!0),!0},setBlocksLibraryOptions:(o,l)=>{const n=S(l,!1,!1);if(!n||!o||typeof o!="object")return!1;const a=b.get(n)||t,s=J.get(n)||Ue(a),i={...s,...o,labels:{...s.labels||{},...o.labels||{}},blocks:Array.isArray(o.blocks)?o.blocks:s.blocks,normalizeText:o.normalizeText||a.normalizeText,sanitizeBlockHtml:o.sanitizeBlockHtml||a.sanitizeBlockHtml,getBlocks:o.getBlocks||a.getBlocks},c=Q(i),u=Array.isArray(o.blocks),f=o.getBlocks!==void 0;b.set(n,c),J.set(n,i),(u||f||!I.has(n))&&(I.set(n,c.blocks),O.set(n,f?0:Date.now()));const g=k(n,c);return g.filterCache.clear(),typeof o.defaultCategory=="string"&&(g.category=ne(c.defaultCategory)||"all"),L(n),N(n),f&&be(n,!0),!0},getBlocksLibraryState:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;k(n,a);const s=ut(n);if(typeof o=="function")try{o(s)}catch{}return n.__blocksLibraryState=s,n.dispatchEvent(new CustomEvent("editora:blocks-library-state",{bubbles:!0,detail:s})),!0}},keymap:{"Mod-Alt-Shift-b":"toggleBlocksLibraryPanel","Mod-Alt-Shift-B":"toggleBlocksLibraryPanel","Mod-Alt-Shift-l":"insertLastBlockSnippet","Mod-Alt-Shift-L":"insertLastBlockSnippet"},init:function(l){X+=1;const n=this&&typeof this.__pluginConfig=="object"?{...e,...this.__pluginConfig}:e,a=Q(n);ft(a);const s=S(l?.editorElement?{editorElement:l.editorElement}:void 0,!1,!1);s&&(y=s,r.add(s),k(s,a),b.set(s,a),J.set(s,n),I.set(s,a.blocks),O.set(s,Date.now()),N(s))},destroy:()=>{r.forEach(o=>ge(o)),r.clear(),X=Math.max(0,X-1),!(X>0)&&gt()}}};exports.BlocksLibraryPlugin=mt;
`,document.head.appendChild(e)}const yt=(e={})=>{const t=Q(e),r=new Set;return mt(),{name:"blocksLibrary",toolbar:[{id:"blocksLibraryGroup",label:"Blocks Library",type:"group",command:"blocksLibrary",items:[{id:"blocksLibraryPanel",label:"Blocks Library Panel",command:"toggleBlocksLibraryPanel",shortcut:"Mod-Alt-Shift-b",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4" y="5" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="13" y="5" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="4" y="13" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="13" y="13" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/></svg>'},{id:"insertLastBlockSnippet",label:"Insert Last Block",command:"insertLastBlockSnippet",shortcut:"Mod-Alt-Shift-l",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M7 5.5h10a1.5 1.5 0 0 1 1.5 1.5v10A1.5 1.5 0 0 1 17 18.5H7A1.5 1.5 0 0 1 5.5 17V7A1.5 1.5 0 0 1 7 5.5Z" stroke="currentColor" stroke-width="1.6"/><path d="M12 8.5v7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M8.5 12h7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'}]}],commands:{blocksLibrary:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),y=n,de(n),!0},openBlocksLibraryPanel:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),y=n,de(n),!0},toggleBlocksLibraryPanel:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),y=n,Ie(n,typeof o=="boolean"?o:void 0)},insertBlockSnippet:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;k(n,a),b.set(n,a);const s=typeof o=="string"?o:o?.id;return s?(y=n,F(n,s)):!1},insertLastBlockSnippet:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),y=n,ze(n)},refreshBlocksLibraryData:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),be(n,!0),!0},setBlocksLibraryOptions:(o,l)=>{const n=S(l,!1,!1);if(!n||!o||typeof o!="object")return!1;const a=b.get(n)||t,s=J.get(n)||Ve(a),i={...s,...o,labels:{...s.labels||{},...o.labels||{}},blocks:Array.isArray(o.blocks)?o.blocks:s.blocks,normalizeText:o.normalizeText||a.normalizeText,sanitizeBlockHtml:o.sanitizeBlockHtml||a.sanitizeBlockHtml,getBlocks:o.getBlocks||a.getBlocks},c=Q(i),u=Array.isArray(o.blocks),f=o.getBlocks!==void 0;b.set(n,c),J.set(n,i),(u||f||!I.has(n))&&(I.set(n,c.blocks),O.set(n,f?0:Date.now()));const g=k(n,c);return g.filterCache.clear(),typeof o.defaultCategory=="string"&&(g.category=ne(c.defaultCategory)||"all"),L(n),K(n),f&&be(n,!0),!0},getBlocksLibraryState:(o,l)=>{const n=S(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;k(n,a);const s=dt(n);if(typeof o=="function")try{o(s)}catch{}return n.__blocksLibraryState=s,n.dispatchEvent(new CustomEvent("editora:blocks-library-state",{bubbles:!0,detail:s})),!0}},keymap:{"Mod-Alt-Shift-b":"toggleBlocksLibraryPanel","Mod-Alt-Shift-B":"toggleBlocksLibraryPanel","Mod-Alt-Shift-l":"insertLastBlockSnippet","Mod-Alt-Shift-L":"insertLastBlockSnippet"},init:function(l){X+=1;const n=this&&typeof this.__pluginConfig=="object"?{...e,...this.__pluginConfig}:e,a=Q(n);gt(a);const s=S(l?.editorElement?{editorElement:l.editorElement}:void 0,!1,!1);s&&(y=s,r.add(s),k(s,a),b.set(s,a),J.set(s,n),I.set(s,a.blocks),O.set(s,Date.now()),K(s))},destroy:()=>{r.forEach(o=>ge(o)),r.clear(),X=Math.max(0,X-1),!(X>0)&&pt()}}};exports.BlocksLibraryPlugin=yt;

@@ -1,3 +0,3 @@

const v = ".rte-content, .editora-content", fe = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", ye = "__editoraCommandEditorRoot", he = "rte-blocks-library-styles", u = "rte-blocks-library-panel", E = "blocks-library", B = "blocksLibrary", $ = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)';
const Ce = /* @__PURE__ */ new Set(["script", "style", "meta", "link", "object", "embed", "iframe"]), Pe = /^(https?:|mailto:|tel:|#|\/)/i, De = /^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i, Oe = {
const v = ".rte-content, .editora-content", fe = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", ye = "__editoraCommandEditorRoot", he = "rte-blocks-library-styles", u = "rte-blocks-library-panel", E = "blocks-library", C = "blocksLibrary", $ = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)';
const Be = /* @__PURE__ */ new Set(["script", "style", "meta", "link", "object", "embed", "iframe"]), De = /^(https?:|mailto:|tel:|#|\/)/i, Oe = /^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i, Ke = {
panelTitle: "Blocks Library",

@@ -26,6 +26,6 @@ panelAriaLabel: "Blocks library panel",

}
function Ke(e) {
function je(e) {
return e.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
}
function je(e) {
function We(e) {
return e.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);

@@ -35,7 +35,7 @@ }

const t = e.trim();
return t && (Pe.test(t) || De.test(t)) ? t : "";
return t && (De.test(t) || Oe.test(t)) ? t : "";
}
function xe(e) {
let t = e;
return Ce.forEach((r) => {
return Be.forEach((r) => {
const o = new RegExp(`<${r}[\\s\\S]*?>[\\s\\S]*?<\\/${r}>`, "gi"), l = new RegExp(`<${r}\\b[^>]*\\/?>`, "gi");

@@ -65,3 +65,3 @@ t = t.replace(o, "").replace(l, "");

}
function We(e) {
function Fe(e) {
if (!e) return "";

@@ -75,3 +75,3 @@ if (typeof document > "u")

const n = l.tagName.toLowerCase();
if (Ce.has(n)) {
if (Be.has(n)) {
l.remove();

@@ -104,3 +104,3 @@ return;

}
function Fe(e) {
function Ge(e) {
if (!e) return "";

@@ -114,3 +114,3 @@ if (typeof document > "u")

}
function Be(e, t) {
function Ce(e, t) {
if (!Array.isArray(e) || e.length === 0) return [];

@@ -122,7 +122,7 @@ const r = /* @__PURE__ */ new Set(), o = [];

const s = t.normalizeText(l.category || "General") || "General", i = ne(s);
let d = je(t.normalizeText(l.id || n)) || `block-${ke++}`;
let d = We(t.normalizeText(l.id || n)) || `block-${ke++}`;
for (; r.has(d); )
d = `${d}-${ke++}`;
r.add(d);
const f = (l.tags || []).map((H) => t.normalizeText(H)).filter(Boolean), g = (l.keywords || []).map((H) => t.normalizeText(H)).filter(Boolean), h = t.normalizeText(l.description || ""), R = Fe(a), V = [n, h, s, ...f, ...g, R].join(" ").toLowerCase();
const f = (l.tags || []).map((H) => t.normalizeText(H)).filter(Boolean), g = (l.keywords || []).map((H) => t.normalizeText(H)).filter(Boolean), h = t.normalizeText(l.description || ""), R = Ge(a), V = [n, h, s, ...f, ...g, R].join(" ").toLowerCase();
o.push({

@@ -143,3 +143,3 @@ id: d,

function Q(e = {}) {
const t = e.normalizeText || Ke, r = e.sanitizeBlockHtml || We, o = {
const t = e.normalizeText || je, r = e.sanitizeBlockHtml || Fe, o = {
blocks: [],

@@ -152,3 +152,3 @@ defaultCategory: t(e.defaultCategory || ""),

labels: {
...Oe,
...Ke,
...e.labels || {}

@@ -160,5 +160,5 @@ },

};
return o.blocks = Be(e.blocks, o), o;
return o.blocks = Ce(e.blocks, o), o;
}
function Ge(e) {
function Ue(e) {
return {

@@ -194,3 +194,3 @@ blocks: e.blocks.map((t) => ({

}
function Ue() {
function Ve() {
if (typeof window > "u") return null;

@@ -210,3 +210,3 @@ const e = window[ye];

}
function Ve(e) {
function Ye(e) {
const t = e.closest("[data-editora-editor]");

@@ -237,3 +237,3 @@ if (t && G(t) === e)

}
const o = Ue();
const o = Ve();
if (o) return o;

@@ -257,3 +257,3 @@ const l = window.getSelection();

}
function Ye(e) {
function Xe(e) {
const t = e.target;

@@ -274,3 +274,3 @@ if (t) {

}
function Xe(e) {
function Ze(e) {
const t = le(e);

@@ -282,3 +282,3 @@ if (Z(t)) return !0;

function re(e, t) {
e.classList.remove("rte-blocks-library-theme-dark"), Xe(t) && e.classList.add("rte-blocks-library-theme-dark");
e.classList.remove("rte-blocks-library-theme-dark"), Ze(t) && e.classList.add("rte-blocks-library-theme-dark");
}

@@ -289,3 +289,3 @@ function Te(e) {

function we(e, t, r) {
const o = Ve(e);
const o = Ye(e);
Array.from(

@@ -323,7 +323,7 @@ o.querySelectorAll(

}
function Ze(e) {
function Je(e) {
const t = Se(e);
return t ? (He(e, t), !0) : !1;
}
function Je(e) {
function Qe(e) {
if (te.has(e)) return;

@@ -338,3 +338,3 @@ const t = () => {

}
function Qe(e) {
function et(e) {
const t = te.get(e);

@@ -358,3 +358,3 @@ t && (e.removeEventListener("keyup", t), e.removeEventListener("mouseup", t), e.removeEventListener("touchend", t), te.delete(e));

debounceTimer: null
}, w.set(e, r)), oe.add(e), Je(e), r;
}, w.set(e, r)), oe.add(e), Qe(e), r;
}

@@ -366,7 +366,7 @@ function Me(e) {

function ge(e) {
Me(e), Qe(e), q.delete(e);
Me(e), et(e), q.delete(e);
const t = W.get(e);
t && (t.abort(), W.delete(e)), j.delete(e), z.delete(e), x.get(e)?.remove(), x.delete(e), U.delete(e), b.delete(e), J.delete(e), w.delete(e), I.delete(e), O.delete(e), oe.delete(e), y === e && (y = null);
}
function et(e) {
function tt(e) {
for (let t = 0; t < e.length; t += 1) {

@@ -396,3 +396,3 @@ const r = e[t];

}
function tt(e, t) {
function rt(e, t) {
const r = /* @__PURE__ */ new Map();

@@ -426,3 +426,3 @@ ae(e).forEach((l) => {

}
function rt(e, t) {
function ot(e, t) {
const r = w.get(e);

@@ -436,3 +436,3 @@ if (!r) return;

}
function N(e) {
function K(e) {
const t = w.get(e);

@@ -457,4 +457,4 @@ we(e, "toggleBlocksLibraryPanel", pe(e)), we(e, "insertLastBlockSnippet", !!t?.lastInsertedBlockId);

if (c) {
const C = tt(e, r);
c.innerHTML = C.map((p) => `<option value="${m(p.value)}">${m(p.label)}</option>`).join(""), C.some((p) => p.value === o.category) || (o.category = "all"), c.value = o.category;
const B = rt(e, r);
c.innerHTML = B.map((p) => `<option value="${m(p.value)}">${m(p.label)}</option>`).join(""), B.some((p) => p.value === o.category) || (o.category = "all"), c.value = o.category;
}

@@ -470,12 +470,12 @@ const d = t.querySelector(".rte-blocks-library-helper");

h.textContent = r.labels.insertText;
const C = !Te(e) && !!o.selectedBlockId;
h.disabled = !C, h.setAttribute("aria-disabled", C ? "false" : "true");
const B = !Te(e) && !!o.selectedBlockId;
h.disabled = !B, h.setAttribute("aria-disabled", B ? "false" : "true");
}
const R = t.querySelector(".rte-blocks-library-empty"), V = t.querySelector(".rte-blocks-library-list"), H = Ae(e, r);
rt(e, H);
ot(e, H);
const Y = t.querySelector(".rte-blocks-library-status");
if (Y && (o.loading ? Y.textContent = r.labels.loadingText : o.loadError ? Y.textContent = o.loadError : Y.textContent = `${r.labels.summaryPrefix}: ${o.visibleMatches}/${o.totalMatches}`), V) {
const C = new Set(o.recentBlockIds);
const B = new Set(o.recentBlockIds);
V.innerHTML = H.map((p) => {
const ie = o.selectedBlockId === p.id, qe = p.tags.length ? ` • ${p.tags.join(", ")}` : "", _e = C.has(p.id), me = p.previewText.slice(0, 180);
const ie = o.selectedBlockId === p.id, _e = p.tags.length ? ` • ${p.tags.join(", ")}` : "", Pe = B.has(p.id), me = p.previewText.slice(0, 180);
return `

@@ -494,5 +494,5 @@ <li class="rte-blocks-library-item-wrapper" role="presentation">

<span class="rte-blocks-library-item-label">${m(p.label)}</span>
${_e ? `<span class="rte-blocks-library-recent-pill">${m(r.labels.recentHeading)}</span>` : ""}
${Pe ? `<span class="rte-blocks-library-recent-pill">${m(r.labels.recentHeading)}</span>` : ""}
</span>
<span class="rte-blocks-library-item-meta">${m(p.category)}${m(qe)}</span>
<span class="rte-blocks-library-item-meta">${m(p.category)}${m(_e)}</span>
${p.description ? `<span class="rte-blocks-library-item-description">${m(p.description)}</span>` : ""}

@@ -506,9 +506,9 @@ ${me ? `<span class="rte-blocks-library-item-preview">${m(me)}</span>` : ""}

R && (R.hidden = H.length > 0, R.textContent = r.labels.noResultsText);
const K = t.querySelector(".rte-blocks-library-last-inserted");
if (K)
const N = t.querySelector(".rte-blocks-library-last-inserted");
if (N)
if (o.lastInsertedBlockId) {
const C = ae(e).find((p) => p.id === o.lastInsertedBlockId);
C ? (K.hidden = !1, K.textContent = `${r.labels.lastInsertedPrefix}: ${C.label}`) : K.hidden = !0;
const B = ae(e).find((p) => p.id === o.lastInsertedBlockId);
B ? (N.hidden = !1, N.textContent = `${r.labels.lastInsertedPrefix}: ${B.label}`) : N.hidden = !0;
} else
K.hidden = !0;
N.hidden = !0;
t.setAttribute("aria-label", r.labels.panelAriaLabel);

@@ -518,5 +518,5 @@ }

const r = x.get(e);
r && (r.classList.remove("show"), U.set(e, !1), N(e), t && (e.focus({ preventScroll: !0 }), Ze(e)));
r && (r.classList.remove("show"), U.set(e, !1), K(e), t && (e.focus({ preventScroll: !0 }), Je(e)));
}
function ot(e) {
function nt(e) {
e.querySelector(".rte-blocks-library-item.active")?.focus();

@@ -537,9 +537,9 @@ }

const s = x.get(e);
s && ot(s);
s && nt(s);
}
function ue(e) {
const t = it(e);
const t = ct(e);
se(e), x.forEach((o, l) => {
l !== e && S(l, !1);
}), t.classList.add("show"), U.set(e, !0), L(e), de(e, t), N(e), t.querySelector('[data-field="query"]')?.focus(), be(e, !1);
}), t.classList.add("show"), U.set(e, !0), L(e), de(e, t), K(e), t.querySelector('[data-field="query"]')?.focus(), be(e, !1);
}

@@ -576,3 +576,3 @@ function Ie(e, t) {

}
function nt(e, t) {
function lt(e, t) {
e.focus({ preventScroll: !0 });

@@ -590,3 +590,3 @@ const r = Se(e);

}
function lt(e, t) {
function st(e, t) {
if (t === e.innerHTML) return;

@@ -600,3 +600,3 @@ const r = window.execEditorCommand || window.executeEditorCommand;

}
function st(e) {
function at(e) {
e.dispatchEvent(new Event("input", { bubbles: !0 }));

@@ -613,6 +613,6 @@ }

const a = e.innerHTML;
return nt(e, n.html) ? (o.lastInsertedBlockId = n.id, o.selectedBlockId = n.id, o.recentBlockIds = [n.id, ...o.recentBlockIds.filter((i) => i !== n.id)].slice(
return lt(e, n.html) ? (o.lastInsertedBlockId = n.id, o.selectedBlockId = n.id, o.recentBlockIds = [n.id, ...o.recentBlockIds.filter((i) => i !== n.id)].slice(
0,
r.maxRecentBlocks
), lt(e, a), st(e), N(e), e.dispatchEvent(
), st(e, a), at(e), K(e), e.dispatchEvent(
new CustomEvent("editora:blocks-library-insert", {

@@ -632,3 +632,3 @@ bubbles: !0,

}
function at(e) {
function it(e) {
const t = b.get(e) || M;

@@ -648,3 +648,3 @@ if (!t) return;

}
function it(e) {
function ct(e) {
const t = x.get(e);

@@ -696,3 +696,3 @@ if (t) return t;

const c = i.target;
!(c instanceof HTMLInputElement) || c.getAttribute("data-field") !== "query" || (o.query = r.normalizeText(c.value).toLowerCase(), o.filterCache.clear(), at(e));
!(c instanceof HTMLInputElement) || c.getAttribute("data-field") !== "query" || (o.query = r.normalizeText(c.value).toLowerCase(), o.filterCache.clear(), it(e));
}), s.addEventListener("change", (i) => {

@@ -720,3 +720,3 @@ const c = i.target;

}
function ct(e) {
function dt(e) {
const t = w.get(e);

@@ -757,3 +757,3 @@ return {

if (s.signal.aborted || z.get(e) !== i) return;
const g = Be(f || [], r);
const g = Ce(f || [], r);
I.set(e, g), O.set(e, Date.now());

@@ -771,11 +771,14 @@ const h = w.get(e);

}
function dt(e) {
const t = e.key.toLowerCase();
function qe(e) {
return typeof e.key == "string" ? e.key.toLowerCase() : "";
}
function ut(e) {
const t = qe(e);
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "b";
}
function ut(e) {
const t = e.key.toLowerCase();
function bt(e) {
const t = qe(e);
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "l";
}
function bt(e) {
function ft(e) {
M = e, _ || (_ = (t) => {

@@ -786,3 +789,3 @@ ee();

const l = b.get(o) || e;
k(o, l), b.set(o, l), y = o, N(o);
k(o, l), b.set(o, l), y = o, K(o);
const n = x.get(o);

@@ -800,3 +803,3 @@ n && (re(n, o), de(o, n), L(o));

}
const l = Ye(t);
const l = Xe(t);
if (!l) return;

@@ -808,7 +811,7 @@ const n = b.get(l) || M || e;

}
if (dt(t)) {
if (ut(t)) {
t.preventDefault(), t.stopPropagation(), Ie(l);
return;
}
ut(t) && (t.preventDefault(), t.stopPropagation(), ze(l));
bt(t) && (t.preventDefault(), t.stopPropagation(), ze(l));
}, document.addEventListener("keydown", P, !0)), A || (A = () => {

@@ -819,3 +822,3 @@ ee(), x.forEach((t, r) => {

}, window.addEventListener("scroll", A, !0), window.addEventListener("resize", A)), !D && typeof MutationObserver < "u" && document.body && (D = new MutationObserver((t) => {
et(t) && ee();
tt(t) && ee();
}), D.observe(document.body, {

@@ -826,6 +829,6 @@ childList: !0,

}
function ft() {
function gt() {
_ && (document.removeEventListener("focusin", _, !0), _ = null), P && (document.removeEventListener("keydown", P, !0), P = null), A && (window.removeEventListener("scroll", A, !0), window.removeEventListener("resize", A), A = null), D && (D.disconnect(), D = null), x.forEach((t) => t.remove()), x.clear(), Array.from(oe).forEach((t) => ge(t)), M = null, y = null;
}
function gt() {
function pt() {
if (typeof document > "u" || document.getElementById(he)) return;

@@ -836,4 +839,4 @@ const e = document.createElement("style");

.editora-toolbar-group-items.${E},
.rte-toolbar-group-items.${B},
.editora-toolbar-group-items.${B} {
.rte-toolbar-group-items.${C},
.editora-toolbar-group-items.${C} {
display: flex;

@@ -847,4 +850,4 @@ border: 1px solid #cbd5e1;

.editora-toolbar-group-items.${E} .editora-toolbar-button,
.rte-toolbar-group-items.${B} .rte-toolbar-button,
.editora-toolbar-group-items.${B} .editora-toolbar-button {
.rte-toolbar-group-items.${C} .rte-toolbar-button,
.editora-toolbar-group-items.${C} .editora-toolbar-button {
border: none;

@@ -857,4 +860,4 @@ border-right: 1px solid #cbd5e1;

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

@@ -870,4 +873,4 @@ }

${$} .editora-toolbar-group-items.${E},
${$} .rte-toolbar-group-items.${B},
${$} .editora-toolbar-group-items.${B} {
${$} .rte-toolbar-group-items.${C},
${$} .editora-toolbar-group-items.${C} {
border-color: #566275;

@@ -877,4 +880,4 @@ }

${$} .editora-toolbar-group-items.${E} .editora-toolbar-button svg,
${$} .rte-toolbar-group-items.${B} .rte-toolbar-button svg,
${$} .editora-toolbar-group-items.${B} .editora-toolbar-button svg
${$} .rte-toolbar-group-items.${C} .rte-toolbar-button svg,
${$} .editora-toolbar-group-items.${C} .editora-toolbar-button svg
{

@@ -1238,5 +1241,5 @@ fill: none;

}
const pt = (e = {}) => {
const mt = (e = {}) => {
const t = Q(e), r = /* @__PURE__ */ new Set();
return gt(), {
return pt(), {
name: "blocksLibrary",

@@ -1309,3 +1312,3 @@ toolbar: [

if (!n || !o || typeof o != "object") return !1;
const a = b.get(n) || t, s = J.get(n) || Ge(a), i = {
const a = b.get(n) || t, s = J.get(n) || Ue(a), i = {
...s,

@@ -1324,3 +1327,3 @@ ...o,

const g = k(n, c);
return g.filterCache.clear(), typeof o.defaultCategory == "string" && (g.category = ne(c.defaultCategory) || "all"), L(n), N(n), f && be(n, !0), !0;
return g.filterCache.clear(), typeof o.defaultCategory == "string" && (g.category = ne(c.defaultCategory) || "all"), L(n), K(n), f && be(n, !0), !0;
},

@@ -1332,3 +1335,3 @@ getBlocksLibraryState: (o, l) => {

k(n, a);
const s = ct(n);
const s = dt(n);
if (typeof o == "function")

@@ -1356,3 +1359,3 @@ try {

const n = this && typeof this.__pluginConfig == "object" ? { ...e, ...this.__pluginConfig } : e, a = Q(n);
bt(a);
ft(a);
const s = T(

@@ -1363,6 +1366,6 @@ l?.editorElement ? { editorElement: l.editorElement } : void 0,

);
s && (y = s, r.add(s), k(s, a), b.set(s, a), J.set(s, n), I.set(s, a.blocks), O.set(s, Date.now()), N(s));
s && (y = s, r.add(s), k(s, a), b.set(s, a), J.set(s, n), I.set(s, a.blocks), O.set(s, Date.now()), K(s));
},
destroy: () => {
r.forEach((o) => ge(o)), r.clear(), X = Math.max(0, X - 1), !(X > 0) && ft();
r.forEach((o) => ge(o)), r.clear(), X = Math.max(0, X - 1), !(X > 0) && gt();
}

@@ -1372,3 +1375,3 @@ };

export {
pt as BlocksLibraryPlugin
mt as BlocksLibraryPlugin
};

@@ -1,1 +0,1 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=()=>({name:"bold",marks:{bold:{parseDOM:[{tag:"strong"},{tag:"b"},{style:"font-weight",getAttrs:t=>{const o=typeof t=="string"?t:t.style.fontWeight;return/^(bold(er)?|[5-9]\d{2,})$/.test(o)&&null}}],toDOM:()=>["strong",0]}},toolbar:[{label:"Bold",command:"toggleBold",icon:'<svg width="24" height="24" focusable="false"><path d="M7.8 19c-.3 0-.5 0-.6-.2l-.2-.5V5.7c0-.2 0-.4.2-.5l.6-.2h5c1.5 0 2.7.3 3.5 1 .7.6 1.1 1.4 1.1 2.5a3 3 0 0 1-.6 1.9c-.4.6-1 1-1.6 1.2.4.1.9.3 1.3.6s.8.7 1 1.2c.4.4.5 1 .5 1.6 0 1.3-.4 2.3-1.3 3-.8.7-2.1 1-3.8 1H7.8Zm5-8.3c.6 0 1.2-.1 1.6-.5.4-.3.6-.7.6-1.3 0-1.1-.8-1.7-2.3-1.7H9.3v3.5h3.4Zm.5 6c.7 0 1.3-.1 1.7-.4.4-.4.6-.9.6-1.5s-.2-1-.7-1.4c-.4-.3-1-.4-2-.4H9.4v3.8h4Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-b"}],commands:{toggleBold:()=>(document.execCommand("bold",!1),!0)},keymap:{"Mod-b":"toggleBold","Mod-B":"toggleBold"}});exports.BoldPlugin=e;
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./inlineFormatting-DOYOJdnD.js"),l=()=>({name:"bold",marks:{bold:{parseDOM:[{tag:"strong"},{tag:"b"},{style:"font-weight",getAttrs:t=>{const o=typeof t=="string"?t:t.style.fontWeight;return/^(bold(er)?|[5-9]\d{2,})$/.test(o)&&null}}],toDOM:()=>["strong",0]}},toolbar:[{label:"Bold",command:"toggleBold",icon:'<svg width="24" height="24" focusable="false"><path d="M7.8 19c-.3 0-.5 0-.6-.2l-.2-.5V5.7c0-.2 0-.4.2-.5l.6-.2h5c1.5 0 2.7.3 3.5 1 .7.6 1.1 1.4 1.1 2.5a3 3 0 0 1-.6 1.9c-.4.6-1 1-1.6 1.2.4.1.9.3 1.3.6s.8.7 1 1.2c.4.4.5 1 .5 1.6 0 1.3-.4 2.3-1.3 3-.8.7-2.1 1-3.8 1H7.8Zm5-8.3c.6 0 1.2-.1 1.6-.5.4-.3.6-.7.6-1.3 0-1.1-.8-1.7-2.3-1.7H9.3v3.5h3.4Zm.5 6c.7 0 1.3-.1 1.7-.4.4-.4.6-.9.6-1.5s-.2-1-.7-1.4c-.4-.3-1-.4-2-.4H9.4v3.8h4Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-b"}],commands:{toggleBold:(t,o)=>e.applyInlineFormatting({command:"bold",context:o})},keymap:{"Mod-b":"toggleBold","Mod-B":"toggleBold"}});exports.BoldPlugin=l;

@@ -1,2 +0,3 @@

const e = () => ({
import { a as l } from "./inlineFormatting-DuVTGXYG.mjs";
const g = () => ({
name: "bold",

@@ -11,5 +12,5 @@ // Schema definition for bold mark

style: "font-weight",
getAttrs: (t) => {
const o = typeof t == "string" ? t : t.style.fontWeight;
return /^(bold(er)?|[5-9]\d{2,})$/.test(o) && null;
getAttrs: (o) => {
const t = typeof o == "string" ? o : o.style.fontWeight;
return /^(bold(er)?|[5-9]\d{2,})$/.test(t) && null;
}

@@ -35,3 +36,6 @@ }

*/
toggleBold: () => (document.execCommand("bold", !1), !0)
toggleBold: (o, t) => l({
command: "bold",
context: t
})
},

@@ -45,3 +49,3 @@ // Keyboard shortcuts

export {
e as BoldPlugin
g as BoldPlugin
};

@@ -1,1 +0,1 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=()=>{const o=()=>{try{const e=window.getSelection();if(e&&e.rangeCount>0&&!e.isCollapsed){const t=e.getRangeAt(0),r=t.toString().toUpperCase();return t.deleteContents(),t.insertNode(document.createTextNode(r)),!0}return!1}catch(e){return console.error("Failed to convert to uppercase:",e),!1}},a=()=>{try{const e=window.getSelection();if(e&&e.rangeCount>0&&!e.isCollapsed){const t=e.getRangeAt(0),r=t.toString().toLowerCase();return t.deleteContents(),t.insertNode(document.createTextNode(r)),!0}return!1}catch(e){return console.error("Failed to convert to lowercase:",e),!1}},n=()=>{try{const e=window.getSelection();if(e&&e.rangeCount>0&&!e.isCollapsed){const t=e.getRangeAt(0),r=t.toString().replace(/\w\S*/g,l=>l.charAt(0).toUpperCase()+l.substr(1).toLowerCase());return t.deleteContents(),t.insertNode(document.createTextNode(r)),!0}return!1}catch(e){return console.error("Failed to convert to title case:",e),!1}};return{name:"capitalization",toolbar:[{label:"Capitalization",command:"setCapitalization",type:"inline-menu",options:[{label:"lowercase",value:"lowercase"},{label:"UPPERCASE",value:"uppercase"},{label:"Title Case",value:"titlecase"}],icon:'<svg fill="#000000" width="24" height="24" viewBox="0 0 32.00 32.00" id="icon" 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" stroke="#CCCCCC" stroke-width="0.192"></g><g id="SVGRepo_iconCarrier"><defs><style>.cls-1{fill:none;}</style></defs><title>letter--Aa</title><path d="M23,13H18v2h5v2H19a2,2,0,0,0-2,2v2a2,2,0,0,0,2,2h6V15A2,2,0,0,0,23,13Zm0,8H19V19h4Z"></path><path d="M13,9H9a2,2,0,0,0-2,2V23H9V18h4v5h2V11A2,2,0,0,0,13,9ZM9,16V11h4v5Z"></path><rect id="_Transparent_Rectangle_" data-name="&lt;Transparent Rectangle&gt;" class="cls-1" width="32" height="32"></rect></g></svg>'}],commands:{setCapitalization:e=>{if(!e)return!1;switch(e){case"uppercase":return o();case"lowercase":return a();case"titlecase":return n();default:return!1}},toUpperCase:o,toLowerCase:a,toTitleCase:n},keymap:{"Mod-Shift-u":"toUpperCase","Mod-Shift-k":"toLowerCase","Mod-Shift-t":"toTitleCase"}}};exports.CapitalizationPlugin=i;
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f='.rte-content, .editora-content, [contenteditable="true"]',w="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",h=t=>t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null,v=t=>{const e=t?.contentElement;if(e instanceof HTMLElement)return e;const n=t?.editorElement;if(n instanceof HTMLElement){const s=n.querySelector(f);if(s instanceof HTMLElement)return s;if(n.getAttribute("contenteditable")==="true")return n}const r=window.__editoraCommandEditorRoot;if(r instanceof HTMLElement){const s=r.querySelector(f);if(s instanceof HTMLElement)return s;if(r.getAttribute("contenteditable")==="true")return r}const c=window.getSelection();if(c&&c.rangeCount>0){const s=h(c.getRangeAt(0).startContainer),i=s?.closest(f);if(i instanceof HTMLElement)return i;const a=s?.closest(w)?.querySelector(f);if(a instanceof HTMLElement)return a}const l=document.activeElement,u=l instanceof HTMLElement?l.closest(f):null;return u instanceof HTMLElement?u:document.querySelector(f)},R=t=>{const e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed)return null;const n=e.getRangeAt(0);return!t.contains(n.startContainer)||!t.contains(n.endContainer)?null:n},S=(t,e)=>{if(!e.data)return!1;if(typeof t.intersectsNode=="function")try{return t.intersectsNode(e)}catch{return!1}const n=document.createRange();return n.selectNodeContents(e),t.compareBoundaryPoints(Range.END_TO_START,n)<0&&t.compareBoundaryPoints(Range.START_TO_END,n)>0},y=(t,e)=>{const n=[],r=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);let c=r.nextNode();for(;c;){const l=c;if(S(e,l)){const u=l===e.startContainer?e.startOffset:0,s=l===e.endContainer?e.endOffset:l.data.length;u<s&&n.push({node:l,start:u,end:s,text:l.data.slice(u,s)})}c=r.nextNode()}return n},L=t=>new RegExp("\\p{L}","u").test(t),_=t=>/[\p{M}'’-]/u.test(t),x=()=>{let t=!1;return e=>{let n="";return Array.from(e.text).forEach(r=>{if(L(r)){n+=t?r.toLocaleLowerCase():r.toLocaleUpperCase(),t=!0;return}n+=r,_(r)||(t=!1)}),n}},M=t=>{if(t.length===0)return;const e=t[0],n=t[t.length-1],r=window.getSelection();if(!r)return;const c=document.createRange();c.setStart(e.node,e.start),c.setEnd(n.node,n.end),r.removeAllRanges(),r.addRange(c)},b=(t,e,n)=>{if(e!==n){if(typeof window.execEditorCommand=="function"){window.execEditorCommand("recordDomTransaction",t,e,n);return}if(typeof window.executeEditorCommand=="function")try{window.executeEditorCommand("recordDomTransaction",{editor:t,beforeHTML:e,afterHTML:n})}catch{}}},H=()=>{const t=(i,o)=>{try{const a=v(o);if(!a)return!1;const m=R(a);if(!m)return!1;const p=y(a,m);if(p.length===0)return!1;const C=a.innerHTML;p.forEach((d,T)=>{const E=i(d,T);d.node.replaceData(d.start,d.end-d.start,E),d.end=d.start+E.length});const g=a.innerHTML;return C===g?!1:(b(a,C,g),a.dispatchEvent(new window.Event("input",{bubbles:!0})),M(p),!0)}catch(a){return console.error("Failed to transform capitalization:",a),!1}},e=(i,o)=>t(a=>a.text.toLocaleUpperCase(),o),n=(i,o)=>t(a=>a.text.toLocaleLowerCase(),o),r=(i,o)=>t(x(),o),c=(i,o)=>{if(!i)return!1;switch(i){case"uppercase":return e(void 0,o);case"lowercase":return n(void 0,o);case"titlecase":return r(void 0,o);default:return!1}},l=(i,o)=>typeof i=="string"?{value:i,context:o}:typeof o=="string"?{value:o}:{value:void 0,context:o},u=(i,o)=>{if(o&&typeof o=="object"&&!o.doc)return o},s=i=>(o,a)=>i(void 0,u(o,a));return{name:"capitalization",toolbar:[{label:"Capitalization",command:"setCapitalization",type:"inline-menu",options:[{label:"lowercase",value:"lowercase"},{label:"UPPERCASE",value:"uppercase"},{label:"Title Case",value:"titlecase"}],icon:'<svg fill="#000000" width="24" height="24" viewBox="0 0 32.00 32.00" id="icon" 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" stroke="#CCCCCC" stroke-width="0.192"></g><g id="SVGRepo_iconCarrier"><defs><style>.cls-1{fill:none;}</style></defs><title>letter--Aa</title><path d="M23,13H18v2h5v2H19a2,2,0,0,0-2,2v2a2,2,0,0,0,2,2h6V15A2,2,0,0,0,23,13Zm0,8H19V19h4Z"></path><path d="M13,9H9a2,2,0,0,0-2,2V23H9V18h4v5h2V11A2,2,0,0,0,13,9ZM9,16V11h4v5Z"></path><rect id="_Transparent_Rectangle_" data-name="&lt;Transparent Rectangle&gt;" class="cls-1" width="32" height="32"></rect></g></svg>'}],commands:{setCapitalization:(i,o)=>{const{value:a,context:m}=l(i,o);return c(a,m)},toUpperCase:s(e),toLowerCase:s(n),toTitleCase:s(r)},keymap:{"Mod-Shift-u":"toUpperCase","Mod-Shift-k":"toLowerCase","Mod-Shift-t":"toTitleCase"}}};exports.CapitalizationPlugin=H;

@@ -1,36 +0,125 @@

const i = () => {
const o = () => {
const f = '.rte-content, .editora-content, [contenteditable="true"]', w = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", h = (t) => t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null, v = (t) => {
const e = t?.contentElement;
if (e instanceof HTMLElement) return e;
const n = t?.editorElement;
if (n instanceof HTMLElement) {
const s = n.querySelector(f);
if (s instanceof HTMLElement) return s;
if (n.getAttribute("contenteditable") === "true") return n;
}
const r = window.__editoraCommandEditorRoot;
if (r instanceof HTMLElement) {
const s = r.querySelector(f);
if (s instanceof HTMLElement) return s;
if (r.getAttribute("contenteditable") === "true") return r;
}
const c = window.getSelection();
if (c && c.rangeCount > 0) {
const s = h(c.getRangeAt(0).startContainer), i = s?.closest(f);
if (i instanceof HTMLElement) return i;
const a = s?.closest(w)?.querySelector(f);
if (a instanceof HTMLElement) return a;
}
const l = document.activeElement, d = l instanceof HTMLElement ? l.closest(f) : null;
return d instanceof HTMLElement ? d : document.querySelector(f);
}, R = (t) => {
const e = window.getSelection();
if (!e || e.rangeCount === 0 || e.isCollapsed) return null;
const n = e.getRangeAt(0);
return !t.contains(n.startContainer) || !t.contains(n.endContainer) ? null : n;
}, S = (t, e) => {
if (!e.data) return !1;
if (typeof t.intersectsNode == "function")
try {
const e = window.getSelection();
if (e && e.rangeCount > 0 && !e.isCollapsed) {
const t = e.getRangeAt(0), r = t.toString().toUpperCase();
return t.deleteContents(), t.insertNode(document.createTextNode(r)), !0;
}
return t.intersectsNode(e);
} catch {
return !1;
} catch (e) {
return console.error("Failed to convert to uppercase:", e), !1;
}
}, a = () => {
try {
const e = window.getSelection();
if (e && e.rangeCount > 0 && !e.isCollapsed) {
const t = e.getRangeAt(0), r = t.toString().toLowerCase();
return t.deleteContents(), t.insertNode(document.createTextNode(r)), !0;
const n = document.createRange();
return n.selectNodeContents(e), t.compareBoundaryPoints(Range.END_TO_START, n) < 0 && t.compareBoundaryPoints(Range.START_TO_END, n) > 0;
}, L = (t, e) => {
const n = [], r = document.createTreeWalker(t, NodeFilter.SHOW_TEXT);
let c = r.nextNode();
for (; c; ) {
const l = c;
if (S(e, l)) {
const d = l === e.startContainer ? e.startOffset : 0, s = l === e.endContainer ? e.endOffset : l.data.length;
d < s && n.push({
node: l,
start: d,
end: s,
text: l.data.slice(d, s)
});
}
c = r.nextNode();
}
return n;
}, x = (t) => new RegExp("\\p{L}", "u").test(t), y = (t) => /[\p{M}'’-]/u.test(t), _ = () => {
let t = !1;
return (e) => {
let n = "";
return Array.from(e.text).forEach((r) => {
if (x(r)) {
n += t ? r.toLocaleLowerCase() : r.toLocaleUpperCase(), t = !0;
return;
}
return !1;
} catch (e) {
return console.error("Failed to convert to lowercase:", e), !1;
n += r, y(r) || (t = !1);
}), n;
};
}, M = (t) => {
if (t.length === 0) return;
const e = t[0], n = t[t.length - 1], r = window.getSelection();
if (!r) return;
const c = document.createRange();
c.setStart(e.node, e.start), c.setEnd(n.node, n.end), r.removeAllRanges(), r.addRange(c);
}, H = (t, e, n) => {
if (e !== n) {
if (typeof window.execEditorCommand == "function") {
window.execEditorCommand("recordDomTransaction", t, e, n);
return;
}
}, n = () => {
if (typeof window.executeEditorCommand == "function")
try {
window.executeEditorCommand("recordDomTransaction", { editor: t, beforeHTML: e, afterHTML: n });
} catch {
}
}
}, N = () => {
const t = (i, o) => {
try {
const e = window.getSelection();
if (e && e.rangeCount > 0 && !e.isCollapsed) {
const t = e.getRangeAt(0), r = t.toString().replace(/\w\S*/g, (l) => l.charAt(0).toUpperCase() + l.substr(1).toLowerCase());
return t.deleteContents(), t.insertNode(document.createTextNode(r)), !0;
}
return !1;
} catch (e) {
return console.error("Failed to convert to title case:", e), !1;
const a = v(o);
if (!a) return !1;
const m = R(a);
if (!m) return !1;
const p = L(a, m);
if (p.length === 0) return !1;
const C = a.innerHTML;
p.forEach((u, T) => {
const E = i(u, T);
u.node.replaceData(u.start, u.end - u.start, E), u.end = u.start + E.length;
});
const g = a.innerHTML;
return C === g ? !1 : (H(a, C, g), a.dispatchEvent(new window.Event("input", { bubbles: !0 })), M(p), !0);
} catch (a) {
return console.error("Failed to transform capitalization:", a), !1;
}
};
}, e = (i, o) => t((a) => a.text.toLocaleUpperCase(), o), n = (i, o) => t((a) => a.text.toLocaleLowerCase(), o), r = (i, o) => t(_(), o), c = (i, o) => {
if (!i) return !1;
switch (i) {
case "uppercase":
return e(void 0, o);
case "lowercase":
return n(void 0, o);
case "titlecase":
return r(void 0, o);
default:
return !1;
}
}, l = (i, o) => typeof i == "string" ? { value: i, context: o } : typeof o == "string" ? { value: o } : {
value: void 0,
context: o
}, d = (i, o) => {
if (o && typeof o == "object" && !o.doc)
return o;
}, s = (i) => (o, a) => i(void 0, d(o, a));
return {

@@ -52,18 +141,9 @@ name: "capitalization",

commands: {
setCapitalization: (e) => {
if (!e) return !1;
switch (e) {
case "uppercase":
return o();
case "lowercase":
return a();
case "titlecase":
return n();
default:
return !1;
}
setCapitalization: (i, o) => {
const { value: a, context: m } = l(i, o);
return c(a, m);
},
toUpperCase: o,
toLowerCase: a,
toTitleCase: n
toUpperCase: s(e),
toLowerCase: s(n),
toTitleCase: s(r)
},

@@ -78,3 +158,3 @@ keymap: {

export {
i as CapitalizationPlugin
N as CapitalizationPlugin
};

@@ -1,1 +0,1 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const N="__editoraCommandEditorRoot",w=e=>{if(!e)return null;const t=e.querySelector('[contenteditable="true"]');return t instanceof HTMLElement?t:null},A=()=>{if(typeof window>"u")return null;const e=window[N];if(!(e instanceof HTMLElement))return null;window[N]=null;const t=e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?e:null);if(t){const r=w(t);if(r)return r;if(t.getAttribute("contenteditable")==="true")return t}if(e.getAttribute("contenteditable")==="true")return e;const n=e.closest('[contenteditable="true"]');return n instanceof HTMLElement?n:null},_=()=>{const e=A();if(e&&document.contains(e))return e;const t=window.getSelection();if(t&&t.rangeCount>0){let r=t.getRangeAt(0).startContainer;for(;r&&r!==document.body;){if(r.nodeType===Node.ELEMENT_NODE){const o=r;if(o.getAttribute("contenteditable")==="true")return o}r=r.parentNode}}const n=document.activeElement;if(n){if(n.getAttribute("contenteditable")==="true")return n;const r=n.closest('[contenteditable="true"]');if(r)return r}return document.querySelector('[contenteditable="true"]')},S=e=>e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null,H=e=>{const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return e.contains(n.commonAncestorContainer)?n:null},y=e=>{e.dispatchEvent(new Event("input",{bubbles:!0}))},M=(e,t)=>{if(t===e.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",e,t,e.innerHTML)}catch{}},k=(e,t)=>{if(!e.isConnected){t.focus({preventScroll:!0});return}const n=window.getSelection();if(!n)return;const r=document.createRange();r.selectNodeContents(e),r.collapse(!1),n.removeAllRanges();try{n.addRange(r)}catch{t.focus({preventScroll:!0});return}t.focus({preventScroll:!0})},v=e=>{let t=e.querySelector(":scope > p");if(!t){t=document.createElement("p");const n=[];e.childNodes.forEach(r=>{r.nodeType===Node.ELEMENT_NODE&&["UL","OL"].includes(r.tagName)||n.push(r)}),n.forEach(r=>t.appendChild(r)),e.insertBefore(t,e.firstChild)}return t.innerHTML.trim()||(t.innerHTML="<br>"),t},C=e=>{const t=document.createElement("li");t.setAttribute("data-type","checklist-item"),t.setAttribute("data-checked","false");const n=document.createElement("p");return n.innerHTML=e.trim()||"<br>",t.appendChild(n),t},T=e=>Array.from(e.children).filter(t=>t instanceof HTMLLIElement),I=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","LI"]),b=e=>I.has(e.tagName)&&e.getAttribute("contenteditable")!=="true",R=(e,t)=>{const n=[],r=new Set,o=i=>{!i||r.has(i)||t.contains(i)&&b(i)&&(i.closest("ul, ol")||(r.add(i),n.push(i)))},u=i=>{let a=i;for(;a&&a!==document.body;){if(a.nodeType===Node.ELEMENT_NODE){const h=a;if(b(h))return h;if(h.getAttribute("contenteditable")==="true")break}a=a.parentNode}return null};if(e.collapsed)return o(u(e.startContainer)),n;const d=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>{const a=i;if(!b(a)||a.closest("ul, ol"))return NodeFilter.FILTER_SKIP;if(typeof e.intersectsNode=="function")return e.intersectsNode(a)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP;const h=document.createRange();return h.selectNodeContents(a),e.compareBoundaryPoints(Range.END_TO_START,h)>0&&e.compareBoundaryPoints(Range.START_TO_END,h)<0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});let l=d.nextNode();for(;l;)o(l),l=d.nextNode();if(n.length===0&&o(u(e.commonAncestorContainer)),n.length<=1)return n;const m=n.filter(i=>!n.some(a=>a!==i&&i.contains(a)));return m.length>0?m:n},O=e=>{const t=[],n=document.createElement("div"),r=()=>{const o=n.innerHTML.trim();if(!o)return;const u=document.createElement("p");u.innerHTML=o,t.push(u),n.innerHTML=""};if(e.childNodes.forEach(o=>{if(o.nodeType===Node.ELEMENT_NODE&&["UL","OL"].includes(o.tagName)){r();return}if(o.nodeType===Node.ELEMENT_NODE&&o.tagName==="P"){r();const u=o.innerHTML.trim(),d=document.createElement("p");d.innerHTML=u||"<br>",t.push(d);return}o.nodeType===Node.TEXT_NODE&&!(o.textContent||"").trim()||n.appendChild(o.cloneNode(!0))}),r(),t.length===0){const o=document.createElement("p");o.innerHTML="<br>",t.push(o)}return t},P=()=>({name:"checklist",init:()=>{if(typeof document>"u"||typeof window>"u"||window.__checklistPluginClickInitialized)return;window.__checklistPluginClickInitialized=!0;const e=t=>{const r=t.target.closest('li[data-type="checklist-item"]');if(!r)return;const o=r.getBoundingClientRect();if(!(t.clientX-o.left<32))return;t.preventDefault(),t.stopPropagation();const l=r.closest("[contenteditable], .rte-content, .editora-content");if(l?.getAttribute("contenteditable")==="false"||!!l?.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]'))return;const i=l?.innerHTML||"",a=r.getAttribute("data-checked")==="true";r.setAttribute("data-checked",(!a).toString()),l&&(M(l,i),y(l))};document.addEventListener("click",e)},nodes:{checklist:{content:"checklistItem+",group:"block",parseDOM:[{tag:'ul[data-type="checklist"]'}],toDOM:()=>["ul",{"data-type":"checklist"},0]},checklistItem:{content:"paragraph",attrs:{checked:{default:!1}},parseDOM:[{tag:'li[data-type="checklist-item"]',getAttrs:e=>({checked:e.getAttribute("data-checked")==="true"})}],toDOM:e=>["li",{"data-type":"checklist-item","data-checked":e?.attrs?.checked?"true":"false"},0]}},toolbar:[{label:"Checklist",command:"toggleChecklist",icon:'<svg width="24px" height="24px" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="#000000"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.75 4.48h-.71L2 3.43l.71-.7.69.68L4.81 2l.71.71-1.77 1.77zM6.99 3h8v1h-8V3zm0 3h8v1h-8V6zm8 3h-8v1h8V9zm-8 3h8v1h-8v-1zM3.04 7.48h.71l1.77-1.77-.71-.7L3.4 6.42l-.69-.69-.71.71 1.04 1.04zm.71 3.01h-.71L2 9.45l.71-.71.69.69 1.41-1.42.71.71-1.77 1.77zm-.71 3.01h.71l1.77-1.77-.71-.71-1.41 1.42-.69-.69-.71.7 1.04 1.05z"></path></g></svg>',shortcut:"Mod-Shift-9"}],commands:{toggleChecklist:()=>{try{const e=_();if(!e)return!1;const t=e.innerHTML,n=()=>(M(e,t),y(e),!0),r=H(e);if(!r)return!1;const o=S(r.startContainer);if(!o)return!1;const u=o.closest('ul[data-type="checklist"]');if(u&&e.contains(u)){const c=T(u);if(c.length===0)return!1;const p=document.createDocumentFragment();let s=null;return c.forEach((f,g)=>{const E=O(f);E.forEach(L=>{p.appendChild(L),!s&&(f.contains(r.startContainer)||g===0)&&(s=L)}),!s&&g===0&&E[0]&&(s=E[0])}),u.replaceWith(p),s&&k(s,e),n()}const d=o.closest("ul, ol");if(d&&e.contains(d)){let c;if(d.tagName.toLowerCase()==="ul")c=d;else{for(c=document.createElement("ul");d.firstChild;)c.appendChild(d.firstChild);d.replaceWith(c)}c.setAttribute("data-type","checklist");let p=T(c);p.length===0&&(c.appendChild(C("")),p=T(c));let s=null;p.forEach(g=>{g.setAttribute("data-type","checklist-item"),g.hasAttribute("data-checked")||g.setAttribute("data-checked","false");const E=v(g);g.contains(r.startContainer)&&(s=E)});const f=c.querySelector(':scope > li[data-type="checklist-item"] > p');return k(s||f||c,e),n()}const l=R(r,e);if(l.length>1){const c=document.createElement("ul");c.setAttribute("data-type","checklist"),l.forEach(f=>{c.appendChild(C(f.innerHTML))}),l[0].replaceWith(c),l.slice(1).forEach(f=>{f.isConnected&&f.remove()});const s=c.querySelector(':scope > li[data-type="checklist-item"] > p');return s&&k(s,e),n()}const m=l[0]||o.closest("p, h1, h2, h3, h4, h5, h6, blockquote, pre");if(m&&m!==e){const c=document.createElement("ul");c.setAttribute("data-type","checklist");const p=C(m.innerHTML);c.appendChild(p),m.replaceWith(c);const s=p.querySelector(":scope > p");return s&&k(s,e),n()}const i=document.createElement("ul");i.setAttribute("data-type","checklist");const a=C("");i.appendChild(a),r.deleteContents(),r.insertNode(i);const h=a.querySelector(":scope > p");return h&&k(h,e),n()}catch(e){return console.error("Failed to toggle checklist:",e),!1}}},keymap:{"Mod-Shift-9":"toggleChecklist"}});exports.ChecklistPlugin=P;
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const M="__editoraCommandEditorRoot",H=e=>{if(!e)return null;const t=e.querySelector('[contenteditable="true"]');return t instanceof HTMLElement?t:null},R=()=>{if(typeof window>"u")return null;const e=window[M];if(!(e instanceof HTMLElement))return null;window[M]=null;const t=e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?e:null);if(t){const n=H(t);if(n)return n;if(t.getAttribute("contenteditable")==="true")return t}if(e.getAttribute("contenteditable")==="true")return e;const r=e.closest('[contenteditable="true"]');return r instanceof HTMLElement?r:null},_=()=>{const e=R();if(e&&document.contains(e))return e;const t=window.getSelection();if(t&&t.rangeCount>0){let n=t.getRangeAt(0).startContainer;for(;n&&n!==document.body;){if(n.nodeType===Node.ELEMENT_NODE){const o=n;if(o.getAttribute("contenteditable")==="true")return o}n=n.parentNode}}const r=document.activeElement;if(r){if(r.getAttribute("contenteditable")==="true")return r;const n=r.closest('[contenteditable="true"]');if(n)return n}return document.querySelector('[contenteditable="true"]')},A=e=>e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null,I=e=>{const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=t.getRangeAt(0);return e.contains(r.commonAncestorContainer)?r:null},T=e=>{e.dispatchEvent(new Event("input",{bubbles:!0}))},b=(e,t)=>{if(t===e.innerHTML)return;const r=window.execEditorCommand||window.executeEditorCommand;if(typeof r=="function")try{r("recordDomTransaction",e,t,e.innerHTML)}catch{}},C=(e,t)=>{if(!e.isConnected){t.focus({preventScroll:!0});return}const r=window.getSelection();if(!r)return;const n=document.createRange();n.selectNodeContents(e),n.collapse(!1),r.removeAllRanges();try{r.addRange(n)}catch{t.focus({preventScroll:!0});return}t.focus({preventScroll:!0})},N=e=>{let t=e.querySelector(":scope > p");if(!t){t=document.createElement("p");const r=[];e.childNodes.forEach(n=>{n.nodeType===Node.ELEMENT_NODE&&["UL","OL"].includes(n.tagName)||r.push(n)}),r.forEach(n=>t.appendChild(n)),e.insertBefore(t,e.firstChild)}return t.innerHTML.trim()||(t.innerHTML="<br>"),t},v=e=>(e.textContent||"").replace(/\u200B/g,"").trim()?!1:!e.querySelector("img, video, table, iframe, hr, pre, ul, ol"),P=()=>{const e=document.createElement("p");return e.innerHTML="<br>",e},S=(e,t)=>{if(!e.isConnected){t.focus({preventScroll:!0});return}const r=window.getSelection();if(!r)return;const n=document.createRange();n.selectNodeContents(e),n.collapse(!0),r.removeAllRanges();try{r.addRange(n)}catch{t.focus({preventScroll:!0});return}t.focus({preventScroll:!0})},x=(e,t)=>{e.appendChild(t),e.innerHTML.trim()||(e.innerHTML="<br>")},O=(e,t,r)=>{const n=P();t.parentNode?.insertBefore(n,t.nextSibling),r.remove(),y(t).length===0&&t.remove(),S(n,e)},D=(e,t,r)=>{const n=N(t),o=r.cloneRange();o.deleteContents();const i=document.createRange();i.setStart(o.startContainer,o.startOffset),i.setEndAfter(n.lastChild||n);const d=document.createDocumentFragment();try{d.appendChild(i.extractContents())}catch{}n.innerHTML.trim()||(n.innerHTML="<br>");const c=document.createElement("li");c.setAttribute("data-type","checklist-item"),c.setAttribute("data-checked","false");const h=document.createElement("p");x(h,d),c.appendChild(h),t.parentNode?.insertBefore(c,t.nextSibling),S(h,e)},k=e=>{const t=document.createElement("li");t.setAttribute("data-type","checklist-item"),t.setAttribute("data-checked","false");const r=document.createElement("p");return r.innerHTML=e.trim()||"<br>",t.appendChild(r),t},y=e=>Array.from(e.children).filter(t=>t instanceof HTMLLIElement),F=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","LI"]),L=e=>F.has(e.tagName)&&e.getAttribute("contenteditable")!=="true",B=(e,t)=>{const r=[],n=new Set,o=s=>{!s||n.has(s)||t.contains(s)&&L(s)&&(s.closest("ul, ol")||(n.add(s),r.push(s)))},i=s=>{let l=s;for(;l&&l!==document.body;){if(l.nodeType===Node.ELEMENT_NODE){const p=l;if(L(p))return p;if(p.getAttribute("contenteditable")==="true")break}l=l.parentNode}return null};if(e.collapsed)return o(i(e.startContainer)),r;const d=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const l=s;if(!L(l)||l.closest("ul, ol"))return NodeFilter.FILTER_SKIP;if(typeof e.intersectsNode=="function")return e.intersectsNode(l)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP;const p=document.createRange();return p.selectNodeContents(l),e.compareBoundaryPoints(Range.END_TO_START,p)>0&&e.compareBoundaryPoints(Range.START_TO_END,p)<0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});let c=d.nextNode();for(;c;)o(c),c=d.nextNode();if(r.length===0&&o(i(e.commonAncestorContainer)),r.length<=1)return r;const h=r.filter(s=>!r.some(l=>l!==s&&s.contains(l)));return h.length>0?h:r},K=e=>{const t=[],r=document.createElement("div"),n=()=>{const o=r.innerHTML.trim();if(!o)return;const i=document.createElement("p");i.innerHTML=o,t.push(i),r.innerHTML=""};if(e.childNodes.forEach(o=>{if(o.nodeType===Node.ELEMENT_NODE&&["UL","OL"].includes(o.tagName)){n();return}if(o.nodeType===Node.ELEMENT_NODE&&o.tagName==="P"){n();const i=o.innerHTML.trim(),d=document.createElement("p");d.innerHTML=i||"<br>",t.push(d);return}o.nodeType===Node.TEXT_NODE&&!(o.textContent||"").trim()||r.appendChild(o.cloneNode(!0))}),n(),t.length===0){const o=document.createElement("p");o.innerHTML="<br>",t.push(o)}return t},z=()=>({name:"checklist",init:()=>{if(!(typeof document>"u"||typeof window>"u")){if(!window.__checklistPluginClickInitialized){window.__checklistPluginClickInitialized=!0;const e=t=>{const n=t.target.closest('li[data-type="checklist-item"]');if(!n)return;const o=n.getBoundingClientRect();if(!(t.clientX-o.left<32))return;t.preventDefault(),t.stopPropagation();const c=n.closest("[contenteditable], .rte-content, .editora-content");if(c?.getAttribute("contenteditable")==="false"||!!c?.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]'))return;const s=c?.innerHTML||"",l=n.getAttribute("data-checked")==="true";n.setAttribute("data-checked",(!l).toString()),c&&(b(c,s),T(c))};document.addEventListener("click",e)}if(!window.__checklistPluginKeydownInitialized){window.__checklistPluginKeydownInitialized=!0;const e=t=>{if(t.key!=="Enter"||t.shiftKey||t.altKey||t.ctrlKey||t.metaKey||t.defaultPrevented)return;const r=window.getSelection();if(!r||r.rangeCount===0)return;const n=r.getRangeAt(0),i=A(n.startContainer)?.closest('li[data-type="checklist-item"]');if(!i)return;const d=i.closest('ul[data-type="checklist"]');if(!d)return;const c=i.closest("[contenteditable], .rte-content, .editora-content");if(!c||c.getAttribute("contenteditable")==="false"||!!c.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]'))return;t.preventDefault();const s=c.innerHTML,l=N(i);v(l)?O(c,d,i):D(c,i,n),b(c,s),T(c)};document.addEventListener("keydown",e)}}},nodes:{checklist:{content:"checklistItem+",group:"block",parseDOM:[{tag:'ul[data-type="checklist"]'}],toDOM:()=>["ul",{"data-type":"checklist"},0]},checklistItem:{content:"paragraph",attrs:{checked:{default:!1}},parseDOM:[{tag:'li[data-type="checklist-item"]',getAttrs:e=>({checked:e.getAttribute("data-checked")==="true"})}],toDOM:e=>["li",{"data-type":"checklist-item","data-checked":e?.attrs?.checked?"true":"false"},0]}},toolbar:[{label:"Checklist",command:"toggleChecklist",icon:'<svg width="24px" height="24px" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="#000000"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.75 4.48h-.71L2 3.43l.71-.7.69.68L4.81 2l.71.71-1.77 1.77zM6.99 3h8v1h-8V3zm0 3h8v1h-8V6zm8 3h-8v1h8V9zm-8 3h8v1h-8v-1zM3.04 7.48h.71l1.77-1.77-.71-.7L3.4 6.42l-.69-.69-.71.71 1.04 1.04zm.71 3.01h-.71L2 9.45l.71-.71.69.69 1.41-1.42.71.71-1.77 1.77zm-.71 3.01h.71l1.77-1.77-.71-.71-1.41 1.42-.69-.69-.71.7 1.04 1.05z"></path></g></svg>',shortcut:"Mod-Shift-9"}],commands:{toggleChecklist:()=>{try{const e=_();if(!e)return!1;const t=e.innerHTML,r=()=>(b(e,t),T(e),!0),n=I(e);if(!n)return!1;const o=A(n.startContainer);if(!o)return!1;const i=o.closest('ul[data-type="checklist"]');if(i&&e.contains(i)){const a=y(i);if(a.length===0)return!1;const f=document.createDocumentFragment();let u=null;return a.forEach((m,g)=>{const E=K(m);E.forEach(w=>{f.appendChild(w),!u&&(m.contains(n.startContainer)||g===0)&&(u=w)}),!u&&g===0&&E[0]&&(u=E[0])}),i.replaceWith(f),u&&C(u,e),r()}const d=o.closest("ul, ol");if(d&&e.contains(d)){let a;if(d.tagName.toLowerCase()==="ul")a=d;else{for(a=document.createElement("ul");d.firstChild;)a.appendChild(d.firstChild);d.replaceWith(a)}a.setAttribute("data-type","checklist");let f=y(a);f.length===0&&(a.appendChild(k("")),f=y(a));let u=null;f.forEach(g=>{g.setAttribute("data-type","checklist-item"),g.hasAttribute("data-checked")||g.setAttribute("data-checked","false");const E=N(g);g.contains(n.startContainer)&&(u=E)});const m=a.querySelector(':scope > li[data-type="checklist-item"] > p');return C(u||m||a,e),r()}const c=B(n,e);if(c.length>1){const a=document.createElement("ul");a.setAttribute("data-type","checklist"),c.forEach(m=>{a.appendChild(k(m.innerHTML))}),c[0].replaceWith(a),c.slice(1).forEach(m=>{m.isConnected&&m.remove()});const u=a.querySelector(':scope > li[data-type="checklist-item"] > p');return u&&C(u,e),r()}const h=c[0]||o.closest("p, h1, h2, h3, h4, h5, h6, blockquote, pre");if(h&&h!==e){const a=document.createElement("ul");a.setAttribute("data-type","checklist");const f=k(h.innerHTML);a.appendChild(f),h.replaceWith(a);const u=f.querySelector(":scope > p");return u&&C(u,e),r()}const s=document.createElement("ul");s.setAttribute("data-type","checklist");const l=k("");s.appendChild(l),n.deleteContents(),n.insertNode(s);const p=l.querySelector(":scope > p");return p&&C(p,e),r()}catch(e){return console.error("Failed to toggle checklist:",e),!1}}},keymap:{"Mod-Shift-9":"toggleChecklist"}});exports.ChecklistPlugin=z;

@@ -1,93 +0,132 @@

const N = "__editoraCommandEditorRoot", w = (t) => {
if (!t) return null;
const e = t.querySelector('[contenteditable="true"]');
return e instanceof HTMLElement ? e : null;
}, A = () => {
const M = "__editoraCommandEditorRoot", H = (e) => {
if (!e) return null;
const t = e.querySelector('[contenteditable="true"]');
return t instanceof HTMLElement ? t : null;
}, R = () => {
if (typeof window > "u") return null;
const t = window[N];
if (!(t instanceof HTMLElement)) return null;
window[N] = null;
const e = t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (t.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? t : null);
if (e) {
const r = w(e);
if (r) return r;
if (e.getAttribute("contenteditable") === "true") return e;
const e = window[M];
if (!(e instanceof HTMLElement)) return null;
window[M] = null;
const t = e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? e : null);
if (t) {
const n = H(t);
if (n) return n;
if (t.getAttribute("contenteditable") === "true") return t;
}
if (t.getAttribute("contenteditable") === "true")
return t;
const n = t.closest('[contenteditable="true"]');
return n instanceof HTMLElement ? n : null;
if (e.getAttribute("contenteditable") === "true")
return e;
const r = e.closest('[contenteditable="true"]');
return r instanceof HTMLElement ? r : null;
}, _ = () => {
const t = A();
if (t && document.contains(t))
return t;
const e = window.getSelection();
if (e && e.rangeCount > 0) {
let r = e.getRangeAt(0).startContainer;
for (; r && r !== document.body; ) {
if (r.nodeType === Node.ELEMENT_NODE) {
const o = r;
const e = R();
if (e && document.contains(e))
return e;
const t = window.getSelection();
if (t && t.rangeCount > 0) {
let n = t.getRangeAt(0).startContainer;
for (; n && n !== document.body; ) {
if (n.nodeType === Node.ELEMENT_NODE) {
const o = n;
if (o.getAttribute("contenteditable") === "true")
return o;
}
r = r.parentNode;
n = n.parentNode;
}
}
const n = document.activeElement;
if (n) {
if (n.getAttribute("contenteditable") === "true")
return n;
const r = n.closest('[contenteditable="true"]');
if (r) return r;
const r = document.activeElement;
if (r) {
if (r.getAttribute("contenteditable") === "true")
return r;
const n = r.closest('[contenteditable="true"]');
if (n) return n;
}
return document.querySelector('[contenteditable="true"]');
}, H = (t) => t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null, S = (t) => {
const e = window.getSelection();
if (!e || e.rangeCount === 0) return null;
const n = e.getRangeAt(0);
return t.contains(n.commonAncestorContainer) ? n : null;
}, y = (t) => {
t.dispatchEvent(new Event("input", { bubbles: !0 }));
}, M = (t, e) => {
if (e === t.innerHTML) return;
const n = window.execEditorCommand || window.executeEditorCommand;
if (typeof n == "function")
}, A = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null, I = (e) => {
const t = window.getSelection();
if (!t || t.rangeCount === 0) return null;
const r = t.getRangeAt(0);
return e.contains(r.commonAncestorContainer) ? r : null;
}, T = (e) => {
e.dispatchEvent(new Event("input", { bubbles: !0 }));
}, b = (e, t) => {
if (t === e.innerHTML) return;
const r = window.execEditorCommand || window.executeEditorCommand;
if (typeof r == "function")
try {
n("recordDomTransaction", t, e, t.innerHTML);
r("recordDomTransaction", e, t, e.innerHTML);
} catch {
}
}, k = (t, e) => {
if (!t.isConnected) {
e.focus({ preventScroll: !0 });
}, C = (e, t) => {
if (!e.isConnected) {
t.focus({ preventScroll: !0 });
return;
}
const n = window.getSelection();
if (!n) return;
const r = document.createRange();
r.selectNodeContents(t), r.collapse(!1), n.removeAllRanges();
const r = window.getSelection();
if (!r) return;
const n = document.createRange();
n.selectNodeContents(e), n.collapse(!1), r.removeAllRanges();
try {
n.addRange(r);
r.addRange(n);
} catch {
e.focus({ preventScroll: !0 });
t.focus({ preventScroll: !0 });
return;
}
e.focus({ preventScroll: !0 });
}, I = (t) => {
let e = t.querySelector(":scope > p");
if (!e) {
e = document.createElement("p");
const n = [];
t.childNodes.forEach((r) => {
r.nodeType === Node.ELEMENT_NODE && ["UL", "OL"].includes(r.tagName) || n.push(r);
}), n.forEach((r) => e.appendChild(r)), t.insertBefore(e, t.firstChild);
t.focus({ preventScroll: !0 });
}, N = (e) => {
let t = e.querySelector(":scope > p");
if (!t) {
t = document.createElement("p");
const r = [];
e.childNodes.forEach((n) => {
n.nodeType === Node.ELEMENT_NODE && ["UL", "OL"].includes(n.tagName) || r.push(n);
}), r.forEach((n) => t.appendChild(n)), e.insertBefore(t, e.firstChild);
}
return e.innerHTML.trim() || (e.innerHTML = "<br>"), e;
}, C = (t) => {
const e = document.createElement("li");
e.setAttribute("data-type", "checklist-item"), e.setAttribute("data-checked", "false");
const n = document.createElement("p");
return n.innerHTML = t.trim() || "<br>", e.appendChild(n), e;
}, T = (t) => Array.from(t.children).filter(
(e) => e instanceof HTMLLIElement
), R = /* @__PURE__ */ new Set([
return t.innerHTML.trim() || (t.innerHTML = "<br>"), t;
}, v = (e) => (e.textContent || "").replace(/\u200B/g, "").trim() ? !1 : !e.querySelector("img, video, table, iframe, hr, pre, ul, ol"), x = () => {
const e = document.createElement("p");
return e.innerHTML = "<br>", e;
}, S = (e, t) => {
if (!e.isConnected) {
t.focus({ preventScroll: !0 });
return;
}
const r = window.getSelection();
if (!r) return;
const n = document.createRange();
n.selectNodeContents(e), n.collapse(!0), r.removeAllRanges();
try {
r.addRange(n);
} catch {
t.focus({ preventScroll: !0 });
return;
}
t.focus({ preventScroll: !0 });
}, P = (e, t) => {
e.appendChild(t), e.innerHTML.trim() || (e.innerHTML = "<br>");
}, D = (e, t, r) => {
const n = x();
t.parentNode?.insertBefore(n, t.nextSibling), r.remove(), y(t).length === 0 && t.remove(), S(n, e);
}, O = (e, t, r) => {
const n = N(t), o = r.cloneRange();
o.deleteContents();
const i = document.createRange();
i.setStart(o.startContainer, o.startOffset), i.setEndAfter(n.lastChild || n);
const d = document.createDocumentFragment();
try {
d.appendChild(i.extractContents());
} catch {
}
n.innerHTML.trim() || (n.innerHTML = "<br>");
const c = document.createElement("li");
c.setAttribute("data-type", "checklist-item"), c.setAttribute("data-checked", "false");
const h = document.createElement("p");
P(h, d), c.appendChild(h), t.parentNode?.insertBefore(c, t.nextSibling), S(h, e);
}, k = (e) => {
const t = document.createElement("li");
t.setAttribute("data-type", "checklist-item"), t.setAttribute("data-checked", "false");
const r = document.createElement("p");
return r.innerHTML = e.trim() || "<br>", t.appendChild(r), t;
}, y = (e) => Array.from(e.children).filter(
(t) => t instanceof HTMLLIElement
), F = /* @__PURE__ */ new Set([
"P",

@@ -104,82 +143,103 @@ "DIV",

"LI"
]), b = (t) => R.has(t.tagName) && t.getAttribute("contenteditable") !== "true", v = (t, e) => {
const n = [], r = /* @__PURE__ */ new Set(), o = (i) => {
!i || r.has(i) || e.contains(i) && b(i) && (i.closest("ul, ol") || (r.add(i), n.push(i)));
}, u = (i) => {
let a = i;
for (; a && a !== document.body; ) {
if (a.nodeType === Node.ELEMENT_NODE) {
const h = a;
if (b(h)) return h;
if (h.getAttribute("contenteditable") === "true") break;
]), L = (e) => F.has(e.tagName) && e.getAttribute("contenteditable") !== "true", B = (e, t) => {
const r = [], n = /* @__PURE__ */ new Set(), o = (s) => {
!s || n.has(s) || t.contains(s) && L(s) && (s.closest("ul, ol") || (n.add(s), r.push(s)));
}, i = (s) => {
let l = s;
for (; l && l !== document.body; ) {
if (l.nodeType === Node.ELEMENT_NODE) {
const p = l;
if (L(p)) return p;
if (p.getAttribute("contenteditable") === "true") break;
}
a = a.parentNode;
l = l.parentNode;
}
return null;
};
if (t.collapsed)
return o(u(t.startContainer)), n;
if (e.collapsed)
return o(i(e.startContainer)), r;
const d = document.createTreeWalker(
e,
t,
NodeFilter.SHOW_ELEMENT,
{
acceptNode: (i) => {
const a = i;
if (!b(a) || a.closest("ul, ol")) return NodeFilter.FILTER_SKIP;
if (typeof t.intersectsNode == "function")
return t.intersectsNode(a) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
const h = document.createRange();
return h.selectNodeContents(a), t.compareBoundaryPoints(Range.END_TO_START, h) > 0 && t.compareBoundaryPoints(Range.START_TO_END, h) < 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
acceptNode: (s) => {
const l = s;
if (!L(l) || l.closest("ul, ol")) return NodeFilter.FILTER_SKIP;
if (typeof e.intersectsNode == "function")
return e.intersectsNode(l) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
const p = document.createRange();
return p.selectNodeContents(l), e.compareBoundaryPoints(Range.END_TO_START, p) > 0 && e.compareBoundaryPoints(Range.START_TO_END, p) < 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
}
}
);
let l = d.nextNode();
for (; l; )
o(l), l = d.nextNode();
if (n.length === 0 && o(u(t.commonAncestorContainer)), n.length <= 1)
return n;
const m = n.filter((i) => !n.some((a) => a !== i && i.contains(a)));
return m.length > 0 ? m : n;
}, O = (t) => {
const e = [], n = document.createElement("div"), r = () => {
const o = n.innerHTML.trim();
let c = d.nextNode();
for (; c; )
o(c), c = d.nextNode();
if (r.length === 0 && o(i(e.commonAncestorContainer)), r.length <= 1)
return r;
const h = r.filter((s) => !r.some((l) => l !== s && s.contains(l)));
return h.length > 0 ? h : r;
}, K = (e) => {
const t = [], r = document.createElement("div"), n = () => {
const o = r.innerHTML.trim();
if (!o) return;
const u = document.createElement("p");
u.innerHTML = o, e.push(u), n.innerHTML = "";
const i = document.createElement("p");
i.innerHTML = o, t.push(i), r.innerHTML = "";
};
if (t.childNodes.forEach((o) => {
if (e.childNodes.forEach((o) => {
if (o.nodeType === Node.ELEMENT_NODE && ["UL", "OL"].includes(o.tagName)) {
r();
n();
return;
}
if (o.nodeType === Node.ELEMENT_NODE && o.tagName === "P") {
r();
const u = o.innerHTML.trim(), d = document.createElement("p");
d.innerHTML = u || "<br>", e.push(d);
n();
const i = o.innerHTML.trim(), d = document.createElement("p");
d.innerHTML = i || "<br>", t.push(d);
return;
}
o.nodeType === Node.TEXT_NODE && !(o.textContent || "").trim() || n.appendChild(o.cloneNode(!0));
}), r(), e.length === 0) {
o.nodeType === Node.TEXT_NODE && !(o.textContent || "").trim() || r.appendChild(o.cloneNode(!0));
}), n(), t.length === 0) {
const o = document.createElement("p");
o.innerHTML = "<br>", e.push(o);
o.innerHTML = "<br>", t.push(o);
}
return e;
}, D = () => ({
return t;
}, z = () => ({
name: "checklist",
// Initialize click handler when plugin is loaded
init: () => {
if (typeof document > "u" || typeof window > "u" || window.__checklistPluginClickInitialized) return;
window.__checklistPluginClickInitialized = !0;
const t = (e) => {
const r = e.target.closest('li[data-type="checklist-item"]');
if (!r) return;
const o = r.getBoundingClientRect();
if (!(e.clientX - o.left < 32)) return;
e.preventDefault(), e.stopPropagation();
const l = r.closest("[contenteditable], .rte-content, .editora-content");
if (l?.getAttribute("contenteditable") === "false" || !!l?.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]')) return;
const i = l?.innerHTML || "", a = r.getAttribute("data-checked") === "true";
r.setAttribute("data-checked", (!a).toString()), l && (M(l, i), y(l));
};
document.addEventListener("click", t);
if (!(typeof document > "u" || typeof window > "u")) {
if (!window.__checklistPluginClickInitialized) {
window.__checklistPluginClickInitialized = !0;
const e = (t) => {
const n = t.target.closest('li[data-type="checklist-item"]');
if (!n) return;
const o = n.getBoundingClientRect();
if (!(t.clientX - o.left < 32)) return;
t.preventDefault(), t.stopPropagation();
const c = n.closest("[contenteditable], .rte-content, .editora-content");
if (c?.getAttribute("contenteditable") === "false" || !!c?.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]')) return;
const s = c?.innerHTML || "", l = n.getAttribute("data-checked") === "true";
n.setAttribute("data-checked", (!l).toString()), c && (b(c, s), T(c));
};
document.addEventListener("click", e);
}
if (!window.__checklistPluginKeydownInitialized) {
window.__checklistPluginKeydownInitialized = !0;
const e = (t) => {
if (t.key !== "Enter" || t.shiftKey || t.altKey || t.ctrlKey || t.metaKey || t.defaultPrevented) return;
const r = window.getSelection();
if (!r || r.rangeCount === 0) return;
const n = r.getRangeAt(0), i = A(n.startContainer)?.closest('li[data-type="checklist-item"]');
if (!i) return;
const d = i.closest('ul[data-type="checklist"]');
if (!d) return;
const c = i.closest("[contenteditable], .rte-content, .editora-content");
if (!c || c.getAttribute("contenteditable") === "false" || !!c.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]')) return;
t.preventDefault();
const s = c.innerHTML, l = N(i);
v(l) ? D(c, d, i) : O(c, i, n), b(c, s), T(c);
};
document.addEventListener("keydown", e);
}
}
},

@@ -202,12 +262,12 @@ // Schema definition for checklist nodes

tag: 'li[data-type="checklist-item"]',
getAttrs: (t) => ({
checked: t.getAttribute("data-checked") === "true"
getAttrs: (e) => ({
checked: e.getAttribute("data-checked") === "true"
})
}
],
toDOM: (t) => [
toDOM: (e) => [
"li",
{
"data-type": "checklist-item",
"data-checked": t?.attrs?.checked ? "true" : "false"
"data-checked": e?.attrs?.checked ? "true" : "false"
},

@@ -229,71 +289,71 @@ 0

try {
const t = _();
if (!t) return !1;
const e = t.innerHTML, n = () => (M(t, e), y(t), !0), r = S(t);
if (!r) return !1;
const o = H(r.startContainer);
const e = _();
if (!e) return !1;
const t = e.innerHTML, r = () => (b(e, t), T(e), !0), n = I(e);
if (!n) return !1;
const o = A(n.startContainer);
if (!o) return !1;
const u = o.closest('ul[data-type="checklist"]');
if (u && t.contains(u)) {
const c = T(u);
if (c.length === 0) return !1;
const p = document.createDocumentFragment();
let s = null;
return c.forEach((f, g) => {
const E = O(f);
E.forEach((L) => {
p.appendChild(L), !s && (f.contains(r.startContainer) || g === 0) && (s = L);
}), !s && g === 0 && E[0] && (s = E[0]);
}), u.replaceWith(p), s && k(s, t), n();
const i = o.closest('ul[data-type="checklist"]');
if (i && e.contains(i)) {
const a = y(i);
if (a.length === 0) return !1;
const f = document.createDocumentFragment();
let u = null;
return a.forEach((m, g) => {
const E = K(m);
E.forEach((w) => {
f.appendChild(w), !u && (m.contains(n.startContainer) || g === 0) && (u = w);
}), !u && g === 0 && E[0] && (u = E[0]);
}), i.replaceWith(f), u && C(u, e), r();
}
const d = o.closest("ul, ol");
if (d && t.contains(d)) {
let c;
if (d && e.contains(d)) {
let a;
if (d.tagName.toLowerCase() === "ul")
c = d;
a = d;
else {
for (c = document.createElement("ul"); d.firstChild; )
c.appendChild(d.firstChild);
d.replaceWith(c);
for (a = document.createElement("ul"); d.firstChild; )
a.appendChild(d.firstChild);
d.replaceWith(a);
}
c.setAttribute("data-type", "checklist");
let p = T(c);
p.length === 0 && (c.appendChild(C("")), p = T(c));
let s = null;
p.forEach((g) => {
a.setAttribute("data-type", "checklist");
let f = y(a);
f.length === 0 && (a.appendChild(k("")), f = y(a));
let u = null;
f.forEach((g) => {
g.setAttribute("data-type", "checklist-item"), g.hasAttribute("data-checked") || g.setAttribute("data-checked", "false");
const E = I(g);
g.contains(r.startContainer) && (s = E);
const E = N(g);
g.contains(n.startContainer) && (u = E);
});
const f = c.querySelector(':scope > li[data-type="checklist-item"] > p');
return k(s || f || c, t), n();
const m = a.querySelector(':scope > li[data-type="checklist-item"] > p');
return C(u || m || a, e), r();
}
const l = v(r, t);
if (l.length > 1) {
const c = document.createElement("ul");
c.setAttribute("data-type", "checklist"), l.forEach((f) => {
c.appendChild(C(f.innerHTML));
}), l[0].replaceWith(c), l.slice(1).forEach((f) => {
f.isConnected && f.remove();
const c = B(n, e);
if (c.length > 1) {
const a = document.createElement("ul");
a.setAttribute("data-type", "checklist"), c.forEach((m) => {
a.appendChild(k(m.innerHTML));
}), c[0].replaceWith(a), c.slice(1).forEach((m) => {
m.isConnected && m.remove();
});
const s = c.querySelector(':scope > li[data-type="checklist-item"] > p');
return s && k(s, t), n();
const u = a.querySelector(':scope > li[data-type="checklist-item"] > p');
return u && C(u, e), r();
}
const m = l[0] || o.closest("p, h1, h2, h3, h4, h5, h6, blockquote, pre");
if (m && m !== t) {
const c = document.createElement("ul");
c.setAttribute("data-type", "checklist");
const p = C(m.innerHTML);
c.appendChild(p), m.replaceWith(c);
const s = p.querySelector(":scope > p");
return s && k(s, t), n();
const h = c[0] || o.closest("p, h1, h2, h3, h4, h5, h6, blockquote, pre");
if (h && h !== e) {
const a = document.createElement("ul");
a.setAttribute("data-type", "checklist");
const f = k(h.innerHTML);
a.appendChild(f), h.replaceWith(a);
const u = f.querySelector(":scope > p");
return u && C(u, e), r();
}
const i = document.createElement("ul");
i.setAttribute("data-type", "checklist");
const a = C("");
i.appendChild(a), r.deleteContents(), r.insertNode(i);
const h = a.querySelector(":scope > p");
return h && k(h, t), n();
} catch (t) {
return console.error("Failed to toggle checklist:", t), !1;
const s = document.createElement("ul");
s.setAttribute("data-type", "checklist");
const l = k("");
s.appendChild(l), n.deleteContents(), n.insertNode(s);
const p = l.querySelector(":scope > p");
return p && C(p, e), r();
} catch (e) {
return console.error("Failed to toggle checklist:", e), !1;
}

@@ -307,3 +367,3 @@ }

export {
D as ChecklistPlugin
z as ChecklistPlugin
};

@@ -1,2 +0,2 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const E=".rte-content, .editora-content",mt="rte-citations-styles",b="rte-citations-panel",ot=".rte-citation-ref[data-citation-id]",W='.rte-citation-bibliography[data-type="citation-bibliography"]',G='.rte-citation-footnotes[data-type="citation-footnotes"]',x=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',L=["apa","mla","chicago"],Bt={panelTitle:"Citations",panelAriaLabel:"Citations panel",styleLabel:"Citation style",authorLabel:"Author",yearLabel:"Year",titleLabel:"Title",sourceLabel:"Source",urlLabel:"URL",noteLabel:"Footnote note",insertText:"Insert Citation",refreshText:"Refresh Bibliography",closeText:"Close",bibliographyTitle:"References",footnotesTitle:"Citation Notes",noCitationsText:"No citations inserted yet.",styleButtonPrefix:"Style",recentHeading:"Recent citations",deleteRecentText:"x",summaryPrefix:"Citations",invalidMessage:"Author and title are required."},f=new WeakMap,T=new WeakMap,pt=new WeakMap,D=new WeakMap,v=new Map,V=new WeakMap,Q=new WeakMap,q=new Set;let I=null,B=null,O=null,k=null,Y=0,Ot=0,at=0,M=null,p=null;function g(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Pt(t){return t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function ht(t,e){const n=e(t);if(!n)return"";const i=n.match(/\d{4}/);return i?i[0]:n}function xt(t,e){const n=e(t);return n?/^https?:\/\//i.test(n)?n:`https://${n}`:""}function F(t){return t.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function yt(t,e){return{id:F(e.normalizeText(t.id||"")),author:e.normalizeText(t.author||""),year:ht(t.year||"",e.normalizeText)||void 0,title:e.normalizeText(t.title||""),source:e.normalizeText(t.source||"")||void 0,url:xt(t.url||"",e.normalizeText)||void 0,note:e.normalizeText(t.note||"")||void 0}}function Z(t={}){const e=t.defaultStyle&&L.includes(t.defaultStyle)?t.defaultStyle:"apa",n={...Bt,...t.labels||{}};return{defaultStyle:e,enableFootnoteSync:t.enableFootnoteSync!==!1,debounceMs:Math.max(80,Number(t.debounceMs??220)),maxRecentCitations:Math.max(3,Math.min(30,Number(t.maxRecentCitations??8))),labels:n,normalizeText:t.normalizeText||Pt,generateCitationId:typeof t.generateCitationId=="function"?t.generateCitationId:void 0}}function Ct(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function lt(t){return t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||t}function X(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function Dt(t){const e=lt(t);if(X(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return X(n)?!0:X(document.documentElement)||X(document.body)}function tt(t,e){t.classList.remove("rte-citations-theme-dark"),Dt(e)&&t.classList.add("rte-citations-theme-dark")}function h(t,e=!0){if(t?.contentElement instanceof HTMLElement)return t.contentElement;if(t?.editorElement instanceof HTMLElement){const o=t.editorElement;if(o.matches(E))return o;const r=o.querySelector(E);if(r instanceof HTMLElement)return r}const n=window.getSelection();if(n&&n.rangeCount>0){const o=n.getRangeAt(0).startContainer,a=Ct(o)?.closest(E);if(a)return a}const i=document.activeElement;if(i){if(i.matches(E))return i;const o=i.closest(E);if(o)return o}return p&&p.isConnected?p:(p&&!p.isConnected&&(p=null),e?document.querySelector(E):null)}function $(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function j(t){const e=Ct(t);return e?!!(e.closest(W)||e.closest(G)):!1}function Ht(t,e){if(at+=1,e.generateCitationId){const n=e.generateCitationId({editor:t,index:at}),i=F(e.normalizeText(n||""));if(i)return i}return`cite-${Date.now().toString(36)}-${at.toString(36)}`}function st(t){return t.map(e=>(e||"").trim()).filter(Boolean).join(" ").trim()}function Ft(t,e){const n=t.author||"Unknown",i=t.year||"n.d.";return e==="mla"?`(${n} ${i})`:e==="chicago"?`(${n} ${i})`:`(${n}, ${i})`}function ut(t,e){const n=t.author||"Unknown",i=t.year||"n.d.",o=t.title||"Untitled",r=t.source||"",a=t.url||"";return st(e==="mla"?[`${n}.`,`"${o}."`,r?`${r},`:"",`${i}.`,a]:e==="chicago"?[`${n}.`,`${o}.`,r?`${r}.`:"",`(${i}).`,a]:[`${n}.`,`(${i}).`,`${o}.`,r?`${r}.`:"",a])}function R(t){return Array.from(t.querySelectorAll(ot)).filter(e=>!e.closest(W)&&!e.closest(G))}function wt(t,e){const n=F(e.normalizeText(t.getAttribute("data-citation-id")||""));if(!n)return null;const i=e.normalizeText(t.getAttribute("data-citation-author")||""),o=e.normalizeText(t.getAttribute("data-citation-title")||"");return{id:n,author:i||"Unknown",year:ht(t.getAttribute("data-citation-year")||"",e.normalizeText)||void 0,title:o||"Untitled",source:e.normalizeText(t.getAttribute("data-citation-source")||"")||void 0,url:xt(t.getAttribute("data-citation-url")||"",e.normalizeText)||void 0,note:e.normalizeText(t.getAttribute("data-citation-note")||"")||void 0}}function vt(t,e,n){t.classList.add("rte-citation-ref"),t.setAttribute("data-citation-id",e.id),t.setAttribute("data-citation-author",e.author||""),t.setAttribute("data-citation-year",e.year||""),t.setAttribute("data-citation-title",e.title||""),t.setAttribute("data-citation-source",e.source||""),t.setAttribute("data-citation-url",e.url||""),t.setAttribute("data-citation-note",e.note||""),t.setAttribute("contenteditable","false"),t.setAttribute("tabindex","0"),t.setAttribute("role","doc-biblioref"),t.setAttribute("data-style",n),t.textContent=Ft(e,n)}function it(t,e,n){const i=lt(t);Array.from(i.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(r=>{r.classList.toggle("active",n),r.setAttribute("data-active",n?"true":"false"),r.setAttribute("aria-pressed",n?"true":"false")})}function N(t,e){const n=T.get(t);return n&&L.includes(n)?n:e?.defaultStyle||"apa"}function K(t,e){const n=R(t),i=new Map;return n.forEach(o=>{const r=wt(o,e);if(!r)return;if(!i.has(r.id)){i.set(r.id,r);return}const a=i.get(r.id);i.set(r.id,{...a,author:a.author||r.author,title:a.title||r.title,year:a.year||r.year,source:a.source||r.source,url:a.url||r.url,note:a.note||r.note})}),Array.from(i.values())}function _t(t,e,n){const i=yt(e,n);if(!i.id||!i.author||!i.title)return;const r=(D.get(t)||[]).filter(a=>a.id!==i.id);D.set(t,[i,...r].slice(0,n.maxRecentCitations))}function rt(t,e,n){const i=D.get(t)||[],o=new Map;e.slice(Math.max(0,e.length-n.maxRecentCitations)).reverse().forEach(a=>{a.id&&o.set(a.id,a)}),i.forEach(a=>{!a.id||o.has(a.id)||o.set(a.id,a)});const r=Array.from(o.values()).slice(0,n.maxRecentCitations);return D.set(t,r),r}function St(t,e,n,i){const o=F(i.normalizeText(e||""));return o&&rt(t,n,i).find(a=>a.id===o)||null}function qt(t,e,n){const i=F(n.normalizeText(e||""));if(!i)return!1;const o=D.get(t)||[],r=o.filter(a=>a.id!==i);return r.length===o.length?!1:(D.set(t,r),!0)}function Et(t,e,n){const i=document.createElement("section");i.className=t,i.setAttribute("data-type",e),i.setAttribute("contenteditable","false"),i.setAttribute("aria-label",n),e==="citation-bibliography"?i.setAttribute("role","doc-bibliography"):e==="citation-footnotes"&&i.setAttribute("role","doc-endnotes");const o=document.createElement("h3");o.className="rte-citation-section-title",o.textContent=n;const r=document.createElement("ol");return r.className="rte-citation-list",r.setAttribute("role","list"),i.appendChild(o),i.appendChild(r),i}function jt(t,e){let n=t.querySelector(W);n||(n=Et("rte-citation-bibliography","citation-bibliography",e.labels.bibliographyTitle),t.appendChild(n));const i=n.querySelector(".rte-citation-section-title");return i&&(i.textContent=e.labels.bibliographyTitle),n.setAttribute("aria-label",e.labels.bibliographyTitle),n}function Kt(t,e){let n=t.querySelector(G);n||(n=Et("rte-citation-footnotes","citation-footnotes",e.labels.footnotesTitle),t.appendChild(n));const i=n.querySelector(".rte-citation-section-title");return i&&(i.textContent=e.labels.footnotesTitle),n.setAttribute("aria-label",e.labels.footnotesTitle),n}function $t(t,e){t.querySelector(e)?.remove()}function Ut(t,e,n,i){if(e.length===0){$t(t,W);return}const r=jt(t,n).querySelector(".rte-citation-list");if(!r)return;const a=document.createDocumentFragment();e.forEach((s,u)=>{const c=document.createElement("li");c.className="rte-citation-item",c.id=`rte-citation-entry-${s.id}`,c.setAttribute("data-citation-id",s.id),c.setAttribute("data-citation-number",String(u+1)),c.textContent=ut(s,i),a.appendChild(c)}),r.innerHTML="",r.appendChild(a)}function Wt(t,e,n,i){if(!n.enableFootnoteSync||e.length===0){$t(t,G),R(t).forEach(l=>{l.removeAttribute("data-footnote-number"),l.removeAttribute("data-footnote-target")});return}const r=Kt(t,n).querySelector(".rte-citation-list");if(!r)return;const a=new Map,s=new Map;e.forEach((l,d)=>{s.set(l.id,d+1)});const u=new Map;R(t).forEach(l=>{const d=l.getAttribute("data-citation-id")||"";if(!d||!s.has(d))return;const m=(u.get(d)||0)+1;u.set(d,m);const w=`rte-citation-ref-${d}-${m}`;l.id=w;const A=s.get(d);l.setAttribute("data-footnote-number",String(A)),l.setAttribute("data-footnote-target",`rte-citation-note-${d}`),a.has(d)||a.set(d,w)});const c=document.createDocumentFragment();e.forEach((l,d)=>{const m=document.createElement("li");m.className="rte-citation-item rte-citation-footnote-item",m.id=`rte-citation-note-${l.id}`,m.setAttribute("data-citation-id",l.id);const w=document.createElement("span");w.className="rte-citation-footnote-number",w.textContent=`${d+1}. `;const A=document.createElement("span");A.className="rte-citation-footnote-text";const It=l.note?`${l.note}. `:"";A.textContent=`${It}${ut(l,i)}`,m.appendChild(w),m.appendChild(A);const gt=a.get(l.id);if(gt){const _=document.createElement("a");_.className="rte-citation-backref",_.href=`#${gt}`,_.setAttribute("aria-label",`Back to citation ${d+1}`),_.textContent="Back",m.appendChild(_)}c.appendChild(m)}),r.innerHTML="",r.appendChild(c)}function Gt(t,e,n,i){const o=ut(e,n);t.setAttribute("data-citation-number",String(i)),t.setAttribute("aria-label",`Citation ${i}: ${o}`)}function Vt(t,e,n){const i=R(t);let o=`${e}:${n?"1":"0"}:${i.length}`;return i.forEach(r=>{o+=`|${r.getAttribute("data-citation-id")||""}`,o+=`|${r.getAttribute("data-citation-author")||""}`,o+=`|${r.getAttribute("data-citation-year")||""}`,o+=`|${r.getAttribute("data-citation-title")||""}`,o+=`|${r.getAttribute("data-citation-source")||""}`,o+=`|${r.getAttribute("data-citation-url")||""}`,o+=`|${r.getAttribute("data-citation-note")||""}`}),o}function H(t){const e=v.get(t);if(!e)return;const n=f.get(t)||M;if(!n)return;const i=N(t,n),o=K(t,n),r=rt(t,o,n),a=e.querySelector(".rte-citations-status"),s=e.querySelector('[data-action="cycle-style"]'),u=e.querySelector(".rte-citations-recent-list");if(a){const c=o.length;a.textContent=`${n.labels.summaryPrefix}: ${c} | Style: ${i.toUpperCase()} | Footnotes: ${n.enableFootnoteSync?"On":"Off"}`}if(s&&(s.textContent=`${n.labels.styleButtonPrefix}: ${i.toUpperCase()}`,s.setAttribute("aria-label",`${n.labels.styleButtonPrefix}: ${i.toUpperCase()}`)),u){if(r.length===0){u.innerHTML=`<li class="rte-citations-empty">${g(n.labels.noCitationsText)}</li>`;return}u.innerHTML=r.map(c=>`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const S=".rte-content, .editora-content",pt="rte-citations-styles",b="rte-citations-panel",ot=".rte-citation-ref[data-citation-id]",W='.rte-citation-bibliography[data-type="citation-bibliography"]',G='.rte-citation-footnotes[data-type="citation-footnotes"]',x=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',L=["apa","mla","chicago"],Ot={panelTitle:"Citations",panelAriaLabel:"Citations panel",styleLabel:"Citation style",authorLabel:"Author",yearLabel:"Year",titleLabel:"Title",sourceLabel:"Source",urlLabel:"URL",noteLabel:"Footnote note",insertText:"Insert Citation",refreshText:"Refresh Bibliography",closeText:"Close",bibliographyTitle:"References",footnotesTitle:"Citation Notes",noCitationsText:"No citations inserted yet.",styleButtonPrefix:"Style",recentHeading:"Recent citations",deleteRecentText:"x",summaryPrefix:"Citations",invalidMessage:"Author and title are required."},f=new WeakMap,T=new WeakMap,ht=new WeakMap,D=new WeakMap,w=new Map,V=new WeakMap,Q=new WeakMap,q=new Set;let I=null,B=null,O=null,k=null,Y=0,Pt=0,at=0,M=null,p=null;function g(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Dt(t){return t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function xt(t,e){const n=e(t);if(!n)return"";const i=n.match(/\d{4}/);return i?i[0]:n}function yt(t,e){const n=e(t);return n?/^https?:\/\//i.test(n)?n:`https://${n}`:""}function F(t){return t.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function Ct(t,e){return{id:F(e.normalizeText(t.id||"")),author:e.normalizeText(t.author||""),year:xt(t.year||"",e.normalizeText)||void 0,title:e.normalizeText(t.title||""),source:e.normalizeText(t.source||"")||void 0,url:yt(t.url||"",e.normalizeText)||void 0,note:e.normalizeText(t.note||"")||void 0}}function Z(t={}){const e=t.defaultStyle&&L.includes(t.defaultStyle)?t.defaultStyle:"apa",n={...Ot,...t.labels||{}};return{defaultStyle:e,enableFootnoteSync:t.enableFootnoteSync!==!1,debounceMs:Math.max(80,Number(t.debounceMs??220)),maxRecentCitations:Math.max(3,Math.min(30,Number(t.maxRecentCitations??8))),labels:n,normalizeText:t.normalizeText||Dt,generateCitationId:typeof t.generateCitationId=="function"?t.generateCitationId:void 0}}function vt(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function lt(t){return t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||t}function X(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function Ht(t){const e=lt(t);if(X(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return X(n)?!0:X(document.documentElement)||X(document.body)}function tt(t,e){t.classList.remove("rte-citations-theme-dark"),Ht(e)&&t.classList.add("rte-citations-theme-dark")}function h(t,e=!0){if(t?.contentElement instanceof HTMLElement)return t.contentElement;if(t?.editorElement instanceof HTMLElement){const o=t.editorElement;if(o.matches(S))return o;const r=o.querySelector(S);if(r instanceof HTMLElement)return r}const n=window.getSelection();if(n&&n.rangeCount>0){const o=n.getRangeAt(0).startContainer,a=vt(o)?.closest(S);if(a)return a}const i=document.activeElement;if(i){if(i.matches(S))return i;const o=i.closest(S);if(o)return o}return p&&p.isConnected?p:(p&&!p.isConnected&&(p=null),e?document.querySelector(S):null)}function $(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function K(t){const e=vt(t);return e?!!(e.closest(W)||e.closest(G)):!1}function Ft(t,e){if(at+=1,e.generateCitationId){const n=e.generateCitationId({editor:t,index:at}),i=F(e.normalizeText(n||""));if(i)return i}return`cite-${Date.now().toString(36)}-${at.toString(36)}`}function st(t){return t.map(e=>(e||"").trim()).filter(Boolean).join(" ").trim()}function _t(t,e){const n=t.author||"Unknown",i=t.year||"n.d.";return e==="mla"?`(${n} ${i})`:e==="chicago"?`(${n} ${i})`:`(${n}, ${i})`}function ut(t,e){const n=t.author||"Unknown",i=t.year||"n.d.",o=t.title||"Untitled",r=t.source||"",a=t.url||"";return st(e==="mla"?[`${n}.`,`"${o}."`,r?`${r},`:"",`${i}.`,a]:e==="chicago"?[`${n}.`,`${o}.`,r?`${r}.`:"",`(${i}).`,a]:[`${n}.`,`(${i}).`,`${o}.`,r?`${r}.`:"",a])}function R(t){return Array.from(t.querySelectorAll(ot)).filter(e=>!e.closest(W)&&!e.closest(G))}function wt(t,e){const n=F(e.normalizeText(t.getAttribute("data-citation-id")||""));if(!n)return null;const i=e.normalizeText(t.getAttribute("data-citation-author")||""),o=e.normalizeText(t.getAttribute("data-citation-title")||"");return{id:n,author:i||"Unknown",year:xt(t.getAttribute("data-citation-year")||"",e.normalizeText)||void 0,title:o||"Untitled",source:e.normalizeText(t.getAttribute("data-citation-source")||"")||void 0,url:yt(t.getAttribute("data-citation-url")||"",e.normalizeText)||void 0,note:e.normalizeText(t.getAttribute("data-citation-note")||"")||void 0}}function Et(t,e,n){t.classList.add("rte-citation-ref"),t.setAttribute("data-citation-id",e.id),t.setAttribute("data-citation-author",e.author||""),t.setAttribute("data-citation-year",e.year||""),t.setAttribute("data-citation-title",e.title||""),t.setAttribute("data-citation-source",e.source||""),t.setAttribute("data-citation-url",e.url||""),t.setAttribute("data-citation-note",e.note||""),t.setAttribute("contenteditable","false"),t.setAttribute("tabindex","0"),t.setAttribute("role","doc-biblioref"),t.setAttribute("data-style",n),t.textContent=_t(e,n)}function it(t,e,n){const i=lt(t);Array.from(i.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(r=>{r.classList.toggle("active",n),r.setAttribute("data-active",n?"true":"false"),r.setAttribute("aria-pressed",n?"true":"false")})}function N(t,e){const n=T.get(t);return n&&L.includes(n)?n:e?.defaultStyle||"apa"}function j(t,e){const n=R(t),i=new Map;return n.forEach(o=>{const r=wt(o,e);if(!r)return;if(!i.has(r.id)){i.set(r.id,r);return}const a=i.get(r.id);i.set(r.id,{...a,author:a.author||r.author,title:a.title||r.title,year:a.year||r.year,source:a.source||r.source,url:a.url||r.url,note:a.note||r.note})}),Array.from(i.values())}function qt(t,e,n){const i=Ct(e,n);if(!i.id||!i.author||!i.title)return;const r=(D.get(t)||[]).filter(a=>a.id!==i.id);D.set(t,[i,...r].slice(0,n.maxRecentCitations))}function rt(t,e,n){const i=D.get(t)||[],o=new Map;e.slice(Math.max(0,e.length-n.maxRecentCitations)).reverse().forEach(a=>{a.id&&o.set(a.id,a)}),i.forEach(a=>{!a.id||o.has(a.id)||o.set(a.id,a)});const r=Array.from(o.values()).slice(0,n.maxRecentCitations);return D.set(t,r),r}function St(t,e,n,i){const o=F(i.normalizeText(e||""));return o&&rt(t,n,i).find(a=>a.id===o)||null}function Kt(t,e,n){const i=F(n.normalizeText(e||""));if(!i)return!1;const o=D.get(t)||[],r=o.filter(a=>a.id!==i);return r.length===o.length?!1:(D.set(t,r),!0)}function $t(t,e,n){const i=document.createElement("section");i.className=t,i.setAttribute("data-type",e),i.setAttribute("contenteditable","false"),i.setAttribute("aria-label",n),e==="citation-bibliography"?i.setAttribute("role","doc-bibliography"):e==="citation-footnotes"&&i.setAttribute("role","doc-endnotes");const o=document.createElement("h3");o.className="rte-citation-section-title",o.textContent=n;const r=document.createElement("ol");return r.className="rte-citation-list",r.setAttribute("role","list"),i.appendChild(o),i.appendChild(r),i}function jt(t,e){let n=t.querySelector(W);n||(n=$t("rte-citation-bibliography","citation-bibliography",e.labels.bibliographyTitle),t.appendChild(n));const i=n.querySelector(".rte-citation-section-title");return i&&(i.textContent=e.labels.bibliographyTitle),n.setAttribute("aria-label",e.labels.bibliographyTitle),n}function Ut(t,e){let n=t.querySelector(G);n||(n=$t("rte-citation-footnotes","citation-footnotes",e.labels.footnotesTitle),t.appendChild(n));const i=n.querySelector(".rte-citation-section-title");return i&&(i.textContent=e.labels.footnotesTitle),n.setAttribute("aria-label",e.labels.footnotesTitle),n}function At(t,e){t.querySelector(e)?.remove()}function Wt(t,e,n,i){if(e.length===0){At(t,W);return}const r=jt(t,n).querySelector(".rte-citation-list");if(!r)return;const a=document.createDocumentFragment();e.forEach((s,u)=>{const c=document.createElement("li");c.className="rte-citation-item",c.id=`rte-citation-entry-${s.id}`,c.setAttribute("data-citation-id",s.id),c.setAttribute("data-citation-number",String(u+1)),c.textContent=ut(s,i),a.appendChild(c)}),r.innerHTML="",r.appendChild(a)}function Gt(t,e,n,i){if(!n.enableFootnoteSync||e.length===0){At(t,G),R(t).forEach(l=>{l.removeAttribute("data-footnote-number"),l.removeAttribute("data-footnote-target")});return}const r=Ut(t,n).querySelector(".rte-citation-list");if(!r)return;const a=new Map,s=new Map;e.forEach((l,d)=>{s.set(l.id,d+1)});const u=new Map;R(t).forEach(l=>{const d=l.getAttribute("data-citation-id")||"";if(!d||!s.has(d))return;const m=(u.get(d)||0)+1;u.set(d,m);const v=`rte-citation-ref-${d}-${m}`;l.id=v;const A=s.get(d);l.setAttribute("data-footnote-number",String(A)),l.setAttribute("data-footnote-target",`rte-citation-note-${d}`),a.has(d)||a.set(d,v)});const c=document.createDocumentFragment();e.forEach((l,d)=>{const m=document.createElement("li");m.className="rte-citation-item rte-citation-footnote-item",m.id=`rte-citation-note-${l.id}`,m.setAttribute("data-citation-id",l.id);const v=document.createElement("span");v.className="rte-citation-footnote-number",v.textContent=`${d+1}. `;const A=document.createElement("span");A.className="rte-citation-footnote-text";const Bt=l.note?`${l.note}. `:"";A.textContent=`${Bt}${ut(l,i)}`,m.appendChild(v),m.appendChild(A);const mt=a.get(l.id);if(mt){const _=document.createElement("a");_.className="rte-citation-backref",_.href=`#${mt}`,_.setAttribute("aria-label",`Back to citation ${d+1}`),_.textContent="Back",m.appendChild(_)}c.appendChild(m)}),r.innerHTML="",r.appendChild(c)}function Vt(t,e,n,i){const o=ut(e,n);t.setAttribute("data-citation-number",String(i)),t.setAttribute("aria-label",`Citation ${i}: ${o}`)}function Yt(t,e,n){const i=R(t);let o=`${e}:${n?"1":"0"}:${i.length}`;return i.forEach(r=>{o+=`|${r.getAttribute("data-citation-id")||""}`,o+=`|${r.getAttribute("data-citation-author")||""}`,o+=`|${r.getAttribute("data-citation-year")||""}`,o+=`|${r.getAttribute("data-citation-title")||""}`,o+=`|${r.getAttribute("data-citation-source")||""}`,o+=`|${r.getAttribute("data-citation-url")||""}`,o+=`|${r.getAttribute("data-citation-note")||""}`}),o}function H(t){const e=w.get(t);if(!e)return;const n=f.get(t)||M;if(!n)return;const i=N(t,n),o=j(t,n),r=rt(t,o,n),a=e.querySelector(".rte-citations-status"),s=e.querySelector('[data-action="cycle-style"]'),u=e.querySelector(".rte-citations-recent-list");if(a){const c=o.length;a.textContent=`${n.labels.summaryPrefix}: ${c} | Style: ${i.toUpperCase()} | Footnotes: ${n.enableFootnoteSync?"On":"Off"}`}if(s&&(s.textContent=`${n.labels.styleButtonPrefix}: ${i.toUpperCase()}`,s.setAttribute("aria-label",`${n.labels.styleButtonPrefix}: ${i.toUpperCase()}`)),u){if(r.length===0){u.innerHTML=`<li class="rte-citations-empty">${g(n.labels.noCitationsText)}</li>`;return}u.innerHTML=r.map(c=>`
<li class="rte-citations-recent-item">

@@ -23,3 +23,3 @@ <div class="rte-citations-recent-row">

</li>
`).join("")}}function y(t,e,n=!1){const i=N(t,e),o=Vt(t,i,e.enableFootnoteSync);if(!n&&pt.get(t)===o)return K(t,e);const r=R(t),a=new Map;r.forEach(c=>{const l=wt(c,e);l&&(a.has(l.id)||a.set(l.id,l))});const s=Array.from(a.values());rt(t,s,e);const u=new Map;return s.forEach((c,l)=>{u.set(c.id,l+1)}),r.forEach(c=>{const l=c.getAttribute("data-citation-id")||"",d=a.get(l);if(!d)return;vt(c,d,i);const m=u.get(d.id)||1;Gt(c,d,i,Math.max(1,m))}),Ut(t,s,e,i),Wt(t,s,e,i),pt.set(t,o),H(t),t.dispatchEvent(new CustomEvent("editora:citations-refreshed",{bubbles:!0,detail:{citations:s,style:i,footnoteSync:e.enableFootnoteSync}})),s}function At(t){const e=Q.get(t);typeof e=="number"&&(window.clearTimeout(e),q.delete(e),Q.delete(t))}function kt(t){const e=f.get(t)||M;if(!e)return;At(t);const n=window.setTimeout(()=>{q.delete(n),Q.delete(t),y(t,e,!1)},e.debounceMs);q.add(n),Q.set(t,n)}function Yt(t){const e=window.getSelection();if(!e)throw new Error("Selection unavailable");if(e.rangeCount>0){const a=e.getRangeAt(0);if(t.contains(a.commonAncestorContainer)&&!j(a.commonAncestorContainer))return a.cloneRange()}const n=document.createRange(),i=t.querySelector(W),o=t.querySelector(G),r=i||o;return r?(n.setStartBefore(r),n.collapse(!0),n):(n.selectNodeContents(t),n.collapse(!1),n)}function dt(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function ft(t,e){if(e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch{}}function Tt(t,e){const n=window.getSelection();if(!n)return;const i=document.createRange();if(t.nodeType===Node.TEXT_NODE){const o=t,r=Math.max(0,Math.min(e,o.length));i.setStart(o,r)}else{const o=t.childNodes.length,r=Math.max(0,Math.min(e,o));i.setStart(t,r)}i.collapse(!0),n.removeAllRanges(),n.addRange(i)}function Mt(t){if(t.collapsed||t.startContainer!==t.endContainer||t.endOffset!==t.startOffset+1||!(t.startContainer instanceof Element||t.startContainer instanceof DocumentFragment))return null;const e=t.startContainer.childNodes[t.startOffset];return!(e instanceof HTMLElement)||!e.matches(ot)?null:e}function J(t,e,n){const{startContainer:i,startOffset:o}=t;if(i.nodeType===Node.ELEMENT_NODE){const a=i;if(n==="previous"){if(o>0)return a.childNodes[o-1]||null}else if(o<a.childNodes.length)return a.childNodes[o]||null}if(i.nodeType===Node.TEXT_NODE&&(n==="previous"&&o<i.data.length||n==="next"&&o>0))return null;let r=i;for(;r&&r!==e;){const a=n==="previous"?r.previousSibling:r.nextSibling;if(a)return a;r=r.parentNode}return null}function Lt(t,e,n){if(!t.collapsed)return null;const i=a=>a instanceof HTMLElement&&a.matches(ot)?a:null,{startContainer:o,startOffset:r}=t;if(o.nodeType===Node.ELEMENT_NODE){const a=o;return n==="Backspace"&&r>0?i(a.childNodes[r-1]||null):n==="Delete"?i(a.childNodes[r]||null):null}if(o.nodeType===Node.TEXT_NODE){const a=o;if(n==="Backspace"&&r===0){const s=i(a.previousSibling);return s||i(J(t,e,"previous"))}if(n==="Delete"&&r===a.data.length){const s=i(a.nextSibling);return s||i(J(t,e,"next"))}}return i(n==="Backspace"?J(t,e,"previous"):J(t,e,"next"))}function P(t,e,n){const i=t.closest(E);if(!i||j(t))return!1;const o=t.parentNode;if(!o)return!1;const r=i.innerHTML,a=Array.from(o.childNodes).indexOf(t);if(a<0)return!1;const s=t.nextSibling;return s instanceof Text&&(s.data===" "?s.remove():s.data.startsWith(" ")&&(s.data=s.data.slice(1))),t.remove(),Tt(o,a),y(i,n,!0),ft(i,r),dt(i),e==="Delete"&&i.focus({preventScroll:!0}),!0}function Xt(t,e,n){if(t.key!=="Backspace"&&t.key!=="Delete")return!1;const i=t.key,o=t.target;if(o?.matches(ot)&&e.contains(o)&&!j(o))return t.preventDefault(),t.stopPropagation(),P(o,i,n);const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const a=r.getRangeAt(0);if(!e.contains(a.commonAncestorContainer)||j(a.commonAncestorContainer))return!1;const s=Mt(a);if(s)return t.preventDefault(),t.stopPropagation(),P(s,i,n);const u=Lt(a,e,i);return u?(t.preventDefault(),t.stopPropagation(),P(u,i,n)):!1}function Rt(t,e,n){const i=F(n.normalizeText(e||""));if(!i)return!1;const o=R(t).filter(a=>a.getAttribute("data-citation-id")===i);if(o.length===0)return!1;if(o.length===1)return P(o[0],"Delete",n);const r=t.innerHTML;return o.forEach(a=>{const s=a.nextSibling;s instanceof Text&&(s.data===" "?s.remove():s.data.startsWith(" ")&&(s.data=s.data.slice(1))),a.remove()}),Tt(t,t.childNodes.length),y(t,n,!0),ft(t,r),dt(t),t.focus({preventScroll:!0}),!0}function Jt(t,e){const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const i=n.getRangeAt(0);if(!t.contains(i.commonAncestorContainer)||j(i.commonAncestorContainer))return!1;const o=Mt(i);if(o)return P(o,"Delete",e);const r=Lt(i,t,"Backspace");return r?P(r,"Backspace",e):!1}function et(t,e,n){const i=yt(e,n);if(!i.author||!i.title)return!1;i.id||(i.id=Ht(t,n));const o=t.innerHTML;let r;try{r=Yt(t)}catch{return!1}const a=window.getSelection();if(!a)return!1;r.collapsed||r.deleteContents();const s=document.createElement("span");vt(s,i,N(t,n));try{r.insertNode(s)}catch{return!1}const u=document.createTextNode(" ");s.nextSibling?s.parentNode?.insertBefore(u,s.nextSibling):s.parentNode?.appendChild(u);const c=document.createRange();if(u.parentNode){const l=Array.from(u.parentNode.childNodes).indexOf(u)+1;c.setStart(u.parentNode,Math.max(0,l))}else c.setStartAfter(s);return c.collapse(!0),a.removeAllRanges(),a.addRange(c),_t(t,i,n),y(t,n,!0),ft(t,o),dt(t),!0}function Zt(t,e){if(!e)return!1;const n=R(t).find(r=>r.getAttribute("data-citation-id")===e)||null;if(!n)return!1;n.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),n.focus({preventScroll:!0});const i=window.getSelection();if(!i)return!0;const o=document.createRange();return o.selectNode(n),i.removeAllRanges(),i.addRange(o),!0}function nt(t){return V.get(t)===!0}function U(t,e=!1){const n=v.get(t);n&&(n.classList.remove("show"),V.set(t,!1),it(t,"toggleCitationsPanel",!1),e&&t.focus({preventScroll:!0}))}function Qt(t){v.forEach((e,n)=>{n!==t&&U(n,!1)})}function ct(t,e){if(!e.classList.contains("show"))return;const i=lt(t).getBoundingClientRect(),o=Math.min(window.innerWidth-20,380),r=Math.max(10,window.innerWidth-o-10),a=Math.min(Math.max(10,i.right-o),r),s=Math.max(10,Math.min(window.innerHeight-10-260,i.top+10));e.style.width=`${o}px`,e.style.left=`${a}px`,e.style.top=`${s}px`,e.style.maxHeight=`${Math.max(260,window.innerHeight-24)}px`}function C(t,e){return t.querySelector(`[data-field="${e}"]`)}function te(t){const e=C(t,"author")?.value||"",n=C(t,"year")?.value||"",i=C(t,"title")?.value||"",o=C(t,"source")?.value||"",r=C(t,"url")?.value||"",a=C(t,"note")?.value||"";return{author:e,year:n,title:i,source:o,url:r,note:a}}function S(t,e){const n=t.querySelector(".rte-citations-live");n&&(n.textContent=e)}function ee(t,e,n){const i=C(e,"style");i&&(i.value=N(t,n))}function Nt(t,e,n){const i=L.includes(e)?e:n.defaultStyle;return T.set(t,i),y(t,n,!0),i}function bt(t,e){const n=N(t,e),i=L.indexOf(n),o=L[(i+1)%L.length];return T.set(t,o),y(t,e,!0),o}function ne(t){const e=v.get(t);if(e)return e;const n=f.get(t)||M||Z(),i=`rte-citations-panel-${Ot++}`,o=document.createElement("section");o.className=b,o.id=i,o.setAttribute("role","dialog"),o.setAttribute("aria-modal","false"),o.setAttribute("aria-label",n.labels.panelAriaLabel),o.setAttribute("tabindex","-1"),o.innerHTML=`
`).join("")}}function y(t,e,n=!1){const i=N(t,e),o=Yt(t,i,e.enableFootnoteSync);if(!n&&ht.get(t)===o)return j(t,e);const r=R(t),a=new Map;r.forEach(c=>{const l=wt(c,e);l&&(a.has(l.id)||a.set(l.id,l))});const s=Array.from(a.values());rt(t,s,e);const u=new Map;return s.forEach((c,l)=>{u.set(c.id,l+1)}),r.forEach(c=>{const l=c.getAttribute("data-citation-id")||"",d=a.get(l);if(!d)return;Et(c,d,i);const m=u.get(d.id)||1;Vt(c,d,i,Math.max(1,m))}),Wt(t,s,e,i),Gt(t,s,e,i),ht.set(t,o),H(t),t.dispatchEvent(new CustomEvent("editora:citations-refreshed",{bubbles:!0,detail:{citations:s,style:i,footnoteSync:e.enableFootnoteSync}})),s}function kt(t){const e=Q.get(t);typeof e=="number"&&(window.clearTimeout(e),q.delete(e),Q.delete(t))}function Tt(t){const e=f.get(t)||M;if(!e)return;kt(t);const n=window.setTimeout(()=>{q.delete(n),Q.delete(t),y(t,e,!1)},e.debounceMs);q.add(n),Q.set(t,n)}function Xt(t){const e=window.getSelection();if(!e)throw new Error("Selection unavailable");if(e.rangeCount>0){const a=e.getRangeAt(0);if(t.contains(a.commonAncestorContainer)&&!K(a.commonAncestorContainer))return a.cloneRange()}const n=document.createRange(),i=t.querySelector(W),o=t.querySelector(G),r=i||o;return r?(n.setStartBefore(r),n.collapse(!0),n):(n.selectNodeContents(t),n.collapse(!1),n)}function dt(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function ft(t,e){if(e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch{}}function Mt(t,e){const n=window.getSelection();if(!n)return;const i=document.createRange();if(t.nodeType===Node.TEXT_NODE){const o=t,r=Math.max(0,Math.min(e,o.length));i.setStart(o,r)}else{const o=t.childNodes.length,r=Math.max(0,Math.min(e,o));i.setStart(t,r)}i.collapse(!0),n.removeAllRanges(),n.addRange(i)}function Lt(t){if(t.collapsed||t.startContainer!==t.endContainer||t.endOffset!==t.startOffset+1||!(t.startContainer instanceof Element||t.startContainer instanceof DocumentFragment))return null;const e=t.startContainer.childNodes[t.startOffset];return!(e instanceof HTMLElement)||!e.matches(ot)?null:e}function J(t,e,n){const{startContainer:i,startOffset:o}=t;if(i.nodeType===Node.ELEMENT_NODE){const a=i;if(n==="previous"){if(o>0)return a.childNodes[o-1]||null}else if(o<a.childNodes.length)return a.childNodes[o]||null}if(i.nodeType===Node.TEXT_NODE&&(n==="previous"&&o<i.data.length||n==="next"&&o>0))return null;let r=i;for(;r&&r!==e;){const a=n==="previous"?r.previousSibling:r.nextSibling;if(a)return a;r=r.parentNode}return null}function Rt(t,e,n){if(!t.collapsed)return null;const i=a=>a instanceof HTMLElement&&a.matches(ot)?a:null,{startContainer:o,startOffset:r}=t;if(o.nodeType===Node.ELEMENT_NODE){const a=o;return n==="Backspace"&&r>0?i(a.childNodes[r-1]||null):n==="Delete"?i(a.childNodes[r]||null):null}if(o.nodeType===Node.TEXT_NODE){const a=o;if(n==="Backspace"&&r===0){const s=i(a.previousSibling);return s||i(J(t,e,"previous"))}if(n==="Delete"&&r===a.data.length){const s=i(a.nextSibling);return s||i(J(t,e,"next"))}}return i(n==="Backspace"?J(t,e,"previous"):J(t,e,"next"))}function P(t,e,n){const i=t.closest(S);if(!i||K(t))return!1;const o=t.parentNode;if(!o)return!1;const r=i.innerHTML,a=Array.from(o.childNodes).indexOf(t);if(a<0)return!1;const s=t.nextSibling;return s instanceof Text&&(s.data===" "?s.remove():s.data.startsWith(" ")&&(s.data=s.data.slice(1))),t.remove(),Mt(o,a),y(i,n,!0),ft(i,r),dt(i),e==="Delete"&&i.focus({preventScroll:!0}),!0}function Jt(t,e,n){if(t.key!=="Backspace"&&t.key!=="Delete")return!1;const i=t.key,o=t.target;if(o?.matches(ot)&&e.contains(o)&&!K(o))return t.preventDefault(),t.stopPropagation(),P(o,i,n);const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const a=r.getRangeAt(0);if(!e.contains(a.commonAncestorContainer)||K(a.commonAncestorContainer))return!1;const s=Lt(a);if(s)return t.preventDefault(),t.stopPropagation(),P(s,i,n);const u=Rt(a,e,i);return u?(t.preventDefault(),t.stopPropagation(),P(u,i,n)):!1}function Nt(t,e,n){const i=F(n.normalizeText(e||""));if(!i)return!1;const o=R(t).filter(a=>a.getAttribute("data-citation-id")===i);if(o.length===0)return!1;if(o.length===1)return P(o[0],"Delete",n);const r=t.innerHTML;return o.forEach(a=>{const s=a.nextSibling;s instanceof Text&&(s.data===" "?s.remove():s.data.startsWith(" ")&&(s.data=s.data.slice(1))),a.remove()}),Mt(t,t.childNodes.length),y(t,n,!0),ft(t,r),dt(t),t.focus({preventScroll:!0}),!0}function Zt(t,e){const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const i=n.getRangeAt(0);if(!t.contains(i.commonAncestorContainer)||K(i.commonAncestorContainer))return!1;const o=Lt(i);if(o)return P(o,"Delete",e);const r=Rt(i,t,"Backspace");return r?P(r,"Backspace",e):!1}function et(t,e,n){const i=Ct(e,n);if(!i.author||!i.title)return!1;i.id||(i.id=Ft(t,n));const o=t.innerHTML;let r;try{r=Xt(t)}catch{return!1}const a=window.getSelection();if(!a)return!1;r.collapsed||r.deleteContents();const s=document.createElement("span");Et(s,i,N(t,n));try{r.insertNode(s)}catch{return!1}const u=document.createTextNode(" ");s.nextSibling?s.parentNode?.insertBefore(u,s.nextSibling):s.parentNode?.appendChild(u);const c=document.createRange();if(u.parentNode){const l=Array.from(u.parentNode.childNodes).indexOf(u)+1;c.setStart(u.parentNode,Math.max(0,l))}else c.setStartAfter(s);return c.collapse(!0),a.removeAllRanges(),a.addRange(c),qt(t,i,n),y(t,n,!0),ft(t,o),dt(t),!0}function Qt(t,e){if(!e)return!1;const n=R(t).find(r=>r.getAttribute("data-citation-id")===e)||null;if(!n)return!1;n.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),n.focus({preventScroll:!0});const i=window.getSelection();if(!i)return!0;const o=document.createRange();return o.selectNode(n),i.removeAllRanges(),i.addRange(o),!0}function nt(t){return V.get(t)===!0}function U(t,e=!1){const n=w.get(t);n&&(n.classList.remove("show"),V.set(t,!1),it(t,"toggleCitationsPanel",!1),e&&t.focus({preventScroll:!0}))}function te(t){w.forEach((e,n)=>{n!==t&&U(n,!1)})}function ct(t,e){if(!e.classList.contains("show"))return;const i=lt(t).getBoundingClientRect(),o=Math.min(window.innerWidth-20,380),r=Math.max(10,window.innerWidth-o-10),a=Math.min(Math.max(10,i.right-o),r),s=Math.max(10,Math.min(window.innerHeight-10-260,i.top+10));e.style.width=`${o}px`,e.style.left=`${a}px`,e.style.top=`${s}px`,e.style.maxHeight=`${Math.max(260,window.innerHeight-24)}px`}function C(t,e){return t.querySelector(`[data-field="${e}"]`)}function ee(t){const e=C(t,"author")?.value||"",n=C(t,"year")?.value||"",i=C(t,"title")?.value||"",o=C(t,"source")?.value||"",r=C(t,"url")?.value||"",a=C(t,"note")?.value||"";return{author:e,year:n,title:i,source:o,url:r,note:a}}function E(t,e){const n=t.querySelector(".rte-citations-live");n&&(n.textContent=e)}function ne(t,e,n){const i=C(e,"style");i&&(i.value=N(t,n))}function zt(t,e,n){const i=L.includes(e)?e:n.defaultStyle;return T.set(t,i),y(t,n,!0),i}function bt(t,e){const n=N(t,e),i=L.indexOf(n),o=L[(i+1)%L.length];return T.set(t,o),y(t,e,!0),o}function oe(t){const e=w.get(t);if(e)return e;const n=f.get(t)||M||Z(),i=`rte-citations-panel-${Pt++}`,o=document.createElement("section");o.className=b,o.id=i,o.setAttribute("role","dialog"),o.setAttribute("aria-modal","false"),o.setAttribute("aria-label",n.labels.panelAriaLabel),o.setAttribute("tabindex","-1"),o.innerHTML=`
<header class="rte-citations-header">

@@ -81,3 +81,3 @@ <h2 class="rte-citations-title">${g(n.labels.panelTitle)}</h2>

</div>
`,o.addEventListener("click",a=>{const s=a.target;if(!s)return;const u=s.closest("[data-action]");if(!u)return;const c=u.getAttribute("data-action")||"",l=f.get(t)||M||n;if(f.set(t,l),c==="close"){U(t,!0);return}if(c==="insert"){if($(t))return;const d=te(o);if(!l.normalizeText(d.author)||!l.normalizeText(d.title)){S(o,l.labels.invalidMessage);return}if(!et(t,d,l)){S(o,l.labels.invalidMessage);return}S(o,"Citation inserted.");const w=C(o,"title"),A=C(o,"note");w&&(w.value=""),A&&(A.value="");return}if(c==="refresh"){const d=y(t,l,!0);S(o,`Refreshed ${d.length} citation${d.length===1?"":"s"}.`);return}if(c==="cycle-style"){const d=bt(t,l);ee(t,o,l),S(o,`Style changed to ${d.toUpperCase()}.`);return}if(c==="insert-from-recent"){if($(t))return;const d=u.getAttribute("data-citation-id")||"",m=St(t,d,K(t,l),l);if(!m)return;et(t,m,l),S(o,`Inserted citation: ${m.title}.`);return}if(c==="delete-by-id"){if($(t))return;const d=u.getAttribute("data-citation-id")||"";if(Rt(t,d,l)){S(o,"Citation deleted.");return}qt(t,d,l)&&(H(t),S(o,"Removed from recent citations."))}}),o.addEventListener("keydown",a=>{if(a.key==="Escape"){a.preventDefault(),U(t,!0);return}const s=a.target;if(!s||!s.matches(".rte-citations-recent-btn")||a.key!=="ArrowDown"&&a.key!=="ArrowUp")return;const u=Array.from(o.querySelectorAll(".rte-citations-recent-btn"));if(u.length===0)return;const c=u.indexOf(s);if(c<0)return;a.preventDefault();const l=a.key==="ArrowDown"?1:-1,d=(c+l+u.length)%u.length;u[d].focus()});const r=C(o,"style");return r?.addEventListener("change",()=>{const a=f.get(t)||M||n,s=r.value;Nt(t,s,a),S(o,`Style changed to ${s.toUpperCase()}.`)}),tt(o,t),document.body.appendChild(o),v.set(t,o),V.set(t,!1),H(t),o}function z(t){const e=ne(t);Qt(t),e.classList.add("show"),V.set(t,!0),it(t,"toggleCitationsPanel",!0),tt(e,t),ct(t,e),H(t),C(e,"author")?.focus()}function zt(t,e){const n=nt(t);return(typeof e=="boolean"?e:!n)?z(t):U(t,!1),!0}function oe(t){const e=t.key.toLowerCase();return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="c"}function ie(t){const e=t.key.toLowerCase();return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="b"}function re(t){const e=t.key.toLowerCase();return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="j"}function ae(t){M=t,I||(I=e=>{const i=e.target?.closest(E);if(!i)return;p=i,f.has(i)||f.set(i,t),T.has(i)||T.set(i,t.defaultStyle);const o=v.get(i);o&&(tt(o,i),ct(i,o)),it(i,"toggleCitationsPanel",nt(i))},document.addEventListener("focusin",I,!0)),B||(B=e=>{const i=e.target?.closest(E);i&&(p=i,kt(i))},document.addEventListener("input",B,!0)),O||(O=e=>{if(e.defaultPrevented)return;const i=!!e.target?.closest(`.${b} input, .${b} textarea, .${b} select`),o=h(void 0,!1);if(!o||$(o))return;const r=f.get(o)||M||t;if(f.set(o,r),p=o,e.key==="Escape"&&nt(o)){e.preventDefault(),U(o,!0);return}if(!i&&!Xt(e,o,r)){if(oe(e)){e.preventDefault(),e.stopPropagation(),zt(o);return}if(ie(e)){e.preventDefault(),e.stopPropagation(),y(o,r,!0),z(o);return}re(e)&&(e.preventDefault(),e.stopPropagation(),bt(o,r))}},document.addEventListener("keydown",O,!0)),k||(k=()=>{v.forEach((e,n)=>{if(!n.isConnected||!e.isConnected){At(n),e.remove(),v.delete(n),V.delete(n);return}tt(e,n),ct(n,e)})},window.addEventListener("scroll",k,!0),window.addEventListener("resize",k))}function se(){I&&(document.removeEventListener("focusin",I,!0),I=null),B&&(document.removeEventListener("input",B,!0),B=null),O&&(document.removeEventListener("keydown",O,!0),O=null),k&&(window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k),k=null),v.forEach(t=>t.remove()),v.clear(),M=null,p=null}function ce(){if(typeof document>"u"||document.getElementById(mt))return;const t=document.createElement("style");t.id=mt,t.textContent=`
`,o.addEventListener("click",a=>{const s=a.target;if(!s)return;const u=s.closest("[data-action]");if(!u)return;const c=u.getAttribute("data-action")||"",l=f.get(t)||M||n;if(f.set(t,l),c==="close"){U(t,!0);return}if(c==="insert"){if($(t))return;const d=ee(o);if(!l.normalizeText(d.author)||!l.normalizeText(d.title)){E(o,l.labels.invalidMessage);return}if(!et(t,d,l)){E(o,l.labels.invalidMessage);return}E(o,"Citation inserted.");const v=C(o,"title"),A=C(o,"note");v&&(v.value=""),A&&(A.value="");return}if(c==="refresh"){const d=y(t,l,!0);E(o,`Refreshed ${d.length} citation${d.length===1?"":"s"}.`);return}if(c==="cycle-style"){const d=bt(t,l);ne(t,o,l),E(o,`Style changed to ${d.toUpperCase()}.`);return}if(c==="insert-from-recent"){if($(t))return;const d=u.getAttribute("data-citation-id")||"",m=St(t,d,j(t,l),l);if(!m)return;et(t,m,l),E(o,`Inserted citation: ${m.title}.`);return}if(c==="delete-by-id"){if($(t))return;const d=u.getAttribute("data-citation-id")||"";if(Nt(t,d,l)){E(o,"Citation deleted.");return}Kt(t,d,l)&&(H(t),E(o,"Removed from recent citations."))}}),o.addEventListener("keydown",a=>{if(a.key==="Escape"){a.preventDefault(),U(t,!0);return}const s=a.target;if(!s||!s.matches(".rte-citations-recent-btn")||a.key!=="ArrowDown"&&a.key!=="ArrowUp")return;const u=Array.from(o.querySelectorAll(".rte-citations-recent-btn"));if(u.length===0)return;const c=u.indexOf(s);if(c<0)return;a.preventDefault();const l=a.key==="ArrowDown"?1:-1,d=(c+l+u.length)%u.length;u[d].focus()});const r=C(o,"style");return r?.addEventListener("change",()=>{const a=f.get(t)||M||n,s=r.value;zt(t,s,a),E(o,`Style changed to ${s.toUpperCase()}.`)}),tt(o,t),document.body.appendChild(o),w.set(t,o),V.set(t,!1),H(t),o}function z(t){const e=oe(t);te(t),e.classList.add("show"),V.set(t,!0),it(t,"toggleCitationsPanel",!0),tt(e,t),ct(t,e),H(t),C(e,"author")?.focus()}function It(t,e){const n=nt(t);return(typeof e=="boolean"?e:!n)?z(t):U(t,!1),!0}function gt(t){return typeof t.key=="string"?t.key.toLowerCase():""}function ie(t){const e=gt(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="c"}function re(t){const e=gt(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="b"}function ae(t){const e=gt(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="j"}function se(t){M=t,I||(I=e=>{const i=e.target?.closest(S);if(!i)return;p=i,f.has(i)||f.set(i,t),T.has(i)||T.set(i,t.defaultStyle);const o=w.get(i);o&&(tt(o,i),ct(i,o)),it(i,"toggleCitationsPanel",nt(i))},document.addEventListener("focusin",I,!0)),B||(B=e=>{const i=e.target?.closest(S);i&&(p=i,Tt(i))},document.addEventListener("input",B,!0)),O||(O=e=>{if(e.defaultPrevented)return;const i=!!e.target?.closest(`.${b} input, .${b} textarea, .${b} select`),o=h(void 0,!1);if(!o||$(o))return;const r=f.get(o)||M||t;if(f.set(o,r),p=o,e.key==="Escape"&&nt(o)){e.preventDefault(),U(o,!0);return}if(!i&&!Jt(e,o,r)){if(ie(e)){e.preventDefault(),e.stopPropagation(),It(o);return}if(re(e)){e.preventDefault(),e.stopPropagation(),y(o,r,!0),z(o);return}ae(e)&&(e.preventDefault(),e.stopPropagation(),bt(o,r))}},document.addEventListener("keydown",O,!0)),k||(k=()=>{w.forEach((e,n)=>{if(!n.isConnected||!e.isConnected){kt(n),e.remove(),w.delete(n),V.delete(n);return}tt(e,n),ct(n,e)})},window.addEventListener("scroll",k,!0),window.addEventListener("resize",k))}function ce(){I&&(document.removeEventListener("focusin",I,!0),I=null),B&&(document.removeEventListener("input",B,!0),B=null),O&&(document.removeEventListener("keydown",O,!0),O=null),k&&(window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k),k=null),w.forEach(t=>t.remove()),w.clear(),M=null,p=null}function le(){if(typeof document>"u"||document.getElementById(pt))return;const t=document.createElement("style");t.id=pt,t.textContent=`
.rte-toolbar-group-items.citations,

@@ -550,2 +550,2 @@ .editora-toolbar-group-items.citations {

}
`,document.head.appendChild(t)}const le=(t={})=>{const e=Z(t);return ce(),{name:"citations",toolbar:[{id:"citationsGroup",label:"Citations",type:"group",command:"citations",items:[{id:"citations",label:"Citations",command:"toggleCitationsPanel",shortcut:"Mod-Alt-Shift-c",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 5h12M6 9h12M6 13h8M6 17h10" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M17 14.5a2.5 2.5 0 0 1 2.5 2.5v2H15v-2a2 2 0 0 1 2-2Z" stroke="currentColor" stroke-width="1.5"/></svg>'},{id:"citationsRefresh",label:"Refresh Citations",command:"refreshCitations",shortcut:"Mod-Alt-Shift-b",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M20 12a8 8 0 1 1-2.34-5.66" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M20 4v6h-6" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"citationsStyle",label:"Cycle Citation Style",command:"cycleCitationStyle",shortcut:"Mod-Alt-Shift-j",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M5 6h14M5 10h8M5 14h14M5 18h10" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><circle cx="18" cy="10" r="2" stroke="currentColor" stroke-width="1.6"/></svg>'}]}],commands:{citations:(n,i)=>{const o=h(i);if(!o||$(o))return!1;const r=f.get(o)||e;return f.set(o,r),T.set(o,N(o,r)),p=o,z(o),y(o,r,!1),!0},toggleCitationsPanel:(n,i)=>{const o=h(i);if(!o||$(o))return!1;const r=f.get(o)||e;f.set(o,r),p=o;const a=zt(o,typeof n=="boolean"?n:void 0);return nt(o)&&y(o,r,!1),a},insertCitation:(n,i)=>{const o=h(i);if(!o||$(o)||!n||typeof n!="object")return!1;const r=f.get(o)||e;f.set(o,r),p=o;const a=et(o,n,r);return a&&z(o),a},refreshCitations:(n,i)=>{const o=h(i);if(!o)return!1;const r=f.get(o)||e;return f.set(o,r),p=o,y(o,r,!0),z(o),!0},setCitationStyle:(n,i)=>{const o=h(i);if(!o||!n)return!1;const r=f.get(o)||e;return f.set(o,r),p=o,Nt(o,n,r),!0},cycleCitationStyle:(n,i)=>{const o=h(i);if(!o)return!1;const r=f.get(o)||e;return f.set(o,r),p=o,bt(o,r),H(o),!0},getCitationRecords:(n,i)=>{const o=h(i);if(!o)return!1;const r=f.get(o)||e,a=K(o,r);if(typeof n=="function")try{n(a)}catch{}return o.__citationRecords=a,o.dispatchEvent(new CustomEvent("editora:citations-data",{bubbles:!0,detail:{records:a,style:N(o,r)}})),!0},setCitationsOptions:(n,i)=>{const o=h(i);if(!o||!n||typeof n!="object")return!1;const r=f.get(o)||e,a=Z({...r,...n,labels:{...r.labels,...n.labels||{}},normalizeText:n.normalizeText||r.normalizeText,generateCitationId:n.generateCitationId||r.generateCitationId});return f.set(o,a),n.defaultStyle&&L.includes(n.defaultStyle)&&T.set(o,n.defaultStyle),y(o,a,!0),H(o),!0},locateCitation:(n,i)=>{const o=h(i);return!o||typeof n!="string"?!1:Zt(o,n)},deleteCitation:(n,i)=>{const o=h(i);if(!o||$(o))return!1;const r=f.get(o)||e;return f.set(o,r),typeof n=="string"&&n.trim()?Rt(o,n,r):Jt(o,r)},insertRecentCitation:(n,i)=>{const o=h(i);if(!o||$(o))return!1;const r=f.get(o)||e;f.set(o,r);const a=K(o,r),s=rt(o,a,r);if(s.length===0)return!1;const u=typeof n=="string"&&n.trim()?St(o,n,a,r):s[0];if(!u)return!1;const c=et(o,u,r);return c&&z(o),c}},keymap:{"Mod-Alt-Shift-c":"toggleCitationsPanel","Mod-Alt-Shift-C":"toggleCitationsPanel","Mod-Alt-Shift-b":"refreshCitations","Mod-Alt-Shift-B":"refreshCitations","Mod-Alt-Shift-j":"cycleCitationStyle","Mod-Alt-Shift-J":"cycleCitationStyle"},init:function(i){Y+=1;const o=this&&typeof this.__pluginConfig=="object"?Z({...e,...this.__pluginConfig}):e;ae(o);const r=h(i&&i.editorElement?{editorElement:i.editorElement}:void 0,!1);r&&(p=r,f.set(r,o),T.set(r,o.defaultStyle),it(r,"toggleCitationsPanel",!1),kt(r))},destroy:()=>{Y=Math.max(0,Y-1),!(Y>0)&&(q.forEach(n=>{window.clearTimeout(n)}),q.clear(),se())}}};exports.CitationsPlugin=le;
`,document.head.appendChild(t)}const ue=(t={})=>{const e=Z(t);return le(),{name:"citations",toolbar:[{id:"citationsGroup",label:"Citations",type:"group",command:"citations",items:[{id:"citations",label:"Citations",command:"toggleCitationsPanel",shortcut:"Mod-Alt-Shift-c",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 5h12M6 9h12M6 13h8M6 17h10" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M17 14.5a2.5 2.5 0 0 1 2.5 2.5v2H15v-2a2 2 0 0 1 2-2Z" stroke="currentColor" stroke-width="1.5"/></svg>'},{id:"citationsRefresh",label:"Refresh Citations",command:"refreshCitations",shortcut:"Mod-Alt-Shift-b",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M20 12a8 8 0 1 1-2.34-5.66" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M20 4v6h-6" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"citationsStyle",label:"Cycle Citation Style",command:"cycleCitationStyle",shortcut:"Mod-Alt-Shift-j",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M5 6h14M5 10h8M5 14h14M5 18h10" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><circle cx="18" cy="10" r="2" stroke="currentColor" stroke-width="1.6"/></svg>'}]}],commands:{citations:(n,i)=>{const o=h(i);if(!o||$(o))return!1;const r=f.get(o)||e;return f.set(o,r),T.set(o,N(o,r)),p=o,z(o),y(o,r,!1),!0},toggleCitationsPanel:(n,i)=>{const o=h(i);if(!o||$(o))return!1;const r=f.get(o)||e;f.set(o,r),p=o;const a=It(o,typeof n=="boolean"?n:void 0);return nt(o)&&y(o,r,!1),a},insertCitation:(n,i)=>{const o=h(i);if(!o||$(o)||!n||typeof n!="object")return!1;const r=f.get(o)||e;f.set(o,r),p=o;const a=et(o,n,r);return a&&z(o),a},refreshCitations:(n,i)=>{const o=h(i);if(!o)return!1;const r=f.get(o)||e;return f.set(o,r),p=o,y(o,r,!0),z(o),!0},setCitationStyle:(n,i)=>{const o=h(i);if(!o||!n)return!1;const r=f.get(o)||e;return f.set(o,r),p=o,zt(o,n,r),!0},cycleCitationStyle:(n,i)=>{const o=h(i);if(!o)return!1;const r=f.get(o)||e;return f.set(o,r),p=o,bt(o,r),H(o),!0},getCitationRecords:(n,i)=>{const o=h(i);if(!o)return!1;const r=f.get(o)||e,a=j(o,r);if(typeof n=="function")try{n(a)}catch{}return o.__citationRecords=a,o.dispatchEvent(new CustomEvent("editora:citations-data",{bubbles:!0,detail:{records:a,style:N(o,r)}})),!0},setCitationsOptions:(n,i)=>{const o=h(i);if(!o||!n||typeof n!="object")return!1;const r=f.get(o)||e,a=Z({...r,...n,labels:{...r.labels,...n.labels||{}},normalizeText:n.normalizeText||r.normalizeText,generateCitationId:n.generateCitationId||r.generateCitationId});return f.set(o,a),n.defaultStyle&&L.includes(n.defaultStyle)&&T.set(o,n.defaultStyle),y(o,a,!0),H(o),!0},locateCitation:(n,i)=>{const o=h(i);return!o||typeof n!="string"?!1:Qt(o,n)},deleteCitation:(n,i)=>{const o=h(i);if(!o||$(o))return!1;const r=f.get(o)||e;return f.set(o,r),typeof n=="string"&&n.trim()?Nt(o,n,r):Zt(o,r)},insertRecentCitation:(n,i)=>{const o=h(i);if(!o||$(o))return!1;const r=f.get(o)||e;f.set(o,r);const a=j(o,r),s=rt(o,a,r);if(s.length===0)return!1;const u=typeof n=="string"&&n.trim()?St(o,n,a,r):s[0];if(!u)return!1;const c=et(o,u,r);return c&&z(o),c}},keymap:{"Mod-Alt-Shift-c":"toggleCitationsPanel","Mod-Alt-Shift-C":"toggleCitationsPanel","Mod-Alt-Shift-b":"refreshCitations","Mod-Alt-Shift-B":"refreshCitations","Mod-Alt-Shift-j":"cycleCitationStyle","Mod-Alt-Shift-J":"cycleCitationStyle"},init:function(i){Y+=1;const o=this&&typeof this.__pluginConfig=="object"?Z({...e,...this.__pluginConfig}):e;se(o);const r=h(i&&i.editorElement?{editorElement:i.editorElement}:void 0,!1);r&&(p=r,f.set(r,o),T.set(r,o.defaultStyle),it(r,"toggleCitationsPanel",!1),Tt(r))},destroy:()=>{Y=Math.max(0,Y-1),!(Y>0)&&(q.forEach(n=>{window.clearTimeout(n)}),q.clear(),ce())}}};exports.CitationsPlugin=ue;

@@ -1,2 +0,2 @@

const S = ".rte-content, .editora-content", mt = "rte-citations-styles", b = "rte-citations-panel", ot = ".rte-citation-ref[data-citation-id]", W = '.rte-citation-bibliography[data-type="citation-bibliography"]', G = '.rte-citation-footnotes[data-type="citation-footnotes"]', x = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', L = ["apa", "mla", "chicago"], Bt = {
const S = ".rte-content, .editora-content", pt = "rte-citations-styles", b = "rte-citations-panel", ot = ".rte-citation-ref[data-citation-id]", W = '.rte-citation-bibliography[data-type="citation-bibliography"]', G = '.rte-citation-footnotes[data-type="citation-footnotes"]', x = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', L = ["apa", "mla", "chicago"], Ot = {
panelTitle: "Citations",

@@ -22,11 +22,11 @@ panelAriaLabel: "Citations panel",

invalidMessage: "Author and title are required."
}, f = /* @__PURE__ */ new WeakMap(), T = /* @__PURE__ */ new WeakMap(), pt = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new Set();
let I = null, B = null, O = null, k = null, Y = 0, Ot = 0, at = 0, M = null, p = null;
}, f = /* @__PURE__ */ new WeakMap(), T = /* @__PURE__ */ new WeakMap(), ht = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new Set();
let I = null, B = null, O = null, k = null, Y = 0, Pt = 0, at = 0, M = null, p = null;
function g(t) {
return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
}
function Pt(t) {
function Dt(t) {
return t.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
}
function ht(t, e) {
function xt(t, e) {
const n = e(t);

@@ -37,3 +37,3 @@ if (!n) return "";

}
function xt(t, e) {
function yt(t, e) {
const n = e(t);

@@ -45,10 +45,10 @@ return n ? /^https?:\/\//i.test(n) ? n : `https://${n}` : "";

}
function yt(t, e) {
function Ct(t, e) {
return {
id: F(e.normalizeText(t.id || "")),
author: e.normalizeText(t.author || ""),
year: ht(t.year || "", e.normalizeText) || void 0,
year: xt(t.year || "", e.normalizeText) || void 0,
title: e.normalizeText(t.title || ""),
source: e.normalizeText(t.source || "") || void 0,
url: xt(t.url || "", e.normalizeText) || void 0,
url: yt(t.url || "", e.normalizeText) || void 0,
note: e.normalizeText(t.note || "") || void 0

@@ -59,3 +59,3 @@ };

const e = t.defaultStyle && L.includes(t.defaultStyle) ? t.defaultStyle : "apa", n = {
...Bt,
...Ot,
...t.labels || {}

@@ -69,7 +69,7 @@ };

labels: n,
normalizeText: t.normalizeText || Pt,
normalizeText: t.normalizeText || Dt,
generateCitationId: typeof t.generateCitationId == "function" ? t.generateCitationId : void 0
};
}
function Ct(t) {
function wt(t) {
return t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null;

@@ -83,3 +83,3 @@ }

}
function Dt(t) {
function Ht(t) {
const e = lt(t);

@@ -91,3 +91,3 @@ if (X(e)) return !0;

function tt(t, e) {
t.classList.remove("rte-citations-theme-dark"), Dt(e) && t.classList.add("rte-citations-theme-dark");
t.classList.remove("rte-citations-theme-dark"), Ht(e) && t.classList.add("rte-citations-theme-dark");
}

@@ -104,3 +104,3 @@ function h(t, e = !0) {

if (n && n.rangeCount > 0) {
const o = n.getRangeAt(0).startContainer, a = Ct(o)?.closest(S);
const o = n.getRangeAt(0).startContainer, a = wt(o)?.closest(S);
if (a) return a;

@@ -119,7 +119,7 @@ }

}
function j(t) {
const e = Ct(t);
function K(t) {
const e = wt(t);
return e ? !!(e.closest(W) || e.closest(G)) : !1;
}
function Ht(t, e) {
function Ft(t, e) {
if (at += 1, e.generateCitationId) {

@@ -134,3 +134,3 @@ const n = e.generateCitationId({ editor: t, index: at }), i = F(e.normalizeText(n || ""));

}
function Ft(t, e) {
function _t(t, e) {
const n = t.author || "Unknown", i = t.year || "n.d.";

@@ -166,3 +166,3 @@ return e === "mla" ? `(${n} ${i})` : e === "chicago" ? `(${n} ${i})` : `(${n}, ${i})`;

}
function wt(t, e) {
function vt(t, e) {
const n = F(e.normalizeText(t.getAttribute("data-citation-id") || ""));

@@ -174,11 +174,11 @@ if (!n) return null;

author: i || "Unknown",
year: ht(t.getAttribute("data-citation-year") || "", e.normalizeText) || void 0,
year: xt(t.getAttribute("data-citation-year") || "", e.normalizeText) || void 0,
title: o || "Untitled",
source: e.normalizeText(t.getAttribute("data-citation-source") || "") || void 0,
url: xt(t.getAttribute("data-citation-url") || "", e.normalizeText) || void 0,
url: yt(t.getAttribute("data-citation-url") || "", e.normalizeText) || void 0,
note: e.normalizeText(t.getAttribute("data-citation-note") || "") || void 0
};
}
function vt(t, e, n) {
t.classList.add("rte-citation-ref"), t.setAttribute("data-citation-id", e.id), t.setAttribute("data-citation-author", e.author || ""), t.setAttribute("data-citation-year", e.year || ""), t.setAttribute("data-citation-title", e.title || ""), t.setAttribute("data-citation-source", e.source || ""), t.setAttribute("data-citation-url", e.url || ""), t.setAttribute("data-citation-note", e.note || ""), t.setAttribute("contenteditable", "false"), t.setAttribute("tabindex", "0"), t.setAttribute("role", "doc-biblioref"), t.setAttribute("data-style", n), t.textContent = Ft(e, n);
function Et(t, e, n) {
t.classList.add("rte-citation-ref"), t.setAttribute("data-citation-id", e.id), t.setAttribute("data-citation-author", e.author || ""), t.setAttribute("data-citation-year", e.year || ""), t.setAttribute("data-citation-title", e.title || ""), t.setAttribute("data-citation-source", e.source || ""), t.setAttribute("data-citation-url", e.url || ""), t.setAttribute("data-citation-note", e.note || ""), t.setAttribute("contenteditable", "false"), t.setAttribute("tabindex", "0"), t.setAttribute("role", "doc-biblioref"), t.setAttribute("data-style", n), t.textContent = _t(e, n);
}

@@ -199,6 +199,6 @@ function it(t, e, n) {

}
function K(t, e) {
function j(t, e) {
const n = R(t), i = /* @__PURE__ */ new Map();
return n.forEach((o) => {
const r = wt(o, e);
const r = vt(o, e);
if (!r) return;

@@ -221,4 +221,4 @@ if (!i.has(r.id)) {

}
function _t(t, e, n) {
const i = yt(e, n);
function qt(t, e, n) {
const i = Ct(e, n);
if (!i.id || !i.author || !i.title) return;

@@ -238,7 +238,7 @@ const r = (D.get(t) || []).filter((a) => a.id !== i.id);

}
function Et(t, e, n, i) {
function St(t, e, n, i) {
const o = F(i.normalizeText(e || ""));
return o && rt(t, n, i).find((a) => a.id === o) || null;
}
function qt(t, e, n) {
function Kt(t, e, n) {
const i = F(n.normalizeText(e || ""));

@@ -249,3 +249,3 @@ if (!i) return !1;

}
function St(t, e, n) {
function $t(t, e, n) {
const i = document.createElement("section");

@@ -260,18 +260,18 @@ i.className = t, i.setAttribute("data-type", e), i.setAttribute("contenteditable", "false"), i.setAttribute("aria-label", n), e === "citation-bibliography" ? i.setAttribute("role", "doc-bibliography") : e === "citation-footnotes" && i.setAttribute("role", "doc-endnotes");

let n = t.querySelector(W);
n || (n = St("rte-citation-bibliography", "citation-bibliography", e.labels.bibliographyTitle), t.appendChild(n));
n || (n = $t("rte-citation-bibliography", "citation-bibliography", e.labels.bibliographyTitle), t.appendChild(n));
const i = n.querySelector(".rte-citation-section-title");
return i && (i.textContent = e.labels.bibliographyTitle), n.setAttribute("aria-label", e.labels.bibliographyTitle), n;
}
function Kt(t, e) {
function Ut(t, e) {
let n = t.querySelector(G);
n || (n = St("rte-citation-footnotes", "citation-footnotes", e.labels.footnotesTitle), t.appendChild(n));
n || (n = $t("rte-citation-footnotes", "citation-footnotes", e.labels.footnotesTitle), t.appendChild(n));
const i = n.querySelector(".rte-citation-section-title");
return i && (i.textContent = e.labels.footnotesTitle), n.setAttribute("aria-label", e.labels.footnotesTitle), n;
}
function $t(t, e) {
function At(t, e) {
t.querySelector(e)?.remove();
}
function Ut(t, e, n, i) {
function Wt(t, e, n, i) {
if (e.length === 0) {
$t(t, W);
At(t, W);
return;

@@ -287,5 +287,5 @@ }

}
function Wt(t, e, n, i) {
function Gt(t, e, n, i) {
if (!n.enableFootnoteSync || e.length === 0) {
$t(t, G), R(t).forEach((l) => {
At(t, G), R(t).forEach((l) => {
l.removeAttribute("data-footnote-number"), l.removeAttribute("data-footnote-target");

@@ -295,3 +295,3 @@ });

}
const r = Kt(t, n).querySelector(".rte-citation-list");
const r = Ut(t, n).querySelector(".rte-citation-list");
if (!r) return;

@@ -321,8 +321,8 @@ const a = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();

A.className = "rte-citation-footnote-text";
const It = l.note ? `${l.note}. ` : "";
A.textContent = `${It}${ut(l, i)}`, m.appendChild(w), m.appendChild(A);
const gt = a.get(l.id);
if (gt) {
const Bt = l.note ? `${l.note}. ` : "";
A.textContent = `${Bt}${ut(l, i)}`, m.appendChild(w), m.appendChild(A);
const mt = a.get(l.id);
if (mt) {
const _ = document.createElement("a");
_.className = "rte-citation-backref", _.href = `#${gt}`, _.setAttribute("aria-label", `Back to citation ${d + 1}`), _.textContent = "Back", m.appendChild(_);
_.className = "rte-citation-backref", _.href = `#${mt}`, _.setAttribute("aria-label", `Back to citation ${d + 1}`), _.textContent = "Back", m.appendChild(_);
}

@@ -332,7 +332,7 @@ c.appendChild(m);

}
function Gt(t, e, n, i) {
function Vt(t, e, n, i) {
const o = ut(e, n);
t.setAttribute("data-citation-number", String(i)), t.setAttribute("aria-label", `Citation ${i}: ${o}`);
}
function Vt(t, e, n) {
function Yt(t, e, n) {
const i = R(t);

@@ -349,3 +349,3 @@ let o = `${e}:${n ? "1" : "0"}:${i.length}`;

if (!n) return;
const i = N(t, n), o = K(t, n), r = rt(t, o, n), a = e.querySelector(".rte-citations-status"), s = e.querySelector('[data-action="cycle-style"]'), u = e.querySelector(".rte-citations-recent-list");
const i = N(t, n), o = j(t, n), r = rt(t, o, n), a = e.querySelector(".rte-citations-status"), s = e.querySelector('[data-action="cycle-style"]'), u = e.querySelector(".rte-citations-recent-list");
if (a) {

@@ -388,8 +388,8 @@ const c = o.length;

function y(t, e, n = !1) {
const i = N(t, e), o = Vt(t, i, e.enableFootnoteSync);
if (!n && pt.get(t) === o)
return K(t, e);
const i = N(t, e), o = Yt(t, i, e.enableFootnoteSync);
if (!n && ht.get(t) === o)
return j(t, e);
const r = R(t), a = /* @__PURE__ */ new Map();
r.forEach((c) => {
const l = wt(c, e);
const l = vt(c, e);
l && (a.has(l.id) || a.set(l.id, l));

@@ -405,6 +405,6 @@ });

if (!d) return;
vt(c, d, i);
Et(c, d, i);
const m = u.get(d.id) || 1;
Gt(c, d, i, Math.max(1, m));
}), Ut(t, s, e, i), Wt(t, s, e, i), pt.set(t, o), H(t), t.dispatchEvent(
Vt(c, d, i, Math.max(1, m));
}), Wt(t, s, e, i), Gt(t, s, e, i), ht.set(t, o), H(t), t.dispatchEvent(
new CustomEvent("editora:citations-refreshed", {

@@ -420,10 +420,10 @@ bubbles: !0,

}
function At(t) {
function kt(t) {
const e = Q.get(t);
typeof e == "number" && (window.clearTimeout(e), q.delete(e), Q.delete(t));
}
function kt(t) {
function Tt(t) {
const e = f.get(t) || M;
if (!e) return;
At(t);
kt(t);
const n = window.setTimeout(() => {

@@ -434,3 +434,3 @@ q.delete(n), Q.delete(t), y(t, e, !1);

}
function Yt(t) {
function Xt(t) {
const e = window.getSelection();

@@ -440,3 +440,3 @@ if (!e) throw new Error("Selection unavailable");

const a = e.getRangeAt(0);
if (t.contains(a.commonAncestorContainer) && !j(a.commonAncestorContainer))
if (t.contains(a.commonAncestorContainer) && !K(a.commonAncestorContainer))
return a.cloneRange();

@@ -459,3 +459,3 @@ }

}
function Tt(t, e) {
function Mt(t, e) {
const n = window.getSelection();

@@ -473,3 +473,3 @@ if (!n) return;

}
function Mt(t) {
function Lt(t) {
if (t.collapsed || t.startContainer !== t.endContainer || t.endOffset !== t.startOffset + 1 || !(t.startContainer instanceof Element || t.startContainer instanceof DocumentFragment))

@@ -499,3 +499,3 @@ return null;

}
function Lt(t, e, n) {
function Rt(t, e, n) {
if (!t.collapsed) return null;

@@ -522,3 +522,3 @@ const i = (a) => a instanceof HTMLElement && a.matches(ot) ? a : null, { startContainer: o, startOffset: r } = t;

const i = t.closest(S);
if (!i || j(t)) return !1;
if (!i || K(t)) return !1;
const o = t.parentNode;

@@ -529,8 +529,8 @@ if (!o) return !1;

const s = t.nextSibling;
return s instanceof Text && (s.data === " " ? s.remove() : s.data.startsWith(" ") && (s.data = s.data.slice(1))), t.remove(), Tt(o, a), y(i, n, !0), ft(i, r), dt(i), e === "Delete" && i.focus({ preventScroll: !0 }), !0;
return s instanceof Text && (s.data === " " ? s.remove() : s.data.startsWith(" ") && (s.data = s.data.slice(1))), t.remove(), Mt(o, a), y(i, n, !0), ft(i, r), dt(i), e === "Delete" && i.focus({ preventScroll: !0 }), !0;
}
function Xt(t, e, n) {
function Jt(t, e, n) {
if (t.key !== "Backspace" && t.key !== "Delete") return !1;
const i = t.key, o = t.target;
if (o?.matches(ot) && e.contains(o) && !j(o))
if (o?.matches(ot) && e.contains(o) && !K(o))
return t.preventDefault(), t.stopPropagation(), P(o, i, n);

@@ -540,10 +540,10 @@ const r = window.getSelection();

const a = r.getRangeAt(0);
if (!e.contains(a.commonAncestorContainer) || j(a.commonAncestorContainer)) return !1;
const s = Mt(a);
if (!e.contains(a.commonAncestorContainer) || K(a.commonAncestorContainer)) return !1;
const s = Lt(a);
if (s)
return t.preventDefault(), t.stopPropagation(), P(s, i, n);
const u = Lt(a, e, i);
const u = Rt(a, e, i);
return u ? (t.preventDefault(), t.stopPropagation(), P(u, i, n)) : !1;
}
function Rt(t, e, n) {
function Nt(t, e, n) {
const i = F(n.normalizeText(e || ""));

@@ -559,23 +559,23 @@ if (!i) return !1;

s instanceof Text && (s.data === " " ? s.remove() : s.data.startsWith(" ") && (s.data = s.data.slice(1))), a.remove();
}), Tt(t, t.childNodes.length), y(t, n, !0), ft(t, r), dt(t), t.focus({ preventScroll: !0 }), !0;
}), Mt(t, t.childNodes.length), y(t, n, !0), ft(t, r), dt(t), t.focus({ preventScroll: !0 }), !0;
}
function Jt(t, e) {
function Zt(t, e) {
const n = window.getSelection();
if (!n || n.rangeCount === 0) return !1;
const i = n.getRangeAt(0);
if (!t.contains(i.commonAncestorContainer) || j(i.commonAncestorContainer)) return !1;
const o = Mt(i);
if (!t.contains(i.commonAncestorContainer) || K(i.commonAncestorContainer)) return !1;
const o = Lt(i);
if (o)
return P(o, "Delete", e);
const r = Lt(i, t, "Backspace");
const r = Rt(i, t, "Backspace");
return r ? P(r, "Backspace", e) : !1;
}
function et(t, e, n) {
const i = yt(e, n);
const i = Ct(e, n);
if (!i.author || !i.title) return !1;
i.id || (i.id = Ht(t, n));
i.id || (i.id = Ft(t, n));
const o = t.innerHTML;
let r;
try {
r = Yt(t);
r = Xt(t);
} catch {

@@ -588,3 +588,3 @@ return !1;

const s = document.createElement("span");
vt(s, i, N(t, n));
Et(s, i, N(t, n));
try {

@@ -603,5 +603,5 @@ r.insertNode(s);

c.setStartAfter(s);
return c.collapse(!0), a.removeAllRanges(), a.addRange(c), _t(t, i, n), y(t, n, !0), ft(t, o), dt(t), !0;
return c.collapse(!0), a.removeAllRanges(), a.addRange(c), qt(t, i, n), y(t, n, !0), ft(t, o), dt(t), !0;
}
function Zt(t, e) {
function Qt(t, e) {
if (!e) return !1;

@@ -623,3 +623,3 @@ const n = R(t).find((r) => r.getAttribute("data-citation-id") === e) || null;

}
function Qt(t) {
function te(t) {
v.forEach((e, n) => {

@@ -637,3 +637,3 @@ n !== t && U(n, !1);

}
function te(t) {
function ee(t) {
const e = C(t, "author")?.value || "", n = C(t, "year")?.value || "", i = C(t, "title")?.value || "", o = C(t, "source")?.value || "", r = C(t, "url")?.value || "", a = C(t, "note")?.value || "";

@@ -653,7 +653,7 @@ return {

}
function ee(t, e, n) {
function ne(t, e, n) {
const i = C(e, "style");
i && (i.value = N(t, n));
}
function Nt(t, e, n) {
function zt(t, e, n) {
const i = L.includes(e) ? e : n.defaultStyle;

@@ -666,6 +666,6 @@ return T.set(t, i), y(t, n, !0), i;

}
function ne(t) {
function oe(t) {
const e = v.get(t);
if (e) return e;
const n = f.get(t) || M || Z(), i = `rte-citations-panel-${Ot++}`, o = document.createElement("section");
const n = f.get(t) || M || Z(), i = `rte-citations-panel-${Pt++}`, o = document.createElement("section");
o.className = b, o.id = i, o.setAttribute("role", "dialog"), o.setAttribute("aria-modal", "false"), o.setAttribute("aria-label", n.labels.panelAriaLabel), o.setAttribute("tabindex", "-1"), o.innerHTML = `

@@ -740,3 +740,3 @@ <header class="rte-citations-header">

if ($(t)) return;
const d = te(o);
const d = ee(o);
if (!l.normalizeText(d.author) || !l.normalizeText(d.title)) {

@@ -762,3 +762,3 @@ E(o, l.labels.invalidMessage);

const d = bt(t, l);
ee(t, o, l), E(o, `Style changed to ${d.toUpperCase()}.`);
ne(t, o, l), E(o, `Style changed to ${d.toUpperCase()}.`);
return;

@@ -768,3 +768,3 @@ }

if ($(t)) return;
const d = u.getAttribute("data-citation-id") || "", m = Et(t, d, K(t, l), l);
const d = u.getAttribute("data-citation-id") || "", m = St(t, d, j(t, l), l);
if (!m) return;

@@ -777,7 +777,7 @@ et(t, m, l), E(o, `Inserted citation: ${m.title}.`);

const d = u.getAttribute("data-citation-id") || "";
if (Rt(t, d, l)) {
if (Nt(t, d, l)) {
E(o, "Citation deleted.");
return;
}
qt(t, d, l) && (H(t), E(o, "Removed from recent citations."));
Kt(t, d, l) && (H(t), E(o, "Removed from recent citations."));
}

@@ -802,26 +802,29 @@ }), o.addEventListener("keydown", (a) => {

const a = f.get(t) || M || n, s = r.value;
Nt(t, s, a), E(o, `Style changed to ${s.toUpperCase()}.`);
zt(t, s, a), E(o, `Style changed to ${s.toUpperCase()}.`);
}), tt(o, t), document.body.appendChild(o), v.set(t, o), V.set(t, !1), H(t), o;
}
function z(t) {
const e = ne(t);
Qt(t), e.classList.add("show"), V.set(t, !0), it(t, "toggleCitationsPanel", !0), tt(e, t), ct(t, e), H(t), C(e, "author")?.focus();
const e = oe(t);
te(t), e.classList.add("show"), V.set(t, !0), it(t, "toggleCitationsPanel", !0), tt(e, t), ct(t, e), H(t), C(e, "author")?.focus();
}
function zt(t, e) {
function It(t, e) {
const n = nt(t);
return (typeof e == "boolean" ? e : !n) ? z(t) : U(t, !1), !0;
}
function oe(t) {
const e = t.key.toLowerCase();
function gt(t) {
return typeof t.key == "string" ? t.key.toLowerCase() : "";
}
function ie(t) {
const e = gt(t);
return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "c";
}
function ie(t) {
const e = t.key.toLowerCase();
function re(t) {
const e = gt(t);
return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "b";
}
function re(t) {
const e = t.key.toLowerCase();
function ae(t) {
const e = gt(t);
return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "j";
}
function ae(t) {
function se(t) {
M = t, I || (I = (e) => {

@@ -835,3 +838,3 @@ const i = e.target?.closest(S);

const i = e.target?.closest(S);
i && (p = i, kt(i));
i && (p = i, Tt(i));
}, document.addEventListener("input", B, !0)), O || (O = (e) => {

@@ -846,12 +849,12 @@ if (e.defaultPrevented) return;

}
if (!i && !Xt(e, o, r)) {
if (oe(e)) {
e.preventDefault(), e.stopPropagation(), zt(o);
if (!i && !Jt(e, o, r)) {
if (ie(e)) {
e.preventDefault(), e.stopPropagation(), It(o);
return;
}
if (ie(e)) {
if (re(e)) {
e.preventDefault(), e.stopPropagation(), y(o, r, !0), z(o);
return;
}
re(e) && (e.preventDefault(), e.stopPropagation(), bt(o, r));
ae(e) && (e.preventDefault(), e.stopPropagation(), bt(o, r));
}

@@ -861,3 +864,3 @@ }, document.addEventListener("keydown", O, !0)), k || (k = () => {

if (!n.isConnected || !e.isConnected) {
At(n), e.remove(), v.delete(n), V.delete(n);
kt(n), e.remove(), v.delete(n), V.delete(n);
return;

@@ -869,9 +872,9 @@ }

}
function se() {
function ce() {
I && (document.removeEventListener("focusin", I, !0), I = null), B && (document.removeEventListener("input", B, !0), B = null), O && (document.removeEventListener("keydown", O, !0), O = null), k && (window.removeEventListener("scroll", k, !0), window.removeEventListener("resize", k), k = null), v.forEach((t) => t.remove()), v.clear(), M = null, p = null;
}
function ce() {
if (typeof document > "u" || document.getElementById(mt)) return;
function le() {
if (typeof document > "u" || document.getElementById(pt)) return;
const t = document.createElement("style");
t.id = mt, t.textContent = `
t.id = pt, t.textContent = `
.rte-toolbar-group-items.citations,

@@ -1346,5 +1349,5 @@ .editora-toolbar-group-items.citations {

}
const le = (t = {}) => {
const ue = (t = {}) => {
const e = Z(t);
return ce(), {
return le(), {
name: "citations",

@@ -1394,3 +1397,3 @@ toolbar: [

f.set(o, r), p = o;
const a = zt(o, typeof n == "boolean" ? n : void 0);
const a = It(o, typeof n == "boolean" ? n : void 0);
return nt(o) && y(o, r, !1), a;

@@ -1416,3 +1419,3 @@ },

const r = f.get(o) || e;
return f.set(o, r), p = o, Nt(o, n, r), !0;
return f.set(o, r), p = o, zt(o, n, r), !0;
},

@@ -1428,3 +1431,3 @@ cycleCitationStyle: (n, i) => {

if (!o) return !1;
const r = f.get(o) || e, a = K(o, r);
const r = f.get(o) || e, a = j(o, r);
if (typeof n == "function")

@@ -1462,3 +1465,3 @@ try {

const o = h(i);
return !o || typeof n != "string" ? !1 : Zt(o, n);
return !o || typeof n != "string" ? !1 : Qt(o, n);
},

@@ -1469,3 +1472,3 @@ deleteCitation: (n, i) => {

const r = f.get(o) || e;
return f.set(o, r), typeof n == "string" && n.trim() ? Rt(o, n, r) : Jt(o, r);
return f.set(o, r), typeof n == "string" && n.trim() ? Nt(o, n, r) : Zt(o, r);
},

@@ -1477,5 +1480,5 @@ insertRecentCitation: (n, i) => {

f.set(o, r);
const a = K(o, r), s = rt(o, a, r);
const a = j(o, r), s = rt(o, a, r);
if (s.length === 0) return !1;
const u = typeof n == "string" && n.trim() ? Et(o, n, a, r) : s[0];
const u = typeof n == "string" && n.trim() ? St(o, n, a, r) : s[0];
if (!u) return !1;

@@ -1497,3 +1500,3 @@ const c = et(o, u, r);

const o = this && typeof this.__pluginConfig == "object" ? Z({ ...e, ...this.__pluginConfig }) : e;
ae(o);
se(o);
const r = h(

@@ -1503,3 +1506,3 @@ i && i.editorElement ? { editorElement: i.editorElement } : void 0,

);
r && (p = r, f.set(r, o), T.set(r, o.defaultStyle), it(r, "toggleCitationsPanel", !1), kt(r));
r && (p = r, f.set(r, o), T.set(r, o.defaultStyle), it(r, "toggleCitationsPanel", !1), Tt(r));
},

@@ -1509,3 +1512,3 @@ destroy: () => {

window.clearTimeout(n);
}), q.clear(), se());
}), q.clear(), ce());
}

@@ -1515,3 +1518,3 @@ };

export {
le as CitationsPlugin
ue as CitationsPlugin
};

@@ -1,1 +0,1 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=()=>({name:"clearFormatting",toolbar:[{label:"Clear Formatting",command:"clearFormatting",icon:'<svg width="24" height="24" focusable="false"><path d="M13.2 6a1 1 0 0 1 0 .2l-2.6 10a1 1 0 0 1-1 .8h-.2a.8.8 0 0 1-.8-1l2.6-10H8a1 1 0 1 1 0-2h9a1 1 0 0 1 0 2h-3.8ZM5 18h7a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Zm13 1.5L16.5 18 15 19.5a.7.7 0 0 1-1-1l1.5-1.5-1.5-1.5a.7.7 0 0 1 1-1l1.5 1.5 1.5-1.5a.7.7 0 0 1 1 1L17.5 17l1.5 1.5a.7.7 0 0 1-1 1Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-\\"}],commands:{clearFormatting:()=>{const t=f();if(!t)return!1;const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const o=e.getRangeAt(0);if(!t.contains(o.commonAncestorContainer))return!1;const n=o.cloneRange();return t.focus({preventScroll:!0}),document.execCommand("unlink",!1),document.execCommand("removeFormat",!1),h(t,n),m(t,n),t.dispatchEvent(new Event("input",{bubbles:!0})),!0}},keymap:{"Mod-\\":"clearFormatting"}}),l=new Set(["A","B","STRONG","I","EM","U","S","STRIKE","DEL","FONT","MARK","CODE","SUB","SUP"]),u=new Set(["H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE"]),d=["color","background-color","font-size","font-family","font-weight","font-style","text-decoration","text-transform","line-height","letter-spacing","word-spacing","vertical-align","text-align","padding-left"];function f(){const t=window.getSelection();if(t&&t.rangeCount>0){const o=t.getRangeAt(0).startContainer,r=(o.nodeType===Node.ELEMENT_NODE?o:o.parentElement)?.closest('[contenteditable="true"], .rte-content, .editora-content');if(r)return r}const e=document.activeElement;return e?e.getAttribute("contenteditable")==="true"?e:e.closest('[contenteditable="true"], .rte-content, .editora-content'):null}function c(t,e){try{if(typeof t.intersectsNode=="function")return t.intersectsNode(e)}catch{}const o=document.createRange();return e.nodeType===Node.ELEMENT_NODE?o.selectNodeContents(e):o.selectNode(e),t.compareBoundaryPoints(Range.END_TO_START,o)>0&&t.compareBoundaryPoints(Range.START_TO_END,o)<0}function a(t){let e=0,o=t;for(;o&&o.parentNode;)e+=1,o=o.parentNode;return e}function g(t){d.forEach(e=>{t.style.removeProperty(e)}),(!t.getAttribute("style")||t.style.length===0)&&t.removeAttribute("style"),t.classList.contains("rte-text-color")&&t.classList.remove("rte-text-color"),t.classList.contains("rte-bg-color")&&t.classList.remove("rte-bg-color"),t.classList.length===0&&t.removeAttribute("class")}function i(t){const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t)}}function h(t,e){Array.from(t.querySelectorAll("h1,h2,h3,h4,h5,h6,blockquote,pre")).forEach(n=>{if(!c(e,n)||!u.has(n.tagName))return;const r=document.createElement("p");for(;n.firstChild;)r.appendChild(n.firstChild);n.parentNode?.replaceChild(r,n)})}function m(t,e){const o=Array.from(t.querySelectorAll("a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span,[style],[class]"));o.sort((n,r)=>a(r)-a(n)),o.forEach(n=>{if(n.isConnected&&c(e,n)&&!(n.getAttribute("contenteditable")==="false"||n.closest('[contenteditable="false"]'))){if(g(n),l.has(n.tagName)){i(n);return}n.tagName==="SPAN"&&n.attributes.length===0&&i(n)}})}exports.ClearFormattingPlugin=s;
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=()=>({name:"clearFormatting",toolbar:[{label:"Clear Formatting",command:"clearFormatting",icon:'<svg width="24" height="24" focusable="false"><path d="M13.2 6a1 1 0 0 1 0 .2l-2.6 10a1 1 0 0 1-1 .8h-.2a.8.8 0 0 1-.8-1l2.6-10H8a1 1 0 1 1 0-2h9a1 1 0 0 1 0 2h-3.8ZM5 18h7a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Zm13 1.5L16.5 18 15 19.5a.7.7 0 0 1-1-1l1.5-1.5-1.5-1.5a.7.7 0 0 1 1-1l1.5 1.5 1.5-1.5a.7.7 0 0 1 1 1L17.5 17l1.5 1.5a.7.7 0 0 1-1 1Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-\\"}],commands:{clearFormatting:()=>{const t=m();if(!t)return!1;const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const n=e.getRangeAt(0);if(!t.contains(n.commonAncestorContainer))return!1;const r=n.cloneRange();return t.focus({preventScroll:!0}),A(t,r),C(t,r),t.dispatchEvent(new Event("input",{bubbles:!0})),!0}},keymap:{"Mod-\\":"clearFormatting"}}),d=new Set(["A","B","STRONG","I","EM","U","S","STRIKE","DEL","FONT","MARK","CODE","SUB","SUP"]),g=new Set(["H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE"]),h=["color","background-color","font-size","font-family","font-weight","font-style","text-decoration","text-transform","line-height","letter-spacing","word-spacing","vertical-align","text-align","padding-left"];function m(){const t=window.getSelection();if(t&&t.rangeCount>0){const n=t.getRangeAt(0).startContainer,o=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest('[contenteditable="true"], .rte-content, .editora-content');if(o)return o}const e=document.activeElement;return e?e.getAttribute("contenteditable")==="true"?e:e.closest('[contenteditable="true"], .rte-content, .editora-content'):null}function c(t,e){try{if(typeof t.intersectsNode=="function")return t.intersectsNode(e)}catch{}const n=document.createRange();return e.nodeType===Node.ELEMENT_NODE?n.selectNodeContents(e):n.selectNode(e),t.compareBoundaryPoints(Range.END_TO_START,n)>0&&t.compareBoundaryPoints(Range.START_TO_END,n)<0}function i(t){let e=0,n=t;for(;n&&n.parentNode;)e+=1,n=n.parentNode;return e}function p(t){h.forEach(e=>{t.style.removeProperty(e)}),(!t.getAttribute("style")||t.style.length===0)&&t.removeAttribute("style"),t.classList.contains("rte-text-color")&&t.classList.remove("rte-text-color"),t.classList.contains("rte-bg-color")&&t.classList.remove("rte-bg-color"),t.classList.length===0&&t.removeAttribute("class")}function a(t){const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t)}}function E(t){return t.tagName!=="P"||t.attributes.length>0||(t.textContent||"").trim()!==""?!1:!t.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function l(t){Array.from(t.children).forEach(e=>{E(e)&&e.remove()})}function s(t){l(t),a(t)}function f(t){const e=document.createElement("p");for(Array.from(t.attributes).forEach(n=>{e.setAttribute(n.name,n.value)});t.firstChild;)e.appendChild(t.firstChild);e.innerHTML.trim()||(e.innerHTML="<br>"),t.parentNode?.replaceChild(e,t)}function N(t){if(l(t),t.parentElement instanceof HTMLLIElement){s(t);return}if(Array.from(t.childNodes).filter(o=>o.nodeType!==Node.TEXT_NODE||(o.textContent||"").trim()!=="").some(o=>o instanceof HTMLElement&&/^(P|DIV|H[1-6]|UL|OL|PRE|TABLE|BLOCKQUOTE)$/.test(o.tagName))){s(t);return}f(t)}function C(t,e){Array.from(t.querySelectorAll("h1,h2,h3,h4,h5,h6,blockquote,pre")).forEach(r=>{if(c(e,r)&&g.has(r.tagName)){if(r.tagName==="BLOCKQUOTE"){N(r);return}f(r)}})}function A(t,e){const n=Array.from(t.querySelectorAll("a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span,[style],[class]"));n.sort((r,o)=>i(o)-i(r)),n.forEach(r=>{if(r.isConnected&&c(e,r)&&!(r.getAttribute("contenteditable")==="false"||r.closest('[contenteditable="false"]'))){if(p(r),d.has(r.tagName)){a(r);return}r.tagName==="SPAN"&&r.attributes.length===0&&a(r)}})}exports.ClearFormattingPlugin=u;

@@ -1,2 +0,2 @@

const m = () => ({
const C = () => ({
name: "clearFormatting",

@@ -18,10 +18,10 @@ // Toolbar button configuration

clearFormatting: () => {
const t = d();
const t = h();
if (!t) return !1;
const e = window.getSelection();
if (!e || e.rangeCount === 0) return !1;
const o = e.getRangeAt(0);
if (!t.contains(o.commonAncestorContainer)) return !1;
const n = o.cloneRange();
return t.focus({ preventScroll: !0 }), document.execCommand("unlink", !1), document.execCommand("removeFormat", !1), g(t, n), h(t, n), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
const n = e.getRangeAt(0);
if (!t.contains(n.commonAncestorContainer)) return !1;
const r = n.cloneRange();
return t.focus({ preventScroll: !0 }), A(t, r), N(t, r), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
}

@@ -33,3 +33,3 @@ },

}
}), s = /* @__PURE__ */ new Set([
}), u = /* @__PURE__ */ new Set([
"A",

@@ -49,3 +49,3 @@ "B",

"SUP"
]), l = /* @__PURE__ */ new Set([
]), d = /* @__PURE__ */ new Set([
"H1",

@@ -59,3 +59,3 @@ "H2",

"PRE"
]), u = [
]), g = [
"color",

@@ -76,7 +76,7 @@ "background-color",

];
function d() {
function h() {
const t = window.getSelection();
if (t && t.rangeCount > 0) {
const o = t.getRangeAt(0).startContainer, r = (o.nodeType === Node.ELEMENT_NODE ? o : o.parentElement)?.closest('[contenteditable="true"], .rte-content, .editora-content');
if (r) return r;
const n = t.getRangeAt(0).startContainer, o = (n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest('[contenteditable="true"], .rte-content, .editora-content');
if (o) return o;
}

@@ -92,17 +92,17 @@ const e = document.activeElement;

}
const o = document.createRange();
return e.nodeType === Node.ELEMENT_NODE ? o.selectNodeContents(e) : o.selectNode(e), t.compareBoundaryPoints(Range.END_TO_START, o) > 0 && t.compareBoundaryPoints(Range.START_TO_END, o) < 0;
const n = document.createRange();
return e.nodeType === Node.ELEMENT_NODE ? n.selectNodeContents(e) : n.selectNode(e), t.compareBoundaryPoints(Range.END_TO_START, n) > 0 && t.compareBoundaryPoints(Range.START_TO_END, n) < 0;
}
function a(t) {
let e = 0, o = t;
for (; o && o.parentNode; )
e += 1, o = o.parentNode;
function i(t) {
let e = 0, n = t;
for (; n && n.parentNode; )
e += 1, n = n.parentNode;
return e;
}
function f(t) {
u.forEach((e) => {
function m(t) {
g.forEach((e) => {
t.style.removeProperty(e);
}), (!t.getAttribute("style") || t.style.length === 0) && t.removeAttribute("style"), t.classList.contains("rte-text-color") && t.classList.remove("rte-text-color"), t.classList.contains("rte-bg-color") && t.classList.remove("rte-bg-color"), t.classList.length === 0 && t.removeAttribute("class");
}
function i(t) {
function a(t) {
const e = t.parentNode;

@@ -115,15 +115,47 @@ if (e) {

}
function g(t, e) {
function p(t) {
return t.tagName !== "P" || t.attributes.length > 0 || (t.textContent || "").trim() !== "" ? !1 : !t.querySelector("img, video, table, iframe, hr, pre, ul, ol");
}
function l(t) {
Array.from(t.children).forEach((e) => {
p(e) && e.remove();
});
}
function s(t) {
l(t), a(t);
}
function f(t) {
const e = document.createElement("p");
for (Array.from(t.attributes).forEach((n) => {
e.setAttribute(n.name, n.value);
}); t.firstChild; )
e.appendChild(t.firstChild);
e.innerHTML.trim() || (e.innerHTML = "<br>"), t.parentNode?.replaceChild(e, t);
}
function E(t) {
if (l(t), t.parentElement instanceof HTMLLIElement) {
s(t);
return;
}
if (Array.from(t.childNodes).filter((o) => o.nodeType !== Node.TEXT_NODE || (o.textContent || "").trim() !== "").some((o) => o instanceof HTMLElement && /^(P|DIV|H[1-6]|UL|OL|PRE|TABLE|BLOCKQUOTE)$/.test(o.tagName))) {
s(t);
return;
}
f(t);
}
function N(t, e) {
Array.from(
t.querySelectorAll("h1,h2,h3,h4,h5,h6,blockquote,pre")
).forEach((n) => {
if (!c(e, n) || !l.has(n.tagName)) return;
const r = document.createElement("p");
for (; n.firstChild; )
r.appendChild(n.firstChild);
n.parentNode?.replaceChild(r, n);
).forEach((r) => {
if (c(e, r) && d.has(r.tagName)) {
if (r.tagName === "BLOCKQUOTE") {
E(r);
return;
}
f(r);
}
});
}
function h(t, e) {
const o = Array.from(
function A(t, e) {
const n = Array.from(
t.querySelectorAll(

@@ -133,9 +165,9 @@ "a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span,[style],[class]"

);
o.sort((n, r) => a(r) - a(n)), o.forEach((n) => {
if (n.isConnected && c(e, n) && !(n.getAttribute("contenteditable") === "false" || n.closest('[contenteditable="false"]'))) {
if (f(n), s.has(n.tagName)) {
i(n);
n.sort((r, o) => i(o) - i(r)), n.forEach((r) => {
if (r.isConnected && c(e, r) && !(r.getAttribute("contenteditable") === "false" || r.closest('[contenteditable="false"]'))) {
if (m(r), u.has(r.tagName)) {
a(r);
return;
}
n.tagName === "SPAN" && n.attributes.length === 0 && i(n);
r.tagName === "SPAN" && r.attributes.length === 0 && a(r);
}

@@ -145,3 +177,3 @@ });

export {
m as ClearFormattingPlugin
C as ClearFormattingPlugin
};

@@ -1,2 +0,2 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const R=".rte-content, .editora-content",ee="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",oe="__editoraCommandEditorRoot",se="rte-content-rules-styles",f="rte-content-rules-panel",P=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',he={panelTitle:"Content Rules",panelAriaLabel:"Content rules panel",runAuditText:"Run Audit",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",noIssuesText:"No rule violations detected.",summaryPrefix:"Issues",locateText:"Locate",bannedWordMessage:"Banned word found",requiredHeadingMessage:"Missing required heading",sentenceLengthMessage:"Sentence is too long",readabilityMessage:"Readability score is below threshold"},d=new WeakMap,v=new WeakMap,de=new WeakMap,T=new WeakMap,V=new WeakMap,le=new WeakMap,Y=new WeakMap,h=new Map,B=new WeakMap,z=new Set;let N=0,pe=0,E=null,g=null,L=null,I=null,H=null,S=null;function k(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function xe(e){return{...he,...e||{}}}function ye(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function ae(e){if(!e)return[];const t=new Set;return e.forEach(n=>{const o=n.trim();o&&t.add(o)}),Array.from(t)}function j(e={}){return{bannedWords:ae(e.bannedWords),requiredHeadings:ae(e.requiredHeadings),maxSentenceWords:Math.max(8,Number(e.maxSentenceWords??32)),minReadabilityScore:Math.max(0,Math.min(120,Number(e.minReadabilityScore??55))),maxIssues:Math.max(1,Number(e.maxIssues??100)),debounceMs:Math.max(50,Number(e.debounceMs??220)),enableRealtime:e.enableRealtime!==!1,labels:xe(e.labels),normalizeText:e.normalizeText||ye,customRules:Array.isArray(e.customRules)?e.customRules:[]}}function X(e){return e.closest(ee)||e}function F(e){if(!e)return null;if(e.matches(R))return e;const t=e.querySelector(R);return t instanceof HTMLElement?t:null}function we(){if(typeof window>"u")return null;const e=window[oe];if(!(e instanceof HTMLElement))return null;window[oe]=null;const t=F(e);if(t)return t;const n=e.closest(ee);if(n){const o=F(n);if(o)return o}return null}function ke(e){const t=e.closest("[data-editora-editor]");if(t&&F(t)===e)return t;let n=e;for(;n;){if(n.matches(ee)&&(n===e||F(n)===e))return n;n=n.parentElement}return X(e)}function K(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 Re(e){const t=X(e);if(K(t))return!0;const n=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return K(n)?!0:K(document.documentElement)||K(document.body)}function G(e,t){e.classList.remove("rte-content-rules-theme-dark"),Re(t)&&e.classList.add("rte-content-rules-theme-dark")}function Ee(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function $(e,t=!0){if(e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const s=e.editorElement;if(s.matches(R))return s;const i=s.querySelector(R);if(i instanceof HTMLElement)return i}const n=we();if(n)return n;const o=window.getSelection();if(o&&o.rangeCount>0){const s=o.getRangeAt(0).startContainer,l=Ee(s)?.closest(R);if(l)return l}const r=document.activeElement;if(r){if(r.matches(R))return r;const s=r.closest(R);if(s)return s}return g&&g.isConnected?g:(g&&!g.isConnected&&(g=null),t?document.querySelector(R):null)}function Z(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function Ce(e,t){const n=e.innerText||e.textContent||"";return t(n)}function ve(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ie(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function ce(e){const t=e.match(/\b[\w'-]+\b/g);return t?t.length:0}function fe(e){const t=e.match(/[^.!?]+[.!?]*/g);return t?t.map(n=>n.trim()).filter(Boolean).length:0}function Me(e){const t=e.toLowerCase().replace(/[^a-z]/g,"");if(!t)return 0;if(t.length<=3)return 1;const n=t.match(/[aeiouy]+/g);let o=n?n.length:1;return t.endsWith("e")&&(o-=1),Math.max(1,o)}function $e(e){const t=e.match(/\b[\w'-]+\b/g)||[],n=t.length;if(n===0)return 100;const o=Math.max(1,fe(e)),r=t.reduce((i,l)=>i+Me(l),0),s=206.835-1.015*(n/o)-84.6*(r/Math.max(1,n));return Number.isFinite(s)?Math.max(0,Math.min(120,s)):0}function _(e,t){return`${e}-${t}`}function x(e,t){return e.length>=t}function q(e,t,n){x(e,n)||e.push(t)}function ge(e,t=140){return e.length<=t?e:`${e.slice(0,t-1).trimEnd()}...`}function Se(e,t,n,o){return{id:e.id||_(t,o),ruleId:e.ruleId||t,severity:e.severity||n,message:e.message||t,excerpt:e.excerpt?ge(e.excerpt,220):void 0,suggestion:e.suggestion,locateText:e.locateText,selector:e.selector}}function Te(e,t){const n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),o=new Set;return n.forEach(r=>{const s=t(r.textContent||"").toLowerCase();s&&o.add(s)}),o}function Ae(e){const t=e.match(/[^.!?\n]+[.!?]?/g);return t?t.map(n=>n.trim()).filter(Boolean):[]}async function C(e,t,n=!1){const o=Ce(e,t.normalizeText),r=e.innerHTML,s=`${o.length}:${ie(o)}:${r.length}:${ie(r)}`;if(!n&&le.get(e)===s)return v.get(e)||[];const i=(Y.get(e)||0)+1;Y.set(e,i);const l=ce(o),c=fe(o),u=$e(o),a=[],y=t.labels;if(t.bannedWords.length>0){let w=0;for(const p of t.bannedWords){const m=new RegExp(`\\b${ve(p)}\\b`,"gi");let b=m.exec(o);for(;b&&!x(a,t.maxIssues);){const re=b[0];q(a,{id:_("banned-word",w),ruleId:"banned-word",severity:"error",message:`${y.bannedWordMessage}: "${re}"`,locateText:re,suggestion:"Replace or remove banned terms."},t.maxIssues),w+=1,b=m.exec(o)}if(x(a,t.maxIssues))break}}if(!x(a,t.maxIssues)&&t.requiredHeadings.length>0){const w=Te(e,t.normalizeText);let p=0;t.requiredHeadings.forEach(m=>{if(x(a,t.maxIssues))return;const b=t.normalizeText(m).toLowerCase();!b||w.has(b)||(q(a,{id:_("required-heading",p),ruleId:"required-heading",severity:"warning",message:`${y.requiredHeadingMessage}: "${m}"`,suggestion:`Add a heading named "${m}".`},t.maxIssues),p+=1)})}if(!x(a,t.maxIssues)){const w=Ae(o);let p=0;for(const m of w){if(x(a,t.maxIssues))break;const b=ce(m);b<=t.maxSentenceWords||(q(a,{id:_("sentence-length",p),ruleId:"sentence-length",severity:"warning",message:`${y.sentenceLengthMessage} (${b}/${t.maxSentenceWords} words)`,excerpt:ge(m,200),locateText:m.slice(0,64),suggestion:"Split into shorter sentences for readability."},t.maxIssues),p+=1)}}if(!x(a,t.maxIssues)&&l>0&&u<t.minReadabilityScore&&q(a,{id:_("readability",0),ruleId:"readability",severity:"info",message:`${y.readabilityMessage}: ${u.toFixed(1)} < ${t.minReadabilityScore}`,suggestion:"Use shorter sentences and simpler wording."},t.maxIssues),!x(a,t.maxIssues)&&t.customRules.length>0){const w={editor:e,editorRoot:X(e),text:o,html:r,wordCount:l,sentenceCount:c,readabilityScore:u};for(const p of t.customRules){if(x(a,t.maxIssues))break;try{const m=await p.evaluate(w);if(!Array.isArray(m))continue;for(let b=0;b<m.length&&!x(a,t.maxIssues);b+=1)q(a,Se(m[b],p.id,p.severity||"warning",b),t.maxIssues)}catch{}}}if(Y.get(e)!==i)return v.get(e)||[];const D={readabilityScore:u,wordCount:l,sentenceCount:c};return le.set(e,s),v.set(e,a),de.set(e,D),te(e),e.dispatchEvent(new CustomEvent("editora:content-rules-audit",{bubbles:!0,detail:{issues:a,metrics:D}})),a}function Le(e){return e.reduce((t,n)=>(t[n.severity]+=1,t),{error:0,warning:0,info:0})}function Ie(e){return e==="error"?"Error":e==="warning"?"Warning":"Info"}function M(e,t,n){const o=ke(e);Array.from(o.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(s=>{s.classList.toggle("active",n),s.setAttribute("data-active",n?"true":"false"),s.setAttribute("aria-pressed",n?"true":"false")})}function U(e){return B.get(e)===!0}function J(e,t){if(!t.classList.contains("show"))return;const o=X(e).getBoundingClientRect(),r=Math.min(window.innerWidth-20,360);t.style.width=`${r}px`,t.style.maxHeight=`${Math.max(220,window.innerHeight-24)}px`;const s=Math.max(10,o.right-r),i=Math.max(10,window.innerWidth-r-10),l=Math.min(s,i),c=Math.max(10,Math.min(window.innerHeight-10-240,o.top+10));t.style.left=`${l}px`,t.style.top=`${c}px`}function ue(e,t){const n=t.trim().toLowerCase();if(!n)return!1;const o=window.getSelection();if(!o)return!1;const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let s=r.nextNode();for(;s;){const l=s.data.toLowerCase().indexOf(n);if(l!==-1){const c=document.createRange();c.setStart(s,l),c.setEnd(s,Math.min(s.length,l+n.length)),o.removeAllRanges(),o.addRange(c);const u=s.parentElement;return u&&u.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),e.focus({preventScroll:!0}),!0}s=r.nextNode()}return!1}function He(e,t){if(t.selector){const n=e.querySelector(t.selector);if(n)return n.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),n.focus({preventScroll:!0}),!0}return!!(t.locateText&&ue(e,t.locateText)||t.excerpt&&ue(e,t.excerpt.slice(0,64)))}function Oe(e,t){return(v.get(e)||[]).find(o=>o.id===t)}function A(e,t){const n=T.get(e);return typeof n=="boolean"?n:t?t.enableRealtime:!0}function W(e,t,n){const o=t.querySelector('[data-action="toggle-realtime"]');if(!o)return;const r=A(e,n);o.textContent=r?n.labels.realtimeOnText:n.labels.realtimeOffText,o.setAttribute("aria-pressed",r?"true":"false"),M(e,"toggleContentRulesRealtime",r)}function te(e){const t=h.get(e);if(!t)return;const n=d.get(e)||E;if(!n)return;const o=v.get(e)||[],r=de.get(e)||{readabilityScore:100},s=t.querySelector(".rte-content-rules-count"),i=t.querySelector(".rte-content-rules-summary"),l=t.querySelector(".rte-content-rules-list"),c=t.querySelector(".rte-content-rules-live");if(!s||!i||!l||!c)return;const u=Le(o);if(s.textContent=String(o.length),i.textContent=`${n.labels.summaryPrefix}: ${o.length} | Error ${u.error} | Warning ${u.warning} | Info ${u.info} | Readability ${r.readabilityScore.toFixed(1)}`,c.textContent=`${o.length} issues. ${u.error} errors, ${u.warning} warnings, ${u.info} info.`,o.length===0){l.innerHTML=`<li class="rte-content-rules-empty">${k(n.labels.noIssuesText)}</li>`;return}l.innerHTML=o.map(a=>{const y=a.excerpt?`<p class="rte-content-rules-excerpt">${k(a.excerpt)}</p>`:"",D=a.suggestion?`<p class="rte-content-rules-suggestion">${k(a.suggestion)}</p>`:"",w=`${n.labels.locateText}: ${a.message}`;return`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const R=".rte-content, .editora-content",ee="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",se="__editoraCommandEditorRoot",le="rte-content-rules-styles",f="rte-content-rules-panel",P=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',pe={panelTitle:"Content Rules",panelAriaLabel:"Content rules panel",runAuditText:"Run Audit",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",noIssuesText:"No rule violations detected.",summaryPrefix:"Issues",locateText:"Locate",bannedWordMessage:"Banned word found",requiredHeadingMessage:"Missing required heading",sentenceLengthMessage:"Sentence is too long",readabilityMessage:"Readability score is below threshold"},d=new WeakMap,C=new WeakMap,fe=new WeakMap,T=new WeakMap,V=new WeakMap,ae=new WeakMap,Y=new WeakMap,h=new Map,B=new WeakMap,z=new Set;let N=0,xe=0,E=null,g=null,L=null,I=null,H=null,S=null;function k(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ye(e){return{...pe,...e||{}}}function we(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function ie(e){if(!e)return[];const t=new Set;return e.forEach(n=>{const o=n.trim();o&&t.add(o)}),Array.from(t)}function j(e={}){return{bannedWords:ie(e.bannedWords),requiredHeadings:ie(e.requiredHeadings),maxSentenceWords:Math.max(8,Number(e.maxSentenceWords??32)),minReadabilityScore:Math.max(0,Math.min(120,Number(e.minReadabilityScore??55))),maxIssues:Math.max(1,Number(e.maxIssues??100)),debounceMs:Math.max(50,Number(e.debounceMs??220)),enableRealtime:e.enableRealtime!==!1,labels:ye(e.labels),normalizeText:e.normalizeText||we,customRules:Array.isArray(e.customRules)?e.customRules:[]}}function X(e){return e.closest(ee)||e}function F(e){if(!e)return null;if(e.matches(R))return e;const t=e.querySelector(R);return t instanceof HTMLElement?t:null}function ke(){if(typeof window>"u")return null;const e=window[se];if(!(e instanceof HTMLElement))return null;window[se]=null;const t=F(e);if(t)return t;const n=e.closest(ee);if(n){const o=F(n);if(o)return o}return null}function Re(e){const t=e.closest("[data-editora-editor]");if(t&&F(t)===e)return t;let n=e;for(;n;){if(n.matches(ee)&&(n===e||F(n)===e))return n;n=n.parentElement}return X(e)}function K(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 Ee(e){const t=X(e);if(K(t))return!0;const n=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return K(n)?!0:K(document.documentElement)||K(document.body)}function G(e,t){e.classList.remove("rte-content-rules-theme-dark"),Ee(t)&&e.classList.add("rte-content-rules-theme-dark")}function ve(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function $(e,t=!0){if(e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const s=e.editorElement;if(s.matches(R))return s;const i=s.querySelector(R);if(i instanceof HTMLElement)return i}const n=ke();if(n)return n;const o=window.getSelection();if(o&&o.rangeCount>0){const s=o.getRangeAt(0).startContainer,l=ve(s)?.closest(R);if(l)return l}const r=document.activeElement;if(r){if(r.matches(R))return r;const s=r.closest(R);if(s)return s}return g&&g.isConnected?g:(g&&!g.isConnected&&(g=null),t?document.querySelector(R):null)}function Z(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function Ce(e,t){const n=e.innerText||e.textContent||"";return t(n)}function Me(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ce(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function ue(e){const t=e.match(/\b[\w'-]+\b/g);return t?t.length:0}function ge(e){const t=e.match(/[^.!?]+[.!?]*/g);return t?t.map(n=>n.trim()).filter(Boolean).length:0}function $e(e){const t=e.toLowerCase().replace(/[^a-z]/g,"");if(!t)return 0;if(t.length<=3)return 1;const n=t.match(/[aeiouy]+/g);let o=n?n.length:1;return t.endsWith("e")&&(o-=1),Math.max(1,o)}function Se(e){const t=e.match(/\b[\w'-]+\b/g)||[],n=t.length;if(n===0)return 100;const o=Math.max(1,ge(e)),r=t.reduce((i,l)=>i+$e(l),0),s=206.835-1.015*(n/o)-84.6*(r/Math.max(1,n));return Number.isFinite(s)?Math.max(0,Math.min(120,s)):0}function _(e,t){return`${e}-${t}`}function x(e,t){return e.length>=t}function q(e,t,n){x(e,n)||e.push(t)}function me(e,t=140){return e.length<=t?e:`${e.slice(0,t-1).trimEnd()}...`}function Te(e,t,n,o){return{id:e.id||_(t,o),ruleId:e.ruleId||t,severity:e.severity||n,message:e.message||t,excerpt:e.excerpt?me(e.excerpt,220):void 0,suggestion:e.suggestion,locateText:e.locateText,selector:e.selector}}function Ae(e,t){const n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),o=new Set;return n.forEach(r=>{const s=t(r.textContent||"").toLowerCase();s&&o.add(s)}),o}function Le(e){const t=e.match(/[^.!?\n]+[.!?]?/g);return t?t.map(n=>n.trim()).filter(Boolean):[]}async function v(e,t,n=!1){const o=Ce(e,t.normalizeText),r=e.innerHTML,s=`${o.length}:${ce(o)}:${r.length}:${ce(r)}`;if(!n&&ae.get(e)===s)return C.get(e)||[];const i=(Y.get(e)||0)+1;Y.set(e,i);const l=ue(o),c=ge(o),u=Se(o),a=[],y=t.labels;if(t.bannedWords.length>0){let w=0;for(const p of t.bannedWords){const m=new RegExp(`\\b${Me(p)}\\b`,"gi");let b=m.exec(o);for(;b&&!x(a,t.maxIssues);){const oe=b[0];q(a,{id:_("banned-word",w),ruleId:"banned-word",severity:"error",message:`${y.bannedWordMessage}: "${oe}"`,locateText:oe,suggestion:"Replace or remove banned terms."},t.maxIssues),w+=1,b=m.exec(o)}if(x(a,t.maxIssues))break}}if(!x(a,t.maxIssues)&&t.requiredHeadings.length>0){const w=Ae(e,t.normalizeText);let p=0;t.requiredHeadings.forEach(m=>{if(x(a,t.maxIssues))return;const b=t.normalizeText(m).toLowerCase();!b||w.has(b)||(q(a,{id:_("required-heading",p),ruleId:"required-heading",severity:"warning",message:`${y.requiredHeadingMessage}: "${m}"`,suggestion:`Add a heading named "${m}".`},t.maxIssues),p+=1)})}if(!x(a,t.maxIssues)){const w=Le(o);let p=0;for(const m of w){if(x(a,t.maxIssues))break;const b=ue(m);b<=t.maxSentenceWords||(q(a,{id:_("sentence-length",p),ruleId:"sentence-length",severity:"warning",message:`${y.sentenceLengthMessage} (${b}/${t.maxSentenceWords} words)`,excerpt:me(m,200),locateText:m.slice(0,64),suggestion:"Split into shorter sentences for readability."},t.maxIssues),p+=1)}}if(!x(a,t.maxIssues)&&l>0&&u<t.minReadabilityScore&&q(a,{id:_("readability",0),ruleId:"readability",severity:"info",message:`${y.readabilityMessage}: ${u.toFixed(1)} < ${t.minReadabilityScore}`,suggestion:"Use shorter sentences and simpler wording."},t.maxIssues),!x(a,t.maxIssues)&&t.customRules.length>0){const w={editor:e,editorRoot:X(e),text:o,html:r,wordCount:l,sentenceCount:c,readabilityScore:u};for(const p of t.customRules){if(x(a,t.maxIssues))break;try{const m=await p.evaluate(w);if(!Array.isArray(m))continue;for(let b=0;b<m.length&&!x(a,t.maxIssues);b+=1)q(a,Te(m[b],p.id,p.severity||"warning",b),t.maxIssues)}catch{}}}if(Y.get(e)!==i)return C.get(e)||[];const D={readabilityScore:u,wordCount:l,sentenceCount:c};return ae.set(e,s),C.set(e,a),fe.set(e,D),te(e),e.dispatchEvent(new CustomEvent("editora:content-rules-audit",{bubbles:!0,detail:{issues:a,metrics:D}})),a}function Ie(e){return e.reduce((t,n)=>(t[n.severity]+=1,t),{error:0,warning:0,info:0})}function He(e){return e==="error"?"Error":e==="warning"?"Warning":"Info"}function M(e,t,n){const o=Re(e);Array.from(o.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(s=>{s.classList.toggle("active",n),s.setAttribute("data-active",n?"true":"false"),s.setAttribute("aria-pressed",n?"true":"false")})}function U(e){return B.get(e)===!0}function J(e,t){if(!t.classList.contains("show"))return;const o=X(e).getBoundingClientRect(),r=Math.min(window.innerWidth-20,360);t.style.width=`${r}px`,t.style.maxHeight=`${Math.max(220,window.innerHeight-24)}px`;const s=Math.max(10,o.right-r),i=Math.max(10,window.innerWidth-r-10),l=Math.min(s,i),c=Math.max(10,Math.min(window.innerHeight-10-240,o.top+10));t.style.left=`${l}px`,t.style.top=`${c}px`}function de(e,t){const n=t.trim().toLowerCase();if(!n)return!1;const o=window.getSelection();if(!o)return!1;const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let s=r.nextNode();for(;s;){const l=s.data.toLowerCase().indexOf(n);if(l!==-1){const c=document.createRange();c.setStart(s,l),c.setEnd(s,Math.min(s.length,l+n.length)),o.removeAllRanges(),o.addRange(c);const u=s.parentElement;return u&&u.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),e.focus({preventScroll:!0}),!0}s=r.nextNode()}return!1}function Oe(e,t){if(t.selector){const n=e.querySelector(t.selector);if(n)return n.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),n.focus({preventScroll:!0}),!0}return!!(t.locateText&&de(e,t.locateText)||t.excerpt&&de(e,t.excerpt.slice(0,64)))}function We(e,t){return(C.get(e)||[]).find(o=>o.id===t)}function A(e,t){const n=T.get(e);return typeof n=="boolean"?n:t?t.enableRealtime:!0}function W(e,t,n){const o=t.querySelector('[data-action="toggle-realtime"]');if(!o)return;const r=A(e,n);o.textContent=r?n.labels.realtimeOnText:n.labels.realtimeOffText,o.setAttribute("aria-pressed",r?"true":"false"),M(e,"toggleContentRulesRealtime",r)}function te(e){const t=h.get(e);if(!t)return;const n=d.get(e)||E;if(!n)return;const o=C.get(e)||[],r=fe.get(e)||{readabilityScore:100},s=t.querySelector(".rte-content-rules-count"),i=t.querySelector(".rte-content-rules-summary"),l=t.querySelector(".rte-content-rules-list"),c=t.querySelector(".rte-content-rules-live");if(!s||!i||!l||!c)return;const u=Ie(o);if(s.textContent=String(o.length),i.textContent=`${n.labels.summaryPrefix}: ${o.length} | Error ${u.error} | Warning ${u.warning} | Info ${u.info} | Readability ${r.readabilityScore.toFixed(1)}`,c.textContent=`${o.length} issues. ${u.error} errors, ${u.warning} warnings, ${u.info} info.`,o.length===0){l.innerHTML=`<li class="rte-content-rules-empty">${k(n.labels.noIssuesText)}</li>`;return}l.innerHTML=o.map(a=>{const y=a.excerpt?`<p class="rte-content-rules-excerpt">${k(a.excerpt)}</p>`:"",D=a.suggestion?`<p class="rte-content-rules-suggestion">${k(a.suggestion)}</p>`:"",w=`${n.labels.locateText}: ${a.message}`;return`
<li class="rte-content-rules-item rte-content-rules-item-${a.severity}">

@@ -11,3 +11,3 @@ <button

>
<span class="rte-content-rules-badge">${k(Ie(a.severity))}</span>
<span class="rte-content-rules-badge">${k(He(a.severity))}</span>
<span class="rte-content-rules-message">${k(a.message)}</span>

@@ -18,3 +18,3 @@ </button>

</li>
`}).join("")}function O(e,t=!1){const n=h.get(e);n&&(n.classList.remove("show"),B.set(e,!1),M(e,"toggleContentRulesPanel",!1),t&&e.focus({preventScroll:!0}))}function We(e){h.forEach((t,n)=>{n!==e&&O(n,!1)})}function Pe(e){const t=h.get(e);if(t)return t;const n=d.get(e)||E||j(),o=`rte-content-rules-panel-${pe++}`,r=document.createElement("section");return r.className=f,r.id=o,r.setAttribute("role","dialog"),r.setAttribute("aria-modal","false"),r.setAttribute("aria-label",n.labels.panelAriaLabel),r.innerHTML=`
`}).join("")}function O(e,t=!1){const n=h.get(e);n&&(n.classList.remove("show"),B.set(e,!1),M(e,"toggleContentRulesPanel",!1),t&&e.focus({preventScroll:!0}))}function Pe(e){h.forEach((t,n)=>{n!==e&&O(n,!1)})}function qe(e){const t=h.get(e);if(t)return t;const n=d.get(e)||E||j(),o=`rte-content-rules-panel-${xe++}`,r=document.createElement("section");return r.className=f,r.id=o,r.setAttribute("role","dialog"),r.setAttribute("aria-modal","false"),r.setAttribute("aria-label",n.labels.panelAriaLabel),r.innerHTML=`
<header class="rte-content-rules-header">

@@ -37,3 +37,3 @@ <h2 class="rte-content-rules-title">${k(n.labels.panelTitle)}</h2>

</div>
`,r.addEventListener("click",s=>{const l=s.target?.closest("[data-action]");if(!l)return;const c=l.getAttribute("data-action");if(c){if(c==="close"){O(e,!0);return}if(c==="run-audit"){const u=d.get(e)||E||n;C(e,u,!0);return}if(c==="toggle-realtime"){const a=!A(e,d.get(e)||E||n);if(T.set(e,a),W(e,r,d.get(e)||E||n),a){const y=d.get(e)||E||n;C(e,y,!0)}return}if(c==="focus-issue"){const u=l.getAttribute("data-issue-id")||"",a=Oe(e,u);if(!a)return;He(e,a),O(e,!1)}}}),r.addEventListener("keydown",s=>{if(s.key==="Escape"){s.preventDefault(),O(e,!0);return}if(s.key!=="ArrowDown"&&s.key!=="ArrowUp")return;const i=Array.from(r.querySelectorAll('[data-role="issue-button"]'));if(i.length===0)return;const l=document.activeElement,c=i.findIndex(y=>y===l);if(c===-1)return;s.preventDefault();const u=s.key==="ArrowDown"?1:-1,a=(c+u+i.length)%i.length;i[a].focus()}),G(r,e),document.body.appendChild(r),h.set(e,r),B.set(e,!1),W(e,r,n),r}function ne(e){const t=Pe(e);We(e),t.classList.add("show"),B.set(e,!0),G(t,e),J(e,t),te(e),M(e,"toggleContentRulesPanel",!0),t.querySelector('[data-action="run-audit"]')?.focus()}function Q(e,t){const n=U(e);return(typeof t=="boolean"?t:!n)?ne(e):O(e,!1),!0}function me(e){const t=V.get(e);typeof t=="number"&&(window.clearTimeout(t),z.delete(t),V.delete(e))}function be(e){const t=d.get(e)||E;if(!t||!A(e,t))return;me(e);const n=window.setTimeout(()=>{z.delete(n),V.delete(e),C(e,t,!1)},t.debounceMs);z.add(n),V.set(e,n)}function qe(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="r"}function _e(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="l"}function ze(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="t"}function Be(){if(typeof document>"u"||document.getElementById(se))return;const e=document.createElement("style");e.id=se,e.textContent=`
`,r.addEventListener("click",s=>{const l=s.target?.closest("[data-action]");if(!l)return;const c=l.getAttribute("data-action");if(c){if(c==="close"){O(e,!0);return}if(c==="run-audit"){const u=d.get(e)||E||n;v(e,u,!0);return}if(c==="toggle-realtime"){const a=!A(e,d.get(e)||E||n);if(T.set(e,a),W(e,r,d.get(e)||E||n),a){const y=d.get(e)||E||n;v(e,y,!0)}return}if(c==="focus-issue"){const u=l.getAttribute("data-issue-id")||"",a=We(e,u);if(!a)return;Oe(e,a),O(e,!1)}}}),r.addEventListener("keydown",s=>{if(s.key==="Escape"){s.preventDefault(),O(e,!0);return}if(s.key!=="ArrowDown"&&s.key!=="ArrowUp")return;const i=Array.from(r.querySelectorAll('[data-role="issue-button"]'));if(i.length===0)return;const l=document.activeElement,c=i.findIndex(y=>y===l);if(c===-1)return;s.preventDefault();const u=s.key==="ArrowDown"?1:-1,a=(c+u+i.length)%i.length;i[a].focus()}),G(r,e),document.body.appendChild(r),h.set(e,r),B.set(e,!1),W(e,r,n),r}function ne(e){const t=qe(e);Pe(e),t.classList.add("show"),B.set(e,!0),G(t,e),J(e,t),te(e),M(e,"toggleContentRulesPanel",!0),t.querySelector('[data-action="run-audit"]')?.focus()}function Q(e,t){const n=U(e);return(typeof t=="boolean"?t:!n)?ne(e):O(e,!1),!0}function be(e){const t=V.get(e);typeof t=="number"&&(window.clearTimeout(t),z.delete(t),V.delete(e))}function he(e){const t=d.get(e)||E;if(!t||!A(e,t))return;be(e);const n=window.setTimeout(()=>{z.delete(n),V.delete(e),v(e,t,!1)},t.debounceMs);z.add(n),V.set(e,n)}function re(e){return typeof e.key=="string"?e.key.toLowerCase():""}function _e(e){const t=re(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="r"}function ze(e){const t=re(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="l"}function Be(e){const t=re(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="t"}function De(){if(typeof document>"u"||document.getElementById(le))return;const e=document.createElement("style");e.id=le,e.textContent=`
.rte-toolbar-group-items.content-rules,

@@ -411,2 +411,2 @@ .editora-toolbar-group-items.content-rules {

}
`,document.head.appendChild(e)}function De(e){E=e,L||(L=t=>{const o=t.target?.closest(R);if(!o)return;g=o,d.has(o)||d.set(o,e),v.has(o)||v.set(o,[]),T.has(o)||T.set(o,e.enableRealtime);const r=h.get(o);r&&(G(r,o),J(o,r),W(o,r,d.get(o)||e)),M(o,"toggleContentRulesPanel",U(o)),M(o,"toggleContentRulesRealtime",A(o,e))},document.addEventListener("focusin",L,!0)),I||(I=t=>{const o=t.target?.closest(R);o&&(g=o,be(o))},document.addEventListener("input",I,!0)),H||(H=t=>{if(t.defaultPrevented||t.target?.closest("input, textarea, select"))return;const o=t.key==="Escape",r=qe(t),s=_e(t),i=ze(t);if(!o&&!r&&!s&&!i)return;const l=$(void 0,!1);if(!l||Z(l))return;const c=d.get(l)||E||e;if(d.set(l,c),g=l,o&&U(l)){t.preventDefault(),O(l,!0);return}if(r){t.preventDefault(),t.stopPropagation(),Q(l);return}if(s){t.preventDefault(),t.stopPropagation(),C(l,c,!0),ne(l);return}if(i){t.preventDefault(),t.stopPropagation();const u=!A(l,c);T.set(l,u);const a=h.get(l);a&&W(l,a,c),M(l,"toggleContentRulesRealtime",u),u&&C(l,c,!0)}},document.addEventListener("keydown",H,!0)),S||(S=()=>{h.forEach((t,n)=>{if(!n.isConnected||!t.isConnected){me(n),t.remove(),h.delete(n),B.delete(n);return}G(t,n),J(n,t)})},window.addEventListener("scroll",S,!0),window.addEventListener("resize",S))}function Ne(){L&&(document.removeEventListener("focusin",L,!0),L=null),I&&(document.removeEventListener("input",I,!0),I=null),H&&(document.removeEventListener("keydown",H,!0),H=null),S&&(window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S),S=null),h.forEach(e=>{e.remove()}),h.clear(),E=null,g=null}const Ke=(e={})=>{const t=j(e);return Be(),{name:"contentRules",toolbar:[{id:"contentRulesGroup",label:"Content Rules",type:"group",command:"contentRules",items:[{id:"contentRules",label:"Content Rules",command:"toggleContentRulesPanel",shortcut:"Mod-Alt-Shift-r",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 3h9l5 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2Zm8 2v4h4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><path d="M8 11h8M8 15h8M8 19h5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'},{id:"contentRulesAudit",label:"Run Rules Audit",command:"runContentRulesAudit",shortcut:"Mod-Alt-Shift-l",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4 12h4l2 5 4-10 2 5h4" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><circle cx="12" cy="12" r="9" stroke="currentColor" stroke-width="1.6"/></svg>'},{id:"contentRulesRealtime",label:"Toggle Realtime Rules",command:"toggleContentRulesRealtime",shortcut:"Mod-Alt-Shift-t",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3v4M12 17v4M4.9 4.9l2.8 2.8M16.3 16.3l2.8 2.8M3 12h4M17 12h4M4.9 19.1l2.8-2.8M16.3 7.7l2.8-2.8" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="12" cy="12" r="4" stroke="currentColor" stroke-width="1.6"/></svg>'}]}],commands:{contentRules:(n,o)=>{const r=$(o);if(!r||Z(r))return!1;const s=d.get(r)||t;return d.set(r,s),g=r,Q(r,!0),C(r,s,!1),!0},toggleContentRulesPanel:(n,o)=>{const r=$(o);if(!r||Z(r))return!1;g=r;const s=d.get(r)||t;d.set(r,s);const i=Q(r,typeof n=="boolean"?n:void 0);return U(r)&&C(r,s,!1),i},runContentRulesAudit:async(n,o)=>{const r=$(o);if(!r)return!1;g=r;const s=d.get(r)||t;return d.set(r,s),await C(r,s,!0),ne(r),!0},toggleContentRulesRealtime:(n,o)=>{const r=$(o);if(!r)return!1;g=r;const s=d.get(r)||t;d.set(r,s);const i=typeof n=="boolean"?n:!A(r,s);T.set(r,i);const l=h.get(r);return l&&W(r,l,s),M(r,"toggleContentRulesRealtime",i),i&&C(r,s,!0),!0},getContentRulesIssues:(n,o)=>{const r=$(o);if(!r)return!1;const s=v.get(r)||[];if(typeof n=="function")try{n(s)}catch{}return r.__contentRulesIssues=s,r.dispatchEvent(new CustomEvent("editora:content-rules-issues",{bubbles:!0,detail:{issues:s}})),!0},setContentRulesOptions:(n,o)=>{const r=$(o);if(!r||!n||typeof n!="object")return!1;const s=d.get(r)||t,i=j({...s,...n,labels:{...s.labels,...n.labels||{}}});d.set(r,i),typeof n.enableRealtime=="boolean"&&T.set(r,n.enableRealtime),A(r,i)&&C(r,i,!0);const l=h.get(r);if(l){l.setAttribute("aria-label",i.labels.panelAriaLabel);const c=l.querySelector(".rte-content-rules-title");c&&(c.textContent=i.labels.panelTitle),W(r,l,i),te(r)}return!0}},keymap:{"Mod-Alt-Shift-r":"toggleContentRulesPanel","Mod-Alt-Shift-R":"toggleContentRulesPanel","Mod-Alt-Shift-l":"runContentRulesAudit","Mod-Alt-Shift-L":"runContentRulesAudit","Mod-Alt-Shift-t":"toggleContentRulesRealtime","Mod-Alt-Shift-T":"toggleContentRulesRealtime"},init:function(o){N+=1;const r=this&&typeof this.__pluginConfig=="object"?j({...t,...this.__pluginConfig}):t;De(r);const s=$(o&&o.editorElement?{editorElement:o.editorElement}:void 0,!1);s&&(g=s,d.set(s,r),T.set(s,r.enableRealtime),v.set(s,[]),M(s,"toggleContentRulesPanel",!1),M(s,"toggleContentRulesRealtime",r.enableRealtime),r.enableRealtime&&be(s))},destroy:()=>{N=Math.max(0,N-1),!(N>0)&&(z.forEach(n=>{window.clearTimeout(n)}),z.clear(),Ne())}}};exports.ContentRulesPlugin=Ke;
`,document.head.appendChild(e)}function Ne(e){E=e,L||(L=t=>{const o=t.target?.closest(R);if(!o)return;g=o,d.has(o)||d.set(o,e),C.has(o)||C.set(o,[]),T.has(o)||T.set(o,e.enableRealtime);const r=h.get(o);r&&(G(r,o),J(o,r),W(o,r,d.get(o)||e)),M(o,"toggleContentRulesPanel",U(o)),M(o,"toggleContentRulesRealtime",A(o,e))},document.addEventListener("focusin",L,!0)),I||(I=t=>{const o=t.target?.closest(R);o&&(g=o,he(o))},document.addEventListener("input",I,!0)),H||(H=t=>{if(t.defaultPrevented||t.target?.closest("input, textarea, select"))return;const o=t.key==="Escape",r=_e(t),s=ze(t),i=Be(t);if(!o&&!r&&!s&&!i)return;const l=$(void 0,!1);if(!l||Z(l))return;const c=d.get(l)||E||e;if(d.set(l,c),g=l,o&&U(l)){t.preventDefault(),O(l,!0);return}if(r){t.preventDefault(),t.stopPropagation(),Q(l);return}if(s){t.preventDefault(),t.stopPropagation(),v(l,c,!0),ne(l);return}if(i){t.preventDefault(),t.stopPropagation();const u=!A(l,c);T.set(l,u);const a=h.get(l);a&&W(l,a,c),M(l,"toggleContentRulesRealtime",u),u&&v(l,c,!0)}},document.addEventListener("keydown",H,!0)),S||(S=()=>{h.forEach((t,n)=>{if(!n.isConnected||!t.isConnected){be(n),t.remove(),h.delete(n),B.delete(n);return}G(t,n),J(n,t)})},window.addEventListener("scroll",S,!0),window.addEventListener("resize",S))}function Ke(){L&&(document.removeEventListener("focusin",L,!0),L=null),I&&(document.removeEventListener("input",I,!0),I=null),H&&(document.removeEventListener("keydown",H,!0),H=null),S&&(window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S),S=null),h.forEach(e=>{e.remove()}),h.clear(),E=null,g=null}const je=(e={})=>{const t=j(e);return De(),{name:"contentRules",toolbar:[{id:"contentRulesGroup",label:"Content Rules",type:"group",command:"contentRules",items:[{id:"contentRules",label:"Content Rules",command:"toggleContentRulesPanel",shortcut:"Mod-Alt-Shift-r",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 3h9l5 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2Zm8 2v4h4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><path d="M8 11h8M8 15h8M8 19h5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'},{id:"contentRulesAudit",label:"Run Rules Audit",command:"runContentRulesAudit",shortcut:"Mod-Alt-Shift-l",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4 12h4l2 5 4-10 2 5h4" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><circle cx="12" cy="12" r="9" stroke="currentColor" stroke-width="1.6"/></svg>'},{id:"contentRulesRealtime",label:"Toggle Realtime Rules",command:"toggleContentRulesRealtime",shortcut:"Mod-Alt-Shift-t",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3v4M12 17v4M4.9 4.9l2.8 2.8M16.3 16.3l2.8 2.8M3 12h4M17 12h4M4.9 19.1l2.8-2.8M16.3 7.7l2.8-2.8" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="12" cy="12" r="4" stroke="currentColor" stroke-width="1.6"/></svg>'}]}],commands:{contentRules:(n,o)=>{const r=$(o);if(!r||Z(r))return!1;const s=d.get(r)||t;return d.set(r,s),g=r,Q(r,!0),v(r,s,!1),!0},toggleContentRulesPanel:(n,o)=>{const r=$(o);if(!r||Z(r))return!1;g=r;const s=d.get(r)||t;d.set(r,s);const i=Q(r,typeof n=="boolean"?n:void 0);return U(r)&&v(r,s,!1),i},runContentRulesAudit:async(n,o)=>{const r=$(o);if(!r)return!1;g=r;const s=d.get(r)||t;return d.set(r,s),await v(r,s,!0),ne(r),!0},toggleContentRulesRealtime:(n,o)=>{const r=$(o);if(!r)return!1;g=r;const s=d.get(r)||t;d.set(r,s);const i=typeof n=="boolean"?n:!A(r,s);T.set(r,i);const l=h.get(r);return l&&W(r,l,s),M(r,"toggleContentRulesRealtime",i),i&&v(r,s,!0),!0},getContentRulesIssues:(n,o)=>{const r=$(o);if(!r)return!1;const s=C.get(r)||[];if(typeof n=="function")try{n(s)}catch{}return r.__contentRulesIssues=s,r.dispatchEvent(new CustomEvent("editora:content-rules-issues",{bubbles:!0,detail:{issues:s}})),!0},setContentRulesOptions:(n,o)=>{const r=$(o);if(!r||!n||typeof n!="object")return!1;const s=d.get(r)||t,i=j({...s,...n,labels:{...s.labels,...n.labels||{}}});d.set(r,i),typeof n.enableRealtime=="boolean"&&T.set(r,n.enableRealtime),A(r,i)&&v(r,i,!0);const l=h.get(r);if(l){l.setAttribute("aria-label",i.labels.panelAriaLabel);const c=l.querySelector(".rte-content-rules-title");c&&(c.textContent=i.labels.panelTitle),W(r,l,i),te(r)}return!0}},keymap:{"Mod-Alt-Shift-r":"toggleContentRulesPanel","Mod-Alt-Shift-R":"toggleContentRulesPanel","Mod-Alt-Shift-l":"runContentRulesAudit","Mod-Alt-Shift-L":"runContentRulesAudit","Mod-Alt-Shift-t":"toggleContentRulesRealtime","Mod-Alt-Shift-T":"toggleContentRulesRealtime"},init:function(o){N+=1;const r=this&&typeof this.__pluginConfig=="object"?j({...t,...this.__pluginConfig}):t;Ne(r);const s=$(o&&o.editorElement?{editorElement:o.editorElement}:void 0,!1);s&&(g=s,d.set(s,r),T.set(s,r.enableRealtime),C.set(s,[]),M(s,"toggleContentRulesPanel",!1),M(s,"toggleContentRulesRealtime",r.enableRealtime),r.enableRealtime&&he(s))},destroy:()=>{N=Math.max(0,N-1),!(N>0)&&(z.forEach(n=>{window.clearTimeout(n)}),z.clear(),Ke())}}};exports.ContentRulesPlugin=je;

@@ -1,2 +0,2 @@

const R = ".rte-content, .editora-content", ee = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", oe = "__editoraCommandEditorRoot", se = "rte-content-rules-styles", f = "rte-content-rules-panel", q = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', he = {
const R = ".rte-content, .editora-content", ee = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", se = "__editoraCommandEditorRoot", le = "rte-content-rules-styles", f = "rte-content-rules-panel", q = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', pe = {
panelTitle: "Content Rules",

@@ -15,17 +15,17 @@ panelAriaLabel: "Content rules panel",

readabilityMessage: "Readability score is below threshold"
}, d = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new WeakMap(), de = /* @__PURE__ */ new WeakMap(), T = /* @__PURE__ */ new WeakMap(), V = /* @__PURE__ */ new WeakMap(), le = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new WeakMap(), _ = /* @__PURE__ */ new Set();
let N = 0, pe = 0, E = null, g = null, L = null, I = null, H = null, S = null;
}, d = /* @__PURE__ */ new WeakMap(), C = /* @__PURE__ */ new WeakMap(), fe = /* @__PURE__ */ new WeakMap(), T = /* @__PURE__ */ new WeakMap(), V = /* @__PURE__ */ new WeakMap(), ae = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new WeakMap(), _ = /* @__PURE__ */ new Set();
let N = 0, xe = 0, E = null, g = null, L = null, I = null, H = null, S = null;
function k(e) {
return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
}
function xe(e) {
function ye(e) {
return {
...he,
...pe,
...e || {}
};
}
function ye(e) {
function we(e) {
return e.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
}
function ae(e) {
function ie(e) {
if (!e) return [];

@@ -40,4 +40,4 @@ const t = /* @__PURE__ */ new Set();

return {
bannedWords: ae(e.bannedWords),
requiredHeadings: ae(e.requiredHeadings),
bannedWords: ie(e.bannedWords),
requiredHeadings: ie(e.requiredHeadings),
maxSentenceWords: Math.max(8, Number(e.maxSentenceWords ?? 32)),

@@ -48,4 +48,4 @@ minReadabilityScore: Math.max(0, Math.min(120, Number(e.minReadabilityScore ?? 55))),

enableRealtime: e.enableRealtime !== !1,
labels: xe(e.labels),
normalizeText: e.normalizeText || ye,
labels: ye(e.labels),
normalizeText: e.normalizeText || we,
customRules: Array.isArray(e.customRules) ? e.customRules : []

@@ -63,7 +63,7 @@ };

}
function we() {
function ke() {
if (typeof window > "u") return null;
const e = window[oe];
const e = window[se];
if (!(e instanceof HTMLElement)) return null;
window[oe] = null;
window[se] = null;
const t = F(e);

@@ -78,3 +78,3 @@ if (t) return t;

}
function ke(e) {
function Re(e) {
const t = e.closest("[data-editora-editor]");

@@ -94,3 +94,3 @@ if (t && F(t) === e)

}
function Re(e) {
function Ee(e) {
const t = X(e);

@@ -102,5 +102,5 @@ if (K(t)) return !0;

function G(e, t) {
e.classList.remove("rte-content-rules-theme-dark"), Re(t) && e.classList.add("rte-content-rules-theme-dark");
e.classList.remove("rte-content-rules-theme-dark"), Ee(t) && e.classList.add("rte-content-rules-theme-dark");
}
function Ee(e) {
function ve(e) {
return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;

@@ -116,7 +116,7 @@ }

}
const n = we();
const n = ke();
if (n) return n;
const o = window.getSelection();
if (o && o.rangeCount > 0) {
const s = o.getRangeAt(0).startContainer, l = Ee(s)?.closest(R);
const s = o.getRangeAt(0).startContainer, l = ve(s)?.closest(R);
if (l) return l;

@@ -139,6 +139,6 @@ }

}
function ve(e) {
function $e(e) {
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function ie(e) {
function ce(e) {
let t = 2166136261;

@@ -149,11 +149,11 @@ for (let n = 0; n < e.length; n += 1)

}
function ce(e) {
function ue(e) {
const t = e.match(/\b[\w'-]+\b/g);
return t ? t.length : 0;
}
function fe(e) {
function ge(e) {
const t = e.match(/[^.!?]+[.!?]*/g);
return t ? t.map((n) => n.trim()).filter(Boolean).length : 0;
}
function $e(e) {
function Me(e) {
const t = e.toLowerCase().replace(/[^a-z]/g, "");

@@ -166,6 +166,6 @@ if (!t) return 0;

}
function Me(e) {
function Se(e) {
const t = e.match(/\b[\w'-]+\b/g) || [], n = t.length;
if (n === 0) return 100;
const o = Math.max(1, fe(e)), r = t.reduce((i, l) => i + $e(l), 0), s = 206.835 - 1.015 * (n / o) - 84.6 * (r / Math.max(1, n));
const o = Math.max(1, ge(e)), r = t.reduce((i, l) => i + Me(l), 0), s = 206.835 - 1.015 * (n / o) - 84.6 * (r / Math.max(1, n));
return Number.isFinite(s) ? Math.max(0, Math.min(120, s)) : 0;

@@ -182,6 +182,6 @@ }

}
function ge(e, t = 140) {
function me(e, t = 140) {
return e.length <= t ? e : `${e.slice(0, t - 1).trimEnd()}...`;
}
function Se(e, t, n, o) {
function Te(e, t, n, o) {
return {

@@ -192,3 +192,3 @@ id: e.id || z(t, o),

message: e.message || t,
excerpt: e.excerpt ? ge(e.excerpt, 220) : void 0,
excerpt: e.excerpt ? me(e.excerpt, 220) : void 0,
suggestion: e.suggestion,

@@ -199,3 +199,3 @@ locateText: e.locateText,

}
function Te(e, t) {
function Ae(e, t) {
const n = Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")), o = /* @__PURE__ */ new Set();

@@ -207,20 +207,20 @@ return n.forEach((r) => {

}
function Ae(e) {
function Le(e) {
const t = e.match(/[^.!?\n]+[.!?]?/g);
return t ? t.map((n) => n.trim()).filter(Boolean) : [];
}
async function C(e, t, n = !1) {
const o = Ce(e, t.normalizeText), r = e.innerHTML, s = `${o.length}:${ie(o)}:${r.length}:${ie(r)}`;
if (!n && le.get(e) === s)
return v.get(e) || [];
async function v(e, t, n = !1) {
const o = Ce(e, t.normalizeText), r = e.innerHTML, s = `${o.length}:${ce(o)}:${r.length}:${ce(r)}`;
if (!n && ae.get(e) === s)
return C.get(e) || [];
const i = (Y.get(e) || 0) + 1;
Y.set(e, i);
const l = ce(o), c = fe(o), u = Me(o), a = [], y = t.labels;
const l = ue(o), c = ge(o), u = Se(o), a = [], y = t.labels;
if (t.bannedWords.length > 0) {
let w = 0;
for (const p of t.bannedWords) {
const m = new RegExp(`\\b${ve(p)}\\b`, "gi");
const m = new RegExp(`\\b${$e(p)}\\b`, "gi");
let b = m.exec(o);
for (; b && !x(a, t.maxIssues); ) {
const re = b[0];
const oe = b[0];
P(

@@ -232,4 +232,4 @@ a,

severity: "error",
message: `${y.bannedWordMessage}: "${re}"`,
locateText: re,
message: `${y.bannedWordMessage}: "${oe}"`,
locateText: oe,
suggestion: "Replace or remove banned terms."

@@ -244,3 +244,3 @@ },

if (!x(a, t.maxIssues) && t.requiredHeadings.length > 0) {
const w = Te(e, t.normalizeText);
const w = Ae(e, t.normalizeText);
let p = 0;

@@ -264,7 +264,7 @@ t.requiredHeadings.forEach((m) => {

if (!x(a, t.maxIssues)) {
const w = Ae(o);
const w = Le(o);
let p = 0;
for (const m of w) {
if (x(a, t.maxIssues)) break;
const b = ce(m);
const b = ue(m);
b <= t.maxSentenceWords || (P(

@@ -277,3 +277,3 @@ a,

message: `${y.sentenceLengthMessage} (${b}/${t.maxSentenceWords} words)`,
excerpt: ge(m, 200),
excerpt: me(m, 200),
locateText: m.slice(0, 64),

@@ -314,3 +314,3 @@ suggestion: "Split into shorter sentences for readability."

a,
Se(m[b], p.id, p.severity || "warning", b),
Te(m[b], p.id, p.severity || "warning", b),
t.maxIssues

@@ -323,3 +323,3 @@ );

if (Y.get(e) !== i)
return v.get(e) || [];
return C.get(e) || [];
const D = {

@@ -330,3 +330,3 @@ readabilityScore: u,

};
return le.set(e, s), v.set(e, a), de.set(e, D), te(e), e.dispatchEvent(
return ae.set(e, s), C.set(e, a), fe.set(e, D), te(e), e.dispatchEvent(
new CustomEvent("editora:content-rules-audit", {

@@ -341,3 +341,3 @@ bubbles: !0,

}
function Le(e) {
function Ie(e) {
return e.reduce(

@@ -348,7 +348,7 @@ (t, n) => (t[n.severity] += 1, t),

}
function Ie(e) {
function He(e) {
return e === "error" ? "Error" : e === "warning" ? "Warning" : "Info";
}
function $(e, t, n) {
const o = ke(e);
const o = Re(e);
Array.from(

@@ -372,3 +372,3 @@ o.querySelectorAll(

}
function ue(e, t) {
function de(e, t) {
const n = t.trim().toLowerCase();

@@ -392,3 +392,3 @@ if (!n) return !1;

}
function He(e, t) {
function We(e, t) {
if (t.selector) {

@@ -399,6 +399,6 @@ const n = e.querySelector(t.selector);

}
return !!(t.locateText && ue(e, t.locateText) || t.excerpt && ue(e, t.excerpt.slice(0, 64)));
return !!(t.locateText && de(e, t.locateText) || t.excerpt && de(e, t.excerpt.slice(0, 64)));
}
function We(e, t) {
return (v.get(e) || []).find((o) => o.id === t);
function Oe(e, t) {
return (C.get(e) || []).find((o) => o.id === t);
}

@@ -420,7 +420,7 @@ function A(e, t) {

if (!n) return;
const o = v.get(e) || [], r = de.get(e) || {
const o = C.get(e) || [], r = fe.get(e) || {
readabilityScore: 100
}, s = t.querySelector(".rte-content-rules-count"), i = t.querySelector(".rte-content-rules-summary"), l = t.querySelector(".rte-content-rules-list"), c = t.querySelector(".rte-content-rules-live");
if (!s || !i || !l || !c) return;
const u = Le(o);
const u = Ie(o);
if (s.textContent = String(o.length), i.textContent = `${n.labels.summaryPrefix}: ${o.length} | Error ${u.error} | Warning ${u.warning} | Info ${u.info} | Readability ${r.readabilityScore.toFixed(1)}`, c.textContent = `${o.length} issues. ${u.error} errors, ${u.warning} warnings, ${u.info} info.`, o.length === 0) {

@@ -442,3 +442,3 @@ l.innerHTML = `<li class="rte-content-rules-empty">${k(n.labels.noIssuesText)}</li>`;

>
<span class="rte-content-rules-badge">${k(Ie(a.severity))}</span>
<span class="rte-content-rules-badge">${k(He(a.severity))}</span>
<span class="rte-content-rules-message">${k(a.message)}</span>

@@ -456,3 +456,3 @@ </button>

}
function Oe(e) {
function qe(e) {
h.forEach((t, n) => {

@@ -462,6 +462,6 @@ n !== e && W(n, !1);

}
function qe(e) {
function Pe(e) {
const t = h.get(e);
if (t) return t;
const n = d.get(e) || E || j(), o = `rte-content-rules-panel-${pe++}`, r = document.createElement("section");
const n = d.get(e) || E || j(), o = `rte-content-rules-panel-${xe++}`, r = document.createElement("section");
return r.className = f, r.id = o, r.setAttribute("role", "dialog"), r.setAttribute("aria-modal", "false"), r.setAttribute("aria-label", n.labels.panelAriaLabel), r.innerHTML = `

@@ -496,3 +496,3 @@ <header class="rte-content-rules-header">

const u = d.get(e) || E || n;
C(e, u, !0);
v(e, u, !0);
return;

@@ -504,3 +504,3 @@ }

const y = d.get(e) || E || n;
C(e, y, !0);
v(e, y, !0);
}

@@ -510,5 +510,5 @@ return;

if (c === "focus-issue") {
const u = l.getAttribute("data-issue-id") || "", a = We(e, u);
const u = l.getAttribute("data-issue-id") || "", a = Oe(e, u);
if (!a) return;
He(e, a), W(e, !1);
We(e, a), W(e, !1);
}

@@ -532,4 +532,4 @@ }

function ne(e) {
const t = qe(e);
Oe(e), t.classList.add("show"), B.set(e, !0), G(t, e), J(e, t), te(e), $(e, "toggleContentRulesPanel", !0), t.querySelector('[data-action="run-audit"]')?.focus();
const t = Pe(e);
qe(e), t.classList.add("show"), B.set(e, !0), G(t, e), J(e, t), te(e), $(e, "toggleContentRulesPanel", !0), t.querySelector('[data-action="run-audit"]')?.focus();
}

@@ -540,31 +540,34 @@ function Q(e, t) {

}
function me(e) {
function be(e) {
const t = V.get(e);
typeof t == "number" && (window.clearTimeout(t), _.delete(t), V.delete(e));
}
function be(e) {
function he(e) {
const t = d.get(e) || E;
if (!t || !A(e, t)) return;
me(e);
be(e);
const n = window.setTimeout(() => {
_.delete(n), V.delete(e), C(e, t, !1);
_.delete(n), V.delete(e), v(e, t, !1);
}, t.debounceMs);
_.add(n), V.set(e, n);
}
function Pe(e) {
const t = e.key.toLowerCase();
function re(e) {
return typeof e.key == "string" ? e.key.toLowerCase() : "";
}
function ze(e) {
const t = re(e);
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "r";
}
function ze(e) {
const t = e.key.toLowerCase();
function _e(e) {
const t = re(e);
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "l";
}
function _e(e) {
const t = e.key.toLowerCase();
function Be(e) {
const t = re(e);
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "t";
}
function Be() {
if (typeof document > "u" || document.getElementById(se)) return;
function De() {
if (typeof document > "u" || document.getElementById(le)) return;
const e = document.createElement("style");
e.id = se, e.textContent = `
e.id = le, e.textContent = `
.rte-toolbar-group-items.content-rules,

@@ -944,7 +947,7 @@ .editora-toolbar-group-items.content-rules {

}
function De(e) {
function Ne(e) {
E = e, L || (L = (t) => {
const o = t.target?.closest(R);
if (!o) return;
g = o, d.has(o) || d.set(o, e), v.has(o) || v.set(o, []), T.has(o) || T.set(o, e.enableRealtime);
g = o, d.has(o) || d.set(o, e), C.has(o) || C.set(o, []), T.has(o) || T.set(o, e.enableRealtime);
const r = h.get(o);

@@ -954,6 +957,6 @@ r && (G(r, o), J(o, r), O(o, r, d.get(o) || e)), $(o, "toggleContentRulesPanel", U(o)), $(o, "toggleContentRulesRealtime", A(o, e));

const o = t.target?.closest(R);
o && (g = o, be(o));
o && (g = o, he(o));
}, document.addEventListener("input", I, !0)), H || (H = (t) => {
if (t.defaultPrevented || t.target?.closest("input, textarea, select")) return;
const o = t.key === "Escape", r = Pe(t), s = ze(t), i = _e(t);
const o = t.key === "Escape", r = ze(t), s = _e(t), i = Be(t);
if (!o && !r && !s && !i)

@@ -973,3 +976,3 @@ return;

if (s) {
t.preventDefault(), t.stopPropagation(), C(l, c, !0), ne(l);
t.preventDefault(), t.stopPropagation(), v(l, c, !0), ne(l);
return;

@@ -982,3 +985,3 @@ }

const a = h.get(l);
a && O(l, a, c), $(l, "toggleContentRulesRealtime", u), u && C(l, c, !0);
a && O(l, a, c), $(l, "toggleContentRulesRealtime", u), u && v(l, c, !0);
}

@@ -988,3 +991,3 @@ }, document.addEventListener("keydown", H, !0)), S || (S = () => {

if (!n.isConnected || !t.isConnected) {
me(n), t.remove(), h.delete(n), B.delete(n);
be(n), t.remove(), h.delete(n), B.delete(n);
return;

@@ -996,3 +999,3 @@ }

}
function Ne() {
function Ke() {
L && (document.removeEventListener("focusin", L, !0), L = null), I && (document.removeEventListener("input", I, !0), I = null), H && (document.removeEventListener("keydown", H, !0), H = null), S && (window.removeEventListener("scroll", S, !0), window.removeEventListener("resize", S), S = null), h.forEach((e) => {

@@ -1002,5 +1005,5 @@ e.remove();

}
const Ke = (e = {}) => {
const je = (e = {}) => {
const t = j(e);
return Be(), {
return De(), {
name: "contentRules",

@@ -1043,3 +1046,3 @@ toolbar: [

const s = d.get(r) || t;
return d.set(r, s), g = r, Q(r, !0), C(r, s, !1), !0;
return d.set(r, s), g = r, Q(r, !0), v(r, s, !1), !0;
},

@@ -1053,3 +1056,3 @@ toggleContentRulesPanel: (n, o) => {

const i = Q(r, typeof n == "boolean" ? n : void 0);
return U(r) && C(r, s, !1), i;
return U(r) && v(r, s, !1), i;
},

@@ -1061,3 +1064,3 @@ runContentRulesAudit: async (n, o) => {

const s = d.get(r) || t;
return d.set(r, s), await C(r, s, !0), ne(r), !0;
return d.set(r, s), await v(r, s, !0), ne(r), !0;
},

@@ -1073,3 +1076,3 @@ toggleContentRulesRealtime: (n, o) => {

const l = h.get(r);
return l && O(r, l, s), $(r, "toggleContentRulesRealtime", i), i && C(r, s, !0), !0;
return l && O(r, l, s), $(r, "toggleContentRulesRealtime", i), i && v(r, s, !0), !0;
},

@@ -1079,3 +1082,3 @@ getContentRulesIssues: (n, o) => {

if (!r) return !1;
const s = v.get(r) || [];
const s = C.get(r) || [];
if (typeof n == "function")

@@ -1104,3 +1107,3 @@ try {

});
d.set(r, i), typeof n.enableRealtime == "boolean" && T.set(r, n.enableRealtime), A(r, i) && C(r, i, !0);
d.set(r, i), typeof n.enableRealtime == "boolean" && T.set(r, n.enableRealtime), A(r, i) && v(r, i, !0);
const l = h.get(r);

@@ -1126,3 +1129,3 @@ if (l) {

const r = this && typeof this.__pluginConfig == "object" ? j({ ...t, ...this.__pluginConfig }) : t;
De(r);
Ne(r);
const s = M(

@@ -1132,3 +1135,3 @@ o && o.editorElement ? { editorElement: o.editorElement } : void 0,

);
s && (g = s, d.set(s, r), T.set(s, r.enableRealtime), v.set(s, []), $(s, "toggleContentRulesPanel", !1), $(s, "toggleContentRulesRealtime", r.enableRealtime), r.enableRealtime && be(s));
s && (g = s, d.set(s, r), T.set(s, r.enableRealtime), C.set(s, []), $(s, "toggleContentRulesPanel", !1), $(s, "toggleContentRulesRealtime", r.enableRealtime), r.enableRealtime && he(s));
},

@@ -1138,3 +1141,3 @@ destroy: () => {

window.clearTimeout(n);
}), _.clear(), Ne());
}), _.clear(), Ke());
}

@@ -1144,3 +1147,3 @@ };

export {
Ke as ContentRulesPlugin
je as ContentRulesPlugin
};

@@ -1,2 +0,2 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const A=".rte-content, .editora-content",C='.rte-data-binding[data-binding="true"]',it="rte-data-binding-styles",g="rte-data-binding-dialog-overlay",f=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',pt={dialogTitleInsert:"Insert Data Binding",dialogTitleEdit:"Edit Data Binding",keyLabel:"Data Key",keyPlaceholder:"user.firstName",fallbackLabel:"Fallback Text",fallbackPlaceholder:"Guest",formatLabel:"Format",currencyLabel:"Currency",currencyPlaceholder:"USD",saveText:"Save",cancelText:"Cancel",previewOnText:"Preview On",previewOffText:"Preview Off",tokenAriaPrefix:"Data binding token"},v=new WeakMap,W=new WeakMap,b=new WeakMap,N=new WeakMap,G=new WeakMap;let R=null,h=null,U=0,P=null,O=null,M=null,_=null;function yt(t){return{...pt,...t||{}}}function ot(t={}){const n=(t.locale||(typeof navigator<"u"?navigator.language:"en-US")).trim()||"en-US";return{data:t.data,getData:t.getData,api:t.api,cacheTtlMs:Math.max(0,Number(t.cacheTtlMs??3e4)),labels:yt(t.labels),defaultFormat:t.defaultFormat||"text",defaultFallback:t.defaultFallback||"",locale:n,numberFormatOptions:t.numberFormatOptions||{},dateFormatOptions:t.dateFormatOptions||{year:"numeric",month:"short",day:"2-digit"}}}function y(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function dt(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function j(t){return t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||t}function q(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function ht(t){const n=j(t);if(q(n))return!0;const a=n.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return q(a)?!0:q(document.documentElement)||q(document.body)}function D(t,n=!0){if(t?.contentElement instanceof HTMLElement)return t.contentElement;if(t?.editorElement instanceof HTMLElement){const e=t.editorElement;if(e.matches(A))return e;const i=e.querySelector(A);if(i instanceof HTMLElement)return i}const a=window.getSelection();if(a&&a.rangeCount>0){const e=a.getRangeAt(0).startContainer,o=dt(e)?.closest(A);if(o)return o}const r=document.activeElement;if(r){if(r.matches(A))return r;const e=r.closest(A);if(e)return e}return h&&h.isConnected?h:n?document.querySelector(A):null}function K(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function lt(t){const n=window.getSelection();if(!n||n.rangeCount===0)return null;const a=n.getRangeAt(0);return t.contains(a.commonAncestorContainer)?a.cloneRange():null}function st(t,n){const a=window.getSelection();a&&(a.removeAllRanges(),a.addRange(n),t.focus({preventScroll:!0}))}function kt(t,n){const a=(n||"").trim();if(a)return a.split(".").filter(Boolean).reduce((r,e)=>{if(!(r==null||typeof r!="object"))return r[e]},t)}function vt(){if(typeof document>"u"||document.getElementById(it))return;const t=document.createElement("style");t.id=it,t.textContent=`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const A=".rte-content, .editora-content",C='.rte-data-binding[data-binding="true"]',it="rte-data-binding-styles",g="rte-data-binding-dialog-overlay",f=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',yt={dialogTitleInsert:"Insert Data Binding",dialogTitleEdit:"Edit Data Binding",keyLabel:"Data Key",keyPlaceholder:"user.firstName",fallbackLabel:"Fallback Text",fallbackPlaceholder:"Guest",formatLabel:"Format",currencyLabel:"Currency",currencyPlaceholder:"USD",saveText:"Save",cancelText:"Cancel",previewOnText:"Preview On",previewOffText:"Preview Off",tokenAriaPrefix:"Data binding token"},v=new WeakMap,W=new WeakMap,b=new WeakMap,K=new WeakMap,G=new WeakMap;let N=null,h=null,U=0,P=null,O=null,M=null,_=null;function ht(t){return{...yt,...t||{}}}function ot(t={}){const n=(t.locale||(typeof navigator<"u"?navigator.language:"en-US")).trim()||"en-US";return{data:t.data,getData:t.getData,api:t.api,cacheTtlMs:Math.max(0,Number(t.cacheTtlMs??3e4)),labels:ht(t.labels),defaultFormat:t.defaultFormat||"text",defaultFallback:t.defaultFallback||"",locale:n,numberFormatOptions:t.numberFormatOptions||{},dateFormatOptions:t.dateFormatOptions||{year:"numeric",month:"short",day:"2-digit"}}}function y(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function dt(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function j(t){return t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||t}function q(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function kt(t){const n=j(t);if(q(n))return!0;const a=n.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return q(a)?!0:q(document.documentElement)||q(document.body)}function D(t,n=!0){if(t?.contentElement instanceof HTMLElement)return t.contentElement;if(t?.editorElement instanceof HTMLElement){const e=t.editorElement;if(e.matches(A))return e;const i=e.querySelector(A);if(i instanceof HTMLElement)return i}const a=window.getSelection();if(a&&a.rangeCount>0){const e=a.getRangeAt(0).startContainer,o=dt(e)?.closest(A);if(o)return o}const r=document.activeElement;if(r){if(r.matches(A))return r;const e=r.closest(A);if(e)return e}return h&&h.isConnected?h:n?document.querySelector(A):null}function R(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function lt(t){const n=window.getSelection();if(!n||n.rangeCount===0)return null;const a=n.getRangeAt(0);return t.contains(a.commonAncestorContainer)?a.cloneRange():null}function st(t,n){const a=window.getSelection();a&&(a.removeAllRanges(),a.addRange(n),t.focus({preventScroll:!0}))}function vt(t,n){const a=(n||"").trim();if(a)return a.split(".").filter(Boolean).reduce((r,e)=>{if(!(r==null||typeof r!="object"))return r[e]},t)}function xt(){if(typeof document>"u"||document.getElementById(it))return;const t=document.createElement("style");t.id=it,t.textContent=`
.rte-data-binding {

@@ -287,3 +287,3 @@ display: inline-flex;

}
`,document.head.appendChild(t)}function J(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function Y(t,n){if(n===t.innerHTML)return;const a=window.execEditorCommand||window.executeEditorCommand;if(typeof a=="function")try{a("recordDomTransaction",t,n,t.innerHTML)}catch{}}function H(t,n){return{key:String(t.key||"").trim(),fallback:String(t.fallback??n.defaultFallback??""),format:t.format||n.defaultFormat||"text",currency:String(t.currency||"USD").trim().toUpperCase()||"USD"}}function ct(t){return`{{${t.key}}}`}function ut(t,n){const a=document.createElement("span");return a.className="rte-data-binding",a.setAttribute("data-binding","true"),a.setAttribute("data-binding-key",t.key),a.setAttribute("data-binding-fallback",t.fallback||""),a.setAttribute("data-binding-format",t.format||"text"),a.setAttribute("data-binding-currency",t.currency||"USD"),a.setAttribute("contenteditable","false"),a.setAttribute("spellcheck","false"),a.setAttribute("draggable","false"),a.setAttribute("tabindex","0"),a.setAttribute("role","button"),a.setAttribute("aria-label",`${n.tokenAriaPrefix}: ${t.key}. Press Enter to edit.`),a.textContent=ct(t),a}function Z(t,n){return H({key:t.getAttribute("data-binding-key")||"",fallback:t.getAttribute("data-binding-fallback")||n.defaultFallback,format:t.getAttribute("data-binding-format")||n.defaultFormat,currency:t.getAttribute("data-binding-currency")||"USD"},n)}function X(t,n,a){t.classList.add("rte-data-binding"),t.setAttribute("data-binding","true"),t.setAttribute("data-binding-key",n.key),t.setAttribute("data-binding-fallback",n.fallback||""),t.setAttribute("data-binding-format",n.format||"text"),t.setAttribute("data-binding-currency",n.currency||"USD"),t.setAttribute("contenteditable","false"),t.setAttribute("spellcheck","false"),t.setAttribute("draggable","false"),t.setAttribute("tabindex","0"),t.setAttribute("role","button"),t.setAttribute("aria-label",`${a.tokenAriaPrefix}: ${n.key}. Press Enter to edit.`)}function V(t,n){const a=Array.from(t.querySelectorAll(C));return a.forEach(r=>{const e=Z(r,n);X(r,e,n.labels)}),a}function Q(t){const n=window.getSelection();if(n&&n.rangeCount>0){const e=n.getRangeAt(0).startContainer,o=dt(e)?.closest(C);if(o&&t.contains(o))return o}const r=document.activeElement?.closest(C);return r&&t.contains(r)?r:null}function ft(){R&&(R.cleanup(),R=null)}function tt(t,n,a){const r=j(t);Array.from(r.querySelectorAll('[data-command="toggleDataBindingPreview"]')).forEach(i=>{if(i.setAttribute("data-active",n?"true":"false"),i.classList.toggle("active",n),i.setAttribute("aria-pressed",n?"true":"false"),a){const o=n?a.labels.previewOnText:a.labels.previewOffText;i.setAttribute("title",o),i.setAttribute("aria-label",o)}})}function xt(t,n,a){const r=n.format||"text";if(t==null)return n.fallback||"";if(r==="json"){if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}if(r==="date"){const e=t instanceof Date?t:new Date(String(t));if(Number.isNaN(e.getTime()))return String(t);try{return new Intl.DateTimeFormat(a.locale,a.dateFormatOptions).format(e)}catch{return e.toISOString()}}if(r==="number"||r==="currency"){const e=typeof t=="number"?t:Number(t);if(!Number.isFinite(e))return String(t);const i={...a.numberFormatOptions};if(r==="currency"){const o=(n.currency||"USD").toUpperCase();Object.assign(i,{style:"currency",currency:o})}try{return new Intl.NumberFormat(a.locale,i).format(e)}catch{return String(e)}}return String(t)}function T(t,n,a,r){const e=Z(t,n),i=e.key;if(t.classList.remove("rte-data-binding-preview","rte-data-binding-missing"),!a){t.textContent=ct(e),t.setAttribute("aria-label",`${n.labels.tokenAriaPrefix}: ${i}. Press Enter to edit.`);return}const o=kt(r,i),l=o==null,d=l?e.fallback||"":xt(o,e,n);t.textContent=d||e.fallback||"",t.classList.add("rte-data-binding-preview"),l&&!(e.fallback||"").trim()&&t.classList.add("rte-data-binding-missing"),t.setAttribute("aria-label",`${n.labels.tokenAriaPrefix}: ${i} = ${t.textContent||""}. Press Enter to edit.`)}function x(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function wt(t,n){return n?n.split(".").filter(Boolean).reduce((a,r)=>{if(!(!x(a)&&!Array.isArray(a)))return a[r]},t):t}function Et(t,n,a){const r=n.api,e=j(t),i={editor:t,editorRoot:e,signal:a};if(r.buildRequest){const p=r.buildRequest(i);return{url:p.url,init:{...p.init||{},signal:a}}}const o=(r.method||"GET").toUpperCase(),l=typeof r.headers=="function"?r.headers(i):r.headers||{},d=typeof r.params=="function"?r.params(i):r.params,c=new URL(r.url,window.location.origin);d&&Object.entries(d).forEach(([p,m])=>{m!=null&&c.searchParams.set(p,String(m))});const u={method:o,headers:{...l},credentials:r.credentials,mode:r.mode,cache:r.cache,signal:a};if(o!=="GET"&&o!=="HEAD"){const p=typeof r.body=="function"?r.body(i):r.body;if(p!=null)if(x(p)){u.body=JSON.stringify(p);const m=u.headers;!m["Content-Type"]&&!m["content-type"]&&(m["Content-Type"]="application/json")}else u.body=p}return{url:c.toString(),init:u}}async function Dt(t,n){const a=n.api;if(!a)return{};const r=new AbortController,e=j(t),i={editor:t,editorRoot:e,signal:r.signal},o=Math.max(0,Number(a.timeoutMs??1e4));let l=null;o>0&&(l=window.setTimeout(()=>r.abort(),o));try{const{url:d,init:c}=Et(t,n,r.signal),u=await fetch(d,{...c,signal:r.signal});if(!u.ok)throw new Error(`Data binding API request failed: ${u.status}`);const m=(a.responseType||"json")==="text"?await u.text():await u.json();if(a.transformResponse){const B=a.transformResponse(m,i);return x(B)?B:{}}const $=wt(m,a.responsePath);return x($)?$:x(m)?m:{value:$}}catch(d){return d?.name!=="AbortError"&&a.onError?.(d,i),{}}finally{l!==null&&window.clearTimeout(l)}}async function I(t,n){const a=W.get(t);if(a)return a;const r=N.get(t),e=Date.now();if(r&&e-r.timestamp<=n.cacheTtlMs)return r.data;const i=G.get(t);if(i)return i;const o=(async()=>{try{if(typeof n.getData=="function"){const d=await Promise.resolve(n.getData({editor:t,editorRoot:j(t)}));if(x(d))return d}if(n.api){const d=await Dt(t,n);if(x(d))return d}if(typeof n.data=="function"){const d=await Promise.resolve(n.data());if(x(d))return d}return x(n.data)?n.data:{}}finally{G.delete(t)}})();G.set(t,o);const l=await o;return N.set(t,{timestamp:e,data:l}),l}async function z(t,n,a){const r=V(t,n);if(v.set(t,a),tt(t,a,n),!a){r.forEach(i=>T(i,n,!1));return}const e=await I(t,n);r.forEach(i=>T(i,n,!0,e))}function bt(t,n){let a=lt(t);a||(a=document.createRange(),a.selectNodeContents(t),a.collapse(!1)),a.collapsed||a.deleteContents(),a.insertNode(n);const r=document.createTextNode(" ");n.after(r);const e=document.createRange();e.setStart(r,1),e.collapse(!0),st(t,e),t.normalize()}function At(t){const n=t.metaKey||t.ctrlKey,a=t.key.toLowerCase(),r=n&&t.altKey&&t.shiftKey&&a==="d",e=!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.shiftKey&&a==="f7";return r||e}function St(t){const n=t.metaKey||t.ctrlKey,a=t.key.toLowerCase(),r=n&&t.altKey&&t.shiftKey&&a==="b",e=!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.shiftKey&&a==="f8";return r||e}function S(t,n,a,r,e){ft();const i=a==="insert"?lt(t):null,o=n.labels,l=e?Z(e,n):H(r||{},n),d=document.createElement("div");d.className=g,ht(t)&&d.classList.add("rte-data-binding-theme-dark");const c=document.createElement("section");c.className="rte-data-binding-dialog",c.setAttribute("role","dialog"),c.setAttribute("aria-modal","true"),c.setAttribute("aria-labelledby","rte-data-binding-dialog-title"),c.innerHTML=`
`,document.head.appendChild(t)}function J(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function Y(t,n){if(n===t.innerHTML)return;const a=window.execEditorCommand||window.executeEditorCommand;if(typeof a=="function")try{a("recordDomTransaction",t,n,t.innerHTML)}catch{}}function H(t,n){return{key:String(t.key||"").trim(),fallback:String(t.fallback??n.defaultFallback??""),format:t.format||n.defaultFormat||"text",currency:String(t.currency||"USD").trim().toUpperCase()||"USD"}}function ct(t){return`{{${t.key}}}`}function ut(t,n){const a=document.createElement("span");return a.className="rte-data-binding",a.setAttribute("data-binding","true"),a.setAttribute("data-binding-key",t.key),a.setAttribute("data-binding-fallback",t.fallback||""),a.setAttribute("data-binding-format",t.format||"text"),a.setAttribute("data-binding-currency",t.currency||"USD"),a.setAttribute("contenteditable","false"),a.setAttribute("spellcheck","false"),a.setAttribute("draggable","false"),a.setAttribute("tabindex","0"),a.setAttribute("role","button"),a.setAttribute("aria-label",`${n.tokenAriaPrefix}: ${t.key}. Press Enter to edit.`),a.textContent=ct(t),a}function Z(t,n){return H({key:t.getAttribute("data-binding-key")||"",fallback:t.getAttribute("data-binding-fallback")||n.defaultFallback,format:t.getAttribute("data-binding-format")||n.defaultFormat,currency:t.getAttribute("data-binding-currency")||"USD"},n)}function X(t,n,a){t.classList.add("rte-data-binding"),t.setAttribute("data-binding","true"),t.setAttribute("data-binding-key",n.key),t.setAttribute("data-binding-fallback",n.fallback||""),t.setAttribute("data-binding-format",n.format||"text"),t.setAttribute("data-binding-currency",n.currency||"USD"),t.setAttribute("contenteditable","false"),t.setAttribute("spellcheck","false"),t.setAttribute("draggable","false"),t.setAttribute("tabindex","0"),t.setAttribute("role","button"),t.setAttribute("aria-label",`${a.tokenAriaPrefix}: ${n.key}. Press Enter to edit.`)}function V(t,n){const a=Array.from(t.querySelectorAll(C));return a.forEach(r=>{const e=Z(r,n);X(r,e,n.labels)}),a}function Q(t){const n=window.getSelection();if(n&&n.rangeCount>0){const e=n.getRangeAt(0).startContainer,o=dt(e)?.closest(C);if(o&&t.contains(o))return o}const r=document.activeElement?.closest(C);return r&&t.contains(r)?r:null}function ft(){N&&(N.cleanup(),N=null)}function tt(t,n,a){const r=j(t);Array.from(r.querySelectorAll('[data-command="toggleDataBindingPreview"]')).forEach(i=>{if(i.setAttribute("data-active",n?"true":"false"),i.classList.toggle("active",n),i.setAttribute("aria-pressed",n?"true":"false"),a){const o=n?a.labels.previewOnText:a.labels.previewOffText;i.setAttribute("title",o),i.setAttribute("aria-label",o)}})}function wt(t,n,a){const r=n.format||"text";if(t==null)return n.fallback||"";if(r==="json"){if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}if(r==="date"){const e=t instanceof Date?t:new Date(String(t));if(Number.isNaN(e.getTime()))return String(t);try{return new Intl.DateTimeFormat(a.locale,a.dateFormatOptions).format(e)}catch{return e.toISOString()}}if(r==="number"||r==="currency"){const e=typeof t=="number"?t:Number(t);if(!Number.isFinite(e))return String(t);const i={...a.numberFormatOptions};if(r==="currency"){const o=(n.currency||"USD").toUpperCase();Object.assign(i,{style:"currency",currency:o})}try{return new Intl.NumberFormat(a.locale,i).format(e)}catch{return String(e)}}return String(t)}function T(t,n,a,r){const e=Z(t,n),i=e.key;if(t.classList.remove("rte-data-binding-preview","rte-data-binding-missing"),!a){t.textContent=ct(e),t.setAttribute("aria-label",`${n.labels.tokenAriaPrefix}: ${i}. Press Enter to edit.`);return}const o=vt(r,i),l=o==null,d=l?e.fallback||"":wt(o,e,n);t.textContent=d||e.fallback||"",t.classList.add("rte-data-binding-preview"),l&&!(e.fallback||"").trim()&&t.classList.add("rte-data-binding-missing"),t.setAttribute("aria-label",`${n.labels.tokenAriaPrefix}: ${i} = ${t.textContent||""}. Press Enter to edit.`)}function x(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Et(t,n){return n?n.split(".").filter(Boolean).reduce((a,r)=>{if(!(!x(a)&&!Array.isArray(a)))return a[r]},t):t}function Dt(t,n,a){const r=n.api,e=j(t),i={editor:t,editorRoot:e,signal:a};if(r.buildRequest){const p=r.buildRequest(i);return{url:p.url,init:{...p.init||{},signal:a}}}const o=(r.method||"GET").toUpperCase(),l=typeof r.headers=="function"?r.headers(i):r.headers||{},d=typeof r.params=="function"?r.params(i):r.params,c=new URL(r.url,window.location.origin);d&&Object.entries(d).forEach(([p,m])=>{m!=null&&c.searchParams.set(p,String(m))});const u={method:o,headers:{...l},credentials:r.credentials,mode:r.mode,cache:r.cache,signal:a};if(o!=="GET"&&o!=="HEAD"){const p=typeof r.body=="function"?r.body(i):r.body;if(p!=null)if(x(p)){u.body=JSON.stringify(p);const m=u.headers;!m["Content-Type"]&&!m["content-type"]&&(m["Content-Type"]="application/json")}else u.body=p}return{url:c.toString(),init:u}}async function At(t,n){const a=n.api;if(!a)return{};const r=new AbortController,e=j(t),i={editor:t,editorRoot:e,signal:r.signal},o=Math.max(0,Number(a.timeoutMs??1e4));let l=null;o>0&&(l=window.setTimeout(()=>r.abort(),o));try{const{url:d,init:c}=Dt(t,n,r.signal),u=await fetch(d,{...c,signal:r.signal});if(!u.ok)throw new Error(`Data binding API request failed: ${u.status}`);const m=(a.responseType||"json")==="text"?await u.text():await u.json();if(a.transformResponse){const B=a.transformResponse(m,i);return x(B)?B:{}}const $=Et(m,a.responsePath);return x($)?$:x(m)?m:{value:$}}catch(d){return d?.name!=="AbortError"&&a.onError?.(d,i),{}}finally{l!==null&&window.clearTimeout(l)}}async function I(t,n){const a=W.get(t);if(a)return a;const r=K.get(t),e=Date.now();if(r&&e-r.timestamp<=n.cacheTtlMs)return r.data;const i=G.get(t);if(i)return i;const o=(async()=>{try{if(typeof n.getData=="function"){const d=await Promise.resolve(n.getData({editor:t,editorRoot:j(t)}));if(x(d))return d}if(n.api){const d=await At(t,n);if(x(d))return d}if(typeof n.data=="function"){const d=await Promise.resolve(n.data());if(x(d))return d}return x(n.data)?n.data:{}}finally{G.delete(t)}})();G.set(t,o);const l=await o;return K.set(t,{timestamp:e,data:l}),l}async function z(t,n,a){const r=V(t,n);if(v.set(t,a),tt(t,a,n),!a){r.forEach(i=>T(i,n,!1));return}const e=await I(t,n);r.forEach(i=>T(i,n,!0,e))}function bt(t,n){let a=lt(t);a||(a=document.createRange(),a.selectNodeContents(t),a.collapse(!1)),a.collapsed||a.deleteContents(),a.insertNode(n);const r=document.createTextNode(" ");n.after(r);const e=document.createRange();e.setStart(r,1),e.collapse(!0),st(t,e),t.normalize()}function gt(t){return typeof t.key=="string"?t.key.toLowerCase():""}function St(t){const n=t.metaKey||t.ctrlKey,a=gt(t),r=n&&t.altKey&&t.shiftKey&&a==="d",e=!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.shiftKey&&a==="f7";return r||e}function Tt(t){const n=t.metaKey||t.ctrlKey,a=gt(t),r=n&&t.altKey&&t.shiftKey&&a==="b",e=!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.shiftKey&&a==="f8";return r||e}function S(t,n,a,r,e){ft();const i=a==="insert"?lt(t):null,o=n.labels,l=e?Z(e,n):H(r||{},n),d=document.createElement("div");d.className=g,kt(t)&&d.classList.add("rte-data-binding-theme-dark");const c=document.createElement("section");c.className="rte-data-binding-dialog",c.setAttribute("role","dialog"),c.setAttribute("aria-modal","true"),c.setAttribute("aria-labelledby","rte-data-binding-dialog-title"),c.innerHTML=`
<header class="rte-data-binding-header">

@@ -322,2 +322,2 @@ <h2 id="rte-data-binding-dialog-title" class="rte-data-binding-title">${y(a==="edit"?o.dialogTitleEdit:o.dialogTitleInsert)}</h2>

</footer>
`,d.appendChild(c),document.body.appendChild(d);const u=c.querySelector(".rte-data-binding-key"),p=c.querySelector(".rte-data-binding-fallback"),m=c.querySelector(".rte-data-binding-format"),$=c.querySelector(".rte-data-binding-currency"),B=()=>{const s=m?.value==="currency",k=$?.closest(".rte-data-binding-field");k&&(k.style.display=s?"grid":"none")};B(),m?.addEventListener("change",B);const L=()=>{d.removeEventListener("click",nt),d.removeEventListener("keydown",rt,!0),document.removeEventListener("keydown",et,!0),d.parentNode&&d.parentNode.removeChild(d),R=null,t.focus({preventScroll:!0})},et=s=>{s.key==="Escape"&&(s.preventDefault(),s.stopPropagation(),L())},nt=s=>{s.target===d&&L()},gt=s=>{if(s.key!=="Tab")return;const k=Array.from(c.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(k.length===0)return;const w=k[0],E=k[k.length-1],F=document.activeElement;if(s.shiftKey&&F===w){s.preventDefault(),E.focus();return}!s.shiftKey&&F===E&&(s.preventDefault(),w.focus())},at=async()=>{const s=(u?.value||"").trim();if(!s){u?.focus();return}const k=H({key:s,fallback:(p?.value||"").trim(),format:m?.value||n.defaultFormat,currency:($?.value||"USD").trim().toUpperCase()},n),w=t.innerHTML;if(e){X(e,k,o);const E=v.get(t)===!0,F=E?await I(t,n):void 0;T(e,n,E,F)}else{if(i)try{st(t,i)}catch{}const E=ut(k,o);if(bt(t,E),v.get(t)===!0){const mt=await I(t,n);T(E,n,!0,mt)}}J(t),Y(t,w),L()},rt=s=>{if(s.key==="Escape"){s.preventDefault(),L();return}gt(s),s.key==="Enter"&&!s.shiftKey&&s.target instanceof HTMLInputElement&&(s.preventDefault(),at())};c.addEventListener("click",s=>{const w=s.target?.getAttribute("data-action");if(w){if(w==="cancel"){L();return}w==="save"&&at()}}),d.addEventListener("click",nt),d.addEventListener("keydown",rt,!0),document.addEventListener("keydown",et,!0),R={cleanup:L},u?.focus()}function Tt(t){_=t,O||(O=n=>{const r=n.target?.closest(A);if(!r)return;h=r,b.has(r)||b.set(r,t);const e=b.get(r)||t;V(r,e);const i=v.get(r)===!0;tt(r,i,e),i||Array.from(r.querySelectorAll(C)).forEach(l=>T(l,e,!1))},document.addEventListener("focusin",O,!0)),P||(P=n=>{if(document.querySelector(`.${g}`))return;const a=n.target;if(a?.closest("input, textarea, select"))return;const r=D(void 0,!1);if(!r||K(r))return;const e=b.get(r)||_||t,i=a?.closest(C);if(i&&(n.key==="Enter"||n.key===" ")){n.preventDefault(),n.stopPropagation(),h=r,S(r,e,"edit",void 0,i);return}if(At(n)){n.preventDefault(),n.stopPropagation();const o=Q(r);o?S(r,e,"edit",void 0,o):S(r,e,"insert");return}if(St(n)){n.preventDefault(),n.stopPropagation();const o=v.get(r)!==!0;z(r,e,o)}},document.addEventListener("keydown",P,!0)),M||(M=n=>{if(document.querySelector(`.${g}`)||n.defaultPrevented||n.button!==0||n.metaKey||n.ctrlKey||n.altKey||n.shiftKey)return;const r=n.target?.closest(C);if(!r)return;const e=r.closest(A);if(!e||K(e))return;const i=b.get(e)||_||t;b.set(e,i),h=e,n.preventDefault(),n.stopPropagation(),r.focus({preventScroll:!0}),S(e,i,"edit",void 0,r)},document.addEventListener("click",M,!0))}function $t(){O&&(document.removeEventListener("focusin",O,!0),O=null),P&&(document.removeEventListener("keydown",P,!0),P=null),M&&(document.removeEventListener("click",M,!0),M=null),_=null,h=null}const Lt=(t={})=>{const n=ot(t);return vt(),{name:"dataBinding",toolbar:[{id:"dataBindingTools",label:"Data Binding",type:"group",command:"openDataBindingDialog",items:[{id:"dataBinding",label:"Data Binding",command:"openDataBindingDialog",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M7 4a3 3 0 0 0-3 3v3h2V7a1 1 0 0 1 1-1h3V4H7Zm10 0h-3v2h3a1 1 0 0 1 1 1v3h2V7a3 3 0 0 0-3-3ZM4 14v3a3 3 0 0 0 3 3h3v-2H7a1 1 0 0 1-1-1v-3H4Zm14 0v3a1 1 0 0 1-1 1h-3v2h3a3 3 0 0 0 3-3v-3h-2ZM8.5 12a1.5 1.5 0 1 1 0-3h7a1.5 1.5 0 0 1 0 3h-7Zm0 4a1.5 1.5 0 1 1 0-3h4a1.5 1.5 0 0 1 0 3h-4Z" fill="currentColor"></path></svg>'},{id:"dataBindingPreview",label:"Data Preview",command:"toggleDataBindingPreview",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3c-4.4 0-8 1.3-8 3v12c0 1.7 3.6 3 8 3s8-1.3 8-3V6c0-1.7-3.6-3-8-3Zm0 2c3.9 0 6 .9 6 1s-2.1 1-6 1-6-.9-6-1 2.1-1 6-1Zm0 4c3 0 5.6-.5 7-1.3V11c0 .9-2.7 2-7 2s-7-1.1-7-2V7.7C6.4 8.5 9 9 12 9Zm0 6c-4.3 0-7-1.1-7-2v3c0 .9 2.7 2 7 2s7-1.1 7-2v-3c0 .9-2.7 2-7 2Z" fill="currentColor"></path><path d="M16.5 9.4a1 1 0 0 1 1.4 0l1.1 1.1 1.8-1.8a1 1 0 1 1 1.4 1.4l-2.5 2.5a1 1 0 0 1-1.4 0l-1.8-1.8a1 1 0 0 1 0-1.4Z" fill="currentColor"></path></svg>'}]}],commands:{openDataBindingDialog:(a,r)=>{const e=D(r);if(!e||K(e))return!1;h=e;const i=b.get(e)||n;b.set(e,i),V(e,i);const o=a?.target;if(o==="insert")return S(e,i,"insert",a),!0;const l=Q(e);return o==="edit"||l?!l&&o==="edit"?!1:(S(e,i,"edit",a,l||void 0),!0):(S(e,i,"insert",a),!0)},insertDataBindingToken:async(a,r)=>{const e=D(r);if(!e||K(e))return!1;h=e;const i=b.get(e)||n;b.set(e,i);const o=H(a||{},i);if(!o.key)return!1;const l=e.innerHTML,d=ut(o,i.labels);if(bt(e,d),v.get(e)===!0){const u=await I(e,i);T(d,i,!0,u)}return J(e),Y(e,l),!0},editDataBindingToken:async(a,r)=>{const e=D(r);if(!e||K(e))return!1;h=e;const i=b.get(e)||n;b.set(e,i);const o=Q(e);if(!o)return!1;const l=Z(o,i),d=H({...l,...a||{}},i);if(!d.key)return!1;const c=e.innerHTML;X(o,d,i.labels);const u=v.get(e)===!0,p=u?await I(e,i):void 0;return T(o,i,u,p),J(e),Y(e,c),!0},toggleDataBindingPreview:async(a,r)=>{const e=D(r);if(!e)return!1;h=e;const i=b.get(e)||n;b.set(e,i);const o=typeof a=="boolean"?a:v.get(e)!==!0;return await z(e,i,o),!0},setDataBindingData:async(a,r)=>{const e=D(r);if(!e)return!1;if(h=e,a&&typeof a=="object"?(W.set(e,a),N.set(e,{timestamp:Date.now(),data:a})):(W.delete(e),N.delete(e)),v.get(e)===!0){const i=b.get(e)||n;await z(e,i,!0)}return!0},refreshDataBindings:async(a,r)=>{const e=D(r);if(!e)return!1;h=e,N.delete(e);const i=b.get(e)||n;b.set(e,i);const o=v.get(e)===!0;return await z(e,i,o),!0}},keymap:{"Mod-Alt-Shift-d":"openDataBindingDialog","Mod-Alt-Shift-D":"openDataBindingDialog","Mod-Alt-Shift-b":"toggleDataBindingPreview","Mod-Alt-Shift-B":"toggleDataBindingPreview",F7:"openDataBindingDialog",F8:"toggleDataBindingPreview"},init:function(r){U+=1;const e=this&&typeof this.__pluginConfig=="object"?ot({...n,...this.__pluginConfig}):n;Tt(e);const i=D(r&&r.editorElement?{editorElement:r.editorElement}:void 0,!1);if(i){h=i,b.set(i,e),V(i,e);const o=v.get(i)===!0;tt(i,o,e)}},destroy:()=>{U=Math.max(0,U-1),U===0&&(ft(),$t())}}};exports.DataBindingPlugin=Lt;
`,d.appendChild(c),document.body.appendChild(d);const u=c.querySelector(".rte-data-binding-key"),p=c.querySelector(".rte-data-binding-fallback"),m=c.querySelector(".rte-data-binding-format"),$=c.querySelector(".rte-data-binding-currency"),B=()=>{const s=m?.value==="currency",k=$?.closest(".rte-data-binding-field");k&&(k.style.display=s?"grid":"none")};B(),m?.addEventListener("change",B);const L=()=>{d.removeEventListener("click",nt),d.removeEventListener("keydown",rt,!0),document.removeEventListener("keydown",et,!0),d.parentNode&&d.parentNode.removeChild(d),N=null,t.focus({preventScroll:!0})},et=s=>{s.key==="Escape"&&(s.preventDefault(),s.stopPropagation(),L())},nt=s=>{s.target===d&&L()},mt=s=>{if(s.key!=="Tab")return;const k=Array.from(c.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(k.length===0)return;const w=k[0],E=k[k.length-1],F=document.activeElement;if(s.shiftKey&&F===w){s.preventDefault(),E.focus();return}!s.shiftKey&&F===E&&(s.preventDefault(),w.focus())},at=async()=>{const s=(u?.value||"").trim();if(!s){u?.focus();return}const k=H({key:s,fallback:(p?.value||"").trim(),format:m?.value||n.defaultFormat,currency:($?.value||"USD").trim().toUpperCase()},n),w=t.innerHTML;if(e){X(e,k,o);const E=v.get(t)===!0,F=E?await I(t,n):void 0;T(e,n,E,F)}else{if(i)try{st(t,i)}catch{}const E=ut(k,o);if(bt(t,E),v.get(t)===!0){const pt=await I(t,n);T(E,n,!0,pt)}}J(t),Y(t,w),L()},rt=s=>{if(s.key==="Escape"){s.preventDefault(),L();return}mt(s),s.key==="Enter"&&!s.shiftKey&&s.target instanceof HTMLInputElement&&(s.preventDefault(),at())};c.addEventListener("click",s=>{const w=s.target?.getAttribute("data-action");if(w){if(w==="cancel"){L();return}w==="save"&&at()}}),d.addEventListener("click",nt),d.addEventListener("keydown",rt,!0),document.addEventListener("keydown",et,!0),N={cleanup:L},u?.focus()}function $t(t){_=t,O||(O=n=>{const r=n.target?.closest(A);if(!r)return;h=r,b.has(r)||b.set(r,t);const e=b.get(r)||t;V(r,e);const i=v.get(r)===!0;tt(r,i,e),i||Array.from(r.querySelectorAll(C)).forEach(l=>T(l,e,!1))},document.addEventListener("focusin",O,!0)),P||(P=n=>{if(document.querySelector(`.${g}`))return;const a=n.target;if(a?.closest("input, textarea, select"))return;const r=D(void 0,!1);if(!r||R(r))return;const e=b.get(r)||_||t,i=a?.closest(C);if(i&&(n.key==="Enter"||n.key===" ")){n.preventDefault(),n.stopPropagation(),h=r,S(r,e,"edit",void 0,i);return}if(St(n)){n.preventDefault(),n.stopPropagation();const o=Q(r);o?S(r,e,"edit",void 0,o):S(r,e,"insert");return}if(Tt(n)){n.preventDefault(),n.stopPropagation();const o=v.get(r)!==!0;z(r,e,o)}},document.addEventListener("keydown",P,!0)),M||(M=n=>{if(document.querySelector(`.${g}`)||n.defaultPrevented||n.button!==0||n.metaKey||n.ctrlKey||n.altKey||n.shiftKey)return;const r=n.target?.closest(C);if(!r)return;const e=r.closest(A);if(!e||R(e))return;const i=b.get(e)||_||t;b.set(e,i),h=e,n.preventDefault(),n.stopPropagation(),r.focus({preventScroll:!0}),S(e,i,"edit",void 0,r)},document.addEventListener("click",M,!0))}function Lt(){O&&(document.removeEventListener("focusin",O,!0),O=null),P&&(document.removeEventListener("keydown",P,!0),P=null),M&&(document.removeEventListener("click",M,!0),M=null),_=null,h=null}const Ct=(t={})=>{const n=ot(t);return xt(),{name:"dataBinding",toolbar:[{id:"dataBindingTools",label:"Data Binding",type:"group",command:"openDataBindingDialog",items:[{id:"dataBinding",label:"Data Binding",command:"openDataBindingDialog",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M7 4a3 3 0 0 0-3 3v3h2V7a1 1 0 0 1 1-1h3V4H7Zm10 0h-3v2h3a1 1 0 0 1 1 1v3h2V7a3 3 0 0 0-3-3ZM4 14v3a3 3 0 0 0 3 3h3v-2H7a1 1 0 0 1-1-1v-3H4Zm14 0v3a1 1 0 0 1-1 1h-3v2h3a3 3 0 0 0 3-3v-3h-2ZM8.5 12a1.5 1.5 0 1 1 0-3h7a1.5 1.5 0 0 1 0 3h-7Zm0 4a1.5 1.5 0 1 1 0-3h4a1.5 1.5 0 0 1 0 3h-4Z" fill="currentColor"></path></svg>'},{id:"dataBindingPreview",label:"Data Preview",command:"toggleDataBindingPreview",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3c-4.4 0-8 1.3-8 3v12c0 1.7 3.6 3 8 3s8-1.3 8-3V6c0-1.7-3.6-3-8-3Zm0 2c3.9 0 6 .9 6 1s-2.1 1-6 1-6-.9-6-1 2.1-1 6-1Zm0 4c3 0 5.6-.5 7-1.3V11c0 .9-2.7 2-7 2s-7-1.1-7-2V7.7C6.4 8.5 9 9 12 9Zm0 6c-4.3 0-7-1.1-7-2v3c0 .9 2.7 2 7 2s7-1.1 7-2v-3c0 .9-2.7 2-7 2Z" fill="currentColor"></path><path d="M16.5 9.4a1 1 0 0 1 1.4 0l1.1 1.1 1.8-1.8a1 1 0 1 1 1.4 1.4l-2.5 2.5a1 1 0 0 1-1.4 0l-1.8-1.8a1 1 0 0 1 0-1.4Z" fill="currentColor"></path></svg>'}]}],commands:{openDataBindingDialog:(a,r)=>{const e=D(r);if(!e||R(e))return!1;h=e;const i=b.get(e)||n;b.set(e,i),V(e,i);const o=a?.target;if(o==="insert")return S(e,i,"insert",a),!0;const l=Q(e);return o==="edit"||l?!l&&o==="edit"?!1:(S(e,i,"edit",a,l||void 0),!0):(S(e,i,"insert",a),!0)},insertDataBindingToken:async(a,r)=>{const e=D(r);if(!e||R(e))return!1;h=e;const i=b.get(e)||n;b.set(e,i);const o=H(a||{},i);if(!o.key)return!1;const l=e.innerHTML,d=ut(o,i.labels);if(bt(e,d),v.get(e)===!0){const u=await I(e,i);T(d,i,!0,u)}return J(e),Y(e,l),!0},editDataBindingToken:async(a,r)=>{const e=D(r);if(!e||R(e))return!1;h=e;const i=b.get(e)||n;b.set(e,i);const o=Q(e);if(!o)return!1;const l=Z(o,i),d=H({...l,...a||{}},i);if(!d.key)return!1;const c=e.innerHTML;X(o,d,i.labels);const u=v.get(e)===!0,p=u?await I(e,i):void 0;return T(o,i,u,p),J(e),Y(e,c),!0},toggleDataBindingPreview:async(a,r)=>{const e=D(r);if(!e)return!1;h=e;const i=b.get(e)||n;b.set(e,i);const o=typeof a=="boolean"?a:v.get(e)!==!0;return await z(e,i,o),!0},setDataBindingData:async(a,r)=>{const e=D(r);if(!e)return!1;if(h=e,a&&typeof a=="object"?(W.set(e,a),K.set(e,{timestamp:Date.now(),data:a})):(W.delete(e),K.delete(e)),v.get(e)===!0){const i=b.get(e)||n;await z(e,i,!0)}return!0},refreshDataBindings:async(a,r)=>{const e=D(r);if(!e)return!1;h=e,K.delete(e);const i=b.get(e)||n;b.set(e,i);const o=v.get(e)===!0;return await z(e,i,o),!0}},keymap:{"Mod-Alt-Shift-d":"openDataBindingDialog","Mod-Alt-Shift-D":"openDataBindingDialog","Mod-Alt-Shift-b":"toggleDataBindingPreview","Mod-Alt-Shift-B":"toggleDataBindingPreview",F7:"openDataBindingDialog",F8:"toggleDataBindingPreview"},init:function(r){U+=1;const e=this&&typeof this.__pluginConfig=="object"?ot({...n,...this.__pluginConfig}):n;$t(e);const i=D(r&&r.editorElement?{editorElement:r.editorElement}:void 0,!1);if(i){h=i,b.set(i,e),V(i,e);const o=v.get(i)===!0;tt(i,o,e)}},destroy:()=>{U=Math.max(0,U-1),U===0&&(ft(),Lt())}}};exports.DataBindingPlugin=Ct;

@@ -1,2 +0,2 @@

const A = ".rte-content, .editora-content", C = '.rte-data-binding[data-binding="true"]', it = "rte-data-binding-styles", g = "rte-data-binding-dialog-overlay", f = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', pt = {
const A = ".rte-content, .editora-content", C = '.rte-data-binding[data-binding="true"]', it = "rte-data-binding-styles", g = "rte-data-binding-dialog-overlay", f = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', yt = {
dialogTitleInsert: "Insert Data Binding",

@@ -16,7 +16,7 @@ dialogTitleEdit: "Edit Data Binding",

tokenAriaPrefix: "Data binding token"
}, x = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new WeakMap();
let R = null, h = null, U = 0, P = null, O = null, M = null, z = null;
function yt(t) {
}, x = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new WeakMap();
let N = null, h = null, U = 0, P = null, O = null, M = null, z = null;
function ht(t) {
return {
...pt,
...yt,
...t || {}

@@ -32,3 +32,3 @@ };

cacheTtlMs: Math.max(0, Number(t.cacheTtlMs ?? 3e4)),
labels: yt(t.labels),
labels: ht(t.labels),
defaultFormat: t.defaultFormat || "text",

@@ -53,3 +53,3 @@ defaultFallback: t.defaultFallback || "",

}
function ht(t) {
function kt(t) {
const n = j(t);

@@ -81,3 +81,3 @@ if (q(n)) return !0;

}
function K(t) {
function R(t) {
return t.getAttribute("contenteditable") === "false" || t.getAttribute("data-readonly") === "true";

@@ -95,3 +95,3 @@ }

}
function kt(t, n) {
function xt(t, n) {
const a = (n || "").trim();

@@ -104,3 +104,3 @@ if (a)

}
function xt() {
function vt() {
if (typeof document > "u" || document.getElementById(it)) return;

@@ -454,3 +454,3 @@ const t = document.createElement("style");

function ft() {
R && (R.cleanup(), R = null);
N && (N.cleanup(), N = null);
}

@@ -466,3 +466,3 @@ function tt(t, n, a) {

}
function vt(t, n, a) {
function wt(t, n, a) {
const r = n.format || "text";

@@ -509,3 +509,3 @@ if (t == null) return n.fallback || "";

}
const o = kt(r, i), l = o == null, d = l ? e.fallback || "" : vt(o, e, n);
const o = xt(r, i), l = o == null, d = l ? e.fallback || "" : wt(o, e, n);
t.textContent = d || e.fallback || "", t.classList.add("rte-data-binding-preview"), l && !(e.fallback || "").trim() && t.classList.add("rte-data-binding-missing"), t.setAttribute("aria-label", `${n.labels.tokenAriaPrefix}: ${i} = ${t.textContent || ""}. Press Enter to edit.`);

@@ -516,3 +516,3 @@ }

}
function wt(t, n) {
function Et(t, n) {
return n ? n.split(".").filter(Boolean).reduce((a, r) => {

@@ -523,3 +523,3 @@ if (!(!v(a) && !Array.isArray(a)))

}
function Et(t, n, a) {
function Dt(t, n, a) {
const r = n.api, e = j(t), i = { editor: t, editorRoot: e, signal: a };

@@ -554,3 +554,3 @@ if (r.buildRequest) {

}
async function Dt(t, n) {
async function At(t, n) {
const a = n.api;

@@ -562,3 +562,3 @@ if (!a) return {};

try {
const { url: d, init: c } = Et(t, n, r.signal), u = await fetch(d, { ...c, signal: r.signal });
const { url: d, init: c } = Dt(t, n, r.signal), u = await fetch(d, { ...c, signal: r.signal });
if (!u.ok)

@@ -571,3 +571,3 @@ throw new Error(`Data binding API request failed: ${u.status}`);

}
const $ = wt(m, a.responsePath);
const $ = Et(m, a.responsePath);
return v($) ? $ : v(m) ? m : { value: $ };

@@ -583,3 +583,3 @@ } catch (d) {

if (a) return a;
const r = N.get(t), e = Date.now();
const r = K.get(t), e = Date.now();
if (r && e - r.timestamp <= n.cacheTtlMs)

@@ -596,3 +596,3 @@ return r.data;

if (n.api) {
const d = await Dt(t, n);
const d = await At(t, n);
if (v(d)) return d;

@@ -611,3 +611,3 @@ }

const l = await o;
return N.set(t, { timestamp: e, data: l }), l;
return K.set(t, { timestamp: e, data: l }), l;
}

@@ -631,14 +631,17 @@ async function _(t, n, a) {

}
function At(t) {
const n = t.metaKey || t.ctrlKey, a = t.key.toLowerCase(), r = n && t.altKey && t.shiftKey && a === "d", e = !t.metaKey && !t.ctrlKey && !t.altKey && !t.shiftKey && a === "f7";
return r || e;
function gt(t) {
return typeof t.key == "string" ? t.key.toLowerCase() : "";
}
function St(t) {
const n = t.metaKey || t.ctrlKey, a = t.key.toLowerCase(), r = n && t.altKey && t.shiftKey && a === "b", e = !t.metaKey && !t.ctrlKey && !t.altKey && !t.shiftKey && a === "f8";
const n = t.metaKey || t.ctrlKey, a = gt(t), r = n && t.altKey && t.shiftKey && a === "d", e = !t.metaKey && !t.ctrlKey && !t.altKey && !t.shiftKey && a === "f7";
return r || e;
}
function Tt(t) {
const n = t.metaKey || t.ctrlKey, a = gt(t), r = n && t.altKey && t.shiftKey && a === "b", e = !t.metaKey && !t.ctrlKey && !t.altKey && !t.shiftKey && a === "f8";
return r || e;
}
function S(t, n, a, r, e) {
ft();
const i = a === "insert" ? lt(t) : null, o = n.labels, l = e ? Z(e, n) : H(r || {}, n), d = document.createElement("div");
d.className = g, ht(t) && d.classList.add("rte-data-binding-theme-dark");
d.className = g, kt(t) && d.classList.add("rte-data-binding-theme-dark");
const c = document.createElement("section");

@@ -694,3 +697,3 @@ c.className = "rte-data-binding-dialog", c.setAttribute("role", "dialog"), c.setAttribute("aria-modal", "true"), c.setAttribute("aria-labelledby", "rte-data-binding-dialog-title"), c.innerHTML = `

const L = () => {
d.removeEventListener("click", nt), d.removeEventListener("keydown", rt, !0), document.removeEventListener("keydown", et, !0), d.parentNode && d.parentNode.removeChild(d), R = null, t.focus({ preventScroll: !0 });
d.removeEventListener("click", nt), d.removeEventListener("keydown", rt, !0), document.removeEventListener("keydown", et, !0), d.parentNode && d.parentNode.removeChild(d), N = null, t.focus({ preventScroll: !0 });
}, et = (s) => {

@@ -700,3 +703,3 @@ s.key === "Escape" && (s.preventDefault(), s.stopPropagation(), L());

s.target === d && L();
}, gt = (s) => {
}, mt = (s) => {
if (s.key !== "Tab") return;

@@ -740,4 +743,4 @@ const k = Array.from(

if (bt(t, E), x.get(t) === !0) {
const mt = await I(t, n);
T(E, n, !0, mt);
const pt = await I(t, n);
T(E, n, !0, pt);
}

@@ -751,3 +754,3 @@ }

}
gt(s), s.key === "Enter" && !s.shiftKey && s.target instanceof HTMLInputElement && (s.preventDefault(), at());
mt(s), s.key === "Enter" && !s.shiftKey && s.target instanceof HTMLInputElement && (s.preventDefault(), at());
};

@@ -763,5 +766,5 @@ c.addEventListener("click", (s) => {

}
}), d.addEventListener("click", nt), d.addEventListener("keydown", rt, !0), document.addEventListener("keydown", et, !0), R = { cleanup: L }, u?.focus();
}), d.addEventListener("click", nt), d.addEventListener("keydown", rt, !0), document.addEventListener("keydown", et, !0), N = { cleanup: L }, u?.focus();
}
function Tt(t) {
function $t(t) {
z = t, O || (O = (n) => {

@@ -780,3 +783,3 @@ const r = n.target?.closest(A);

const r = D(void 0, !1);
if (!r || K(r)) return;
if (!r || R(r)) return;
const e = b.get(r) || z || t, i = a?.closest(C);

@@ -787,3 +790,3 @@ if (i && (n.key === "Enter" || n.key === " ")) {

}
if (At(n)) {
if (St(n)) {
n.preventDefault(), n.stopPropagation();

@@ -794,3 +797,3 @@ const o = Q(r);

}
if (St(n)) {
if (Tt(n)) {
n.preventDefault(), n.stopPropagation();

@@ -805,3 +808,3 @@ const o = x.get(r) !== !0;

const e = r.closest(A);
if (!e || K(e)) return;
if (!e || R(e)) return;
const i = b.get(e) || z || t;

@@ -811,8 +814,8 @@ b.set(e, i), h = e, n.preventDefault(), n.stopPropagation(), r.focus({ preventScroll: !0 }), S(e, i, "edit", void 0, r);

}
function $t() {
function Lt() {
O && (document.removeEventListener("focusin", O, !0), O = null), P && (document.removeEventListener("keydown", P, !0), P = null), M && (document.removeEventListener("click", M, !0), M = null), z = null, h = null;
}
const Lt = (t = {}) => {
const Ct = (t = {}) => {
const n = ot(t);
return xt(), {
return vt(), {
name: "dataBinding",

@@ -844,3 +847,3 @@ toolbar: [

const e = D(r);
if (!e || K(e)) return !1;
if (!e || R(e)) return !1;
h = e;

@@ -857,3 +860,3 @@ const i = b.get(e) || n;

const e = D(r);
if (!e || K(e)) return !1;
if (!e || R(e)) return !1;
h = e;

@@ -873,3 +876,3 @@ const i = b.get(e) || n;

const e = D(r);
if (!e || K(e)) return !1;
if (!e || R(e)) return !1;
h = e;

@@ -899,3 +902,3 @@ const i = b.get(e) || n;

if (!e) return !1;
if (h = e, a && typeof a == "object" ? (W.set(e, a), N.set(e, { timestamp: Date.now(), data: a })) : (W.delete(e), N.delete(e)), x.get(e) === !0) {
if (h = e, a && typeof a == "object" ? (W.set(e, a), K.set(e, { timestamp: Date.now(), data: a })) : (W.delete(e), K.delete(e)), x.get(e) === !0) {
const i = b.get(e) || n;

@@ -909,3 +912,3 @@ await _(e, i, !0);

if (!e) return !1;
h = e, N.delete(e);
h = e, K.delete(e);
const i = b.get(e) || n;

@@ -928,3 +931,3 @@ b.set(e, i);

const e = this && typeof this.__pluginConfig == "object" ? ot({ ...n, ...this.__pluginConfig }) : n;
Tt(e);
$t(e);
const i = D(

@@ -941,3 +944,3 @@ r && r.editorElement ? { editorElement: r.editorElement } : void 0,

destroy: () => {
U = Math.max(0, U - 1), U === 0 && (ft(), $t());
U = Math.max(0, U - 1), U === 0 && (ft(), Lt());
}

@@ -947,3 +950,3 @@ };

export {
Lt as DataBindingPlugin
Ct as DataBindingPlugin
};

@@ -1,1 +0,1 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","LI","BLOCKQUOTE","PRE"]),a=e=>f.has(e.tagName)&&e.getAttribute("contenteditable")!=="true",h=()=>{const e=window.getSelection();if(e&&e.rangeCount>0){let t=e.getRangeAt(0).startContainer;for(;t&&t!==document.body;){if(t.nodeType===Node.ELEMENT_NODE){const r=t;if(r.getAttribute("contenteditable")==="true")return r}t=t.parentNode}}const n=document.activeElement;if(n){if(n.getAttribute("contenteditable")==="true")return n;const t=n.closest('[contenteditable="true"]');if(t)return t}return document.querySelector('[contenteditable="true"]')},u=e=>{let n=e;for(;n&&n!==document.body;){if(n.nodeType===Node.ELEMENT_NODE){const t=n;if(a(t))return t;if(t.getAttribute("contenteditable")==="true")break}n=n.parentNode}return null},C=(e,n)=>{const t=[],r=new Set,i=o=>{!o||r.has(o)||n.contains(o)&&a(o)&&(r.add(o),t.push(o))};if(e.collapsed)return i(u(e.startContainer)),t;const s=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const d=o;if(!a(d))return NodeFilter.FILTER_SKIP;if(typeof e.intersectsNode=="function")return e.intersectsNode(d)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP;const l=document.createRange();return l.selectNodeContents(d),e.compareBoundaryPoints(Range.END_TO_START,l)>0&&e.compareBoundaryPoints(Range.START_TO_END,l)<0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});let c=s.nextNode();for(;c;)i(c),c=s.nextNode();return t.length===0&&i(u(e.commonAncestorContainer)),t},T=(e,n)=>{if(n===e.innerHTML)return;const t=window.execEditorCommand||window.executeEditorCommand;if(typeof t=="function")try{t("recordDomTransaction",e,n,e.innerHTML)}catch{}},g=e=>{const n=h();if(!n)return!1;const t=window.getSelection();if(!t||t.rangeCount===0)return!1;const r=t.getRangeAt(0);if(!n.contains(r.commonAncestorContainer))return!1;const i=C(r,n);if(i.length===0)return!1;const s=n.innerHTML;return i.forEach(c=>{e==="rtl"?c.setAttribute("dir","rtl"):c.removeAttribute("dir")}),T(n,s),n.dispatchEvent(new Event("input",{bubbles:!0})),!0},p=()=>({name:"direction",toolbar:[{label:"Left to Right",command:"setDirectionLTR",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" 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="M21 18H3M21 18L18 21M21 18L18 15M13 3V12M13 3H7M13 3C13.4596 3 13.9148 3.0776 14.3394 3.22836C14.764 3.37913 15.1499 3.6001 15.4749 3.87868C15.7999 4.15726 16.0577 4.48797 16.2336 4.85195C16.4095 5.21593 16.5 5.60603 16.5 6C16.5 6.39397 16.4095 6.78407 16.2336 7.14805C16.0577 7.51203 15.7999 7.84274 15.4749 8.12132C15.1499 8.3999 14.764 8.62087 14.3394 8.77164C13.9148 8.9224 13.4596 9 13 9V3ZM9 3V12" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"Mod-Shift-l"},{label:"Right to Left",command:"setDirectionRTL",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" 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="M3 18H21M3 18L6 21M3 18L6 15M11 12V3H17M15 3V12M10.5 3C10.0404 3 9.58525 3.0776 9.16061 3.22836C8.73597 3.37913 8.35013 3.6001 8.02513 3.87868C7.70012 4.15726 7.44231 4.48797 7.26642 4.85195C7.09053 5.21593 7 5.60603 7 6C7 6.39397 7.09053 6.78407 7.26642 7.14805C7.44231 7.51203 7.70012 7.84274 8.02513 8.12132C8.35013 8.3999 8.73597 8.62087 9.16061 8.77164C9.58525 8.9224 10.0404 9 10.5 9L10.5 3Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"Mod-Shift-r"}],commands:{setDirectionLTR:()=>{try{return g(null)}catch(e){return console.error("Failed to set LTR direction:",e),!1}},setDirectionRTL:()=>{try{return g("rtl")}catch(e){return console.error("Failed to set RTL direction:",e),!1}}},keymap:{"Mod-Shift-l":"setDirectionLTR","Mod-Shift-r":"setDirectionRTL"}});exports.DirectionPlugin=p;
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l='.rte-content, .editora-content, [contenteditable="true"]',g="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",T=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","LI","BLOCKQUOTE","PRE","TABLE","FIGURE","UL","OL"]),d=e=>T.has(e.tagName)&&e.getAttribute("contenteditable")!=="true",m=e=>e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null,C=e=>{const n=e?.contentElement;if(n instanceof HTMLElement)return n;const t=e?.editorElement;if(t instanceof HTMLElement){const o=t.querySelector(l);if(o instanceof HTMLElement)return o;if(t.getAttribute("contenteditable")==="true")return t}const r=window.__editoraCommandEditorRoot;if(r instanceof HTMLElement){const o=r.querySelector(l);if(o instanceof HTMLElement)return o;if(r.getAttribute("contenteditable")==="true")return r}const i=window.getSelection();if(i&&i.rangeCount>0){const o=m(i.getRangeAt(0).startContainer),c=o?.closest(l);if(c instanceof HTMLElement)return c;const f=o?.closest(g)?.querySelector(l);if(f instanceof HTMLElement)return f}const a=document.activeElement,s=a instanceof HTMLElement?a.closest(l):null;return s instanceof HTMLElement?s:document.querySelector(l)},L=e=>{const n=window.getSelection();if(!n||n.rangeCount===0)return null;const t=n.getRangeAt(0);return!e.contains(t.startContainer)||!e.contains(t.endContainer)?null:t},R=(e,n)=>{let t=m(n);for(;t&&t!==e&&e.contains(t);){if(d(t))return t;t=t.parentElement}return d(e)?e:null},u=(e,n)=>{const t=R(e,n);if(!t||t===e)return null;const r=t.closest("li");return r instanceof HTMLElement&&e.contains(r)?r:t},h=(e,n)=>{if(typeof e.intersectsNode=="function")try{return e.intersectsNode(n)}catch{return!1}const t=document.createRange();return t.selectNode(n),e.compareBoundaryPoints(Range.END_TO_START,t)<0&&e.compareBoundaryPoints(Range.START_TO_END,t)>0},w=(e,n)=>{const t=[],r=new Set,i=o=>{!o||r.has(o)||o===n||!n.contains(o)||d(o)&&(r.add(o),t.push(o))};if(e.collapsed)return i(u(n,e.startContainer)),t;i(u(n,e.startContainer)),i(u(n,e.endContainer));const a=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const c=o;return!d(c)||c.closest("li")&&c.tagName!=="LI"?NodeFilter.FILTER_SKIP:h(e,c)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});let s=a.nextNode();for(;s;)i(s),s=a.nextNode();return t.length===0&&i(u(n,e.commonAncestorContainer)),t.filter(o=>!t.some(c=>c!==o&&o.contains(c)))},p=(e,n,t)=>{if(n!==t){if(typeof window.execEditorCommand=="function"){window.execEditorCommand("recordDomTransaction",e,n,t);return}if(typeof window.executeEditorCommand=="function")try{window.executeEditorCommand("recordDomTransaction",{editor:e,beforeHTML:n,afterHTML:t})}catch{}}},E=(e,n)=>{const t=C(n);if(!t)return!1;const r=L(t);if(!r)return!1;const i=w(r,t);if(i.length===0)return!1;const a=t.innerHTML;i.forEach(o=>{o.setAttribute("dir",e)});const s=t.innerHTML;return a===s?!1:(p(t,a,s),t.dispatchEvent(new window.Event("input",{bubbles:!0})),!0)},S=()=>({name:"direction",toolbar:[{label:"Left to Right",command:"setDirectionLTR",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" 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="M21 18H3M21 18L18 21M21 18L18 15M13 3V12M13 3H7M13 3C13.4596 3 13.9148 3.0776 14.3394 3.22836C14.764 3.37913 15.1499 3.6001 15.4749 3.87868C15.7999 4.15726 16.0577 4.48797 16.2336 4.85195C16.4095 5.21593 16.5 5.60603 16.5 6C16.5 6.39397 16.4095 6.78407 16.2336 7.14805C16.0577 7.51203 15.7999 7.84274 15.4749 8.12132C15.1499 8.3999 14.764 8.62087 14.3394 8.77164C13.9148 8.9224 13.4596 9 13 9V3ZM9 3V12" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"Mod-Shift-l"},{label:"Right to Left",command:"setDirectionRTL",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" 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="M3 18H21M3 18L6 21M3 18L6 15M11 12V3H17M15 3V12M10.5 3C10.0404 3 9.58525 3.0776 9.16061 3.22836C8.73597 3.37913 8.35013 3.6001 8.02513 3.87868C7.70012 4.15726 7.44231 4.48797 7.26642 4.85195C7.09053 5.21593 7 5.60603 7 6C7 6.39397 7.09053 6.78407 7.26642 7.14805C7.44231 7.51203 7.70012 7.84274 8.02513 8.12132C8.35013 8.3999 8.73597 8.62087 9.16061 8.77164C9.58525 8.9224 10.0404 9 10.5 9L10.5 3Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"Mod-Shift-r"}],commands:{setDirectionLTR:(e,n)=>{try{return E("ltr",n)}catch(t){return console.error("Failed to set LTR direction:",t),!1}},setDirectionRTL:(e,n)=>{try{return E("rtl",n)}catch(t){return console.error("Failed to set RTL direction:",t),!1}}},keymap:{"Mod-Shift-l":"setDirectionLTR","Mod-Shift-r":"setDirectionRTL"}});exports.DirectionPlugin=S;

@@ -1,2 +0,2 @@

const g = /* @__PURE__ */ new Set([
const l = '.rte-content, .editora-content, [contenteditable="true"]', T = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", C = /* @__PURE__ */ new Set([
"P",

@@ -12,42 +12,65 @@ "DIV",

"BLOCKQUOTE",
"PRE"
]), l = (e) => g.has(e.tagName) && e.getAttribute("contenteditable") !== "true", h = () => {
const e = window.getSelection();
if (e && e.rangeCount > 0) {
let t = e.getRangeAt(0).startContainer;
for (; t && t !== document.body; ) {
if (t.nodeType === Node.ELEMENT_NODE) {
const r = t;
if (r.getAttribute("contenteditable") === "true")
return r;
}
t = t.parentNode;
}
"PRE",
"TABLE",
"FIGURE",
"UL",
"OL"
]), d = (e) => C.has(e.tagName) && e.getAttribute("contenteditable") !== "true", m = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null, g = (e) => {
const n = e?.contentElement;
if (n instanceof HTMLElement) return n;
const t = e?.editorElement;
if (t instanceof HTMLElement) {
const o = t.querySelector(l);
if (o instanceof HTMLElement) return o;
if (t.getAttribute("contenteditable") === "true") return t;
}
const n = document.activeElement;
if (n) {
if (n.getAttribute("contenteditable") === "true")
return n;
const t = n.closest('[contenteditable="true"]');
if (t) return t;
const r = window.__editoraCommandEditorRoot;
if (r instanceof HTMLElement) {
const o = r.querySelector(l);
if (o instanceof HTMLElement) return o;
if (r.getAttribute("contenteditable") === "true") return r;
}
return document.querySelector('[contenteditable="true"]');
}, u = (e) => {
let n = e;
for (; n && n !== document.body; ) {
if (n.nodeType === Node.ELEMENT_NODE) {
const t = n;
if (l(t)) return t;
if (t.getAttribute("contenteditable") === "true") break;
const i = window.getSelection();
if (i && i.rangeCount > 0) {
const o = m(i.getRangeAt(0).startContainer), c = o?.closest(l);
if (c instanceof HTMLElement) return c;
const f = o?.closest(T)?.querySelector(l);
if (f instanceof HTMLElement) return f;
}
const a = document.activeElement, s = a instanceof HTMLElement ? a.closest(l) : null;
return s instanceof HTMLElement ? s : document.querySelector(l);
}, L = (e) => {
const n = window.getSelection();
if (!n || n.rangeCount === 0) return null;
const t = n.getRangeAt(0);
return !e.contains(t.startContainer) || !e.contains(t.endContainer) ? null : t;
}, R = (e, n) => {
let t = m(n);
for (; t && t !== e && e.contains(t); ) {
if (d(t)) return t;
t = t.parentElement;
}
return d(e) ? e : null;
}, u = (e, n) => {
const t = R(e, n);
if (!t || t === e) return null;
const r = t.closest("li");
return r instanceof HTMLElement && e.contains(r) ? r : t;
}, h = (e, n) => {
if (typeof e.intersectsNode == "function")
try {
return e.intersectsNode(n);
} catch {
return !1;
}
n = n.parentNode;
}
return null;
}, C = (e, n) => {
const t = document.createRange();
return t.selectNode(n), e.compareBoundaryPoints(Range.END_TO_START, t) < 0 && e.compareBoundaryPoints(Range.START_TO_END, t) > 0;
}, w = (e, n) => {
const t = [], r = /* @__PURE__ */ new Set(), i = (o) => {
!o || r.has(o) || n.contains(o) && l(o) && (r.add(o), t.push(o));
!o || r.has(o) || o === n || !n.contains(o) || d(o) && (r.add(o), t.push(o));
};
if (e.collapsed)
return i(u(e.startContainer)), t;
const s = document.createTreeWalker(
return i(u(n, e.startContainer)), t;
i(u(n, e.startContainer)), i(u(n, e.endContainer));
const a = document.createTreeWalker(
n,

@@ -57,37 +80,37 @@ NodeFilter.SHOW_ELEMENT,

acceptNode: (o) => {
const d = o;
if (!l(d)) return NodeFilter.FILTER_SKIP;
if (typeof e.intersectsNode == "function")
return e.intersectsNode(d) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
const a = document.createRange();
return a.selectNodeContents(d), e.compareBoundaryPoints(Range.END_TO_START, a) > 0 && e.compareBoundaryPoints(Range.START_TO_END, a) < 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
const c = o;
return !d(c) || c.closest("li") && c.tagName !== "LI" ? NodeFilter.FILTER_SKIP : h(e, c) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
}
}
);
let c = s.nextNode();
for (; c; )
i(c), c = s.nextNode();
return t.length === 0 && i(u(e.commonAncestorContainer)), t;
}, T = (e, n) => {
if (n === e.innerHTML) return;
const t = window.execEditorCommand || window.executeEditorCommand;
if (typeof t == "function")
try {
t("recordDomTransaction", e, n, e.innerHTML);
} catch {
let s = a.nextNode();
for (; s; )
i(s), s = a.nextNode();
return t.length === 0 && i(u(n, e.commonAncestorContainer)), t.filter((o) => !t.some((c) => c !== o && o.contains(c)));
}, p = (e, n, t) => {
if (n !== t) {
if (typeof window.execEditorCommand == "function") {
window.execEditorCommand("recordDomTransaction", e, n, t);
return;
}
}, f = (e) => {
const n = h();
if (!n) return !1;
const t = window.getSelection();
if (!t || t.rangeCount === 0) return !1;
const r = t.getRangeAt(0);
if (!n.contains(r.commonAncestorContainer)) return !1;
const i = C(r, n);
if (typeof window.executeEditorCommand == "function")
try {
window.executeEditorCommand("recordDomTransaction", { editor: e, beforeHTML: n, afterHTML: t });
} catch {
}
}
}, E = (e, n) => {
const t = g(n);
if (!t) return !1;
const r = L(t);
if (!r) return !1;
const i = w(r, t);
if (i.length === 0) return !1;
const s = n.innerHTML;
return i.forEach((c) => {
e === "rtl" ? c.setAttribute("dir", "rtl") : c.removeAttribute("dir");
}), T(n, s), n.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
}, E = () => ({
const a = t.innerHTML;
i.forEach((o) => {
o.setAttribute("dir", e);
});
const s = t.innerHTML;
return a === s ? !1 : (p(t, a, s), t.dispatchEvent(new window.Event("input", { bubbles: !0 })), !0);
}, M = () => ({
name: "direction",

@@ -109,14 +132,14 @@ toolbar: [

commands: {
setDirectionLTR: () => {
setDirectionLTR: (e, n) => {
try {
return f(null);
} catch (e) {
return console.error("Failed to set LTR direction:", e), !1;
return E("ltr", n);
} catch (t) {
return console.error("Failed to set LTR direction:", t), !1;
}
},
setDirectionRTL: () => {
setDirectionRTL: (e, n) => {
try {
return f("rtl");
} catch (e) {
return console.error("Failed to set RTL direction:", e), !1;
return E("rtl", n);
} catch (t) {
return console.error("Failed to set RTL direction:", t), !1;
}

@@ -131,3 +154,3 @@ }

export {
E as DirectionPlugin
M as DirectionPlugin
};

@@ -1,2 +0,2 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const S=".rte-content, .editora-content",ie="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",fe="__editoraCommandEditorRoot",he="rte-doc-schema-styles",m="rte-doc-schema-panel",v="document-schema",M="doc-schema",H="docSchema",E=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Ie={panelTitle:"Document Schema",panelAriaLabel:"Document schema panel",schemaLabel:"Schema",schemaDescriptionPrefix:"Description",validateText:"Run Validation",insertMissingText:"Insert Missing Sections",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",noIssuesText:"No schema violations detected.",summaryPrefix:"Schema",issueListLabel:"Schema issues",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+G (panel), Ctrl/Cmd+Alt+Shift+J (validate)",helperText:"Choose a schema, validate structure, then insert missing sections safely.",readonlyMessage:"Editor is read-only. Missing sections cannot be inserted.",defaultPlaceholderText:"Add section content.",missingSectionMessage:"Missing required section",duplicateSectionMessage:"Section appears too many times",outOfOrderMessage:"Section appears out of required order",unknownHeadingMessage:"Heading is not part of selected schema",insertedSummaryPrefix:"Inserted missing sections"},u=new WeakMap,X=new WeakMap,j=new WeakMap,p=new Map,F=new WeakMap,te=new WeakMap,ne=new Set;let W=0,Ae=0,ge=0,w=null,b=null,q=null,z=null,B=null,R=null,K=null;function I(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Le(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function P(e,t,n){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):t}function xe(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function ce(e,t){return t(e).toLowerCase().replace(/^[\s\-\u2022]*(?:[0-9]+(?:\.[0-9]+)*)[\)\.\-:\s]+/,"").replace(/^[\s\-\u2022]*(?:[ivxlcdm]+)[\)\.\-:\s]+/i,"").replace(/[::]+$/g,"").replace(/\s+/g," ").trim()}function be(){return[{id:"contract",label:"Contract",description:"Template for legal/commercial agreements with strict section ordering.",strictOrder:!0,allowUnknownHeadings:!1,sections:[{id:"summary",title:"Executive Summary",aliases:["Overview"]},{id:"scope",title:"Scope"},{id:"terms",title:"Terms and Conditions",aliases:["Terms"]},{id:"responsibilities",title:"Responsibilities"},{id:"sla",title:"Service Levels",aliases:["SLA","Service Level Agreement"]},{id:"termination",title:"Termination"}]},{id:"sop",label:"SOP",description:"Standard operating procedure with clear implementation and governance sections.",strictOrder:!0,allowUnknownHeadings:!0,sections:[{id:"purpose",title:"Purpose"},{id:"scope",title:"Scope"},{id:"procedure",title:"Procedure",maxOccurrences:10},{id:"roles",title:"Roles and Responsibilities",aliases:["Responsibilities"]},{id:"validation",title:"Validation"},{id:"revision-history",title:"Revision History",aliases:["Change History"]}]},{id:"policy",label:"Policy",description:"Policy document with control ownership, exception handling, and enforcement.",strictOrder:!0,allowUnknownHeadings:!0,sections:[{id:"statement",title:"Policy Statement"},{id:"applicability",title:"Applicability",aliases:["Scope"]},{id:"controls",title:"Controls"},{id:"exceptions",title:"Exceptions"},{id:"enforcement",title:"Enforcement"}]}]}function Oe(e,t,n){const r=n(e.title||"");if(!r)return null;const s=xe(n(e.id||r))||`section-${t+1}`,o=P(Number(e.minOccurrences??1),0,20),a=Math.max(1,o),c=P(Number(e.maxOccurrences??a),o,40),i=n(e.placeholder||""),l=Array.isArray(e.aliases)?e.aliases.map(y=>n(y)).filter(Boolean):[],d=[r,...l].map(y=>ce(y,n)).filter(Boolean);return{id:s,title:r,minOccurrences:o,maxOccurrences:c,placeholder:i,matchKeys:Array.from(new Set(d))}}function Se(e,t){const n=Array.isArray(e)&&e.length>0?e:be(),r=[],s=new Set;return n.forEach((o,a)=>{const c=t(o.label||"");if(!c)return;const i=xe(t(o.id||c))||`schema-${a+1}`;let l=i,d=1;for(;s.has(l);)l=`${i}-${d++}`;s.add(l);const y=Array.isArray(o.sections)?o.sections:[],f=[],k=new Set;if(y.forEach(($,h)=>{const x=Oe($,h,t);if(!x)return;let N=x.id,Te=1;for(;k.has(N);)N=`${x.id}-${Te++}`;k.add(N),f.push({...x,id:N})}),f.length===0)return;const O=new Map,A=new Map;f.forEach(($,h)=>{A.set($.id,h),$.matchKeys.forEach(x=>{O.has(x)||O.set(x,$)})}),r.push({id:l,label:c,description:t(o.description||""),strictOrder:o.strictOrder!==!1,allowUnknownHeadings:!!o.allowUnknownHeadings,sections:f,matchKeyToSection:O,orderBySectionId:A})}),r.length>0?r:Se(be(),t)}function Z(e={}){const t=e.normalizeText||Le,n=Se(e.schemas,t),r=t(e.defaultSchemaId||""),s=n.some(o=>o.id===r)?r:n[0]?.id||null;return{schemas:n,defaultSchemaId:s,enableRealtime:e.enableRealtime!==!1,debounceMs:P(Number(e.debounceMs??260),60,2e3),maxIssues:P(Number(e.maxIssues??80),5,500),labels:{...Ie,...e.labels||{}},normalizeText:t}}function He(e){return{schemas:e.schemas.map(t=>({id:t.id,label:t.label,description:t.description||void 0,strictOrder:t.strictOrder,allowUnknownHeadings:t.allowUnknownHeadings,sections:t.sections.map(n=>({id:n.id,title:n.title,minOccurrences:n.minOccurrences,maxOccurrences:n.maxOccurrences,placeholder:n.placeholder||void 0}))})),defaultSchemaId:e.defaultSchemaId||void 0,enableRealtime:e.enableRealtime,debounceMs:e.debounceMs,maxIssues:e.maxIssues,labels:{...e.labels},normalizeText:e.normalizeText}}function le(e){return e.closest(ie)||e}function U(e){if(!e)return null;if(e.matches(S))return e;const t=e.querySelector(S);return t instanceof HTMLElement?t:null}function Re(){if(typeof window>"u")return null;const e=window[fe];if(!(e instanceof HTMLElement))return null;window[fe]=null;const t=U(e);if(t)return t;const n=e.closest(ie);if(n){const s=U(n);if(s)return s}const r=e.closest(S);return r instanceof HTMLElement?r:null}function De(e){const t=e.closest("[data-editora-editor]");if(t&&U(t)===e)return t;let n=e;for(;n;){if(n.matches(ie)&&(n===e||U(n)===e))return n;n=n.parentElement}return le(e)}function ye(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function Y(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 Ne(e){const t=le(e);if(Y(t))return!0;const n=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return Y(n)?!0:Y(document.documentElement)||Y(document.body)}function oe(e,t){e.classList.remove("rte-doc-schema-theme-dark"),Ne(t)&&e.classList.add("rte-doc-schema-theme-dark")}function Pe(e){for(let t=0;t<e.length;t+=1){const n=e[t];if(!(n.type!=="childList"||n.removedNodes.length===0))for(let r=0;r<n.removedNodes.length;r+=1){const s=n.removedNodes[r];if(s.nodeType!==Node.ELEMENT_NODE)continue;const o=s;if(o.matches?.(S)||o.matches?.(`.${m}`)||o.querySelector?.(S)||o.querySelector?.(`.${m}`))return!0}}return!1}function Q(){Array.from(ne).forEach(t=>{t.isConnected||ue(t)})}function T(e,t=!0,n=!0){if(Q(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const c=U(e.editorElement);if(c)return c}const r=Re();if(r)return r;const s=window.getSelection();if(s&&s.rangeCount>0){const c=ye(s.getRangeAt(0).startContainer)?.closest(S);if(c)return c}const o=document.activeElement;if(o){if(o.matches(S))return o;const c=o.closest(S);if(c)return c}if(n&&b&&b.isConnected)return b;if(!t)return null;const a=document.querySelector(S);return a instanceof HTMLElement?a:null}function _e(e){const t=e.target;if(t){const r=t.closest(`.${m}`);if(r){const o=Array.from(p.entries()).find(([,a])=>a===r);if(o)return o[0]}const s=t.closest(S);if(s)return s}const n=document.activeElement;if(n){const r=n.closest(`.${m}`);if(r){const o=Array.from(p.entries()).find(([,a])=>a===r);if(o)return o[0]}const s=n.closest(S);if(s)return s}return null}function pe(e,t,n){const r=De(e);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false")})}function de(e){const t=te.get(e);typeof t=="number"&&(window.clearTimeout(t),te.delete(e))}function L(e,t){return t&&e.schemas.find(n=>n.id===t)||null}function re(e){return e.defaultSchemaId||e.schemas[0]?.id||null}function g(e,t){u.has(e)||u.set(e,t);let n=j.get(e);return n||(n={activeSchemaId:re(t),realtimeEnabled:t.enableRealtime,issues:[],headingCount:0,recognizedHeadingCount:0,missingCount:0,lastRunAt:null,snapshot:""},j.set(e,n)),(!n.activeSchemaId||!L(t,n.activeSchemaId))&&(n.activeSchemaId=re(t)),ne.add(e),n}function ue(e){de(e),p.get(e)?.remove(),p.delete(e),F.delete(e),u.delete(e),X.delete(e),j.delete(e),ne.delete(e),b===e&&(b=null)}function me(e){return F.get(e)===!0}function ve(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function se(e,t){if(!t.classList.contains("show"))return;const n=le(e).getBoundingClientRect(),r=Math.min(window.innerWidth-20,440),s=Math.max(10,window.innerWidth-r-10),o=Math.min(Math.max(10,n.right-r),s),a=Math.max(10,Math.min(window.innerHeight-10,n.top+12));t.style.width=`${r}px`,t.style.left=`${o}px`,t.style.top=`${a}px`,t.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function ee(e,t){const n=e.querySelector(".rte-doc-schema-live");n&&(n.textContent=t)}function qe(e,t){const n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),r=[];return n.forEach((s,o)=>{const a=t(s.textContent||"");if(!a)return;const c=Number(s.tagName.slice(1))||0,i=ce(a,t);r.push({text:a,key:i,index:o,level:c})}),r}function Ee(e,t,n){const r=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),s=[];return r.forEach(o=>{const a=n(o.textContent||"");if(!a)return;const c=ce(a,n),i=c&&t.matchKeyToSection.get(c)||null,l=i?t.orderBySectionId.get(i.id)??null:null,d=P(Number(o.tagName.slice(1))||0,1,6);s.push({element:o,level:d,section:i,order:l})}),s}function ze(e,t=2){const n=e.filter(i=>i.section).map(i=>i.level),r=n.length>0?n:e.map(i=>i.level);if(r.length===0)return t;const s=new Map;r.forEach((i,l)=>{s.has(i)||s.set(i,{count:0,firstIndex:l});const d=s.get(i);d.count+=1});let o=t,a=-1,c=Number.MAX_SAFE_INTEGER;return s.forEach((i,l)=>{(i.count>a||i.count===a&&i.firstIndex<c||i.count===a&&i.firstIndex===c&&l<o)&&(o=l,a=i.count,c=i.firstIndex)}),P(o,1,6)}function Be(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(ye(n.startContainer)?.closest(S)!==e)return null;if(n.startContainer.nodeType===Node.ELEMENT_NODE){const o=n.startContainer,a=o.childNodes[n.startOffset]||null;return{parent:o,referenceNode:a}}const s=n.startContainer.parentNode;return s?{parent:s,referenceNode:n.startContainer.nextSibling||null}:null}function Ke(e,t,n,r){const s=Ee(e,n,r),o=n.orderBySectionId.get(t.id);if(typeof o!="number"||s.length===0)return{parent:e,referenceNode:null};const a=s.find(i=>typeof i.order=="number"&&i.order>o);if(a&&a.element.parentNode)return{parent:a.element.parentNode,referenceNode:a.element};let c=-1;for(let i=0;i<s.length;i+=1){const l=s[i];typeof l.order=="number"&&l.order<o&&(c=i)}if(c>=0){const i=s[c+1]?.element||null;return{parent:i?.parentNode||s[c].element.parentNode||e,referenceNode:i}}return{parent:e,referenceNode:null}}function Ve(e,t,n,r){const s=e.ownerDocument||document,o=`h${P(r,1,6)}`,a=s.createElement(o);a.setAttribute("data-doc-schema-section",t.id),a.textContent=t.title;const c=s.createElement("p");return c.textContent=t.placeholder||n.labels.defaultPlaceholderText,[a,c]}function V(e,t,n,r={}){return ge+=1,{id:`doc-schema-issue-${ge}`,type:e,severity:t,message:n,...r}}function J(e,t,n){return e.replace(/\{section\}/g,t||"").replace(/\{heading\}/g,n||"").trim()}function je(e,t,n){const r=qe(e,n.normalizeText),s=[],o=new Map,a=[];for(let i=0;i<r.length&&!(s.length>=n.maxIssues);i+=1){const l=r[i];if(!l.key)continue;const d=t.matchKeyToSection.get(l.key);if(d){o.set(d.id,(o.get(d.id)||0)+1),a.push({section:d,heading:l});continue}t.allowUnknownHeadings||s.push(V("unknown-heading","warning",J(n.labels.unknownHeadingMessage,null,l.text),{headingText:l.text,suggestion:"Map this heading to a schema alias or remove it from strict structure mode."}))}let c=0;for(let i=0;i<t.sections.length&&!(s.length>=n.maxIssues);i+=1){const l=t.sections[i],d=o.get(l.id)||0;d<l.minOccurrences&&(c+=1,s.push(V("missing-section","error",J(n.labels.missingSectionMessage,l.title,null),{sectionId:l.id,sectionTitle:l.title,suggestion:`Add heading "${l.title}" to satisfy schema requirements.`}))),d>l.maxOccurrences&&s.length<n.maxIssues&&s.push(V("duplicate-section","warning",J(n.labels.duplicateSectionMessage,l.title,null),{sectionId:l.id,sectionTitle:l.title,suggestion:`Keep at most ${l.maxOccurrences} instance(s) of "${l.title}".`}))}if(t.strictOrder&&s.length<n.maxIssues){let i=-1;for(let l=0;l<a.length&&!(s.length>=n.maxIssues);l+=1){const d=a[l],y=t.orderBySectionId.get(d.section.id)??l;y<i?s.push(V("out-of-order","warning",J(n.labels.outOfOrderMessage,d.section.title,d.heading.text),{sectionId:d.section.id,sectionTitle:d.section.title,headingText:d.heading.text,suggestion:`Move "${d.section.title}" after earlier required sections.`})):i=y}}return{issues:s,headingCount:r.length,recognizedHeadingCount:a.length,missingCount:c}}function we(e){const t=u.get(e)||w,n=j.get(e),r=t?L(t,n?.activeSchemaId||null):null;return{activeSchemaId:n?.activeSchemaId||null,activeSchemaLabel:r?.label||null,realtimeEnabled:n?.realtimeEnabled===!0,issues:n?.issues?n.issues.map(s=>({...s})):[],headingCount:n?.headingCount||0,recognizedHeadingCount:n?.recognizedHeadingCount||0,missingCount:n?.missingCount||0,lastRunAt:n?.lastRunAt||null}}function D(e){const t=j.get(e);pe(e,"toggleDocSchemaPanel",me(e)),pe(e,"toggleDocSchemaRealtime",t?.realtimeEnabled===!0)}function _(e){const t=p.get(e);if(!t)return;const n=u.get(e)||w;if(!n)return;const r=g(e,n),s=L(n,r.activeSchemaId),o=t.querySelector(".rte-doc-schema-label");o&&(o.textContent=n.labels.schemaLabel);const a=t.querySelector('[data-field="schema"]');a&&(a.innerHTML=n.schemas.map(h=>`<option value="${I(h.id)}">${I(h.label)}</option>`).join(""),a.value=r.activeSchemaId||"");const c=t.querySelector(".rte-doc-schema-description");if(c){const h=s?.description||"";c.textContent=h?`${n.labels.schemaDescriptionPrefix}: ${h}`:"",c.hidden=!h}const i=t.querySelector(".rte-doc-schema-summary");if(i){const h=s?.label||"N/A",x=r.issues.length;i.textContent=`${n.labels.summaryPrefix}: ${h} • ${x} issue${x===1?"":"s"}`}const l=t.querySelector(".rte-doc-schema-helper");l&&(l.textContent=n.labels.helperText);const d=t.querySelector(".rte-doc-schema-shortcut");d&&(d.textContent=n.labels.shortcutText);const y=t.querySelector('[data-action="run-validation"]');y&&(y.textContent=n.labels.validateText);const f=t.querySelector('[data-action="insert-missing"]');if(f){f.textContent=n.labels.insertMissingText;const h=r.issues.some(x=>x.type==="missing-section");f.disabled=!h||ve(e)}const k=t.querySelector('[data-action="toggle-realtime"]');k&&(k.textContent=r.realtimeEnabled?n.labels.realtimeOnText:n.labels.realtimeOffText,k.setAttribute("aria-pressed",r.realtimeEnabled?"true":"false"));const O=t.querySelector('[data-action="close"]');O&&O.setAttribute("aria-label",n.labels.closeText);const A=t.querySelector(".rte-doc-schema-issues"),$=t.querySelector(".rte-doc-schema-empty");A&&(A.setAttribute("aria-label",n.labels.issueListLabel),r.issues.length===0?(A.innerHTML="",$&&($.hidden=!1,$.textContent=n.labels.noIssuesText)):($&&($.hidden=!0),A.innerHTML=r.issues.map(h=>{const x=h.severity==="error"?"error":h.severity==="warning"?"warning":"info",N=h.sectionTitle||h.headingText||"";return`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const S=".rte-content, .editora-content",ie="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",fe="__editoraCommandEditorRoot",he="rte-doc-schema-styles",m="rte-doc-schema-panel",v="document-schema",M="doc-schema",H="docSchema",E=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Ae={panelTitle:"Document Schema",panelAriaLabel:"Document schema panel",schemaLabel:"Schema",schemaDescriptionPrefix:"Description",validateText:"Run Validation",insertMissingText:"Insert Missing Sections",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",noIssuesText:"No schema violations detected.",summaryPrefix:"Schema",issueListLabel:"Schema issues",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+G (panel), Ctrl/Cmd+Alt+Shift+J (validate)",helperText:"Choose a schema, validate structure, then insert missing sections safely.",readonlyMessage:"Editor is read-only. Missing sections cannot be inserted.",defaultPlaceholderText:"Add section content.",missingSectionMessage:"Missing required section",duplicateSectionMessage:"Section appears too many times",outOfOrderMessage:"Section appears out of required order",unknownHeadingMessage:"Heading is not part of selected schema",insertedSummaryPrefix:"Inserted missing sections"},u=new WeakMap,X=new WeakMap,j=new WeakMap,p=new Map,F=new WeakMap,te=new WeakMap,ne=new Set;let W=0,Le=0,ge=0,w=null,b=null,q=null,z=null,B=null,R=null,K=null;function I(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Oe(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function P(e,t,n){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):t}function xe(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function ce(e,t){return t(e).toLowerCase().replace(/^[\s\-\u2022]*(?:[0-9]+(?:\.[0-9]+)*)[\)\.\-:\s]+/,"").replace(/^[\s\-\u2022]*(?:[ivxlcdm]+)[\)\.\-:\s]+/i,"").replace(/[::]+$/g,"").replace(/\s+/g," ").trim()}function be(){return[{id:"contract",label:"Contract",description:"Template for legal/commercial agreements with strict section ordering.",strictOrder:!0,allowUnknownHeadings:!1,sections:[{id:"summary",title:"Executive Summary",aliases:["Overview"]},{id:"scope",title:"Scope"},{id:"terms",title:"Terms and Conditions",aliases:["Terms"]},{id:"responsibilities",title:"Responsibilities"},{id:"sla",title:"Service Levels",aliases:["SLA","Service Level Agreement"]},{id:"termination",title:"Termination"}]},{id:"sop",label:"SOP",description:"Standard operating procedure with clear implementation and governance sections.",strictOrder:!0,allowUnknownHeadings:!0,sections:[{id:"purpose",title:"Purpose"},{id:"scope",title:"Scope"},{id:"procedure",title:"Procedure",maxOccurrences:10},{id:"roles",title:"Roles and Responsibilities",aliases:["Responsibilities"]},{id:"validation",title:"Validation"},{id:"revision-history",title:"Revision History",aliases:["Change History"]}]},{id:"policy",label:"Policy",description:"Policy document with control ownership, exception handling, and enforcement.",strictOrder:!0,allowUnknownHeadings:!0,sections:[{id:"statement",title:"Policy Statement"},{id:"applicability",title:"Applicability",aliases:["Scope"]},{id:"controls",title:"Controls"},{id:"exceptions",title:"Exceptions"},{id:"enforcement",title:"Enforcement"}]}]}function He(e,t,n){const r=n(e.title||"");if(!r)return null;const s=xe(n(e.id||r))||`section-${t+1}`,o=P(Number(e.minOccurrences??1),0,20),a=Math.max(1,o),c=P(Number(e.maxOccurrences??a),o,40),i=n(e.placeholder||""),l=Array.isArray(e.aliases)?e.aliases.map(y=>n(y)).filter(Boolean):[],d=[r,...l].map(y=>ce(y,n)).filter(Boolean);return{id:s,title:r,minOccurrences:o,maxOccurrences:c,placeholder:i,matchKeys:Array.from(new Set(d))}}function Se(e,t){const n=Array.isArray(e)&&e.length>0?e:be(),r=[],s=new Set;return n.forEach((o,a)=>{const c=t(o.label||"");if(!c)return;const i=xe(t(o.id||c))||`schema-${a+1}`;let l=i,d=1;for(;s.has(l);)l=`${i}-${d++}`;s.add(l);const y=Array.isArray(o.sections)?o.sections:[],f=[],k=new Set;if(y.forEach(($,h)=>{const x=He($,h,t);if(!x)return;let N=x.id,Ie=1;for(;k.has(N);)N=`${x.id}-${Ie++}`;k.add(N),f.push({...x,id:N})}),f.length===0)return;const O=new Map,A=new Map;f.forEach(($,h)=>{A.set($.id,h),$.matchKeys.forEach(x=>{O.has(x)||O.set(x,$)})}),r.push({id:l,label:c,description:t(o.description||""),strictOrder:o.strictOrder!==!1,allowUnknownHeadings:!!o.allowUnknownHeadings,sections:f,matchKeyToSection:O,orderBySectionId:A})}),r.length>0?r:Se(be(),t)}function Z(e={}){const t=e.normalizeText||Oe,n=Se(e.schemas,t),r=t(e.defaultSchemaId||""),s=n.some(o=>o.id===r)?r:n[0]?.id||null;return{schemas:n,defaultSchemaId:s,enableRealtime:e.enableRealtime!==!1,debounceMs:P(Number(e.debounceMs??260),60,2e3),maxIssues:P(Number(e.maxIssues??80),5,500),labels:{...Ae,...e.labels||{}},normalizeText:t}}function Re(e){return{schemas:e.schemas.map(t=>({id:t.id,label:t.label,description:t.description||void 0,strictOrder:t.strictOrder,allowUnknownHeadings:t.allowUnknownHeadings,sections:t.sections.map(n=>({id:n.id,title:n.title,minOccurrences:n.minOccurrences,maxOccurrences:n.maxOccurrences,placeholder:n.placeholder||void 0}))})),defaultSchemaId:e.defaultSchemaId||void 0,enableRealtime:e.enableRealtime,debounceMs:e.debounceMs,maxIssues:e.maxIssues,labels:{...e.labels},normalizeText:e.normalizeText}}function le(e){return e.closest(ie)||e}function U(e){if(!e)return null;if(e.matches(S))return e;const t=e.querySelector(S);return t instanceof HTMLElement?t:null}function De(){if(typeof window>"u")return null;const e=window[fe];if(!(e instanceof HTMLElement))return null;window[fe]=null;const t=U(e);if(t)return t;const n=e.closest(ie);if(n){const s=U(n);if(s)return s}const r=e.closest(S);return r instanceof HTMLElement?r:null}function Ne(e){const t=e.closest("[data-editora-editor]");if(t&&U(t)===e)return t;let n=e;for(;n;){if(n.matches(ie)&&(n===e||U(n)===e))return n;n=n.parentElement}return le(e)}function ye(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function Y(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 Pe(e){const t=le(e);if(Y(t))return!0;const n=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return Y(n)?!0:Y(document.documentElement)||Y(document.body)}function oe(e,t){e.classList.remove("rte-doc-schema-theme-dark"),Pe(t)&&e.classList.add("rte-doc-schema-theme-dark")}function _e(e){for(let t=0;t<e.length;t+=1){const n=e[t];if(!(n.type!=="childList"||n.removedNodes.length===0))for(let r=0;r<n.removedNodes.length;r+=1){const s=n.removedNodes[r];if(s.nodeType!==Node.ELEMENT_NODE)continue;const o=s;if(o.matches?.(S)||o.matches?.(`.${m}`)||o.querySelector?.(S)||o.querySelector?.(`.${m}`))return!0}}return!1}function Q(){Array.from(ne).forEach(t=>{t.isConnected||ue(t)})}function T(e,t=!0,n=!0){if(Q(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const c=U(e.editorElement);if(c)return c}const r=De();if(r)return r;const s=window.getSelection();if(s&&s.rangeCount>0){const c=ye(s.getRangeAt(0).startContainer)?.closest(S);if(c)return c}const o=document.activeElement;if(o){if(o.matches(S))return o;const c=o.closest(S);if(c)return c}if(n&&b&&b.isConnected)return b;if(!t)return null;const a=document.querySelector(S);return a instanceof HTMLElement?a:null}function qe(e){const t=e.target;if(t){const r=t.closest(`.${m}`);if(r){const o=Array.from(p.entries()).find(([,a])=>a===r);if(o)return o[0]}const s=t.closest(S);if(s)return s}const n=document.activeElement;if(n){const r=n.closest(`.${m}`);if(r){const o=Array.from(p.entries()).find(([,a])=>a===r);if(o)return o[0]}const s=n.closest(S);if(s)return s}return null}function pe(e,t,n){const r=Ne(e);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false")})}function de(e){const t=te.get(e);typeof t=="number"&&(window.clearTimeout(t),te.delete(e))}function L(e,t){return t&&e.schemas.find(n=>n.id===t)||null}function re(e){return e.defaultSchemaId||e.schemas[0]?.id||null}function g(e,t){u.has(e)||u.set(e,t);let n=j.get(e);return n||(n={activeSchemaId:re(t),realtimeEnabled:t.enableRealtime,issues:[],headingCount:0,recognizedHeadingCount:0,missingCount:0,lastRunAt:null,snapshot:""},j.set(e,n)),(!n.activeSchemaId||!L(t,n.activeSchemaId))&&(n.activeSchemaId=re(t)),ne.add(e),n}function ue(e){de(e),p.get(e)?.remove(),p.delete(e),F.delete(e),u.delete(e),X.delete(e),j.delete(e),ne.delete(e),b===e&&(b=null)}function me(e){return F.get(e)===!0}function ve(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function se(e,t){if(!t.classList.contains("show"))return;const n=le(e).getBoundingClientRect(),r=Math.min(window.innerWidth-20,440),s=Math.max(10,window.innerWidth-r-10),o=Math.min(Math.max(10,n.right-r),s),a=Math.max(10,Math.min(window.innerHeight-10,n.top+12));t.style.width=`${r}px`,t.style.left=`${o}px`,t.style.top=`${a}px`,t.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function ee(e,t){const n=e.querySelector(".rte-doc-schema-live");n&&(n.textContent=t)}function ze(e,t){const n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),r=[];return n.forEach((s,o)=>{const a=t(s.textContent||"");if(!a)return;const c=Number(s.tagName.slice(1))||0,i=ce(a,t);r.push({text:a,key:i,index:o,level:c})}),r}function Ee(e,t,n){const r=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),s=[];return r.forEach(o=>{const a=n(o.textContent||"");if(!a)return;const c=ce(a,n),i=c&&t.matchKeyToSection.get(c)||null,l=i?t.orderBySectionId.get(i.id)??null:null,d=P(Number(o.tagName.slice(1))||0,1,6);s.push({element:o,level:d,section:i,order:l})}),s}function Be(e,t=2){const n=e.filter(i=>i.section).map(i=>i.level),r=n.length>0?n:e.map(i=>i.level);if(r.length===0)return t;const s=new Map;r.forEach((i,l)=>{s.has(i)||s.set(i,{count:0,firstIndex:l});const d=s.get(i);d.count+=1});let o=t,a=-1,c=Number.MAX_SAFE_INTEGER;return s.forEach((i,l)=>{(i.count>a||i.count===a&&i.firstIndex<c||i.count===a&&i.firstIndex===c&&l<o)&&(o=l,a=i.count,c=i.firstIndex)}),P(o,1,6)}function Ke(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(ye(n.startContainer)?.closest(S)!==e)return null;if(n.startContainer.nodeType===Node.ELEMENT_NODE){const o=n.startContainer,a=o.childNodes[n.startOffset]||null;return{parent:o,referenceNode:a}}const s=n.startContainer.parentNode;return s?{parent:s,referenceNode:n.startContainer.nextSibling||null}:null}function Ve(e,t,n,r){const s=Ee(e,n,r),o=n.orderBySectionId.get(t.id);if(typeof o!="number"||s.length===0)return{parent:e,referenceNode:null};const a=s.find(i=>typeof i.order=="number"&&i.order>o);if(a&&a.element.parentNode)return{parent:a.element.parentNode,referenceNode:a.element};let c=-1;for(let i=0;i<s.length;i+=1){const l=s[i];typeof l.order=="number"&&l.order<o&&(c=i)}if(c>=0){const i=s[c+1]?.element||null;return{parent:i?.parentNode||s[c].element.parentNode||e,referenceNode:i}}return{parent:e,referenceNode:null}}function je(e,t,n,r){const s=e.ownerDocument||document,o=`h${P(r,1,6)}`,a=s.createElement(o);a.setAttribute("data-doc-schema-section",t.id),a.textContent=t.title;const c=s.createElement("p");return c.textContent=t.placeholder||n.labels.defaultPlaceholderText,[a,c]}function V(e,t,n,r={}){return ge+=1,{id:`doc-schema-issue-${ge}`,type:e,severity:t,message:n,...r}}function J(e,t,n){return e.replace(/\{section\}/g,t||"").replace(/\{heading\}/g,n||"").trim()}function Ue(e,t,n){const r=ze(e,n.normalizeText),s=[],o=new Map,a=[];for(let i=0;i<r.length&&!(s.length>=n.maxIssues);i+=1){const l=r[i];if(!l.key)continue;const d=t.matchKeyToSection.get(l.key);if(d){o.set(d.id,(o.get(d.id)||0)+1),a.push({section:d,heading:l});continue}t.allowUnknownHeadings||s.push(V("unknown-heading","warning",J(n.labels.unknownHeadingMessage,null,l.text),{headingText:l.text,suggestion:"Map this heading to a schema alias or remove it from strict structure mode."}))}let c=0;for(let i=0;i<t.sections.length&&!(s.length>=n.maxIssues);i+=1){const l=t.sections[i],d=o.get(l.id)||0;d<l.minOccurrences&&(c+=1,s.push(V("missing-section","error",J(n.labels.missingSectionMessage,l.title,null),{sectionId:l.id,sectionTitle:l.title,suggestion:`Add heading "${l.title}" to satisfy schema requirements.`}))),d>l.maxOccurrences&&s.length<n.maxIssues&&s.push(V("duplicate-section","warning",J(n.labels.duplicateSectionMessage,l.title,null),{sectionId:l.id,sectionTitle:l.title,suggestion:`Keep at most ${l.maxOccurrences} instance(s) of "${l.title}".`}))}if(t.strictOrder&&s.length<n.maxIssues){let i=-1;for(let l=0;l<a.length&&!(s.length>=n.maxIssues);l+=1){const d=a[l],y=t.orderBySectionId.get(d.section.id)??l;y<i?s.push(V("out-of-order","warning",J(n.labels.outOfOrderMessage,d.section.title,d.heading.text),{sectionId:d.section.id,sectionTitle:d.section.title,headingText:d.heading.text,suggestion:`Move "${d.section.title}" after earlier required sections.`})):i=y}}return{issues:s,headingCount:r.length,recognizedHeadingCount:a.length,missingCount:c}}function we(e){const t=u.get(e)||w,n=j.get(e),r=t?L(t,n?.activeSchemaId||null):null;return{activeSchemaId:n?.activeSchemaId||null,activeSchemaLabel:r?.label||null,realtimeEnabled:n?.realtimeEnabled===!0,issues:n?.issues?n.issues.map(s=>({...s})):[],headingCount:n?.headingCount||0,recognizedHeadingCount:n?.recognizedHeadingCount||0,missingCount:n?.missingCount||0,lastRunAt:n?.lastRunAt||null}}function D(e){const t=j.get(e);pe(e,"toggleDocSchemaPanel",me(e)),pe(e,"toggleDocSchemaRealtime",t?.realtimeEnabled===!0)}function _(e){const t=p.get(e);if(!t)return;const n=u.get(e)||w;if(!n)return;const r=g(e,n),s=L(n,r.activeSchemaId),o=t.querySelector(".rte-doc-schema-label");o&&(o.textContent=n.labels.schemaLabel);const a=t.querySelector('[data-field="schema"]');a&&(a.innerHTML=n.schemas.map(h=>`<option value="${I(h.id)}">${I(h.label)}</option>`).join(""),a.value=r.activeSchemaId||"");const c=t.querySelector(".rte-doc-schema-description");if(c){const h=s?.description||"";c.textContent=h?`${n.labels.schemaDescriptionPrefix}: ${h}`:"",c.hidden=!h}const i=t.querySelector(".rte-doc-schema-summary");if(i){const h=s?.label||"N/A",x=r.issues.length;i.textContent=`${n.labels.summaryPrefix}: ${h} • ${x} issue${x===1?"":"s"}`}const l=t.querySelector(".rte-doc-schema-helper");l&&(l.textContent=n.labels.helperText);const d=t.querySelector(".rte-doc-schema-shortcut");d&&(d.textContent=n.labels.shortcutText);const y=t.querySelector('[data-action="run-validation"]');y&&(y.textContent=n.labels.validateText);const f=t.querySelector('[data-action="insert-missing"]');if(f){f.textContent=n.labels.insertMissingText;const h=r.issues.some(x=>x.type==="missing-section");f.disabled=!h||ve(e)}const k=t.querySelector('[data-action="toggle-realtime"]');k&&(k.textContent=r.realtimeEnabled?n.labels.realtimeOnText:n.labels.realtimeOffText,k.setAttribute("aria-pressed",r.realtimeEnabled?"true":"false"));const O=t.querySelector('[data-action="close"]');O&&O.setAttribute("aria-label",n.labels.closeText);const A=t.querySelector(".rte-doc-schema-issues"),$=t.querySelector(".rte-doc-schema-empty");A&&(A.setAttribute("aria-label",n.labels.issueListLabel),r.issues.length===0?(A.innerHTML="",$&&($.hidden=!1,$.textContent=n.labels.noIssuesText)):($&&($.hidden=!0),A.innerHTML=r.issues.map(h=>{const x=h.severity==="error"?"error":h.severity==="warning"?"warning":"info",N=h.sectionTitle||h.headingText||"";return`
<li class="rte-doc-schema-issue ${x}" role="listitem">

@@ -6,3 +6,3 @@ <p class="rte-doc-schema-issue-message">${I(h.message)}${N?`: <strong>${I(N)}</strong>`:""}</p>

</li>
`}).join(""))),t.setAttribute("aria-label",n.labels.panelAriaLabel)}function G(e,t=!1){const n=p.get(e);n&&(n.classList.remove("show"),F.set(e,!1),D(e),t&&e.focus({preventScroll:!0}))}function ae(e){const t=Fe(e);p.forEach((r,s)=>{s!==e&&G(s,!1)}),t.classList.add("show"),F.set(e,!0),_(e),se(e,t),D(e),t.querySelector('[data-field="schema"]')?.focus(),C(e,"panel-open",!1)}function ke(e,t){const n=me(e);return(typeof t=="boolean"?t:!n)?ae(e):G(e,!1),!0}function Ue(e,t){if(t===e.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",e,t,e.innerHTML)}catch{}}function Ge(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function C(e,t,n){const r=u.get(e)||w;if(!r)return[];const s=g(e,r),o=p.get(e),a=e.innerHTML;if(!n&&s.snapshot===a)return s.issues;const c=L(r,s.activeSchemaId);if(!c)return s.issues=[V("missing-section","error","No active schema is configured for this editor.",{suggestion:"Set `defaultSchemaId` or update schema options."})],s.headingCount=0,s.recognizedHeadingCount=0,s.missingCount=1,s.lastRunAt=new Date().toISOString(),s.snapshot=a,_(e),D(e),s.issues;const i=je(e,c,r);return s.issues=i.issues,s.headingCount=i.headingCount,s.recognizedHeadingCount=i.recognizedHeadingCount,s.missingCount=i.missingCount,s.lastRunAt=new Date().toISOString(),s.snapshot=a,_(e),D(e),e.dispatchEvent(new CustomEvent("editora:doc-schema-validation",{bubbles:!0,detail:{reason:t,state:we(e)}})),o&&ee(o,i.issues.length===0?r.labels.noIssuesText:`${i.issues.length} issue${i.issues.length===1?"":"s"} detected.`),s.issues}function $e(e){const t=u.get(e)||w;if(!t)return;de(e);const n=window.setTimeout(()=>{te.delete(e),C(e,"realtime",!1)},t.debounceMs);te.set(e,n)}function Ce(e,t){const n=u.get(e)||w;if(!n)return!1;const r=g(e,n),s=typeof t=="boolean"?t:!r.realtimeEnabled;return r.realtimeEnabled=s,s?$e(e):de(e),_(e),D(e),!0}function Me(e){const t=u.get(e)||w;if(!t)return!1;const n=g(e,t),r=p.get(e);if(ve(e))return r&&ee(r,t.labels.readonlyMessage),!1;const s=L(t,n.activeSchemaId);if(!s)return!1;C(e,"insert-missing-pre",!0);const o=Array.from(new Set(n.issues.filter(f=>f.type==="missing-section"&&f.sectionId).map(f=>f.sectionId))),a=s.sections.filter(f=>o.includes(f.id));if(a.length===0)return r&&ee(r,t.labels.noIssuesText),!1;const c=e.innerHTML,i=Ee(e,s,t.normalizeText),l=ze(i,2),d=Be(e);a.forEach(f=>{const k=s.strictOrder?Ke(e,f,s,t.normalizeText):d||{parent:e,referenceNode:null},[O,A]=Ve(e,f,t,l);k.parent.insertBefore(O,k.referenceNode),k.parent.insertBefore(A,k.referenceNode)}),Ue(e,c),Ge(e),C(e,"insert-missing-post",!0);const y=a.map(f=>f.title).join(", ");return e.dispatchEvent(new CustomEvent("editora:doc-schema-insert-missing",{bubbles:!0,detail:{schemaId:s.id,sectionIds:a.map(f=>f.id)}})),r&&ee(r,`${t.labels.insertedSummaryPrefix}: ${y}`),!0}function Fe(e){const t=p.get(e);if(t)return t;const n=u.get(e)||w||Z();g(e,n);const r=`rte-doc-schema-panel-${Ae++}`,s=`${r}-schema`,o=document.createElement("section");return o.className=m,o.id=r,o.setAttribute("role","dialog"),o.setAttribute("aria-modal","false"),o.setAttribute("aria-label",n.labels.panelAriaLabel),o.innerHTML=`
`}).join(""))),t.setAttribute("aria-label",n.labels.panelAriaLabel)}function G(e,t=!1){const n=p.get(e);n&&(n.classList.remove("show"),F.set(e,!1),D(e),t&&e.focus({preventScroll:!0}))}function ae(e){const t=We(e);p.forEach((r,s)=>{s!==e&&G(s,!1)}),t.classList.add("show"),F.set(e,!0),_(e),se(e,t),D(e),t.querySelector('[data-field="schema"]')?.focus(),C(e,"panel-open",!1)}function ke(e,t){const n=me(e);return(typeof t=="boolean"?t:!n)?ae(e):G(e,!1),!0}function Ge(e,t){if(t===e.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",e,t,e.innerHTML)}catch{}}function Fe(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function C(e,t,n){const r=u.get(e)||w;if(!r)return[];const s=g(e,r),o=p.get(e),a=e.innerHTML;if(!n&&s.snapshot===a)return s.issues;const c=L(r,s.activeSchemaId);if(!c)return s.issues=[V("missing-section","error","No active schema is configured for this editor.",{suggestion:"Set `defaultSchemaId` or update schema options."})],s.headingCount=0,s.recognizedHeadingCount=0,s.missingCount=1,s.lastRunAt=new Date().toISOString(),s.snapshot=a,_(e),D(e),s.issues;const i=Ue(e,c,r);return s.issues=i.issues,s.headingCount=i.headingCount,s.recognizedHeadingCount=i.recognizedHeadingCount,s.missingCount=i.missingCount,s.lastRunAt=new Date().toISOString(),s.snapshot=a,_(e),D(e),e.dispatchEvent(new CustomEvent("editora:doc-schema-validation",{bubbles:!0,detail:{reason:t,state:we(e)}})),o&&ee(o,i.issues.length===0?r.labels.noIssuesText:`${i.issues.length} issue${i.issues.length===1?"":"s"} detected.`),s.issues}function $e(e){const t=u.get(e)||w;if(!t)return;de(e);const n=window.setTimeout(()=>{te.delete(e),C(e,"realtime",!1)},t.debounceMs);te.set(e,n)}function Ce(e,t){const n=u.get(e)||w;if(!n)return!1;const r=g(e,n),s=typeof t=="boolean"?t:!r.realtimeEnabled;return r.realtimeEnabled=s,s?$e(e):de(e),_(e),D(e),!0}function Me(e){const t=u.get(e)||w;if(!t)return!1;const n=g(e,t),r=p.get(e);if(ve(e))return r&&ee(r,t.labels.readonlyMessage),!1;const s=L(t,n.activeSchemaId);if(!s)return!1;C(e,"insert-missing-pre",!0);const o=Array.from(new Set(n.issues.filter(f=>f.type==="missing-section"&&f.sectionId).map(f=>f.sectionId))),a=s.sections.filter(f=>o.includes(f.id));if(a.length===0)return r&&ee(r,t.labels.noIssuesText),!1;const c=e.innerHTML,i=Ee(e,s,t.normalizeText),l=Be(i,2),d=Ke(e);a.forEach(f=>{const k=s.strictOrder?Ve(e,f,s,t.normalizeText):d||{parent:e,referenceNode:null},[O,A]=je(e,f,t,l);k.parent.insertBefore(O,k.referenceNode),k.parent.insertBefore(A,k.referenceNode)}),Ge(e,c),Fe(e),C(e,"insert-missing-post",!0);const y=a.map(f=>f.title).join(", ");return e.dispatchEvent(new CustomEvent("editora:doc-schema-insert-missing",{bubbles:!0,detail:{schemaId:s.id,sectionIds:a.map(f=>f.id)}})),r&&ee(r,`${t.labels.insertedSummaryPrefix}: ${y}`),!0}function We(e){const t=p.get(e);if(t)return t;const n=u.get(e)||w||Z();g(e,n);const r=`rte-doc-schema-panel-${Le++}`,s=`${r}-schema`,o=document.createElement("section");return o.className=m,o.id=r,o.setAttribute("role","dialog"),o.setAttribute("aria-modal","false"),o.setAttribute("aria-label",n.labels.panelAriaLabel),o.innerHTML=`
<header class="rte-doc-schema-header">

@@ -30,3 +30,3 @@ <h2 class="rte-doc-schema-title">${I(n.labels.panelTitle)}</h2>

<div class="rte-doc-schema-live" aria-live="polite" aria-atomic="true"></div>
`,o.addEventListener("click",a=>{const i=a.target?.closest("[data-action]");if(!i)return;const l=i.getAttribute("data-action");if(l==="close"){G(e,!0);return}if(l==="run-validation"){C(e,"panel-button",!0);return}if(l==="insert-missing"){Me(e);return}l==="toggle-realtime"&&Ce(e)}),o.addEventListener("change",a=>{const c=a.target;if(!(c instanceof HTMLSelectElement)||c.getAttribute("data-field")!=="schema")return;const i=u.get(e)||w;if(!i)return;const l=g(e,i),d=c.value;L(i,d)&&(l.activeSchemaId=d,l.snapshot="",C(e,"schema-change",!0))}),o.addEventListener("keydown",a=>{a.key==="Escape"&&(a.preventDefault(),G(e,!0))}),oe(o,e),document.body.appendChild(o),p.set(e,o),F.set(e,!1),_(e),o}function We(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="g"}function Ye(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="j"}function Je(e){w=e,q||(q=t=>{Q();const r=t.target?.closest(S);if(!r)return;const s=u.get(r)||e;g(r,s),u.set(r,s),b=r,D(r);const o=p.get(r);o&&(oe(o,r),se(r,o),_(r))},document.addEventListener("focusin",q,!0)),z||(z=t=>{const r=t.target?.closest(S);if(!r)return;const s=u.get(r)||w;!s||!g(r,s).realtimeEnabled||$e(r)},document.addEventListener("input",z,!0)),B||(B=t=>{if(t.defaultPrevented||t.target?.closest(`.${m}`)&&t.key!=="Escape")return;const r=_e(t);if(!r)return;const s=u.get(r)||w||e;if(g(r,s),u.set(r,s),b=r,t.key==="Escape"&&me(r)){t.preventDefault(),G(r,!0);return}if(We(t)){t.preventDefault(),t.stopPropagation(),ke(r);return}Ye(t)&&(t.preventDefault(),t.stopPropagation(),C(r,"shortcut",!0))},document.addEventListener("keydown",B,!0)),R||(R=()=>{Q(),p.forEach((t,n)=>{!n.isConnected||!t.isConnected||(oe(t,n),se(n,t))})},window.addEventListener("scroll",R,!0),window.addEventListener("resize",R)),!K&&typeof MutationObserver<"u"&&document.body&&(K=new MutationObserver(t=>{Pe(t)&&Q()}),K.observe(document.body,{childList:!0,subtree:!0}))}function Xe(){q&&(document.removeEventListener("focusin",q,!0),q=null),z&&(document.removeEventListener("input",z,!0),z=null),B&&(document.removeEventListener("keydown",B,!0),B=null),R&&(window.removeEventListener("scroll",R,!0),window.removeEventListener("resize",R),R=null),K&&(K.disconnect(),K=null),p.forEach(t=>t.remove()),p.clear(),Array.from(ne).forEach(t=>ue(t)),w=null,b=null}function Ze(){if(typeof document>"u"||document.getElementById(he))return;const e=document.createElement("style");e.id=he,e.textContent=`
`,o.addEventListener("click",a=>{const i=a.target?.closest("[data-action]");if(!i)return;const l=i.getAttribute("data-action");if(l==="close"){G(e,!0);return}if(l==="run-validation"){C(e,"panel-button",!0);return}if(l==="insert-missing"){Me(e);return}l==="toggle-realtime"&&Ce(e)}),o.addEventListener("change",a=>{const c=a.target;if(!(c instanceof HTMLSelectElement)||c.getAttribute("data-field")!=="schema")return;const i=u.get(e)||w;if(!i)return;const l=g(e,i),d=c.value;L(i,d)&&(l.activeSchemaId=d,l.snapshot="",C(e,"schema-change",!0))}),o.addEventListener("keydown",a=>{a.key==="Escape"&&(a.preventDefault(),G(e,!0))}),oe(o,e),document.body.appendChild(o),p.set(e,o),F.set(e,!1),_(e),o}function Te(e){return typeof e.key=="string"?e.key.toLowerCase():""}function Ye(e){const t=Te(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="g"}function Je(e){const t=Te(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="j"}function Xe(e){w=e,q||(q=t=>{Q();const r=t.target?.closest(S);if(!r)return;const s=u.get(r)||e;g(r,s),u.set(r,s),b=r,D(r);const o=p.get(r);o&&(oe(o,r),se(r,o),_(r))},document.addEventListener("focusin",q,!0)),z||(z=t=>{const r=t.target?.closest(S);if(!r)return;const s=u.get(r)||w;!s||!g(r,s).realtimeEnabled||$e(r)},document.addEventListener("input",z,!0)),B||(B=t=>{if(t.defaultPrevented||t.target?.closest(`.${m}`)&&t.key!=="Escape")return;const r=qe(t);if(!r)return;const s=u.get(r)||w||e;if(g(r,s),u.set(r,s),b=r,t.key==="Escape"&&me(r)){t.preventDefault(),G(r,!0);return}if(Ye(t)){t.preventDefault(),t.stopPropagation(),ke(r);return}Je(t)&&(t.preventDefault(),t.stopPropagation(),C(r,"shortcut",!0))},document.addEventListener("keydown",B,!0)),R||(R=()=>{Q(),p.forEach((t,n)=>{!n.isConnected||!t.isConnected||(oe(t,n),se(n,t))})},window.addEventListener("scroll",R,!0),window.addEventListener("resize",R)),!K&&typeof MutationObserver<"u"&&document.body&&(K=new MutationObserver(t=>{_e(t)&&Q()}),K.observe(document.body,{childList:!0,subtree:!0}))}function Ze(){q&&(document.removeEventListener("focusin",q,!0),q=null),z&&(document.removeEventListener("input",z,!0),z=null),B&&(document.removeEventListener("keydown",B,!0),B=null),R&&(window.removeEventListener("scroll",R,!0),window.removeEventListener("resize",R),R=null),K&&(K.disconnect(),K=null),p.forEach(t=>t.remove()),p.clear(),Array.from(ne).forEach(t=>ue(t)),w=null,b=null}function Qe(){if(typeof document>"u"||document.getElementById(he))return;const e=document.createElement("style");e.id=he,e.textContent=`
.rte-toolbar-group-items.${v},

@@ -400,2 +400,2 @@ .editora-toolbar-group-items.${v},

}
`,document.head.appendChild(e)}const Qe=(e={})=>{const t=Z(e),n=new Set;return Ze(),{name:"docSchema",toolbar:[{id:"docSchemaGroup",label:"Document Schema",type:"group",command:"docSchema",items:[{id:"toggleDocSchemaPanel",label:"Document Schema",command:"toggleDocSchemaPanel",shortcut:"Mod-Alt-Shift-g",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 4.5h12A1.5 1.5 0 0 1 19.5 6v12A1.5 1.5 0 0 1 18 19.5H6A1.5 1.5 0 0 1 4.5 18V6A1.5 1.5 0 0 1 6 4.5Z" stroke="currentColor" stroke-width="1.6"/><path d="M8 8h8M8 12h8M8 16h5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'},{id:"runDocSchemaValidation",label:"Run Schema Validation",command:"runDocSchemaValidation",shortcut:"Mod-Alt-Shift-j",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3.5 4.5 6.5v5c0 4.8 3.1 8.9 7.5 10 4.4-1.1 7.5-5.2 7.5-10v-5L12 3.5Z" stroke="currentColor" stroke-width="1.6"/><path d="m9 12.5 2 2 4-4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"toggleDocSchemaRealtime",label:"Toggle Schema Realtime",command:"toggleDocSchemaRealtime",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4.5 12a7.5 7.5 0 1 1 7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M9.5 19.5H5.5v-4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><circle cx="12" cy="12" r="2" fill="currentColor"/></svg>'}]}],commands:{docSchema:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,ae(o),!0},openDocSchemaPanel:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,ae(o),!0},toggleDocSchemaPanel:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,ke(o,typeof r=="boolean"?r:void 0)},runDocSchemaValidation:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,C(o,"command",!0),!0},insertMissingDocSchemaSections:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,Me(o)},toggleDocSchemaRealtime:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,Ce(o,typeof r=="boolean"?r:void 0)},setDocSchemaMode:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t,c=g(o,a);u.set(o,a);const i=typeof r=="string"?r:r?.schemaId||r?.id;return!i||!L(a,i)?!1:(c.activeSchemaId=i,c.snapshot="",C(o,"set-mode",!0),!0)},setDocSchemaOptions:(r,s)=>{const o=T(s,!1,!1);if(!o||!r||typeof r!="object")return!1;const a=u.get(o)||t,c=X.get(o)||He(a),i={...c,...r,labels:{...c.labels||{},...r.labels||{}},schemas:Array.isArray(r.schemas)?r.schemas:c.schemas,normalizeText:r.normalizeText||a.normalizeText},l=Z(i);u.set(o,l),X.set(o,i);const d=g(o,l);return typeof r.enableRealtime=="boolean"&&(d.realtimeEnabled=r.enableRealtime),(!d.activeSchemaId||!L(l,d.activeSchemaId))&&(d.activeSchemaId=re(l)),typeof r.defaultSchemaId=="string"&&L(l,r.defaultSchemaId)&&(d.activeSchemaId=r.defaultSchemaId),d.snapshot="",C(o,"set-options",!0),_(o),D(o),!0},getDocSchemaState:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;g(o,a);const c=we(o);if(typeof r=="function")try{r(c)}catch{}return o.__docSchemaState=c,o.dispatchEvent(new CustomEvent("editora:doc-schema-state",{bubbles:!0,detail:c})),!0}},keymap:{"Mod-Alt-Shift-g":"toggleDocSchemaPanel","Mod-Alt-Shift-G":"toggleDocSchemaPanel","Mod-Alt-Shift-j":"runDocSchemaValidation","Mod-Alt-Shift-J":"runDocSchemaValidation"},init:function(s){W+=1;const o=this&&typeof this.__pluginConfig=="object"?{...e,...this.__pluginConfig}:e,a=Z(o);Je(a);const c=T(s?.editorElement?{editorElement:s.editorElement}:void 0,!1,!1);c&&(b=c,n.add(c),g(c,a),u.set(c,a),X.set(c,o),D(c),C(c,"init",!0))},destroy:()=>{n.forEach(r=>ue(r)),n.clear(),W=Math.max(0,W-1),!(W>0)&&Xe()}}};exports.DocSchemaPlugin=Qe;
`,document.head.appendChild(e)}const et=(e={})=>{const t=Z(e),n=new Set;return Qe(),{name:"docSchema",toolbar:[{id:"docSchemaGroup",label:"Document Schema",type:"group",command:"docSchema",items:[{id:"toggleDocSchemaPanel",label:"Document Schema",command:"toggleDocSchemaPanel",shortcut:"Mod-Alt-Shift-g",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 4.5h12A1.5 1.5 0 0 1 19.5 6v12A1.5 1.5 0 0 1 18 19.5H6A1.5 1.5 0 0 1 4.5 18V6A1.5 1.5 0 0 1 6 4.5Z" stroke="currentColor" stroke-width="1.6"/><path d="M8 8h8M8 12h8M8 16h5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'},{id:"runDocSchemaValidation",label:"Run Schema Validation",command:"runDocSchemaValidation",shortcut:"Mod-Alt-Shift-j",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3.5 4.5 6.5v5c0 4.8 3.1 8.9 7.5 10 4.4-1.1 7.5-5.2 7.5-10v-5L12 3.5Z" stroke="currentColor" stroke-width="1.6"/><path d="m9 12.5 2 2 4-4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"toggleDocSchemaRealtime",label:"Toggle Schema Realtime",command:"toggleDocSchemaRealtime",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4.5 12a7.5 7.5 0 1 1 7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M9.5 19.5H5.5v-4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><circle cx="12" cy="12" r="2" fill="currentColor"/></svg>'}]}],commands:{docSchema:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,ae(o),!0},openDocSchemaPanel:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,ae(o),!0},toggleDocSchemaPanel:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,ke(o,typeof r=="boolean"?r:void 0)},runDocSchemaValidation:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,C(o,"command",!0),!0},insertMissingDocSchemaSections:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,Me(o)},toggleDocSchemaRealtime:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,Ce(o,typeof r=="boolean"?r:void 0)},setDocSchemaMode:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t,c=g(o,a);u.set(o,a);const i=typeof r=="string"?r:r?.schemaId||r?.id;return!i||!L(a,i)?!1:(c.activeSchemaId=i,c.snapshot="",C(o,"set-mode",!0),!0)},setDocSchemaOptions:(r,s)=>{const o=T(s,!1,!1);if(!o||!r||typeof r!="object")return!1;const a=u.get(o)||t,c=X.get(o)||Re(a),i={...c,...r,labels:{...c.labels||{},...r.labels||{}},schemas:Array.isArray(r.schemas)?r.schemas:c.schemas,normalizeText:r.normalizeText||a.normalizeText},l=Z(i);u.set(o,l),X.set(o,i);const d=g(o,l);return typeof r.enableRealtime=="boolean"&&(d.realtimeEnabled=r.enableRealtime),(!d.activeSchemaId||!L(l,d.activeSchemaId))&&(d.activeSchemaId=re(l)),typeof r.defaultSchemaId=="string"&&L(l,r.defaultSchemaId)&&(d.activeSchemaId=r.defaultSchemaId),d.snapshot="",C(o,"set-options",!0),_(o),D(o),!0},getDocSchemaState:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;g(o,a);const c=we(o);if(typeof r=="function")try{r(c)}catch{}return o.__docSchemaState=c,o.dispatchEvent(new CustomEvent("editora:doc-schema-state",{bubbles:!0,detail:c})),!0}},keymap:{"Mod-Alt-Shift-g":"toggleDocSchemaPanel","Mod-Alt-Shift-G":"toggleDocSchemaPanel","Mod-Alt-Shift-j":"runDocSchemaValidation","Mod-Alt-Shift-J":"runDocSchemaValidation"},init:function(s){W+=1;const o=this&&typeof this.__pluginConfig=="object"?{...e,...this.__pluginConfig}:e,a=Z(o);Xe(a);const c=T(s?.editorElement?{editorElement:s.editorElement}:void 0,!1,!1);c&&(b=c,n.add(c),g(c,a),u.set(c,a),X.set(c,o),D(c),C(c,"init",!0))},destroy:()=>{n.forEach(r=>ue(r)),n.clear(),W=Math.max(0,W-1),!(W>0)&&Ze()}}};exports.DocSchemaPlugin=et;

@@ -1,2 +0,2 @@

const S = ".rte-content, .editora-content", ie = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", fe = "__editoraCommandEditorRoot", he = "rte-doc-schema-styles", m = "rte-doc-schema-panel", v = "document-schema", T = "doc-schema", H = "docSchema", E = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', Me = {
const y = ".rte-content, .editora-content", ie = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", fe = "__editoraCommandEditorRoot", he = "rte-doc-schema-styles", m = "rte-doc-schema-panel", E = "document-schema", T = "doc-schema", H = "docSchema", v = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', Ae = {
panelTitle: "Document Schema",

@@ -24,7 +24,7 @@ panelAriaLabel: "Document schema panel",

}, u = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new WeakMap(), j = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new Map(), F = /* @__PURE__ */ new WeakMap(), te = /* @__PURE__ */ new WeakMap(), ne = /* @__PURE__ */ new Set();
let W = 0, Ae = 0, ge = 0, w = null, p = null, q = null, z = null, B = null, R = null, K = null;
let W = 0, Le = 0, ge = 0, w = null, p = null, q = null, z = null, B = null, R = null, K = null;
function M(e) {
return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
}
function Le(e) {
function Oe(e) {
return e.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();

@@ -89,6 +89,6 @@ }

}
function Oe(e, t, n) {
function He(e, t, n) {
const r = n(e.title || "");
if (!r) return null;
const s = xe(n(e.id || r)) || `section-${t + 1}`, o = P(Number(e.minOccurrences ?? 1), 0, 20), a = Math.max(1, o), c = P(Number(e.maxOccurrences ?? a), o, 40), i = n(e.placeholder || ""), l = Array.isArray(e.aliases) ? e.aliases.map((y) => n(y)).filter(Boolean) : [], d = [r, ...l].map((y) => ce(y, n)).filter(Boolean);
const s = xe(n(e.id || r)) || `section-${t + 1}`, o = P(Number(e.minOccurrences ?? 1), 0, 20), a = Math.max(1, o), c = P(Number(e.maxOccurrences ?? a), o, 40), i = n(e.placeholder || ""), l = Array.isArray(e.aliases) ? e.aliases.map((S) => n(S)).filter(Boolean) : [], d = [r, ...l].map((S) => ce(S, n)).filter(Boolean);
return {

@@ -103,3 +103,3 @@ id: s,

}
function Se(e, t) {
function ye(e, t) {
const n = Array.isArray(e) && e.length > 0 ? e : pe(), r = [], s = /* @__PURE__ */ new Set();

@@ -114,9 +114,9 @@ return n.forEach((o, a) => {

s.add(l);
const y = Array.isArray(o.sections) ? o.sections : [], f = [], k = /* @__PURE__ */ new Set();
if (y.forEach(($, h) => {
const x = Oe($, h, t);
const S = Array.isArray(o.sections) ? o.sections : [], f = [], k = /* @__PURE__ */ new Set();
if (S.forEach(($, h) => {
const x = He($, h, t);
if (!x) return;
let N = x.id, Ie = 1;
let N = x.id, Me = 1;
for (; k.has(N); )
N = `${x.id}-${Ie++}`;
N = `${x.id}-${Me++}`;
k.add(N), f.push({

@@ -142,6 +142,6 @@ ...x,

});
}), r.length > 0 ? r : Se(pe(), t);
}), r.length > 0 ? r : ye(pe(), t);
}
function Z(e = {}) {
const t = e.normalizeText || Le, n = Se(e.schemas, t), r = t(e.defaultSchemaId || ""), s = n.some((o) => o.id === r) ? r : n[0]?.id || null;
const t = e.normalizeText || Oe, n = ye(e.schemas, t), r = t(e.defaultSchemaId || ""), s = n.some((o) => o.id === r) ? r : n[0]?.id || null;
return {

@@ -154,3 +154,3 @@ schemas: n,

labels: {
...Me,
...Ae,
...e.labels || {}

@@ -161,3 +161,3 @@ },

}
function He(e) {
function Re(e) {
return {

@@ -191,7 +191,7 @@ schemas: e.schemas.map((t) => ({

if (!e) return null;
if (e.matches(S)) return e;
const t = e.querySelector(S);
if (e.matches(y)) return e;
const t = e.querySelector(y);
return t instanceof HTMLElement ? t : null;
}
function Re() {
function De() {
if (typeof window > "u") return null;

@@ -208,6 +208,6 @@ const e = window[fe];

}
const r = e.closest(S);
const r = e.closest(y);
return r instanceof HTMLElement ? r : null;
}
function De(e) {
function Ne(e) {
const t = e.closest("[data-editora-editor]");

@@ -224,3 +224,3 @@ if (t && U(t) === e)

}
function ye(e) {
function Se(e) {
return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;

@@ -231,3 +231,3 @@ }

}
function Ne(e) {
function Pe(e) {
const t = le(e);

@@ -239,5 +239,5 @@ if (Y(t)) return !0;

function oe(e, t) {
e.classList.remove("rte-doc-schema-theme-dark"), Ne(t) && e.classList.add("rte-doc-schema-theme-dark");
e.classList.remove("rte-doc-schema-theme-dark"), Pe(t) && e.classList.add("rte-doc-schema-theme-dark");
}
function Pe(e) {
function _e(e) {
for (let t = 0; t < e.length; t += 1) {

@@ -250,3 +250,3 @@ const n = e[t];

const o = s;
if (o.matches?.(S) || o.matches?.(`.${m}`) || o.querySelector?.(S) || o.querySelector?.(`.${m}`))
if (o.matches?.(y) || o.matches?.(`.${m}`) || o.querySelector?.(y) || o.querySelector?.(`.${m}`))
return !0;

@@ -268,8 +268,8 @@ }

}
const r = Re();
const r = De();
if (r) return r;
const s = window.getSelection();
if (s && s.rangeCount > 0) {
const c = ye(s.getRangeAt(0).startContainer)?.closest(
S
const c = Se(s.getRangeAt(0).startContainer)?.closest(
y
);

@@ -280,4 +280,4 @@ if (c) return c;

if (o) {
if (o.matches(S)) return o;
const c = o.closest(S);
if (o.matches(y)) return o;
const c = o.closest(y);
if (c) return c;

@@ -288,6 +288,6 @@ }

if (!t) return null;
const a = document.querySelector(S);
const a = document.querySelector(y);
return a instanceof HTMLElement ? a : null;
}
function _e(e) {
function qe(e) {
const t = e.target;

@@ -300,3 +300,3 @@ if (t) {

}
const s = t.closest(S);
const s = t.closest(y);
if (s) return s;

@@ -311,3 +311,3 @@ }

}
const s = n.closest(S);
const s = n.closest(y);
if (s) return s;

@@ -318,3 +318,3 @@ }

function be(e, t, n) {
const r = De(e);
const r = Ne(e);
Array.from(

@@ -358,3 +358,3 @@ r.querySelectorAll(

}
function ve(e) {
function Ee(e) {
return e.getAttribute("contenteditable") === "false" || e.getAttribute("data-readonly") === "true";

@@ -371,3 +371,3 @@ }

}
function qe(e, t) {
function ze(e, t) {
const n = Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")), r = [];

@@ -386,3 +386,3 @@ return n.forEach((s, o) => {

}
function Ee(e, t, n) {
function ve(e, t, n) {
const r = Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")), s = [];

@@ -401,3 +401,3 @@ return r.forEach((o) => {

}
function ze(e, t = 2) {
function Be(e, t = 2) {
const n = e.filter((i) => i.section).map((i) => i.level), r = n.length > 0 ? n : e.map((i) => i.level);

@@ -416,7 +416,7 @@ if (r.length === 0) return t;

}
function Be(e) {
function Ke(e) {
const t = window.getSelection();
if (!t || t.rangeCount === 0) return null;
const n = t.getRangeAt(0);
if (ye(n.startContainer)?.closest(S) !== e) return null;
if (Se(n.startContainer)?.closest(y) !== e) return null;
if (n.startContainer.nodeType === Node.ELEMENT_NODE) {

@@ -432,4 +432,4 @@ const o = n.startContainer, a = o.childNodes[n.startOffset] || null;

}
function Ke(e, t, n, r) {
const s = Ee(e, n, r), o = n.orderBySectionId.get(t.id);
function Ve(e, t, n, r) {
const s = ve(e, n, r), o = n.orderBySectionId.get(t.id);
if (typeof o != "number" || s.length === 0)

@@ -457,3 +457,3 @@ return { parent: e, referenceNode: null };

}
function Ve(e, t, n, r) {
function je(e, t, n, r) {
const s = e.ownerDocument || document, o = `h${P(r, 1, 6)}`, a = s.createElement(o);

@@ -476,4 +476,4 @@ a.setAttribute("data-doc-schema-section", t.id), a.textContent = t.title;

}
function je(e, t, n) {
const r = qe(e, n.normalizeText), s = [], o = /* @__PURE__ */ new Map(), a = [];
function Ue(e, t, n) {
const r = ze(e, n.normalizeText), s = [], o = /* @__PURE__ */ new Map(), a = [];
for (let i = 0; i < r.length && !(s.length >= n.maxIssues); i += 1) {

@@ -529,4 +529,4 @@ const l = r[i];

for (let l = 0; l < a.length && !(s.length >= n.maxIssues); l += 1) {
const d = a[l], y = t.orderBySectionId.get(d.section.id) ?? l;
y < i ? s.push(
const d = a[l], S = t.orderBySectionId.get(d.section.id) ?? l;
S < i ? s.push(
V(

@@ -543,3 +543,3 @@ "out-of-order",

)
) : i = y;
) : i = S;
}

@@ -594,4 +594,4 @@ }

d && (d.textContent = n.labels.shortcutText);
const y = t.querySelector('[data-action="run-validation"]');
y && (y.textContent = n.labels.validateText);
const S = t.querySelector('[data-action="run-validation"]');
S && (S.textContent = n.labels.validateText);
const f = t.querySelector('[data-action="insert-missing"]');

@@ -601,3 +601,3 @@ if (f) {

const h = r.issues.some((x) => x.type === "missing-section");
f.disabled = !h || ve(e);
f.disabled = !h || Ee(e);
}

@@ -624,3 +624,3 @@ const k = t.querySelector('[data-action="toggle-realtime"]');

function ae(e) {
const t = Fe(e);
const t = We(e);
b.forEach((r, s) => {

@@ -634,3 +634,3 @@ s !== e && G(s, !1);

}
function Ue(e, t) {
function Ge(e, t) {
if (t === e.innerHTML) return;

@@ -644,3 +644,3 @@ const n = window.execEditorCommand || window.executeEditorCommand;

}
function Ge(e) {
function Fe(e) {
e.dispatchEvent(new Event("input", { bubbles: !0 }));

@@ -661,3 +661,3 @@ }

], s.headingCount = 0, s.recognizedHeadingCount = 0, s.missingCount = 1, s.lastRunAt = (/* @__PURE__ */ new Date()).toISOString(), s.snapshot = a, _(e), D(e), s.issues;
const i = je(e, c, r);
const i = Ue(e, c, r);
return s.issues = i.issues, s.headingCount = i.headingCount, s.recognizedHeadingCount = i.recognizedHeadingCount, s.missingCount = i.missingCount, s.lastRunAt = (/* @__PURE__ */ new Date()).toISOString(), s.snapshot = a, _(e), D(e), e.dispatchEvent(

@@ -695,3 +695,3 @@ new CustomEvent("editora:doc-schema-validation", {

const n = g(e, t), r = b.get(e);
if (ve(e))
if (Ee(e))
return r && ee(r, t.labels.readonlyMessage), !1;

@@ -708,8 +708,8 @@ const s = L(t, n.activeSchemaId);

return r && ee(r, t.labels.noIssuesText), !1;
const c = e.innerHTML, i = Ee(e, s, t.normalizeText), l = ze(i, 2), d = Be(e);
const c = e.innerHTML, i = ve(e, s, t.normalizeText), l = Be(i, 2), d = Ke(e);
a.forEach((f) => {
const k = s.strictOrder ? Ke(e, f, s, t.normalizeText) : d || { parent: e, referenceNode: null }, [O, A] = Ve(e, f, t, l);
const k = s.strictOrder ? Ve(e, f, s, t.normalizeText) : d || { parent: e, referenceNode: null }, [O, A] = je(e, f, t, l);
k.parent.insertBefore(O, k.referenceNode), k.parent.insertBefore(A, k.referenceNode);
}), Ue(e, c), Ge(e), C(e, "insert-missing-post", !0);
const y = a.map((f) => f.title).join(", ");
}), Ge(e, c), Fe(e), C(e, "insert-missing-post", !0);
const S = a.map((f) => f.title).join(", ");
return e.dispatchEvent(

@@ -723,5 +723,5 @@ new CustomEvent("editora:doc-schema-insert-missing", {

})
), r && ee(r, `${t.labels.insertedSummaryPrefix}: ${y}`), !0;
), r && ee(r, `${t.labels.insertedSummaryPrefix}: ${S}`), !0;
}
function Fe(e) {
function We(e) {
const t = b.get(e);

@@ -731,3 +731,3 @@ if (t) return t;

g(e, n);
const r = `rte-doc-schema-panel-${Ae++}`, s = `${r}-schema`, o = document.createElement("section");
const r = `rte-doc-schema-panel-${Le++}`, s = `${r}-schema`, o = document.createElement("section");
return o.className = m, o.id = r, o.setAttribute("role", "dialog"), o.setAttribute("aria-modal", "false"), o.setAttribute("aria-label", n.labels.panelAriaLabel), o.innerHTML = `

@@ -786,14 +786,17 @@ <header class="rte-doc-schema-header">

}
function We(e) {
const t = e.key.toLowerCase();
function Ie(e) {
return typeof e.key == "string" ? e.key.toLowerCase() : "";
}
function Ye(e) {
const t = Ie(e);
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "g";
}
function Ye(e) {
const t = e.key.toLowerCase();
function Je(e) {
const t = Ie(e);
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "j";
}
function Je(e) {
function Xe(e) {
w = e, q || (q = (t) => {
Q();
const r = t.target?.closest(S);
const r = t.target?.closest(y);
if (!r) return;

@@ -805,3 +808,3 @@ const s = u.get(r) || e;

}, document.addEventListener("focusin", q, !0)), z || (z = (t) => {
const r = t.target?.closest(S);
const r = t.target?.closest(y);
if (!r) return;

@@ -812,3 +815,3 @@ const s = u.get(r) || w;

if (t.defaultPrevented || t.target?.closest(`.${m}`) && t.key !== "Escape") return;
const r = _e(t);
const r = qe(t);
if (!r) return;

@@ -820,7 +823,7 @@ const s = u.get(r) || w || e;

}
if (We(t)) {
if (Ye(t)) {
t.preventDefault(), t.stopPropagation(), ke(r);
return;
}
Ye(t) && (t.preventDefault(), t.stopPropagation(), C(r, "shortcut", !0));
Je(t) && (t.preventDefault(), t.stopPropagation(), C(r, "shortcut", !0));
}, document.addEventListener("keydown", B, !0)), R || (R = () => {

@@ -831,3 +834,3 @@ Q(), b.forEach((t, n) => {

}, window.addEventListener("scroll", R, !0), window.addEventListener("resize", R)), !K && typeof MutationObserver < "u" && document.body && (K = new MutationObserver((t) => {
Pe(t) && Q();
_e(t) && Q();
}), K.observe(document.body, {

@@ -838,11 +841,11 @@ childList: !0,

}
function Xe() {
function Ze() {
q && (document.removeEventListener("focusin", q, !0), q = null), z && (document.removeEventListener("input", z, !0), z = null), B && (document.removeEventListener("keydown", B, !0), B = null), R && (window.removeEventListener("scroll", R, !0), window.removeEventListener("resize", R), R = null), K && (K.disconnect(), K = null), b.forEach((t) => t.remove()), b.clear(), Array.from(ne).forEach((t) => ue(t)), w = null, p = null;
}
function Ze() {
function Qe() {
if (typeof document > "u" || document.getElementById(he)) return;
const e = document.createElement("style");
e.id = he, e.textContent = `
.rte-toolbar-group-items.${v},
.editora-toolbar-group-items.${v},
.rte-toolbar-group-items.${E},
.editora-toolbar-group-items.${E},
.rte-toolbar-group-items.${T},

@@ -858,4 +861,4 @@ .editora-toolbar-group-items.${T},

.rte-toolbar-group-items.${v} .rte-toolbar-button,
.editora-toolbar-group-items.${v} .editora-toolbar-button,
.rte-toolbar-group-items.${E} .rte-toolbar-button,
.editora-toolbar-group-items.${E} .editora-toolbar-button,
.rte-toolbar-group-items.${T} .rte-toolbar-button,

@@ -870,4 +873,4 @@ .editora-toolbar-group-items.${T} .editora-toolbar-button,

.rte-toolbar-group-items.${v} .rte-toolbar-item:last-child .rte-toolbar-button,
.editora-toolbar-group-items.${v} .editora-toolbar-item:last-child .editora-toolbar-button,
.rte-toolbar-group-items.${E} .rte-toolbar-item:last-child .rte-toolbar-button,
.editora-toolbar-group-items.${E} .editora-toolbar-item:last-child .editora-toolbar-button,
.rte-toolbar-group-items.${T} .rte-toolbar-item:last-child .rte-toolbar-button,

@@ -880,8 +883,8 @@ .editora-toolbar-group-items.${T} .editora-toolbar-item:last-child .editora-toolbar-button,

${E} .rte-toolbar-group-items.${v},
${E} .editora-toolbar-group-items.${v},
${E} .rte-toolbar-group-items.${T},
${E} .editora-toolbar-group-items.${T},
${E} .rte-toolbar-group-items.${H},
${E} .editora-toolbar-group-items.${H} {
${v} .rte-toolbar-group-items.${E},
${v} .editora-toolbar-group-items.${E},
${v} .rte-toolbar-group-items.${T},
${v} .editora-toolbar-group-items.${T},
${v} .rte-toolbar-group-items.${H},
${v} .editora-toolbar-group-items.${H} {
border-color: #566275;

@@ -893,11 +896,11 @@ }

}
${E} .rte-toolbar-group-items.${v} .rte-toolbar-button svg,
${E} .editora-toolbar-group-items.${v} .editora-toolbar-button svg,
${E} .rte-toolbar-group-items.${T} .rte-toolbar-button svg,
${E} .editora-toolbar-group-items.${T} .editora-toolbar-button svg
${v} .rte-toolbar-group-items.${E} .rte-toolbar-button svg,
${v} .editora-toolbar-group-items.${E} .editora-toolbar-button svg,
${v} .rte-toolbar-group-items.${T} .rte-toolbar-button svg,
${v} .editora-toolbar-group-items.${T} .editora-toolbar-button svg
{
fill: none;
}
${E} .rte-toolbar-group-items.${v} .rte-toolbar-button,
${E} .editora-toolbar-group-items.${v} .editora-toolbar-button
${v} .rte-toolbar-group-items.${E} .rte-toolbar-button,
${v} .editora-toolbar-group-items.${E} .editora-toolbar-button
{

@@ -1220,5 +1223,5 @@ border-color: #566275;

}
const Qe = (e = {}) => {
const et = (e = {}) => {
const t = Z(e), n = /* @__PURE__ */ new Set();
return Ze(), {
return Qe(), {
name: "docSchema",

@@ -1303,3 +1306,3 @@ toolbar: [

if (!o || !r || typeof r != "object") return !1;
const a = u.get(o) || t, c = X.get(o) || He(a), i = {
const a = u.get(o) || t, c = X.get(o) || Re(a), i = {
...c,

@@ -1346,3 +1349,3 @@ ...r,

const o = this && typeof this.__pluginConfig == "object" ? { ...e, ...this.__pluginConfig } : e, a = Z(o);
Je(a);
Xe(a);
const c = I(

@@ -1356,3 +1359,3 @@ s?.editorElement ? { editorElement: s.editorElement } : void 0,

destroy: () => {
n.forEach((r) => ue(r)), n.clear(), W = Math.max(0, W - 1), !(W > 0) && Xe();
n.forEach((r) => ue(r)), n.clear(), W = Math.max(0, W - 1), !(W > 0) && Ze();
}

@@ -1362,3 +1365,3 @@ };

export {
Qe as DocSchemaPlugin
et as DocSchemaPlugin
};

@@ -1,2 +0,19 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=[{label:"Inline Value",value:"inline"},{label:"Responsive - 21x9",value:"21x9"},{label:"Responsive - 16x9",value:"16x9"},{label:"Responsive - 4x3",value:"4x3"},{label:"Responsive - 1x1",value:"1x1"}],m='[data-theme="dark"], .dark, .editora-theme-dark',u=new WeakMap,l=e=>(u.has(e)||u.set(e,{dialogElement:null,escapeHandler:null,activeTab:"general",formData:{src:"",selectedSize:"inline",width:"100%",height:"400px",constrainProportions:!0,name:"",title:"",longDescription:"",descriptionUrl:"",showBorder:!0,enableScrollbar:!0}}),u.get(e));function v(e){return e?.matches(m)||e?.closest(m)||document.activeElement?.closest(m)?!0:document.body.matches(m)||document.documentElement.matches(m)}const x=()=>({name:"embedIframe",toolbar:[{label:"Embed Content",command:"openEmbedIframeDialog",icon:'<svg width="24" height="24" focusable="false"><path d="M19 6V5H5v14h2A13 13 0 0 1 19 6Zm0 1.4c-.8.8-1.6 2.4-2.2 4.6H19V7.4Zm0 5.6h-2.4c-.4 1.8-.6 3.8-.6 6h3v-6Zm-4 6c0-2.2.2-4.2.6-6H13c-.7 1.8-1.1 3.8-1.1 6h3Zm-4 0c0-2.2.4-4.2 1-6H9.6A12 12 0 0 0 8 19h3ZM4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm11.8 9c.4-1.9 1-3.4 1.8-4.5a9.2 9.2 0 0 0-4 4.5h2.2Zm-3.4 0a12 12 0 0 1 2.8-4 12 12 0 0 0-5 4h2.2Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-Shift-e",type:"button"}],commands:{openEmbedIframeDialog:e=>(y(e),!0)},keymap:{"Mod-Shift-e":"openEmbedIframeDialog"}});function y(e){if(!e){const o=document.activeElement;o&&o.closest("[data-editora-editor]")&&(e=o.closest("[data-editora-editor]"))}if(e||(e=document.querySelector("[data-editora-editor]")),!e){console.warn("Editor element not found");return}const t=l(e);t.formData={src:"",selectedSize:"inline",width:"100%",height:"400px",constrainProportions:!0,name:"",title:"",longDescription:"",descriptionUrl:"",showBorder:!0,enableScrollbar:!0},t.activeTab="general";const a=document.createElement("div");a.className="rte-dialog-overlay rte-embed-iframe-overlay",v(e)&&a.classList.add("rte-theme-dark"),a.onclick=()=>f(e);const r=document.createElement("div");r.className="rte-dialog-content embed-iframe-dialog",r.onclick=o=>o.stopPropagation(),r.innerHTML=`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const D=[{label:"Inline Value",value:"inline"},{label:"Responsive - 21x9",value:"21x9"},{label:"Responsive - 16x9",value:"16x9"},{label:"Responsive - 4x3",value:"4x3"},{label:"Responsive - 1x1",value:"1x1"}],u='[data-theme="dark"], .dark, .editora-theme-dark';let l=null;const v=new WeakMap,s=e=>(v.has(e)||v.set(e,{dialogElement:null,escapeHandler:null,savedRange:null,activeTab:"general",formData:{src:"",selectedSize:"inline",width:"100%",height:"400px",constrainProportions:!0,name:"",title:"",longDescription:"",descriptionUrl:"",showBorder:!0,enableScrollbar:!0}}),v.get(e));function C(e){return e?.matches(u)||e?.closest(u)||document.activeElement?.closest(u)?!0:document.body.matches(u)||document.documentElement.matches(u)}function x(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function R(e){const t=e?.editorElement;if(t instanceof HTMLElement)return t;const r=e?.contentElement;if(r instanceof HTMLElement){const i=r.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");return i instanceof HTMLElement?i:r}const o=window.__editoraCommandEditorRoot;if(o instanceof HTMLElement)return o;const a=window.getSelection();if(a&&a.rangeCount>0){const c=x(a.getRangeAt(0).startContainer)?.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");if(c instanceof HTMLElement)return c}const n=document.activeElement;if(n instanceof HTMLElement){const i=n.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");if(i instanceof HTMLElement)return i}return document.querySelector("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")}function w(e){return e.getAttribute("contenteditable")==="true"?e:e.querySelector('.rte-content, .editora-content, [contenteditable="true"]')}function h(e){return x(e)?.closest('.rte-content, .editora-content, [contenteditable="true"]')}function L(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=t.getRangeAt(0);return!e.contains(r.startContainer)||!e.contains(r.endContainer)?null:r.cloneRange()}function k(e,t,r){if(t!==r){if(typeof window.execEditorCommand=="function"){window.execEditorCommand("recordDomTransaction",e,t,r);return}if(typeof window.executeEditorCommand=="function")try{window.executeEditorCommand("recordDomTransaction",{editor:e,beforeHTML:t,afterHTML:r})}catch{}}}function I(e,t){let r=t;for(;r&&r.parentNode&&r.parentNode!==e;)r=r.parentNode;return r&&r.parentNode===e?r:null}function y(e,t){return e.tagName!=="P"?!1:Array.from(e.childNodes).every(r=>r===t?!0:r.nodeType===Node.ELEMENT_NODE?r.tagName==="BR":r.nodeType===Node.TEXT_NODE&&!r.textContent?.trim())}function T(e){if(!(e instanceof Element))return null;const t=e.closest("iframe");if(t instanceof HTMLIFrameElement){const n=h(t);if(!n)return null;const i=t.parentElement;return i&&i.parentElement===n&&y(i,t)?i:t}const r=e.closest("p");if(!(r instanceof HTMLElement))return null;const o=h(r);if(!o||r.parentElement!==o)return null;const a=Array.from(r.children).find(n=>n instanceof HTMLIFrameElement);return a&&y(r,a)?r:null}function f(){l&&(l.classList.remove("rte-selected-embed-object"),l.querySelector("iframe")?.removeAttribute("data-rte-selected-object"),l instanceof HTMLIFrameElement&&l.removeAttribute("data-rte-selected-object"),l=null)}function H(e){if(l===e)return;f(),l=e,e.classList.add("rte-selected-embed-object"),(e instanceof HTMLIFrameElement?e:e.querySelector("iframe"))?.setAttribute("data-rte-selected-object","true");const r=window.getSelection();if(!r)return;const o=document.createRange();o.selectNode(e),r.removeAllRanges(),r.addRange(o)}function N(e,t){const r=window.getSelection();if(!r)return;const o=document.createRange();t&&t.parentNode===e?o.setStartBefore(t):(o.selectNodeContents(e),o.collapse(!1)),o.collapse(!0),r.removeAllRanges(),r.addRange(o)}function q(e){if(e.childNodes.length>0)return;const t=document.createElement("p");t.appendChild(document.createElement("br")),e.appendChild(t)}function A(){if(!l||!l.isConnected)return f(),!1;const e=l,t=h(e);if(!t)return f(),!1;const r=t.innerHTML,o=e.nextSibling;e.remove(),q(t),f(),N(t,o);const a=t.innerHTML;return k(t,r,a),t.dispatchEvent(new window.Event("input",{bubbles:!0})),r!==a}function E(){if(document.getElementById("embed-iframe-object-selection-styles"))return;const e=document.createElement("style");e.id="embed-iframe-object-selection-styles",e.textContent=`
.rte-selected-embed-object {
outline: 2px solid #2563eb;
outline-offset: 3px;
border-radius: 4px;
}
.rte-content iframe,
.editora-content iframe,
[contenteditable="true"] iframe {
pointer-events: none;
}
.rte-selected-embed-object iframe,
iframe.rte-selected-embed-object {
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.28);
}
`,document.head.appendChild(e)}function M(){typeof window>"u"||window.__embedIframeObjectSelectionInitialized||(window.__embedIframeObjectSelectionInitialized=!0,E(),document.addEventListener("pointerdown",e=>{const t=T(e.target);if(!t){e.target?.closest?.(".rte-embed-iframe-overlay")||f();return}e.preventDefault(),h(t)?.focus(),H(t)},!0),document.addEventListener("keydown",e=>{if(l){if(e.key==="Escape"){f();return}e.key!=="Backspace"&&e.key!=="Delete"||(e.preventDefault(),e.stopPropagation(),A())}},!0))}function z(e){try{const t=new URL(e),r=t.hostname.replace(/^www\./,"");if(r==="youtu.be"){const o=t.pathname.split("/").filter(Boolean)[0];if(o)return`https://www.youtube.com/embed/${encodeURIComponent(o)}`}if(r==="youtube.com"||r==="m.youtube.com"){const o=t.searchParams.get("v");if(o)return`https://www.youtube.com/embed/${encodeURIComponent(o)}`;const a=t.pathname.match(/^\/embed\/([^/]+)/);if(a?.[1])return`https://www.youtube.com/embed/${encodeURIComponent(a[1])}`}if(r==="vimeo.com"){const o=t.pathname.split("/").filter(Boolean)[0];if(o&&/^\d+$/.test(o))return`https://player.vimeo.com/video/${o}`}return e}catch{return e}}const j=()=>({name:"embedIframe",init:M,toolbar:[{label:"Embed Content",command:"openEmbedIframeDialog",icon:'<svg width="24" height="24" focusable="false"><path d="M19 6V5H5v14h2A13 13 0 0 1 19 6Zm0 1.4c-.8.8-1.6 2.4-2.2 4.6H19V7.4Zm0 5.6h-2.4c-.4 1.8-.6 3.8-.6 6h3v-6Zm-4 6c0-2.2.2-4.2.6-6H13c-.7 1.8-1.1 3.8-1.1 6h3Zm-4 0c0-2.2.4-4.2 1-6H9.6A12 12 0 0 0 8 19h3ZM4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm11.8 9c.4-1.9 1-3.4 1.8-4.5a9.2 9.2 0 0 0-4 4.5h2.2Zm-3.4 0a12 12 0 0 1 2.8-4 12 12 0 0 0-5 4h2.2Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-Shift-e",type:"button"}],commands:{openEmbedIframeDialog:(e,t)=>(P(R(t)||void 0),!0)},keymap:{"Mod-Shift-e":"openEmbedIframeDialog"}});function P(e){if(!e){const n=document.activeElement;n&&n.closest("[data-editora-editor]")&&(e=n.closest("[data-editora-editor]"))}if(e||(e=document.querySelector("[data-editora-editor]")),!e){console.warn("Editor element not found");return}const t=s(e),r=w(e);t.savedRange=r?L(r):null,t.formData={src:"",selectedSize:"inline",width:"100%",height:"400px",constrainProportions:!0,name:"",title:"",longDescription:"",descriptionUrl:"",showBorder:!0,enableScrollbar:!0},t.activeTab="general";const o=document.createElement("div");o.className="rte-dialog-overlay rte-embed-iframe-overlay",C(e)&&o.classList.add("rte-theme-dark"),o.onclick=()=>b(e);const a=document.createElement("div");a.className="rte-dialog-content embed-iframe-dialog",a.onclick=n=>n.stopPropagation(),a.innerHTML=`
<div class="rte-dialog-header">

@@ -21,3 +38,3 @@ <h3>Embed Iframe</h3>

<select class="rte-form-select" id="iframe-size">
${g.map(o=>`<option value="${o.value}">${o.label}</option>`).join("")}
${D.map(n=>`<option value="${n.value}">${n.label}</option>`).join("")}
</select>

@@ -76,3 +93,3 @@ </div>

</div>
`,a.appendChild(r),document.body.appendChild(a),t.dialogElement=a,t.escapeHandler=o=>{o.key==="Escape"&&(o.preventDefault(),o.stopPropagation(),f(e))},document.addEventListener("keydown",t.escapeHandler,!0),k(r,e),z(),setTimeout(()=>{r.querySelector("#iframe-src")?.focus()},100)}function k(e,t){l(t),e.querySelector(".rte-dialog-close")?.addEventListener("click",()=>f(t)),e.querySelectorAll(".rte-tab-button").forEach(i=>{i.addEventListener("click",n=>{const c=n.target.getAttribute("data-tab");c&&w(e,c,t)})}),e.querySelector("#iframe-size")?.addEventListener("change",i=>S(e,i.target.value,t));const r=e.querySelector("#iframe-width"),o=e.querySelector("#iframe-height");r?.addEventListener("input",i=>D(e,i.target.value,t)),o?.addEventListener("input",i=>q(e,i.target.value,t)),e.querySelector("#constrain-btn")?.addEventListener("click",()=>E(e,t)),e.querySelector("#cancel-btn")?.addEventListener("click",()=>f(t)),e.querySelector("#save-btn")?.addEventListener("click",()=>L(e,t))}function w(e,t,a){const r=l(a);r.activeTab=t,e.querySelectorAll(".rte-tab-button").forEach(o=>{o.classList.toggle("active",o.getAttribute("data-tab")===t)}),e.querySelectorAll(".rte-tab-panel").forEach(o=>{o.style.display=o.getAttribute("data-panel")===t?"block":"none"})}function S(e,t,a){const r=l(a);r.formData.selectedSize=t;const o=e.querySelector("#dimensions-row"),i=e.querySelector("#iframe-width"),n=e.querySelector("#iframe-height");t==="inline"?(o.style.display="flex",i.value="100%",n.value="400px",r.formData.width="100%",r.formData.height="400px"):(o.style.display="none",r.formData.width="100%",r.formData.height="auto")}function D(e,t,a){const r=l(a);if(r.formData.width=t,r.formData.constrainProportions&&r.formData.selectedSize==="inline"){const o=parseFloat(t);if(!isNaN(o)){const i=o*9/16;r.formData.height=`${i}px`;const n=e.querySelector("#iframe-height");n&&(n.value=r.formData.height)}}}function q(e,t,a){const r=l(a);if(r.formData.height=t,r.formData.constrainProportions&&r.formData.selectedSize==="inline"){const o=parseFloat(t);if(!isNaN(o)){const i=o*16/9;r.formData.width=`${i}px`;const n=e.querySelector("#iframe-width");n&&(n.value=r.formData.width)}}}function E(e,t){const a=l(t);a.formData.constrainProportions=!a.formData.constrainProportions;const r=e.querySelector("#constrain-btn");r&&(r.textContent=a.formData.constrainProportions?"🔒":"🔓",r.className=`rte-constrain-btn ${a.formData.constrainProportions?"locked":"unlocked"}`,r.title=a.formData.constrainProportions?"Unlock proportions":"Lock proportions")}function L(e,t){const a=l(t),r=e.querySelector("#iframe-src")?.value.trim();if(!r){alert("Please enter a source URL");return}if(!r.startsWith("https://")&&!r.startsWith("http://")){alert("Please enter a valid URL starting with https:// or http://");return}const o=e.querySelector("#iframe-name")?.value.trim(),i=e.querySelector("#iframe-title")?.value.trim(),n=e.querySelector("#iframe-longdesc")?.value.trim();e.querySelector("#iframe-desc-url")?.value.trim();const c=e.querySelector("#iframe-border")?.checked??!0,p=e.querySelector("#iframe-scrollbar")?.checked??!0;let s=a.formData.width,d=a.formData.height;a.formData.selectedSize!=="inline"&&(s="100%",d="auto"),I(t,{src:r,width:s,height:d,aspectRatio:a.formData.selectedSize,name:o||void 0,title:i||void 0,longDescription:n||void 0,showBorder:c,enableScrollbar:p}),f(t)}function I(e,t){const a=e.querySelector('[contenteditable="true"]');a&&(a.focus(),setTimeout(()=>{const r=[`src="${t.src}"`,`width="${t.width}"`,`height="${t.height}"`,"allowfullscreen",`frameborder="${t.showBorder?"1":"0"}"`,`scrolling="${t.enableScrollbar?"auto":"no"}"`];t.name&&r.push(`name="${t.name}"`),t.title&&r.push(`title="${t.title}"`),t.longDescription&&r.push(`longdesc="${t.longDescription}"`);const o=[];t.aspectRatio!=="inline"&&o.push(`rte-iframe-${t.aspectRatio}`);const i=o.length>0?`class="${o.join(" ")}"`:"",n=`data-aspect-ratio="${t.aspectRatio}"`,c=`<iframe ${r.join(" ")} ${i} ${n}></iframe>`;if(!document.execCommand("insertHTML",!1,c)){const s=window.getSelection();if(s&&s.rangeCount>0){const d=s.getRangeAt(0);d.deleteContents();const b=document.createElement("div");b.innerHTML=c;const h=document.createDocumentFragment();for(;b.firstChild;)h.appendChild(b.firstChild);d.insertNode(h)}}},10))}function f(e){const t=l(e);t.escapeHandler&&(document.removeEventListener("keydown",t.escapeHandler,!0),t.escapeHandler=null),t.dialogElement&&(t.dialogElement.remove(),t.dialogElement=null)}function z(){if(document.getElementById("embed-iframe-dialog-styles"))return;const e=document.createElement("style");e.id="embed-iframe-dialog-styles",e.textContent=`
`,o.appendChild(a),document.body.appendChild(o),t.dialogElement=o,t.escapeHandler=n=>{n.key==="Escape"&&(n.preventDefault(),n.stopPropagation(),b(e))},document.addEventListener("keydown",t.escapeHandler,!0),O(a,e),W(),setTimeout(()=>{a.querySelector("#iframe-src")?.focus()},100)}function O(e,t){s(t),e.querySelector(".rte-dialog-close")?.addEventListener("click",()=>b(t)),e.querySelectorAll(".rte-tab-button").forEach(n=>{n.addEventListener("click",i=>{const c=i.target.getAttribute("data-tab");c&&_(e,c,t)})}),e.querySelector("#iframe-size")?.addEventListener("change",n=>B(e,n.target.value,t));const o=e.querySelector("#iframe-width"),a=e.querySelector("#iframe-height");o?.addEventListener("input",n=>U(e,n.target.value,t)),a?.addEventListener("input",n=>$(e,n.target.value,t)),e.querySelector("#constrain-btn")?.addEventListener("click",()=>F(e,t)),e.querySelector("#cancel-btn")?.addEventListener("click",()=>b(t)),e.querySelector("#save-btn")?.addEventListener("click",()=>Z(e,t))}function _(e,t,r){const o=s(r);o.activeTab=t,e.querySelectorAll(".rte-tab-button").forEach(a=>{a.classList.toggle("active",a.getAttribute("data-tab")===t)}),e.querySelectorAll(".rte-tab-panel").forEach(a=>{a.style.display=a.getAttribute("data-panel")===t?"block":"none"})}function B(e,t,r){const o=s(r);o.formData.selectedSize=t;const a=e.querySelector("#dimensions-row"),n=e.querySelector("#iframe-width"),i=e.querySelector("#iframe-height");t==="inline"?(a.style.display="flex",n.value="100%",i.value="400px",o.formData.width="100%",o.formData.height="400px"):(a.style.display="none",o.formData.width="100%",o.formData.height="auto")}function U(e,t,r){const o=s(r);if(o.formData.width=t,o.formData.constrainProportions&&o.formData.selectedSize==="inline"){const a=parseFloat(t);if(!isNaN(a)){const n=a*9/16;o.formData.height=`${n}px`;const i=e.querySelector("#iframe-height");i&&(i.value=o.formData.height)}}}function $(e,t,r){const o=s(r);if(o.formData.height=t,o.formData.constrainProportions&&o.formData.selectedSize==="inline"){const a=parseFloat(t);if(!isNaN(a)){const n=a*16/9;o.formData.width=`${n}px`;const i=e.querySelector("#iframe-width");i&&(i.value=o.formData.width)}}}function F(e,t){const r=s(t);r.formData.constrainProportions=!r.formData.constrainProportions;const o=e.querySelector("#constrain-btn");o&&(o.textContent=r.formData.constrainProportions?"🔒":"🔓",o.className=`rte-constrain-btn ${r.formData.constrainProportions?"locked":"unlocked"}`,o.title=r.formData.constrainProportions?"Unlock proportions":"Lock proportions")}function Z(e,t){const r=s(t),o=e.querySelector("#iframe-src")?.value.trim();if(!o){alert("Please enter a source URL");return}if(!o.startsWith("https://")&&!o.startsWith("http://")){alert("Please enter a valid URL starting with https:// or http://");return}const a=e.querySelector("#iframe-name")?.value.trim(),n=e.querySelector("#iframe-title")?.value.trim(),i=e.querySelector("#iframe-longdesc")?.value.trim(),c=e.querySelector("#iframe-desc-url")?.value.trim(),p=e.querySelector("#iframe-border")?.checked??!0,g=e.querySelector("#iframe-scrollbar")?.checked??!0;let d=r.formData.width,m=r.formData.height;r.formData.selectedSize!=="inline"&&(d="100%",m="auto"),V(t,{src:o,width:d,height:m,aspectRatio:r.formData.selectedSize,name:a||void 0,title:n||void 0,longDescription:i||void 0,descriptionUrl:c||void 0,showBorder:p,enableScrollbar:g}),b(t)}function V(e,t){const r=s(e),o=w(e);if(!o)return;const a=o.innerHTML,n=document.createElement("iframe");n.src=z(t.src),n.width=t.width,n.height=t.height,n.allowFullscreen=!0,n.setAttribute("frameborder",t.showBorder?"1":"0"),n.setAttribute("scrolling",t.enableScrollbar?"auto":"no"),n.setAttribute("data-aspect-ratio",t.aspectRatio),t.aspectRatio!=="inline"&&n.classList.add(`rte-iframe-${t.aspectRatio}`),t.name&&(n.name=t.name),t.title&&(n.title=t.title),t.longDescription&&n.setAttribute("data-long-description",t.longDescription),t.descriptionUrl&&n.setAttribute("longdesc",t.descriptionUrl);const i=document.createElement("p");i.appendChild(n),i.appendChild(document.createElement("br"));const c=r.savedRange&&o.contains(r.savedRange.commonAncestorContainer)?r.savedRange:document.createRange();(!r.savedRange||!o.contains(r.savedRange.commonAncestorContainer))&&(c.selectNodeContents(o),c.collapse(!1));const p=I(o,c.startContainer),g=p?p.nextSibling:null;o.insertBefore(i,g);const d=document.createRange();d.setStartAfter(i),d.collapse(!0);const m=window.getSelection();m&&(m.removeAllRanges(),m.addRange(d)),r.savedRange=null;const S=o.innerHTML;k(o,a,S),o.dispatchEvent(new window.Event("input",{bubbles:!0}))}function b(e){const t=s(e);t.savedRange=null,t.escapeHandler&&(document.removeEventListener("keydown",t.escapeHandler,!0),t.escapeHandler=null),t.dialogElement&&(t.dialogElement.remove(),t.dialogElement=null)}function W(){if(E(),document.getElementById("embed-iframe-dialog-styles"))return;const e=document.createElement("style");e.id="embed-iframe-dialog-styles",e.textContent=`
/* Embed Iframe Dialog Styles */

@@ -363,2 +380,2 @@ .embed-iframe-dialog {

}
`,document.head.appendChild(e)}exports.EmbedIframePlugin=x;
`,document.head.appendChild(e)}exports.EmbedIframePlugin=j;

@@ -1,2 +0,2 @@

const g = [
const D = [
{ label: "Inline Value", value: "inline" },

@@ -7,5 +7,8 @@ { label: "Responsive - 21x9", value: "21x9" },

{ label: "Responsive - 1x1", value: "1x1" }
], m = '[data-theme="dark"], .dark, .editora-theme-dark', u = /* @__PURE__ */ new WeakMap(), l = (e) => (u.has(e) || u.set(e, {
], u = '[data-theme="dark"], .dark, .editora-theme-dark';
let c = null;
const v = /* @__PURE__ */ new WeakMap(), s = (e) => (v.has(e) || v.set(e, {
dialogElement: null,
escapeHandler: null,
savedRange: null,
activeTab: "general",

@@ -25,8 +28,181 @@ formData: {

}
}), u.get(e));
function v(e) {
return e?.matches(m) || e?.closest(m) || document.activeElement?.closest(m) ? !0 : document.body.matches(m) || document.documentElement.matches(m);
}), v.get(e));
function C(e) {
return e?.matches(u) || e?.closest(u) || document.activeElement?.closest(u) ? !0 : document.body.matches(u) || document.documentElement.matches(u);
}
const I = () => ({
function x(e) {
return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
}
function R(e) {
const t = e?.editorElement;
if (t instanceof HTMLElement) return t;
const r = e?.contentElement;
if (r instanceof HTMLElement) {
const i = r.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");
return i instanceof HTMLElement ? i : r;
}
const o = window.__editoraCommandEditorRoot;
if (o instanceof HTMLElement) return o;
const a = window.getSelection();
if (a && a.rangeCount > 0) {
const l = x(a.getRangeAt(0).startContainer)?.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");
if (l instanceof HTMLElement) return l;
}
const n = document.activeElement;
if (n instanceof HTMLElement) {
const i = n.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");
if (i instanceof HTMLElement) return i;
}
return document.querySelector("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");
}
function w(e) {
return e.getAttribute("contenteditable") === "true" ? e : e.querySelector('.rte-content, .editora-content, [contenteditable="true"]');
}
function h(e) {
return x(e)?.closest('.rte-content, .editora-content, [contenteditable="true"]');
}
function L(e) {
const t = window.getSelection();
if (!t || t.rangeCount === 0) return null;
const r = t.getRangeAt(0);
return !e.contains(r.startContainer) || !e.contains(r.endContainer) ? null : r.cloneRange();
}
function k(e, t, r) {
if (t !== r) {
if (typeof window.execEditorCommand == "function") {
window.execEditorCommand("recordDomTransaction", e, t, r);
return;
}
if (typeof window.executeEditorCommand == "function")
try {
window.executeEditorCommand("recordDomTransaction", { editor: e, beforeHTML: t, afterHTML: r });
} catch {
}
}
}
function I(e, t) {
let r = t;
for (; r && r.parentNode && r.parentNode !== e; )
r = r.parentNode;
return r && r.parentNode === e ? r : null;
}
function y(e, t) {
return e.tagName !== "P" ? !1 : Array.from(e.childNodes).every((r) => r === t ? !0 : r.nodeType === Node.ELEMENT_NODE ? r.tagName === "BR" : r.nodeType === Node.TEXT_NODE && !r.textContent?.trim());
}
function T(e) {
if (!(e instanceof Element)) return null;
const t = e.closest("iframe");
if (t instanceof HTMLIFrameElement) {
const n = h(t);
if (!n) return null;
const i = t.parentElement;
return i && i.parentElement === n && y(i, t) ? i : t;
}
const r = e.closest("p");
if (!(r instanceof HTMLElement)) return null;
const o = h(r);
if (!o || r.parentElement !== o) return null;
const a = Array.from(r.children).find(
(n) => n instanceof HTMLIFrameElement
);
return a && y(r, a) ? r : null;
}
function f() {
c && (c.classList.remove("rte-selected-embed-object"), c.querySelector("iframe")?.removeAttribute("data-rte-selected-object"), c instanceof HTMLIFrameElement && c.removeAttribute("data-rte-selected-object"), c = null);
}
function H(e) {
if (c === e) return;
f(), c = e, e.classList.add("rte-selected-embed-object"), (e instanceof HTMLIFrameElement ? e : e.querySelector("iframe"))?.setAttribute("data-rte-selected-object", "true");
const r = window.getSelection();
if (!r) return;
const o = document.createRange();
o.selectNode(e), r.removeAllRanges(), r.addRange(o);
}
function N(e, t) {
const r = window.getSelection();
if (!r) return;
const o = document.createRange();
t && t.parentNode === e ? o.setStartBefore(t) : (o.selectNodeContents(e), o.collapse(!1)), o.collapse(!0), r.removeAllRanges(), r.addRange(o);
}
function q(e) {
if (e.childNodes.length > 0) return;
const t = document.createElement("p");
t.appendChild(document.createElement("br")), e.appendChild(t);
}
function A() {
if (!c || !c.isConnected)
return f(), !1;
const e = c, t = h(e);
if (!t)
return f(), !1;
const r = t.innerHTML, o = e.nextSibling;
e.remove(), q(t), f(), N(t, o);
const a = t.innerHTML;
return k(t, r, a), t.dispatchEvent(new window.Event("input", { bubbles: !0 })), r !== a;
}
function E() {
if (document.getElementById("embed-iframe-object-selection-styles")) return;
const e = document.createElement("style");
e.id = "embed-iframe-object-selection-styles", e.textContent = `
.rte-selected-embed-object {
outline: 2px solid #2563eb;
outline-offset: 3px;
border-radius: 4px;
}
.rte-content iframe,
.editora-content iframe,
[contenteditable="true"] iframe {
pointer-events: none;
}
.rte-selected-embed-object iframe,
iframe.rte-selected-embed-object {
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.28);
}
`, document.head.appendChild(e);
}
function M() {
typeof window > "u" || window.__embedIframeObjectSelectionInitialized || (window.__embedIframeObjectSelectionInitialized = !0, E(), document.addEventListener("pointerdown", (e) => {
const t = T(e.target);
if (!t) {
e.target?.closest?.(".rte-embed-iframe-overlay") || f();
return;
}
e.preventDefault(), h(t)?.focus(), H(t);
}, !0), document.addEventListener("keydown", (e) => {
if (c) {
if (e.key === "Escape") {
f();
return;
}
e.key !== "Backspace" && e.key !== "Delete" || (e.preventDefault(), e.stopPropagation(), A());
}
}, !0));
}
function z(e) {
try {
const t = new URL(e), r = t.hostname.replace(/^www\./, "");
if (r === "youtu.be") {
const o = t.pathname.split("/").filter(Boolean)[0];
if (o) return `https://www.youtube.com/embed/${encodeURIComponent(o)}`;
}
if (r === "youtube.com" || r === "m.youtube.com") {
const o = t.searchParams.get("v");
if (o) return `https://www.youtube.com/embed/${encodeURIComponent(o)}`;
const a = t.pathname.match(/^\/embed\/([^/]+)/);
if (a?.[1]) return `https://www.youtube.com/embed/${encodeURIComponent(a[1])}`;
}
if (r === "vimeo.com") {
const o = t.pathname.split("/").filter(Boolean)[0];
if (o && /^\d+$/.test(o)) return `https://player.vimeo.com/video/${o}`;
}
return e;
} catch {
return e;
}
}
const W = () => ({
name: "embedIframe",
init: M,
toolbar: [

@@ -42,3 +218,3 @@ {

commands: {
openEmbedIframeDialog: (e) => (x(e), !0)
openEmbedIframeDialog: (e, t) => (j(R(t) || void 0), !0)
},

@@ -49,6 +225,6 @@ keymap: {

});
function x(e) {
function j(e) {
if (!e) {
const o = document.activeElement;
o && o.closest("[data-editora-editor]") && (e = o.closest("[data-editora-editor]"));
const n = document.activeElement;
n && n.closest("[data-editora-editor]") && (e = n.closest("[data-editora-editor]"));
}

@@ -59,4 +235,4 @@ if (e || (e = document.querySelector("[data-editora-editor]")), !e) {

}
const t = l(e);
t.formData = {
const t = s(e), r = w(e);
t.savedRange = r ? L(r) : null, t.formData = {
src: "",

@@ -74,6 +250,6 @@ selectedSize: "inline",

}, t.activeTab = "general";
const o = document.createElement("div");
o.className = "rte-dialog-overlay rte-embed-iframe-overlay", C(e) && o.classList.add("rte-theme-dark"), o.onclick = () => b(e);
const a = document.createElement("div");
a.className = "rte-dialog-overlay rte-embed-iframe-overlay", v(e) && a.classList.add("rte-theme-dark"), a.onclick = () => f(e);
const r = document.createElement("div");
r.className = "rte-dialog-content embed-iframe-dialog", r.onclick = (o) => o.stopPropagation(), r.innerHTML = `
a.className = "rte-dialog-content embed-iframe-dialog", a.onclick = (n) => n.stopPropagation(), a.innerHTML = `
<div class="rte-dialog-header">

@@ -98,3 +274,3 @@ <h3>Embed Iframe</h3>

<select class="rte-form-select" id="iframe-size">
${g.map((o) => `<option value="${o.value}">${o.label}</option>`).join("")}
${D.map((n) => `<option value="${n.value}">${n.label}</option>`).join("")}
</select>

@@ -153,124 +329,111 @@ </div>

</div>
`, a.appendChild(r), document.body.appendChild(a), t.dialogElement = a, t.escapeHandler = (o) => {
o.key === "Escape" && (o.preventDefault(), o.stopPropagation(), f(e));
}, document.addEventListener("keydown", t.escapeHandler, !0), y(r, e), z(), setTimeout(() => {
r.querySelector("#iframe-src")?.focus();
`, o.appendChild(a), document.body.appendChild(o), t.dialogElement = o, t.escapeHandler = (n) => {
n.key === "Escape" && (n.preventDefault(), n.stopPropagation(), b(e));
}, document.addEventListener("keydown", t.escapeHandler, !0), P(a, e), V(), setTimeout(() => {
a.querySelector("#iframe-src")?.focus();
}, 100);
}
function y(e, t) {
l(t), e.querySelector(".rte-dialog-close")?.addEventListener("click", () => f(t)), e.querySelectorAll(".rte-tab-button").forEach((i) => {
i.addEventListener("click", (n) => {
const c = n.target.getAttribute("data-tab");
c && k(e, c, t);
function P(e, t) {
s(t), e.querySelector(".rte-dialog-close")?.addEventListener("click", () => b(t)), e.querySelectorAll(".rte-tab-button").forEach((n) => {
n.addEventListener("click", (i) => {
const l = i.target.getAttribute("data-tab");
l && O(e, l, t);
});
}), e.querySelector("#iframe-size")?.addEventListener("change", (i) => w(e, i.target.value, t));
const r = e.querySelector("#iframe-width"), o = e.querySelector("#iframe-height");
r?.addEventListener("input", (i) => S(e, i.target.value, t)), o?.addEventListener("input", (i) => D(e, i.target.value, t)), e.querySelector("#constrain-btn")?.addEventListener("click", () => q(e, t)), e.querySelector("#cancel-btn")?.addEventListener("click", () => f(t)), e.querySelector("#save-btn")?.addEventListener("click", () => E(e, t));
}), e.querySelector("#iframe-size")?.addEventListener("change", (n) => B(e, n.target.value, t));
const o = e.querySelector("#iframe-width"), a = e.querySelector("#iframe-height");
o?.addEventListener("input", (n) => U(e, n.target.value, t)), a?.addEventListener("input", (n) => _(e, n.target.value, t)), e.querySelector("#constrain-btn")?.addEventListener("click", () => $(e, t)), e.querySelector("#cancel-btn")?.addEventListener("click", () => b(t)), e.querySelector("#save-btn")?.addEventListener("click", () => F(e, t));
}
function k(e, t, a) {
const r = l(a);
r.activeTab = t, e.querySelectorAll(".rte-tab-button").forEach((o) => {
o.classList.toggle("active", o.getAttribute("data-tab") === t);
}), e.querySelectorAll(".rte-tab-panel").forEach((o) => {
o.style.display = o.getAttribute("data-panel") === t ? "block" : "none";
function O(e, t, r) {
const o = s(r);
o.activeTab = t, e.querySelectorAll(".rte-tab-button").forEach((a) => {
a.classList.toggle("active", a.getAttribute("data-tab") === t);
}), e.querySelectorAll(".rte-tab-panel").forEach((a) => {
a.style.display = a.getAttribute("data-panel") === t ? "block" : "none";
});
}
function w(e, t, a) {
const r = l(a);
r.formData.selectedSize = t;
const o = e.querySelector("#dimensions-row"), i = e.querySelector("#iframe-width"), n = e.querySelector("#iframe-height");
t === "inline" ? (o.style.display = "flex", i.value = "100%", n.value = "400px", r.formData.width = "100%", r.formData.height = "400px") : (o.style.display = "none", r.formData.width = "100%", r.formData.height = "auto");
function B(e, t, r) {
const o = s(r);
o.formData.selectedSize = t;
const a = e.querySelector("#dimensions-row"), n = e.querySelector("#iframe-width"), i = e.querySelector("#iframe-height");
t === "inline" ? (a.style.display = "flex", n.value = "100%", i.value = "400px", o.formData.width = "100%", o.formData.height = "400px") : (a.style.display = "none", o.formData.width = "100%", o.formData.height = "auto");
}
function S(e, t, a) {
const r = l(a);
if (r.formData.width = t, r.formData.constrainProportions && r.formData.selectedSize === "inline") {
const o = parseFloat(t);
if (!isNaN(o)) {
const i = o * 9 / 16;
r.formData.height = `${i}px`;
const n = e.querySelector("#iframe-height");
n && (n.value = r.formData.height);
function U(e, t, r) {
const o = s(r);
if (o.formData.width = t, o.formData.constrainProportions && o.formData.selectedSize === "inline") {
const a = parseFloat(t);
if (!isNaN(a)) {
const n = a * 9 / 16;
o.formData.height = `${n}px`;
const i = e.querySelector("#iframe-height");
i && (i.value = o.formData.height);
}
}
}
function D(e, t, a) {
const r = l(a);
if (r.formData.height = t, r.formData.constrainProportions && r.formData.selectedSize === "inline") {
const o = parseFloat(t);
if (!isNaN(o)) {
const i = o * 16 / 9;
r.formData.width = `${i}px`;
const n = e.querySelector("#iframe-width");
n && (n.value = r.formData.width);
function _(e, t, r) {
const o = s(r);
if (o.formData.height = t, o.formData.constrainProportions && o.formData.selectedSize === "inline") {
const a = parseFloat(t);
if (!isNaN(a)) {
const n = a * 16 / 9;
o.formData.width = `${n}px`;
const i = e.querySelector("#iframe-width");
i && (i.value = o.formData.width);
}
}
}
function q(e, t) {
const a = l(t);
a.formData.constrainProportions = !a.formData.constrainProportions;
const r = e.querySelector("#constrain-btn");
r && (r.textContent = a.formData.constrainProportions ? "🔒" : "🔓", r.className = `rte-constrain-btn ${a.formData.constrainProportions ? "locked" : "unlocked"}`, r.title = a.formData.constrainProportions ? "Unlock proportions" : "Lock proportions");
function $(e, t) {
const r = s(t);
r.formData.constrainProportions = !r.formData.constrainProportions;
const o = e.querySelector("#constrain-btn");
o && (o.textContent = r.formData.constrainProportions ? "🔒" : "🔓", o.className = `rte-constrain-btn ${r.formData.constrainProportions ? "locked" : "unlocked"}`, o.title = r.formData.constrainProportions ? "Unlock proportions" : "Lock proportions");
}
function E(e, t) {
const a = l(t), r = e.querySelector("#iframe-src")?.value.trim();
if (!r) {
function F(e, t) {
const r = s(t), o = e.querySelector("#iframe-src")?.value.trim();
if (!o) {
alert("Please enter a source URL");
return;
}
if (!r.startsWith("https://") && !r.startsWith("http://")) {
if (!o.startsWith("https://") && !o.startsWith("http://")) {
alert("Please enter a valid URL starting with https:// or http://");
return;
}
const o = e.querySelector("#iframe-name")?.value.trim(), i = e.querySelector("#iframe-title")?.value.trim(), n = e.querySelector("#iframe-longdesc")?.value.trim();
e.querySelector("#iframe-desc-url")?.value.trim();
const c = e.querySelector("#iframe-border")?.checked ?? !0, p = e.querySelector("#iframe-scrollbar")?.checked ?? !0;
let s = a.formData.width, d = a.formData.height;
a.formData.selectedSize !== "inline" && (s = "100%", d = "auto"), L(t, {
src: r,
width: s,
height: d,
aspectRatio: a.formData.selectedSize,
name: o || void 0,
title: i || void 0,
longDescription: n || void 0,
showBorder: c,
enableScrollbar: p
}), f(t);
const a = e.querySelector("#iframe-name")?.value.trim(), n = e.querySelector("#iframe-title")?.value.trim(), i = e.querySelector("#iframe-longdesc")?.value.trim(), l = e.querySelector("#iframe-desc-url")?.value.trim(), p = e.querySelector("#iframe-border")?.checked ?? !0, g = e.querySelector("#iframe-scrollbar")?.checked ?? !0;
let d = r.formData.width, m = r.formData.height;
r.formData.selectedSize !== "inline" && (d = "100%", m = "auto"), Z(t, {
src: o,
width: d,
height: m,
aspectRatio: r.formData.selectedSize,
name: a || void 0,
title: n || void 0,
longDescription: i || void 0,
descriptionUrl: l || void 0,
showBorder: p,
enableScrollbar: g
}), b(t);
}
function L(e, t) {
const a = e.querySelector('[contenteditable="true"]');
a && (a.focus(), setTimeout(() => {
const r = [
`src="${t.src}"`,
`width="${t.width}"`,
`height="${t.height}"`,
"allowfullscreen",
`frameborder="${t.showBorder ? "1" : "0"}"`,
`scrolling="${t.enableScrollbar ? "auto" : "no"}"`
];
t.name && r.push(`name="${t.name}"`), t.title && r.push(`title="${t.title}"`), t.longDescription && r.push(`longdesc="${t.longDescription}"`);
const o = [];
t.aspectRatio !== "inline" && o.push(`rte-iframe-${t.aspectRatio}`);
const i = o.length > 0 ? `class="${o.join(" ")}"` : "", n = `data-aspect-ratio="${t.aspectRatio}"`, c = `<iframe ${r.join(" ")} ${i} ${n}></iframe>`;
if (!document.execCommand("insertHTML", !1, c)) {
const s = window.getSelection();
if (s && s.rangeCount > 0) {
const d = s.getRangeAt(0);
d.deleteContents();
const b = document.createElement("div");
b.innerHTML = c;
const h = document.createDocumentFragment();
for (; b.firstChild; )
h.appendChild(b.firstChild);
d.insertNode(h);
}
}
}, 10));
function Z(e, t) {
const r = s(e), o = w(e);
if (!o) return;
const a = o.innerHTML, n = document.createElement("iframe");
n.src = z(t.src), n.width = t.width, n.height = t.height, n.allowFullscreen = !0, n.setAttribute("frameborder", t.showBorder ? "1" : "0"), n.setAttribute("scrolling", t.enableScrollbar ? "auto" : "no"), n.setAttribute("data-aspect-ratio", t.aspectRatio), t.aspectRatio !== "inline" && n.classList.add(`rte-iframe-${t.aspectRatio}`), t.name && (n.name = t.name), t.title && (n.title = t.title), t.longDescription && n.setAttribute("data-long-description", t.longDescription), t.descriptionUrl && n.setAttribute("longdesc", t.descriptionUrl);
const i = document.createElement("p");
i.appendChild(n), i.appendChild(document.createElement("br"));
const l = r.savedRange && o.contains(r.savedRange.commonAncestorContainer) ? r.savedRange : document.createRange();
(!r.savedRange || !o.contains(r.savedRange.commonAncestorContainer)) && (l.selectNodeContents(o), l.collapse(!1));
const p = I(o, l.startContainer), g = p ? p.nextSibling : null;
o.insertBefore(i, g);
const d = document.createRange();
d.setStartAfter(i), d.collapse(!0);
const m = window.getSelection();
m && (m.removeAllRanges(), m.addRange(d)), r.savedRange = null;
const S = o.innerHTML;
k(o, a, S), o.dispatchEvent(new window.Event("input", { bubbles: !0 }));
}
function f(e) {
const t = l(e);
t.escapeHandler && (document.removeEventListener("keydown", t.escapeHandler, !0), t.escapeHandler = null), t.dialogElement && (t.dialogElement.remove(), t.dialogElement = null);
function b(e) {
const t = s(e);
t.savedRange = null, t.escapeHandler && (document.removeEventListener("keydown", t.escapeHandler, !0), t.escapeHandler = null), t.dialogElement && (t.dialogElement.remove(), t.dialogElement = null);
}
function z() {
if (document.getElementById("embed-iframe-dialog-styles")) return;
function V() {
if (E(), document.getElementById("embed-iframe-dialog-styles")) return;
const e = document.createElement("style");

@@ -566,3 +729,3 @@ e.id = "embed-iframe-dialog-styles", e.textContent = `

export {
I as EmbedIframePlugin
W as EmbedIframePlugin
};

@@ -1,1 +0,1 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=()=>{const e=a=>{try{return document.execCommand("formatBlock",!1,a),!0}catch(l){return console.error(`Failed to set block type to ${a}:`,l),!1}};return{name:"heading",toolbar:[{label:"Heading",command:"setBlockType",type:"dropdown",options:[{value:"p",label:"Paragraph"},{value:"h1",label:"Heading 1"},{value:"h2",label:"Heading 2"},{value:"h3",label:"Heading 3"},{value:"h4",label:"Heading 4"},{value:"h5",label:"Heading 5"},{value:"h6",label:"Heading 6"}],icon:'<svg width="24" height="24" focusable="false"><path d="M16.1 8.6 14.2 4l-1.4.5 2.8 7.4c.1.4.5.6.9.6h.1c.4-.1.6-.5.6-.9l1.8-4.8-1.4-.5-1.5 2.3ZM4 11.5h6V10H4v1.5ZM18.5 3v1L17 7l.9.9L20.7 3h-2.2ZM5.5 12h1v7h1v-7h1v-.5h-3V12Zm4 0h1v7h1v-7h1v-.5h-3V12Zm10 1.5a2 2 0 0 0-2-2h-1v7.5h1v-2.7h1a2 2 0 0 0 2-2v-.8Zm-2 1.3h-1v-2.3h1a.8.8 0 1 1 0 1.6v.7Z" fill-rule="evenodd"></path></svg>'}],commands:{setBlockType:a=>a?e(a):!1,setHeading1:()=>e("h1"),setHeading2:()=>e("h2"),setHeading3:()=>e("h3"),setParagraph:()=>e("p")},keymap:{"Mod-Alt-1":"setHeading1","Mod-Alt-2":"setHeading2","Mod-Alt-3":"setHeading3","Mod-Alt-0":"setParagraph"}}};exports.HeadingPlugin=t;
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f='.rte-content, .editora-content, [contenteditable="true"]',y="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",g=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","PRE"]),E="p,div,h1,h2,h3,h4,h5,h6,ul,ol,blockquote,pre,table",B=new Set(["p","h1","h2","h3","h4","h5","h6"]);function H(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function S(e){const n=e?.contentElement;if(n instanceof HTMLElement)return n;const t=e?.editorElement;if(t instanceof HTMLElement){const a=t.querySelector(f);if(a instanceof HTMLElement)return a;if(t.getAttribute("contenteditable")==="true")return t}const r=window.getSelection();if(r&&r.rangeCount>0){const a=H(r.getRangeAt(0).startContainer),i=a?.closest(f);if(i instanceof HTMLElement)return i;const u=a?.closest(y)?.querySelector(f);if(u instanceof HTMLElement)return u}const o=document.activeElement?.closest(f);return o instanceof HTMLElement?o:document.querySelector(f)}function N(e){const n=window.getSelection();if(!n||n.rangeCount===0)return null;const t=n.getRangeAt(0);return!e.contains(t.startContainer)||!e.contains(t.endContainer)?null:t}function T(e,n){let t=H(n);if(!t||t===e||!e.contains(t))return null;for(;t.parentElement&&t.parentElement!==e;)t=t.parentElement;if(t.parentElement!==e)return null;if(t.matches(E))return t;const r=t.closest(E);return r instanceof HTMLElement&&r.parentElement===e?r:t}function v(e,n){if(typeof e.intersectsNode=="function")try{return e.intersectsNode(n)}catch{return!1}const t=document.createRange();return t.selectNode(n),e.compareBoundaryPoints(Range.END_TO_START,t)<0&&e.compareBoundaryPoints(Range.START_TO_END,t)>0}function w(e,n){const t=T(e,n.startContainer),r=T(e,n.endContainer);if(!t)return[];if(!r||t===r)return[t];const o=Array.from(e.children).filter(a=>a instanceof HTMLElement).filter(a=>v(n,a));return o.length>0?o:[t]}function A(e,n){Array.from(e.attributes).forEach(t=>{n.setAttribute(t.name,t.value)})}function p(e,n){for(;e.firstChild;)n.appendChild(e.firstChild)}function R(e){return e.tagName!=="P"||e.attributes.length>0||(e.textContent||"").trim()!==""?!1:!e.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function d(e,n){const t=document.createElement(e);return n&&A(n,t),t}function C(e,n){const t=d(n,e);return p(e,t),t.innerHTML.trim()||(t.innerHTML="<br>"),t}function _(e){const n=e.cloneNode(!1);return n instanceof HTMLElement?n:document.createElement(e.tagName.toLowerCase())}function L(e,n,t){const r=e.parentNode;if(!r)return[];const s=document.createDocumentFragment(),o=[];let a=null;const i=()=>{a&&a.children.length>0&&s.appendChild(a),a=null};return Array.from(e.children).forEach(c=>{if(c instanceof HTMLLIElement){if(n.has(c)){i();const u=C(c,t);s.appendChild(u),o.push(u);return}a||(a=_(e)),a.appendChild(c)}}),i(),r.insertBefore(s,e),r.removeChild(e),o}function I(e,n){if(e.tagName.toLowerCase()===n)return[e];const t=d(n,e);return p(e,t),t.innerHTML.trim()||(t.innerHTML="<br>"),e.parentNode?.replaceChild(t,e),[t]}function O(e,n){const t=e.parentNode;if(!t)return[];const r=document.createDocumentFragment(),s=[];return Array.from(e.childNodes).forEach(o=>{if(o instanceof HTMLElement&&R(o)){o.remove();return}if(o instanceof HTMLUListElement||o instanceof HTMLOListElement){Array.from(o.children).forEach(i=>{if(!(i instanceof HTMLLIElement))return;const c=C(i,n);r.appendChild(c),s.push(c)}),o.remove();return}if(o instanceof HTMLElement&&g.has(o.tagName)){const i=d(n,o);p(o,i),r.appendChild(i),s.push(i);return}if(o.nodeType===Node.TEXT_NODE&&(o.textContent||"").trim()===""){o.remove();return}const a=d(n,e);a.appendChild(o),r.appendChild(a),s.push(a)}),t.insertBefore(r,e),t.removeChild(e),s}function b(e){const n=window.getSelection();if(!n)return;const t=document.createRange(),r=e instanceof HTMLElement&&e.querySelector("p,li,h1,h2,h3,h4,h5,h6")||e;t.selectNodeContents(r),t.collapse(!0),n.removeAllRanges(),n.addRange(t)}function k(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function P(e,n,t){const r=window.execEditorCommand;if(typeof r=="function"){r("recordDomTransaction",e,n,t);return}const s=window.executeEditorCommand;typeof s=="function"&&s("recordDomTransaction",{editor:e,beforeHTML:n,afterHTML:t})}function x(e,n){const t=new Map;return Array.from(e.querySelectorAll("li")).filter(s=>s instanceof HTMLLIElement&&v(n,s)).forEach(s=>{const o=s.parentElement;(o instanceof HTMLUListElement||o instanceof HTMLOListElement)&&o.parentElement===e&&(t.has(o)||t.set(o,new Set),t.get(o)?.add(s))}),t}function m(e,n){const t=e.toLowerCase();if(!B.has(t))return!1;const r=S(n);if(!r)return!1;const s=N(r);if(!s)return!1;const o=r.innerHTML,a=[],i=x(r,s);i.size>0?i.forEach((u,l)=>{a.push(...L(l,u,t))}):w(r,s).forEach(l=>{if(l instanceof HTMLUListElement||l instanceof HTMLOListElement){const h=new Set(Array.from(l.children).filter(M=>M instanceof HTMLLIElement));a.push(...L(l,h,t));return}if(g.has(l.tagName)){const h=l.querySelector(":scope > ul, :scope > ol, :scope > blockquote, :scope > table");a.push(...h?O(l,t):I(l,t))}});const c=r.innerHTML;return o===c||a.length===0?!1:(P(r,o,c),k(r),b(a[0]),!0)}const D=()=>({name:"heading",toolbar:[{label:"P",command:"setBlockType",type:"dropdown",options:[{value:"p",label:"P"},{value:"h1",label:"H1"},{value:"h2",label:"H2"},{value:"h3",label:"H3"},{value:"h4",label:"H4"},{value:"h5",label:"H5"},{value:"h6",label:"H6"}],icon:'<svg width="24" height="24" focusable="false"><path d="M16.1 8.6 14.2 4l-1.4.5 2.8 7.4c.1.4.5.6.9.6h.1c.4-.1.6-.5.6-.9l1.8-4.8-1.4-.5-1.5 2.3ZM4 11.5h6V10H4v1.5ZM18.5 3v1L17 7l.9.9L20.7 3h-2.2ZM5.5 12h1v7h1v-7h1v-.5h-3V12Zm4 0h1v7h1v-7h1v-.5h-3V12Zm10 1.5a2 2 0 0 0-2-2h-1v7.5h1v-2.7h1a2 2 0 0 0 2-2v-.8Zm-2 1.3h-1v-2.3h1a.8.8 0 1 1 0 1.6v.7Z" fill-rule="evenodd"></path></svg>'}],commands:{setBlockType:(e,n)=>e?m(e,n):!1,setHeading1:(e,n)=>m("h1",n),setHeading2:(e,n)=>m("h2",n),setHeading3:(e,n)=>m("h3",n),setParagraph:(e,n)=>m("p",n)},keymap:{"Mod-Alt-1":"setHeading1","Mod-Alt-2":"setHeading2","Mod-Alt-3":"setHeading3","Mod-Alt-0":"setParagraph"}});exports.HeadingPlugin=D;

@@ -1,63 +0,246 @@

const t = () => {
const e = (a) => {
const f = '.rte-content, .editora-content, [contenteditable="true"]', y = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", g = /* @__PURE__ */ new Set(["P", "DIV", "H1", "H2", "H3", "H4", "H5", "H6", "PRE"]), E = "p,div,h1,h2,h3,h4,h5,h6,ul,ol,blockquote,pre,table", B = /* @__PURE__ */ new Set(["p", "h1", "h2", "h3", "h4", "h5", "h6"]);
function H(e) {
return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
}
function S(e) {
const n = e?.contentElement;
if (n instanceof HTMLElement) return n;
const t = e?.editorElement;
if (t instanceof HTMLElement) {
const a = t.querySelector(f);
if (a instanceof HTMLElement) return a;
if (t.getAttribute("contenteditable") === "true") return t;
}
const r = window.getSelection();
if (r && r.rangeCount > 0) {
const a = H(r.getRangeAt(0).startContainer), c = a?.closest(f);
if (c instanceof HTMLElement) return c;
const u = a?.closest(y)?.querySelector(f);
if (u instanceof HTMLElement) return u;
}
const o = document.activeElement?.closest(f);
return o instanceof HTMLElement ? o : document.querySelector(f);
}
function N(e) {
const n = window.getSelection();
if (!n || n.rangeCount === 0) return null;
const t = n.getRangeAt(0);
return !e.contains(t.startContainer) || !e.contains(t.endContainer) ? null : t;
}
function T(e, n) {
let t = H(n);
if (!t || t === e || !e.contains(t)) return null;
for (; t.parentElement && t.parentElement !== e; )
t = t.parentElement;
if (t.parentElement !== e) return null;
if (t.matches(E)) return t;
const r = t.closest(E);
return r instanceof HTMLElement && r.parentElement === e ? r : t;
}
function v(e, n) {
if (typeof e.intersectsNode == "function")
try {
return document.execCommand("formatBlock", !1, a), !0;
} catch (l) {
return console.error(`Failed to set block type to ${a}:`, l), !1;
return e.intersectsNode(n);
} catch {
return !1;
}
const t = document.createRange();
return t.selectNode(n), e.compareBoundaryPoints(Range.END_TO_START, t) < 0 && e.compareBoundaryPoints(Range.START_TO_END, t) > 0;
}
function w(e, n) {
const t = T(e, n.startContainer), r = T(e, n.endContainer);
if (!t) return [];
if (!r || t === r) return [t];
const o = Array.from(e.children).filter(
(a) => a instanceof HTMLElement
).filter((a) => v(n, a));
return o.length > 0 ? o : [t];
}
function A(e, n) {
Array.from(e.attributes).forEach((t) => {
n.setAttribute(t.name, t.value);
});
}
function p(e, n) {
for (; e.firstChild; )
n.appendChild(e.firstChild);
}
function R(e) {
return e.tagName !== "P" || e.attributes.length > 0 || (e.textContent || "").trim() !== "" ? !1 : !e.querySelector("img, video, table, iframe, hr, pre, ul, ol");
}
function d(e, n) {
const t = document.createElement(e);
return n && A(n, t), t;
}
function C(e, n) {
const t = d(n, e);
return p(e, t), t.innerHTML.trim() || (t.innerHTML = "<br>"), t;
}
function I(e) {
const n = e.cloneNode(!1);
return n instanceof HTMLElement ? n : document.createElement(e.tagName.toLowerCase());
}
function L(e, n, t) {
const r = e.parentNode;
if (!r) return [];
const s = document.createDocumentFragment(), o = [];
let a = null;
const c = () => {
a && a.children.length > 0 && s.appendChild(a), a = null;
};
return {
name: "heading",
// Toolbar button configuration with dropdown
toolbar: [
{
label: "Heading",
command: "setBlockType",
type: "dropdown",
options: [
{ value: "p", label: "Paragraph" },
{ value: "h1", label: "Heading 1" },
{ value: "h2", label: "Heading 2" },
{ value: "h3", label: "Heading 3" },
{ value: "h4", label: "Heading 4" },
{ value: "h5", label: "Heading 5" },
{ value: "h6", label: "Heading 6" }
],
icon: '<svg width="24" height="24" focusable="false"><path d="M16.1 8.6 14.2 4l-1.4.5 2.8 7.4c.1.4.5.6.9.6h.1c.4-.1.6-.5.6-.9l1.8-4.8-1.4-.5-1.5 2.3ZM4 11.5h6V10H4v1.5ZM18.5 3v1L17 7l.9.9L20.7 3h-2.2ZM5.5 12h1v7h1v-7h1v-.5h-3V12Zm4 0h1v7h1v-7h1v-.5h-3V12Zm10 1.5a2 2 0 0 0-2-2h-1v7.5h1v-2.7h1a2 2 0 0 0 2-2v-.8Zm-2 1.3h-1v-2.3h1a.8.8 0 1 1 0 1.6v.7Z" fill-rule="evenodd"></path></svg>'
return Array.from(e.children).forEach((i) => {
if (i instanceof HTMLLIElement) {
if (n.has(i)) {
c();
const u = C(i, t);
s.appendChild(u), o.push(u);
return;
}
],
// Native command implementations
commands: {
/**
* Set block type to specific heading level or paragraph
*/
setBlockType: (a) => a ? e(a) : !1,
/**
* Set heading level 1
*/
setHeading1: () => e("h1"),
/**
* Set heading level 2
*/
setHeading2: () => e("h2"),
/**
* Set heading level 3
*/
setHeading3: () => e("h3"),
/**
* Set to paragraph
*/
setParagraph: () => e("p")
},
// Keyboard shortcuts
keymap: {
"Mod-Alt-1": "setHeading1",
"Mod-Alt-2": "setHeading2",
"Mod-Alt-3": "setHeading3",
"Mod-Alt-0": "setParagraph"
a || (a = I(e)), a.appendChild(i);
}
};
};
}), c(), r.insertBefore(s, e), r.removeChild(e), o;
}
function _(e, n) {
if (e.tagName.toLowerCase() === n) return [e];
const t = d(n, e);
return p(e, t), t.innerHTML.trim() || (t.innerHTML = "<br>"), e.parentNode?.replaceChild(t, e), [t];
}
function O(e, n) {
const t = e.parentNode;
if (!t) return [];
const r = document.createDocumentFragment(), s = [];
return Array.from(e.childNodes).forEach((o) => {
if (o instanceof HTMLElement && R(o)) {
o.remove();
return;
}
if (o instanceof HTMLUListElement || o instanceof HTMLOListElement) {
Array.from(o.children).forEach((c) => {
if (!(c instanceof HTMLLIElement)) return;
const i = C(c, n);
r.appendChild(i), s.push(i);
}), o.remove();
return;
}
if (o instanceof HTMLElement && g.has(o.tagName)) {
const c = d(n, o);
p(o, c), r.appendChild(c), s.push(c);
return;
}
if (o.nodeType === Node.TEXT_NODE && (o.textContent || "").trim() === "") {
o.remove();
return;
}
const a = d(n, e);
a.appendChild(o), r.appendChild(a), s.push(a);
}), t.insertBefore(r, e), t.removeChild(e), s;
}
function b(e) {
const n = window.getSelection();
if (!n) return;
const t = document.createRange(), r = e instanceof HTMLElement && e.querySelector("p,li,h1,h2,h3,h4,h5,h6") || e;
t.selectNodeContents(r), t.collapse(!0), n.removeAllRanges(), n.addRange(t);
}
function k(e) {
e.dispatchEvent(new Event("input", { bubbles: !0 }));
}
function x(e, n, t) {
const r = window.execEditorCommand;
if (typeof r == "function") {
r("recordDomTransaction", e, n, t);
return;
}
const s = window.executeEditorCommand;
typeof s == "function" && s("recordDomTransaction", { editor: e, beforeHTML: n, afterHTML: t });
}
function D(e, n) {
const t = /* @__PURE__ */ new Map();
return Array.from(e.querySelectorAll("li")).filter(
(s) => s instanceof HTMLLIElement && v(n, s)
).forEach((s) => {
const o = s.parentElement;
(o instanceof HTMLUListElement || o instanceof HTMLOListElement) && o.parentElement === e && (t.has(o) || t.set(o, /* @__PURE__ */ new Set()), t.get(o)?.add(s));
}), t;
}
function m(e, n) {
const t = e.toLowerCase();
if (!B.has(t)) return !1;
const r = S(n);
if (!r) return !1;
const s = N(r);
if (!s) return !1;
const o = r.innerHTML, a = [], c = D(r, s);
c.size > 0 ? c.forEach((u, l) => {
a.push(...L(l, u, t));
}) : w(r, s).forEach((l) => {
if (l instanceof HTMLUListElement || l instanceof HTMLOListElement) {
const h = new Set(Array.from(l.children).filter(
(M) => M instanceof HTMLLIElement
));
a.push(...L(l, h, t));
return;
}
if (g.has(l.tagName)) {
const h = l.querySelector(":scope > ul, :scope > ol, :scope > blockquote, :scope > table");
a.push(
...h ? O(l, t) : _(l, t)
);
}
});
const i = r.innerHTML;
return o === i || a.length === 0 ? !1 : (x(r, o, i), k(r), b(a[0]), !0);
}
const P = () => ({
name: "heading",
// Toolbar button configuration with dropdown
toolbar: [
{
label: "P",
command: "setBlockType",
type: "dropdown",
options: [
{ value: "p", label: "P" },
{ value: "h1", label: "H1" },
{ value: "h2", label: "H2" },
{ value: "h3", label: "H3" },
{ value: "h4", label: "H4" },
{ value: "h5", label: "H5" },
{ value: "h6", label: "H6" }
],
icon: '<svg width="24" height="24" focusable="false"><path d="M16.1 8.6 14.2 4l-1.4.5 2.8 7.4c.1.4.5.6.9.6h.1c.4-.1.6-.5.6-.9l1.8-4.8-1.4-.5-1.5 2.3ZM4 11.5h6V10H4v1.5ZM18.5 3v1L17 7l.9.9L20.7 3h-2.2ZM5.5 12h1v7h1v-7h1v-.5h-3V12Zm4 0h1v7h1v-7h1v-.5h-3V12Zm10 1.5a2 2 0 0 0-2-2h-1v7.5h1v-2.7h1a2 2 0 0 0 2-2v-.8Zm-2 1.3h-1v-2.3h1a.8.8 0 1 1 0 1.6v.7Z" fill-rule="evenodd"></path></svg>'
}
],
// Native command implementations
commands: {
/**
* Set block type to specific heading level or paragraph
*/
setBlockType: (e, n) => e ? m(e, n) : !1,
/**
* Set heading level 1
*/
setHeading1: (e, n) => m("h1", n),
/**
* Set heading level 2
*/
setHeading2: (e, n) => m("h2", n),
/**
* Set heading level 3
*/
setHeading3: (e, n) => m("h3", n),
/**
* Set to paragraph
*/
setParagraph: (e, n) => m("p", n)
},
// Keyboard shortcuts
keymap: {
"Mod-Alt-1": "setHeading1",
"Mod-Alt-2": "setHeading2",
"Mod-Alt-3": "setHeading3",
"Mod-Alt-0": "setParagraph"
}
});
export {
t as HeadingPlugin
P as HeadingPlugin
};

@@ -1,1 +0,1 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=".rte-content, .editora-content",y=100,M="__editoraCommandEditorRoot",d=new Map,E={};let T=!1,c=null;function I(t){if(!t)return null;const e=t.querySelector('[contenteditable="true"]');return e instanceof HTMLElement?e:null}function z(){if(typeof window>"u")return null;const t=window[M];if(!(t instanceof HTMLElement))return null;window[M]=null;const e=t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(t.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?t:null);if(e){const o=I(e);if(o)return o;if(e.getAttribute("contenteditable")==="true")return e}if(t.getAttribute("contenteditable")==="true")return t;const n=t.closest('[contenteditable="true"]');return n instanceof HTMLElement?n:null}function F(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function a(t){const e=F(t);if(!e)return null;const n=e.closest(v);if(n)return n;const o=e.closest('[contenteditable="true"]');if(!o)return null;let r=o,i=r.parentElement;for(;i;)i.getAttribute("contenteditable")==="true"&&(r=i),i=i.parentElement;return r}function l(){const t=z();if(t&&document.contains(t))return t;const e=window.getSelection();if(e&&e.rangeCount>0){const i=a(e.getRangeAt(0).startContainer);if(i)return i}const n=document.activeElement;if(n){const i=a(n);if(i)return i}if(c?.isConnected)return c;const o=Array.from(d.keys()).find(i=>i.isConnected);if(o)return o;const r=document.querySelector(v);return r||document.querySelector('[contenteditable="true"]')}function A(){for(const t of d.keys())t.isConnected||(d.delete(t),c===t&&(c=null))}function C(t){A();let e=d.get(t);return e||(e={undoStack:[],redoStack:[]},d.set(t,e)),e}function s(t){t&&t.dispatchEvent(new Event("input",{bubbles:!0}))}function h(t){return t?t.innerHTML:""}function m(t,e){if(!t)return;const n=C(t);n.undoStack.push(e),n.redoStack.length=0,n.undoStack.length>y&&n.undoStack.splice(0,n.undoStack.length-y),c=t}function L(t,e="undo"){if(A(),t?.isConnected)return t;const n=l();if(n?.isConnected)return n;if(c?.isConnected)return c;const o=r=>e==="undo"?r.undoStack.length>0:r.redoStack.length>0;for(const[r,i]of d.entries())if(r.isConnected&&o(i))return r;return null}function w(t){const e={};for(const r of t.getAttributeNames()){const i=t.getAttribute(r);i!==null&&(e[r]=i)}const n=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement,o=t instanceof HTMLInputElement;return{attributes:e,innerHTML:t.innerHTML,value:n?t.value:null,checked:o?t.checked:null}}function H(t,e){const n=new Set(t.getAttributeNames());Object.keys(e.attributes).forEach(o=>n.delete(o)),n.forEach(o=>t.removeAttribute(o)),Object.entries(e.attributes).forEach(([o,r])=>{t.setAttribute(o,r)}),t.innerHTML!==e.innerHTML&&(t.innerHTML=e.innerHTML),e.value!==null&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&(t.value=e.value),e.checked!==null&&t instanceof HTMLInputElement&&(t.checked=e.checked)}function u(t,e){if(E[t]=e,typeof window>"u")return;const n=window.registerEditorCommand;typeof n=="function"?n(t,e):(window.registerEditorCommand=(o,r)=>{E[o]=r},window.registerEditorCommand(t,e))}const S=(t,...e)=>{const n=E[t];return n?n(...e):!1};function p(){T||typeof window>"u"||(T=!0,window.execEditorCommand||(window.execEditorCommand=S),window.executeEditorCommand||(window.executeEditorCommand=S),u("undo",k),u("redo",D),u("setAttribute",O),u("setText",_),u("autoFixA11y",N),u("recordDomTransaction",R),u("undoDom",b),u("redoDom",g))}function x(t,e){const n=e||l(),o=h(n);n?.focus({preventScroll:!0});let r=!1;try{r=!!document.execCommand(t,!1)}catch{r=!1}const i=h(n),f=o!==i;return f&&s(n),{executed:r,changed:f}}const k=()=>{const t=l();return x("undo",t).changed?!0:b(t??void 0)},D=()=>{const t=l();return x("redo",t).changed?!0:g(t??void 0)},O=(t,e,n)=>{if(!(t instanceof HTMLElement))return;const o=a(t),r=t.hasAttribute(e),i=t.getAttribute(e);t.setAttribute(e,n),m(o,{undo:()=>{t.isConnected&&(r&&i!==null?t.setAttribute(e,i):t.removeAttribute(e))},redo:()=>{t.isConnected&&t.setAttribute(e,n)}}),s(o)},_=(t,e)=>{if(!(t instanceof HTMLElement))return;const n=a(t),o=t.textContent??"";t.textContent=e,m(n,{undo:()=>{t.isConnected&&(t.textContent=o)},redo:()=>{t.isConnected&&(t.textContent=e)}}),s(n)},N=t=>{const e=t?.element;if(!(e instanceof HTMLElement))return;const n=a(e),o=window.a11yRuleRegistry?.find(f=>f.id===t.rule);if(!o||typeof o.fix!="function")return;const r=w(e);o.fix(t);const i=w(e);m(n,{undo:()=>{e.isConnected&&H(e,r)},redo:()=>{e.isConnected&&H(e,i)}}),s(n)},R=(t,e,n)=>{if(!(t instanceof HTMLElement))return!1;const o=typeof n=="string"?n:t.innerHTML;return e===o?!1:(m(t,{undo:()=>{t.isConnected&&(t.innerHTML=e)},redo:()=>{t.isConnected&&(t.innerHTML=o)}}),!0)},b=t=>{const e=L(t,"undo");if(!e)return!1;const n=C(e),o=n.undoStack.pop();return o?(o.undo(),n.redoStack.push(o),c=e,s(e),!0):!1},g=t=>{const e=L(t,"redo");if(!e)return!1;const n=C(e),o=n.redoStack.pop();return o?(o.redo(),n.undoStack.push(o),c=e,s(e),!0):!1};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",p,{once:!0}):p());const Z=()=>(p(),{name:"history",toolbar:[{label:"Undo",command:"undo",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M6.4 8H12c3.7 0 6.2 2 6.8 5.1.6 2.7-.4 5.6-2.3 6.8a1 1 0 0 1-1-1.8c1.1-.6 1.8-2.7 1.4-4.6-.5-2.1-2.1-3.5-4.9-3.5H6.4l3.3 3.3a1 1 0 1 1-1.4 1.4l-5-5a1 1 0 0 1 0-1.4l5-5a1 1 0 0 1 1.4 1.4L6.4 8Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-z"},{label:"Redo",command:"redo",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M17.6 10H12c-2.8 0-4.4 1.4-4.9 3.5-.4 2 .3 4 1.4 4.6a1 1 0 1 1-1 1.8c-2-1.2-2.9-4.1-2.3-6.8.6-3 3-5.1 6.8-5.1h5.6l-3.3-3.3a1 1 0 1 1 1.4-1.4l5 5a1 1 0 0 1 0 1.4l-5 5a1 1 0 0 1-1.4-1.4l3.3-3.3Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-y"}],commands:{undo:k,redo:D,setAttribute:O,setText:_,autoFixA11y:N,recordDomTransaction:R,undoDom:b,redoDom:g},keymap:{"Mod-z":"undo","Mod-Z":"undo","Mod-y":"redo","Mod-Y":"redo","Mod-Shift-z":"redo","Mod-Shift-Z":"redo"}});exports.HistoryPlugin=Z;
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const H=".rte-content, .editora-content",M=100,T="__editoraCommandEditorRoot",d=new Map,l={};let g=!1,c=null;function N(t){if(!t)return null;const e=t.querySelector('[contenteditable="true"]');return e instanceof HTMLElement?e:null}function R(){if(typeof window>"u")return null;const t=window[T];if(!(t instanceof HTMLElement))return null;window[T]=null;const e=t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(t.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?t:null);if(e){const o=N(e);if(o)return o;if(e.getAttribute("contenteditable")==="true")return e}if(t.getAttribute("contenteditable")==="true")return t;const n=t.closest('[contenteditable="true"]');return n instanceof HTMLElement?n:null}function I(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function s(t){const e=I(t);if(!e)return null;const n=e.closest(H);if(n)return n;const o=e.closest('[contenteditable="true"]');if(!o)return null;let r=o,i=r.parentElement;for(;i;)i.getAttribute("contenteditable")==="true"&&(r=i),i=i.parentElement;return r}function E(){const t=R();if(t&&document.contains(t))return t;const e=window.getSelection();if(e&&e.rangeCount>0){const i=s(e.getRangeAt(0).startContainer);if(i)return i}const n=document.activeElement;if(n){const i=s(n);if(i)return i}if(c?.isConnected)return c;const o=Array.from(d.keys()).find(i=>i.isConnected);if(o)return o;const r=document.querySelector(H);return r||document.querySelector('[contenteditable="true"]')}function S(){for(const t of d.keys())t.isConnected||(d.delete(t),c===t&&(c=null))}function b(t){S();let e=d.get(t);return e||(e={undoStack:[],redoStack:[]},d.set(t,e)),e}function a(t){t&&t.dispatchEvent(new Event("input",{bubbles:!0}))}function f(t,e){if(!t)return;const n=b(t);n.undoStack.push(e),n.redoStack.length=0,n.undoStack.length>M&&n.undoStack.splice(0,n.undoStack.length-M),c=t}function A(t,e="undo"){if(S(),t?.isConnected)return t;const n=E();if(n?.isConnected)return n;if(c?.isConnected)return c;const o=r=>e==="undo"?r.undoStack.length>0:r.redoStack.length>0;for(const[r,i]of d.entries())if(r.isConnected&&o(i))return r;return null}function y(t){const e={};for(const r of t.getAttributeNames()){const i=t.getAttribute(r);i!==null&&(e[r]=i)}const n=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement,o=t instanceof HTMLInputElement;return{attributes:e,innerHTML:t.innerHTML,value:n?t.value:null,checked:o?t.checked:null}}function w(t,e){const n=new Set(t.getAttributeNames());Object.keys(e.attributes).forEach(o=>n.delete(o)),n.forEach(o=>t.removeAttribute(o)),Object.entries(e.attributes).forEach(([o,r])=>{t.setAttribute(o,r)}),t.innerHTML!==e.innerHTML&&(t.innerHTML=e.innerHTML),e.value!==null&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&(t.value=e.value),e.checked!==null&&t instanceof HTMLInputElement&&(t.checked=e.checked)}function u(t,e){if(l[t]=e,typeof window>"u")return;const n=window.registerEditorCommand;typeof n=="function"?n(t,e):(window.registerEditorCommand=(o,r)=>{l[o]=r},window.registerEditorCommand(t,e))}const h=(t,...e)=>{const n=l[t];return n?n(...e):!1};function m(){g||typeof window>"u"||(g=!0,window.execEditorCommand||(window.execEditorCommand=h),window.executeEditorCommand||(window.executeEditorCommand=h),u("undo",L),u("redo",v),u("setAttribute",k),u("setText",x),u("autoFixA11y",D),u("recordDomTransaction",O),u("undoDom",p),u("redoDom",C))}const L=()=>{const t=E();return p(t??void 0)},v=()=>{const t=E();return C(t??void 0)},k=(t,e,n)=>{if(!(t instanceof HTMLElement))return;const o=s(t),r=t.hasAttribute(e),i=t.getAttribute(e);t.setAttribute(e,n),f(o,{undo:()=>{t.isConnected&&(r&&i!==null?t.setAttribute(e,i):t.removeAttribute(e))},redo:()=>{t.isConnected&&t.setAttribute(e,n)}}),a(o)},x=(t,e)=>{if(!(t instanceof HTMLElement))return;const n=s(t),o=t.textContent??"";t.textContent=e,f(n,{undo:()=>{t.isConnected&&(t.textContent=o)},redo:()=>{t.isConnected&&(t.textContent=e)}}),a(n)},D=t=>{const e=t?.element;if(!(e instanceof HTMLElement))return;const n=s(e),o=window.a11yRuleRegistry?.find(_=>_.id===t.rule);if(!o||typeof o.fix!="function")return;const r=y(e);o.fix(t);const i=y(e);f(n,{undo:()=>{e.isConnected&&w(e,r)},redo:()=>{e.isConnected&&w(e,i)}}),a(n)},O=(t,e,n)=>{if(!(t instanceof HTMLElement))return!1;const o=typeof n=="string"?n:t.innerHTML;return e===o?!1:(f(t,{undo:()=>{t.isConnected&&(t.innerHTML=e)},redo:()=>{t.isConnected&&(t.innerHTML=o)}}),!0)},p=t=>{const e=A(t,"undo");if(!e)return!1;const n=b(e),o=n.undoStack.pop();return o?(o.undo(),n.redoStack.push(o),c=e,a(e),!0):!1},C=t=>{const e=A(t,"redo");if(!e)return!1;const n=b(e),o=n.redoStack.pop();return o?(o.redo(),n.undoStack.push(o),c=e,a(e),!0):!1};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",m,{once:!0}):m());const z=()=>(m(),{name:"history",toolbar:[{label:"Undo",command:"undo",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M6.4 8H12c3.7 0 6.2 2 6.8 5.1.6 2.7-.4 5.6-2.3 6.8a1 1 0 0 1-1-1.8c1.1-.6 1.8-2.7 1.4-4.6-.5-2.1-2.1-3.5-4.9-3.5H6.4l3.3 3.3a1 1 0 1 1-1.4 1.4l-5-5a1 1 0 0 1 0-1.4l5-5a1 1 0 0 1 1.4 1.4L6.4 8Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-z"},{label:"Redo",command:"redo",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M17.6 10H12c-2.8 0-4.4 1.4-4.9 3.5-.4 2 .3 4 1.4 4.6a1 1 0 1 1-1 1.8c-2-1.2-2.9-4.1-2.3-6.8.6-3 3-5.1 6.8-5.1h5.6l-3.3-3.3a1 1 0 1 1 1.4-1.4l5 5a1 1 0 0 1 0 1.4l-5 5a1 1 0 0 1-1.4-1.4l3.3-3.3Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-y"}],commands:{undo:L,redo:v,setAttribute:k,setText:x,autoFixA11y:D,recordDomTransaction:O,undoDom:p,redoDom:C},keymap:{"Mod-z":"undo","Mod-Z":"undo","Mod-y":"redo","Mod-Y":"redo","Mod-Shift-z":"redo","Mod-Shift-Z":"redo"}});exports.HistoryPlugin=z;

@@ -1,5 +0,5 @@

const S = ".rte-content, .editora-content";
const T = "__editoraCommandEditorRoot", d = /* @__PURE__ */ new Map(), E = {};
let g = !1, c = null;
function I(t) {
const H = ".rte-content, .editora-content";
const b = "__editoraCommandEditorRoot", d = /* @__PURE__ */ new Map(), l = {};
let T = !1, c = null;
function _(t) {
if (!t) return null;

@@ -9,10 +9,10 @@ const e = t.querySelector('[contenteditable="true"]');

}
function N() {
function R() {
if (typeof window > "u") return null;
const t = window[T];
const t = window[b];
if (!(t instanceof HTMLElement)) return null;
window[T] = null;
window[b] = null;
const e = t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (t.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? t : null);
if (e) {
const o = I(e);
const o = _(e);
if (o) return o;

@@ -26,9 +26,9 @@ if (e.getAttribute("contenteditable") === "true") return e;

}
function z(t) {
function I(t) {
return t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null;
}
function a(t) {
const e = z(t);
function s(t) {
const e = I(t);
if (!e) return null;
const n = e.closest(S);
const n = e.closest(H);
if (n) return n;

@@ -42,4 +42,4 @@ const o = e.closest('[contenteditable="true"]');

}
function l() {
const t = N();
function E() {
const t = R();
if (t && document.contains(t))

@@ -49,3 +49,3 @@ return t;

if (e && e.rangeCount > 0) {
const i = a(e.getRangeAt(0).startContainer);
const i = s(e.getRangeAt(0).startContainer);
if (i) return i;

@@ -55,3 +55,3 @@ }

if (n) {
const i = a(n);
const i = s(n);
if (i) return i;

@@ -62,29 +62,26 @@ }

if (o) return o;
const r = document.querySelector(S);
const r = document.querySelector(H);
return r || document.querySelector('[contenteditable="true"]');
}
function v() {
function h() {
for (const t of d.keys())
t.isConnected || (d.delete(t), c === t && (c = null));
}
function C(t) {
v();
function p(t) {
h();
let e = d.get(t);
return e || (e = { undoStack: [], redoStack: [] }, d.set(t, e)), e;
}
function s(t) {
function a(t) {
t && t.dispatchEvent(new Event("input", { bubbles: !0 }));
}
function h(t) {
return t ? t.innerHTML : "";
}
function m(t, e) {
function f(t, e) {
if (!t) return;
const n = C(t);
const n = p(t);
n.undoStack.push(e), n.redoStack.length = 0, n.undoStack.length > 100 && n.undoStack.splice(0, n.undoStack.length - 100), c = t;
}
function A(t, e = "undo") {
if (v(), t?.isConnected)
function S(t, e = "undo") {
if (h(), t?.isConnected)
return t;
const n = l();
const n = E();
if (n?.isConnected)

@@ -114,3 +111,3 @@ return n;

}
function H(t, e) {
function g(t, e) {
const n = new Set(t.getAttributeNames());

@@ -122,37 +119,25 @@ Object.keys(e.attributes).forEach((o) => n.delete(o)), n.forEach((o) => t.removeAttribute(o)), Object.entries(e.attributes).forEach(([o, r]) => {

function u(t, e) {
if (E[t] = e, typeof window > "u") return;
if (l[t] = e, typeof window > "u") return;
const n = window.registerEditorCommand;
typeof n == "function" ? n(t, e) : (window.registerEditorCommand = (o, r) => {
E[o] = r;
l[o] = r;
}, window.registerEditorCommand(t, e));
}
const w = (t, ...e) => {
const n = E[t];
const n = l[t];
return n ? n(...e) : !1;
};
function p() {
g || typeof window > "u" || (g = !0, window.execEditorCommand || (window.execEditorCommand = w), window.executeEditorCommand || (window.executeEditorCommand = w), u("undo", x), u("redo", k), u("setAttribute", O), u("setText", D), u("autoFixA11y", _), u("recordDomTransaction", R), u("undoDom", M), u("redoDom", b));
function m() {
T || typeof window > "u" || (T = !0, window.execEditorCommand || (window.execEditorCommand = w), window.executeEditorCommand || (window.executeEditorCommand = w), u("undo", A), u("redo", L), u("setAttribute", v), u("setText", x), u("autoFixA11y", k), u("recordDomTransaction", O), u("undoDom", C), u("redoDom", M));
}
function L(t, e) {
const n = e || l(), o = h(n);
n?.focus({ preventScroll: !0 });
let r = !1;
try {
r = !!document.execCommand(t, !1);
} catch {
r = !1;
}
const i = h(n), f = o !== i;
return f && s(n), { executed: r, changed: f };
}
const x = () => {
const t = l();
return L("undo", t).changed ? !0 : M(t ?? void 0);
}, k = () => {
const t = l();
return L("redo", t).changed ? !0 : b(t ?? void 0);
}, O = (t, e, n) => {
const A = () => {
const t = E();
return C(t ?? void 0);
}, L = () => {
const t = E();
return M(t ?? void 0);
}, v = (t, e, n) => {
if (!(t instanceof HTMLElement)) return;
const o = a(t), r = t.hasAttribute(e), i = t.getAttribute(e);
t.setAttribute(e, n), m(o, {
const o = s(t), r = t.hasAttribute(e), i = t.getAttribute(e);
t.setAttribute(e, n), f(o, {
undo: () => {

@@ -164,7 +149,7 @@ t.isConnected && (r && i !== null ? t.setAttribute(e, i) : t.removeAttribute(e));

}
}), s(o);
}, D = (t, e) => {
}), a(o);
}, x = (t, e) => {
if (!(t instanceof HTMLElement)) return;
const n = a(t), o = t.textContent ?? "";
t.textContent = e, m(n, {
const n = s(t), o = t.textContent ?? "";
t.textContent = e, f(n, {
undo: () => {

@@ -176,7 +161,7 @@ t.isConnected && (t.textContent = o);

}
}), s(n);
}, _ = (t) => {
}), a(n);
}, k = (t) => {
const e = t?.element;
if (!(e instanceof HTMLElement)) return;
const n = a(e), o = window.a11yRuleRegistry?.find((f) => f.id === t.rule);
const n = s(e), o = window.a11yRuleRegistry?.find((D) => D.id === t.rule);
if (!o || typeof o.fix != "function") return;

@@ -186,14 +171,14 @@ const r = y(e);

const i = y(e);
m(n, {
f(n, {
undo: () => {
e.isConnected && H(e, r);
e.isConnected && g(e, r);
},
redo: () => {
e.isConnected && H(e, i);
e.isConnected && g(e, i);
}
}), s(n);
}, R = (t, e, n) => {
}), a(n);
}, O = (t, e, n) => {
if (!(t instanceof HTMLElement)) return !1;
const o = typeof n == "string" ? n : t.innerHTML;
return e === o ? !1 : (m(t, {
return e === o ? !1 : (f(t, {
undo: () => {

@@ -206,15 +191,15 @@ t.isConnected && (t.innerHTML = e);

}), !0);
}, C = (t) => {
const e = S(t, "undo");
if (!e) return !1;
const n = p(e), o = n.undoStack.pop();
return o ? (o.undo(), n.redoStack.push(o), c = e, a(e), !0) : !1;
}, M = (t) => {
const e = A(t, "undo");
const e = S(t, "redo");
if (!e) return !1;
const n = C(e), o = n.undoStack.pop();
return o ? (o.undo(), n.redoStack.push(o), c = e, s(e), !0) : !1;
}, b = (t) => {
const e = A(t, "redo");
if (!e) return !1;
const n = C(e), o = n.redoStack.pop();
return o ? (o.redo(), n.undoStack.push(o), c = e, s(e), !0) : !1;
const n = p(e), o = n.redoStack.pop();
return o ? (o.redo(), n.undoStack.push(o), c = e, a(e), !0) : !1;
};
typeof window < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", p, { once: !0 }) : p());
const F = () => (p(), {
typeof window < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", m, { once: !0 }) : m());
const N = () => (m(), {
name: "history",

@@ -238,10 +223,10 @@ toolbar: [

commands: {
undo: x,
redo: k,
setAttribute: O,
setText: D,
autoFixA11y: _,
recordDomTransaction: R,
undoDom: M,
redoDom: b
undo: A,
redo: L,
setAttribute: v,
setText: x,
autoFixA11y: k,
recordDomTransaction: O,
undoDom: C,
redoDom: M
},

@@ -258,3 +243,3 @@ keymap: {

export {
F as HistoryPlugin
N as HistoryPlugin
};

@@ -1,1 +0,1 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=()=>(document.execCommand("italic",!1),!0),o=(i,l)=>{typeof window<"u"&&window.registerEditorCommand?.(i,l)},t=()=>{o("toggleItalic",e)};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):t());const a=()=>({name:"italic",marks:{italic:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"}],toDOM:()=>["em",0]}},toolbar:[{label:"Italic",command:"toggleItalic",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M16.7 4.7l-.1.9h-.3c-.6 0-1 0-1.4.3-.3.3-.4.6-.5 1.1l-2.1 9.8v.6c0 .5.4.8 1.4.8h.2l-.2.8H8l.2-.8h.2c1.1 0 1.8-.5 2-1.5l2-9.8.1-.5c0-.6-.4-.8-1.4-.8h-.3l.2-.9h5.8Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-i"}],commands:{toggleItalic:e},keymap:{"Mod-i":"toggleItalic","Mod-I":"toggleItalic"}});exports.ItalicPlugin=a;
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("./inlineFormatting-DOYOJdnD.js"),l=(e,t)=>o.applyInlineFormatting({command:"italic",context:t}),a=(e,t)=>{typeof window<"u"&&window.registerEditorCommand?.(e,t)},i=()=>{a("toggleItalic",l)};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",i):i());const n=()=>({name:"italic",marks:{italic:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"}],toDOM:()=>["em",0]}},toolbar:[{label:"Italic",command:"toggleItalic",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M16.7 4.7l-.1.9h-.3c-.6 0-1 0-1.4.3-.3.3-.4.6-.5 1.1l-2.1 9.8v.6c0 .5.4.8 1.4.8h.2l-.2.8H8l.2-.8h.2c1.1 0 1.8-.5 2-1.5l2-9.8.1-.5c0-.6-.4-.8-1.4-.8h-.3l.2-.9h5.8Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-i"}],commands:{toggleItalic:l},keymap:{"Mod-i":"toggleItalic","Mod-I":"toggleItalic"}});exports.ItalicPlugin=n;

@@ -1,8 +0,12 @@

const e = () => (document.execCommand("italic", !1), !0), l = (i, o) => {
typeof window < "u" && window.registerEditorCommand?.(i, o);
}, t = () => {
l("toggleItalic", e);
import { a } from "./inlineFormatting-DuVTGXYG.mjs";
const o = (e, t) => a({
command: "italic",
context: t
}), l = (e, t) => {
typeof window < "u" && window.registerEditorCommand?.(e, t);
}, i = () => {
l("toggleItalic", o);
};
typeof window < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", t) : t());
const a = () => ({
typeof window < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", i) : i());
const d = () => ({
name: "italic",

@@ -31,3 +35,3 @@ marks: {

commands: {
toggleItalic: e
toggleItalic: o
},

@@ -40,3 +44,3 @@ keymap: {

export {
a as ItalicPlugin
d as ItalicPlugin
};

@@ -1,5 +0,11 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const F={latex:[{name:"Fraction",formula:"\\frac{a}{b}",description:"Simple fraction"},{name:"Square Root",formula:"\\sqrt{x}",description:"Square root"},{name:"Power",formula:"x^{2}",description:"Exponent/power"},{name:"Subscript",formula:"x_{sub}",description:"Subscript"},{name:"Integral",formula:"\\int_{a}^{b} f(x) \\, dx",description:"Definite integral"},{name:"Summation",formula:"\\sum_{i=1}^{n} x_{i}",description:"Summation"},{name:"Limit",formula:"\\lim_{x \\to 0} f(x)",description:"Limit"},{name:"Derivative",formula:"\\frac{d}{dx} f(x)",description:"Derivative"},{name:"Matrix 2x2",formula:"\\begin{pmatrix} a & b \\\\ c & d \\end{pmatrix}",description:"2x2 matrix"},{name:"System",formula:"\\begin{cases} x + y = 1 \\\\ 2x - y = 0 \\end{cases}",description:"System of equations"}],mathml:[{name:"Fraction",formula:"<mfrac><mi>a</mi><mi>b</mi></mfrac>",description:"Simple fraction"},{name:"Square Root",formula:"<msqrt><mi>x</mi></msqrt>",description:"Square root"},{name:"Power",formula:"<msup><mi>x</mi><mn>2</mn></msup>",description:"Exponent/power"},{name:"Subscript",formula:"<msub><mi>x</mi><mi>sub</mi></msub>",description:"Subscript"},{name:"Parentheses",formula:'<mfenced open="(" close=")"><mi>a</mi><mo>+</mo><mi>b</mi></mfenced>',description:"Grouped expression"}]};let $=null,B=null,A=!1,b=null;const w='[data-theme="dark"], .dark, .editora-theme-dark',N=()=>new Promise((a,l)=>{if(window.katex){a(window.katex);return}if(A){const i=setInterval(()=>{window.katex&&(clearInterval(i),a(window.katex))},100);return}A=!0;const o=document.createElement("link");o.rel="stylesheet",o.href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css",document.head.appendChild(o);const d=document.createElement("script");d.src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js",d.onload=()=>a(window.katex),d.onerror=l,document.head.appendChild(d)}),H=()=>{const a=window.getSelection();if(!a||a.rangeCount===0)return null;const l=a.getRangeAt(0).startContainer;return(l.nodeType===Node.ELEMENT_NODE?l:l.parentElement)?.closest(".rte-content, .editora-content")||null},j=a=>{if((a||H())?.closest(w))return!0;const o=window.getSelection();if(o&&o.rangeCount>0){const i=o.getRangeAt(0).startContainer;if((i.nodeType===Node.ELEMENT_NODE?i:i.parentElement)?.closest(w))return!0}return document.activeElement?.closest(w)?!0:document.body.matches(w)||document.documentElement.matches(w)},q=async(a,l)=>{const o=l||B?.closest(".rte-content, .editora-content")||H()||b;b=o||null;const d=window.getSelection();if(d&&d.rangeCount>0){const e=d.getRangeAt(0);$=o&&o.contains(e.commonAncestorContainer)?e.cloneRange():null}await N();const i=j(o),t=i?{overlay:"rgba(0, 0, 0, 0.62)",dialogBg:"#1f2937",border:"#3b4657",panelBg:"#222d3a",fieldBg:"#111827",fieldBorder:"#4b5563",text:"#e2e8f0",muted:"#94a3b8",templateBtnBg:"#273244",templateBtnHover:"#334155",templateBtnText:"#dbe7f7",templateSubText:"#9fb0c6",previewBg:"#111827",previewText:"#cbd5e1",cancelBg:"#334155",cancelText:"#e2e8f0",cancelBorder:"#4b5563",insertBg:"#3b82f6",insertHover:"#2563eb",invalid:"#f87171"}:{overlay:"rgba(0, 0, 0, 0.5)",dialogBg:"#ffffff",border:"#e1e5e9",panelBg:"#f8f9fa",fieldBg:"#ffffff",fieldBorder:"#ced4da",text:"#1f2937",muted:"#6c757d",templateBtnBg:"#ffffff",templateBtnHover:"#f8f9fa",templateBtnText:"#1f2937",templateSubText:"#6c757d",previewBg:"#f8f9fa",previewText:"#6c757d",cancelBg:"#ffffff",cancelText:"#1f2937",cancelBorder:"#ced4da",insertBg:"#007bff",insertHover:"#0069d9",invalid:"#cc0000"},c=document.createElement("div");c.style.cssText=`position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: ${t.overlay}; display: flex; align-items: center; justify-content: center; z-index: 99999;`;const s=document.createElement("div");s.style.cssText=`background: ${t.dialogBg}; border: 1px solid ${t.border}; border-radius: 8px; width: 90%; max-width: 600px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2); color: ${t.text};`;let m=a?.format||"latex",T=a?.formula||"",P=a?.inline!==!1,g=null,M="";s.innerHTML=`
<div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${t.border}; background: ${t.panelBg};">
<h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${t.text};">${a?"Edit":"Insert"} Math Formula</h2>
<button class="close-btn" style="background: none; border: none; font-size: 28px; cursor: pointer; color: ${t.muted}; padding: 0; width: 30px; height: 30px; line-height: 1;">×</button>
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const O={latex:[{name:"Fraction",formula:"\\frac{a}{b}",description:"Simple fraction"},{name:"Square Root",formula:"\\sqrt{x}",description:"Square root"},{name:"Power",formula:"x^{2}",description:"Exponent/power"},{name:"Subscript",formula:"x_{sub}",description:"Subscript"},{name:"Integral",formula:"\\int_{a}^{b} f(x) \\, dx",description:"Definite integral"},{name:"Summation",formula:"\\sum_{i=1}^{n} x_{i}",description:"Summation"},{name:"Limit",formula:"\\lim_{x \\to 0} f(x)",description:"Limit"},{name:"Derivative",formula:"\\frac{d}{dx} f(x)",description:"Derivative"},{name:"Matrix 2x2",formula:"\\begin{pmatrix} a & b \\\\ c & d \\end{pmatrix}",description:"2x2 matrix"},{name:"System",formula:"\\begin{cases} x + y = 1 \\\\ 2x - y = 0 \\end{cases}",description:"System of equations"}],mathml:[{name:"Fraction",formula:"<mfrac><mi>a</mi><mi>b</mi></mfrac>",description:"Simple fraction"},{name:"Square Root",formula:"<msqrt><mi>x</mi></msqrt>",description:"Square root"},{name:"Power",formula:"<msup><mi>x</mi><mn>2</mn></msup>",description:"Exponent/power"},{name:"Subscript",formula:"<msub><mi>x</mi><mi>sub</mi></msub>",description:"Subscript"},{name:"Parentheses",formula:'<mfenced open="(" close=")"><mi>a</mi><mo>+</mo><mi>b</mi></mfenced>',description:"Grouped expression"}]};let T=null,S=null,H=!1,y=null,m=null;const k='[data-theme="dark"], .dark, .editora-theme-dark',K=()=>new Promise((e,t)=>{if(window.katex){e(window.katex);return}if(H){const s=setInterval(()=>{window.katex&&(clearInterval(s),e(window.katex))},100);return}H=!0;const r=document.createElement("link");r.rel="stylesheet",r.href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css",document.head.appendChild(r);const l=document.createElement("script");l.src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js",l.onload=()=>e(window.katex),l.onerror=t,document.head.appendChild(l)}),_=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.getRangeAt(0).startContainer;return(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(".rte-content, .editora-content")||null},U=e=>e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null,j=e=>U(e)?.closest('.rte-content, .editora-content, [contenteditable="true"]')||null,W=(e,t,r)=>{if(t!==r){if(typeof window.execEditorCommand=="function"){window.execEditorCommand("recordDomTransaction",e,t,r);return}if(typeof window.executeEditorCommand=="function")try{window.executeEditorCommand("recordDomTransaction",{editor:e,beforeHTML:t,afterHTML:r})}catch{}}},G=e=>{if(!(e instanceof Element))return null;const t=e.closest(".math-formula, .math-block");return t instanceof HTMLElement?t:null},h=()=>{m&&(m.classList.remove("math-object-selected"),m.removeAttribute("data-rte-selected-object"),m=null)},X=e=>{if(m===e)return;h(),m=e,e.classList.add("math-object-selected"),e.setAttribute("data-rte-selected-object","true");const t=window.getSelection();if(!t)return;const r=document.createRange();r.selectNode(e),t.removeAllRanges(),t.addRange(r)},Z=(e,t)=>{const r=window.getSelection();if(!r)return;const l=document.createRange();t&&t.parentNode===e?l.setStartBefore(t):(l.selectNodeContents(e),l.collapse(!1)),l.collapse(!0),r.removeAllRanges(),r.addRange(l)},Q=e=>{if(e.childNodes.length>0)return;const t=document.createElement("p");t.appendChild(document.createElement("br")),e.appendChild(t)},J=()=>{if(!m||!m.isConnected)return h(),!1;const e=m,t=j(e);if(!t)return h(),!1;const r=t.innerHTML,l=e.nextSibling;e.remove(),Q(t),h(),Z(t,l);const s=t.innerHTML;return W(t,r,s),t.dispatchEvent(new window.Event("input",{bubbles:!0})),r!==s},V=()=>{if(document.getElementById("math-object-selection-styles"))return;const e=document.createElement("style");e.id="math-object-selection-styles",e.textContent=`
.math-object-selected {
outline: 2px solid #2563eb !important;
outline-offset: 2px;
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}
`,document.head.appendChild(e)},Y=()=>{typeof window>"u"||window.__mathPluginObjectSelectionInitialized||(window.__mathPluginObjectSelectionInitialized=!0,V(),document.addEventListener("pointerdown",e=>{const t=G(e.target);if(!t){e.target?.closest?.(".math-dialog-overlay")||h();return}e.preventDefault(),j(t)?.focus(),X(t)},!0),document.addEventListener("keydown",e=>{if(m){if(e.key==="Escape"){h();return}e.key!=="Backspace"&&e.key!=="Delete"||(e.preventDefault(),e.stopPropagation(),J())}},!0))},ee=e=>{if((e||_())?.closest(k))return!0;const r=window.getSelection();if(r&&r.rangeCount>0){const s=r.getRangeAt(0).startContainer;if((s.nodeType===Node.ELEMENT_NODE?s:s.parentElement)?.closest(k))return!0}return document.activeElement?.closest(k)?!0:document.body.matches(k)||document.documentElement.matches(k)},N=async(e,t)=>{const r=t||S?.closest(".rte-content, .editora-content")||_()||y;y=r||null;const l=window.getSelection();if(l&&l.rangeCount>0){const n=l.getRangeAt(0);T=r&&r.contains(n.commonAncestorContainer)?n.cloneRange():null}await K();const s=ee(r),o=s?{overlay:"rgba(0, 0, 0, 0.62)",dialogBg:"#1f2937",border:"#3b4657",panelBg:"#222d3a",fieldBg:"#111827",fieldBorder:"#4b5563",text:"#e2e8f0",muted:"#94a3b8",templateBtnBg:"#273244",templateBtnHover:"#334155",templateBtnText:"#dbe7f7",templateSubText:"#9fb0c6",previewBg:"#111827",previewText:"#cbd5e1",cancelBg:"#334155",cancelText:"#e2e8f0",cancelBorder:"#4b5563",insertBg:"#3b82f6",insertHover:"#2563eb",invalid:"#f87171"}:{overlay:"rgba(0, 0, 0, 0.5)",dialogBg:"#ffffff",border:"#e1e5e9",panelBg:"#f8f9fa",fieldBg:"#ffffff",fieldBorder:"#ced4da",text:"#1f2937",muted:"#6c757d",templateBtnBg:"#ffffff",templateBtnHover:"#f8f9fa",templateBtnText:"#1f2937",templateSubText:"#6c757d",previewBg:"#f8f9fa",previewText:"#6c757d",cancelBg:"#ffffff",cancelText:"#1f2937",cancelBorder:"#ced4da",insertBg:"#007bff",insertHover:"#0069d9",invalid:"#cc0000"},d=document.createElement("div");d.className="math-dialog-overlay",d.style.cssText=`position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: ${o.overlay}; display: flex; align-items: center; justify-content: center; z-index: 99999;`;const c=document.createElement("div");c.style.cssText=`background: ${o.dialogBg}; border: 1px solid ${o.border}; border-radius: 8px; width: 90%; max-width: 600px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2); color: ${o.text};`;let u=e?.format||"latex",B=e?.formula||"",R=e?.inline!==!1,b=null,L="";c.innerHTML=`
<div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${o.border}; background: ${o.panelBg};">
<h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${o.text};">${e?"Edit":"Insert"} Math Formula</h2>
<button class="close-btn" style="background: none; border: none; font-size: 28px; cursor: pointer; color: ${o.muted}; padding: 0; width: 30px; height: 30px; line-height: 1;">×</button>
</div>

@@ -9,6 +15,6 @@

<div style="margin-bottom: 20px;">
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Format:</label>
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${o.text};">Format:</label>
<div style="display: flex; gap: 16px;">
<label style="cursor: pointer; color: ${t.text};"><input type="radio" name="format" value="latex" ${m==="latex"?"checked":""} style="margin-right: 6px;"> LaTeX</label>
<label style="cursor: pointer; color: ${t.text};"><input type="radio" name="format" value="mathml" ${m==="mathml"?"checked":""} style="margin-right: 6px;"> MathML</label>
<label style="cursor: pointer; color: ${o.text};"><input type="radio" name="format" value="latex" ${u==="latex"?"checked":""} style="margin-right: 6px;"> LaTeX</label>
<label style="cursor: pointer; color: ${o.text};"><input type="radio" name="format" value="mathml" ${u==="mathml"?"checked":""} style="margin-right: 6px;"> MathML</label>
</div>

@@ -18,3 +24,3 @@ </div>

<div style="margin-bottom: 20px;">
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Quick Templates:</label>
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${o.text};">Quick Templates:</label>
<div id="templates-grid" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 200px; overflow-y: auto;"></div>

@@ -24,25 +30,25 @@ </div>

<div style="margin-bottom: 20px;">
<label style="cursor: pointer; color: ${t.text};"><input type="checkbox" id="inline-cb" ${P?"checked":""} style="margin-right: 8px;"> Inline math</label>
<label style="cursor: pointer; color: ${o.text};"><input type="checkbox" id="inline-cb" ${R?"checked":""} style="margin-right: 8px;"> Inline math</label>
</div>
<div style="margin-bottom: 20px;">
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Formula:</label>
<textarea id="formula-input" rows="4" style="width: 100%; min-height: 112px; padding: 10px 12px; border: 1px solid ${t.fieldBorder}; border-radius: 6px; font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.45; background: ${t.fieldBg}; color: ${t.text}; box-sizing: border-box; overflow-x: hidden; overflow-y: auto; resize: vertical;">${T}</textarea>
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${o.text};">Formula:</label>
<textarea id="formula-input" rows="4" style="width: 100%; min-height: 112px; padding: 10px 12px; border: 1px solid ${o.fieldBorder}; border-radius: 6px; font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.45; background: ${o.fieldBg}; color: ${o.text}; box-sizing: border-box; overflow-x: hidden; overflow-y: auto; resize: vertical;">${B}</textarea>
</div>
<div style="margin-bottom: 20px;">
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Preview:</label>
<div id="preview-area" style="min-height: 60px; padding: 15px; border: 1px solid ${t.fieldBorder}; border-radius: 4px; background: ${t.previewBg}; display: flex; align-items: center; justify-content: center; color: ${t.previewText};"></div>
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${o.text};">Preview:</label>
<div id="preview-area" style="min-height: 60px; padding: 15px; border: 1px solid ${o.fieldBorder}; border-radius: 4px; background: ${o.previewBg}; display: flex; align-items: center; justify-content: center; color: ${o.previewText};"></div>
</div>
</div>
<div style="display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid ${t.border}; background: ${t.panelBg};">
<button class="cancel-btn" style="padding: 10px 20px; background: ${t.cancelBg}; color: ${t.cancelText}; border: 1px solid ${t.cancelBorder}; border-radius: 4px; cursor: pointer; font-size: 14px;">Cancel</button>
<button id="insert-btn" style="padding: 10px 20px; background: ${t.insertBg}; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;" disabled>${a?"Update":"Insert"}</button>
<div style="display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid ${o.border}; background: ${o.panelBg};">
<button class="cancel-btn" style="padding: 10px 20px; background: ${o.cancelBg}; color: ${o.cancelText}; border: 1px solid ${o.cancelBorder}; border-radius: 4px; cursor: pointer; font-size: 14px;">Cancel</button>
<button id="insert-btn" style="padding: 10px 20px; background: ${o.insertBg}; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;" disabled>${e?"Update":"Insert"}</button>
</div>
`,c.appendChild(s),document.body.appendChild(c);const u=s.querySelector("#formula-input"),h=s.querySelector("#preview-area"),k=s.querySelector("#templates-grid"),_=s.querySelectorAll('input[name="format"]'),z=s.querySelector("#inline-cb"),p=s.querySelector("#insert-btn"),f=s.querySelector(".close-btn"),v=s.querySelector(".cancel-btn"),I=e=>encodeURIComponent(e),D=e=>{try{return decodeURIComponent(e)}catch{return e}},L=()=>{const e=F[m];k.innerHTML=e.map(r=>`
<button type="button" data-formula="${I(r.formula)}" title="${r.description}" style="padding: 8px; border: 1px solid ${t.fieldBorder}; border-radius: 4px; background: ${t.templateBtnBg}; cursor: pointer; text-align: left; transition: background-color 0.16s ease;">
<div style="font-weight: 600; font-size: 12px; color: ${t.templateBtnText};">${r.name}</div>
<div style="font-size: 10px; color: ${t.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${r.formula.substring(0,20)}...</div>
`,d.appendChild(c),document.body.appendChild(d);const p=c.querySelector("#formula-input"),v=c.querySelector("#preview-area"),$=c.querySelector("#templates-grid"),P=c.querySelectorAll('input[name="format"]'),z=c.querySelector("#inline-cb"),f=c.querySelector("#insert-btn"),g=c.querySelector(".close-btn"),w=c.querySelector(".cancel-btn"),I=n=>encodeURIComponent(n),q=n=>{try{return decodeURIComponent(n)}catch{return n}},C=()=>{const n=O[u];$.innerHTML=n.map(i=>`
<button type="button" data-formula="${I(i.formula)}" title="${i.description}" style="padding: 8px; border: 1px solid ${o.fieldBorder}; border-radius: 4px; background: ${o.templateBtnBg}; cursor: pointer; text-align: left; transition: background-color 0.16s ease;">
<div style="font-weight: 600; font-size: 12px; color: ${o.templateBtnText};">${i.name}</div>
<div style="font-size: 10px; color: ${o.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${i.formula.substring(0,20)}...</div>
</button>
`).join("")},R=()=>{const e=u.value.trim(),r=`${m}:${e}`;if(r!==M){if(M=r,!e){h.innerHTML=`<span style="color: ${t.previewText};">Enter a formula to see preview</span>`,p.disabled=!0;return}p.disabled=!1;try{if(m==="latex"){const n=window.katex;h.innerHTML=n.renderToString(e,{displayMode:!1,throwOnError:!1})}else e.trim().startsWith("<math")?h.innerHTML=e:h.innerHTML=`<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${e}</math>`}catch{h.innerHTML=`<span style="color: ${t.invalid};">Invalid formula</span>`}}},E=()=>{g!==null&&cancelAnimationFrame(g),g=requestAnimationFrame(()=>{g=null,R()})},S=e=>{e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),y())},y=()=>{document.removeEventListener("keydown",S,!0),g!==null&&(cancelAnimationFrame(g),g=null),c.parentNode&&c.parentNode.removeChild(c)};f.onmouseover=()=>{f.style.color="#f8fafc",f.style.background=i?"#334155":"#e5e7eb",f.style.borderRadius="4px"},f.onmouseout=()=>{f.style.color=t.muted,f.style.background="none"},v.onmouseover=()=>{v.style.background=i?"#475569":"#f3f4f6"},v.onmouseout=()=>{v.style.background=t.cancelBg},p.onmouseover=()=>{p.disabled||(p.style.background=t.insertHover)},p.onmouseout=()=>{p.style.background=t.insertBg},k.addEventListener("mouseover",e=>{const n=e.target.closest("button[data-formula]");n&&(n.style.background=t.templateBtnHover)}),k.addEventListener("mouseout",e=>{const n=e.target.closest("button[data-formula]");n&&(n.style.background=t.templateBtnBg)}),k.addEventListener("click",e=>{const n=e.target.closest("button[data-formula]");n&&(u.value=D(n.getAttribute("data-formula")||""),T=u.value,E())});const C=()=>{const e=u.value.trim();if(!e)return;const r={formula:e,format:m,inline:z.checked},n=r.inline?document.createElement("span"):document.createElement("div");if(n.className=r.inline?"math-formula":"math-block",n.setAttribute("data-math-formula",e),n.setAttribute("data-math-format",m),n.contentEditable="false",n.style.cssText=r.inline?"background: #f0f8ff; border: 1px solid #b8daff; border-radius: 4px; padding: 2px 6px; margin: 0 2px; color: #004085; display: inline-block; cursor: pointer;":"background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 4px; padding: 12px; margin: 8px 0; text-align: center; display: block; cursor: pointer;",m==="latex"){const x=window.katex;try{n.innerHTML=x.renderToString(e,{displayMode:!r.inline,throwOnError:!1})}catch{n.textContent=r.inline?`$${e}$`:`$$${e}$$`}}else if(e.trim().startsWith("<math"))n.innerHTML=e;else{const x=`<math xmlns="http://www.w3.org/1998/Math/MathML" display="${r.inline?"inline":"block"}">${e}</math>`;n.innerHTML=x}if(B)B.replaceWith(n);else if($)$.deleteContents(),$.insertNode(n);else if(b&&b.isConnected){const x=document.createRange();x.selectNodeContents(b),x.collapse(!1),x.insertNode(n)}(n.closest(".rte-content, .editora-content")||b)?.dispatchEvent(new Event("input",{bubbles:!0})),y()};f.addEventListener("click",y),v.addEventListener("click",y),p.addEventListener("click",C),c.addEventListener("click",e=>{e.target===c&&y()}),document.addEventListener("keydown",S,!0),_.forEach(e=>{e.addEventListener("change",r=>{m=r.target.value,M="",L(),E()})}),u.addEventListener("input",()=>{T=u.value,E()}),u.addEventListener("keydown",e=>{(e.ctrlKey||e.metaKey)&&e.key==="Enter"&&(e.preventDefault(),C())}),L(),E(),u.focus()};if(typeof window<"u"&&!window.__mathPluginDoubleClickInitialized){window.__mathPluginDoubleClickInitialized=!0;const a=o=>{const i=o.target.closest(".math-formula, .math-block");if(i){o.preventDefault(),o.stopPropagation(),o.stopImmediatePropagation(),B=i;const t=i.getAttribute("data-math-formula")||"",c=i.getAttribute("data-math-format")||"latex",s=i.classList.contains("math-formula");q({formula:t,format:c,inline:s})}},l=()=>{document.addEventListener("dblclick",a,{capture:!0})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",l):setTimeout(l,100)}const O=()=>({name:"math",toolbar:[{label:"Insert Math",command:"insertMath",icon:'<svg width="24" height="24" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M9 4.8c.1-.5.5-.8 1-.8h10a1 1 0 1 1 0 2h-9.2L8.3 19.2a1 1 0 0 1-1.7.4l-3.4-4.2a1 1 0 0 1 1.6-1.2l2 2.5L9 4.8Zm9.7 5.5c.4.4.4 1 0 1.4L17 13.5l1.8 1.8a1 1 0 0 1-1.4 1.4L15.5 15l-1.8 1.8a1 1 0 0 1-1.4-1.4l1.8-1.8-1.8-1.8a1 1 0 0 1 1.4-1.4l1.8 1.8 1.8-1.8a1 1 0 0 1 1.4 0Z"></path></svg>'}],commands:{insertMath:(a,l)=>{const o=l?.contentElement instanceof HTMLElement?l.contentElement:null;return q(void 0,o),!0}},keymap:{"Mod-Shift-m":"insertMath"}});exports.MathPlugin=O;
`).join("")},F=()=>{const n=p.value.trim(),i=`${u}:${n}`;if(i!==L){if(L=i,!n){v.innerHTML=`<span style="color: ${o.previewText};">Enter a formula to see preview</span>`,f.disabled=!0;return}f.disabled=!1;try{if(u==="latex"){const a=window.katex;v.innerHTML=a.renderToString(n,{displayMode:!1,throwOnError:!1})}else n.trim().startsWith("<math")?v.innerHTML=n:v.innerHTML=`<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${n}</math>`}catch{v.innerHTML=`<span style="color: ${o.invalid};">Invalid formula</span>`}}},M=()=>{b!==null&&cancelAnimationFrame(b),b=requestAnimationFrame(()=>{b=null,F()})},A=n=>{n.key==="Escape"&&(n.preventDefault(),n.stopPropagation(),E())},E=()=>{document.removeEventListener("keydown",A,!0),b!==null&&(cancelAnimationFrame(b),b=null),d.parentNode&&d.parentNode.removeChild(d)};g.onmouseover=()=>{g.style.color="#f8fafc",g.style.background=s?"#334155":"#e5e7eb",g.style.borderRadius="4px"},g.onmouseout=()=>{g.style.color=o.muted,g.style.background="none"},w.onmouseover=()=>{w.style.background=s?"#475569":"#f3f4f6"},w.onmouseout=()=>{w.style.background=o.cancelBg},f.onmouseover=()=>{f.disabled||(f.style.background=o.insertHover)},f.onmouseout=()=>{f.style.background=o.insertBg},$.addEventListener("mouseover",n=>{const a=n.target.closest("button[data-formula]");a&&(a.style.background=o.templateBtnHover)}),$.addEventListener("mouseout",n=>{const a=n.target.closest("button[data-formula]");a&&(a.style.background=o.templateBtnBg)}),$.addEventListener("click",n=>{const a=n.target.closest("button[data-formula]");a&&(p.value=q(a.getAttribute("data-formula")||""),B=p.value,M())});const D=()=>{const n=p.value.trim();if(!n)return;const i={formula:n,format:u,inline:z.checked},a=i.inline?document.createElement("span"):document.createElement("div");if(a.className=i.inline?"math-formula":"math-block",a.setAttribute("data-math-formula",n),a.setAttribute("data-math-format",u),a.contentEditable="false",a.style.cssText=i.inline?"background: #f0f8ff; border: 1px solid #b8daff; border-radius: 4px; padding: 2px 6px; margin: 0 2px; color: #004085; display: inline-block; cursor: pointer;":"background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 4px; padding: 12px; margin: 8px 0; text-align: center; display: block; cursor: pointer;",u==="latex"){const x=window.katex;try{a.innerHTML=x.renderToString(n,{displayMode:!i.inline,throwOnError:!1})}catch{a.textContent=i.inline?`$${n}$`:`$$${n}$$`}}else if(n.trim().startsWith("<math"))a.innerHTML=n;else{const x=`<math xmlns="http://www.w3.org/1998/Math/MathML" display="${i.inline?"inline":"block"}">${n}</math>`;a.innerHTML=x}if(S)S.replaceWith(a);else if(T)T.deleteContents(),T.insertNode(a);else if(y&&y.isConnected){const x=document.createRange();x.selectNodeContents(y),x.collapse(!1),x.insertNode(a)}(a.closest(".rte-content, .editora-content")||y)?.dispatchEvent(new Event("input",{bubbles:!0})),E()};g.addEventListener("click",E),w.addEventListener("click",E),f.addEventListener("click",D),d.addEventListener("click",n=>{n.target===d&&E()}),document.addEventListener("keydown",A,!0),P.forEach(n=>{n.addEventListener("change",i=>{u=i.target.value,L="",C(),M()})}),p.addEventListener("input",()=>{B=p.value,M()}),p.addEventListener("keydown",n=>{(n.ctrlKey||n.metaKey)&&n.key==="Enter"&&(n.preventDefault(),D())}),C(),M(),p.focus()};if(typeof window<"u"&&!window.__mathPluginDoubleClickInitialized){window.__mathPluginDoubleClickInitialized=!0;const e=r=>{const s=r.target.closest(".math-formula, .math-block");if(s){r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation(),h(),S=s;const o=s.getAttribute("data-math-formula")||"",d=s.getAttribute("data-math-format")||"latex",c=s.classList.contains("math-formula");N({formula:o,format:d,inline:c})}},t=()=>{document.addEventListener("dblclick",e,{capture:!0})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):setTimeout(t,100)}const te=()=>({name:"math",init:Y,toolbar:[{label:"Insert Math",command:"insertMath",icon:'<svg width="24" height="24" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M9 4.8c.1-.5.5-.8 1-.8h10a1 1 0 1 1 0 2h-9.2L8.3 19.2a1 1 0 0 1-1.7.4l-3.4-4.2a1 1 0 0 1 1.6-1.2l2 2.5L9 4.8Zm9.7 5.5c.4.4.4 1 0 1.4L17 13.5l1.8 1.8a1 1 0 0 1-1.4 1.4L15.5 15l-1.8 1.8a1 1 0 0 1-1.4-1.4l1.8-1.8-1.8-1.8a1 1 0 0 1 1.4-1.4l1.8 1.8 1.8-1.8a1 1 0 0 1 1.4 0Z"></path></svg>'}],commands:{insertMath:(e,t)=>{const r=t?.contentElement instanceof HTMLElement?t.contentElement:null;return N(void 0,r),!0}},keymap:{"Mod-Shift-m":"insertMath"}});exports.MathPlugin=te;

@@ -1,2 +0,2 @@

const F = {
const O = {
latex: [

@@ -22,42 +22,113 @@ { name: "Fraction", formula: "\\frac{a}{b}", description: "Simple fraction" },

};
let $ = null, B = null, A = !1, b = null;
const w = '[data-theme="dark"], .dark, .editora-theme-dark', N = () => new Promise((a, l) => {
let T = null, B = null, H = !1, y = null, m = null;
const k = '[data-theme="dark"], .dark, .editora-theme-dark', K = () => new Promise((e, t) => {
if (window.katex) {
a(window.katex);
e(window.katex);
return;
}
if (A) {
const i = setInterval(() => {
window.katex && (clearInterval(i), a(window.katex));
if (H) {
const s = setInterval(() => {
window.katex && (clearInterval(s), e(window.katex));
}, 100);
return;
}
A = !0;
const o = document.createElement("link");
o.rel = "stylesheet", o.href = "https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css", document.head.appendChild(o);
const d = document.createElement("script");
d.src = "https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js", d.onload = () => a(window.katex), d.onerror = l, document.head.appendChild(d);
}), H = () => {
const a = window.getSelection();
if (!a || a.rangeCount === 0) return null;
const l = a.getRangeAt(0).startContainer;
return (l.nodeType === Node.ELEMENT_NODE ? l : l.parentElement)?.closest(".rte-content, .editora-content") || null;
}, j = (a) => {
if ((a || H())?.closest(w)) return !0;
const o = window.getSelection();
if (o && o.rangeCount > 0) {
const i = o.getRangeAt(0).startContainer;
if ((i.nodeType === Node.ELEMENT_NODE ? i : i.parentElement)?.closest(w)) return !0;
H = !0;
const r = document.createElement("link");
r.rel = "stylesheet", r.href = "https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css", document.head.appendChild(r);
const l = document.createElement("script");
l.src = "https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js", l.onload = () => e(window.katex), l.onerror = t, document.head.appendChild(l);
}), N = () => {
const e = window.getSelection();
if (!e || e.rangeCount === 0) return null;
const t = e.getRangeAt(0).startContainer;
return (t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement)?.closest(".rte-content, .editora-content") || null;
}, U = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null, R = (e) => U(e)?.closest('.rte-content, .editora-content, [contenteditable="true"]') || null, W = (e, t, r) => {
if (t !== r) {
if (typeof window.execEditorCommand == "function") {
window.execEditorCommand("recordDomTransaction", e, t, r);
return;
}
if (typeof window.executeEditorCommand == "function")
try {
window.executeEditorCommand("recordDomTransaction", { editor: e, beforeHTML: t, afterHTML: r });
} catch {
}
}
return document.activeElement?.closest(w) ? !0 : document.body.matches(w) || document.documentElement.matches(w);
}, q = async (a, l) => {
const o = l || B?.closest(".rte-content, .editora-content") || H() || b;
b = o || null;
const d = window.getSelection();
if (d && d.rangeCount > 0) {
const e = d.getRangeAt(0);
$ = o && o.contains(e.commonAncestorContainer) ? e.cloneRange() : null;
}, G = (e) => {
if (!(e instanceof Element)) return null;
const t = e.closest(".math-formula, .math-block");
return t instanceof HTMLElement ? t : null;
}, h = () => {
m && (m.classList.remove("math-object-selected"), m.removeAttribute("data-rte-selected-object"), m = null);
}, X = (e) => {
if (m === e) return;
h(), m = e, e.classList.add("math-object-selected"), e.setAttribute("data-rte-selected-object", "true");
const t = window.getSelection();
if (!t) return;
const r = document.createRange();
r.selectNode(e), t.removeAllRanges(), t.addRange(r);
}, Z = (e, t) => {
const r = window.getSelection();
if (!r) return;
const l = document.createRange();
t && t.parentNode === e ? l.setStartBefore(t) : (l.selectNodeContents(e), l.collapse(!1)), l.collapse(!0), r.removeAllRanges(), r.addRange(l);
}, Q = (e) => {
if (e.childNodes.length > 0) return;
const t = document.createElement("p");
t.appendChild(document.createElement("br")), e.appendChild(t);
}, J = () => {
if (!m || !m.isConnected)
return h(), !1;
const e = m, t = R(e);
if (!t)
return h(), !1;
const r = t.innerHTML, l = e.nextSibling;
e.remove(), Q(t), h(), Z(t, l);
const s = t.innerHTML;
return W(t, r, s), t.dispatchEvent(new window.Event("input", { bubbles: !0 })), r !== s;
}, V = () => {
if (document.getElementById("math-object-selection-styles")) return;
const e = document.createElement("style");
e.id = "math-object-selection-styles", e.textContent = `
.math-object-selected {
outline: 2px solid #2563eb !important;
outline-offset: 2px;
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}
`, document.head.appendChild(e);
}, Y = () => {
typeof window > "u" || window.__mathPluginObjectSelectionInitialized || (window.__mathPluginObjectSelectionInitialized = !0, V(), document.addEventListener("pointerdown", (e) => {
const t = G(e.target);
if (!t) {
e.target?.closest?.(".math-dialog-overlay") || h();
return;
}
e.preventDefault(), R(t)?.focus(), X(t);
}, !0), document.addEventListener("keydown", (e) => {
if (m) {
if (e.key === "Escape") {
h();
return;
}
e.key !== "Backspace" && e.key !== "Delete" || (e.preventDefault(), e.stopPropagation(), J());
}
}, !0));
}, ee = (e) => {
if ((e || N())?.closest(k)) return !0;
const r = window.getSelection();
if (r && r.rangeCount > 0) {
const s = r.getRangeAt(0).startContainer;
if ((s.nodeType === Node.ELEMENT_NODE ? s : s.parentElement)?.closest(k)) return !0;
}
await N();
const i = j(o), t = i ? {
return document.activeElement?.closest(k) ? !0 : document.body.matches(k) || document.documentElement.matches(k);
}, j = async (e, t) => {
const r = t || B?.closest(".rte-content, .editora-content") || N() || y;
y = r || null;
const l = window.getSelection();
if (l && l.rangeCount > 0) {
const n = l.getRangeAt(0);
T = r && r.contains(n.commonAncestorContainer) ? n.cloneRange() : null;
}
await K();
const s = ee(r), o = s ? {
overlay: "rgba(0, 0, 0, 0.62)",

@@ -104,11 +175,11 @@ dialogBg: "#1f2937",

invalid: "#cc0000"
}, c = document.createElement("div");
c.style.cssText = `position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: ${t.overlay}; display: flex; align-items: center; justify-content: center; z-index: 99999;`;
const s = document.createElement("div");
s.style.cssText = `background: ${t.dialogBg}; border: 1px solid ${t.border}; border-radius: 8px; width: 90%; max-width: 600px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2); color: ${t.text};`;
let m = a?.format || "latex", T = a?.formula || "", z = a?.inline !== !1, x = null, L = "";
s.innerHTML = `
<div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${t.border}; background: ${t.panelBg};">
<h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${t.text};">${a ? "Edit" : "Insert"} Math Formula</h2>
<button class="close-btn" style="background: none; border: none; font-size: 28px; cursor: pointer; color: ${t.muted}; padding: 0; width: 30px; height: 30px; line-height: 1;">×</button>
}, d = document.createElement("div");
d.className = "math-dialog-overlay", d.style.cssText = `position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: ${o.overlay}; display: flex; align-items: center; justify-content: center; z-index: 99999;`;
const c = document.createElement("div");
c.style.cssText = `background: ${o.dialogBg}; border: 1px solid ${o.border}; border-radius: 8px; width: 90%; max-width: 600px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2); color: ${o.text};`;
let u = e?.format || "latex", S = e?.formula || "", _ = e?.inline !== !1, b = null, L = "";
c.innerHTML = `
<div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${o.border}; background: ${o.panelBg};">
<h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${o.text};">${e ? "Edit" : "Insert"} Math Formula</h2>
<button class="close-btn" style="background: none; border: none; font-size: 28px; cursor: pointer; color: ${o.muted}; padding: 0; width: 30px; height: 30px; line-height: 1;">×</button>
</div>

@@ -118,6 +189,6 @@

<div style="margin-bottom: 20px;">
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Format:</label>
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${o.text};">Format:</label>
<div style="display: flex; gap: 16px;">
<label style="cursor: pointer; color: ${t.text};"><input type="radio" name="format" value="latex" ${m === "latex" ? "checked" : ""} style="margin-right: 6px;"> LaTeX</label>
<label style="cursor: pointer; color: ${t.text};"><input type="radio" name="format" value="mathml" ${m === "mathml" ? "checked" : ""} style="margin-right: 6px;"> MathML</label>
<label style="cursor: pointer; color: ${o.text};"><input type="radio" name="format" value="latex" ${u === "latex" ? "checked" : ""} style="margin-right: 6px;"> LaTeX</label>
<label style="cursor: pointer; color: ${o.text};"><input type="radio" name="format" value="mathml" ${u === "mathml" ? "checked" : ""} style="margin-right: 6px;"> MathML</label>
</div>

@@ -127,3 +198,3 @@ </div>

<div style="margin-bottom: 20px;">
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Quick Templates:</label>
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${o.text};">Quick Templates:</label>
<div id="templates-grid" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 200px; overflow-y: auto;"></div>

@@ -133,142 +204,143 @@ </div>

<div style="margin-bottom: 20px;">
<label style="cursor: pointer; color: ${t.text};"><input type="checkbox" id="inline-cb" ${z ? "checked" : ""} style="margin-right: 8px;"> Inline math</label>
<label style="cursor: pointer; color: ${o.text};"><input type="checkbox" id="inline-cb" ${_ ? "checked" : ""} style="margin-right: 8px;"> Inline math</label>
</div>
<div style="margin-bottom: 20px;">
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Formula:</label>
<textarea id="formula-input" rows="4" style="width: 100%; min-height: 112px; padding: 10px 12px; border: 1px solid ${t.fieldBorder}; border-radius: 6px; font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.45; background: ${t.fieldBg}; color: ${t.text}; box-sizing: border-box; overflow-x: hidden; overflow-y: auto; resize: vertical;">${T}</textarea>
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${o.text};">Formula:</label>
<textarea id="formula-input" rows="4" style="width: 100%; min-height: 112px; padding: 10px 12px; border: 1px solid ${o.fieldBorder}; border-radius: 6px; font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.45; background: ${o.fieldBg}; color: ${o.text}; box-sizing: border-box; overflow-x: hidden; overflow-y: auto; resize: vertical;">${S}</textarea>
</div>
<div style="margin-bottom: 20px;">
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Preview:</label>
<div id="preview-area" style="min-height: 60px; padding: 15px; border: 1px solid ${t.fieldBorder}; border-radius: 4px; background: ${t.previewBg}; display: flex; align-items: center; justify-content: center; color: ${t.previewText};"></div>
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${o.text};">Preview:</label>
<div id="preview-area" style="min-height: 60px; padding: 15px; border: 1px solid ${o.fieldBorder}; border-radius: 4px; background: ${o.previewBg}; display: flex; align-items: center; justify-content: center; color: ${o.previewText};"></div>
</div>
</div>
<div style="display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid ${t.border}; background: ${t.panelBg};">
<button class="cancel-btn" style="padding: 10px 20px; background: ${t.cancelBg}; color: ${t.cancelText}; border: 1px solid ${t.cancelBorder}; border-radius: 4px; cursor: pointer; font-size: 14px;">Cancel</button>
<button id="insert-btn" style="padding: 10px 20px; background: ${t.insertBg}; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;" disabled>${a ? "Update" : "Insert"}</button>
<div style="display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid ${o.border}; background: ${o.panelBg};">
<button class="cancel-btn" style="padding: 10px 20px; background: ${o.cancelBg}; color: ${o.cancelText}; border: 1px solid ${o.cancelBorder}; border-radius: 4px; cursor: pointer; font-size: 14px;">Cancel</button>
<button id="insert-btn" style="padding: 10px 20px; background: ${o.insertBg}; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;" disabled>${e ? "Update" : "Insert"}</button>
</div>
`, c.appendChild(s), document.body.appendChild(c);
const u = s.querySelector("#formula-input"), h = s.querySelector("#preview-area"), k = s.querySelector("#templates-grid"), I = s.querySelectorAll('input[name="format"]'), D = s.querySelector("#inline-cb"), p = s.querySelector("#insert-btn"), f = s.querySelector(".close-btn"), v = s.querySelector(".cancel-btn"), P = (e) => encodeURIComponent(e), R = (e) => {
`, d.appendChild(c), document.body.appendChild(d);
const p = c.querySelector("#formula-input"), v = c.querySelector("#preview-area"), $ = c.querySelector("#templates-grid"), z = c.querySelectorAll('input[name="format"]'), I = c.querySelector("#inline-cb"), f = c.querySelector("#insert-btn"), g = c.querySelector(".close-btn"), w = c.querySelector(".cancel-btn"), P = (n) => encodeURIComponent(n), q = (n) => {
try {
return decodeURIComponent(e);
return decodeURIComponent(n);
} catch {
return e;
return n;
}
}, M = () => {
const e = F[m];
k.innerHTML = e.map((r) => `
<button type="button" data-formula="${P(r.formula)}" title="${r.description}" style="padding: 8px; border: 1px solid ${t.fieldBorder}; border-radius: 4px; background: ${t.templateBtnBg}; cursor: pointer; text-align: left; transition: background-color 0.16s ease;">
<div style="font-weight: 600; font-size: 12px; color: ${t.templateBtnText};">${r.name}</div>
<div style="font-size: 10px; color: ${t.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${r.formula.substring(0, 20)}...</div>
}, C = () => {
const n = O[u];
$.innerHTML = n.map((i) => `
<button type="button" data-formula="${P(i.formula)}" title="${i.description}" style="padding: 8px; border: 1px solid ${o.fieldBorder}; border-radius: 4px; background: ${o.templateBtnBg}; cursor: pointer; text-align: left; transition: background-color 0.16s ease;">
<div style="font-weight: 600; font-size: 12px; color: ${o.templateBtnText};">${i.name}</div>
<div style="font-size: 10px; color: ${o.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${i.formula.substring(0, 20)}...</div>
</button>
`).join("");
}, _ = () => {
const e = u.value.trim(), r = `${m}:${e}`;
if (r !== L) {
if (L = r, !e) {
h.innerHTML = `<span style="color: ${t.previewText};">Enter a formula to see preview</span>`, p.disabled = !0;
}, F = () => {
const n = p.value.trim(), i = `${u}:${n}`;
if (i !== L) {
if (L = i, !n) {
v.innerHTML = `<span style="color: ${o.previewText};">Enter a formula to see preview</span>`, f.disabled = !0;
return;
}
p.disabled = !1;
f.disabled = !1;
try {
if (m === "latex") {
const n = window.katex;
h.innerHTML = n.renderToString(e, { displayMode: !1, throwOnError: !1 });
if (u === "latex") {
const a = window.katex;
v.innerHTML = a.renderToString(n, { displayMode: !1, throwOnError: !1 });
} else
e.trim().startsWith("<math") ? h.innerHTML = e : h.innerHTML = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${e}</math>`;
n.trim().startsWith("<math") ? v.innerHTML = n : v.innerHTML = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${n}</math>`;
} catch {
h.innerHTML = `<span style="color: ${t.invalid};">Invalid formula</span>`;
v.innerHTML = `<span style="color: ${o.invalid};">Invalid formula</span>`;
}
}
}, M = () => {
b !== null && cancelAnimationFrame(b), b = requestAnimationFrame(() => {
b = null, F();
});
}, A = (n) => {
n.key === "Escape" && (n.preventDefault(), n.stopPropagation(), E());
}, E = () => {
x !== null && cancelAnimationFrame(x), x = requestAnimationFrame(() => {
x = null, _();
});
}, S = (e) => {
e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), y());
}, y = () => {
document.removeEventListener("keydown", S, !0), x !== null && (cancelAnimationFrame(x), x = null), c.parentNode && c.parentNode.removeChild(c);
document.removeEventListener("keydown", A, !0), b !== null && (cancelAnimationFrame(b), b = null), d.parentNode && d.parentNode.removeChild(d);
};
f.onmouseover = () => {
f.style.color = "#f8fafc", f.style.background = i ? "#334155" : "#e5e7eb", f.style.borderRadius = "4px";
g.onmouseover = () => {
g.style.color = "#f8fafc", g.style.background = s ? "#334155" : "#e5e7eb", g.style.borderRadius = "4px";
}, g.onmouseout = () => {
g.style.color = o.muted, g.style.background = "none";
}, w.onmouseover = () => {
w.style.background = s ? "#475569" : "#f3f4f6";
}, w.onmouseout = () => {
w.style.background = o.cancelBg;
}, f.onmouseover = () => {
f.disabled || (f.style.background = o.insertHover);
}, f.onmouseout = () => {
f.style.color = t.muted, f.style.background = "none";
}, v.onmouseover = () => {
v.style.background = i ? "#475569" : "#f3f4f6";
}, v.onmouseout = () => {
v.style.background = t.cancelBg;
}, p.onmouseover = () => {
p.disabled || (p.style.background = t.insertHover);
}, p.onmouseout = () => {
p.style.background = t.insertBg;
}, k.addEventListener("mouseover", (e) => {
const n = e.target.closest("button[data-formula]");
n && (n.style.background = t.templateBtnHover);
}), k.addEventListener("mouseout", (e) => {
const n = e.target.closest("button[data-formula]");
n && (n.style.background = t.templateBtnBg);
}), k.addEventListener("click", (e) => {
const n = e.target.closest("button[data-formula]");
n && (u.value = R(n.getAttribute("data-formula") || ""), T = u.value, E());
f.style.background = o.insertBg;
}, $.addEventListener("mouseover", (n) => {
const a = n.target.closest("button[data-formula]");
a && (a.style.background = o.templateBtnHover);
}), $.addEventListener("mouseout", (n) => {
const a = n.target.closest("button[data-formula]");
a && (a.style.background = o.templateBtnBg);
}), $.addEventListener("click", (n) => {
const a = n.target.closest("button[data-formula]");
a && (p.value = q(a.getAttribute("data-formula") || ""), S = p.value, M());
});
const C = () => {
const e = u.value.trim();
if (!e) return;
const r = { formula: e, format: m, inline: D.checked }, n = r.inline ? document.createElement("span") : document.createElement("div");
if (n.className = r.inline ? "math-formula" : "math-block", n.setAttribute("data-math-formula", e), n.setAttribute("data-math-format", m), n.contentEditable = "false", n.style.cssText = r.inline ? "background: #f0f8ff; border: 1px solid #b8daff; border-radius: 4px; padding: 2px 6px; margin: 0 2px; color: #004085; display: inline-block; cursor: pointer;" : "background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 4px; padding: 12px; margin: 8px 0; text-align: center; display: block; cursor: pointer;", m === "latex") {
const g = window.katex;
const D = () => {
const n = p.value.trim();
if (!n) return;
const i = { formula: n, format: u, inline: I.checked }, a = i.inline ? document.createElement("span") : document.createElement("div");
if (a.className = i.inline ? "math-formula" : "math-block", a.setAttribute("data-math-formula", n), a.setAttribute("data-math-format", u), a.contentEditable = "false", a.style.cssText = i.inline ? "background: #f0f8ff; border: 1px solid #b8daff; border-radius: 4px; padding: 2px 6px; margin: 0 2px; color: #004085; display: inline-block; cursor: pointer;" : "background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 4px; padding: 12px; margin: 8px 0; text-align: center; display: block; cursor: pointer;", u === "latex") {
const x = window.katex;
try {
n.innerHTML = g.renderToString(e, {
displayMode: !r.inline,
a.innerHTML = x.renderToString(n, {
displayMode: !i.inline,
throwOnError: !1
});
} catch {
n.textContent = r.inline ? `$${e}$` : `$$${e}$$`;
a.textContent = i.inline ? `$${n}$` : `$$${n}$$`;
}
} else if (e.trim().startsWith("<math"))
n.innerHTML = e;
} else if (n.trim().startsWith("<math"))
a.innerHTML = n;
else {
const g = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="${r.inline ? "inline" : "block"}">${e}</math>`;
n.innerHTML = g;
const x = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="${i.inline ? "inline" : "block"}">${n}</math>`;
a.innerHTML = x;
}
if (B)
B.replaceWith(n);
else if ($)
$.deleteContents(), $.insertNode(n);
else if (b && b.isConnected) {
const g = document.createRange();
g.selectNodeContents(b), g.collapse(!1), g.insertNode(n);
B.replaceWith(a);
else if (T)
T.deleteContents(), T.insertNode(a);
else if (y && y.isConnected) {
const x = document.createRange();
x.selectNodeContents(y), x.collapse(!1), x.insertNode(a);
}
(n.closest(".rte-content, .editora-content") || b)?.dispatchEvent(new Event("input", { bubbles: !0 })), y();
(a.closest(".rte-content, .editora-content") || y)?.dispatchEvent(new Event("input", { bubbles: !0 })), E();
};
f.addEventListener("click", y), v.addEventListener("click", y), p.addEventListener("click", C), c.addEventListener("click", (e) => {
e.target === c && y();
}), document.addEventListener("keydown", S, !0), I.forEach((e) => {
e.addEventListener("change", (r) => {
m = r.target.value, L = "", M(), E();
g.addEventListener("click", E), w.addEventListener("click", E), f.addEventListener("click", D), d.addEventListener("click", (n) => {
n.target === d && E();
}), document.addEventListener("keydown", A, !0), z.forEach((n) => {
n.addEventListener("change", (i) => {
u = i.target.value, L = "", C(), M();
});
}), u.addEventListener("input", () => {
T = u.value, E();
}), u.addEventListener("keydown", (e) => {
(e.ctrlKey || e.metaKey) && e.key === "Enter" && (e.preventDefault(), C());
}), M(), E(), u.focus();
}), p.addEventListener("input", () => {
S = p.value, M();
}), p.addEventListener("keydown", (n) => {
(n.ctrlKey || n.metaKey) && n.key === "Enter" && (n.preventDefault(), D());
}), C(), M(), p.focus();
};
if (typeof window < "u" && !window.__mathPluginDoubleClickInitialized) {
window.__mathPluginDoubleClickInitialized = !0;
const a = (o) => {
const i = o.target.closest(".math-formula, .math-block");
if (i) {
o.preventDefault(), o.stopPropagation(), o.stopImmediatePropagation(), B = i;
const t = i.getAttribute("data-math-formula") || "", c = i.getAttribute("data-math-format") || "latex", s = i.classList.contains("math-formula");
q({ formula: t, format: c, inline: s });
const e = (r) => {
const s = r.target.closest(".math-formula, .math-block");
if (s) {
r.preventDefault(), r.stopPropagation(), r.stopImmediatePropagation(), h(), B = s;
const o = s.getAttribute("data-math-formula") || "", d = s.getAttribute("data-math-format") || "latex", c = s.classList.contains("math-formula");
j({ formula: o, format: d, inline: c });
}
}, l = () => {
document.addEventListener("dblclick", a, { capture: !0 });
}, t = () => {
document.addEventListener("dblclick", e, { capture: !0 });
};
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", l) : setTimeout(l, 100);
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", t) : setTimeout(t, 100);
}
const K = () => ({
const ne = () => ({
name: "math",
init: Y,
toolbar: [

@@ -282,5 +354,5 @@ {

commands: {
insertMath: (a, l) => {
const o = l?.contentElement instanceof HTMLElement ? l.contentElement : null;
return q(void 0, o), !0;
insertMath: (e, t) => {
const r = t?.contentElement instanceof HTMLElement ? t.contentElement : null;
return j(void 0, r), !0;
}

@@ -293,3 +365,3 @@ },

export {
K as MathPlugin
ne as MathPlugin
};

@@ -1,2 +0,2 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=".rte-content, .editora-content",Q='[data-theme="dark"], .dark, .editora-theme-dark',ee={title:"Insert Merge Tag",searchPlaceholder:"Search merge tags...",emptyStateText:"No merge tags found",cancelText:"Cancel",insertText:"Insert",showPreview:!0};function te(){return[{id:"USER",name:"User",tags:[{key:"first_name",label:"First Name",category:"User",preview:"John"},{key:"last_name",label:"Last Name",category:"User",preview:"Doe"},{key:"email",label:"Email",category:"User",preview:"john@example.com"},{key:"phone",label:"Phone",category:"User",preview:"+1-555-1234"},{key:"full_name",label:"Full Name",category:"User",preview:"John Doe"},{key:"username",label:"Username",category:"User",preview:"johndoe"}]},{id:"COMPANY",name:"Company",tags:[{key:"company_name",label:"Company Name",category:"Company",preview:"Acme Corp"},{key:"company_address",label:"Company Address",category:"Company",preview:"123 Main St"},{key:"company_phone",label:"Company Phone",category:"Company",preview:"+1-555-0000"},{key:"company_email",label:"Company Email",category:"Company",preview:"info@acme.com"}]},{id:"DATE",name:"Date",tags:[{key:"today",label:"Today",category:"Date",preview:new Date().toLocaleDateString()},{key:"tomorrow",label:"Tomorrow",category:"Date",preview:new Date(Date.now()+864e5).toLocaleDateString()},{key:"next_week",label:"Next Week",category:"Date",preview:new Date(Date.now()+6048e5).toLocaleDateString()}]},{id:"CUSTOM",name:"Custom",tags:[]}]}function I(t,r){return t.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`CATEGORY_${r+1}`}function re(t,r){return(t.key||t.value||t.label).trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`tag_${r+1}`}function ne(t){const r=(()=>{if(Array.isArray(t?.categories)&&t.categories.length>0)return t.categories;if(Array.isArray(t?.tags)&&t.tags.length>0){const c=new Map;return t.tags.forEach(d=>{const g=(d.category||"Custom").trim()||"Custom",i=c.get(g);i?i.push(d):c.set(g,[d])}),Array.from(c.entries()).map(([d,g],i)=>({id:I(d,i),name:d,tags:g}))}return te()})(),e={},n=[];if(r.forEach((c,d)=>{const g=I(c.id||c.name,d);n.push(g),e[g]={name:c.name,tags:(Array.isArray(c.tags)?c.tags:[]).map((i,b)=>{const u=re(i,b),f=(i.category||c.name).trim()||c.name;return{...i,key:u,category:f,categoryKey:g,searchIndex:`${i.label} ${u} ${f} ${i.description??""} ${i.value??""}`.toLowerCase()}})}}),n.length===0){const c="CUSTOM";n.push(c),e[c]={name:"Custom",tags:[]}}const a=t?.defaultCategory?I(t.defaultCategory,0):null,l=a&&n.includes(a)?a:n[0];return{categoriesByKey:e,categoryKeys:n,defaultCategory:l}}function ae(t){const r=t?.tokenTemplate;return typeof r=="function"?e=>{const n=r(e);return typeof n=="string"&&n.trim()?n:e.value?.trim()||`{{ ${e.label} }}`}:typeof r=="string"&&r.trim()?e=>r.replace(/\{key\}/gi,e.key).replace(/\{label\}/gi,e.label).replace(/\{category\}/gi,e.category).replace(/\{value\}/gi,e.value??""):e=>e.value?.trim()||`{{ ${e.label} }}`}function oe(t){return{catalog:ne(t),dialog:{...ee,...t?.dialog||{}},formatToken:ae(t)}}let $=!1,K=!1,S=null,N=null,E=null,H=!1;function J(t,r){if(r===t.innerHTML)return;const e=window.execEditorCommand||window.executeEditorCommand;if(typeof e=="function")try{e("recordDomTransaction",t,r,t.innerHTML)}catch{}}function R(){if($||typeof document>"u")return;$=!0;const t=document.createElement("style");t.id="merge-tag-plugin-styles",t.textContent=`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const E=".rte-content, .editora-content",te='[data-theme="dark"], .dark, .editora-theme-dark',re={title:"Insert Merge Tag",searchPlaceholder:"Search merge tags...",emptyStateText:"No merge tags found",cancelText:"Cancel",insertText:"Insert",showPreview:!0};function ne(){return[{id:"USER",name:"User",tags:[{key:"first_name",label:"First Name",category:"User",preview:"John"},{key:"last_name",label:"Last Name",category:"User",preview:"Doe"},{key:"email",label:"Email",category:"User",preview:"john@example.com"},{key:"phone",label:"Phone",category:"User",preview:"+1-555-1234"},{key:"full_name",label:"Full Name",category:"User",preview:"John Doe"},{key:"username",label:"Username",category:"User",preview:"johndoe"}]},{id:"COMPANY",name:"Company",tags:[{key:"company_name",label:"Company Name",category:"Company",preview:"Acme Corp"},{key:"company_address",label:"Company Address",category:"Company",preview:"123 Main St"},{key:"company_phone",label:"Company Phone",category:"Company",preview:"+1-555-0000"},{key:"company_email",label:"Company Email",category:"Company",preview:"info@acme.com"}]},{id:"DATE",name:"Date",tags:[{key:"today",label:"Today",category:"Date",preview:new Date().toLocaleDateString()},{key:"tomorrow",label:"Tomorrow",category:"Date",preview:new Date(Date.now()+864e5).toLocaleDateString()},{key:"next_week",label:"Next Week",category:"Date",preview:new Date(Date.now()+6048e5).toLocaleDateString()}]},{id:"CUSTOM",name:"Custom",tags:[]}]}function R(t,r){return t.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`CATEGORY_${r+1}`}function ae(t,r){return(t.key||t.value||t.label).trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`tag_${r+1}`}function oe(t){const r=(()=>{if(Array.isArray(t?.categories)&&t.categories.length>0)return t.categories;if(Array.isArray(t?.tags)&&t.tags.length>0){const c=new Map;return t.tags.forEach(d=>{const g=(d.category||"Custom").trim()||"Custom",i=c.get(g);i?i.push(d):c.set(g,[d])}),Array.from(c.entries()).map(([d,g],i)=>({id:R(d,i),name:d,tags:g}))}return ne()})(),e={},n=[];if(r.forEach((c,d)=>{const g=R(c.id||c.name,d);n.push(g),e[g]={name:c.name,tags:(Array.isArray(c.tags)?c.tags:[]).map((i,b)=>{const u=ae(i,b),f=(i.category||c.name).trim()||c.name;return{...i,key:u,category:f,categoryKey:g,searchIndex:`${i.label} ${u} ${f} ${i.description??""} ${i.value??""}`.toLowerCase()}})}}),n.length===0){const c="CUSTOM";n.push(c),e[c]={name:"Custom",tags:[]}}const a=t?.defaultCategory?R(t.defaultCategory,0):null,l=a&&n.includes(a)?a:n[0];return{categoriesByKey:e,categoryKeys:n,defaultCategory:l}}function le(t){const r=t?.tokenTemplate;return typeof r=="function"?e=>{const n=r(e);return typeof n=="string"&&n.trim()?n:e.value?.trim()||`{{ ${e.label} }}`}:typeof r=="string"&&r.trim()?e=>r.replace(/\{key\}/gi,e.key).replace(/\{label\}/gi,e.label).replace(/\{category\}/gi,e.category).replace(/\{value\}/gi,e.value??""):e=>e.value?.trim()||`{{ ${e.label} }}`}function ce(t){return{catalog:oe(t),dialog:{...re,...t?.dialog||{}},formatToken:le(t)}}let j=!1,H=!1,L=null,S=null,w=null,q=!1,y=null;function X(t,r){if(r===t.innerHTML)return;const e=window.execEditorCommand||window.executeEditorCommand;if(typeof e=="function")try{e("recordDomTransaction",t,r,t.innerHTML)}catch{}}function _(){if(j||typeof document>"u")return;j=!0;const t=document.createElement("style");t.id="merge-tag-plugin-styles",t.textContent=`
.rte-merge-tag-overlay {

@@ -120,2 +120,8 @@ --rte-mt-overlay-bg: rgba(15, 23, 36, 0.56);

.rte-merge-tag.rte-merge-tag-selected {
outline: 2px solid #2563eb;
outline-offset: 2px;
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}
:is([data-theme="dark"], .dark, .editora-theme-dark) .rte-merge-tag {

@@ -126,2 +132,2 @@ background: #223247;

}
`,document.head.appendChild(t)}function j(){K||typeof document>"u"||(K=!0,document.addEventListener("focusin",t=>{const e=t.target?.closest(h);e&&(S=e)}),document.addEventListener("selectionchange",()=>{const t=Y();t&&(S=t)}))}function Y(){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const e=t.getRangeAt(0).startContainer;return(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest(h)||null}function X(){const t=Y();if(t)return t;const e=document.activeElement?.closest(h);return e||(S?.isConnected?S:document.querySelector(h))}function le(t){const r=t.parentNode;if(!r)return;const e=window.getSelection();if(!e)return;const n=document.createRange(),l=Array.from(r.childNodes).indexOf(t);l<0||(n.setStart(r,l),n.setEnd(r,l+1),e.removeAllRanges(),e.addRange(n))}function q(t,r){t instanceof Text&&t.data.length!==0&&(r?(t.data.startsWith(" ")||t.data.startsWith(" "))&&t.deleteData(0,1):(t.data.endsWith(" ")||t.data.endsWith(" "))&&t.deleteData(t.data.length-1,1),t.data.length===0&&t.parentNode?.removeChild(t))}function W(t,r){const e=window.getSelection();if(!e)return;const n=document.createRange(),a=Math.max(0,Math.min(r,t.childNodes.length));n.setStart(t,a),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}function ce(t,r){const e=t.closest(h),n=e?.innerHTML??"",a=t.parentNode;if(!a)return!1;const c=Array.from(a.childNodes).indexOf(t);if(c<0)return!1;const d=t.previousSibling,g=t.nextSibling;return a.removeChild(t),r==="Backspace"?(q(g,!0),W(a,c)):(q(d,!1),W(a,c)),e&&(J(e,n),e.dispatchEvent(new Event("input",{bubbles:!0}))),!0}function ie(t){if(t.collapsed||!(t.startContainer instanceof HTMLElement||t.startContainer instanceof Text)||t.startContainer!==t.endContainer||t.endOffset!==t.startOffset+1)return null;const r=t.startContainer;if(!(r instanceof Element||r instanceof DocumentFragment))return null;const e=r.childNodes[t.startOffset];return e instanceof HTMLElement&&e.classList.contains("rte-merge-tag")?e:null}function se(t,r){if(!t.collapsed)return null;const{startContainer:e,startOffset:n}=t,a=l=>l instanceof HTMLElement&&l.classList.contains("rte-merge-tag")?l:null;if(e.nodeType===Node.ELEMENT_NODE){const l=e;return r==="Backspace"&&n>0?a(l.childNodes[n-1]||null):r==="Delete"?a(l.childNodes[n]||null):null}if(e.nodeType===Node.TEXT_NODE){const l=e;return r==="Backspace"?n===0?a(l.previousSibling):n===1&&(l.data[0]===" "||l.data[0]===" ")&&l.previousSibling instanceof HTMLElement&&l.previousSibling.classList.contains("rte-merge-tag")?l.previousSibling:null:n===l.data.length?a(l.nextSibling):null}return null}function V(){H||typeof document>"u"||(H=!0,document.addEventListener("click",t=>{const e=t.target?.closest(".rte-merge-tag");if(!e)return;const n=e.closest(h);n&&(t.preventDefault(),t.stopPropagation(),n.focus({preventScroll:!0}),le(e))}),document.addEventListener("keydown",t=>{if(t.key!=="Backspace"&&t.key!=="Delete")return;const r=window.getSelection();if(!r||r.rangeCount===0)return;const e=r.getRangeAt(0),n=X();if(!n||!n.contains(e.commonAncestorContainer))return;let a=ie(e);a||(a=se(e,t.key)),a&&(t.preventDefault(),t.stopPropagation(),ce(a,t.key))}))}function de(t){return t?!!t.closest(Q):!1}function ge(){E&&(E(),E=null),N=null}function G(t){const r=document.createRange();return r.selectNodeContents(t),r.collapse(!1),r}function me(t,r){const e=window.getSelection(),n=r?r.cloneRange():G(t),l=n.startContainer.isConnected&&n.endContainer.isConnected&&t.contains(n.commonAncestorContainer)?n:G(t);return e&&(e.removeAllRanges(),e.addRange(l)),l}function ue(t,r){const e=document.createElement("span");e.className="rte-merge-tag",e.setAttribute("contenteditable","false"),e.setAttribute("data-key",t.key),e.setAttribute("data-category",t.category),e.setAttribute("data-label",t.label),t.value&&e.setAttribute("data-value",t.value);const n=r(t);return e.setAttribute("data-token",n),e.setAttribute("aria-label",`Merge tag: ${t.label}`),e.textContent=n,e}function fe(t,r,e,n){const a=window.getSelection();if(!a)return!1;const l=t.innerHTML;t.focus({preventScroll:!0});const c=me(t,r),g=(c.startContainer.nodeType===Node.ELEMENT_NODE?c.startContainer:c.startContainer.parentElement)?.closest(".rte-merge-tag");g&&t.contains(g)&&(c.setStartAfter(g),c.setEndAfter(g));try{c.deleteContents();const i=ue(e,n),b=document.createTextNode(" "),u=document.createDocumentFragment();u.appendChild(i),u.appendChild(b),c.insertNode(u);const f=document.createRange();return f.setStartAfter(b),f.collapse(!0),a.removeAllRanges(),a.addRange(f),J(t,l),t.dispatchEvent(new Event("input",{bubbles:!0})),!0}catch(i){return console.error("Failed to insert merge tag:",i),!1}}function pe(t,r,e){const n=t.catalog.categoriesByKey[r]?.tags||[],a=e.trim().toLowerCase();return a?n.filter(l=>l.searchIndex.includes(a)):n}function be(t,r){ge(),R();const e={category:r.catalog.defaultCategory,searchTerm:"",filteredTags:r.catalog.categoriesByKey[r.catalog.defaultCategory]?.tags||[],selectedIndex:0,savedRange:(()=>{const o=window.getSelection();if(!o||o.rangeCount===0)return null;const s=o.getRangeAt(0);return t.contains(s.commonAncestorContainer)?s.cloneRange():null})(),searchRaf:null},n=document.createElement("div");n.className="rte-merge-tag-overlay",n.setAttribute("role","dialog"),n.setAttribute("aria-modal","true"),de(t)&&n.classList.add("rte-ui-theme-dark");const a=document.createElement("div");a.className="rte-merge-tag-dialog";const l=document.createElement("div");l.className="rte-merge-tag-header";const c=document.createElement("h2");c.style.margin="0",c.style.fontSize="18px",c.style.fontWeight="700",c.textContent=r.dialog.title;const d=document.createElement("button");d.className="rte-merge-tag-close",d.setAttribute("aria-label","Close"),d.style.background="none",d.style.border="none",d.style.color="inherit",d.style.cursor="pointer",d.style.fontSize="20px",d.textContent="✕",l.appendChild(c),l.appendChild(d);const g=document.createElement("div");g.className="rte-merge-tag-body";const i=document.createElement("input");i.type="text",i.className="rte-merge-tag-input",i.placeholder=r.dialog.searchPlaceholder,i.setAttribute("aria-label","Search merge tags");const b=document.createElement("div");b.className="rte-merge-tag-tabs",r.catalog.categoryKeys.forEach(o=>{const s=document.createElement("button");s.type="button",s.className="rte-merge-tag-tab",s.setAttribute("data-category",o),s.textContent=r.catalog.categoriesByKey[o]?.name||o,b.appendChild(s)});const u=document.createElement("div");u.className="rte-merge-tag-list";const f=document.createElement("div");f.className="rte-merge-tag-preview",g.appendChild(i),g.appendChild(b),g.appendChild(u),g.appendChild(f);const w=document.createElement("div");w.className="rte-merge-tag-footer";const x=document.createElement("button");x.type="button",x.className="rte-merge-tag-btn-secondary",x.textContent=r.dialog.cancelText;const y=document.createElement("button");y.type="button",y.className="rte-merge-tag-btn-primary",y.textContent=r.dialog.insertText,w.appendChild(x),w.appendChild(y),a.appendChild(l),a.appendChild(g),a.appendChild(w),n.appendChild(a),document.body.appendChild(n),N=n;const _=()=>{b.querySelectorAll(".rte-merge-tag-tab").forEach(s=>{const p=s.dataset.category===e.category;s.classList.toggle("active",p)})},L=()=>{if(e.filteredTags.length===0){e.selectedIndex=-1;return}e.selectedIndex<0&&(e.selectedIndex=0),e.selectedIndex>=e.filteredTags.length&&(e.selectedIndex=e.filteredTags.length-1)},O=()=>{if(!r.dialog.showPreview){f.style.display="none",y.disabled=e.filteredTags.length===0;return}L();const o=e.selectedIndex>=0?e.filteredTags[e.selectedIndex]:null;if(!o){f.style.display="none",y.disabled=!0;return}f.style.display="block",f.textContent=`Preview: ${r.formatToken(o)}`,y.disabled=!1},Z=()=>{if(e.selectedIndex<0)return;u.querySelector(`.rte-merge-tag-item[data-index="${e.selectedIndex}"]`)?.scrollIntoView({block:"nearest"})},k=()=>{u.querySelector(".rte-merge-tag-item.selected")?.classList.remove("selected"),e.selectedIndex>=0&&u.querySelector(`.rte-merge-tag-item[data-index="${e.selectedIndex}"]`)?.classList.add("selected"),O(),Z()},A=()=>{if(e.filteredTags=pe(r,e.category,e.searchTerm),e.filteredTags.length>0&&e.selectedIndex<0&&(e.selectedIndex=0),L(),u.innerHTML="",e.filteredTags.length===0){const s=document.createElement("div");s.className="rte-merge-tag-empty",s.textContent=r.dialog.emptyStateText,u.appendChild(s),O();return}const o=document.createDocumentFragment();e.filteredTags.forEach((s,p)=>{const m=document.createElement("div");m.className="rte-merge-tag-item",m.setAttribute("data-index",String(p)),m.classList.toggle("selected",p===e.selectedIndex);const D=document.createElement("div");if(D.className="rte-merge-tag-item-label",D.textContent=s.label,m.appendChild(D),s.preview){const M=document.createElement("div");M.className="rte-merge-tag-item-preview",M.textContent=s.preview,m.appendChild(M)}o.appendChild(m)}),u.appendChild(o),k()},z=()=>{e.searchRaf!==null&&cancelAnimationFrame(e.searchRaf),e.searchRaf=requestAnimationFrame(()=>{e.searchRaf=null,e.searchTerm=i.value,e.selectedIndex=0,A()})},v=()=>{e.searchRaf!==null&&(cancelAnimationFrame(e.searchRaf),e.searchRaf=null),n.remove(),N===n&&(N=null,E=null)},T=()=>{if(L(),e.selectedIndex<0)return;const o=e.filteredTags[e.selectedIndex];fe(t,e.savedRange,o,r.formatToken)&&v()},F=o=>{const p=o.target.closest(".rte-merge-tag-tab");if(!p)return;const m=p.dataset.category;!m||!r.catalog.categoriesByKey[m]||(e.category=m,e.searchTerm="",i.value="",e.selectedIndex=0,_(),A())},P=o=>{const p=o.target.closest(".rte-merge-tag-item");if(!p)return;const m=Number(p.dataset.index||"-1");Number.isNaN(m)||m<0||m>=e.filteredTags.length||(e.selectedIndex=m,k())},B=o=>{const p=o.target.closest(".rte-merge-tag-item");if(!p)return;const m=Number(p.dataset.index||"-1");Number.isNaN(m)||m<0||m>=e.filteredTags.length||(e.selectedIndex=m,T())},C=o=>{if(o.key==="Escape"){o.preventDefault(),v();return}if(o.key==="ArrowDown"){if(o.preventDefault(),e.filteredTags.length===0)return;e.selectedIndex=Math.min(e.filteredTags.length-1,e.selectedIndex+1),k();return}if(o.key==="ArrowUp"){if(o.preventDefault(),e.filteredTags.length===0)return;e.selectedIndex=Math.max(0,e.selectedIndex-1),k();return}o.key==="Enter"&&(o.preventDefault(),T())},U=o=>{o.target===n&&v()};b.addEventListener("click",F),u.addEventListener("click",P),u.addEventListener("dblclick",B),i.addEventListener("input",z),i.addEventListener("keydown",C),n.addEventListener("click",U),a.addEventListener("keydown",C),d?.addEventListener("click",v),x.addEventListener("click",v),y.addEventListener("click",T),E=()=>{b.removeEventListener("click",F),u.removeEventListener("click",P),u.removeEventListener("dblclick",B),i.removeEventListener("input",z),i.removeEventListener("keydown",C),n.removeEventListener("click",U),a.removeEventListener("keydown",C),d?.removeEventListener("click",v),x.removeEventListener("click",v),y.removeEventListener("click",T),e.searchRaf!==null&&(cancelAnimationFrame(e.searchRaf),e.searchRaf=null),n.remove()},_(),A(),setTimeout(()=>{i.focus()},0)}const ye=t=>({name:"mergeTag",config:t,init:()=>{R(),j(),V()},toolbar:[{label:"Merge Tag",command:"insertMergeTag",icon:"{{ }}"}],commands:{insertMergeTag:()=>{R(),j(),V();const r=X();return r?(be(r,oe(t)),!0):!1}}});exports.MergeTagPlugin=ye;
`,document.head.appendChild(t)}function W(){H||typeof document>"u"||(H=!0,document.addEventListener("focusin",t=>{const e=t.target?.closest(E);e&&(L=e)}),document.addEventListener("selectionchange",()=>{const t=Z();t&&(L=t)}))}function Z(){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const e=t.getRangeAt(0).startContainer;return(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest(E)||null}function Q(){const t=Z();if(t)return t;const e=document.activeElement?.closest(E);return e||(L?.isConnected?L:document.querySelector(E))}function O(){y&&(y.classList.remove("rte-merge-tag-selected"),y.removeAttribute("data-rte-selected-object"),y=null)}function ie(t){y!==t&&(O(),y=t,t.classList.add("rte-merge-tag-selected"),t.setAttribute("data-rte-selected-object","true")),se(t)}function se(t){const r=t.parentNode;if(!r)return;const e=window.getSelection();if(!e)return;const n=document.createRange(),l=Array.from(r.childNodes).indexOf(t);l<0||(n.setStart(r,l),n.setEnd(r,l+1),e.removeAllRanges(),e.addRange(n))}function V(t,r){t instanceof Text&&t.data.length!==0&&(r?(t.data.startsWith(" ")||t.data.startsWith(" "))&&t.deleteData(0,1):(t.data.endsWith(" ")||t.data.endsWith(" "))&&t.deleteData(t.data.length-1,1),t.data.length===0&&t.parentNode?.removeChild(t))}function G(t,r){const e=window.getSelection();if(!e)return;const n=document.createRange(),a=Math.max(0,Math.min(r,t.childNodes.length));n.setStart(t,a),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}function de(t,r){const e=t.closest(E),n=e?.innerHTML??"",a=t.parentNode;if(!a)return!1;const c=Array.from(a.childNodes).indexOf(t);if(c<0)return!1;const d=t.previousSibling,g=t.nextSibling;return a.removeChild(t),y===t&&(y=null),r==="Backspace"?(V(g,!0),G(a,c)):(V(d,!1),G(a,c)),e&&(X(e,n),e.dispatchEvent(new Event("input",{bubbles:!0}))),!0}function ge(t){if(t.collapsed||!(t.startContainer instanceof HTMLElement||t.startContainer instanceof Text)||t.startContainer!==t.endContainer||t.endOffset!==t.startOffset+1)return null;const r=t.startContainer;if(!(r instanceof Element||r instanceof DocumentFragment))return null;const e=r.childNodes[t.startOffset];return e instanceof HTMLElement&&e.classList.contains("rte-merge-tag")?e:null}function me(t,r){if(!t.collapsed)return null;const{startContainer:e,startOffset:n}=t,a=l=>l instanceof HTMLElement&&l.classList.contains("rte-merge-tag")?l:null;if(e.nodeType===Node.ELEMENT_NODE){const l=e;return r==="Backspace"&&n>0?a(l.childNodes[n-1]||null):r==="Delete"?a(l.childNodes[n]||null):null}if(e.nodeType===Node.TEXT_NODE){const l=e;return r==="Backspace"?n===0?a(l.previousSibling):n===1&&(l.data[0]===" "||l.data[0]===" ")&&l.previousSibling instanceof HTMLElement&&l.previousSibling.classList.contains("rte-merge-tag")?l.previousSibling:null:n===l.data.length?a(l.nextSibling):null}return null}function J(){q||typeof document>"u"||(q=!0,document.addEventListener("pointerdown",t=>{const e=t.target?.closest(".rte-merge-tag");if(!e){t.target?.closest?.(".rte-merge-tag-overlay")||O();return}const n=e.closest(E);n&&(t.preventDefault(),t.stopPropagation(),n.focus({preventScroll:!0}),ie(e))},!0),document.addEventListener("keydown",t=>{if(t.key==="Escape"&&y){O();return}if(t.key!=="Backspace"&&t.key!=="Delete")return;const r=window.getSelection();if(!r||r.rangeCount===0)return;const e=r.getRangeAt(0),n=Q();if(!n||!n.contains(e.commonAncestorContainer))return;let a=y?.isConnected?y:null;a&&!n.contains(a)&&(a=null),a||(a=ge(e)),a||(a=me(e,t.key)),a&&(t.preventDefault(),t.stopPropagation(),de(a,t.key))}))}function ue(t){return t?!!t.closest(te):!1}function fe(){w&&(w(),w=null),S=null}function Y(t){const r=document.createRange();return r.selectNodeContents(t),r.collapse(!1),r}function pe(t,r){const e=window.getSelection(),n=r?r.cloneRange():Y(t),l=n.startContainer.isConnected&&n.endContainer.isConnected&&t.contains(n.commonAncestorContainer)?n:Y(t);return e&&(e.removeAllRanges(),e.addRange(l)),l}function be(t,r){const e=document.createElement("span");e.className="rte-merge-tag",e.setAttribute("contenteditable","false"),e.setAttribute("data-key",t.key),e.setAttribute("data-category",t.category),e.setAttribute("data-label",t.label),t.value&&e.setAttribute("data-value",t.value);const n=r(t);return e.setAttribute("data-token",n),e.setAttribute("aria-label",`Merge tag: ${t.label}`),e.textContent=n,e}function ye(t,r,e,n){const a=window.getSelection();if(!a)return!1;const l=t.innerHTML;t.focus({preventScroll:!0});const c=pe(t,r),g=(c.startContainer.nodeType===Node.ELEMENT_NODE?c.startContainer:c.startContainer.parentElement)?.closest(".rte-merge-tag");g&&t.contains(g)&&(c.setStartAfter(g),c.setEndAfter(g));try{c.deleteContents();const i=be(e,n),b=document.createTextNode(" "),u=document.createDocumentFragment();u.appendChild(i),u.appendChild(b),c.insertNode(u);const f=document.createRange();return f.setStartAfter(b),f.collapse(!0),a.removeAllRanges(),a.addRange(f),X(t,l),t.dispatchEvent(new Event("input",{bubbles:!0})),!0}catch(i){return console.error("Failed to insert merge tag:",i),!1}}function xe(t,r,e){const n=t.catalog.categoriesByKey[r]?.tags||[],a=e.trim().toLowerCase();return a?n.filter(l=>l.searchIndex.includes(a)):n}function ve(t,r){fe(),_();const e={category:r.catalog.defaultCategory,searchTerm:"",filteredTags:r.catalog.categoriesByKey[r.catalog.defaultCategory]?.tags||[],selectedIndex:0,savedRange:(()=>{const o=window.getSelection();if(!o||o.rangeCount===0)return null;const s=o.getRangeAt(0);return t.contains(s.commonAncestorContainer)?s.cloneRange():null})(),searchRaf:null},n=document.createElement("div");n.className="rte-merge-tag-overlay",n.setAttribute("role","dialog"),n.setAttribute("aria-modal","true"),ue(t)&&n.classList.add("rte-ui-theme-dark");const a=document.createElement("div");a.className="rte-merge-tag-dialog";const l=document.createElement("div");l.className="rte-merge-tag-header";const c=document.createElement("h2");c.style.margin="0",c.style.fontSize="18px",c.style.fontWeight="700",c.textContent=r.dialog.title;const d=document.createElement("button");d.className="rte-merge-tag-close",d.setAttribute("aria-label","Close"),d.style.background="none",d.style.border="none",d.style.color="inherit",d.style.cursor="pointer",d.style.fontSize="20px",d.textContent="✕",l.appendChild(c),l.appendChild(d);const g=document.createElement("div");g.className="rte-merge-tag-body";const i=document.createElement("input");i.type="text",i.className="rte-merge-tag-input",i.placeholder=r.dialog.searchPlaceholder,i.setAttribute("aria-label","Search merge tags");const b=document.createElement("div");b.className="rte-merge-tag-tabs",r.catalog.categoryKeys.forEach(o=>{const s=document.createElement("button");s.type="button",s.className="rte-merge-tag-tab",s.setAttribute("data-category",o),s.textContent=r.catalog.categoriesByKey[o]?.name||o,b.appendChild(s)});const u=document.createElement("div");u.className="rte-merge-tag-list";const f=document.createElement("div");f.className="rte-merge-tag-preview",g.appendChild(i),g.appendChild(b),g.appendChild(u),g.appendChild(f);const T=document.createElement("div");T.className="rte-merge-tag-footer";const h=document.createElement("button");h.type="button",h.className="rte-merge-tag-btn-secondary",h.textContent=r.dialog.cancelText;const x=document.createElement("button");x.type="button",x.className="rte-merge-tag-btn-primary",x.textContent=r.dialog.insertText,T.appendChild(h),T.appendChild(x),a.appendChild(l),a.appendChild(g),a.appendChild(T),n.appendChild(a),document.body.appendChild(n),S=n;const z=()=>{b.querySelectorAll(".rte-merge-tag-tab").forEach(s=>{const p=s.dataset.category===e.category;s.classList.toggle("active",p)})},A=()=>{if(e.filteredTags.length===0){e.selectedIndex=-1;return}e.selectedIndex<0&&(e.selectedIndex=0),e.selectedIndex>=e.filteredTags.length&&(e.selectedIndex=e.filteredTags.length-1)},F=()=>{if(!r.dialog.showPreview){f.style.display="none",x.disabled=e.filteredTags.length===0;return}A();const o=e.selectedIndex>=0?e.filteredTags[e.selectedIndex]:null;if(!o){f.style.display="none",x.disabled=!0;return}f.style.display="block",f.textContent=`Preview: ${r.formatToken(o)}`,x.disabled=!1},ee=()=>{if(e.selectedIndex<0)return;u.querySelector(`.rte-merge-tag-item[data-index="${e.selectedIndex}"]`)?.scrollIntoView({block:"nearest"})},k=()=>{u.querySelector(".rte-merge-tag-item.selected")?.classList.remove("selected"),e.selectedIndex>=0&&u.querySelector(`.rte-merge-tag-item[data-index="${e.selectedIndex}"]`)?.classList.add("selected"),F(),ee()},D=()=>{if(e.filteredTags=xe(r,e.category,e.searchTerm),e.filteredTags.length>0&&e.selectedIndex<0&&(e.selectedIndex=0),A(),u.innerHTML="",e.filteredTags.length===0){const s=document.createElement("div");s.className="rte-merge-tag-empty",s.textContent=r.dialog.emptyStateText,u.appendChild(s),F();return}const o=document.createDocumentFragment();e.filteredTags.forEach((s,p)=>{const m=document.createElement("div");m.className="rte-merge-tag-item",m.setAttribute("data-index",String(p)),m.classList.toggle("selected",p===e.selectedIndex);const M=document.createElement("div");if(M.className="rte-merge-tag-item-label",M.textContent=s.label,m.appendChild(M),s.preview){const I=document.createElement("div");I.className="rte-merge-tag-item-preview",I.textContent=s.preview,m.appendChild(I)}o.appendChild(m)}),u.appendChild(o),k()},P=()=>{e.searchRaf!==null&&cancelAnimationFrame(e.searchRaf),e.searchRaf=requestAnimationFrame(()=>{e.searchRaf=null,e.searchTerm=i.value,e.selectedIndex=0,D()})},v=()=>{e.searchRaf!==null&&(cancelAnimationFrame(e.searchRaf),e.searchRaf=null),n.remove(),S===n&&(S=null,w=null)},C=()=>{if(A(),e.selectedIndex<0)return;const o=e.filteredTags[e.selectedIndex];ye(t,e.savedRange,o,r.formatToken)&&v()},B=o=>{const p=o.target.closest(".rte-merge-tag-tab");if(!p)return;const m=p.dataset.category;!m||!r.catalog.categoriesByKey[m]||(e.category=m,e.searchTerm="",i.value="",e.selectedIndex=0,z(),D())},U=o=>{const p=o.target.closest(".rte-merge-tag-item");if(!p)return;const m=Number(p.dataset.index||"-1");Number.isNaN(m)||m<0||m>=e.filteredTags.length||(e.selectedIndex=m,k())},$=o=>{const p=o.target.closest(".rte-merge-tag-item");if(!p)return;const m=Number(p.dataset.index||"-1");Number.isNaN(m)||m<0||m>=e.filteredTags.length||(e.selectedIndex=m,C())},N=o=>{if(o.key==="Escape"){o.preventDefault(),v();return}if(o.key==="ArrowDown"){if(o.preventDefault(),e.filteredTags.length===0)return;e.selectedIndex=Math.min(e.filteredTags.length-1,e.selectedIndex+1),k();return}if(o.key==="ArrowUp"){if(o.preventDefault(),e.filteredTags.length===0)return;e.selectedIndex=Math.max(0,e.selectedIndex-1),k();return}o.key==="Enter"&&(o.preventDefault(),C())},K=o=>{o.target===n&&v()};b.addEventListener("click",B),u.addEventListener("click",U),u.addEventListener("dblclick",$),i.addEventListener("input",P),i.addEventListener("keydown",N),n.addEventListener("click",K),a.addEventListener("keydown",N),d?.addEventListener("click",v),h.addEventListener("click",v),x.addEventListener("click",C),w=()=>{b.removeEventListener("click",B),u.removeEventListener("click",U),u.removeEventListener("dblclick",$),i.removeEventListener("input",P),i.removeEventListener("keydown",N),n.removeEventListener("click",K),a.removeEventListener("keydown",N),d?.removeEventListener("click",v),h.removeEventListener("click",v),x.removeEventListener("click",C),e.searchRaf!==null&&(cancelAnimationFrame(e.searchRaf),e.searchRaf=null),n.remove()},z(),D(),setTimeout(()=>{i.focus()},0)}const he=t=>({name:"mergeTag",config:t,init:()=>{_(),W(),J()},toolbar:[{label:"Merge Tag",command:"insertMergeTag",icon:"{{ }}"}],commands:{insertMergeTag:()=>{_(),W(),J();const r=Q();return r?(ve(r,ce(t)),!0):!1}}});exports.MergeTagPlugin=he;

@@ -1,2 +0,2 @@

const h = ".rte-content, .editora-content", Q = '[data-theme="dark"], .dark, .editora-theme-dark', ee = {
const E = ".rte-content, .editora-content", te = '[data-theme="dark"], .dark, .editora-theme-dark', re = {
title: "Insert Merge Tag",

@@ -9,3 +9,3 @@ searchPlaceholder: "Search merge tags...",

};
function te() {
function ne() {
return [

@@ -50,9 +50,9 @@ {

}
function M(t, r) {
function R(t, r) {
return t.trim().toUpperCase().replace(/[^A-Z0-9]+/g, "_").replace(/^_+|_+$/g, "") || `CATEGORY_${r + 1}`;
}
function re(t, r) {
function ae(t, r) {
return (t.key || t.value || t.label).trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "") || `tag_${r + 1}`;
}
function ne(t) {
function oe(t) {
const r = (() => {

@@ -67,3 +67,3 @@ if (Array.isArray(t?.categories) && t.categories.length > 0)

}), Array.from(c.entries()).map(([d, g], i) => ({
id: M(d, i),
id: R(d, i),
name: d,

@@ -73,10 +73,10 @@ tags: g

}
return te();
return ne();
})(), e = {}, n = [];
if (r.forEach((c, d) => {
const g = M(c.id || c.name, d);
const g = R(c.id || c.name, d);
n.push(g), e[g] = {
name: c.name,
tags: (Array.isArray(c.tags) ? c.tags : []).map((i, b) => {
const u = re(i, b), f = (i.category || c.name).trim() || c.name;
const u = ae(i, b), f = (i.category || c.name).trim() || c.name;
return {

@@ -95,3 +95,3 @@ ...i,

}
const a = t?.defaultCategory ? M(t.defaultCategory, 0) : null, l = a && n.includes(a) ? a : n[0];
const a = t?.defaultCategory ? R(t.defaultCategory, 0) : null, l = a && n.includes(a) ? a : n[0];
return {

@@ -103,3 +103,3 @@ categoriesByKey: e,

}
function ae(t) {
function le(t) {
const r = t?.tokenTemplate;

@@ -111,14 +111,14 @@ return typeof r == "function" ? (e) => {

}
function oe(t) {
function ce(t) {
return {
catalog: ne(t),
catalog: oe(t),
dialog: {
...ee,
...re,
...t?.dialog || {}
},
formatToken: ae(t)
formatToken: le(t)
};
}
let K = !1, P = !1, S = null, N = null, E = null, H = !1;
function J(t, r) {
let H = !1, j = !1, L = null, S = null, w = null, q = !1, y = null;
function X(t, r) {
if (r === t.innerHTML) return;

@@ -132,5 +132,5 @@ const e = window.execEditorCommand || window.executeEditorCommand;

}
function R() {
if (K || typeof document > "u") return;
K = !0;
function _() {
if (H || typeof document > "u") return;
H = !0;
const t = document.createElement("style");

@@ -256,2 +256,8 @@ t.id = "merge-tag-plugin-styles", t.textContent = `

.rte-merge-tag.rte-merge-tag-selected {
outline: 2px solid #2563eb;
outline-offset: 2px;
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}
:is([data-theme="dark"], .dark, .editora-theme-dark) .rte-merge-tag {

@@ -264,24 +270,30 @@ background: #223247;

}
function j() {
P || typeof document > "u" || (P = !0, document.addEventListener("focusin", (t) => {
const e = t.target?.closest(h);
e && (S = e);
function W() {
j || typeof document > "u" || (j = !0, document.addEventListener("focusin", (t) => {
const e = t.target?.closest(E);
e && (L = e);
}), document.addEventListener("selectionchange", () => {
const t = Y();
t && (S = t);
const t = Z();
t && (L = t);
}));
}
function Y() {
function Z() {
const t = window.getSelection();
if (!t || t.rangeCount === 0) return null;
const e = t.getRangeAt(0).startContainer;
return (e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement)?.closest(h) || null;
return (e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement)?.closest(E) || null;
}
function X() {
const t = Y();
function Q() {
const t = Z();
if (t) return t;
const e = document.activeElement?.closest(h);
return e || (S?.isConnected ? S : document.querySelector(h));
const e = document.activeElement?.closest(E);
return e || (L?.isConnected ? L : document.querySelector(E));
}
function le(t) {
function O() {
y && (y.classList.remove("rte-merge-tag-selected"), y.removeAttribute("data-rte-selected-object"), y = null);
}
function ie(t) {
y !== t && (O(), y = t, t.classList.add("rte-merge-tag-selected"), t.setAttribute("data-rte-selected-object", "true")), se(t);
}
function se(t) {
const r = t.parentNode;

@@ -294,6 +306,6 @@ if (!r) return;

}
function q(t, r) {
function V(t, r) {
t instanceof Text && t.data.length !== 0 && (r ? (t.data.startsWith(" ") || t.data.startsWith(" ")) && t.deleteData(0, 1) : (t.data.endsWith(" ") || t.data.endsWith(" ")) && t.deleteData(t.data.length - 1, 1), t.data.length === 0 && t.parentNode?.removeChild(t));
}
function W(t, r) {
function G(t, r) {
const e = window.getSelection();

@@ -304,4 +316,4 @@ if (!e) return;

}
function ce(t, r) {
const e = t.closest(h), n = e?.innerHTML ?? "", a = t.parentNode;
function de(t, r) {
const e = t.closest(E), n = e?.innerHTML ?? "", a = t.parentNode;
if (!a) return !1;

@@ -311,5 +323,5 @@ const c = Array.from(a.childNodes).indexOf(t);

const d = t.previousSibling, g = t.nextSibling;
return a.removeChild(t), r === "Backspace" ? (q(g, !0), W(a, c)) : (q(d, !1), W(a, c)), e && (J(e, n), e.dispatchEvent(new Event("input", { bubbles: !0 }))), !0;
return a.removeChild(t), y === t && (y = null), r === "Backspace" ? (V(g, !0), G(a, c)) : (V(d, !1), G(a, c)), e && (X(e, n), e.dispatchEvent(new Event("input", { bubbles: !0 }))), !0;
}
function ie(t) {
function ge(t) {
if (t.collapsed || !(t.startContainer instanceof HTMLElement || t.startContainer instanceof Text) || t.startContainer !== t.endContainer || t.endOffset !== t.startOffset + 1) return null;

@@ -321,3 +333,3 @@ const r = t.startContainer;

}
function se(t, r) {
function me(t, r) {
if (!t.collapsed) return null;

@@ -335,33 +347,40 @@ const { startContainer: e, startOffset: n } = t, a = (l) => l instanceof HTMLElement && l.classList.contains("rte-merge-tag") ? l : null;

}
function V() {
H || typeof document > "u" || (H = !0, document.addEventListener("click", (t) => {
function J() {
q || typeof document > "u" || (q = !0, document.addEventListener("pointerdown", (t) => {
const e = t.target?.closest(".rte-merge-tag");
if (!e) return;
const n = e.closest(h);
n && (t.preventDefault(), t.stopPropagation(), n.focus({ preventScroll: !0 }), le(e));
}), document.addEventListener("keydown", (t) => {
if (!e) {
t.target?.closest?.(".rte-merge-tag-overlay") || O();
return;
}
const n = e.closest(E);
n && (t.preventDefault(), t.stopPropagation(), n.focus({ preventScroll: !0 }), ie(e));
}, !0), document.addEventListener("keydown", (t) => {
if (t.key === "Escape" && y) {
O();
return;
}
if (t.key !== "Backspace" && t.key !== "Delete") return;
const r = window.getSelection();
if (!r || r.rangeCount === 0) return;
const e = r.getRangeAt(0), n = X();
const e = r.getRangeAt(0), n = Q();
if (!n || !n.contains(e.commonAncestorContainer)) return;
let a = ie(e);
a || (a = se(e, t.key)), a && (t.preventDefault(), t.stopPropagation(), ce(a, t.key));
let a = y?.isConnected ? y : null;
a && !n.contains(a) && (a = null), a || (a = ge(e)), a || (a = me(e, t.key)), a && (t.preventDefault(), t.stopPropagation(), de(a, t.key));
}));
}
function de(t) {
return t ? !!t.closest(Q) : !1;
function ue(t) {
return t ? !!t.closest(te) : !1;
}
function ge() {
E && (E(), E = null), N = null;
function fe() {
w && (w(), w = null), S = null;
}
function G(t) {
function Y(t) {
const r = document.createRange();
return r.selectNodeContents(t), r.collapse(!1), r;
}
function me(t, r) {
const e = window.getSelection(), n = r ? r.cloneRange() : G(t), l = n.startContainer.isConnected && n.endContainer.isConnected && t.contains(n.commonAncestorContainer) ? n : G(t);
function pe(t, r) {
const e = window.getSelection(), n = r ? r.cloneRange() : Y(t), l = n.startContainer.isConnected && n.endContainer.isConnected && t.contains(n.commonAncestorContainer) ? n : Y(t);
return e && (e.removeAllRanges(), e.addRange(l)), l;
}
function ue(t, r) {
function be(t, r) {
const e = document.createElement("span");

@@ -372,3 +391,3 @@ e.className = "rte-merge-tag", e.setAttribute("contenteditable", "false"), e.setAttribute("data-key", t.key), e.setAttribute("data-category", t.category), e.setAttribute("data-label", t.label), t.value && e.setAttribute("data-value", t.value);

}
function fe(t, r, e, n) {
function ye(t, r, e, n) {
const a = window.getSelection();

@@ -378,10 +397,10 @@ if (!a) return !1;

t.focus({ preventScroll: !0 });
const c = me(t, r), g = (c.startContainer.nodeType === Node.ELEMENT_NODE ? c.startContainer : c.startContainer.parentElement)?.closest(".rte-merge-tag");
const c = pe(t, r), g = (c.startContainer.nodeType === Node.ELEMENT_NODE ? c.startContainer : c.startContainer.parentElement)?.closest(".rte-merge-tag");
g && t.contains(g) && (c.setStartAfter(g), c.setEndAfter(g));
try {
c.deleteContents();
const i = ue(e, n), b = document.createTextNode(" "), u = document.createDocumentFragment();
const i = be(e, n), b = document.createTextNode(" "), u = document.createDocumentFragment();
u.appendChild(i), u.appendChild(b), c.insertNode(u);
const f = document.createRange();
return f.setStartAfter(b), f.collapse(!0), a.removeAllRanges(), a.addRange(f), J(t, l), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
return f.setStartAfter(b), f.collapse(!0), a.removeAllRanges(), a.addRange(f), X(t, l), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
} catch (i) {

@@ -391,8 +410,8 @@ return console.error("Failed to insert merge tag:", i), !1;

}
function pe(t, r, e) {
function xe(t, r, e) {
const n = t.catalog.categoriesByKey[r]?.tags || [], a = e.trim().toLowerCase();
return a ? n.filter((l) => l.searchIndex.includes(a)) : n;
}
function be(t, r) {
ge(), R();
function ve(t, r) {
fe(), _();
const e = {

@@ -411,3 +430,3 @@ category: r.catalog.defaultCategory,

}, n = document.createElement("div");
n.className = "rte-merge-tag-overlay", n.setAttribute("role", "dialog"), n.setAttribute("aria-modal", "true"), de(t) && n.classList.add("rte-ui-theme-dark");
n.className = "rte-merge-tag-overlay", n.setAttribute("role", "dialog"), n.setAttribute("aria-modal", "true"), ue(t) && n.classList.add("rte-ui-theme-dark");
const a = document.createElement("div");

@@ -434,9 +453,9 @@ a.className = "rte-merge-tag-dialog";

f.className = "rte-merge-tag-preview", g.appendChild(i), g.appendChild(b), g.appendChild(u), g.appendChild(f);
const w = document.createElement("div");
w.className = "rte-merge-tag-footer";
const v = document.createElement("button");
v.type = "button", v.className = "rte-merge-tag-btn-secondary", v.textContent = r.dialog.cancelText;
const y = document.createElement("button");
y.type = "button", y.className = "rte-merge-tag-btn-primary", y.textContent = r.dialog.insertText, w.appendChild(v), w.appendChild(y), a.appendChild(l), a.appendChild(g), a.appendChild(w), n.appendChild(a), document.body.appendChild(n), N = n;
const _ = () => {
const T = document.createElement("div");
T.className = "rte-merge-tag-footer";
const h = document.createElement("button");
h.type = "button", h.className = "rte-merge-tag-btn-secondary", h.textContent = r.dialog.cancelText;
const x = document.createElement("button");
x.type = "button", x.className = "rte-merge-tag-btn-primary", x.textContent = r.dialog.insertText, T.appendChild(h), T.appendChild(x), a.appendChild(l), a.appendChild(g), a.appendChild(T), n.appendChild(a), document.body.appendChild(n), S = n;
const z = () => {
b.querySelectorAll(".rte-merge-tag-tab").forEach((s) => {

@@ -446,3 +465,3 @@ const p = s.dataset.category === e.category;

});
}, L = () => {
}, A = () => {
if (e.filteredTags.length === 0) {

@@ -453,23 +472,23 @@ e.selectedIndex = -1;

e.selectedIndex < 0 && (e.selectedIndex = 0), e.selectedIndex >= e.filteredTags.length && (e.selectedIndex = e.filteredTags.length - 1);
}, O = () => {
}, F = () => {
if (!r.dialog.showPreview) {
f.style.display = "none", y.disabled = e.filteredTags.length === 0;
f.style.display = "none", x.disabled = e.filteredTags.length === 0;
return;
}
L();
A();
const o = e.selectedIndex >= 0 ? e.filteredTags[e.selectedIndex] : null;
if (!o) {
f.style.display = "none", y.disabled = !0;
f.style.display = "none", x.disabled = !0;
return;
}
f.style.display = "block", f.textContent = `Preview: ${r.formatToken(o)}`, y.disabled = !1;
}, Z = () => {
f.style.display = "block", f.textContent = `Preview: ${r.formatToken(o)}`, x.disabled = !1;
}, ee = () => {
if (e.selectedIndex < 0) return;
u.querySelector(`.rte-merge-tag-item[data-index="${e.selectedIndex}"]`)?.scrollIntoView({ block: "nearest" });
}, k = () => {
u.querySelector(".rte-merge-tag-item.selected")?.classList.remove("selected"), e.selectedIndex >= 0 && u.querySelector(`.rte-merge-tag-item[data-index="${e.selectedIndex}"]`)?.classList.add("selected"), O(), Z();
}, A = () => {
if (e.filteredTags = pe(r, e.category, e.searchTerm), e.filteredTags.length > 0 && e.selectedIndex < 0 && (e.selectedIndex = 0), L(), u.innerHTML = "", e.filteredTags.length === 0) {
u.querySelector(".rte-merge-tag-item.selected")?.classList.remove("selected"), e.selectedIndex >= 0 && u.querySelector(`.rte-merge-tag-item[data-index="${e.selectedIndex}"]`)?.classList.add("selected"), F(), ee();
}, D = () => {
if (e.filteredTags = xe(r, e.category, e.searchTerm), e.filteredTags.length > 0 && e.selectedIndex < 0 && (e.selectedIndex = 0), A(), u.innerHTML = "", e.filteredTags.length === 0) {
const s = document.createElement("div");
s.className = "rte-merge-tag-empty", s.textContent = r.dialog.emptyStateText, u.appendChild(s), O();
s.className = "rte-merge-tag-empty", s.textContent = r.dialog.emptyStateText, u.appendChild(s), F();
return;

@@ -481,4 +500,4 @@ }

m.className = "rte-merge-tag-item", m.setAttribute("data-index", String(p)), m.classList.toggle("selected", p === e.selectedIndex);
const D = document.createElement("div");
if (D.className = "rte-merge-tag-item-label", D.textContent = s.label, m.appendChild(D), s.preview) {
const M = document.createElement("div");
if (M.className = "rte-merge-tag-item-label", M.textContent = s.label, m.appendChild(M), s.preview) {
const I = document.createElement("div");

@@ -489,18 +508,18 @@ I.className = "rte-merge-tag-item-preview", I.textContent = s.preview, m.appendChild(I);

}), u.appendChild(o), k();
}, z = () => {
}, B = () => {
e.searchRaf !== null && cancelAnimationFrame(e.searchRaf), e.searchRaf = requestAnimationFrame(() => {
e.searchRaf = null, e.searchTerm = i.value, e.selectedIndex = 0, A();
e.searchRaf = null, e.searchTerm = i.value, e.selectedIndex = 0, D();
});
}, x = () => {
e.searchRaf !== null && (cancelAnimationFrame(e.searchRaf), e.searchRaf = null), n.remove(), N === n && (N = null, E = null);
}, T = () => {
if (L(), e.selectedIndex < 0) return;
}, v = () => {
e.searchRaf !== null && (cancelAnimationFrame(e.searchRaf), e.searchRaf = null), n.remove(), S === n && (S = null, w = null);
}, C = () => {
if (A(), e.selectedIndex < 0) return;
const o = e.filteredTags[e.selectedIndex];
fe(t, e.savedRange, o, r.formatToken) && x();
}, F = (o) => {
ye(t, e.savedRange, o, r.formatToken) && v();
}, U = (o) => {
const p = o.target.closest(".rte-merge-tag-tab");
if (!p) return;
const m = p.dataset.category;
!m || !r.catalog.categoriesByKey[m] || (e.category = m, e.searchTerm = "", i.value = "", e.selectedIndex = 0, _(), A());
}, B = (o) => {
!m || !r.catalog.categoriesByKey[m] || (e.category = m, e.searchTerm = "", i.value = "", e.selectedIndex = 0, z(), D());
}, $ = (o) => {
const p = o.target.closest(".rte-merge-tag-item");

@@ -510,10 +529,10 @@ if (!p) return;

Number.isNaN(m) || m < 0 || m >= e.filteredTags.length || (e.selectedIndex = m, k());
}, U = (o) => {
}, K = (o) => {
const p = o.target.closest(".rte-merge-tag-item");
if (!p) return;
const m = Number(p.dataset.index || "-1");
Number.isNaN(m) || m < 0 || m >= e.filteredTags.length || (e.selectedIndex = m, T());
}, C = (o) => {
Number.isNaN(m) || m < 0 || m >= e.filteredTags.length || (e.selectedIndex = m, C());
}, N = (o) => {
if (o.key === "Escape") {
o.preventDefault(), x();
o.preventDefault(), v();
return;

@@ -531,17 +550,17 @@ }

}
o.key === "Enter" && (o.preventDefault(), T());
}, $ = (o) => {
o.target === n && x();
o.key === "Enter" && (o.preventDefault(), C());
}, P = (o) => {
o.target === n && v();
};
b.addEventListener("click", F), u.addEventListener("click", B), u.addEventListener("dblclick", U), i.addEventListener("input", z), i.addEventListener("keydown", C), n.addEventListener("click", $), a.addEventListener("keydown", C), d?.addEventListener("click", x), v.addEventListener("click", x), y.addEventListener("click", T), E = () => {
b.removeEventListener("click", F), u.removeEventListener("click", B), u.removeEventListener("dblclick", U), i.removeEventListener("input", z), i.removeEventListener("keydown", C), n.removeEventListener("click", $), a.removeEventListener("keydown", C), d?.removeEventListener("click", x), v.removeEventListener("click", x), y.removeEventListener("click", T), e.searchRaf !== null && (cancelAnimationFrame(e.searchRaf), e.searchRaf = null), n.remove();
}, _(), A(), setTimeout(() => {
b.addEventListener("click", U), u.addEventListener("click", $), u.addEventListener("dblclick", K), i.addEventListener("input", B), i.addEventListener("keydown", N), n.addEventListener("click", P), a.addEventListener("keydown", N), d?.addEventListener("click", v), h.addEventListener("click", v), x.addEventListener("click", C), w = () => {
b.removeEventListener("click", U), u.removeEventListener("click", $), u.removeEventListener("dblclick", K), i.removeEventListener("input", B), i.removeEventListener("keydown", N), n.removeEventListener("click", P), a.removeEventListener("keydown", N), d?.removeEventListener("click", v), h.removeEventListener("click", v), x.removeEventListener("click", C), e.searchRaf !== null && (cancelAnimationFrame(e.searchRaf), e.searchRaf = null), n.remove();
}, z(), D(), setTimeout(() => {
i.focus();
}, 0);
}
const ye = (t) => ({
const he = (t) => ({
name: "mergeTag",
config: t,
init: () => {
R(), j(), V();
_(), W(), J();
},

@@ -557,5 +576,5 @@ toolbar: [

insertMergeTag: () => {
R(), j(), V();
const r = X();
return r ? (be(r, oe(t)), !0) : !1;
_(), W(), J();
const r = Q();
return r ? (ve(r, ce(t)), !0) : !1;
}

@@ -565,3 +584,3 @@ }

export {
ye as MergeTagPlugin
he as MergeTagPlugin
};

@@ -1,2 +0,2 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=".rte-content, .editora-content",ae="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",ke="__editoraCommandEditorRoot",we="rte-pii-redaction-styles",u="rte-pii-redaction-panel",k="pii-redaction",v="piiRedaction",$=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',pe=typeof NodeFilter<"u"?NodeFilter.SHOW_TEXT:4,Ne=["email","phone","ssn","credit-card","ipv4","api-key","jwt"],Oe={panelTitle:"PII Redaction",panelAriaLabel:"PII redaction panel",scanText:"Scan PII",redactAllText:"Redact All",redactText:"Redact",locateText:"Locate",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",noFindingsText:"No PII detected in the document.",summaryPrefix:"Findings",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+I/U/M/Y",readonlyRedactionText:"Editor is read-only. Reopen editable mode to redact.",matchLabel:"Detected",maskedLabel:"Masked",excerptLabel:"Context"},ze={email:{label:"Email",severity:"medium",pattern:/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi},phone:{label:"Phone",severity:"medium",pattern:/\b(?:\+?\d{1,3}[\s.-]?)?(?:\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4})\b/g},ssn:{label:"SSN",severity:"high",pattern:/\b\d{3}-\d{2}-\d{4}\b/g},"credit-card":{label:"Credit Card",severity:"high",pattern:/\b(?:\d[ -]*?){13,19}\b/g,validator:e=>qe(e)},ipv4:{label:"IPv4",severity:"low",pattern:/\b(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)\b/g},"api-key":{label:"API Key",severity:"high",pattern:/\b(?:sk-[A-Za-z0-9]{20,}|AKIA[0-9A-Z]{16}|AIza[0-9A-Za-z\-_]{35}|ghp_[A-Za-z0-9]{36}|xox[baprs]-[A-Za-z0-9-]{10,})\b/g},jwt:{label:"JWT",severity:"high",pattern:/\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g}},f=new WeakMap,I=new WeakMap,E=new WeakMap,S=new WeakMap,te=new WeakMap,de=new WeakMap,Q=new WeakMap,m=new Map,Z=new WeakMap,q=new Set,W=new Set;let G=0,Fe=0,Ee=0,M=null,b=null,P=null,L=null,_=null,R=null,D=null;function p(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function He(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function Y(e){const t=e.flags.includes("g")?e.flags:`${e.flags}g`;return new RegExp(e.source,t)}function ge(e){return new RegExp(e.source,e.flags)}function X(e,t,n){return Math.max(t,Math.min(n,e))}function Be(e,t){return e==="high"||e==="medium"||e==="low"?e:t}function Ke(e){const t=(e||"*").slice(0,1)||"*";return/[A-Za-z0-9._%+\-\s]/.test(t)?"*":t}function ve(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function qe(e){const t=e.replace(/\D/g,"");if(t.length<13||t.length>19)return!1;let n=0,r=!1;for(let i=t.length-1;i>=0;i-=1){let o=Number(t[i]);r&&(o*=2,o>9&&(o-=9)),n+=o,r=!r}return n%10===0}function We(e,t){const n=ze[e];if(typeof t=="boolean")return{type:e,label:n.label,severity:n.severity,enabled:t,pattern:Y(n.pattern),validator:n.validator};if(!t)return{type:e,label:n.label,severity:n.severity,enabled:!0,pattern:Y(n.pattern),validator:n.validator};const r=t.pattern instanceof RegExp?Y(t.pattern):Y(n.pattern);return{type:e,label:n.label,severity:Be(t.severity,n.severity),enabled:t.enabled!==!1,pattern:r,validator:n.validator}}function ee(e={}){const t=Ne.map(r=>We(r,e.detectors?.[r])),n=t.map(r=>`${r.type}:${r.enabled?"1":"0"}:${r.severity}:${r.pattern.source}:${r.pattern.flags}`).join("|");return{enableRealtime:e.enableRealtime!==!1,debounceMs:X(Number(e.debounceMs??220),60,3e3),maxFindings:X(Number(e.maxFindings??140),1,500),maskChar:Ke(e.maskChar),revealStart:X(Number(e.revealStart??2),0,12),revealEnd:X(Number(e.revealEnd??2),0,12),redactionMode:e.redactionMode==="mask"?"mask":"token",redactionToken:(e.redactionToken||"REDACTED").trim()||"REDACTED",skipInCodeBlocks:e.skipInCodeBlocks!==!1,labels:{...Oe,...e.labels||{}},normalizeText:e.normalizeText||He,detectors:t,detectorSignature:n}}function ce(e){const t={};return e.detectors.forEach(n=>{t[n.type]={enabled:n.enabled,severity:n.severity,pattern:n.pattern}}),{enableRealtime:e.enableRealtime,debounceMs:e.debounceMs,maxFindings:e.maxFindings,maskChar:e.maskChar,revealStart:e.revealStart,revealEnd:e.revealEnd,redactionMode:e.redactionMode,redactionToken:e.redactionToken,skipInCodeBlocks:e.skipInCodeBlocks,labels:{...e.labels},normalizeText:e.normalizeText,detectors:t}}function be(e){return e.closest(ae)||e}function je(e){const t=e.closest("[data-editora-editor]");if(t&&O(t)===e)return t;let n=e;for(;n;){if(n.matches(ae)&&(n===e||O(n)===e))return n;n=n.parentElement}return be(e)}function O(e){if(!e)return null;if(e.matches(x))return e;const t=e.querySelector(x);return t instanceof HTMLElement?t:null}function Ze(){if(typeof window>"u")return null;const e=window[ke];if(!(e instanceof HTMLElement))return null;window[ke]=null;const t=O(e);if(t)return t;const n=e.closest(ae);if(n){const i=O(n);if(i)return i}const r=e.closest(x);return r instanceof HTMLElement?r:null}function J(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 Ve(e){const t=be(e);if(J(t))return!0;const n=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return J(n)?!0:J(document.documentElement)||J(document.body)}function ne(e,t){e.classList.remove("rte-pii-redaction-theme-dark"),Ve(t)&&e.classList.add("rte-pii-redaction-theme-dark")}function re(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function me(e){const t=te.get(e);typeof t=="number"&&(window.clearTimeout(t),W.delete(t),te.delete(e))}function V(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function le(e=0){return{total:0,high:0,medium:0,low:0,redactedCount:e,byType:{email:0,phone:0,ssn:0,"credit-card":0,ipv4:0,"api-key":0,jwt:0}}}function K(){Array.from(q).forEach(t=>{t.isConnected||Ie(t)})}function Ue(e){for(let t=0;t<e.length;t+=1){const n=e[t];if(!(n.type!=="childList"||n.removedNodes.length===0))for(let r=0;r<n.removedNodes.length;r+=1){const i=n.removedNodes[r];if(i.nodeType!==Node.ELEMENT_NODE)continue;const o=i;if(o.matches?.(x)||o.matches?.(`.${u}`)||o.querySelector?.(x)||o.querySelector?.(`.${u}`))return!0}}return!1}function T(e,t=!0){if(K(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const o=e.editorElement,a=O(o);if(a)return a}const n=Ze();if(n)return n;const r=window.getSelection();if(r&&r.rangeCount>0){const a=re(r.getRangeAt(0).startContainer)?.closest(x);if(a)return a}const i=document.activeElement;if(i){if(i.matches(x))return i;const o=i.closest(x);if(o)return o}return b&&b.isConnected?b:(b&&!b.isConnected&&(b=null),t?document.querySelector(x):null)}function Ie(e){me(e),m.get(e)?.remove(),m.delete(e),Z.delete(e),f.delete(e),I.delete(e),E.delete(e),S.delete(e),de.delete(e),Q.delete(e),q.delete(e),b===e&&(b=null)}function C(e,t,n){const r=je(e);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false")})}function w(e,t){f.has(e)||f.set(e,t),I.has(e)||I.set(e,[]),E.has(e)||E.set(e,le(0)),S.has(e)||S.set(e,t.enableRealtime),q.add(e)}function oe(e){return Z.get(e)===!0}function $e(e,t,n,r){if(!e)return e;if(e.length<=n+r)return t.repeat(e.length);const i=e.slice(0,n),o=r>0?e.slice(e.length-r):"";return`${i}${t.repeat(Math.max(1,e.length-n-r))}${o}`}function se(e,t,n){const r=e.replace(/\D/g,"");if(r.length===0)return e;let i=0;const o=Math.max(0,r.length-n);return e.split("").map(a=>/\d/.test(a)?(i+=1,i<=o?t:a):a).join("")}function Ge(e,t){const n=e.indexOf("@");if(n<=0)return e;const r=e.slice(0,n),i=e.slice(n+1);return r.length<=2?`${r[0]||""}${t}[at]${i}`:`${r[0]}${t.repeat(Math.max(1,r.length-2))}${r[r.length-1]}[at]${i}`}function Ye(e,t){const n=e.split(".");return n.length!==4?e:`${n[0]}.${n[1]}.${n[2]}.${t.repeat(Math.max(1,n[3].length))}`}function Te(e,t,n){return e&&(t==="email"?Ge(e,n.maskChar):t==="phone"||t==="ssn"||t==="credit-card"?se(e,n.maskChar,4):t==="ipv4"?Ye(e,n.maskChar):t==="api-key"||t==="jwt"?$e(e,n.maskChar,0,0):$e(e,n.maskChar,n.revealStart,n.revealEnd))}function Ce(e,t,n){return n.redactionMode==="mask"?Te(e,t,n):`[${n.redactionToken}:${t.toUpperCase()}]`}function Xe(e){return Ee+=1,`pii-${e}-${Date.now().toString(36)}-${Ee.toString(36)}`}function he(e,t){return t.skipInCodeBlocks?!!e.parentElement?.closest("code, pre, kbd, samp"):!1}function Je(e,t){return t.some(n=>e.start<n.end&&n.start<e.end)}function Qe(e,t,n){const r=[];t.filter(a=>a.enabled).forEach(a=>{const l=ge(a.pattern);let c=l.exec(e);for(;c&&r.length<n*5;){const d=c[0]||"",s=c.index,g=s+d.length;d&&g>s&&(!a.validator||a.validator(d))&&r.push({type:a.type,severity:a.severity,value:d,start:s,end:g}),l.lastIndex===c.index&&(l.lastIndex+=1),c=l.exec(e)}}),r.sort((a,l)=>a.start!==l.start?a.start-l.start:l.end-a.end);const o=[];for(let a=0;a<r.length&&!(o.length>=n);a+=1){const l=r[a];Je({start:l.start,end:l.end},o)||o.push(l)}return o}function ue(e,t=120){return e.length<=t?e:`${e.slice(0,t-1).trimEnd()}...`}function et(e,t,n){const r=Math.max(0,t-28),i=Math.min(e.length,n+28);return ue(e.slice(r,i).trim(),180)}function tt(e,t){const n=le(t);return n.total=e.length,e.forEach(r=>{n.byType[r.type]+=1,r.severity==="high"?n.high+=1:r.severity==="medium"?n.medium+=1:n.low+=1}),n}function ie(e,t){const n=e.querySelector(".rte-pii-redaction-live");n&&(n.textContent=t)}function z(e,t,n){const r=t.querySelector('[data-action="toggle-realtime"]');if(!r)return;const i=F(e,n);r.textContent=i?n.labels.realtimeOnText:n.labels.realtimeOffText,r.setAttribute("aria-pressed",i?"true":"false"),C(e,"togglePIIRealtime",i)}function nt(e,t){e.setAttribute("aria-label",t.labels.panelAriaLabel);const n=e.querySelector(".rte-pii-redaction-title");n&&(n.textContent=t.labels.panelTitle);const r=e.querySelector('[data-action="close"]');r&&r.setAttribute("aria-label",t.labels.closeText);const i=e.querySelector('[data-action="run-scan"]');i&&(i.textContent=t.labels.scanText);const o=e.querySelector('[data-action="redact-all"]');o&&(o.textContent=t.labels.redactAllText);const a=e.querySelector(".rte-pii-redaction-shortcut");a&&(a.textContent=t.labels.shortcutText)}function H(e){const t=m.get(e);if(!t)return;const n=f.get(e)||M;if(!n)return;const r=I.get(e)||[],i=E.get(e)||le(0),o=V(e),a=t.querySelector(".rte-pii-redaction-count"),l=t.querySelector(".rte-pii-redaction-summary"),c=t.querySelector(".rte-pii-redaction-list"),d=t.querySelector('[data-action="redact-all"]');if(!(!a||!l||!c||!d)){if(a.textContent=String(i.total),l.textContent=`${n.labels.summaryPrefix}: ${i.total} | High ${i.high} | Medium ${i.medium} | Low ${i.low} | Redacted ${i.redactedCount}`,d.disabled=o||r.length===0,o?ie(t,n.labels.readonlyRedactionText):ie(t,`${i.total} PII findings detected.`),z(e,t,n),r.length===0){c.innerHTML=`<li class="rte-pii-redaction-empty">${p(n.labels.noFindingsText)}</li>`;return}c.innerHTML=r.map(s=>{const g=s.type.toUpperCase(),A=s.suggestion||"Redact this finding before export/share.",B=`${n.labels.locateText}: ${s.match}`,y=`${n.labels.redactText}: ${s.match}`,U=o?'disabled aria-disabled="true"':"";return`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=".rte-content, .editora-content",ae="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",we="__editoraCommandEditorRoot",Ee="rte-pii-redaction-styles",u="rte-pii-redaction-panel",k="pii-redaction",v="piiRedaction",$=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',ge=typeof NodeFilter<"u"?NodeFilter.SHOW_TEXT:4,Oe=["email","phone","ssn","credit-card","ipv4","api-key","jwt"],ze={panelTitle:"PII Redaction",panelAriaLabel:"PII redaction panel",scanText:"Scan PII",redactAllText:"Redact All",redactText:"Redact",locateText:"Locate",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",noFindingsText:"No PII detected in the document.",summaryPrefix:"Findings",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+I/U/M/Y",readonlyRedactionText:"Editor is read-only. Reopen editable mode to redact.",matchLabel:"Detected",maskedLabel:"Masked",excerptLabel:"Context"},Fe={email:{label:"Email",severity:"medium",pattern:/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi},phone:{label:"Phone",severity:"medium",pattern:/\b(?:\+?\d{1,3}[\s.-]?)?(?:\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4})\b/g},ssn:{label:"SSN",severity:"high",pattern:/\b\d{3}-\d{2}-\d{4}\b/g},"credit-card":{label:"Credit Card",severity:"high",pattern:/\b(?:\d[ -]*?){13,19}\b/g,validator:e=>We(e)},ipv4:{label:"IPv4",severity:"low",pattern:/\b(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)\b/g},"api-key":{label:"API Key",severity:"high",pattern:/\b(?:sk-[A-Za-z0-9]{20,}|AKIA[0-9A-Z]{16}|AIza[0-9A-Za-z\-_]{35}|ghp_[A-Za-z0-9]{36}|xox[baprs]-[A-Za-z0-9-]{10,})\b/g},jwt:{label:"JWT",severity:"high",pattern:/\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g}},f=new WeakMap,I=new WeakMap,E=new WeakMap,S=new WeakMap,te=new WeakMap,ue=new WeakMap,Q=new WeakMap,m=new Map,Z=new WeakMap,q=new Set,W=new Set;let G=0,He=0,ve=0,M=null,b=null,P=null,L=null,_=null,R=null,D=null;function p(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Be(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function Y(e){const t=e.flags.includes("g")?e.flags:`${e.flags}g`;return new RegExp(e.source,t)}function be(e){return new RegExp(e.source,e.flags)}function X(e,t,n){return Math.max(t,Math.min(n,e))}function Ke(e,t){return e==="high"||e==="medium"||e==="low"?e:t}function qe(e){const t=(e||"*").slice(0,1)||"*";return/[A-Za-z0-9._%+\-\s]/.test(t)?"*":t}function $e(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function We(e){const t=e.replace(/\D/g,"");if(t.length<13||t.length>19)return!1;let n=0,r=!1;for(let i=t.length-1;i>=0;i-=1){let o=Number(t[i]);r&&(o*=2,o>9&&(o-=9)),n+=o,r=!r}return n%10===0}function je(e,t){const n=Fe[e];if(typeof t=="boolean")return{type:e,label:n.label,severity:n.severity,enabled:t,pattern:Y(n.pattern),validator:n.validator};if(!t)return{type:e,label:n.label,severity:n.severity,enabled:!0,pattern:Y(n.pattern),validator:n.validator};const r=t.pattern instanceof RegExp?Y(t.pattern):Y(n.pattern);return{type:e,label:n.label,severity:Ke(t.severity,n.severity),enabled:t.enabled!==!1,pattern:r,validator:n.validator}}function ee(e={}){const t=Oe.map(r=>je(r,e.detectors?.[r])),n=t.map(r=>`${r.type}:${r.enabled?"1":"0"}:${r.severity}:${r.pattern.source}:${r.pattern.flags}`).join("|");return{enableRealtime:e.enableRealtime!==!1,debounceMs:X(Number(e.debounceMs??220),60,3e3),maxFindings:X(Number(e.maxFindings??140),1,500),maskChar:qe(e.maskChar),revealStart:X(Number(e.revealStart??2),0,12),revealEnd:X(Number(e.revealEnd??2),0,12),redactionMode:e.redactionMode==="mask"?"mask":"token",redactionToken:(e.redactionToken||"REDACTED").trim()||"REDACTED",skipInCodeBlocks:e.skipInCodeBlocks!==!1,labels:{...ze,...e.labels||{}},normalizeText:e.normalizeText||Be,detectors:t,detectorSignature:n}}function se(e){const t={};return e.detectors.forEach(n=>{t[n.type]={enabled:n.enabled,severity:n.severity,pattern:n.pattern}}),{enableRealtime:e.enableRealtime,debounceMs:e.debounceMs,maxFindings:e.maxFindings,maskChar:e.maskChar,revealStart:e.revealStart,revealEnd:e.revealEnd,redactionMode:e.redactionMode,redactionToken:e.redactionToken,skipInCodeBlocks:e.skipInCodeBlocks,labels:{...e.labels},normalizeText:e.normalizeText,detectors:t}}function me(e){return e.closest(ae)||e}function Ze(e){const t=e.closest("[data-editora-editor]");if(t&&O(t)===e)return t;let n=e;for(;n;){if(n.matches(ae)&&(n===e||O(n)===e))return n;n=n.parentElement}return me(e)}function O(e){if(!e)return null;if(e.matches(x))return e;const t=e.querySelector(x);return t instanceof HTMLElement?t:null}function Ve(){if(typeof window>"u")return null;const e=window[we];if(!(e instanceof HTMLElement))return null;window[we]=null;const t=O(e);if(t)return t;const n=e.closest(ae);if(n){const i=O(n);if(i)return i}const r=e.closest(x);return r instanceof HTMLElement?r:null}function J(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 Ue(e){const t=me(e);if(J(t))return!0;const n=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return J(n)?!0:J(document.documentElement)||J(document.body)}function ne(e,t){e.classList.remove("rte-pii-redaction-theme-dark"),Ue(t)&&e.classList.add("rte-pii-redaction-theme-dark")}function re(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function he(e){const t=te.get(e);typeof t=="number"&&(window.clearTimeout(t),W.delete(t),te.delete(e))}function V(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function le(e=0){return{total:0,high:0,medium:0,low:0,redactedCount:e,byType:{email:0,phone:0,ssn:0,"credit-card":0,ipv4:0,"api-key":0,jwt:0}}}function K(){Array.from(q).forEach(t=>{t.isConnected||Te(t)})}function Ge(e){for(let t=0;t<e.length;t+=1){const n=e[t];if(!(n.type!=="childList"||n.removedNodes.length===0))for(let r=0;r<n.removedNodes.length;r+=1){const i=n.removedNodes[r];if(i.nodeType!==Node.ELEMENT_NODE)continue;const o=i;if(o.matches?.(x)||o.matches?.(`.${u}`)||o.querySelector?.(x)||o.querySelector?.(`.${u}`))return!0}}return!1}function T(e,t=!0){if(K(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const o=e.editorElement,a=O(o);if(a)return a}const n=Ve();if(n)return n;const r=window.getSelection();if(r&&r.rangeCount>0){const a=re(r.getRangeAt(0).startContainer)?.closest(x);if(a)return a}const i=document.activeElement;if(i){if(i.matches(x))return i;const o=i.closest(x);if(o)return o}return b&&b.isConnected?b:(b&&!b.isConnected&&(b=null),t?document.querySelector(x):null)}function Te(e){he(e),m.get(e)?.remove(),m.delete(e),Z.delete(e),f.delete(e),I.delete(e),E.delete(e),S.delete(e),ue.delete(e),Q.delete(e),q.delete(e),b===e&&(b=null)}function C(e,t,n){const r=Ze(e);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false")})}function w(e,t){f.has(e)||f.set(e,t),I.has(e)||I.set(e,[]),E.has(e)||E.set(e,le(0)),S.has(e)||S.set(e,t.enableRealtime),q.add(e)}function oe(e){return Z.get(e)===!0}function Ie(e,t,n,r){if(!e)return e;if(e.length<=n+r)return t.repeat(e.length);const i=e.slice(0,n),o=r>0?e.slice(e.length-r):"";return`${i}${t.repeat(Math.max(1,e.length-n-r))}${o}`}function de(e,t,n){const r=e.replace(/\D/g,"");if(r.length===0)return e;let i=0;const o=Math.max(0,r.length-n);return e.split("").map(a=>/\d/.test(a)?(i+=1,i<=o?t:a):a).join("")}function Ye(e,t){const n=e.indexOf("@");if(n<=0)return e;const r=e.slice(0,n),i=e.slice(n+1);return r.length<=2?`${r[0]||""}${t}[at]${i}`:`${r[0]}${t.repeat(Math.max(1,r.length-2))}${r[r.length-1]}[at]${i}`}function Xe(e,t){const n=e.split(".");return n.length!==4?e:`${n[0]}.${n[1]}.${n[2]}.${t.repeat(Math.max(1,n[3].length))}`}function Ce(e,t,n){return e&&(t==="email"?Ye(e,n.maskChar):t==="phone"||t==="ssn"||t==="credit-card"?de(e,n.maskChar,4):t==="ipv4"?Xe(e,n.maskChar):t==="api-key"||t==="jwt"?Ie(e,n.maskChar,0,0):Ie(e,n.maskChar,n.revealStart,n.revealEnd))}function Re(e,t,n){return n.redactionMode==="mask"?Ce(e,t,n):`[${n.redactionToken}:${t.toUpperCase()}]`}function Je(e){return ve+=1,`pii-${e}-${Date.now().toString(36)}-${ve.toString(36)}`}function xe(e,t){return t.skipInCodeBlocks?!!e.parentElement?.closest("code, pre, kbd, samp"):!1}function Qe(e,t){return t.some(n=>e.start<n.end&&n.start<e.end)}function et(e,t,n){const r=[];t.filter(a=>a.enabled).forEach(a=>{const l=be(a.pattern);let c=l.exec(e);for(;c&&r.length<n*5;){const d=c[0]||"",s=c.index,g=s+d.length;d&&g>s&&(!a.validator||a.validator(d))&&r.push({type:a.type,severity:a.severity,value:d,start:s,end:g}),l.lastIndex===c.index&&(l.lastIndex+=1),c=l.exec(e)}}),r.sort((a,l)=>a.start!==l.start?a.start-l.start:l.end-a.end);const o=[];for(let a=0;a<r.length&&!(o.length>=n);a+=1){const l=r[a];Qe({start:l.start,end:l.end},o)||o.push(l)}return o}function fe(e,t=120){return e.length<=t?e:`${e.slice(0,t-1).trimEnd()}...`}function tt(e,t,n){const r=Math.max(0,t-28),i=Math.min(e.length,n+28);return fe(e.slice(r,i).trim(),180)}function nt(e,t){const n=le(t);return n.total=e.length,e.forEach(r=>{n.byType[r.type]+=1,r.severity==="high"?n.high+=1:r.severity==="medium"?n.medium+=1:n.low+=1}),n}function ie(e,t){const n=e.querySelector(".rte-pii-redaction-live");n&&(n.textContent=t)}function z(e,t,n){const r=t.querySelector('[data-action="toggle-realtime"]');if(!r)return;const i=F(e,n);r.textContent=i?n.labels.realtimeOnText:n.labels.realtimeOffText,r.setAttribute("aria-pressed",i?"true":"false"),C(e,"togglePIIRealtime",i)}function rt(e,t){e.setAttribute("aria-label",t.labels.panelAriaLabel);const n=e.querySelector(".rte-pii-redaction-title");n&&(n.textContent=t.labels.panelTitle);const r=e.querySelector('[data-action="close"]');r&&r.setAttribute("aria-label",t.labels.closeText);const i=e.querySelector('[data-action="run-scan"]');i&&(i.textContent=t.labels.scanText);const o=e.querySelector('[data-action="redact-all"]');o&&(o.textContent=t.labels.redactAllText);const a=e.querySelector(".rte-pii-redaction-shortcut");a&&(a.textContent=t.labels.shortcutText)}function H(e){const t=m.get(e);if(!t)return;const n=f.get(e)||M;if(!n)return;const r=I.get(e)||[],i=E.get(e)||le(0),o=V(e),a=t.querySelector(".rte-pii-redaction-count"),l=t.querySelector(".rte-pii-redaction-summary"),c=t.querySelector(".rte-pii-redaction-list"),d=t.querySelector('[data-action="redact-all"]');if(!(!a||!l||!c||!d)){if(a.textContent=String(i.total),l.textContent=`${n.labels.summaryPrefix}: ${i.total} | High ${i.high} | Medium ${i.medium} | Low ${i.low} | Redacted ${i.redactedCount}`,d.disabled=o||r.length===0,o?ie(t,n.labels.readonlyRedactionText):ie(t,`${i.total} PII findings detected.`),z(e,t,n),r.length===0){c.innerHTML=`<li class="rte-pii-redaction-empty">${p(n.labels.noFindingsText)}</li>`;return}c.innerHTML=r.map(s=>{const g=s.type.toUpperCase(),A=s.suggestion||"Redact this finding before export/share.",B=`${n.labels.locateText}: ${s.match}`,y=`${n.labels.redactText}: ${s.match}`,U=o?'disabled aria-disabled="true"':"";return`
<li class="rte-pii-redaction-item rte-pii-redaction-item-${s.severity}">

@@ -14,4 +14,4 @@ <button

</button>
<p class="rte-pii-redaction-line"><strong>${p(n.labels.matchLabel)}:</strong> ${p(ue(s.match,80))}</p>
<p class="rte-pii-redaction-line"><strong>${p(n.labels.maskedLabel)}:</strong> ${p(ue(s.masked,80))}</p>
<p class="rte-pii-redaction-line"><strong>${p(n.labels.matchLabel)}:</strong> ${p(fe(s.match,80))}</p>
<p class="rte-pii-redaction-line"><strong>${p(n.labels.maskedLabel)}:</strong> ${p(fe(s.masked,80))}</p>
${s.excerpt?`<p class="rte-pii-redaction-line"><strong>${p(n.labels.excerptLabel)}:</strong> ${p(s.excerpt)}</p>`:""}

@@ -23,3 +23,3 @@ <p class="rte-pii-redaction-help">${p(A)}</p>

</li>
`}).join("")}}function fe(e,t){if(!t.classList.contains("show"))return;const r=be(e).getBoundingClientRect(),i=Math.min(window.innerWidth-20,390),o=Math.max(10,window.innerWidth-i-10),a=Math.min(Math.max(10,r.right-i),o),l=Math.max(10,Math.min(window.innerHeight-10-280,r.top+10));t.style.width=`${i}px`,t.style.left=`${a}px`,t.style.top=`${l}px`,t.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function F(e,t){const n=S.get(e);return typeof n=="boolean"?n:t?t.enableRealtime:!0}function Re(e,t){if(t===e.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",e,t,e.innerHTML)}catch{}}function Se(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function Me(e,t){e.dispatchEvent(new CustomEvent("editora:pii-redacted",{bubbles:!0,detail:{redactedCount:t}}))}function Ae(e,t){return(I.get(e)||[]).find(r=>r.id===t)}function rt(e){const t=m.get(e);if(t)return t;const n=f.get(e)||M||ee(),r=`rte-pii-redaction-panel-${Fe++}`,i=document.createElement("section");return i.className=u,i.id=r,i.setAttribute("role","dialog"),i.setAttribute("aria-modal","false"),i.setAttribute("aria-label",n.labels.panelAriaLabel),i.innerHTML=`
`}).join("")}}function pe(e,t){if(!t.classList.contains("show"))return;const r=me(e).getBoundingClientRect(),i=Math.min(window.innerWidth-20,390),o=Math.max(10,window.innerWidth-i-10),a=Math.min(Math.max(10,r.right-i),o),l=Math.max(10,Math.min(window.innerHeight-10-280,r.top+10));t.style.width=`${i}px`,t.style.left=`${a}px`,t.style.top=`${l}px`,t.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function F(e,t){const n=S.get(e);return typeof n=="boolean"?n:t?t.enableRealtime:!0}function Se(e,t){if(t===e.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",e,t,e.innerHTML)}catch{}}function Me(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function Ae(e,t){e.dispatchEvent(new CustomEvent("editora:pii-redacted",{bubbles:!0,detail:{redactedCount:t}}))}function Pe(e,t){return(I.get(e)||[]).find(r=>r.id===t)}function ot(e){const t=m.get(e);if(t)return t;const n=f.get(e)||M||ee(),r=`rte-pii-redaction-panel-${He++}`,i=document.createElement("section");return i.className=u,i.id=r,i.setAttribute("role","dialog"),i.setAttribute("aria-modal","false"),i.setAttribute("aria-label",n.labels.panelAriaLabel),i.innerHTML=`
<header class="rte-pii-redaction-header">

@@ -43,3 +43,3 @@ <h2 class="rte-pii-redaction-title">${p(n.labels.panelTitle)}</h2>

</div>
`,i.addEventListener("click",o=>{const l=o.target?.closest("[data-action]");if(!l)return;const c=l.getAttribute("data-action")||"",d=f.get(e)||M||n;if(f.set(e,d),w(e,d),c==="close"){j(e,!0);return}if(c==="run-scan"){h(e,d,!0);return}if(c==="toggle-realtime"){const s=!F(e,d);S.set(e,s),z(e,i,d),s&&h(e,d,!0);return}if(c==="redact-all"){xe(e,d);return}if(c==="locate-finding"){const s=l.getAttribute("data-finding-id")||"",g=Ae(e,s);if(!g)return;at(e,g,d);return}if(c==="redact-finding"){const s=l.getAttribute("data-finding-id")||"";_e(e,s,d)}}),i.addEventListener("keydown",o=>{if(o.key==="Escape"){o.preventDefault(),j(e,!0);return}if(o.key!=="ArrowDown"&&o.key!=="ArrowUp")return;const a=Array.from(i.querySelectorAll('[data-role="finding-button"]'));if(a.length===0)return;const l=document.activeElement,c=a.findIndex(g=>g===l);if(c===-1)return;o.preventDefault();const d=o.key==="ArrowDown"?1:-1,s=(c+d+a.length)%a.length;a[s].focus()}),ne(i,e),document.body.appendChild(i),m.set(e,i),Z.set(e,!1),H(e),i}function j(e,t=!1){const n=m.get(e);n&&(n.classList.remove("show"),Z.set(e,!1),C(e,"togglePIIRedactionPanel",!1),t&&e.focus({preventScroll:!0}))}function N(e){K();const t=rt(e);m.forEach((r,i)=>{i!==e&&j(i,!1)}),t.classList.add("show"),Z.set(e,!0),C(e,"togglePIIRedactionPanel",!0),ne(t,e),fe(e,t),H(e),t.querySelector('[data-action="run-scan"]')?.focus()}function Pe(e,t){const n=oe(e);return(typeof t=="boolean"?t:!n)?N(e):j(e),!0}function ot(e,t){const n=t.normalizeText(e.innerText||e.textContent||""),r=e.innerHTML;return`${n.length}:${ve(n)}:${r.length}:${ve(r)}:${t.detectorSignature}`}function it(e,t){const n=[],r=ge(e.pattern);let i=r.exec(t);for(;i;){const o=i[0]||"",a=i.index,l=a+o.length;o&&l>a&&(!e.validator||e.validator(o))&&n.push({value:o,start:a,end:l}),r.lastIndex===i.index&&(r.lastIndex+=1),i=r.exec(t)}return n}function Le(e,t,n){const r=n.detectors.find(c=>c.type===t.type&&c.enabled);if(!r)return null;const i=t.match.toLowerCase();let o=0;const a=document.createTreeWalker(e,pe,null);let l=a.nextNode();for(;l;){if(!he(l,n)){const c=it(r,l.data);for(let d=0;d<c.length;d+=1){const s=c[d];if(s.value.toLowerCase()===i&&(o+=1,o===t.occurrence)){const g=document.createRange();return g.setStart(l,s.start),g.setEnd(l,s.end),g}}}l=a.nextNode()}return null}function at(e,t,n){const r=Le(e,t,n);if(!r)return!1;const i=window.getSelection();return i?(i.removeAllRanges(),i.addRange(r),re(r.startContainer)?.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),e.focus({preventScroll:!0}),!0):!1}async function h(e,t,n=!1){w(e,t);const r=ot(e,t);if(!n&&de.get(e)===r)return I.get(e)||[];const i=(Q.get(e)||0)+1;Q.set(e,i);const o=[],a=new Map,l=document.createTreeWalker(e,pe,null);let c=l.nextNode();for(;c&&o.length<t.maxFindings;){const g=c.data||"";if(g.trim()&&!he(c,t)){const A=Qe(g,t.detectors,t.maxFindings-o.length);for(let B=0;B<A.length&&!(o.length>=t.maxFindings);B+=1){const y=A[B],U=`${y.type}:${y.value.toLowerCase()}`,ye=(a.get(U)||0)+1;a.set(U,ye),o.push({id:Xe(y.type),type:y.type,severity:y.severity,match:y.value,masked:Te(y.value,y.type,t),occurrence:ye,excerpt:et(g,y.start,y.end),suggestion:"Review and redact this value before external sharing."})}}c=l.nextNode()}if(Q.get(e)!==i)return I.get(e)||[];const d=E.get(e)?.redactedCount||0,s=tt(o,d);return de.set(e,r),I.set(e,o),E.set(e,s),H(e),e.dispatchEvent(new CustomEvent("editora:pii-scan",{bubbles:!0,detail:{findings:o,stats:s}})),o}function lt(e,t){let n=e,r=0;return t.detectors.filter(o=>o.enabled).forEach(o=>{const a=ge(o.pattern);n=n.replace(a,l=>o.validator&&!o.validator(l)?l:(r+=1,Ce(l,o.type,t)))}),{nextValue:n,count:r}}async function _e(e,t,n){if(V(e)){const d=m.get(e);return d&&ie(d,n.labels.readonlyRedactionText),!1}const r=Ae(e,t);if(!r)return!1;const i=Le(e,r,n);if(!i)return!1;const o=e.innerHTML,a=Ce(r.match,r.type,n);if(i.startContainer===i.endContainer&&i.startContainer.nodeType===Node.TEXT_NODE){const d=i.startContainer,s=d.data,g=i.startOffset,A=i.endOffset;d.data=`${s.slice(0,g)}${a}${s.slice(A)}`}else i.deleteContents(),i.insertNode(document.createTextNode(a));Se(e),Re(e,o);const l=E.get(e)?.redactedCount||0;await h(e,n,!0);const c=E.get(e);return c&&(c.redactedCount=l+1,H(e)),Me(e,1),!0}async function xe(e,t){if(V(e)){const d=m.get(e);return d&&ie(d,t.labels.readonlyRedactionText),0}(I.get(e)||[]).length===0&&await h(e,t,!0);const r=e.innerHTML;let i=0;const o=document.createTreeWalker(e,pe,null);let a=o.nextNode();for(;a;){if(he(a,t)){a=o.nextNode();continue}const d=a.data||"";if(!d){a=o.nextNode();continue}const s=lt(d,t);s.count>0&&s.nextValue!==d&&(a.data=s.nextValue,i+=s.count),a=o.nextNode()}if(i===0)return 0;Se(e),Re(e,r);const l=E.get(e)?.redactedCount||0;await h(e,t,!0);const c=E.get(e);return c&&(c.redactedCount=l+i,H(e)),Me(e,i),i}function De(e){const t=f.get(e)||M;if(!t||!F(e,t)||V(e))return;me(e);const n=window.setTimeout(()=>{W.delete(n),te.delete(e),h(e,t,!1)},t.debounceMs);W.add(n),te.set(e,n)}function ct(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="i"}function st(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="u"}function dt(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="m"}function ut(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="y"}function ft(e){const t=re(e.target);if(t){const r=t.closest(x);if(r)return r;const i=t.closest(ae);if(i){const a=O(i);if(a)return a}const o=t.closest(`.${u}`);if(o){const a=Array.from(m.entries()).find(([,l])=>l===o);if(a)return a[0]}}const n=window.getSelection();if(n&&n.rangeCount>0){const r=re(n.getRangeAt(0).startContainer)?.closest(x);if(r)return r}return null}function pt(){if(typeof document>"u"||document.getElementById(we))return;const e=document.createElement("style");e.id=we,e.textContent=`
`,i.addEventListener("click",o=>{const l=o.target?.closest("[data-action]");if(!l)return;const c=l.getAttribute("data-action")||"",d=f.get(e)||M||n;if(f.set(e,d),w(e,d),c==="close"){j(e,!0);return}if(c==="run-scan"){h(e,d,!0);return}if(c==="toggle-realtime"){const s=!F(e,d);S.set(e,s),z(e,i,d),s&&h(e,d,!0);return}if(c==="redact-all"){ye(e,d);return}if(c==="locate-finding"){const s=l.getAttribute("data-finding-id")||"",g=Pe(e,s);if(!g)return;lt(e,g,d);return}if(c==="redact-finding"){const s=l.getAttribute("data-finding-id")||"";De(e,s,d)}}),i.addEventListener("keydown",o=>{if(o.key==="Escape"){o.preventDefault(),j(e,!0);return}if(o.key!=="ArrowDown"&&o.key!=="ArrowUp")return;const a=Array.from(i.querySelectorAll('[data-role="finding-button"]'));if(a.length===0)return;const l=document.activeElement,c=a.findIndex(g=>g===l);if(c===-1)return;o.preventDefault();const d=o.key==="ArrowDown"?1:-1,s=(c+d+a.length)%a.length;a[s].focus()}),ne(i,e),document.body.appendChild(i),m.set(e,i),Z.set(e,!1),H(e),i}function j(e,t=!1){const n=m.get(e);n&&(n.classList.remove("show"),Z.set(e,!1),C(e,"togglePIIRedactionPanel",!1),t&&e.focus({preventScroll:!0}))}function N(e){K();const t=ot(e);m.forEach((r,i)=>{i!==e&&j(i,!1)}),t.classList.add("show"),Z.set(e,!0),C(e,"togglePIIRedactionPanel",!0),ne(t,e),pe(e,t),H(e),t.querySelector('[data-action="run-scan"]')?.focus()}function Le(e,t){const n=oe(e);return(typeof t=="boolean"?t:!n)?N(e):j(e),!0}function it(e,t){const n=t.normalizeText(e.innerText||e.textContent||""),r=e.innerHTML;return`${n.length}:${$e(n)}:${r.length}:${$e(r)}:${t.detectorSignature}`}function at(e,t){const n=[],r=be(e.pattern);let i=r.exec(t);for(;i;){const o=i[0]||"",a=i.index,l=a+o.length;o&&l>a&&(!e.validator||e.validator(o))&&n.push({value:o,start:a,end:l}),r.lastIndex===i.index&&(r.lastIndex+=1),i=r.exec(t)}return n}function _e(e,t,n){const r=n.detectors.find(c=>c.type===t.type&&c.enabled);if(!r)return null;const i=t.match.toLowerCase();let o=0;const a=document.createTreeWalker(e,ge,null);let l=a.nextNode();for(;l;){if(!xe(l,n)){const c=at(r,l.data);for(let d=0;d<c.length;d+=1){const s=c[d];if(s.value.toLowerCase()===i&&(o+=1,o===t.occurrence)){const g=document.createRange();return g.setStart(l,s.start),g.setEnd(l,s.end),g}}}l=a.nextNode()}return null}function lt(e,t,n){const r=_e(e,t,n);if(!r)return!1;const i=window.getSelection();return i?(i.removeAllRanges(),i.addRange(r),re(r.startContainer)?.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),e.focus({preventScroll:!0}),!0):!1}async function h(e,t,n=!1){w(e,t);const r=it(e,t);if(!n&&ue.get(e)===r)return I.get(e)||[];const i=(Q.get(e)||0)+1;Q.set(e,i);const o=[],a=new Map,l=document.createTreeWalker(e,ge,null);let c=l.nextNode();for(;c&&o.length<t.maxFindings;){const g=c.data||"";if(g.trim()&&!xe(c,t)){const A=et(g,t.detectors,t.maxFindings-o.length);for(let B=0;B<A.length&&!(o.length>=t.maxFindings);B+=1){const y=A[B],U=`${y.type}:${y.value.toLowerCase()}`,ke=(a.get(U)||0)+1;a.set(U,ke),o.push({id:Je(y.type),type:y.type,severity:y.severity,match:y.value,masked:Ce(y.value,y.type,t),occurrence:ke,excerpt:tt(g,y.start,y.end),suggestion:"Review and redact this value before external sharing."})}}c=l.nextNode()}if(Q.get(e)!==i)return I.get(e)||[];const d=E.get(e)?.redactedCount||0,s=nt(o,d);return ue.set(e,r),I.set(e,o),E.set(e,s),H(e),e.dispatchEvent(new CustomEvent("editora:pii-scan",{bubbles:!0,detail:{findings:o,stats:s}})),o}function ct(e,t){let n=e,r=0;return t.detectors.filter(o=>o.enabled).forEach(o=>{const a=be(o.pattern);n=n.replace(a,l=>o.validator&&!o.validator(l)?l:(r+=1,Re(l,o.type,t)))}),{nextValue:n,count:r}}async function De(e,t,n){if(V(e)){const d=m.get(e);return d&&ie(d,n.labels.readonlyRedactionText),!1}const r=Pe(e,t);if(!r)return!1;const i=_e(e,r,n);if(!i)return!1;const o=e.innerHTML,a=Re(r.match,r.type,n);if(i.startContainer===i.endContainer&&i.startContainer.nodeType===Node.TEXT_NODE){const d=i.startContainer,s=d.data,g=i.startOffset,A=i.endOffset;d.data=`${s.slice(0,g)}${a}${s.slice(A)}`}else i.deleteContents(),i.insertNode(document.createTextNode(a));Me(e),Se(e,o);const l=E.get(e)?.redactedCount||0;await h(e,n,!0);const c=E.get(e);return c&&(c.redactedCount=l+1,H(e)),Ae(e,1),!0}async function ye(e,t){if(V(e)){const d=m.get(e);return d&&ie(d,t.labels.readonlyRedactionText),0}(I.get(e)||[]).length===0&&await h(e,t,!0);const r=e.innerHTML;let i=0;const o=document.createTreeWalker(e,ge,null);let a=o.nextNode();for(;a;){if(xe(a,t)){a=o.nextNode();continue}const d=a.data||"";if(!d){a=o.nextNode();continue}const s=ct(d,t);s.count>0&&s.nextValue!==d&&(a.data=s.nextValue,i+=s.count),a=o.nextNode()}if(i===0)return 0;Me(e),Se(e,r);const l=E.get(e)?.redactedCount||0;await h(e,t,!0);const c=E.get(e);return c&&(c.redactedCount=l+i,H(e)),Ae(e,i),i}function Ne(e){const t=f.get(e)||M;if(!t||!F(e,t)||V(e))return;he(e);const n=window.setTimeout(()=>{W.delete(n),te.delete(e),h(e,t,!1)},t.debounceMs);W.add(n),te.set(e,n)}function ce(e){return typeof e.key=="string"?e.key.toLowerCase():""}function st(e){const t=ce(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="i"}function dt(e){const t=ce(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="u"}function ut(e){const t=ce(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="m"}function ft(e){const t=ce(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="y"}function pt(e){const t=re(e.target);if(t){const r=t.closest(x);if(r)return r;const i=t.closest(ae);if(i){const a=O(i);if(a)return a}const o=t.closest(`.${u}`);if(o){const a=Array.from(m.entries()).find(([,l])=>l===o);if(a)return a[0]}}const n=window.getSelection();if(n&&n.rangeCount>0){const r=re(n.getRangeAt(0).startContainer)?.closest(x);if(r)return r}return null}function gt(){if(typeof document>"u"||document.getElementById(Ee))return;const e=document.createElement("style");e.id=Ee,e.textContent=`
.rte-toolbar-group-items.${k},

@@ -439,2 +439,2 @@ .editora-toolbar-group-items.${k},

}
`,document.head.appendChild(e)}function gt(e){M=e,P||(P=t=>{K();const r=t.target?.closest(x);if(!r)return;b=r;const i=f.get(r)||e;w(r,i),f.set(r,i),C(r,"togglePIIRedactionPanel",oe(r)),C(r,"togglePIIRealtime",F(r,i));const o=m.get(r);o&&(ne(o,r),fe(r,o),z(r,o,i))},document.addEventListener("focusin",P,!0)),L||(L=t=>{const r=t.target?.closest(x);r&&(b=r,De(r))},document.addEventListener("input",L,!0)),_||(_=t=>{if(t.defaultPrevented||t.target?.closest(`.${u} input, .${u} textarea, .${u} select`))return;const r=ft(t);if(!r)return;const i=f.get(r)||M||e;if(w(r,i),f.set(r,i),b=r,t.key==="Escape"&&oe(r)){t.preventDefault(),j(r,!0);return}if(ct(t)){t.preventDefault(),t.stopPropagation(),Pe(r);return}if(st(t)){t.preventDefault(),t.stopPropagation(),h(r,i,!0),N(r);return}if(dt(t)){t.preventDefault(),t.stopPropagation(),V(r)||(xe(r,i),N(r));return}if(ut(t)){t.preventDefault(),t.stopPropagation();const o=!F(r,i);S.set(r,o);const a=m.get(r);a&&z(r,a,i),C(r,"togglePIIRealtime",o),o&&h(r,i,!0)}},document.addEventListener("keydown",_,!0)),R||(R=()=>{K(),m.forEach((t,n)=>{!n.isConnected||!t.isConnected||(ne(t,n),fe(n,t))})},window.addEventListener("scroll",R,!0),window.addEventListener("resize",R)),!D&&typeof MutationObserver<"u"&&document.body&&(D=new MutationObserver(t=>{Ue(t)&&K()}),D.observe(document.body,{childList:!0,subtree:!0}))}function bt(){P&&(document.removeEventListener("focusin",P,!0),P=null),L&&(document.removeEventListener("input",L,!0),L=null),_&&(document.removeEventListener("keydown",_,!0),_=null),R&&(window.removeEventListener("scroll",R,!0),window.removeEventListener("resize",R),R=null),D&&(D.disconnect(),D=null),m.forEach(e=>e.remove()),m.clear(),q.forEach(e=>me(e)),q.clear(),M=null,b=null}const mt=(e={})=>{const t=ee(e),n=new Set;return pt(),{name:"piiRedaction",toolbar:[{id:"piiRedactionGroup",label:"PII Redaction",type:"group",command:"piiRedaction",items:[{id:"piiRedaction",label:"PII Redaction",command:"togglePIIRedactionPanel",shortcut:"Mod-Alt-Shift-i",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3.5 19 6.5v4.8c0 4.4-2.7 8.1-7 9.2-4.3-1.1-7-4.8-7-9.2V6.5l7-3Z" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/><path d="M8.8 11.6h6.4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="12" cy="11.6" r="1.2" fill="currentColor"/></svg>'},{id:"piiScan",label:"Scan PII",command:"runPIIScan",shortcut:"Mod-Alt-Shift-u",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4.5" y="3.5" width="11" height="15" rx="2" stroke="currentColor" stroke-width="1.6"/><path d="M7.5 8.2h5M7.5 11.2h5M7.5 14.2h3.2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="16.8" cy="16.8" r="2.8" stroke="currentColor" stroke-width="1.6"/><path d="m18.8 18.8 2 2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'},{id:"piiRedactAll",label:"Redact All PII",command:"redactAllPII",shortcut:"Mod-Alt-Shift-m",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M5 18h14" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M7 6h10l-1 8H8L7 6Z" stroke="currentColor" stroke-width="1.7"/><path d="m9 9 6 4" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/></svg>'},{id:"piiRealtime",label:"Toggle Realtime PII Scan",command:"togglePIIRealtime",shortcut:"Mod-Alt-Shift-y",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3v4M12 17v4M4 12h4M16 12h4" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><circle cx="12" cy="12" r="4" stroke="currentColor" stroke-width="1.7"/></svg>'}]}],commands:{piiRedaction:(r,i)=>{const o=T(i);if(!o)return!1;const a=f.get(o)||t;return w(o,a),f.set(o,a),b=o,N(o),h(o,a,!1),!0},togglePIIRedactionPanel:(r,i)=>{const o=T(i);if(!o)return!1;const a=f.get(o)||t;w(o,a),f.set(o,a),b=o;const l=Pe(o,typeof r=="boolean"?r:void 0);return oe(o)&&h(o,a,!1),l},runPIIScan:async(r,i)=>{const o=T(i);if(!o)return!1;const a=f.get(o)||t;return w(o,a),f.set(o,a),b=o,await h(o,a,!0),N(o),!0},redactAllPII:async(r,i)=>{const o=T(i);if(!o)return!1;const a=f.get(o)||t;w(o,a),f.set(o,a),b=o;const l=await xe(o,a);return l>0&&N(o),l>0},redactPIIFinding:async(r,i)=>{const o=T(i);if(!o||typeof r!="string"||!r)return!1;const a=f.get(o)||t;return w(o,a),f.set(o,a),b=o,_e(o,r,a)},togglePIIRealtime:(r,i)=>{const o=T(i);if(!o)return!1;const a=f.get(o)||t;w(o,a),f.set(o,a);const l=typeof r=="boolean"?r:!F(o,a);S.set(o,l);const c=m.get(o);return c&&z(o,c,a),C(o,"togglePIIRealtime",l),l&&h(o,a,!0),!0},getPIIRedactionFindings:(r,i)=>{const o=T(i);if(!o)return!1;const a=I.get(o)||[],l=E.get(o)||le(0),c=a.map(s=>({...s})),d={...l,byType:{...l.byType}};if(typeof r=="function")try{r(c,d)}catch{}return o.__piiRedactionFindings=c,o.dispatchEvent(new CustomEvent("editora:pii-findings",{bubbles:!0,detail:{findings:c,stats:d}})),!0},setPIIRedactionOptions:(r,i)=>{const o=T(i);if(!o||!r||typeof r!="object")return!1;const a=f.get(o)||t,l=ee({...ce(a),...r,labels:{...a.labels,...r.labels||{}},detectors:{...ce(a).detectors||{},...r.detectors||{}},normalizeText:r.normalizeText||a.normalizeText});f.set(o,l),typeof r.enableRealtime=="boolean"&&S.set(o,r.enableRealtime);const c=m.get(o);return c&&(nt(c,l),H(o),z(o,c,l)),h(o,l,!0),!0}},keymap:{"Mod-Alt-Shift-i":"togglePIIRedactionPanel","Mod-Alt-Shift-I":"togglePIIRedactionPanel","Mod-Alt-Shift-u":"runPIIScan","Mod-Alt-Shift-U":"runPIIScan","Mod-Alt-Shift-m":"redactAllPII","Mod-Alt-Shift-M":"redactAllPII","Mod-Alt-Shift-y":"togglePIIRealtime","Mod-Alt-Shift-Y":"togglePIIRealtime"},init:function(i){G+=1;const o=this&&typeof this.__pluginConfig=="object"?ee({...ce(t),...this.__pluginConfig}):t;gt(o);const a=T(i?.editorElement?{editorElement:i.editorElement}:void 0,!1);a&&(b=a,n.add(a),w(a,o),f.set(a,o),C(a,"togglePIIRedactionPanel",!1),C(a,"togglePIIRealtime",o.enableRealtime),o.enableRealtime&&De(a))},destroy:()=>{n.forEach(r=>Ie(r)),n.clear(),G=Math.max(0,G-1),!(G>0)&&(W.forEach(r=>{window.clearTimeout(r)}),W.clear(),bt())}}};exports.PIIRedactionPlugin=mt;
`,document.head.appendChild(e)}function bt(e){M=e,P||(P=t=>{K();const r=t.target?.closest(x);if(!r)return;b=r;const i=f.get(r)||e;w(r,i),f.set(r,i),C(r,"togglePIIRedactionPanel",oe(r)),C(r,"togglePIIRealtime",F(r,i));const o=m.get(r);o&&(ne(o,r),pe(r,o),z(r,o,i))},document.addEventListener("focusin",P,!0)),L||(L=t=>{const r=t.target?.closest(x);r&&(b=r,Ne(r))},document.addEventListener("input",L,!0)),_||(_=t=>{if(t.defaultPrevented||t.target?.closest(`.${u} input, .${u} textarea, .${u} select`))return;const r=pt(t);if(!r)return;const i=f.get(r)||M||e;if(w(r,i),f.set(r,i),b=r,t.key==="Escape"&&oe(r)){t.preventDefault(),j(r,!0);return}if(st(t)){t.preventDefault(),t.stopPropagation(),Le(r);return}if(dt(t)){t.preventDefault(),t.stopPropagation(),h(r,i,!0),N(r);return}if(ut(t)){t.preventDefault(),t.stopPropagation(),V(r)||(ye(r,i),N(r));return}if(ft(t)){t.preventDefault(),t.stopPropagation();const o=!F(r,i);S.set(r,o);const a=m.get(r);a&&z(r,a,i),C(r,"togglePIIRealtime",o),o&&h(r,i,!0)}},document.addEventListener("keydown",_,!0)),R||(R=()=>{K(),m.forEach((t,n)=>{!n.isConnected||!t.isConnected||(ne(t,n),pe(n,t))})},window.addEventListener("scroll",R,!0),window.addEventListener("resize",R)),!D&&typeof MutationObserver<"u"&&document.body&&(D=new MutationObserver(t=>{Ge(t)&&K()}),D.observe(document.body,{childList:!0,subtree:!0}))}function mt(){P&&(document.removeEventListener("focusin",P,!0),P=null),L&&(document.removeEventListener("input",L,!0),L=null),_&&(document.removeEventListener("keydown",_,!0),_=null),R&&(window.removeEventListener("scroll",R,!0),window.removeEventListener("resize",R),R=null),D&&(D.disconnect(),D=null),m.forEach(e=>e.remove()),m.clear(),q.forEach(e=>he(e)),q.clear(),M=null,b=null}const ht=(e={})=>{const t=ee(e),n=new Set;return gt(),{name:"piiRedaction",toolbar:[{id:"piiRedactionGroup",label:"PII Redaction",type:"group",command:"piiRedaction",items:[{id:"piiRedaction",label:"PII Redaction",command:"togglePIIRedactionPanel",shortcut:"Mod-Alt-Shift-i",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3.5 19 6.5v4.8c0 4.4-2.7 8.1-7 9.2-4.3-1.1-7-4.8-7-9.2V6.5l7-3Z" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/><path d="M8.8 11.6h6.4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="12" cy="11.6" r="1.2" fill="currentColor"/></svg>'},{id:"piiScan",label:"Scan PII",command:"runPIIScan",shortcut:"Mod-Alt-Shift-u",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4.5" y="3.5" width="11" height="15" rx="2" stroke="currentColor" stroke-width="1.6"/><path d="M7.5 8.2h5M7.5 11.2h5M7.5 14.2h3.2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="16.8" cy="16.8" r="2.8" stroke="currentColor" stroke-width="1.6"/><path d="m18.8 18.8 2 2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'},{id:"piiRedactAll",label:"Redact All PII",command:"redactAllPII",shortcut:"Mod-Alt-Shift-m",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M5 18h14" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M7 6h10l-1 8H8L7 6Z" stroke="currentColor" stroke-width="1.7"/><path d="m9 9 6 4" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/></svg>'},{id:"piiRealtime",label:"Toggle Realtime PII Scan",command:"togglePIIRealtime",shortcut:"Mod-Alt-Shift-y",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3v4M12 17v4M4 12h4M16 12h4" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><circle cx="12" cy="12" r="4" stroke="currentColor" stroke-width="1.7"/></svg>'}]}],commands:{piiRedaction:(r,i)=>{const o=T(i);if(!o)return!1;const a=f.get(o)||t;return w(o,a),f.set(o,a),b=o,N(o),h(o,a,!1),!0},togglePIIRedactionPanel:(r,i)=>{const o=T(i);if(!o)return!1;const a=f.get(o)||t;w(o,a),f.set(o,a),b=o;const l=Le(o,typeof r=="boolean"?r:void 0);return oe(o)&&h(o,a,!1),l},runPIIScan:async(r,i)=>{const o=T(i);if(!o)return!1;const a=f.get(o)||t;return w(o,a),f.set(o,a),b=o,await h(o,a,!0),N(o),!0},redactAllPII:async(r,i)=>{const o=T(i);if(!o)return!1;const a=f.get(o)||t;w(o,a),f.set(o,a),b=o;const l=await ye(o,a);return l>0&&N(o),l>0},redactPIIFinding:async(r,i)=>{const o=T(i);if(!o||typeof r!="string"||!r)return!1;const a=f.get(o)||t;return w(o,a),f.set(o,a),b=o,De(o,r,a)},togglePIIRealtime:(r,i)=>{const o=T(i);if(!o)return!1;const a=f.get(o)||t;w(o,a),f.set(o,a);const l=typeof r=="boolean"?r:!F(o,a);S.set(o,l);const c=m.get(o);return c&&z(o,c,a),C(o,"togglePIIRealtime",l),l&&h(o,a,!0),!0},getPIIRedactionFindings:(r,i)=>{const o=T(i);if(!o)return!1;const a=I.get(o)||[],l=E.get(o)||le(0),c=a.map(s=>({...s})),d={...l,byType:{...l.byType}};if(typeof r=="function")try{r(c,d)}catch{}return o.__piiRedactionFindings=c,o.dispatchEvent(new CustomEvent("editora:pii-findings",{bubbles:!0,detail:{findings:c,stats:d}})),!0},setPIIRedactionOptions:(r,i)=>{const o=T(i);if(!o||!r||typeof r!="object")return!1;const a=f.get(o)||t,l=ee({...se(a),...r,labels:{...a.labels,...r.labels||{}},detectors:{...se(a).detectors||{},...r.detectors||{}},normalizeText:r.normalizeText||a.normalizeText});f.set(o,l),typeof r.enableRealtime=="boolean"&&S.set(o,r.enableRealtime);const c=m.get(o);return c&&(rt(c,l),H(o),z(o,c,l)),h(o,l,!0),!0}},keymap:{"Mod-Alt-Shift-i":"togglePIIRedactionPanel","Mod-Alt-Shift-I":"togglePIIRedactionPanel","Mod-Alt-Shift-u":"runPIIScan","Mod-Alt-Shift-U":"runPIIScan","Mod-Alt-Shift-m":"redactAllPII","Mod-Alt-Shift-M":"redactAllPII","Mod-Alt-Shift-y":"togglePIIRealtime","Mod-Alt-Shift-Y":"togglePIIRealtime"},init:function(i){G+=1;const o=this&&typeof this.__pluginConfig=="object"?ee({...se(t),...this.__pluginConfig}):t;bt(o);const a=T(i?.editorElement?{editorElement:i.editorElement}:void 0,!1);a&&(b=a,n.add(a),w(a,o),f.set(a,o),C(a,"togglePIIRedactionPanel",!1),C(a,"togglePIIRealtime",o.enableRealtime),o.enableRealtime&&Ne(a))},destroy:()=>{n.forEach(r=>Te(r)),n.clear(),G=Math.max(0,G-1),!(G>0)&&(W.forEach(r=>{window.clearTimeout(r)}),W.clear(),mt())}}};exports.PIIRedactionPlugin=ht;

@@ -1,2 +0,2 @@

const x = ".rte-content, .editora-content", ae = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", ke = "__editoraCommandEditorRoot", we = "rte-pii-redaction-styles", u = "rte-pii-redaction-panel", k = "pii-redaction", v = "piiRedaction", $ = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', pe = typeof NodeFilter < "u" ? NodeFilter.SHOW_TEXT : 4, Ne = [
const x = ".rte-content, .editora-content", ae = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", we = "__editoraCommandEditorRoot", Ee = "rte-pii-redaction-styles", u = "rte-pii-redaction-panel", k = "pii-redaction", v = "piiRedaction", $ = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', ge = typeof NodeFilter < "u" ? NodeFilter.SHOW_TEXT : 4, Oe = [
"email",

@@ -9,3 +9,3 @@ "phone",

"jwt"
], Oe = {
], ze = {
panelTitle: "PII Redaction",

@@ -27,3 +27,3 @@ panelAriaLabel: "PII redaction panel",

excerptLabel: "Context"
}, ze = {
}, Fe = {
email: {

@@ -48,3 +48,3 @@ label: "Email",

pattern: /\b(?:\d[ -]*?){13,19}\b/g,
validator: (e) => qe(e)
validator: (e) => We(e)
},

@@ -66,8 +66,8 @@ ipv4: {

}
}, f = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new WeakMap(), te = /* @__PURE__ */ new WeakMap(), de = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new Map(), Z = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new Set(), W = /* @__PURE__ */ new Set();
let G = 0, Fe = 0, Ee = 0, A = null, g = null, P = null, L = null, D = null, R = null, _ = null;
}, f = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new WeakMap(), te = /* @__PURE__ */ new WeakMap(), ue = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new Map(), Z = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new Set(), W = /* @__PURE__ */ new Set();
let G = 0, He = 0, ve = 0, A = null, b = null, P = null, L = null, D = null, R = null, _ = null;
function p(e) {
return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
}
function He(e) {
function Be(e) {
return e.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();

@@ -85,10 +85,10 @@ }

}
function Be(e, t) {
function Ke(e, t) {
return e === "high" || e === "medium" || e === "low" ? e : t;
}
function Ke(e) {
function qe(e) {
const t = (e || "*").slice(0, 1) || "*";
return /[A-Za-z0-9._%+\-\s]/.test(t) ? "*" : t;
}
function ve(e) {
function $e(e) {
let t = 2166136261;

@@ -99,3 +99,3 @@ for (let n = 0; n < e.length; n += 1)

}
function qe(e) {
function We(e) {
const t = e.replace(/\D/g, "");

@@ -110,4 +110,4 @@ if (t.length < 13 || t.length > 19) return !1;

}
function We(e, t) {
const n = ze[e];
function je(e, t) {
const n = Fe[e];
if (typeof t == "boolean")

@@ -135,3 +135,3 @@ return {

label: n.label,
severity: Be(t.severity, n.severity),
severity: Ke(t.severity, n.severity),
enabled: t.enabled !== !1,

@@ -143,3 +143,3 @@ pattern: r,

function ee(e = {}) {
const t = Ne.map((r) => We(r, e.detectors?.[r])), n = t.map((r) => `${r.type}:${r.enabled ? "1" : "0"}:${r.severity}:${r.pattern.source}:${r.pattern.flags}`).join("|");
const t = Oe.map((r) => je(r, e.detectors?.[r])), n = t.map((r) => `${r.type}:${r.enabled ? "1" : "0"}:${r.severity}:${r.pattern.source}:${r.pattern.flags}`).join("|");
return {

@@ -149,3 +149,3 @@ enableRealtime: e.enableRealtime !== !1,

maxFindings: X(Number(e.maxFindings ?? 140), 1, 500),
maskChar: Ke(e.maskChar),
maskChar: qe(e.maskChar),
revealStart: X(Number(e.revealStart ?? 2), 0, 12),

@@ -157,6 +157,6 @@ revealEnd: X(Number(e.revealEnd ?? 2), 0, 12),

labels: {
...Oe,
...ze,
...e.labels || {}
},
normalizeText: e.normalizeText || He,
normalizeText: e.normalizeText || Be,
detectors: t,

@@ -166,3 +166,3 @@ detectorSignature: n

}
function ce(e) {
function se(e) {
const t = {};

@@ -190,6 +190,6 @@ return e.detectors.forEach((n) => {

}
function ge(e) {
function me(e) {
return e.closest(ae) || e;
}
function je(e) {
function Ze(e) {
const t = e.closest("[data-editora-editor]");

@@ -204,3 +204,3 @@ if (t && O(t) === e)

}
return ge(e);
return me(e);
}

@@ -213,7 +213,7 @@ function O(e) {

}
function Ze() {
function Ve() {
if (typeof window > "u") return null;
const e = window[ke];
const e = window[we];
if (!(e instanceof HTMLElement)) return null;
window[ke] = null;
window[we] = null;
const t = O(e);

@@ -232,4 +232,4 @@ if (t) return t;

}
function Ve(e) {
const t = ge(e);
function Ue(e) {
const t = me(e);
if (J(t)) return !0;

@@ -240,3 +240,3 @@ const n = t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");

function ne(e, t) {
e.classList.remove("rte-pii-redaction-theme-dark"), Ve(t) && e.classList.add("rte-pii-redaction-theme-dark");
e.classList.remove("rte-pii-redaction-theme-dark"), Ue(t) && e.classList.add("rte-pii-redaction-theme-dark");
}

@@ -246,3 +246,3 @@ function re(e) {

}
function me(e) {
function he(e) {
const t = te.get(e);

@@ -274,6 +274,6 @@ typeof t == "number" && (window.clearTimeout(t), W.delete(t), te.delete(e));

Array.from(q).forEach((t) => {
t.isConnected || Ie(t);
t.isConnected || Te(t);
});
}
function Ue(e) {
function Ge(e) {
for (let t = 0; t < e.length; t += 1) {

@@ -298,3 +298,3 @@ const n = e[t];

}
const n = Ze();
const n = Ve();
if (n) return n;

@@ -312,9 +312,9 @@ const r = window.getSelection();

}
return g && g.isConnected ? g : (g && !g.isConnected && (g = null), t ? document.querySelector(x) : null);
return b && b.isConnected ? b : (b && !b.isConnected && (b = null), t ? document.querySelector(x) : null);
}
function Ie(e) {
me(e), m.get(e)?.remove(), m.delete(e), Z.delete(e), f.delete(e), I.delete(e), E.delete(e), S.delete(e), de.delete(e), Q.delete(e), q.delete(e), g === e && (g = null);
function Te(e) {
he(e), m.get(e)?.remove(), m.delete(e), Z.delete(e), f.delete(e), I.delete(e), E.delete(e), S.delete(e), ue.delete(e), Q.delete(e), q.delete(e), b === e && (b = null);
}
function C(e, t, n) {
const r = je(e);
const r = Ze(e);
Array.from(

@@ -334,3 +334,3 @@ r.querySelectorAll(

}
function $e(e, t, n, r) {
function Ie(e, t, n, r) {
if (!e) return e;

@@ -342,3 +342,3 @@ if (e.length <= n + r)

}
function se(e, t, n) {
function de(e, t, n) {
const r = e.replace(/\D/g, "");

@@ -350,3 +350,3 @@ if (r.length === 0) return e;

}
function Ge(e, t) {
function Ye(e, t) {
const n = e.indexOf("@");

@@ -357,22 +357,22 @@ if (n <= 0) return e;

}
function Ye(e, t) {
function Xe(e, t) {
const n = e.split(".");
return n.length !== 4 ? e : `${n[0]}.${n[1]}.${n[2]}.${t.repeat(Math.max(1, n[3].length))}`;
}
function Te(e, t, n) {
return e && (t === "email" ? Ge(e, n.maskChar) : t === "phone" || t === "ssn" || t === "credit-card" ? se(e, n.maskChar, 4) : t === "ipv4" ? Ye(e, n.maskChar) : t === "api-key" || t === "jwt" ? $e(e, n.maskChar, 0, 0) : $e(e, n.maskChar, n.revealStart, n.revealEnd));
}
function Ce(e, t, n) {
return n.redactionMode === "mask" ? Te(e, t, n) : `[${n.redactionToken}:${t.toUpperCase()}]`;
return e && (t === "email" ? Ye(e, n.maskChar) : t === "phone" || t === "ssn" || t === "credit-card" ? de(e, n.maskChar, 4) : t === "ipv4" ? Xe(e, n.maskChar) : t === "api-key" || t === "jwt" ? Ie(e, n.maskChar, 0, 0) : Ie(e, n.maskChar, n.revealStart, n.revealEnd));
}
function Xe(e) {
return Ee += 1, `pii-${e}-${Date.now().toString(36)}-${Ee.toString(36)}`;
function Re(e, t, n) {
return n.redactionMode === "mask" ? Ce(e, t, n) : `[${n.redactionToken}:${t.toUpperCase()}]`;
}
function he(e, t) {
function Je(e) {
return ve += 1, `pii-${e}-${Date.now().toString(36)}-${ve.toString(36)}`;
}
function xe(e, t) {
return t.skipInCodeBlocks ? !!e.parentElement?.closest("code, pre, kbd, samp") : !1;
}
function Je(e, t) {
function Qe(e, t) {
return t.some((n) => e.start < n.end && n.start < e.end);
}
function Qe(e, t, n) {
function et(e, t, n) {
const r = [];

@@ -383,4 +383,4 @@ t.filter((a) => a.enabled).forEach((a) => {

for (; c && r.length < n * 5; ) {
const d = c[0] || "", s = c.index, b = s + d.length;
d && b > s && (!a.validator || a.validator(d)) && r.push({
const d = c[0] || "", s = c.index, g = s + d.length;
d && g > s && (!a.validator || a.validator(d)) && r.push({
type: a.type,

@@ -390,3 +390,3 @@ severity: a.severity,

start: s,
end: b
end: g
}), l.lastIndex === c.index && (l.lastIndex += 1), c = l.exec(e);

@@ -398,14 +398,14 @@ }

const l = r[a];
Je({ start: l.start, end: l.end }, o) || o.push(l);
Qe({ start: l.start, end: l.end }, o) || o.push(l);
}
return o;
}
function ue(e, t = 120) {
function fe(e, t = 120) {
return e.length <= t ? e : `${e.slice(0, t - 1).trimEnd()}...`;
}
function et(e, t, n) {
function tt(e, t, n) {
const r = Math.max(0, t - 28), i = Math.min(e.length, n + 28);
return ue(e.slice(r, i).trim(), 180);
return fe(e.slice(r, i).trim(), 180);
}
function tt(e, t) {
function nt(e, t) {
const n = le(t);

@@ -426,3 +426,3 @@ return n.total = e.length, e.forEach((r) => {

}
function nt(e, t) {
function rt(e, t) {
e.setAttribute("aria-label", t.labels.panelAriaLabel);

@@ -452,3 +452,3 @@ const n = e.querySelector(".rte-pii-redaction-title");

c.innerHTML = r.map((s) => {
const b = s.type.toUpperCase(), M = s.suggestion || "Redact this finding before export/share.", B = `${n.labels.locateText}: ${s.match}`, y = `${n.labels.redactText}: ${s.match}`, U = o ? 'disabled aria-disabled="true"' : "";
const g = s.type.toUpperCase(), M = s.suggestion || "Redact this finding before export/share.", B = `${n.labels.locateText}: ${s.match}`, y = `${n.labels.redactText}: ${s.match}`, U = o ? 'disabled aria-disabled="true"' : "";
return `

@@ -465,6 +465,6 @@ <li class="rte-pii-redaction-item rte-pii-redaction-item-${s.severity}">

<span class="rte-pii-redaction-badge">${p(s.severity.toUpperCase())}</span>
<span class="rte-pii-redaction-type">${p(b)}</span>
<span class="rte-pii-redaction-type">${p(g)}</span>
</button>
<p class="rte-pii-redaction-line"><strong>${p(n.labels.matchLabel)}:</strong> ${p(ue(s.match, 80))}</p>
<p class="rte-pii-redaction-line"><strong>${p(n.labels.maskedLabel)}:</strong> ${p(ue(s.masked, 80))}</p>
<p class="rte-pii-redaction-line"><strong>${p(n.labels.matchLabel)}:</strong> ${p(fe(s.match, 80))}</p>
<p class="rte-pii-redaction-line"><strong>${p(n.labels.maskedLabel)}:</strong> ${p(fe(s.masked, 80))}</p>
${s.excerpt ? `<p class="rte-pii-redaction-line"><strong>${p(n.labels.excerptLabel)}:</strong> ${p(s.excerpt)}</p>` : ""}

@@ -482,5 +482,5 @@ <p class="rte-pii-redaction-help">${p(M)}</p>

}
function fe(e, t) {
function pe(e, t) {
if (!t.classList.contains("show")) return;
const r = ge(e).getBoundingClientRect(), i = Math.min(window.innerWidth - 20, 390), o = Math.max(10, window.innerWidth - i - 10), a = Math.min(Math.max(10, r.right - i), o), l = Math.max(10, Math.min(window.innerHeight - 10 - 280, r.top + 10));
const r = me(e).getBoundingClientRect(), i = Math.min(window.innerWidth - 20, 390), o = Math.max(10, window.innerWidth - i - 10), a = Math.min(Math.max(10, r.right - i), o), l = Math.max(10, Math.min(window.innerHeight - 10 - 280, r.top + 10));
t.style.width = `${i}px`, t.style.left = `${a}px`, t.style.top = `${l}px`, t.style.maxHeight = `${Math.max(260, window.innerHeight - 20)}px`;

@@ -492,3 +492,3 @@ }

}
function Re(e, t) {
function Se(e, t) {
if (t === e.innerHTML) return;

@@ -502,6 +502,6 @@ const n = window.execEditorCommand || window.executeEditorCommand;

}
function Se(e) {
function Ae(e) {
e.dispatchEvent(new Event("input", { bubbles: !0 }));
}
function Ae(e, t) {
function Me(e, t) {
e.dispatchEvent(

@@ -516,9 +516,9 @@ new CustomEvent("editora:pii-redacted", {

}
function Me(e, t) {
function Pe(e, t) {
return (I.get(e) || []).find((r) => r.id === t);
}
function rt(e) {
function ot(e) {
const t = m.get(e);
if (t) return t;
const n = f.get(e) || A || ee(), r = `rte-pii-redaction-panel-${Fe++}`, i = document.createElement("section");
const n = f.get(e) || A || ee(), r = `rte-pii-redaction-panel-${He++}`, i = document.createElement("section");
return i.className = u, i.id = r, i.setAttribute("role", "dialog"), i.setAttribute("aria-modal", "false"), i.setAttribute("aria-label", n.labels.panelAriaLabel), i.innerHTML = `

@@ -567,9 +567,9 @@ <header class="rte-pii-redaction-header">

if (c === "redact-all") {
xe(e, d);
ye(e, d);
return;
}
if (c === "locate-finding") {
const s = l.getAttribute("data-finding-id") || "", b = Me(e, s);
if (!b) return;
at(e, b, d);
const s = l.getAttribute("data-finding-id") || "", g = Pe(e, s);
if (!g) return;
lt(e, g, d);
return;

@@ -579,3 +579,3 @@ }

const s = l.getAttribute("data-finding-id") || "";
De(e, s, d);
_e(e, s, d);
}

@@ -590,3 +590,3 @@ }), i.addEventListener("keydown", (o) => {

if (a.length === 0) return;
const l = document.activeElement, c = a.findIndex((b) => b === l);
const l = document.activeElement, c = a.findIndex((g) => g === l);
if (c === -1) return;

@@ -604,16 +604,16 @@ o.preventDefault();

K();
const t = rt(e);
const t = ot(e);
m.forEach((r, i) => {
i !== e && j(i, !1);
}), t.classList.add("show"), Z.set(e, !0), C(e, "togglePIIRedactionPanel", !0), ne(t, e), fe(e, t), H(e), t.querySelector('[data-action="run-scan"]')?.focus();
}), t.classList.add("show"), Z.set(e, !0), C(e, "togglePIIRedactionPanel", !0), ne(t, e), pe(e, t), H(e), t.querySelector('[data-action="run-scan"]')?.focus();
}
function Pe(e, t) {
function Le(e, t) {
const n = oe(e);
return (typeof t == "boolean" ? t : !n) ? N(e) : j(e), !0;
}
function ot(e, t) {
function it(e, t) {
const n = t.normalizeText(e.innerText || e.textContent || ""), r = e.innerHTML;
return `${n.length}:${ve(n)}:${r.length}:${ve(r)}:${t.detectorSignature}`;
return `${n.length}:${$e(n)}:${r.length}:${$e(r)}:${t.detectorSignature}`;
}
function it(e, t) {
function at(e, t) {
const n = [], r = be(e.pattern);

@@ -627,3 +627,3 @@ let i = r.exec(t);

}
function Le(e, t, n) {
function De(e, t, n) {
const r = n.detectors.find((c) => c.type === t.type && c.enabled);

@@ -633,12 +633,12 @@ if (!r) return null;

let o = 0;
const a = document.createTreeWalker(e, pe, null);
const a = document.createTreeWalker(e, ge, null);
let l = a.nextNode();
for (; l; ) {
if (!he(l, n)) {
const c = it(r, l.data);
if (!xe(l, n)) {
const c = at(r, l.data);
for (let d = 0; d < c.length; d += 1) {
const s = c[d];
if (s.value.toLowerCase() === i && (o += 1, o === t.occurrence)) {
const b = document.createRange();
return b.setStart(l, s.start), b.setEnd(l, s.end), b;
const g = document.createRange();
return g.setStart(l, s.start), g.setEnd(l, s.end), g;
}

@@ -651,4 +651,4 @@ }

}
function at(e, t, n) {
const r = Le(e, t, n);
function lt(e, t, n) {
const r = De(e, t, n);
if (!r) return !1;

@@ -660,23 +660,23 @@ const i = window.getSelection();

w(e, t);
const r = ot(e, t);
if (!n && de.get(e) === r)
const r = it(e, t);
if (!n && ue.get(e) === r)
return I.get(e) || [];
const i = (Q.get(e) || 0) + 1;
Q.set(e, i);
const o = [], a = /* @__PURE__ */ new Map(), l = document.createTreeWalker(e, pe, null);
const o = [], a = /* @__PURE__ */ new Map(), l = document.createTreeWalker(e, ge, null);
let c = l.nextNode();
for (; c && o.length < t.maxFindings; ) {
const b = c.data || "";
if (b.trim() && !he(c, t)) {
const M = Qe(b, t.detectors, t.maxFindings - o.length);
const g = c.data || "";
if (g.trim() && !xe(c, t)) {
const M = et(g, t.detectors, t.maxFindings - o.length);
for (let B = 0; B < M.length && !(o.length >= t.maxFindings); B += 1) {
const y = M[B], U = `${y.type}:${y.value.toLowerCase()}`, ye = (a.get(U) || 0) + 1;
a.set(U, ye), o.push({
id: Xe(y.type),
const y = M[B], U = `${y.type}:${y.value.toLowerCase()}`, ke = (a.get(U) || 0) + 1;
a.set(U, ke), o.push({
id: Je(y.type),
type: y.type,
severity: y.severity,
match: y.value,
masked: Te(y.value, y.type, t),
occurrence: ye,
excerpt: et(b, y.start, y.end),
masked: Ce(y.value, y.type, t),
occurrence: ke,
excerpt: tt(g, y.start, y.end),
suggestion: "Review and redact this value before external sharing."

@@ -690,4 +690,4 @@ });

return I.get(e) || [];
const d = E.get(e)?.redactedCount || 0, s = tt(o, d);
return de.set(e, r), I.set(e, o), E.set(e, s), H(e), e.dispatchEvent(
const d = E.get(e)?.redactedCount || 0, s = nt(o, d);
return ue.set(e, r), I.set(e, o), E.set(e, s), H(e), e.dispatchEvent(
new CustomEvent("editora:pii-scan", {

@@ -702,10 +702,10 @@ bubbles: !0,

}
function lt(e, t) {
function ct(e, t) {
let n = e, r = 0;
return t.detectors.filter((o) => o.enabled).forEach((o) => {
const a = be(o.pattern);
n = n.replace(a, (l) => o.validator && !o.validator(l) ? l : (r += 1, Ce(l, o.type, t)));
n = n.replace(a, (l) => o.validator && !o.validator(l) ? l : (r += 1, Re(l, o.type, t)));
}), { nextValue: n, count: r };
}
async function De(e, t, n) {
async function _e(e, t, n) {
if (V(e)) {

@@ -715,19 +715,19 @@ const d = m.get(e);

}
const r = Me(e, t);
const r = Pe(e, t);
if (!r) return !1;
const i = Le(e, r, n);
const i = De(e, r, n);
if (!i) return !1;
const o = e.innerHTML, a = Ce(r.match, r.type, n);
const o = e.innerHTML, a = Re(r.match, r.type, n);
if (i.startContainer === i.endContainer && i.startContainer.nodeType === Node.TEXT_NODE) {
const d = i.startContainer, s = d.data, b = i.startOffset, M = i.endOffset;
d.data = `${s.slice(0, b)}${a}${s.slice(M)}`;
const d = i.startContainer, s = d.data, g = i.startOffset, M = i.endOffset;
d.data = `${s.slice(0, g)}${a}${s.slice(M)}`;
} else
i.deleteContents(), i.insertNode(document.createTextNode(a));
Se(e), Re(e, o);
Ae(e), Se(e, o);
const l = E.get(e)?.redactedCount || 0;
await h(e, n, !0);
const c = E.get(e);
return c && (c.redactedCount = l + 1, H(e)), Ae(e, 1), !0;
return c && (c.redactedCount = l + 1, H(e)), Me(e, 1), !0;
}
async function xe(e, t) {
async function ye(e, t) {
if (V(e)) {

@@ -740,6 +740,6 @@ const d = m.get(e);

let i = 0;
const o = document.createTreeWalker(e, pe, null);
const o = document.createTreeWalker(e, ge, null);
let a = o.nextNode();
for (; a; ) {
if (he(a, t)) {
if (xe(a, t)) {
a = o.nextNode();

@@ -753,16 +753,16 @@ continue;

}
const s = lt(d, t);
const s = ct(d, t);
s.count > 0 && s.nextValue !== d && (a.data = s.nextValue, i += s.count), a = o.nextNode();
}
if (i === 0) return 0;
Se(e), Re(e, r);
Ae(e), Se(e, r);
const l = E.get(e)?.redactedCount || 0;
await h(e, t, !0);
const c = E.get(e);
return c && (c.redactedCount = l + i, H(e)), Ae(e, i), i;
return c && (c.redactedCount = l + i, H(e)), Me(e, i), i;
}
function _e(e) {
function Ne(e) {
const t = f.get(e) || A;
if (!t || !F(e, t) || V(e)) return;
me(e);
he(e);
const n = window.setTimeout(() => {

@@ -773,19 +773,22 @@ W.delete(n), te.delete(e), h(e, t, !1);

}
function ct(e) {
const t = e.key.toLowerCase();
function ce(e) {
return typeof e.key == "string" ? e.key.toLowerCase() : "";
}
function st(e) {
const t = ce(e);
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "i";
}
function st(e) {
const t = e.key.toLowerCase();
function dt(e) {
const t = ce(e);
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "u";
}
function dt(e) {
const t = e.key.toLowerCase();
function ut(e) {
const t = ce(e);
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "m";
}
function ut(e) {
const t = e.key.toLowerCase();
function ft(e) {
const t = ce(e);
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "y";
}
function ft(e) {
function pt(e) {
const t = re(e.target);

@@ -815,6 +818,6 @@ if (t) {

}
function pt() {
if (typeof document > "u" || document.getElementById(we)) return;
function gt() {
if (typeof document > "u" || document.getElementById(Ee)) return;
const e = document.createElement("style");
e.id = we, e.textContent = `
e.id = Ee, e.textContent = `
.rte-toolbar-group-items.${k},

@@ -1221,32 +1224,32 @@ .editora-toolbar-group-items.${k},

if (!r) return;
g = r;
b = r;
const i = f.get(r) || e;
w(r, i), f.set(r, i), C(r, "togglePIIRedactionPanel", oe(r)), C(r, "togglePIIRealtime", F(r, i));
const o = m.get(r);
o && (ne(o, r), fe(r, o), z(r, o, i));
o && (ne(o, r), pe(r, o), z(r, o, i));
}, document.addEventListener("focusin", P, !0)), L || (L = (t) => {
const r = t.target?.closest(x);
r && (g = r, _e(r));
r && (b = r, Ne(r));
}, document.addEventListener("input", L, !0)), D || (D = (t) => {
if (t.defaultPrevented || t.target?.closest(`.${u} input, .${u} textarea, .${u} select`)) return;
const r = ft(t);
const r = pt(t);
if (!r) return;
const i = f.get(r) || A || e;
if (w(r, i), f.set(r, i), g = r, t.key === "Escape" && oe(r)) {
if (w(r, i), f.set(r, i), b = r, t.key === "Escape" && oe(r)) {
t.preventDefault(), j(r, !0);
return;
}
if (ct(t)) {
t.preventDefault(), t.stopPropagation(), Pe(r);
if (st(t)) {
t.preventDefault(), t.stopPropagation(), Le(r);
return;
}
if (st(t)) {
if (dt(t)) {
t.preventDefault(), t.stopPropagation(), h(r, i, !0), N(r);
return;
}
if (dt(t)) {
t.preventDefault(), t.stopPropagation(), V(r) || (xe(r, i), N(r));
if (ut(t)) {
t.preventDefault(), t.stopPropagation(), V(r) || (ye(r, i), N(r));
return;
}
if (ut(t)) {
if (ft(t)) {
t.preventDefault(), t.stopPropagation();

@@ -1260,6 +1263,6 @@ const o = !F(r, i);

K(), m.forEach((t, n) => {
!n.isConnected || !t.isConnected || (ne(t, n), fe(n, t));
!n.isConnected || !t.isConnected || (ne(t, n), pe(n, t));
});
}, window.addEventListener("scroll", R, !0), window.addEventListener("resize", R)), !_ && typeof MutationObserver < "u" && document.body && (_ = new MutationObserver((t) => {
Ue(t) && K();
Ge(t) && K();
}), _.observe(document.body, {

@@ -1270,8 +1273,8 @@ childList: !0,

}
function gt() {
P && (document.removeEventListener("focusin", P, !0), P = null), L && (document.removeEventListener("input", L, !0), L = null), D && (document.removeEventListener("keydown", D, !0), D = null), R && (window.removeEventListener("scroll", R, !0), window.removeEventListener("resize", R), R = null), _ && (_.disconnect(), _ = null), m.forEach((e) => e.remove()), m.clear(), q.forEach((e) => me(e)), q.clear(), A = null, g = null;
function mt() {
P && (document.removeEventListener("focusin", P, !0), P = null), L && (document.removeEventListener("input", L, !0), L = null), D && (document.removeEventListener("keydown", D, !0), D = null), R && (window.removeEventListener("scroll", R, !0), window.removeEventListener("resize", R), R = null), _ && (_.disconnect(), _ = null), m.forEach((e) => e.remove()), m.clear(), q.forEach((e) => he(e)), q.clear(), A = null, b = null;
}
const mt = (e = {}) => {
const ht = (e = {}) => {
const t = ee(e), n = /* @__PURE__ */ new Set();
return pt(), {
return gt(), {
name: "piiRedaction",

@@ -1321,3 +1324,3 @@ toolbar: [

const a = f.get(o) || t;
return w(o, a), f.set(o, a), g = o, N(o), h(o, a, !1), !0;
return w(o, a), f.set(o, a), b = o, N(o), h(o, a, !1), !0;
},

@@ -1328,4 +1331,4 @@ togglePIIRedactionPanel: (r, i) => {

const a = f.get(o) || t;
w(o, a), f.set(o, a), g = o;
const l = Pe(o, typeof r == "boolean" ? r : void 0);
w(o, a), f.set(o, a), b = o;
const l = Le(o, typeof r == "boolean" ? r : void 0);
return oe(o) && h(o, a, !1), l;

@@ -1337,3 +1340,3 @@ },

const a = f.get(o) || t;
return w(o, a), f.set(o, a), g = o, await h(o, a, !0), N(o), !0;
return w(o, a), f.set(o, a), b = o, await h(o, a, !0), N(o), !0;
},

@@ -1344,4 +1347,4 @@ redactAllPII: async (r, i) => {

const a = f.get(o) || t;
w(o, a), f.set(o, a), g = o;
const l = await xe(o, a);
w(o, a), f.set(o, a), b = o;
const l = await ye(o, a);
return l > 0 && N(o), l > 0;

@@ -1353,3 +1356,3 @@ },

const a = f.get(o) || t;
return w(o, a), f.set(o, a), g = o, De(o, r, a);
return w(o, a), f.set(o, a), b = o, _e(o, r, a);
},

@@ -1389,3 +1392,3 @@ togglePIIRealtime: (r, i) => {

const a = f.get(o) || t, l = ee({
...ce(a),
...se(a),
...r,

@@ -1397,3 +1400,3 @@ labels: {

detectors: {
...ce(a).detectors || {},
...se(a).detectors || {},
...r.detectors || {}

@@ -1405,3 +1408,3 @@ },

const c = m.get(o);
return c && (nt(c, l), H(o), z(o, c, l)), h(o, l, !0), !0;
return c && (rt(c, l), H(o), z(o, c, l)), h(o, l, !0), !0;
}

@@ -1421,3 +1424,3 @@ },

G += 1;
const o = this && typeof this.__pluginConfig == "object" ? ee({ ...ce(t), ...this.__pluginConfig }) : t;
const o = this && typeof this.__pluginConfig == "object" ? ee({ ...se(t), ...this.__pluginConfig }) : t;
bt(o);

@@ -1428,8 +1431,8 @@ const a = T(

);
a && (g = a, n.add(a), w(a, o), f.set(a, o), C(a, "togglePIIRedactionPanel", !1), C(a, "togglePIIRealtime", o.enableRealtime), o.enableRealtime && _e(a));
a && (b = a, n.add(a), w(a, o), f.set(a, o), C(a, "togglePIIRedactionPanel", !1), C(a, "togglePIIRealtime", o.enableRealtime), o.enableRealtime && Ne(a));
},
destroy: () => {
n.forEach((r) => Ie(r)), n.clear(), G = Math.max(0, G - 1), !(G > 0) && (W.forEach((r) => {
n.forEach((r) => Te(r)), n.clear(), G = Math.max(0, G - 1), !(G > 0) && (W.forEach((r) => {
window.clearTimeout(r);
}), W.clear(), gt());
}), W.clear(), mt());
}

@@ -1439,3 +1442,3 @@ };

export {
mt as PIIRedactionPlugin
ht as PIIRedactionPlugin
};

@@ -1,7 +0,7 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=".rte-content, .editora-content",ee="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",se="__editoraCommandEditorRoot",le="rte-smart-paste-styles",u="rte-smart-paste-panel",h="smart-paste",S="smartPaste",E=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Ee=typeof NodeFilter<"u"?NodeFilter.SHOW_COMMENT:128,ie="__editoraSmartPasteHandled",ke=new Set(["script","style","meta","link","object","embed","iframe","svg","canvas","math","form","input","button","textarea","select","option"]),Ce=new Set(["table","thead","tbody","tfoot","tr","td","th","colgroup","col"]),Te=new Set(["span","font"]),Pe=/^(https?:|mailto:|tel:|#|\/)/i,Ae=/^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i,we=new Set(["color","background-color","font-weight","font-style","text-decoration","text-align","font-size","font-family","line-height","letter-spacing","word-spacing","white-space","vertical-align","margin-left","margin-right","margin-top","margin-bottom","padding-left","padding-right","padding-top","padding-bottom","text-indent","border","border-top","border-right","border-bottom","border-left","border-color","border-width","border-style","list-style-type"]),Le={panelTitle:"Smart Paste",panelAriaLabel:"Smart paste panel",enabledText:"Smart paste is enabled",disabledText:"Smart paste is disabled",toggleOnText:"Disable Smart Paste",toggleOffText:"Enable Smart Paste",cycleProfileText:"Cycle Profile",profileLabel:"Profile",fidelityText:"Fidelity",balancedText:"Balanced",plainText:"Plain Text",lastPasteHeading:"Last Paste Result",lastPasteEmptyText:"Paste content to see cleanup metrics.",lastPasteSourceLabel:"Source",lastPasteProfileLabel:"Profile",lastPasteRemovedLabel:"Removed",lastPasteCharsLabel:"Output Chars",closeText:"Close",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+S/V/G",readonlyMessage:"Editor is read-only. Smart paste was skipped."},Y={fidelity:{keepStyles:!0,keepClasses:!1,keepDataAttributes:!1,preserveTables:!0},balanced:{keepStyles:!1,keepClasses:!1,keepDataAttributes:!1,preserveTables:!0},plain:{keepStyles:!1,keepClasses:!1,keepDataAttributes:!1,preserveTables:!1}},d=new WeakMap,L=new WeakMap,g=new Map,q=new WeakMap,j=new WeakMap,_=new Set;let I=0,$e=0,$=null,m=null,P=null,A=null,T=null,w=null;function X(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Me(e){return e.replace(/\u00A0/g," ").replace(/\r\n?/g,`
`)}function z(e){return e==="balanced"||e==="plain"?e:"fidelity"}function Z(e,t){return{keepStyles:e?.keepStyles??t.keepStyles,keepClasses:e?.keepClasses??t.keepClasses,keepDataAttributes:e?.keepDataAttributes??t.keepDataAttributes,preserveTables:e?.preserveTables??t.preserveTables}}function K(e={}){const t=e.profileOptions||{};return{enabled:e.enabled!==!1,defaultProfile:z(e.defaultProfile),maxHtmlLength:Math.max(8e3,Math.min(8e5,Number(e.maxHtmlLength??22e4))),removeComments:e.removeComments!==!1,normalizeWhitespace:e.normalizeWhitespace!==!1,labels:{...Le,...e.labels||{}},normalizeText:e.normalizeText||Me,profileOptions:{fidelity:Z(t.fidelity,Y.fidelity),balanced:Z(t.balanced,Y.balanced),plain:Z(t.plain,Y.plain)}}}function ce(e){return{enabled:e.enabled,defaultProfile:e.defaultProfile,maxHtmlLength:e.maxHtmlLength,removeComments:e.removeComments,normalizeWhitespace:e.normalizeWhitespace,labels:{...e.labels},normalizeText:e.normalizeText,profileOptions:{fidelity:{...e.profileOptions.fidelity},balanced:{...e.profileOptions.balanced},plain:{...e.profileOptions.plain}}}}function te(e){return e.closest(ee)||e}function H(e){if(!e)return null;if(e.matches(y))return e;const t=e.querySelector(y);return t instanceof HTMLElement?t:null}function Oe(){if(typeof window>"u")return null;const e=window[se];if(!(e instanceof HTMLElement))return null;window[se]=null;const t=H(e);if(t)return t;const a=e.closest(ee);if(a){const n=H(a);if(n)return n}const r=e.closest(y);return r instanceof HTMLElement?r:null}function Re(e){const t=e.closest("[data-editora-editor]");if(t&&H(t)===e)return t;let a=e;for(;a;){if(a.matches(ee)&&(a===e||H(a)===e))return a;a=a.parentElement}return te(e)}function pe(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function C(e,t=!0,a=!0){if(V(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const s=H(e.editorElement);if(s)return s}const r=Oe();if(r)return r;const n=window.getSelection();if(n&&n.rangeCount>0){const l=pe(n.getRangeAt(0).startContainer)?.closest(y);if(l)return l}const o=document.activeElement;if(o){if(o.matches(y))return o;const s=o.closest(y);if(s)return s}if(a){if(m&&m.isConnected)return m;m&&!m.isConnected&&(m=null)}return t?document.querySelector(y):null}function _e(e){const t=e.target;if(t){const r=t.closest(y);if(r)return r}const a=window.getSelection();if(a&&a.rangeCount>0){const n=pe(a.getRangeAt(0).startContainer)?.closest(y);if(n)return n}return null}function B(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 ze(e){const t=te(e);if(B(t))return!0;const a=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return B(a)?!0:B(document.documentElement)||B(document.body)}function F(e,t){e.classList.remove("rte-smart-paste-theme-dark"),ze(t)&&e.classList.add("rte-smart-paste-theme-dark")}function de(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function D(e,t,a){const r=Re(e);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(o=>{o.classList.toggle("active",a),o.setAttribute("data-active",a?"true":"false"),o.setAttribute("aria-pressed",a?"true":"false")})}function p(e,t){d.has(e)||d.set(e,t);let a=L.get(e);return a||(a={enabled:t.enabled,profile:t.defaultProfile,lastReport:null},L.set(e,a)),Qe(e),_.add(e),a}function me(e){const t=j.get(e);t&&(e.removeEventListener("paste",t,!0),j.delete(e))}function be(e){me(e),g.get(e)?.remove(),g.delete(e),q.delete(e),d.delete(e),L.delete(e),_.delete(e),m===e&&(m=null)}function V(){Array.from(_).forEach(t=>{t.isConnected||be(t)})}function He(e){for(let t=0;t<e.length;t+=1){const a=e[t];if(!(a.type!=="childList"||a.removedNodes.length===0))for(let r=0;r<a.removedNodes.length;r+=1){const n=a.removedNodes[r];if(n.nodeType!==Node.ELEMENT_NODE)continue;const o=n;if(o.matches?.(y)||o.matches?.(`.${u}`)||o.querySelector?.(y)||o.querySelector?.(`.${u}`))return!0}}return!1}function re(e){return q.get(e)===!0}function O(e,t){const a=e.querySelector(".rte-smart-paste-live");a&&(a.textContent=t)}function J(e,t){const a=t.normalizeText(e);return t.normalizeWhitespace?a.split(`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=".rte-content, .editora-content",ee="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",le="__editoraCommandEditorRoot",ie="rte-smart-paste-styles",u="rte-smart-paste-panel",h="smart-paste",S="smartPaste",E=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',ke=typeof NodeFilter<"u"?NodeFilter.SHOW_COMMENT:128,ce="__editoraSmartPasteHandled",Ce=new Set(["script","style","meta","link","object","embed","iframe","svg","canvas","math","form","input","button","textarea","select","option"]),Te=new Set(["table","thead","tbody","tfoot","tr","td","th","colgroup","col"]),Pe=new Set(["span","font"]),Ae=/^(https?:|mailto:|tel:|#|\/)/i,we=/^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i,Le=new Set(["color","background-color","font-weight","font-style","text-decoration","text-align","font-size","font-family","line-height","letter-spacing","word-spacing","white-space","vertical-align","margin-left","margin-right","margin-top","margin-bottom","padding-left","padding-right","padding-top","padding-bottom","text-indent","border","border-top","border-right","border-bottom","border-left","border-color","border-width","border-style","list-style-type"]),$e={panelTitle:"Smart Paste",panelAriaLabel:"Smart paste panel",enabledText:"Smart paste is enabled",disabledText:"Smart paste is disabled",toggleOnText:"Disable Smart Paste",toggleOffText:"Enable Smart Paste",cycleProfileText:"Cycle Profile",profileLabel:"Profile",fidelityText:"Fidelity",balancedText:"Balanced",plainText:"Plain Text",lastPasteHeading:"Last Paste Result",lastPasteEmptyText:"Paste content to see cleanup metrics.",lastPasteSourceLabel:"Source",lastPasteProfileLabel:"Profile",lastPasteRemovedLabel:"Removed",lastPasteCharsLabel:"Output Chars",closeText:"Close",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+S/V/G",readonlyMessage:"Editor is read-only. Smart paste was skipped."},Y={fidelity:{keepStyles:!0,keepClasses:!1,keepDataAttributes:!1,preserveTables:!0},balanced:{keepStyles:!1,keepClasses:!1,keepDataAttributes:!1,preserveTables:!0},plain:{keepStyles:!1,keepClasses:!1,keepDataAttributes:!1,preserveTables:!1}},d=new WeakMap,L=new WeakMap,g=new Map,q=new WeakMap,j=new WeakMap,_=new Set;let I=0,Me=0,$=null,m=null,P=null,A=null,T=null,w=null;function X(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Oe(e){return e.replace(/\u00A0/g," ").replace(/\r\n?/g,`
`)}function z(e){return e==="balanced"||e==="plain"?e:"fidelity"}function Z(e,t){return{keepStyles:e?.keepStyles??t.keepStyles,keepClasses:e?.keepClasses??t.keepClasses,keepDataAttributes:e?.keepDataAttributes??t.keepDataAttributes,preserveTables:e?.preserveTables??t.preserveTables}}function K(e={}){const t=e.profileOptions||{};return{enabled:e.enabled!==!1,defaultProfile:z(e.defaultProfile),maxHtmlLength:Math.max(8e3,Math.min(8e5,Number(e.maxHtmlLength??22e4))),removeComments:e.removeComments!==!1,normalizeWhitespace:e.normalizeWhitespace!==!1,labels:{...$e,...e.labels||{}},normalizeText:e.normalizeText||Oe,profileOptions:{fidelity:Z(t.fidelity,Y.fidelity),balanced:Z(t.balanced,Y.balanced),plain:Z(t.plain,Y.plain)}}}function de(e){return{enabled:e.enabled,defaultProfile:e.defaultProfile,maxHtmlLength:e.maxHtmlLength,removeComments:e.removeComments,normalizeWhitespace:e.normalizeWhitespace,labels:{...e.labels},normalizeText:e.normalizeText,profileOptions:{fidelity:{...e.profileOptions.fidelity},balanced:{...e.profileOptions.balanced},plain:{...e.profileOptions.plain}}}}function te(e){return e.closest(ee)||e}function H(e){if(!e)return null;if(e.matches(y))return e;const t=e.querySelector(y);return t instanceof HTMLElement?t:null}function Re(){if(typeof window>"u")return null;const e=window[le];if(!(e instanceof HTMLElement))return null;window[le]=null;const t=H(e);if(t)return t;const a=e.closest(ee);if(a){const n=H(a);if(n)return n}const r=e.closest(y);return r instanceof HTMLElement?r:null}function _e(e){const t=e.closest("[data-editora-editor]");if(t&&H(t)===e)return t;let a=e;for(;a;){if(a.matches(ee)&&(a===e||H(a)===e))return a;a=a.parentElement}return te(e)}function me(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function C(e,t=!0,a=!0){if(V(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const s=H(e.editorElement);if(s)return s}const r=Re();if(r)return r;const n=window.getSelection();if(n&&n.rangeCount>0){const l=me(n.getRangeAt(0).startContainer)?.closest(y);if(l)return l}const o=document.activeElement;if(o){if(o.matches(y))return o;const s=o.closest(y);if(s)return s}if(a){if(m&&m.isConnected)return m;m&&!m.isConnected&&(m=null)}return t?document.querySelector(y):null}function ze(e){const t=e.target;if(t){const r=t.closest(y);if(r)return r}const a=window.getSelection();if(a&&a.rangeCount>0){const n=me(a.getRangeAt(0).startContainer)?.closest(y);if(n)return n}return null}function B(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 He(e){const t=te(e);if(B(t))return!0;const a=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return B(a)?!0:B(document.documentElement)||B(document.body)}function F(e,t){e.classList.remove("rte-smart-paste-theme-dark"),He(t)&&e.classList.add("rte-smart-paste-theme-dark")}function ue(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function D(e,t,a){const r=_e(e);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(o=>{o.classList.toggle("active",a),o.setAttribute("data-active",a?"true":"false"),o.setAttribute("aria-pressed",a?"true":"false")})}function p(e,t){d.has(e)||d.set(e,t);let a=L.get(e);return a||(a={enabled:t.enabled,profile:t.defaultProfile,lastReport:null},L.set(e,a)),et(e),_.add(e),a}function be(e){const t=j.get(e);t&&(e.removeEventListener("paste",t,!0),j.delete(e))}function ge(e){be(e),g.get(e)?.remove(),g.delete(e),q.delete(e),d.delete(e),L.delete(e),_.delete(e),m===e&&(m=null)}function V(){Array.from(_).forEach(t=>{t.isConnected||ge(t)})}function De(e){for(let t=0;t<e.length;t+=1){const a=e[t];if(!(a.type!=="childList"||a.removedNodes.length===0))for(let r=0;r<a.removedNodes.length;r+=1){const n=a.removedNodes[r];if(n.nodeType!==Node.ELEMENT_NODE)continue;const o=n;if(o.matches?.(y)||o.matches?.(`.${u}`)||o.querySelector?.(y)||o.querySelector?.(`.${u}`))return!0}}return!1}function re(e){return q.get(e)===!0}function O(e,t){const a=e.querySelector(".rte-smart-paste-live");a&&(a.textContent=t)}function J(e,t){const a=t.normalizeText(e);return t.normalizeWhitespace?a.split(`
`).map(n=>n.replace(/[\t ]+/g," ").trimEnd()).join(`
`).replace(/\n{3,}/g,`
`).trim():a}function De(e){return/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office|<o:p\b/i.test(e)}function Ne(e){return/id=["']docs-internal-guid|docs-\w+|data-sheets-value|data-sheets-userformat/i.test(e)}function qe(e,t){return e?De(e)?"word":Ne(e)?"google-docs":"html":t?"plain":"html"}function Ie(e){return e.split(/\s+/).map(a=>a.trim()).filter(Boolean).filter(a=>!/^mso/i.test(a)).filter(a=>!/^docs-/i.test(a)).filter(a=>!/^c\d+$/i.test(a)).join(" ")}function Be(e){if(!e)return{value:"",changed:!1};const t=e.split(";"),a=[];let r=!1;return t.forEach(n=>{const o=n.indexOf(":");if(o<=0){n.trim()&&(r=!0);return}const s=n.slice(0,o).trim().toLowerCase(),l=n.slice(o+1).trim();if(!s||!l){r=!0;return}if(!we.has(s)){r=!0;return}if(/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(l)){r=!0;return}a.push(`${s}: ${l}`)}),{value:a.join("; "),changed:r}}function ue(e){const t=e.trim();return t&&(Pe.test(t)||Ae.test(t))?t:""}function fe(e){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}}function We(e,t,a,r){const n=e.tagName.toLowerCase();if(ke.has(n)){r.removedElements+=1,e.remove();return}if(!t.preserveTables&&Ce.has(n)){const s=e.textContent||"",l=document.createTextNode(s);e.replaceWith(l),r.removedElements+=1;return}if(Array.from(e.attributes).forEach(s=>{const l=s.name.toLowerCase(),i=s.value;if(l.startsWith("on")){e.removeAttribute(s.name),r.removedAttributes+=1;return}if(l==="style"){if(!t.keepStyles){e.removeAttribute(s.name),r.removedAttributes+=1;return}const c=Be(i);if(!c.value){e.removeAttribute(s.name),r.removedAttributes+=1,c.changed&&(r.normalizedStyles+=1);return}(c.changed||c.value!==i)&&(e.setAttribute("style",c.value),r.normalizedStyles+=1);return}if(l==="class"){if(!t.keepClasses){e.removeAttribute(s.name),r.removedAttributes+=1;return}const c=Ie(i);if(!c){e.removeAttribute(s.name),r.removedAttributes+=1;return}c!==i&&(e.setAttribute("class",c),r.removedAttributes+=1);return}if(l.startsWith("data-")&&!t.keepDataAttributes){e.removeAttribute(s.name),r.removedAttributes+=1;return}if(l==="id"||l==="xmlns"||l.startsWith("xml")){e.removeAttribute(s.name),r.removedAttributes+=1;return}if((a==="word"||a==="google-docs")&&(l==="lang"||l==="dir")){e.removeAttribute(s.name),r.removedAttributes+=1;return}if(l==="href"||l==="src"||l==="xlink:href"){const c=ue(i);if(!c){e.removeAttribute(s.name),r.removedAttributes+=1;return}c!==i&&e.setAttribute(s.name,c)}}),n==="a"){if(!e.getAttribute("href")){fe(e),r.removedElements+=1;return}e.getAttribute("target")==="_blank"&&e.setAttribute("rel","noopener noreferrer")}if(n==="img"){const s=e.getAttribute("src");if(!s||!ue(s)){r.removedElements+=1,e.remove();return}}if(Te.has(n)&&!e.attributes.length&&!e.className&&!e.style.cssText){const s=e.children.length>0,l=(e.textContent||"").trim().length>0;if(!s&&!l){e.remove(),r.removedElements+=1;return}!s&&l&&(fe(e),r.removedElements+=1)}}function Ke(e,t,a,r,n){const o=document.createElement("template");o.innerHTML=e;const s={removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0};if(r.removeComments)try{const f=document.createTreeWalker(o.content,Ee,null),b=[];let k=f.nextNode();for(;k;)b.push(k),k=f.nextNode();b.forEach(v=>{v.remove(),s.removedComments+=1})}catch{}Array.from(o.content.querySelectorAll("*")).forEach(f=>{f.isConnected&&We(f,t,a,s)});let i=o.innerHTML;r.normalizeWhitespace&&n!=="fidelity"?i=i.replace(/\s{2,}/g," ").replace(/>\s+</g,"><").trim():r.normalizeWhitespace&&(i=i.trim());const c=(o.content.textContent||"").trim().length;return{html:i,textLength:c,counters:s}}function ge(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const a=t.getRangeAt(0);return e.contains(a.commonAncestorContainer)?a:null}function he(e,t){if(!e.isConnected)return;const a=window.getSelection();a&&(a.removeAllRanges(),a.addRange(t))}function Ve(e,t){e.focus({preventScroll:!0});try{if(document.execCommand("insertHTML",!1,t))return!0}catch{}const a=ge(e);if(!a)return!1;a.deleteContents();const r=document.createElement("template");r.innerHTML=t;const n=r.content,o=n.lastChild;if(a.insertNode(n),o){const s=document.createRange();s.setStartAfter(o),s.collapse(!0),he(e,s)}return!0}function je(e,t){e.focus({preventScroll:!0});try{if(document.execCommand("insertText",!1,t))return!0}catch{}const a=ge(e);if(!a)return!1;a.deleteContents();const r=document.createTextNode(t);a.insertNode(r);const n=document.createRange();return n.setStart(r,r.length),n.collapse(!0),he(e,n),!0}function Fe(e,t){if(t===e.innerHTML)return;const a=window.execEditorCommand||window.executeEditorCommand;if(typeof a=="function")try{a("recordDomTransaction",e,t,e.innerHTML)}catch{}}function Ge(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function W(e,t,a,r,n,o){return{source:e,profile:t,inputHtmlLength:a,outputHtmlLength:r,outputTextLength:n,removedElements:o.removedElements,removedAttributes:o.removedAttributes,removedComments:o.removedComments,normalizedStyles:o.normalizedStyles,createdAt:new Date().toISOString()}}function Ue(e,t,a,r){const n=qe(e,t);if(a==="plain"){const l=t||e.replace(/<[^>]*>/g," "),i=J(l,r);return{mode:"text",value:i,report:W(n,a,e.length,0,i.length,{removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0})}}if(!e||e.length>r.maxHtmlLength){const l=J(t||e.replace(/<[^>]*>/g," "),r);return{mode:"text",value:l,report:W(n,a,e.length,0,l.length,{removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0})}}const o=r.profileOptions[a],s=Ke(e,o,n,r,a);if(!s.html){const l=J(t||e.replace(/<[^>]*>/g," "),r);return{mode:"text",value:l,report:W(n,a,e.length,0,l.length,s.counters)}}return{mode:"html",value:s.html,report:W(n,a,e.length,s.html.length,s.textLength,s.counters)}}function G(e,t){return e==="balanced"?t.balancedText:e==="plain"?t.plainText:t.fidelityText}function ae(e){return e==="fidelity"?"balanced":e==="balanced"?"plain":"fidelity"}function Ye(e,t){e.setAttribute("aria-label",t.labels.panelAriaLabel);const a=e.querySelector(".rte-smart-paste-title");a&&(a.textContent=t.labels.panelTitle);const r=e.querySelector('[data-action="close"]');r&&r.setAttribute("aria-label",t.labels.closeText);const n=e.querySelector('[data-action="toggle-enabled"]');if(n){const Se=n.getAttribute("data-enabled")==="true";n.textContent=Se?t.labels.toggleOnText:t.labels.toggleOffText}const o=e.querySelector('[data-action="cycle-profile"]');o&&(o.textContent=t.labels.cycleProfileText);const s=e.querySelector(".rte-smart-paste-profile-heading");s&&(s.textContent=t.labels.profileLabel);const l=e.querySelector('.rte-smart-paste-profile[role="group"]');l&&l.setAttribute("aria-label",t.labels.profileLabel);const i=e.querySelector('[data-action="set-profile"][data-profile="fidelity"]');i&&(i.textContent=t.labels.fidelityText);const c=e.querySelector('[data-action="set-profile"][data-profile="balanced"]');c&&(c.textContent=t.labels.balancedText);const f=e.querySelector('[data-action="set-profile"][data-profile="plain"]');f&&(f.textContent=t.labels.plainText);const b=e.querySelector(".rte-smart-paste-report-title");b&&(b.textContent=t.labels.lastPasteHeading);const k=e.querySelector(".rte-smart-paste-empty");k&&(k.textContent=t.labels.lastPasteEmptyText);const v=e.querySelector('[data-key="source-label"]');v&&(v.textContent=t.labels.lastPasteSourceLabel);const U=e.querySelector('[data-key="profile-label"]');U&&(U.textContent=t.labels.lastPasteProfileLabel);const M=e.querySelector('[data-key="removed-label"]');M&&(M.textContent=t.labels.lastPasteRemovedLabel);const oe=e.querySelector('[data-key="chars-label"]');oe&&(oe.textContent=t.labels.lastPasteCharsLabel);const ne=e.querySelector(".rte-smart-paste-shortcut");ne&&(ne.textContent=t.labels.shortcutText)}function x(e){const t=g.get(e),a=d.get(e)||$,r=L.get(e);if(!t||!a||!r)return;Ye(t,a);const n=t.querySelector(".rte-smart-paste-status");n&&(n.textContent=r.enabled?a.labels.enabledText:a.labels.disabledText);const o=t.querySelector('[data-action="toggle-enabled"]');o&&(o.setAttribute("data-enabled",r.enabled?"true":"false"),o.textContent=r.enabled?a.labels.toggleOnText:a.labels.toggleOffText,o.setAttribute("aria-pressed",r.enabled?"true":"false")),Array.from(t.querySelectorAll('[data-action="set-profile"][data-profile]')).forEach(v=>{const M=z(v.getAttribute("data-profile"))===r.profile;v.classList.toggle("active",M),v.setAttribute("aria-pressed",M?"true":"false")});const l=t.querySelector(".rte-smart-paste-empty"),i=t.querySelector(".rte-smart-paste-report"),c=t.querySelector('[data-key="source-value"]'),f=t.querySelector('[data-key="profile-value"]'),b=t.querySelector('[data-key="removed-value"]'),k=t.querySelector('[data-key="chars-value"]');if(!r.lastReport){l&&(l.hidden=!1),i&&(i.hidden=!0);return}if(l&&(l.hidden=!0),i&&(i.hidden=!1),c&&(c.textContent=r.lastReport.source),f&&(f.textContent=G(r.lastReport.profile,a.labels)),b){const v=r.lastReport.removedElements+r.lastReport.removedAttributes+r.lastReport.removedComments+r.lastReport.normalizedStyles;b.textContent=String(v)}k&&(k.textContent=String(r.lastReport.outputTextLength))}function Q(e,t){if(!t.classList.contains("show"))return;const a=te(e).getBoundingClientRect(),r=Math.min(window.innerWidth-20,360),n=Math.max(10,window.innerWidth-r-10),o=Math.min(Math.max(10,a.right-r),n),s=Math.max(10,Math.min(window.innerHeight-10,a.top+12));t.style.width=`${r}px`,t.style.left=`${o}px`,t.style.top=`${s}px`,t.style.maxHeight=`${Math.max(240,window.innerHeight-20)}px`}function N(e,t=!1){const a=g.get(e);a&&(a.classList.remove("show"),q.set(e,!1),D(e,"toggleSmartPastePanel",!1),t&&e.focus({preventScroll:!0}))}function Xe(e){const t=g.get(e);if(t)return t;const a=d.get(e)||$||K(),r=`rte-smart-paste-panel-${$e++}`,n=document.createElement("section");return n.className=u,n.id=r,n.setAttribute("role","dialog"),n.setAttribute("aria-modal","false"),n.setAttribute("aria-label",a.labels.panelAriaLabel),n.innerHTML=`
`).trim():a}function Ne(e){return/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office|<o:p\b/i.test(e)}function qe(e){return/id=["']docs-internal-guid|docs-\w+|data-sheets-value|data-sheets-userformat/i.test(e)}function Ie(e,t){return e?Ne(e)?"word":qe(e)?"google-docs":"html":t?"plain":"html"}function Be(e){return e.split(/\s+/).map(a=>a.trim()).filter(Boolean).filter(a=>!/^mso/i.test(a)).filter(a=>!/^docs-/i.test(a)).filter(a=>!/^c\d+$/i.test(a)).join(" ")}function We(e){if(!e)return{value:"",changed:!1};const t=e.split(";"),a=[];let r=!1;return t.forEach(n=>{const o=n.indexOf(":");if(o<=0){n.trim()&&(r=!0);return}const s=n.slice(0,o).trim().toLowerCase(),l=n.slice(o+1).trim();if(!s||!l){r=!0;return}if(!Le.has(s)){r=!0;return}if(/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(l)){r=!0;return}a.push(`${s}: ${l}`)}),{value:a.join("; "),changed:r}}function fe(e){const t=e.trim();return t&&(Ae.test(t)||we.test(t))?t:""}function pe(e){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}}function Ke(e,t,a,r){const n=e.tagName.toLowerCase();if(Ce.has(n)){r.removedElements+=1,e.remove();return}if(!t.preserveTables&&Te.has(n)){const s=e.textContent||"",l=document.createTextNode(s);e.replaceWith(l),r.removedElements+=1;return}if(Array.from(e.attributes).forEach(s=>{const l=s.name.toLowerCase(),i=s.value;if(l.startsWith("on")){e.removeAttribute(s.name),r.removedAttributes+=1;return}if(l==="style"){if(!t.keepStyles){e.removeAttribute(s.name),r.removedAttributes+=1;return}const c=We(i);if(!c.value){e.removeAttribute(s.name),r.removedAttributes+=1,c.changed&&(r.normalizedStyles+=1);return}(c.changed||c.value!==i)&&(e.setAttribute("style",c.value),r.normalizedStyles+=1);return}if(l==="class"){if(!t.keepClasses){e.removeAttribute(s.name),r.removedAttributes+=1;return}const c=Be(i);if(!c){e.removeAttribute(s.name),r.removedAttributes+=1;return}c!==i&&(e.setAttribute("class",c),r.removedAttributes+=1);return}if(l.startsWith("data-")&&!t.keepDataAttributes){e.removeAttribute(s.name),r.removedAttributes+=1;return}if(l==="id"||l==="xmlns"||l.startsWith("xml")){e.removeAttribute(s.name),r.removedAttributes+=1;return}if((a==="word"||a==="google-docs")&&(l==="lang"||l==="dir")){e.removeAttribute(s.name),r.removedAttributes+=1;return}if(l==="href"||l==="src"||l==="xlink:href"){const c=fe(i);if(!c){e.removeAttribute(s.name),r.removedAttributes+=1;return}c!==i&&e.setAttribute(s.name,c)}}),n==="a"){if(!e.getAttribute("href")){pe(e),r.removedElements+=1;return}e.getAttribute("target")==="_blank"&&e.setAttribute("rel","noopener noreferrer")}if(n==="img"){const s=e.getAttribute("src");if(!s||!fe(s)){r.removedElements+=1,e.remove();return}}if(Pe.has(n)&&!e.attributes.length&&!e.className&&!e.style.cssText){const s=e.children.length>0,l=(e.textContent||"").trim().length>0;if(!s&&!l){e.remove(),r.removedElements+=1;return}!s&&l&&(pe(e),r.removedElements+=1)}}function Ve(e,t,a,r,n){const o=document.createElement("template");o.innerHTML=e;const s={removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0};if(r.removeComments)try{const f=document.createTreeWalker(o.content,ke,null),b=[];let k=f.nextNode();for(;k;)b.push(k),k=f.nextNode();b.forEach(v=>{v.remove(),s.removedComments+=1})}catch{}Array.from(o.content.querySelectorAll("*")).forEach(f=>{f.isConnected&&Ke(f,t,a,s)});let i=o.innerHTML;r.normalizeWhitespace&&n!=="fidelity"?i=i.replace(/\s{2,}/g," ").replace(/>\s+</g,"><").trim():r.normalizeWhitespace&&(i=i.trim());const c=(o.content.textContent||"").trim().length;return{html:i,textLength:c,counters:s}}function he(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const a=t.getRangeAt(0);return e.contains(a.commonAncestorContainer)?a:null}function ye(e,t){if(!e.isConnected)return;const a=window.getSelection();a&&(a.removeAllRanges(),a.addRange(t))}function je(e,t){e.focus({preventScroll:!0});try{if(document.execCommand("insertHTML",!1,t))return!0}catch{}const a=he(e);if(!a)return!1;a.deleteContents();const r=document.createElement("template");r.innerHTML=t;const n=r.content,o=n.lastChild;if(a.insertNode(n),o){const s=document.createRange();s.setStartAfter(o),s.collapse(!0),ye(e,s)}return!0}function Fe(e,t){e.focus({preventScroll:!0});try{if(document.execCommand("insertText",!1,t))return!0}catch{}const a=he(e);if(!a)return!1;a.deleteContents();const r=document.createTextNode(t);a.insertNode(r);const n=document.createRange();return n.setStart(r,r.length),n.collapse(!0),ye(e,n),!0}function Ge(e,t){if(t===e.innerHTML)return;const a=window.execEditorCommand||window.executeEditorCommand;if(typeof a=="function")try{a("recordDomTransaction",e,t,e.innerHTML)}catch{}}function Ue(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function W(e,t,a,r,n,o){return{source:e,profile:t,inputHtmlLength:a,outputHtmlLength:r,outputTextLength:n,removedElements:o.removedElements,removedAttributes:o.removedAttributes,removedComments:o.removedComments,normalizedStyles:o.normalizedStyles,createdAt:new Date().toISOString()}}function Ye(e,t,a,r){const n=Ie(e,t);if(a==="plain"){const l=t||e.replace(/<[^>]*>/g," "),i=J(l,r);return{mode:"text",value:i,report:W(n,a,e.length,0,i.length,{removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0})}}if(!e||e.length>r.maxHtmlLength){const l=J(t||e.replace(/<[^>]*>/g," "),r);return{mode:"text",value:l,report:W(n,a,e.length,0,l.length,{removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0})}}const o=r.profileOptions[a],s=Ve(e,o,n,r,a);if(!s.html){const l=J(t||e.replace(/<[^>]*>/g," "),r);return{mode:"text",value:l,report:W(n,a,e.length,0,l.length,s.counters)}}return{mode:"html",value:s.html,report:W(n,a,e.length,s.html.length,s.textLength,s.counters)}}function G(e,t){return e==="balanced"?t.balancedText:e==="plain"?t.plainText:t.fidelityText}function ae(e){return e==="fidelity"?"balanced":e==="balanced"?"plain":"fidelity"}function Xe(e,t){e.setAttribute("aria-label",t.labels.panelAriaLabel);const a=e.querySelector(".rte-smart-paste-title");a&&(a.textContent=t.labels.panelTitle);const r=e.querySelector('[data-action="close"]');r&&r.setAttribute("aria-label",t.labels.closeText);const n=e.querySelector('[data-action="toggle-enabled"]');if(n){const Ee=n.getAttribute("data-enabled")==="true";n.textContent=Ee?t.labels.toggleOnText:t.labels.toggleOffText}const o=e.querySelector('[data-action="cycle-profile"]');o&&(o.textContent=t.labels.cycleProfileText);const s=e.querySelector(".rte-smart-paste-profile-heading");s&&(s.textContent=t.labels.profileLabel);const l=e.querySelector('.rte-smart-paste-profile[role="group"]');l&&l.setAttribute("aria-label",t.labels.profileLabel);const i=e.querySelector('[data-action="set-profile"][data-profile="fidelity"]');i&&(i.textContent=t.labels.fidelityText);const c=e.querySelector('[data-action="set-profile"][data-profile="balanced"]');c&&(c.textContent=t.labels.balancedText);const f=e.querySelector('[data-action="set-profile"][data-profile="plain"]');f&&(f.textContent=t.labels.plainText);const b=e.querySelector(".rte-smart-paste-report-title");b&&(b.textContent=t.labels.lastPasteHeading);const k=e.querySelector(".rte-smart-paste-empty");k&&(k.textContent=t.labels.lastPasteEmptyText);const v=e.querySelector('[data-key="source-label"]');v&&(v.textContent=t.labels.lastPasteSourceLabel);const U=e.querySelector('[data-key="profile-label"]');U&&(U.textContent=t.labels.lastPasteProfileLabel);const M=e.querySelector('[data-key="removed-label"]');M&&(M.textContent=t.labels.lastPasteRemovedLabel);const ne=e.querySelector('[data-key="chars-label"]');ne&&(ne.textContent=t.labels.lastPasteCharsLabel);const se=e.querySelector(".rte-smart-paste-shortcut");se&&(se.textContent=t.labels.shortcutText)}function x(e){const t=g.get(e),a=d.get(e)||$,r=L.get(e);if(!t||!a||!r)return;Xe(t,a);const n=t.querySelector(".rte-smart-paste-status");n&&(n.textContent=r.enabled?a.labels.enabledText:a.labels.disabledText);const o=t.querySelector('[data-action="toggle-enabled"]');o&&(o.setAttribute("data-enabled",r.enabled?"true":"false"),o.textContent=r.enabled?a.labels.toggleOnText:a.labels.toggleOffText,o.setAttribute("aria-pressed",r.enabled?"true":"false")),Array.from(t.querySelectorAll('[data-action="set-profile"][data-profile]')).forEach(v=>{const M=z(v.getAttribute("data-profile"))===r.profile;v.classList.toggle("active",M),v.setAttribute("aria-pressed",M?"true":"false")});const l=t.querySelector(".rte-smart-paste-empty"),i=t.querySelector(".rte-smart-paste-report"),c=t.querySelector('[data-key="source-value"]'),f=t.querySelector('[data-key="profile-value"]'),b=t.querySelector('[data-key="removed-value"]'),k=t.querySelector('[data-key="chars-value"]');if(!r.lastReport){l&&(l.hidden=!1),i&&(i.hidden=!0);return}if(l&&(l.hidden=!0),i&&(i.hidden=!1),c&&(c.textContent=r.lastReport.source),f&&(f.textContent=G(r.lastReport.profile,a.labels)),b){const v=r.lastReport.removedElements+r.lastReport.removedAttributes+r.lastReport.removedComments+r.lastReport.normalizedStyles;b.textContent=String(v)}k&&(k.textContent=String(r.lastReport.outputTextLength))}function Q(e,t){if(!t.classList.contains("show"))return;const a=te(e).getBoundingClientRect(),r=Math.min(window.innerWidth-20,360),n=Math.max(10,window.innerWidth-r-10),o=Math.min(Math.max(10,a.right-r),n),s=Math.max(10,Math.min(window.innerHeight-10,a.top+12));t.style.width=`${r}px`,t.style.left=`${o}px`,t.style.top=`${s}px`,t.style.maxHeight=`${Math.max(240,window.innerHeight-20)}px`}function N(e,t=!1){const a=g.get(e);a&&(a.classList.remove("show"),q.set(e,!1),D(e,"toggleSmartPastePanel",!1),t&&e.focus({preventScroll:!0}))}function Ze(e){const t=g.get(e);if(t)return t;const a=d.get(e)||$||K(),r=`rte-smart-paste-panel-${Me++}`,n=document.createElement("section");return n.className=u,n.id=r,n.setAttribute("role","dialog"),n.setAttribute("aria-modal","false"),n.setAttribute("aria-label",a.labels.panelAriaLabel),n.innerHTML=`
<header class="rte-smart-paste-header">

@@ -38,3 +38,3 @@ <h2 class="rte-smart-paste-title">${X(a.labels.panelTitle)}</h2>

<div class="rte-smart-paste-live" aria-live="polite" aria-atomic="true"></div>
`,n.addEventListener("click",o=>{const l=o.target?.closest("[data-action]");if(!l)return;const i=l.getAttribute("data-action");if(i){if(i==="close"){N(e,!0);return}if(i==="toggle-enabled"){const c=p(e,d.get(e)||a);c.enabled=!c.enabled,D(e,"toggleSmartPasteEnabled",c.enabled),x(e),O(n,c.enabled?a.labels.enabledText:a.labels.disabledText);return}if(i==="cycle-profile"){const c=p(e,d.get(e)||a);c.profile=ae(c.profile),x(e),O(n,`${a.labels.profileLabel}: ${G(c.profile,a.labels)}`);return}if(i==="set-profile"){const c=p(e,d.get(e)||a);c.profile=z(l.getAttribute("data-profile")),x(e),O(n,`${a.labels.profileLabel}: ${G(c.profile,a.labels)}`)}}}),n.addEventListener("keydown",o=>{if(o.key==="Escape"){o.preventDefault(),N(e,!0);return}if(o.key!=="ArrowRight"&&o.key!=="ArrowLeft")return;const s=Array.from(n.querySelectorAll('[data-action="set-profile"][data-profile]'));if(s.length===0)return;const l=s.findIndex(f=>f===document.activeElement);if(l<0)return;const i=o.key==="ArrowRight"?1:-1,c=(l+i+s.length)%s.length;o.preventDefault(),s[c].focus()}),F(n,e),document.body.appendChild(n),g.set(e,n),q.set(e,!1),x(e),n}function ye(e){const t=Xe(e);g.forEach((r,n)=>{n!==e&&N(n,!1)}),t.classList.add("show"),q.set(e,!0),D(e,"toggleSmartPastePanel",!0),F(t,e),Q(e,t),t.querySelector('[data-action="toggle-enabled"]')?.focus()}function xe(e,t){const a=re(e);return(typeof t=="boolean"?t:!a)?ye(e):N(e,!1),!0}function ve(e){return{enabled:e.enabled,profile:e.profile,lastReport:e.lastReport?{...e.lastReport}:null}}function Ze(e,t){const a=d.get(e)||$;if(!a)return!1;const r=p(e,a);if(!r.enabled||de(e)){const b=g.get(e);return b&&de(e)&&O(b,a.labels.readonlyMessage),!1}const n=t.clipboardData;if(!n)return!1;const o=n.getData("text/html")||"",s=n.getData("text/plain")||"";if(!o&&!s)return!1;const l=Ue(o,s,r.profile,a);if(!l.value)return!1;const i=e.innerHTML;if(!(l.mode==="html"?Ve(e,l.value):je(e,l.value)))return!1;r.lastReport={...l.report},L.set(e,r),Fe(e,i),Ge(e),e.dispatchEvent(new CustomEvent("editora:smart-paste",{bubbles:!0,detail:ve(r)})),x(e);const f=g.get(e);if(f){const b=l.report.removedElements+l.report.removedAttributes+l.report.removedComments+l.report.normalizedStyles;O(f,`${a.labels.panelTitle}: ${G(r.profile,a.labels)}. ${a.labels.lastPasteRemovedLabel}: ${b}.`)}return!0}function Je(e){return t=>{t.defaultPrevented||t[ie]===!0||(m=e,!Ze(e,t))||(t[ie]=!0,t.preventDefault(),typeof t.stopImmediatePropagation=="function"?t.stopImmediatePropagation():t.stopPropagation())}}function Qe(e){if(j.has(e))return;const t=Je(e);e.addEventListener("paste",t,!0),j.set(e,t)}function R(e){const t=L.get(e);D(e,"toggleSmartPastePanel",re(e)),D(e,"toggleSmartPasteEnabled",t?.enabled===!0)}function et(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="s"}function tt(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="v"}function rt(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="g"}function at(e){$=e,P||(P=t=>{V();const r=t.target?.closest(y);if(!r)return;const n=d.get(r)||e;p(r,n),d.set(r,n),m=r,R(r);const o=g.get(r);o&&(F(o,r),Q(r,o),x(r))},document.addEventListener("focusin",P,!0)),A||(A=t=>{if(t.defaultPrevented||t.target?.closest(`.${u} input, .${u} textarea, .${u} select`))return;const r=_e(t);if(!r)return;const n=d.get(r)||$||e;if(p(r,n),d.set(r,n),m=r,t.key==="Escape"&&re(r)){t.preventDefault(),N(r,!0);return}if(et(t)){t.preventDefault(),t.stopPropagation(),xe(r);return}if(tt(t)){t.preventDefault(),t.stopPropagation();const o=p(r,n);o.profile=ae(o.profile),x(r);return}if(rt(t)){t.preventDefault(),t.stopPropagation();const o=p(r,n);o.enabled=!o.enabled,R(r),x(r)}},document.addEventListener("keydown",A,!0)),T||(T=()=>{V(),g.forEach((t,a)=>{!a.isConnected||!t.isConnected||(F(t,a),Q(a,t))})},window.addEventListener("scroll",T,!0),window.addEventListener("resize",T)),!w&&typeof MutationObserver<"u"&&document.body&&(w=new MutationObserver(t=>{He(t)&&V()}),w.observe(document.body,{childList:!0,subtree:!0}))}function ot(){P&&(document.removeEventListener("focusin",P,!0),P=null),A&&(document.removeEventListener("keydown",A,!0),A=null),T&&(window.removeEventListener("scroll",T,!0),window.removeEventListener("resize",T),T=null),w&&(w.disconnect(),w=null),g.forEach(e=>e.remove()),g.clear(),_.forEach(e=>me(e)),_.clear(),$=null,m=null}function nt(){if(typeof document>"u"||document.getElementById(le))return;const e=document.createElement("style");e.id=le,e.textContent=`
`,n.addEventListener("click",o=>{const l=o.target?.closest("[data-action]");if(!l)return;const i=l.getAttribute("data-action");if(i){if(i==="close"){N(e,!0);return}if(i==="toggle-enabled"){const c=p(e,d.get(e)||a);c.enabled=!c.enabled,D(e,"toggleSmartPasteEnabled",c.enabled),x(e),O(n,c.enabled?a.labels.enabledText:a.labels.disabledText);return}if(i==="cycle-profile"){const c=p(e,d.get(e)||a);c.profile=ae(c.profile),x(e),O(n,`${a.labels.profileLabel}: ${G(c.profile,a.labels)}`);return}if(i==="set-profile"){const c=p(e,d.get(e)||a);c.profile=z(l.getAttribute("data-profile")),x(e),O(n,`${a.labels.profileLabel}: ${G(c.profile,a.labels)}`)}}}),n.addEventListener("keydown",o=>{if(o.key==="Escape"){o.preventDefault(),N(e,!0);return}if(o.key!=="ArrowRight"&&o.key!=="ArrowLeft")return;const s=Array.from(n.querySelectorAll('[data-action="set-profile"][data-profile]'));if(s.length===0)return;const l=s.findIndex(f=>f===document.activeElement);if(l<0)return;const i=o.key==="ArrowRight"?1:-1,c=(l+i+s.length)%s.length;o.preventDefault(),s[c].focus()}),F(n,e),document.body.appendChild(n),g.set(e,n),q.set(e,!1),x(e),n}function xe(e){const t=Ze(e);g.forEach((r,n)=>{n!==e&&N(n,!1)}),t.classList.add("show"),q.set(e,!0),D(e,"toggleSmartPastePanel",!0),F(t,e),Q(e,t),t.querySelector('[data-action="toggle-enabled"]')?.focus()}function ve(e,t){const a=re(e);return(typeof t=="boolean"?t:!a)?xe(e):N(e,!1),!0}function Se(e){return{enabled:e.enabled,profile:e.profile,lastReport:e.lastReport?{...e.lastReport}:null}}function Je(e,t){const a=d.get(e)||$;if(!a)return!1;const r=p(e,a);if(!r.enabled||ue(e)){const b=g.get(e);return b&&ue(e)&&O(b,a.labels.readonlyMessage),!1}const n=t.clipboardData;if(!n)return!1;const o=n.getData("text/html")||"",s=n.getData("text/plain")||"";if(!o&&!s)return!1;const l=Ye(o,s,r.profile,a);if(!l.value)return!1;const i=e.innerHTML;if(!(l.mode==="html"?je(e,l.value):Fe(e,l.value)))return!1;r.lastReport={...l.report},L.set(e,r),Ge(e,i),Ue(e),e.dispatchEvent(new CustomEvent("editora:smart-paste",{bubbles:!0,detail:Se(r)})),x(e);const f=g.get(e);if(f){const b=l.report.removedElements+l.report.removedAttributes+l.report.removedComments+l.report.normalizedStyles;O(f,`${a.labels.panelTitle}: ${G(r.profile,a.labels)}. ${a.labels.lastPasteRemovedLabel}: ${b}.`)}return!0}function Qe(e){return t=>{t.defaultPrevented||t[ce]===!0||(m=e,!Je(e,t))||(t[ce]=!0,t.preventDefault(),typeof t.stopImmediatePropagation=="function"?t.stopImmediatePropagation():t.stopPropagation())}}function et(e){if(j.has(e))return;const t=Qe(e);e.addEventListener("paste",t,!0),j.set(e,t)}function R(e){const t=L.get(e);D(e,"toggleSmartPastePanel",re(e)),D(e,"toggleSmartPasteEnabled",t?.enabled===!0)}function oe(e){return typeof e.key=="string"?e.key.toLowerCase():""}function tt(e){const t=oe(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="s"}function rt(e){const t=oe(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="v"}function at(e){const t=oe(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="g"}function ot(e){$=e,P||(P=t=>{V();const r=t.target?.closest(y);if(!r)return;const n=d.get(r)||e;p(r,n),d.set(r,n),m=r,R(r);const o=g.get(r);o&&(F(o,r),Q(r,o),x(r))},document.addEventListener("focusin",P,!0)),A||(A=t=>{if(t.defaultPrevented||t.target?.closest(`.${u} input, .${u} textarea, .${u} select`))return;const r=ze(t);if(!r)return;const n=d.get(r)||$||e;if(p(r,n),d.set(r,n),m=r,t.key==="Escape"&&re(r)){t.preventDefault(),N(r,!0);return}if(tt(t)){t.preventDefault(),t.stopPropagation(),ve(r);return}if(rt(t)){t.preventDefault(),t.stopPropagation();const o=p(r,n);o.profile=ae(o.profile),x(r);return}if(at(t)){t.preventDefault(),t.stopPropagation();const o=p(r,n);o.enabled=!o.enabled,R(r),x(r)}},document.addEventListener("keydown",A,!0)),T||(T=()=>{V(),g.forEach((t,a)=>{!a.isConnected||!t.isConnected||(F(t,a),Q(a,t))})},window.addEventListener("scroll",T,!0),window.addEventListener("resize",T)),!w&&typeof MutationObserver<"u"&&document.body&&(w=new MutationObserver(t=>{De(t)&&V()}),w.observe(document.body,{childList:!0,subtree:!0}))}function nt(){P&&(document.removeEventListener("focusin",P,!0),P=null),A&&(document.removeEventListener("keydown",A,!0),A=null),T&&(window.removeEventListener("scroll",T,!0),window.removeEventListener("resize",T),T=null),w&&(w.disconnect(),w=null),g.forEach(e=>e.remove()),g.clear(),_.forEach(e=>be(e)),_.clear(),$=null,m=null}function st(){if(typeof document>"u"||document.getElementById(ie))return;const e=document.createElement("style");e.id=ie,e.textContent=`
.rte-toolbar-group-items.${h},

@@ -399,2 +399,2 @@ .editora-toolbar-group-items.${h},

}
`,document.head.appendChild(e)}const st=(e={})=>{const t=K(e),a=new Set;return nt(),{name:"smartPaste",toolbar:[{id:"smartPasteGroup",label:"Smart Paste",type:"group",command:"smartPaste",items:[{id:"smartPaste",label:"Smart Paste Panel",command:"toggleSmartPastePanel",shortcut:"Mod-Alt-Shift-s",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M8.5 4.5h7l3 3V18a2.5 2.5 0 0 1-2.5 2.5h-7A2.5 2.5 0 0 1 6.5 18V7a2.5 2.5 0 0 1 2-2.45Z" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/><path d="M15.5 4.5V8h3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><path d="M9.3 12h5.4M9.3 15h5.4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'},{id:"smartPasteProfile",label:"Cycle Smart Paste Profile",command:"cycleSmartPasteProfile",shortcut:"Mod-Alt-Shift-v",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4.5 7.5h10" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="17.5" cy="7.5" r="2" stroke="currentColor" stroke-width="1.6"/><path d="M4.5 12h5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="12.5" cy="12" r="2" stroke="currentColor" stroke-width="1.6"/><path d="M4.5 16.5h12" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="9.5" cy="16.5" r="2" stroke="currentColor" stroke-width="1.6"/></svg>'},{id:"smartPasteToggle",label:"Toggle Smart Paste",command:"toggleSmartPasteEnabled",shortcut:"Mod-Alt-Shift-g",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="3.5" y="8" width="17" height="8" rx="4" stroke="currentColor" stroke-width="1.6"/><circle cx="8" cy="12" r="2.6" fill="currentColor"/><path d="M14.5 12h3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'}]}],commands:{smartPaste:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t;return p(o,s),d.set(o,s),m=o,ye(o),!0},toggleSmartPastePanel:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t;return p(o,s),d.set(o,s),m=o,xe(o,typeof r=="boolean"?r:void 0)},cycleSmartPasteProfile:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t,l=p(o,s);return d.set(o,s),l.profile=ae(l.profile),x(o),!0},setSmartPasteProfile:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t,l=p(o,s);return d.set(o,s),l.profile=z(r),x(o),!0},toggleSmartPasteEnabled:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t,l=p(o,s);return d.set(o,s),l.enabled=typeof r=="boolean"?r:!l.enabled,R(o),x(o),!0},setSmartPasteOptions:(r,n)=>{const o=C(n,!1,!1);if(!o||!r||typeof r!="object")return!1;const s=d.get(o)||t,l=ce(s),i=K({...l,...r,labels:{...s.labels,...r.labels||{}},profileOptions:{...l.profileOptions,...r.profileOptions||{},fidelity:{...l.profileOptions?.fidelity||{},...r.profileOptions?.fidelity||{}},balanced:{...l.profileOptions?.balanced||{},...r.profileOptions?.balanced||{}},plain:{...l.profileOptions?.plain||{},...r.profileOptions?.plain||{}}},normalizeText:r.normalizeText||s.normalizeText});d.set(o,i);const c=p(o,i);return typeof r.enabled=="boolean"&&(c.enabled=r.enabled),r.defaultProfile&&(c.profile=z(r.defaultProfile)),x(o),R(o),!0},getSmartPasteState:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t,l=p(o,s),i=ve(l);if(typeof r=="function")try{r(i)}catch{}return o.__smartPasteState=i,o.dispatchEvent(new CustomEvent("editora:smart-paste-state",{bubbles:!0,detail:i})),!0}},keymap:{"Mod-Alt-Shift-s":"toggleSmartPastePanel","Mod-Alt-Shift-S":"toggleSmartPastePanel","Mod-Alt-Shift-v":"cycleSmartPasteProfile","Mod-Alt-Shift-V":"cycleSmartPasteProfile","Mod-Alt-Shift-g":"toggleSmartPasteEnabled","Mod-Alt-Shift-G":"toggleSmartPasteEnabled"},init:function(n){I+=1;const o=this&&typeof this.__pluginConfig=="object"?K({...ce(t),...this.__pluginConfig}):t;at(o);const s=C(n?.editorElement?{editorElement:n.editorElement}:void 0,!1,!1);if(!s)return;m=s,a.add(s);const l=p(s,o);l.enabled=o.enabled,l.profile=o.defaultProfile,d.set(s,o),R(s)},destroy:()=>{a.forEach(r=>be(r)),a.clear(),I=Math.max(0,I-1),!(I>0)&&ot()}}};exports.SmartPastePlugin=st;
`,document.head.appendChild(e)}const lt=(e={})=>{const t=K(e),a=new Set;return st(),{name:"smartPaste",toolbar:[{id:"smartPasteGroup",label:"Smart Paste",type:"group",command:"smartPaste",items:[{id:"smartPaste",label:"Smart Paste Panel",command:"toggleSmartPastePanel",shortcut:"Mod-Alt-Shift-s",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M8.5 4.5h7l3 3V18a2.5 2.5 0 0 1-2.5 2.5h-7A2.5 2.5 0 0 1 6.5 18V7a2.5 2.5 0 0 1 2-2.45Z" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/><path d="M15.5 4.5V8h3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><path d="M9.3 12h5.4M9.3 15h5.4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'},{id:"smartPasteProfile",label:"Cycle Smart Paste Profile",command:"cycleSmartPasteProfile",shortcut:"Mod-Alt-Shift-v",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4.5 7.5h10" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="17.5" cy="7.5" r="2" stroke="currentColor" stroke-width="1.6"/><path d="M4.5 12h5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="12.5" cy="12" r="2" stroke="currentColor" stroke-width="1.6"/><path d="M4.5 16.5h12" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="9.5" cy="16.5" r="2" stroke="currentColor" stroke-width="1.6"/></svg>'},{id:"smartPasteToggle",label:"Toggle Smart Paste",command:"toggleSmartPasteEnabled",shortcut:"Mod-Alt-Shift-g",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="3.5" y="8" width="17" height="8" rx="4" stroke="currentColor" stroke-width="1.6"/><circle cx="8" cy="12" r="2.6" fill="currentColor"/><path d="M14.5 12h3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'}]}],commands:{smartPaste:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t;return p(o,s),d.set(o,s),m=o,xe(o),!0},toggleSmartPastePanel:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t;return p(o,s),d.set(o,s),m=o,ve(o,typeof r=="boolean"?r:void 0)},cycleSmartPasteProfile:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t,l=p(o,s);return d.set(o,s),l.profile=ae(l.profile),x(o),!0},setSmartPasteProfile:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t,l=p(o,s);return d.set(o,s),l.profile=z(r),x(o),!0},toggleSmartPasteEnabled:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t,l=p(o,s);return d.set(o,s),l.enabled=typeof r=="boolean"?r:!l.enabled,R(o),x(o),!0},setSmartPasteOptions:(r,n)=>{const o=C(n,!1,!1);if(!o||!r||typeof r!="object")return!1;const s=d.get(o)||t,l=de(s),i=K({...l,...r,labels:{...s.labels,...r.labels||{}},profileOptions:{...l.profileOptions,...r.profileOptions||{},fidelity:{...l.profileOptions?.fidelity||{},...r.profileOptions?.fidelity||{}},balanced:{...l.profileOptions?.balanced||{},...r.profileOptions?.balanced||{}},plain:{...l.profileOptions?.plain||{},...r.profileOptions?.plain||{}}},normalizeText:r.normalizeText||s.normalizeText});d.set(o,i);const c=p(o,i);return typeof r.enabled=="boolean"&&(c.enabled=r.enabled),r.defaultProfile&&(c.profile=z(r.defaultProfile)),x(o),R(o),!0},getSmartPasteState:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t,l=p(o,s),i=Se(l);if(typeof r=="function")try{r(i)}catch{}return o.__smartPasteState=i,o.dispatchEvent(new CustomEvent("editora:smart-paste-state",{bubbles:!0,detail:i})),!0}},keymap:{"Mod-Alt-Shift-s":"toggleSmartPastePanel","Mod-Alt-Shift-S":"toggleSmartPastePanel","Mod-Alt-Shift-v":"cycleSmartPasteProfile","Mod-Alt-Shift-V":"cycleSmartPasteProfile","Mod-Alt-Shift-g":"toggleSmartPasteEnabled","Mod-Alt-Shift-G":"toggleSmartPasteEnabled"},init:function(n){I+=1;const o=this&&typeof this.__pluginConfig=="object"?K({...de(t),...this.__pluginConfig}):t;ot(o);const s=C(n?.editorElement?{editorElement:n.editorElement}:void 0,!1,!1);if(!s)return;m=s,a.add(s);const l=p(s,o);l.enabled=o.enabled,l.profile=o.defaultProfile,d.set(s,o),R(s)},destroy:()=>{a.forEach(r=>ge(r)),a.clear(),I=Math.max(0,I-1),!(I>0)&&nt()}}};exports.SmartPastePlugin=lt;

@@ -1,2 +0,2 @@

const y = ".rte-content, .editora-content", ee = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", se = "__editoraCommandEditorRoot", le = "rte-smart-paste-styles", u = "rte-smart-paste-panel", h = "smart-paste", S = "smartPaste", E = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', Ee = typeof NodeFilter < "u" ? NodeFilter.SHOW_COMMENT : 128, ie = "__editoraSmartPasteHandled", ke = /* @__PURE__ */ new Set([
const y = ".rte-content, .editora-content", ee = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", le = "__editoraCommandEditorRoot", ie = "rte-smart-paste-styles", u = "rte-smart-paste-panel", h = "smart-paste", S = "smartPaste", E = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', ke = typeof NodeFilter < "u" ? NodeFilter.SHOW_COMMENT : 128, ce = "__editoraSmartPasteHandled", Ce = /* @__PURE__ */ new Set([
"script",

@@ -18,3 +18,3 @@ "style",

"option"
]), Ce = /* @__PURE__ */ new Set(["table", "thead", "tbody", "tfoot", "tr", "td", "th", "colgroup", "col"]), Te = /* @__PURE__ */ new Set(["span", "font"]), Ae = /^(https?:|mailto:|tel:|#|\/)/i, Pe = /^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i, we = /* @__PURE__ */ new Set([
]), Te = /* @__PURE__ */ new Set(["table", "thead", "tbody", "tfoot", "tr", "td", "th", "colgroup", "col"]), Ae = /* @__PURE__ */ new Set(["span", "font"]), Pe = /^(https?:|mailto:|tel:|#|\/)/i, we = /^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i, Le = /* @__PURE__ */ new Set([
"color",

@@ -51,3 +51,3 @@ "background-color",

"list-style-type"
]), Le = {
]), $e = {
panelTitle: "Smart Paste",

@@ -93,7 +93,7 @@ panelAriaLabel: "Smart paste panel",

}, d = /* @__PURE__ */ new WeakMap(), L = /* @__PURE__ */ new WeakMap(), g = /* @__PURE__ */ new Map(), q = /* @__PURE__ */ new WeakMap(), j = /* @__PURE__ */ new WeakMap(), z = /* @__PURE__ */ new Set();
let I = 0, $e = 0, $ = null, m = null, A = null, P = null, T = null, w = null;
let I = 0, Me = 0, $ = null, m = null, A = null, P = null, T = null, w = null;
function X(e) {
return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
}
function Me(e) {
function Oe(e) {
return e.replace(/\u00A0/g, " ").replace(/\r\n?/g, `

@@ -122,6 +122,6 @@ `);

labels: {
...Le,
...$e,
...e.labels || {}
},
normalizeText: e.normalizeText || Me,
normalizeText: e.normalizeText || Oe,
profileOptions: {

@@ -134,3 +134,3 @@ fidelity: Z(t.fidelity, Y.fidelity),

}
function ce(e) {
function de(e) {
return {

@@ -160,7 +160,7 @@ enabled: e.enabled,

}
function Oe() {
function Re() {
if (typeof window > "u") return null;
const e = window[se];
const e = window[le];
if (!(e instanceof HTMLElement)) return null;
window[se] = null;
window[le] = null;
const t = H(e);

@@ -176,3 +176,3 @@ if (t) return t;

}
function Re(e) {
function ze(e) {
const t = e.closest("[data-editora-editor]");

@@ -189,3 +189,3 @@ if (t && H(t) === e)

}
function pe(e) {
function me(e) {
return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;

@@ -199,7 +199,7 @@ }

}
const r = Oe();
const r = Re();
if (r) return r;
const n = window.getSelection();
if (n && n.rangeCount > 0) {
const l = pe(n.getRangeAt(0).startContainer)?.closest(y);
const l = me(n.getRangeAt(0).startContainer)?.closest(y);
if (l) return l;

@@ -219,3 +219,3 @@ }

}
function ze(e) {
function _e(e) {
const t = e.target;

@@ -228,3 +228,3 @@ if (t) {

if (a && a.rangeCount > 0) {
const n = pe(a.getRangeAt(0).startContainer)?.closest(y);
const n = me(a.getRangeAt(0).startContainer)?.closest(y);
if (n) return n;

@@ -237,3 +237,3 @@ }

}
function _e(e) {
function He(e) {
const t = te(e);

@@ -245,9 +245,9 @@ if (B(t)) return !0;

function F(e, t) {
e.classList.remove("rte-smart-paste-theme-dark"), _e(t) && e.classList.add("rte-smart-paste-theme-dark");
e.classList.remove("rte-smart-paste-theme-dark"), He(t) && e.classList.add("rte-smart-paste-theme-dark");
}
function de(e) {
function ue(e) {
return e.getAttribute("contenteditable") === "false" || e.getAttribute("data-readonly") === "true";
}
function D(e, t, a) {
const r = Re(e);
const r = ze(e);
Array.from(

@@ -268,17 +268,17 @@ r.querySelectorAll(

lastReport: null
}, L.set(e, a)), Qe(e), z.add(e), a;
}, L.set(e, a)), et(e), z.add(e), a;
}
function me(e) {
function be(e) {
const t = j.get(e);
t && (e.removeEventListener("paste", t, !0), j.delete(e));
}
function be(e) {
me(e), g.get(e)?.remove(), g.delete(e), q.delete(e), d.delete(e), L.delete(e), z.delete(e), m === e && (m = null);
function ge(e) {
be(e), g.get(e)?.remove(), g.delete(e), q.delete(e), d.delete(e), L.delete(e), z.delete(e), m === e && (m = null);
}
function V() {
Array.from(z).forEach((t) => {
t.isConnected || be(t);
t.isConnected || ge(t);
});
}
function He(e) {
function De(e) {
for (let t = 0; t < e.length; t += 1) {

@@ -312,15 +312,15 @@ const a = e[t];

}
function De(e) {
function Ne(e) {
return /class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office|<o:p\b/i.test(e);
}
function Ne(e) {
function qe(e) {
return /id=["']docs-internal-guid|docs-\w+|data-sheets-value|data-sheets-userformat/i.test(e);
}
function qe(e, t) {
return e ? De(e) ? "word" : Ne(e) ? "google-docs" : "html" : t ? "plain" : "html";
function Ie(e, t) {
return e ? Ne(e) ? "word" : qe(e) ? "google-docs" : "html" : t ? "plain" : "html";
}
function Ie(e) {
function Be(e) {
return e.split(/\s+/).map((a) => a.trim()).filter(Boolean).filter((a) => !/^mso/i.test(a)).filter((a) => !/^docs-/i.test(a)).filter((a) => !/^c\d+$/i.test(a)).join(" ");
}
function Be(e) {
function We(e) {
if (!e) return { value: "", changed: !1 };

@@ -340,3 +340,3 @@ const t = e.split(";"), a = [];

}
if (!we.has(s)) {
if (!Le.has(s)) {
r = !0;

@@ -355,7 +355,7 @@ return;

}
function ue(e) {
function fe(e) {
const t = e.trim();
return t && (Ae.test(t) || Pe.test(t)) ? t : "";
return t && (Pe.test(t) || we.test(t)) ? t : "";
}
function fe(e) {
function pe(e) {
const t = e.parentNode;

@@ -368,9 +368,9 @@ if (t) {

}
function We(e, t, a, r) {
function Ke(e, t, a, r) {
const n = e.tagName.toLowerCase();
if (ke.has(n)) {
if (Ce.has(n)) {
r.removedElements += 1, e.remove();
return;
}
if (!t.preserveTables && Ce.has(n)) {
if (!t.preserveTables && Te.has(n)) {
const s = e.textContent || "", l = document.createTextNode(s);

@@ -391,3 +391,3 @@ e.replaceWith(l), r.removedElements += 1;

}
const c = Be(i);
const c = We(i);
if (!c.value) {

@@ -405,3 +405,3 @@ e.removeAttribute(s.name), r.removedAttributes += 1, c.changed && (r.normalizedStyles += 1);

}
const c = Ie(i);
const c = Be(i);
if (!c) {

@@ -427,3 +427,3 @@ e.removeAttribute(s.name), r.removedAttributes += 1;

if (l === "href" || l === "src" || l === "xlink:href") {
const c = ue(i);
const c = fe(i);
if (!c) {

@@ -437,3 +437,3 @@ e.removeAttribute(s.name), r.removedAttributes += 1;

if (!e.getAttribute("href")) {
fe(e), r.removedElements += 1;
pe(e), r.removedElements += 1;
return;

@@ -445,3 +445,3 @@ }

const s = e.getAttribute("src");
if (!s || !ue(s)) {
if (!s || !fe(s)) {
r.removedElements += 1, e.remove();

@@ -451,3 +451,3 @@ return;

}
if (Te.has(n) && !e.attributes.length && !e.className && !e.style.cssText) {
if (Ae.has(n) && !e.attributes.length && !e.className && !e.style.cssText) {
const s = e.children.length > 0, l = (e.textContent || "").trim().length > 0;

@@ -458,6 +458,6 @@ if (!s && !l) {

}
!s && l && (fe(e), r.removedElements += 1);
!s && l && (pe(e), r.removedElements += 1);
}
}
function Ke(e, t, a, r, n) {
function Ve(e, t, a, r, n) {
const o = document.createElement("template");

@@ -473,3 +473,3 @@ o.innerHTML = e;

try {
const f = document.createTreeWalker(o.content, Ee, null), b = [];
const f = document.createTreeWalker(o.content, ke, null), b = [];
let k = f.nextNode();

@@ -484,3 +484,3 @@ for (; k; )

Array.from(o.content.querySelectorAll("*")).forEach((f) => {
f.isConnected && We(f, t, a, s);
f.isConnected && Ke(f, t, a, s);
});

@@ -496,3 +496,3 @@ let i = o.innerHTML;

}
function ge(e) {
function he(e) {
const t = window.getSelection();

@@ -503,3 +503,3 @@ if (!t || t.rangeCount === 0) return null;

}
function he(e, t) {
function ye(e, t) {
if (!e.isConnected) return;

@@ -509,3 +509,3 @@ const a = window.getSelection();

}
function Ve(e, t) {
function je(e, t) {
e.focus({ preventScroll: !0 });

@@ -517,3 +517,3 @@ try {

}
const a = ge(e);
const a = he(e);
if (!a) return !1;

@@ -526,7 +526,7 @@ a.deleteContents();

const s = document.createRange();
s.setStartAfter(o), s.collapse(!0), he(e, s);
s.setStartAfter(o), s.collapse(!0), ye(e, s);
}
return !0;
}
function je(e, t) {
function Fe(e, t) {
e.focus({ preventScroll: !0 });

@@ -538,3 +538,3 @@ try {

}
const a = ge(e);
const a = he(e);
if (!a) return !1;

@@ -545,5 +545,5 @@ a.deleteContents();

const n = document.createRange();
return n.setStart(r, r.length), n.collapse(!0), he(e, n), !0;
return n.setStart(r, r.length), n.collapse(!0), ye(e, n), !0;
}
function Fe(e, t) {
function Ge(e, t) {
if (t === e.innerHTML) return;

@@ -557,3 +557,3 @@ const a = window.execEditorCommand || window.executeEditorCommand;

}
function Ge(e) {
function Ue(e) {
e.dispatchEvent(new Event("input", { bubbles: !0 }));

@@ -575,4 +575,4 @@ }

}
function Ue(e, t, a, r) {
const n = qe(e, t);
function Ye(e, t, a, r) {
const n = Ie(e, t);
if (a === "plain") {

@@ -618,3 +618,3 @@ const l = t || e.replace(/<[^>]*>/g, " "), i = J(l, r);

}
const o = r.profileOptions[a], s = Ke(e, o, n, r, a);
const o = r.profileOptions[a], s = Ve(e, o, n, r, a);
if (!s.html) {

@@ -647,3 +647,3 @@ const l = J(t || e.replace(/<[^>]*>/g, " "), r);

}
function Ye(e, t) {
function Xe(e, t) {
e.setAttribute("aria-label", t.labels.panelAriaLabel);

@@ -656,4 +656,4 @@ const a = e.querySelector(".rte-smart-paste-title");

if (n) {
const Se = n.getAttribute("data-enabled") === "true";
n.textContent = Se ? t.labels.toggleOnText : t.labels.toggleOffText;
const Ee = n.getAttribute("data-enabled") === "true";
n.textContent = Ee ? t.labels.toggleOnText : t.labels.toggleOffText;
}

@@ -682,6 +682,6 @@ const o = e.querySelector('[data-action="cycle-profile"]');

M && (M.textContent = t.labels.lastPasteRemovedLabel);
const oe = e.querySelector('[data-key="chars-label"]');
oe && (oe.textContent = t.labels.lastPasteCharsLabel);
const ne = e.querySelector(".rte-smart-paste-shortcut");
ne && (ne.textContent = t.labels.shortcutText);
const ne = e.querySelector('[data-key="chars-label"]');
ne && (ne.textContent = t.labels.lastPasteCharsLabel);
const se = e.querySelector(".rte-smart-paste-shortcut");
se && (se.textContent = t.labels.shortcutText);
}

@@ -691,3 +691,3 @@ function x(e) {

if (!t || !a || !r) return;
Ye(t, a);
Xe(t, a);
const n = t.querySelector(".rte-smart-paste-status");

@@ -722,6 +722,6 @@ n && (n.textContent = r.enabled ? a.labels.enabledText : a.labels.disabledText);

}
function Xe(e) {
function Ze(e) {
const t = g.get(e);
if (t) return t;
const a = d.get(e) || $ || K(), r = `rte-smart-paste-panel-${$e++}`, n = document.createElement("section");
const a = d.get(e) || $ || K(), r = `rte-smart-paste-panel-${Me++}`, n = document.createElement("section");
return n.className = u, n.id = r, n.setAttribute("role", "dialog"), n.setAttribute("aria-modal", "false"), n.setAttribute("aria-label", a.labels.panelAriaLabel), n.innerHTML = `

@@ -799,4 +799,4 @@ <header class="rte-smart-paste-header">

}
function ye(e) {
const t = Xe(e);
function xe(e) {
const t = Ze(e);
g.forEach((r, n) => {

@@ -806,7 +806,7 @@ n !== e && N(n, !1);

}
function xe(e, t) {
function ve(e, t) {
const a = re(e);
return (typeof t == "boolean" ? t : !a) ? ye(e) : N(e, !1), !0;
return (typeof t == "boolean" ? t : !a) ? xe(e) : N(e, !1), !0;
}
function ve(e) {
function Se(e) {
return {

@@ -818,9 +818,9 @@ enabled: e.enabled,

}
function Ze(e, t) {
function Je(e, t) {
const a = d.get(e) || $;
if (!a) return !1;
const r = p(e, a);
if (!r.enabled || de(e)) {
if (!r.enabled || ue(e)) {
const b = g.get(e);
return b && de(e) && O(b, a.labels.readonlyMessage), !1;
return b && ue(e) && O(b, a.labels.readonlyMessage), !1;
}

@@ -831,10 +831,10 @@ const n = t.clipboardData;

if (!o && !s) return !1;
const l = Ue(o, s, r.profile, a);
const l = Ye(o, s, r.profile, a);
if (!l.value) return !1;
const i = e.innerHTML;
if (!(l.mode === "html" ? Ve(e, l.value) : je(e, l.value))) return !1;
r.lastReport = { ...l.report }, L.set(e, r), Fe(e, i), Ge(e), e.dispatchEvent(
if (!(l.mode === "html" ? je(e, l.value) : Fe(e, l.value))) return !1;
r.lastReport = { ...l.report }, L.set(e, r), Ge(e, i), Ue(e), e.dispatchEvent(
new CustomEvent("editora:smart-paste", {
bubbles: !0,
detail: ve(r)
detail: Se(r)
})

@@ -852,10 +852,10 @@ ), x(e);

}
function Je(e) {
function Qe(e) {
return (t) => {
t.defaultPrevented || t[ie] === !0 || (m = e, !Ze(e, t)) || (t[ie] = !0, t.preventDefault(), typeof t.stopImmediatePropagation == "function" ? t.stopImmediatePropagation() : t.stopPropagation());
t.defaultPrevented || t[ce] === !0 || (m = e, !Je(e, t)) || (t[ce] = !0, t.preventDefault(), typeof t.stopImmediatePropagation == "function" ? t.stopImmediatePropagation() : t.stopPropagation());
};
}
function Qe(e) {
function et(e) {
if (j.has(e)) return;
const t = Je(e);
const t = Qe(e);
e.addEventListener("paste", t, !0), j.set(e, t);

@@ -867,15 +867,18 @@ }

}
function et(e) {
const t = e.key.toLowerCase();
function oe(e) {
return typeof e.key == "string" ? e.key.toLowerCase() : "";
}
function tt(e) {
const t = oe(e);
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "s";
}
function tt(e) {
const t = e.key.toLowerCase();
function rt(e) {
const t = oe(e);
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "v";
}
function rt(e) {
const t = e.key.toLowerCase();
function at(e) {
const t = oe(e);
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "g";
}
function at(e) {
function ot(e) {
$ = e, A || (A = (t) => {

@@ -891,3 +894,3 @@ V();

if (t.defaultPrevented || t.target?.closest(`.${u} input, .${u} textarea, .${u} select`)) return;
const r = ze(t);
const r = _e(t);
if (!r) return;

@@ -899,7 +902,7 @@ const n = d.get(r) || $ || e;

}
if (et(t)) {
t.preventDefault(), t.stopPropagation(), xe(r);
if (tt(t)) {
t.preventDefault(), t.stopPropagation(), ve(r);
return;
}
if (tt(t)) {
if (rt(t)) {
t.preventDefault(), t.stopPropagation();

@@ -910,3 +913,3 @@ const o = p(r, n);

}
if (rt(t)) {
if (at(t)) {
t.preventDefault(), t.stopPropagation();

@@ -921,3 +924,3 @@ const o = p(r, n);

}, window.addEventListener("scroll", T, !0), window.addEventListener("resize", T)), !w && typeof MutationObserver < "u" && document.body && (w = new MutationObserver((t) => {
He(t) && V();
De(t) && V();
}), w.observe(document.body, {

@@ -928,9 +931,9 @@ childList: !0,

}
function ot() {
A && (document.removeEventListener("focusin", A, !0), A = null), P && (document.removeEventListener("keydown", P, !0), P = null), T && (window.removeEventListener("scroll", T, !0), window.removeEventListener("resize", T), T = null), w && (w.disconnect(), w = null), g.forEach((e) => e.remove()), g.clear(), z.forEach((e) => me(e)), z.clear(), $ = null, m = null;
function nt() {
A && (document.removeEventListener("focusin", A, !0), A = null), P && (document.removeEventListener("keydown", P, !0), P = null), T && (window.removeEventListener("scroll", T, !0), window.removeEventListener("resize", T), T = null), w && (w.disconnect(), w = null), g.forEach((e) => e.remove()), g.clear(), z.forEach((e) => be(e)), z.clear(), $ = null, m = null;
}
function nt() {
if (typeof document > "u" || document.getElementById(le)) return;
function st() {
if (typeof document > "u" || document.getElementById(ie)) return;
const e = document.createElement("style");
e.id = le, e.textContent = `
e.id = ie, e.textContent = `
.rte-toolbar-group-items.${h},

@@ -1297,5 +1300,5 @@ .editora-toolbar-group-items.${h},

}
const st = (e = {}) => {
const lt = (e = {}) => {
const t = K(e), a = /* @__PURE__ */ new Set();
return nt(), {
return st(), {
name: "smartPaste",

@@ -1338,3 +1341,3 @@ toolbar: [

const s = d.get(o) || t;
return p(o, s), d.set(o, s), m = o, ye(o), !0;
return p(o, s), d.set(o, s), m = o, xe(o), !0;
},

@@ -1345,3 +1348,3 @@ toggleSmartPastePanel: (r, n) => {

const s = d.get(o) || t;
return p(o, s), d.set(o, s), m = o, xe(o, typeof r == "boolean" ? r : void 0);
return p(o, s), d.set(o, s), m = o, ve(o, typeof r == "boolean" ? r : void 0);
},

@@ -1369,3 +1372,3 @@ cycleSmartPasteProfile: (r, n) => {

if (!o || !r || typeof r != "object") return !1;
const s = d.get(o) || t, l = ce(s), i = K({
const s = d.get(o) || t, l = de(s), i = K({
...l,

@@ -1402,3 +1405,3 @@ ...r,

if (!o) return !1;
const s = d.get(o) || t, l = p(o, s), i = ve(l);
const s = d.get(o) || t, l = p(o, s), i = Se(l);
if (typeof r == "function")

@@ -1427,4 +1430,4 @@ try {

I += 1;
const o = this && typeof this.__pluginConfig == "object" ? K({ ...ce(t), ...this.__pluginConfig }) : t;
at(o);
const o = this && typeof this.__pluginConfig == "object" ? K({ ...de(t), ...this.__pluginConfig }) : t;
ot(o);
const s = C(

@@ -1441,3 +1444,3 @@ n?.editorElement ? { editorElement: n.editorElement } : void 0,

destroy: () => {
a.forEach((r) => be(r)), a.clear(), I = Math.max(0, I - 1), !(I > 0) && ot();
a.forEach((r) => ge(r)), a.clear(), I = Math.max(0, I - 1), !(I > 0) && nt();
}

@@ -1447,3 +1450,3 @@ };

export {
st as SmartPastePlugin
lt as SmartPastePlugin
};

@@ -1,2 +0,2 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g={all:{name:"All",characters:["€","£","¥","¢","₹","₽","₩","₿","₺","₴","₦","₨","₪","₫","₭","₮","₯","₰","₱","₲","₳","₴","₵","₶","₷","₹","₺","₼","₽","₾","₿",'"',"'","«","»","„","‟","‹","›","‚","‛","〝","〞","〟","‟","„","©","®","™","°","§","¶","†","‡","•","‣","⁃","‰","‱","′","″","‴","‵","‶","‷","※","‼","‽","‾","‿","⁀","⁁","⁂","⁃","⁇","⁈","⁉","+","-","×","÷","=","≠","≈","≡","≤","≥","<",">","±","∓","∴","∵","∶","∷","∸","∹","∺","∻","∼","∽","∾","∿","≀","≁","≂","≃","≄","≅","≆","≇","≈","≉","≊","≋","≌","≍","≎","≏","≐","≑","≒","≓","≔","≕","≖","≗","≘","≙","≚","≛","≜","≝","≞","≟","≠","≡","≢","≣","≤","≥","≦","≧","≨","≩","≪","≫","≬","≭","≮","≯","≰","≱","≲","≳","≴","≵","≶","≷","≸","≹","≺","≻","≼","≽","≾","≿","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ý","þ","ÿ","¡","¿","‽","‼","⁇","⁈","⁉","※","‾","‿","⁀","⁁","⁂","⁃","←","↑","→","↓","↔","↕","↖","↗","↘","↙","↚","↛","↜","↝","↞","↟","↠","↡","↢","↣","↤","↥","↦","↧","↨","↩","↪","↫","↬","↭","↮","↯","↰","↱","↲","↳","↴","↵","↶","↷","↸","↹","↺","↻","↼","↽","↾","↿","⇀","⇁","⇂","⇃","⇄","⇅","⇆","⇇","⇈","⇉","⇊","⇋","⇌","⇍","⇎","⇏","⇐","⇑","⇒","⇓","⇔","⇕","⇖","⇗","⇘","⇙","⇚","⇛","⇜","⇝","⇞","⇟","⇠","⇡","⇢","⇣","⇤","⇥","⇦","⇧","⇨","⇩","⇪","⇫","⇬","⇭","⇮","⇯","⇰","⇱","⇲","⇳","⇴","⇵","⇶","⇷","⇸","⇹","⇺","⇻","⇼","⇽","⇾","⇿"]},currency:{name:"Currency",characters:["€","£","¥","¢","₹","₽","₩","₿","₺","₴","₦","₨","₪","₫","₭","₮","₯","₰","₱","₲","₳","₵","₶","₷","₼","₾","₿"]},text:{name:"Text",characters:["©","®","™","°","§","¶","†","‡","•","‣","⁃","‰","‱","′","″","‴","‵","‶","‷","※","‼","‽","‾","‿","⁀","⁁","⁂"]},quotation:{name:"Quotation",characters:['"',"'","«","»","„","‟","‹","›","‚","‛","〝","〞","〟"]},mathematical:{name:"Mathematical",characters:["+","-","×","÷","=","≠","≈","≡","≤","≥","<",">","±","∓","∴","∵","∶","∷","∸","∹","∺","∻","∼","∽","∾","∿","≀","≁","≂","≃","≄","≅","≆","≇","≉","≊","≋","≌","≍","≎","≏","≐","≑","≒","≓","≔","≕","≖","≗","≘","≙","≚","≛","≜","≝","≞","≟","≢","≣","≦","≧","≨","≩","≪","≫","≬","≭","≮","≯","≰","≱","≲","≳","≴","≵","≶","≷","≸","≹","≺","≻","≼","≽","≾","≿"]},"extended-latin":{name:"Extended Latin",characters:["À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ý","þ","ÿ"]},symbols:{name:"Symbols",characters:["¡","¿","‽","‼","⁇","⁈","⁉","※","‾","‿","⁀","⁁","⁂","⁃"]},arrows:{name:"Arrows",characters:["←","↑","→","↓","↔","↕","↖","↗","↘","↙","↚","↛","↜","↝","↞","↟","↠","↡","↢","↣","↤","↥","↦","↧","↨","↩","↪","↫","↬","↭","↮","↯","↰","↱","↲","↳","↴","↵","↶","↷","↸","↹","↺","↻","↼","↽","↾","↿","⇀","⇁","⇂","⇃","⇄","⇅","⇆","⇇","⇈","⇉","⇊","⇋","⇌","⇍","⇎","⇏","⇐","⇑","⇒","⇓","⇔","⇕","⇖","⇗","⇘","⇙","⇚","⇛","⇜","⇝","⇞","⇟","⇠","⇡","⇢","⇣","⇤","⇥","⇦","⇧","⇨","⇩","⇪","⇫","⇬","⇭","⇮","⇯","⇰","⇱","⇲","⇳","⇴","⇵","⇶","⇷","⇸","⇹","⇺","⇻","⇼","⇽","⇾","⇿"]}},x={"€":"euro","£":"pound","¥":"yen","¢":"cent","₹":"rupee","₽":"ruble","₩":"won","₿":"bitcoin",'"':"quote","'":"apostrophe","«":"left angle quote","»":"right angle quote","„":"low quote","©":"copyright","®":"registered","™":"trademark","°":"degree","§":"section","¶":"paragraph","†":"dagger","‡":"double dagger","•":"bullet","‰":"per mille","′":"prime","″":"double prime","+":"plus","-":"minus","×":"multiplication","÷":"division","=":"equals","≠":"not equal","≈":"approximately","≡":"identical","≤":"less or equal","≥":"greater or equal","±":"plus minus",À:"a grave",Á:"a acute",Â:"a circumflex",Ã:"a tilde",Ä:"a diaeresis",Ç:"c cedilla","←":"left arrow","↑":"up arrow","→":"right arrow","↓":"down arrow","↔":"left right arrow"};let u=!1;const C='[data-theme="dark"], .dark, .editora-theme-dark',k=()=>{const t=window.getSelection();if(!t||t.rangeCount===0)return null;const e=t.anchorNode;return(e instanceof HTMLElement?e:e?.parentElement)?.closest(".rte-content, .editora-content")||null},E=t=>{const e=t||k();return e?!!e.closest(C):!1},z=()=>{if(typeof document>"u")return;const t="special-characters-plugin-styles";if(document.getElementById(t))return;const e=document.createElement("style");e.id=t,e.textContent=`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f={all:{name:"All",characters:["€","£","¥","¢","₹","₽","₩","₿","₺","₴","₦","₨","₪","₫","₭","₮","₯","₰","₱","₲","₳","₴","₵","₶","₷","₹","₺","₼","₽","₾","₿",'"',"'","«","»","„","‟","‹","›","‚","‛","〝","〞","〟","‟","„","©","®","™","°","§","¶","†","‡","•","‣","⁃","‰","‱","′","″","‴","‵","‶","‷","※","‼","‽","‾","‿","⁀","⁁","⁂","⁃","⁇","⁈","⁉","+","-","×","÷","=","≠","≈","≡","≤","≥","<",">","±","∓","∴","∵","∶","∷","∸","∹","∺","∻","∼","∽","∾","∿","≀","≁","≂","≃","≄","≅","≆","≇","≈","≉","≊","≋","≌","≍","≎","≏","≐","≑","≒","≓","≔","≕","≖","≗","≘","≙","≚","≛","≜","≝","≞","≟","≠","≡","≢","≣","≤","≥","≦","≧","≨","≩","≪","≫","≬","≭","≮","≯","≰","≱","≲","≳","≴","≵","≶","≷","≸","≹","≺","≻","≼","≽","≾","≿","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ý","þ","ÿ","¡","¿","‽","‼","⁇","⁈","⁉","※","‾","‿","⁀","⁁","⁂","⁃","←","↑","→","↓","↔","↕","↖","↗","↘","↙","↚","↛","↜","↝","↞","↟","↠","↡","↢","↣","↤","↥","↦","↧","↨","↩","↪","↫","↬","↭","↮","↯","↰","↱","↲","↳","↴","↵","↶","↷","↸","↹","↺","↻","↼","↽","↾","↿","⇀","⇁","⇂","⇃","⇄","⇅","⇆","⇇","⇈","⇉","⇊","⇋","⇌","⇍","⇎","⇏","⇐","⇑","⇒","⇓","⇔","⇕","⇖","⇗","⇘","⇙","⇚","⇛","⇜","⇝","⇞","⇟","⇠","⇡","⇢","⇣","⇤","⇥","⇦","⇧","⇨","⇩","⇪","⇫","⇬","⇭","⇮","⇯","⇰","⇱","⇲","⇳","⇴","⇵","⇶","⇷","⇸","⇹","⇺","⇻","⇼","⇽","⇾","⇿"]},currency:{name:"Currency",characters:["€","£","¥","¢","₹","₽","₩","₿","₺","₴","₦","₨","₪","₫","₭","₮","₯","₰","₱","₲","₳","₵","₶","₷","₼","₾","₿"]},text:{name:"Text",characters:["©","®","™","°","§","¶","†","‡","•","‣","⁃","‰","‱","′","″","‴","‵","‶","‷","※","‼","‽","‾","‿","⁀","⁁","⁂"]},quotation:{name:"Quotation",characters:['"',"'","«","»","„","‟","‹","›","‚","‛","〝","〞","〟"]},mathematical:{name:"Mathematical",characters:["+","-","×","÷","=","≠","≈","≡","≤","≥","<",">","±","∓","∴","∵","∶","∷","∸","∹","∺","∻","∼","∽","∾","∿","≀","≁","≂","≃","≄","≅","≆","≇","≉","≊","≋","≌","≍","≎","≏","≐","≑","≒","≓","≔","≕","≖","≗","≘","≙","≚","≛","≜","≝","≞","≟","≢","≣","≦","≧","≨","≩","≪","≫","≬","≭","≮","≯","≰","≱","≲","≳","≴","≵","≶","≷","≸","≹","≺","≻","≼","≽","≾","≿"]},"extended-latin":{name:"Extended Latin",characters:["À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ý","þ","ÿ"]},symbols:{name:"Symbols",characters:["¡","¿","‽","‼","⁇","⁈","⁉","※","‾","‿","⁀","⁁","⁂","⁃"]},arrows:{name:"Arrows",characters:["←","↑","→","↓","↔","↕","↖","↗","↘","↙","↚","↛","↜","↝","↞","↟","↠","↡","↢","↣","↤","↥","↦","↧","↨","↩","↪","↫","↬","↭","↮","↯","↰","↱","↲","↳","↴","↵","↶","↷","↸","↹","↺","↻","↼","↽","↾","↿","⇀","⇁","⇂","⇃","⇄","⇅","⇆","⇇","⇈","⇉","⇊","⇋","⇌","⇍","⇎","⇏","⇐","⇑","⇒","⇓","⇔","⇕","⇖","⇗","⇘","⇙","⇚","⇛","⇜","⇝","⇞","⇟","⇠","⇡","⇢","⇣","⇤","⇥","⇦","⇧","⇨","⇩","⇪","⇫","⇬","⇭","⇮","⇯","⇰","⇱","⇲","⇳","⇴","⇵","⇶","⇷","⇸","⇹","⇺","⇻","⇼","⇽","⇾","⇿"]}},y={"€":"euro","£":"pound","¥":"yen","¢":"cent","₹":"rupee","₽":"ruble","₩":"won","₿":"bitcoin",'"':"quote","'":"apostrophe","«":"left angle quote","»":"right angle quote","„":"low quote","©":"copyright","®":"registered","™":"trademark","°":"degree","§":"section","¶":"paragraph","†":"dagger","‡":"double dagger","•":"bullet","‰":"per mille","′":"prime","″":"double prime","+":"plus","-":"minus","×":"multiplication","÷":"division","=":"equals","≠":"not equal","≈":"approximately","≡":"identical","≤":"less or equal","≥":"greater or equal","±":"plus minus",À:"a grave",Á:"a acute",Â:"a circumflex",Ã:"a tilde",Ä:"a diaeresis",Ç:"c cedilla","←":"left arrow","↑":"up arrow","→":"right arrow","↓":"down arrow","↔":"left right arrow"};let v=!1;const S='[data-theme="dark"], .dark, .editora-theme-dark',z=r=>r?r.nodeType===Node.ELEMENT_NODE?r:r.parentElement:null,b=()=>{const r=window.getSelection();return!r||r.rangeCount===0?null:z(r.getRangeAt(0).startContainer)?.closest('.rte-content, .editora-content, [contenteditable="true"]')||null},T=r=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const a=e.getRangeAt(0);return!r.contains(a.startContainer)||!r.contains(a.endContainer)?null:a.cloneRange()},A=r=>{const e=document.createRange();return e.selectNodeContents(r),e.collapse(!1),e},L=(r,e,a)=>{if(e!==a){if(typeof window.execEditorCommand=="function"){window.execEditorCommand("recordDomTransaction",r,e,a);return}if(typeof window.executeEditorCommand=="function")try{window.executeEditorCommand("recordDomTransaction",{editor:r,beforeHTML:e,afterHTML:a})}catch{}}},q=r=>{const e=r||b();return e?!!e.closest(S):!1},N=()=>{if(typeof document>"u")return;const r="special-characters-plugin-styles";if(document.getElementById(r))return;const e=document.createElement("style");e.id=r,e.textContent=`
.special-characters-overlay {

@@ -267,3 +267,3 @@ --rte-sc-overlay-bg: rgba(15, 23, 36, 0.56);

}
`,document.head.appendChild(e)},S=t=>{const e=window.getSelection();if(e&&e.rangeCount>0){const a=e.getRangeAt(0);a.deleteContents();const c=document.createTextNode(t);a.insertNode(c),a.setStartAfter(c),a.setEndAfter(c),e.removeAllRanges(),e.addRange(a)}},L=t=>{if(typeof window>"u"||u)return;u=!0,z();let e="all",a="",c=null;const i=document.createElement("div");i.className="special-characters-overlay",E(t)&&i.classList.add("rte-ui-theme-dark");const s=document.createElement("div");s.className="special-characters-dialog",s.setAttribute("role","dialog"),s.setAttribute("aria-modal","true"),s.innerHTML=`
`,document.head.appendChild(e)},D=(r,e,a)=>{const c=e||b();if(!c)return;const l=a&&c.contains(a.commonAncestorContainer)?a:A(c),d=c.innerHTML;l.deleteContents();const i=document.createTextNode(r);l.insertNode(i),l.setStartAfter(i),l.setEndAfter(i);const o=window.getSelection();o&&(o.removeAllRanges(),o.addRange(l));const h=c.innerHTML;L(c,d,h),c.dispatchEvent(new window.Event("input",{bubbles:!0})),c.focus()},R=r=>{if(typeof window>"u"||v)return;v=!0,N();const e=r||b(),a=e?T(e):null;let c="all",l="",d=null;const i=document.createElement("div");i.className="special-characters-overlay",q(r)&&i.classList.add("rte-ui-theme-dark");const o=document.createElement("div");o.className="special-characters-dialog",o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true"),o.innerHTML=`
<div class="special-characters-header">

@@ -275,5 +275,5 @@ <h2>Insert Special Characters</h2>

<div class="special-characters-tabs">
${Object.keys(g).map(r=>`
<button class="special-characters-tab ${e===r?"active":""}" data-category="${r}">
${g[r].name}
${Object.keys(f).map(t=>`
<button class="special-characters-tab ${c===t?"active":""}" data-category="${t}">
${f[t].name}
</button>

@@ -293,6 +293,2 @@ `).join("")}

</div>
`;const b=s.querySelector(".special-characters-tabs"),d=s.querySelector(".special-characters-grid"),m=s.querySelector(".special-characters-search-input"),w=s.querySelector(".special-characters-close"),y=()=>g[e].characters.filter(r=>{if(!a.trim())return!0;const o=a.toLowerCase();return r.toLowerCase().includes(o)||(x[r]||"").toLowerCase().includes(o)}),v=()=>{b?.querySelectorAll(".special-characters-tab").forEach(r=>{r.classList.toggle("active",r.getAttribute("data-category")===e)})},h=()=>{if(!d)return;const r=y();if(r.length===0){d.innerHTML=`<div class="special-characters-no-results">No characters found for "${a}"</div>`;return}d.innerHTML=r.map(o=>`
<button class="special-characters-item" data-char="${o}" title="${x[o]||o}">
${o}
</button>
`).join("")},p=()=>{c!==null&&(window.clearTimeout(c),c=null),i.parentNode&&i.parentNode.removeChild(i),u=!1,document.removeEventListener("keydown",f,!0)},f=r=>{r.key==="Escape"&&(r.preventDefault(),r.stopPropagation(),p())};w?.addEventListener("click",p),b?.addEventListener("click",r=>{const l=r.target.closest(".special-characters-tab");if(!l)return;const n=l.getAttribute("data-category");!n||e===n||(e=n,v(),h())}),m?.addEventListener("input",r=>{a=r.target.value,c!==null&&window.clearTimeout(c),c=window.setTimeout(()=>{c=null,h()},90)}),d?.addEventListener("click",r=>{const l=r.target.closest(".special-characters-item");if(!l)return;const n=l.getAttribute("data-char");n&&(S(n),p())}),i.addEventListener("click",r=>{r.target===i&&p()}),document.addEventListener("keydown",f,!0),v(),h(),i.appendChild(s),document.body.appendChild(i),requestAnimationFrame(()=>m?.focus())},T=()=>({name:"specialCharacters",toolbar:[{label:"Special Characters",command:"insertSpecialCharacter",icon:'<svg width="24" height="24" focusable="false"><path d="M15 18h4l1-2v4h-6v-3.3l1.4-1a6 6 0 0 0 1.8-2.9 6.3 6.3 0 0 0-.1-4.1 5.8 5.8 0 0 0-3-3.2c-.6-.3-1.3-.5-2.1-.5a5.1 5.1 0 0 0-3.9 1.8 6.3 6.3 0 0 0-1.3 6 6.2 6.2 0 0 0 1.8 3l1.4.9V20H4v-4l1 2h4v-.5l-2-1L5.4 15A6.5 6.5 0 0 1 4 11c0-1 .2-1.9.6-2.7A7 7 0 0 1 6.3 6C7.1 5.4 8 5 9 4.5c1-.3 2-.5 3.1-.5a8.8 8.8 0 0 1 5.7 2 7 7 0 0 1 1.7 2.3 6 6 0 0 1 .2 4.8c-.2.7-.6 1.3-1 1.9a7.6 7.6 0 0 1-3.6 2.5v.5Z" fill-rule="evenodd"></path></svg>'}],commands:{insertSpecialCharacter:(t,e)=>{const a=e?.contentElement instanceof HTMLElement?e.contentElement:k();return L(a),!0}},keymap:{}});exports.SpecialCharactersPlugin=T;
`;const h=o.querySelector(".special-characters-tabs"),u=o.querySelector(".special-characters-grid"),x=o.querySelector(".special-characters-search-input"),E=o.querySelector(".special-characters-close"),C=()=>f[c].characters.filter(t=>{if(!l.trim())return!0;const s=l.toLowerCase();return t.toLowerCase().includes(s)||(y[t]||"").toLowerCase().includes(s)}),w=()=>{h?.querySelectorAll(".special-characters-tab").forEach(t=>{t.classList.toggle("active",t.getAttribute("data-category")===c)})},m=()=>{if(!u)return;const t=C();if(u.textContent="",t.length===0){const s=document.createElement("div");s.className="special-characters-no-results",s.textContent=`No characters found for "${l}"`,u.appendChild(s);return}t.forEach(s=>{const n=document.createElement("button");n.type="button",n.className="special-characters-item",n.dataset.char=s,n.title=y[s]||s,n.textContent=s,u.appendChild(n)})},g=()=>{d!==null&&(window.clearTimeout(d),d=null),i.parentNode&&i.parentNode.removeChild(i),v=!1,document.removeEventListener("keydown",k,!0)},k=t=>{t.key==="Escape"&&(t.preventDefault(),t.stopPropagation(),g())};E?.addEventListener("click",g),h?.addEventListener("click",t=>{const n=t.target.closest(".special-characters-tab");if(!n)return;const p=n.getAttribute("data-category");!p||c===p||(c=p,w(),m())}),x?.addEventListener("input",t=>{l=t.target.value,d!==null&&window.clearTimeout(d),d=window.setTimeout(()=>{d=null,m()},90)}),u?.addEventListener("click",t=>{const n=t.target.closest(".special-characters-item");if(!n)return;const p=n.dataset.char;p&&(D(p,e,a),g())}),i.addEventListener("click",t=>{t.target===i&&g()}),document.addEventListener("keydown",k,!0),w(),m(),i.appendChild(o),document.body.appendChild(i),requestAnimationFrame(()=>x?.focus())},j=()=>({name:"specialCharacters",toolbar:[{label:"Special Characters",command:"insertSpecialCharacter",icon:'<svg width="24" height="24" focusable="false"><path d="M15 18h4l1-2v4h-6v-3.3l1.4-1a6 6 0 0 0 1.8-2.9 6.3 6.3 0 0 0-.1-4.1 5.8 5.8 0 0 0-3-3.2c-.6-.3-1.3-.5-2.1-.5a5.1 5.1 0 0 0-3.9 1.8 6.3 6.3 0 0 0-1.3 6 6.2 6.2 0 0 0 1.8 3l1.4.9V20H4v-4l1 2h4v-.5l-2-1L5.4 15A6.5 6.5 0 0 1 4 11c0-1 .2-1.9.6-2.7A7 7 0 0 1 6.3 6C7.1 5.4 8 5 9 4.5c1-.3 2-.5 3.1-.5a8.8 8.8 0 0 1 5.7 2 7 7 0 0 1 1.7 2.3 6 6 0 0 1 .2 4.8c-.2.7-.6 1.3-1 1.9a7.6 7.6 0 0 1-3.6 2.5v.5Z" fill-rule="evenodd"></path></svg>'}],commands:{insertSpecialCharacter:(r,e)=>{const a=e?.contentElement instanceof HTMLElement?e.contentElement:b();return R(a),!0}},keymap:{}});exports.SpecialCharactersPlugin=j;

@@ -1,2 +0,2 @@

const g = {
const f = {
all: {

@@ -392,3 +392,3 @@ name: "All",

}
}, x = {
}, y = {
"€": "euro",

@@ -442,17 +442,35 @@ "£": "pound",

};
let u = !1;
const C = '[data-theme="dark"], .dark, .editora-theme-dark', k = () => {
const t = window.getSelection();
if (!t || t.rangeCount === 0) return null;
const e = t.anchorNode;
return (e instanceof HTMLElement ? e : e?.parentElement)?.closest(".rte-content, .editora-content") || null;
}, E = (t) => {
const e = t || k();
return e ? !!e.closest(C) : !1;
}, z = () => {
let v = !1;
const z = '[data-theme="dark"], .dark, .editora-theme-dark', S = (r) => r ? r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement : null, b = () => {
const r = window.getSelection();
return !r || r.rangeCount === 0 ? null : S(r.getRangeAt(0).startContainer)?.closest('.rte-content, .editora-content, [contenteditable="true"]') || null;
}, A = (r) => {
const e = window.getSelection();
if (!e || e.rangeCount === 0) return null;
const a = e.getRangeAt(0);
return !r.contains(a.startContainer) || !r.contains(a.endContainer) ? null : a.cloneRange();
}, L = (r) => {
const e = document.createRange();
return e.selectNodeContents(r), e.collapse(!1), e;
}, T = (r, e, a) => {
if (e !== a) {
if (typeof window.execEditorCommand == "function") {
window.execEditorCommand("recordDomTransaction", r, e, a);
return;
}
if (typeof window.executeEditorCommand == "function")
try {
window.executeEditorCommand("recordDomTransaction", { editor: r, beforeHTML: e, afterHTML: a });
} catch {
}
}
}, q = (r) => {
const e = r || b();
return e ? !!e.closest(z) : !1;
}, N = () => {
if (typeof document > "u") return;
const t = "special-characters-plugin-styles";
if (document.getElementById(t)) return;
const r = "special-characters-plugin-styles";
if (document.getElementById(r)) return;
const e = document.createElement("style");
e.id = t, e.textContent = `
e.id = r, e.textContent = `
.special-characters-overlay {

@@ -724,18 +742,22 @@ --rte-sc-overlay-bg: rgba(15, 23, 36, 0.56);

`, document.head.appendChild(e);
}, L = (t) => {
const e = window.getSelection();
if (e && e.rangeCount > 0) {
const a = e.getRangeAt(0);
a.deleteContents();
const c = document.createTextNode(t);
a.insertNode(c), a.setStartAfter(c), a.setEndAfter(c), e.removeAllRanges(), e.addRange(a);
}
}, S = (t) => {
if (typeof window > "u" || u) return;
u = !0, z();
let e = "all", a = "", c = null;
}, D = (r, e, a) => {
const c = e || b();
if (!c) return;
const l = a && c.contains(a.commonAncestorContainer) ? a : L(c), d = c.innerHTML;
l.deleteContents();
const i = document.createTextNode(r);
l.insertNode(i), l.setStartAfter(i), l.setEndAfter(i);
const o = window.getSelection();
o && (o.removeAllRanges(), o.addRange(l));
const h = c.innerHTML;
T(c, d, h), c.dispatchEvent(new window.Event("input", { bubbles: !0 })), c.focus();
}, R = (r) => {
if (typeof window > "u" || v) return;
v = !0, N();
const e = r || b(), a = e ? A(e) : null;
let c = "all", l = "", d = null;
const i = document.createElement("div");
i.className = "special-characters-overlay", E(t) && i.classList.add("rte-ui-theme-dark");
const s = document.createElement("div");
s.className = "special-characters-dialog", s.setAttribute("role", "dialog"), s.setAttribute("aria-modal", "true"), s.innerHTML = `
i.className = "special-characters-overlay", q(r) && i.classList.add("rte-ui-theme-dark");
const o = document.createElement("div");
o.className = "special-characters-dialog", o.setAttribute("role", "dialog"), o.setAttribute("aria-modal", "true"), o.innerHTML = `
<div class="special-characters-header">

@@ -747,5 +769,5 @@ <h2>Insert Special Characters</h2>

<div class="special-characters-tabs">
${Object.keys(g).map((r) => `
<button class="special-characters-tab ${e === r ? "active" : ""}" data-category="${r}">
${g[r].name}
${Object.keys(f).map((t) => `
<button class="special-characters-tab ${c === t ? "active" : ""}" data-category="${t}">
${f[t].name}
</button>

@@ -766,45 +788,45 @@ `).join("")}

`;
const b = s.querySelector(".special-characters-tabs"), d = s.querySelector(".special-characters-grid"), m = s.querySelector(".special-characters-search-input"), w = s.querySelector(".special-characters-close"), y = () => g[e].characters.filter((r) => {
if (!a.trim()) return !0;
const o = a.toLowerCase();
return r.toLowerCase().includes(o) || (x[r] || "").toLowerCase().includes(o);
}), v = () => {
b?.querySelectorAll(".special-characters-tab").forEach((r) => {
r.classList.toggle("active", r.getAttribute("data-category") === e);
const h = o.querySelector(".special-characters-tabs"), u = o.querySelector(".special-characters-grid"), x = o.querySelector(".special-characters-search-input"), E = o.querySelector(".special-characters-close"), C = () => f[c].characters.filter((t) => {
if (!l.trim()) return !0;
const s = l.toLowerCase();
return t.toLowerCase().includes(s) || (y[t] || "").toLowerCase().includes(s);
}), w = () => {
h?.querySelectorAll(".special-characters-tab").forEach((t) => {
t.classList.toggle("active", t.getAttribute("data-category") === c);
});
}, h = () => {
if (!d) return;
const r = y();
if (r.length === 0) {
d.innerHTML = `<div class="special-characters-no-results">No characters found for "${a}"</div>`;
}, m = () => {
if (!u) return;
const t = C();
if (u.textContent = "", t.length === 0) {
const s = document.createElement("div");
s.className = "special-characters-no-results", s.textContent = `No characters found for "${l}"`, u.appendChild(s);
return;
}
d.innerHTML = r.map((o) => `
<button class="special-characters-item" data-char="${o}" title="${x[o] || o}">
${o}
</button>
`).join("");
}, p = () => {
c !== null && (window.clearTimeout(c), c = null), i.parentNode && i.parentNode.removeChild(i), u = !1, document.removeEventListener("keydown", f, !0);
}, f = (r) => {
r.key === "Escape" && (r.preventDefault(), r.stopPropagation(), p());
t.forEach((s) => {
const n = document.createElement("button");
n.type = "button", n.className = "special-characters-item", n.dataset.char = s, n.title = y[s] || s, n.textContent = s, u.appendChild(n);
});
}, g = () => {
d !== null && (window.clearTimeout(d), d = null), i.parentNode && i.parentNode.removeChild(i), v = !1, document.removeEventListener("keydown", k, !0);
}, k = (t) => {
t.key === "Escape" && (t.preventDefault(), t.stopPropagation(), g());
};
w?.addEventListener("click", p), b?.addEventListener("click", (r) => {
const l = r.target.closest(".special-characters-tab");
if (!l) return;
const n = l.getAttribute("data-category");
!n || e === n || (e = n, v(), h());
}), m?.addEventListener("input", (r) => {
a = r.target.value, c !== null && window.clearTimeout(c), c = window.setTimeout(() => {
c = null, h();
E?.addEventListener("click", g), h?.addEventListener("click", (t) => {
const n = t.target.closest(".special-characters-tab");
if (!n) return;
const p = n.getAttribute("data-category");
!p || c === p || (c = p, w(), m());
}), x?.addEventListener("input", (t) => {
l = t.target.value, d !== null && window.clearTimeout(d), d = window.setTimeout(() => {
d = null, m();
}, 90);
}), d?.addEventListener("click", (r) => {
const l = r.target.closest(".special-characters-item");
if (!l) return;
const n = l.getAttribute("data-char");
n && (L(n), p());
}), i.addEventListener("click", (r) => {
r.target === i && p();
}), document.addEventListener("keydown", f, !0), v(), h(), i.appendChild(s), document.body.appendChild(i), requestAnimationFrame(() => m?.focus());
}, q = () => ({
}), u?.addEventListener("click", (t) => {
const n = t.target.closest(".special-characters-item");
if (!n) return;
const p = n.dataset.char;
p && (D(p, e, a), g());
}), i.addEventListener("click", (t) => {
t.target === i && g();
}), document.addEventListener("keydown", k, !0), w(), m(), i.appendChild(o), document.body.appendChild(i), requestAnimationFrame(() => x?.focus());
}, j = () => ({
name: "specialCharacters",

@@ -817,5 +839,5 @@ toolbar: [{

commands: {
insertSpecialCharacter: (t, e) => {
const a = e?.contentElement instanceof HTMLElement ? e.contentElement : k();
return S(a), !0;
insertSpecialCharacter: (r, e) => {
const a = e?.contentElement instanceof HTMLElement ? e.contentElement : b();
return R(a), !0;
}

@@ -826,3 +848,3 @@ },

export {
q as SpecialCharactersPlugin
j as SpecialCharactersPlugin
};

@@ -1,1 +0,1 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=()=>({name:"strikethrough",marks:{strikethrough:{parseDOM:[{tag:"s"},{tag:"strike"},{tag:"del"},{style:"text-decoration",getAttrs:t=>(typeof t=="string"?t:t.style.textDecoration)==="line-through"&&null}],toDOM:()=>["s",0]}},toolbar:[{label:"Strikethrough",command:"toggleStrikethrough",icon:'<svg width="24" height="24" focusable="false"><g fill-rule="evenodd"><path d="M15.6 8.5c-.5-.7-1-1.1-1.3-1.3-.6-.4-1.3-.6-2-.6-2.7 0-2.8 1.7-2.8 2.1 0 1.6 1.8 2 3.2 2.3 4.4.9 4.6 2.8 4.6 3.9 0 1.4-.7 4.1-5 4.1A6.2 6.2 0 0 1 7 16.4l1.5-1.1c.4.6 1.6 2 3.7 2 1.6 0 2.5-.4 3-1.2.4-.8.3-2-.8-2.6-.7-.4-1.6-.7-2.9-1-1-.2-3.9-.8-3.9-3.6C7.6 6 10.3 5 12.4 5c2.9 0 4.2 1.6 4.7 2.4l-1.5 1.1Z"></path><path d="M5 11h14a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Z" fill-rule="nonzero"></path></g></svg>',shortcut:"Mod-Shift-x"}],commands:{toggleStrikethrough:()=>{const t=l();if(!t)return!1;const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const e=n.getRangeAt(0);if(!t.contains(e.commonAncestorContainer))return!1;t.focus({preventScroll:!0});const o=document.execCommand("strikeThrough",!1);return c(t),t.dispatchEvent(new Event("input",{bubbles:!0})),o!==!1}},keymap:{"Mod-Shift-x":"toggleStrikethrough","Mod-Shift-X":"toggleStrikethrough"}});function l(){const t=window.getSelection();if(t&&t.rangeCount>0){const e=t.getRangeAt(0).startContainer,r=(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest('[contenteditable="true"], .rte-content, .editora-content');if(r)return r}const n=document.activeElement;return n?n.getAttribute("contenteditable")==="true"?n:n.closest('[contenteditable="true"], .rte-content, .editora-content'):null}function c(t){t.querySelectorAll("strike, del").forEach(e=>{const o=document.createElement("s");for(const r of Array.from(e.attributes))r.name!=="style"&&o.setAttribute(r.name,r.value);for(;e.firstChild;)o.appendChild(e.firstChild);e.parentNode?.replaceChild(o,e)})}exports.StrikethroughPlugin=i;
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("./inlineFormatting-DOYOJdnD.js"),n=()=>({name:"strikethrough",marks:{strikethrough:{parseDOM:[{tag:"s"},{tag:"strike"},{tag:"del"},{style:"text-decoration",getAttrs:t=>(typeof t=="string"?t:t.style.textDecoration)==="line-through"&&null}],toDOM:()=>["s",0]}},toolbar:[{label:"Strikethrough",command:"toggleStrikethrough",icon:'<svg width="24" height="24" focusable="false"><g fill-rule="evenodd"><path d="M15.6 8.5c-.5-.7-1-1.1-1.3-1.3-.6-.4-1.3-.6-2-.6-2.7 0-2.8 1.7-2.8 2.1 0 1.6 1.8 2 3.2 2.3 4.4.9 4.6 2.8 4.6 3.9 0 1.4-.7 4.1-5 4.1A6.2 6.2 0 0 1 7 16.4l1.5-1.1c.4.6 1.6 2 3.7 2 1.6 0 2.5-.4 3-1.2.4-.8.3-2-.8-2.6-.7-.4-1.6-.7-2.9-1-1-.2-3.9-.8-3.9-3.6C7.6 6 10.3 5 12.4 5c2.9 0 4.2 1.6 4.7 2.4l-1.5 1.1Z"></path><path d="M5 11h14a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Z" fill-rule="nonzero"></path></g></svg>',shortcut:"Mod-Shift-x"}],commands:{toggleStrikethrough:(t,r)=>l.applyInlineFormatting({command:"strikeThrough",context:r,normalize:a})},keymap:{"Mod-Shift-x":"toggleStrikethrough","Mod-Shift-X":"toggleStrikethrough"}});function a(t){t.querySelectorAll("strike, del").forEach(e=>{const o=document.createElement("s");for(const i of Array.from(e.attributes))i.name!=="style"&&o.setAttribute(i.name,i.value);for(;e.firstChild;)o.appendChild(e.firstChild);e.parentNode?.replaceChild(o,e)})}exports.StrikethroughPlugin=n;

@@ -1,2 +0,3 @@

const l = () => ({
import { a } from "./inlineFormatting-DuVTGXYG.mjs";
const n = () => ({
name: "strikethrough",

@@ -32,13 +33,7 @@ // Schema definition for strikethrough mark

*/
toggleStrikethrough: () => {
const t = i();
if (!t) return !1;
const n = window.getSelection();
if (!n || n.rangeCount === 0) return !1;
const e = n.getRangeAt(0);
if (!t.contains(e.commonAncestorContainer)) return !1;
t.focus({ preventScroll: !0 });
const o = document.execCommand("strikeThrough", !1);
return c(t), t.dispatchEvent(new Event("input", { bubbles: !0 })), o !== !1;
}
toggleStrikethrough: (t, r) => a({
command: "strikeThrough",
context: r,
normalize: h
})
},

@@ -51,16 +46,7 @@ // Keyboard shortcuts

});
function i() {
const t = window.getSelection();
if (t && t.rangeCount > 0) {
const e = t.getRangeAt(0).startContainer, r = (e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement)?.closest('[contenteditable="true"], .rte-content, .editora-content');
if (r) return r;
}
const n = document.activeElement;
return n ? n.getAttribute("contenteditable") === "true" ? n : n.closest('[contenteditable="true"], .rte-content, .editora-content') : null;
}
function c(t) {
function h(t) {
t.querySelectorAll("strike, del").forEach((e) => {
const o = document.createElement("s");
for (const r of Array.from(e.attributes))
r.name !== "style" && o.setAttribute(r.name, r.value);
for (const i of Array.from(e.attributes))
i.name !== "style" && o.setAttribute(i.name, i.value);
for (; e.firstChild; )

@@ -72,3 +58,3 @@ o.appendChild(e.firstChild);

export {
l as StrikethroughPlugin
n as StrikethroughPlugin
};

@@ -1,2 +0,2 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const S=".rte-content, .editora-content",ke="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",Te="__editoraCommandEditorRoot",ve="rte-translation-workflow-styles",u="rte-translation-workflow-panel",y="translation-workflow",$="translationWorkflow",h=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',$e=["p","h1","h2","h3","h4","h5","h6","li","td","th","blockquote","figcaption"].join(", "),Me=new Set(["ArrowUp","ArrowDown","Home","End"]),Ee=[{locale:"en",label:"English",minLengthRatio:.6,maxLengthRatio:1.4,requireDifferentFromSource:!1,preserveTokens:!0},{locale:"fr",label:"French",minLengthRatio:.75,maxLengthRatio:1.7,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"de",label:"German",minLengthRatio:.8,maxLengthRatio:1.9,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"es",label:"Spanish",minLengthRatio:.7,maxLengthRatio:1.7,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"it",label:"Italian",minLengthRatio:.7,maxLengthRatio:1.7,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"ja",label:"Japanese",minLengthRatio:.45,maxLengthRatio:1.2,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"zh",label:"Chinese",minLengthRatio:.4,maxLengthRatio:1.2,requireDifferentFromSource:!0,preserveTokens:!0}],Ne={panelTitle:"Translation Workflow",panelAriaLabel:"Translation workflow panel",sourceLocaleLabel:"Source Locale",targetLocaleLabel:"Target Locale",validateText:"Validate Locale",captureSourceText:"Capture Source",lockSelectedText:"Lock Selected",unlockSelectedText:"Unlock Selected",lockSegmentAriaLabel:"Lock segment",unlockSegmentAriaLabel:"Unlock segment",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",summaryPrefix:"Locale QA",noIssuesText:"No locale validation issues.",issuesLabel:"Locale issues",segmentsLabel:"Segments",sourcePreviewLabel:"Source",targetPreviewLabel:"Target",helperText:"Select segments, lock finalized ones, and run locale validation before handoff.",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+L (panel), Ctrl/Cmd+Alt+Shift+V (validate), Ctrl/Cmd+Alt+Shift+K (lock segment)",readonlySegmentMessage:"This segment is locked. Unlock before editing.",sourceCapturedMessage:"Source snapshot captured from current content.",selectedSegmentPrefix:"Selected Segment",missingTargetMessage:"Segment is empty in target locale.",tokenMismatchMessage:"Tokens/placeholders do not match source segment.",untranslatedMessage:"Segment appears untranslated (same as source).",lengthOutOfRangeMessage:"Translation length is outside expected locale range."},c=new WeakMap,re=new WeakMap,P=new WeakMap,p=new Map,j=new WeakMap,le=new WeakMap,U=new Set;let X=0,_e=0,Ae=0,Fe=0,k=null,x=null,D=null,z=null,O=null,N=null,I=null,_=null;function m(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function We(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function C(e,t,r){return Number.isFinite(e)?Math.max(t,Math.min(r,e)):t}function A(e){return(e||"").trim()||"en-US"}function W(e){return e.trim().toLowerCase()}function Ke(e){return e.replace(/"/g,"&quot;")}function Ve(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}function Re(e){const t=e.match(/\{\{[^{}]+\}\}|%[A-Z0-9_]+%|\$\{[^{}]+\}/gi);return!t||t.length===0?[]:t.map(r=>r.trim()).filter(Boolean)}function je(e,t){const r=Re(e).sort(),n=Re(t).sort();if(r.length!==n.length)return!1;for(let a=0;a<r.length;a+=1)if(r[a]!==n[a])return!1;return!0}function Ue(e,t){const r=Array.isArray(t)&&t.length>0?t:Ee,n=[],a=new Set;return r.forEach(o=>{const l=W(o.locale||"");if(!l)return;const s=l;a.has(s)||(a.add(s),n.push({locale:s,label:(o.label||l).trim()||l,minLengthRatio:C(Number(o.minLengthRatio??.5),.1,3),maxLengthRatio:C(Number(o.maxLengthRatio??1.8),.2,4),requireDifferentFromSource:o.requireDifferentFromSource!==!1,preserveTokens:o.preserveTokens!==!1}))}),e.forEach(o=>{const l=W(o);if(a.has(l))return;const s=Ee.find(i=>l.startsWith(i.locale));n.push(s?{...s,locale:l,label:o}:{locale:l,label:o,minLengthRatio:.5,maxLengthRatio:1.8,requireDifferentFromSource:!0,preserveTokens:!0})}),n}function oe(e={}){const t=e.normalizeText||We,r=A(e.sourceLocale||"en-US"),n=A(e.targetLocale||"fr-FR"),a=new Set([r,n]);(Array.isArray(e.locales)?e.locales:[]).forEach(s=>{if(typeof s!="string")return;const i=A(s);a.add(i)});const o=Array.from(a),l=Ue(o,e.localeRules);return{sourceLocale:r,targetLocale:n,locales:o,localeRules:l,enableRealtime:e.enableRealtime!==!1,debounceMs:C(Number(e.debounceMs??260),60,2e3),maxIssues:C(Number(e.maxIssues??120),5,1e3),maxSegments:C(Number(e.maxSegments??600),20,3e3),minSourceLengthForRatio:C(Number(e.minSourceLengthForRatio??8),2,100),segmentSelector:(e.segmentSelector||$e).trim()||$e,labels:{...Ne,...e.labels||{}},normalizeText:t}}function Ge(e){return{sourceLocale:e.sourceLocale,targetLocale:e.targetLocale,locales:[...e.locales],localeRules:e.localeRules.map(t=>({locale:t.locale,label:t.label,minLengthRatio:t.minLengthRatio,maxLengthRatio:t.maxLengthRatio,requireDifferentFromSource:t.requireDifferentFromSource,preserveTokens:t.preserveTokens})),enableRealtime:e.enableRealtime,debounceMs:e.debounceMs,maxIssues:e.maxIssues,maxSegments:e.maxSegments,minSourceLengthForRatio:e.minSourceLengthForRatio,segmentSelector:e.segmentSelector,labels:{...e.labels},normalizeText:e.normalizeText}}function xe(e){return e.closest(ke)||e}function K(e){if(!e)return null;if(e.matches(S))return e;const t=e.querySelector(S);return t instanceof HTMLElement?t:null}function Ye(){if(typeof window>"u")return null;const e=window[Te];if(!(e instanceof HTMLElement))return null;window[Te]=null;const t=K(e);if(t)return t;const r=e.closest(ke);if(r){const a=K(r);if(a)return a}const n=e.closest(S);return n instanceof HTMLElement?n:null}function Ze(e){const t=e.closest("[data-editora-editor]");if(t&&K(t)===e)return t;let r=e;for(;r;){if(r.matches(ke)&&(r===e||K(r)===e))return r;r=r.parentElement}return xe(e)}function Ce(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function ee(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 Je(e){const t=xe(e);if(ee(t))return!0;const r=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return ee(r)?!0:ee(document.documentElement)||ee(document.body)}function ge(e,t){e.classList.remove("rte-translation-workflow-theme-dark"),Je(t)&&e.classList.add("rte-translation-workflow-theme-dark")}function Qe(e){for(let t=0;t<e.length;t+=1){const r=e[t];if(!(r.type!=="childList"||r.removedNodes.length===0))for(let n=0;n<r.removedNodes.length;n+=1){const a=r.removedNodes[n];if(a.nodeType!==Node.ELEMENT_NODE)continue;const o=a;if(o.matches?.(S)||o.matches?.(`.${u}`)||o.querySelector?.(S)||o.querySelector?.(`.${u}`))return!0}}return!1}function ae(){Array.from(U).forEach(t=>{t.isConnected||Se(t)})}function T(e,t=!0,r=!0){if(ae(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const s=K(e.editorElement);if(s)return s}const n=Ye();if(n)return n;const a=window.getSelection();if(a&&a.rangeCount>0){const s=Ce(a.getRangeAt(0).startContainer)?.closest(S);if(s)return s}const o=document.activeElement;if(o){if(o.matches(S))return o;const s=o.closest(S);if(s)return s}if(r&&x&&x.isConnected)return x;if(!t)return null;const l=document.querySelector(S);return l instanceof HTMLElement?l:null}function Xe(e){const t=e.target;if(t){const n=t.closest(`.${u}`);if(n){const o=Array.from(p.entries()).find(([,l])=>l===n);if(o)return o[0]}const a=t.closest(S);if(a)return a}const r=document.activeElement;if(r){const n=r.closest(`.${u}`);if(n){const o=Array.from(p.entries()).find(([,l])=>l===n);if(o)return o[0]}const a=r.closest(S);if(a)return a}return null}function fe(e,t,r){const n=Ze(e);Array.from(n.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(o=>{o.classList.toggle("active",r),o.setAttribute("data-active",r?"true":"false"),o.setAttribute("aria-pressed",r?"true":"false")})}function we(e){const t=le.get(e);typeof t=="number"&&(window.clearTimeout(t),le.delete(e))}function et(e,t){const r=W(t),n=e.localeRules.find(l=>W(l.locale)===r);if(n)return n;const a=r.split("-")[0],o=e.localeRules.find(l=>W(l.locale).split("-")[0]===a);return o||{locale:r,label:t,minLengthRatio:.5,maxLengthRatio:1.8,requireDifferentFromSource:!0,preserveTokens:!0}}function te(e,t,r,n={}){return Ae+=1,{id:`translation-workflow-issue-${Ae}`,type:e,severity:t,message:r,...n}}function ie(e,t){if(t){e.hasAttribute("data-translation-prev-contenteditable")||e.setAttribute("data-translation-prev-contenteditable",e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")||"inherit"),e.setAttribute("data-translation-locked","true"),e.setAttribute("contenteditable","false"),e.setAttribute("aria-readonly","true"),e.classList.add("rte-translation-segment-locked");return}if(e.removeAttribute("data-translation-locked"),e.removeAttribute("aria-readonly"),e.classList.remove("rte-translation-segment-locked"),e.hasAttribute("data-translation-prev-contenteditable")){const r=e.getAttribute("data-translation-prev-contenteditable")||"";r==="inherit"?e.setAttribute("contenteditable","true"):e.setAttribute("contenteditable",r),e.removeAttribute("data-translation-prev-contenteditable")}else e.setAttribute("contenteditable","true")}function ce(e,t){return e.querySelector(`[data-translation-segment-id="${Ke(t)}"]`)}function He(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=Ce(t.getRangeAt(0).startContainer);return!r||!e.contains(r)?null:r.closest("[data-translation-segment-id]")}function tt(e,t){const r=Array.from(e.querySelectorAll(t));if(r.length<=1)return r;const n=new Set(r);return r.filter(a=>{let o=a.parentElement;for(;o&&o!==e;){if(n.has(o))return!1;o=o.parentElement}return!0})}function nt(e,t,r){let n=(r||"").trim();if(!n||t.has(n)){do n=`translation-segment-${_e++}`;while(t.has(n));e.setAttribute("data-translation-segment-id",n)}return n}function me(e,t){if(t.lockedSegmentIds.size===0)return!1;let r=!1;return t.lockedSegmentIds.forEach(n=>{const a=ce(e,n);if(!a)return;ie(a,!0);const o=t.lockedHtmlBySegmentId.get(n);if(typeof o=="string"){a.innerHTML!==o&&(a.innerHTML=o,r=!0);return}t.lockedHtmlBySegmentId.set(n,a.innerHTML)}),r}function M(e,t,r){const n=tt(e,t.segmentSelector),a=[],o=new Set;for(let l=0;l<n.length&&!(a.length>=t.maxSegments);l+=1){const s=n[l],i=nt(s,o,s.getAttribute("data-translation-segment-id")),d=r.lockedSegmentIds.has(i),g=s.getAttribute("data-translation-locked")==="true",w=d||g;if(w)if(r.lockedSegmentIds.add(i),ie(s,!0),!r.lockedHtmlBySegmentId.has(i))r.lockedHtmlBySegmentId.set(i,s.innerHTML);else{const q=r.lockedHtmlBySegmentId.get(i)||"";s.innerHTML!==q&&(s.innerHTML=q)}else r.lockedHtmlBySegmentId.delete(i);const v=t.normalizeText(s.textContent||"");if(!v)continue;r.sourceTextBySegmentId.has(i)||r.sourceTextBySegmentId.set(i,v);const G=r.sourceTextBySegmentId.get(i)||v;a.push({id:i,tagName:s.tagName.toLowerCase(),index:a.length,text:v,sourceText:G,locked:w}),o.add(i)}return Array.from(r.sourceTextBySegmentId.keys()).forEach(l=>{o.has(l)||r.sourceTextBySegmentId.delete(l)}),Array.from(r.lockedSegmentIds.keys()).forEach(l=>{o.has(l)||r.lockedSegmentIds.delete(l)}),Array.from(r.lockedHtmlBySegmentId.keys()).forEach(l=>{(!o.has(l)||!r.lockedSegmentIds.has(l))&&r.lockedHtmlBySegmentId.delete(l)}),(!r.selectedSegmentId||!a.some(l=>l.id===r.selectedSegmentId))&&(r.selectedSegmentId=a[0]?.id||null),a}function b(e,t){c.has(e)||c.set(e,t);let r=P.get(e);return r||(r={sourceLocale:t.sourceLocale,targetLocale:t.targetLocale,selectedSegmentId:null,realtimeEnabled:t.enableRealtime,segments:[],issues:[],sourceTextBySegmentId:new Map,lockedSegmentIds:new Set,lockedHtmlBySegmentId:new Map,snapshot:"",lastRunAt:null},P.set(e,r)),U.add(e),r}function Se(e){we(e);const t=p.get(e);t&&t.remove(),p.delete(e),j.delete(e);const r=P.get(e);r&&(r.lockedSegmentIds.forEach(n=>{const a=ce(e,n);a&&ie(a,!1)}),r.lockedHtmlBySegmentId.clear()),c.delete(e),re.delete(e),P.delete(e),U.delete(e),x===e&&(x=null)}function ye(e){return j.get(e)===!0}function be(e,t){if(!t.classList.contains("show"))return;const r=xe(e).getBoundingClientRect(),n=Math.min(window.innerWidth-20,520),a=Math.max(10,window.innerWidth-n-10),o=Math.min(Math.max(10,r.right-n),a),l=Math.max(10,Math.min(window.innerHeight-10,r.top+12));t.style.width=`${n}px`,t.style.left=`${o}px`,t.style.top=`${l}px`,t.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function H(e,t){const r=e.querySelector(".rte-translation-live");r&&(r.textContent=t)}function rt(e,t){return`${e.innerHTML}::${t.sourceLocale}::${t.targetLocale}::${Array.from(t.lockedSegmentIds).sort().join("|")}`}function ot(e,t,r){const n=[],a=et(r,t.targetLocale);for(let o=0;o<e.length&&!(n.length>=r.maxIssues);o+=1){const l=e[o],s=r.normalizeText(l.sourceText||""),i=r.normalizeText(l.text||"");if(!i){n.push(te("missing-target","error",r.labels.missingTargetMessage,{segmentId:l.id,sourceText:s,targetText:i,suggestion:"Provide translated content for this segment before export."}));continue}if(a.preserveTokens&&s&&!je(s,i)&&(n.push(te("token-mismatch","error",r.labels.tokenMismatchMessage,{segmentId:l.id,sourceText:s,targetText:i,suggestion:"Preserve placeholders/tokens exactly (for example {{name}}, %ID%, ${value})."})),n.length>=r.maxIssues)||a.requireDifferentFromSource&&s&&r.normalizeText(s)===r.normalizeText(i)&&(n.push(te("untranslated","warning",r.labels.untranslatedMessage,{segmentId:l.id,sourceText:s,targetText:i,suggestion:"Translate the segment or mark it intentionally unchanged."})),n.length>=r.maxIssues))break;if(s.length>=r.minSourceLengthForRatio){const d=i.length/Math.max(1,s.length);(d<a.minLengthRatio||d>a.maxLengthRatio)&&n.push(te("length-out-of-range","warning",r.labels.lengthOutOfRangeMessage,{segmentId:l.id,sourceText:s,targetText:i,suggestion:`Expected ratio for ${a.label}: ${a.minLengthRatio.toFixed(2)} - ${a.maxLengthRatio.toFixed(2)}.`}))}}return n}function Pe(e){const t=c.get(e)||k,r=P.get(e);return{sourceLocale:r?.sourceLocale||t?.sourceLocale||"en-US",targetLocale:r?.targetLocale||t?.targetLocale||"fr-FR",realtimeEnabled:r?.realtimeEnabled===!0,selectedSegmentId:r?.selectedSegmentId||null,segmentCount:r?.segments.length||0,lockedSegmentCount:r?r.segments.filter(n=>n.locked).length:0,issues:r?.issues?r.issues.map(n=>({...n})):[],segments:r?.segments.map(n=>({id:n.id,tagName:n.tagName,index:n.index,sourceLength:n.sourceText.length,targetLength:n.text.length,locked:n.locked}))||[],lastRunAt:r?.lastRunAt||null}}function E(e){const t=P.get(e),r=t&&t.selectedSegmentId?t.segments.find(n=>n.id===t.selectedSegmentId):null;fe(e,"toggleTranslationWorkflowPanel",ye(e)),fe(e,"toggleTranslationRealtime",t?.realtimeEnabled===!0),fe(e,"toggleTranslationSegmentLock",r?.locked===!0)}function at(e,t){const r=ce(e,t);if(!r)return;try{r.scrollIntoView({block:"nearest",inline:"nearest"})}catch{}const n=window.getSelection();if(!(!n||typeof document.createRange!="function"))try{const a=document.createRange();a.selectNodeContents(r),a.collapse(!0),n.removeAllRanges(),n.addRange(a),e.focus({preventScroll:!0})}catch{}}function R(e){const t=p.get(e);if(!t)return;const r=c.get(e)||k;if(!r)return;const n=b(e,r),a=t.querySelector(".rte-translation-source-label");a&&(a.textContent=r.labels.sourceLocaleLabel);const o=t.querySelector(".rte-translation-target-label");o&&(o.textContent=r.labels.targetLocaleLabel);const l=t.querySelector('[data-field="source-locale"]'),s=t.querySelector('[data-field="target-locale"]'),i=r.locales.map(f=>`<option value="${m(f)}">${m(f)}</option>`).join("");l&&(l.innerHTML=i,l.value=n.sourceLocale),s&&(s.innerHTML=i,s.value=n.targetLocale);const d=t.querySelector(".rte-translation-summary");if(d){const f=n.issues.length,B=n.selectedSegmentId?` • ${r.labels.selectedSegmentPrefix}: ${n.selectedSegmentId}`:"";d.textContent=`${r.labels.summaryPrefix}: ${n.sourceLocale} → ${n.targetLocale} • ${f} issue${f===1?"":"s"}${B}`}const g=t.querySelector(".rte-translation-helper");g&&(g.textContent=r.labels.helperText);const w=t.querySelector(".rte-translation-shortcut");w&&(w.textContent=r.labels.shortcutText);const v=t.querySelector('[data-action="run-validation"]');v&&(v.textContent=r.labels.validateText);const G=t.querySelector('[data-action="capture-source"]');G&&(G.textContent=r.labels.captureSourceText);const q=t.querySelector('[data-action="toggle-realtime"]');q&&(q.textContent=n.realtimeEnabled?r.labels.realtimeOnText:r.labels.realtimeOffText,q.setAttribute("aria-pressed",n.realtimeEnabled?"true":"false"));const Y=t.querySelector('[data-action="lock-selected"]'),ue=n.selectedSegmentId&&n.segments.find(f=>f.id===n.selectedSegmentId)||null;Y&&(Y.textContent=ue?.locked?r.labels.unlockSelectedText:r.labels.lockSelectedText,Y.disabled=!ue,Y.setAttribute("aria-pressed",ue?.locked?"true":"false"));const Le=t.querySelector('[data-action="close"]');Le&&Le.setAttribute("aria-label",r.labels.closeText);const Z=t.querySelector(".rte-translation-issues"),F=t.querySelector(".rte-translation-empty");Z&&(Z.setAttribute("aria-label",r.labels.issuesLabel),n.issues.length===0?(Z.innerHTML="",F&&(F.hidden=!1,F.textContent=r.labels.noIssuesText)):(F&&(F.hidden=!0),Z.innerHTML=n.issues.map(f=>`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const S=".rte-content, .editora-content",ke="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",ve="__editoraCommandEditorRoot",$e="rte-translation-workflow-styles",u="rte-translation-workflow-panel",y="translation-workflow",$="translationWorkflow",h=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Ee=["p","h1","h2","h3","h4","h5","h6","li","td","th","blockquote","figcaption"].join(", "),Ce=new Set(["ArrowUp","ArrowDown","Home","End"]),Ae=[{locale:"en",label:"English",minLengthRatio:.6,maxLengthRatio:1.4,requireDifferentFromSource:!1,preserveTokens:!0},{locale:"fr",label:"French",minLengthRatio:.75,maxLengthRatio:1.7,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"de",label:"German",minLengthRatio:.8,maxLengthRatio:1.9,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"es",label:"Spanish",minLengthRatio:.7,maxLengthRatio:1.7,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"it",label:"Italian",minLengthRatio:.7,maxLengthRatio:1.7,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"ja",label:"Japanese",minLengthRatio:.45,maxLengthRatio:1.2,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"zh",label:"Chinese",minLengthRatio:.4,maxLengthRatio:1.2,requireDifferentFromSource:!0,preserveTokens:!0}],_e={panelTitle:"Translation Workflow",panelAriaLabel:"Translation workflow panel",sourceLocaleLabel:"Source Locale",targetLocaleLabel:"Target Locale",validateText:"Validate Locale",captureSourceText:"Capture Source",lockSelectedText:"Lock Selected",unlockSelectedText:"Unlock Selected",lockSegmentAriaLabel:"Lock segment",unlockSegmentAriaLabel:"Unlock segment",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",summaryPrefix:"Locale QA",noIssuesText:"No locale validation issues.",issuesLabel:"Locale issues",segmentsLabel:"Segments",sourcePreviewLabel:"Source",targetPreviewLabel:"Target",helperText:"Select segments, lock finalized ones, and run locale validation before handoff.",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+L (panel), Ctrl/Cmd+Alt+Shift+V (validate), Ctrl/Cmd+Alt+Shift+K (lock segment)",readonlySegmentMessage:"This segment is locked. Unlock before editing.",sourceCapturedMessage:"Source snapshot captured from current content.",selectedSegmentPrefix:"Selected Segment",missingTargetMessage:"Segment is empty in target locale.",tokenMismatchMessage:"Tokens/placeholders do not match source segment.",untranslatedMessage:"Segment appears untranslated (same as source).",lengthOutOfRangeMessage:"Translation length is outside expected locale range."},c=new WeakMap,re=new WeakMap,P=new WeakMap,p=new Map,j=new WeakMap,le=new WeakMap,U=new Set;let X=0,Fe=0,Re=0,We=0,k=null,x=null,D=null,z=null,O=null,N=null,I=null,_=null;function m(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ke(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function C(e,t,r){return Number.isFinite(e)?Math.max(t,Math.min(r,e)):t}function A(e){return(e||"").trim()||"en-US"}function W(e){return e.trim().toLowerCase()}function Ve(e){return e.replace(/"/g,"&quot;")}function je(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}function Ie(e){const t=e.match(/\{\{[^{}]+\}\}|%[A-Z0-9_]+%|\$\{[^{}]+\}/gi);return!t||t.length===0?[]:t.map(r=>r.trim()).filter(Boolean)}function Ue(e,t){const r=Ie(e).sort(),n=Ie(t).sort();if(r.length!==n.length)return!1;for(let a=0;a<r.length;a+=1)if(r[a]!==n[a])return!1;return!0}function Ge(e,t){const r=Array.isArray(t)&&t.length>0?t:Ae,n=[],a=new Set;return r.forEach(o=>{const l=W(o.locale||"");if(!l)return;const s=l;a.has(s)||(a.add(s),n.push({locale:s,label:(o.label||l).trim()||l,minLengthRatio:C(Number(o.minLengthRatio??.5),.1,3),maxLengthRatio:C(Number(o.maxLengthRatio??1.8),.2,4),requireDifferentFromSource:o.requireDifferentFromSource!==!1,preserveTokens:o.preserveTokens!==!1}))}),e.forEach(o=>{const l=W(o);if(a.has(l))return;const s=Ae.find(i=>l.startsWith(i.locale));n.push(s?{...s,locale:l,label:o}:{locale:l,label:o,minLengthRatio:.5,maxLengthRatio:1.8,requireDifferentFromSource:!0,preserveTokens:!0})}),n}function oe(e={}){const t=e.normalizeText||Ke,r=A(e.sourceLocale||"en-US"),n=A(e.targetLocale||"fr-FR"),a=new Set([r,n]);(Array.isArray(e.locales)?e.locales:[]).forEach(s=>{if(typeof s!="string")return;const i=A(s);a.add(i)});const o=Array.from(a),l=Ge(o,e.localeRules);return{sourceLocale:r,targetLocale:n,locales:o,localeRules:l,enableRealtime:e.enableRealtime!==!1,debounceMs:C(Number(e.debounceMs??260),60,2e3),maxIssues:C(Number(e.maxIssues??120),5,1e3),maxSegments:C(Number(e.maxSegments??600),20,3e3),minSourceLengthForRatio:C(Number(e.minSourceLengthForRatio??8),2,100),segmentSelector:(e.segmentSelector||Ee).trim()||Ee,labels:{..._e,...e.labels||{}},normalizeText:t}}function Ye(e){return{sourceLocale:e.sourceLocale,targetLocale:e.targetLocale,locales:[...e.locales],localeRules:e.localeRules.map(t=>({locale:t.locale,label:t.label,minLengthRatio:t.minLengthRatio,maxLengthRatio:t.maxLengthRatio,requireDifferentFromSource:t.requireDifferentFromSource,preserveTokens:t.preserveTokens})),enableRealtime:e.enableRealtime,debounceMs:e.debounceMs,maxIssues:e.maxIssues,maxSegments:e.maxSegments,minSourceLengthForRatio:e.minSourceLengthForRatio,segmentSelector:e.segmentSelector,labels:{...e.labels},normalizeText:e.normalizeText}}function xe(e){return e.closest(ke)||e}function K(e){if(!e)return null;if(e.matches(S))return e;const t=e.querySelector(S);return t instanceof HTMLElement?t:null}function Ze(){if(typeof window>"u")return null;const e=window[ve];if(!(e instanceof HTMLElement))return null;window[ve]=null;const t=K(e);if(t)return t;const r=e.closest(ke);if(r){const a=K(r);if(a)return a}const n=e.closest(S);return n instanceof HTMLElement?n:null}function Je(e){const t=e.closest("[data-editora-editor]");if(t&&K(t)===e)return t;let r=e;for(;r;){if(r.matches(ke)&&(r===e||K(r)===e))return r;r=r.parentElement}return xe(e)}function He(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function ee(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 Qe(e){const t=xe(e);if(ee(t))return!0;const r=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return ee(r)?!0:ee(document.documentElement)||ee(document.body)}function ge(e,t){e.classList.remove("rte-translation-workflow-theme-dark"),Qe(t)&&e.classList.add("rte-translation-workflow-theme-dark")}function Xe(e){for(let t=0;t<e.length;t+=1){const r=e[t];if(!(r.type!=="childList"||r.removedNodes.length===0))for(let n=0;n<r.removedNodes.length;n+=1){const a=r.removedNodes[n];if(a.nodeType!==Node.ELEMENT_NODE)continue;const o=a;if(o.matches?.(S)||o.matches?.(`.${u}`)||o.querySelector?.(S)||o.querySelector?.(`.${u}`))return!0}}return!1}function ae(){Array.from(U).forEach(t=>{t.isConnected||Se(t)})}function T(e,t=!0,r=!0){if(ae(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const s=K(e.editorElement);if(s)return s}const n=Ze();if(n)return n;const a=window.getSelection();if(a&&a.rangeCount>0){const s=He(a.getRangeAt(0).startContainer)?.closest(S);if(s)return s}const o=document.activeElement;if(o){if(o.matches(S))return o;const s=o.closest(S);if(s)return s}if(r&&x&&x.isConnected)return x;if(!t)return null;const l=document.querySelector(S);return l instanceof HTMLElement?l:null}function et(e){const t=e.target;if(t){const n=t.closest(`.${u}`);if(n){const o=Array.from(p.entries()).find(([,l])=>l===n);if(o)return o[0]}const a=t.closest(S);if(a)return a}const r=document.activeElement;if(r){const n=r.closest(`.${u}`);if(n){const o=Array.from(p.entries()).find(([,l])=>l===n);if(o)return o[0]}const a=r.closest(S);if(a)return a}return null}function fe(e,t,r){const n=Je(e);Array.from(n.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(o=>{o.classList.toggle("active",r),o.setAttribute("data-active",r?"true":"false"),o.setAttribute("aria-pressed",r?"true":"false")})}function we(e){const t=le.get(e);typeof t=="number"&&(window.clearTimeout(t),le.delete(e))}function tt(e,t){const r=W(t),n=e.localeRules.find(l=>W(l.locale)===r);if(n)return n;const a=r.split("-")[0],o=e.localeRules.find(l=>W(l.locale).split("-")[0]===a);return o||{locale:r,label:t,minLengthRatio:.5,maxLengthRatio:1.8,requireDifferentFromSource:!0,preserveTokens:!0}}function te(e,t,r,n={}){return Re+=1,{id:`translation-workflow-issue-${Re}`,type:e,severity:t,message:r,...n}}function ie(e,t){if(t){e.hasAttribute("data-translation-prev-contenteditable")||e.setAttribute("data-translation-prev-contenteditable",e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")||"inherit"),e.setAttribute("data-translation-locked","true"),e.setAttribute("contenteditable","false"),e.setAttribute("aria-readonly","true"),e.classList.add("rte-translation-segment-locked");return}if(e.removeAttribute("data-translation-locked"),e.removeAttribute("aria-readonly"),e.classList.remove("rte-translation-segment-locked"),e.hasAttribute("data-translation-prev-contenteditable")){const r=e.getAttribute("data-translation-prev-contenteditable")||"";r==="inherit"?e.setAttribute("contenteditable","true"):e.setAttribute("contenteditable",r),e.removeAttribute("data-translation-prev-contenteditable")}else e.setAttribute("contenteditable","true")}function ce(e,t){return e.querySelector(`[data-translation-segment-id="${Ve(t)}"]`)}function Pe(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=He(t.getRangeAt(0).startContainer);return!r||!e.contains(r)?null:r.closest("[data-translation-segment-id]")}function nt(e,t){const r=Array.from(e.querySelectorAll(t));if(r.length<=1)return r;const n=new Set(r);return r.filter(a=>{let o=a.parentElement;for(;o&&o!==e;){if(n.has(o))return!1;o=o.parentElement}return!0})}function rt(e,t,r){let n=(r||"").trim();if(!n||t.has(n)){do n=`translation-segment-${Fe++}`;while(t.has(n));e.setAttribute("data-translation-segment-id",n)}return n}function me(e,t){if(t.lockedSegmentIds.size===0)return!1;let r=!1;return t.lockedSegmentIds.forEach(n=>{const a=ce(e,n);if(!a)return;ie(a,!0);const o=t.lockedHtmlBySegmentId.get(n);if(typeof o=="string"){a.innerHTML!==o&&(a.innerHTML=o,r=!0);return}t.lockedHtmlBySegmentId.set(n,a.innerHTML)}),r}function M(e,t,r){const n=nt(e,t.segmentSelector),a=[],o=new Set;for(let l=0;l<n.length&&!(a.length>=t.maxSegments);l+=1){const s=n[l],i=rt(s,o,s.getAttribute("data-translation-segment-id")),d=r.lockedSegmentIds.has(i),g=s.getAttribute("data-translation-locked")==="true",w=d||g;if(w)if(r.lockedSegmentIds.add(i),ie(s,!0),!r.lockedHtmlBySegmentId.has(i))r.lockedHtmlBySegmentId.set(i,s.innerHTML);else{const q=r.lockedHtmlBySegmentId.get(i)||"";s.innerHTML!==q&&(s.innerHTML=q)}else r.lockedHtmlBySegmentId.delete(i);const v=t.normalizeText(s.textContent||"");if(!v)continue;r.sourceTextBySegmentId.has(i)||r.sourceTextBySegmentId.set(i,v);const G=r.sourceTextBySegmentId.get(i)||v;a.push({id:i,tagName:s.tagName.toLowerCase(),index:a.length,text:v,sourceText:G,locked:w}),o.add(i)}return Array.from(r.sourceTextBySegmentId.keys()).forEach(l=>{o.has(l)||r.sourceTextBySegmentId.delete(l)}),Array.from(r.lockedSegmentIds.keys()).forEach(l=>{o.has(l)||r.lockedSegmentIds.delete(l)}),Array.from(r.lockedHtmlBySegmentId.keys()).forEach(l=>{(!o.has(l)||!r.lockedSegmentIds.has(l))&&r.lockedHtmlBySegmentId.delete(l)}),(!r.selectedSegmentId||!a.some(l=>l.id===r.selectedSegmentId))&&(r.selectedSegmentId=a[0]?.id||null),a}function b(e,t){c.has(e)||c.set(e,t);let r=P.get(e);return r||(r={sourceLocale:t.sourceLocale,targetLocale:t.targetLocale,selectedSegmentId:null,realtimeEnabled:t.enableRealtime,segments:[],issues:[],sourceTextBySegmentId:new Map,lockedSegmentIds:new Set,lockedHtmlBySegmentId:new Map,snapshot:"",lastRunAt:null},P.set(e,r)),U.add(e),r}function Se(e){we(e);const t=p.get(e);t&&t.remove(),p.delete(e),j.delete(e);const r=P.get(e);r&&(r.lockedSegmentIds.forEach(n=>{const a=ce(e,n);a&&ie(a,!1)}),r.lockedHtmlBySegmentId.clear()),c.delete(e),re.delete(e),P.delete(e),U.delete(e),x===e&&(x=null)}function ye(e){return j.get(e)===!0}function be(e,t){if(!t.classList.contains("show"))return;const r=xe(e).getBoundingClientRect(),n=Math.min(window.innerWidth-20,520),a=Math.max(10,window.innerWidth-n-10),o=Math.min(Math.max(10,r.right-n),a),l=Math.max(10,Math.min(window.innerHeight-10,r.top+12));t.style.width=`${n}px`,t.style.left=`${o}px`,t.style.top=`${l}px`,t.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function H(e,t){const r=e.querySelector(".rte-translation-live");r&&(r.textContent=t)}function ot(e,t){return`${e.innerHTML}::${t.sourceLocale}::${t.targetLocale}::${Array.from(t.lockedSegmentIds).sort().join("|")}`}function at(e,t,r){const n=[],a=tt(r,t.targetLocale);for(let o=0;o<e.length&&!(n.length>=r.maxIssues);o+=1){const l=e[o],s=r.normalizeText(l.sourceText||""),i=r.normalizeText(l.text||"");if(!i){n.push(te("missing-target","error",r.labels.missingTargetMessage,{segmentId:l.id,sourceText:s,targetText:i,suggestion:"Provide translated content for this segment before export."}));continue}if(a.preserveTokens&&s&&!Ue(s,i)&&(n.push(te("token-mismatch","error",r.labels.tokenMismatchMessage,{segmentId:l.id,sourceText:s,targetText:i,suggestion:"Preserve placeholders/tokens exactly (for example {{name}}, %ID%, ${value})."})),n.length>=r.maxIssues)||a.requireDifferentFromSource&&s&&r.normalizeText(s)===r.normalizeText(i)&&(n.push(te("untranslated","warning",r.labels.untranslatedMessage,{segmentId:l.id,sourceText:s,targetText:i,suggestion:"Translate the segment or mark it intentionally unchanged."})),n.length>=r.maxIssues))break;if(s.length>=r.minSourceLengthForRatio){const d=i.length/Math.max(1,s.length);(d<a.minLengthRatio||d>a.maxLengthRatio)&&n.push(te("length-out-of-range","warning",r.labels.lengthOutOfRangeMessage,{segmentId:l.id,sourceText:s,targetText:i,suggestion:`Expected ratio for ${a.label}: ${a.minLengthRatio.toFixed(2)} - ${a.maxLengthRatio.toFixed(2)}.`}))}}return n}function qe(e){const t=c.get(e)||k,r=P.get(e);return{sourceLocale:r?.sourceLocale||t?.sourceLocale||"en-US",targetLocale:r?.targetLocale||t?.targetLocale||"fr-FR",realtimeEnabled:r?.realtimeEnabled===!0,selectedSegmentId:r?.selectedSegmentId||null,segmentCount:r?.segments.length||0,lockedSegmentCount:r?r.segments.filter(n=>n.locked).length:0,issues:r?.issues?r.issues.map(n=>({...n})):[],segments:r?.segments.map(n=>({id:n.id,tagName:n.tagName,index:n.index,sourceLength:n.sourceText.length,targetLength:n.text.length,locked:n.locked}))||[],lastRunAt:r?.lastRunAt||null}}function E(e){const t=P.get(e),r=t&&t.selectedSegmentId?t.segments.find(n=>n.id===t.selectedSegmentId):null;fe(e,"toggleTranslationWorkflowPanel",ye(e)),fe(e,"toggleTranslationRealtime",t?.realtimeEnabled===!0),fe(e,"toggleTranslationSegmentLock",r?.locked===!0)}function lt(e,t){const r=ce(e,t);if(!r)return;try{r.scrollIntoView({block:"nearest",inline:"nearest"})}catch{}const n=window.getSelection();if(!(!n||typeof document.createRange!="function"))try{const a=document.createRange();a.selectNodeContents(r),a.collapse(!0),n.removeAllRanges(),n.addRange(a),e.focus({preventScroll:!0})}catch{}}function R(e){const t=p.get(e);if(!t)return;const r=c.get(e)||k;if(!r)return;const n=b(e,r),a=t.querySelector(".rte-translation-source-label");a&&(a.textContent=r.labels.sourceLocaleLabel);const o=t.querySelector(".rte-translation-target-label");o&&(o.textContent=r.labels.targetLocaleLabel);const l=t.querySelector('[data-field="source-locale"]'),s=t.querySelector('[data-field="target-locale"]'),i=r.locales.map(f=>`<option value="${m(f)}">${m(f)}</option>`).join("");l&&(l.innerHTML=i,l.value=n.sourceLocale),s&&(s.innerHTML=i,s.value=n.targetLocale);const d=t.querySelector(".rte-translation-summary");if(d){const f=n.issues.length,B=n.selectedSegmentId?` • ${r.labels.selectedSegmentPrefix}: ${n.selectedSegmentId}`:"";d.textContent=`${r.labels.summaryPrefix}: ${n.sourceLocale} → ${n.targetLocale} • ${f} issue${f===1?"":"s"}${B}`}const g=t.querySelector(".rte-translation-helper");g&&(g.textContent=r.labels.helperText);const w=t.querySelector(".rte-translation-shortcut");w&&(w.textContent=r.labels.shortcutText);const v=t.querySelector('[data-action="run-validation"]');v&&(v.textContent=r.labels.validateText);const G=t.querySelector('[data-action="capture-source"]');G&&(G.textContent=r.labels.captureSourceText);const q=t.querySelector('[data-action="toggle-realtime"]');q&&(q.textContent=n.realtimeEnabled?r.labels.realtimeOnText:r.labels.realtimeOffText,q.setAttribute("aria-pressed",n.realtimeEnabled?"true":"false"));const Y=t.querySelector('[data-action="lock-selected"]'),ue=n.selectedSegmentId&&n.segments.find(f=>f.id===n.selectedSegmentId)||null;Y&&(Y.textContent=ue?.locked?r.labels.unlockSelectedText:r.labels.lockSelectedText,Y.disabled=!ue,Y.setAttribute("aria-pressed",ue?.locked?"true":"false"));const Te=t.querySelector('[data-action="close"]');Te&&Te.setAttribute("aria-label",r.labels.closeText);const Z=t.querySelector(".rte-translation-issues"),F=t.querySelector(".rte-translation-empty");Z&&(Z.setAttribute("aria-label",r.labels.issuesLabel),n.issues.length===0?(Z.innerHTML="",F&&(F.hidden=!1,F.textContent=r.labels.noIssuesText)):(F&&(F.hidden=!0),Z.innerHTML=n.issues.map(f=>`
<li class="rte-translation-issue ${f.severity==="error"?"error":f.severity==="warning"?"warning":"info"}" role="listitem" data-segment-id="${m(f.segmentId||"")}">

@@ -6,11 +6,11 @@ <p class="rte-translation-issue-message">${m(f.message)}</p>

</li>
`).join("")));const de=t.querySelector(".rte-translation-segments");de&&(de.setAttribute("aria-label",r.labels.segmentsLabel),de.innerHTML=n.segments.map(f=>{const B=f.id===n.selectedSegmentId?"selected":"",Oe=f.locked?"locked":"";return`
<li class="rte-translation-segment-item ${B} ${Oe}" role="option" aria-selected="${f.id===n.selectedSegmentId?"true":"false"}" data-segment-id="${m(f.id)}">
`).join("")));const de=t.querySelector(".rte-translation-segments");de&&(de.setAttribute("aria-label",r.labels.segmentsLabel),de.innerHTML=n.segments.map(f=>{const B=f.id===n.selectedSegmentId?"selected":"",Ne=f.locked?"locked":"";return`
<li class="rte-translation-segment-item ${B} ${Ne}" role="option" aria-selected="${f.id===n.selectedSegmentId?"true":"false"}" data-segment-id="${m(f.id)}">
<button type="button" class="rte-translation-segment-select" data-action="select-segment" data-segment-id="${m(f.id)}" title="${m(f.text)}">
<span class="rte-translation-segment-meta">#${f.index+1} • ${m(f.tagName)}</span>
<span class="rte-translation-segment-text">${m(Ve(f.text,110))}</span>
<span class="rte-translation-segment-text">${m(je(f.text,110))}</span>
</button>
<button type="button" class="rte-translation-segment-lock" data-action="toggle-lock" data-segment-id="${m(f.id)}" aria-label="${f.locked?r.labels.unlockSegmentAriaLabel:r.labels.lockSegmentAriaLabel}" aria-pressed="${f.locked?"true":"false"}"></button>
</li>
`}).join(""));const J=t.querySelector(".rte-translation-source-preview"),Q=t.querySelector(".rte-translation-target-preview");if(J||Q){const f=n.selectedSegmentId&&n.segments.find(B=>B.id===n.selectedSegmentId)||null;J&&(J.textContent=f?.sourceText||"—",J.setAttribute("aria-label",r.labels.sourcePreviewLabel)),Q&&(Q.textContent=f?.text||"—",Q.setAttribute("aria-label",r.labels.targetPreviewLabel))}t.setAttribute("aria-label",r.labels.panelAriaLabel)}function qe(e){const t=c.get(e)||k;if(!t)return;we(e);const r=window.setTimeout(()=>{le.delete(e),L(e,"realtime",!1)},t.debounceMs);le.set(e,r)}function L(e,t,r){const n=c.get(e)||k;if(!n)return[];const a=b(e,n),o=me(e,a);a.segments=M(e,n,a);const l=rt(e,a);if(!r&&a.snapshot===l)return a.issues;a.issues=ot(a.segments,a,n),a.lastRunAt=new Date().toISOString(),a.snapshot=l,R(e),E(e),e.dispatchEvent(new CustomEvent("editora:translation-workflow-validation",{bubbles:!0,detail:{reason:t,state:Pe(e)}}));const s=p.get(e);if(s){if(o)return H(s,n.labels.readonlySegmentMessage),a.issues;H(s,a.issues.length===0?n.labels.noIssuesText:`${a.issues.length} issue${a.issues.length===1?"":"s"} detected.`)}return a.issues}function Be(e){const t=c.get(e)||k;if(!t)return!1;const r=b(e,t),n=M(e,t,r);n.forEach(o=>{r.sourceTextBySegmentId.set(o.id,o.text)}),r.snapshot="",L(e,"capture-source",!0);const a=p.get(e);return a&&H(a,t.labels.sourceCapturedMessage),e.dispatchEvent(new CustomEvent("editora:translation-source-captured",{bubbles:!0,detail:{sourceLocale:r.sourceLocale,segmentCount:n.length}})),!0}function se(e,t,r){const n=c.get(e)||k;if(!n)return!1;const a=b(e,n);a.segments=M(e,n,a);const o=He(e)?.getAttribute("data-translation-segment-id")||null,l=t||o||a.selectedSegmentId||a.segments[0]?.id||null;if(!l)return!1;const s=ce(e,l);if(!s)return!1;const i=typeof r=="boolean"?r:!a.lockedSegmentIds.has(l);return i?(a.lockedSegmentIds.add(l),a.lockedHtmlBySegmentId.set(l,s.innerHTML)):(a.lockedSegmentIds.delete(l),a.lockedHtmlBySegmentId.delete(l)),ie(s,i),a.selectedSegmentId=l,a.snapshot="",L(e,"lock-segment",!0),e.dispatchEvent(new CustomEvent("editora:translation-segment-lock",{bubbles:!0,detail:{segmentId:l,locked:i}})),!0}function De(e,t){const r=c.get(e)||k;if(!r)return!1;const n=b(e,r),a=typeof t=="boolean"?t:!n.realtimeEnabled;return n.realtimeEnabled=a,a?qe(e):we(e),R(e),E(e),!0}function pe(e,t,r=!0){const n=c.get(e)||k;if(!n)return!1;const a=b(e,n);return a.segments=M(e,n,a),a.segments.some(o=>o.id===t)?(a.selectedSegmentId=t,R(e),E(e),r&&at(e,t),!0):!1}function ne(e,t){const r=c.get(e)||k;if(!r)return!1;const n=b(e,r);if(n.segments=M(e,r,n),n.segments.length===0)return!1;const a=Math.max(0,n.segments.findIndex(s=>s.id===n.selectedSegmentId));let o=a;t==="start"?o=0:t==="end"?o=n.segments.length-1:o=C(a+t,0,n.segments.length-1);const l=n.segments[o];return l?pe(e,l.id,!0):!1}function V(e,t=!1){const r=p.get(e);r&&(r.classList.remove("show"),j.set(e,!1),E(e),t&&e.focus({preventScroll:!0}))}function he(e){const t=ut(e);p.forEach((n,a)=>{a!==e&&V(a,!1)}),t.classList.add("show"),j.set(e,!0),L(e,"panel-open",!1),R(e),be(e,t),E(e),t.querySelector('[data-field="target-locale"]')?.focus()}function ze(e,t){const r=ye(e);return(typeof t=="boolean"?t:!r)?he(e):V(e,!1),!0}function lt(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="l"}function st(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="v"}function it(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="k"}function ct(e){return e.key.length===1&&!e.metaKey&&!e.ctrlKey&&!e.altKey?!0:e.key==="Backspace"||e.key==="Delete"||e.key==="Enter"}function Ie(e){return e instanceof HTMLElement?e.closest('[data-translation-locked="true"]'):null}function ut(e){const t=p.get(e);if(t)return t;const r=c.get(e)||k||oe();b(e,r);const n=`rte-translation-workflow-panel-${Fe++}`,a=`${n}-source`,o=`${n}-target`,l=document.createElement("section");return l.className=u,l.id=n,l.setAttribute("role","dialog"),l.setAttribute("aria-modal","false"),l.setAttribute("aria-label",r.labels.panelAriaLabel),l.innerHTML=`
`}).join(""));const J=t.querySelector(".rte-translation-source-preview"),Q=t.querySelector(".rte-translation-target-preview");if(J||Q){const f=n.selectedSegmentId&&n.segments.find(B=>B.id===n.selectedSegmentId)||null;J&&(J.textContent=f?.sourceText||"—",J.setAttribute("aria-label",r.labels.sourcePreviewLabel)),Q&&(Q.textContent=f?.text||"—",Q.setAttribute("aria-label",r.labels.targetPreviewLabel))}t.setAttribute("aria-label",r.labels.panelAriaLabel)}function Be(e){const t=c.get(e)||k;if(!t)return;we(e);const r=window.setTimeout(()=>{le.delete(e),L(e,"realtime",!1)},t.debounceMs);le.set(e,r)}function L(e,t,r){const n=c.get(e)||k;if(!n)return[];const a=b(e,n),o=me(e,a);a.segments=M(e,n,a);const l=ot(e,a);if(!r&&a.snapshot===l)return a.issues;a.issues=at(a.segments,a,n),a.lastRunAt=new Date().toISOString(),a.snapshot=l,R(e),E(e),e.dispatchEvent(new CustomEvent("editora:translation-workflow-validation",{bubbles:!0,detail:{reason:t,state:qe(e)}}));const s=p.get(e);if(s){if(o)return H(s,n.labels.readonlySegmentMessage),a.issues;H(s,a.issues.length===0?n.labels.noIssuesText:`${a.issues.length} issue${a.issues.length===1?"":"s"} detected.`)}return a.issues}function De(e){const t=c.get(e)||k;if(!t)return!1;const r=b(e,t),n=M(e,t,r);n.forEach(o=>{r.sourceTextBySegmentId.set(o.id,o.text)}),r.snapshot="",L(e,"capture-source",!0);const a=p.get(e);return a&&H(a,t.labels.sourceCapturedMessage),e.dispatchEvent(new CustomEvent("editora:translation-source-captured",{bubbles:!0,detail:{sourceLocale:r.sourceLocale,segmentCount:n.length}})),!0}function se(e,t,r){const n=c.get(e)||k;if(!n)return!1;const a=b(e,n);a.segments=M(e,n,a);const o=Pe(e)?.getAttribute("data-translation-segment-id")||null,l=t||o||a.selectedSegmentId||a.segments[0]?.id||null;if(!l)return!1;const s=ce(e,l);if(!s)return!1;const i=typeof r=="boolean"?r:!a.lockedSegmentIds.has(l);return i?(a.lockedSegmentIds.add(l),a.lockedHtmlBySegmentId.set(l,s.innerHTML)):(a.lockedSegmentIds.delete(l),a.lockedHtmlBySegmentId.delete(l)),ie(s,i),a.selectedSegmentId=l,a.snapshot="",L(e,"lock-segment",!0),e.dispatchEvent(new CustomEvent("editora:translation-segment-lock",{bubbles:!0,detail:{segmentId:l,locked:i}})),!0}function ze(e,t){const r=c.get(e)||k;if(!r)return!1;const n=b(e,r),a=typeof t=="boolean"?t:!n.realtimeEnabled;return n.realtimeEnabled=a,a?Be(e):we(e),R(e),E(e),!0}function pe(e,t,r=!0){const n=c.get(e)||k;if(!n)return!1;const a=b(e,n);return a.segments=M(e,n,a),a.segments.some(o=>o.id===t)?(a.selectedSegmentId=t,R(e),E(e),r&&lt(e,t),!0):!1}function ne(e,t){const r=c.get(e)||k;if(!r)return!1;const n=b(e,r);if(n.segments=M(e,r,n),n.segments.length===0)return!1;const a=Math.max(0,n.segments.findIndex(s=>s.id===n.selectedSegmentId));let o=a;t==="start"?o=0:t==="end"?o=n.segments.length-1:o=C(a+t,0,n.segments.length-1);const l=n.segments[o];return l?pe(e,l.id,!0):!1}function V(e,t=!1){const r=p.get(e);r&&(r.classList.remove("show"),j.set(e,!1),E(e),t&&e.focus({preventScroll:!0}))}function he(e){const t=dt(e);p.forEach((n,a)=>{a!==e&&V(a,!1)}),t.classList.add("show"),j.set(e,!0),L(e,"panel-open",!1),R(e),be(e,t),E(e),t.querySelector('[data-field="target-locale"]')?.focus()}function Oe(e,t){const r=ye(e);return(typeof t=="boolean"?t:!r)?he(e):V(e,!1),!0}function Le(e){return typeof e.key=="string"?e.key.toLowerCase():""}function st(e){const t=Le(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="l"}function it(e){const t=Le(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="v"}function ct(e){const t=Le(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="k"}function ut(e){return e.key.length===1&&!e.metaKey&&!e.ctrlKey&&!e.altKey?!0:e.key==="Backspace"||e.key==="Delete"||e.key==="Enter"}function Me(e){return e instanceof HTMLElement?e.closest('[data-translation-locked="true"]'):null}function dt(e){const t=p.get(e);if(t)return t;const r=c.get(e)||k||oe();b(e,r);const n=`rte-translation-workflow-panel-${We++}`,a=`${n}-source`,o=`${n}-target`,l=document.createElement("section");return l.className=u,l.id=n,l.setAttribute("role","dialog"),l.setAttribute("aria-modal","false"),l.setAttribute("aria-label",r.labels.panelAriaLabel),l.innerHTML=`
<header class="rte-translation-header">

@@ -64,3 +64,3 @@ <h2 class="rte-translation-title">${m(r.labels.panelTitle)}</h2>

<div class="rte-translation-live" aria-live="polite" aria-atomic="true"></div>
`,l.addEventListener("click",s=>{const i=s.target;if(!i)return;const d=i.closest("[data-action]");if(!d){const v=i.closest(".rte-translation-issue[data-segment-id]")?.getAttribute("data-segment-id")||"";v&&pe(e,v,!0);return}const g=d.getAttribute("data-action");if(g==="close"){V(e,!0);return}if(g==="run-validation"){L(e,"panel-button",!0);return}if(g==="capture-source"){Be(e);return}if(g==="lock-selected"){se(e);return}if(g==="toggle-realtime"){De(e);return}if(g==="select-segment"){const w=d.getAttribute("data-segment-id")||"";w&&pe(e,w,!0);return}if(g==="toggle-lock"){const w=d.getAttribute("data-segment-id")||"";w&&se(e,w)}}),l.addEventListener("change",s=>{const i=s.target;if(!(i instanceof HTMLSelectElement))return;const d=c.get(e)||k;if(!d)return;const g=b(e,d);if(i.getAttribute("data-field")==="source-locale"){g.sourceLocale=A(i.value),g.snapshot="",L(e,"source-locale-change",!0);return}i.getAttribute("data-field")==="target-locale"&&(g.targetLocale=A(i.value),g.snapshot="",L(e,"target-locale-change",!0))}),l.addEventListener("keydown",s=>{const i=s.target;if(s.key==="Escape"){s.preventDefault(),V(e,!0);return}!i?.closest(".rte-translation-segments")||!Me.has(s.key)||(s.preventDefault(),s.key==="ArrowUp"?ne(e,-1):s.key==="ArrowDown"?ne(e,1):s.key==="Home"?ne(e,"start"):s.key==="End"&&ne(e,"end"))}),ge(l,e),document.body.appendChild(l),p.set(e,l),j.set(e,!1),R(e),l}function dt(e){k=e,D||(D=t=>{ae();const n=t.target?.closest(S);if(!n)return;const a=c.get(n)||e,o=b(n,a);c.set(n,a),x=n;const l=He(n)?.getAttribute("data-translation-segment-id")||null;l&&(o.selectedSegmentId=l),E(n);const s=p.get(n);s&&(ge(s,n),be(n,s),R(n))},document.addEventListener("focusin",D,!0)),z||(z=t=>{const n=t.target?.closest(S);if(!n)return;const a=c.get(n)||k;if(!a)return;const o=b(n,a),l=me(n,o);if(o.segments=M(n,a,o),!o.realtimeEnabled){if(l){const s=p.get(n);s&&H(s,a.labels.readonlySegmentMessage)}R(n),E(n);return}qe(n)},document.addEventListener("input",z,!0)),O||(O=t=>{const r=t,n=r.target,a=n?.closest(S);if(!a)return;const o=Ie(n);if(!o||!a.contains(o))return;r.preventDefault();const l=p.get(a),s=c.get(a)||k;l&&s&&H(l,s.labels.readonlySegmentMessage)},document.addEventListener("beforeinput",O,!0)),N||(N=t=>{if(t.defaultPrevented)return;const r=t.target;if(r?.closest(`.${u}`)&&t.key!=="Escape"&&!Me.has(t.key))return;const a=t.key==="Escape",o=lt(t),l=st(t),s=it(t),i=Ie(r);if(!a&&!o&&!l&&!s&&!i)return;const d=Xe(t);if(!d)return;const g=c.get(d)||k||e;if(b(d,g),c.set(d,g),x=d,a&&ye(d)){t.preventDefault(),V(d,!0);return}if(i&&d.contains(i)&&ct(t)){t.preventDefault();const w=p.get(d);w&&H(w,g.labels.readonlySegmentMessage);return}if(o){t.preventDefault(),t.stopPropagation(),ze(d);return}if(l){t.preventDefault(),t.stopPropagation(),L(d,"shortcut",!0);return}s&&(t.preventDefault(),t.stopPropagation(),se(d))},document.addEventListener("keydown",N,!0)),I||(I=()=>{ae(),p.forEach((t,r)=>{!r.isConnected||!t.isConnected||(ge(t,r),be(r,t))})},window.addEventListener("scroll",I,!0),window.addEventListener("resize",I)),!_&&typeof MutationObserver<"u"&&document.body&&(_=new MutationObserver(t=>{Qe(t)&&ae(),t.some(n=>n.type==="characterData"?!0:n.type==="childList"&&(n.addedNodes.length>0||n.removedNodes.length>0))&&U.forEach(n=>{const a=P.get(n);if(!a||a.lockedSegmentIds.size===0||!me(n,a))return;a.snapshot="";const l=c.get(n)||k,s=p.get(n);s&&l&&H(s,l.labels.readonlySegmentMessage),l&&(a.segments=M(n,l,a),R(n),E(n))})}),_.observe(document.body,{childList:!0,subtree:!0,characterData:!0}))}function ft(){D&&(document.removeEventListener("focusin",D,!0),D=null),z&&(document.removeEventListener("input",z,!0),z=null),O&&(document.removeEventListener("beforeinput",O,!0),O=null),N&&(document.removeEventListener("keydown",N,!0),N=null),I&&(window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I),I=null),_&&(_.disconnect(),_=null),p.forEach(t=>t.remove()),p.clear(),Array.from(U).forEach(t=>Se(t)),k=null,x=null}function gt(){if(typeof document>"u"||document.getElementById(ve))return;const e=document.createElement("style");e.id=ve,e.textContent=`
`,l.addEventListener("click",s=>{const i=s.target;if(!i)return;const d=i.closest("[data-action]");if(!d){const v=i.closest(".rte-translation-issue[data-segment-id]")?.getAttribute("data-segment-id")||"";v&&pe(e,v,!0);return}const g=d.getAttribute("data-action");if(g==="close"){V(e,!0);return}if(g==="run-validation"){L(e,"panel-button",!0);return}if(g==="capture-source"){De(e);return}if(g==="lock-selected"){se(e);return}if(g==="toggle-realtime"){ze(e);return}if(g==="select-segment"){const w=d.getAttribute("data-segment-id")||"";w&&pe(e,w,!0);return}if(g==="toggle-lock"){const w=d.getAttribute("data-segment-id")||"";w&&se(e,w)}}),l.addEventListener("change",s=>{const i=s.target;if(!(i instanceof HTMLSelectElement))return;const d=c.get(e)||k;if(!d)return;const g=b(e,d);if(i.getAttribute("data-field")==="source-locale"){g.sourceLocale=A(i.value),g.snapshot="",L(e,"source-locale-change",!0);return}i.getAttribute("data-field")==="target-locale"&&(g.targetLocale=A(i.value),g.snapshot="",L(e,"target-locale-change",!0))}),l.addEventListener("keydown",s=>{const i=s.target;if(s.key==="Escape"){s.preventDefault(),V(e,!0);return}!i?.closest(".rte-translation-segments")||!Ce.has(s.key)||(s.preventDefault(),s.key==="ArrowUp"?ne(e,-1):s.key==="ArrowDown"?ne(e,1):s.key==="Home"?ne(e,"start"):s.key==="End"&&ne(e,"end"))}),ge(l,e),document.body.appendChild(l),p.set(e,l),j.set(e,!1),R(e),l}function ft(e){k=e,D||(D=t=>{ae();const n=t.target?.closest(S);if(!n)return;const a=c.get(n)||e,o=b(n,a);c.set(n,a),x=n;const l=Pe(n)?.getAttribute("data-translation-segment-id")||null;l&&(o.selectedSegmentId=l),E(n);const s=p.get(n);s&&(ge(s,n),be(n,s),R(n))},document.addEventListener("focusin",D,!0)),z||(z=t=>{const n=t.target?.closest(S);if(!n)return;const a=c.get(n)||k;if(!a)return;const o=b(n,a),l=me(n,o);if(o.segments=M(n,a,o),!o.realtimeEnabled){if(l){const s=p.get(n);s&&H(s,a.labels.readonlySegmentMessage)}R(n),E(n);return}Be(n)},document.addEventListener("input",z,!0)),O||(O=t=>{const r=t,n=r.target,a=n?.closest(S);if(!a)return;const o=Me(n);if(!o||!a.contains(o))return;r.preventDefault();const l=p.get(a),s=c.get(a)||k;l&&s&&H(l,s.labels.readonlySegmentMessage)},document.addEventListener("beforeinput",O,!0)),N||(N=t=>{if(t.defaultPrevented)return;const r=t.target;if(r?.closest(`.${u}`)&&t.key!=="Escape"&&!Ce.has(t.key))return;const a=t.key==="Escape",o=st(t),l=it(t),s=ct(t),i=Me(r);if(!a&&!o&&!l&&!s&&!i)return;const d=et(t);if(!d)return;const g=c.get(d)||k||e;if(b(d,g),c.set(d,g),x=d,a&&ye(d)){t.preventDefault(),V(d,!0);return}if(i&&d.contains(i)&&ut(t)){t.preventDefault();const w=p.get(d);w&&H(w,g.labels.readonlySegmentMessage);return}if(o){t.preventDefault(),t.stopPropagation(),Oe(d);return}if(l){t.preventDefault(),t.stopPropagation(),L(d,"shortcut",!0);return}s&&(t.preventDefault(),t.stopPropagation(),se(d))},document.addEventListener("keydown",N,!0)),I||(I=()=>{ae(),p.forEach((t,r)=>{!r.isConnected||!t.isConnected||(ge(t,r),be(r,t))})},window.addEventListener("scroll",I,!0),window.addEventListener("resize",I)),!_&&typeof MutationObserver<"u"&&document.body&&(_=new MutationObserver(t=>{Xe(t)&&ae(),t.some(n=>n.type==="characterData"?!0:n.type==="childList"&&(n.addedNodes.length>0||n.removedNodes.length>0))&&U.forEach(n=>{const a=P.get(n);if(!a||a.lockedSegmentIds.size===0||!me(n,a))return;a.snapshot="";const l=c.get(n)||k,s=p.get(n);s&&l&&H(s,l.labels.readonlySegmentMessage),l&&(a.segments=M(n,l,a),R(n),E(n))})}),_.observe(document.body,{childList:!0,subtree:!0,characterData:!0}))}function gt(){D&&(document.removeEventListener("focusin",D,!0),D=null),z&&(document.removeEventListener("input",z,!0),z=null),O&&(document.removeEventListener("beforeinput",O,!0),O=null),N&&(document.removeEventListener("keydown",N,!0),N=null),I&&(window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I),I=null),_&&(_.disconnect(),_=null),p.forEach(t=>t.remove()),p.clear(),Array.from(U).forEach(t=>Se(t)),k=null,x=null}function mt(){if(typeof document>"u"||document.getElementById($e))return;const e=document.createElement("style");e.id=$e,e.textContent=`
.rte-toolbar-group-items.${y},

@@ -628,2 +628,2 @@ .editora-toolbar-group-items.${y},

}
`,document.head.appendChild(e)}const mt=(e={})=>{const t=oe(e),r=new Set;return gt(),{name:"translationWorkflow",toolbar:[{id:"translationWorkflowGroup",label:"Translation Workflow",type:"group",command:"translationWorkflow",items:[{id:"toggleTranslationWorkflowPanel",label:"Translation Workflow",command:"toggleTranslationWorkflowPanel",shortcut:"Mod-Alt-Shift-l",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4 6.5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H8l-4 3V6.5Z" stroke="currentColor" stroke-width="1.6"/><path d="M20 17.5a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2v-1.5" stroke="currentColor" stroke-width="1.6"/><path d="m13 8 2 2m0 0 2-2m-2 2V4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"runTranslationLocaleValidation",label:"Run Locale Validation",command:"runTranslationLocaleValidation",shortcut:"Mod-Alt-Shift-v",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4.5" y="4" width="12" height="16" rx="2" stroke="currentColor" stroke-width="1.6"/><path d="M8 8h5.5M8 11h4M8 14h3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="m15.5 15.5 1.7 1.7 3.3-3.3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"toggleTranslationSegmentLock",label:"Toggle Segment Lock",command:"toggleTranslationSegmentLock",shortcut:"Mod-Alt-Shift-k",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="5" y="10" width="14" height="10" rx="2" stroke="currentColor" stroke-width="1.6"/><path d="M8.5 10V7.5a3.5 3.5 0 1 1 7 0V10" stroke="currentColor" stroke-width="1.6"/><circle cx="12" cy="15" r="1.2" fill="currentColor"/></svg>'},{id:"toggleTranslationRealtime",label:"Toggle Translation Realtime",command:"toggleTranslationRealtime",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4.5 12a7.5 7.5 0 1 1 7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M9.5 19.5H5.5v-4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 8v4l2.5 2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'}]}],commands:{translationWorkflow:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;return b(o,l),c.set(o,l),x=o,he(o),!0},openTranslationWorkflowPanel:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;return b(o,l),c.set(o,l),x=o,he(o),!0},toggleTranslationWorkflowPanel:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;return b(o,l),c.set(o,l),x=o,ze(o,typeof n=="boolean"?n:void 0)},runTranslationLocaleValidation:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;return b(o,l),c.set(o,l),x=o,L(o,"command",!0),!0},toggleTranslationRealtime:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;return b(o,l),c.set(o,l),x=o,De(o,typeof n=="boolean"?n:void 0)},toggleTranslationSegmentLock:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;b(o,l),c.set(o,l),x=o;const s=typeof n=="boolean"?n:n?.locked,i=typeof n=="object"?n?.segmentId:void 0;return se(o,i,s)},setTranslationLocales:(n,a)=>{const o=T(a,!1,!1);if(!o||!n||typeof n!="object")return!1;const l=c.get(o)||t,s=b(o,l);return c.set(o,l),typeof n.sourceLocale=="string"&&n.sourceLocale.trim()&&(s.sourceLocale=A(n.sourceLocale)),typeof n.targetLocale=="string"&&n.targetLocale.trim()&&(s.targetLocale=A(n.targetLocale)),s.snapshot="",L(o,"set-locales",!0),!0},captureTranslationSourceSnapshot:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;return b(o,l),c.set(o,l),x=o,Be(o)},setTranslationWorkflowOptions:(n,a)=>{const o=T(a,!1,!1);if(!o||!n||typeof n!="object")return!1;const l=c.get(o)||t,s=re.get(o)||Ge(l),i={...s,...n,labels:{...s.labels||{},...n.labels||{}},localeRules:Array.isArray(n.localeRules)?n.localeRules:s.localeRules,locales:Array.isArray(n.locales)?n.locales:s.locales,normalizeText:n.normalizeText||l.normalizeText},d=oe(i);c.set(o,d),re.set(o,i);const g=b(o,d);return typeof n.enableRealtime=="boolean"&&(g.realtimeEnabled=n.enableRealtime),typeof n.sourceLocale=="string"&&n.sourceLocale.trim()&&(g.sourceLocale=A(n.sourceLocale)),typeof n.targetLocale=="string"&&n.targetLocale.trim()&&(g.targetLocale=A(n.targetLocale)),g.snapshot="",L(o,"set-options",!0),R(o),E(o),!0},getTranslationWorkflowState:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;b(o,l);const s=Pe(o);if(typeof n=="function")try{n(s)}catch{}return o.__translationWorkflowState=s,o.dispatchEvent(new CustomEvent("editora:translation-workflow-state",{bubbles:!0,detail:s})),!0}},keymap:{"Mod-Alt-Shift-l":"toggleTranslationWorkflowPanel","Mod-Alt-Shift-L":"toggleTranslationWorkflowPanel","Mod-Alt-Shift-v":"runTranslationLocaleValidation","Mod-Alt-Shift-V":"runTranslationLocaleValidation","Mod-Alt-Shift-k":"toggleTranslationSegmentLock","Mod-Alt-Shift-K":"toggleTranslationSegmentLock"},init:function(a){X+=1;const o=this&&typeof this.__pluginConfig=="object"?{...e,...this.__pluginConfig}:e,l=oe(o);dt(l);const s=T(a?.editorElement?{editorElement:a.editorElement}:void 0,!1,!1);if(!s)return;x=s,r.add(s);const i=b(s,l);c.set(s,l),re.set(s,o),i.segments=M(s,l,i),L(s,"init",!0),E(s)},destroy:()=>{r.forEach(n=>Se(n)),r.clear(),X=Math.max(0,X-1),!(X>0)&&ft()}}};exports.TranslationWorkflowPlugin=mt;
`,document.head.appendChild(e)}const bt=(e={})=>{const t=oe(e),r=new Set;return mt(),{name:"translationWorkflow",toolbar:[{id:"translationWorkflowGroup",label:"Translation Workflow",type:"group",command:"translationWorkflow",items:[{id:"toggleTranslationWorkflowPanel",label:"Translation Workflow",command:"toggleTranslationWorkflowPanel",shortcut:"Mod-Alt-Shift-l",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4 6.5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H8l-4 3V6.5Z" stroke="currentColor" stroke-width="1.6"/><path d="M20 17.5a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2v-1.5" stroke="currentColor" stroke-width="1.6"/><path d="m13 8 2 2m0 0 2-2m-2 2V4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"runTranslationLocaleValidation",label:"Run Locale Validation",command:"runTranslationLocaleValidation",shortcut:"Mod-Alt-Shift-v",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4.5" y="4" width="12" height="16" rx="2" stroke="currentColor" stroke-width="1.6"/><path d="M8 8h5.5M8 11h4M8 14h3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="m15.5 15.5 1.7 1.7 3.3-3.3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"toggleTranslationSegmentLock",label:"Toggle Segment Lock",command:"toggleTranslationSegmentLock",shortcut:"Mod-Alt-Shift-k",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="5" y="10" width="14" height="10" rx="2" stroke="currentColor" stroke-width="1.6"/><path d="M8.5 10V7.5a3.5 3.5 0 1 1 7 0V10" stroke="currentColor" stroke-width="1.6"/><circle cx="12" cy="15" r="1.2" fill="currentColor"/></svg>'},{id:"toggleTranslationRealtime",label:"Toggle Translation Realtime",command:"toggleTranslationRealtime",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4.5 12a7.5 7.5 0 1 1 7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M9.5 19.5H5.5v-4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 8v4l2.5 2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'}]}],commands:{translationWorkflow:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;return b(o,l),c.set(o,l),x=o,he(o),!0},openTranslationWorkflowPanel:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;return b(o,l),c.set(o,l),x=o,he(o),!0},toggleTranslationWorkflowPanel:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;return b(o,l),c.set(o,l),x=o,Oe(o,typeof n=="boolean"?n:void 0)},runTranslationLocaleValidation:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;return b(o,l),c.set(o,l),x=o,L(o,"command",!0),!0},toggleTranslationRealtime:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;return b(o,l),c.set(o,l),x=o,ze(o,typeof n=="boolean"?n:void 0)},toggleTranslationSegmentLock:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;b(o,l),c.set(o,l),x=o;const s=typeof n=="boolean"?n:n?.locked,i=typeof n=="object"?n?.segmentId:void 0;return se(o,i,s)},setTranslationLocales:(n,a)=>{const o=T(a,!1,!1);if(!o||!n||typeof n!="object")return!1;const l=c.get(o)||t,s=b(o,l);return c.set(o,l),typeof n.sourceLocale=="string"&&n.sourceLocale.trim()&&(s.sourceLocale=A(n.sourceLocale)),typeof n.targetLocale=="string"&&n.targetLocale.trim()&&(s.targetLocale=A(n.targetLocale)),s.snapshot="",L(o,"set-locales",!0),!0},captureTranslationSourceSnapshot:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;return b(o,l),c.set(o,l),x=o,De(o)},setTranslationWorkflowOptions:(n,a)=>{const o=T(a,!1,!1);if(!o||!n||typeof n!="object")return!1;const l=c.get(o)||t,s=re.get(o)||Ye(l),i={...s,...n,labels:{...s.labels||{},...n.labels||{}},localeRules:Array.isArray(n.localeRules)?n.localeRules:s.localeRules,locales:Array.isArray(n.locales)?n.locales:s.locales,normalizeText:n.normalizeText||l.normalizeText},d=oe(i);c.set(o,d),re.set(o,i);const g=b(o,d);return typeof n.enableRealtime=="boolean"&&(g.realtimeEnabled=n.enableRealtime),typeof n.sourceLocale=="string"&&n.sourceLocale.trim()&&(g.sourceLocale=A(n.sourceLocale)),typeof n.targetLocale=="string"&&n.targetLocale.trim()&&(g.targetLocale=A(n.targetLocale)),g.snapshot="",L(o,"set-options",!0),R(o),E(o),!0},getTranslationWorkflowState:(n,a)=>{const o=T(a,!1,!1);if(!o)return!1;const l=c.get(o)||t;b(o,l);const s=qe(o);if(typeof n=="function")try{n(s)}catch{}return o.__translationWorkflowState=s,o.dispatchEvent(new CustomEvent("editora:translation-workflow-state",{bubbles:!0,detail:s})),!0}},keymap:{"Mod-Alt-Shift-l":"toggleTranslationWorkflowPanel","Mod-Alt-Shift-L":"toggleTranslationWorkflowPanel","Mod-Alt-Shift-v":"runTranslationLocaleValidation","Mod-Alt-Shift-V":"runTranslationLocaleValidation","Mod-Alt-Shift-k":"toggleTranslationSegmentLock","Mod-Alt-Shift-K":"toggleTranslationSegmentLock"},init:function(a){X+=1;const o=this&&typeof this.__pluginConfig=="object"?{...e,...this.__pluginConfig}:e,l=oe(o);ft(l);const s=T(a?.editorElement?{editorElement:a.editorElement}:void 0,!1,!1);if(!s)return;x=s,r.add(s);const i=b(s,l);c.set(s,l),re.set(s,o),i.segments=M(s,l,i),L(s,"init",!0),E(s)},destroy:()=>{r.forEach(n=>Se(n)),r.clear(),X=Math.max(0,X-1),!(X>0)&&gt()}}};exports.TranslationWorkflowPlugin=bt;

@@ -1,2 +0,2 @@

const S = ".rte-content, .editora-content", ke = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", Te = "__editoraCommandEditorRoot", ve = "rte-translation-workflow-styles", u = "rte-translation-workflow-panel", y = "translation-workflow", $ = "translationWorkflow", h = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', $e = [
const S = ".rte-content, .editora-content", ke = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", ve = "__editoraCommandEditorRoot", $e = "rte-translation-workflow-styles", u = "rte-translation-workflow-panel", y = "translation-workflow", $ = "translationWorkflow", h = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', Ee = [
"p",

@@ -14,3 +14,3 @@ "h1",

"figcaption"
].join(", "), Me = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "Home", "End"]), Ee = [
].join(", "), Ce = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "Home", "End"]), Ae = [
{

@@ -72,3 +72,3 @@ locale: "en",

}
], Oe = {
], _e = {
panelTitle: "Translation Workflow",

@@ -103,7 +103,7 @@ panelAriaLabel: "Translation workflow panel",

}, c = /* @__PURE__ */ new WeakMap(), re = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new Map(), j = /* @__PURE__ */ new WeakMap(), le = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new Set();
let X = 0, _e = 0, Ae = 0, Fe = 0, k = null, x = null, D = null, z = null, N = null, O = null, I = null, _ = null;
let X = 0, Fe = 0, Re = 0, We = 0, k = null, x = null, D = null, z = null, N = null, O = null, I = null, _ = null;
function m(e) {
return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
}
function We(e) {
function Ke(e) {
return e.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();

@@ -120,14 +120,14 @@ }

}
function Ke(e) {
function Ve(e) {
return e.replace(/"/g, "&quot;");
}
function Ve(e, t = 120) {
function je(e, t = 120) {
return e.length <= t ? e : `${e.slice(0, Math.max(0, t - 1)).trimEnd()}…`;
}
function Re(e) {
function Ie(e) {
const t = e.match(/\{\{[^{}]+\}\}|%[A-Z0-9_]+%|\$\{[^{}]+\}/gi);
return !t || t.length === 0 ? [] : t.map((r) => r.trim()).filter(Boolean);
}
function je(e, t) {
const r = Re(e).sort(), n = Re(t).sort();
function Ue(e, t) {
const r = Ie(e).sort(), n = Ie(t).sort();
if (r.length !== n.length) return !1;

@@ -138,4 +138,4 @@ for (let a = 0; a < r.length; a += 1)

}
function Ue(e, t) {
const r = Array.isArray(t) && t.length > 0 ? t : Ee, n = [], a = /* @__PURE__ */ new Set();
function Ge(e, t) {
const r = Array.isArray(t) && t.length > 0 ? t : Ae, n = [], a = /* @__PURE__ */ new Set();
return r.forEach((o) => {

@@ -156,3 +156,3 @@ const l = W(o.locale || "");

if (a.has(l)) return;
const s = Ee.find((i) => l.startsWith(i.locale));
const s = Ae.find((i) => l.startsWith(i.locale));
n.push(

@@ -171,3 +171,3 @@ s ? { ...s, locale: l, label: o } : {

function oe(e = {}) {
const t = e.normalizeText || We, r = A(e.sourceLocale || "en-US"), n = A(e.targetLocale || "fr-FR"), a = /* @__PURE__ */ new Set([r, n]);
const t = e.normalizeText || Ke, r = A(e.sourceLocale || "en-US"), n = A(e.targetLocale || "fr-FR"), a = /* @__PURE__ */ new Set([r, n]);
(Array.isArray(e.locales) ? e.locales : []).forEach((s) => {

@@ -178,3 +178,3 @@ if (typeof s != "string") return;

});
const o = Array.from(a), l = Ue(o, e.localeRules);
const o = Array.from(a), l = Ge(o, e.localeRules);
return {

@@ -190,5 +190,5 @@ sourceLocale: r,

minSourceLengthForRatio: C(Number(e.minSourceLengthForRatio ?? 8), 2, 100),
segmentSelector: (e.segmentSelector || $e).trim() || $e,
segmentSelector: (e.segmentSelector || Ee).trim() || Ee,
labels: {
...Oe,
..._e,
...e.labels || {}

@@ -199,3 +199,3 @@ },

}
function Ge(e) {
function Ye(e) {
return {

@@ -232,7 +232,7 @@ sourceLocale: e.sourceLocale,

}
function Ye() {
function Ze() {
if (typeof window > "u") return null;
const e = window[Te];
const e = window[ve];
if (!(e instanceof HTMLElement)) return null;
window[Te] = null;
window[ve] = null;
const t = K(e);

@@ -248,3 +248,3 @@ if (t) return t;

}
function Ze(e) {
function Je(e) {
const t = e.closest("[data-editora-editor]");

@@ -261,3 +261,3 @@ if (t && K(t) === e)

}
function Ce(e) {
function He(e) {
return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;

@@ -268,3 +268,3 @@ }

}
function Je(e) {
function Qe(e) {
const t = xe(e);

@@ -276,5 +276,5 @@ if (ee(t)) return !0;

function ge(e, t) {
e.classList.remove("rte-translation-workflow-theme-dark"), Je(t) && e.classList.add("rte-translation-workflow-theme-dark");
e.classList.remove("rte-translation-workflow-theme-dark"), Qe(t) && e.classList.add("rte-translation-workflow-theme-dark");
}
function Qe(e) {
function Xe(e) {
for (let t = 0; t < e.length; t += 1) {

@@ -304,7 +304,7 @@ const r = e[t];

}
const n = Ye();
const n = Ze();
if (n) return n;
const a = window.getSelection();
if (a && a.rangeCount > 0) {
const s = Ce(a.getRangeAt(0).startContainer)?.closest(
const s = He(a.getRangeAt(0).startContainer)?.closest(
S

@@ -326,3 +326,3 @@ );

}
function Xe(e) {
function et(e) {
const t = e.target;

@@ -351,3 +351,3 @@ if (t) {

function fe(e, t, r) {
const n = Ze(e);
const n = Je(e);
Array.from(

@@ -365,3 +365,3 @@ n.querySelectorAll(

}
function et(e, t) {
function tt(e, t) {
const r = W(t), n = e.localeRules.find((l) => W(l.locale) === r);

@@ -380,4 +380,4 @@ if (n) return n;

function te(e, t, r, n = {}) {
return Ae += 1, {
id: `translation-workflow-issue-${Ae}`,
return Re += 1, {
id: `translation-workflow-issue-${Re}`,
type: e,

@@ -404,11 +404,11 @@ severity: t,

function ce(e, t) {
return e.querySelector(`[data-translation-segment-id="${Ke(t)}"]`);
return e.querySelector(`[data-translation-segment-id="${Ve(t)}"]`);
}
function He(e) {
function qe(e) {
const t = window.getSelection();
if (!t || t.rangeCount === 0) return null;
const r = Ce(t.getRangeAt(0).startContainer);
const r = He(t.getRangeAt(0).startContainer);
return !r || !e.contains(r) ? null : r.closest("[data-translation-segment-id]");
}
function tt(e, t) {
function nt(e, t) {
const r = Array.from(e.querySelectorAll(t));

@@ -427,7 +427,7 @@ if (r.length <= 1) return r;

}
function nt(e, t, r) {
function rt(e, t, r) {
let n = (r || "").trim();
if (!n || t.has(n)) {
do
n = `translation-segment-${_e++}`;
n = `translation-segment-${Fe++}`;
while (t.has(n));

@@ -454,5 +454,5 @@ e.setAttribute("data-translation-segment-id", n);

function M(e, t, r) {
const n = tt(e, t.segmentSelector), a = [], o = /* @__PURE__ */ new Set();
const n = nt(e, t.segmentSelector), a = [], o = /* @__PURE__ */ new Set();
for (let l = 0; l < n.length && !(a.length >= t.maxSegments); l += 1) {
const s = n[l], i = nt(s, o, s.getAttribute("data-translation-segment-id")), d = r.lockedSegmentIds.has(i), g = s.getAttribute("data-translation-locked") === "true", w = d || g;
const s = n[l], i = rt(s, o, s.getAttribute("data-translation-segment-id")), d = r.lockedSegmentIds.has(i), g = s.getAttribute("data-translation-locked") === "true", w = d || g;
if (w)

@@ -527,7 +527,7 @@ if (r.lockedSegmentIds.add(i), ie(s, !0), !r.lockedHtmlBySegmentId.has(i))

}
function rt(e, t) {
function ot(e, t) {
return `${e.innerHTML}::${t.sourceLocale}::${t.targetLocale}::${Array.from(t.lockedSegmentIds).sort().join("|")}`;
}
function ot(e, t, r) {
const n = [], a = et(r, t.targetLocale);
function at(e, t, r) {
const n = [], a = tt(r, t.targetLocale);
for (let o = 0; o < e.length && !(n.length >= r.maxIssues); o += 1) {

@@ -546,3 +546,3 @@ const l = e[o], s = r.normalizeText(l.sourceText || ""), i = r.normalizeText(l.text || "");

}
if (a.preserveTokens && s && !je(s, i) && (n.push(
if (a.preserveTokens && s && !Ue(s, i) && (n.push(
te("token-mismatch", "error", r.labels.tokenMismatchMessage, {

@@ -577,3 +577,3 @@ segmentId: l.id,

}
function qe(e) {
function Be(e) {
const t = c.get(e) || k, r = q.get(e);

@@ -603,3 +603,3 @@ return {

}
function at(e, t) {
function lt(e, t) {
const r = ce(e, t);

@@ -647,4 +647,4 @@ if (!r) return;

Y && (Y.textContent = ue?.locked ? r.labels.unlockSelectedText : r.labels.lockSelectedText, Y.disabled = !ue, Y.setAttribute("aria-pressed", ue?.locked ? "true" : "false"));
const Le = t.querySelector('[data-action="close"]');
Le && Le.setAttribute("aria-label", r.labels.closeText);
const Te = t.querySelector('[data-action="close"]');
Te && Te.setAttribute("aria-label", r.labels.closeText);
const Z = t.querySelector(".rte-translation-issues"), F = t.querySelector(".rte-translation-empty");

@@ -661,5 +661,5 @@ Z && (Z.setAttribute("aria-label", r.labels.issuesLabel), n.issues.length === 0 ? (Z.innerHTML = "", F && (F.hidden = !1, F.textContent = r.labels.noIssuesText)) : (F && (F.hidden = !0), Z.innerHTML = n.issues.map((f) => `

de && (de.setAttribute("aria-label", r.labels.segmentsLabel), de.innerHTML = n.segments.map((f) => {
const P = f.id === n.selectedSegmentId ? "selected" : "", Ne = f.locked ? "locked" : "";
const P = f.id === n.selectedSegmentId ? "selected" : "", Oe = f.locked ? "locked" : "";
return `
<li class="rte-translation-segment-item ${P} ${Ne}" role="option" aria-selected="${f.id === n.selectedSegmentId ? "true" : "false"}" data-segment-id="${m(f.id)}">
<li class="rte-translation-segment-item ${P} ${Oe}" role="option" aria-selected="${f.id === n.selectedSegmentId ? "true" : "false"}" data-segment-id="${m(f.id)}">
<button type="button" class="rte-translation-segment-select" data-action="select-segment" data-segment-id="${m(

@@ -669,3 +669,3 @@ f.id

<span class="rte-translation-segment-meta">#${f.index + 1} • ${m(f.tagName)}</span>
<span class="rte-translation-segment-text">${m(Ve(f.text, 110))}</span>
<span class="rte-translation-segment-text">${m(je(f.text, 110))}</span>
</button>

@@ -685,3 +685,3 @@ <button type="button" class="rte-translation-segment-lock" data-action="toggle-lock" data-segment-id="${m(

}
function Be(e) {
function Pe(e) {
const t = c.get(e) || k;

@@ -700,6 +700,6 @@ if (!t) return;

a.segments = M(e, n, a);
const l = rt(e, a);
const l = ot(e, a);
if (!r && a.snapshot === l)
return a.issues;
a.issues = ot(a.segments, a, n), a.lastRunAt = (/* @__PURE__ */ new Date()).toISOString(), a.snapshot = l, R(e), E(e), e.dispatchEvent(
a.issues = at(a.segments, a, n), a.lastRunAt = (/* @__PURE__ */ new Date()).toISOString(), a.snapshot = l, R(e), E(e), e.dispatchEvent(
new CustomEvent("editora:translation-workflow-validation", {

@@ -709,3 +709,3 @@ bubbles: !0,

reason: t,
state: qe(e)
state: Be(e)
}

@@ -725,3 +725,3 @@ })

}
function Pe(e) {
function De(e) {
const t = c.get(e) || k;

@@ -749,3 +749,3 @@ if (!t) return !1;

a.segments = M(e, n, a);
const o = He(e)?.getAttribute("data-translation-segment-id") || null, l = t || o || a.selectedSegmentId || a.segments[0]?.id || null;
const o = qe(e)?.getAttribute("data-translation-segment-id") || null, l = t || o || a.selectedSegmentId || a.segments[0]?.id || null;
if (!l) return !1;

@@ -765,7 +765,7 @@ const s = ce(e, l);

}
function De(e, t) {
function ze(e, t) {
const r = c.get(e) || k;
if (!r) return !1;
const n = b(e, r), a = typeof t == "boolean" ? t : !n.realtimeEnabled;
return n.realtimeEnabled = a, a ? Be(e) : we(e), R(e), E(e), !0;
return n.realtimeEnabled = a, a ? Pe(e) : we(e), R(e), E(e), !0;
}

@@ -776,3 +776,3 @@ function pe(e, t, r = !0) {

const a = b(e, n);
return a.segments = M(e, n, a), a.segments.some((o) => o.id === t) ? (a.selectedSegmentId = t, R(e), E(e), r && at(e, t), !0) : !1;
return a.segments = M(e, n, a), a.segments.some((o) => o.id === t) ? (a.selectedSegmentId = t, R(e), E(e), r && lt(e, t), !0) : !1;
}

@@ -798,3 +798,3 @@ function ne(e, t) {

function he(e) {
const t = ut(e);
const t = dt(e);
p.forEach((n, a) => {

@@ -804,25 +804,28 @@ a !== e && V(a, !1);

}
function ze(e, t) {
function Ne(e, t) {
const r = ye(e);
return (typeof t == "boolean" ? t : !r) ? he(e) : V(e, !1), !0;
}
function lt(e) {
const t = e.key.toLowerCase();
function Le(e) {
return typeof e.key == "string" ? e.key.toLowerCase() : "";
}
function st(e) {
const t = Le(e);
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "l";
}
function st(e) {
const t = e.key.toLowerCase();
function it(e) {
const t = Le(e);
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "v";
}
function it(e) {
const t = e.key.toLowerCase();
function ct(e) {
const t = Le(e);
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "k";
}
function ct(e) {
function ut(e) {
return e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey ? !0 : e.key === "Backspace" || e.key === "Delete" || e.key === "Enter";
}
function Ie(e) {
function Me(e) {
return e instanceof HTMLElement ? e.closest('[data-translation-locked="true"]') : null;
}
function ut(e) {
function dt(e) {
const t = p.get(e);

@@ -832,3 +835,3 @@ if (t) return t;

b(e, r);
const n = `rte-translation-workflow-panel-${Fe++}`, a = `${n}-source`, o = `${n}-target`, l = document.createElement("section");
const n = `rte-translation-workflow-panel-${We++}`, a = `${n}-source`, o = `${n}-target`, l = document.createElement("section");
return l.className = u, l.id = n, l.setAttribute("role", "dialog"), l.setAttribute("aria-modal", "false"), l.setAttribute("aria-label", r.labels.panelAriaLabel), l.innerHTML = `

@@ -908,3 +911,3 @@ <header class="rte-translation-header">

if (g === "capture-source") {
Pe(e);
De(e);
return;

@@ -917,3 +920,3 @@ }

if (g === "toggle-realtime") {
De(e);
ze(e);
return;

@@ -947,6 +950,6 @@ }

}
!i?.closest(".rte-translation-segments") || !Me.has(s.key) || (s.preventDefault(), s.key === "ArrowUp" ? ne(e, -1) : s.key === "ArrowDown" ? ne(e, 1) : s.key === "Home" ? ne(e, "start") : s.key === "End" && ne(e, "end"));
!i?.closest(".rte-translation-segments") || !Ce.has(s.key) || (s.preventDefault(), s.key === "ArrowUp" ? ne(e, -1) : s.key === "ArrowDown" ? ne(e, 1) : s.key === "Home" ? ne(e, "start") : s.key === "End" && ne(e, "end"));
}), ge(l, e), document.body.appendChild(l), p.set(e, l), j.set(e, !1), R(e), l;
}
function dt(e) {
function ft(e) {
k = e, D || (D = (t) => {

@@ -958,3 +961,3 @@ ae();

c.set(n, a), x = n;
const l = He(n)?.getAttribute("data-translation-segment-id") || null;
const l = qe(n)?.getAttribute("data-translation-segment-id") || null;
l && (o.selectedSegmentId = l), E(n);

@@ -977,7 +980,7 @@ const s = p.get(n);

}
Be(n);
Pe(n);
}, document.addEventListener("input", z, !0)), N || (N = (t) => {
const r = t, n = r.target, a = n?.closest(S);
if (!a) return;
const o = Ie(n);
const o = Me(n);
if (!o || !a.contains(o)) return;

@@ -990,7 +993,7 @@ r.preventDefault();

const r = t.target;
if (r?.closest(`.${u}`) && t.key !== "Escape" && !Me.has(t.key)) return;
const a = t.key === "Escape", o = lt(t), l = st(t), s = it(t), i = Ie(r);
if (r?.closest(`.${u}`) && t.key !== "Escape" && !Ce.has(t.key)) return;
const a = t.key === "Escape", o = st(t), l = it(t), s = ct(t), i = Me(r);
if (!a && !o && !l && !s && !i)
return;
const d = Xe(t);
const d = et(t);
if (!d) return;

@@ -1002,3 +1005,3 @@ const g = c.get(d) || k || e;

}
if (i && d.contains(i) && ct(t)) {
if (i && d.contains(i) && ut(t)) {
t.preventDefault();

@@ -1010,3 +1013,3 @@ const w = p.get(d);

if (o) {
t.preventDefault(), t.stopPropagation(), ze(d);
t.preventDefault(), t.stopPropagation(), Ne(d);
return;

@@ -1024,3 +1027,3 @@ }

}, window.addEventListener("scroll", I, !0), window.addEventListener("resize", I)), !_ && typeof MutationObserver < "u" && document.body && (_ = new MutationObserver((t) => {
Qe(t) && ae(), t.some((n) => n.type === "characterData" ? !0 : n.type === "childList" && (n.addedNodes.length > 0 || n.removedNodes.length > 0)) && U.forEach((n) => {
Xe(t) && ae(), t.some((n) => n.type === "characterData" ? !0 : n.type === "childList" && (n.addedNodes.length > 0 || n.removedNodes.length > 0)) && U.forEach((n) => {
const a = q.get(n);

@@ -1038,9 +1041,9 @@ if (!a || a.lockedSegmentIds.size === 0 || !me(n, a)) return;

}
function ft() {
function gt() {
D && (document.removeEventListener("focusin", D, !0), D = null), z && (document.removeEventListener("input", z, !0), z = null), N && (document.removeEventListener("beforeinput", N, !0), N = null), O && (document.removeEventListener("keydown", O, !0), O = null), I && (window.removeEventListener("scroll", I, !0), window.removeEventListener("resize", I), I = null), _ && (_.disconnect(), _ = null), p.forEach((t) => t.remove()), p.clear(), Array.from(U).forEach((t) => Se(t)), k = null, x = null;
}
function gt() {
if (typeof document > "u" || document.getElementById(ve)) return;
function mt() {
if (typeof document > "u" || document.getElementById($e)) return;
const e = document.createElement("style");
e.id = ve, e.textContent = `
e.id = $e, e.textContent = `
.rte-toolbar-group-items.${y},

@@ -1610,5 +1613,5 @@ .editora-toolbar-group-items.${y},

}
const mt = (e = {}) => {
const bt = (e = {}) => {
const t = oe(e), r = /* @__PURE__ */ new Set();
return gt(), {
return mt(), {
name: "translationWorkflow",

@@ -1669,3 +1672,3 @@ toolbar: [

const l = c.get(o) || t;
return b(o, l), c.set(o, l), x = o, ze(o, typeof n == "boolean" ? n : void 0);
return b(o, l), c.set(o, l), x = o, Ne(o, typeof n == "boolean" ? n : void 0);
},

@@ -1682,3 +1685,3 @@ runTranslationLocaleValidation: (n, a) => {

const l = c.get(o) || t;
return b(o, l), c.set(o, l), x = o, De(o, typeof n == "boolean" ? n : void 0);
return b(o, l), c.set(o, l), x = o, ze(o, typeof n == "boolean" ? n : void 0);
},

@@ -1703,3 +1706,3 @@ toggleTranslationSegmentLock: (n, a) => {

const l = c.get(o) || t;
return b(o, l), c.set(o, l), x = o, Pe(o);
return b(o, l), c.set(o, l), x = o, De(o);
},

@@ -1709,3 +1712,3 @@ setTranslationWorkflowOptions: (n, a) => {

if (!o || !n || typeof n != "object") return !1;
const l = c.get(o) || t, s = re.get(o) || Ge(l), i = {
const l = c.get(o) || t, s = re.get(o) || Ye(l), i = {
...s,

@@ -1730,3 +1733,3 @@ ...n,

b(o, l);
const s = qe(o);
const s = Be(o);
if (typeof n == "function")

@@ -1756,3 +1759,3 @@ try {

const o = this && typeof this.__pluginConfig == "object" ? { ...e, ...this.__pluginConfig } : e, l = oe(o);
dt(l);
ft(l);
const s = T(

@@ -1769,3 +1772,3 @@ a?.editorElement ? { editorElement: a.editorElement } : void 0,

destroy: () => {
r.forEach((n) => Se(n)), r.clear(), X = Math.max(0, X - 1), !(X > 0) && ft();
r.forEach((n) => Se(n)), r.clear(), X = Math.max(0, X - 1), !(X > 0) && gt();
}

@@ -1775,3 +1778,3 @@ };

export {
mt as TranslationWorkflowPlugin
bt as TranslationWorkflowPlugin
};

@@ -1,1 +0,1 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=()=>({name:"underline",marks:{underline:{parseDOM:[{tag:"u"}],toDOM:()=>["u",{},0]}},toolbar:[{label:"Underline",command:"toggleUnderline",icon:'<svg width="24" height="24" focusable="false"><path d="M16 5c.6 0 1 .4 1 1v7c0 2.8-2.2 5-5 5s-5-2.2-5-5V6c0-.6.4-1 1-1s1 .4 1 1v7c0 1.7 1.3 3 3 3s3-1.3 3-3V6c0-.6.4-1 1-1ZM4 17h16c.6 0 1 .4 1 1s-.4 1-1 1H4a1 1 0 1 1 0-2Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-u"}],commands:{toggleUnderline:()=>(document.execCommand("underline",!1),!0)},keymap:{"Mod-u":"toggleUnderline","Mod-U":"toggleUnderline"}});exports.UnderlinePlugin=e;
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("./inlineFormatting-DOYOJdnD.js"),l=()=>({name:"underline",marks:{underline:{parseDOM:[{tag:"u"}],toDOM:()=>["u",{},0]}},toolbar:[{label:"Underline",command:"toggleUnderline",icon:'<svg width="24" height="24" focusable="false"><path d="M16 5c.6 0 1 .4 1 1v7c0 2.8-2.2 5-5 5s-5-2.2-5-5V6c0-.6.4-1 1-1s1 .4 1 1v7c0 1.7 1.3 3 3 3s3-1.3 3-3V6c0-.6.4-1 1-1ZM4 17h16c.6 0 1 .4 1 1s-.4 1-1 1H4a1 1 0 1 1 0-2Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-u"}],commands:{toggleUnderline:(i,e)=>n.applyInlineFormatting({command:"underline",context:e})},keymap:{"Mod-u":"toggleUnderline","Mod-U":"toggleUnderline"}});exports.UnderlinePlugin=l;

@@ -1,2 +0,3 @@

const e = () => ({
import { a as n } from "./inlineFormatting-DuVTGXYG.mjs";
const a = () => ({
name: "underline",

@@ -24,3 +25,6 @@ // Schema definition for underline mark

*/
toggleUnderline: () => (document.execCommand("underline", !1), !0)
toggleUnderline: (l, e) => n({
command: "underline",
context: e
})
},

@@ -34,3 +38,3 @@ // Keyboard shortcuts

export {
e as UnderlinePlugin
a as UnderlinePlugin
};
{
"name": "@editora/plugins",
"version": "1.0.12",
"version": "1.0.13",
"description": "Enterprise plugin suite for Editora rich text editor in React and web apps, including tables, media, workflow, and compliance tooling.",

@@ -425,3 +425,3 @@ "author": "Ajay Kumar <ajaykr089@gmail.com>",

"peerDependencies": {
"@editora/core": "^1.0.9"
"@editora/core": "^1.0.10"
},

@@ -433,3 +433,3 @@ "dependencies": {

"devDependencies": {
"@editora/core": "^1.0.9",
"@editora/core": "^1.0.10",
"@types/katex": "^0.16.8",

@@ -436,0 +436,0 @@ "typescript": "^5.0.0",