var as=Object.defineProperty;var cs=(n,t,e)=>t in n?as(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var d=(n,t,e)=>(cs(n,typeof t!="symbol"?t+"":t,e),e);import{E as C,T as Ut,I as us,S as q,B as Re,A as hs,L as O,P as At,R as Oe,a as ds,b as Ie,C as Be,c as Wt,d as z,e as ot}from"./parchment.d5c5924e.js";import{D as g,a as I}from"./quill-delta.f1b7ce48.js";import{E as fs}from"./eventemitter3.78b735ad.js";import{i as Xt,c as nt,m as W}from"./lodash-es.df04b444.js";class D extends C{static value(){}optimize(){(this.prev||this.next)&&this.remove()}length(){return 0}value(){return""}}D.blotName="break";D.tagName="BR";class B extends Ut{}function Lt(n){return n.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}const j=class extends us{static compare(t,e){const s=j.order.indexOf(t),i=j.order.indexOf(e);return s>=0||i>=0?s-i:t===e?0:t0){const e=this.parent.isolate(this.offset(),this.length());this.moveChildren(e),e.wrap(this)}}};let S=j;d(S,"allowedChildren",[j,D,C,B]),d(S,"order",["cursor","inline","link","underline","strike","italic","bold","script","code"]);const ce=1;class N extends Re{constructor(){super(...arguments);d(this,"cache",{})}delta(){return this.cache.delta==null&&(this.cache.delta=De(this)),this.cache.delta}deleteAt(e,s){super.deleteAt(e,s),this.cache={}}formatAt(e,s,i,r){s<=0||(this.scroll.query(i,q.BLOCK)?e+s===this.length()&&this.format(i,r):super.formatAt(e,Math.min(s,this.length()-e-1),i,r),this.cache={})}insertAt(e,s,i){if(i!=null){super.insertAt(e,s,i),this.cache={};return}if(s.length===0)return;const r=s.split(` `),l=r.shift();l.length>0&&(e(o=o.split(a,!0),o.insertAt(0,c),c.length),e+l.length)}insertBefore(e,s){const{head:i}=this.children;super.insertBefore(e,s),i instanceof D&&i.remove(),this.cache={}}length(){return this.cache.length==null&&(this.cache.length=super.length()+ce),this.cache.length}moveChildren(e,s){super.moveChildren(e,s),this.cache={}}optimize(e){super.optimize(e),this.cache={}}path(e){return super.path(e,!0)}removeChild(e){super.removeChild(e),this.cache={}}split(e){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(s&&(e===0||e>=this.length()-ce)){const r=this.clone();return e===0?(this.parent.insertBefore(r,this),this):(this.parent.insertBefore(r,this.next),r)}const i=super.split(e,s);return this.cache={},i}}N.blotName="block";N.tagName="P";N.defaultChild=D;N.allowedChildren=[D,S,C,B];class T extends C{attach(){super.attach(),this.attributes=new hs(this.domNode)}delta(){return new g().insert(this.value(),{...this.formats(),...this.attributes.values()})}format(t,e){const s=this.scroll.query(t,q.BLOCK_ATTRIBUTE);s!=null&&this.attributes.attribute(s,e)}formatAt(t,e,s,i){this.format(s,i)}insertAt(t,e,s){if(s!=null){super.insertAt(t,e,s);return}const i=e.split(` `),r=i.pop(),l=i.map(a=>{const c=this.scroll.create(N.blotName);return c.insertAt(0,a),c}),o=this.split(t);l.forEach(a=>{this.parent.insertBefore(a,o)}),r&&this.parent.insertBefore(this.scroll.create("text",r),o)}}T.scope=q.BLOCK_BLOT;function De(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return n.descendants(O).reduce((e,s)=>s.length()===0?e:e.insert(s.value(),L(s,{},t)),new g).insert(` `,L(n))}function L(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return n==null||("formats"in n&&typeof n.formats=="function"&&(t={...t,...n.formats()},e&&delete t["code-token"]),n.parent==null||n.parent.statics.blotName==="scroll"||n.parent.statics.scope!==n.statics.scope)?t:L(n.parent,t,e)}const V=class extends C{static value(){}constructor(t,e,s){super(t,e),this.selection=s,this.textNode=document.createTextNode(V.CONTENTS),this.domNode.appendChild(this.textNode),this.savedLength=0}detach(){this.parent!=null&&this.parent.removeChild(this)}format(t,e){if(this.savedLength!==0){super.format(t,e);return}let s=this,i=0;for(;s!=null&&s.statics.scope!==q.BLOCK_BLOT;)i+=s.offset(s.parent),s=s.parent;s!=null&&(this.savedLength=V.CONTENTS.length,s.optimize(),s.formatAt(i,V.CONTENTS.length,t,e),this.savedLength=0)}index(t,e){return t===this.textNode?0:super.index(t,e)}length(){return this.savedLength}position(){return[this.textNode,this.textNode.data.length]}remove(){super.remove(),this.parent=null}restore(){if(this.selection.composing||this.parent==null)return null;const t=this.selection.getNativeRange();for(;this.domNode.lastChild!=null&&this.domNode.lastChild!==this.textNode;)this.domNode.parentNode.insertBefore(this.domNode.lastChild,this.domNode);const e=this.prev instanceof B?this.prev:null,s=e?e.length():0,i=this.next instanceof B?this.next:null,r=i?i.text:"",{textNode:l}=this,o=l.data.split(V.CONTENTS).join("");l.data=V.CONTENTS;let a;if(e)a=e,(o||i)&&(e.insertAt(e.length(),o+r),i&&i.remove());else if(i)a=i,i.insertAt(0,o);else{const c=document.createTextNode(o);a=this.scroll.create(c),this.parent.insertBefore(a,this)}if(this.remove(),t){const c=(b,E)=>e&&b===e.domNode?E:b===l?s+E-1:i&&b===i.domNode?s+o.length+E:null,h=c(t.start.node,t.start.offset),m=c(t.end.node,t.end.offset);if(h!==null&&m!==null)return{startNode:a.domNode,startOffset:h,endNode:a.domNode,endOffset:m}}return null}update(t,e){if(t.some(s=>s.type==="characterData"&&s.target===this.textNode)){const s=this.restore();s&&(e.range=s)}}optimize(t){super.optimize(t);let{parent:e}=this;for(;e;){if(e.domNode.tagName==="A"){this.savedLength=V.CONTENTS.length,e.isolate(this.offset(e),this.length()).unwrap(),this.savedLength=0;break}e=e.parent}}value(){return""}};let U=V;d(U,"blotName","cursor"),d(U,"className","ql-cursor"),d(U,"tagName","span"),d(U,"CONTENTS","\uFEFF");var Ft=new WeakMap;const Pt=["error","warn","log","info"];let $t="warn";function Me(n){if($t&&Pt.indexOf(n)<=Pt.indexOf($t)){for(var t=arguments.length,e=new Array(t>1?t-1:0),s=1;s(t[e]=Me.bind(console,e,n),t),{})}_.level=n=>{$t=n};Me.level=_.level;const St=_("quill:events"),gs=["selectionchange","mousedown","mouseup","click"];gs.forEach(n=>{document.addEventListener(n,function(){for(var t=arguments.length,e=new Array(t),s=0;s{const r=Ft.get(i);r&&r.emitter&&r.emitter.handleDOM(...e)})})});class f extends fs{constructor(){super(),this.domListeners={},this.on("error",St.error)}emit(){for(var t=arguments.length,e=new Array(t),s=0;s1?e-1:0),i=1;i{let{node:l,handler:o}=r;(t.target===l||l.contains(t.target))&&o(t,...s)})}listenDOM(t,e,s){this.domListeners[t]||(this.domListeners[t]=[]),this.domListeners[t].push({node:e,handler:s})}}d(f,"events",{EDITOR_CHANGE:"editor-change",SCROLL_BEFORE_UPDATE:"scroll-before-update",SCROLL_BLOT_MOUNT:"scroll-blot-mount",SCROLL_BLOT_UNMOUNT:"scroll-blot-unmount",SCROLL_OPTIMIZE:"scroll-optimize",SCROLL_UPDATE:"scroll-update",SCROLL_EMBED_UPDATE:"scroll-embed-update",SELECTION_CHANGE:"selection-change",TEXT_CHANGE:"text-change",COMPOSITION_BEFORE_START:"composition-before-start",COMPOSITION_START:"composition-start",COMPOSITION_BEFORE_END:"composition-before-end",COMPOSITION_END:"composition-end"}),d(f,"sources",{API:"api",SILENT:"silent",USER:"user"});const Ct=_("quill:selection");class X{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;this.index=t,this.length=e}}class ms{constructor(t,e){this.emitter=e,this.scroll=t,this.composing=!1,this.mouseDown=!1,this.root=this.scroll.domNode,this.cursor=this.scroll.create("cursor",this),this.savedRange=new X(0,0),this.lastRange=this.savedRange,this.lastNative=null,this.handleComposition(),this.handleDragging(),this.emitter.listenDOM("selectionchange",document,()=>{!this.mouseDown&&!this.composing&&setTimeout(this.update.bind(this,f.sources.USER),1)}),this.emitter.on(f.events.SCROLL_BEFORE_UPDATE,()=>{if(!this.hasFocus())return;const s=this.getNativeRange();s!=null&&s.start.node!==this.cursor.textNode&&this.emitter.once(f.events.SCROLL_UPDATE,(i,r)=>{try{this.root.contains(s.start.node)&&this.root.contains(s.end.node)&&this.setNativeRange(s.start.node,s.start.offset,s.end.node,s.end.offset);const l=r.some(o=>o.type==="characterData"||o.type==="childList"||o.type==="attributes"&&o.target===this.root);this.update(l?f.sources.SILENT:i)}catch{}})}),this.emitter.on(f.events.SCROLL_OPTIMIZE,(s,i)=>{if(i.range){const{startNode:r,startOffset:l,endNode:o,endOffset:a}=i.range;this.setNativeRange(r,l,o,a),this.update(f.sources.SILENT)}}),this.update(f.sources.SILENT)}handleComposition(){this.emitter.on(f.events.COMPOSITION_BEFORE_START,()=>{this.composing=!0}),this.emitter.on(f.events.COMPOSITION_END,()=>{if(this.composing=!1,this.cursor.parent){const t=this.cursor.restore();if(!t)return;setTimeout(()=>{this.setNativeRange(t.startNode,t.startOffset,t.endNode,t.endOffset)},1)}})}handleDragging(){this.emitter.listenDOM("mousedown",document.body,()=>{this.mouseDown=!0}),this.emitter.listenDOM("mouseup",document.body,()=>{this.mouseDown=!1,this.update(f.sources.USER)})}focus(){this.hasFocus()||(this.root.focus(),this.setRange(this.savedRange))}format(t,e){this.scroll.update();const s=this.getNativeRange();if(!(s==null||!s.native.collapsed||this.scroll.query(t,q.BLOCK))){if(s.start.node!==this.cursor.textNode){const i=this.scroll.find(s.start.node,!1);if(i==null)return;if(i instanceof O){const r=i.split(s.start.offset);i.parent.insertBefore(this.cursor,r)}else i.insertBefore(this.cursor,s.start.node);this.cursor.attach()}this.cursor.format(t,e),this.scroll.optimize(),this.setNativeRange(this.cursor.textNode,this.cursor.textNode.data.length),this.update()}}getBounds(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;const s=this.scroll.length();t=Math.min(t,s-1),e=Math.min(t+e,s-1)-t;let i,[r,l]=this.scroll.leaf(t);if(r==null)return null;if(e>0&&l===r.length()){const[h]=this.scroll.leaf(t+1);if(h){const[m]=this.scroll.line(t),[b]=this.scroll.line(t+1);m===b&&(r=h,l=0)}}[i,l]=r.position(l,!0);const o=document.createRange();if(e>0)return o.setStart(i,l),[r,l]=this.scroll.leaf(t+e),r==null?null:([i,l]=r.position(l,!0),o.setEnd(i,l),o.getBoundingClientRect());let a="left",c;if(i instanceof Text){if(!i.data.length)return null;l0&&(a="right")}return{bottom:c.top+c.height,height:c.height,left:c[a],right:c[a],top:c.top,width:0}}getNativeRange(){const t=document.getSelection();if(t==null||t.rangeCount<=0)return null;const e=t.getRangeAt(0);if(e==null)return null;const s=this.normalizeNative(e);return Ct.info("getNativeRange",s),s}getRange(){const t=this.scroll.domNode;if("isConnected"in t&&!t.isConnected)return[null,null];const e=this.getNativeRange();return e==null?[null,null]:[this.normalizedToRange(e),e]}hasFocus(){return document.activeElement===this.root||document.activeElement!=null&&Rt(this.root,document.activeElement)}normalizedToRange(t){const e=[[t.start.node,t.start.offset]];t.native.collapsed||e.push([t.end.node,t.end.offset]);const s=e.map(l=>{const[o,a]=l,c=this.scroll.find(o,!0),h=c.offset(this.scroll);return a===0?h:c instanceof O?h+c.index(o,a):h+c.length()}),i=Math.min(Math.max(...s),this.scroll.length()-1),r=Math.min(i,...s);return new X(r,i-r)}normalizeNative(t){if(!Rt(this.root,t.startContainer)||!t.collapsed&&!Rt(this.root,t.endContainer))return null;const e={start:{node:t.startContainer,offset:t.startOffset},end:{node:t.endContainer,offset:t.endOffset},native:t};return[e.start,e.end].forEach(s=>{let{node:i,offset:r}=s;for(;!(i instanceof Text)&&i.childNodes.length>0;)if(i.childNodes.length>r)i=i.childNodes[r],r=0;else if(i.childNodes.length===r)i=i.lastChild,i instanceof Text?r=i.data.length:i.childNodes.length>0?r=i.childNodes.length:r=i.childNodes.length+1;else break;s.node=i,s.offset=r}),e}rangeToNative(t){const e=this.scroll.length(),s=(i,r)=>{i=Math.min(e-1,i);const[l,o]=this.scroll.leaf(i);return l?l.position(o,r):[null,-1]};return[...s(t.index,!1),...s(t.index+t.length,!0)]}setNativeRange(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:t,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:e,r=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;if(Ct.info("setNativeRange",t,e,s,i),t!=null&&(this.root.parentNode==null||t.parentNode==null||s.parentNode==null))return;const l=document.getSelection();if(l!=null)if(t!=null){this.hasFocus()||this.root.focus();const{native:o}=this.getNativeRange()||{};if(o==null||r||t!==o.startContainer||e!==o.startOffset||s!==o.endContainer||i!==o.endOffset){t instanceof Element&&t.tagName==="BR"&&(e=Array.from(t.parentNode.childNodes).indexOf(t),t=t.parentNode),s instanceof Element&&s.tagName==="BR"&&(i=Array.from(s.parentNode.childNodes).indexOf(s),s=s.parentNode);const a=document.createRange();a.setStart(t,e),a.setEnd(s,i),l.removeAllRanges(),l.addRange(a)}}else l.removeAllRanges(),this.root.blur()}setRange(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:f.sources.API;if(typeof e=="string"&&(s=e,e=!1),Ct.info("setRange",t),t!=null){const i=this.rangeToNative(t);this.setNativeRange(...i,e)}else this.setNativeRange(null);this.update(s)}update(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:f.sources.USER;const e=this.lastRange,[s,i]=this.getRange();if(this.lastRange=s,this.lastNative=i,this.lastRange!=null&&(this.savedRange=this.lastRange),!Xt(e,this.lastRange)){if(!this.composing&&i!=null&&i.native.collapsed&&i.start.node!==this.cursor.textNode){const l=this.cursor.restore();l&&this.setNativeRange(l.startNode,l.startOffset,l.endNode,l.endOffset)}const r=[f.events.SELECTION_CHANGE,nt(this.lastRange),nt(e),t];this.emitter.emit(f.events.EDITOR_CHANGE,...r),t!==f.sources.SILENT&&this.emitter.emit(...r)}}}function Rt(n,t){try{t.parentNode}catch{return!1}return n.contains(t)}const ps=/^[ -~]*$/;class bs{constructor(t){this.scroll=t,this.delta=this.getDelta()}applyDelta(t){this.scroll.update();let e=this.scroll.length();this.scroll.batchStart();const s=ue(t),i=new g;return Es(s.ops.slice()).reduce((l,o)=>{const a=I.exports.Op.length(o);let c=o.attributes||{},h=!1,m=!1;if(o.insert!=null){if(i.retain(a),typeof o.insert=="string"){const p=o.insert;m=!p.endsWith(` `)&&(e<=l||!!this.scroll.descendant(T,l)[0]),this.scroll.insertAt(l,p);const[A,y]=this.scroll.line(l);let x=W({},L(A));if(A instanceof N){const[tt]=A.descendant(O,y);tt&&(x=W(x,L(tt)))}c=I.exports.AttributeMap.diff(x,c)||{}}else if(typeof o.insert=="object"){const p=Object.keys(o.insert)[0];if(p==null)return l;const A=this.scroll.query(p,q.INLINE)!=null;if(A)(e<=l||!!this.scroll.descendant(T,l)[0])&&(m=!0);else if(l>0){const[y,x]=this.scroll.descendant(O,l-1);y instanceof B?y.value()[x]!==` `&&(h=!0):y instanceof C&&y.statics.scope===q.INLINE_BLOT&&(h=!0)}if(this.scroll.insertAt(l,p,o.insert[p]),A){const[y]=this.scroll.descendant(O,l);if(y){const x=W({},L(y));c=I.exports.AttributeMap.diff(x,c)||{}}}}e+=a}else if(i.push(o),o.retain!==null&&typeof o.retain=="object"){const p=Object.keys(o.retain)[0];if(p==null)return l;this.scroll.updateEmbedAt(l,p,o.retain[p])}Object.keys(c).forEach(p=>{this.scroll.formatAt(l,a,p,c[p])});const b=h?1:0,E=m?1:0;return e+=b+E,i.retain(b),i.delete(E),l+a+b+E},0),i.reduce((l,o)=>typeof o.delete=="number"?(this.scroll.deleteAt(l,o.delete),l):l+I.exports.Op.length(o),0),this.scroll.batchEnd(),this.scroll.optimize(),this.update(s)}deleteText(t,e){return this.scroll.deleteAt(t,e),this.update(new g().retain(t).delete(e))}formatLine(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.scroll.update(),Object.keys(s).forEach(r=>{this.scroll.lines(t,Math.max(e,1)).forEach(l=>{l.format(r,s[r])})}),this.scroll.optimize();const i=new g().retain(t).retain(e,nt(s));return this.update(i)}formatText(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.keys(s).forEach(r=>{this.scroll.formatAt(t,e,r,s[r])});const i=new g().retain(t).retain(e,nt(s));return this.update(i)}getContents(t,e){return this.delta.slice(t,t+e)}getDelta(){return this.scroll.lines().reduce((t,e)=>t.concat(e.delta()),new g)}getFormat(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=[],i=[];e===0?this.scroll.path(t).forEach(o=>{const[a]=o;a instanceof N?s.push(a):a instanceof O&&i.push(a)}):(s=this.scroll.lines(t,e),i=this.scroll.descendants(O,t,e));const[r,l]=[s,i].map(o=>{const a=o.shift();if(a==null)return{};let c=L(a);for(;Object.keys(c).length>0;){const h=o.shift();if(h==null)return c;c=ys(L(h),c)}return c});return{...r,...l}}getHTML(t,e){const[s,i]=this.scroll.line(t);if(s){const r=s.length();return s.length()>=i+e&&!(i===0&&e===r)?ht(s,i,e,!0):ht(this.scroll,t,e,!0)}return""}getText(t,e){return this.getContents(t,e).filter(s=>typeof s.insert=="string").map(s=>s.insert).join("")}insertContents(t,e){const s=ue(e),i=new g().retain(t).concat(s);return this.scroll.insertContents(t,s),this.update(i)}insertEmbed(t,e,s){return this.scroll.insertAt(t,e,s),this.update(new g().retain(t).insert({[e]:s}))}insertText(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return e=e.replace(/\r\n/g,` `).replace(/\r/g,` `),this.scroll.insertAt(t,e),Object.keys(s).forEach(i=>{this.scroll.formatAt(t,e.length,i,s[i])}),this.update(new g().retain(t).insert(e,nt(s)))}isBlank(){if(this.scroll.children.length===0)return!0;if(this.scroll.children.length>1)return!1;const t=this.scroll.children.head;if((t==null?void 0:t.statics.blotName)!==N.blotName)return!1;const e=t;return e.children.length>1?!1:e.children.head instanceof D}removeFormat(t,e){const s=this.getText(t,e),[i,r]=this.scroll.line(t+e);let l=0,o=new g;i!=null&&(l=i.length()-r,o=i.delta().slice(r,r+l-1).insert(` `));const c=this.getContents(t,e+l).diff(new g().insert(s).concat(o)),h=new g().retain(t).concat(c);return this.applyDelta(h)}update(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;const i=this.delta;if(e.length===1&&e[0].type==="characterData"&&e[0].target.data.match(ps)&&this.scroll.find(e[0].target)){const r=this.scroll.find(e[0].target),l=L(r),o=r.offset(this.scroll),a=e[0].oldValue.replace(U.CONTENTS,""),c=new g().insert(a),h=new g().insert(r.value()),m=s&&{oldRange:he(s.oldRange,-o),newRange:he(s.newRange,-o)};t=new g().retain(o).concat(c.diff(h,m)).reduce((E,p)=>p.insert?E.insert(p.insert,l):E.push(p),new g),this.delta=i.compose(t)}else this.delta=this.getDelta(),(!t||!Xt(i.compose(t),this.delta))&&(t=i.diff(this.delta,s));return t}}function et(n,t,e){if(n.length===0){const[E]=Ot(e.pop());return t<=0?``:`${et([],t-1,e)}`}const[{child:s,offset:i,length:r,indent:l,type:o},...a]=n,[c,h]=Ot(o);if(l>t)return e.push(o),l===t+1?`<${c}>${ht(s,i,r)}${et(a,l,e)}`:`<${c}>
  • ${et(n,t+1,e)}`;const m=e[e.length-1];if(l===t&&o===m)return`
  • ${ht(s,i,r)}${et(a,l,e)}`;const[b]=Ot(e.pop());return`${et(n,t-1,e)}`}function ht(n,t,e){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if("html"in n&&typeof n.html=="function")return n.html(t,e);if(n instanceof B)return Lt(n.value().slice(t,t+e));if(n instanceof At){if(n.statics.blotName==="list-container"){const c=[];return n.children.forEachAt(t,e,(h,m,b)=>{const E="formats"in h&&typeof h.formats=="function"?h.formats():{};c.push({child:h,offset:m,length:b,indent:E.indent||0,type:E.list})}),et(c,-1,[])}const i=[];if(n.children.forEachAt(t,e,(c,h,m)=>{i.push(ht(c,h,m))}),s||n.statics.blotName==="list")return i.join("");const{outerHTML:r,innerHTML:l}=n.domNode,[o,a]=r.split(`>${l}<`);return o==="${i.join("")}<${a}`:`${o}>${i.join("")}<${a}`}return n.domNode instanceof Element?n.domNode.outerHTML:""}function ys(n,t){return Object.keys(t).reduce((e,s)=>{if(n[s]==null)return e;const i=t[s];return i===n[s]?e[s]=i:Array.isArray(i)?i.indexOf(n[s])<0?e[s]=i.concat([n[s]]):e[s]=i:e[s]=[i,n[s]],e},{})}function Ot(n){const t=n==="ordered"?"ol":"ul";switch(n){case"checked":return[t,' data-list="checked"'];case"unchecked":return[t,' data-list="unchecked"'];default:return[t,""]}}function ue(n){return n.reduce((t,e)=>{if(typeof e.insert=="string"){const s=e.insert.replace(/\r\n/g,` `).replace(/\r/g,` `);return t.insert(s,e.attributes)}return t.push(e)},new g)}function he(n,t){let{index:e,length:s}=n;return new X(e+t,s)}function Es(n){const t=[];return n.forEach(e=>{typeof e.insert=="string"?e.insert.split(` `).forEach((i,r)=>{r&&t.push({insert:` `,attributes:e.attributes}),i&&t.push({insert:i,attributes:e.attributes})}):t.push(e)}),t}class M{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.quill=t,this.options=e}}d(M,"DEFAULTS",{});const yt="\uFEFF";class Yt extends C{constructor(t,e){super(t,e),this.contentNode=document.createElement("span"),this.contentNode.setAttribute("contenteditable","false"),Array.from(this.domNode.childNodes).forEach(s=>{this.contentNode.appendChild(s)}),this.leftGuard=document.createTextNode(yt),this.rightGuard=document.createTextNode(yt),this.domNode.appendChild(this.leftGuard),this.domNode.appendChild(this.contentNode),this.domNode.appendChild(this.rightGuard)}index(t,e){return t===this.leftGuard?0:t===this.rightGuard?1:super.index(t,e)}restore(t){let e=null,s;const i=t.data.split(yt).join("");if(t===this.leftGuard)if(this.prev instanceof B){const r=this.prev.length();this.prev.insertAt(r,i),e={startNode:this.prev.domNode,startOffset:r+i.length}}else s=document.createTextNode(i),this.parent.insertBefore(this.scroll.create(s),this),e={startNode:s,startOffset:i.length};else t===this.rightGuard&&(this.next instanceof B?(this.next.insertAt(0,i),e={startNode:this.next.domNode,startOffset:i.length}):(s=document.createTextNode(i),this.parent.insertBefore(this.scroll.create(s),this.next),e={startNode:s,startOffset:i.length}));return t.data=yt,e}update(t,e){t.forEach(s=>{if(s.type==="characterData"&&(s.target===this.leftGuard||s.target===this.rightGuard)){const i=this.restore(s.target);i&&(e.range=i)}})}}class qs{constructor(t,e){d(this,"isComposing",!1);this.scroll=t,this.emitter=e,this.setupListeners()}setupListeners(){this.scroll.domNode.addEventListener("compositionstart",t=>{this.isComposing||this.handleCompositionStart(t)}),this.scroll.domNode.addEventListener("compositionend",t=>{this.isComposing&&queueMicrotask(()=>{this.handleCompositionEnd(t)})})}handleCompositionStart(t){const e=t.target instanceof Node?this.scroll.find(t.target,!0):null;e&&!(e instanceof Yt)&&(this.emitter.emit(f.events.COMPOSITION_BEFORE_START,t),this.scroll.batchStart(),this.emitter.emit(f.events.COMPOSITION_START,t),this.isComposing=!0)}handleCompositionEnd(t){this.emitter.emit(f.events.COMPOSITION_BEFORE_END,t),this.scroll.batchEnd(),this.emitter.emit(f.events.COMPOSITION_END,t),this.isComposing=!1}}const oe=class{constructor(t,e){d(this,"modules",{});this.quill=t,this.options=e}init(){Object.keys(this.options.modules).forEach(t=>{this.modules[t]==null&&this.addModule(t)})}addModule(t){const e=this.quill.constructor.import(`modules/${t}`);return this.modules[t]=new e(this.quill,this.options.modules[t]||{}),this.modules[t]}};let K=oe;d(K,"DEFAULTS",{modules:{}}),d(K,"themes",{default:oe});const xs=n=>n.parentElement||n.getRootNode().host||null,Ns=n=>{const t=n.getBoundingClientRect(),e="offsetWidth"in n&&Math.abs(t.width)/n.offsetWidth||1,s="offsetHeight"in n&&Math.abs(t.height)/n.offsetHeight||1;return{top:t.top,right:t.left+n.clientWidth*e,bottom:t.top+n.clientHeight*s,left:t.left}},Et=n=>{const t=parseInt(n,10);return Number.isNaN(t)?0:t},de=(n,t,e,s,i,r)=>ns?0:ns?t-n>s-e?n+i-e:t-s+r:0,ws=(n,t)=>{var r,l,o,a,c;const e=n.ownerDocument;let s=t,i=n;for(;i;){const h=i===e.body,m=h?{top:0,right:(l=(r=window.visualViewport)==null?void 0:r.width)!=null?l:e.documentElement.clientWidth,bottom:(a=(o=window.visualViewport)==null?void 0:o.height)!=null?a:e.documentElement.clientHeight,left:0}:Ns(i),b=getComputedStyle(i),E=de(s.left,s.right,m.left,m.right,Et(b.scrollPaddingLeft),Et(b.scrollPaddingRight)),p=de(s.top,s.bottom,m.top,m.bottom,Et(b.scrollPaddingTop),Et(b.scrollPaddingBottom));if(E||p)if(h)(c=e.defaultView)==null||c.scrollBy(E,p);else{const{scrollLeft:A,scrollTop:y}=i;p&&(i.scrollTop+=p),E&&(i.scrollLeft+=E);const x=i.scrollLeft-A,tt=i.scrollTop-y;s={left:s.left-x,top:s.top-tt,right:s.right-x,bottom:s.bottom-tt}}i=h||b.position==="fixed"?null:xs(i)}},ks=100,As=["block","break","cursor","inline","scroll","text"],Ls=(n,t,e)=>{const s=new Oe;return As.forEach(i=>{const r=t.query(i);r&&s.register(r)}),n.forEach(i=>{var o;let r=t.query(i);r||e.error(`Cannot register "${i}" specified in "formats" config. Are you sure it was registered?`);let l=0;for(;r;)if(s.register(r),r="blotName"in r&&(o=r.requiredContainer)!=null?o:null,l+=1,l>ks){e.error(`Cycle detected in registering blot requiredContainer: "${i}"`);break}}),s},rt=_("quill"),qt=new Oe;At.uiClass="ql-ui";const it=class{static debug(t){t===!0&&(t="log"),_.level(t)}static find(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Ft.get(t)||qt.find(t,e)}static import(t){return this.imports[t]==null&&rt.error(`Cannot import ${t}. Are you sure it was registered?`),this.imports[t]}static register(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(typeof t!="string"){const i="attrName"in t?t.attrName:t.blotName;typeof i=="string"?this.register(`formats/${i}`,t,e):Object.keys(t).forEach(r=>{this.register(r,t[r],e)})}else this.imports[t]!=null&&!s&&rt.warn(`Overwriting ${t} with`,e),this.imports[t]=e,(t.startsWith("blots/")||t.startsWith("formats/"))&&e&&typeof e!="boolean"&&e.blotName!=="abstract"&&qt.register(e),typeof e.register=="function"&&e.register(qt)}constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.options=vs(t,e),this.container=this.options.container,this.container==null){rt.error("Invalid Quill container",t);return}this.options.debug&&it.debug(this.options.debug);const s=this.container.innerHTML.trim();this.container.classList.add("ql-container"),this.container.innerHTML="",Ft.set(this.container,this),this.root=this.addContainer("ql-editor"),this.root.classList.add("ql-blank"),this.emitter=new f;const i=Ie.blotName,r=this.options.registry.query(i);if(!r||!("blotName"in r))throw new Error(`Cannot initialize Quill without "${i}" blot`);if(this.scroll=new r(this.options.registry,this.root,{emitter:this.emitter}),this.editor=new bs(this.scroll),this.selection=new ms(this.scroll,this.emitter),this.composition=new qs(this.scroll,this.emitter),this.theme=new this.options.theme(this,this.options),this.keyboard=this.theme.addModule("keyboard"),this.clipboard=this.theme.addModule("clipboard"),this.history=this.theme.addModule("history"),this.uploader=this.theme.addModule("uploader"),this.theme.addModule("input"),this.theme.addModule("uiNode"),this.theme.init(),this.emitter.on(f.events.COMPOSITION_START,()=>{this.root.classList.toggle("ql-blank",!1)}),this.emitter.on(f.events.COMPOSITION_END,()=>{this.root.classList.toggle("ql-blank",this.editor.isBlank())}),this.emitter.on(f.events.EDITOR_CHANGE,l=>{l===f.events.TEXT_CHANGE&&this.root.classList.toggle("ql-blank",this.editor.isBlank())}),this.emitter.on(f.events.SCROLL_UPDATE,(l,o)=>{const a=this.selection.lastRange,[c]=this.selection.getRange(),h=a&&c?{oldRange:a,newRange:c}:void 0;R.call(this,()=>this.editor.update(null,o,h),l)}),this.emitter.on(f.events.SCROLL_EMBED_UPDATE,(l,o)=>{const a=this.selection.lastRange,[c]=this.selection.getRange(),h=a&&c?{oldRange:a,newRange:c}:void 0;R.call(this,()=>{const m=new g().retain(l.offset(this)).retain({[l.statics.blotName]:o});return this.editor.update(m,[],h)},it.sources.USER)}),s){const l=this.clipboard.convert({html:`${s}


    `,text:` `});this.setContents(l)}this.history.clear(),this.options.placeholder&&this.root.setAttribute("data-placeholder",this.options.placeholder),this.options.readOnly&&this.disable(),this.allowReadOnlyEdits=!1}addContainer(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(typeof t=="string"){const s=t;t=document.createElement("div"),t.classList.add(s)}return this.container.insertBefore(t,e),t}blur(){this.selection.setRange(null)}deleteText(t,e,s){return[t,e,,s]=P(t,e,s),R.call(this,()=>this.editor.deleteText(t,e),s,t,-1*e)}disable(){this.enable(!1)}editReadOnly(t){this.allowReadOnlyEdits=!0;const e=t();return this.allowReadOnlyEdits=!1,e}enable(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.scroll.enable(t),this.container.classList.toggle("ql-disabled",!t)}focus(){this.selection.focus(),this.scrollSelectionIntoView()}format(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:f.sources.API;return R.call(this,()=>{const i=this.getSelection(!0);let r=new g;if(i==null)return r;if(this.scroll.query(t,q.BLOCK))r=this.editor.formatLine(i.index,i.length,{[t]:e});else{if(i.length===0)return this.selection.format(t,e),r;r=this.editor.formatText(i.index,i.length,{[t]:e})}return this.setSelection(i,f.sources.SILENT),r},s)}formatLine(t,e,s,i,r){let l;return[t,e,l,r]=P(t,e,s,i,r),R.call(this,()=>this.editor.formatLine(t,e,l),r,t,0)}formatText(t,e,s,i,r){let l;return[t,e,l,r]=P(t,e,s,i,r),R.call(this,()=>this.editor.formatText(t,e,l),r,t,0)}getBounds(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=null;if(typeof t=="number"?s=this.selection.getBounds(t,e):s=this.selection.getBounds(t.index,t.length),!s)return null;const i=this.container.getBoundingClientRect();return{bottom:s.bottom-i.top,height:s.height,left:s.left-i.left,right:s.right-i.left,top:s.top-i.top,width:s.width}}getContents(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getLength()-t;return[t,e]=P(t,e),this.editor.getContents(t,e)}getFormat(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.getSelection(!0),e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return typeof t=="number"?this.editor.getFormat(t,e):this.editor.getFormat(t.index,t.length)}getIndex(t){return t.offset(this.scroll)}getLength(){return this.scroll.length()}getLeaf(t){return this.scroll.leaf(t)}getLine(t){return this.scroll.line(t)}getLines(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE;return typeof t!="number"?this.scroll.lines(t.index,t.length):this.scroll.lines(t,e)}getModule(t){return this.theme.modules[t]}getSelection(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1)&&this.focus(),this.update(),this.selection.getRange()[0]}getSemanticHTML(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1?arguments[1]:void 0;return typeof t=="number"&&(e=e!=null?e:this.getLength()-t),[t,e]=P(t,e),this.editor.getHTML(t,e)}getText(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1?arguments[1]:void 0;return typeof t=="number"&&(e=e!=null?e:this.getLength()-t),[t,e]=P(t,e),this.editor.getText(t,e)}hasFocus(){return this.selection.hasFocus()}insertEmbed(t,e,s){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:it.sources.API;return R.call(this,()=>this.editor.insertEmbed(t,e,s),i,t)}insertText(t,e,s,i,r){let l;return[t,,l,r]=P(t,0,s,i,r),R.call(this,()=>this.editor.insertText(t,e,l),r,t,e.length)}isEnabled(){return this.scroll.isEnabled()}off(){return this.emitter.off(...arguments)}on(){return this.emitter.on(...arguments)}once(){return this.emitter.once(...arguments)}removeFormat(t,e,s){return[t,e,,s]=P(t,e,s),R.call(this,()=>this.editor.removeFormat(t,e),s,t)}scrollRectIntoView(t){ws(this.root,t)}scrollIntoView(){console.warn("Quill#scrollIntoView() has been deprecated and will be removed in the near future. Please use Quill#scrollSelectionIntoView() instead."),this.scrollSelectionIntoView()}scrollSelectionIntoView(){const t=this.selection.lastRange,e=t&&this.selection.getBounds(t.index,t.length);e&&this.scrollRectIntoView(e)}setContents(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f.sources.API;return R.call(this,()=>{t=new g(t);const s=this.getLength(),i=this.editor.deleteText(0,s),r=this.editor.insertContents(0,t),l=this.editor.deleteText(this.getLength()-1,1);return i.compose(r).compose(l)},e)}setSelection(t,e,s){t==null?this.selection.setRange(null,e||it.sources.API):([t,e,,s]=P(t,e,s),this.selection.setRange(new X(Math.max(0,t),e),s),s!==f.sources.SILENT&&this.scrollSelectionIntoView())}setText(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f.sources.API;const s=new g().insert(t);return this.setContents(s,e)}update(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:f.sources.USER;const e=this.scroll.update(t);return this.selection.update(t),e}updateContents(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f.sources.API;return R.call(this,()=>(t=new g(t),this.editor.applyDelta(t)),e,!0)}};let u=it;d(u,"DEFAULTS",{bounds:null,modules:{clipboard:!0,keyboard:!0,history:!0,uploader:!0},placeholder:"",readOnly:!1,registry:qt,theme:"default"}),d(u,"events",f.events),d(u,"sources",f.sources),d(u,"version","2.0.0-rc1"),d(u,"imports",{delta:g,parchment:ds,"core/module":M,"core/theme":K});function fe(n){return typeof n=="string"?document.querySelector(n):n}function It(n){return Object.entries(n!=null?n:{}).reduce((t,e)=>{let[s,i]=e;return{...t,[s]:i===!0?{}:i}},{})}function ge(n){return Object.fromEntries(Object.entries(n).filter(t=>t[1]!==void 0))}function vs(n,t){const e=fe(n);if(!e)throw new Error("Invalid Quill container");const i=!t.theme||t.theme===u.DEFAULTS.theme?K:u.import(`themes/${t.theme}`);if(!i)throw new Error(`Invalid theme ${t.theme}. Did you register it?`);const{modules:r,...l}=u.DEFAULTS,{modules:o,...a}=i.DEFAULTS,c=W({},It(r),It(o),It(t.modules));c!=null&&c.toolbar&&c.toolbar.constructor!==Object&&(c.toolbar={container:c.toolbar});const h={...l,...ge(a),...ge(t)};let m=t.registry;return m?t.formats&&rt.warn('Ignoring "formats" option because "registry" is specified'):m=t.formats?Ls(t.formats,h.registry,rt):h.registry,{...h,registry:m,container:e,theme:i,modules:Object.entries(c).reduce((b,E)=>{let[p,A]=E;if(!A)return b;const y=u.import(`modules/${p}`);return y==null?(rt.error(`Cannot load ${p} module. Are you sure you registered it?`),b):{...b,[p]:W({},y.DEFAULTS||{},A)}},{}),bounds:fe(h.bounds)}}function R(n,t,e,s){if(!this.isEnabled()&&t===f.sources.USER&&!this.allowReadOnlyEdits)return new g;let i=e==null?null:this.getSelection();const r=this.editor.delta,l=n();if(i!=null&&(e===!0&&(e=i.index),s==null?i=me(i,l,t):s!==0&&(i=me(i,e,s,t)),this.setSelection(i,f.sources.SILENT)),l.length()>0){const o=[f.events.TEXT_CHANGE,l,r,t];this.emitter.emit(f.events.EDITOR_CHANGE,...o),t!==f.sources.SILENT&&this.emitter.emit(...o)}return l}function P(n,t,e,s,i){let r={};return typeof n.index=="number"&&typeof n.length=="number"?typeof t!="number"?(i=s,s=e,e=t,t=n.length,n=n.index):(t=n.length,n=n.index):typeof t!="number"&&(i=s,s=e,e=t,t=0),typeof e=="object"?(r=e,i=s):typeof e=="string"&&(s!=null?r[e]=s:i=e),i=i||f.sources.API,[n,t,r,i]}function me(n,t,e,s){const i=typeof e=="number"?e:0;if(n==null)return null;let r,l;return t&&typeof t.transformPosition=="function"?[r,l]=[n.index,n.index+n.length].map(o=>t.transformPosition(o,s!==f.sources.USER)):[r,l]=[n.index,n.index+n.length].map(o=>o=0?o+i:Math.max(t,o+i)),new X(r,l-r)}class Y extends Be{}function pe(n){return n instanceof N||n instanceof T}function be(n){return typeof n.updateContent=="function"}class st extends Ie{constructor(t,e,s){let{emitter:i}=s;super(t,e),this.emitter=i,this.batch=!1,this.optimize(),this.enable(),this.domNode.addEventListener("dragstart",r=>this.handleDragStart(r))}batchStart(){Array.isArray(this.batch)||(this.batch=[])}batchEnd(){if(!this.batch)return;const t=this.batch;this.batch=!1,this.update(t)}emitMount(t){this.emitter.emit(f.events.SCROLL_BLOT_MOUNT,t)}emitUnmount(t){this.emitter.emit(f.events.SCROLL_BLOT_UNMOUNT,t)}emitEmbedUpdate(t,e){this.emitter.emit(f.events.SCROLL_EMBED_UPDATE,t,e)}deleteAt(t,e){const[s,i]=this.line(t),[r]=this.line(t+e);if(super.deleteAt(t,e),r!=null&&s!==r&&i>0){if(s instanceof T||r instanceof T){this.optimize();return}const l=r.children.head instanceof D?null:r.children.head;s.moveChildren(r,l),s.remove()}this.optimize()}enable(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.domNode.setAttribute("contenteditable",t?"true":"false")}formatAt(t,e,s,i){super.formatAt(t,e,s,i),this.optimize()}insertAt(t,e,s){if(t>=this.length())if(s==null||this.scroll.query(e,q.BLOCK)==null){const i=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(i),s==null&&e.endsWith(` `)?i.insertAt(0,e.slice(0,-1),s):i.insertAt(0,e,s)}else{const i=this.scroll.create(e,s);this.appendChild(i)}else super.insertAt(t,e,s);this.optimize()}insertBefore(t,e){if(t.statics.scope===q.INLINE_BLOT){const s=this.scroll.create(this.statics.defaultChild.blotName);s.appendChild(t),super.insertBefore(s,e)}else super.insertBefore(t,e)}insertContents(t,e){const s=this.deltaToRenderBlocks(e.concat(new g().insert(` `))),i=s.pop();if(i==null)return;this.batchStart();const r=s.shift();if(r){const a=r.type==="block"&&(r.delta.length()===0||!this.descendant(T,t)[0]&&t{this.formatAt(m-1,1,p,E[p])}),t=m}let[l,o]=this.children.find(t);if(s.length&&(l&&(l=l.split(o),o=0),s.forEach(a=>{if(a.type==="block"){const c=this.createBlock(a.attributes,l||void 0);Bt(c,0,a.delta)}else{const c=this.create(a.key,a.value);this.insertBefore(c,l||void 0),Object.keys(a.attributes).forEach(h=>{c.format(h,a.attributes[h])})}})),i.type==="block"&&i.delta.length()){const a=l?l.offset(l.scroll)+o:this.length();Bt(this,a,i.delta)}this.batchEnd(),this.optimize()}isEnabled(){return this.domNode.getAttribute("contenteditable")==="true"}leaf(t){const e=this.path(t).pop();if(!e)return[null,-1];const[s,i]=e;return s instanceof O?[s,i]:[null,-1]}line(t){return t===this.length()?this.line(t-1):this.descendant(pe,t)}lines(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE;const s=(i,r,l)=>{let o=[],a=l;return i.children.forEachAt(r,l,(c,h,m)=>{pe(c)?o.push(c):c instanceof Be&&(o=o.concat(s(c,h,a))),a-=m}),o};return s(this,t,e)}optimize(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.batch||(super.optimize(t,e),t.length>0&&this.emitter.emit(f.events.SCROLL_OPTIMIZE,t,e))}path(t){return super.path(t).slice(1)}remove(){}update(t){if(this.batch){Array.isArray(t)&&(this.batch=this.batch.concat(t));return}let e=f.sources.USER;typeof t=="string"&&(e=t),Array.isArray(t)||(t=this.observer.takeRecords()),t=t.filter(s=>{let{target:i}=s;const r=this.find(i,!0);return r&&!be(r)}),t.length>0&&this.emitter.emit(f.events.SCROLL_BEFORE_UPDATE,e,t),super.update(t.concat([])),t.length>0&&this.emitter.emit(f.events.SCROLL_UPDATE,e,t)}updateEmbedAt(t,e,s){const[i]=this.descendant(r=>r instanceof T,t);i&&i.statics.blotName===e&&be(i)&&i.updateContent(s)}handleDragStart(t){t.preventDefault()}deltaToRenderBlocks(t){const e=[];let s=new g;return t.forEach(i=>{var l;const r=i==null?void 0:i.insert;if(!!r)if(typeof r=="string"){const o=r.split(` `);o.slice(0,-1).forEach(c=>{var h;s.insert(c,i.attributes),e.push({type:"block",delta:s,attributes:(h=i.attributes)!=null?h:{}}),s=new g});const a=o[o.length-1];a&&s.insert(a,i.attributes)}else{const o=Object.keys(r)[0];if(!o)return;this.query(o,q.INLINE)?s.push(i):(s.length()&&e.push({type:"block",delta:s,attributes:{}}),s=new g,e.push({type:"blockEmbed",key:o,value:r[o],attributes:(l=i.attributes)!=null?l:{}}))}}),s.length()&&e.push({type:"block",delta:s,attributes:{}}),e}createBlock(t,e){let s;const i={};Object.entries(t).forEach(o=>{let[a,c]=o;this.query(a,q.BLOCK&q.BLOT)!=null?s=a:i[a]=c});const r=this.create(s||this.statics.defaultChild.blotName,s?t[s]:void 0);this.insertBefore(r,e||void 0);const l=r.length();return Object.entries(i).forEach(o=>{let[a,c]=o;r.formatAt(0,l,a,c)}),r}}d(st,"blotName","scroll"),d(st,"className","ql-editor"),d(st,"tagName","DIV"),d(st,"defaultChild",N),d(st,"allowedChildren",[N,T,Y]);function Bt(n,t,e){e.reduce((s,i)=>{const r=I.exports.Op.length(i);let l=i.attributes||{};if(i.insert!=null){if(typeof i.insert=="string"){const o=i.insert;n.insertAt(s,o);const[a]=n.descendant(O,s),c=L(a);l=I.exports.AttributeMap.diff(c,l)||{}}else if(typeof i.insert=="object"){const o=Object.keys(i.insert)[0];if(o==null)return s;if(n.insertAt(s,o,i.insert[o]),n.scroll.query(o,q.INLINE)!=null){const[c]=n.descendant(O,s),h=L(c);l=I.exports.AttributeMap.diff(h,l)||{}}}}return Object.keys(l).forEach(o=>{n.formatAt(s,r,o,l[o])}),s+r},t)}const Qt={scope:q.BLOCK,whitelist:["right","center","justify"]},Ts=new Wt("align","align",Qt),Ue=new z("align","ql-align",Qt),Fe=new ot("align","text-align",Qt);class Pe extends ot{value(t){let e=super.value(t);return e.startsWith("rgb(")?(e=e.replace(/^[^\d]+/,"").replace(/[^\d]+$/,""),`#${e.split(",").map(i=>`00${parseInt(i,10).toString(16)}`.slice(-2)).join("")}`):e}}const Ss=new z("color","ql-color",{scope:q.INLINE}),Jt=new Pe("color","color",{scope:q.INLINE}),Cs=new z("background","ql-bg",{scope:q.INLINE}),te=new Pe("background","background-color",{scope:q.INLINE});class Q extends Y{static create(t){const e=super.create(t);return e.setAttribute("spellcheck","false"),e}code(t,e){return this.children.map(s=>s.length()<=1?"":s.domNode.innerText).join(` `).slice(t,t+e)}html(t,e){return`
    ${Lt(this.code(t,e))}
    
    `}}class w extends N{static register(){u.register(Q)}}d(w,"TAB"," ");class ee extends S{}ee.blotName="code";ee.tagName="CODE";w.blotName="code-block";w.className="ql-code-block";w.tagName="DIV";Q.blotName="code-block-container";Q.className="ql-code-block-container";Q.tagName="DIV";Q.allowedChildren=[w];w.allowedChildren=[B,D,U];w.requiredContainer=Q;const se={scope:q.BLOCK,whitelist:["rtl"]},$e=new Wt("direction","dir",se),He=new z("direction","ql-direction",se),ze=new ot("direction","direction",se),_e={scope:q.INLINE,whitelist:["serif","monospace"]},je=new z("font","ql-font",_e);class Rs extends ot{value(t){return super.value(t).replace(/["']/g,"")}}const Ve=new Rs("font","font-family",_e),Ke=new z("size","ql-size",{scope:q.INLINE,whitelist:["small","large","huge"]}),Ze=new ot("size","font-size",{scope:q.INLINE,whitelist:["10px","18px","32px"]}),Os=_("quill:keyboard"),Is=/Mac/i.test(navigator.platform)?"metaKey":"ctrlKey";class vt extends M{static match(t,e){return["altKey","ctrlKey","metaKey","shiftKey"].some(s=>!!e[s]!==t[s]&&e[s]!==null)?!1:e.key===t.key||e.key===t.which}constructor(t,e){super(t,e),this.bindings={},Object.keys(this.options.bindings).forEach(s=>{this.options.bindings[s]&&this.addBinding(this.options.bindings[s])}),this.addBinding({key:"Enter",shiftKey:null},this.handleEnter),this.addBinding({key:"Enter",metaKey:null,ctrlKey:null,altKey:null},()=>{}),/Firefox/i.test(navigator.userAgent)?(this.addBinding({key:"Backspace"},{collapsed:!0},this.handleBackspace),this.addBinding({key:"Delete"},{collapsed:!0},this.handleDelete)):(this.addBinding({key:"Backspace"},{collapsed:!0,prefix:/^.?$/},this.handleBackspace),this.addBinding({key:"Delete"},{collapsed:!0,suffix:/^.?$/},this.handleDelete)),this.addBinding({key:"Backspace"},{collapsed:!1},this.handleDeleteRange),this.addBinding({key:"Delete"},{collapsed:!1},this.handleDeleteRange),this.addBinding({key:"Backspace",altKey:null,ctrlKey:null,metaKey:null,shiftKey:null},{collapsed:!0,offset:0},this.handleBackspace),this.listen()}addBinding(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=Ds(t);if(i==null){Os.warn("Attempted to add invalid keyboard binding",i);return}typeof e=="function"&&(e={handler:e}),typeof s=="function"&&(s={handler:s}),(Array.isArray(i.key)?i.key:[i.key]).forEach(l=>{const o={...i,key:l,...e,...s};this.bindings[o.key]=this.bindings[o.key]||[],this.bindings[o.key].push(o)})}listen(){this.quill.root.addEventListener("keydown",t=>{if(t.defaultPrevented||t.isComposing)return;const s=(this.bindings[t.key]||[]).concat(this.bindings[t.which]||[]).filter(y=>vt.match(t,y));if(s.length===0)return;const i=u.find(t.target,!0);if(i&&i.scroll!==this.quill.scroll)return;const r=this.quill.getSelection();if(r==null||!this.quill.hasFocus())return;const[l,o]=this.quill.getLine(r.index),[a,c]=this.quill.getLeaf(r.index),[h,m]=r.length===0?[a,c]:this.quill.getLeaf(r.index+r.length),b=a instanceof Ut?a.value().slice(0,c):"",E=h instanceof Ut?h.value().slice(m):"",p={collapsed:r.length===0,empty:r.length===0&&l.length()<=1,format:this.quill.getFormat(r),line:l,offset:o,prefix:b,suffix:E,event:t};s.some(y=>{if(y.collapsed!=null&&y.collapsed!==p.collapsed||y.empty!=null&&y.empty!==p.empty||y.offset!=null&&y.offset!==p.offset)return!1;if(Array.isArray(y.format)){if(y.format.every(x=>p.format[x]==null))return!1}else if(typeof y.format=="object"&&!Object.keys(y.format).every(x=>y.format[x]===!0?p.format[x]!=null:y.format[x]===!1?p.format[x]==null:Xt(y.format[x],p.format[x])))return!1;return y.prefix!=null&&!y.prefix.test(p.prefix)||y.suffix!=null&&!y.suffix.test(p.suffix)?!1:y.handler.call(this,r,p,y)!==!0})&&t.preventDefault()})}handleBackspace(t,e){const s=/[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(e.prefix)?2:1;if(t.index===0||this.quill.getLength()<=1)return;let i={};const[r]=this.quill.getLine(t.index);let l=new g().retain(t.index-s).delete(s);if(e.offset===0){const[o]=this.quill.getLine(t.index-1);if(o&&!(o.statics.blotName==="block"&&o.length()<=1)){const c=r.formats(),h=this.quill.getFormat(t.index-1,1);if(i=I.exports.AttributeMap.diff(c,h)||{},Object.keys(i).length>0){const m=new g().retain(t.index+r.length()-2).retain(1,i);l=l.compose(m)}}}this.quill.updateContents(l,u.sources.USER),this.quill.focus()}handleDelete(t,e){const s=/^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(e.suffix)?2:1;if(t.index>=this.quill.getLength()-s)return;let i={};const[r]=this.quill.getLine(t.index);let l=new g().retain(t.index).delete(s);if(e.offset>=r.length()-1){const[o]=this.quill.getLine(t.index+1);if(o){const a=r.formats(),c=this.quill.getFormat(t.index,1);i=I.exports.AttributeMap.diff(a,c)||{},Object.keys(i).length>0&&(l=l.retain(o.length()-1).retain(1,i))}}this.quill.updateContents(l,u.sources.USER),this.quill.focus()}handleDeleteRange(t){ie({range:t,quill:this.quill}),this.quill.focus()}handleEnter(t,e){const s=Object.keys(e.format).reduce((r,l)=>(this.quill.scroll.query(l,q.BLOCK)&&!Array.isArray(e.format[l])&&(r[l]=e.format[l]),r),{}),i=new g().retain(t.index).delete(t.length).insert(` `,s);this.quill.updateContents(i,u.sources.USER),this.quill.setSelection(t.index+1,u.sources.SILENT),this.quill.focus()}}const Bs={bindings:{bold:Dt("bold"),italic:Dt("italic"),underline:Dt("underline"),indent:{key:"Tab",format:["blockquote","indent","list"],handler(n,t){return t.collapsed&&t.offset!==0?!0:(this.quill.format("indent","+1",u.sources.USER),!1)}},outdent:{key:"Tab",shiftKey:!0,format:["blockquote","indent","list"],handler(n,t){return t.collapsed&&t.offset!==0?!0:(this.quill.format("indent","-1",u.sources.USER),!1)}},"outdent backspace":{key:"Backspace",collapsed:!0,shiftKey:null,metaKey:null,ctrlKey:null,altKey:null,format:["indent","list"],offset:0,handler(n,t){t.format.indent!=null?this.quill.format("indent","-1",u.sources.USER):t.format.list!=null&&this.quill.format("list",!1,u.sources.USER)}},"indent code-block":ye(!0),"outdent code-block":ye(!1),"remove tab":{key:"Tab",shiftKey:!0,collapsed:!0,prefix:/\t$/,handler(n){this.quill.deleteText(n.index-1,1,u.sources.USER)}},tab:{key:"Tab",handler(n,t){if(t.format.table)return!0;this.quill.history.cutoff();const e=new g().retain(n.index).delete(n.length).insert(" ");return this.quill.updateContents(e,u.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(n.index+1,u.sources.SILENT),!1}},"blockquote empty enter":{key:"Enter",collapsed:!0,format:["blockquote"],empty:!0,handler(){this.quill.format("blockquote",!1,u.sources.USER)}},"list empty enter":{key:"Enter",collapsed:!0,format:["list"],empty:!0,handler(n,t){const e={list:!1};t.format.indent&&(e.indent=!1),this.quill.formatLine(n.index,n.length,e,u.sources.USER)}},"checklist enter":{key:"Enter",collapsed:!0,format:{list:"checked"},handler(n){const[t,e]=this.quill.getLine(n.index),s={...t.formats(),list:"checked"},i=new g().retain(n.index).insert(` `,s).retain(t.length()-e-1).retain(1,{list:"unchecked"});this.quill.updateContents(i,u.sources.USER),this.quill.setSelection(n.index+1,u.sources.SILENT),this.quill.scrollSelectionIntoView()}},"header enter":{key:"Enter",collapsed:!0,format:["header"],suffix:/^$/,handler(n,t){const[e,s]=this.quill.getLine(n.index),i=new g().retain(n.index).insert(` `,t.format).retain(e.length()-s-1).retain(1,{header:null});this.quill.updateContents(i,u.sources.USER),this.quill.setSelection(n.index+1,u.sources.SILENT),this.quill.scrollSelectionIntoView()}},"table backspace":{key:"Backspace",format:["table"],collapsed:!0,offset:0,handler(){}},"table delete":{key:"Delete",format:["table"],collapsed:!0,suffix:/^$/,handler(){}},"table enter":{key:"Enter",shiftKey:null,format:["table"],handler(n){const t=this.quill.getModule("table");if(t){const[e,s,i,r]=t.getTable(n),l=Ms(e,s,i,r);if(l==null)return;let o=e.offset();if(l<0){const a=new g().retain(o).insert(` `);this.quill.updateContents(a,u.sources.USER),this.quill.setSelection(n.index+1,n.length,u.sources.SILENT)}else if(l>0){o+=e.length();const a=new g().retain(o).insert(` `);this.quill.updateContents(a,u.sources.USER),this.quill.setSelection(o,u.sources.USER)}}}},"table tab":{key:"Tab",shiftKey:null,format:["table"],handler(n,t){const{event:e,line:s}=t,i=s.offset(this.quill.scroll);e.shiftKey?this.quill.setSelection(i-1,u.sources.USER):this.quill.setSelection(i+s.length(),u.sources.USER)}},"list autofill":{key:" ",shiftKey:null,collapsed:!0,format:{"code-block":!1,blockquote:!1,table:!1},prefix:/^\s*?(\d+\.|-|\*|\[ ?\]|\[x\])$/,handler(n,t){if(this.quill.scroll.query("list")==null)return!0;const{length:e}=t.prefix,[s,i]=this.quill.getLine(n.index);if(i>e)return!0;let r;switch(t.prefix.trim()){case"[]":case"[ ]":r="unchecked";break;case"[x]":r="checked";break;case"-":case"*":r="bullet";break;default:r="ordered"}this.quill.insertText(n.index," ",u.sources.USER),this.quill.history.cutoff();const l=new g().retain(n.index-i).delete(e+1).retain(s.length()-2-i).retain(1,{list:r});return this.quill.updateContents(l,u.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(n.index-e,u.sources.SILENT),!1}},"code exit":{key:"Enter",collapsed:!0,format:["code-block"],prefix:/^$/,suffix:/^\s*$/,handler(n){const[t,e]=this.quill.getLine(n.index);let s=2,i=t;for(;i!=null&&i.length()<=1&&i.formats()["code-block"];)if(i=i.prev,s-=1,s<=0){const r=new g().retain(n.index+t.length()-e-2).retain(1,{"code-block":null}).delete(1);return this.quill.updateContents(r,u.sources.USER),this.quill.setSelection(n.index-1,u.sources.SILENT),!1}return!0}},"embed left":xt("ArrowLeft",!1),"embed left shift":xt("ArrowLeft",!0),"embed right":xt("ArrowRight",!1),"embed right shift":xt("ArrowRight",!0),"table down":Ee(!1),"table up":Ee(!0)}};vt.DEFAULTS=Bs;function ye(n){return{key:"Tab",shiftKey:!n,format:{"code-block":!0},handler(t,e){let{event:s}=e;const i=this.quill.scroll.query("code-block"),{TAB:r}=i;if(t.length===0&&!s.shiftKey){this.quill.insertText(t.index,r,u.sources.USER),this.quill.setSelection(t.index+r.length,u.sources.SILENT);return}const l=t.length===0?this.quill.getLines(t.index,1):this.quill.getLines(t);let{index:o,length:a}=t;l.forEach((c,h)=>{n?(c.insertAt(0,r),h===0?o+=r.length:a+=r.length):c.domNode.textContent.startsWith(r)&&(c.deleteAt(0,r.length),h===0?o-=r.length:a-=r.length)}),this.quill.update(u.sources.USER),this.quill.setSelection(o,a,u.sources.SILENT)}}}function xt(n,t){return{key:n,shiftKey:t,altKey:null,[n==="ArrowLeft"?"prefix":"suffix"]:/^$/,handler(s){let{index:i}=s;n==="ArrowRight"&&(i+=s.length+1);const[r]=this.quill.getLeaf(i);return r instanceof C?(n==="ArrowLeft"?t?this.quill.setSelection(s.index-1,s.length+1,u.sources.USER):this.quill.setSelection(s.index-1,u.sources.USER):t?this.quill.setSelection(s.index,s.length+1,u.sources.USER):this.quill.setSelection(s.index+s.length+1,u.sources.USER),!1):!0}}}function Dt(n){return{key:n[0],shortKey:!0,handler(t,e){this.quill.format(n,!e.format[n],u.sources.USER)}}}function Ee(n){return{key:n?"ArrowUp":"ArrowDown",collapsed:!0,format:["table"],handler(t,e){const s=n?"prev":"next",i=e.line,r=i.parent[s];if(r!=null){if(r.statics.blotName==="table-row"){let l=r.children.head,o=i;for(;o.prev!=null;)o=o.prev,l=l.next;const a=l.offset(this.quill.scroll)+Math.min(e.offset,l.length()-1);this.quill.setSelection(a,0,u.sources.USER)}}else{const l=i.table()[s];l!=null&&(n?this.quill.setSelection(l.offset(this.quill.scroll)+l.length()-1,0,u.sources.USER):this.quill.setSelection(l.offset(this.quill.scroll),0,u.sources.USER))}return!1}}}function Ds(n){if(typeof n=="string"||typeof n=="number")n={key:n};else if(typeof n=="object")n=nt(n);else return null;return n.shortKey&&(n[Is]=n.shortKey,delete n.shortKey),n}function ie(n){let{quill:t,range:e}=n;const s=t.getLines(e);let i={};if(s.length>1){const r=s[0].formats(),l=s[s.length-1].formats();i=I.exports.AttributeMap.diff(l,r)||{}}t.deleteText(e,u.sources.USER),Object.keys(i).length>0&&t.formatLine(e.index,1,i,u.sources.USER),t.setSelection(e.index,u.sources.SILENT)}function Ms(n,t,e,s){return t.prev==null&&t.next==null?e.prev==null&&e.next==null?s===0?-1:1:e.prev==null?-1:1:t.prev==null?-1:t.next==null?1:null}const Us=/font-weight:\s*normal/,Fs=["P","OL","UL"],qe=n=>n&&Fs.includes(n.tagName),Ps=n=>{Array.from(n.querySelectorAll("br")).filter(t=>qe(t.previousElementSibling)&&qe(t.nextElementSibling)).forEach(t=>{var e;(e=t.parentNode)==null||e.removeChild(t)})},$s=n=>{Array.from(n.querySelectorAll('b[style*="font-weight"]')).filter(t=>{var e;return(e=t.getAttribute("style"))==null?void 0:e.match(Us)}).forEach(t=>{var s;const e=n.createDocumentFragment();e.append(...t.childNodes),(s=t.parentNode)==null||s.replaceChild(e,t)})};function Hs(n){n.querySelector('[id^="docs-internal-guid-"]')&&($s(n),Ps(n))}const zs=/\bmso-list:[^;]*ignore/i,_s=/\bmso-list:[^;]*\bl(\d+)/i,js=/\bmso-list:[^;]*\blevel(\d+)/i,Vs=(n,t)=>{const e=n.getAttribute("style"),s=e==null?void 0:e.match(_s);if(!s)return null;const i=Number(s[1]),r=e==null?void 0:e.match(js),l=r?Number(r[1]):1,o=new RegExp(`@list l${i}:level${l}\\s*\\{[^\\}]*mso-level-number-format:\\s*([\\w-]+)`,"i"),a=t.match(o),c=a&&a[1]==="bullet"?"bullet":"ordered";return{id:i,indent:l,type:c,element:n}},Ks=n=>{var l,o;const t=Array.from(n.querySelectorAll("[style*=mso-list]")),e=[],s=[];t.forEach(a=>{(a.getAttribute("style")||"").match(zs)?e.push(a):s.push(a)}),e.forEach(a=>{var c;return(c=a.parentNode)==null?void 0:c.removeChild(a)});const i=n.documentElement.innerHTML,r=s.map(a=>Vs(a,i)).filter(a=>a);for(;r.length;){const a=[];let c=r.shift();for(;c;)a.push(c),c=r.length&&((l=r[0])==null?void 0:l.element)===c.element.nextElementSibling&&r[0].id===c.id?r.shift():null;const h=document.createElement("ul");a.forEach(E=>{const p=document.createElement("li");p.setAttribute("data-list",E.type),E.indent>1&&p.setAttribute("class",`ql-indent-${E.indent-1}`),p.innerHTML=E.element.innerHTML,h.appendChild(p)});const m=(o=a[0])==null?void 0:o.element,{parentNode:b}=m!=null?m:{};m&&(b==null||b.replaceChild(h,m)),a.slice(1).forEach(E=>{let{element:p}=E;b==null||b.removeChild(p)})}};function Zs(n){n.documentElement.getAttribute("xmlns:w")==="urn:schemas-microsoft-com:office:word"&&Ks(n)}const Gs=[Zs,Hs],Ws=n=>{n.documentElement&&Gs.forEach(t=>{t(n)})},Xs=_("quill:clipboard"),Ys=[[Node.TEXT_NODE,ci],[Node.TEXT_NODE,Ne],["br",si],[Node.ELEMENT_NODE,Ne],[Node.ELEMENT_NODE,ei],[Node.ELEMENT_NODE,ti],[Node.ELEMENT_NODE,oi],["li",ri],["ol, ul",li],["pre",ii],["tr",ai],["b",Mt("bold")],["i",Mt("italic")],["strike",Mt("strike")],["style",ni]],Qs=[Ts,$e].reduce((n,t)=>(n[t.keyName]=t,n),{}),xe=[Fe,te,Jt,ze,Ve,Ze].reduce((n,t)=>(n[t.keyName]=t,n),{});class Ge extends M{constructor(t,e){var s;super(t,e),this.quill.root.addEventListener("copy",i=>this.onCaptureCopy(i,!1)),this.quill.root.addEventListener("cut",i=>this.onCaptureCopy(i,!0)),this.quill.root.addEventListener("paste",this.onCapturePaste.bind(this)),this.matchers=[],Ys.concat((s=this.options.matchers)!=null?s:[]).forEach(i=>{let[r,l]=i;this.addMatcher(r,l)})}addMatcher(t,e){this.matchers.push([t,e])}convert(t){let{html:e,text:s}=t,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(i[w.blotName])return new g().insert(s||"",{[w.blotName]:i[w.blotName]});if(!e)return new g().insert(s||"",i);const r=this.convertHTML(e);return gt(r,` `)&&(r.ops[r.ops.length-1].attributes==null||i.table)?r.compose(new g().retain(r.length()-1).delete(1)):r}normalizeHTML(t){Ws(t)}convertHTML(t){const e=new DOMParser().parseFromString(t,"text/html");this.normalizeHTML(e);const s=e.body,i=new WeakMap,[r,l]=this.prepareMatching(s,i);return ne(this.quill.scroll,s,r,l,i)}dangerouslyPasteHTML(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:u.sources.API;if(typeof t=="string"){const i=this.convert({html:t,text:""});this.quill.setContents(i,e),this.quill.setSelection(0,u.sources.SILENT)}else{const i=this.convert({html:e,text:""});this.quill.updateContents(new g().retain(t).concat(i),s),this.quill.setSelection(t+i.length(),u.sources.SILENT)}}onCaptureCopy(t){var l,o;let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(t.defaultPrevented)return;t.preventDefault();const[s]=this.quill.selection.getRange();if(s==null)return;const{html:i,text:r}=this.onCopy(s,e);(l=t.clipboardData)==null||l.setData("text/plain",r),(o=t.clipboardData)==null||o.setData("text/html",i),e&&ie({range:s,quill:this.quill})}normalizeURIList(t){return t.split(/\r?\n/).filter(e=>e[0]!=="#").join(` `)}onCapturePaste(t){var l,o,a,c,h;if(t.defaultPrevented||!this.quill.isEnabled())return;t.preventDefault();const e=this.quill.getSelection(!0);if(e==null)return;const s=(l=t.clipboardData)==null?void 0:l.getData("text/html");let i=(o=t.clipboardData)==null?void 0:o.getData("text/plain");if(!s&&!i){const m=(a=t.clipboardData)==null?void 0:a.getData("text/uri-list");m&&(i=this.normalizeURIList(m))}const r=Array.from(((c=t.clipboardData)==null?void 0:c.files)||[]);if(!s&&r.length>0){this.quill.uploader.upload(e,r);return}if(s&&r.length>0){const m=new DOMParser().parseFromString(s,"text/html");if(m.body.childElementCount===1&&((h=m.body.firstElementChild)==null?void 0:h.tagName)==="IMG"){this.quill.uploader.upload(e,r);return}}this.onPaste(e,{html:s,text:i})}onCopy(t){const e=this.quill.getText(t);return{html:this.quill.getSemanticHTML(t),text:e}}onPaste(t,e){let{text:s,html:i}=e;const r=this.quill.getFormat(t.index),l=this.convert({text:s,html:i},r);Xs.log("onPaste",l,{text:s,html:i});const o=new g().retain(t.index).delete(t.length).concat(l);this.quill.updateContents(o,u.sources.USER),this.quill.setSelection(o.length()-t.length,u.sources.SILENT),this.quill.scrollSelectionIntoView()}prepareMatching(t,e){const s=[],i=[];return this.matchers.forEach(r=>{const[l,o]=r;switch(l){case Node.TEXT_NODE:i.push(o);break;case Node.ELEMENT_NODE:s.push(o);break;default:Array.from(t.querySelectorAll(l)).forEach(a=>{if(e.has(a)){const c=e.get(a);c==null||c.push(o)}else e.set(a,[o])});break}}),[s,i]}}d(Ge,"DEFAULTS",{matchers:[]});function J(n,t,e,s){return s.query(t)?n.reduce((i,r)=>{if(!r.insert)return i;if(r.attributes&&r.attributes[t])return i.push(r);const l=e?{[t]:e}:{};return i.insert(r.insert,{...l,...r.attributes})},new g):n}function gt(n,t){let e="";for(let s=n.ops.length-1;s>=0&&e.lengthl(t,r,n),new g):t.nodeType===t.ELEMENT_NODE?Array.from(t.childNodes||[]).reduce((r,l)=>{let o=ne(n,l,e,s,i);return l.nodeType===t.ELEMENT_NODE&&(o=e.reduce((a,c)=>c(l,a,n),o),o=(i.get(l)||[]).reduce((a,c)=>c(l,a,n),o)),r.concat(o)},new g):new g}function Mt(n){return(t,e,s)=>J(e,n,!0,s)}function ti(n,t,e){const s=Wt.keys(n),i=z.keys(n),r=ot.keys(n),l={};return s.concat(i).concat(r).forEach(o=>{let a=e.query(o,q.ATTRIBUTE);a!=null&&(l[a.attrName]=a.value(n),l[a.attrName])||(a=Qs[o],a!=null&&(a.attrName===o||a.keyName===o)&&(l[a.attrName]=a.value(n)||void 0),a=xe[o],a!=null&&(a.attrName===o||a.keyName===o)&&(a=xe[o],l[a.attrName]=a.value(n)||void 0))}),Object.entries(l).reduce((o,a)=>{let[c,h]=a;return J(o,c,h,e)},t)}function ei(n,t,e){const s=e.query(n);if(s==null)return t;if(s.prototype instanceof C){const i={},r=s.value(n);if(r!=null)return i[s.blotName]=r,new g().insert(i,s.formats(n,e))}else if(s.prototype instanceof Re&&!gt(t,` `)&&t.insert(` `),"blotName"in s&&"formats"in s&&typeof s.formats=="function")return J(t,s.blotName,s.formats(n,e),e);return t}function si(n,t){return gt(t,` `)||t.insert(` `),t}function ii(n,t,e){const s=e.query("code-block"),i=s&&"formats"in s&&typeof s.formats=="function"?s.formats(n,e):!0;return J(t,"code-block",i,e)}function ni(){return new g}function ri(n,t,e){const s=e.query(n);if(s==null||s.blotName!=="list"||!gt(t,` `))return t;let i=-1,r=n.parentNode;for(;r!=null;)["OL","UL"].includes(r.tagName)&&(i+=1),r=r.parentNode;return i<=0?t:t.reduce((l,o)=>o.insert?o.attributes&&typeof o.attributes.indent=="number"?l.push(o):l.insert(o.insert,{indent:i,...o.attributes||{}}):l,new g)}function li(n,t,e){const s=n;let i=s.tagName==="OL"?"ordered":"bullet";const r=s.getAttribute("data-checked");return r&&(i=r==="true"?"checked":"unchecked"),J(t,"list",i,e)}function Ne(n,t,e){if(!gt(t,` `)){if(Z(n,e)&&(n.childNodes.length>0||n instanceof HTMLParagraphElement))return t.insert(` `);if(t.length()>0&&n.nextSibling){let s=n.nextSibling;for(;s!=null;){if(Z(s,e))return t.insert(` `);const i=e.query(s);if(i&&i.prototype instanceof T)return t.insert(` `);s=s.firstChild}}}return t}function oi(n,t,e){var r;const s={},i=n.style||{};return i.fontStyle==="italic"&&(s.italic=!0),i.textDecoration==="underline"&&(s.underline=!0),i.textDecoration==="line-through"&&(s.strike=!0),(((r=i.fontWeight)==null?void 0:r.startsWith("bold"))||parseInt(i.fontWeight,10)>=700)&&(s.bold=!0),t=Object.entries(s).reduce((l,o)=>{let[a,c]=o;return J(l,a,c,e)},t),parseFloat(i.textIndent||0)>0?new g().insert(" ").concat(t):t}function ai(n,t,e){var i,r;const s=((i=n.parentElement)==null?void 0:i.tagName)==="TABLE"?n.parentElement:(r=n.parentElement)==null?void 0:r.parentElement;if(s!=null){const o=Array.from(s.querySelectorAll("tr")).indexOf(n)+1;return J(t,"table",o,e)}return t}function ci(n,t,e){var i;let s=n.data;if(((i=n.parentElement)==null?void 0:i.tagName)==="O:P")return t.insert(s.trim());if(!We(n)){if(s.trim().length===0&&s.includes(` `)&&!Js(n,e))return t;const r=(l,o)=>{const a=o.replace(/[^\u00a0]/g,"");return a.length<1&&l?" ":a};s=s.replace(/\r\n/g," ").replace(/\n/g," "),s=s.replace(/\s\s+/g,r.bind(r,!0)),(n.previousSibling==null&&n.parentElement!=null&&Z(n.parentElement,e)||n.previousSibling instanceof Element&&Z(n.previousSibling,e))&&(s=s.replace(/^\s+/,r.bind(r,!1))),(n.nextSibling==null&&n.parentElement!=null&&Z(n.parentElement,e)||n.nextSibling instanceof Element&&Z(n.nextSibling,e))&&(s=s.replace(/\s+$/,r.bind(r,!1)))}return t.insert(s)}class Xe extends M{constructor(e,s){super(e,s);d(this,"lastRecorded",0);d(this,"ignoreChange",!1);d(this,"stack",{undo:[],redo:[]});d(this,"currentRange",null);this.quill.on(u.events.EDITOR_CHANGE,(i,r,l,o)=>{i===u.events.SELECTION_CHANGE?r&&o!==u.sources.SILENT&&(this.currentRange=r):i===u.events.TEXT_CHANGE&&(this.ignoreChange||(!this.options.userOnly||o===u.sources.USER?this.record(r,l):this.transform(r)),this.currentRange=Ht(this.currentRange,r))}),this.quill.keyboard.addBinding({key:"z",shortKey:!0},this.undo.bind(this)),this.quill.keyboard.addBinding({key:["z","Z"],shortKey:!0,shiftKey:!0},this.redo.bind(this)),/Win/i.test(navigator.platform)&&this.quill.keyboard.addBinding({key:"y",shortKey:!0},this.redo.bind(this)),this.quill.root.addEventListener("beforeinput",i=>{i.inputType==="historyUndo"?(this.undo(),i.preventDefault()):i.inputType==="historyRedo"&&(this.redo(),i.preventDefault())})}change(e,s){if(this.stack[e].length===0)return;const i=this.stack[e].pop();if(!i)return;const r=this.quill.getContents(),l=i.delta.invert(r);this.stack[s].push({delta:l,range:Ht(i.range,l)}),this.lastRecorded=0,this.ignoreChange=!0,this.quill.updateContents(i.delta,u.sources.USER),this.ignoreChange=!1,this.restoreSelection(i)}clear(){this.stack={undo:[],redo:[]}}cutoff(){this.lastRecorded=0}record(e,s){if(e.ops.length===0)return;this.stack.redo=[];let i=e.invert(s),r=this.currentRange;const l=Date.now();if(this.lastRecorded+this.options.delay>l&&this.stack.undo.length>0){const o=this.stack.undo.pop();o&&(i=i.compose(o.delta),r=o.range)}else this.lastRecorded=l;i.length()!==0&&(this.stack.undo.push({delta:i,range:r}),this.stack.undo.length>this.options.maxStack&&this.stack.undo.shift())}redo(){this.change("redo","undo")}transform(e){we(this.stack.undo,e),we(this.stack.redo,e)}undo(){this.change("undo","redo")}restoreSelection(e){if(e.range)this.quill.setSelection(e.range,u.sources.USER);else{const s=hi(this.quill.scroll,e.delta);this.quill.setSelection(s,u.sources.USER)}}}d(Xe,"DEFAULTS",{delay:1e3,maxStack:100,userOnly:!1});function we(n,t){let e=t;for(let s=n.length-1;s>=0;s-=1){const i=n[s];n[s]={delta:e.transform(i.delta,!0),range:i.range&&Ht(i.range,e)},e=i.delta.transform(e),n[s].delta.length()===0&&n.splice(s,1)}}function ui(n,t){const e=t.ops[t.ops.length-1];return e==null?!1:e.insert!=null?typeof e.insert=="string"&&e.insert.endsWith(` `):e.attributes!=null?Object.keys(e.attributes).some(s=>n.query(s,q.BLOCK)!=null):!1}function hi(n,t){const e=t.reduce((i,r)=>i+(r.delete||0),0);let s=t.length()-e;return ui(n,t)&&(s-=1),s}function Ht(n,t){if(!n)return n;const e=t.transformPosition(n.index),s=t.transformPosition(n.index+n.length);return{index:e,length:s-e}}class Ye extends M{constructor(t,e){super(t,e),t.root.addEventListener("drop",s=>{var l;s.preventDefault();let i=null;if(document.caretRangeFromPoint)i=document.caretRangeFromPoint(s.clientX,s.clientY);else if(document.caretPositionFromPoint){const o=document.caretPositionFromPoint(s.clientX,s.clientY);i=document.createRange(),i.setStart(o.offsetNode,o.offset),i.setEnd(o.offsetNode,o.offset)}const r=i&&t.selection.normalizeNative(i);if(r){const o=t.selection.normalizedToRange(r);(l=s.dataTransfer)!=null&&l.files&&this.upload(o,s.dataTransfer.files)}})}upload(t,e){const s=[];Array.from(e).forEach(i=>{var r;i&&((r=this.options.mimetypes)==null?void 0:r.includes(i.type))&&s.push(i)}),s.length>0&&this.options.handler.call(this,t,s)}}Ye.DEFAULTS={mimetypes:["image/png","image/jpeg"],handler(n,t){const e=t.map(s=>new Promise(i=>{const r=new FileReader;r.onload=l=>{i(l.target.result)},r.readAsDataURL(s)}));Promise.all(e).then(s=>{const i=s.reduce((r,l)=>r.insert({image:l}),new g().retain(n.index).delete(n.length));this.quill.updateContents(i,f.sources.USER),this.quill.setSelection(n.index+s.length,f.sources.SILENT)})}};const di=["insertText","insertReplacementText"];class fi extends M{constructor(t,e){super(t,e),t.root.addEventListener("beforeinput",s=>{this.handleBeforeInput(s)}),/Android/i.test(navigator.userAgent)||t.on(u.events.COMPOSITION_BEFORE_START,()=>{this.handleCompositionStart()})}deleteRange(t){ie({range:t,quill:this.quill})}replaceText(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";if(t.length===0)return!1;if(e){const s=this.quill.getFormat(t.index,1);this.deleteRange(t),this.quill.updateContents(new g().retain(t.index).insert(e,s),u.sources.USER)}else this.deleteRange(t);return this.quill.setSelection(t.index+e.length,0,u.sources.SILENT),!0}handleBeforeInput(t){if(this.quill.composition.isComposing||t.defaultPrevented||!di.includes(t.inputType))return;const e=t.getTargetRanges?t.getTargetRanges()[0]:null;if(!e||e.collapsed===!0)return;const s=gi(t);if(s==null)return;const i=this.quill.selection.normalizeNative(e),r=i?this.quill.selection.normalizedToRange(i):null;r&&this.replaceText(r,s)&&t.preventDefault()}handleCompositionStart(){const t=this.quill.getSelection();t&&this.replaceText(t)}}function gi(n){var t;return typeof n.data=="string"?n.data:(t=n.dataTransfer)!=null&&t.types.includes("text/plain")?n.dataTransfer.getData("text/plain"):null}const mi=/Mac/i.test(navigator.platform),pi=100,bi=n=>!!(n.key==="ArrowLeft"||n.key==="ArrowRight"||n.key==="ArrowUp"||n.key==="ArrowDown"||n.key==="Home"||mi&&n.key==="a"&&n.ctrlKey===!0);class yi extends M{constructor(e,s){super(e,s);d(this,"isListening",!1);d(this,"selectionChangeDeadline",0);this.handleArrowKeys(),this.handleNavigationShortcuts()}handleArrowKeys(){this.quill.keyboard.addBinding({key:["ArrowLeft","ArrowRight"],offset:0,shiftKey:null,handler(e,s){let{line:i,event:r}=s;if(!(i instanceof At)||!i.uiNode)return!0;const l=getComputedStyle(i.domNode).direction==="rtl";return l&&r.key!=="ArrowRight"||!l&&r.key!=="ArrowLeft"?!0:(this.quill.setSelection(e.index-1,e.length+(r.shiftKey?1:0),u.sources.USER),!1)}})}handleNavigationShortcuts(){this.quill.root.addEventListener("keydown",e=>{!e.defaultPrevented&&bi(e)&&this.ensureListeningToSelectionChange()})}ensureListeningToSelectionChange(){if(this.selectionChangeDeadline=Date.now()+pi,this.isListening)return;this.isListening=!0;const e=()=>{this.isListening=!1,Date.now()<=this.selectionChangeDeadline&&this.handleSelectionChange()};document.addEventListener("selectionchange",e,{once:!0})}handleSelectionChange(){const e=document.getSelection();if(!e)return;const s=e.getRangeAt(0);if(s.collapsed!==!0||s.startOffset!==0)return;const i=this.quill.scroll.find(s.startContainer);if(!(i instanceof At)||!i.uiNode)return;const r=document.createRange();r.setStartAfter(i.uiNode),r.setEndAfter(i.uiNode),e.removeAllRanges(),e.addRange(r)}}u.register({"blots/block":N,"blots/block/embed":T,"blots/break":D,"blots/container":Y,"blots/cursor":U,"blots/embed":Yt,"blots/inline":S,"blots/scroll":st,"blots/text":B,"modules/clipboard":Ge,"modules/history":Xe,"modules/keyboard":vt,"modules/uploader":Ye,"modules/input":fi,"modules/uiNode":yi});class Ei extends z{add(t,e){let s=0;if(e==="+1"||e==="-1"){const i=this.value(t)||0;s=e==="+1"?i+1:i-1}else typeof e=="number"&&(s=e);return s===0?(this.remove(t),!0):super.add(t,s.toString())}canAdd(t,e){return super.canAdd(t,e)||super.canAdd(t,parseInt(e,10))}value(t){return parseInt(super.value(t),10)||void 0}}const qi=new Ei("indent","ql-indent",{scope:q.BLOCK,whitelist:[1,2,3,4,5,6,7,8]});class zt extends N{}d(zt,"blotName","blockquote"),d(zt,"tagName","blockquote");class _t extends N{static formats(t){return this.tagName.indexOf(t.tagName)+1}}d(_t,"blotName","header"),d(_t,"tagName",["H1","H2","H3","H4","H5","H6"]);class mt extends Y{}mt.blotName="list-container";mt.tagName="OL";class pt extends N{static create(t){const e=super.create();return e.setAttribute("data-list",t),e}static formats(t){return t.getAttribute("data-list")||void 0}static register(){u.register(mt)}constructor(t,e){super(t,e);const s=e.ownerDocument.createElement("span"),i=r=>{if(!t.isEnabled())return;const l=this.statics.formats(e,t);l==="checked"?(this.format("list","unchecked"),r.preventDefault()):l==="unchecked"&&(this.format("list","checked"),r.preventDefault())};s.addEventListener("mousedown",i),s.addEventListener("touchstart",i),this.attachUI(s)}format(t,e){t===this.statics.blotName&&e?this.domNode.setAttribute("data-list",e):super.format(t,e)}}pt.blotName="list";pt.tagName="LI";mt.allowedChildren=[pt];pt.requiredContainer=mt;class dt extends S{static create(){return super.create()}static formats(){return!0}optimize(t){super.optimize(t),this.domNode.tagName!==this.statics.tagName[0]&&this.replaceWith(this.statics.blotName)}}d(dt,"blotName","bold"),d(dt,"tagName",["STRONG","B"]);class jt extends dt{}d(jt,"blotName","italic"),d(jt,"tagName",["EM","I"]);class G extends S{static create(t){const e=super.create(t);return e.setAttribute("href",this.sanitize(t)),e.setAttribute("rel","noopener noreferrer"),e.setAttribute("target","_blank"),e}static formats(t){return t.getAttribute("href")}static sanitize(t){return Qe(t,this.PROTOCOL_WHITELIST)?t:this.SANITIZED_URL}format(t,e){t!==this.statics.blotName||!e?super.format(t,e):this.domNode.setAttribute("href",this.constructor.sanitize(e))}}d(G,"blotName","link"),d(G,"tagName","A"),d(G,"SANITIZED_URL","about:blank"),d(G,"PROTOCOL_WHITELIST",["http","https","mailto","tel","sms"]);function Qe(n,t){const e=document.createElement("a");e.href=n;const s=e.href.slice(0,e.href.indexOf(":"));return t.indexOf(s)>-1}class Vt extends S{static create(t){return t==="super"?document.createElement("sup"):t==="sub"?document.createElement("sub"):super.create(t)}static formats(t){if(t.tagName==="SUB")return"sub";if(t.tagName==="SUP")return"super"}}d(Vt,"blotName","script"),d(Vt,"tagName",["SUB","SUP"]);class Kt extends dt{}d(Kt,"blotName","strike"),d(Kt,"tagName",["S","STRIKE"]);class Zt extends S{}d(Zt,"blotName","underline"),d(Zt,"tagName","U");class wt extends Yt{static create(t){if(window.katex==null)throw new Error("Formula module requires KaTeX.");const e=super.create(t);return typeof t=="string"&&(window.katex.render(t,e,{throwOnError:!1,errorColor:"#f00"}),e.setAttribute("data-value",t)),e}static value(t){return t.getAttribute("data-value")}html(){const{formula:t}=this.value();return`${t}`}}d(wt,"blotName","formula"),d(wt,"className","ql-formula"),d(wt,"tagName","SPAN");const ke=["alt","height","width"];class Gt extends C{static create(t){const e=super.create(t);return typeof t=="string"&&e.setAttribute("src",this.sanitize(t)),e}static formats(t){return ke.reduce((e,s)=>(t.hasAttribute(s)&&(e[s]=t.getAttribute(s)),e),{})}static match(t){return/\.(jpe?g|gif|png)$/.test(t)||/^data:image\/.+;base64/.test(t)}static sanitize(t){return Qe(t,["http","https","data"])?t:"//:0"}static value(t){return t.getAttribute("src")}format(t,e){ke.indexOf(t)>-1?e?this.domNode.setAttribute(t,e):this.domNode.removeAttribute(t):super.format(t,e)}}d(Gt,"blotName","image"),d(Gt,"tagName","IMG");const Ae=["height","width"];class kt extends T{static create(t){const e=super.create(t);return e.setAttribute("frameborder","0"),e.setAttribute("allowfullscreen","true"),e.setAttribute("src",this.sanitize(t)),e}static formats(t){return Ae.reduce((e,s)=>(t.hasAttribute(s)&&(e[s]=t.getAttribute(s)),e),{})}static sanitize(t){return G.sanitize(t)}static value(t){return t.getAttribute("src")}format(t,e){Ae.indexOf(t)>-1?e?this.domNode.setAttribute(t,e):this.domNode.removeAttribute(t):super.format(t,e)}html(){const{video:t}=this.value();return`${t}`}}d(kt,"blotName","video"),d(kt,"className","ql-video"),d(kt,"tagName","IFRAME");const ct=new z("code-token","hljs",{scope:q.INLINE});class $ extends S{static formats(t,e){for(;t!=null&&t!==e.domNode;){if(t.classList&&t.classList.contains(w.className))return super.formats(t,e);t=t.parentNode}}constructor(t,e,s){super(t,e,s),ct.add(this.domNode,s)}format(t,e){t!==$.blotName?super.format(t,e):e?ct.add(this.domNode,e):(ct.remove(this.domNode),this.domNode.classList.remove(this.statics.className))}optimize(){super.optimize(...arguments),ct.value(this.domNode)||this.unwrap()}}$.blotName="code-token";$.className="ql-token";class v extends w{static create(t){const e=super.create(t);return typeof t=="string"&&e.setAttribute("data-language",t),e}static formats(t){return t.getAttribute("data-language")||"plain"}static register(){}format(t,e){t===this.statics.blotName&&e?this.domNode.setAttribute("data-language",e):super.format(t,e)}replaceWith(t,e){return this.formatAt(0,this.length(),$.blotName,!1),super.replaceWith(t,e)}}class ut extends Q{attach(){super.attach(),this.forceNext=!1,this.scroll.emitMount(this)}format(t,e){t===v.blotName&&(this.forceNext=!0,this.children.forEach(s=>{s.format(t,e)}))}formatAt(t,e,s,i){s===v.blotName&&(this.forceNext=!0),super.formatAt(t,e,s,i)}highlight(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(this.children.head==null)return;const i=`${Array.from(this.domNode.childNodes).filter(l=>l!==this.uiNode).map(l=>l.textContent).join(` `)} `,r=v.formats(this.children.head.domNode);if(e||this.forceNext||this.cachedText!==i){if(i.trim().length>0||this.cachedText==null){const l=this.children.reduce((a,c)=>a.concat(De(c,!1)),new g),o=t(i,r);l.diff(o).reduce((a,c)=>{let{retain:h,attributes:m}=c;return h?(m&&Object.keys(m).forEach(b=>{[v.blotName,$.blotName].includes(b)&&this.formatAt(a,h,b,m[b])}),a+h):a},0)}this.cachedText=i,this.forceNext=!1}}html(t,e){const[s]=this.children.find(t);return`
    ${Lt(this.code(t,e))}
    
    `}optimize(t){if(super.optimize(t),this.parent!=null&&this.children.head!=null&&this.uiNode!=null){const e=v.formats(this.children.head.domNode);e!==this.uiNode.value&&(this.uiNode.value=e)}}}ut.allowedChildren=[v];v.requiredContainer=ut;v.allowedChildren=[$,U,B,D];const xi=(n,t,e)=>{if(typeof n.versionString=="string"){const s=n.versionString.split(".")[0];if(parseInt(s,10)>=11)return n.highlight(e,{language:t}).value}return n.highlight(t,e).value};class Je extends M{static register(){u.register($,!0),u.register(v,!0),u.register(ut,!0)}constructor(t,e){if(super(t,e),this.options.hljs==null)throw new Error("Syntax module requires highlight.js. Please include the library on the page before Quill.");this.languages=this.options.languages.reduce((s,i)=>{let{key:r}=i;return s[r]=!0,s},{}),this.highlightBlot=this.highlightBlot.bind(this),this.initListener(),this.initTimer()}initListener(){this.quill.on(u.events.SCROLL_BLOT_MOUNT,t=>{if(!(t instanceof ut))return;const e=this.quill.root.ownerDocument.createElement("select");this.options.languages.forEach(s=>{let{key:i,label:r}=s;const l=e.ownerDocument.createElement("option");l.textContent=r,l.setAttribute("value",i),e.appendChild(l)}),e.addEventListener("change",()=>{t.format(v.blotName,e.value),this.quill.root.focus(),this.highlight(t,!0)}),t.uiNode==null&&(t.attachUI(e),t.children.head&&(e.value=v.formats(t.children.head.domNode)))})}initTimer(){let t=null;this.quill.on(u.events.SCROLL_OPTIMIZE,()=>{t&&clearTimeout(t),t=setTimeout(()=>{this.highlight(),t=null},this.options.interval)})}highlight(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(this.quill.selection.composing)return;this.quill.update(u.sources.USER);const s=this.quill.getSelection();(t==null?this.quill.scroll.descendants(ut):[t]).forEach(r=>{r.highlight(this.highlightBlot,e)}),this.quill.update(u.sources.SILENT),s!=null&&this.quill.setSelection(s,u.sources.SILENT)}highlightBlot(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"plain";if(e=this.languages[e]?e:"plain",e==="plain")return Lt(t).split(` `).reduce((i,r,l)=>(l!==0&&i.insert(` `,{[w.blotName]:e}),i.insert(r)),new g);const s=this.quill.root.ownerDocument.createElement("div");return s.classList.add(w.className),s.innerHTML=xi(this.options.hljs,e,t),ne(this.quill.scroll,s,[(i,r)=>{const l=ct.value(i);return l?r.compose(new g().retain(r.length(),{[$.blotName]:l})):r}],[(i,r)=>i.data.split(` `).reduce((l,o,a)=>(a!==0&&l.insert(` `,{[w.blotName]:e}),l.insert(o)),r)],new WeakMap)}}Je.DEFAULTS={hljs:(()=>window.hljs)(),interval:1e3,languages:[{key:"plain",label:"Plain"},{key:"bash",label:"Bash"},{key:"cpp",label:"C++"},{key:"cs",label:"C#"},{key:"css",label:"CSS"},{key:"diff",label:"Diff"},{key:"xml",label:"HTML/XML"},{key:"java",label:"Java"},{key:"javascript",label:"JavaScript"},{key:"markdown",label:"Markdown"},{key:"php",label:"PHP"},{key:"python",label:"Python"},{key:"ruby",label:"Ruby"},{key:"sql",label:"SQL"}]};const ae=class extends N{static create(t){const e=super.create();return t?e.setAttribute("data-row",t):e.setAttribute("data-row",re()),e}static formats(t){if(t.hasAttribute("data-row"))return t.getAttribute("data-row")}cellOffset(){return this.parent?this.parent.children.indexOf(this):-1}format(t,e){t===ae.blotName&&e?this.domNode.setAttribute("data-row",e):super.format(t,e)}row(){return this.parent}rowOffset(){return this.row()?this.row().rowOffset():-1}table(){return this.row()&&this.row().table()}};let k=ae;d(k,"blotName","table"),d(k,"tagName","TD");class H extends Y{checkMerge(){if(super.checkMerge()&&this.next.children.head!=null){const t=this.children.head.formats(),e=this.children.tail.formats(),s=this.next.children.head.formats(),i=this.next.children.tail.formats();return t.table===e.table&&t.table===s.table&&t.table===i.table}return!1}optimize(t){super.optimize(t),this.children.forEach(e=>{if(e.next==null)return;const s=e.formats(),i=e.next.formats();if(s.table!==i.table){const r=this.splitAfter(e);r&&r.optimize(),this.prev&&this.prev.optimize()}})}rowOffset(){return this.parent?this.parent.children.indexOf(this):-1}table(){return this.parent&&this.parent.parent}}d(H,"blotName","table-row"),d(H,"tagName","TR");class F extends Y{}d(F,"blotName","table-body"),d(F,"tagName","TBODY");class lt extends Y{balanceCells(){const t=this.descendants(H),e=t.reduce((s,i)=>Math.max(i.children.length,s),0);t.forEach(s=>{new Array(e-s.children.length).fill(0).forEach(()=>{let i;s.children.head!=null&&(i=k.formats(s.children.head.domNode));const r=this.scroll.create(k.blotName,i);s.appendChild(r),r.optimize()})})}cells(t){return this.rows().map(e=>e.children.at(t))}deleteColumn(t){const[e]=this.descendant(F);e==null||e.children.head==null||e.children.forEach(s=>{const i=s.children.at(t);i!=null&&i.remove()})}insertColumn(t){const[e]=this.descendant(F);e==null||e.children.head==null||e.children.forEach(s=>{const i=s.children.at(t),r=k.formats(s.children.head.domNode),l=this.scroll.create(k.blotName,r);s.insertBefore(l,i)})}insertRow(t){const[e]=this.descendant(F);if(e==null||e.children.head==null)return;const s=re(),i=this.scroll.create(H.blotName);e.children.head.children.forEach(()=>{const l=this.scroll.create(k.blotName,s);i.appendChild(l)});const r=e.children.at(t);e.insertBefore(i,r)}rows(){const t=this.children.head;return t==null?[]:t.children.map(e=>e)}}d(lt,"blotName","table-container"),d(lt,"tagName","TABLE");lt.allowedChildren=[F];F.requiredContainer=lt;F.allowedChildren=[H];H.requiredContainer=F;H.allowedChildren=[k];k.requiredContainer=H;function re(){return`row-${Math.random().toString(36).slice(2,6)}`}class Ni extends M{static register(){u.register(k),u.register(H),u.register(F),u.register(lt)}constructor(){super(...arguments),this.listenBalanceCells()}balanceTables(){this.quill.scroll.descendants(lt).forEach(t=>{t.balanceCells()})}deleteColumn(){const[t,,e]=this.getTable();e!=null&&(t.deleteColumn(e.cellOffset()),this.quill.update(u.sources.USER))}deleteRow(){const[,t]=this.getTable();t!=null&&(t.remove(),this.quill.update(u.sources.USER))}deleteTable(){const[t]=this.getTable();if(t==null)return;const e=t.offset();t.remove(),this.quill.update(u.sources.USER),this.quill.setSelection(e,u.sources.SILENT)}getTable(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.quill.getSelection();if(t==null)return[null,null,null,-1];const[e,s]=this.quill.getLine(t.index);if(e==null||e.statics.blotName!==k.blotName)return[null,null,null,-1];const i=e.parent;return[i.parent.parent,i,e,s]}insertColumn(t){const e=this.quill.getSelection();if(!e)return;const[s,i,r]=this.getTable(e);if(r==null)return;const l=r.cellOffset();s.insertColumn(l+t),this.quill.update(u.sources.USER);let o=i.rowOffset();t===0&&(o+=1),this.quill.setSelection(e.index+o,e.length,u.sources.SILENT)}insertColumnLeft(){this.insertColumn(0)}insertColumnRight(){this.insertColumn(1)}insertRow(t){const e=this.quill.getSelection();if(!e)return;const[s,i,r]=this.getTable(e);if(r==null)return;const l=i.rowOffset();s.insertRow(l+t),this.quill.update(u.sources.USER),t>0?this.quill.setSelection(e,u.sources.SILENT):this.quill.setSelection(e.index+i.children.length,e.length,u.sources.SILENT)}insertRowAbove(){this.insertRow(0)}insertRowBelow(){this.insertRow(1)}insertTable(t,e){const s=this.quill.getSelection();if(s==null)return;const i=new Array(t).fill(0).reduce(r=>{const l=new Array(e).fill(` `).join("");return r.insert(l,{table:re()})},new g().retain(s.index));this.quill.updateContents(i,u.sources.USER),this.quill.setSelection(s.index,u.sources.SILENT),this.balanceTables()}listenBalanceCells(){this.quill.on(u.events.SCROLL_OPTIMIZE,t=>{t.some(e=>["TD","TR","TBODY","TABLE"].includes(e.target.tagName)?(this.quill.once(u.events.TEXT_CHANGE,(s,i,r)=>{r===u.sources.USER&&this.balanceTables()}),!0):!1)})}}const Le=_("quill:toolbar");class le extends M{constructor(t,e){var s,i;if(super(t,e),Array.isArray(this.options.container)){const r=document.createElement("div");r.setAttribute("role","toolbar"),wi(r,this.options.container),(i=(s=t.container)==null?void 0:s.parentNode)==null||i.insertBefore(r,t.container),this.container=r}else typeof this.options.container=="string"?this.container=document.querySelector(this.options.container):this.container=this.options.container;if(!(this.container instanceof HTMLElement)){Le.error("Container required for toolbar",this.options);return}this.container.classList.add("ql-toolbar"),this.controls=[],this.handlers={},this.options.handlers&&Object.keys(this.options.handlers).forEach(r=>{var o;const l=(o=this.options.handlers)==null?void 0:o[r];l&&this.addHandler(r,l)}),Array.from(this.container.querySelectorAll("button, select")).forEach(r=>{this.attach(r)}),this.quill.on(u.events.EDITOR_CHANGE,()=>{const[r]=this.quill.selection.getRange();this.update(r)})}addHandler(t,e){this.handlers[t]=e}attach(t){let e=Array.from(t.classList).find(i=>i.indexOf("ql-")===0);if(!e)return;if(e=e.slice(3),t.tagName==="BUTTON"&&t.setAttribute("type","button"),this.handlers[e]==null&&this.quill.scroll.query(e)==null){Le.warn("ignoring attaching to nonexistent format",e,t);return}const s=t.tagName==="SELECT"?"change":"click";t.addEventListener(s,i=>{let r;if(t.tagName==="SELECT"){if(t.selectedIndex<0)return;const o=t.options[t.selectedIndex];o.hasAttribute("selected")?r=!1:r=o.value||!1}else t.classList.contains("ql-active")?r=!1:r=t.value||!t.hasAttribute("value"),i.preventDefault();this.quill.focus();const[l]=this.quill.selection.getRange();if(this.handlers[e]!=null)this.handlers[e].call(this,r);else if(this.quill.scroll.query(e).prototype instanceof C){if(r=prompt(`Enter ${e}`),!r)return;this.quill.updateContents(new g().retain(l.index).delete(l.length).insert({[e]:r}),u.sources.USER)}else this.quill.format(e,r,u.sources.USER);this.update(l)}),this.controls.push([e,t])}update(t){const e=t==null?{}:this.quill.getFormat(t);this.controls.forEach(s=>{const[i,r]=s;if(r.tagName==="SELECT"){let l=null;if(t==null)l=null;else if(e[i]==null)l=r.querySelector("option[selected]");else if(!Array.isArray(e[i])){let o=e[i];typeof o=="string"&&(o=o.replace(/"/g,'\\"')),l=r.querySelector(`option[value="${o}"]`)}l==null?(r.value="",r.selectedIndex=-1):l.selected=!0}else if(t==null)r.classList.remove("ql-active"),r.setAttribute("aria-pressed","false");else if(r.hasAttribute("value")){const l=e[i],o=l===r.getAttribute("value")||l!=null&&l.toString()===r.getAttribute("value")||l==null&&!r.getAttribute("value");r.classList.toggle("ql-active",o),r.setAttribute("aria-pressed",o.toString())}else{const l=e[i]!=null;r.classList.toggle("ql-active",l),r.setAttribute("aria-pressed",l.toString())}})}}le.DEFAULTS={};function ve(n,t,e){const s=document.createElement("button");s.setAttribute("type","button"),s.classList.add(`ql-${t}`),s.setAttribute("aria-pressed","false"),e!=null?(s.value=e,s.setAttribute("aria-label",`${t}: ${e}`)):s.setAttribute("aria-label",t),n.appendChild(s)}function wi(n,t){Array.isArray(t[0])||(t=[t]),t.forEach(e=>{const s=document.createElement("span");s.classList.add("ql-formats"),e.forEach(i=>{if(typeof i=="string")ve(s,i);else{const r=Object.keys(i)[0],l=i[r];Array.isArray(l)?ki(s,r,l):ve(s,r,l)}}),n.appendChild(s)})}function ki(n,t,e){const s=document.createElement("select");s.classList.add(`ql-${t}`),e.forEach(i=>{const r=document.createElement("option");i!==!1?r.setAttribute("value",String(i)):r.setAttribute("selected","selected"),s.appendChild(r)}),n.appendChild(s)}le.DEFAULTS={container:null,handlers:{clean(){const n=this.quill.getSelection();if(n!=null)if(n.length===0){const t=this.quill.getFormat();Object.keys(t).forEach(e=>{this.quill.scroll.query(e,q.INLINE)!=null&&this.quill.format(e,!1,u.sources.USER)})}else this.quill.removeFormat(n,u.sources.USER)},direction(n){const{align:t}=this.quill.getFormat();n==="rtl"&&t==null?this.quill.format("align","right",u.sources.USER):!n&&t==="right"&&this.quill.format("align",!1,u.sources.USER),this.quill.format("direction",n,u.sources.USER)},indent(n){const t=this.quill.getSelection(),e=this.quill.getFormat(t),s=parseInt(e.indent||0,10);if(n==="+1"||n==="-1"){let i=n==="+1"?1:-1;e.direction==="rtl"&&(i*=-1),this.quill.format("indent",s+i,u.sources.USER)}},link(n){n===!0&&(n=prompt("Enter link URL:")),this.quill.format("link",n,u.sources.USER)},list(n){const t=this.quill.getSelection(),e=this.quill.getFormat(t);n==="check"?e.list==="checked"||e.list==="unchecked"?this.quill.format("list",!1,u.sources.USER):this.quill.format("list","unchecked",u.sources.USER):this.quill.format("list",n,u.sources.USER)}}};const Ai='',Li='',vi='',Ti='',Si='',Ci='',Ri='',Oi='',Te='',Ii='',Bi='',Di='',Mi='',Ui='',Fi='',Pi='',$i='',Hi='',zi='',_i='',ji='',Vi='',Ki='',Zi='',Gi='',Wi='',Xi='',Yi='',Qi='';var ft={align:{"":Ai,center:Li,right:vi,justify:Ti},background:Si,blockquote:Ci,bold:Ri,clean:Oi,code:Te,"code-block":Te,color:Ii,direction:{"":Bi,rtl:Di},formula:Mi,header:{1:Ui,2:Fi},italic:Pi,image:$i,indent:{"+1":Hi,"-1":zi},link:_i,list:{bullet:ji,check:Vi,ordered:Ki},script:{sub:Zi,super:Gi},strike:Wi,table:Xi,underline:Yi,video:Qi};const Ji='';let Se=0;function Ce(n,t){n.setAttribute(t,`${n.getAttribute(t)!=="true"}`)}class Tt{constructor(t){this.select=t,this.container=document.createElement("span"),this.buildPicker(),this.select.style.display="none",this.select.parentNode.insertBefore(this.container,this.select),this.label.addEventListener("mousedown",()=>{this.togglePicker()}),this.label.addEventListener("keydown",e=>{switch(e.key){case"Enter":this.togglePicker();break;case"Escape":this.escape(),e.preventDefault();break}}),this.select.addEventListener("change",this.update.bind(this))}togglePicker(){this.container.classList.toggle("ql-expanded"),Ce(this.label,"aria-expanded"),Ce(this.options,"aria-hidden")}buildItem(t){const e=document.createElement("span");e.tabIndex="0",e.setAttribute("role","button"),e.classList.add("ql-picker-item");const s=t.getAttribute("value");return s&&e.setAttribute("data-value",s),t.textContent&&e.setAttribute("data-label",t.textContent),e.addEventListener("click",()=>{this.selectItem(e,!0)}),e.addEventListener("keydown",i=>{switch(i.key){case"Enter":this.selectItem(e,!0),i.preventDefault();break;case"Escape":this.escape(),i.preventDefault();break}}),e}buildLabel(){const t=document.createElement("span");return t.classList.add("ql-picker-label"),t.innerHTML=Ji,t.tabIndex="0",t.setAttribute("role","button"),t.setAttribute("aria-expanded","false"),this.container.appendChild(t),t}buildOptions(){const t=document.createElement("span");t.classList.add("ql-picker-options"),t.setAttribute("aria-hidden","true"),t.tabIndex="-1",t.id=`ql-picker-options-${Se}`,Se+=1,this.label.setAttribute("aria-controls",t.id),this.options=t,Array.from(this.select.options).forEach(e=>{const s=this.buildItem(e);t.appendChild(s),e.selected===!0&&this.selectItem(s)}),this.container.appendChild(t)}buildPicker(){Array.from(this.select.attributes).forEach(t=>{this.container.setAttribute(t.name,t.value)}),this.container.classList.add("ql-picker"),this.label=this.buildLabel(),this.buildOptions()}escape(){this.close(),setTimeout(()=>this.label.focus(),1)}close(){this.container.classList.remove("ql-expanded"),this.label.setAttribute("aria-expanded","false"),this.options.setAttribute("aria-hidden","true")}selectItem(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const s=this.container.querySelector(".ql-selected");t!==s&&(s!=null&&s.classList.remove("ql-selected"),t!=null&&(t.classList.add("ql-selected"),this.select.selectedIndex=Array.from(t.parentNode.children).indexOf(t),t.hasAttribute("data-value")?this.label.setAttribute("data-value",t.getAttribute("data-value")):this.label.removeAttribute("data-value"),t.hasAttribute("data-label")?this.label.setAttribute("data-label",t.getAttribute("data-label")):this.label.removeAttribute("data-label"),e&&(this.select.dispatchEvent(new Event("change")),this.close())))}update(){let t;if(this.select.selectedIndex>-1){const s=this.container.querySelector(".ql-picker-options").children[this.select.selectedIndex];t=this.select.options[this.select.selectedIndex],this.selectItem(s)}else this.selectItem(null);const e=t!=null&&t!==this.select.querySelector("option[selected]");this.label.classList.toggle("ql-active",e)}}class ts extends Tt{constructor(t,e){super(t),this.label.innerHTML=e,this.container.classList.add("ql-color-picker"),Array.from(this.container.querySelectorAll(".ql-picker-item")).slice(0,7).forEach(s=>{s.classList.add("ql-primary")})}buildItem(t){const e=super.buildItem(t);return e.style.backgroundColor=t.getAttribute("value")||"",e}selectItem(t,e){super.selectItem(t,e);const s=this.label.querySelector(".ql-color-label"),i=t&&t.getAttribute("data-value")||"";s&&(s.tagName==="line"?s.style.stroke=i:s.style.fill=i)}}class es extends Tt{constructor(t,e){super(t),this.container.classList.add("ql-icon-picker"),Array.from(this.container.querySelectorAll(".ql-picker-item")).forEach(s=>{s.innerHTML=e[s.getAttribute("data-value")||""]}),this.defaultItem=this.container.querySelector(".ql-selected"),this.selectItem(this.defaultItem)}selectItem(t,e){super.selectItem(t,e);const s=t||this.defaultItem;if(s!=null){if(this.label.innerHTML===s.innerHTML)return;this.label.innerHTML=s.innerHTML}}}const tn=n=>{const{overflowY:t}=getComputedStyle(n,null);return t!=="visible"&&t!=="clip"};class ss{constructor(t,e){this.quill=t,this.boundsContainer=e||document.body,this.root=t.addContainer("ql-tooltip"),this.root.innerHTML=this.constructor.TEMPLATE,tn(this.quill.root)&&this.quill.root.addEventListener("scroll",()=>{this.root.style.marginTop=`${-1*this.quill.root.scrollTop}px`}),this.hide()}hide(){this.root.classList.add("ql-hidden")}position(t){const e=t.left+t.width/2-this.root.offsetWidth/2,s=t.bottom+this.quill.root.scrollTop;this.root.style.left=`${e}px`,this.root.style.top=`${s}px`,this.root.classList.remove("ql-flip");const i=this.boundsContainer.getBoundingClientRect(),r=this.root.getBoundingClientRect();let l=0;if(r.right>i.right&&(l=i.right-r.right,this.root.style.left=`${e+l}px`),r.lefti.bottom){const o=r.bottom-r.top,a=t.bottom-t.top+o;this.root.style.top=`${s-a}px`,this.root.classList.add("ql-flip")}return l}show(){this.root.classList.remove("ql-editing"),this.root.classList.remove("ql-hidden")}}const en=[!1,"center","right","justify"],sn=["#000000","#e60000","#ff9900","#ffff00","#008a00","#0066cc","#9933ff","#ffffff","#facccc","#ffebcc","#ffffcc","#cce8cc","#cce0f5","#ebd6ff","#bbbbbb","#f06666","#ffc266","#ffff66","#66b966","#66a3e0","#c285ff","#888888","#a10000","#b26b00","#b2b200","#006100","#0047b2","#6b24b2","#444444","#5c0000","#663d00","#666600","#003700","#002966","#3d1466"],nn=[!1,"serif","monospace"],rn=["1","2","3",!1],ln=["small",!1,"large","huge"];class bt extends K{constructor(t,e){super(t,e);const s=i=>{if(!document.body.contains(t.root)){document.body.removeEventListener("click",s);return}this.tooltip!=null&&!this.tooltip.root.contains(i.target)&&document.activeElement!==this.tooltip.textbox&&!this.quill.hasFocus()&&this.tooltip.hide(),this.pickers!=null&&this.pickers.forEach(r=>{r.container.contains(i.target)||r.close()})};t.emitter.listenDOM("click",document.body,s)}addModule(t){const e=super.addModule(t);return t==="toolbar"&&this.extendToolbar(e),e}buildButtons(t,e){Array.from(t).forEach(s=>{(s.getAttribute("class")||"").split(/\s+/).forEach(r=>{if(!!r.startsWith("ql-")&&(r=r.slice(3),e[r]!=null))if(r==="direction")s.innerHTML=e[r][""]+e[r].rtl;else if(typeof e[r]=="string")s.innerHTML=e[r];else{const l=s.value||"";l!=null&&e[r][l]&&(s.innerHTML=e[r][l])}})})}buildPickers(t,e){this.pickers=Array.from(t).map(i=>{if(i.classList.contains("ql-align")&&(i.querySelector("option")==null&&at(i,en),typeof e.align=="object"))return new es(i,e.align);if(i.classList.contains("ql-background")||i.classList.contains("ql-color")){const r=i.classList.contains("ql-background")?"background":"color";return i.querySelector("option")==null&&at(i,sn,r==="background"?"#ffffff":"#000000"),new ts(i,e[r])}return i.querySelector("option")==null&&(i.classList.contains("ql-font")?at(i,nn):i.classList.contains("ql-header")?at(i,rn):i.classList.contains("ql-size")&&at(i,ln)),new Tt(i)});const s=()=>{this.pickers.forEach(i=>{i.update()})};this.quill.on(f.events.EDITOR_CHANGE,s)}}bt.DEFAULTS=W({},K.DEFAULTS,{modules:{toolbar:{handlers:{formula(){this.quill.theme.tooltip.edit("formula")},image(){let n=this.container.querySelector("input.ql-image[type=file]");n==null&&(n=document.createElement("input"),n.setAttribute("type","file"),n.setAttribute("accept",this.quill.uploader.options.mimetypes.join(", ")),n.classList.add("ql-image"),n.addEventListener("change",()=>{const t=this.quill.getSelection(!0);this.quill.uploader.upload(t,n.files),n.value=""}),this.container.appendChild(n)),n.click()},video(){this.quill.theme.tooltip.edit("video")}}}}});class is extends ss{constructor(t,e){super(t,e),this.textbox=this.root.querySelector('input[type="text"]'),this.listen()}listen(){this.textbox.addEventListener("keydown",t=>{t.key==="Enter"?(this.save(),t.preventDefault()):t.key==="Escape"&&(this.cancel(),t.preventDefault())})}cancel(){this.hide(),this.restoreFocus()}edit(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"link",e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(this.root.classList.remove("ql-hidden"),this.root.classList.add("ql-editing"),this.textbox==null)return;e!=null?this.textbox.value=e:t!==this.root.getAttribute("data-mode")&&(this.textbox.value="");const s=this.quill.getBounds(this.quill.selection.savedRange);s!=null&&this.position(s),this.textbox.select(),this.textbox.setAttribute("placeholder",this.textbox.getAttribute(`data-${t}`)||""),this.root.setAttribute("data-mode",t)}restoreFocus(){this.quill.focus()}save(){let{value:t}=this.textbox;switch(this.root.getAttribute("data-mode")){case"link":{const{scrollTop:e}=this.quill.root;this.linkRange?(this.quill.formatText(this.linkRange,"link",t,f.sources.USER),delete this.linkRange):(this.restoreFocus(),this.quill.format("link",t,f.sources.USER)),this.quill.root.scrollTop=e;break}case"video":t=on(t);case"formula":{if(!t)break;const e=this.quill.getSelection(!0);if(e!=null){const s=e.index+e.length;this.quill.insertEmbed(s,this.root.getAttribute("data-mode"),t,f.sources.USER),this.root.getAttribute("data-mode")==="formula"&&this.quill.insertText(s+1," ",f.sources.USER),this.quill.setSelection(s+2,f.sources.USER)}break}}this.textbox.value="",this.hide()}}function on(n){let t=n.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/)||n.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtu\.be\/([a-zA-Z0-9_-]+)/);return t?`${t[1]||"https"}://www.youtube.com/embed/${t[2]}?showinfo=0`:(t=n.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/))?`${t[1]||"https"}://player.vimeo.com/video/${t[2]}/`:n}function at(n,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;t.forEach(s=>{const i=document.createElement("option");s===e?i.setAttribute("selected","selected"):i.setAttribute("value",String(s)),n.appendChild(i)})}const an=[["bold","italic","link"],[{header:1},{header:2},"blockquote"]];class ns extends is{constructor(t,e){super(t,e),this.quill.on(f.events.EDITOR_CHANGE,(s,i,r,l)=>{if(s===f.events.SELECTION_CHANGE)if(i!=null&&i.length>0&&l===f.sources.USER){this.show(),this.root.style.left="0px",this.root.style.width="",this.root.style.width=`${this.root.offsetWidth}px`;const o=this.quill.getLines(i.index,i.length);if(o.length===1||t.options.bubbleTooltipTop===!0){const a=this.quill.getBounds(i);a!=null&&this.position(a)}else{const a=o[o.length-1],c=this.quill.getIndex(a),h=Math.min(a.length()-1,i.index+i.length-c),m=this.quill.getBounds(new X(c,h));m!=null&&this.position(m)}}else document.activeElement!==this.textbox&&this.quill.hasFocus()&&this.hide()})}listen(){super.listen(),this.root.querySelector(".ql-close").addEventListener("click",()=>{this.root.classList.remove("ql-editing")}),this.quill.on(f.events.SCROLL_OPTIMIZE,()=>{setTimeout(()=>{if(this.root.classList.contains("ql-hidden"))return;const t=this.quill.getSelection();if(t!=null){const e=this.quill.getBounds(t);e!=null&&this.position(e)}},1)})}cancel(){this.show()}position(t){const e=super.position(t),s=this.root.querySelector(".ql-tooltip-arrow");return s.style.marginLeft="",e!==0&&(s.style.marginLeft=`${-1*e-s.offsetWidth/2}px`),e}}d(ns,"TEMPLATE",['','
    ','','',"
    "].join(""));class rs extends bt{constructor(t,e){e.modules.toolbar!=null&&e.modules.toolbar.container==null&&(e.modules.toolbar.container=an),super(t,e),this.quill.container.classList.add("ql-bubble")}extendToolbar(t){this.tooltip=new ns(this.quill,this.options.bounds),t.container!=null&&(this.tooltip.root.appendChild(t.container),this.buildButtons(t.container.querySelectorAll("button"),ft),this.buildPickers(t.container.querySelectorAll("select"),ft))}}rs.DEFAULTS=W({},bt.DEFAULTS,{modules:{toolbar:{handlers:{link(n){n?this.quill.theme.tooltip.edit():this.quill.format("link",!1)}}}}});const cn=[[{header:["1","2","3",!1]}],["bold","italic","underline","link"],[{list:"ordered"},{list:"bullet"}],["clean"]];class ls extends is{constructor(){super(...arguments);d(this,"preview",this.root.querySelector("a.ql-preview"))}listen(){super.listen(),this.root.querySelector("a.ql-action").addEventListener("click",e=>{this.root.classList.contains("ql-editing")?this.save():this.edit("link",this.preview.textContent),e.preventDefault()}),this.root.querySelector("a.ql-remove").addEventListener("click",e=>{if(this.linkRange!=null){const s=this.linkRange;this.restoreFocus(),this.quill.formatText(s,"link",!1,f.sources.USER),delete this.linkRange}e.preventDefault(),this.hide()}),this.quill.on(f.events.SELECTION_CHANGE,(e,s,i)=>{if(e!=null){if(e.length===0&&i===f.sources.USER){const[r,l]=this.quill.scroll.descendant(G,e.index);if(r!=null){this.linkRange=new X(e.index-l,r.length());const o=G.formats(r.domNode);this.preview.textContent=o,this.preview.setAttribute("href",o),this.show();const a=this.quill.getBounds(this.linkRange);a!=null&&this.position(a);return}}else delete this.linkRange;this.hide()}})}show(){super.show(),this.root.removeAttribute("data-mode")}}d(ls,"TEMPLATE",['','','',''].join(""));class os extends bt{constructor(t,e){e.modules.toolbar!=null&&e.modules.toolbar.container==null&&(e.modules.toolbar.container=cn),super(t,e),this.quill.container.classList.add("ql-snow")}extendToolbar(t){t.container!=null&&(t.container.classList.add("ql-snow"),this.buildButtons(t.container.querySelectorAll("button"),ft),this.buildPickers(t.container.querySelectorAll("select"),ft),this.tooltip=new ls(this.quill,this.options.bounds),t.container.querySelector(".ql-link")&&this.quill.keyboard.addBinding({key:"k",shortKey:!0},(e,s)=>{t.handlers.link.call(t,!s.format.link)}))}}os.DEFAULTS=W({},bt.DEFAULTS,{modules:{toolbar:{handlers:{link(n){if(n){const t=this.quill.getSelection();if(t==null||t.length===0)return;let e=this.quill.getText(t);/^\S+@\S+\.\S+$/.test(e)&&e.indexOf("mailto:")!==0&&(e=`mailto:${e}`);const{tooltip:s}=this.quill.theme;s.edit("link",e)}else this.quill.format("link",!1)}}}}});u.register({"attributors/attribute/direction":$e,"attributors/class/align":Ue,"attributors/class/background":Cs,"attributors/class/color":Ss,"attributors/class/direction":He,"attributors/class/font":je,"attributors/class/size":Ke,"attributors/style/align":Fe,"attributors/style/background":te,"attributors/style/color":Jt,"attributors/style/direction":ze,"attributors/style/font":Ve,"attributors/style/size":Ze},!0);u.register({"formats/align":Ue,"formats/direction":He,"formats/indent":qi,"formats/background":te,"formats/color":Jt,"formats/font":je,"formats/size":Ke,"formats/blockquote":zt,"formats/code-block":w,"formats/header":_t,"formats/list":pt,"formats/bold":dt,"formats/code":ee,"formats/italic":jt,"formats/link":G,"formats/script":Vt,"formats/strike":Kt,"formats/underline":Zt,"formats/formula":wt,"formats/image":Gt,"formats/video":kt,"modules/syntax":Je,"modules/table":Ni,"modules/toolbar":le,"themes/bubble":rs,"themes/snow":os,"ui/icons":ft,"ui/picker":Tt,"ui/icon-picker":es,"ui/color-picker":ts,"ui/tooltip":ss},!0);export{f as E,u as Q};