@panphora/clayjs 1.5.3 → 1.6.1
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.
- package/README.md +5 -3
- package/THIRD-PARTY-NOTICES.md +6 -0
- package/dist/clay.standalone.js +15041 -10657
- package/package.json +9 -4
- package/src/core/conflict-download.js +91 -0
- package/src/core/conflict-notice.js +720 -0
- package/src/core/conflict-presentation.js +301 -0
- package/src/core/save-conflict-notice.js +2 -192
- package/src/core/save-core.js +35 -2
- package/src/core/save-feedback.js +6 -0
- package/src/core/save.js +157 -3
- package/src/core/snapshot.js +21 -0
- package/src/core/stale-host-notice.js +21 -24
- package/src/core/unsaved-warning.js +64 -16
- package/src/lib/content-dom.js +4 -2
- package/src/lib/dirty-gate.js +37 -1
- package/src/lib/unsaved-state.js +55 -0
- package/src/loader-logic.js +26 -15
- package/src/loader.js +10 -3
- package/src/plugins/ai-edit.js +489 -179
- package/src/plugins/cms.js +12 -0
- package/src/plugins/indicator.js +35 -16
- package/src/plugins/quickcrop.js +103 -0
- package/src/plugins/richclay.js +21 -0
- package/src/plugins/source.js +13 -6
- package/src/plugins/wire.js +4 -0
- package/src/sync/conflict-revert.js +1138 -0
- package/src/sync/conflicts.js +159 -0
- package/src/sync/live-sync.js +130 -109
- package/src/sync/presence.js +42 -36
- package/src/sync/section-notice.js +53 -28
- package/src/ui/bevel-controls.js +277 -0
- package/src/ui/bevel-dialog.js +112 -0
- package/src/ui/bevel.js +247 -0
- package/src/ui/dialogs.js +63 -86
- package/src/ui/index.js +22 -11
- package/src/ui/modal.js +80 -387
- package/src/ui/skins/cms-toggle.js +15 -0
- package/src/ui/skins/cms.js +4 -0
- package/src/ui/skins/quickcrop.js +4 -0
- package/src/ui/skins/richclay.js +4 -0
- package/src/ui/toast.js +116 -401
- package/src/ui/vendor-skin.js +65 -0
- package/src/vendor/hyper-morph.vendor.js +4 -4
- package/src/vendor/quickcrop.vendor.js +14 -8
- package/src/vendor/richclay.vendor.js +22 -41
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* richclay self-contained vendor build (bundles Squire + DOMPurify) for hyperclayjs. Generated; do not edit. */
|
|
2
|
-
var richclay=(()=>{var vn=Object.defineProperty;var us=Object.getOwnPropertyDescriptor;var ds=Object.getOwnPropertyNames;var hs=Object.prototype.hasOwnProperty;var fs=(e,t)=>{for(var n in t)vn(e,n,{get:t[n],enumerable:!0})},ps=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ds(t))!hs.call(e,r)&&r!==n&&vn(e,r,{get:()=>t[r],enumerable:!(i=us(t,r))||i.enumerable});return e};var ms=e=>ps(vn({},"__esModule",{value:!0}),e);var kl={};fs(kl,{RichClay:()=>We,default:()=>Ol});var gs=()=>!0,ne=class{constructor(e,t,n){this.root=e,this.currentNode=e,this.nodeType=t,this.filter=n||gs}isAcceptableNode(e){let t=e.nodeType;return!!((t===Node.ELEMENT_NODE?1:t===Node.TEXT_NODE?4:0)&this.nodeType)&&this.filter(e)}nextNode(){let e=this.root,t=this.currentNode,n;for(;;){for(n=t.firstChild;!n&&t&&t!==e;)n=t.nextSibling,n||(t=t.parentNode);if(!n)return null;if(this.isAcceptableNode(n))return this.currentNode=n,n;t=n}}previousNode(){let e=this.root,t=this.currentNode,n;for(;;){if(t===e)return null;if(n=t.previousSibling,n)for(;t=n.lastChild;)n=t;else n=t.parentNode;if(!n)return null;if(this.isAcceptableNode(n))return this.currentNode=n,n;t=n}}previousPONode(){let e=this.root,t=this.currentNode,n;for(;;){for(n=t.lastChild;!n&&t&&t!==e;)n=t.previousSibling,n||(t=t.parentNode);if(!n)return null;if(this.isAcceptableNode(n))return this.currentNode=n,n;t=n}}},ze=navigator.userAgent,In=/Mac OS X/.test(ze),nr=/Windows NT/.test(ze),ir=/iP(?:ad|hone|od)/.test(ze)||In&&!!navigator.maxTouchPoints,Il=/Android/.test(ze),ys=/Gecko\//.test(ze),Ht=/Edge\//.test(ze),bs=!Ht&&/WebKit\//.test(ze),J=In||ir?"Meta-":"Ctrl-",zt=bs,Ts="onbeforeinput"in document&&"inputType"in new InputEvent("input"),fe=/[^ \t\r\n\u200B]/,_s=/^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|EL|FN)|EM|FONT|HR|I(?:FRAME|MG|NPUT|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:AMP|MALL|PAN|TR(?:IKE|ONG)|U[BP])?|TIME|U|VAR|WBR)$/,Es=new Set(["BR","HR","IFRAME","IMG","INPUT"]),Ss=0,Ln=1,rr=2,or=3,Ut=new WeakMap,sr=()=>{Ut=new WeakMap},Re=e=>Es.has(e.nodeName),Mn=e=>{switch(e.nodeType){case 8:case 3:return Ln;case 1:case 11:if(Ut.has(e))return Ut.get(e);break;default:return Ss}let t;return Array.from(e.childNodes).every(x)?_s.test(e.nodeName)?t=Ln:t=rr:t=or,Ut.set(e,t),t},x=e=>Mn(e)===Ln,we=e=>Mn(e)===rr,Ze=e=>Mn(e)===or,T=(e,t,n)=>{let i=document.createElement(e);if(t instanceof Array&&(n=t,t=null),t)for(let r in t){let o=t[r];o!==void 0&&i.setAttribute(r,o)}return n&&n.forEach(r=>i.appendChild(r)),i},ar=(e,t)=>Re(e)||e.nodeType!==t.nodeType||e.nodeName!==t.nodeName?!1:e instanceof HTMLElement&&t instanceof HTMLElement?e.nodeName!=="A"&&e.className===t.className&&e.style.cssText===t.style.cssText:!0,wn=(e,t,n)=>{if(e.nodeName!==t)return!1;for(let i in n)if(!("getAttribute"in e)||e.getAttribute(i)!==n[i])return!1;return!0},L=(e,t,n,i)=>{for(;e&&e!==t;){if(wn(e,n,i))return e;e=e.parentNode}return null},Pn=(e,t)=>{let n=e.childNodes;for(;t&&e instanceof Element;)e=n[t-1],n=e.childNodes,t=n.length;return e},lr=(e,t)=>{let n=e;if(n instanceof Element){let i=n.childNodes;if(t<i.length)n=i[t];else{for(;n&&!n.nextSibling;)n=n.parentNode;n&&(n=n.nextSibling)}}return n},re=e=>e instanceof Element||e instanceof DocumentFragment?e.childNodes.length:e instanceof CharacterData?e.length:0,D=e=>{let t=document.createDocumentFragment(),n=e.firstChild;for(;n;)t.appendChild(n),n=e.firstChild;return t},H=e=>{let t=e.parentNode;return t&&t.removeChild(e),e},j=(e,t)=>{let n=e.parentNode;n&&n.replaceChild(t,e)},As=e=>e instanceof Element?e.nodeName==="BR":fe.test(e.data),$t=(e,t)=>{let n=e.parentNode;for(;x(n);)n=n.parentNode;let i=new ne(n,5,As);return i.currentNode=e,!!i.nextNode()||t&&!i.previousNode()},Bt=(e,t)=>{let n=new ne(e,4),i,r;for(;i=n.nextNode();)for(;(r=i.data.indexOf("\u200B"))>-1&&(!t||i.parentNode!==t);)if(i.length===1){let o=i,s=o.parentNode;for(;s&&(s.removeChild(o),n.currentNode=s,!(!x(s)||re(s)));)o=s,s=o.parentNode;break}else i.deleteData(r,1)},vs=0,Cs=1,xs=2,Ns=3,Le=(e,t,n)=>{let i=document.createRange();if(i.selectNode(t),n){let r=e.compareBoundaryPoints(Ns,i)>-1,o=e.compareBoundaryPoints(Cs,i)<1;return!r&&!o}else{let r=e.compareBoundaryPoints(vs,i)<1,o=e.compareBoundaryPoints(xs,i)>-1;return r&&o}},V=e=>{let{startContainer:t,startOffset:n,endContainer:i,endOffset:r}=e;for(;!(t instanceof Text);){let o=t.childNodes[n];if(!o||Re(o)){if(n&&(o=t.childNodes[n-1],o instanceof Text)){let s=o,a;for(;!s.length&&(a=s.previousSibling)&&a instanceof Text;)s.remove(),s=a;t=s,n=s.data.length}break}t=o,n=0}if(r)for(;!(i instanceof Text);){let o=i.childNodes[r-1];if(!o||Re(o)){if(o&&o.nodeName==="BR"&&!$t(o,!1)){r-=1;continue}break}i=o,r=re(i)}else for(;!(i instanceof Text);){let o=i.firstChild;if(!o||Re(o))break;i=o}e.setStart(t,n),e.setEnd(i,r)},Fe=(e,t,n,i)=>{let r=e.startContainer,o=e.startOffset,s=e.endContainer,a=e.endOffset,l;for(t||(t=e.commonAncestorContainer),n||(n=t);!o&&r!==t&&r!==i;)l=r.parentNode,o=Array.from(l.childNodes).indexOf(r),r=l;for(;!(s===n||s===i||(s.nodeType!==3&&s.childNodes[a]&&s.childNodes[a].nodeName==="BR"&&!$t(s.childNodes[a],!1)&&(a+=1),a!==re(s)));)l=s.parentNode,a=Array.from(l.childNodes).indexOf(s)+1,s=l;e.setStart(r,o),e.setEnd(s,a)},Vi=(e,t,n)=>{let i=L(e.endContainer,n,t);if(i&&(i=i.parentNode)){let r=e.cloneRange();Fe(r,i,i,n),r.endContainer===i&&(e.setStart(r.endContainer,r.endOffset),e.setEnd(r.endContainer,r.endOffset))}return e},z=e=>{let t=null;if(e instanceof Text)return e;if(x(e)){let n=e.firstChild;if(zt)for(;n&&n instanceof Text&&!n.data;)e.removeChild(n),n=e.firstChild;n||(zt?t=document.createTextNode("\u200B"):t=document.createTextNode(""))}else if((e instanceof Element||e instanceof DocumentFragment)&&!e.querySelector("BR")&&!fe.test(e.textContent||"")){t=T("BR");let n=e,i;for(;(i=n.lastElementChild)&&!x(i);)n=i;e=n,e instanceof HTMLElement&&e.contentEditable==="true"&&(e=T("DIV"),n.appendChild(e))}if(t)try{e.appendChild(t)}catch{}return e},pe=(e,t)=>{let n=null;return/^(?:TABLE|TBODY|TR|TH|TD|P)/.test(e.nodeName)||(Array.from(e.childNodes).forEach(i=>{let r=i.nodeName==="BR";!r&&x(i)?(n||(n=T("DIV")),n.appendChild(i)):(r||n)&&(n||(n=T("DIV")),z(n),r?e.replaceChild(n,i):e.insertBefore(n,i),n=null),Ze(i)&&pe(i,t)}),n&&e.appendChild(z(n))),e},se=(e,t,n,i)=>{if(!n.contains(e))throw new Error("split: stopNode does not contain node");if(e instanceof Text&&e!==n){if(typeof t!="number")throw new Error("Offset must be a number to split text node!");if(!e.parentNode)throw new Error("Cannot split text node with no parent!");return se(e.parentNode,e.splitText(t),n,i)}let r=typeof t=="number"?t<e.childNodes.length?e.childNodes[t]:null:t,o=e.parentNode;if(!o||e===n||!(e instanceof Element))return r;let s=e.cloneNode(!1);for(;r;){let a=r.nextSibling;s.appendChild(r),r=a}return e instanceof HTMLOListElement&&L(e,i,"BLOCKQUOTE")&&(s.start=(+e.start||1)+e.childNodes.length-1),z(e),z(s),o.insertBefore(s,e.nextSibling),se(o,s,n,i)},cr=(e,t)=>{let n=e.childNodes,i=n.length,r=[];for(;i--;){let o=n[i],s=i?n[i-1]:null;if(s&&x(o)&&ar(o,s))t.startContainer===o&&(t.startContainer=s,t.startOffset+=re(s)),t.endContainer===o&&(t.endContainer=s,t.endOffset+=re(s)),t.startContainer===e&&(t.startOffset>i?t.startOffset-=1:t.startOffset===i&&(t.startContainer=s,t.startOffset=re(s))),t.endContainer===e&&(t.endOffset>i?t.endOffset-=1:t.endOffset===i&&(t.endContainer=s,t.endOffset=re(s))),H(o),o instanceof Text?s.appendData(o.data):r.push(D(o));else if(o instanceof Element){let a;for(;a=r.pop();)o.appendChild(a);cr(o,t)}}},Qe=(e,t)=>{let n=e instanceof Text?e.parentNode:e;if(n instanceof Element){let i={startContainer:t.startContainer,startOffset:t.startOffset,endContainer:t.endContainer,endOffset:t.endOffset};cr(n,i),t.setStart(i.startContainer,i.startOffset),t.setEnd(i.endContainer,i.endOffset)}},ft=(e,t,n,i)=>{let r=t,o,s;for(;(o=r.parentNode)&&o!==i&&o instanceof Element&&o.childNodes.length===1;)r=o;H(r),s=e.childNodes.length;let a=e.lastChild;a&&a.nodeName==="BR"&&(e.removeChild(a),s-=1),e.appendChild(D(t)),n.setStart(e,s),n.collapse(!0),Qe(e,n)},_e=(e,t)=>{let n=e.previousSibling,i=e.firstChild,r=e.nodeName==="LI";if(!(r&&(!i||!/^[OU]L$/.test(i.nodeName)))){if(n&&ar(n,e)){if(!Ze(n))if(r){let s=T("DIV");s.appendChild(D(n)),n.appendChild(s)}else return;H(e);let o=!Ze(e);n.appendChild(D(e)),o&&pe(n,t),i&&_e(i,t)}else if(r){let o=T("DIV");e.insertBefore(o,i),z(o)}}},Yi={"font-weight":{regexp:/^bold|^700/i,replace(){return T("B")}},"font-style":{regexp:/^italic/i,replace(){return T("I")}},"font-family":{regexp:fe,replace(e,t){let n=T("SPAN",{class:e.fontFamily});return n.style.fontFamily=t,n}},"font-size":{regexp:fe,replace(e,t){let n=T("SPAN",{class:e.fontSize});return n.style.fontSize=t,n}},"text-decoration":{regexp:/^underline/i,replace(){return T("U")}}},Ls=(e,t,n)=>{let i=e.style,r,o;for(let s in Yi){let a=Yi[s],l=i.getPropertyValue(s);if(l&&a.regexp.test(l)){let u=a.replace(n.classNames,l);if(u.nodeName===e.nodeName&&u.className===e.className)continue;o||(o=u),r&&r.appendChild(u),r=u,e.style.removeProperty(s)}}return o&&r&&(r.appendChild(D(e)),e.style.cssText?e.appendChild(o):j(e,o)),r||e},Ft=e=>(t,n)=>{let i=T(e),r=t.attributes;for(let o=0,s=r.length;o<s;o+=1){let a=r[o];i.setAttribute(a.name,a.value)}return n.replaceChild(i,t),i.appendChild(D(t)),i},ws={1:"10",2:"13",3:"16",4:"18",5:"24",6:"32",7:"48"},Rs={STRONG:Ft("B"),EM:Ft("I"),INS:Ft("U"),STRIKE:Ft("S"),SPAN:Ls,FONT:(e,t,n)=>{let i=e,r=i.face,o=i.size,s=i.color,a=n.classNames,l,u,d,f,p;return r&&(l=T("SPAN",{class:a.fontFamily}),l.style.fontFamily=r,p=l,f=l),o&&(u=T("SPAN",{class:a.fontSize}),u.style.fontSize=ws[o]+"px",p||(p=u),f&&f.appendChild(u),f=u),s&&/^#?([\dA-F]{3}){1,2}$/i.test(s)&&(s.charAt(0)!=="#"&&(s="#"+s),d=T("SPAN",{class:a.color}),d.style.color=s,p||(p=d),f&&f.appendChild(d),f=d),(!p||!f)&&(p=f=T("SPAN")),t.replaceChild(p,i),f.appendChild(D(i)),f},TT:(e,t,n)=>{let i=T("SPAN",{class:n.classNames.fontFamily,style:'font-family:menlo,consolas,"courier new",monospace'});return t.replaceChild(i,e),i.appendChild(D(e)),i}},Os=/^(?:A(?:DDRESS|RTICLE|SIDE|UDIO)|BLOCKQUOTE|CAPTION|D(?:[DLT]|IV)|F(?:IGURE|IGCAPTION|OOTER)|H[1-6]|HEADER|L(?:ABEL|EGEND|I)|O(?:L|UTPUT)|P(?:RE)?|SECTION|T(?:ABLE|BODY|D|FOOT|H|HEAD|R)|COL(?:GROUP)?|UL)$/,ks=/^(?:HEAD|META|STYLE)/,Rn=(e,t,n)=>{let i=e.childNodes,r=e;for(;x(r);)r=r.parentNode;let o=new ne(r,5);for(let s=0,a=i.length;s<a;s+=1){let l=i[s],u=l.nodeName,d=Rs[u];if(l instanceof HTMLElement){let f=l.childNodes.length;if(d)l=d(l,e,t);else if(ks.test(u)){e.removeChild(l),s-=1,a-=1;continue}else if(!Os.test(u)&&!x(l)){s-=1,a+=f-1,e.replaceChild(D(l),l);continue}f&&Rn(l,t,n||u==="PRE")}else{if(l instanceof Text){let f=l.data,p=!fe.test(f.charAt(0)),y=!fe.test(f.charAt(f.length-1));if(n||!p&&!y)continue;if(p){o.currentNode=l;let E;for(;(E=o.previousPONode())&&!(E.nodeName==="IMG"||E instanceof Text&&fe.test(E.data));)if(!x(E)){E=null;break}f=f.replace(/^[ \t\r\n]+/g,E?" ":"")}if(y){o.currentNode=l;let E;for(;(E=o.nextNode())&&!(E.nodeName==="IMG"||E instanceof Text&&fe.test(E.data));)if(!x(E)){E=null;break}f=f.replace(/[ \t\r\n]+$/g,E?" ":"")}if(f){l.data=f;continue}}e.removeChild(l),s-=1,a-=1}}return e},On=e=>{let t=e.childNodes,n=t.length;for(;n--;){let i=t[n];i instanceof Element&&!Re(i)?(On(i),x(i)&&!i.firstChild&&e.removeChild(i)):i instanceof Text&&!i.data&&e.removeChild(i)}},kn=(e,t,n)=>{let i=e.querySelectorAll("BR"),r=[],o=i.length;for(let s=0;s<o;s+=1)r[s]=$t(i[s],n);for(;o--;){let s=i[o],a=s.parentNode;a&&(r[o]?x(a)||pe(a,t):H(s))}},Xi=e=>e.split("&").join("&").split("<").join("<").split(">").join(">").split('"').join("""),qt=(e,t)=>{let n=new ne(t,1,we);return n.currentNode=e,n},Ue=(e,t)=>{let n=qt(e,t).previousNode();return n!==t?n:null},Ee=(e,t)=>{let n=qt(e,t).nextNode();return n!==t?n:null},Dn=e=>!e.textContent&&!e.querySelector("IMG"),ie=(e,t)=>{let n=e.startContainer,i;if(x(n))i=Ue(n,t);else if(n!==t&&n instanceof HTMLElement&&we(n))i=n;else{let r=Pn(n,e.startOffset);i=Ee(r,t)}return i&&Le(e,i,!0)?i:null},He=(e,t)=>{let n=e.endContainer,i;if(x(n))i=Ue(n,t);else if(n!==t&&n instanceof HTMLElement&&we(n))i=n;else{let r=lr(n,e.endOffset);if(!r||!t.contains(r)){r=t;let o;for(;o=r.lastChild;)r=o}i=Ue(r,t)}return i&&Le(e,i,!0)?i:null},ur=e=>e instanceof Text?fe.test(e.data):e.nodeName==="IMG",pt=(e,t)=>{let n=e.startContainer,i=e.startOffset,r;if(n instanceof Text){let a=n.data;for(let l=i;l>0;l-=1)if(a.charAt(l-1)!=="\u200B")return!1;r=n}else if(r=lr(n,i),r&&!t.contains(r)&&(r=null),!r&&(r=Pn(n,i),r instanceof Text&&r.length))return!1;let o=ie(e,t);if(!o)return!1;let s=new ne(o,5,ur);return s.currentNode=r,!s.previousNode()},mt=(e,t)=>{let n=e.endContainer,i=e.endOffset,r;if(n instanceof Text){let a=n.data,l=a.length;for(let u=i;u<l;u+=1)if(a.charAt(u)!=="\u200B")return!1;r=n}else r=Pn(n,i);let o=He(e,t);if(!o)return!1;let s=new ne(o,5,ur);return s.currentNode=r,!s.nextNode()},Qi=(e,t)=>{let n=ie(e,t),i=He(e,t),r;n&&i&&(r=n.parentNode,e.setStart(r,Array.from(r.childNodes).indexOf(n)),r=i.parentNode,e.setEnd(r,Array.from(r.childNodes).indexOf(i)+1))};function Be(e,t,n,i){let r=document.createRange();return r.setStart(e,t),n&&typeof i=="number"?r.setEnd(n,i):r.setEnd(e,t),r}var Te=(e,t)=>{let{startContainer:n,startOffset:i,endContainer:r,endOffset:o}=e,s;if(n instanceof Text){let l=n.parentNode;if(s=l.childNodes,i===n.length)i=Array.from(s).indexOf(n)+1,e.collapsed&&(r=l,o=i);else{if(i){let u=n.splitText(i);r===n?(o-=i,r=u):r===l&&(o+=1),n=u}i=Array.from(s).indexOf(n)}n=l}else s=n.childNodes;let a=s.length;i===a?n.appendChild(t):n.insertBefore(t,s[i]),n===r&&(o+=s.length-a),e.setStart(n,i),e.setEnd(r,o)},dr=(e,t,n)=>{let i=document.createDocumentFragment();if(e.collapsed)return i;t||(t=e.commonAncestorContainer),t instanceof Text&&(t=t.parentNode);let r=e.startContainer,o=e.startOffset,s=se(e.endContainer,e.endOffset,t,n),a=0,l=se(r,o,t,n);for(;l&&l!==s;){let u=l.nextSibling;i.appendChild(l),l=u}return l=s&&s.previousSibling,l&&l instanceof Text&&s instanceof Text&&(a=l.length,l.appendData(s.data),H(s),s=l),e.setStart(r,o),s?e.setEnd(s,a):e.setEnd(t,t.childNodes.length),z(t),i},Zi=(e,t,n)=>{e.currentNode=n;let i;for(;i=e[t]();){if(i instanceof Text||Re(i))return i;if(!x(i))return null}return null},qe=(e,t)=>{let n=ie(e,t),i=He(e,t),r=n!==i;n&&i&&(V(e),Fe(e,n,i,t));let o=dr(e,null,t);V(e),r&&(i=He(e,t),n&&i&&n!==i&&ft(n,i,e,t)),n&&z(n);let s=t.firstChild;(!s||s.nodeName==="BR")&&(z(t),t.firstChild&&e.selectNodeContents(t.firstChild)),e.collapse(!0);let a=e.startContainer,l=e.startOffset,u=new ne(t,5),d=a,f=l;(!(d instanceof Text)||f===d.data.length)&&(d=Zi(u,"nextNode",d),f=0);let p=a,y=l-1;(!(p instanceof Text)||y===-1)&&(p=Zi(u,"previousPONode",d||(a instanceof Text?a:a.childNodes[l]||a)),p instanceof Text&&(y=p.data.length));let E=null,N=0;return d instanceof Text&&d.data.charAt(f)===" "&&pt(e,t)?(E=d,N=f):p instanceof Text&&p.data.charAt(y)===" "&&(d instanceof Text&&d.data.charAt(f)===" "||mt(e,t))&&(E=p,N=y),E&&E.replaceData(N,1,"\xA0"),e.setStart(a,l),e.collapse(!0),o},Ds=(e,t,n)=>{let i=t.firstChild&&x(t.firstChild),r;for(pe(t,n),r=t;r=Ee(r,n);)z(r);e.collapsed||qe(e,n),V(e),e.collapse(!1);let o=L(e.endContainer,n,"BLOCKQUOTE")||n,s=ie(e,n),a=null,l=Ee(t,t),u=!i&&!!s&&Dn(s);if(s&&l&&!u&&!L(l,t,"PRE")&&!L(l,t,"TABLE")){Fe(e,s,s,n),e.collapse(!0);let d=e.endContainer,f=e.endOffset;if(kn(s,n,!1),x(d)){let p=se(d,f,Ue(d,n)||n,n);d=p.parentNode,f=Array.from(d.childNodes).indexOf(p)}if(f!==re(d))for(a=document.createDocumentFragment();r=d.childNodes[f];)a.appendChild(r);ft(d,l,e,n),d===n?e.setEnd(n,re(n)):(f=Array.from(d.parentNode.childNodes).indexOf(d)+1,d=d.parentNode,e.setEnd(d,f))}if(re(t)){u&&s&&(e.setEndBefore(s),e.collapse(!1),H(s)),o.contains(e.endContainer)||(n.contains(e.endContainer)||(e.setEnd(n,re(n)),e.collapse(!1)),o=L(e.endContainer,n,"BLOCKQUOTE")||n),Fe(e,o,o,n);let d=se(e.endContainer,e.endOffset,o,n),f=d?d.previousSibling:o.lastChild;o.insertBefore(t,d),d?e.setEndBefore(d):e.setEnd(o,re(o)),s=He(e,n),V(e);let p=e.endContainer,y=e.endOffset;d&&Ze(d)&&_e(d,n),d=f&&f.nextSibling,d&&Ze(d)&&_e(d,n),e.setEnd(p,y)}if(a&&s){let d=e.cloneRange();z(a),ft(s,a,d,n),e.setEnd(d.endContainer,d.endOffset)}V(e)},hr=e=>{if(e.collapsed)return"";let t=e.startContainer,n=e.endContainer,i=new ne(e.commonAncestorContainer,5,l=>Le(e,l,!0));i.currentNode=t;let r=t,o="",s=!1,a;for((!(r instanceof Element)&&!(r instanceof Text)||!i.filter(r))&&(r=i.nextNode());r;)r instanceof Text?(a=r.data,a&&/\S/.test(a)&&(r===n&&(a=a.slice(0,e.endOffset)),r===t&&(a=a.slice(e.startOffset)),o+=a,s=!0)):(r.nodeName==="BR"||s&&!x(r))&&(o+=`
|
|
3
|
-
`,s=!1),r=i.nextNode();return o=o.replace(/ /g," "),o},
|
|
4
|
-
`)),f&&(f="<!-- squire -->"+f),[o,f]},pr=(e,t,n,i,r,o,s)=>{let a=e.clipboardData;if(Ht||!a)return!1;let[l,u]=fr(t,n,i,r,o);return e.preventDefault(),!s&&u&&a.setData("text/html",u),a.setData("text/plain",l),!0},Is=function(e){let t=this.getSelection(),n=this._root;if(t.collapsed){e.preventDefault();return}this.saveUndoState(t),pr(e,t,n,!0,this._config.willCutCopy,this._config.toPlainText,!1)||setTimeout(()=>{try{this._ensureBottomLine()}catch(i){this._config.didError(i)}},0),this.setSelection(t)},Ms=function(e){pr(e,this.getSelection(),this._root,!1,this._config.willCutCopy,this._config.toPlainText,!1)},Ji=function(e){this._isShiftDown=e.shiftKey},Ps=function(e){let t=e.clipboardData,n=t?.items,i=this._isShiftDown,r=!1,o=!1,s=null,a=null;if(n){let C=n.length;for(;C--;){let M=n[C],$=M.type;$==="text/html"?a=M:$==="text/plain"||$==="text/uri-list"?s=M:$==="text/rtf"?r=!0:/^image\/.*/.test($)&&(o=!0)}if(o&&!(r&&a)&&!s){e.preventDefault(),this.fireEvent("pasteImage",{clipboardData:t});return}if(!Ht){e.preventDefault(),a&&(!i||!s)?a.getAsString(M=>{this.insertHTML(M,!0)}):s&&s.getAsString(M=>{let $=this.getSelection();if(!$.collapsed&&fe.test($.toString())){let le=this.linkRegExp.exec(M);if(le&&le[0].length===M.length){let Q=le[1]?/^(?:ht|f)tps?:/i.test(le[1])?le[1]:"http://"+le[1]:"mailto:"+le[0];this.makeLink(Q);return}}this.insertPlainText(M,!0)});return}}let l=t?.types;if(!Ht&&l&&(Cn.call(l,"text/html")>-1||!ys&&Cn.call(l,"text/plain")>-1&&Cn.call(l,"text/rtf")<0)){e.preventDefault();let C;!i&&(C=t.getData("text/html"))?this.insertHTML(C,!0):((C=t.getData("text/plain"))||(C=t.getData("text/uri-list")))&&this.insertPlainText(C,!0);return}let u=document.body,d=this.getSelection(),f=d.startContainer,p=d.startOffset,y=d.endContainer,E=d.endOffset,N=T("DIV",{contenteditable:"true",style:"position:fixed; overflow:hidden; top:0; right:100%; width:1px; height:1px;"});u.appendChild(N),d.selectNodeContents(N),this.setSelection(d),setTimeout(()=>{try{let C="",M=N,$;for(;N=M;)M=N.nextSibling,H(N),$=N.firstChild,$&&$===N.lastChild&&$ instanceof HTMLDivElement&&(N=$),C+=N.innerHTML;this.setSelection(Be(f,p,y,E)),C&&this.insertHTML(C,!0)}catch(C){this._config.didError(C)}},0)},Bs=function(){let e=this.getSelection();e&&!e.collapsed&&this._root.contains(e.commonAncestorContainer)?this._dragRange=e.cloneRange():this._dragRange=null},Fs=function(){this._dragRange=null},Us=(e,t,n)=>{let i=null,r=document;if(r.caretPositionFromPoint){let o=r.caretPositionFromPoint(e,t);o&&(i=document.createRange(),i.setStart(o.offsetNode,o.offset),i.collapse(!0))}else r.caretRangeFromPoint&&(i=r.caretRangeFromPoint(e,t));return i&&!n.contains(i.commonAncestorContainer)?null:i},Hs=(e,t)=>e.compareBoundaryPoints(Range.START_TO_START,t)>=0&&e.compareBoundaryPoints(Range.END_TO_END,t)<=0,zs=function(e){let t=e.dataTransfer;if(!t)return;let n=t.types,i=!1,r=!1;for(let d=0,f=n.length;d<f;d+=1)switch(n[d]){case"text/plain":i=!0;break;case"text/html":r=!0;break}if(!i&&!r)return;e.preventDefault();let o=this._root,s=Us(e.clientX,e.clientY,o),a=this._dragRange;if(this._dragRange=null,!s)return;let l,u;if(a){if(Hs(s,a))return;this._recordUndoState(a,this._isInUndoState);let d=document.createComment("");s.insertNode(d),this._getRangeAndRemoveBookmark(a),[l,u]=fr(a,o,t.dropEffect!=="copy",this._config.willCutCopy,this._config.toPlainText),d.replaceWith(T("INPUT",{id:this.startSelectionId,type:"hidden"}),T("INPUT",{id:this.endSelectionId,type:"hidden"})),this._getRangeAndRemoveBookmark(s),sr()}else this.saveUndoState(s),r?u=t.getData("text/html"):l=t.getData("text/plain");this.setSelection(s),u!==void 0?this.insertHTML(u,!0):l!==void 0&&this.insertPlainText(l,!0)},er=(e,t,n)=>{t.preventDefault(),e.splitBlock(t.shiftKey,n)},ht=(e,t)=>{try{t||(t=e.getSelection());let n=t.startContainer;n instanceof Text&&(n=n.parentNode);let i=n;for(;i!==e._root&&x(i)&&(!i.textContent||i.textContent==="\u200B");)n=i,i=n.parentNode;n!==i&&(t.setStart(i,Array.from(i.childNodes).indexOf(n)),t.collapse(!0),i.removeChild(n),we(i)||(i=Ue(i,e._root)||e._root),z(i),V(t)),n===e._root&&(n=n.firstChild)&&n.nodeName==="BR"&&H(n),e._ensureBottomLine(),e.setSelection(t),e._updatePath(t,!0)}catch(n){e._config.didError(n)}},mr=(e,t)=>{let n;for(;(n=e.parentNode)&&!(n===t||n.isContentEditable);)e=n;H(e)},gr=(e,t,n)=>{if(L(t,e._root,"A"))return;let i=t.data||"",r=Math.max(i.lastIndexOf(" ",n-1),i.lastIndexOf("\xA0",n-1))+1,o=i.slice(r,n),s=e.linkRegExp.exec(o);if(s){let a=e.getSelection();e._docWasChanged(),e._recordUndoState(a),e._getRangeAndRemoveBookmark(a);let l=r+s.index,u=l+s[0].length,d=a.startContainer===t,f=a.startOffset-u;l&&(t=t.splitText(l));let p=e._config.tagAttributes.a,y=T("A",Object.assign({href:s[1]?/^(?:ht|f)tps?:/i.test(s[1])?s[1]:"http://"+s[1]:"mailto:"+s[0]},p));y.textContent=i.slice(l,u),t.parentNode.insertBefore(y,t),t.data=i.slice(u),d&&(a.setStart(t,f),a.setEnd(t,f)),e.setSelection(a)}},qs=(e,t,n)=>{let i=e._root;if(e._removeZWS(),e.saveUndoState(n),!n.collapsed)t.preventDefault(),qe(n,i),ht(e,n);else if(pt(n,i)){t.preventDefault();let r=ie(n,i);if(!r)return;let o=r;pe(o.parentNode,i);let s=Ue(o,i);if(s){if(!s.isContentEditable){mr(s,i);return}for(ft(s,o,n,i),o=s.parentNode;o!==i&&!o.nextSibling;)o=o.parentNode;o!==i&&(o=o.nextSibling)&&_e(o,i),e.setSelection(n)}else if(o){if(L(o,i,"UL")||L(o,i,"OL")){e.decreaseListLevel(n);return}else if(L(o,i,"BLOCKQUOTE")){e.removeQuote(n);return}e.setSelection(n),e._updatePath(n,!0)}}else{V(n);let r=n.startContainer,o=n.startOffset,s=r.parentNode;r instanceof Text&&s instanceof HTMLAnchorElement&&o&&s.href.includes(r.data)?(r.deleteData(o-1,1),e.setSelection(n),e.removeLink(),t.preventDefault()):(e.setSelection(n),setTimeout(()=>{ht(e)},0))}},$s=(e,t,n)=>{let i=e._root,r,o,s,a,l,u;if(e._removeZWS(),e.saveUndoState(n),!n.collapsed)t.preventDefault(),qe(n,i),ht(e,n);else if(mt(n,i)){if(t.preventDefault(),r=ie(n,i),!r)return;if(pe(r.parentNode,i),o=Ee(r,i),o){if(!o.isContentEditable){mr(o,i);return}for(ft(r,o,n,i),o=r.parentNode;o!==i&&!o.nextSibling;)o=o.parentNode;o!==i&&(o=o.nextSibling)&&_e(o,i),e.setSelection(n),e._updatePath(n,!0)}}else{if(s=n.cloneRange(),Fe(n,i,i,i),a=n.endContainer,l=n.endOffset,a instanceof Element&&(u=a.childNodes[l],u&&u.nodeName==="IMG")){t.preventDefault(),H(u),V(n),ht(e,n);return}e.setSelection(s),setTimeout(()=>{ht(e)},0)}},Ws=(e,t,n)=>{let i=e._root;if(e._removeZWS(),n.collapsed&&pt(n,i)){let r=ie(n,i),o;for(;o=r.parentNode;){if(o.nodeName==="UL"||o.nodeName==="OL"){t.preventDefault(),e.increaseListLevel(n);break}r=o}}},Gs=(e,t,n)=>{let i=e._root;if(e._removeZWS(),n.collapsed&&pt(n,i)){let r=n.startContainer;(L(r,i,"UL")||L(r,i,"OL"))&&(t.preventDefault(),e.decreaseListLevel(n))}},Ks=(e,t,n)=>{let i,r=e._root;if(e._recordUndoState(n),e._getRangeAndRemoveBookmark(n),!n.collapsed)qe(n,r),e._ensureBottomLine(),e.setSelection(n),e._updatePath(n,!0);else if(mt(n,r)){let o=ie(n,r);if(o&&o.nodeName!=="PRE"){let s=o.textContent?.trimEnd().replace("\u200B","");if(s==="*"||s==="1."){t.preventDefault(),e.insertPlainText(" ",!1),e._docWasChanged(),e.saveUndoState(n);let a=new ne(o,4),l;for(;l=a.nextNode();)H(l);s==="*"?e.makeUnorderedList():e.makeOrderedList();return}}}if(i=n.endContainer,n.endOffset===re(i))do if(i.nodeName==="A"){n.setStartAfter(i);break}while(!i.nextSibling&&(i=i.parentNode)&&i!==r);if(e._config.addLinks){let o=n.cloneRange();V(o);let s=o.startContainer,a=o.startOffset;setTimeout(()=>{gr(e,s,a)},0)}e.setSelection(n)},js=function(e){if(e.defaultPrevented||e.isComposing)return;let t=e.key,n="",i=e.code;/^Digit\d$/.test(i)&&(t=i.slice(-1)),t!=="Backspace"&&t!=="Delete"&&(e.altKey&&(n+="Alt-"),e.ctrlKey&&(n+="Ctrl-"),e.metaKey&&(n+="Meta-"),e.shiftKey&&(n+="Shift-")),nr&&e.shiftKey&&t==="Delete"&&(n+="Shift-"),t=n+t;let r=this.getSelection(),o=this._keyHandlers[t];o?o(this,e,r):!r.collapsed&&!e.ctrlKey&&!e.metaKey&&t.length===1&&(this.saveUndoState(r),qe(r,this._root),this._ensureBottomLine(),this.setSelection(r),this._updatePath(r,!0))},B={Backspace:qs,Delete:$s,Tab:Ws,"Shift-Tab":Gs," ":Ks,ArrowLeft(e){e._removeZWS()},ArrowRight(e,t,n){e._removeZWS();let i=e.getRoot();if(mt(n,i)){V(n);let r=n.endContainer;do if(r.nodeName==="CODE"){let o=r.nextSibling;if(!(o instanceof Text)||o.length===0){let s=document.createTextNode("\xA0");r.parentNode.insertBefore(s,o),o=s}n.setStart(o,1),e.setSelection(n),t.preventDefault();break}while(!r.nextSibling&&(r=r.parentNode)&&r!==i)}}};Ts||(B.Enter=er,B["Shift-Enter"]=er);!In&&!ir&&(B.PageUp=e=>{e.moveCursorToStart()},B.PageDown=e=>{e.moveCursorToEnd()});var Je=(e,t)=>(t=t||null,(n,i)=>{i.preventDefault();let r=n.getSelection();n.hasFormat(e,null,r)?n.changeFormat(null,{tag:e},r):n.changeFormat({tag:e},t,r)});B[J+"b"]=Je("B");B[J+"i"]=Je("I");B[J+"u"]=Je("U");B[J+"Shift-7"]=Je("S");B[J+"Shift-5"]=Je("SUB",{tag:"SUP"});B[J+"Shift-6"]=Je("SUP",{tag:"SUB"});B[J+"Shift-8"]=(e,t)=>{t.preventDefault();let n=e.getPath();/(?:^|>)UL/.test(n)?e.removeList():e.makeUnorderedList()};B[J+"Shift-9"]=(e,t)=>{t.preventDefault();let n=e.getPath();/(?:^|>)OL/.test(n)?e.removeList():e.makeOrderedList()};B[J+"["]=(e,t)=>{t.preventDefault();let n=e.getPath();/(?:^|>)BLOCKQUOTE/.test(n)||!/(?:^|>)[OU]L/.test(n)?e.decreaseQuoteLevel():e.decreaseListLevel()};B[J+"]"]=(e,t)=>{t.preventDefault();let n=e.getPath();/(?:^|>)BLOCKQUOTE/.test(n)||!/(?:^|>)[OU]L/.test(n)?e.increaseQuoteLevel():e.increaseListLevel()};B[J+"d"]=(e,t)=>{t.preventDefault(),e.toggleCode()};B[J+"z"]=(e,t)=>{t.preventDefault(),e.undo()};B[J+"y"]=B[J+"Shift-z"]=B[J+"Shift-Z"]=(e,t)=>{t.preventDefault(),e.redo()};var xn=8,tr=40,Nn=1200,Vs=[{pos:"nw",cursor:"nwse-resize"},{pos:"n",cursor:"ns-resize"},{pos:"ne",cursor:"nesw-resize"},{pos:"e",cursor:"ew-resize"},{pos:"se",cursor:"nwse-resize"},{pos:"s",cursor:"ns-resize"},{pos:"sw",cursor:"nesw-resize"},{pos:"w",cursor:"ew-resize"}],Ys={ArrowUp:(e,t,n)=>{let i=ie(t,n);if(i){let r=Ue(i,n);r&&(t.selectNodeContents(r),t.collapse(!1),e.setSelection(t).focus())}},ArrowDown:(e,t,n)=>{let i=ie(t,n);if(i){let r=Ee(i,n);r&&(t.selectNodeContents(r),t.collapse(!0),e.setSelection(t).focus())}},Delete:(e,t)=>{e.replaceWithBlankLine(t)},Backspace:(e,t)=>{e.replaceWithBlankLine(t)}},Xs=class{constructor(e,t){this._currentImage=null,this._resizeContainer=null,this._handles=null,this._currentHandle=null,this._startX=0,this._startY=0,this._startWidth=0,this._startHeight=0,this._maxWidth=Nn,this._originalRatio=1,this._editor=t,this._root=e,document.addEventListener("click",this),t.addEventListener("drop",this)}destroy(){this._deselectImage(),this._editor.removeEventListener("drop",this),document.removeEventListener("click",this)}handleEvent(e){switch(e.type){case"click":this._onClick(e);break;case"pointerdown":this._onPointerDown(e);break;case"pointermove":this._onPointerMove(e);break;case"pointercancel":case"pointerup":this._onPointerUp(e);break;case"keydown":this._onKeyDown(e);break;case"drop":this._deselectImage();break}}_onClick(e){let t=e.target;t.nodeName==="IMG"&&this._root.contains(t)?(e.stopPropagation(),this._selectImage(t)):this._currentImage&&this._handles&&!this._handles.some(n=>n.element===t)&&this._deselectImage()}_deselectImage(){this._currentImage&&(document.removeEventListener("keydown",this,!0),this._currentHandle&&this._onPointerUp({preventDefault(){},target:this._currentHandle.element}),this._handles&&this._handles.forEach(({element:e})=>e.removeEventListener("pointerdown",this)),this._resizeContainer&&this._resizeContainer.remove(),this._currentImage.removeAttribute("tabindex"),this._handles=null,this._resizeContainer=null,this._currentImage=null)}_selectImage(e){if(this._currentImage===e)return;this._deselectImage(),this._root.blur();let t=Vs.map(({pos:r,cursor:o})=>{let s=xn/2,a="";switch(r){case"nw":a=`left: -${s}px; top: -${s}px;`;break;case"n":a=`left: calc(50% - ${s}px); top: -${s}px;`;break;case"ne":a=`right: -${s}px; top: -${s}px;`;break;case"e":a=`right: -${s}px; top: calc(50% - ${s}px);`;break;case"se":a=`right: -${s}px; bottom: -${s}px;`;break;case"s":a=`left: calc(50% - ${s}px); bottom: -${s}px;`;break;case"sw":a=`left: -${s}px; bottom: -${s}px;`;break;case"w":a=`left: -${s}px; top: calc(50% - ${s}px);`;break}let l=T("div",{class:`squire-resize-handle squire-resize-handle-${r}`,style:`
|
|
2
|
+
var richclay=(()=>{var An=Object.defineProperty;var ls=Object.getOwnPropertyDescriptor;var cs=Object.getOwnPropertyNames;var us=Object.prototype.hasOwnProperty;var ds=(e,t)=>{for(var n in t)An(e,n,{get:t[n],enumerable:!0})},hs=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of cs(t))!us.call(e,r)&&r!==n&&An(e,r,{get:()=>t[r],enumerable:!(i=ls(t,r))||i.enumerable});return e};var fs=e=>hs(An({},"__esModule",{value:!0}),e);var Dl={};ds(Dl,{RichClay:()=>Ve,default:()=>Ol});var ps=()=>!0,ne=class{constructor(e,t,n){this.root=e,this.currentNode=e,this.nodeType=t,this.filter=n||ps}isAcceptableNode(e){let t=e.nodeType;return!!((t===Node.ELEMENT_NODE?1:t===Node.TEXT_NODE?4:0)&this.nodeType)&&this.filter(e)}nextNode(){let e=this.root,t=this.currentNode,n;for(;;){for(n=t.firstChild;!n&&t&&t!==e;)n=t.nextSibling,n||(t=t.parentNode);if(!n)return null;if(this.isAcceptableNode(n))return this.currentNode=n,n;t=n}}previousNode(){let e=this.root,t=this.currentNode,n;for(;;){if(t===e)return null;if(n=t.previousSibling,n)for(;t=n.lastChild;)n=t;else n=t.parentNode;if(!n)return null;if(this.isAcceptableNode(n))return this.currentNode=n,n;t=n}}previousPONode(){let e=this.root,t=this.currentNode,n;for(;;){for(n=t.lastChild;!n&&t&&t!==e;)n=t.previousSibling,n||(t=t.parentNode);if(!n)return null;if(this.isAcceptableNode(n))return this.currentNode=n,n;t=n}}},ze=navigator.userAgent,kn=/Mac OS X/.test(ze),er=/Windows NT/.test(ze),tr=/iP(?:ad|hone|od)/.test(ze)||kn&&!!navigator.maxTouchPoints,Il=/Android/.test(ze),ms=/Gecko\//.test(ze),Ht=/Edge\//.test(ze),gs=!Ht&&/WebKit\//.test(ze),J=kn||tr?"Meta-":"Ctrl-",Ut=gs,ys="onbeforeinput"in document&&"inputType"in new InputEvent("input"),he=/[^ \t\r\n\u200B]/,bs=/^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|EL|FN)|EM|FONT|HR|I(?:FRAME|MG|NPUT|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:AMP|MALL|PAN|TR(?:IKE|ONG)|U[BP])?|TIME|U|VAR|WBR)$/,Ts=new Set(["BR","HR","IFRAME","IMG","INPUT"]),_s=0,Ln=1,nr=2,ir=3,Ft=new WeakMap,rr=()=>{Ft=new WeakMap},Re=e=>Ts.has(e.nodeName),In=e=>{switch(e.nodeType){case 8:case 3:return Ln;case 1:case 11:if(Ft.has(e))return Ft.get(e);break;default:return _s}let t;return Array.from(e.childNodes).every(N)?bs.test(e.nodeName)?t=Ln:t=nr:t=ir,Ft.set(e,t),t},N=e=>In(e)===Ln,xe=e=>In(e)===nr,Qe=e=>In(e)===ir,T=(e,t,n)=>{let i=document.createElement(e);if(t instanceof Array&&(n=t,t=null),t)for(let r in t){let o=t[r];o!==void 0&&i.setAttribute(r,o)}return n&&n.forEach(r=>i.appendChild(r)),i},or=(e,t)=>Re(e)||e.nodeType!==t.nodeType||e.nodeName!==t.nodeName?!1:e instanceof HTMLElement&&t instanceof HTMLElement?e.nodeName!=="A"&&e.className===t.className&&e.style.cssText===t.style.cssText:!0,wn=(e,t,n)=>{if(e.nodeName!==t)return!1;for(let i in n)if(!("getAttribute"in e)||e.getAttribute(i)!==n[i])return!1;return!0},L=(e,t,n,i)=>{for(;e&&e!==t;){if(wn(e,n,i))return e;e=e.parentNode}return null},Mn=(e,t)=>{let n=e.childNodes;for(;t&&e instanceof Element;)e=n[t-1],n=e.childNodes,t=n.length;return e},sr=(e,t)=>{let n=e;if(n instanceof Element){let i=n.childNodes;if(t<i.length)n=i[t];else{for(;n&&!n.nextSibling;)n=n.parentNode;n&&(n=n.nextSibling)}}return n},re=e=>e instanceof Element||e instanceof DocumentFragment?e.childNodes.length:e instanceof CharacterData?e.length:0,D=e=>{let t=document.createDocumentFragment(),n=e.firstChild;for(;n;)t.appendChild(n),n=e.firstChild;return t},H=e=>{let t=e.parentNode;return t&&t.removeChild(e),e},$=(e,t)=>{let n=e.parentNode;n&&n.replaceChild(t,e)},Es=e=>e instanceof Element?e.nodeName==="BR":he.test(e.data),qt=(e,t)=>{let n=e.parentNode;for(;N(n);)n=n.parentNode;let i=new ne(n,5,Es);return i.currentNode=e,!!i.nextNode()||t&&!i.previousNode()},Pt=(e,t)=>{let n=new ne(e,4),i,r;for(;i=n.nextNode();)for(;(r=i.data.indexOf("\u200B"))>-1&&(!t||i.parentNode!==t);)if(i.length===1){let o=i,s=o.parentNode;for(;s&&(s.removeChild(o),n.currentNode=s,!(!N(s)||re(s)));)o=s,s=o.parentNode;break}else i.deleteData(r,1)},Ss=0,As=1,vs=2,Cs=3,we=(e,t,n)=>{let i=document.createRange();if(i.selectNode(t),n){let r=e.compareBoundaryPoints(Cs,i)>-1,o=e.compareBoundaryPoints(As,i)<1;return!r&&!o}else{let r=e.compareBoundaryPoints(Ss,i)<1,o=e.compareBoundaryPoints(vs,i)>-1;return r&&o}},j=e=>{let{startContainer:t,startOffset:n,endContainer:i,endOffset:r}=e;for(;!(t instanceof Text);){let o=t.childNodes[n];if(!o||Re(o)){if(n&&(o=t.childNodes[n-1],o instanceof Text)){let s=o,a;for(;!s.length&&(a=s.previousSibling)&&a instanceof Text;)s.remove(),s=a;t=s,n=s.data.length}break}t=o,n=0}if(r)for(;!(i instanceof Text);){let o=i.childNodes[r-1];if(!o||Re(o)){if(o&&o.nodeName==="BR"&&!qt(o,!1)){r-=1;continue}break}i=o,r=re(i)}else for(;!(i instanceof Text);){let o=i.firstChild;if(!o||Re(o))break;i=o}e.setStart(t,n),e.setEnd(i,r)},Fe=(e,t,n,i)=>{let r=e.startContainer,o=e.startOffset,s=e.endContainer,a=e.endOffset,l;for(t||(t=e.commonAncestorContainer),n||(n=t);!o&&r!==t&&r!==i;)l=r.parentNode,o=Array.from(l.childNodes).indexOf(r),r=l;for(;!(s===n||s===i||(s.nodeType!==3&&s.childNodes[a]&&s.childNodes[a].nodeName==="BR"&&!qt(s.childNodes[a],!1)&&(a+=1),a!==re(s)));)l=s.parentNode,a=Array.from(l.childNodes).indexOf(s)+1,s=l;e.setStart(r,o),e.setEnd(s,a)},Ki=(e,t,n)=>{let i=L(e.endContainer,n,t);if(i&&(i=i.parentNode)){let r=e.cloneRange();Fe(r,i,i,n),r.endContainer===i&&(e.setStart(r.endContainer,r.endOffset),e.setEnd(r.endContainer,r.endOffset))}return e},U=e=>{let t=null;if(e instanceof Text)return e;if(N(e)){let n=e.firstChild;if(Ut)for(;n&&n instanceof Text&&!n.data;)e.removeChild(n),n=e.firstChild;n||(Ut?t=document.createTextNode("\u200B"):t=document.createTextNode(""))}else if((e instanceof Element||e instanceof DocumentFragment)&&!e.querySelector("BR")&&!he.test(e.textContent||"")){t=T("BR");let n=e,i;for(;(i=n.lastElementChild)&&!N(i);)n=i;e=n,e instanceof HTMLElement&&e.contentEditable==="true"&&(e=T("DIV"),n.appendChild(e))}if(t)try{e.appendChild(t)}catch{}return e},fe=(e,t)=>{let n=null;return/^(?:TABLE|TBODY|TR|TH|TD|P)/.test(e.nodeName)||(Array.from(e.childNodes).forEach(i=>{let r=i.nodeName==="BR";!r&&N(i)?(n||(n=T("DIV")),n.appendChild(i)):(r||n)&&(n||(n=T("DIV")),U(n),r?e.replaceChild(n,i):e.insertBefore(n,i),n=null),Qe(i)&&fe(i,t)}),n&&e.appendChild(U(n))),e},se=(e,t,n,i)=>{if(!n.contains(e))throw new Error("split: stopNode does not contain node");if(e instanceof Text&&e!==n){if(typeof t!="number")throw new Error("Offset must be a number to split text node!");if(!e.parentNode)throw new Error("Cannot split text node with no parent!");return se(e.parentNode,e.splitText(t),n,i)}let r=typeof t=="number"?t<e.childNodes.length?e.childNodes[t]:null:t,o=e.parentNode;if(!o||e===n||!(e instanceof Element))return r;let s=e.cloneNode(!1);for(;r;){let a=r.nextSibling;s.appendChild(r),r=a}return e instanceof HTMLOListElement&&L(e,i,"BLOCKQUOTE")&&(s.start=(+e.start||1)+e.childNodes.length-1),U(e),U(s),o.insertBefore(s,e.nextSibling),se(o,s,n,i)},ar=(e,t)=>{let n=e.childNodes,i=n.length,r=[];for(;i--;){let o=n[i],s=i?n[i-1]:null;if(s&&N(o)&&or(o,s))t.startContainer===o&&(t.startContainer=s,t.startOffset+=re(s)),t.endContainer===o&&(t.endContainer=s,t.endOffset+=re(s)),t.startContainer===e&&(t.startOffset>i?t.startOffset-=1:t.startOffset===i&&(t.startContainer=s,t.startOffset=re(s))),t.endContainer===e&&(t.endOffset>i?t.endOffset-=1:t.endOffset===i&&(t.endContainer=s,t.endOffset=re(s))),H(o),o instanceof Text?s.appendData(o.data):r.push(D(o));else if(o instanceof Element){let a;for(;a=r.pop();)o.appendChild(a);ar(o,t)}}},Xe=(e,t)=>{let n=e instanceof Text?e.parentNode:e;if(n instanceof Element){let i={startContainer:t.startContainer,startOffset:t.startOffset,endContainer:t.endContainer,endOffset:t.endOffset};ar(n,i),t.setStart(i.startContainer,i.startOffset),t.setEnd(i.endContainer,i.endOffset)}},ft=(e,t,n,i)=>{let r=t,o,s;for(;(o=r.parentNode)&&o!==i&&o instanceof Element&&o.childNodes.length===1;)r=o;H(r),s=e.childNodes.length;let a=e.lastChild;a&&a.nodeName==="BR"&&(e.removeChild(a),s-=1),e.appendChild(D(t)),n.setStart(e,s),n.collapse(!0),Xe(e,n)},_e=(e,t)=>{let n=e.previousSibling,i=e.firstChild,r=e.nodeName==="LI";if(!(r&&(!i||!/^[OU]L$/.test(i.nodeName)))){if(n&&or(n,e)){if(!Qe(n))if(r){let s=T("DIV");s.appendChild(D(n)),n.appendChild(s)}else return;H(e);let o=!Qe(e);n.appendChild(D(e)),o&&fe(n,t),i&&_e(i,t)}else if(r){let o=T("DIV");e.insertBefore(o,i),U(o)}}},$i={"font-weight":{regexp:/^bold|^700/i,replace(){return T("B")}},"font-style":{regexp:/^italic/i,replace(){return T("I")}},"font-family":{regexp:he,replace(e,t){let n=T("SPAN",{class:e.fontFamily});return n.style.fontFamily=t,n}},"font-size":{regexp:he,replace(e,t){let n=T("SPAN",{class:e.fontSize});return n.style.fontSize=t,n}},"text-decoration":{regexp:/^underline/i,replace(){return T("U")}}},Ns=(e,t,n)=>{let i=e.style,r,o;for(let s in $i){let a=$i[s],l=i.getPropertyValue(s);if(l&&a.regexp.test(l)){let u=a.replace(n.classNames,l);if(u.nodeName===e.nodeName&&u.className===e.className)continue;o||(o=u),r&&r.appendChild(u),r=u,e.style.removeProperty(s)}}return o&&r&&(r.appendChild(D(e)),e.style.cssText?e.appendChild(o):$(e,o)),r||e},Bt=e=>(t,n)=>{let i=T(e),r=t.attributes;for(let o=0,s=r.length;o<s;o+=1){let a=r[o];i.setAttribute(a.name,a.value)}return n.replaceChild(i,t),i.appendChild(D(t)),i},Ls={1:"10",2:"13",3:"16",4:"18",5:"24",6:"32",7:"48"},ws={STRONG:Bt("B"),EM:Bt("I"),INS:Bt("U"),STRIKE:Bt("S"),SPAN:Ns,FONT:(e,t,n)=>{let i=e,r=i.face,o=i.size,s=i.color,a=n.classNames,l,u,d,h,p;return r&&(l=T("SPAN",{class:a.fontFamily}),l.style.fontFamily=r,p=l,h=l),o&&(u=T("SPAN",{class:a.fontSize}),u.style.fontSize=Ls[o]+"px",p||(p=u),h&&h.appendChild(u),h=u),s&&/^#?([\dA-F]{3}){1,2}$/i.test(s)&&(s.charAt(0)!=="#"&&(s="#"+s),d=T("SPAN",{class:a.color}),d.style.color=s,p||(p=d),h&&h.appendChild(d),h=d),(!p||!h)&&(p=h=T("SPAN")),t.replaceChild(p,i),h.appendChild(D(i)),h},TT:(e,t,n)=>{let i=T("SPAN",{class:n.classNames.fontFamily,style:'font-family:menlo,consolas,"courier new",monospace'});return t.replaceChild(i,e),i.appendChild(D(e)),i}},xs=/^(?:A(?:DDRESS|RTICLE|SIDE|UDIO)|BLOCKQUOTE|CAPTION|D(?:[DLT]|IV)|F(?:IGURE|IGCAPTION|OOTER)|H[1-6]|HEADER|L(?:ABEL|EGEND|I)|O(?:L|UTPUT)|P(?:RE)?|SECTION|T(?:ABLE|BODY|D|FOOT|H|HEAD|R)|COL(?:GROUP)?|UL)$/,Rs=/^(?:HEAD|META|STYLE)/,xn=(e,t,n)=>{let i=e.childNodes,r=e;for(;N(r);)r=r.parentNode;let o=new ne(r,5);for(let s=0,a=i.length;s<a;s+=1){let l=i[s],u=l.nodeName,d=ws[u];if(l instanceof HTMLElement){let h=l.childNodes.length;if(d)l=d(l,e,t);else if(Rs.test(u)){e.removeChild(l),s-=1,a-=1;continue}else if(!xs.test(u)&&!N(l)){s-=1,a+=h-1,e.replaceChild(D(l),l);continue}h&&xn(l,t,n||u==="PRE")}else{if(l instanceof Text){let h=l.data,p=!he.test(h.charAt(0)),y=!he.test(h.charAt(h.length-1));if(n||!p&&!y)continue;if(p){o.currentNode=l;let _;for(;(_=o.previousPONode())&&!(_.nodeName==="IMG"||_ instanceof Text&&he.test(_.data));)if(!N(_)){_=null;break}h=h.replace(/^[ \t\r\n]+/g,_?" ":"")}if(y){o.currentNode=l;let _;for(;(_=o.nextNode())&&!(_.nodeName==="IMG"||_ instanceof Text&&he.test(_.data));)if(!N(_)){_=null;break}h=h.replace(/[ \t\r\n]+$/g,_?" ":"")}if(h){l.data=h;continue}}e.removeChild(l),s-=1,a-=1}}return e},Rn=e=>{let t=e.childNodes,n=t.length;for(;n--;){let i=t[n];i instanceof Element&&!Re(i)?(Rn(i),N(i)&&!i.firstChild&&e.removeChild(i)):i instanceof Text&&!i.data&&e.removeChild(i)}},On=(e,t,n)=>{let i=e.querySelectorAll("BR"),r=[],o=i.length;for(let s=0;s<o;s+=1)r[s]=qt(i[s],n);for(;o--;){let s=i[o],a=s.parentNode;a&&(r[o]?N(a)||fe(a,t):H(s))}},ji=e=>e.split("&").join("&").split("<").join("<").split(">").join(">").split('"').join("""),zt=(e,t)=>{let n=new ne(t,1,xe);return n.currentNode=e,n},He=(e,t)=>{let n=zt(e,t).previousNode();return n!==t?n:null},Ee=(e,t)=>{let n=zt(e,t).nextNode();return n!==t?n:null},Dn=e=>!e.textContent&&!e.querySelector("IMG"),ie=(e,t)=>{let n=e.startContainer,i;if(N(n))i=He(n,t);else if(n!==t&&n instanceof HTMLElement&&xe(n))i=n;else{let r=Mn(n,e.startOffset);i=Ee(r,t)}return i&&we(e,i,!0)?i:null},Ue=(e,t)=>{let n=e.endContainer,i;if(N(n))i=He(n,t);else if(n!==t&&n instanceof HTMLElement&&xe(n))i=n;else{let r=sr(n,e.endOffset);if(!r||!t.contains(r)){r=t;let o;for(;o=r.lastChild;)r=o}i=He(r,t)}return i&&we(e,i,!0)?i:null},lr=e=>e instanceof Text?he.test(e.data):e.nodeName==="IMG",pt=(e,t)=>{let n=e.startContainer,i=e.startOffset,r;if(n instanceof Text){let a=n.data;for(let l=i;l>0;l-=1)if(a.charAt(l-1)!=="\u200B")return!1;r=n}else if(r=sr(n,i),r&&!t.contains(r)&&(r=null),!r&&(r=Mn(n,i),r instanceof Text&&r.length))return!1;let o=ie(e,t);if(!o)return!1;let s=new ne(o,5,lr);return s.currentNode=r,!s.previousNode()},mt=(e,t)=>{let n=e.endContainer,i=e.endOffset,r;if(n instanceof Text){let a=n.data,l=a.length;for(let u=i;u<l;u+=1)if(a.charAt(u)!=="\u200B")return!1;r=n}else r=Mn(n,i);let o=Ue(e,t);if(!o)return!1;let s=new ne(o,5,lr);return s.currentNode=r,!s.nextNode()},Zi=(e,t)=>{let n=ie(e,t),i=Ue(e,t),r;n&&i&&(r=n.parentNode,e.setStart(r,Array.from(r.childNodes).indexOf(n)),r=i.parentNode,e.setEnd(r,Array.from(r.childNodes).indexOf(i)+1))};function Be(e,t,n,i){let r=document.createRange();return r.setStart(e,t),n&&typeof i=="number"?r.setEnd(n,i):r.setEnd(e,t),r}var Te=(e,t)=>{let{startContainer:n,startOffset:i,endContainer:r,endOffset:o}=e,s;if(n instanceof Text){let l=n.parentNode;if(s=l.childNodes,i===n.length)i=Array.from(s).indexOf(n)+1,e.collapsed&&(r=l,o=i);else{if(i){let u=n.splitText(i);r===n?(o-=i,r=u):r===l&&(o+=1),n=u}i=Array.from(s).indexOf(n)}n=l}else s=n.childNodes;let a=s.length;i===a?n.appendChild(t):n.insertBefore(t,s[i]),n===r&&(o+=s.length-a),e.setStart(n,i),e.setEnd(r,o)},cr=(e,t,n)=>{let i=document.createDocumentFragment();if(e.collapsed)return i;t||(t=e.commonAncestorContainer),t instanceof Text&&(t=t.parentNode);let r=e.startContainer,o=e.startOffset,s=se(e.endContainer,e.endOffset,t,n),a=0,l=se(r,o,t,n);for(;l&&l!==s;){let u=l.nextSibling;i.appendChild(l),l=u}return l=s&&s.previousSibling,l&&l instanceof Text&&s instanceof Text&&(a=l.length,l.appendData(s.data),H(s),s=l),e.setStart(r,o),s?e.setEnd(s,a):e.setEnd(t,t.childNodes.length),U(t),i},Yi=(e,t,n)=>{e.currentNode=n;let i;for(;i=e[t]();){if(i instanceof Text||Re(i))return i;if(!N(i))return null}return null},qe=(e,t)=>{let n=ie(e,t),i=Ue(e,t),r=n!==i;n&&i&&(j(e),Fe(e,n,i,t));let o=cr(e,null,t);j(e),r&&(i=Ue(e,t),n&&i&&n!==i&&ft(n,i,e,t)),n&&U(n);let s=t.firstChild;(!s||s.nodeName==="BR")&&(U(t),t.firstChild&&e.selectNodeContents(t.firstChild)),e.collapse(!0);let a=e.startContainer,l=e.startOffset,u=new ne(t,5),d=a,h=l;(!(d instanceof Text)||h===d.data.length)&&(d=Yi(u,"nextNode",d),h=0);let p=a,y=l-1;(!(p instanceof Text)||y===-1)&&(p=Yi(u,"previousPONode",d||(a instanceof Text?a:a.childNodes[l]||a)),p instanceof Text&&(y=p.data.length));let _=null,C=0;return d instanceof Text&&d.data.charAt(h)===" "&&pt(e,t)?(_=d,C=h):p instanceof Text&&p.data.charAt(y)===" "&&(d instanceof Text&&d.data.charAt(h)===" "||mt(e,t))&&(_=p,C=y),_&&_.replaceData(C,1,"\xA0"),e.setStart(a,l),e.collapse(!0),o},Os=(e,t,n)=>{let i=t.firstChild&&N(t.firstChild),r;for(fe(t,n),r=t;r=Ee(r,n);)U(r);e.collapsed||qe(e,n),j(e),e.collapse(!1);let o=L(e.endContainer,n,"BLOCKQUOTE")||n,s=ie(e,n),a=null,l=Ee(t,t),u=!i&&!!s&&Dn(s);if(s&&l&&!u&&!L(l,t,"PRE")&&!L(l,t,"TABLE")){Fe(e,s,s,n),e.collapse(!0);let d=e.endContainer,h=e.endOffset;if(On(s,n,!1),N(d)){let p=se(d,h,He(d,n)||n,n);d=p.parentNode,h=Array.from(d.childNodes).indexOf(p)}if(h!==re(d))for(a=document.createDocumentFragment();r=d.childNodes[h];)a.appendChild(r);ft(d,l,e,n),d===n?e.setEnd(n,re(n)):(h=Array.from(d.parentNode.childNodes).indexOf(d)+1,d=d.parentNode,e.setEnd(d,h))}if(re(t)){u&&s&&(e.setEndBefore(s),e.collapse(!1),H(s)),o.contains(e.endContainer)||(n.contains(e.endContainer)||(e.setEnd(n,re(n)),e.collapse(!1)),o=L(e.endContainer,n,"BLOCKQUOTE")||n),Fe(e,o,o,n);let d=se(e.endContainer,e.endOffset,o,n),h=d?d.previousSibling:o.lastChild;o.insertBefore(t,d),d?e.setEndBefore(d):e.setEnd(o,re(o)),s=Ue(e,n),j(e);let p=e.endContainer,y=e.endOffset;d&&Qe(d)&&_e(d,n),d=h&&h.nextSibling,d&&Qe(d)&&_e(d,n),e.setEnd(p,y)}if(a&&s){let d=e.cloneRange();U(a),ft(s,a,d,n),e.setEnd(d.endContainer,d.endOffset)}j(e)},ur=e=>{if(e.collapsed)return"";let t=e.startContainer,n=e.endContainer,i=new ne(e.commonAncestorContainer,5,l=>we(e,l,!0));i.currentNode=t;let r=t,o="",s=!1,a;for((!(r instanceof Element)&&!(r instanceof Text)||!i.filter(r))&&(r=i.nextNode());r;)r instanceof Text?(a=r.data,a&&/\S/.test(a)&&(r===n&&(a=a.slice(0,e.endOffset)),r===t&&(a=a.slice(e.startOffset)),o+=a,s=!0)):(r.nodeName==="BR"||s&&!N(r))&&(o+=`
|
|
3
|
+
`,s=!1),r=i.nextNode();return o=o.replace(/ /g," "),o},vn=Array.prototype.indexOf,dr=(e,t,n,i,r)=>{let o=r?"":ur(e),s=ie(e,t),a=Ue(e,t),l=e.commonAncestorContainer,u=t;s===a&&s?.contains(l)&&(u=s);let d;for(n?(d=qe(e,t),l.isConnected||(l=e.commonAncestorContainer)):d=e.cloneContents(),l instanceof Text&&(l=l.parentNode);l&&l!==u;){let p=l.cloneNode(!1);p.appendChild(d),d=p,l=l.parentNode}let h;if(d.childNodes.length===1&&d.childNodes[0]instanceof Text)o=d.childNodes[0].data.replace(/ /g," "),h=void 0;else{let p=T("DIV");p.appendChild(d),h=p.innerHTML,i&&(h=i(h))}return r&&h!==void 0&&(o=r(h)),o===h&&(h=void 0),er&&(o=o.replace(/\r?\n/g,`\r
|
|
4
|
+
`)),h&&(h="<!-- squire -->"+h),[o,h]},hr=(e,t,n,i,r,o,s)=>{let a=e.clipboardData;if(Ht||!a)return!1;let[l,u]=dr(t,n,i,r,o);return e.preventDefault(),!s&&u&&a.setData("text/html",u),a.setData("text/plain",l),!0},Ds=function(e){let t=this.getSelection(),n=this._root;if(t.collapsed){e.preventDefault();return}this.saveUndoState(t),hr(e,t,n,!0,this._config.willCutCopy,this._config.toPlainText,!1)||setTimeout(()=>{try{this._ensureBottomLine()}catch(i){this._config.didError(i)}},0),this.setSelection(t)},ks=function(e){hr(e,this.getSelection(),this._root,!1,this._config.willCutCopy,this._config.toPlainText,!1)},Xi=function(e){this._isShiftDown=e.shiftKey},Is=function(e){let t=e.clipboardData,n=t?.items,i=this._isShiftDown,r=!1,o=!1,s=null,a=null;if(n){let v=n.length;for(;v--;){let I=n[v],W=I.type;W==="text/html"?a=I:W==="text/plain"||W==="text/uri-list"?s=I:W==="text/rtf"?r=!0:/^image\/.*/.test(W)&&(o=!0)}if(o&&!(r&&a)&&!s){e.preventDefault(),this.fireEvent("pasteImage",{clipboardData:t});return}if(!Ht){e.preventDefault(),a&&(!i||!s)?a.getAsString(I=>{this.insertHTML(I,!0)}):s&&s.getAsString(I=>{let W=this.getSelection();if(!W.collapsed&&he.test(W.toString())){let ae=this.linkRegExp.exec(I);if(ae&&ae[0].length===I.length){let X=ae[1]?/^(?:ht|f)tps?:/i.test(ae[1])?ae[1]:"http://"+ae[1]:"mailto:"+ae[0];this.makeLink(X);return}}this.insertPlainText(I,!0)});return}}let l=t?.types;if(!Ht&&l&&(vn.call(l,"text/html")>-1||!ms&&vn.call(l,"text/plain")>-1&&vn.call(l,"text/rtf")<0)){e.preventDefault();let v;!i&&(v=t.getData("text/html"))?this.insertHTML(v,!0):((v=t.getData("text/plain"))||(v=t.getData("text/uri-list")))&&this.insertPlainText(v,!0);return}let u=document.body,d=this.getSelection(),h=d.startContainer,p=d.startOffset,y=d.endContainer,_=d.endOffset,C=T("DIV",{contenteditable:"true",style:"position:fixed; overflow:hidden; top:0; right:100%; width:1px; height:1px;"});u.appendChild(C),d.selectNodeContents(C),this.setSelection(d),setTimeout(()=>{try{let v="",I=C,W;for(;C=I;)I=C.nextSibling,H(C),W=C.firstChild,W&&W===C.lastChild&&W instanceof HTMLDivElement&&(C=W),v+=C.innerHTML;this.setSelection(Be(h,p,y,_)),v&&this.insertHTML(v,!0)}catch(v){this._config.didError(v)}},0)},Ms=function(){let e=this.getSelection();e&&!e.collapsed&&this._root.contains(e.commonAncestorContainer)?this._dragRange=e.cloneRange():this._dragRange=null},Ps=function(){this._dragRange=null},Bs=(e,t,n)=>{let i=null,r=document;if(r.caretPositionFromPoint){let o=r.caretPositionFromPoint(e,t);o&&(i=document.createRange(),i.setStart(o.offsetNode,o.offset),i.collapse(!0))}else r.caretRangeFromPoint&&(i=r.caretRangeFromPoint(e,t));return i&&!n.contains(i.commonAncestorContainer)?null:i},Fs=(e,t)=>e.compareBoundaryPoints(Range.START_TO_START,t)>=0&&e.compareBoundaryPoints(Range.END_TO_END,t)<=0,Hs=function(e){let t=e.dataTransfer;if(!t)return;let n=t.types,i=!1,r=!1;for(let d=0,h=n.length;d<h;d+=1)switch(n[d]){case"text/plain":i=!0;break;case"text/html":r=!0;break}if(!i&&!r)return;e.preventDefault();let o=this._root,s=Bs(e.clientX,e.clientY,o),a=this._dragRange;if(this._dragRange=null,!s)return;let l,u;if(a){if(Fs(s,a))return;this._recordUndoState(a,this._isInUndoState);let d=document.createComment("");s.insertNode(d),this._getRangeAndRemoveBookmark(a),[l,u]=dr(a,o,t.dropEffect!=="copy",this._config.willCutCopy,this._config.toPlainText),d.replaceWith(T("INPUT",{id:this.startSelectionId,type:"hidden"}),T("INPUT",{id:this.endSelectionId,type:"hidden"})),this._getRangeAndRemoveBookmark(s),rr()}else this.saveUndoState(s),r?u=t.getData("text/html"):l=t.getData("text/plain");this.setSelection(s),u!==void 0?this.insertHTML(u,!0):l!==void 0&&this.insertPlainText(l,!0)},Qi=(e,t,n)=>{t.preventDefault(),e.splitBlock(t.shiftKey,n)},ht=(e,t)=>{try{t||(t=e.getSelection());let n=t.startContainer;n instanceof Text&&(n=n.parentNode);let i=n;for(;i!==e._root&&N(i)&&(!i.textContent||i.textContent==="\u200B");)n=i,i=n.parentNode;n!==i&&(t.setStart(i,Array.from(i.childNodes).indexOf(n)),t.collapse(!0),i.removeChild(n),xe(i)||(i=He(i,e._root)||e._root),U(i),j(t)),n===e._root&&(n=n.firstChild)&&n.nodeName==="BR"&&H(n),e._ensureBottomLine(),e.setSelection(t),e._updatePath(t,!0)}catch(n){e._config.didError(n)}},fr=(e,t)=>{let n;for(;(n=e.parentNode)&&!(n===t||n.isContentEditable);)e=n;H(e)},pr=(e,t,n)=>{if(L(t,e._root,"A"))return;let i=t.data||"",r=Math.max(i.lastIndexOf(" ",n-1),i.lastIndexOf("\xA0",n-1))+1,o=i.slice(r,n),s=e.linkRegExp.exec(o);if(s){let a=e.getSelection();e._docWasChanged(),e._recordUndoState(a),e._getRangeAndRemoveBookmark(a);let l=r+s.index,u=l+s[0].length,d=a.startContainer===t,h=a.startOffset-u;l&&(t=t.splitText(l));let p=e._config.tagAttributes.a,y=T("A",Object.assign({href:s[1]?/^(?:ht|f)tps?:/i.test(s[1])?s[1]:"http://"+s[1]:"mailto:"+s[0]},p));y.textContent=i.slice(l,u),t.parentNode.insertBefore(y,t),t.data=i.slice(u),d&&(a.setStart(t,h),a.setEnd(t,h)),e.setSelection(a)}},Us=(e,t,n)=>{let i=e._root;if(e._removeZWS(),e.saveUndoState(n),!n.collapsed)t.preventDefault(),qe(n,i),ht(e,n);else if(pt(n,i)){t.preventDefault();let r=ie(n,i);if(!r)return;let o=r;fe(o.parentNode,i);let s=He(o,i);if(s){if(!s.isContentEditable){fr(s,i);return}for(ft(s,o,n,i),o=s.parentNode;o!==i&&!o.nextSibling;)o=o.parentNode;o!==i&&(o=o.nextSibling)&&_e(o,i),e.setSelection(n)}else if(o){if(L(o,i,"UL")||L(o,i,"OL")){e.decreaseListLevel(n);return}else if(L(o,i,"BLOCKQUOTE")){e.removeQuote(n);return}e.setSelection(n),e._updatePath(n,!0)}}else{j(n);let r=n.startContainer,o=n.startOffset,s=r.parentNode;r instanceof Text&&s instanceof HTMLAnchorElement&&o&&s.href.includes(r.data)?(r.deleteData(o-1,1),e.setSelection(n),e.removeLink(),t.preventDefault()):(e.setSelection(n),setTimeout(()=>{ht(e)},0))}},zs=(e,t,n)=>{let i=e._root,r,o,s,a,l,u;if(e._removeZWS(),e.saveUndoState(n),!n.collapsed)t.preventDefault(),qe(n,i),ht(e,n);else if(mt(n,i)){if(t.preventDefault(),r=ie(n,i),!r)return;if(fe(r.parentNode,i),o=Ee(r,i),o){if(!o.isContentEditable){fr(o,i);return}for(ft(r,o,n,i),o=r.parentNode;o!==i&&!o.nextSibling;)o=o.parentNode;o!==i&&(o=o.nextSibling)&&_e(o,i),e.setSelection(n),e._updatePath(n,!0)}}else{if(s=n.cloneRange(),Fe(n,i,i,i),a=n.endContainer,l=n.endOffset,a instanceof Element&&(u=a.childNodes[l],u&&u.nodeName==="IMG")){t.preventDefault(),H(u),j(n),ht(e,n);return}e.setSelection(s),setTimeout(()=>{ht(e)},0)}},qs=(e,t,n)=>{let i=e._root;if(e._removeZWS(),n.collapsed&&pt(n,i)){let r=ie(n,i),o;for(;o=r.parentNode;){if(o.nodeName==="UL"||o.nodeName==="OL"){t.preventDefault(),e.increaseListLevel(n);break}r=o}}},Ws=(e,t,n)=>{let i=e._root;if(e._removeZWS(),n.collapsed&&pt(n,i)){let r=n.startContainer;(L(r,i,"UL")||L(r,i,"OL"))&&(t.preventDefault(),e.decreaseListLevel(n))}},Vs=(e,t,n)=>{let i,r=e._root;if(e._recordUndoState(n),e._getRangeAndRemoveBookmark(n),!n.collapsed)qe(n,r),e._ensureBottomLine(),e.setSelection(n),e._updatePath(n,!0);else if(mt(n,r)){let o=ie(n,r);if(o&&o.nodeName!=="PRE"){let s=o.textContent?.trimEnd().replace("\u200B","");if(s==="*"||s==="1."){t.preventDefault(),e.insertPlainText(" ",!1),e._docWasChanged(),e.saveUndoState(n);let a=new ne(o,4),l;for(;l=a.nextNode();)H(l);s==="*"?e.makeUnorderedList():e.makeOrderedList();return}}}if(i=n.endContainer,n.endOffset===re(i))do if(i.nodeName==="A"){n.setStartAfter(i);break}while(!i.nextSibling&&(i=i.parentNode)&&i!==r);if(e._config.addLinks){let o=n.cloneRange();j(o);let s=o.startContainer,a=o.startOffset;setTimeout(()=>{pr(e,s,a)},0)}e.setSelection(n)},Gs=function(e){if(e.defaultPrevented||e.isComposing)return;let t=e.key,n="",i=e.code;/^Digit\d$/.test(i)&&(t=i.slice(-1)),t!=="Backspace"&&t!=="Delete"&&(e.altKey&&(n+="Alt-"),e.ctrlKey&&(n+="Ctrl-"),e.metaKey&&(n+="Meta-"),e.shiftKey&&(n+="Shift-")),er&&e.shiftKey&&t==="Delete"&&(n+="Shift-"),t=n+t;let r=this.getSelection(),o=this._keyHandlers[t];o?o(this,e,r):!r.collapsed&&!e.ctrlKey&&!e.metaKey&&t.length===1&&(this.saveUndoState(r),qe(r,this._root),this._ensureBottomLine(),this.setSelection(r),this._updatePath(r,!0))},P={Backspace:Us,Delete:zs,Tab:qs,"Shift-Tab":Ws," ":Vs,ArrowLeft(e){e._removeZWS()},ArrowRight(e,t,n){e._removeZWS();let i=e.getRoot();if(mt(n,i)){j(n);let r=n.endContainer;do if(r.nodeName==="CODE"){let o=r.nextSibling;if(!(o instanceof Text)||o.length===0){let s=document.createTextNode("\xA0");r.parentNode.insertBefore(s,o),o=s}n.setStart(o,1),e.setSelection(n),t.preventDefault();break}while(!r.nextSibling&&(r=r.parentNode)&&r!==i)}}};ys||(P.Enter=Qi,P["Shift-Enter"]=Qi);!kn&&!tr&&(P.PageUp=e=>{e.moveCursorToStart()},P.PageDown=e=>{e.moveCursorToEnd()});var Je=(e,t)=>(t=t||null,(n,i)=>{i.preventDefault();let r=n.getSelection();n.hasFormat(e,null,r)?n.changeFormat(null,{tag:e},r):n.changeFormat({tag:e},t,r)});P[J+"b"]=Je("B");P[J+"i"]=Je("I");P[J+"u"]=Je("U");P[J+"Shift-7"]=Je("S");P[J+"Shift-5"]=Je("SUB",{tag:"SUP"});P[J+"Shift-6"]=Je("SUP",{tag:"SUB"});P[J+"Shift-8"]=(e,t)=>{t.preventDefault();let n=e.getPath();/(?:^|>)UL/.test(n)?e.removeList():e.makeUnorderedList()};P[J+"Shift-9"]=(e,t)=>{t.preventDefault();let n=e.getPath();/(?:^|>)OL/.test(n)?e.removeList():e.makeOrderedList()};P[J+"["]=(e,t)=>{t.preventDefault();let n=e.getPath();/(?:^|>)BLOCKQUOTE/.test(n)||!/(?:^|>)[OU]L/.test(n)?e.decreaseQuoteLevel():e.decreaseListLevel()};P[J+"]"]=(e,t)=>{t.preventDefault();let n=e.getPath();/(?:^|>)BLOCKQUOTE/.test(n)||!/(?:^|>)[OU]L/.test(n)?e.increaseQuoteLevel():e.increaseListLevel()};P[J+"d"]=(e,t)=>{t.preventDefault(),e.toggleCode()};P[J+"z"]=(e,t)=>{t.preventDefault(),e.undo()};P[J+"y"]=P[J+"Shift-z"]=P[J+"Shift-Z"]=(e,t)=>{t.preventDefault(),e.redo()};var Cn=8,Ji=40,Nn=1200,Ks=[{pos:"nw",cursor:"nwse-resize"},{pos:"n",cursor:"ns-resize"},{pos:"ne",cursor:"nesw-resize"},{pos:"e",cursor:"ew-resize"},{pos:"se",cursor:"nwse-resize"},{pos:"s",cursor:"ns-resize"},{pos:"sw",cursor:"nesw-resize"},{pos:"w",cursor:"ew-resize"}],$s={ArrowUp:(e,t,n)=>{let i=ie(t,n);if(i){let r=He(i,n);r&&(t.selectNodeContents(r),t.collapse(!1),e.setSelection(t).focus())}},ArrowDown:(e,t,n)=>{let i=ie(t,n);if(i){let r=Ee(i,n);r&&(t.selectNodeContents(r),t.collapse(!0),e.setSelection(t).focus())}},Delete:(e,t)=>{e.replaceWithBlankLine(t)},Backspace:(e,t)=>{e.replaceWithBlankLine(t)}},js=class{constructor(e,t){this._currentImage=null,this._resizeContainer=null,this._handles=null,this._currentHandle=null,this._startX=0,this._startY=0,this._startWidth=0,this._startHeight=0,this._maxWidth=Nn,this._originalRatio=1,this._editor=t,this._root=e,document.addEventListener("click",this),t.addEventListener("drop",this)}destroy(){this._deselectImage(),this._editor.removeEventListener("drop",this),document.removeEventListener("click",this)}handleEvent(e){switch(e.type){case"click":this._onClick(e);break;case"pointerdown":this._onPointerDown(e);break;case"pointermove":this._onPointerMove(e);break;case"pointercancel":case"pointerup":this._onPointerUp(e);break;case"keydown":this._onKeyDown(e);break;case"drop":this._deselectImage();break}}_onClick(e){let t=e.target;t.nodeName==="IMG"&&this._root.contains(t)?(e.stopPropagation(),this._selectImage(t)):this._currentImage&&this._handles&&!this._handles.some(n=>n.element===t)&&this._deselectImage()}_deselectImage(){this._currentImage&&(document.removeEventListener("keydown",this,!0),this._currentHandle&&this._onPointerUp({preventDefault(){},target:this._currentHandle.element}),this._handles&&this._handles.forEach(({element:e})=>e.removeEventListener("pointerdown",this)),this._resizeContainer&&this._resizeContainer.remove(),this._currentImage.removeAttribute("tabindex"),this._handles=null,this._resizeContainer=null,this._currentImage=null)}_selectImage(e){if(this._currentImage===e)return;this._deselectImage(),this._root.blur();let t=Ks.map(({pos:r,cursor:o})=>{let s=Cn/2,a="";switch(r){case"nw":a=`left: -${s}px; top: -${s}px;`;break;case"n":a=`left: calc(50% - ${s}px); top: -${s}px;`;break;case"ne":a=`right: -${s}px; top: -${s}px;`;break;case"e":a=`right: -${s}px; top: calc(50% - ${s}px);`;break;case"se":a=`right: -${s}px; bottom: -${s}px;`;break;case"s":a=`left: calc(50% - ${s}px); bottom: -${s}px;`;break;case"sw":a=`left: -${s}px; bottom: -${s}px;`;break;case"w":a=`left: -${s}px; top: calc(50% - ${s}px);`;break}let l=T("div",{class:`squire-resize-handle squire-resize-handle-${r}`,style:`
|
|
5
5
|
position: absolute;
|
|
6
|
-
width: ${
|
|
7
|
-
height: ${
|
|
6
|
+
width: ${Cn}px;
|
|
7
|
+
height: ${Cn}px;
|
|
8
8
|
background: #0067b9;
|
|
9
9
|
border: 1px solid #fff;
|
|
10
10
|
cursor: ${o};
|
|
@@ -12,23 +12,23 @@ var richclay=(()=>{var vn=Object.defineProperty;var us=Object.getOwnPropertyDesc
|
|
|
12
12
|
touch-action: none;
|
|
13
13
|
box-shadow: 0 1px 3px rgba(0,0,0,0.3);
|
|
14
14
|
${a}
|
|
15
|
-
`});return l.addEventListener("pointerdown",this),{element:l,cursor:o,position:r}}),n=T("div",{class:"squire-image-resize-container","editor-ui":"",style:"position: absolute; pointer-events: none; z-index: 1000;"},t.map(r=>r.element));this._currentImage=e,this._resizeContainer=n,this._handles=t,this._root.appendChild(this._resizeContainer);let i=e.naturalWidth;this._originalRatio=i/e.naturalHeight,this._maxWidth=Math.min(i*2,e.parentElement?e.parentElement.offsetWidth:Nn,Nn),this._positionResizeContainer(),e.tabIndex=-1,e.focus(),document.addEventListener("keydown",this,!0)}_positionResizeContainer(){let e=this._resizeContainer,t=this._root,n=this._currentImage;if(!e||!n)return;let i=t.getBoundingClientRect(),r=n.getBoundingClientRect(),o=r.top-i.top+t.scrollTop,s=r.left-i.left+t.scrollLeft,a=r.width,l=r.height;e.style.top=o+"px",e.style.left=s+"px",e.style.width=a+"px",e.style.height=l+"px"}_onPointerDown(e){if(this._currentHandle||!this._handles)return;let t=e.target,n=this._handles.find(o=>o.element===t)||null;if(!n)return;let i=this._currentImage;if(!i)return;e.preventDefault(),e.stopPropagation(),t.addEventListener("pointermove",this),t.addEventListener("pointerup",this),t.addEventListener("pointercancel",this),t.setPointerCapture(e.pointerId),this._currentHandle=n,this._startX=e.clientX,this._startY=e.clientY;let r=getComputedStyle(i);this._startWidth=parseFloat(r.width),this._startHeight=parseFloat(r.height),document.body.style.cursor=n.cursor}_onPointerMove(e){e.preventDefault();let t=this._currentHandle,n=this._currentImage;if(!t||!n)return;let i=e.clientX-this._startX,r=e.clientY-this._startY,o=this._maxWidth,s=this._originalRatio,a=this._startWidth,l=this._startHeight;switch(t.position){case"sw":case"nw":case"w":a-=2*i;break;case"se":case"ne":case"e":a+=2*i;break;case"n":l-=r,a=l*s;break;case"s":l+=r,a=l*s;break}a<tr?a=tr:a>o&&(a=o);let u=n.style;u.width=a+"px",u.height="auto",this._positionResizeContainer()}_onPointerUp(e){e.preventDefault();let t=e.target;t&&(t.removeEventListener("pointermove",this),t.removeEventListener("pointerup",this),t.removeEventListener("pointercancel",this)),this._currentHandle=null,document.body.style.cursor=""}_onKeyDown(e){e.preventDefault(),e.stopPropagation();let t=Ys[e.key];if(!t)return;let n=this._currentImage;if(!n)return;let i=this._editor,r=this._root;this._deselectImage();let o=i.getSelection();o.selectNode(n),t(i,o,r)}},Qs=class{constructor(e,t){this.customEvents=new Set(["pathChange","select","input","pasteImage","undoStateChange"]),this.startSelectionId="squire-selection-start",this.endSelectionId="squire-selection-end",this.linkRegExp=/\b(?:((?:(?:ht|f)tps?:\/\/|www\d{0,3}[.]|[a-z0-9][a-z0-9.\-]*[.][a-z]{2,}\/)(?:[^\s()<>]+|\([^\s()<>]+\))+(?:[^\s?&`!()\[\]{};:'".,<>«»“”‘’]|\([^\s()<>]+\)))|([\w\-.%+]+@(?:[\w\-]+\.)+[a-z]{2,}\b(?:[?][^&?\s]+=[^\s?&`!()\[\]{};:'".,<>«»“”‘’]+(?:&[^&?\s]+=[^\s?&`!()\[\]{};:'".,<>«»“”‘’]+)*)?))/i,this.tagAfterSplit={DT:"DD",DD:"DT",LI:"LI",PRE:"PRE"},this._root=e,this._config=this._makeConfig(t),this._isFocused=!1,this._lastSelection=Be(e,0),this._willRestoreSelection=!1,this._mayHaveZWS=!1,this._lastAnchorNode=null,this._lastFocusNode=null,this._path="",this._events=new Map,this._undoIndex=-1,this._undoStack=[],this._undoStackLength=0,this._isInUndoState=!1,this._ignoreChange=!1,this._ignoreAllChanges=!1,this.addEventListener("selectionchange",this._updatePathOnEvent),this.addEventListener("blur",this._enableRestoreSelection),this.addEventListener("mousedown",this._disableRestoreSelection),this.addEventListener("touchstart",this._disableRestoreSelection),this.addEventListener("focus",this._restoreSelection),this.addEventListener("blur",this._removeZWS),this._isShiftDown=!1,this.addEventListener("cut",Is),this.addEventListener("copy",Ms),this.addEventListener("paste",Ps),this._dragRange=null,this.addEventListener("dragstart",Bs),this.addEventListener("dragend",Fs),this.addEventListener("drop",zs),this.addEventListener("keydown",Ji),this.addEventListener("keyup",Ji),this.addEventListener("keydown",js),this._keyHandlers=Object.create(B);let n=new MutationObserver(i=>this._onMutations(i));n.observe(e,{childList:!0,attributes:!0,attributeOldValue:!0,characterData:!0,subtree:!0}),this._mutation=n,e.setAttribute("contenteditable","true"),this.addEventListener("beforeinput",this._beforeInput),this._imageResizer=new Xs(e,this),this.setHTML("")}destroy(){this._events.forEach((e,t)=>{this.removeEventListener(t)}),this._mutation.disconnect(),this._imageResizer.destroy(),this._undoIndex=-1,this._undoStack=[],this._undoStackLength=0}_makeConfig(e){let t={blockTag:"DIV",blockAttributes:null,tagAttributes:{},classNames:{color:"color",fontFamily:"font",fontSize:"size",highlight:"highlight"},undo:{documentSizeThreshold:-1,undoLimit:-1},addLinks:!0,willCutCopy:null,toPlainText:null,sanitizeToDOMFragment:n=>{let i=DOMPurify.sanitize(n,{ALLOW_UNKNOWN_PROTOCOLS:!0,WHOLE_DOCUMENT:!1,RETURN_DOM:!0,RETURN_DOM_FRAGMENT:!0,FORCE_BODY:!1});return i?document.importNode(i,!0):document.createDocumentFragment()},didError:n=>console.log(n)};return e&&(Object.assign(t,e),t.blockTag=t.blockTag.toUpperCase()),t}setKeyHandler(e,t){return this._keyHandlers[e]=t,this}_beforeInput(e){switch(e.inputType){case"insertLineBreak":e.preventDefault(),this.splitBlock(!0);break;case"insertParagraph":e.preventDefault(),this.splitBlock(!1);break;case"insertOrderedList":e.preventDefault(),this.makeOrderedList();break;case"insertUnoderedList":e.preventDefault(),this.makeUnorderedList();break;case"historyUndo":e.preventDefault(),this.undo();break;case"historyRedo":e.preventDefault(),this.redo();break;case"formatBold":e.preventDefault(),this.bold();break;case"formatItalic":e.preventDefault(),this.italic();break;case"formatUnderline":e.preventDefault(),this.underline();break;case"formatStrikeThrough":e.preventDefault(),this.strikethrough();break;case"formatSuperscript":e.preventDefault(),this.superscript();break;case"formatSubscript":e.preventDefault(),this.subscript();break;case"formatJustifyFull":case"formatJustifyCenter":case"formatJustifyRight":case"formatJustifyLeft":{e.preventDefault();let t=e.inputType.slice(13).toLowerCase();t==="full"&&(t="justify"),this.setTextAlignment(t);break}case"formatRemove":e.preventDefault(),this.removeAllFormatting();break;case"formatSetBlockTextDirection":{e.preventDefault();let t=e.data;t==="null"&&(t=null),this.setTextDirection(t);break}case"formatBackColor":e.preventDefault(),this.setHighlightColor(e.data);break;case"formatFontColor":e.preventDefault(),this.setTextColor(e.data);break;case"formatFontName":e.preventDefault(),this.setFontFace(e.data);break}}handleEvent(e){this.fireEvent(e.type,e)}fireEvent(e,t){let n=this._events.get(e);if(/^(?:focus|blur)/.test(e)){let i=this._root===document.activeElement;if(e==="focus"){if(!i||this._isFocused)return this;this._isFocused=!0}else{if(i||!this._isFocused)return this;this._isFocused=!1}}if(n){let i=t instanceof Event?t:new CustomEvent(e,{detail:t});n=n.slice();for(let r of n)try{"handleEvent"in r?r.handleEvent(i):r.call(this,i)}catch(o){this._config.didError(o)}}return this}addEventListener(e,t){let n=this._events.get(e),i=this._root;return n||(n=[],this._events.set(e,n),this.customEvents.has(e)||(e==="selectionchange"&&(i=document),i.addEventListener(e,this,!0))),n.push(t),this}removeEventListener(e,t){let n=this._events.get(e),i=this._root;if(n){if(t){let r=n.length;for(;r--;)n[r]===t&&n.splice(r,1)}else n.length=0;n.length||(this._events.delete(e),this.customEvents.has(e)||(e==="selectionchange"&&(i=document),i.removeEventListener(e,this,!0)))}return this}focus(){return this._root.focus({preventScroll:!0}),this}blur(){return this._root.blur(),this}_enableRestoreSelection(){this._willRestoreSelection=!0}_disableRestoreSelection(){this._willRestoreSelection=!1}_restoreSelection(){this._willRestoreSelection&&this.setSelection(this._lastSelection)}_removeZWS(){this._mayHaveZWS&&(Bt(this._root),this._mayHaveZWS=!1)}_saveRangeToBookmark(e){let t=T("INPUT",{id:this.startSelectionId,type:"hidden"}),n=T("INPUT",{id:this.endSelectionId,type:"hidden"}),i;Te(e,t),e.collapse(!1),Te(e,n),t.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_PRECEDING&&(t.id=this.endSelectionId,n.id=this.startSelectionId,i=t,t=n,n=i),e.setStartAfter(t),e.setEndBefore(n)}_getRangeAndRemoveBookmark(e){let t=this._root,n=t.querySelectorAll("#"+this.startSelectionId),i=t.querySelectorAll("#"+this.endSelectionId),r=n[0],o=i[0];if(r&&o&&r.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING){let s=r.parentNode,a=o.parentNode,l=Array.from(s.childNodes).indexOf(r),u=Array.from(a.childNodes).indexOf(o);s===a&&(u-=1),r.remove(),o.remove(),e||(e=document.createRange()),e.setStart(s,l),e.setEnd(a,u),Qe(s,e),s!==a&&Qe(a,e),e.collapsed&&(s=e.startContainer,s instanceof Text&&(a=s.childNodes[e.startOffset],(!a||!(a instanceof Text))&&(a=s.childNodes[e.startOffset-1]),a&&a instanceof Text&&(e.setStart(a,0),e.collapse(!0))))}for(let s=0;s<n.length;s+=1)n[s].remove();for(let s=0;s<i.length;s+=1)i[s].remove();return e||null}getSelection(){let e=window.getSelection(),t=this._root,n=null;if(this._isFocused&&e&&e.rangeCount){n=e.getRangeAt(0).cloneRange();let i=n.startContainer,r=n.endContainer;i&&Re(i)&&n.setStartBefore(i),r&&Re(r)&&n.setEndBefore(r)}return n&&t.contains(n.commonAncestorContainer)?this._lastSelection=n:(n=this._lastSelection,document.contains(n.commonAncestorContainer)||(n=null)),n||(n=Be(t.firstElementChild||t,0)),n}setSelection(e){if(this._lastSelection=e,!this._isFocused)this._enableRestoreSelection();else{let t=window.getSelection();t&&("setBaseAndExtent"in Selection.prototype?t.setBaseAndExtent(e.startContainer,e.startOffset,e.endContainer,e.endOffset):(t.removeAllRanges(),t.addRange(e)))}return this}_moveCursorTo(e){let t=this._root,n=Be(t,e?0:t.childNodes.length);return V(n),this.setSelection(n),this}moveCursorToStart(){return this._moveCursorTo(!0)}moveCursorToEnd(){return this._moveCursorTo(!1)}getCursorPosition(){let e=this.getSelection(),t=e.getBoundingClientRect();if(t&&!t.top){this._ignoreChange=!0;let n=T("SPAN");n.textContent="\u200B",Te(e,n),t=n.getBoundingClientRect();let i=n.parentNode;i.removeChild(n),Qe(i,e)}return t}getPath(){return this._path}_updatePathOnEvent(){this._isFocused&&this._updatePath(this.getSelection())}_updatePath(e,t){let n=e.startContainer,i=e.endContainer,r;(t||n!==this._lastAnchorNode||i!==this._lastFocusNode)&&(this._lastAnchorNode=n,this._lastFocusNode=i,r=n&&i?n===i?this._getPath(i):"(selection)":"",(this._path!==r||n!==i)&&(this._path=r,this.fireEvent("pathChange",{path:r}))),this.fireEvent(e.collapsed?"cursor":"select",{range:e})}_getPath(e){let t=this._root,n=this._config,i="";if(e&&e!==t){let r=e.parentNode;if(i=r?this._getPath(r):"",e instanceof HTMLElement){let o=e.id,s=e.classList,a=Array.from(s).sort(),l=e.dir,u=n.classNames;i+=(i?">":"")+e.nodeName,o&&(i+="#"+o),a.length&&(i+=".",i+=a.join(".")),l&&(i+="[dir="+l+"]"),s.contains(u.highlight)&&(i+="[backgroundColor="+e.style.backgroundColor.replace(/ /g,"")+"]"),s.contains(u.color)&&(i+="[color="+e.style.color.replace(/ /g,"")+"]"),s.contains(u.fontFamily)&&(i+="[fontFamily="+e.style.fontFamily.replace(/ /g,"")+"]"),s.contains(u.fontSize)&&(i+="[fontSize="+e.style.fontSize+"]")}}return i}modifyDocument(e){let t=this._mutation;return t&&((()=>{let n=t.takeRecords();n.length&&this._onMutations(n)})(),t.disconnect()),this._ignoreAllChanges=!0,e(),this._ignoreAllChanges=!1,t&&(t.observe(this._root,{childList:!0,attributes:!0,attributeOldValue:!0,characterData:!0,subtree:!0}),this._ignoreChange=!1),this}_onMutations(e){let t=this._config.onMutations;return t?t(e,this):this._docWasChanged()}_docWasChanged(){if(sr(),this._mayHaveZWS=!0,!this._ignoreAllChanges){if(this._ignoreChange){this._ignoreChange=!1;return}this._isInUndoState&&(this._isInUndoState=!1,this.fireEvent("undoStateChange",{canUndo:!0,canRedo:!1})),this.fireEvent("input")}}_recordUndoState(e,t){let n=this._isInUndoState;if(!n||t){let i=this._undoIndex+1,r=this._undoStack,o=this._config.undo,s=o.documentSizeThreshold,a=o.undoLimit;if(i<this._undoStackLength&&(r.length=this._undoStackLength=i),e&&this._saveRangeToBookmark(e),n)return this;let l=this._getRawHTML();t&&(i-=1),s>-1&&l.length*2>s&&a>-1&&i>a&&(r.splice(0,i-a),i=a,this._undoStackLength=a),r[i]=l,this._undoIndex=i,this._undoStackLength+=1,this._isInUndoState=!0}return this}saveUndoState(e){let t=!1;return e||(e=this.getSelection(),t=!0),this._recordUndoState(e,this._isInUndoState),this._getRangeAndRemoveBookmark(e),t&&this.setSelection(e),this}undo(){if(this._undoIndex!==0||!this._isInUndoState){this._recordUndoState(this.getSelection(),!1),this._undoIndex-=1,this._setRawHTML(this._undoStack[this._undoIndex]);let e=this._getRangeAndRemoveBookmark();e&&this.setSelection(e),this._isInUndoState=!0,this.fireEvent("undoStateChange",{canUndo:this._undoIndex!==0,canRedo:!0}),this.fireEvent("input")}return this.focus()}redo(){let e=this._undoIndex,t=this._undoStackLength;if(e+1<t&&this._isInUndoState){this._undoIndex+=1,this._setRawHTML(this._undoStack[this._undoIndex]);let n=this._getRangeAndRemoveBookmark();n&&this.setSelection(n),this.fireEvent("undoStateChange",{canUndo:!0,canRedo:e+2<t}),this.fireEvent("input")}return this.focus()}getRoot(){return this._root}_getRawHTML(){let e=this._config.serializeRoot;return e?e(this._root,this):this._root.innerHTML}_setRawHTML(e){let t=this._root;this._config.replaceRoot?this._config.replaceRoot(t,e,this):t.innerHTML=e;let n=t,i=n.firstChild;if(!i||i.nodeName==="BR"){let r=this.createDefaultBlock();i?n.replaceChild(r,i):n.appendChild(r)}else for(;n=Ee(n,t);)z(n);return this._ignoreChange=!0,this}getHTML(e){if(this._config.serializeRoot)return this._config.serializeRoot(this._root,this,e?this.getSelection():null).replace(/\u200B/g,"");let t,n="";return this.modifyDocument(()=>{e&&(t=this.getSelection(),this._saveRangeToBookmark(t)),n=this._getRawHTML().replace(/\u200B/g,""),e&&this._getRangeAndRemoveBookmark(t)}),n}setHTML(e){let t=this._config.sanitizeToDOMFragment(e,this),n=this._root;Rn(t,this._config),kn(t,n,!1),pe(t,n);let i=t,r=i.firstChild;if(!r||r.nodeName==="BR"){let s=this.createDefaultBlock();r?i.replaceChild(s,r):i.appendChild(s)}else for(;i=Ee(i,n);)z(i);for(this._ignoreChange=!0;r=n.lastChild;)n.removeChild(r);n.appendChild(t),this._undoIndex=-1,this._undoStack.length=0,this._undoStackLength=0,this._isInUndoState=!1;let o=this._getRangeAndRemoveBookmark()||Be(n.firstElementChild||n,0);return this.saveUndoState(o),this.setSelection(o),this._updatePath(o,!0),this}insertHTML(e,t){let n=this._config,i=n.sanitizeToDOMFragment(e,this),r=this.getSelection();this.saveUndoState(r);try{let o=this._root;n.addLinks&&this.addDetectedLinks(i,i),Rn(i,this._config),kn(i,o,!1),On(i),i.normalize();let s=i;for(;s=Ee(s,i);)z(s);let a=!0;if(t){let l=new CustomEvent("willPaste",{cancelable:!0,detail:{html:e,fragment:i}});this.fireEvent("willPaste",l),i=l.detail.fragment,a=!l.defaultPrevented}a&&(Ds(r,i,o),r.collapse(!1),Vi(r,"A",o),this._ensureBottomLine()),this.setSelection(r),this._updatePath(r,!0),t&&this.focus()}catch(o){this._config.didError(o)}return this}insertElement(e,t){if(t||(t=this.getSelection()),t.collapse(!0),x(e))Te(t,e),t.setStartAfter(e);else{let n=this._root,i=ie(t,n),r=i||n,o=null;for(;r!==n&&!r.nextSibling;)r=r.parentNode;if(r!==n){let a=r.parentNode;o=se(a,r.nextSibling,n,n)}i&&Dn(i)&&H(i),n.insertBefore(e,o);let s=this.createDefaultBlock();n.insertBefore(s,o),t.setStart(s,0),t.setEnd(s,0),V(t)}return this.focus(),this.setSelection(t),this._updatePath(t),this}insertImage(e,t){let n=T("IMG",Object.assign({src:e},t));return this.insertElement(n),n}insertPlainText(e,t){let n=this.getSelection();if(n.collapsed&&L(n.startContainer,this._root,"PRE")){let u=n.startContainer,d=n.startOffset,f;if(!u||!(u instanceof Text)){let y=document.createTextNode("");u.insertBefore(y,u.childNodes[d]),f=y,d=0}else f=u;let p=!0;if(t){let y=new CustomEvent("willPaste",{cancelable:!0,detail:{text:e}});this.fireEvent("willPaste",y),e=y.detail.text,p=!y.defaultPrevented}return p&&(this.saveUndoState(n),f.insertData(d,e),n.setStart(f,d+e.length),n.collapse(!0)),this.setSelection(n),this}let i=e.split(`
|
|
16
|
-
`),r=this._config,o=r.blockTag,s=r.blockAttributes,a="</"+o+">",l="<"+o;for(let u in s)l+=" "+u+'="'+
|
|
17
|
-
`||pt(t,n))&&(o.data.charAt(
|
|
18
|
-
`||mt(t,n))?(o.deleteData(
|
|
19
|
-
`),o.nextSibling||r.appendChild(T("BR")),o.length===
|
|
20
|
-
`)):H(d)}for(a=o.querySelectorAll("CODE"),u=a.length;u--;)
|
|
21
|
-
`)),i.appendChild(D(o))}let s=new ne(i,4);for(;o=s.nextNode();)o.data=o.data.replace(/ /g," ");return i.normalize(),
|
|
22
|
-
`))>-1;)d.appendChild(document.createTextNode(u.slice(0,
|
|
23
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ta(e,t){return Zs(e)||Js(e,t)||na(e,t)||ea()}function na(e,t){if(e){if(typeof e=="string")return br(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?br(e,t):void 0}}var kr=Object.entries,Tr=Object.setPrototypeOf,ia=Object.isFrozen,ra=Object.getPrototypeOf,oa=Object.getOwnPropertyDescriptor,G=Object.freeze,K=Object.seal,tt=Object.create,Dr=typeof Reflect<"u"&&Reflect,qn=Dr.apply,$n=Dr.construct;G||(G=function(t){return t});K||(K=function(t){return t});qn||(qn=function(t,n){for(var i=arguments.length,r=new Array(i>2?i-2:0),o=2;o<i;o++)r[o-2]=arguments[o];return t.apply(n,r)});$n||($n=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return new t(...i)});var gt=F(Array.prototype.forEach),sa=F(Array.prototype.lastIndexOf),_r=F(Array.prototype.pop),et=F(Array.prototype.push),aa=F(Array.prototype.splice),ke=Array.isArray,Tt=F(String.prototype.toLowerCase),Bn=F(String.prototype.toString),Er=F(String.prototype.match),yt=F(String.prototype.replace),Sr=F(String.prototype.indexOf),la=F(String.prototype.trim),ca=F(Number.prototype.toString),ua=F(Boolean.prototype.toString),Ar=typeof BigInt>"u"?null:F(BigInt.prototype.toString),vr=typeof Symbol>"u"?null:F(Symbol.prototype.toString),q=F(Object.prototype.hasOwnProperty),bt=F(Object.prototype.toString),W=F(RegExp.prototype.test),$e=da(TypeError);function F(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return qn(e,t,i)}}function da(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return $n(e,n)}}function A(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Tt;if(Tr&&Tr(e,null),!ke(t))return e;let i=t.length;for(;i--;){let r=t[i];if(typeof r=="string"){let o=n(r);o!==r&&(ia(t)||(t[i]=o),r=o)}e[r]=!0}return e}function ha(e){for(let t=0;t<e.length;t++)q(e,t)||(e[t]=null);return e}function ee(e){let t=tt(null);for(let i of kr(e)){var n=ta(i,2);let r=n[0],o=n[1];q(e,r)&&(ke(o)?t[r]=ha(o):o&&typeof o=="object"&&o.constructor===Object?t[r]=ee(o):t[r]=o)}return t}function fa(e){switch(typeof e){case"string":return e;case"number":return ca(e);case"boolean":return ua(e);case"bigint":return Ar?Ar(e):"0";case"symbol":return vr?vr(e):"Symbol()";case"undefined":return bt(e);case"function":case"object":{if(e===null)return bt(e);let t=e,n=ge(t,"toString");if(typeof n=="function"){let i=n(t);return typeof i=="string"?i:bt(i)}return bt(e)}default:return bt(e)}}function ge(e,t){for(;e!==null;){let i=oa(e,t);if(i){if(i.get)return F(i.get);if(typeof i.value=="function")return F(i.value)}e=ra(e)}function n(){return null}return n}function pa(e){try{return W(e,""),!0}catch{return!1}}var Cr=G(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Fn=G(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Un=G(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),ma=G(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Hn=G(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),ga=G(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),xr=G(["#text"]),Nr=G(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),zn=G(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Lr=G(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Wt=G(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),ya=K(/{{[\w\W]*|^[\w\W]*}}/g),ba=K(/<%[\w\W]*|^[\w\W]*%>/g),Ta=K(/\${[\w\W]*/g),_a=K(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ea=K(/^aria-[\-\w]+$/),wr=K(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Sa=K(/^(?:\w+script|data):/i),Aa=K(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),va=K(/^html$/i),Ca=K(/^[a-z][.\w]*(-[.\w]+)+$/i),Rr=K(/<[/\w!]/g),xa=K(/<[/\w]/g),Na=K(/<\/no(script|embed|frames)/i),La=K(/\/>/i),me={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},wa=function(){return typeof window>"u"?null:window},Ra=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null,r="data-tt-policy-suffix";n&&n.hasAttribute(r)&&(i=n.getAttribute(r));let o="dompurify"+(i?"#"+i:"");try{return t.createPolicy(o,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Or=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Oe=function(t,n,i,r){return q(t,n)&&ke(t[n])?A(r.base?ee(r.base):{},t[n],r.transform):i};function Ir(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:wa(),t=g=>Ir(g);if(t.version="3.4.11",t.removed=[],!e||!e.document||e.document.nodeType!==me.document||!e.Element)return t.isSupported=!1,t;let n=e.document,i=n,r=i.currentScript;e.DocumentFragment;let o=e.HTMLTemplateElement,s=e.Node,a=e.Element,l=e.NodeFilter,u=e.NamedNodeMap;u===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let d=e.DOMParser,f=e.trustedTypes,p=a.prototype,y=ge(p,"cloneNode"),E=ge(p,"remove"),N=ge(p,"nextSibling"),C=ge(p,"childNodes"),M=ge(p,"parentNode"),$=ge(p,"shadowRoot"),le=ge(p,"attributes"),Q=s&&s.prototype?ge(s.prototype,"nodeType"):null,ve=s&&s.prototype?ge(s.prototype,"nodeName"):null;if(typeof o=="function"){let g=n.createElement("template");g.content&&g.content.ownerDocument&&(n=g.content.ownerDocument)}let te,Ie="",on,Ti=!1,at=0,_i=function(){if(at>0)throw $e('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},Ge=function(c){_i(),at++;try{return te.createHTML(c)}finally{at--}},Po=function(c){_i(),at++;try{return te.createScriptURL(c)}finally{at--}},Bo=function(){return Ti||(on=Ra(f,r),Ti=!0),on},wt=n,sn=wt.implementation,Ei=wt.createNodeIterator,Fo=wt.createDocumentFragment,Uo=wt.getElementsByTagName,Ho=i.importNode,I=Or();t.isSupported=typeof kr=="function"&&typeof M=="function"&&sn&&sn.createHTMLDocument!==void 0;let zo=ya,qo=ba,$o=Ta,Wo=_a,Go=Ea,Ko=Sa,Si=Aa,jo=Ca,Ai=wr,w=null,vi=A({},[...Cr,...Fn,...Un,...Hn,...xr]),R=null,Ci=A({},[...Nr,...zn,...Lr,...Wt]),O=Object.seal(tt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),lt=null,xi=null,Ce=Object.seal(tt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ni=!0,an=!0,Li=!1,wi=!0,xe=!1,ct=!0,Me=!1,ln=!1,cn=null,un=null,dn=!1,Ke=!1,Rt=!1,Ot=!1,Ri=!0,Oi=!1,ki="user-content-",hn=!0,fn=!1,je={},de=null,pn=A({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),Di=null,Ii=A({},["audio","video","img","source","image","track"]),mn=null,Mi=A({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),kt="http://www.w3.org/1998/Math/MathML",Dt="http://www.w3.org/2000/svg",he="http://www.w3.org/1999/xhtml",Ve=he,gn=!1,yn=null,Vo=A({},[kt,Dt,he],Bn),Pi=G(["mi","mo","mn","ms","mtext"]),bn=A({},Pi),Bi=G(["annotation-xml"]),Tn=A({},Bi),Yo=A({},["title","style","font","a","script"]),ut=null,Xo=["application/xhtml+xml","text/html"],Qo="text/html",k=null,Ye=null,Zo=n.createElement("form"),Fi=function(c){return c instanceof RegExp||c instanceof Function},_n=function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ye&&Ye===c)return;(!c||typeof c!="object")&&(c={}),c=ee(c),ut=Xo.indexOf(c.PARSER_MEDIA_TYPE)===-1?Qo:c.PARSER_MEDIA_TYPE,k=ut==="application/xhtml+xml"?Bn:Tt,w=Oe(c,"ALLOWED_TAGS",vi,{transform:k}),R=Oe(c,"ALLOWED_ATTR",Ci,{transform:k}),yn=Oe(c,"ALLOWED_NAMESPACES",Vo,{transform:Bn}),mn=Oe(c,"ADD_URI_SAFE_ATTR",Mi,{transform:k,base:Mi}),Di=Oe(c,"ADD_DATA_URI_TAGS",Ii,{transform:k,base:Ii}),de=Oe(c,"FORBID_CONTENTS",pn,{transform:k}),lt=Oe(c,"FORBID_TAGS",ee({}),{transform:k}),xi=Oe(c,"FORBID_ATTR",ee({}),{transform:k}),je=q(c,"USE_PROFILES")?c.USE_PROFILES&&typeof c.USE_PROFILES=="object"?ee(c.USE_PROFILES):c.USE_PROFILES:!1,Ni=c.ALLOW_ARIA_ATTR!==!1,an=c.ALLOW_DATA_ATTR!==!1,Li=c.ALLOW_UNKNOWN_PROTOCOLS||!1,wi=c.ALLOW_SELF_CLOSE_IN_ATTR!==!1,xe=c.SAFE_FOR_TEMPLATES||!1,ct=c.SAFE_FOR_XML!==!1,Me=c.WHOLE_DOCUMENT||!1,Ke=c.RETURN_DOM||!1,Rt=c.RETURN_DOM_FRAGMENT||!1,Ot=c.RETURN_TRUSTED_TYPE||!1,dn=c.FORCE_BODY||!1,Ri=c.SANITIZE_DOM!==!1,Oi=c.SANITIZE_NAMED_PROPS||!1,hn=c.KEEP_CONTENT!==!1,fn=c.IN_PLACE||!1,Ai=pa(c.ALLOWED_URI_REGEXP)?c.ALLOWED_URI_REGEXP:wr,Ve=typeof c.NAMESPACE=="string"?c.NAMESPACE:he,bn=q(c,"MATHML_TEXT_INTEGRATION_POINTS")&&c.MATHML_TEXT_INTEGRATION_POINTS&&typeof c.MATHML_TEXT_INTEGRATION_POINTS=="object"?ee(c.MATHML_TEXT_INTEGRATION_POINTS):A({},Pi),Tn=q(c,"HTML_INTEGRATION_POINTS")&&c.HTML_INTEGRATION_POINTS&&typeof c.HTML_INTEGRATION_POINTS=="object"?ee(c.HTML_INTEGRATION_POINTS):A({},Bi);let h=q(c,"CUSTOM_ELEMENT_HANDLING")&&c.CUSTOM_ELEMENT_HANDLING&&typeof c.CUSTOM_ELEMENT_HANDLING=="object"?ee(c.CUSTOM_ELEMENT_HANDLING):tt(null);if(O=tt(null),q(h,"tagNameCheck")&&Fi(h.tagNameCheck)&&(O.tagNameCheck=h.tagNameCheck),q(h,"attributeNameCheck")&&Fi(h.attributeNameCheck)&&(O.attributeNameCheck=h.attributeNameCheck),q(h,"allowCustomizedBuiltInElements")&&typeof h.allowCustomizedBuiltInElements=="boolean"&&(O.allowCustomizedBuiltInElements=h.allowCustomizedBuiltInElements),K(O),xe&&(an=!1),Rt&&(Ke=!0),je&&(w=A({},xr),R=tt(null),je.html===!0&&(A(w,Cr),A(R,Nr)),je.svg===!0&&(A(w,Fn),A(R,zn),A(R,Wt)),je.svgFilters===!0&&(A(w,Un),A(R,zn),A(R,Wt)),je.mathMl===!0&&(A(w,Hn),A(R,Lr),A(R,Wt))),Ce.tagCheck=null,Ce.attributeCheck=null,q(c,"ADD_TAGS")&&(typeof c.ADD_TAGS=="function"?Ce.tagCheck=c.ADD_TAGS:ke(c.ADD_TAGS)&&(w===vi&&(w=ee(w)),A(w,c.ADD_TAGS,k))),q(c,"ADD_ATTR")&&(typeof c.ADD_ATTR=="function"?Ce.attributeCheck=c.ADD_ATTR:ke(c.ADD_ATTR)&&(R===Ci&&(R=ee(R)),A(R,c.ADD_ATTR,k))),q(c,"ADD_URI_SAFE_ATTR")&&ke(c.ADD_URI_SAFE_ATTR)&&A(mn,c.ADD_URI_SAFE_ATTR,k),q(c,"FORBID_CONTENTS")&&ke(c.FORBID_CONTENTS)&&(de===pn&&(de=ee(de)),A(de,c.FORBID_CONTENTS,k)),q(c,"ADD_FORBID_CONTENTS")&&ke(c.ADD_FORBID_CONTENTS)&&(de===pn&&(de=ee(de)),A(de,c.ADD_FORBID_CONTENTS,k)),hn&&(w["#text"]=!0),Me&&A(w,["html","head","body"]),w.table&&(A(w,["tbody"]),delete lt.tbody),c.TRUSTED_TYPES_POLICY){if(typeof c.TRUSTED_TYPES_POLICY.createHTML!="function")throw $e('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof c.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw $e('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let m=te;te=c.TRUSTED_TYPES_POLICY;try{Ie=Ge("")}catch(b){throw te=m,b}}else c.TRUSTED_TYPES_POLICY===null?(te=void 0,Ie=""):(te===void 0&&(te=Bo()),te&&typeof Ie=="string"&&(Ie=Ge("")));G&&G(c),Ye=c},Ui=A({},[...Fn,...Un,...ma]),Hi=A({},[...Hn,...ga]),Jo=function(c,h,m){return h.namespaceURI===he?c==="svg":h.namespaceURI===kt?c==="svg"&&(m==="annotation-xml"||bn[m]):!!Ui[c]},es=function(c,h,m){return h.namespaceURI===he?c==="math":h.namespaceURI===Dt?c==="math"&&Tn[m]:!!Hi[c]},ts=function(c,h,m){return h.namespaceURI===Dt&&!Tn[m]||h.namespaceURI===kt&&!bn[m]?!1:!Hi[c]&&(Yo[c]||!Ui[c])},ns=function(c){let h=M(c);(!h||!h.tagName)&&(h={namespaceURI:Ve,tagName:"template"});let m=Tt(c.tagName),b=Tt(h.tagName);return yn[c.namespaceURI]?c.namespaceURI===Dt?Jo(m,h,b):c.namespaceURI===kt?es(m,h,b):c.namespaceURI===he?ts(m,h,b):!!(ut==="application/xhtml+xml"&&yn[c.namespaceURI]):!1},Ne=function(c){et(t.removed,{element:c});try{M(c).removeChild(c)}catch{if(E(c),!M(c))throw $e("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},zi=function(c){let h=C(c);if(h){let b=[];gt(h,S=>{et(b,S)}),gt(b,S=>{try{E(S)}catch{}})}let m=le(c);if(m)for(let b=m.length-1;b>=0;--b){let S=m[b],v=S&&S.name;if(typeof v=="string")try{c.removeAttribute(v)}catch{}}},Pe=function(c,h){try{et(t.removed,{attribute:h.getAttributeNode(c),from:h})}catch{et(t.removed,{attribute:null,from:h})}if(h.removeAttribute(c),c==="is")if(Ke||Rt)try{Ne(h)}catch{}else try{h.setAttribute(c,"")}catch{}},is=function(c){let h=le(c);if(h)for(let m=h.length-1;m>=0;--m){let b=h[m],S=b&&b.name;if(!(typeof S!="string"||R[k(S)]))try{c.removeAttribute(S)}catch{}}},rs=function(c){let h=[c];for(;h.length>0;){let m=h.pop();(Q?Q(m):m.nodeType)===me.element&&is(m);let S=C(m);if(S)for(let v=S.length-1;v>=0;--v)h.push(S[v])}},qi=function(c){let h=null,m=null;if(dn)c="<remove></remove>"+c;else{let v=Er(c,/^[\r\n\t ]+/);m=v&&v[0]}ut==="application/xhtml+xml"&&Ve===he&&(c='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+c+"</body></html>");let b=te?Ge(c):c;if(Ve===he)try{h=new d().parseFromString(b,ut)}catch{}if(!h||!h.documentElement){h=sn.createDocument(Ve,"template",null);try{h.documentElement.innerHTML=gn?Ie:b}catch{}}let S=h.body||h.documentElement;return c&&m&&S.insertBefore(n.createTextNode(m),S.childNodes[0]||null),Ve===he?Uo.call(h,Me?"html":"body")[0]:Me?h.documentElement:S},$i=function(c){return Ei.call(c.ownerDocument||c,c,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},It=function(c){return c=yt(c,zo," "),c=yt(c,qo," "),c=yt(c,$o," "),c},En=function(c){var h;c.normalize();let m=Ei.call(c.ownerDocument||c,c,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),b=m.nextNode();for(;b;)b.data=It(b.data),b=m.nextNode();let S=(h=c.querySelectorAll)===null||h===void 0?void 0:h.call(c,"template");S&>(S,v=>{Xe(v.content)&&En(v.content)})},Mt=function(c){let h=ve?ve(c):null;return typeof h!="string"||k(h)!=="form"?!1:typeof c.nodeName!="string"||typeof c.textContent!="string"||typeof c.removeChild!="function"||c.attributes!==le(c)||typeof c.removeAttribute!="function"||typeof c.setAttribute!="function"||typeof c.namespaceURI!="string"||typeof c.insertBefore!="function"||typeof c.hasChildNodes!="function"||c.nodeType!==Q(c)||c.childNodes!==C(c)},Xe=function(c){if(!Q||typeof c!="object"||c===null)return!1;try{return Q(c)===me.documentFragment}catch{return!1}},dt=function(c){if(!Q||typeof c!="object"||c===null)return!1;try{return typeof Q(c)=="number"}catch{return!1}};function be(g,c,h){g.length!==0&>(g,m=>{m.call(t,c,h,Ye)})}let os=function(c,h){return!!(ct&&c.hasChildNodes()&&!dt(c.firstElementChild)&&W(Rr,c.textContent)&&W(Rr,c.innerHTML)||ct&&c.namespaceURI===he&&h==="style"&&dt(c.firstElementChild)||c.nodeType===me.processingInstruction||ct&&c.nodeType===me.comment&&W(xa,c.data))},ss=function(c,h){if(!lt[h]&&Ki(h)&&(O.tagNameCheck instanceof RegExp&&W(O.tagNameCheck,h)||O.tagNameCheck instanceof Function&&O.tagNameCheck(h)))return!1;if(hn&&!de[h]){let m=M(c),b=C(c);if(b&&m){let S=b.length;for(let v=S-1;v>=0;--v){let U=fn?b[v]:y(b[v],!0);m.insertBefore(U,N(c))}}}return Ne(c),!0},Wi=function(c){if(be(I.beforeSanitizeElements,c,null),Mt(c))return Ne(c),!0;let h=k(ve?ve(c):c.nodeName);if(be(I.uponSanitizeElement,c,{tagName:h,allowedTags:w}),os(c,h))return Ne(c),!0;if(lt[h]||!(Ce.tagCheck instanceof Function&&Ce.tagCheck(h))&&!w[h])return ss(c,h);if((Q?Q(c):c.nodeType)===me.element&&!ns(c)||(h==="noscript"||h==="noembed"||h==="noframes")&&W(Na,c.innerHTML))return Ne(c),!0;if(xe&&c.nodeType===me.text){let b=It(c.textContent);c.textContent!==b&&(et(t.removed,{element:c.cloneNode()}),c.textContent=b)}return be(I.afterSanitizeElements,c,null),!1},Gi=function(c,h,m){if(xi[h]||Ri&&(h==="id"||h==="name")&&(m in n||m in Zo))return!1;let b=R[h]||Ce.attributeCheck instanceof Function&&Ce.attributeCheck(h,c);if(!(an&&W(Wo,h))){if(!(Ni&&W(Go,h))){if(b){if(!mn[h]){if(!W(Ai,yt(m,Si,""))){if(!((h==="src"||h==="xlink:href"||h==="href")&&c!=="script"&&Sr(m,"data:")===0&&Di[c])){if(!(Li&&!W(Ko,yt(m,Si,"")))){if(m)return!1}}}}}else if(!(Ki(c)&&(O.tagNameCheck instanceof RegExp&&W(O.tagNameCheck,c)||O.tagNameCheck instanceof Function&&O.tagNameCheck(c))&&(O.attributeNameCheck instanceof RegExp&&W(O.attributeNameCheck,h)||O.attributeNameCheck instanceof Function&&O.attributeNameCheck(h,c))||h==="is"&&O.allowCustomizedBuiltInElements&&(O.tagNameCheck instanceof RegExp&&W(O.tagNameCheck,m)||O.tagNameCheck instanceof Function&&O.tagNameCheck(m))))return!1}}return!0},as=A({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Ki=function(c){return!as[Tt(c)]&&W(jo,c)},ls=function(c,h,m,b){if(te&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!m)switch(f.getAttributeType(c,h)){case"TrustedHTML":return Ge(b);case"TrustedScriptURL":return Po(b)}return b},cs=function(c,h,m,b){try{m?c.setAttributeNS(m,h,b):c.setAttribute(h,b),Mt(c)?Ne(c):_r(t.removed)}catch{Pe(h,c)}},ji=function(c){be(I.beforeSanitizeAttributes,c,null);let h=c.attributes;if(!h||Mt(c))return;let m={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:R,forceKeepAttr:void 0},b=h.length,S=k(c.nodeName);for(;b--;){let v=h[b],U=v.name,P=v.namespaceURI,oe=v.value,ce=k(U),An=oe,Z=U==="value"?An:la(An);if(m.attrName=ce,m.attrValue=Z,m.keepAttr=!0,m.forceKeepAttr=void 0,be(I.uponSanitizeAttribute,c,m),Z=m.attrValue,Oi&&(ce==="id"||ce==="name")&&Sr(Z,ki)!==0&&(Pe(U,c),Z=ki+Z),ct&&W(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Z)){Pe(U,c);continue}if(ce==="attributename"&&Er(Z,"href")){Pe(U,c);continue}if(!m.forceKeepAttr){if(!m.keepAttr){Pe(U,c);continue}if(!wi&&W(La,Z)){Pe(U,c);continue}if(xe&&(Z=It(Z)),!Gi(S,ce,Z)){Pe(U,c);continue}Z=ls(S,ce,P,Z),Z!==An&&cs(c,U,P,Z)}}be(I.afterSanitizeAttributes,c,null)},Pt=function(c){let h=null,m=$i(c);for(be(I.beforeSanitizeShadowDOM,c,null);h=m.nextNode();)if(be(I.uponSanitizeShadowNode,h,null),Wi(h),ji(h),Xe(h.content)&&Pt(h.content),(Q?Q(h):h.nodeType)===me.element){let S=$(h);Xe(S)&&(Sn(S),Pt(S))}be(I.afterSanitizeShadowDOM,c,null)},Sn=function(c){let h=[{node:c,shadow:null}];for(;h.length>0;){let m=h.pop();if(m.shadow){Pt(m.shadow);continue}let b=m.node,v=(Q?Q(b):b.nodeType)===me.element,U=C(b);if(U)for(let P=U.length-1;P>=0;--P)h.push({node:U[P],shadow:null});if(v){let P=ve?ve(b):null;if(typeof P=="string"&&k(P)==="template"){let oe=b.content;Xe(oe)&&h.push({node:oe,shadow:null})}}if(v){let P=$(b);Xe(P)&&h.push({node:null,shadow:P},{node:P,shadow:null})}}};return t.sanitize=function(g){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},h=null,m=null,b=null,S=null;if(gn=!g,gn&&(g="<!-->"),typeof g!="string"&&!dt(g)&&(g=fa(g),typeof g!="string"))throw $e("dirty is not a string, aborting");if(!t.isSupported)return g;ln?(w=cn,R=un):_n(c),(I.uponSanitizeElement.length>0||I.uponSanitizeAttribute.length>0)&&(w=ee(w)),I.uponSanitizeAttribute.length>0&&(R=ee(R)),t.removed=[];let v=fn&&typeof g!="string"&&dt(g);if(v){let oe=ve?ve(g):g.nodeName;if(typeof oe=="string"){let ce=k(oe);if(!w[ce]||lt[ce])throw $e("root node is forbidden and cannot be sanitized in-place")}if(Mt(g))throw $e("root node is clobbered and cannot be sanitized in-place");try{Sn(g)}catch(ce){throw zi(g),ce}}else if(dt(g))h=qi("<!---->"),m=h.ownerDocument.importNode(g,!0),m.nodeType===me.element&&m.nodeName==="BODY"||m.nodeName==="HTML"?h=m:h.appendChild(m),Sn(m);else{if(!Ke&&!xe&&!Me&&g.indexOf("<")===-1)return te&&Ot?Ge(g):g;if(h=qi(g),!h)return Ke?null:Ot?Ie:""}h&&dn&&Ne(h.firstChild);let U=$i(v?g:h);try{for(;b=U.nextNode();)Wi(b),ji(b),Xe(b.content)&&Pt(b.content)}catch(oe){throw v&&zi(g),oe}if(v)return gt(t.removed,oe=>{oe.element&&rs(oe.element)}),xe&&En(g),g;if(Ke){if(xe&&En(h),Rt)for(S=Fo.call(h.ownerDocument);h.firstChild;)S.appendChild(h.firstChild);else S=h;return(R.shadowroot||R.shadowrootmode)&&(S=Ho.call(i,S,!0)),S}let P=Me?h.outerHTML:h.innerHTML;return Me&&w["!doctype"]&&h.ownerDocument&&h.ownerDocument.doctype&&h.ownerDocument.doctype.name&&W(va,h.ownerDocument.doctype.name)&&(P="<!DOCTYPE "+h.ownerDocument.doctype.name+`>
|
|
24
|
-
`+P),xe&&(P=It(P)),te&&Ot?Ge(P):P},t.setConfig=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_n(g),ln=!0,cn=w,un=R},t.clearConfig=function(){Ye=null,ln=!1,cn=null,un=null,te=on,Ie=""},t.isValidAttribute=function(g,c,h){Ye||_n({});let m=k(g),b=k(c);return Gi(m,b,h)},t.addHook=function(g,c){typeof c=="function"&&q(I,g)&&et(I[g],c)},t.removeHook=function(g,c){if(q(I,g)){if(c!==void 0){let h=sa(I[g],c);return h===-1?void 0:aa(I[g],h,1)[0]}return _r(I[g])}},t.removeHooks=function(g){q(I,g)&&(I[g]=[])},t.removeAllHooks=function(){I=Or()},t}var Mr=Ir();var _='stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"',Wn='stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"',_t='fill="currentColor"',Y=(e,t="0 0 18 18")=>`<svg viewBox="${t}" width="18" height="18" aria-hidden="true" focusable="false">${e}</svg>`,Pr=`<line ${_} x1="7" x2="11" y1="7" y2="11"/><path ${_} d="M8.9,4.577a3.476,3.476,0,0,1,.36,4.679A3.476,3.476,0,0,1,4.577,8.9C3.185,7.5,2.035,6.4,4.217,4.217S7.5,3.185,8.9,4.577Z"/><path ${_} d="M13.423,9.1a3.476,3.476,0,0,0-4.679-.36,3.476,3.476,0,0,0,.36,4.679c1.392,1.392,2.5,2.542,4.679.36S14.815,10.5,13.423,9.1Z"/>`,X={bold:Y(`<path ${_} d="M5,4H9.5A2.5,2.5,0,0,1,12,6.5v0A2.5,2.5,0,0,1,9.5,9H5A0,0,0,0,1,5,9V4A0,0,0,0,1,5,4Z"/><path ${_} d="M5,9h5.5A2.5,2.5,0,0,1,13,11.5v0A2.5,2.5,0,0,1,10.5,14H5a0,0,0,0,1,0,0V9A0,0,0,0,1,5,9Z"/>`),italic:Y(`<line ${_} x1="7" x2="13" y1="4" y2="4"/><line ${_} x1="5" x2="11" y1="14" y2="14"/><line ${_} x1="8" x2="10" y1="14" y2="4"/>`),underline:Y(`<path ${_} d="M5,3V9a4.012,4.012,0,0,0,4,4H9a4.012,4.012,0,0,0,4-4V3"/><rect ${_t} height="1" rx="0.5" ry="0.5" width="12" x="3" y="15"/>`),strike:Y(`<path ${_t} d="M9.007,8C6.542,7.791,6,7.519,6,6.5,6,5.792,7.283,5,9,5c1.571,0,2.765.679,2.969,1.309a1,1,0,0,0,1.9-.617C13.356,4.106,11.354,3,9,3,6.2,3,4,4.538,4,6.5a3.2,3.2,0,0,0,.5,1.843Z"/><path ${_t} d="M8.984,10C11.457,10.208,12,10.479,12,11.5c0,0.708-1.283,1.5-3,1.5-1.571,0-2.765-.679-2.969-1.309a1,1,0,1,0-1.9.617C4.644,13.894,6.646,15,9,15c2.8,0,5-1.538,5-3.5a3.2,3.2,0,0,0-.5-1.843Z"/><line x1="2" y1="9" x2="16" y2="9" stroke="currentColor" fill="none" stroke-linecap="round" stroke-width="1.5"/>`),link:Y(Pr),unlink:Y(`${Pr}<line class="richclay-cut" x1="2.5" y1="15.5" x2="15.5" y2="2.5" stroke-linecap="round" stroke-width="3.5"/><line x1="4.06" y1="13.94" x2="13.94" y2="4.06" stroke="currentColor" fill="none" stroke-linecap="round" stroke-width="1.5"/>`),ul:Y(`<line ${_} x1="6" x2="15" y1="4" y2="4"/><line ${_} x1="6" x2="15" y1="9" y2="9"/><line ${_} x1="6" x2="15" y1="14" y2="14"/><line ${_} x1="3" x2="3" y1="4" y2="4"/><line ${_} x1="3" x2="3" y1="9" y2="9"/><line ${_} x1="3" x2="3" y1="14" y2="14"/>`),ol:Y(`<line ${_} x1="7" x2="15" y1="4" y2="4"/><line ${_} x1="7" x2="15" y1="9" y2="9"/><line ${_} x1="7" x2="15" y1="14" y2="14"/><line ${Wn} x1="2.5" x2="4.5" y1="5.5" y2="5.5"/><path ${_t} d="M3.5,6A0.5,0.5,0,0,1,3,5.5V3.085l-0.276.138A0.5,0.5,0,0,1,2.053,3c-0.124-.247-0.023-0.324.224-0.447l1-.5A0.5,0.5,0,0,1,4,2.5v3A0.5,0.5,0,0,1,3.5,6Z"/><path ${Wn} d="M4.5,10.5h-2c0-.234,1.85-1.076,1.85-2.234A0.959,0.959,0,0,0,2.5,8.156"/><path ${Wn} d="M2.5,14.846a0.959,0.959,0,0,0,1.85-.109A0.7,0.7,0,0,0,3.75,14a0.688,0.688,0,0,0,.6-0.736,0.959,0.959,0,0,0-1.85-.109"/>`),quote:Y(`<path ${_} d="M10 10.8182L9 10.8182C8.80222 10.8182 8.60888 10.7649 8.44443 10.665C8.27998 10.5651 8.15181 10.4231 8.07612 10.257C8.00043 10.0909 7.98063 9.90808 8.01922 9.73174C8.0578 9.55539 8.15304 9.39341 8.29289 9.26627C8.43275 9.13913 8.61093 9.05255 8.80491 9.01747C8.99889 8.98239 9.19996 9.00039 9.38268 9.0692C9.56541 9.13801 9.72159 9.25453 9.83147 9.40403C9.94135 9.55353 10 9.72929 10 9.90909L10 12.1818C10 12.664 9.78929 13.1265 9.41421 13.4675C9.03914 13.8084 8.53043 14 8 14"/><path ${_} d="M16 10.8182L15 10.8182C14.8022 10.8182 14.6089 10.7649 14.4444 10.665C14.28 10.5651 14.1518 10.4231 14.0761 10.257C14.0004 10.0909 13.9806 9.90808 14.0192 9.73174C14.0578 9.55539 14.153 9.39341 14.2929 9.26627C14.4327 9.13913 14.6109 9.05255 14.8049 9.01747C14.9989 8.98239 15.2 9.00039 15.3827 9.0692C15.5654 9.13801 15.7216 9.25453 15.8315 9.40403C15.9414 9.55353 16 9.72929 16 9.90909L16 12.1818C16 12.664 15.7893 13.1265 15.4142 13.4675C15.0391 13.8084 14.5304 14 14 14"/>`,"2 2 20 20"),undo:Y(`<polyline ${_} points="6.5 4 3.5 7 6.5 10"/><path ${_} d="M3.5 7H10a3.5 3.5 0 0 1 0 7H7"/>`),redo:Y(`<polyline ${_} points="11.5 4 14.5 7 11.5 10"/><path ${_} d="M14.5 7H8a3.5 3.5 0 0 0 0 7h3"/>`),clear:Y(`<line ${_} x1="5" x2="13" y1="3" y2="3"/><line ${_} x1="6" x2="9.35" y1="12" y2="3"/><line ${_} x1="11" x2="15" y1="11" y2="15"/><line ${_} x1="15" x2="11" y1="11" y2="15"/><rect ${_t} height="1" rx="0.5" ry="0.5" width="7" x="2" y="14"/>`),code:Y(`<polyline ${_} points="5 7 3 9 5 11"/><polyline ${_} points="13 7 15 9 13 11"/><line ${_} x1="10" x2="8" y1="5" y2="13"/>`),indent:Y(`<line ${_} x1="3" x2="15" y1="4" y2="4"/><line ${_} x1="8" x2="15" y1="9" y2="9"/><line ${_} x1="3" x2="15" y1="14" y2="14"/><polyline ${_} points="3 7 5.5 9 3 11"/>`),outdent:Y(`<line ${_} x1="3" x2="15" y1="4" y2="4"/><line ${_} x1="8" x2="15" y1="9" y2="9"/><line ${_} x1="3" x2="15" y1="14" y2="14"/><polyline ${_} points="5.5 7 3 9 5.5 11"/>`),blocks:Y(`<line ${_} x1="3" x2="15" y1="4" y2="4"/><line ${_} x1="3" x2="15" y1="9" y2="9"/><line ${_} x1="3" x2="10" y1="14" y2="14"/>`)},Se=e=>e.blocksStayOut(),Oa=e=>!!e.element.closest("a"),Et={minimal:["bold","italic","link","unorderedList"],inline:["bold","italic","underline","strikethrough","code","link","unlink","undo","redo","clearFormatting"],standard:["blockMenu","bold","italic","underline","strikethrough","code","link","unlink","unorderedList","orderedList","quote","outdent","indent","undo","redo","clearFormatting"]};function Br(){return new Map(ka.map(e=>[e.id,e]))}function nt(e=globalThis){let t=e?.navigator;return t?/Mac|iPhone|iPad|iPod/.test(t.platform||t.userAgent||""):!1}function Fr(e,t=globalThis){return e?e.replace("Mod",nt(t)?"Cmd":"Ctrl"):""}var ka=[De("bold","Bold",X.bold,"Mod+B","inline",e=>e.toggleFormat("B","bold","removeBold")),De("italic","Italic",X.italic,"Mod+I","inline",e=>e.toggleFormat("I","italic","removeItalic")),De("underline","Underline",X.underline,"Mod+U","inline",e=>e.toggleFormat("U","underline","removeUnderline")),De("strikethrough","Strikethrough",X.strike,"Mod+Shift+7","inline",e=>e.toggleFormat("S","strikethrough","removeStrikethrough")),De("code","Code",X.code,null,"inline",e=>e.toggleCode(),e=>e.selectionHasFormat("CODE")||e.selectionHasFormat("PRE")),{id:"link",label:"Link",ariaLabel:"Insert or edit link",icon:X.link,group:"links",shortcut:"Mod+K",mutates:!1,isDisabled:Oa,run:e=>e.openLinkDialog(),isActive:e=>e.selectionHasFormat("A")},{id:"unlink",label:"Remove link",ariaLabel:"Remove link",icon:X.unlink,group:"links",run:e=>e.squire.removeLink()},De("unorderedList","Bulleted list",X.ul,"Mod+Shift+8","lists",e=>e.toggleList("UL"),e=>e.pathHas("UL"),Se),De("orderedList","Numbered list",X.ol,"Mod+Shift+9","lists",e=>e.toggleList("OL"),e=>e.pathHas("OL"),Se),De("quote","Quote",X.quote,null,"blocks",e=>e.pathHas("BLOCKQUOTE")?e.squire.decreaseQuoteLevel():e.squire.increaseQuoteLevel(),e=>e.pathHas("BLOCKQUOTE"),Se),{id:"outdent",label:"Outdent",ariaLabel:"Decrease indent",icon:X.outdent,group:"blocks",shortcut:"Mod+[",isDisabled:Se,run:e=>e.outdent()},{id:"indent",label:"Indent",ariaLabel:"Increase indent",icon:X.indent,group:"blocks",shortcut:"Mod+]",isDisabled:Se,run:e=>e.indent()},{id:"undo",label:"Undo",ariaLabel:"Undo",icon:X.undo,group:"history",shortcut:"Mod+Z",mutates:!1,run:e=>e.squire.undo()},{id:"redo",label:"Redo",ariaLabel:"Redo",icon:X.redo,group:"history",shortcut:"Mod+Shift+Z",mutates:!1,run:e=>e.squire.redo()},{id:"clearFormatting",label:"Clear formatting",ariaLabel:"Clear formatting",icon:X.clear,group:"cleanup",run:e=>e.squire.removeAllFormatting()},{id:"blockMenu",type:"menu",label:"Block style",ariaLabel:"Choose block style",icon:X.blocks,group:"blocks",isDisabled:Se,options:[Gt("Paragraph","P"),Gt("Heading 1","H1"),Gt("Heading 2","H2"),Gt("Heading 3","H3"),{label:"Quote",value:"BLOCKQUOTE",isDisabled:Se,run:e=>e.squire.increaseQuoteLevel(),isActive:e=>e.pathHas("BLOCKQUOTE")},{label:"Code block",value:"PRE",isDisabled:Se,run:e=>e.setBlockType("PRE"),isActive:e=>e.pathHas("PRE")}]}];function De(e,t,n,i,r,o,s=l=>l.selectionHasFormat(Da(e)),a){return{id:e,label:t,ariaLabel:t,icon:n,group:r,shortcut:i,isDisabled:a,run:o,isActive:s}}function Da(e){return{bold:"B",italic:"I",underline:"U",strikethrough:"S"}[e]}function Gt(e,t){return{label:e,value:t,isDisabled:Se,run:n=>n.setBlockType(t),isActive:n=>n.pathHas(t)}}var Kn=/^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|EL|FN)|EM|FONT|HR|I(?:FRAME|MG|NPUT|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:AMP|MALL|PAN|TR(?:IKE|ONG)|U[BP])?|TIME|U|VAR|WBR)$/,jt=/[^ \t\r\n]/;var Ia=new Set(["BR","HR","IFRAME","IMG","INPUT","WBR"]),jn=e=>e?.nodeType===1&&e.matches('[editor-ui],[clay~="editor-ui"]'),At=new Set(["svg","math"]);function Vt(e){let t=e.nodeType;return t===3||t===8?!0:t!==1?!1:At.has(e.nodeName)?!0:Kn.test(e.nodeName)?Array.from(e.childNodes).every(Vt):!1}function vt(e){return Array.from(e.childNodes).some(t=>!Vt(t))}var Gn=e=>e?.nodeType===1&&!At.has(e.nodeName)&&!Kn.test(e.nodeName);function Ct(e,t){let n=Array.from(e.childNodes),i=0;return n.forEach((r,o)=>{if(!(r.nodeType!==1||At.has(r.nodeName))&&(i+=Ct(r,t),!!Gn(r))){for(Gn(n[o-1])&&e.insertBefore(t(),r);r.firstChild;)e.insertBefore(r.firstChild,r);r.remove(),i+=1}}),i}var Vn=new Set(["TABLE","THEAD","TBODY","TFOOT","TR","COLGROUP"]);function Yt(e){return!!e.closest?.("p")||Vn.has(e.nodeName)}var Ma=new Set(["P","H1","H2","H3","H4","H5","H6","PRE","LABEL","LEGEND","LI","TD","TH","DT","DD","FIGCAPTION","SUMMARY","CAPTION"]);function qr(e){return Ma.has(e.nodeName)||Xt(e)}var $r=new Set(["AREA","BASE","BR","COL","EMBED","HR","IMG","INPUT","LINK","META","PARAM","SOURCE","TRACK","WBR"]),Pa=new Set(["SCRIPT","STYLE","TEXTAREA","TITLE","IFRAME","NOSCRIPT","XMP"]),Wr="http://www.w3.org/1999/xhtml";function Gr(e){return Vn.has(e.nodeName)||$r.has(e.nodeName)||Pa.has(e.nodeName)||e.nodeName==="TEMPLATE"||!!e.namespaceURI&&e.namespaceURI!==Wr}function Kr(e){return Vn.has(e.nodeName)?"a table element cannot be an editable region. Move the editable attribute to a <td>, a <th>, or an element inside one.":e.namespaceURI&&e.namespaceURI!==Wr?"an SVG or MathML element cannot be an editable region: an edit puts an HTML block inside it, and the next page load moves that text out of the graphic entirely. Put a <foreignObject> in the SVG and mark an HTML element inside it instead.":$r.has(e.nodeName)?"this element cannot contain anything, so there is nothing to edit. Move the editable attribute to an element that holds text.":e.nodeName==="TEMPLATE"?"a <template> keeps its content out of the document, so edits to it are never saved.":"this element treats its content as plain text, so any edit would be saved as visible markup rather than formatting."}function Xt(e){return e.nodeType===1&&!At.has(e.nodeName)&&Kn.test(e.nodeName)}function Qt(e){return Array.from(e.querySelectorAll("*")).some(Gn)}function jr(e,t={}){let{blockTag:n="DIV",wrapBareRoot:i=!1,onBareRootWrapped:r,blocksAllowed:o=!Yt(e)}=t;return Xr(e),o&&Ua(e,n,i,r),e}var Ba=e=>Vt(e)&&e.nodeType!==8&&!jn(e),Fa=e=>e.nodeType!==8&&!jn(e)&&!(e.nodeType===3&&!jt.test(e.nodeValue));function Vr(e,{wrapBareRoot:t=!1,blocksAllowed:n=!Yt(e)}={}){return n?vt(e)?Array.from(e.childNodes).some(Ba)||Yr(e):t:!1}function Yr(e){return Array.from(e.children).some(t=>vt(t)?!Yn(t)&&Array.from(t.childNodes).some(i=>i.nodeType===3&&!jt.test(i.nodeValue))||Yr(t):!1)}function Xr(e){vt(e)&&(Yn(e)||Array.from(e.childNodes).forEach(t=>{t.nodeType===3&&!jt.test(t.nodeValue)&&t.remove()}),Array.from(e.children).forEach(Xr))}function Ua(e,t,n,i){if(!vt(e)){if(!n)return;let s=e.ownerDocument.createElement(t);if(!Array.from(e.childNodes).some(Fa)){s.appendChild(e.ownerDocument.createElement("BR")),e.appendChild(s);return}for(;e.firstChild;)s.appendChild(e.firstChild);e.appendChild(s),i?.(e,s);return}let r=[],o=()=>{let s=r;if(r=[],!s.some(l=>l.nodeType!==8))return;let a=e.ownerDocument.createElement(t);e.insertBefore(a,s[0]),s.forEach(l=>a.appendChild(l))};Array.from(e.childNodes).forEach(s=>{jn(s)?o():Vt(s)?r.push(s):o()}),o()}function Yn(e){return e.nodeName==="PRE"}function Qr(e,t){return{start:Ur(e,t.startContainer,t.startOffset),end:Ur(e,t.endContainer,t.endOffset),collapsed:t.collapsed}}function Zr(e,t,n){zr(t,"setStart",e,n.start),n.collapsed?t.collapse(!0):zr(t,"setEnd",e,n.end)}function Ur(e,t,n){if(!e.contains(t))return{scope:e,after:[],before:[]};if(t.nodeType===3){if(!Ha(t))return{container:t,offset:n};let i=t.parentNode;return Hr(i,Array.from(i.childNodes).indexOf(t))}return{container:t,offset:n,childCount:t.childNodes.length,...Hr(t,n)}}function Hr(e,t){let n=Array.from(e.childNodes),i=Math.max(0,t);return{scope:e,after:n.slice(i),before:n.slice(0,i).reverse()}}function zr(e,t,n,i){let{container:r,childCount:o}=i;if(r&&n.contains(r)&&(o===void 0||o===r.childNodes.length)){e[t](r,Math.min(i.offset,Kt(r)));return}let s=i.after?.find(u=>n.contains(u));if(s){e[t](St(s,!0),0);return}let a=i.before?.find(u=>n.contains(u));if(a){let u=St(a,!1);e[t](u,Kt(u));return}let l=i.scope&&n.contains(i.scope)?i.scope:n;e[t](l,0)}function Ha(e){return e.nodeType===3&&!jt.test(e.nodeValue)&&!!e.parentNode&&e.parentNode.nodeType===1&&vt(e.parentNode)&&!Yn(e.parentNode)}var it=e=>e.nodeType===1||e.nodeType===3;function St(e,t=!0){let n=e;for(;n.nodeType===1&&!At.has(n.nodeName);){let i=Array.from(n.childNodes).filter(it),r=t?i[0]:i[i.length-1];if(!r||Ia.has(r.nodeName))break;n=r}return n}function Kt(e){return e.nodeType===3?e.nodeValue.length:e.childNodes.length}var ue="[data-richclay], [richclay], [editable], [clay-editable]",za="[data-richclay], [richclay], [clay-editable]",qa=["editable","clay-editable"],Zn=':is([editable~="single-line"], [clay-editable~="single-line"])';function ei(e){return!e||typeof e.matches!="function"?!1:e.tagName.includes("-")?e.matches(za):!0}var $a="[data-richclay-toolbar], [data-richclay-menu], [data-richclay-dialog], [data-richclay-live], [data-richclay-float]",Wa=["richclay-editor","richclay-inline","richclay-active","richclay-empty","richclay-focused"],Jn=new WeakSet,Jr=new WeakSet,eo=["clay:ready","hyperclay:ready"];function to(e){return[e.clay?.ready,e.hyperclay?.ready].find(t=>t&&typeof t.then=="function")||null}function no(e){return typeof e.clay?.isEditMode=="boolean"?e.clay.isEditMode:typeof e.hyperclay?.isEditMode=="boolean"?e.hyperclay.isEditMode:null}function Ga(e){let t=e.hyperclayModules,n=e.__hyperclayNoAutoExport===!1&&t&&typeof t=="object"&&typeof t.nodeType!="number";return no(e)!==null||!!to(e)||!!n}function Ka(e){return e.clay?.addDocumentTransform||e.hyperclay?.beforeSave||null}function ja(e){return e.clay?.onSnapshot||e.hyperclay?.onSnapshot||null}var Va={boxSizing:"border-box",minWidth:"100%",overflow:"auto",width:"0"};function Zt(e={},t=window){return e.hyperclay===!1?!1:e.hyperclay===!0?!0:!!(Ga(t)||nl(t))}function ti(e=window){let t=oo(e);if(t!==null)return t;if(typeof e.__hyperclayEditMode=="boolean")return e.__hyperclayEditMode;let n=no(e);return n!==null?n:il(e)}function io(e={},t=window){return e.readOnly?!1:Zt(e,t)?ti(t):!0}function ro(e){let t=qa.find(r=>e.hasAttribute(r));if(!t)return null;let n=new Set((e.getAttribute(t)||"").trim().split(/\s+/).filter(Boolean)),i={inline:!0,singleLine:n.has("single-line"),toolbarOnSelect:n.has("toolbar-on-select")};return n.has("no-toolbar")&&(i.toolbar=!1),i}function ni(e=window){if(Jn.has(e))return;let t=ja(e)||Ka(e);if(typeof t!="function"){Ya(e);return}t(n=>ii(n)),Jn.add(e)}function Ya(e){if(Jr.has(e))return;let t=e.document,n=to(e);if(!t&&!n)return;Jr.add(e);let i=()=>{ni(e),Jn.has(e)&&r()},r=()=>{t&&eo.forEach(o=>t.removeEventListener(o,i))};t&&eo.forEach(o=>t.addEventListener(o,i)),n&&n.then(i,()=>{})}function ii(e){e.querySelectorAll?.($a).forEach(t=>t.remove()),e.querySelectorAll?.(ue).forEach(t=>{if(t.getAttribute("data-richclay-active")!=="true")return;if(Jt(t,"save"),Ja(t)){let i=t.ownerDocument,r=!!t.matches?.(Zn);Ct(t,()=>r?i.createTextNode(" "):i.createElement("br")),t.querySelectorAll(t.localName).forEach(o=>{for(;o.firstChild;)o.parentNode.insertBefore(o.firstChild,o);o.remove()})}t.matches?.(Zn)&&tl(t),t.querySelectorAll("#squire-selection-start, #squire-selection-end").forEach(i=>{i.remove()}),t.querySelectorAll(".squire-image-resize-container").forEach(i=>i.remove()),el(t),(t.matches?.("pre")?[t,...t.querySelectorAll("pre")]:Array.from(t.querySelectorAll("pre"))).filter(i=>i.hasAttribute("data-richclay-pre")).forEach(i=>{Object.entries(Va).forEach(([r,o])=>{i.style[r]||(i.style[r]=o)}),i.removeAttribute("data-richclay-pre")})}),e.querySelectorAll?.("#squire-selection-start, #squire-selection-end").forEach(t=>t.remove())}var Xa="p, td, th, li, dl, dt, dd, table, blockquote, div, section, article, aside, main, header, footer, figure, figcaption",Xn="data-richclay-measure";function Qa(e){let t=e.ownerDocument,n=e.closest(Xa)||e;e.setAttribute(Xn,"");let i=t.createElement("div");try{i.innerHTML=n.outerHTML}finally{e.removeAttribute(Xn)}let r=i.querySelector(`[${Xn}]`);return!r||r.textContent!==e.textContent}var Za=e=>!!e.querySelector(e.localName),Ja=e=>!!e.matches?.(Zn)||(Qt(e)||Za(e))&&Qa(e);function Jt(e,t){let n=e.getAttribute("data-richclay-runtime-contenteditable");e.hasAttribute("contenteditable")&&(n==="true"?e.removeAttribute("contenteditable"):n?t==="destroy"?e.setAttribute("contenteditable",n):(e.setAttribute("inert-contenteditable",n),e.removeAttribute("contenteditable")):t==="save"&&(e.setAttribute("inert-contenteditable",e.getAttribute("contenteditable")),e.removeAttribute("contenteditable"))),Wa.forEach(i=>e.classList.remove(i)),e.getAttribute("class")===""&&e.removeAttribute("class"),Qn(e,"role","data-richclay-runtime-role"),Qn(e,"aria-multiline","data-richclay-runtime-aria-multiline"),Qn(e,"no-undo","data-richclay-runtime-no-undo"),e.getAttribute("data-richclay-runtime-display")==="true"&&(e.style.removeProperty("display"),e.getAttribute("style")===""&&e.removeAttribute("style")),rl(e),e.removeAttribute("data-richclay-active"),e.removeAttribute("data-richclay-placeholder"),e.removeAttribute("data-richclay-pre"),e.removeAttribute("data-richclay-runtime-role"),e.removeAttribute("data-richclay-runtime-aria-multiline"),e.removeAttribute("data-richclay-runtime-no-undo"),e.removeAttribute("data-richclay-runtime-describedby"),e.removeAttribute("data-richclay-runtime-contenteditable"),e.removeAttribute("data-richclay-runtime-display"),e.getAttribute("data-richclay-runtime-marker")==="true"&&e.removeAttribute("data-richclay"),e.removeAttribute("data-richclay-runtime-marker")}function el(e){let n=[e];for(;n.length;)n.pop().childNodes.forEach(r=>{r.nodeType===3?r.nodeValue.includes("\u200B")&&(r.nodeValue=r.nodeValue.split("\u200B").join("")):r.nodeType===1&&n.push(r)});e.querySelectorAll("b, i, u, s, em, strong, code, sub, sup, span").forEach(i=>{i.children.length===0&&(i.textContent||"")===""&&i.attributes.length===0&&i.remove()})}function tl(e){let t=Array.from(e.childNodes).filter(i=>i.nodeType!==3||(i.nodeValue||"").trim()!=="");if(t.length!==1)return;let n=t[0];if(!(n.nodeType!==1||n.nodeName!=="P"||n.attributes.length>0)){for(;n.firstChild;)e.insertBefore(n.firstChild,n);n.remove()}}function ri(e){if(!e.hasAttribute("inert-contenteditable"))return null;let t=e.getAttribute("inert-contenteditable");return["false","plaintext-only"].includes(t)||(t="true"),e.setAttribute("contenteditable",t),e.removeAttribute("inert-contenteditable"),t==="true"&&e.setAttribute("data-richclay-runtime-contenteditable","true"),t}function ye(e){return e.setAttribute("snapshot-remove",""),e.setAttribute("no-watch",""),e}function oo(e){try{let t=new URLSearchParams(e.location?.search||"");if(t.get("editmode")==="true")return!0;if(t.get("editmode")==="false")return!1}catch{return null}return null}function nl(e){return oo(e)!==null||typeof e.__hyperclayEditMode=="boolean"}function il(e){let n=(e.document?.cookie||"").match(/(?:^|;\s*)isAdminOfCurrentResource=([^;]*)/);return!!(n&&n[1]!=="")}function Qn(e,t,n){e.hasAttribute(n)&&e.removeAttribute(t)}function rl(e){let t=e.getAttribute("data-richclay-runtime-describedby");if(!t)return;let n=(e.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean).filter(i=>i!==t);n.length?e.setAttribute("aria-describedby",n.join(" ")):e.removeAttribute("aria-describedby")}var ol=0;function so(e=document){let t=e.createElement("div");return t.id=`richclay-live-${++ol}`,t.className="richclay-sr-only",t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.setAttribute("data-richclay-live",""),ye(t),e.body.appendChild(t),t}function xt(e,t){!e||!t||(e.textContent="",e.ownerDocument.defaultView.setTimeout(()=>{e.textContent=t},20))}function oi(e){e.preventDefault()}function si(e){try{return e?.cloneRange?.()||null}catch{return null}}function rt(e){try{return si(e?.getSelection?.())}catch{return null}}function en(e,t){if(!e||!t)return!1;try{return e.setSelection(t),!0}catch{return!1}}function tn(e,t,n,i){e.hasAttribute(t)||e.setAttribute(i,"true"),e.setAttribute(t,n)}function ao(e,t){let n=new Set((e.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));n.add(t.id),e.setAttribute("aria-describedby",Array.from(n).join(" ")),e.setAttribute("data-richclay-runtime-describedby",t.id)}var sl=0,ot=class{constructor(t,n,i={}){this.editor=t,this.controls=n,this.options=i,this.id=++sl,this.items=[],this.menus=new Map,this.activeIndex=0,this.root=this.createRoot(),this.onRootKeydown=r=>this.handleRootKeydown(r),this.onRootClick=r=>this.handleRootClick(r),this.onRootPointerDown=r=>this.handleRootPointerDown(r),this.onDocumentPointerDown=r=>this.handleDocumentPointerDown(r),this.render(),this.root.addEventListener("keydown",this.onRootKeydown),this.root.addEventListener("click",this.onRootClick),this.root.addEventListener("mousedown",this.onRootPointerDown),this.root.ownerDocument.addEventListener("mousedown",this.onDocumentPointerDown)}destroy(){this.closeMenus(),this.root.removeEventListener("keydown",this.onRootKeydown),this.root.removeEventListener("click",this.onRootClick),this.root.removeEventListener("mousedown",this.onRootPointerDown),this.root.ownerDocument.removeEventListener("mousedown",this.onDocumentPointerDown),this.root.remove()}update(){this.items.forEach(t=>{let{def:n,button:i}=t;if(typeof n.isActive=="function"){let r=!!n.isActive(this.editor);i.setAttribute("aria-pressed",r?"true":"false"),i.classList.toggle("is-active",r)}typeof n.isDisabled=="function"&&(i.disabled=!!n.isDisabled(this.editor))}),this.ensureSingleTabStop()}focusFirst(){this.activeIndex=0,this.ensureSingleTabStop(),this.items[0]?.button.focus()}createRoot(){let t=this.editor.element.ownerDocument,n=t.createElement("div");n.className="richclay-toolbar",n.setAttribute("role","toolbar"),n.setAttribute("aria-label",this.options.ariaLabel||"Rich text formatting"),n.setAttribute("data-richclay-toolbar",""),ye(n);let i=al(this.options.toolbarContainer,t);return i?i.appendChild(n):this.editor.element.insertAdjacentElement("beforebegin",n),n}render(){this.root.textContent="",this.items=[],this.menus.clear();let t=null;this.visibleControls().forEach((n,i)=>{if(n.type==="separator"){this.root.appendChild(co(this.root.ownerDocument)),t=null;return}t&&n.group&&n.group!==t&&this.root.appendChild(co(this.root.ownerDocument)),t=n.group||t,n.type==="menu"?this.renderMenu(n,i):this.renderButton(n,i)}),this.ensureSingleTabStop(),this.update()}visibleControls(){let t=this.controls.filter(i=>i.type==="separator"||!i.isDisabled?.(this.editor)),n=[];for(t.forEach(i=>{let r=n[n.length-1];i.type==="separator"&&(!r||r.type==="separator")||n.push(i)});n[n.length-1]?.type==="separator";)n.pop();return n}renderButton(t,n){let i=lo(this.root.ownerDocument,t);i.dataset.richclayControl=t.id,i.dataset.richclayIndex=String(n),typeof t.isActive=="function"&&i.setAttribute("aria-pressed","false"),this.root.appendChild(i),this.items.push({def:t,button:i,type:"button"})}renderMenu(t,n){let i=this.root.ownerDocument,r=lo(i,t),o=`richclay-menu-${this.id}-${t.id}`;r.dataset.richclayControl=t.id,r.dataset.richclayIndex=String(n),r.setAttribute("aria-haspopup","menu"),r.setAttribute("aria-expanded","false"),r.setAttribute("aria-controls",o);let s=i.createElement("div");s.id=o,s.className="richclay-menu",s.hidden=!0,s.setAttribute("role","menu"),s.setAttribute("data-richclay-menu",""),ye(s),t.options.forEach((l,u)=>{let d=i.createElement("button");d.type="button",d.className="richclay-menu-item",d.setAttribute("role","menuitemradio"),d.setAttribute("tabindex","-1"),d.dataset.richclayMenuItem=t.id,d.dataset.richclayOptionIndex=String(u),d.textContent=l.label,d.addEventListener("mousedown",oi),d.addEventListener("click",f=>{f.preventDefault(),this.chooseMenuItem(t,l,r)}),d.addEventListener("keydown",f=>this.handleMenuKeydown(f,t,r)),s.appendChild(d)});let a=i.createElement("span");a.className="richclay-menu-wrap",a.append(r,s),this.root.appendChild(a),this.items.push({def:t,button:r,type:"menu",menu:s}),this.menus.set(t.id,{def:t,button:r,menu:s})}handleRootPointerDown(t){let n=t.target.closest?.("[data-richclay-control]");!n||!this.root.contains(n)||(oi(t),this.editor.saveSelection())}handleRootClick(t){let n=t.target.closest?.("[data-richclay-control]");if(!n||!this.root.contains(n))return;t.preventDefault();let i=this.items.find(r=>r.button===n);if(!(!i||n.disabled)){if(this.activeIndex=this.items.indexOf(i),this.ensureSingleTabStop(),i.type==="menu"){this.toggleMenu(i.def.id);return}this.closeMenus(),this.editor.runControl(i.def)}}handleRootKeydown(t){let n=t.key,i={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1};if(n in i){t.preventDefault(),this.moveFocus(i[n]);return}if(n==="Home"){t.preventDefault(),this.setFocusIndex(0);return}if(n==="End"){t.preventDefault(),this.setFocusIndex(this.items.length-1);return}let r=this.items[this.activeIndex];if(r&&((n==="Enter"||n===" ")&&r.type==="menu"&&(t.preventDefault(),this.openMenu(r.def.id,"first")),n==="Escape")){let o=Array.from(this.menus.values()).some(s=>!s.menu.hidden);this.closeMenus(),o?r.button.focus():this.editor.focus()}}handleMenuKeydown(t,n,i){t.stopPropagation();let r=this.menus.get(n.id)?.menu,o=Array.from(r.querySelectorAll(".richclay-menu-item")),s=o.indexOf(t.currentTarget),a=s;if(t.key==="ArrowDown"&&(a=(s+1)%o.length),t.key==="ArrowUp"&&(a=(s-1+o.length)%o.length),t.key==="Home"&&(a=0),t.key==="End"&&(a=o.length-1),a!==s){t.preventDefault(),o[a].focus();return}if(t.key==="Escape"){t.preventDefault(),this.closeMenus(),i.focus();return}if(t.key==="Enter"||t.key===" "){t.preventDefault();let l=n.options[s];this.chooseMenuItem(n,l,i)}}handleDocumentPointerDown(t){this.root.contains(t.target)||this.closeMenus()}chooseMenuItem(t,n,i){this.closeMenus(),this.editor.runControl({...n,id:`${t.id}:${n.value}`,ariaLabel:n.label}),i.focus()}toggleMenu(t){let n=this.menus.get(t);n&&(n.menu.hidden?this.openMenu(t,"first"):this.closeMenus())}openMenu(t,n="first"){this.closeMenus(t);let i=this.menus.get(t);if(!i)return;i.menu.hidden=!1,i.button.setAttribute("aria-expanded","true"),this.updateMenuState(i);let r=Array.from(i.menu.querySelectorAll(".richclay-menu-item")),o=r.find(a=>a.getAttribute("aria-checked")==="true");(n==="active"&&o||r[0])?.focus()}closeMenus(t=null){this.menus.forEach((n,i)=>{i!==t&&(n.menu.hidden=!0,n.button.setAttribute("aria-expanded","false"))})}updateMenuState(t){Array.from(t.menu.querySelectorAll(".richclay-menu-item")).forEach((i,r)=>{let s=!!t.def.options[r].isActive?.(this.editor);i.setAttribute("aria-checked",s?"true":"false"),i.classList.toggle("is-active",s)})}moveFocus(t){if(!this.items.length)return;let n=this.activeIndex;do n=(n+t+this.items.length)%this.items.length;while(this.items[n].button.disabled&&n!==this.activeIndex);this.setFocusIndex(n)}setFocusIndex(t){this.activeIndex=Math.max(0,Math.min(t,this.items.length-1)),this.ensureSingleTabStop(),this.items[this.activeIndex]?.button.focus()}ensureSingleTabStop(){let t=this.items.filter(n=>!n.button.disabled);t.length&&(t.includes(this.items[this.activeIndex])||(this.activeIndex=this.items.indexOf(t[0])),this.items.forEach((n,i)=>{n.button.tabIndex=i===this.activeIndex?0:-1}))}};function lo(e,t){let n=e.createElement("button");n.type="button",n.className="richclay-button";let i=Fr(t.shortcut,e.defaultView),r=i?`${t.ariaLabel||t.label} (${i})`:t.ariaLabel||t.label;return n.setAttribute("aria-label",r),n.title=r,n.innerHTML=`${t.icon||""}<span class="richclay-sr-only">${t.label}</span>`,n}function co(e){let t=e.createElement("span");return t.className="richclay-separator",t.setAttribute("role","separator"),t.setAttribute("aria-orientation","vertical"),t}function al(e,t){return e?typeof e=="string"?t.querySelector(e):e:null}var uo=16,ll=[16,8,0],ae=8,cl=4;function ul({anchor:e,bar:t,rail:n,viewport:i,current:r=null}){let o=p=>r===p?cl:0;if(e.bottom<=0||e.top>=i.height||e.right<=0||e.left>=i.width)return{mode:"hidden",x:0,y:0};let s=p=>Math.max(ae,Math.min(e.left,i.width-p-ae)),a=e.top-uo-t.height;if(a>=ae-o("above"))return{mode:"above",x:s(t.width),y:a};let l=e.bottom+uo;if(l+t.height<=i.height-ae+o("below"))return{mode:"below",x:s(t.width),y:l};let u=i.width-e.right-ae,d=e.left-ae,f=u>=d?[["rail-right",u],["rail-left",d]]:[["rail-left",d],["rail-right",u]];for(let[p,y]of f)for(let E of ll){if(n.width+E>y+o(p))continue;let N=p==="rail-right"?Math.min(e.right+E,i.width-n.width-ae):Math.max(e.left-E-n.width,ae),C=Math.min(e.bottom,i.height-ae)-n.height,M=Math.max(ae,Math.min(Math.max(e.top,ae),C));return{mode:p,x:N,y:M,gap:E}}return{mode:"pinned",x:s(t.width),y:ae}}var nn=class{constructor(t,n){this.editor=t,this.mode=null,this.hidden=!1,this.frame=0,this.bar={width:0,height:0},this.rail={width:0,height:0};let i=t.element.ownerDocument;this.doc=i,this.win=i.defaultView||globalThis,this.root=i.createElement("div"),this.root.className="richclay-float",this.root.setAttribute("data-richclay-float",""),this.root.setAttribute("save-remove",""),ye(this.root),i.body.appendChild(this.root),this.toolbar=new ot(t,n,{toolbarContainer:this.root}),this.onScroll=()=>this.schedule(),this.onResize=()=>{this.measure(),this.schedule()},i.addEventListener("scroll",this.onScroll,{capture:!0,passive:!0}),this.win.addEventListener("resize",this.onResize,{passive:!0}),this.win.visualViewport?.addEventListener("resize",this.onResize,{passive:!0}),this.win.visualViewport?.addEventListener("scroll",this.onScroll,{passive:!0}),this.resizeObserver=typeof this.win.ResizeObserver=="function"?new this.win.ResizeObserver(()=>this.schedule()):null,this.resizeObserver?.observe(t.element),this.measure(),this.reposition()}measure(){let t=this.root.classList.contains("richclay-float-rail");this.root.style.visibility="hidden",this.root.classList.remove("richclay-float-rail"),this.bar={width:this.root.offsetWidth||0,height:this.root.offsetHeight||0},this.root.classList.add("richclay-float-rail"),this.rail={width:this.root.offsetWidth||0,height:this.root.offsetHeight||0},this.root.classList.toggle("richclay-float-rail",t),this.root.style.visibility=""}schedule(){if(!this.win.requestAnimationFrame){this.reposition();return}this.frame||(this.frame=this.win.requestAnimationFrame(()=>{this.frame=0,this.reposition()}))}setVisible(t){this.hidden=!t,this.reposition()}reposition(){if(this.hidden){this.root.style.display="none";return}let t=this.editor.element.getBoundingClientRect(),n={width:this.win.visualViewport?.width??this.win.innerWidth,height:this.win.visualViewport?.height??this.win.innerHeight},i=ul({anchor:t,bar:this.bar,rail:this.rail,viewport:n,current:this.mode});if(this.mode=i.mode,i.mode==="hidden"){this.root.style.display="none";return}this.root.style.display="",this.root.classList.toggle("richclay-float-rail",i.mode==="rail-left"||i.mode==="rail-right"),this.root.classList.toggle("richclay-float-pinned",i.mode==="pinned"),this.root.style.transform=`translate(${Math.round(i.x)}px, ${Math.round(i.y)}px)`}destroy(){this.frame&&this.win.cancelAnimationFrame?.(this.frame),this.frame=0,this.doc.removeEventListener("scroll",this.onScroll,{capture:!0}),this.win.removeEventListener("resize",this.onResize),this.win.visualViewport?.removeEventListener("resize",this.onResize),this.win.visualViewport?.removeEventListener("scroll",this.onScroll),this.resizeObserver?.disconnect(),this.toolbar.destroy(),this.root.remove()}};var dl={ALLOWED_TAGS:["a","b","blockquote","br","code","div","em","h1","h2","h3","h4","h5","h6","i","li","ol","p","pre","s","span","strong","sub","sup","u","ul"],ALLOWED_ATTR:["aria-label","href","rel","target","title"],ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!0,ALLOWED_URI_REGEXP:/^(?:(?:(?:f|ht)tps?|mailto|tel):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,FORBID_TAGS:["script","style","iframe","object","embed","form","input"],FORBID_ATTR:["style","srcset","onerror","onclick","onload"]};function po(e={},t=document){let n=rn(t);return{sanitizeHTML(i){return ai(i,e,t,n)},sanitizeElement(i){return li(i,e,n)},sanitizeToDOMFragment(i,r){let o=r?.getRoot?.().ownerDocument||t;return hl(i,e,o,n)}}}function ai(e,t={},n=document,i=rn(n)){let r=n.createElement("template");return r.innerHTML=i.sanitize(String(e||""),ci(t)),ui(r.content),r.innerHTML}function li(e,t={},n=rn(e.ownerDocument)){let r=e.ownerDocument.createElement("div");for(;e.firstChild;)r.appendChild(e.firstChild);for(n.sanitize(r,{...ci(t),IN_PLACE:!0}),ui(r);r.firstChild;)e.appendChild(r.firstChild);return e}function hl(e,t={},n=document,i=rn(n)){let r=i.sanitize(String(e||""),{...ci(t),RETURN_DOM_FRAGMENT:!0}),o=r?.ownerDocument===n?r:n.importNode(r,!0);return ui(o),o||n.createDocumentFragment()}function ci(e){return{...dl,...e}}var fl=new Set(["http","https","mailto","tel"]),pl=new RegExp("[\\u0000-\\u0020\\u007F-\\u009F]","g");function ml(e){let n=(String(e??"").replace(pl,"").match(/^([a-z][a-z0-9+.\-]*):/i)||[])[1];return!n||fl.has(n.toLowerCase())}function mo(e){let t=String(e??"").trim();return!t||!ml(t)?"":/^(?:https?:|mailto:|tel:)/i.test(t)?t:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?`mailto:${t}`:/^(?:[#?]|\/|\.{1,2}\/)/.test(t)?t:`https://${t}`}function rn(e){let t=globalThis.DOMPurify;if(t?.sanitize)return t;if(typeof t=="function")return t(e.defaultView||globalThis);throw new Error("RichClay requires DOMPurify. Load vendor/purify.min.js before richclay.js or provide globalThis.DOMPurify.")}function ui(e){e.querySelectorAll?.("a[href]").forEach(t=>{let n=t.getAttribute("href")||"";if(/^\s*javascript:/i.test(n)&&t.removeAttribute("href"),t.getAttribute("target")==="_blank"){let i=new Set((t.getAttribute("rel")||"").split(/\s+/).filter(Boolean));i.add("noopener"),i.add("noreferrer"),t.setAttribute("rel",Array.from(i).join(" "))}})}var ho={ADD_TAGS:["img"],ADD_ATTR:["class","id","src","alt","width","height"]};function go(e={}){return{...e,ADD_TAGS:[...new Set([...ho.ADD_TAGS,...e.ADD_TAGS||[]])],ADD_ATTR:[...new Set([...ho.ADD_ATTR,...e.ADD_ATTR||[]])],ALLOW_DATA_ATTR:e.ALLOW_DATA_ATTR??!0}}var fo="p, div, h1, h2, h3, h4, h5, h6, blockquote, pre, ul, ol, li, figure, figcaption, table, thead, tbody, tr, td, th";function yo(e){let t=e.ownerDocument||document;e.querySelectorAll?.("br").forEach(i=>i.replaceWith(t.createTextNode(" ")));let n=e.querySelector?.(fo);for(;n;){let i=n.parentNode;for(i.insertBefore(t.createTextNode(" "),n);n.firstChild;)i.insertBefore(n.firstChild,n);i.insertBefore(t.createTextNode(" "),n),n.remove(),n=e.querySelector(fo)}return gl(e,t),e}function gl(e,t){e.normalize?.();let n=t.createTreeWalker(e,4),i=[];for(;n.nextNode();)i.push(n.currentNode);i.forEach(s=>{s.nodeValue=s.nodeValue.replace(/\s+/g," ")});let r=e.firstChild;r?.nodeType===3&&(r.nodeValue=r.nodeValue.replace(/^\s+/,""));let o=e.lastChild;o?.nodeType===3&&(o.nodeValue=o.nodeValue.replace(/\s+$/,""))}var bo="richclay-styles",di=new WeakSet,hi="";function To(e){hi=e||""}function _o(e=document){if(!e||di.has(e))return;if(e.getElementById(bo)){di.add(e);return}if(!hi)return;let t=e.createElement("style");t.id=bo,t.setAttribute("save-remove",""),t.setAttribute("save-ignore",""),t.textContent=hi,(e.head||e.documentElement).appendChild(t),di.add(e)}var Eo=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),yl=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),nc=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui"]);function fi(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function bl(e,t){if(fi(e,t))return!0;for(let[n,i]of Object.entries(yl))if(i.includes(t)&&fi(e,n))return!0;return!1}function Nt(e){let t=Eo[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function pi(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let i=Eo[t];if(!i)throw new Error(`Unknown region capability: ${t}`);if(i.tokens.some(r=>bl(n,r))||i.bundles.some(r=>fi(n,r)))return n;n=n.parentElement}return null}function So(e,t){return!!pi(e,t)}var Tl=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function Ao(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();if("value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&(t.value=e.value),"checked"in e&&"checked"in t&&(t.checked=e.checked),"selected"in e&&"selected"in t&&(t.selected=e.selected),e.tagName==="SELECT")for(let i=0;i<e.options.length;i++)t.options[i].selected=e.options[i].selected;"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function vo(e,t,n,i){if(i)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function Co(e,t,n,i,r,o,s,a){if(e.nodeType===1&&((s?So(e,n):vo(e,i,o,!1))||r&&vo(e,r,o,s)))return null;let l=t.importNode(e,!1);a.cloneToLive.set(l,e),a.liveToClone.set(e,l);let u=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,d=l.nodeType===1&&l.tagName==="TEMPLATE"?l.content:l;u!==e&&(a.cloneToLive.set(d,u),a.liveToClone.set(u,d));for(let f of u.childNodes||[]){let p=Co(f,t,n,i,r,o,s,a);p&&(d.appendChild(p),f.nodeType===1&&Ao(f,p))}return e.nodeType===1&&Ao(e,l),l}function mi(e,{capability:t="data",exclude:n=null,inherit:i=!0}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let r=e.nodeType===9?e:e.ownerDocument;if(!r?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let o=r.implementation.createHTMLDocument(""),s=new WeakMap,a=new WeakMap,l=e.nodeType===9?e.documentElement:e;n&&o.documentElement.matches(n);let u=Nt(t),d=Co(l,o,t,u,n,l,i,{cloneToLive:s,liveToClone:a});e.nodeType===9&&d&&(o.replaceChild(d,o.documentElement),a.set(e,o),s.set(o,e));let f=p=>{if(Tl.test(p))throw new Error(`Filtered content queries do not support stateful selector: ${p}`)};return{root:d,document:o,capability:t,selector:Nt(t),cloneToLive:s,liveToClone:a,original(p){return s.get(p)||null},cloneOf(p){return a.get(p)||null},query(p,y=d){return f(p),Array.from(y.querySelectorAll(p),E=>s.get(E)||E)},text(p=d){return(p===d?d:a.get(p))?.textContent||""},html(p=d){return(p===d?d:a.get(p))?.innerHTML??""},clone(p=d){let y=p===d?d:a.get(p);return y?o.importNode(y,!0):null}}}var _l=Nt("history");function Do(e,t){let n=t.createElement("template");n.innerHTML=String(e||"");for(let i of n.content.querySelectorAll(_l))i.remove();return n.innerHTML}function Io(e,t){return Do(e,t)}function El(e,t){let n=t.createElement("template");n.innerHTML=Io(e,t);let i=new Set(["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DIV","DL","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","H1","H2","H3","H4","H5","H6","HEADER","HR","LI","MAIN","NAV","OL","P","PRE","SECTION","TABLE","UL"]),r="",o=s=>{if(s.nodeType===3)r+=s.data;else if(s.nodeType===1&&s.tagName==="BR")r+=`
|
|
15
|
+
`});return l.addEventListener("pointerdown",this),{element:l,cursor:o,position:r}}),n=T("div",{class:"squire-image-resize-container","editor-ui":"",style:"position: absolute; pointer-events: none; z-index: 1000;"},t.map(r=>r.element));this._currentImage=e,this._resizeContainer=n,this._handles=t,this._root.appendChild(this._resizeContainer);let i=e.naturalWidth;this._originalRatio=i/e.naturalHeight,this._maxWidth=Math.min(i*2,e.parentElement?e.parentElement.offsetWidth:Nn,Nn),this._positionResizeContainer(),e.tabIndex=-1,e.focus(),document.addEventListener("keydown",this,!0)}_positionResizeContainer(){let e=this._resizeContainer,t=this._root,n=this._currentImage;if(!e||!n)return;let i=t.getBoundingClientRect(),r=n.getBoundingClientRect(),o=r.top-i.top+t.scrollTop,s=r.left-i.left+t.scrollLeft,a=r.width,l=r.height;e.style.top=o+"px",e.style.left=s+"px",e.style.width=a+"px",e.style.height=l+"px"}_onPointerDown(e){if(this._currentHandle||!this._handles)return;let t=e.target,n=this._handles.find(o=>o.element===t)||null;if(!n)return;let i=this._currentImage;if(!i)return;e.preventDefault(),e.stopPropagation(),t.addEventListener("pointermove",this),t.addEventListener("pointerup",this),t.addEventListener("pointercancel",this),t.setPointerCapture(e.pointerId),this._currentHandle=n,this._startX=e.clientX,this._startY=e.clientY;let r=getComputedStyle(i);this._startWidth=parseFloat(r.width),this._startHeight=parseFloat(r.height),document.body.style.cursor=n.cursor}_onPointerMove(e){e.preventDefault();let t=this._currentHandle,n=this._currentImage;if(!t||!n)return;let i=e.clientX-this._startX,r=e.clientY-this._startY,o=this._maxWidth,s=this._originalRatio,a=this._startWidth,l=this._startHeight;switch(t.position){case"sw":case"nw":case"w":a-=2*i;break;case"se":case"ne":case"e":a+=2*i;break;case"n":l-=r,a=l*s;break;case"s":l+=r,a=l*s;break}a<Ji?a=Ji:a>o&&(a=o);let u=n.style;u.width=a+"px",u.height="auto",this._positionResizeContainer()}_onPointerUp(e){e.preventDefault();let t=e.target;t&&(t.removeEventListener("pointermove",this),t.removeEventListener("pointerup",this),t.removeEventListener("pointercancel",this)),this._currentHandle=null,document.body.style.cursor=""}_onKeyDown(e){e.preventDefault(),e.stopPropagation();let t=$s[e.key];if(!t)return;let n=this._currentImage;if(!n)return;let i=this._editor,r=this._root;this._deselectImage();let o=i.getSelection();o.selectNode(n),t(i,o,r)}},Zs=class{constructor(e,t){this.customEvents=new Set(["pathChange","select","input","pasteImage","undoStateChange"]),this.startSelectionId="squire-selection-start",this.endSelectionId="squire-selection-end",this.linkRegExp=/\b(?:((?:(?:ht|f)tps?:\/\/|www\d{0,3}[.]|[a-z0-9][a-z0-9.\-]*[.][a-z]{2,}\/)(?:[^\s()<>]+|\([^\s()<>]+\))+(?:[^\s?&`!()\[\]{};:'".,<>«»“”‘’]|\([^\s()<>]+\)))|([\w\-.%+]+@(?:[\w\-]+\.)+[a-z]{2,}\b(?:[?][^&?\s]+=[^\s?&`!()\[\]{};:'".,<>«»“”‘’]+(?:&[^&?\s]+=[^\s?&`!()\[\]{};:'".,<>«»“”‘’]+)*)?))/i,this.tagAfterSplit={DT:"DD",DD:"DT",LI:"LI",PRE:"PRE"},this._root=e,this._config=this._makeConfig(t),this._isFocused=!1,this._lastSelection=Be(e,0),this._willRestoreSelection=!1,this._mayHaveZWS=!1,this._lastAnchorNode=null,this._lastFocusNode=null,this._path="",this._events=new Map,this._undoIndex=-1,this._undoStack=[],this._undoStackLength=0,this._isInUndoState=!1,this._ignoreChange=!1,this._ignoreAllChanges=!1,this.addEventListener("selectionchange",this._updatePathOnEvent),this.addEventListener("blur",this._enableRestoreSelection),this.addEventListener("mousedown",this._disableRestoreSelection),this.addEventListener("touchstart",this._disableRestoreSelection),this.addEventListener("focus",this._restoreSelection),this.addEventListener("blur",this._removeZWS),this._isShiftDown=!1,this.addEventListener("cut",Ds),this.addEventListener("copy",ks),this.addEventListener("paste",Is),this._dragRange=null,this.addEventListener("dragstart",Ms),this.addEventListener("dragend",Ps),this.addEventListener("drop",Hs),this.addEventListener("keydown",Xi),this.addEventListener("keyup",Xi),this.addEventListener("keydown",Gs),this._keyHandlers=Object.create(P);let n=new MutationObserver(i=>this._onMutations(i));n.observe(e,{childList:!0,attributes:!0,attributeOldValue:!0,characterData:!0,subtree:!0}),this._mutation=n,e.setAttribute("contenteditable","true"),this.addEventListener("beforeinput",this._beforeInput),this._imageResizer=new js(e,this),this.setHTML("")}destroy(){this._events.forEach((e,t)=>{this.removeEventListener(t)}),this._mutation.disconnect(),this._imageResizer.destroy(),this._undoIndex=-1,this._undoStack=[],this._undoStackLength=0}_makeConfig(e){let t={blockTag:"DIV",blockAttributes:null,tagAttributes:{},classNames:{color:"color",fontFamily:"font",fontSize:"size",highlight:"highlight"},undo:{documentSizeThreshold:-1,undoLimit:-1},addLinks:!0,willCutCopy:null,toPlainText:null,sanitizeToDOMFragment:n=>{let i=DOMPurify.sanitize(n,{ALLOW_UNKNOWN_PROTOCOLS:!0,WHOLE_DOCUMENT:!1,RETURN_DOM:!0,RETURN_DOM_FRAGMENT:!0,FORCE_BODY:!1});return i?document.importNode(i,!0):document.createDocumentFragment()},didError:n=>console.log(n)};return e&&(Object.assign(t,e),t.blockTag=t.blockTag.toUpperCase()),t}setKeyHandler(e,t){return this._keyHandlers[e]=t,this}_beforeInput(e){switch(e.inputType){case"insertLineBreak":e.preventDefault(),this.splitBlock(!0);break;case"insertParagraph":e.preventDefault(),this.splitBlock(!1);break;case"insertOrderedList":e.preventDefault(),this.makeOrderedList();break;case"insertUnoderedList":e.preventDefault(),this.makeUnorderedList();break;case"historyUndo":e.preventDefault(),this.undo();break;case"historyRedo":e.preventDefault(),this.redo();break;case"formatBold":e.preventDefault(),this.bold();break;case"formatItalic":e.preventDefault(),this.italic();break;case"formatUnderline":e.preventDefault(),this.underline();break;case"formatStrikeThrough":e.preventDefault(),this.strikethrough();break;case"formatSuperscript":e.preventDefault(),this.superscript();break;case"formatSubscript":e.preventDefault(),this.subscript();break;case"formatJustifyFull":case"formatJustifyCenter":case"formatJustifyRight":case"formatJustifyLeft":{e.preventDefault();let t=e.inputType.slice(13).toLowerCase();t==="full"&&(t="justify"),this.setTextAlignment(t);break}case"formatRemove":e.preventDefault(),this.removeAllFormatting();break;case"formatSetBlockTextDirection":{e.preventDefault();let t=e.data;t==="null"&&(t=null),this.setTextDirection(t);break}case"formatBackColor":e.preventDefault(),this.setHighlightColor(e.data);break;case"formatFontColor":e.preventDefault(),this.setTextColor(e.data);break;case"formatFontName":e.preventDefault(),this.setFontFace(e.data);break}}handleEvent(e){this.fireEvent(e.type,e)}fireEvent(e,t){let n=this._events.get(e);if(/^(?:focus|blur)/.test(e)){let i=this._root===document.activeElement;if(e==="focus"){if(!i||this._isFocused)return this;this._isFocused=!0}else{if(i||!this._isFocused)return this;this._isFocused=!1}}if(n){let i=t instanceof Event?t:new CustomEvent(e,{detail:t});n=n.slice();for(let r of n)try{"handleEvent"in r?r.handleEvent(i):r.call(this,i)}catch(o){this._config.didError(o)}}return this}addEventListener(e,t){let n=this._events.get(e),i=this._root;return n||(n=[],this._events.set(e,n),this.customEvents.has(e)||(e==="selectionchange"&&(i=document),i.addEventListener(e,this,!0))),n.push(t),this}removeEventListener(e,t){let n=this._events.get(e),i=this._root;if(n){if(t){let r=n.length;for(;r--;)n[r]===t&&n.splice(r,1)}else n.length=0;n.length||(this._events.delete(e),this.customEvents.has(e)||(e==="selectionchange"&&(i=document),i.removeEventListener(e,this,!0)))}return this}focus(){return this._root.focus({preventScroll:!0}),this}blur(){return this._root.blur(),this}_enableRestoreSelection(){this._willRestoreSelection=!0}_disableRestoreSelection(){this._willRestoreSelection=!1}_restoreSelection(){this._willRestoreSelection&&this.setSelection(this._lastSelection)}_removeZWS(){this._mayHaveZWS&&(Pt(this._root),this._mayHaveZWS=!1)}_saveRangeToBookmark(e){let t=T("INPUT",{id:this.startSelectionId,type:"hidden"}),n=T("INPUT",{id:this.endSelectionId,type:"hidden"}),i;Te(e,t),e.collapse(!1),Te(e,n),t.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_PRECEDING&&(t.id=this.endSelectionId,n.id=this.startSelectionId,i=t,t=n,n=i),e.setStartAfter(t),e.setEndBefore(n)}_getRangeAndRemoveBookmark(e){let t=this._root,n=t.querySelectorAll("#"+this.startSelectionId),i=t.querySelectorAll("#"+this.endSelectionId),r=n[0],o=i[0];if(r&&o&&r.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING){let s=r.parentNode,a=o.parentNode,l=Array.from(s.childNodes).indexOf(r),u=Array.from(a.childNodes).indexOf(o);s===a&&(u-=1),r.remove(),o.remove(),e||(e=document.createRange()),e.setStart(s,l),e.setEnd(a,u),Xe(s,e),s!==a&&Xe(a,e),e.collapsed&&(s=e.startContainer,s instanceof Text&&(a=s.childNodes[e.startOffset],(!a||!(a instanceof Text))&&(a=s.childNodes[e.startOffset-1]),a&&a instanceof Text&&(e.setStart(a,0),e.collapse(!0))))}for(let s=0;s<n.length;s+=1)n[s].remove();for(let s=0;s<i.length;s+=1)i[s].remove();return e||null}getSelection(){let e=window.getSelection(),t=this._root,n=null;if(this._isFocused&&e&&e.rangeCount){n=e.getRangeAt(0).cloneRange();let i=n.startContainer,r=n.endContainer;i&&Re(i)&&n.setStartBefore(i),r&&Re(r)&&n.setEndBefore(r)}return n&&t.contains(n.commonAncestorContainer)?this._lastSelection=n:(n=this._lastSelection,document.contains(n.commonAncestorContainer)||(n=null)),n||(n=Be(t.firstElementChild||t,0)),n}setSelection(e){if(this._lastSelection=e,!this._isFocused)this._enableRestoreSelection();else{let t=window.getSelection();t&&("setBaseAndExtent"in Selection.prototype?t.setBaseAndExtent(e.startContainer,e.startOffset,e.endContainer,e.endOffset):(t.removeAllRanges(),t.addRange(e)))}return this}_moveCursorTo(e){let t=this._root,n=Be(t,e?0:t.childNodes.length);return j(n),this.setSelection(n),this}moveCursorToStart(){return this._moveCursorTo(!0)}moveCursorToEnd(){return this._moveCursorTo(!1)}getCursorPosition(){let e=this.getSelection(),t=e.getBoundingClientRect();if(t&&!t.top){this._ignoreChange=!0;let n=T("SPAN");n.textContent="\u200B",Te(e,n),t=n.getBoundingClientRect();let i=n.parentNode;i.removeChild(n),Xe(i,e)}return t}getPath(){return this._path}_updatePathOnEvent(){this._isFocused&&this._updatePath(this.getSelection())}_updatePath(e,t){let n=e.startContainer,i=e.endContainer,r;(t||n!==this._lastAnchorNode||i!==this._lastFocusNode)&&(this._lastAnchorNode=n,this._lastFocusNode=i,r=n&&i?n===i?this._getPath(i):"(selection)":"",(this._path!==r||n!==i)&&(this._path=r,this.fireEvent("pathChange",{path:r}))),this.fireEvent(e.collapsed?"cursor":"select",{range:e})}_getPath(e){let t=this._root,n=this._config,i="";if(e&&e!==t){let r=e.parentNode;if(i=r?this._getPath(r):"",e instanceof HTMLElement){let o=e.id,s=e.classList,a=Array.from(s).sort(),l=e.dir,u=n.classNames;i+=(i?">":"")+e.nodeName,o&&(i+="#"+o),a.length&&(i+=".",i+=a.join(".")),l&&(i+="[dir="+l+"]"),s.contains(u.highlight)&&(i+="[backgroundColor="+e.style.backgroundColor.replace(/ /g,"")+"]"),s.contains(u.color)&&(i+="[color="+e.style.color.replace(/ /g,"")+"]"),s.contains(u.fontFamily)&&(i+="[fontFamily="+e.style.fontFamily.replace(/ /g,"")+"]"),s.contains(u.fontSize)&&(i+="[fontSize="+e.style.fontSize+"]")}}return i}modifyDocument(e){let t=this._mutation;return t&&((()=>{let n=t.takeRecords();n.length&&this._onMutations(n)})(),t.disconnect()),this._ignoreAllChanges=!0,e(),this._ignoreAllChanges=!1,t&&(t.observe(this._root,{childList:!0,attributes:!0,attributeOldValue:!0,characterData:!0,subtree:!0}),this._ignoreChange=!1),this}_onMutations(e){let t=this._config.onMutations;return t?t(e,this):this._docWasChanged()}_docWasChanged(){if(rr(),this._mayHaveZWS=!0,!this._ignoreAllChanges){if(this._ignoreChange){this._ignoreChange=!1;return}this._isInUndoState&&(this._isInUndoState=!1,this.fireEvent("undoStateChange",{canUndo:!0,canRedo:!1})),this.fireEvent("input")}}_recordUndoState(e,t){let n=this._isInUndoState;if(!n||t){let i=this._undoIndex+1,r=this._undoStack,o=this._config.undo,s=o.documentSizeThreshold,a=o.undoLimit;if(i<this._undoStackLength&&(r.length=this._undoStackLength=i),e&&this._saveRangeToBookmark(e),n)return this;let l=this._getRawHTML();t&&(i-=1),s>-1&&l.length*2>s&&a>-1&&i>a&&(r.splice(0,i-a),i=a,this._undoStackLength=a),r[i]=l,this._undoIndex=i,this._undoStackLength+=1,this._isInUndoState=!0}return this}saveUndoState(e){let t=!1;return e||(e=this.getSelection(),t=!0),this._recordUndoState(e,this._isInUndoState),this._getRangeAndRemoveBookmark(e),t&&this.setSelection(e),this}undo(){if(this._undoIndex!==0||!this._isInUndoState){this._recordUndoState(this.getSelection(),!1),this._undoIndex-=1,this._setRawHTML(this._undoStack[this._undoIndex]);let e=this._getRangeAndRemoveBookmark();e&&this.setSelection(e),this._isInUndoState=!0,this.fireEvent("undoStateChange",{canUndo:this._undoIndex!==0,canRedo:!0}),this.fireEvent("input")}return this.focus()}redo(){let e=this._undoIndex,t=this._undoStackLength;if(e+1<t&&this._isInUndoState){this._undoIndex+=1,this._setRawHTML(this._undoStack[this._undoIndex]);let n=this._getRangeAndRemoveBookmark();n&&this.setSelection(n),this.fireEvent("undoStateChange",{canUndo:!0,canRedo:e+2<t}),this.fireEvent("input")}return this.focus()}getRoot(){return this._root}_getRawHTML(){let e=this._config.serializeRoot;return e?e(this._root,this):this._root.innerHTML}_setRawHTML(e){let t=this._root;this._config.replaceRoot?this._config.replaceRoot(t,e,this):t.innerHTML=e;let n=t,i=n.firstChild;if(!i||i.nodeName==="BR"){let r=this.createDefaultBlock();i?n.replaceChild(r,i):n.appendChild(r)}else for(;n=Ee(n,t);)U(n);return this._ignoreChange=!0,this}getHTML(e){if(this._config.serializeRoot)return this._config.serializeRoot(this._root,this,e?this.getSelection():null).replace(/\u200B/g,"");let t,n="";return this.modifyDocument(()=>{e&&(t=this.getSelection(),this._saveRangeToBookmark(t)),n=this._getRawHTML().replace(/\u200B/g,""),e&&this._getRangeAndRemoveBookmark(t)}),n}setHTML(e){let t=this._config.sanitizeToDOMFragment(e,this),n=this._root;xn(t,this._config),On(t,n,!1),fe(t,n);let i=t,r=i.firstChild;if(!r||r.nodeName==="BR"){let s=this.createDefaultBlock();r?i.replaceChild(s,r):i.appendChild(s)}else for(;i=Ee(i,n);)U(i);for(this._ignoreChange=!0;r=n.lastChild;)n.removeChild(r);n.appendChild(t),this._undoIndex=-1,this._undoStack.length=0,this._undoStackLength=0,this._isInUndoState=!1;let o=this._getRangeAndRemoveBookmark()||Be(n.firstElementChild||n,0);return this.saveUndoState(o),this.setSelection(o),this._updatePath(o,!0),this}insertHTML(e,t){let n=this._config,i=n.sanitizeToDOMFragment(e,this),r=this.getSelection();this.saveUndoState(r);try{let o=this._root;n.addLinks&&this.addDetectedLinks(i,i),xn(i,this._config),On(i,o,!1),Rn(i),i.normalize();let s=i;for(;s=Ee(s,i);)U(s);let a=!0;if(t){let l=new CustomEvent("willPaste",{cancelable:!0,detail:{html:e,fragment:i}});this.fireEvent("willPaste",l),i=l.detail.fragment,a=!l.defaultPrevented}a&&(Os(r,i,o),r.collapse(!1),Ki(r,"A",o),this._ensureBottomLine()),this.setSelection(r),this._updatePath(r,!0),t&&this.focus()}catch(o){this._config.didError(o)}return this}insertElement(e,t){if(t||(t=this.getSelection()),t.collapse(!0),N(e))Te(t,e),t.setStartAfter(e);else{let n=this._root,i=ie(t,n),r=i||n,o=null;for(;r!==n&&!r.nextSibling;)r=r.parentNode;if(r!==n){let a=r.parentNode;o=se(a,r.nextSibling,n,n)}i&&Dn(i)&&H(i),n.insertBefore(e,o);let s=this.createDefaultBlock();n.insertBefore(s,o),t.setStart(s,0),t.setEnd(s,0),j(t)}return this.focus(),this.setSelection(t),this._updatePath(t),this}insertImage(e,t){let n=T("IMG",Object.assign({src:e},t));return this.insertElement(n),n}insertPlainText(e,t){let n=this.getSelection();if(n.collapsed&&L(n.startContainer,this._root,"PRE")){let u=n.startContainer,d=n.startOffset,h;if(!u||!(u instanceof Text)){let y=document.createTextNode("");u.insertBefore(y,u.childNodes[d]),h=y,d=0}else h=u;let p=!0;if(t){let y=new CustomEvent("willPaste",{cancelable:!0,detail:{text:e}});this.fireEvent("willPaste",y),e=y.detail.text,p=!y.defaultPrevented}return p&&(this.saveUndoState(n),h.insertData(d,e),n.setStart(h,d+e.length),n.collapse(!0)),this.setSelection(n),this}let i=e.split(`
|
|
16
|
+
`),r=this._config,o=r.blockTag,s=r.blockAttributes,a="</"+o+">",l="<"+o;for(let u in s)l+=" "+u+'="'+ji(s[u])+'"';l+=">";for(let u=0,d=i.length;u<d;u+=1){let h=i[u];h=ji(h).replace(/ (?=(?: |$))/g," "),u&&(h=l+(h||"<BR>")+a),i[u]=h}return this.insertHTML(i.join(""),t)}getSelectedText(e){return ur(e||this.getSelection())}getFontInfo(e){let t={color:void 0,backgroundColor:void 0,fontFamily:void 0,fontSize:void 0};e||(e=this.getSelection()),j(e);let n=0,i=e.commonAncestorContainer;if(e.collapsed||i instanceof Text)for(i instanceof Text&&(i=i.parentNode);n<4&&i;){let r=i.style;if(r){let o=r.color;!t.color&&o&&(t.color=o,n+=1);let s=r.backgroundColor;!t.backgroundColor&&s&&(t.backgroundColor=s,n+=1);let a=r.fontFamily;!t.fontFamily&&a&&(t.fontFamily=a,n+=1);let l=r.fontSize;!t.fontSize&&l&&(t.fontSize=l,n+=1)}i=i.parentNode}return t}hasFormat(e,t,n){e=e.toUpperCase(),t||(t={}),n||(n=this.getSelection()),!n.collapsed&&n.startContainer instanceof Text&&n.startOffset===n.startContainer.length&&n.startContainer.nextSibling&&n.setStartBefore(n.startContainer.nextSibling),!n.collapsed&&n.endContainer instanceof Text&&n.endOffset===0&&n.endContainer.previousSibling&&n.setEndAfter(n.endContainer.previousSibling);let i=this._root,r=n.commonAncestorContainer;if(L(r,i,e,t))return!0;if(r instanceof Text)return!1;let o=new ne(r,4,l=>we(n,l,!0)),s=!1,a;for(;a=o.nextNode();){if(!L(a,i,e,t))return!1;s=!0}return s}changeFormat(e,t,n,i){return n||(n=this.getSelection()),this.saveUndoState(n),t&&(n=this._removeFormat(t.tag.toUpperCase(),t.attributes||{},n,i)),e&&(n=this._addFormat(e.tag.toUpperCase(),e.attributes||{},n)),this.setSelection(n),this._updatePath(n,!0),this.focus()}_addFormat(e,t,n){let i=this._root;if(n.collapsed){let r=U(T(e,t));Te(n,r);let o=r.firstChild||r,s=o instanceof Text?o.length:0;n.setStart(o,s),n.collapse(!0);let a=r;for(;N(a);)a=a.parentNode;Pt(a,r)}else{let r=new ne(n.commonAncestorContainer,5,u=>(u instanceof Text||u.nodeName==="BR"||u.nodeName==="IMG")&&we(n,u,!0)),{startContainer:o,startOffset:s,endContainer:a,endOffset:l}=n;if(r.currentNode=o,!(o instanceof Element)&&!(o instanceof Text)||!r.filter(o)){let u=r.nextNode();if(!u)return n;o=u,s=0}do{let u=r.currentNode;if(!L(u,i,e,t)){u===a&&u.length>l&&u.splitText(l),u===o&&s&&(u=u.splitText(s),a===o?(a=u,l-=s):a===o.parentNode&&(l+=1),o=u,s=0);let d=T(e,t);$(u,d),d.appendChild(u)}}while(r.nextNode());n=Be(o,s,a,l)}return n}_removeFormat(e,t,n,i){this._saveRangeToBookmark(n);let r;n.collapsed&&(Ut?r=document.createTextNode("\u200B"):r=document.createTextNode(""),Te(n,r));let o=n.commonAncestorContainer;for(;o!==this._root&&N(o);)o=o.parentNode;let s=n.startContainer,a=n.startOffset,l=n.endContainer,u=n.endOffset,d=[],h=(y,_)=>{if(we(n,y,!1))return;let C,v;if(!we(n,y,!0)){!(y instanceof HTMLInputElement)&&(!(y instanceof Text)||y.data)&&d.push([_,y]);return}if(y instanceof Text)y===l&&u!==y.length&&d.push([_,y.splitText(u)]),y===s&&a&&(y.splitText(a),d.push([_,y]));else for(C=y.firstChild;C;C=v)v=C.nextSibling,h(C,_)},p=Array.from(o.getElementsByTagName(e)).filter(y=>we(n,y,!0)&&wn(y,e,t));if(i||p.forEach(y=>{h(y,y)}),d.forEach(([y,_])=>{y=y.cloneNode(!1),$(_,y),y.appendChild(_)}),p.forEach(y=>{$(y,D(y))}),Ut&&r){r=r.parentNode;let y=r;for(;y&&N(y);)y=y.parentNode;y&&Pt(y,r)}return this._getRangeAndRemoveBookmark(n),r&&n.collapse(!1),Xe(o,n),n}bold(){return this.changeFormat({tag:"B"})}removeBold(){return this.changeFormat(null,{tag:"B"})}italic(){return this.changeFormat({tag:"I"})}removeItalic(){return this.changeFormat(null,{tag:"I"})}underline(){return this.changeFormat({tag:"U"})}removeUnderline(){return this.changeFormat(null,{tag:"U"})}strikethrough(){return this.changeFormat({tag:"S"})}removeStrikethrough(){return this.changeFormat(null,{tag:"S"})}subscript(){return this.changeFormat({tag:"SUB"},{tag:"SUP"})}removeSubscript(){return this.changeFormat(null,{tag:"SUB"})}superscript(){return this.changeFormat({tag:"SUP"},{tag:"SUB"})}removeSuperscript(){return this.changeFormat(null,{tag:"SUP"})}makeLink(e,t){let n=this.getSelection();if(n.collapsed){let i=e.indexOf(":")+1;if(i)for(;e[i]==="/";)i+=1;Te(n,document.createTextNode(e.slice(i)))}return t=Object.assign({href:e},this._config.tagAttributes.a,t),this.changeFormat({tag:"A",attributes:t},{tag:"A"},n)}removeLink(){return this.changeFormat(null,{tag:"A"},this.getSelection(),!0)}addDetectedLinks(e,t){let n=new ne(e,4,s=>!L(s,t||this._root,"A")),i=this.linkRegExp,r=this._config.tagAttributes.a,o;for(;o=n.nextNode();){let s=o.parentNode,a=o.data,l;for(;l=i.exec(a);){let u=l.index,d=u+l[0].length;u&&s.insertBefore(document.createTextNode(a.slice(0,u)),o);let h=T("A",Object.assign({href:l[1]?/^(?:ht|f)tps?:/i.test(l[1])?l[1]:"http://"+l[1]:"mailto:"+l[0]},r));h.textContent=a.slice(u,d),s.insertBefore(h,o),o.data=a=a.slice(d)}}return this}setFontFace(e){let t=this._config.classNames.fontFamily;return this.changeFormat(e?{tag:"SPAN",attributes:{class:t,style:"font-family: "+e+", sans-serif;"}}:null,{tag:"SPAN",attributes:{class:t}})}setFontSize(e){let t=this._config.classNames.fontSize;return this.changeFormat(e?{tag:"SPAN",attributes:{class:t,style:"font-size: "+(typeof e=="number"?e+"px":e)}}:null,{tag:"SPAN",attributes:{class:t}})}setTextColor(e){let t=this._config.classNames.color;return this.changeFormat(e?{tag:"SPAN",attributes:{class:t,style:"color:"+e}}:null,{tag:"SPAN",attributes:{class:t}})}setHighlightColor(e){let t=this._config.classNames.highlight;return this.changeFormat(e?{tag:"SPAN",attributes:{class:t,style:"background-color:"+e}}:null,{tag:"SPAN",attributes:{class:t}})}_ensureBottomLine(){let e=this._root,t=e.lastElementChild,n=null;for(;t&&(t.matches("[editor-ui],[clay~=editor-ui]")||t.closest("[editor-ui],[clay~=editor-ui]"));)n=t,t=t.previousElementSibling;(!t||t.nodeName!==this._config.blockTag||!xe(t))&&e.insertBefore(this.createDefaultBlock(),n)}createDefaultBlock(e){let t=this._config;return U(T(t.blockTag,t.blockAttributes,e))}splitBlock(e,t){t||(t=this.getSelection());let n=this._root,i,r,o,s;if(this._recordUndoState(t),this._removeZWS(),this._getRangeAndRemoveBookmark(t),t.collapsed||qe(t,n),this._config.addLinks){j(t);let h=t.startContainer,p=t.startOffset;setTimeout(()=>{pr(this,h,p)},0)}if(i=ie(t,n),i&&(r=L(i,n,"PRE"))){j(t),o=t.startContainer;let h=t.startOffset;return o instanceof Text||(o=document.createTextNode(""),r.insertBefore(o,r.firstChild),h=0),!e&&o instanceof Text&&(o.data.charAt(h-1)===`
|
|
17
|
+
`||pt(t,n))&&(o.data.charAt(h)===`
|
|
18
|
+
`||mt(t,n))?(o.deleteData(h&&h-1,h?2:1),s=se(o,h&&h-1,n,n),o=s.previousSibling,o.textContent||H(o),o=this.createDefaultBlock(),s.parentNode.insertBefore(o,s),s.textContent||H(s),t.setStart(o,0)):(o.insertData(h,`
|
|
19
|
+
`),o.nextSibling||r.appendChild(T("BR")),o.length===h+1?t.setStartAfter(o):t.setStart(o,h+1)),t.collapse(!0),this.setSelection(t),this._updatePath(t,!0),this._docWasChanged(),this}if(!i||e||/^T[HD]$/.test(i.nodeName))return Ki(t,"A",n),Te(t,T("BR")),t.collapse(!1),this.setSelection(t),this._updatePath(t,!0),this;if((r=L(i,n,"LI"))&&(i=r),Dn(i)){if(L(i,n,"UL")||L(i,n,"OL"))return this.decreaseListLevel(t),this;if(L(i,n,"BLOCKQUOTE"))return this.replaceWithBlankLine(t),this}o=t.startContainer;let a=t.startOffset,l=this.tagAfterSplit[i.nodeName];s=se(o,a,i.parentNode,this._root);let u=this._config,d=null;for(l||(l=u.blockTag,d=u.blockAttributes),wn(s,l,d)||(i=T(l,d),s.dir&&(i.dir=s.dir),$(s,i),i.appendChild(D(s)),s=i),Pt(i),Rn(i),U(i);s instanceof Element;){let h=s.firstChild,p;if(s.nodeName==="A"&&(!s.textContent||s.textContent==="\u200B")){h=document.createTextNode(""),$(s,h),s=h;break}for(;h&&h instanceof Text&&!h.data&&(p=h.nextSibling,!(!p||p.nodeName==="BR"));)H(h),h=p;if(!h||h.nodeName==="BR"||h instanceof Text)break;s=h}return t=Be(s,0),this.setSelection(t),this._updatePath(t,!0),this}forEachBlock(e,t,n){n||(n=this.getSelection()),t&&this.saveUndoState(n);let i=this._root,r=ie(n,i),o=Ue(n,i);if(r&&o)do if(e(r)||r===o)break;while(r=Ee(r,i));return t&&(this.setSelection(n),this._updatePath(n,!0)),this}modifyBlocks(e,t){t||(t=this.getSelection()),this._recordUndoState(t,this._isInUndoState);let n=this._root;Zi(t,n),Fe(t,n,n,n);let i=cr(t,n,n);if(!t.collapsed){let r=t.endContainer;if(r===n)t.collapse(!1);else{for(;r.parentNode!==n;)r=r.parentNode;t.setStartBefore(r),t.collapse(!0)}}return Te(t,e.call(this,i)),t.endOffset<t.endContainer.childNodes.length&&_e(t.endContainer.childNodes[t.endOffset],n),_e(t.startContainer.childNodes[t.startOffset],n),this._getRangeAndRemoveBookmark(t),this.setSelection(t),this._updatePath(t,!0),this}setTextAlignment(e){return this.forEachBlock(t=>{let n=t.className.split(/\s+/).filter(i=>!!i&&!/^align/.test(i)).join(" ");e?(t.className=n+" align-"+e,t.style.textAlign=e):(t.className=n,t.style.textAlign="")},!0),this.focus()}setTextDirection(e){return this.forEachBlock(t=>{e?t.dir=e:t.removeAttribute("dir")},!0),this.focus()}_getListSelection(e,t){let n=e.commonAncestorContainer,i=e.startContainer,r=e.endContainer;for(;n&&n!==t&&!/^[OU]L$/.test(n.nodeName);)n=n.parentNode;if(!n||n===t)return null;for(i===n&&(i=i.childNodes[e.startOffset]),r===n&&(r=r.childNodes[e.endOffset]);i&&i.parentNode!==n;)i=i.parentNode;for(;r&&r.parentNode!==n;)r=r.parentNode;return[n,i,r]}increaseListLevel(e){e||(e=this.getSelection());let t=this._root,n=this._getListSelection(e,t);if(!n)return this.focus();let[i,r,o]=n;if(!r||r===i.firstChild)return this.focus();this._recordUndoState(e,this._isInUndoState);let s=i.nodeName,a=r.previousSibling,l,u;a.nodeName!==s&&(l=this._config.tagAttributes[s.toLowerCase()],a=T(s,l),i.insertBefore(a,r));do u=r===o?null:r.nextSibling,a.appendChild(r);while(r=u);return u=a.nextSibling,u&&_e(u,t),this._getRangeAndRemoveBookmark(e),this.setSelection(e),this._updatePath(e,!0),this.focus()}decreaseListLevel(e){e||(e=this.getSelection());let t=this._root,n=this._getListSelection(e,t);if(!n)return this.focus();let[i,r,o]=n;r||(r=i.firstChild),o||(o=i.lastChild),this._recordUndoState(e,this._isInUndoState);let s,a=null;if(r){let l=i.parentNode;if(a=o.nextSibling?se(i,o.nextSibling,l,t):i.nextSibling,l!==t&&l.nodeName==="LI"){for(l=l.parentNode;a;)s=a.nextSibling,o.appendChild(a),a=s;a=i.parentNode.nextSibling}let u=!/^[OU]L$/.test(l.nodeName);do s=r===o?null:r.nextSibling,i.removeChild(r),u&&r.nodeName==="LI"&&(r=this.createDefaultBlock([D(r)])),l.insertBefore(r,a);while(r=s)}return i.firstChild||H(i),a&&_e(a,t),this._getRangeAndRemoveBookmark(e),this.setSelection(e),this._updatePath(e,!0),this.focus()}_makeList(e,t){let n=zt(e,this._root),i=this._config.tagAttributes,r=i[t.toLowerCase()],o=i.li,s;for(;s=n.nextNode();)if(s.parentNode instanceof HTMLLIElement&&(s=s.parentNode,n.currentNode=s.lastChild),s instanceof HTMLLIElement){s=s.parentNode;let a=s.nodeName;a!==t&&/^[OU]L$/.test(a)&&$(s,T(t,r,[D(s)]))}else{let a=T("LI",o);s.dir&&(a.dir=s.dir);let l=s.previousSibling;l&&l.nodeName===t?(l.appendChild(a),H(s)):$(s,T(t,r,[a])),a.appendChild(D(s)),n.currentNode=a}return e}makeUnorderedList(){return this.modifyBlocks(e=>this._makeList(e,"UL")),this.focus()}makeOrderedList(){return this.modifyBlocks(e=>this._makeList(e,"OL")),this.focus()}removeList(){return this.modifyBlocks(e=>{let t=e.querySelectorAll("UL, OL"),n=e.querySelectorAll("LI"),i=this._root;for(let r=0,o=t.length;r<o;r+=1){let s=t[r],a=D(s);fe(a,i),$(s,a)}for(let r=0,o=n.length;r<o;r+=1){let s=n[r];xe(s)?$(s,this.createDefaultBlock([D(s)])):(fe(s,i),$(s,D(s)))}return e}),this.focus()}increaseQuoteLevel(e){return this.modifyBlocks(t=>T("BLOCKQUOTE",this._config.tagAttributes.blockquote,[t]),e),this.focus()}decreaseQuoteLevel(e){return this.modifyBlocks(t=>(Array.from(t.querySelectorAll("blockquote")).filter(n=>!L(n.parentNode,t,"BLOCKQUOTE")).forEach(n=>{$(n,D(n))}),t),e),this.focus()}removeQuote(e){return this.modifyBlocks(t=>(Array.from(t.querySelectorAll("blockquote")).forEach(n=>{$(n,D(n))}),t),e),this.focus()}replaceWithBlankLine(e){return this.modifyBlocks(()=>this.createDefaultBlock([T("INPUT",{id:this.startSelectionId,type:"hidden"}),T("INPUT",{id:this.endSelectionId,type:"hidden"})]),e),this.focus()}code(){let e=this.getSelection();return e.collapsed||Qe(e.commonAncestorContainer)?(this.modifyBlocks(t=>{let n=this._root,i=document.createDocumentFragment(),r=zt(t,n),o;for(;o=r.nextNode();){let a=o.querySelectorAll("BR"),l=[],u=a.length;for(let d=0;d<u;d+=1)l[d]=qt(a[d],!1);for(;u--;){let d=a[u];l[u]?$(d,document.createTextNode(`
|
|
20
|
+
`)):H(d)}for(a=o.querySelectorAll("CODE"),u=a.length;u--;)$(a[u],D(a[u]));i.childNodes.length&&i.appendChild(document.createTextNode(`
|
|
21
|
+
`)),i.appendChild(D(o))}let s=new ne(i,4);for(;o=s.nextNode();)o.data=o.data.replace(/ /g," ");return i.normalize(),U(T("PRE",this._config.tagAttributes.pre,[i]))},e),this.focus()):this.changeFormat({tag:"CODE",attributes:this._config.tagAttributes.code},null,e),this}removeCode(){let e=this.getSelection(),t=e.commonAncestorContainer;return L(t,this._root,"PRE")?(this.modifyBlocks(n=>{let i=this._root,r=n.querySelectorAll("PRE"),o=r.length;for(;o--;){let s=r[o],a=new ne(s,4),l;for(;l=a.nextNode();){let u=l.data;u=u.replace(/ (?= )/g,"\xA0");let d=document.createDocumentFragment(),h;for(;(h=u.indexOf(`
|
|
22
|
+
`))>-1;)d.appendChild(document.createTextNode(u.slice(0,h))),d.appendChild(T("BR")),u=u.slice(h+1);l.parentNode.insertBefore(d,l),l.data=u}fe(s,i),$(s,D(s))}return n},e),this.focus()):this.changeFormat(null,{tag:"CODE"},e),this}toggleCode(){return this.hasFormat("PRE")||this.hasFormat("CODE")?this.removeCode():this.code(),this}_removeFormatting(e,t){for(let n=e.firstChild,i;n;n=i){if(i=n.nextSibling,N(n)){if(n instanceof Text||n.nodeName==="BR"||n.nodeName==="IMG"){t.appendChild(n);continue}}else if(xe(n)){t.appendChild(this.createDefaultBlock([this._removeFormatting(n,document.createDocumentFragment())]));continue}this._removeFormatting(n,t)}return t}removeAllFormatting(e){if(e||(e=this.getSelection()),e.collapsed)return this.focus();let t=this._root,n=e.commonAncestorContainer;for(;n&&n!==t&&!xe(n);)n=n.parentNode;if(n||(Zi(e,t),n=t),n instanceof Text)return this.focus();this.saveUndoState(e),Fe(e,n,n,t);let i=e.startContainer,r=e.startOffset,o=e.endContainer,s=e.endOffset,a=document.createDocumentFragment(),l=document.createDocumentFragment(),u=se(o,s,n,t),d=se(i,r,n,t),h;for(;d!==u;)h=d.nextSibling,a.appendChild(d),d=h;if(this._removeFormatting(a,l),l.normalize(),d=l.firstChild,h=l.lastChild,d){n.insertBefore(l,u);let p=Array.from(n.childNodes);r=p.indexOf(d),s=h?p.indexOf(h)+1:0}else u&&(r=Array.from(n.childNodes).indexOf(u),s=r);return e.setStart(n,r),e.setEnd(n,s),Xe(n,e),j(e),this.setSelection(e),this._updatePath(e,!0),this.focus()}},mr=Zs;function gr(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function Ys(e){if(Array.isArray(e))return e}function Xs(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var i,r,o,s,a=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,t!==0)for(;!(l=(i=o.call(n)).done)&&(a.push(i.value),a.length!==t);l=!0);}catch(d){u=!0,r=d}finally{try{if(!l&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw r}}return a}}function Qs(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
23
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Js(e,t){return Ys(e)||Xs(e,t)||ea(e,t)||Qs()}function ea(e,t){if(e){if(typeof e=="string")return gr(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?gr(e,t):void 0}}var Rr=Object.entries,yr=Object.setPrototypeOf,ta=Object.isFrozen,na=Object.getPrototypeOf,ia=Object.getOwnPropertyDescriptor,G=Object.freeze,K=Object.seal,tt=Object.create,Or=typeof Reflect<"u"&&Reflect,zn=Or.apply,qn=Or.construct;G||(G=function(t){return t});K||(K=function(t){return t});zn||(zn=function(t,n){for(var i=arguments.length,r=new Array(i>2?i-2:0),o=2;o<i;o++)r[o-2]=arguments[o];return t.apply(n,r)});qn||(qn=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return new t(...i)});var gt=B(Array.prototype.forEach),ra=B(Array.prototype.lastIndexOf),br=B(Array.prototype.pop),et=B(Array.prototype.push),oa=B(Array.prototype.splice),De=Array.isArray,Tt=B(String.prototype.toLowerCase),Pn=B(String.prototype.toString),Tr=B(String.prototype.match),yt=B(String.prototype.replace),_r=B(String.prototype.indexOf),sa=B(String.prototype.trim),aa=B(Number.prototype.toString),la=B(Boolean.prototype.toString),Er=typeof BigInt>"u"?null:B(BigInt.prototype.toString),Sr=typeof Symbol>"u"?null:B(Symbol.prototype.toString),z=B(Object.prototype.hasOwnProperty),bt=B(Object.prototype.toString),V=B(RegExp.prototype.test),We=ca(TypeError);function B(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return zn(e,t,i)}}function ca(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return qn(e,n)}}function S(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Tt;if(yr&&yr(e,null),!De(t))return e;let i=t.length;for(;i--;){let r=t[i];if(typeof r=="string"){let o=n(r);o!==r&&(ta(t)||(t[i]=o),r=o)}e[r]=!0}return e}function ua(e){for(let t=0;t<e.length;t++)z(e,t)||(e[t]=null);return e}function ee(e){let t=tt(null);for(let i of Rr(e)){var n=Js(i,2);let r=n[0],o=n[1];z(e,r)&&(De(o)?t[r]=ua(o):o&&typeof o=="object"&&o.constructor===Object?t[r]=ee(o):t[r]=o)}return t}function da(e){switch(typeof e){case"string":return e;case"number":return aa(e);case"boolean":return la(e);case"bigint":return Er?Er(e):"0";case"symbol":return Sr?Sr(e):"Symbol()";case"undefined":return bt(e);case"function":case"object":{if(e===null)return bt(e);let t=e,n=me(t,"toString");if(typeof n=="function"){let i=n(t);return typeof i=="string"?i:bt(i)}return bt(e)}default:return bt(e)}}function me(e,t){for(;e!==null;){let i=ia(e,t);if(i){if(i.get)return B(i.get);if(typeof i.value=="function")return B(i.value)}e=na(e)}function n(){return null}return n}function ha(e){try{return V(e,""),!0}catch{return!1}}var Ar=G(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Bn=G(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Fn=G(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),fa=G(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Hn=G(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),pa=G(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),vr=G(["#text"]),Cr=G(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Un=G(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Nr=G(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Wt=G(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),ma=K(/{{[\w\W]*|^[\w\W]*}}/g),ga=K(/<%[\w\W]*|^[\w\W]*%>/g),ya=K(/\${[\w\W]*/g),ba=K(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ta=K(/^aria-[\-\w]+$/),Lr=K(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),_a=K(/^(?:\w+script|data):/i),Ea=K(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Sa=K(/^html$/i),Aa=K(/^[a-z][.\w]*(-[.\w]+)+$/i),wr=K(/<[/\w!]/g),va=K(/<[/\w]/g),Ca=K(/<\/no(script|embed|frames)/i),Na=K(/\/>/i),pe={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},La=function(){return typeof window>"u"?null:window},wa=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null,r="data-tt-policy-suffix";n&&n.hasAttribute(r)&&(i=n.getAttribute(r));let o="dompurify"+(i?"#"+i:"");try{return t.createPolicy(o,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},xr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Oe=function(t,n,i,r){return z(t,n)&&De(t[n])?S(r.base?ee(r.base):{},t[n],r.transform):i};function Dr(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:La(),t=g=>Dr(g);if(t.version="3.4.11",t.removed=[],!e||!e.document||e.document.nodeType!==pe.document||!e.Element)return t.isSupported=!1,t;let n=e.document,i=n,r=i.currentScript;e.DocumentFragment;let o=e.HTMLTemplateElement,s=e.Node,a=e.Element,l=e.NodeFilter,u=e.NamedNodeMap;u===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let d=e.DOMParser,h=e.trustedTypes,p=a.prototype,y=me(p,"cloneNode"),_=me(p,"remove"),C=me(p,"nextSibling"),v=me(p,"childNodes"),I=me(p,"parentNode"),W=me(p,"shadowRoot"),ae=me(p,"attributes"),X=s&&s.prototype?me(s.prototype,"nodeType"):null,ve=s&&s.prototype?me(s.prototype,"nodeName"):null;if(typeof o=="function"){let g=n.createElement("template");g.content&&g.content.ownerDocument&&(n=g.content.ownerDocument)}let te,Ie="",rn,yi=!1,at=0,bi=function(){if(at>0)throw We('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},Ge=function(c){bi(),at++;try{return te.createHTML(c)}finally{at--}},Io=function(c){bi(),at++;try{return te.createScriptURL(c)}finally{at--}},Mo=function(){return yi||(rn=wa(h,r),yi=!0),rn},wt=n,on=wt.implementation,Ti=wt.createNodeIterator,Po=wt.createDocumentFragment,Bo=wt.getElementsByTagName,Fo=i.importNode,k=xr();t.isSupported=typeof Rr=="function"&&typeof I=="function"&&on&&on.createHTMLDocument!==void 0;let Ho=ma,Uo=ga,zo=ya,qo=ba,Wo=Ta,Vo=_a,_i=Ea,Go=Aa,Ei=Lr,w=null,Si=S({},[...Ar,...Bn,...Fn,...Hn,...vr]),x=null,Ai=S({},[...Cr,...Un,...Nr,...Wt]),R=Object.seal(tt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),lt=null,vi=null,Ce=Object.seal(tt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ci=!0,sn=!0,Ni=!1,Li=!0,Ne=!1,ct=!0,Me=!1,an=!1,ln=null,cn=null,un=!1,Ke=!1,xt=!1,Rt=!1,wi=!0,xi=!1,Ri="user-content-",dn=!0,hn=!1,$e={},ue=null,fn=S({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),Oi=null,Di=S({},["audio","video","img","source","image","track"]),pn=null,ki=S({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ot="http://www.w3.org/1998/Math/MathML",Dt="http://www.w3.org/2000/svg",de="http://www.w3.org/1999/xhtml",je=de,mn=!1,gn=null,Ko=S({},[Ot,Dt,de],Pn),Ii=G(["mi","mo","mn","ms","mtext"]),yn=S({},Ii),Mi=G(["annotation-xml"]),bn=S({},Mi),$o=S({},["title","style","font","a","script"]),ut=null,jo=["application/xhtml+xml","text/html"],Zo="text/html",O=null,Ze=null,Yo=n.createElement("form"),Pi=function(c){return c instanceof RegExp||c instanceof Function},Tn=function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ze&&Ze===c)return;(!c||typeof c!="object")&&(c={}),c=ee(c),ut=jo.indexOf(c.PARSER_MEDIA_TYPE)===-1?Zo:c.PARSER_MEDIA_TYPE,O=ut==="application/xhtml+xml"?Pn:Tt,w=Oe(c,"ALLOWED_TAGS",Si,{transform:O}),x=Oe(c,"ALLOWED_ATTR",Ai,{transform:O}),gn=Oe(c,"ALLOWED_NAMESPACES",Ko,{transform:Pn}),pn=Oe(c,"ADD_URI_SAFE_ATTR",ki,{transform:O,base:ki}),Oi=Oe(c,"ADD_DATA_URI_TAGS",Di,{transform:O,base:Di}),ue=Oe(c,"FORBID_CONTENTS",fn,{transform:O}),lt=Oe(c,"FORBID_TAGS",ee({}),{transform:O}),vi=Oe(c,"FORBID_ATTR",ee({}),{transform:O}),$e=z(c,"USE_PROFILES")?c.USE_PROFILES&&typeof c.USE_PROFILES=="object"?ee(c.USE_PROFILES):c.USE_PROFILES:!1,Ci=c.ALLOW_ARIA_ATTR!==!1,sn=c.ALLOW_DATA_ATTR!==!1,Ni=c.ALLOW_UNKNOWN_PROTOCOLS||!1,Li=c.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ne=c.SAFE_FOR_TEMPLATES||!1,ct=c.SAFE_FOR_XML!==!1,Me=c.WHOLE_DOCUMENT||!1,Ke=c.RETURN_DOM||!1,xt=c.RETURN_DOM_FRAGMENT||!1,Rt=c.RETURN_TRUSTED_TYPE||!1,un=c.FORCE_BODY||!1,wi=c.SANITIZE_DOM!==!1,xi=c.SANITIZE_NAMED_PROPS||!1,dn=c.KEEP_CONTENT!==!1,hn=c.IN_PLACE||!1,Ei=ha(c.ALLOWED_URI_REGEXP)?c.ALLOWED_URI_REGEXP:Lr,je=typeof c.NAMESPACE=="string"?c.NAMESPACE:de,yn=z(c,"MATHML_TEXT_INTEGRATION_POINTS")&&c.MATHML_TEXT_INTEGRATION_POINTS&&typeof c.MATHML_TEXT_INTEGRATION_POINTS=="object"?ee(c.MATHML_TEXT_INTEGRATION_POINTS):S({},Ii),bn=z(c,"HTML_INTEGRATION_POINTS")&&c.HTML_INTEGRATION_POINTS&&typeof c.HTML_INTEGRATION_POINTS=="object"?ee(c.HTML_INTEGRATION_POINTS):S({},Mi);let f=z(c,"CUSTOM_ELEMENT_HANDLING")&&c.CUSTOM_ELEMENT_HANDLING&&typeof c.CUSTOM_ELEMENT_HANDLING=="object"?ee(c.CUSTOM_ELEMENT_HANDLING):tt(null);if(R=tt(null),z(f,"tagNameCheck")&&Pi(f.tagNameCheck)&&(R.tagNameCheck=f.tagNameCheck),z(f,"attributeNameCheck")&&Pi(f.attributeNameCheck)&&(R.attributeNameCheck=f.attributeNameCheck),z(f,"allowCustomizedBuiltInElements")&&typeof f.allowCustomizedBuiltInElements=="boolean"&&(R.allowCustomizedBuiltInElements=f.allowCustomizedBuiltInElements),K(R),Ne&&(sn=!1),xt&&(Ke=!0),$e&&(w=S({},vr),x=tt(null),$e.html===!0&&(S(w,Ar),S(x,Cr)),$e.svg===!0&&(S(w,Bn),S(x,Un),S(x,Wt)),$e.svgFilters===!0&&(S(w,Fn),S(x,Un),S(x,Wt)),$e.mathMl===!0&&(S(w,Hn),S(x,Nr),S(x,Wt))),Ce.tagCheck=null,Ce.attributeCheck=null,z(c,"ADD_TAGS")&&(typeof c.ADD_TAGS=="function"?Ce.tagCheck=c.ADD_TAGS:De(c.ADD_TAGS)&&(w===Si&&(w=ee(w)),S(w,c.ADD_TAGS,O))),z(c,"ADD_ATTR")&&(typeof c.ADD_ATTR=="function"?Ce.attributeCheck=c.ADD_ATTR:De(c.ADD_ATTR)&&(x===Ai&&(x=ee(x)),S(x,c.ADD_ATTR,O))),z(c,"ADD_URI_SAFE_ATTR")&&De(c.ADD_URI_SAFE_ATTR)&&S(pn,c.ADD_URI_SAFE_ATTR,O),z(c,"FORBID_CONTENTS")&&De(c.FORBID_CONTENTS)&&(ue===fn&&(ue=ee(ue)),S(ue,c.FORBID_CONTENTS,O)),z(c,"ADD_FORBID_CONTENTS")&&De(c.ADD_FORBID_CONTENTS)&&(ue===fn&&(ue=ee(ue)),S(ue,c.ADD_FORBID_CONTENTS,O)),dn&&(w["#text"]=!0),Me&&S(w,["html","head","body"]),w.table&&(S(w,["tbody"]),delete lt.tbody),c.TRUSTED_TYPES_POLICY){if(typeof c.TRUSTED_TYPES_POLICY.createHTML!="function")throw We('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof c.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw We('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let m=te;te=c.TRUSTED_TYPES_POLICY;try{Ie=Ge("")}catch(b){throw te=m,b}}else c.TRUSTED_TYPES_POLICY===null?(te=void 0,Ie=""):(te===void 0&&(te=Mo()),te&&typeof Ie=="string"&&(Ie=Ge("")));G&&G(c),Ze=c},Bi=S({},[...Bn,...Fn,...fa]),Fi=S({},[...Hn,...pa]),Xo=function(c,f,m){return f.namespaceURI===de?c==="svg":f.namespaceURI===Ot?c==="svg"&&(m==="annotation-xml"||yn[m]):!!Bi[c]},Qo=function(c,f,m){return f.namespaceURI===de?c==="math":f.namespaceURI===Dt?c==="math"&&bn[m]:!!Fi[c]},Jo=function(c,f,m){return f.namespaceURI===Dt&&!bn[m]||f.namespaceURI===Ot&&!yn[m]?!1:!Fi[c]&&($o[c]||!Bi[c])},es=function(c){let f=I(c);(!f||!f.tagName)&&(f={namespaceURI:je,tagName:"template"});let m=Tt(c.tagName),b=Tt(f.tagName);return gn[c.namespaceURI]?c.namespaceURI===Dt?Xo(m,f,b):c.namespaceURI===Ot?Qo(m,f,b):c.namespaceURI===de?Jo(m,f,b):!!(ut==="application/xhtml+xml"&&gn[c.namespaceURI]):!1},Le=function(c){et(t.removed,{element:c});try{I(c).removeChild(c)}catch{if(_(c),!I(c))throw We("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Hi=function(c){let f=v(c);if(f){let b=[];gt(f,E=>{et(b,E)}),gt(b,E=>{try{_(E)}catch{}})}let m=ae(c);if(m)for(let b=m.length-1;b>=0;--b){let E=m[b],A=E&&E.name;if(typeof A=="string")try{c.removeAttribute(A)}catch{}}},Pe=function(c,f){try{et(t.removed,{attribute:f.getAttributeNode(c),from:f})}catch{et(t.removed,{attribute:null,from:f})}if(f.removeAttribute(c),c==="is")if(Ke||xt)try{Le(f)}catch{}else try{f.setAttribute(c,"")}catch{}},ts=function(c){let f=ae(c);if(f)for(let m=f.length-1;m>=0;--m){let b=f[m],E=b&&b.name;if(!(typeof E!="string"||x[O(E)]))try{c.removeAttribute(E)}catch{}}},ns=function(c){let f=[c];for(;f.length>0;){let m=f.pop();(X?X(m):m.nodeType)===pe.element&&ts(m);let E=v(m);if(E)for(let A=E.length-1;A>=0;--A)f.push(E[A])}},Ui=function(c){let f=null,m=null;if(un)c="<remove></remove>"+c;else{let A=Tr(c,/^[\r\n\t ]+/);m=A&&A[0]}ut==="application/xhtml+xml"&&je===de&&(c='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+c+"</body></html>");let b=te?Ge(c):c;if(je===de)try{f=new d().parseFromString(b,ut)}catch{}if(!f||!f.documentElement){f=on.createDocument(je,"template",null);try{f.documentElement.innerHTML=mn?Ie:b}catch{}}let E=f.body||f.documentElement;return c&&m&&E.insertBefore(n.createTextNode(m),E.childNodes[0]||null),je===de?Bo.call(f,Me?"html":"body")[0]:Me?f.documentElement:E},zi=function(c){return Ti.call(c.ownerDocument||c,c,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},kt=function(c){return c=yt(c,Ho," "),c=yt(c,Uo," "),c=yt(c,zo," "),c},_n=function(c){var f;c.normalize();let m=Ti.call(c.ownerDocument||c,c,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),b=m.nextNode();for(;b;)b.data=kt(b.data),b=m.nextNode();let E=(f=c.querySelectorAll)===null||f===void 0?void 0:f.call(c,"template");E&>(E,A=>{Ye(A.content)&&_n(A.content)})},It=function(c){let f=ve?ve(c):null;return typeof f!="string"||O(f)!=="form"?!1:typeof c.nodeName!="string"||typeof c.textContent!="string"||typeof c.removeChild!="function"||c.attributes!==ae(c)||typeof c.removeAttribute!="function"||typeof c.setAttribute!="function"||typeof c.namespaceURI!="string"||typeof c.insertBefore!="function"||typeof c.hasChildNodes!="function"||c.nodeType!==X(c)||c.childNodes!==v(c)},Ye=function(c){if(!X||typeof c!="object"||c===null)return!1;try{return X(c)===pe.documentFragment}catch{return!1}},dt=function(c){if(!X||typeof c!="object"||c===null)return!1;try{return typeof X(c)=="number"}catch{return!1}};function be(g,c,f){g.length!==0&>(g,m=>{m.call(t,c,f,Ze)})}let is=function(c,f){return!!(ct&&c.hasChildNodes()&&!dt(c.firstElementChild)&&V(wr,c.textContent)&&V(wr,c.innerHTML)||ct&&c.namespaceURI===de&&f==="style"&&dt(c.firstElementChild)||c.nodeType===pe.processingInstruction||ct&&c.nodeType===pe.comment&&V(va,c.data))},rs=function(c,f){if(!lt[f]&&Vi(f)&&(R.tagNameCheck instanceof RegExp&&V(R.tagNameCheck,f)||R.tagNameCheck instanceof Function&&R.tagNameCheck(f)))return!1;if(dn&&!ue[f]){let m=I(c),b=v(c);if(b&&m){let E=b.length;for(let A=E-1;A>=0;--A){let F=hn?b[A]:y(b[A],!0);m.insertBefore(F,C(c))}}}return Le(c),!0},qi=function(c){if(be(k.beforeSanitizeElements,c,null),It(c))return Le(c),!0;let f=O(ve?ve(c):c.nodeName);if(be(k.uponSanitizeElement,c,{tagName:f,allowedTags:w}),is(c,f))return Le(c),!0;if(lt[f]||!(Ce.tagCheck instanceof Function&&Ce.tagCheck(f))&&!w[f])return rs(c,f);if((X?X(c):c.nodeType)===pe.element&&!es(c)||(f==="noscript"||f==="noembed"||f==="noframes")&&V(Ca,c.innerHTML))return Le(c),!0;if(Ne&&c.nodeType===pe.text){let b=kt(c.textContent);c.textContent!==b&&(et(t.removed,{element:c.cloneNode()}),c.textContent=b)}return be(k.afterSanitizeElements,c,null),!1},Wi=function(c,f,m){if(vi[f]||wi&&(f==="id"||f==="name")&&(m in n||m in Yo))return!1;let b=x[f]||Ce.attributeCheck instanceof Function&&Ce.attributeCheck(f,c);if(!(sn&&V(qo,f))){if(!(Ci&&V(Wo,f))){if(b){if(!pn[f]){if(!V(Ei,yt(m,_i,""))){if(!((f==="src"||f==="xlink:href"||f==="href")&&c!=="script"&&_r(m,"data:")===0&&Oi[c])){if(!(Ni&&!V(Vo,yt(m,_i,"")))){if(m)return!1}}}}}else if(!(Vi(c)&&(R.tagNameCheck instanceof RegExp&&V(R.tagNameCheck,c)||R.tagNameCheck instanceof Function&&R.tagNameCheck(c))&&(R.attributeNameCheck instanceof RegExp&&V(R.attributeNameCheck,f)||R.attributeNameCheck instanceof Function&&R.attributeNameCheck(f,c))||f==="is"&&R.allowCustomizedBuiltInElements&&(R.tagNameCheck instanceof RegExp&&V(R.tagNameCheck,m)||R.tagNameCheck instanceof Function&&R.tagNameCheck(m))))return!1}}return!0},os=S({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Vi=function(c){return!os[Tt(c)]&&V(Go,c)},ss=function(c,f,m,b){if(te&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!m)switch(h.getAttributeType(c,f)){case"TrustedHTML":return Ge(b);case"TrustedScriptURL":return Io(b)}return b},as=function(c,f,m,b){try{m?c.setAttributeNS(m,f,b):c.setAttribute(f,b),It(c)?Le(c):br(t.removed)}catch{Pe(f,c)}},Gi=function(c){be(k.beforeSanitizeAttributes,c,null);let f=c.attributes;if(!f||It(c))return;let m={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:x,forceKeepAttr:void 0},b=f.length,E=O(c.nodeName);for(;b--;){let A=f[b],F=A.name,M=A.namespaceURI,oe=A.value,le=O(F),Sn=oe,Q=F==="value"?Sn:sa(Sn);if(m.attrName=le,m.attrValue=Q,m.keepAttr=!0,m.forceKeepAttr=void 0,be(k.uponSanitizeAttribute,c,m),Q=m.attrValue,xi&&(le==="id"||le==="name")&&_r(Q,Ri)!==0&&(Pe(F,c),Q=Ri+Q),ct&&V(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Q)){Pe(F,c);continue}if(le==="attributename"&&Tr(Q,"href")){Pe(F,c);continue}if(!m.forceKeepAttr){if(!m.keepAttr){Pe(F,c);continue}if(!Li&&V(Na,Q)){Pe(F,c);continue}if(Ne&&(Q=kt(Q)),!Wi(E,le,Q)){Pe(F,c);continue}Q=ss(E,le,M,Q),Q!==Sn&&as(c,F,M,Q)}}be(k.afterSanitizeAttributes,c,null)},Mt=function(c){let f=null,m=zi(c);for(be(k.beforeSanitizeShadowDOM,c,null);f=m.nextNode();)if(be(k.uponSanitizeShadowNode,f,null),qi(f),Gi(f),Ye(f.content)&&Mt(f.content),(X?X(f):f.nodeType)===pe.element){let E=W(f);Ye(E)&&(En(E),Mt(E))}be(k.afterSanitizeShadowDOM,c,null)},En=function(c){let f=[{node:c,shadow:null}];for(;f.length>0;){let m=f.pop();if(m.shadow){Mt(m.shadow);continue}let b=m.node,A=(X?X(b):b.nodeType)===pe.element,F=v(b);if(F)for(let M=F.length-1;M>=0;--M)f.push({node:F[M],shadow:null});if(A){let M=ve?ve(b):null;if(typeof M=="string"&&O(M)==="template"){let oe=b.content;Ye(oe)&&f.push({node:oe,shadow:null})}}if(A){let M=W(b);Ye(M)&&f.push({node:null,shadow:M},{node:M,shadow:null})}}};return t.sanitize=function(g){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},f=null,m=null,b=null,E=null;if(mn=!g,mn&&(g="<!-->"),typeof g!="string"&&!dt(g)&&(g=da(g),typeof g!="string"))throw We("dirty is not a string, aborting");if(!t.isSupported)return g;an?(w=ln,x=cn):Tn(c),(k.uponSanitizeElement.length>0||k.uponSanitizeAttribute.length>0)&&(w=ee(w)),k.uponSanitizeAttribute.length>0&&(x=ee(x)),t.removed=[];let A=hn&&typeof g!="string"&&dt(g);if(A){let oe=ve?ve(g):g.nodeName;if(typeof oe=="string"){let le=O(oe);if(!w[le]||lt[le])throw We("root node is forbidden and cannot be sanitized in-place")}if(It(g))throw We("root node is clobbered and cannot be sanitized in-place");try{En(g)}catch(le){throw Hi(g),le}}else if(dt(g))f=Ui("<!---->"),m=f.ownerDocument.importNode(g,!0),m.nodeType===pe.element&&m.nodeName==="BODY"||m.nodeName==="HTML"?f=m:f.appendChild(m),En(m);else{if(!Ke&&!Ne&&!Me&&g.indexOf("<")===-1)return te&&Rt?Ge(g):g;if(f=Ui(g),!f)return Ke?null:Rt?Ie:""}f&&un&&Le(f.firstChild);let F=zi(A?g:f);try{for(;b=F.nextNode();)qi(b),Gi(b),Ye(b.content)&&Mt(b.content)}catch(oe){throw A&&Hi(g),oe}if(A)return gt(t.removed,oe=>{oe.element&&ns(oe.element)}),Ne&&_n(g),g;if(Ke){if(Ne&&_n(f),xt)for(E=Po.call(f.ownerDocument);f.firstChild;)E.appendChild(f.firstChild);else E=f;return(x.shadowroot||x.shadowrootmode)&&(E=Fo.call(i,E,!0)),E}let M=Me?f.outerHTML:f.innerHTML;return Me&&w["!doctype"]&&f.ownerDocument&&f.ownerDocument.doctype&&f.ownerDocument.doctype.name&&V(Sa,f.ownerDocument.doctype.name)&&(M="<!DOCTYPE "+f.ownerDocument.doctype.name+`>
|
|
24
|
+
`+M),Ne&&(M=kt(M)),te&&Rt?Ge(M):M},t.setConfig=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Tn(g),an=!0,ln=w,cn=x},t.clearConfig=function(){Ze=null,an=!1,ln=null,cn=null,te=rn,Ie=""},t.isValidAttribute=function(g,c,f){Ze||Tn({});let m=O(g),b=O(c);return Wi(m,b,f)},t.addHook=function(g,c){typeof c=="function"&&z(k,g)&&et(k[g],c)},t.removeHook=function(g,c){if(z(k,g)){if(c!==void 0){let f=ra(k[g],c);return f===-1?void 0:oa(k[g],f,1)[0]}return br(k[g])}},t.removeHooks=function(g){z(k,g)&&(k[g]=[])},t.removeAllHooks=function(){k=xr()},t}var kr=Dr();var Z=(e,t="0 0 18 18")=>`<svg viewBox="${t}" width="18" height="18" aria-hidden="true" focusable="false">${e}</svg>`,Y={bold:Z('<path fill="currentColor" d="M178.48,115.7A44,44,0,0,0,148,40H80a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8h80a48,48,0,0,0,18.48-92.3ZM88,56h60a28,28,0,0,1,0,56H88Zm72,136H88V128h72a32,32,0,0,1,0,64Z"/>',"0 0 256 256"),italic:Z('<path fill="currentColor" d="M200,56a8,8,0,0,1-8,8H157.77L115.1,192H144a8,8,0,0,1,0,16H64a8,8,0,0,1,0-16H98.23L140.9,64H112a8,8,0,0,1,0-16h80A8,8,0,0,1,200,56Z"/>',"0 0 256 256"),underline:Z('<path fill="currentColor" d="M200,224a8,8,0,0,1-8,8H64a8,8,0,0,1,0-16H192A8,8,0,0,1,200,224Zm-72-24a64.07,64.07,0,0,0,64-64V56a8,8,0,0,0-16,0v80a48,48,0,0,1-96,0V56a8,8,0,0,0-16,0v80A64.07,64.07,0,0,0,128,200Z"/>',"0 0 256 256"),strike:Z('<path fill="currentColor" d="M224,128a8,8,0,0,1-8,8H175.93c9.19,7.11,16.07,17.2,16.07,32,0,13.34-7,25.7-19.75,34.79C160.33,211.31,144.61,216,128,216s-32.33-4.69-44.25-13.21C71,193.7,64,181.34,64,168a8,8,0,0,1,16,0c0,17.35,22,32,48,32s48-14.65,48-32c0-14.85-10.54-23.58-38.77-32H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM76.33,104a8,8,0,0,0,7.61-10.49A17.3,17.3,0,0,1,83.11,88c0-18.24,19.3-32,44.89-32,18.84,0,34.16,7.42,41,19.85a8,8,0,0,0,14-7.7C173.33,50.52,152.77,40,128,40,93.29,40,67.11,60.63,67.11,88a33.73,33.73,0,0,0,1.62,10.49A8,8,0,0,0,76.33,104Z"/>',"0 0 256 256"),link:Z('<path fill="currentColor" d="M240,88.23a54.43,54.43,0,0,1-16,37L189.25,160a54.27,54.27,0,0,1-38.63,16h-.05A54.63,54.63,0,0,1,96,119.84a8,8,0,0,1,16,.45A38.62,38.62,0,0,0,150.58,160h0a38.39,38.39,0,0,0,27.31-11.31l34.75-34.75a38.63,38.63,0,0,0-54.63-54.63l-11,11A8,8,0,0,1,135.7,59l11-11A54.65,54.65,0,0,1,224,48,54.86,54.86,0,0,1,240,88.23ZM109,185.66l-11,11A38.41,38.41,0,0,1,70.6,208h0a38.63,38.63,0,0,1-27.29-65.94L78,107.31A38.63,38.63,0,0,1,144,135.71a8,8,0,0,0,16,.45A54.86,54.86,0,0,0,144,96a54.65,54.65,0,0,0-77.27,0L32,130.75A54.62,54.62,0,0,0,70.56,224h0a54.28,54.28,0,0,0,38.64-16l11-11A8,8,0,0,0,109,185.66Z"/>',"0 0 256 256"),unlink:Z('<path fill="currentColor" d="M198.63,57.37a32,32,0,0,0-45.19-.06L141.79,69.52a8,8,0,0,1-11.58-11l11.72-12.29a1.59,1.59,0,0,1,.13-.13,48,48,0,0,1,67.88,67.88,1.59,1.59,0,0,1-.13.13l-12.29,11.72a8,8,0,0,1-11-11.58l12.21-11.65A32,32,0,0,0,198.63,57.37ZM114.21,186.48l-11.65,12.21a32,32,0,0,1-45.25-45.25l12.21-11.65a8,8,0,0,0-11-11.58L46.19,141.93a1.59,1.59,0,0,0-.13.13,48,48,0,0,0,67.88,67.88,1.59,1.59,0,0,0,.13-.13l11.72-12.29a8,8,0,1,0-11.58-11ZM216,152H192a8,8,0,0,0,0,16h24a8,8,0,0,0,0-16ZM40,104H64a8,8,0,0,0,0-16H40a8,8,0,0,0,0,16Zm120,80a8,8,0,0,0-8,8v24a8,8,0,0,0,16,0V192A8,8,0,0,0,160,184ZM96,72a8,8,0,0,0,8-8V40a8,8,0,0,0-16,0V64A8,8,0,0,0,96,72Z"/>',"0 0 256 256"),ul:Z('<path fill="currentColor" d="M80,64a8,8,0,0,1,8-8H216a8,8,0,0,1,0,16H88A8,8,0,0,1,80,64Zm136,56H88a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16Zm0,64H88a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM44,52A12,12,0,1,0,56,64,12,12,0,0,0,44,52Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,116Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,180Z"/>',"0 0 256 256"),ol:Z('<path fill="currentColor" d="M224,128a8,8,0,0,1-8,8H104a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM104,72H216a8,8,0,0,0,0-16H104a8,8,0,0,0,0,16ZM216,184H104a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM43.58,55.16,48,52.94V104a8,8,0,0,0,16,0V40a8,8,0,0,0-11.58-7.16l-16,8a8,8,0,0,0,7.16,14.32ZM79.77,156.72a23.73,23.73,0,0,0-9.6-15.95,24.86,24.86,0,0,0-34.11,4.7,23.63,23.63,0,0,0-3.57,6.46,8,8,0,1,0,15,5.47,7.84,7.84,0,0,1,1.18-2.13,8.76,8.76,0,0,1,12-1.59A7.91,7.91,0,0,1,63.93,159a7.64,7.64,0,0,1-1.57,5.78,1,1,0,0,0-.08.11L33.59,203.21A8,8,0,0,0,40,216H72a8,8,0,0,0,0-16H56l19.08-25.53A23.47,23.47,0,0,0,79.77,156.72Z"/>',"0 0 256 256"),quote:Z('<path fill="currentColor" d="M100,56H40A16,16,0,0,0,24,72v64a16,16,0,0,0,16,16h60v8a32,32,0,0,1-32,32,8,8,0,0,0,0,16,48.05,48.05,0,0,0,48-48V72A16,16,0,0,0,100,56Zm0,80H40V72h60ZM216,56H156a16,16,0,0,0-16,16v64a16,16,0,0,0,16,16h60v8a32,32,0,0,1-32,32,8,8,0,0,0,0,16,48.05,48.05,0,0,0,48-48V72A16,16,0,0,0,216,56Zm0,80H156V72h60Z"/>',"0 0 256 256"),undo:Z('<path fill="currentColor" d="M224,128a96,96,0,0,1-94.71,96H128A95.38,95.38,0,0,1,62.1,197.8a8,8,0,0,1,11-11.63A80,80,0,1,0,71.43,71.39a3.07,3.07,0,0,1-.26.25L44.59,96H72a8,8,0,0,1,0,16H24a8,8,0,0,1-8-8V56a8,8,0,0,1,16,0V85.8L60.25,60A96,96,0,0,1,224,128Z"/>',"0 0 256 256"),redo:Z('<path fill="currentColor" d="M240,56v48a8,8,0,0,1-8,8H184a8,8,0,0,1,0-16H211.4L184.81,71.64l-.25-.24a80,80,0,1,0-1.67,114.78,8,8,0,0,1,11,11.63A95.44,95.44,0,0,1,128,224h-1.32A96,96,0,1,1,195.75,60L224,85.8V56a8,8,0,1,1,16,0Z"/>',"0 0 256 256"),clear:Z('<path fill="currentColor" d="M213.38,221.92a8,8,0,0,1-11.3-.54L136,148.69V192h24a8,8,0,0,1,0,16H96a8,8,0,0,1,0-16h24V131.09L64,69.49V88a8,8,0,0,1-16,0V56a8,8,0,0,1,.72-3.31l-6.64-7.31A8,8,0,1,1,53.92,34.62l160,176A8,8,0,0,1,213.38,221.92ZM105.79,64H120V80.43a8,8,0,0,0,16,0V64h56V88a8,8,0,0,0,16,0V56a8,8,0,0,0-8-8H105.79a8,8,0,0,0,0,16Z"/>',"0 0 256 256"),code:Z('<path fill="currentColor" d="M69.12,94.15,28.5,128l40.62,33.85a8,8,0,1,1-10.24,12.29l-48-40a8,8,0,0,1,0-12.29l48-40a8,8,0,0,1,10.24,12.3Zm176,27.7-48-40a8,8,0,1,0-10.24,12.3L227.5,128l-40.62,33.85a8,8,0,1,0,10.24,12.29l48-40a8,8,0,0,0,0-12.29ZM162.73,32.48a8,8,0,0,0-10.25,4.79l-64,176a8,8,0,0,0,4.79,10.26A8.14,8.14,0,0,0,96,224a8,8,0,0,0,7.52-5.27l64-176A8,8,0,0,0,162.73,32.48Z"/>',"0 0 256 256"),indent:Z('<path fill="currentColor" d="M224,128a8,8,0,0,1-8,8H112a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM112,72H216a8,8,0,0,0,0-16H112a8,8,0,0,0,0,16ZM216,184H40a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM34.34,141.66a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0,0-11.32l-40-40A8,8,0,0,0,34.34,61.66L68.69,96,34.34,130.34A8,8,0,0,0,34.34,141.66Z"/>',"0 0 256 256"),outdent:Z('<path fill="currentColor" d="M224,128a8,8,0,0,1-8,8H112a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM112,72H216a8,8,0,0,0,0-16H112a8,8,0,0,0,0,16ZM216,184H40a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM72,144a8,8,0,0,0,5.66-13.66L43.31,96,77.66,61.66A8,8,0,0,0,66.34,50.34l-40,40a8,8,0,0,0,0,11.32l40,40A8,8,0,0,0,72,144Z"/>',"0 0 256 256"),blocks:Z('<path fill="currentColor" d="M208,40H96a64,64,0,0,0,0,128h40v40a8,8,0,0,0,16,0V56h24V208a8,8,0,0,0,16,0V56h16a8,8,0,0,0,0-16ZM136,152H96a48,48,0,0,1,0-96h40Z"/>',"0 0 256 256")},Se=e=>e.blocksStayOut(),xa=e=>!!e.element.closest("a"),_t={minimal:["bold","italic","link","unorderedList"],inline:["bold","italic","underline","strikethrough","code","link","unlink","undo","redo","clearFormatting"],standard:["blockMenu","bold","italic","underline","strikethrough","code","link","unlink","unorderedList","orderedList","quote","outdent","indent","undo","redo","clearFormatting"]};function Ir(){return new Map(Ra.map(e=>[e.id,e]))}function nt(e=globalThis){let t=e?.navigator;return t?/Mac|iPhone|iPad|iPod/.test(t.platform||t.userAgent||""):!1}function Mr(e,t=globalThis){return e?e.replace("Mod",nt(t)?"Cmd":"Ctrl"):""}var Ra=[ke("bold","Bold",Y.bold,"Mod+B","inline",e=>e.toggleFormat("B","bold","removeBold")),ke("italic","Italic",Y.italic,"Mod+I","inline",e=>e.toggleFormat("I","italic","removeItalic")),ke("underline","Underline",Y.underline,"Mod+U","inline",e=>e.toggleFormat("U","underline","removeUnderline")),ke("strikethrough","Strikethrough",Y.strike,"Mod+Shift+7","inline",e=>e.toggleFormat("S","strikethrough","removeStrikethrough")),ke("code","Code",Y.code,null,"inline",e=>e.toggleCode(),e=>e.selectionHasFormat("CODE")||e.selectionHasFormat("PRE")),{id:"link",label:"Link",ariaLabel:"Insert or edit link",icon:Y.link,group:"links",shortcut:"Mod+K",mutates:!1,isDisabled:xa,run:e=>e.openLinkDialog(),isActive:e=>e.selectionHasFormat("A")},{id:"unlink",label:"Remove link",ariaLabel:"Remove link",icon:Y.unlink,group:"links",run:e=>e.squire.removeLink()},ke("unorderedList","Bulleted list",Y.ul,"Mod+Shift+8","lists",e=>e.toggleList("UL"),e=>e.pathHas("UL"),Se),ke("orderedList","Numbered list",Y.ol,"Mod+Shift+9","lists",e=>e.toggleList("OL"),e=>e.pathHas("OL"),Se),ke("quote","Quote",Y.quote,null,"blocks",e=>e.pathHas("BLOCKQUOTE")?e.squire.decreaseQuoteLevel():e.squire.increaseQuoteLevel(),e=>e.pathHas("BLOCKQUOTE"),Se),{id:"outdent",label:"Outdent",ariaLabel:"Decrease indent",icon:Y.outdent,group:"blocks",shortcut:"Mod+[",isDisabled:Se,run:e=>e.outdent()},{id:"indent",label:"Indent",ariaLabel:"Increase indent",icon:Y.indent,group:"blocks",shortcut:"Mod+]",isDisabled:Se,run:e=>e.indent()},{id:"undo",label:"Undo",ariaLabel:"Undo",icon:Y.undo,group:"history",shortcut:"Mod+Z",mutates:!1,run:e=>e.squire.undo()},{id:"redo",label:"Redo",ariaLabel:"Redo",icon:Y.redo,group:"history",shortcut:"Mod+Shift+Z",mutates:!1,run:e=>e.squire.redo()},{id:"clearFormatting",label:"Clear formatting",ariaLabel:"Clear formatting",icon:Y.clear,group:"cleanup",run:e=>e.squire.removeAllFormatting()},{id:"blockMenu",type:"menu",label:"Block style",ariaLabel:"Choose block style",icon:Y.blocks,group:"blocks",isDisabled:Se,options:[Vt("Paragraph","P"),Vt("Heading 1","H1"),Vt("Heading 2","H2"),Vt("Heading 3","H3"),{label:"Quote",value:"BLOCKQUOTE",isDisabled:Se,run:e=>e.squire.increaseQuoteLevel(),isActive:e=>e.pathHas("BLOCKQUOTE")},{label:"Code block",value:"PRE",isDisabled:Se,run:e=>e.setBlockType("PRE"),isActive:e=>e.pathHas("PRE")}]}];function ke(e,t,n,i,r,o,s=l=>l.selectionHasFormat(Oa(e)),a){return{id:e,label:t,ariaLabel:t,icon:n,group:r,shortcut:i,isDisabled:a,run:o,isActive:s}}function Oa(e){return{bold:"B",italic:"I",underline:"U",strikethrough:"S"}[e]}function Vt(e,t){return{label:e,value:t,isDisabled:Se,run:n=>n.setBlockType(t),isActive:n=>n.pathHas(t)}}var Vn=/^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|EL|FN)|EM|FONT|HR|I(?:FRAME|MG|NPUT|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:AMP|MALL|PAN|TR(?:IKE|ONG)|U[BP])?|TIME|U|VAR|WBR)$/,Kt=/[^ \t\r\n]/;var Da=new Set(["BR","HR","IFRAME","IMG","INPUT","WBR"]),Gn=e=>e?.nodeType===1&&e.matches('[editor-ui],[clay~="editor-ui"]'),St=new Set(["svg","math"]);function $t(e){let t=e.nodeType;return t===3||t===8?!0:t!==1?!1:St.has(e.nodeName)?!0:Vn.test(e.nodeName)?Array.from(e.childNodes).every($t):!1}function At(e){return Array.from(e.childNodes).some(t=>!$t(t))}var Wn=e=>e?.nodeType===1&&!St.has(e.nodeName)&&!Vn.test(e.nodeName);function vt(e,t){let n=Array.from(e.childNodes),i=0;return n.forEach((r,o)=>{if(!(r.nodeType!==1||St.has(r.nodeName))&&(i+=vt(r,t),!!Wn(r))){for(Wn(n[o-1])&&e.insertBefore(t(),r);r.firstChild;)e.insertBefore(r.firstChild,r);r.remove(),i+=1}}),i}var Kn=new Set(["TABLE","THEAD","TBODY","TFOOT","TR","COLGROUP"]);function jt(e){return!!e.closest?.("p")||Kn.has(e.nodeName)}var ka=new Set(["P","H1","H2","H3","H4","H5","H6","PRE","LABEL","LEGEND","LI","TD","TH","DT","DD","FIGCAPTION","SUMMARY","CAPTION"]);function Hr(e){return ka.has(e.nodeName)||Zt(e)}var Ur=new Set(["AREA","BASE","BR","COL","EMBED","HR","IMG","INPUT","LINK","META","PARAM","SOURCE","TRACK","WBR"]),Ia=new Set(["SCRIPT","STYLE","TEXTAREA","TITLE","IFRAME","NOSCRIPT","XMP"]),zr="http://www.w3.org/1999/xhtml";function qr(e){return Kn.has(e.nodeName)||Ur.has(e.nodeName)||Ia.has(e.nodeName)||e.nodeName==="TEMPLATE"||!!e.namespaceURI&&e.namespaceURI!==zr}function Wr(e){return Kn.has(e.nodeName)?"a table element cannot be an editable region. Move the editable attribute to a <td>, a <th>, or an element inside one.":e.namespaceURI&&e.namespaceURI!==zr?"an SVG or MathML element cannot be an editable region: an edit puts an HTML block inside it, and the next page load moves that text out of the graphic entirely. Put a <foreignObject> in the SVG and mark an HTML element inside it instead.":Ur.has(e.nodeName)?"this element cannot contain anything, so there is nothing to edit. Move the editable attribute to an element that holds text.":e.nodeName==="TEMPLATE"?"a <template> keeps its content out of the document, so edits to it are never saved.":"this element treats its content as plain text, so any edit would be saved as visible markup rather than formatting."}function Zt(e){return e.nodeType===1&&!St.has(e.nodeName)&&Vn.test(e.nodeName)}function Yt(e){return Array.from(e.querySelectorAll("*")).some(Wn)}function Vr(e,t={}){let{blockTag:n="DIV",wrapBareRoot:i=!1,onBareRootWrapped:r,blocksAllowed:o=!jt(e)}=t;return $r(e),o&&Ba(e,n,i,r),e}var Ma=e=>$t(e)&&e.nodeType!==8&&!Gn(e),Pa=e=>e.nodeType!==8&&!Gn(e)&&!(e.nodeType===3&&!Kt.test(e.nodeValue));function Gr(e,{wrapBareRoot:t=!1,blocksAllowed:n=!jt(e)}={}){return n?At(e)?Array.from(e.childNodes).some(Ma)||Kr(e):t:!1}function Kr(e){return Array.from(e.children).some(t=>At(t)?!$n(t)&&Array.from(t.childNodes).some(i=>i.nodeType===3&&!Kt.test(i.nodeValue))||Kr(t):!1)}function $r(e){At(e)&&($n(e)||Array.from(e.childNodes).forEach(t=>{t.nodeType===3&&!Kt.test(t.nodeValue)&&t.remove()}),Array.from(e.children).forEach($r))}function Ba(e,t,n,i){if(!At(e)){if(!n)return;let s=e.ownerDocument.createElement(t);if(!Array.from(e.childNodes).some(Pa)){s.appendChild(e.ownerDocument.createElement("BR")),e.appendChild(s);return}for(;e.firstChild;)s.appendChild(e.firstChild);e.appendChild(s),i?.(e,s);return}let r=[],o=()=>{let s=r;if(r=[],!s.some(l=>l.nodeType!==8))return;let a=e.ownerDocument.createElement(t);e.insertBefore(a,s[0]),s.forEach(l=>a.appendChild(l))};Array.from(e.childNodes).forEach(s=>{Gn(s)?o():$t(s)?r.push(s):o()}),o()}function $n(e){return e.nodeName==="PRE"}function jr(e,t){return{start:Pr(e,t.startContainer,t.startOffset),end:Pr(e,t.endContainer,t.endOffset),collapsed:t.collapsed}}function Zr(e,t,n){Fr(t,"setStart",e,n.start),n.collapsed?t.collapse(!0):Fr(t,"setEnd",e,n.end)}function Pr(e,t,n){if(!e.contains(t))return{scope:e,after:[],before:[]};if(t.nodeType===3){if(!Fa(t))return{container:t,offset:n};let i=t.parentNode;return Br(i,Array.from(i.childNodes).indexOf(t))}return{container:t,offset:n,childCount:t.childNodes.length,...Br(t,n)}}function Br(e,t){let n=Array.from(e.childNodes),i=Math.max(0,t);return{scope:e,after:n.slice(i),before:n.slice(0,i).reverse()}}function Fr(e,t,n,i){let{container:r,childCount:o}=i;if(r&&n.contains(r)&&(o===void 0||o===r.childNodes.length)){e[t](r,Math.min(i.offset,Gt(r)));return}let s=i.after?.find(u=>n.contains(u));if(s){e[t](Et(s,!0),0);return}let a=i.before?.find(u=>n.contains(u));if(a){let u=Et(a,!1);e[t](u,Gt(u));return}let l=i.scope&&n.contains(i.scope)?i.scope:n;e[t](l,0)}function Fa(e){return e.nodeType===3&&!Kt.test(e.nodeValue)&&!!e.parentNode&&e.parentNode.nodeType===1&&At(e.parentNode)&&!$n(e.parentNode)}var it=e=>e.nodeType===1||e.nodeType===3;function Et(e,t=!0){let n=e;for(;n.nodeType===1&&!St.has(n.nodeName);){let i=Array.from(n.childNodes).filter(it),r=t?i[0]:i[i.length-1];if(!r||Da.has(r.nodeName))break;n=r}return n}function Gt(e){return e.nodeType===3?e.nodeValue.length:e.childNodes.length}var ce="[data-richclay], [richclay], [editable], [clay-editable]",Ha="[data-richclay], [richclay], [clay-editable]",Ua=["editable","clay-editable"],Yn=':is([editable~="single-line"], [clay-editable~="single-line"])';function Qn(e){return!e||typeof e.matches!="function"?!1:e.tagName.includes("-")?e.matches(Ha):!0}var za="[data-richclay-toolbar], [data-richclay-menu], [data-richclay-dialog], [data-richclay-live], [data-richclay-float]",qa=["richclay-editor","richclay-inline","richclay-active","richclay-empty","richclay-focused"],Xn=new WeakSet,Yr=new WeakSet,Xr=["clay:ready","hyperclay:ready"];function Qr(e){return[e.clay?.ready,e.hyperclay?.ready].find(t=>t&&typeof t.then=="function")||null}function Jr(e){return typeof e.clay?.isEditMode=="boolean"?e.clay.isEditMode:typeof e.hyperclay?.isEditMode=="boolean"?e.hyperclay.isEditMode:null}function Wa(e){let t=e.hyperclayModules,n=e.__hyperclayNoAutoExport===!1&&t&&typeof t=="object"&&typeof t.nodeType!="number";return Jr(e)!==null||!!Qr(e)||!!n}function Va(e){return e.clay?.addDocumentTransform||e.hyperclay?.beforeSave||null}function Ga(e){return e.clay?.onSnapshot||e.hyperclay?.onSnapshot||null}var Ka={boxSizing:"border-box",minWidth:"100%",overflow:"auto",width:"0"};function Xt(e={},t=window){return e.hyperclay===!1?!1:e.hyperclay===!0?!0:!!(Wa(t)||el(t))}function Jn(e=window){let t=no(e);if(t!==null)return t;if(typeof e.__hyperclayEditMode=="boolean")return e.__hyperclayEditMode;let n=Jr(e);return n!==null?n:tl(e)}function eo(e={},t=window){return e.readOnly?!1:Xt(e,t)?Jn(t):!0}function to(e){let t=Ua.find(r=>e.hasAttribute(r));if(!t)return null;let n=new Set((e.getAttribute(t)||"").trim().split(/\s+/).filter(Boolean)),i={inline:!0,singleLine:n.has("single-line"),toolbarOnSelect:n.has("toolbar-on-select")};return n.has("no-toolbar")&&(i.toolbar=!1),i}function ei(e=window){if(Xn.has(e))return;let t=Ga(e)||Va(e);if(typeof t!="function"){$a(e);return}t(n=>ti(n)),Xn.add(e)}function $a(e){if(Yr.has(e))return;let t=e.document,n=Qr(e);if(!t&&!n)return;Yr.add(e);let i=()=>{ei(e),Xn.has(e)&&r()},r=()=>{t&&Xr.forEach(o=>t.removeEventListener(o,i))};t&&Xr.forEach(o=>t.addEventListener(o,i)),n&&n.then(i,()=>{})}function ti(e){e.querySelectorAll?.(za).forEach(t=>t.remove()),e.querySelectorAll?.(ce).forEach(t=>{if(t.getAttribute("data-richclay-active")!=="true")return;if(Qt(t,"save"),Xa(t)){let i=t.ownerDocument,r=!!t.matches?.(Yn);vt(t,()=>r?i.createTextNode(" "):i.createElement("br")),t.querySelectorAll(t.localName).forEach(o=>{for(;o.firstChild;)o.parentNode.insertBefore(o.firstChild,o);o.remove()})}t.matches?.(Yn)&&Ja(t),t.querySelectorAll("#squire-selection-start, #squire-selection-end").forEach(i=>{i.remove()}),t.querySelectorAll(".squire-image-resize-container").forEach(i=>i.remove()),Qa(t),(t.matches?.("pre")?[t,...t.querySelectorAll("pre")]:Array.from(t.querySelectorAll("pre"))).filter(i=>i.hasAttribute("data-richclay-pre")).forEach(i=>{Object.entries(Ka).forEach(([r,o])=>{i.style[r]||(i.style[r]=o)}),i.removeAttribute("data-richclay-pre")})}),e.querySelectorAll?.("#squire-selection-start, #squire-selection-end").forEach(t=>t.remove())}var ja="p, td, th, li, dl, dt, dd, table, blockquote, div, section, article, aside, main, header, footer, figure, figcaption",jn="data-richclay-measure";function Za(e){let t=e.ownerDocument,n=e.closest(ja)||e;e.setAttribute(jn,"");let i=t.createElement("div");try{i.innerHTML=n.outerHTML}finally{e.removeAttribute(jn)}let r=i.querySelector(`[${jn}]`);return!r||r.textContent!==e.textContent}var Ya=e=>!!e.querySelector(e.localName),Xa=e=>!!e.matches?.(Yn)||(Yt(e)||Ya(e))&&Za(e);function Qt(e,t){let n=e.getAttribute("data-richclay-runtime-contenteditable");e.hasAttribute("contenteditable")&&(n==="true"?e.removeAttribute("contenteditable"):n?t==="destroy"?e.setAttribute("contenteditable",n):(e.setAttribute("inert-contenteditable",n),e.removeAttribute("contenteditable")):t==="save"&&(e.setAttribute("inert-contenteditable",e.getAttribute("contenteditable")),e.removeAttribute("contenteditable"))),qa.forEach(i=>e.classList.remove(i)),e.getAttribute("class")===""&&e.removeAttribute("class"),Zn(e,"role","data-richclay-runtime-role"),Zn(e,"aria-multiline","data-richclay-runtime-aria-multiline"),Zn(e,"no-undo","data-richclay-runtime-no-undo"),e.getAttribute("data-richclay-runtime-display")==="true"&&(e.style.removeProperty("display"),e.getAttribute("style")===""&&e.removeAttribute("style")),nl(e),e.removeAttribute("data-richclay-active"),e.removeAttribute("data-richclay-placeholder"),e.removeAttribute("data-richclay-pre"),e.removeAttribute("data-richclay-runtime-role"),e.removeAttribute("data-richclay-runtime-aria-multiline"),e.removeAttribute("data-richclay-runtime-no-undo"),e.removeAttribute("data-richclay-runtime-describedby"),e.removeAttribute("data-richclay-runtime-contenteditable"),e.removeAttribute("data-richclay-runtime-display"),e.getAttribute("data-richclay-runtime-marker")==="true"&&e.removeAttribute("data-richclay"),e.removeAttribute("data-richclay-runtime-marker")}function Qa(e){let n=[e];for(;n.length;)n.pop().childNodes.forEach(r=>{r.nodeType===3?r.nodeValue.includes("\u200B")&&(r.nodeValue=r.nodeValue.split("\u200B").join("")):r.nodeType===1&&n.push(r)});e.querySelectorAll("b, i, u, s, em, strong, code, sub, sup, span").forEach(i=>{i.children.length===0&&(i.textContent||"")===""&&i.attributes.length===0&&i.remove()})}function Ja(e){let t=Array.from(e.childNodes).filter(i=>i.nodeType!==3||(i.nodeValue||"").trim()!=="");if(t.length!==1)return;let n=t[0];if(!(n.nodeType!==1||n.nodeName!=="P"||n.attributes.length>0)){for(;n.firstChild;)e.insertBefore(n.firstChild,n);n.remove()}}function ni(e){if(!e.hasAttribute("inert-contenteditable"))return null;let t=e.getAttribute("inert-contenteditable");return["false","plaintext-only"].includes(t)||(t="true"),e.setAttribute("contenteditable",t),e.removeAttribute("inert-contenteditable"),t==="true"&&e.setAttribute("data-richclay-runtime-contenteditable","true"),t}function ge(e){return e.setAttribute("snapshot-remove",""),e.setAttribute("no-watch",""),e}function no(e){try{let t=new URLSearchParams(e.location?.search||"");if(t.get("editmode")==="true")return!0;if(t.get("editmode")==="false")return!1}catch{return null}return null}function el(e){return no(e)!==null||typeof e.__hyperclayEditMode=="boolean"}function tl(e){let n=(e.document?.cookie||"").match(/(?:^|;\s*)isAdminOfCurrentResource=([^;]*)/);return!!(n&&n[1]!=="")}function Zn(e,t,n){e.hasAttribute(n)&&e.removeAttribute(t)}function nl(e){let t=e.getAttribute("data-richclay-runtime-describedby");if(!t)return;let n=(e.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean).filter(i=>i!==t);n.length?e.setAttribute("aria-describedby",n.join(" ")):e.removeAttribute("aria-describedby")}var il=0;function io(e=document){let t=e.createElement("div");return t.id=`richclay-live-${++il}`,t.className="richclay-sr-only",t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.setAttribute("data-richclay-live",""),ge(t),e.body.appendChild(t),t}function Ct(e,t){!e||!t||(e.textContent="",e.ownerDocument.defaultView.setTimeout(()=>{e.textContent=t},20))}function ii(e){e.preventDefault()}function ri(e){try{return e?.cloneRange?.()||null}catch{return null}}function rt(e){try{return ri(e?.getSelection?.())}catch{return null}}function Jt(e,t){if(!e||!t)return!1;try{return e.setSelection(t),!0}catch{return!1}}function en(e,t,n,i){e.hasAttribute(t)||e.setAttribute(i,"true"),e.setAttribute(t,n)}function ro(e,t){let n=new Set((e.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));n.add(t.id),e.setAttribute("aria-describedby",Array.from(n).join(" ")),e.setAttribute("data-richclay-runtime-describedby",t.id)}var rl=0,ot=class{constructor(t,n,i={}){this.editor=t,this.controls=n,this.options=i,this.id=++rl,this.items=[],this.menus=new Map,this.activeIndex=0,this.root=this.createRoot(),this.onRootKeydown=r=>this.handleRootKeydown(r),this.onRootClick=r=>this.handleRootClick(r),this.onRootPointerDown=r=>this.handleRootPointerDown(r),this.onDocumentPointerDown=r=>this.handleDocumentPointerDown(r),this.render(),this.root.addEventListener("keydown",this.onRootKeydown),this.root.addEventListener("click",this.onRootClick),this.root.addEventListener("mousedown",this.onRootPointerDown),this.root.ownerDocument.addEventListener("mousedown",this.onDocumentPointerDown)}destroy(){this.closeMenus(),this.root.removeEventListener("keydown",this.onRootKeydown),this.root.removeEventListener("click",this.onRootClick),this.root.removeEventListener("mousedown",this.onRootPointerDown),this.root.ownerDocument.removeEventListener("mousedown",this.onDocumentPointerDown),this.root.remove()}update(){this.items.forEach(t=>{let{def:n,button:i}=t;if(typeof n.isActive=="function"){let r=!!n.isActive(this.editor);i.setAttribute("aria-pressed",r?"true":"false"),i.classList.toggle("is-active",r)}typeof n.isDisabled=="function"&&(i.disabled=!!n.isDisabled(this.editor))}),this.ensureSingleTabStop()}focusFirst(){this.activeIndex=0,this.ensureSingleTabStop(),this.items[0]?.button.focus()}createRoot(){let t=this.editor.element.ownerDocument,n=t.createElement("div");n.className="richclay-toolbar",n.setAttribute("role","toolbar"),n.setAttribute("aria-label",this.options.ariaLabel||"Rich text formatting"),n.setAttribute("data-richclay-toolbar",""),ge(n);let i=ol(this.options.toolbarContainer,t);return i?i.appendChild(n):this.editor.element.insertAdjacentElement("beforebegin",n),n}render(){this.root.textContent="",this.items=[],this.menus.clear();let t=null;this.visibleControls().forEach((n,i)=>{if(n.type==="separator"){this.root.appendChild(so(this.root.ownerDocument)),t=null;return}t&&n.group&&n.group!==t&&this.root.appendChild(so(this.root.ownerDocument)),t=n.group||t,n.type==="menu"?this.renderMenu(n,i):this.renderButton(n,i)}),this.ensureSingleTabStop(),this.update()}visibleControls(){let t=this.controls.filter(i=>i.type==="separator"||!i.isDisabled?.(this.editor)),n=[];for(t.forEach(i=>{let r=n[n.length-1];i.type==="separator"&&(!r||r.type==="separator")||n.push(i)});n[n.length-1]?.type==="separator";)n.pop();return n}renderButton(t,n){let i=oo(this.root.ownerDocument,t);i.dataset.richclayControl=t.id,i.dataset.richclayIndex=String(n),typeof t.isActive=="function"&&i.setAttribute("aria-pressed","false"),this.root.appendChild(i),this.items.push({def:t,button:i,type:"button"})}renderMenu(t,n){let i=this.root.ownerDocument,r=oo(i,t),o=`richclay-menu-${this.id}-${t.id}`;r.dataset.richclayControl=t.id,r.dataset.richclayIndex=String(n),r.setAttribute("aria-haspopup","menu"),r.setAttribute("aria-expanded","false"),r.setAttribute("aria-controls",o);let s=i.createElement("div");s.id=o,s.className="richclay-menu",s.hidden=!0,s.setAttribute("role","menu"),s.setAttribute("data-richclay-menu",""),ge(s),t.options.forEach((l,u)=>{let d=i.createElement("button");d.type="button",d.className="richclay-menu-item",d.setAttribute("role","menuitemradio"),d.setAttribute("tabindex","-1"),d.dataset.richclayMenuItem=t.id,d.dataset.richclayOptionIndex=String(u),d.textContent=l.label,d.addEventListener("mousedown",ii),d.addEventListener("click",h=>{h.preventDefault(),this.chooseMenuItem(t,l,r)}),d.addEventListener("keydown",h=>this.handleMenuKeydown(h,t,r)),s.appendChild(d)});let a=i.createElement("span");a.className="richclay-menu-wrap",a.append(r,s),this.root.appendChild(a),this.items.push({def:t,button:r,type:"menu",menu:s}),this.menus.set(t.id,{def:t,button:r,menu:s})}handleRootPointerDown(t){let n=t.target.closest?.("[data-richclay-control]");!n||!this.root.contains(n)||(ii(t),this.editor.saveSelection())}handleRootClick(t){let n=t.target.closest?.("[data-richclay-control]");if(!n||!this.root.contains(n))return;t.preventDefault();let i=this.items.find(r=>r.button===n);if(!(!i||n.disabled)){if(this.activeIndex=this.items.indexOf(i),this.ensureSingleTabStop(),i.type==="menu"){this.toggleMenu(i.def.id);return}this.closeMenus(),this.editor.runControl(i.def)}}handleRootKeydown(t){let n=t.key,i={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1};if(n in i){t.preventDefault(),this.moveFocus(i[n]);return}if(n==="Home"){t.preventDefault(),this.setFocusIndex(0);return}if(n==="End"){t.preventDefault(),this.setFocusIndex(this.items.length-1);return}let r=this.items[this.activeIndex];if(r&&((n==="Enter"||n===" ")&&r.type==="menu"&&(t.preventDefault(),this.openMenu(r.def.id,"first")),n==="Escape")){let o=Array.from(this.menus.values()).some(s=>!s.menu.hidden);this.closeMenus(),o?r.button.focus():this.editor.focus()}}handleMenuKeydown(t,n,i){t.stopPropagation();let r=this.menus.get(n.id)?.menu,o=Array.from(r.querySelectorAll(".richclay-menu-item")),s=o.indexOf(t.currentTarget),a=s;if(t.key==="ArrowDown"&&(a=(s+1)%o.length),t.key==="ArrowUp"&&(a=(s-1+o.length)%o.length),t.key==="Home"&&(a=0),t.key==="End"&&(a=o.length-1),a!==s){t.preventDefault(),o[a].focus();return}if(t.key==="Escape"){t.preventDefault(),this.closeMenus(),i.focus();return}if(t.key==="Enter"||t.key===" "){t.preventDefault();let l=n.options[s];this.chooseMenuItem(n,l,i)}}handleDocumentPointerDown(t){this.root.contains(t.target)||this.closeMenus()}chooseMenuItem(t,n,i){this.closeMenus(),this.editor.runControl({...n,id:`${t.id}:${n.value}`,ariaLabel:n.label}),i.focus()}toggleMenu(t){let n=this.menus.get(t);n&&(n.menu.hidden?this.openMenu(t,"first"):this.closeMenus())}openMenu(t,n="first"){this.closeMenus(t);let i=this.menus.get(t);if(!i)return;i.menu.hidden=!1,i.button.setAttribute("aria-expanded","true"),this.updateMenuState(i);let r=Array.from(i.menu.querySelectorAll(".richclay-menu-item")),o=r.find(a=>a.getAttribute("aria-checked")==="true");(n==="active"&&o||r[0])?.focus()}closeMenus(t=null){this.menus.forEach((n,i)=>{i!==t&&(n.menu.hidden=!0,n.button.setAttribute("aria-expanded","false"))})}updateMenuState(t){Array.from(t.menu.querySelectorAll(".richclay-menu-item")).forEach((i,r)=>{let s=!!t.def.options[r].isActive?.(this.editor);i.setAttribute("aria-checked",s?"true":"false"),i.classList.toggle("is-active",s)})}moveFocus(t){if(!this.items.length)return;let n=this.activeIndex;do n=(n+t+this.items.length)%this.items.length;while(this.items[n].button.disabled&&n!==this.activeIndex);this.setFocusIndex(n)}setFocusIndex(t){this.activeIndex=Math.max(0,Math.min(t,this.items.length-1)),this.ensureSingleTabStop(),this.items[this.activeIndex]?.button.focus()}ensureSingleTabStop(){let t=this.items.filter(n=>!n.button.disabled);t.length&&(t.includes(this.items[this.activeIndex])||(this.activeIndex=this.items.indexOf(t[0])),this.items.forEach((n,i)=>{n.button.tabIndex=i===this.activeIndex?0:-1}))}};function oo(e,t){let n=e.createElement("button");n.type="button",n.className="richclay-button";let i=Mr(t.shortcut,e.defaultView),r=i?`${t.ariaLabel||t.label} (${i})`:t.ariaLabel||t.label;return n.setAttribute("aria-label",r),n.title=r,n.innerHTML=`${t.icon||""}<span class="richclay-sr-only">${t.label}</span>`,n}function so(e){let t=e.createElement("span");return t.className="richclay-separator",t.setAttribute("role","separator"),t.setAttribute("aria-orientation","vertical"),t}function ol(e,t){return e?typeof e=="string"?t.querySelector(e):e:null}var ao=16,sl=[16,8,0],q=8,al=4;function ll({anchor:e,bar:t,rail:n,viewport:i,current:r=null}){let o=p=>r===p?al:0;if(e.bottom<=0||e.top>=i.height||e.right<=0||e.left>=i.width)return{mode:"hidden",x:0,y:0};let s=p=>Math.max(q,Math.min(e.left,i.width-p-q)),a=e.top-ao-t.height;if(a>=q-o("above"))return{mode:"above",x:s(t.width),y:a};let l=e.bottom+ao;if(l+t.height<=i.height-q+o("below"))return{mode:"below",x:s(t.width),y:l};let u=i.width-e.right-q,d=e.left-q,h=u>=d?[["rail-right",u],["rail-left",d]]:[["rail-left",d],["rail-right",u]];for(let[p,y]of h)for(let _ of sl){if(n.width+_>y+o(p))continue;let C=p==="rail-right"?Math.min(e.right+_,i.width-n.width-q):Math.max(e.left-_-n.width,q),v=Math.min(e.bottom,i.height-q)-n.height,I=Math.max(q,Math.min(Math.max(e.top,q),v));return{mode:p,x:C,y:I,gap:_}}return{mode:"pinned",x:s(t.width),y:q}}var cl=10,ul=28;function lo({anchor:e,box:t,viewport:n,gap:i=cl}){let r=n.height-q-e.bottom-i,o=e.top-i-q,s=r>=t.height||r>=o?"below":"above",a=s==="below"?e.bottom+i:e.top-i-t.height,l=Math.max(q,Math.min(a,n.height-q-t.height)),u=(e.left+e.right)/2,d=Math.max(q,Math.min(u-ul,n.width-q-t.width)),h=Math.max(14,Math.min(u-d,t.width-14));return{side:s,x:d,y:l,arrow:h}}function ye(e,t,n){e.style.setProperty(t,n,"important")}var tn=class{constructor(t,n){this.editor=t,this.mode=null,this.hidden=!1,this.frame=0,this.bar={width:0,height:0},this.rail={width:0,height:0};let i=t.element.ownerDocument;this.doc=i,this.win=i.defaultView||globalThis,this.root=i.createElement("div"),this.root.className="richclay-float",this.root.setAttribute("data-richclay-float",""),this.root.setAttribute("save-remove",""),ge(this.root),i.body.appendChild(this.root),this.toolbar=new ot(t,n,{toolbarContainer:this.root}),this.onScroll=()=>this.schedule(),this.onResize=()=>{this.measure(),this.schedule()},i.addEventListener("scroll",this.onScroll,{capture:!0,passive:!0}),this.win.addEventListener("resize",this.onResize,{passive:!0}),this.win.visualViewport?.addEventListener("resize",this.onResize,{passive:!0}),this.win.visualViewport?.addEventListener("scroll",this.onScroll,{passive:!0}),this.resizeObserver=typeof this.win.ResizeObserver=="function"?new this.win.ResizeObserver(()=>this.schedule()):null,this.resizeObserver?.observe(t.element),this.measure(),this.reposition()}measure(){let t=this.root.classList.contains("richclay-float-rail");ye(this.root,"visibility","hidden"),this.root.classList.remove("richclay-float-rail"),this.bar={width:this.root.offsetWidth||0,height:this.root.offsetHeight||0},this.root.classList.add("richclay-float-rail"),this.rail={width:this.root.offsetWidth||0,height:this.root.offsetHeight||0},this.root.classList.toggle("richclay-float-rail",t),this.root.style.removeProperty("visibility")}schedule(){if(!this.win.requestAnimationFrame){this.reposition();return}this.frame||(this.frame=this.win.requestAnimationFrame(()=>{this.frame=0,this.reposition()}))}setVisible(t){this.hidden=!t,this.reposition()}reposition(){if(this.hidden){ye(this.root,"display","none");return}let t=this.editor.element.getBoundingClientRect(),n={width:this.win.visualViewport?.width??this.win.innerWidth,height:this.win.visualViewport?.height??this.win.innerHeight},i=ll({anchor:t,bar:this.bar,rail:this.rail,viewport:n,current:this.mode});if(this.mode=i.mode,i.mode==="hidden"){ye(this.root,"display","none");return}this.root.style.removeProperty("display"),this.root.classList.toggle("richclay-float-rail",i.mode==="rail-left"||i.mode==="rail-right"),this.root.classList.toggle("richclay-float-pinned",i.mode==="pinned"),ye(this.root,"transform",`translate(${Math.round(i.x)}px, ${Math.round(i.y)}px)`)}destroy(){this.frame&&this.win.cancelAnimationFrame?.(this.frame),this.frame=0,this.doc.removeEventListener("scroll",this.onScroll,{capture:!0}),this.win.removeEventListener("resize",this.onResize),this.win.visualViewport?.removeEventListener("resize",this.onResize),this.win.visualViewport?.removeEventListener("scroll",this.onScroll),this.resizeObserver?.disconnect(),this.toolbar.destroy(),this.root.remove()}};var dl={ALLOWED_TAGS:["a","b","blockquote","br","code","div","em","h1","h2","h3","h4","h5","h6","i","li","ol","p","pre","s","span","strong","sub","sup","u","ul"],ALLOWED_ATTR:["aria-label","href","rel","target","title"],ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!0,ALLOWED_URI_REGEXP:/^(?:(?:(?:f|ht)tps?|mailto|tel):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,FORBID_TAGS:["script","style","iframe","object","embed","form","input"],FORBID_ATTR:["style","srcset","onerror","onclick","onload"]};function ho(e={},t=document){let n=nn(t);return{sanitizeHTML(i){return oi(i,e,t,n)},sanitizeElement(i){return si(i,e,n)},sanitizeToDOMFragment(i,r){let o=r?.getRoot?.().ownerDocument||t;return hl(i,e,o,n)}}}function oi(e,t={},n=document,i=nn(n)){let r=n.createElement("template");return r.innerHTML=i.sanitize(String(e||""),ai(t)),li(r.content),r.innerHTML}function si(e,t={},n=nn(e.ownerDocument)){let r=e.ownerDocument.createElement("div");for(;e.firstChild;)r.appendChild(e.firstChild);for(n.sanitize(r,{...ai(t),IN_PLACE:!0}),li(r);r.firstChild;)e.appendChild(r.firstChild);return e}function hl(e,t={},n=document,i=nn(n)){let r=i.sanitize(String(e||""),{...ai(t),RETURN_DOM_FRAGMENT:!0}),o=r?.ownerDocument===n?r:n.importNode(r,!0);return li(o),o||n.createDocumentFragment()}function ai(e){return{...dl,...e}}var fl=new Set(["http","https","mailto","tel"]),pl=new RegExp("[\\u0000-\\u0020\\u007F-\\u009F]","g");function ml(e){let n=(String(e??"").replace(pl,"").match(/^([a-z][a-z0-9+.\-]*):/i)||[])[1];return!n||fl.has(n.toLowerCase())}function fo(e){let t=String(e??"").trim();return!t||!ml(t)?"":/^(?:https?:|mailto:|tel:)/i.test(t)?t:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?`mailto:${t}`:/^(?:[#?]|\/|\.{1,2}\/)/.test(t)?t:`https://${t}`}function nn(e){let t=globalThis.DOMPurify;if(t?.sanitize)return t;if(typeof t=="function")return t(e.defaultView||globalThis);throw new Error("RichClay requires DOMPurify. Load vendor/purify.min.js before richclay.js or provide globalThis.DOMPurify.")}function li(e){e.querySelectorAll?.("a[href]").forEach(t=>{let n=t.getAttribute("href")||"";if(/^\s*javascript:/i.test(n)&&t.removeAttribute("href"),t.getAttribute("target")==="_blank"){let i=new Set((t.getAttribute("rel")||"").split(/\s+/).filter(Boolean));i.add("noopener"),i.add("noreferrer"),t.setAttribute("rel",Array.from(i).join(" "))}})}var co={ADD_TAGS:["img"],ADD_ATTR:["class","id","src","alt","width","height"]};function po(e={}){return{...e,ADD_TAGS:[...new Set([...co.ADD_TAGS,...e.ADD_TAGS||[]])],ADD_ATTR:[...new Set([...co.ADD_ATTR,...e.ADD_ATTR||[]])],ALLOW_DATA_ATTR:e.ALLOW_DATA_ATTR??!0}}var uo="p, div, h1, h2, h3, h4, h5, h6, blockquote, pre, ul, ol, li, figure, figcaption, table, thead, tbody, tr, td, th";function mo(e){let t=e.ownerDocument||document;e.querySelectorAll?.("br").forEach(i=>i.replaceWith(t.createTextNode(" ")));let n=e.querySelector?.(uo);for(;n;){let i=n.parentNode;for(i.insertBefore(t.createTextNode(" "),n);n.firstChild;)i.insertBefore(n.firstChild,n);i.insertBefore(t.createTextNode(" "),n),n.remove(),n=e.querySelector(uo)}return gl(e,t),e}function gl(e,t){e.normalize?.();let n=t.createTreeWalker(e,4),i=[];for(;n.nextNode();)i.push(n.currentNode);i.forEach(s=>{s.nodeValue=s.nodeValue.replace(/\s+/g," ")});let r=e.firstChild;r?.nodeType===3&&(r.nodeValue=r.nodeValue.replace(/^\s+/,""));let o=e.lastChild;o?.nodeType===3&&(o.nodeValue=o.nodeValue.replace(/\s+$/,""))}var go="richclay-styles",ci=new WeakSet,ui="";function yo(e){ui=e||""}function bo(e=document){if(!e||ci.has(e))return;if(e.getElementById(go)){ci.add(e);return}if(!ui)return;let t=e.createElement("style");t.id=go,t.setAttribute("save-remove",""),t.setAttribute("save-ignore",""),t.textContent=ui,(e.head||e.documentElement).appendChild(t),ci.add(e)}var To=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),yl=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),nc=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui"]);function di(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function bl(e,t){if(di(e,t))return!0;for(let[n,i]of Object.entries(yl))if(i.includes(t)&&di(e,n))return!0;return!1}function Nt(e){let t=To[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function hi(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let i=To[t];if(!i)throw new Error(`Unknown region capability: ${t}`);if(i.tokens.some(r=>bl(n,r))||i.bundles.some(r=>di(n,r)))return n;n=n.parentElement}return null}function _o(e,t){return!!hi(e,t)}var Tl=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function Eo(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();if("value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&(t.value=e.value),"checked"in e&&"checked"in t&&(t.checked=e.checked),"selected"in e&&"selected"in t&&(t.selected=e.selected),e.tagName==="SELECT")for(let i=0;i<e.options.length;i++)t.options[i].selected=e.options[i].selected;"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function So(e,t,n,i){if(i)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function Ao(e,t,n,i,r,o,s,a){if(e.nodeType===1&&((s?_o(e,n):So(e,i,o,!1))||r&&(s&&e!==o?e.matches(r):So(e,r,o,s))))return null;let l=t.importNode(e,!1);a.cloneToLive.set(l,e),a.liveToClone.set(e,l);let u=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,d=l.nodeType===1&&l.tagName==="TEMPLATE"?l.content:l;u!==e&&(a.cloneToLive.set(d,u),a.liveToClone.set(u,d));for(let h of u.childNodes||[]){let p=Ao(h,t,n,i,r,o,s,a);p&&(d.appendChild(p),h.nodeType===1&&Eo(h,p))}return e.nodeType===1&&Eo(e,l),l}function fi(e,{capability:t="data",exclude:n=null,inherit:i=!0}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let r=e.nodeType===9?e:e.ownerDocument;if(!r?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let o=r.implementation.createHTMLDocument(""),s=new WeakMap,a=new WeakMap,l=e.nodeType===9?e.documentElement:e;n&&o.documentElement.matches(n);let u=Nt(t),d=Ao(l,o,t,u,n,l,i,{cloneToLive:s,liveToClone:a});e.nodeType===9&&d&&(o.replaceChild(d,o.documentElement),a.set(e,o),s.set(o,e));let h=p=>{if(Tl.test(p))throw new Error(`Filtered content queries do not support stateful selector: ${p}`)};return{root:d,document:o,capability:t,selector:Nt(t),cloneToLive:s,liveToClone:a,original(p){return s.get(p)||null},cloneOf(p){return a.get(p)||null},query(p,y=d){return h(p),Array.from(y.querySelectorAll(p),_=>s.get(_)||_)},text(p=d){return(p===d?d:a.get(p))?.textContent||""},html(p=d){return(p===d?d:a.get(p))?.innerHTML??""},clone(p=d){let y=p===d?d:a.get(p);return y?o.importNode(y,!0):null}}}var _l=Nt("history");function Oo(e,t){let n=t.createElement("template");n.innerHTML=String(e||"");for(let i of n.content.querySelectorAll(_l))i.remove();return n.innerHTML}function Do(e,t){return Oo(e,t)}function El(e,t){let n=t.createElement("template");n.innerHTML=Do(e,t);let i=new Set(["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DIV","DL","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","H1","H2","H3","H4","H5","H6","HEADER","HR","LI","MAIN","NAV","OL","P","PRE","SECTION","TABLE","UL"]),r="",o=s=>{if(s.nodeType===3)r+=s.data;else if(s.nodeType===1&&s.tagName==="BR")r+=`
|
|
25
25
|
`;else{let a=s.nodeType===1&&i.has(s.tagName);a&&r&&!r.endsWith(`
|
|
26
26
|
`)&&(r+=`
|
|
27
27
|
`);for(let l of s.childNodes||[])o(l);a&&r&&!r.endsWith(`
|
|
28
28
|
`)&&(r+=`
|
|
29
29
|
`)}};return o(n.content),r.replace(/\n{3,}/g,`
|
|
30
30
|
|
|
31
|
-
`).replace(/^\n|\n$/g,"")}function Sl(e,t,n=null){let i=mi(e,{capability:"history",inherit:!1}),r=i.root,o=(a,l)=>{for(;a&&!i.cloneOf(a);){let f=a.parentNode;if(!f)return{container:r,offset:0};l=Array.from(f.childNodes).indexOf(a),a=f}let u=i.cloneOf(a)||r;if(a?.nodeType===3)return{container:u,offset:Math.min(l,u.length)};let d=Array.from(a?.childNodes||[]).slice(0,l).filter(f=>i.cloneOf(f)).length;return{container:u,offset:Math.min(d,u.childNodes.length)}},s=(a,l,u)=>{let d=o(l,u),f=r.ownerDocument.createElement("input");f.id=a,f.type="hidden";let p=r.ownerDocument.createRange();p.setStart(d.container,d.offset),p.collapse(!0),p.insertNode(f)};if(n)s(t.endSelectionId,n.endContainer,n.endOffset),s(t.startSelectionId,n.startContainer,n.startOffset);else for(let a of[t.startSelectionId,t.endSelectionId]){if(r.querySelector(`#${a}`))continue;let l=e.querySelector(`#${a}`);l&&s(a,l.parentNode,Array.from(l.parentNode.childNodes).indexOf(l))}return r.innerHTML}var Ae=new WeakMap,xo=new WeakSet,No=new WeakSet,gi=Br(),Lo=Symbol("richclay-keep-focus"),wo=["cut","paste","drop"],Al=["Alt","Ctrl","Meta","Shift"],Ro=0,vl={toolbar:"standard",toolbarContainer:null,sanitize:{},placeholder:"",readOnly:!1,hyperclay:"auto",onChange:null,Squire:null,inline:!1,singleLine:!1,toolbarOnSelect:!1},We=class e{static presets=Et;static selector=ue;constructor(t,n={}){if(!t)throw new Error("RichClay requires an element.");let i=Ae.get(t);if(i)return i;this.element=t,this.unsupported=yi(t)||Nl(t);let r={...ro(t),...n};this.options={...vl,...r},this.options.singleLine&&!("toolbar"in r)&&(this.options.toolbar="inline"),this._blockTag=this.options.inline?"DIV":"P",this.registry=new Map(gi),this.toolbar=null,this.float=null,this._onToolbarKey=null,this._onFloatFocusOut=null,this._onDocPointerDown=null,this.liveRegion=null,this.description=null,this.dialog=null,this.savedSelection=null,this.path="",this.active=!1,this._squire=null,this._squireListeners=[],this._onBeforeInput=null,this._onRootBeforeInput=null,this._onRootKeydown=null,this._onRootTransfer=null,this._shortcutKeys=[],this._appleDeleteKeys=new Set,this._authoredPres=new WeakSet,this._warnedInlineBlock=!1,this._onFocus=()=>{this.element.classList.add("richclay-focused"),this.options.inline&&this.ensureFloatingToolbar()},this._onBlur=o=>{this.element.classList.remove("richclay-focused"),this.options.inline&&this.scheduleFloatTeardown(o)},this.ensureMarker(),this.hyperclay=Zt(this.options,this.window),this.hyperclay&&ni(this.window),Ae.set(t,this),this.sanitizeConfig=this.options.inline?go(this.options.sanitize):this.options.sanitize,this.sanitizer=po(this.sanitizeConfig,this.element.ownerDocument),this.options.inline||li(this.element,this.sanitizeConfig),io(this.options,this.window)&&this.activate()}get squire(){return this._squire}get window(){return this.element.ownerDocument.defaultView||window}static init(t=ue,n={}){let i=t===ue?ei:()=>!0;return Cl(t).filter(i).filter(o=>!yi(o)).map(o=>new e(o,n))}static autoInit(t=typeof window<"u"?window:void 0){if(!t||!t.document||xo.has(t))return;xo.add(t);let n=()=>{Zt({},t)&&ti(t)&&(e.init(),e.watch(t))};t.document.readyState==="loading"?t.document.addEventListener("DOMContentLoaded",n,{once:!0}):n()}static watch(t=typeof window<"u"?window:void 0,n={}){if(!t||!t.document||No.has(t))return;No.add(t);let i=s=>{Lt(s)&&!Ae.has(s)&&!yi(s)&&new e(s,n)},r=s=>Ae.get(s)?.destroy();new t.MutationObserver(s=>{s.forEach(a=>{if(a.type==="attributes"){let l=a.target;Lt(l)?i(l):r(l);return}a.addedNodes.forEach(l=>{l.nodeType===1&&(l.matches?.(ue)&&i(l),l.querySelectorAll?.(ue).forEach(i))}),a.removedNodes.forEach(l=>{if(l.nodeType!==1)return;let u=d=>{d.isConnected||Ae.get(d)?.destroy()};l.matches?.(ue)&&u(l),l.querySelectorAll?.(ue).forEach(u)})})}).observe(t.document.documentElement||t.document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["editable","clay-editable","data-richclay","richclay"]})}static registerButton(t){return bi(t),gi.set(t.id,t),e}static unregisterButton(t){return gi.delete(t),e}static stripFromClone(t){ii(t)}static stripElement(t){if(!t||typeof t.getAttribute!="function")return;let n=Ae.get(t);if(n){n.destroy();return}Jt(t,"destroy")}registerButton(t){return bi(t),this.registry.set(t.id,t),this.active&&this.renderToolbar(),this}unregisterButton(t){return this.registry.delete(t),this.active&&this.renderToolbar(),this}activate(){if(this.unsupported||this.active)return;this.active=!0,this.applyInlineBox(),_o(this.element.ownerDocument),ri(this.element);let t=this.options.inline?Array.from(this.element.childNodes):null,n=this.options.inline?null:this.element.innerHTML,i=this.options.Squire||this.window.Squire||globalThis.Squire;if(!i)throw new Error("RichClay requires Squire. Load vendor/squire.js before richclay.js.");if(this.setupEditorAttributes(),this.liveRegion=so(this.element.ownerDocument),this._squire=new i(this.element,{blockTag:this._blockTag,serializeRoot:Sl,willCutCopy:r=>Io(r,this.element.ownerDocument),toPlainText:r=>El(r,this.element.ownerDocument),replaceRoot:(r,o,s)=>{let a=this.window.clay?.morph||this.window.hyperclay?.morph;if(typeof a!="function"){if(r.querySelector('[editor-ui], [clay~="editor-ui"]'))throw new Error("RichClay requires a retention-aware morph host to replay history containing editor-ui.");r.innerHTML=o;return}a(r,o,{morphStyle:"innerHTML",restoreFocus:!1,scripts:{handle:!1,merge:!1},policy:"history"}),s._ensureBottomLine(),s._mutation?.takeRecords()},onMutations:(r,o)=>{let s=(u,d)=>{let f=pi(u,d);return!!f&&f!==this.element&&this.element.contains(f)},a=!1,l=!1;for(let u of r){if(s(u.target,"history"))continue;let d=u.type==="childList"?[...u.addedNodes,...u.removedNodes]:[u.target];for(let f of d)s(f,"history")||(s(u.target,"undo")||s(f,"undo")?l=!0:a=!0)}if(a){let u=o._ignoreChange;o._docWasChanged(),l&&u&&o.fireEvent("input")}else l?(o._mayHaveZWS=!0,o.fireEvent("input")):o._ignoreChange=!1},sanitizeToDOMFragment:(r,o)=>{let s=this.sanitizer.sanitizeToDOMFragment(Do(r,this.element.ownerDocument),o);return this.options.singleLine?yo(s):s},didError:r=>{console.error("RichClay/Squire error",r)}}),this.options.inline?(this.element.replaceChildren(...t),this.resetSquireUndoBaseline()):this._squire.setHTML(n),this.bindSquire(),this.options.singleLine&&this.installSingleLineGuards(),this.options.inline&&!this.options.singleLine&&this.installRootGuards(),this.installAppleDeleteKeys(),this.blocksStayOut()&&(this._squire._ensureBottomLine=()=>{}),this.maskSquireCodeShortcut(),this.maskSquireBlockShortcuts(),this.installShortcuts(),this.options.inline&&(this._onToolbarKey=r=>{r.altKey&&r.key==="F10"&&(r.preventDefault(),this.ensureFloatingToolbar(),this.float?.toolbar.focusFirst())},this.element.addEventListener("keydown",this._onToolbarKey)),this.blocksStayOut()){let r=o=>{let s=o.detail?.fragment;if(!s)return;let a=this.element.ownerDocument;Ct(s,()=>this.options.singleLine?a.createTextNode(" "):a.createElement("br"))};this._squire.addEventListener("willPaste",r),this._squireListeners.push(["willPaste",r])}this.renderToolbar(),this.updatePlaceholder(),this.warnOnBlockInInlineRegion(),this.element.querySelectorAll("pre").forEach(r=>this._authoredPres.add(r))}reattach(){return this.unsupported||!this.active||this.element.getAttribute("contenteditable")==="true"&&this.element.getAttribute("data-richclay-active")==="true"&&Lt(this.element)?!1:(this.ensureMarker(),this.applyInlineBox(),ri(this.element),this.setupEditorAttributes(),!0)}applyInlineBox(){Xt(this.element)&&!this.element.style.display&&(this.element.style.display="inline-block",this.element.setAttribute("data-richclay-runtime-display","true"))}getHTML(){return this._squire?this._squire.getHTML():this.element.innerHTML}setHTML(t){return this._squire?this._squire.setHTML(String(t||"")):this.element.innerHTML=ai(t,this.sanitizeConfig,this.element.ownerDocument),this.updatePlaceholder(),this.toolbar?.update(),this.options.onChange?.(this.getHTML()),this}focus(){return this._squire?this._squire.focus():this.element.focus(),this}destroy(){this.closeLinkDialog(),this.teardownFloatingToolbar(),this.toolbar?.destroy(),this.toolbar=null,this._onToolbarKey&&(this.element.removeEventListener("keydown",this._onToolbarKey),this._onToolbarKey=null),this.liveRegion?.remove(),this.liveRegion=null,this.description?.remove(),this.description=null,this._shortcutKeys.forEach(n=>this._squire?.setKeyHandler?.(n,null)),this._squireListeners.forEach(([n,i])=>{this._squire?.removeEventListener?.(n,i)}),this._squireListeners=[],this._shortcutKeys=[],this._onBeforeInput&&(this.element.ownerDocument.removeEventListener("beforeinput",this._onBeforeInput,!0),this._onBeforeInput=null);let t=this.element.ownerDocument;this._onRootBeforeInput&&(t.removeEventListener("beforeinput",this._onRootBeforeInput,!0),this._onRootBeforeInput=null),this._onRootKeydown&&(t.removeEventListener("keydown",this._onRootKeydown,!0),this._onRootKeydown=null),this._onRootTransfer&&(wo.forEach(n=>t.removeEventListener(n,this._onRootTransfer,!0)),this._onRootTransfer=null),this._squire?.destroy?.(),this._squire=null,this.cleanupEditorAttributes(),Ae.delete(this.element)}saveSelection(){return this.savedSelection=rt(this._squire)||this.savedSelection,this.savedSelection}restoreSelection(){return en(this._squire,this.savedSelection)}installRootGuards(){let t=this.element.ownerDocument,n=i=>this.element.contains(i.target);this._onRootBeforeInput=i=>{!n(i)||i.isComposing||/^history/.test(i.inputType||"")||this.ensureRootIsEditable()},this._onRootKeydown=i=>{!n(i)||i.defaultPrevented||i.isComposing||this.isEditingKey(i)&&this.ensureRootIsEditable()},this._onRootTransfer=i=>{n(i)&&this.ensureRootIsEditable()},t.addEventListener("beforeinput",this._onRootBeforeInput,!0),t.addEventListener("keydown",this._onRootKeydown,!0),wo.forEach(i=>{t.addEventListener(i,this._onRootTransfer,!0)})}ensureRootIsEditable(){if(!this._squire||this.options.singleLine)return;let t=this.options.inline,n=!this.blocksStayOut();if(!Vr(this.element,{wrapBareRoot:t,blocksAllowed:n}))return;let i=rt(this._squire),r=i?Qr(this.element,i):null,o=()=>{jr(this.element,{blockTag:this._blockTag,wrapBareRoot:t,blocksAllowed:n,onBareRootWrapped:(s,a)=>{console.warn(`richclay: wrapped this region's loose text in a <div> so multi-line editing works. Wrap the content in your own block element to keep the markup you wrote, or use editable="single-line" if it is meant to be one line.`,s,a)}})};typeof this._squire.modifyDocument=="function"?this._squire.modifyDocument(o):o(),r&&(Zr(this.element,i,r),en(this._squire,i),this.savedSelection=si(i))}isEditingKey(t){return["Backspace","Delete","Enter"].includes(t.key)?!0:t.key==="Tab"?this.caretIsInList():t.key.length!==1?!1:!t.ctrlKey&&!t.metaKey&&!t.altKey?!0:t.ctrlKey&&!t.metaKey&&!t.altKey&&this._appleDeleteKeys.has(t.key.toLowerCase())}caretIsInList(){let n=this._squire?.getSelection()?.startContainer;if(!n)return!1;let i=n.nodeType===1?n:n.parentElement;return!!(i&&this.element.contains(i)&&i.closest("ul, ol"))}runControl(t){if(!this._squire||typeof t.run!="function"||t.isDisabled?.(this))return;this.restoreSelection(),t.mutates!==!1&&this.ensureRootIsEditable();let n=t.run(this);this.element.querySelectorAll("pre:not([data-richclay-pre])").forEach(i=>{this._authoredPres.has(i)||i.setAttribute("data-richclay-pre","")}),t.mutates!==!1&&(this.ensureRootIsEditable(),this.anchorSelectionInBlock()),this.saveSelection(),this.toolbar?.update(),this.updatePlaceholder(),this.announceControl(t),n!==Lo&&this.focus(),this.warnOnBlockInInlineRegion()}anchorSelectionInBlock(){let t=rt(this._squire);if(!t?.collapsed||t.startContainer!==this.element)return;let n=Array.from(this.element.childNodes),i=t.startOffset>=n.length,r=i?n.filter(it).pop():n.slice(t.startOffset).find(it)||n.slice(0,t.startOffset).filter(it).pop();if(!r)return;let o=St(r,!i);t.setStart(o,i?Kt(o):0),t.collapse(!0),en(this._squire,t)}selectionHasFormat(t){if(!t||!this._squire?.hasFormat)return!1;try{return this._squire.hasFormat(t)}catch{return!1}}pathHas(t){let n=rt(this._squire);if(!n)return!1;let i=t.toLowerCase(),r=Oo(this.element,n.startContainer,n.startOffset,!0,i);return!!r&&r===Oo(this.element,n.endContainer,n.endOffset,!1,i)}blocksStayOut(){return this.options.singleLine||Yt(this.element)||qr(this.element)}warnOnBlockInInlineRegion(){if(this._warnedInlineBlock||!Xt(this.element)||!Qt(this.element))return;this._warnedInlineBlock=!0;let t=this.element.nodeName.toLowerCase();console.warn(`richclay: a block element inside <${t} editable> is not valid HTML. It stays where it is and saves correctly, but a validator will flag it. Put the editable attribute on a block element if you want blocks here.`,this.element)}toggleFormat(t,n,i){return this.selectionHasFormat(t)?this._squire[i]():this._squire[n]()}toggleList(t){return this.pathHas(t)?this._squire.removeList():t==="UL"?this._squire.makeUnorderedList():this._squire.makeOrderedList()}indent(){return this.pathHas("UL")||this.pathHas("OL")?this._squire.increaseListLevel():this._squire.increaseQuoteLevel()}outdent(){return this.pathHas("UL")||this.pathHas("OL")?this._squire.decreaseListLevel():this._squire.decreaseQuoteLevel()}setBlockType(t){let n=t.toUpperCase();return n==="BLOCKQUOTE"?this._squire.increaseQuoteLevel():this._squire.modifyBlocks(i=>{let r=this.element.ownerDocument,o=r.createDocumentFragment();return Array.from(i.childNodes).forEach(s=>{if(s.nodeType!==1){o.appendChild(s);return}if(s.nodeName===n){o.appendChild(s);return}let a=r.createElement(n);for(;s.firstChild;)a.appendChild(s.firstChild);o.appendChild(a)}),o})}openLinkDialog(){this.saveSelection(),this.closeLinkDialog();let t=this.element.ownerDocument,n=this.currentLinkHref(),i=t.createElement("form"),r=`richclay-link-label-${++Ro}`;i.className="richclay-dialog",i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-labelledby",r),i.setAttribute("data-richclay-dialog",""),ye(i),i.innerHTML=`
|
|
31
|
+
`).replace(/^\n|\n$/g,"")}function Sl(e,t,n=null){let i=fi(e,{capability:"history",inherit:!1}),r=i.root,o=(a,l)=>{for(;a&&!i.cloneOf(a);){let h=a.parentNode;if(!h)return{container:r,offset:0};l=Array.from(h.childNodes).indexOf(a),a=h}let u=i.cloneOf(a)||r;if(a?.nodeType===3)return{container:u,offset:Math.min(l,u.length)};let d=Array.from(a?.childNodes||[]).slice(0,l).filter(h=>i.cloneOf(h)).length;return{container:u,offset:Math.min(d,u.childNodes.length)}},s=(a,l,u)=>{let d=o(l,u),h=r.ownerDocument.createElement("input");h.id=a,h.type="hidden";let p=r.ownerDocument.createRange();p.setStart(d.container,d.offset),p.collapse(!0),p.insertNode(h)};if(n)s(t.endSelectionId,n.endContainer,n.endOffset),s(t.startSelectionId,n.startContainer,n.startOffset);else for(let a of[t.startSelectionId,t.endSelectionId]){if(r.querySelector(`#${a}`))continue;let l=e.querySelector(`#${a}`);l&&s(a,l.parentNode,Array.from(l.parentNode.childNodes).indexOf(l))}return r.innerHTML}var Ae=new WeakMap,vo=new WeakSet,Co=new WeakSet,pi=Ir(),No=Symbol("richclay-keep-focus"),Lo=["cut","paste","drop"],Al=["Alt","Ctrl","Meta","Shift"],wo=0,vl={toolbar:"standard",toolbarContainer:null,sanitize:{},placeholder:"",readOnly:!1,hyperclay:"auto",onChange:null,Squire:null,inline:!1,singleLine:!1,toolbarOnSelect:!1},Ve=class e{static presets=_t;static selector=ce;constructor(t,n={}){if(!t)throw new Error("RichClay requires an element.");let i=Ae.get(t);if(i)return i;this.element=t,this.unsupported=mi(t)||Ll(t);let r={...to(t),...n};this.options={...vl,...r},this.options.singleLine&&!("toolbar"in r)&&(this.options.toolbar="inline"),this._blockTag=this.options.inline?"DIV":"P",this.registry=new Map(pi),this.toolbar=null,this.float=null,this._onToolbarKey=null,this._onFloatFocusOut=null,this._onDocPointerDown=null,this.liveRegion=null,this.description=null,this.dialog=null,this.dialogCleanup=null,this.savedSelection=null,this.path="",this.active=!1,this._squire=null,this._squireListeners=[],this._onBeforeInput=null,this._onRootBeforeInput=null,this._onRootKeydown=null,this._onRootTransfer=null,this._shortcutKeys=[],this._appleDeleteKeys=new Set,this._authoredPres=new WeakSet,this._warnedInlineBlock=!1,this._onFocus=()=>{this.element.classList.add("richclay-focused"),this.options.inline&&this.ensureFloatingToolbar()},this._onBlur=o=>{this.element.classList.remove("richclay-focused"),this.options.inline&&this.scheduleFloatTeardown(o)},this.ensureMarker(),this.hyperclay=Xt(this.options,this.window),this.hyperclay&&ei(this.window),Ae.set(t,this),this.sanitizeConfig=this.options.inline?po(this.options.sanitize):this.options.sanitize,this.sanitizer=ho(this.sanitizeConfig,this.element.ownerDocument),this.options.inline||si(this.element,this.sanitizeConfig),eo(this.options,this.window)&&this.activate()}get squire(){return this._squire}get window(){return this.element.ownerDocument.defaultView||window}static init(t=ce,n={}){let i=t===ce?Qn:()=>!0;return Cl(t).filter(i).filter(o=>!mi(o)).map(o=>new e(o,n))}static autoInit(t=typeof window<"u"?window:void 0){if(!t||!t.document||vo.has(t))return;vo.add(t);let n=()=>{Xt({},t)&&Jn(t)&&(e.init(),e.watch(t))};t.document.readyState==="loading"?t.document.addEventListener("DOMContentLoaded",n,{once:!0}):n()}static watch(t=typeof window<"u"?window:void 0,n={}){if(!t||!t.document||Co.has(t))return;Co.add(t);let i=s=>{Lt(s)&&!Ae.has(s)&&!mi(s)&&new e(s,n)},r=s=>Ae.get(s)?.destroy();new t.MutationObserver(s=>{s.forEach(a=>{if(a.type==="attributes"){let l=a.target;Lt(l)?i(l):r(l);return}a.addedNodes.forEach(l=>{l.nodeType===1&&(l.matches?.(ce)&&i(l),l.querySelectorAll?.(ce).forEach(i))}),a.removedNodes.forEach(l=>{if(l.nodeType!==1)return;let u=d=>{d.isConnected||Ae.get(d)?.destroy()};l.matches?.(ce)&&u(l),l.querySelectorAll?.(ce).forEach(u)})})}).observe(t.document.documentElement||t.document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["editable","clay-editable","data-richclay","richclay"]})}static registerButton(t){return gi(t),pi.set(t.id,t),e}static unregisterButton(t){return pi.delete(t),e}static stripFromClone(t){ti(t)}static stripElement(t){if(!t||typeof t.getAttribute!="function")return;let n=Ae.get(t);if(n){n.destroy();return}Qt(t,"destroy")}registerButton(t){return gi(t),this.registry.set(t.id,t),this.active&&this.renderToolbar(),this}unregisterButton(t){return this.registry.delete(t),this.active&&this.renderToolbar(),this}activate(){if(this.unsupported||this.active)return;this.active=!0,this.applyInlineBox(),bo(this.element.ownerDocument),ni(this.element);let t=this.options.inline?Array.from(this.element.childNodes):null,n=this.options.inline?null:this.element.innerHTML,i=this.options.Squire||this.window.Squire||globalThis.Squire;if(!i)throw new Error("RichClay requires Squire. Load vendor/squire.js before richclay.js.");if(this.setupEditorAttributes(),this.liveRegion=io(this.element.ownerDocument),this._squire=new i(this.element,{blockTag:this._blockTag,serializeRoot:Sl,willCutCopy:r=>Do(r,this.element.ownerDocument),toPlainText:r=>El(r,this.element.ownerDocument),replaceRoot:(r,o,s)=>{let a=this.window.clay?.morph||this.window.hyperclay?.morph;if(typeof a!="function"){if(r.querySelector('[editor-ui], [clay~="editor-ui"]'))throw new Error("RichClay requires a retention-aware morph host to replay history containing editor-ui.");r.innerHTML=o;return}a(r,o,{morphStyle:"innerHTML",restoreFocus:!1,scripts:{handle:!1,merge:!1},policy:"history"}),s._ensureBottomLine(),s._mutation?.takeRecords()},onMutations:(r,o)=>{let s=(u,d)=>{let h=hi(u,d);return!!h&&h!==this.element&&this.element.contains(h)},a=!1,l=!1;for(let u of r){if(s(u.target,"history"))continue;let d=u.type==="childList"?[...u.addedNodes,...u.removedNodes]:[u.target];for(let h of d)s(h,"history")||(s(u.target,"undo")||s(h,"undo")?l=!0:a=!0)}if(a){let u=o._ignoreChange;o._docWasChanged(),l&&u&&o.fireEvent("input")}else l?(o._mayHaveZWS=!0,o.fireEvent("input")):o._ignoreChange=!1},sanitizeToDOMFragment:(r,o)=>{let s=this.sanitizer.sanitizeToDOMFragment(Oo(r,this.element.ownerDocument),o);return this.options.singleLine?mo(s):s},didError:r=>{console.error("RichClay/Squire error",r)}}),this.options.inline?(this.element.replaceChildren(...t),this.resetSquireUndoBaseline()):this._squire.setHTML(n),this.bindSquire(),this.options.singleLine&&this.installSingleLineGuards(),this.options.inline&&!this.options.singleLine&&this.installRootGuards(),this.installAppleDeleteKeys(),this.blocksStayOut()&&(this._squire._ensureBottomLine=()=>{}),this.maskSquireCodeShortcut(),this.maskSquireBlockShortcuts(),this.installShortcuts(),this.options.inline&&(this._onToolbarKey=r=>{r.altKey&&r.key==="F10"&&(r.preventDefault(),this.ensureFloatingToolbar(),this.float?.toolbar.focusFirst())},this.element.addEventListener("keydown",this._onToolbarKey)),this.blocksStayOut()){let r=o=>{let s=o.detail?.fragment;if(!s)return;let a=this.element.ownerDocument;vt(s,()=>this.options.singleLine?a.createTextNode(" "):a.createElement("br"))};this._squire.addEventListener("willPaste",r),this._squireListeners.push(["willPaste",r])}this.renderToolbar(),this.updatePlaceholder(),this.warnOnBlockInInlineRegion(),this.element.querySelectorAll("pre").forEach(r=>this._authoredPres.add(r))}reattach(){return this.unsupported||!this.active||this.element.getAttribute("contenteditable")==="true"&&this.element.getAttribute("data-richclay-active")==="true"&&Lt(this.element)?!1:(this.ensureMarker(),this.applyInlineBox(),ni(this.element),this.setupEditorAttributes(),!0)}applyInlineBox(){Zt(this.element)&&!this.element.style.display&&(this.element.style.display="inline-block",this.element.setAttribute("data-richclay-runtime-display","true"))}getHTML(){return this._squire?this._squire.getHTML():this.element.innerHTML}setHTML(t){return this._squire?this._squire.setHTML(String(t||"")):this.element.innerHTML=oi(t,this.sanitizeConfig,this.element.ownerDocument),this.updatePlaceholder(),this.toolbar?.update(),this.options.onChange?.(this.getHTML()),this}focus(){return this._squire?this._squire.focus():this.element.focus(),this}destroy(){this.closeLinkDialog(),this.teardownFloatingToolbar(),this.toolbar?.destroy(),this.toolbar=null,this._onToolbarKey&&(this.element.removeEventListener("keydown",this._onToolbarKey),this._onToolbarKey=null),this.liveRegion?.remove(),this.liveRegion=null,this.description?.remove(),this.description=null,this._shortcutKeys.forEach(n=>this._squire?.setKeyHandler?.(n,null)),this._squireListeners.forEach(([n,i])=>{this._squire?.removeEventListener?.(n,i)}),this._squireListeners=[],this._shortcutKeys=[],this._onBeforeInput&&(this.element.ownerDocument.removeEventListener("beforeinput",this._onBeforeInput,!0),this._onBeforeInput=null);let t=this.element.ownerDocument;this._onRootBeforeInput&&(t.removeEventListener("beforeinput",this._onRootBeforeInput,!0),this._onRootBeforeInput=null),this._onRootKeydown&&(t.removeEventListener("keydown",this._onRootKeydown,!0),this._onRootKeydown=null),this._onRootTransfer&&(Lo.forEach(n=>t.removeEventListener(n,this._onRootTransfer,!0)),this._onRootTransfer=null),this._squire?.destroy?.(),this._squire=null,this.cleanupEditorAttributes(),Ae.delete(this.element)}saveSelection(){return this.savedSelection=rt(this._squire)||this.savedSelection,this.savedSelection}restoreSelection(){return Jt(this._squire,this.savedSelection)}installRootGuards(){let t=this.element.ownerDocument,n=i=>this.element.contains(i.target);this._onRootBeforeInput=i=>{!n(i)||i.isComposing||/^history/.test(i.inputType||"")||this.ensureRootIsEditable()},this._onRootKeydown=i=>{!n(i)||i.defaultPrevented||i.isComposing||this.isEditingKey(i)&&this.ensureRootIsEditable()},this._onRootTransfer=i=>{n(i)&&this.ensureRootIsEditable()},t.addEventListener("beforeinput",this._onRootBeforeInput,!0),t.addEventListener("keydown",this._onRootKeydown,!0),Lo.forEach(i=>{t.addEventListener(i,this._onRootTransfer,!0)})}ensureRootIsEditable(){if(!this._squire||this.options.singleLine)return;let t=this.options.inline,n=!this.blocksStayOut();if(!Gr(this.element,{wrapBareRoot:t,blocksAllowed:n}))return;let i=rt(this._squire),r=i?jr(this.element,i):null,o=()=>{Vr(this.element,{blockTag:this._blockTag,wrapBareRoot:t,blocksAllowed:n,onBareRootWrapped:(s,a)=>{console.warn(`richclay: wrapped this region's loose text in a <div> so multi-line editing works. Wrap the content in your own block element to keep the markup you wrote, or use editable="single-line" if it is meant to be one line.`,s,a)}})};typeof this._squire.modifyDocument=="function"?this._squire.modifyDocument(o):o(),r&&(Zr(this.element,i,r),Jt(this._squire,i),this.savedSelection=ri(i))}isEditingKey(t){return["Backspace","Delete","Enter"].includes(t.key)?!0:t.key==="Tab"?this.caretIsInList():t.key.length!==1?!1:!t.ctrlKey&&!t.metaKey&&!t.altKey?!0:t.ctrlKey&&!t.metaKey&&!t.altKey&&this._appleDeleteKeys.has(t.key.toLowerCase())}caretIsInList(){let n=this._squire?.getSelection()?.startContainer;if(!n)return!1;let i=n.nodeType===1?n:n.parentElement;return!!(i&&this.element.contains(i)&&i.closest("ul, ol"))}runControl(t){if(!this._squire||typeof t.run!="function"||t.isDisabled?.(this))return;this.restoreSelection(),t.mutates!==!1&&this.ensureRootIsEditable();let n=t.run(this);this.element.querySelectorAll("pre:not([data-richclay-pre])").forEach(i=>{this._authoredPres.has(i)||i.setAttribute("data-richclay-pre","")}),t.mutates!==!1&&(this.ensureRootIsEditable(),this.anchorSelectionInBlock()),this.saveSelection(),this.toolbar?.update(),this.updatePlaceholder(),this.announceControl(t),n!==No&&this.focus(),this.warnOnBlockInInlineRegion()}anchorSelectionInBlock(){let t=rt(this._squire);if(!t?.collapsed||t.startContainer!==this.element)return;let n=Array.from(this.element.childNodes),i=t.startOffset>=n.length,r=i?n.filter(it).pop():n.slice(t.startOffset).find(it)||n.slice(0,t.startOffset).filter(it).pop();if(!r)return;let o=Et(r,!i);t.setStart(o,i?Gt(o):0),t.collapse(!0),Jt(this._squire,t)}selectionHasFormat(t){if(!t||!this._squire?.hasFormat)return!1;try{return this._squire.hasFormat(t)}catch{return!1}}pathHas(t){let n=rt(this._squire);if(!n)return!1;let i=t.toLowerCase(),r=xo(this.element,n.startContainer,n.startOffset,!0,i);return!!r&&r===xo(this.element,n.endContainer,n.endOffset,!1,i)}blocksStayOut(){return this.options.singleLine||jt(this.element)||Hr(this.element)}warnOnBlockInInlineRegion(){if(this._warnedInlineBlock||!Zt(this.element)||!Yt(this.element))return;this._warnedInlineBlock=!0;let t=this.element.nodeName.toLowerCase();console.warn(`richclay: a block element inside <${t} editable> is not valid HTML. It stays where it is and saves correctly, but a validator will flag it. Put the editable attribute on a block element if you want blocks here.`,this.element)}toggleFormat(t,n,i){return this.selectionHasFormat(t)?this._squire[i]():this._squire[n]()}toggleList(t){return this.pathHas(t)?this._squire.removeList():t==="UL"?this._squire.makeUnorderedList():this._squire.makeOrderedList()}indent(){return this.pathHas("UL")||this.pathHas("OL")?this._squire.increaseListLevel():this._squire.increaseQuoteLevel()}outdent(){return this.pathHas("UL")||this.pathHas("OL")?this._squire.decreaseListLevel():this._squire.decreaseQuoteLevel()}setBlockType(t){let n=t.toUpperCase();return n==="BLOCKQUOTE"?this._squire.increaseQuoteLevel():this._squire.modifyBlocks(i=>{let r=this.element.ownerDocument,o=r.createDocumentFragment();return Array.from(i.childNodes).forEach(s=>{if(s.nodeType!==1){o.appendChild(s);return}if(s.nodeName===n){o.appendChild(s);return}let a=r.createElement(n);for(;s.firstChild;)a.appendChild(s.firstChild);o.appendChild(a)}),o})}openLinkDialog(){this.saveSelection(),this.closeLinkDialog();let t=this.element.ownerDocument,n=this.currentLinkHref(),i=t.createElement("form"),r=`richclay-link-label-${++wo}`;i.className="richclay-dialog",i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-labelledby",r),i.setAttribute("data-richclay-dialog",""),ge(i),i.setAttribute("save-remove",""),i.innerHTML=`
|
|
32
32
|
<div class="richclay-dialog-title" id="${r}">${n?"Edit link":"Insert link"}</div>
|
|
33
33
|
<label class="richclay-field">
|
|
34
34
|
<span>URL</span>
|
|
@@ -38,7 +38,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
38
38
|
<button type="button" class="richclay-secondary" data-richclay-cancel>Cancel</button>
|
|
39
39
|
<button type="submit" class="richclay-primary">Apply</button>
|
|
40
40
|
</div>
|
|
41
|
-
`;let o=()=>{this.closeLinkDialog(),this.toolbar?.update(),this.focus()};i.addEventListener("submit",l=>{l.preventDefault();let u=new FormData(i),d=mo(u.get("url"));if(!d){xt(this.liveRegion,"Enter a valid URL");return}this.restoreSelection();let f=this.currentLinkElement();f&&this.selectElement(f),this._squire.makeLink(d),xt(this.liveRegion,"Link applied"),o()}),i.querySelector("[data-richclay-cancel]").addEventListener("click",o),i.addEventListener("keydown",l=>{l.key==="Escape"?(l.preventDefault(),o()):l.key==="Tab"&&wl(l,i)}),(this.toolbar?.root||this.element).insertAdjacentElement("afterend",i),this.dialog=i;let a=i.querySelector("input");return a.value=n,a.focus(),a.select(),Lo}currentLinkElement(){let n=rt(this._squire)?.commonAncestorContainer||null;return n&&n.nodeType!==1&&(n=n.parentElement),n?.closest?.("a[href]")||null}currentLinkHref(){let t=this.currentLinkElement();return t&&t.getAttribute("href")||""}selectElement(t){let n=t.ownerDocument.createRange();return n.selectNode(t),this._squire.setSelection(n),this.saveSelection(),n}closeLinkDialog(){this.dialog?.remove(),this.dialog=null}ensureMarker(){Lt(this.element)||(this.element.setAttribute("data-richclay-runtime-marker","true"),this.element.setAttribute("data-richclay",""))}setupEditorAttributes(){if(this.element.classList.add(this.options.inline?"richclay-inline":"richclay-editor","richclay-active"),this.element.setAttribute("data-richclay-active","true"),!this.element.hasAttribute("data-richclay-runtime-contenteditable")){let t=this.element.getAttribute("contenteditable");t===null?this.element.setAttribute("data-richclay-runtime-contenteditable","true"):t!=="true"&&t!==""&&this.element.setAttribute("data-richclay-runtime-contenteditable",t)}this.element.setAttribute("contenteditable","true"),this.element.hasAttribute("role")||tn(this.element,"role","textbox","data-richclay-runtime-role"),this.element.hasAttribute("aria-multiline")||tn(this.element,"aria-multiline",this.options.singleLine?"false":"true","data-richclay-runtime-aria-multiline"),this.element.hasAttribute("no-undo")||tn(this.element,"no-undo","","data-richclay-runtime-no-undo"),this.options.placeholder&&(this.element.setAttribute("data-richclay-placeholder",this.options.placeholder),this.description||(this.description=this.element.ownerDocument.createElement("div"),this.description.id=`richclay-placeholder-${++Ro}`,this.description.className="richclay-sr-only",this.description.textContent=this.options.placeholder,this.description.setAttribute("data-richclay-live",""),ye(this.description)),this.description.isConnected||this.element.insertAdjacentElement("afterend",this.description),ao(this.element,this.description)),this.element.addEventListener("focus",this._onFocus),this.element.addEventListener("blur",this._onBlur)}cleanupEditorAttributes(){Jt(this.element,"destroy"),this.element.removeEventListener("focus",this._onFocus),this.element.removeEventListener("blur",this._onBlur)}bindSquire(){let t=()=>{this.saveSelection(),this.updatePlaceholder(),this.options.onChange?.(this.getHTML()),this.toolbar?.update()},n=o=>{this.path=o.detail?.path||this._squire.getPath?.()||"",this.saveSelection(),this.toolbar?.update()},i=()=>{this.saveSelection(),this.toolbar?.update(),this.options.toolbarOnSelect&&this.updateFloatVisibility()};[["input",t],["pathChange",n],["select",i],["cursor",i],["undoStateChange",()=>this.toolbar?.update()]].forEach(([o,s])=>{this._squire.addEventListener(o,s),this._squireListeners.push([o,s])})}renderToolbar(){if(!this.active||this.options.readOnly)return;if(this.options.inline){this.float&&(this.teardownFloatingToolbar(),this.ensureFloatingToolbar());return}this.toolbar?.destroy(),this.toolbar=null;let t=this.resolveToolbarControls(this.options.toolbar);t.length&&(this.toolbar=new ot(this,t,{toolbarContainer:this.options.toolbarContainer}))}ensureFloatingToolbar(){if(this.float||!this.active||this.options.readOnly)return;let t=this.resolveToolbarControls(this.options.toolbar);t.length&&(this.float=new nn(this,t),this._onFloatFocusOut=n=>this.scheduleFloatTeardown(n),this.float.root.addEventListener("focusout",this._onFloatFocusOut),this._onDocPointerDown=n=>{if(this.ownsFocusTarget(n.target))return;let i=this.element.ownerDocument;i.activeElement&&this.ownsFocusTarget(i.activeElement)&&i.activeElement.blur?.(),this.teardownFloatingToolbar()},this.element.ownerDocument.addEventListener("pointerdown",this._onDocPointerDown,!0),this.toolbar=this.float.toolbar,this.toolbar.update(),this.options.toolbarOnSelect&&this.updateFloatVisibility())}teardownFloatingToolbar(){this.float&&(this._onFloatFocusOut&&(this.float.root.removeEventListener("focusout",this._onFloatFocusOut),this._onFloatFocusOut=null),this._onDocPointerDown&&(this.element.ownerDocument.removeEventListener("pointerdown",this._onDocPointerDown,!0),this._onDocPointerDown=null),this.float.destroy(),this.float=null,this.toolbar=null)}scheduleFloatTeardown(t){let n=t?.relatedTarget;if(n&&this.ownsFocusTarget(n))return;let i=this.element.ownerDocument;(i.defaultView||globalThis).setTimeout(()=>{let o=i.activeElement;o&&this.ownsFocusTarget(o)||this.teardownFloatingToolbar()},0)}ownsFocusTarget(t){return t===this.element||this.element.contains(t)||!!this.float?.root.contains(t)||!!this.dialog?.contains(t)}updateFloatVisibility(){if(!this.float)return;let t=this.savedSelection;this.float.setVisible(!!(t&&!t.collapsed))}resolveToolbarControls(t){return t===!1||t===null||t==="none"?[]:(Array.isArray(t)?t:Et[t]||Et.standard).map(i=>{if(typeof i=="string"){let r=this.registry.get(i);if(!r)throw new Error(`Unknown RichClay toolbar control: ${i}`);return r}return i?.type==="separator"||bi(i),i})}installShortcuts(){let t=new Set,n=[...this.registry.values()].filter(r=>!this.options.singleLine||Et.inline.includes(r.id));[...this.resolveToolbarControls(this.options.toolbar),...n].forEach(r=>{if(r.type==="menu"||r.type==="separator"||!r.shortcut||!r.id||t.has(r.id))return;if(r.isDisabled?.(this)){let s=ko(r.shortcut,this.window);this._squire.setKeyHandler(s,null),this._shortcutKeys.push(s);return}t.add(r.id);let o=ko(r.shortcut,this.window);this._squire.setKeyHandler(o,(s,a)=>{a.preventDefault(),this.runControl(r)}),this._shortcutKeys.push(o)})}maskSquireCodeShortcut(){let t=`${nt(this.window)?"Meta":"Ctrl"}-d`;this._squire.setKeyHandler(t,null),this._shortcutKeys.push(t)}maskSquireBlockShortcuts(){if(!this.blocksStayOut())return;let t=nt(this.window)?"Meta":"Ctrl";[`${t}-]`,`${t}-[`,`${t}-Shift-8`,`${t}-Shift-9`].forEach(n=>{this._squire.setKeyHandler(n,null),this._shortcutKeys.push(n)})}toggleCode(){return this.blocksStayOut()?this.selectionHasFormat("CODE")?this._squire.changeFormat(null,{tag:"CODE"}):this._squire.changeFormat({tag:"CODE"},null):this._squire.toggleCode()}installAppleDeleteKeys(){if(!nt(this.window))return;let t=this._squire._keyHandlers;t&&[["Ctrl-d","Delete"],["Ctrl-h","Backspace"]].forEach(([n,i])=>{typeof t[i]=="function"&&(this._squire.setKeyHandler(n,t[i]),this._shortcutKeys.push(n),this._appleDeleteKeys.add(n.slice(5)))})}installSingleLineGuards(){["Enter","Shift-Enter"].forEach(t=>{this._squire.setKeyHandler(t,(n,i)=>i.preventDefault()),this._shortcutKeys.push(t)}),this._onBeforeInput=t=>{this.element.contains(t.target)&&(t.inputType==="insertParagraph"||t.inputType==="insertLineBreak")&&(t.preventDefault(),t.stopPropagation())},this.element.ownerDocument.addEventListener("beforeinput",this._onBeforeInput,!0)}resetSquireUndoBaseline(){let t=this._squire;!t||!Array.isArray(t._undoStack)||typeof t.saveUndoState!="function"||(t._undoStack.length=0,t._undoStackLength=0,t._undoIndex=-1,t._isInUndoState=!1,t.saveUndoState())}updatePlaceholder(){let t=mi(this.element,{capability:"history",inherit:!1}),n=t.text().replace(/\u200B/g,"").trim(),i=t.root.querySelector("img, video, audio, iframe, table"),r=!n&&!i;this.element.classList.toggle("richclay-empty",r)}announceControl(t){if(!this.liveRegion)return;let n=t.ariaLabel||t.label;n&&(typeof t.isActive=="function"?xt(this.liveRegion,`${n} ${t.isActive(this)?"on":"off"}`):xt(this.liveRegion,`${n} applied`))}};function Cl(e){return typeof e=="string"?Array.from(document.querySelectorAll(e)):e?.nodeType===1?[e]:Array.from(e||[])}function Oo(e,t,n,i,r){let o=t;if(o===e){let l=Array.from(e.childNodes).filter(it);if(!l.length)return null;let u=Math.min(i?n:Math.max(n-1,0),l.length-1);o=St(l[u],i)}let a=(o?.nodeType===1?o:o?.parentElement)?.closest?.(r);return a&&e.contains(a)&&a!==e?a:null}function xl(e){let t=e.parentElement;for(;t;){if(Ae.has(t)||Lt(t))return t;t=t.parentElement}return null}function Lt(e){return!!e.matches?.(ue)&&ei(e)}function yi(e){let t=xl(e),n=Array.from(e.querySelectorAll?.(ue)||[]).find(r=>Ae.has(r)),i=t||n;return i?(console.warn("richclay: nested editable regions are not supported, so this one was skipped. Remove the editable attribute from either it or the other region.",e,i),!0):!1}function Nl(e){return Gr(e)?(console.warn(`richclay: ${Kr(e)} This region was skipped.`,e),!0):!1}function bi(e){if(!e||!e.id)throw new Error("RichClay button definitions require an id.");if(e.type!=="menu"&&typeof e.run!="function")throw new Error(`RichClay button "${e.id}" requires a run(editor) function.`)}function ko(e,t){let n=e.split("+"),i=n[n.length-1],r=new Set(n.slice(0,-1).map(Ll));r.delete("Mod")&&r.add(nt(t)?"Meta":"Ctrl");let o=i.length===1?r.has("Shift")?i.toUpperCase():i.toLowerCase():i,s=Al.filter(a=>r.has(a)).join("-");return`${s?`${s}-`:""}${o}`}function Ll(e){return e==="Cmd"?"Meta":e}function wl(e,t){let n=t.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(!n.length)return;let i=n[0],r=n[n.length-1],o=t.ownerDocument.activeElement;e.shiftKey&&o===i?(e.preventDefault(),r.focus()):!e.shiftKey&&o===r&&(e.preventDefault(),i.focus())}var Mo=`:root {
|
|
41
|
+
`;let o=()=>{this.closeLinkDialog(),this.toolbar?.update(),this.focus()};i.addEventListener("submit",y=>{y.preventDefault();let _=new FormData(i),C=fo(_.get("url"));if(!C){Ct(this.liveRegion,"Enter a valid URL");return}this.restoreSelection();let v=this.currentLinkElement();v&&this.selectElement(v),this._squire.makeLink(C),Ct(this.liveRegion,"Link applied"),o()}),i.querySelector("[data-richclay-cancel]").addEventListener("click",o),i.addEventListener("keydown",y=>{y.key==="Escape"?(y.preventDefault(),o()):y.key==="Tab"&&xl(y,i)});let s=this.element.closest("dialog")||t.body,a=typeof i.showPopover=="function";a&&i.setAttribute("popover","manual"),ye(i,"position","fixed"),ye(i,"inset","0px auto auto 0px"),ye(i,"margin","0"),ye(i,"overflow","visible"),s.appendChild(i),a&&i.showPopover(),this.dialog=i;let l=t.defaultView||globalThis,u=()=>this.positionLinkDialog(),d=y=>{i.contains(y.target)||this.closeLinkDialog()},h=typeof l.ResizeObserver=="function"?new l.ResizeObserver(u):null;h?.observe(i),t.addEventListener("scroll",u,{capture:!0,passive:!0}),l.addEventListener("resize",u,{passive:!0}),l.visualViewport?.addEventListener("resize",u,{passive:!0}),l.visualViewport?.addEventListener("scroll",u,{passive:!0}),t.addEventListener("pointerdown",d,!0),this.dialogCleanup=()=>{h?.disconnect(),t.removeEventListener("scroll",u,{capture:!0}),l.removeEventListener("resize",u),l.visualViewport?.removeEventListener("resize",u),l.visualViewport?.removeEventListener("scroll",u),t.removeEventListener("pointerdown",d,!0)},this.positionLinkDialog();let p=i.querySelector("input");return p.value=n,p.focus(),p.select(),No}currentLinkElement(){let n=rt(this._squire)?.commonAncestorContainer||null;return n&&n.nodeType!==1&&(n=n.parentElement),n?.closest?.("a[href]")||null}currentLinkHref(){let t=this.currentLinkElement();return t&&t.getAttribute("href")||""}selectElement(t){let n=t.ownerDocument.createRange();return n.selectNode(t),this._squire.setSelection(n),this.saveSelection(),n}linkAnchorRect(){let t=this.savedSelection;if(typeof t?.getClientRects=="function"){let i=[...t.getClientRects()].filter(r=>r.width||r.height);if(i.length)return t.collapsed?i[0]:t.getBoundingClientRect()}return(this.toolbar?.items.find(i=>i.def.id==="link")?.button||this.toolbar?.root||this.element).getBoundingClientRect()}positionLinkDialog(){let t=this.dialog;if(!t)return;let n=t.ownerDocument.defaultView||globalThis,i=lo({anchor:this.linkAnchorRect(),box:{width:t.offsetWidth||0,height:t.offsetHeight||0},viewport:{width:n.visualViewport?.width??n.innerWidth,height:n.visualViewport?.height??n.innerHeight}});t.setAttribute("data-richclay-side",i.side),t.style.setProperty("--richclay-dialog-arrow",`${Math.round(i.arrow)}px`),ye(t,"transform",`translate(${Math.round(i.x)}px, ${Math.round(i.y)}px)`)}closeLinkDialog(){this.dialogCleanup?.(),this.dialogCleanup=null,this.dialog?.remove(),this.dialog=null}ensureMarker(){Lt(this.element)||(this.element.setAttribute("data-richclay-runtime-marker","true"),this.element.setAttribute("data-richclay",""))}setupEditorAttributes(){if(this.element.classList.add(this.options.inline?"richclay-inline":"richclay-editor","richclay-active"),this.element.setAttribute("data-richclay-active","true"),!this.element.hasAttribute("data-richclay-runtime-contenteditable")){let t=this.element.getAttribute("contenteditable");t===null?this.element.setAttribute("data-richclay-runtime-contenteditable","true"):t!=="true"&&t!==""&&this.element.setAttribute("data-richclay-runtime-contenteditable",t)}this.element.setAttribute("contenteditable","true"),this.element.hasAttribute("role")||en(this.element,"role","textbox","data-richclay-runtime-role"),this.element.hasAttribute("aria-multiline")||en(this.element,"aria-multiline",this.options.singleLine?"false":"true","data-richclay-runtime-aria-multiline"),this.element.hasAttribute("no-undo")||en(this.element,"no-undo","","data-richclay-runtime-no-undo"),this.options.placeholder&&(this.element.setAttribute("data-richclay-placeholder",this.options.placeholder),this.description||(this.description=this.element.ownerDocument.createElement("div"),this.description.id=`richclay-placeholder-${++wo}`,this.description.className="richclay-sr-only",this.description.textContent=this.options.placeholder,this.description.setAttribute("data-richclay-live",""),ge(this.description)),this.description.isConnected||this.element.insertAdjacentElement("afterend",this.description),ro(this.element,this.description)),this.element.addEventListener("focus",this._onFocus),this.element.addEventListener("blur",this._onBlur)}cleanupEditorAttributes(){Qt(this.element,"destroy"),this.element.removeEventListener("focus",this._onFocus),this.element.removeEventListener("blur",this._onBlur)}bindSquire(){let t=()=>{this.saveSelection(),this.updatePlaceholder(),this.options.onChange?.(this.getHTML()),this.toolbar?.update()},n=o=>{this.path=o.detail?.path||this._squire.getPath?.()||"",this.saveSelection(),this.toolbar?.update()},i=()=>{this.saveSelection(),this.toolbar?.update(),this.options.toolbarOnSelect&&this.updateFloatVisibility()};[["input",t],["pathChange",n],["select",i],["cursor",i],["undoStateChange",()=>this.toolbar?.update()]].forEach(([o,s])=>{this._squire.addEventListener(o,s),this._squireListeners.push([o,s])})}renderToolbar(){if(!this.active||this.options.readOnly)return;if(this.options.inline){this.float&&(this.teardownFloatingToolbar(),this.ensureFloatingToolbar());return}this.toolbar?.destroy(),this.toolbar=null;let t=this.resolveToolbarControls(this.options.toolbar);t.length&&(this.toolbar=new ot(this,t,{toolbarContainer:this.options.toolbarContainer}))}ensureFloatingToolbar(){if(this.float||!this.active||this.options.readOnly)return;let t=this.resolveToolbarControls(this.options.toolbar);t.length&&(this.float=new tn(this,t),this._onFloatFocusOut=n=>this.scheduleFloatTeardown(n),this.float.root.addEventListener("focusout",this._onFloatFocusOut),this._onDocPointerDown=n=>{if(this.ownsFocusTarget(n.target))return;let i=this.element.ownerDocument;i.activeElement&&this.ownsFocusTarget(i.activeElement)&&i.activeElement.blur?.(),this.teardownFloatingToolbar()},this.element.ownerDocument.addEventListener("pointerdown",this._onDocPointerDown,!0),this.toolbar=this.float.toolbar,this.toolbar.update(),this.options.toolbarOnSelect&&this.updateFloatVisibility())}teardownFloatingToolbar(){this.float&&(this._onFloatFocusOut&&(this.float.root.removeEventListener("focusout",this._onFloatFocusOut),this._onFloatFocusOut=null),this._onDocPointerDown&&(this.element.ownerDocument.removeEventListener("pointerdown",this._onDocPointerDown,!0),this._onDocPointerDown=null),this.float.destroy(),this.float=null,this.toolbar=null)}scheduleFloatTeardown(t){let n=t?.relatedTarget;if(n&&this.ownsFocusTarget(n))return;let i=this.element.ownerDocument;(i.defaultView||globalThis).setTimeout(()=>{let o=i.activeElement;o&&this.ownsFocusTarget(o)||this.teardownFloatingToolbar()},0)}ownsFocusTarget(t){return t===this.element||this.element.contains(t)||!!this.float?.root.contains(t)||!!this.dialog?.contains(t)}updateFloatVisibility(){if(!this.float)return;let t=this.savedSelection;this.float.setVisible(!!(t&&!t.collapsed))}resolveToolbarControls(t){return t===!1||t===null||t==="none"?[]:(Array.isArray(t)?t:_t[t]||_t.standard).map(i=>{if(typeof i=="string"){let r=this.registry.get(i);if(!r)throw new Error(`Unknown RichClay toolbar control: ${i}`);return r}return i?.type==="separator"||gi(i),i})}installShortcuts(){let t=new Set,n=[...this.registry.values()].filter(r=>!this.options.singleLine||_t.inline.includes(r.id));[...this.resolveToolbarControls(this.options.toolbar),...n].forEach(r=>{if(r.type==="menu"||r.type==="separator"||!r.shortcut||!r.id||t.has(r.id))return;if(r.isDisabled?.(this)){let s=Ro(r.shortcut,this.window);this._squire.setKeyHandler(s,null),this._shortcutKeys.push(s);return}t.add(r.id);let o=Ro(r.shortcut,this.window);this._squire.setKeyHandler(o,(s,a)=>{a.preventDefault(),this.runControl(r)}),this._shortcutKeys.push(o)})}maskSquireCodeShortcut(){let t=`${nt(this.window)?"Meta":"Ctrl"}-d`;this._squire.setKeyHandler(t,null),this._shortcutKeys.push(t)}maskSquireBlockShortcuts(){if(!this.blocksStayOut())return;let t=nt(this.window)?"Meta":"Ctrl";[`${t}-]`,`${t}-[`,`${t}-Shift-8`,`${t}-Shift-9`].forEach(n=>{this._squire.setKeyHandler(n,null),this._shortcutKeys.push(n)})}toggleCode(){return this.blocksStayOut()?this.selectionHasFormat("CODE")?this._squire.changeFormat(null,{tag:"CODE"}):this._squire.changeFormat({tag:"CODE"},null):this._squire.toggleCode()}installAppleDeleteKeys(){if(!nt(this.window))return;let t=this._squire._keyHandlers;t&&[["Ctrl-d","Delete"],["Ctrl-h","Backspace"]].forEach(([n,i])=>{typeof t[i]=="function"&&(this._squire.setKeyHandler(n,t[i]),this._shortcutKeys.push(n),this._appleDeleteKeys.add(n.slice(5)))})}installSingleLineGuards(){["Enter","Shift-Enter"].forEach(t=>{this._squire.setKeyHandler(t,(n,i)=>i.preventDefault()),this._shortcutKeys.push(t)}),this._onBeforeInput=t=>{this.element.contains(t.target)&&(t.inputType==="insertParagraph"||t.inputType==="insertLineBreak")&&(t.preventDefault(),t.stopPropagation())},this.element.ownerDocument.addEventListener("beforeinput",this._onBeforeInput,!0)}resetSquireUndoBaseline(){let t=this._squire;!t||!Array.isArray(t._undoStack)||typeof t.saveUndoState!="function"||(t._undoStack.length=0,t._undoStackLength=0,t._undoIndex=-1,t._isInUndoState=!1,t.saveUndoState())}updatePlaceholder(){let t=fi(this.element,{capability:"history",inherit:!1}),n=t.text().replace(/\u200B/g,"").trim(),i=t.root.querySelector("img, video, audio, iframe, table"),r=!n&&!i;this.element.classList.toggle("richclay-empty",r)}announceControl(t){if(!this.liveRegion)return;let n=t.ariaLabel||t.label;n&&(typeof t.isActive=="function"?Ct(this.liveRegion,`${n} ${t.isActive(this)?"on":"off"}`):Ct(this.liveRegion,`${n} applied`))}};function Cl(e){return typeof e=="string"?Array.from(document.querySelectorAll(e)):e?.nodeType===1?[e]:Array.from(e||[])}function xo(e,t,n,i,r){let o=t;if(o===e){let l=Array.from(e.childNodes).filter(it);if(!l.length)return null;let u=Math.min(i?n:Math.max(n-1,0),l.length-1);o=Et(l[u],i)}let a=(o?.nodeType===1?o:o?.parentElement)?.closest?.(r);return a&&e.contains(a)&&a!==e?a:null}function Nl(e){let t=e.parentElement;for(;t;){if(Ae.has(t)||Lt(t))return t;t=t.parentElement}return null}function Lt(e){return!!e.matches?.(ce)&&Qn(e)}function mi(e){let t=Nl(e),n=Array.from(e.querySelectorAll?.(ce)||[]).find(r=>Ae.has(r)),i=t||n;return i?(console.warn("richclay: nested editable regions are not supported, so this one was skipped. Remove the editable attribute from either it or the other region.",e,i),!0):!1}function Ll(e){return qr(e)?(console.warn(`richclay: ${Wr(e)} This region was skipped.`,e),!0):!1}function gi(e){if(!e||!e.id)throw new Error("RichClay button definitions require an id.");if(e.type!=="menu"&&typeof e.run!="function")throw new Error(`RichClay button "${e.id}" requires a run(editor) function.`)}function Ro(e,t){let n=e.split("+"),i=n[n.length-1],r=new Set(n.slice(0,-1).map(wl));r.delete("Mod")&&r.add(nt(t)?"Meta":"Ctrl");let o=i.length===1?r.has("Shift")?i.toUpperCase():i.toLowerCase():i,s=Al.filter(a=>r.has(a)).join("-");return`${s?`${s}-`:""}${o}`}function wl(e){return e==="Cmd"?"Meta":e}function xl(e,t){let n=t.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(!n.length)return;let i=n[0],r=n[n.length-1],o=t.ownerDocument.activeElement;e.shiftKey&&o===i?(e.preventDefault(),r.focus()):!e.shiftKey&&o===r&&(e.preventDefault(),i.focus())}var ko=`:root {
|
|
42
42
|
--richclay-surface: #ffffff;
|
|
43
43
|
--richclay-surface-alt: #f6f7f9;
|
|
44
44
|
--richclay-text: #0b0e14;
|
|
@@ -51,6 +51,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
51
51
|
--richclay-radius: 6px;
|
|
52
52
|
--richclay-control-size: 34px;
|
|
53
53
|
--richclay-shadow: 0 10px 24px rgb(15 23 42 / 0.16);
|
|
54
|
+
--richclay-dialog-arrow: 28px;
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
@media (prefers-color-scheme: dark) {
|
|
@@ -149,19 +150,6 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
149
150
|
opacity: 0.55;
|
|
150
151
|
}
|
|
151
152
|
|
|
152
|
-
/* Remove-link icon: the standard link glyph with a diagonal cut painted in the
|
|
153
|
-
button's own background colour, so the chain reads as severed in every state.
|
|
154
|
-
The cut tracks the background the button shows: the toolbar surface at rest,
|
|
155
|
-
the raised surface on hover. */
|
|
156
|
-
.richclay-cut {
|
|
157
|
-
stroke: var(--richclay-surface-alt);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
.richclay-button:hover .richclay-cut,
|
|
161
|
-
.richclay-button[aria-expanded="true"] .richclay-cut {
|
|
162
|
-
stroke: var(--richclay-surface);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
153
|
.richclay-separator {
|
|
166
154
|
align-self: stretch;
|
|
167
155
|
background: var(--richclay-border);
|
|
@@ -292,10 +280,6 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
292
280
|
margin-block: 0;
|
|
293
281
|
}
|
|
294
282
|
|
|
295
|
-
.richclay-float .richclay-dialog {
|
|
296
|
-
margin-block: 6px 0;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
283
|
/* Compact vertical rail for narrow margins. */
|
|
300
284
|
.richclay-float-rail .richclay-toolbar {
|
|
301
285
|
--richclay-control-size: 28px;
|
|
@@ -357,8 +341,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
357
341
|
color: var(--richclay-text);
|
|
358
342
|
display: grid;
|
|
359
343
|
gap: 10px;
|
|
360
|
-
|
|
361
|
-
|
|
344
|
+
box-sizing: border-box;
|
|
345
|
+
width: min(420px, calc(100vw - 16px));
|
|
346
|
+
z-index: 99999;
|
|
362
347
|
padding: 12px;
|
|
363
348
|
}
|
|
364
349
|
|
|
@@ -449,12 +434,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
449
434
|
.richclay-input:focus-visible {
|
|
450
435
|
outline-color: Highlight;
|
|
451
436
|
}
|
|
452
|
-
|
|
453
|
-
.richclay-cut {
|
|
454
|
-
stroke: Canvas;
|
|
455
|
-
}
|
|
456
437
|
}
|
|
457
|
-
`;var st=typeof globalThis<"u"?globalThis:self;st&&!st.Squire&&(st.Squire=
|
|
438
|
+
`;var st=typeof globalThis<"u"?globalThis:self;st&&!st.Squire&&(st.Squire=mr);st&&!st.DOMPurify&&(st.DOMPurify=kr);yo(ko);Ve.autoInit();var Ol=Ve;return fs(Dl);})();
|
|
458
439
|
/*! @license DOMPurify 3.4.11 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.11/LICENSE */
|
|
459
440
|
|
|
460
441
|
// Auto-export to window unless suppressed by loader. The self-contained bundle
|