@editora/plugins 1.0.9 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/README.md +5 -0
  2. package/dist/_commonjsHelpers-6763f629.js +1 -0
  3. package/dist/_commonjsHelpers-c5d32002.mjs +30 -0
  4. package/dist/a11y-checker.cjs.js +12 -12
  5. package/dist/a11y-checker.esm.js +98 -80
  6. package/dist/anchor.cjs.js +12 -12
  7. package/dist/anchor.esm.js +128 -115
  8. package/dist/anchoredPopover-33f1358d.mjs +109 -0
  9. package/dist/anchoredPopover-8151d535.js +1 -0
  10. package/dist/approval-workflow.cjs.js +40 -40
  11. package/dist/approval-workflow.esm.js +249 -208
  12. package/dist/background-color.cjs.js +2 -2
  13. package/dist/background-color.esm.js +68 -55
  14. package/dist/blockquote.esm.js +2 -1
  15. package/dist/blocks-library.cjs.js +45 -45
  16. package/dist/blocks-library.esm.js +245 -178
  17. package/dist/capitalization.esm.js +2 -1
  18. package/dist/checklist.cjs.js +1 -1
  19. package/dist/checklist.esm.js +82 -58
  20. package/dist/citations.cjs.js +37 -37
  21. package/dist/citations.esm.js +512 -439
  22. package/dist/clear-formatting.cjs.js +1 -1
  23. package/dist/clear-formatting.esm.js +33 -27
  24. package/dist/code-sample.cjs.js +14 -14
  25. package/dist/code-sample.esm.js +93 -82
  26. package/dist/code.cjs.js +32 -32
  27. package/dist/code.esm.js +653 -594
  28. package/dist/comments.cjs.js +6 -6
  29. package/dist/comments.esm.js +158 -116
  30. package/dist/conditional-content.cjs.js +90 -90
  31. package/dist/conditional-content.esm.js +432 -371
  32. package/dist/content-rules.cjs.js +7 -7
  33. package/dist/content-rules.esm.js +159 -105
  34. package/dist/data-binding.cjs.js +46 -46
  35. package/dist/data-binding.esm.js +368 -328
  36. package/dist/direction.esm.js +18 -9
  37. package/dist/doc-schema.cjs.js +29 -29
  38. package/dist/doc-schema.esm.js +308 -240
  39. package/dist/document-manager.cjs.js +1 -1
  40. package/dist/document-manager.esm.js +5 -4
  41. package/dist/documentManager-25b6203c.mjs +9122 -0
  42. package/dist/documentManager-b69e7054.js +17 -0
  43. package/dist/{editorContainerHelpers-C7kdWnS0.mjs → editorContainerHelpers-69585c07.mjs} +2 -1
  44. package/dist/embed-iframe.cjs.js +4 -4
  45. package/dist/embed-iframe.esm.js +81 -73
  46. package/dist/emojis.cjs.js +8 -8
  47. package/dist/emojis.esm.js +77 -65
  48. package/dist/enterprise.cjs.js +1 -1
  49. package/dist/enterprise.esm.js +56 -54
  50. package/dist/font-family.cjs.js +1 -1
  51. package/dist/font-family.esm.js +47 -39
  52. package/dist/font-size.cjs.js +1 -1
  53. package/dist/font-size.esm.js +53 -37
  54. package/dist/footnote.cjs.js +2 -2
  55. package/dist/footnote.esm.js +117 -76
  56. package/dist/history.cjs.js +1 -1
  57. package/dist/history.esm.js +92 -70
  58. package/dist/html2canvas.esm-09133e29.js +22 -0
  59. package/dist/{html2canvas.esm-BWVIUcAF.mjs → html2canvas.esm-1a1724a1.mjs} +225 -141
  60. package/dist/indent.cjs.js +1 -1
  61. package/dist/indent.esm.js +24 -12
  62. package/dist/index-656d224b.js +231 -0
  63. package/dist/index-6a8c48bb.js +1 -0
  64. package/dist/index-d027b7e2.mjs +16859 -0
  65. package/dist/{index-BFsKNTTj.mjs → index-f04538f2.mjs} +71 -70
  66. package/dist/index.cjs.js +1 -1
  67. package/dist/index.es-730f2d98.mjs +5775 -0
  68. package/dist/index.es-dd40173b.js +18 -0
  69. package/dist/index.esm.js +128 -125
  70. package/dist/italic.cjs.js +1 -1
  71. package/dist/italic.esm.js +9 -8
  72. package/dist/jspdf.es.min-90db2c97.js +243 -0
  73. package/dist/{jspdf.es.min-DQCoX5yh.mjs → jspdf.es.min-c36a4fd8.mjs} +4682 -3658
  74. package/dist/line-height.cjs.js +1 -1
  75. package/dist/line-height.esm.js +24 -11
  76. package/dist/link.cjs.js +5 -5
  77. package/dist/link.esm.js +30 -24
  78. package/dist/list.cjs.js +1 -1
  79. package/dist/list.esm.js +25 -20
  80. package/dist/lite.cjs.js +1 -1
  81. package/dist/lite.esm.js +61 -59
  82. package/dist/math.cjs.js +21 -21
  83. package/dist/math.esm.js +146 -139
  84. package/dist/media-manager.cjs.js +38 -38
  85. package/dist/media-manager.esm.js +325 -308
  86. package/dist/mentions.cjs.js +9 -9
  87. package/dist/mentions.esm.js +286 -238
  88. package/dist/merge-tag.cjs.js +2 -2
  89. package/dist/merge-tag.esm.js +216 -177
  90. package/dist/page-break.cjs.js +2 -2
  91. package/dist/page-break.esm.js +49 -33
  92. package/dist/pii-redaction.cjs.js +19 -19
  93. package/dist/pii-redaction.esm.js +463 -393
  94. package/dist/preview.esm.js +10 -5
  95. package/dist/print.cjs.js +4 -4
  96. package/dist/print.esm.js +20 -17
  97. package/dist/{purify.es-DHhaBdbu.mjs → purify.es-35a15df8.mjs} +19 -9
  98. package/dist/{purify.es-T2a3nLiC.js → purify.es-a8d731c6.js} +1 -1
  99. package/dist/slash-commands.cjs.js +3 -3
  100. package/dist/slash-commands.esm.js +212 -176
  101. package/dist/smart-paste.cjs.js +27 -27
  102. package/dist/smart-paste.esm.js +336 -280
  103. package/dist/special-characters.cjs.js +7 -7
  104. package/dist/special-characters.esm.js +69 -61
  105. package/dist/spell-check.cjs.js +5 -5
  106. package/dist/spell-check.esm.js +123 -97
  107. package/dist/strikethrough.cjs.js +1 -1
  108. package/dist/strikethrough.esm.js +19 -14
  109. package/dist/style.css +1 -0
  110. package/dist/table.cjs.js +4 -4
  111. package/dist/table.esm.js +225 -191
  112. package/dist/template.cjs.js +11 -11
  113. package/dist/template.esm.js +153 -124
  114. package/dist/text-alignment.cjs.js +1 -1
  115. package/dist/text-alignment.esm.js +27 -21
  116. package/dist/text-color.cjs.js +3 -3
  117. package/dist/text-color.esm.js +87 -70
  118. package/dist/track-changes.cjs.js +2 -2
  119. package/dist/track-changes.esm.js +162 -100
  120. package/dist/translation-workflow.cjs.js +74 -74
  121. package/dist/translation-workflow.esm.js +678 -602
  122. package/dist/version-diff.cjs.js +14 -14
  123. package/dist/version-diff.esm.js +157 -128
  124. package/package.json +13 -7
  125. package/LICENSE +0 -21
  126. package/dist/_commonjsHelpers-BH3jXuIh.js +0 -1
  127. package/dist/_commonjsHelpers-ByX85dGu.mjs +0 -33
  128. package/dist/anchoredPopover-BzqGPOAE.js +0 -1
  129. package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
  130. package/dist/documentManager-CTqRftU8.mjs +0 -8369
  131. package/dist/documentManager-Jf0RbSks.js +0 -17
  132. package/dist/html2canvas.esm-B5qzocYs.js +0 -5
  133. package/dist/index-CvJk4DKa.js +0 -221
  134. package/dist/index-D3CycEFU.mjs +0 -16543
  135. package/dist/index-tqLTHcO6.js +0 -1
  136. package/dist/index.es-CE_A4QSm.js +0 -5
  137. package/dist/index.es-DQ78mYYo.mjs +0 -6665
  138. package/dist/jspdf.es.min-BoS80556.js +0 -77
  139. package/dist/plugins.css +0 -1
  140. /package/dist/{editorContainerHelpers-CFbfiOJI.js → editorContainerHelpers-36b8ddf3.js} +0 -0
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d='.rte-page-break[data-type="page-break"]',f=".rte-content, .editora-content";let p=null,m=!1;const h=(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{}},x=new Set(["DIV","P","BLOCKQUOTE","PRE","H1","H2","H3","H4","H5","H6","LI","TD","TH"]),C=()=>{p||typeof document>"u"||(p=document.createElement("style"),p.textContent=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d='.rte-page-break[data-type="page-break"]',f=".rte-content, .editora-content";let p=null,m=!1;const h=(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{}},x=new Set(["DIV","P","BLOCKQUOTE","PRE","H1","H2","H3","H4","H5","H6","LI","TD","TH"]),N=()=>{p||typeof document>"u"||(p=document.createElement("style"),p.textContent=`
2
2
  .rte-page-break {
3
3
  display: block;
4
4
  position: relative;
@@ -69,4 +69,4 @@
69
69
  display: none;
70
70
  }
71
71
  }
72
- `,document.head.appendChild(p))},N=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);return(n.startContainer.nodeType===Node.ELEMENT_NODE?n.startContainer:n.startContainer.parentElement)?.closest(f)||null},v=()=>{const e=N();if(e)return e;const t=document.activeElement?.closest(f);return t||document.querySelector(f)},E=(e,n)=>{let t=e;for(;t&&t!==n;){if(t.nodeType===Node.ELEMENT_NODE){const r=t;if(x.has(r.tagName))return r}t=t.parentNode}return null},T=()=>{const e=document.createElement("div");return e.className="rte-page-break",e.setAttribute("data-page-break","true"),e.setAttribute("data-type","page-break"),e.setAttribute("contenteditable","false"),e.setAttribute("tabindex","0"),e.setAttribute("role","separator"),e.setAttribute("aria-label","Page break"),e},S=e=>{let n=e.nextElementSibling;for(;n&&n.matches(d);){const r=n;n=n.nextElementSibling,r.remove()}let t=e.previousElementSibling;for(;t&&t.matches(d);){const r=t;t=t.previousElementSibling,r.remove()}},w=e=>{const n=e.nextElementSibling;if(n&&!n.matches(d))return n;const t=document.createElement("p");return t.innerHTML="<br>",e.parentNode?.insertBefore(t,e.nextSibling),t},u=e=>{const n=window.getSelection();if(!n)return;const t=document.createRange();e.nodeType,Node.TEXT_NODE,t.setStart(e,0),t.collapse(!0),n.removeAllRanges(),n.addRange(t)},b=e=>{const n=window.getSelection();if(!n)return;const t=document.createRange();if(e.nodeType===Node.TEXT_NODE){const r=e;t.setStart(r,r.data.length)}else t.selectNodeContents(e),t.collapse(!1);n.removeAllRanges(),n.addRange(t)},g=(e,n)=>{let t=e;for(;t;){if(!(t instanceof HTMLElement&&t.matches(d)))return t;t=n==="previous"?t.previousSibling:t.nextSibling}return null},A=e=>{const n=window.getSelection();if(!n||!e.parentNode)return;const t=e.parentNode,r=Array.from(t.childNodes).indexOf(e);if(r<0)return;const o=document.createRange();o.setStart(t,r),o.setEnd(t,r+1),n.removeAllRanges(),n.addRange(o),e.focus({preventScroll:!0})},y=e=>{if(e.collapsed||e.startContainer!==e.endContainer||e.endOffset!==e.startOffset+1||!(e.startContainer instanceof Element||e.startContainer instanceof DocumentFragment))return null;const n=e.startContainer.childNodes[e.startOffset];return n instanceof HTMLElement&&n.matches(d)?n:null},B=(e,n,t)=>{if(!e.collapsed)return null;const{startContainer:r,startOffset:o}=e,a=i=>i instanceof HTMLElement&&i.matches(d)?i:null,c=i=>{if(r.nodeType===Node.ELEMENT_NODE){const l=r;if(i==="previous"){if(o>0)return l.childNodes[o-1]||null}else if(o<l.childNodes.length)return l.childNodes[o]||null}if(r.nodeType===Node.TEXT_NODE&&(i==="previous"&&o<r.data.length||i==="next"&&o>0))return null;let s=r;for(;s&&s!==n;){const l=i==="previous"?s.previousSibling:s.nextSibling;if(l)return l;s=s.parentNode}return null};if(r.nodeType===Node.ELEMENT_NODE){const i=r;return t==="Backspace"&&o>0?a(i.childNodes[o-1]||null):t==="Delete"?a(i.childNodes[o]||null):null}if(r.nodeType===Node.TEXT_NODE){const i=r;if(t==="Backspace"&&o===0){const s=a(i.previousSibling);return s||a(c("previous"))}if(t==="Delete"&&o===i.data.length){const s=a(i.nextSibling);return s||a(c("next"))}}return a(c(t==="Backspace"?"previous":"next"))},k=(e,n)=>{const t=e.closest(f),r=t?.innerHTML??"",o=e.previousSibling,a=e.nextSibling;e.remove();const c=g(o,"previous"),i=g(a,"next");if(n==="Backspace"){if(c)b(c);else if(i)u(i);else if(t){const s=document.createElement("p");s.innerHTML="<br>",t.appendChild(s),u(s)}}else if(i)u(i);else if(c)b(c);else if(t){const s=document.createElement("p");s.innerHTML="<br>",t.appendChild(s),u(s)}return t&&(h(t,r),t.dispatchEvent(new Event("input",{bubbles:!0}))),!0},P=()=>{const e=v();if(!e)return!1;const n=e.innerHTML,t=window.getSelection();if(!t)return!1;let r;t.rangeCount>0&&e.contains(t.getRangeAt(0).commonAncestorContainer)?r=t.getRangeAt(0):(r=document.createRange(),r.selectNodeContents(e),r.collapse(!1),t.removeAllRanges(),t.addRange(r));const o=E(r.endContainer,e)||E(r.startContainer,e),a=T();o&&o.parentNode?o.parentNode.insertBefore(a,o.nextSibling):e.appendChild(a),S(a);const c=w(a);return u(c),h(e,n),e.dispatchEvent(new Event("input",{bubbles:!0})),!0},D=()=>{m||typeof document>"u"||(m=!0,document.addEventListener("click",e=>{const t=e.target?.closest(d);t&&(e.preventDefault(),e.stopPropagation(),A(t))}),document.addEventListener("keydown",e=>{const n=e.key;if(!["Backspace","Delete","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(n))return;const t=window.getSelection();if(!t||t.rangeCount===0)return;const r=t.getRangeAt(0),o=v();if(!o||!o.contains(r.commonAncestorContainer))return;const a=y(r);if(a){if(n==="Backspace"||n==="Delete"){e.preventDefault(),e.stopPropagation(),k(a,n);return}if(n==="ArrowRight"||n==="ArrowDown"){e.preventDefault();const c=g(a.nextSibling,"next")||w(a);u(c);return}if(n==="ArrowLeft"||n==="ArrowUp"){e.preventDefault();const c=g(a.previousSibling,"previous");c?b(c):u(o);return}}if(n==="Backspace"||n==="Delete"){const c=B(r,o,n);if(!c)return;e.preventDefault(),e.stopPropagation(),k(c,n)}}))},R=()=>(C(),D(),{name:"pageBreak",toolbar:[{label:"Page Break",command:"insertPageBreak",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M5 5H19" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"/><path d="M5 9H19" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"/><path d="M5 15H19" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-dasharray="3.2 3.2"/><path d="M5 19H19" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"/></svg>',shortcut:"Mod-Enter"}],commands:{insertPageBreak:P},keymap:{"Mod-Enter":"insertPageBreak"}});exports.PageBreakPlugin=R;
72
+ `,document.head.appendChild(p))},T=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0),t=n.startContainer.nodeType===Node.ELEMENT_NODE?n.startContainer:n.startContainer.parentElement;return(t==null?void 0:t.closest(f))||null},v=()=>{const e=T();if(e)return e;const n=document.activeElement,t=n==null?void 0:n.closest(f);return t||document.querySelector(f)},E=(e,n)=>{let t=e;for(;t&&t!==n;){if(t.nodeType===Node.ELEMENT_NODE){const r=t;if(x.has(r.tagName))return r}t=t.parentNode}return null},C=()=>{const e=document.createElement("div");return e.className="rte-page-break",e.setAttribute("data-page-break","true"),e.setAttribute("data-type","page-break"),e.setAttribute("contenteditable","false"),e.setAttribute("tabindex","0"),e.setAttribute("role","separator"),e.setAttribute("aria-label","Page break"),e},S=e=>{let n=e.nextElementSibling;for(;n&&n.matches(d);){const r=n;n=n.nextElementSibling,r.remove()}let t=e.previousElementSibling;for(;t&&t.matches(d);){const r=t;t=t.previousElementSibling,r.remove()}},w=e=>{var r;const n=e.nextElementSibling;if(n&&!n.matches(d))return n;const t=document.createElement("p");return t.innerHTML="<br>",(r=e.parentNode)==null||r.insertBefore(t,e.nextSibling),t},u=e=>{const n=window.getSelection();if(!n)return;const t=document.createRange();e.nodeType,Node.TEXT_NODE,t.setStart(e,0),t.collapse(!0),n.removeAllRanges(),n.addRange(t)},b=e=>{const n=window.getSelection();if(!n)return;const t=document.createRange();if(e.nodeType===Node.TEXT_NODE){const r=e;t.setStart(r,r.data.length)}else t.selectNodeContents(e),t.collapse(!1);n.removeAllRanges(),n.addRange(t)},g=(e,n)=>{let t=e;for(;t;){if(!(t instanceof HTMLElement&&t.matches(d)))return t;t=n==="previous"?t.previousSibling:t.nextSibling}return null},A=e=>{const n=window.getSelection();if(!n||!e.parentNode)return;const t=e.parentNode,r=Array.from(t.childNodes).indexOf(e);if(r<0)return;const o=document.createRange();o.setStart(t,r),o.setEnd(t,r+1),n.removeAllRanges(),n.addRange(o),e.focus({preventScroll:!0})},y=e=>{if(e.collapsed||e.startContainer!==e.endContainer||e.endOffset!==e.startOffset+1||!(e.startContainer instanceof Element||e.startContainer instanceof DocumentFragment))return null;const n=e.startContainer.childNodes[e.startOffset];return n instanceof HTMLElement&&n.matches(d)?n:null},B=(e,n,t)=>{if(!e.collapsed)return null;const{startContainer:r,startOffset:o}=e,a=i=>i instanceof HTMLElement&&i.matches(d)?i:null,c=i=>{if(r.nodeType===Node.ELEMENT_NODE){const l=r;if(i==="previous"){if(o>0)return l.childNodes[o-1]||null}else if(o<l.childNodes.length)return l.childNodes[o]||null}if(r.nodeType===Node.TEXT_NODE&&(i==="previous"&&o<r.data.length||i==="next"&&o>0))return null;let s=r;for(;s&&s!==n;){const l=i==="previous"?s.previousSibling:s.nextSibling;if(l)return l;s=s.parentNode}return null};if(r.nodeType===Node.ELEMENT_NODE){const i=r;return t==="Backspace"&&o>0?a(i.childNodes[o-1]||null):t==="Delete"?a(i.childNodes[o]||null):null}if(r.nodeType===Node.TEXT_NODE){const i=r;if(t==="Backspace"&&o===0){const s=a(i.previousSibling);return s||a(c("previous"))}if(t==="Delete"&&o===i.data.length){const s=a(i.nextSibling);return s||a(c("next"))}}return a(c(t==="Backspace"?"previous":"next"))},k=(e,n)=>{const t=e.closest(f),r=(t==null?void 0:t.innerHTML)??"",o=e.previousSibling,a=e.nextSibling;e.remove();const c=g(o,"previous"),i=g(a,"next");if(n==="Backspace"){if(c)b(c);else if(i)u(i);else if(t){const s=document.createElement("p");s.innerHTML="<br>",t.appendChild(s),u(s)}}else if(i)u(i);else if(c)b(c);else if(t){const s=document.createElement("p");s.innerHTML="<br>",t.appendChild(s),u(s)}return t&&(h(t,r),t.dispatchEvent(new Event("input",{bubbles:!0}))),!0},P=()=>{const e=v();if(!e)return!1;const n=e.innerHTML,t=window.getSelection();if(!t)return!1;let r;t.rangeCount>0&&e.contains(t.getRangeAt(0).commonAncestorContainer)?r=t.getRangeAt(0):(r=document.createRange(),r.selectNodeContents(e),r.collapse(!1),t.removeAllRanges(),t.addRange(r));const o=E(r.endContainer,e)||E(r.startContainer,e),a=C();o&&o.parentNode?o.parentNode.insertBefore(a,o.nextSibling):e.appendChild(a),S(a);const c=w(a);return u(c),h(e,n),e.dispatchEvent(new Event("input",{bubbles:!0})),!0},D=()=>{m||typeof document>"u"||(m=!0,document.addEventListener("click",e=>{const n=e.target,t=n==null?void 0:n.closest(d);t&&(e.preventDefault(),e.stopPropagation(),A(t))}),document.addEventListener("keydown",e=>{const n=e.key;if(!["Backspace","Delete","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(n))return;const t=window.getSelection();if(!t||t.rangeCount===0)return;const r=t.getRangeAt(0),o=v();if(!o||!o.contains(r.commonAncestorContainer))return;const a=y(r);if(a){if(n==="Backspace"||n==="Delete"){e.preventDefault(),e.stopPropagation(),k(a,n);return}if(n==="ArrowRight"||n==="ArrowDown"){e.preventDefault();const c=g(a.nextSibling,"next")||w(a);u(c);return}if(n==="ArrowLeft"||n==="ArrowUp"){e.preventDefault();const c=g(a.previousSibling,"previous");c?b(c):u(o);return}}if(n==="Backspace"||n==="Delete"){const c=B(r,o,n);if(!c)return;e.preventDefault(),e.stopPropagation(),k(c,n)}}))},R=()=>(N(),D(),{name:"pageBreak",toolbar:[{label:"Page Break",command:"insertPageBreak",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M5 5H19" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"/><path d="M5 9H19" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"/><path d="M5 15H19" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-dasharray="3.2 3.2"/><path d="M5 19H19" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"/></svg>',shortcut:"Mod-Enter"}],commands:{insertPageBreak:P},keymap:{"Mod-Enter":"insertPageBreak"}});exports.PageBreakPlugin=R;
@@ -1,7 +1,8 @@
1
1
  const u = '.rte-page-break[data-type="page-break"]', f = ".rte-content, .editora-content";
2
2
  let p = null, m = !1;
3
3
  const h = (e, n) => {
4
- if (n === e.innerHTML) return;
4
+ if (n === e.innerHTML)
5
+ return;
5
6
  const t = window.execEditorCommand || window.executeEditorCommand;
6
7
  if (typeof t == "function")
7
8
  try {
@@ -22,7 +23,7 @@ const h = (e, n) => {
22
23
  "LI",
23
24
  "TD",
24
25
  "TH"
25
- ]), C = () => {
26
+ ]), N = () => {
26
27
  p || typeof document > "u" || (p = document.createElement("style"), p.textContent = `
27
28
  .rte-page-break {
28
29
  display: block;
@@ -95,15 +96,17 @@ const h = (e, n) => {
95
96
  }
96
97
  }
97
98
  `, document.head.appendChild(p));
98
- }, N = () => {
99
+ }, T = () => {
99
100
  const e = window.getSelection();
100
- if (!e || e.rangeCount === 0) return null;
101
- const n = e.getRangeAt(0);
102
- return (n.startContainer.nodeType === Node.ELEMENT_NODE ? n.startContainer : n.startContainer.parentElement)?.closest(f) || null;
103
- }, v = () => {
104
- const e = N();
105
- if (e) return e;
106
- const t = document.activeElement?.closest(f);
101
+ if (!e || e.rangeCount === 0)
102
+ return null;
103
+ const n = e.getRangeAt(0), t = n.startContainer.nodeType === Node.ELEMENT_NODE ? n.startContainer : n.startContainer.parentElement;
104
+ return (t == null ? void 0 : t.closest(f)) || null;
105
+ }, w = () => {
106
+ const e = T();
107
+ if (e)
108
+ return e;
109
+ const n = document.activeElement, t = n == null ? void 0 : n.closest(f);
107
110
  return t || document.querySelector(f);
108
111
  }, E = (e, n) => {
109
112
  let t = e;
@@ -116,7 +119,7 @@ const h = (e, n) => {
116
119
  t = t.parentNode;
117
120
  }
118
121
  return null;
119
- }, T = () => {
122
+ }, C = () => {
120
123
  const e = document.createElement("div");
121
124
  return e.className = "rte-page-break", e.setAttribute("data-page-break", "true"), e.setAttribute("data-type", "page-break"), e.setAttribute("contenteditable", "false"), e.setAttribute("tabindex", "0"), e.setAttribute("role", "separator"), e.setAttribute("aria-label", "Page break"), e;
122
125
  }, S = (e) => {
@@ -130,20 +133,23 @@ const h = (e, n) => {
130
133
  const r = t;
131
134
  t = t.previousElementSibling, r.remove();
132
135
  }
133
- }, w = (e) => {
136
+ }, v = (e) => {
137
+ var r;
134
138
  const n = e.nextElementSibling;
135
139
  if (n && !n.matches(u))
136
140
  return n;
137
141
  const t = document.createElement("p");
138
- return t.innerHTML = "<br>", e.parentNode?.insertBefore(t, e.nextSibling), t;
142
+ return t.innerHTML = "<br>", (r = e.parentNode) == null || r.insertBefore(t, e.nextSibling), t;
139
143
  }, d = (e) => {
140
144
  const n = window.getSelection();
141
- if (!n) return;
145
+ if (!n)
146
+ return;
142
147
  const t = document.createRange();
143
148
  e.nodeType, Node.TEXT_NODE, t.setStart(e, 0), t.collapse(!0), n.removeAllRanges(), n.addRange(t);
144
149
  }, b = (e) => {
145
150
  const n = window.getSelection();
146
- if (!n) return;
151
+ if (!n)
152
+ return;
147
153
  const t = document.createRange();
148
154
  if (e.nodeType === Node.TEXT_NODE) {
149
155
  const r = e;
@@ -161,17 +167,21 @@ const h = (e, n) => {
161
167
  return null;
162
168
  }, A = (e) => {
163
169
  const n = window.getSelection();
164
- if (!n || !e.parentNode) return;
170
+ if (!n || !e.parentNode)
171
+ return;
165
172
  const t = e.parentNode, r = Array.from(t.childNodes).indexOf(e);
166
- if (r < 0) return;
173
+ if (r < 0)
174
+ return;
167
175
  const o = document.createRange();
168
176
  o.setStart(t, r), o.setEnd(t, r + 1), n.removeAllRanges(), n.addRange(o), e.focus({ preventScroll: !0 });
169
177
  }, y = (e) => {
170
- if (e.collapsed || e.startContainer !== e.endContainer || e.endOffset !== e.startOffset + 1 || !(e.startContainer instanceof Element || e.startContainer instanceof DocumentFragment)) return null;
178
+ if (e.collapsed || e.startContainer !== e.endContainer || e.endOffset !== e.startOffset + 1 || !(e.startContainer instanceof Element || e.startContainer instanceof DocumentFragment))
179
+ return null;
171
180
  const n = e.startContainer.childNodes[e.startOffset];
172
181
  return n instanceof HTMLElement && n.matches(u) ? n : null;
173
182
  }, B = (e, n, t) => {
174
- if (!e.collapsed) return null;
183
+ if (!e.collapsed)
184
+ return null;
175
185
  const { startContainer: r, startOffset: o } = e, a = (i) => i instanceof HTMLElement && i.matches(u) ? i : null, c = (i) => {
176
186
  if (r.nodeType === Node.ELEMENT_NODE) {
177
187
  const l = r;
@@ -186,7 +196,8 @@ const h = (e, n) => {
186
196
  let s = r;
187
197
  for (; s && s !== n; ) {
188
198
  const l = i === "previous" ? s.previousSibling : s.nextSibling;
189
- if (l) return l;
199
+ if (l)
200
+ return l;
190
201
  s = s.parentNode;
191
202
  }
192
203
  return null;
@@ -208,7 +219,7 @@ const h = (e, n) => {
208
219
  }
209
220
  return a(c(t === "Backspace" ? "previous" : "next"));
210
221
  }, k = (e, n) => {
211
- const t = e.closest(f), r = t?.innerHTML ?? "", o = e.previousSibling, a = e.nextSibling;
222
+ const t = e.closest(f), r = (t == null ? void 0 : t.innerHTML) ?? "", o = e.previousSibling, a = e.nextSibling;
212
223
  e.remove();
213
224
  const c = g(o, "previous"), i = g(a, "next");
214
225
  if (n === "Backspace") {
@@ -230,28 +241,32 @@ const h = (e, n) => {
230
241
  }
231
242
  return t && (h(t, r), t.dispatchEvent(new Event("input", { bubbles: !0 }))), !0;
232
243
  }, D = () => {
233
- const e = v();
234
- if (!e) return !1;
244
+ const e = w();
245
+ if (!e)
246
+ return !1;
235
247
  const n = e.innerHTML, t = window.getSelection();
236
- if (!t) return !1;
248
+ if (!t)
249
+ return !1;
237
250
  let r;
238
251
  t.rangeCount > 0 && e.contains(t.getRangeAt(0).commonAncestorContainer) ? r = t.getRangeAt(0) : (r = document.createRange(), r.selectNodeContents(e), r.collapse(!1), t.removeAllRanges(), t.addRange(r));
239
- const o = E(r.endContainer, e) || E(r.startContainer, e), a = T();
252
+ const o = E(r.endContainer, e) || E(r.startContainer, e), a = C();
240
253
  o && o.parentNode ? o.parentNode.insertBefore(a, o.nextSibling) : e.appendChild(a), S(a);
241
- const c = w(a);
254
+ const c = v(a);
242
255
  return d(c), h(e, n), e.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
243
256
  }, R = () => {
244
257
  m || typeof document > "u" || (m = !0, document.addEventListener("click", (e) => {
245
- const t = e.target?.closest(u);
258
+ const n = e.target, t = n == null ? void 0 : n.closest(u);
246
259
  t && (e.preventDefault(), e.stopPropagation(), A(t));
247
260
  }), document.addEventListener("keydown", (e) => {
248
261
  const n = e.key;
249
262
  if (!["Backspace", "Delete", "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(n))
250
263
  return;
251
264
  const t = window.getSelection();
252
- if (!t || t.rangeCount === 0) return;
253
- const r = t.getRangeAt(0), o = v();
254
- if (!o || !o.contains(r.commonAncestorContainer)) return;
265
+ if (!t || t.rangeCount === 0)
266
+ return;
267
+ const r = t.getRangeAt(0), o = w();
268
+ if (!o || !o.contains(r.commonAncestorContainer))
269
+ return;
255
270
  const a = y(r);
256
271
  if (a) {
257
272
  if (n === "Backspace" || n === "Delete") {
@@ -260,7 +275,7 @@ const h = (e, n) => {
260
275
  }
261
276
  if (n === "ArrowRight" || n === "ArrowDown") {
262
277
  e.preventDefault();
263
- const c = g(a.nextSibling, "next") || w(a);
278
+ const c = g(a.nextSibling, "next") || v(a);
264
279
  d(c);
265
280
  return;
266
281
  }
@@ -277,11 +292,12 @@ const h = (e, n) => {
277
292
  o,
278
293
  n
279
294
  );
280
- if (!c) return;
295
+ if (!c)
296
+ return;
281
297
  e.preventDefault(), e.stopPropagation(), k(c, n);
282
298
  }
283
299
  }));
284
- }, P = () => (C(), R(), {
300
+ }, P = () => (N(), R(), {
285
301
  name: "pageBreak",
286
302
  toolbar: [
287
303
  {
@@ -1,28 +1,28 @@
1
- "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`
2
- <li class="rte-pii-redaction-item rte-pii-redaction-item-${s.severity}">
1
+ "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)',pe=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,de=new WeakMap,Q=new WeakMap,m=new Map,V=new WeakMap,W=new Set,j=new Set;let G=0,He=0,ve=0,A=null,g=null,L=null,_=null,D=null,R=null,N=null;function b(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 o=t.length-1;o>=0;o-=1){let i=Number(t[o]);r&&(i*=2,i>9&&(i-=9)),n+=i,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=>{var o;return je(r,(o=e.detectors)==null?void 0:o[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 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 ge(e){return e.closest(ae)||e}function Ze(e){const t=e.closest("[data-editora-editor]");if(t&&z(t)===e)return t;let n=e;for(;n;){if(n.matches(ae)&&(n===e||z(n)===e))return n;n=n.parentElement}return ge(e)}function z(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=z(e);if(t)return t;const n=e.closest(ae);if(n){const o=z(n);if(o)return o}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=ge(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 me(e){const t=te.get(e);typeof t=="number"&&(window.clearTimeout(t),j.delete(t),te.delete(e))}function U(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 q(){Array.from(W).forEach(t=>{t.isConnected||Te(t)})}function Ge(e){var t,n,r,o;for(let i=0;i<e.length;i+=1){const a=e[i];if(!(a.type!=="childList"||a.removedNodes.length===0))for(let l=0;l<a.removedNodes.length;l+=1){const c=a.removedNodes[l];if(c.nodeType!==Node.ELEMENT_NODE)continue;const s=c;if((t=s.matches)!=null&&t.call(s,x)||(n=s.matches)!=null&&n.call(s,`.${u}`)||(r=s.querySelector)!=null&&r.call(s,x)||(o=s.querySelector)!=null&&o.call(s,`.${u}`))return!0}}return!1}function T(e,t=!0){if(q(),(e==null?void 0:e.contentElement)instanceof HTMLElement)return e.contentElement;if((e==null?void 0:e.editorElement)instanceof HTMLElement){const i=e.editorElement,a=z(i);if(a)return a}const n=Ve();if(n)return n;const r=window.getSelection();if(r&&r.rangeCount>0){const i=re(r.getRangeAt(0).startContainer),a=i==null?void 0:i.closest(x);if(a)return a}const o=document.activeElement;if(o){if(o.matches(x))return o;const i=o.closest(x);if(i)return i}return g&&g.isConnected?g:(g&&!g.isConnected&&(g=null),t?document.querySelector(x):null)}function Te(e){var t;me(e),(t=m.get(e))==null||t.remove(),m.delete(e),V.delete(e),f.delete(e),I.delete(e),E.delete(e),S.delete(e),de.delete(e),Q.delete(e),W.delete(e),g===e&&(g=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(i=>{i.classList.toggle("active",n),i.setAttribute("data-active",n?"true":"false"),i.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),W.add(e)}function ie(e){return V.get(e)===!0}function Ie(e,t,n,r){if(!e)return e;if(e.length<=n+r)return t.repeat(e.length);const o=e.slice(0,n),i=r>0?e.slice(e.length-r):"";return`${o}${t.repeat(Math.max(1,e.length-n-r))}${i}`}function se(e,t,n){const r=e.replace(/\D/g,"");if(r.length===0)return e;let o=0;const i=Math.max(0,r.length-n);return e.split("").map(a=>/\d/.test(a)?(o+=1,o<=i?t:a):a).join("")}function Ye(e,t){const n=e.indexOf("@");if(n<=0)return e;const r=e.slice(0,n),o=e.slice(n+1);return r.length<=2?`${r[0]||""}${t}[at]${o}`:`${r[0]}${t.repeat(Math.max(1,r.length-2))}${r[r.length-1]}[at]${o}`}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"?se(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 he(e,t){var n;return t.skipInCodeBlocks?!!((n=e.parentElement)!=null&&n.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 s=c[0]||"",d=c.index,p=d+s.length;s&&p>d&&(!a.validator||a.validator(s))&&r.push({type:a.type,severity:a.severity,value:s,start:d,end:p}),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 i=[];for(let a=0;a<r.length&&!(i.length>=n);a+=1){const l=r[a];Qe({start:l.start,end:l.end},i)||i.push(l)}return i}function ue(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),o=Math.min(e.length,n+28);return ue(e.slice(r,o).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 oe(e,t){const n=e.querySelector(".rte-pii-redaction-live");n&&(n.textContent=t)}function F(e,t,n){const r=t.querySelector('[data-action="toggle-realtime"]');if(!r)return;const o=H(e,n);r.textContent=o?n.labels.realtimeOnText:n.labels.realtimeOffText,r.setAttribute("aria-pressed",o?"true":"false"),C(e,"togglePIIRealtime",o)}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 o=e.querySelector('[data-action="run-scan"]');o&&(o.textContent=t.labels.scanText);const i=e.querySelector('[data-action="redact-all"]');i&&(i.textContent=t.labels.redactAllText);const a=e.querySelector(".rte-pii-redaction-shortcut");a&&(a.textContent=t.labels.shortcutText)}function B(e){const t=m.get(e);if(!t)return;const n=f.get(e)||A;if(!n)return;const r=I.get(e)||[],o=E.get(e)||le(0),i=U(e),a=t.querySelector(".rte-pii-redaction-count"),l=t.querySelector(".rte-pii-redaction-summary"),c=t.querySelector(".rte-pii-redaction-list"),s=t.querySelector('[data-action="redact-all"]');if(!(!a||!l||!c||!s)){if(a.textContent=String(o.total),l.textContent=`${n.labels.summaryPrefix}: ${o.total} | High ${o.high} | Medium ${o.medium} | Low ${o.low} | Redacted ${o.redactedCount}`,s.disabled=i||r.length===0,i?oe(t,n.labels.readonlyRedactionText):oe(t,`${o.total} PII findings detected.`),F(e,t,n),r.length===0){c.innerHTML=`<li class="rte-pii-redaction-empty">${b(n.labels.noFindingsText)}</li>`;return}c.innerHTML=r.map(d=>{const p=d.type.toUpperCase(),M=d.suggestion||"Redact this finding before export/share.",P=`${n.labels.locateText}: ${d.match}`,K=`${n.labels.redactText}: ${d.match}`,y=i?'disabled aria-disabled="true"':"";return`
2
+ <li class="rte-pii-redaction-item rte-pii-redaction-item-${d.severity}">
3
3
  <button
4
4
  type="button"
5
5
  class="rte-pii-redaction-item-btn"
6
6
  data-action="locate-finding"
7
- data-finding-id="${p(s.id)}"
7
+ data-finding-id="${b(d.id)}"
8
8
  data-role="finding-button"
9
- aria-label="${p(B)}"
9
+ aria-label="${b(P)}"
10
10
  >
11
- <span class="rte-pii-redaction-badge">${p(s.severity.toUpperCase())}</span>
12
- <span class="rte-pii-redaction-type">${p(g)}</span>
11
+ <span class="rte-pii-redaction-badge">${b(d.severity.toUpperCase())}</span>
12
+ <span class="rte-pii-redaction-type">${b(p)}</span>
13
13
  </button>
14
- <p class="rte-pii-redaction-line"><strong>${p(n.labels.matchLabel)}:</strong> ${p(ue(s.match,80))}</p>
15
- <p class="rte-pii-redaction-line"><strong>${p(n.labels.maskedLabel)}:</strong> ${p(ue(s.masked,80))}</p>
16
- ${s.excerpt?`<p class="rte-pii-redaction-line"><strong>${p(n.labels.excerptLabel)}:</strong> ${p(s.excerpt)}</p>`:""}
17
- <p class="rte-pii-redaction-help">${p(A)}</p>
14
+ <p class="rte-pii-redaction-line"><strong>${b(n.labels.matchLabel)}:</strong> ${b(ue(d.match,80))}</p>
15
+ <p class="rte-pii-redaction-line"><strong>${b(n.labels.maskedLabel)}:</strong> ${b(ue(d.masked,80))}</p>
16
+ ${d.excerpt?`<p class="rte-pii-redaction-line"><strong>${b(n.labels.excerptLabel)}:</strong> ${b(d.excerpt)}</p>`:""}
17
+ <p class="rte-pii-redaction-help">${b(M)}</p>
18
18
  <div class="rte-pii-redaction-item-actions">
19
- <button type="button" class="rte-pii-redaction-btn" data-action="redact-finding" data-finding-id="${p(s.id)}" aria-label="${p(y)}" ${U}>${p(n.labels.redactText)}</button>
19
+ <button type="button" class="rte-pii-redaction-btn" data-action="redact-finding" data-finding-id="${b(d.id)}" aria-label="${b(K)}" ${y}>${b(n.labels.redactText)}</button>
20
20
  </div>
21
21
  </li>
22
- `}).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=`
22
+ `}).join("")}}function fe(e,t){if(!t.classList.contains("show"))return;const r=ge(e).getBoundingClientRect(),o=Math.min(window.innerWidth-20,390),i=Math.max(10,window.innerWidth-o-10),a=Math.min(Math.max(10,r.right-o),i),l=Math.max(10,Math.min(window.innerHeight-10-280,r.top+10));t.style.width=`${o}px`,t.style.left=`${a}px`,t.style.top=`${l}px`,t.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function H(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 it(e){const t=m.get(e);if(t)return t;const n=f.get(e)||A||ee(),r=`rte-pii-redaction-panel-${He++}`,o=document.createElement("section");return o.className=u,o.id=r,o.setAttribute("role","dialog"),o.setAttribute("aria-modal","false"),o.setAttribute("aria-label",n.labels.panelAriaLabel),o.innerHTML=`
23
23
  <header class="rte-pii-redaction-header">
24
- <h2 class="rte-pii-redaction-title">${p(n.labels.panelTitle)}</h2>
25
- <button type="button" class="rte-pii-redaction-icon-btn" data-action="close" aria-label="${p(n.labels.closeText)}">✕</button>
24
+ <h2 class="rte-pii-redaction-title">${b(n.labels.panelTitle)}</h2>
25
+ <button type="button" class="rte-pii-redaction-icon-btn" data-action="close" aria-label="${b(n.labels.closeText)}">✕</button>
26
26
  </header>
27
27
  <div class="rte-pii-redaction-body">
28
28
  <div class="rte-pii-redaction-topline">
@@ -30,15 +30,15 @@
30
30
  <span class="rte-pii-redaction-count" aria-hidden="true">0</span>
31
31
  </div>
32
32
  <div class="rte-pii-redaction-controls" role="toolbar" aria-label="PII redaction controls">
33
- <button type="button" class="rte-pii-redaction-btn rte-pii-redaction-btn-primary" data-action="run-scan">${p(n.labels.scanText)}</button>
34
- <button type="button" class="rte-pii-redaction-btn" data-action="redact-all">${p(n.labels.redactAllText)}</button>
33
+ <button type="button" class="rte-pii-redaction-btn rte-pii-redaction-btn-primary" data-action="run-scan">${b(n.labels.scanText)}</button>
34
+ <button type="button" class="rte-pii-redaction-btn" data-action="redact-all">${b(n.labels.redactAllText)}</button>
35
35
  <button type="button" class="rte-pii-redaction-btn" data-action="toggle-realtime" aria-pressed="false"></button>
36
36
  </div>
37
37
  <ul class="rte-pii-redaction-list" role="list" aria-label="Detected PII findings"></ul>
38
- <p class="rte-pii-redaction-shortcut">${p(n.labels.shortcutText)}</p>
38
+ <p class="rte-pii-redaction-shortcut">${b(n.labels.shortcutText)}</p>
39
39
  <span class="rte-pii-redaction-live" aria-live="polite"></span>
40
40
  </div>
41
- `,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=`
41
+ `,o.addEventListener("click",i=>{const a=i.target,l=a==null?void 0:a.closest("[data-action]");if(!l)return;const c=l.getAttribute("data-action")||"",s=f.get(e)||A||n;if(f.set(e,s),w(e,s),c==="close"){Z(e,!0);return}if(c==="run-scan"){h(e,s,!0);return}if(c==="toggle-realtime"){const d=!H(e,s);S.set(e,d),F(e,o,s),d&&h(e,s,!0);return}if(c==="redact-all"){xe(e,s);return}if(c==="locate-finding"){const d=l.getAttribute("data-finding-id")||"",p=Pe(e,d);if(!p)return;lt(e,p,s);return}if(c==="redact-finding"){const d=l.getAttribute("data-finding-id")||"";De(e,d,s)}}),o.addEventListener("keydown",i=>{if(i.key==="Escape"){i.preventDefault(),Z(e,!0);return}if(i.key!=="ArrowDown"&&i.key!=="ArrowUp")return;const a=Array.from(o.querySelectorAll('[data-role="finding-button"]'));if(a.length===0)return;const l=document.activeElement,c=a.findIndex(p=>p===l);if(c===-1)return;i.preventDefault();const s=i.key==="ArrowDown"?1:-1,d=(c+s+a.length)%a.length;a[d].focus()}),ne(o,e),document.body.appendChild(o),m.set(e,o),V.set(e,!1),B(e),o}function Z(e,t=!1){const n=m.get(e);n&&(n.classList.remove("show"),V.set(e,!1),C(e,"togglePIIRedactionPanel",!1),t&&e.focus({preventScroll:!0}))}function O(e){q();const t=it(e);m.forEach((r,o)=>{o!==e&&Z(o,!1)}),t.classList.add("show"),V.set(e,!0),C(e,"togglePIIRedactionPanel",!0),ne(t,e),fe(e,t),B(e);const n=t.querySelector('[data-action="run-scan"]');n==null||n.focus()}function Le(e,t){const n=ie(e);return(typeof t=="boolean"?t:!n)?O(e):Z(e),!0}function ot(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 o=r.exec(t);for(;o;){const i=o[0]||"",a=o.index,l=a+i.length;i&&l>a&&(!e.validator||e.validator(i))&&n.push({value:i,start:a,end:l}),r.lastIndex===o.index&&(r.lastIndex+=1),o=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 o=t.match.toLowerCase();let i=0;const a=document.createTreeWalker(e,pe,null);let l=a.nextNode();for(;l;){if(!he(l,n)){const c=at(r,l.data);for(let s=0;s<c.length;s+=1){const d=c[s];if(d.value.toLowerCase()===o&&(i+=1,i===t.occurrence)){const p=document.createRange();return p.setStart(l,d.start),p.setEnd(l,d.end),p}}}l=a.nextNode()}return null}function lt(e,t,n){const r=_e(e,t,n);if(!r)return!1;const o=window.getSelection();if(!o)return!1;o.removeAllRanges(),o.addRange(r);const i=re(r.startContainer);return i==null||i.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),e.focus({preventScroll:!0}),!0}async function h(e,t,n=!1){var p;w(e,t);const r=ot(e,t);if(!n&&de.get(e)===r)return I.get(e)||[];const o=(Q.get(e)||0)+1;Q.set(e,o);const i=[],a=new Map,l=document.createTreeWalker(e,pe,null);let c=l.nextNode();for(;c&&i.length<t.maxFindings;){const M=c.data||"";if(M.trim()&&!he(c,t)){const P=et(M,t.detectors,t.maxFindings-i.length);for(let K=0;K<P.length&&!(i.length>=t.maxFindings);K+=1){const y=P[K],ye=`${y.type}:${y.value.toLowerCase()}`,ke=(a.get(ye)||0)+1;a.set(ye,ke),i.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(M,y.start,y.end),suggestion:"Review and redact this value before external sharing."})}}c=l.nextNode()}if(Q.get(e)!==o)return I.get(e)||[];const s=((p=E.get(e))==null?void 0:p.redactedCount)||0,d=nt(i,s);return de.set(e,r),I.set(e,i),E.set(e,d),B(e),e.dispatchEvent(new CustomEvent("editora:pii-scan",{bubbles:!0,detail:{findings:i,stats:d}})),i}function ct(e,t){let n=e,r=0;return t.detectors.filter(i=>i.enabled).forEach(i=>{const a=be(i.pattern);n=n.replace(a,l=>i.validator&&!i.validator(l)?l:(r+=1,Re(l,i.type,t)))}),{nextValue:n,count:r}}async function De(e,t,n){var s;if(U(e)){const d=m.get(e);return d&&oe(d,n.labels.readonlyRedactionText),!1}const r=Pe(e,t);if(!r)return!1;const o=_e(e,r,n);if(!o)return!1;const i=e.innerHTML,a=Re(r.match,r.type,n);if(o.startContainer===o.endContainer&&o.startContainer.nodeType===Node.TEXT_NODE){const d=o.startContainer,p=d.data,M=o.startOffset,P=o.endOffset;d.data=`${p.slice(0,M)}${a}${p.slice(P)}`}else o.deleteContents(),o.insertNode(document.createTextNode(a));Me(e),Se(e,i);const l=((s=E.get(e))==null?void 0:s.redactedCount)||0;await h(e,n,!0);const c=E.get(e);return c&&(c.redactedCount=l+1,B(e)),Ae(e,1),!0}async function xe(e,t){var s;if(U(e)){const d=m.get(e);return d&&oe(d,t.labels.readonlyRedactionText),0}(I.get(e)||[]).length===0&&await h(e,t,!0);const r=e.innerHTML;let o=0;const i=document.createTreeWalker(e,pe,null);let a=i.nextNode();for(;a;){if(he(a,t)){a=i.nextNode();continue}const d=a.data||"";if(!d){a=i.nextNode();continue}const p=ct(d,t);p.count>0&&p.nextValue!==d&&(a.data=p.nextValue,o+=p.count),a=i.nextNode()}if(o===0)return 0;Me(e),Se(e,r);const l=((s=E.get(e))==null?void 0:s.redactedCount)||0;await h(e,t,!0);const c=E.get(e);return c&&(c.redactedCount=l+o,B(e)),Ae(e,o),o}function Ne(e){const t=f.get(e)||A;if(!t||!H(e,t)||U(e))return;me(e);const n=window.setTimeout(()=>{j.delete(n),te.delete(e),h(e,t,!1)},t.debounceMs);j.add(n),te.set(e,n)}function st(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="i"}function dt(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="u"}function ut(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="m"}function ft(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="y"}function pt(e){var r;const t=re(e.target);if(t){const o=t.closest(x);if(o)return o;const i=t.closest(ae);if(i){const l=z(i);if(l)return l}const a=t.closest(`.${u}`);if(a){const l=Array.from(m.entries()).find(([,c])=>c===a);if(l)return l[0]}}const n=window.getSelection();if(n&&n.rangeCount>0){const o=(r=re(n.getRangeAt(0).startContainer))==null?void 0:r.closest(x);if(o)return o}return null}function bt(){if(typeof document>"u"||document.getElementById(Ee))return;const e=document.createElement("style");e.id=Ee,e.textContent=`
42
42
  .rte-toolbar-group-items.${k},
43
43
  .editora-toolbar-group-items.${k},
44
44
  .rte-toolbar-group-items.${v},
@@ -433,4 +433,4 @@
433
433
  max-height: 45vh;
434
434
  }
435
435
  }
436
- `,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;
436
+ `,document.head.appendChild(e)}function gt(e){A=e,L||(L=t=>{q();const n=t.target,r=n==null?void 0:n.closest(x);if(!r)return;g=r;const o=f.get(r)||e;w(r,o),f.set(r,o),C(r,"togglePIIRedactionPanel",ie(r)),C(r,"togglePIIRealtime",H(r,o));const i=m.get(r);i&&(ne(i,r),fe(r,i),F(r,i,o))},document.addEventListener("focusin",L,!0)),_||(_=t=>{const n=t.target,r=n==null?void 0:n.closest(x);r&&(g=r,Ne(r))},document.addEventListener("input",_,!0)),D||(D=t=>{if(t.defaultPrevented)return;const n=t.target;if(n!=null&&n.closest(`.${u} input, .${u} textarea, .${u} select`))return;const r=pt(t);if(!r)return;const o=f.get(r)||A||e;if(w(r,o),f.set(r,o),g=r,t.key==="Escape"&&ie(r)){t.preventDefault(),Z(r,!0);return}if(st(t)){t.preventDefault(),t.stopPropagation(),Le(r);return}if(dt(t)){t.preventDefault(),t.stopPropagation(),h(r,o,!0),O(r);return}if(ut(t)){t.preventDefault(),t.stopPropagation(),U(r)||(xe(r,o),O(r));return}if(ft(t)){t.preventDefault(),t.stopPropagation();const i=!H(r,o);S.set(r,i);const a=m.get(r);a&&F(r,a,o),C(r,"togglePIIRealtime",i),i&&h(r,o,!0)}},document.addEventListener("keydown",D,!0)),R||(R=()=>{q(),m.forEach((t,n)=>{!n.isConnected||!t.isConnected||(ne(t,n),fe(n,t))})},window.addEventListener("scroll",R,!0),window.addEventListener("resize",R)),!N&&typeof MutationObserver<"u"&&document.body&&(N=new MutationObserver(t=>{Ge(t)&&q()}),N.observe(document.body,{childList:!0,subtree:!0}))}function mt(){L&&(document.removeEventListener("focusin",L,!0),L=null),_&&(document.removeEventListener("input",_,!0),_=null),D&&(document.removeEventListener("keydown",D,!0),D=null),R&&(window.removeEventListener("scroll",R,!0),window.removeEventListener("resize",R),R=null),N&&(N.disconnect(),N=null),m.forEach(e=>e.remove()),m.clear(),W.forEach(e=>me(e)),W.clear(),A=null,g=null}const ht=(e={})=>{const t=ee(e),n=new Set;return bt(),{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,o)=>{const i=T(o);if(!i)return!1;const a=f.get(i)||t;return w(i,a),f.set(i,a),g=i,O(i),h(i,a,!1),!0},togglePIIRedactionPanel:(r,o)=>{const i=T(o);if(!i)return!1;const a=f.get(i)||t;w(i,a),f.set(i,a),g=i;const l=Le(i,typeof r=="boolean"?r:void 0);return ie(i)&&h(i,a,!1),l},runPIIScan:async(r,o)=>{const i=T(o);if(!i)return!1;const a=f.get(i)||t;return w(i,a),f.set(i,a),g=i,await h(i,a,!0),O(i),!0},redactAllPII:async(r,o)=>{const i=T(o);if(!i)return!1;const a=f.get(i)||t;w(i,a),f.set(i,a),g=i;const l=await xe(i,a);return l>0&&O(i),l>0},redactPIIFinding:async(r,o)=>{const i=T(o);if(!i||typeof r!="string"||!r)return!1;const a=f.get(i)||t;return w(i,a),f.set(i,a),g=i,De(i,r,a)},togglePIIRealtime:(r,o)=>{const i=T(o);if(!i)return!1;const a=f.get(i)||t;w(i,a),f.set(i,a);const l=typeof r=="boolean"?r:!H(i,a);S.set(i,l);const c=m.get(i);return c&&F(i,c,a),C(i,"togglePIIRealtime",l),l&&h(i,a,!0),!0},getPIIRedactionFindings:(r,o)=>{const i=T(o);if(!i)return!1;const a=I.get(i)||[],l=E.get(i)||le(0),c=a.map(d=>({...d})),s={...l,byType:{...l.byType}};if(typeof r=="function")try{r(c,s)}catch{}return i.__piiRedactionFindings=c,i.dispatchEvent(new CustomEvent("editora:pii-findings",{bubbles:!0,detail:{findings:c,stats:s}})),!0},setPIIRedactionOptions:(r,o)=>{const i=T(o);if(!i||!r||typeof r!="object")return!1;const a=f.get(i)||t,l=ee({...ce(a),...r,labels:{...a.labels,...r.labels||{}},detectors:{...ce(a).detectors||{},...r.detectors||{}},normalizeText:r.normalizeText||a.normalizeText});f.set(i,l),typeof r.enableRealtime=="boolean"&&S.set(i,r.enableRealtime);const c=m.get(i);return c&&(rt(c,l),B(i),F(i,c,l)),h(i,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(o){G+=1;const i=this&&typeof this.__pluginConfig=="object"?ee({...ce(t),...this.__pluginConfig}):t;gt(i);const a=T(o!=null&&o.editorElement?{editorElement:o.editorElement}:void 0,!1);a&&(g=a,n.add(a),w(a,i),f.set(a,i),C(a,"togglePIIRedactionPanel",!1),C(a,"togglePIIRealtime",i.enableRealtime),i.enableRealtime&&Ne(a))},destroy:()=>{n.forEach(r=>Te(r)),n.clear(),G=Math.max(0,G-1),!(G>0)&&(j.forEach(r=>{window.clearTimeout(r)}),j.clear(),mt())}}};exports.PIIRedactionPlugin=ht;