@editora/plugins 1.0.12 → 1.0.13

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 (51) hide show
  1. package/dist/approval-workflow.cjs.js +14 -14
  2. package/dist/approval-workflow.esm.js +265 -262
  3. package/dist/blockquote.cjs.js +1 -1
  4. package/dist/blockquote.esm.js +177 -15
  5. package/dist/blocks-library.cjs.js +6 -6
  6. package/dist/blocks-library.esm.js +95 -92
  7. package/dist/bold.cjs.js +1 -1
  8. package/dist/bold.esm.js +10 -6
  9. package/dist/capitalization.cjs.js +1 -1
  10. package/dist/capitalization.esm.js +124 -44
  11. package/dist/checklist.cjs.js +1 -1
  12. package/dist/checklist.esm.js +251 -191
  13. package/dist/citations.cjs.js +4 -4
  14. package/dist/citations.esm.js +131 -128
  15. package/dist/clear-formatting.cjs.js +1 -1
  16. package/dist/clear-formatting.esm.js +68 -36
  17. package/dist/content-rules.cjs.js +5 -5
  18. package/dist/content-rules.esm.js +104 -101
  19. package/dist/data-binding.cjs.js +3 -3
  20. package/dist/data-binding.esm.js +51 -48
  21. package/dist/direction.cjs.js +1 -1
  22. package/dist/direction.esm.js +97 -74
  23. package/dist/doc-schema.cjs.js +4 -4
  24. package/dist/doc-schema.esm.js +104 -101
  25. package/dist/embed-iframe.cjs.js +21 -4
  26. package/dist/embed-iframe.esm.js +279 -116
  27. package/dist/heading.cjs.js +1 -1
  28. package/dist/heading.esm.js +239 -56
  29. package/dist/history.cjs.js +1 -1
  30. package/dist/history.esm.js +74 -89
  31. package/dist/inlineFormatting-DOYOJdnD.js +1 -0
  32. package/dist/inlineFormatting-DuVTGXYG.mjs +95 -0
  33. package/dist/italic.cjs.js +1 -1
  34. package/dist/italic.esm.js +12 -8
  35. package/dist/math.cjs.js +27 -21
  36. package/dist/math.esm.js +218 -146
  37. package/dist/merge-tag.cjs.js +8 -2
  38. package/dist/merge-tag.esm.js +130 -111
  39. package/dist/pii-redaction.cjs.js +6 -6
  40. package/dist/pii-redaction.esm.js +169 -166
  41. package/dist/smart-paste.cjs.js +5 -5
  42. package/dist/smart-paste.esm.js +120 -117
  43. package/dist/special-characters.cjs.js +6 -10
  44. package/dist/special-characters.esm.js +97 -75
  45. package/dist/strikethrough.cjs.js +1 -1
  46. package/dist/strikethrough.esm.js +11 -25
  47. package/dist/translation-workflow.cjs.js +7 -7
  48. package/dist/translation-workflow.esm.js +103 -100
  49. package/dist/underline.cjs.js +1 -1
  50. package/dist/underline.esm.js +7 -3
  51. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- "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=>`
1
+ "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=>`
2
2
  <li class="rte-citations-recent-item">
3
3
  <div class="rte-citations-recent-row">
4
4
  <button
@@ -20,7 +20,7 @@
20
20
  >${g(n.labels.deleteRecentText)}</button>
21
21
  </div>
22
22
  </li>
23
- `).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=`
23
+ `).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=`
24
24
  <header class="rte-citations-header">
25
25
  <h2 class="rte-citations-title">${g(n.labels.panelTitle)}</h2>
26
26
  <button type="button" class="rte-citations-icon-btn" data-action="close" aria-label="${g(n.labels.closeText)}">✕</button>
@@ -77,7 +77,7 @@
77
77
  <p class="rte-citations-shortcut">Shortcut: Ctrl/Cmd + Alt + Shift + C</p>
78
78
  <span class="rte-citations-live" aria-live="polite"></span>
79
79
  </div>
80
- `,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=`
80
+ `,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=`
81
81
  .rte-toolbar-group-items.citations,
82
82
  .editora-toolbar-group-items.citations {
83
83
  display: flex;
@@ -545,4 +545,4 @@
545
545
  max-height: 34vh;
546
546
  }
547
547
  }
548
- `,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;
548
+ `,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;