rhino-editor
Version:
A custom element wrapped rich text editor
316 lines (271 loc) • 520 kB
JavaScript
var sd=Object.defineProperty;var Xm=(n,t,e)=>t in n?sd(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var Ym=(n,t)=>{for(var e in t)sd(n,e,{get:t[e],enumerable:!0})};var Z=(n,t,e)=>Xm(n,typeof t!="symbol"?t+"":t,e);var fr=globalThis,ko=fr.trustedTypes,ad=ko?ko.createPolicy("lit-html",{createHTML:n=>n}):void 0,oa="$lit$",ge=`lit$${Math.random().toFixed(9).slice(2)}$`,ia="?"+ge,Qm=`<${ia}>`,Ze=document,pr=()=>Ze.createComment(""),mr=n=>n===null||typeof n!="object"&&typeof n!="function",sa=Array.isArray,fd=n=>sa(n)||typeof n?.[Symbol.iterator]=="function",ra=`[
\f\r]`,hr=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ld=/-->/g,cd=/>/g,Ye=RegExp(`>|${ra}(?:([^\\s"'>=/]+)(${ra}*=${ra}*(?:[^
\f\r"'\`<>=]|("|')|))|$)`,"g"),dd=/'/g,ud=/"/g,pd=/^(?:script|style|textarea|title)$/i,aa=n=>(t,...e)=>({_$litType$:n,strings:t,values:e}),T=aa(1),it=aa(2),ik=aa(3),Jt=Symbol.for("lit-noChange"),K=Symbol.for("lit-nothing"),hd=new WeakMap,Qe=Ze.createTreeWalker(Ze,129);function md(n,t){if(!sa(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return ad!==void 0?ad.createHTML(t):t}var gd=(n,t)=>{let e=n.length-1,r=[],o,i=t===2?"<svg>":t===3?"<math>":"",s=hr;for(let a=0;a<e;a++){let l=n[a],c,d,u=-1,h=0;for(;h<l.length&&(s.lastIndex=h,d=s.exec(l),d!==null);)h=s.lastIndex,s===hr?d[1]==="!--"?s=ld:d[1]!==void 0?s=cd:d[2]!==void 0?(pd.test(d[2])&&(o=RegExp("</"+d[2],"g")),s=Ye):d[3]!==void 0&&(s=Ye):s===Ye?d[0]===">"?(s=o??hr,u=-1):d[1]===void 0?u=-2:(u=s.lastIndex-d[2].length,c=d[1],s=d[3]===void 0?Ye:d[3]==='"'?ud:dd):s===ud||s===dd?s=Ye:s===ld||s===cd?s=hr:(s=Ye,o=void 0);let f=s===Ye&&n[a+1].startsWith("/>")?" ":"";i+=s===hr?l+Qm:u>=0?(r.push(c),l.slice(0,u)+oa+l.slice(u)+ge+f):l+ge+(u===-2?a:f)}return[md(n,i+(n[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),r]},gr=class n{constructor({strings:t,_$litType$:e},r){let o;this.parts=[];let i=0,s=0,a=t.length-1,l=this.parts,[c,d]=gd(t,e);if(this.el=n.createElement(c,r),Qe.currentNode=this.el.content,e===2||e===3){let u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(o=Qe.nextNode())!==null&&l.length<a;){if(o.nodeType===1){if(o.hasAttributes())for(let u of o.getAttributeNames())if(u.endsWith(oa)){let h=d[s++],f=o.getAttribute(u).split(ge),p=/([.?@])?(.*)/.exec(h);l.push({type:1,index:i,name:p[2],strings:f,ctor:p[1]==="."?wo:p[1]==="?"?Eo:p[1]==="@"?Mo:en}),o.removeAttribute(u)}else u.startsWith(ge)&&(l.push({type:6,index:i}),o.removeAttribute(u));if(pd.test(o.tagName)){let u=o.textContent.split(ge),h=u.length-1;if(h>0){o.textContent=ko?ko.emptyScript:"";for(let f=0;f<h;f++)o.append(u[f],pr()),Qe.nextNode(),l.push({type:2,index:++i});o.append(u[h],pr())}}}else if(o.nodeType===8)if(o.data===ia)l.push({type:2,index:i});else{let u=-1;for(;(u=o.data.indexOf(ge,u+1))!==-1;)l.push({type:7,index:i}),u+=ge.length-1}i++}}static createElement(t,e){let r=Ze.createElement("template");return r.innerHTML=t,r}};function tn(n,t,e=n,r){if(t===Jt)return t;let o=r!==void 0?e._$Co?.[r]:e._$Cl,i=mr(t)?void 0:t._$litDirective$;return o?.constructor!==i&&(o?._$AO?.(!1),i===void 0?o=void 0:(o=new i(n),o._$AT(n,e,r)),r!==void 0?(e._$Co??(e._$Co=[]))[r]=o:e._$Cl=o),o!==void 0&&(t=tn(n,o._$AS(n,t.values),o,r)),t}var So=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){let{el:{content:e},parts:r}=this._$AD,o=(t?.creationScope??Ze).importNode(e,!0);Qe.currentNode=o;let i=Qe.nextNode(),s=0,a=0,l=r[0];for(;l!==void 0;){if(s===l.index){let c;l.type===2?c=new Pn(i,i.nextSibling,this,t):l.type===1?c=new l.ctor(i,l.name,l.strings,this,t):l.type===6&&(c=new Ao(i,this,t)),this._$AV.push(c),l=r[++a]}s!==l?.index&&(i=Qe.nextNode(),s++)}return Qe.currentNode=Ze,o}p(t){let e=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}},Pn=class n{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,r,o){this.type=2,this._$AH=K,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,this.options=o,this._$Cv=o?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,e=this._$AM;return e!==void 0&&t?.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=tn(this,t,e),mr(t)?t===K||t==null||t===""?(this._$AH!==K&&this._$AR(),this._$AH=K):t!==this._$AH&&t!==Jt&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):fd(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==K&&mr(this._$AH)?this._$AA.nextSibling.data=t:this.T(Ze.createTextNode(t)),this._$AH=t}$(t){let{values:e,_$litType$:r}=t,o=typeof r=="number"?this._$AC(t):(r.el===void 0&&(r.el=gr.createElement(md(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===o)this._$AH.p(e);else{let i=new So(o,this),s=i.u(this.options);i.p(e),this.T(s),this._$AH=i}}_$AC(t){let e=hd.get(t.strings);return e===void 0&&hd.set(t.strings,e=new gr(t)),e}k(t){sa(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,r,o=0;for(let i of t)o===e.length?e.push(r=new n(this.O(pr()),this.O(pr()),this,this.options)):r=e[o],r._$AI(i),o++;o<e.length&&(this._$AR(r&&r._$AB.nextSibling,o),e.length=o)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){let r=t.nextSibling;t.remove(),t=r}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},en=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,o,i){this.type=1,this._$AH=K,this._$AN=void 0,this.element=t,this.name=e,this._$AM=o,this.options=i,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=K}_$AI(t,e=this,r,o){let i=this.strings,s=!1;if(i===void 0)t=tn(this,t,e,0),s=!mr(t)||t!==this._$AH&&t!==Jt,s&&(this._$AH=t);else{let a=t,l,c;for(t=i[0],l=0;l<i.length-1;l++)c=tn(this,a[r+l],e,l),c===Jt&&(c=this._$AH[l]),s||(s=!mr(c)||c!==this._$AH[l]),c===K?t=K:t!==K&&(t+=(c??"")+i[l+1]),this._$AH[l]=c}s&&!o&&this.j(t)}j(t){t===K?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},wo=class extends en{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===K?void 0:t}},Eo=class extends en{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==K)}},Mo=class extends en{constructor(t,e,r,o,i){super(t,e,r,o,i),this.type=5}_$AI(t,e=this){if((t=tn(this,t,e,0)??K)===Jt)return;let r=this._$AH,o=t===K&&r!==K||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,i=t!==K&&(r===K||o);o&&this.element.removeEventListener(this.name,this,r),i&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},Ao=class{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){tn(this,t)}},bd={M:oa,P:ge,A:ia,C:1,L:gd,R:So,D:fd,V:tn,I:Pn,H:en,N:Eo,U:Mo,B:wo,F:Ao},Zm=fr.litHtmlPolyfillSupport;Zm?.(gr,Pn),(fr.litHtmlVersions??(fr.litHtmlVersions=[])).push("3.3.1");var To=(n,t,e)=>{let r=e?.renderBefore??t,o=r._$litPart$;if(o===void 0){let i=e?.renderBefore??null;r._$litPart$=o=new Pn(t.insertBefore(pr(),i),i,void 0,e??{})}return o._$AI(n),o};var{I:lk}=bd;var yd=n=>n.strings===void 0;var Dn={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},nn=n=>(...t)=>({_$litDirective$:n,values:t}),$e=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,r){this._$Ct=t,this._$AM=e,this._$Ci=r}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};var br=(n,t)=>{let e=n._$AN;if(e===void 0)return!1;for(let r of e)r._$AO?.(t,!1),br(r,t);return!0},Co=n=>{let t,e;do{if((t=n._$AM)===void 0)break;e=t._$AN,e.delete(n),n=t}while(e?.size===0)},xd=n=>{for(let t;t=n._$AM;n=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(n))break;e.add(n),ng(t)}};function tg(n){this._$AN!==void 0?(Co(this),this._$AM=n,xd(this)):this._$AM=n}function eg(n,t=!1,e=0){let r=this._$AH,o=this._$AN;if(o!==void 0&&o.size!==0)if(t)if(Array.isArray(r))for(let i=e;i<r.length;i++)br(r[i],!1),Co(r[i]);else r!=null&&(br(r,!1),Co(r));else br(this,n)}var ng=n=>{n.type==Dn.CHILD&&(n._$AP??(n._$AP=eg),n._$AQ??(n._$AQ=tg))},_o=class extends $e{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,r){super._$AT(t,e,r),xd(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(br(this,t),Co(this))}setValue(t){if(yd(this._$Ct))this._$Ct._$AI(t,this);else{let e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}};var vd=()=>new ca,ca=class{},la=new WeakMap,kd=nn(class extends _o{render(n){return K}update(n,[t]){let e=t!==this.G;return e&&this.G!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=t,this.ht=n.options?.host,this.rt(this.ct=n.element)),K}rt(n){if(this.isConnected||(n=void 0),typeof this.G=="function"){let t=this.ht??globalThis,e=la.get(t);e===void 0&&(e=new WeakMap,la.set(t,e)),e.get(this.G)!==void 0&&this.G.call(this.ht,void 0),e.set(this.G,n),n!==void 0&&this.G.call(this.ht,n)}else this.G.value=n}get lt(){return typeof this.G=="function"?la.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var Oo=globalThis,No=Oo.ShadowRoot&&(Oo.ShadyCSS===void 0||Oo.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,da=Symbol(),Sd=new WeakMap,yr=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==da)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o,e=this.t;if(No&&t===void 0){let r=e!==void 0&&e.length===1;r&&(t=Sd.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&Sd.set(e,t))}return t}toString(){return this.cssText}},wd=n=>new yr(typeof n=="string"?n:n+"",void 0,da),Y=(n,...t)=>{let e=n.length===1?n[0]:t.reduce((r,o,i)=>r+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(o)+n[i+1],n[0]);return new yr(e,n,da)},Ed=(n,t)=>{if(No)n.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let e of t){let r=document.createElement("style"),o=Oo.litNonce;o!==void 0&&r.setAttribute("nonce",o),r.textContent=e.cssText,n.appendChild(r)}},ua=No?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(let r of t.cssRules)e+=r.cssText;return wd(e)})(n):n;var{is:rg,defineProperty:og,getOwnPropertyDescriptor:ig,getOwnPropertyNames:sg,getOwnPropertySymbols:ag,getPrototypeOf:lg}=Object,Ie=globalThis,Md=Ie.trustedTypes,cg=Md?Md.emptyScript:"",dg=Ie.reactiveElementPolyfillSupport,xr=(n,t)=>n,ha={toAttribute(n,t){switch(t){case Boolean:n=n?cg:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,t){let e=n;switch(t){case Boolean:e=n!==null;break;case Number:e=n===null?null:Number(n);break;case Object:case Array:try{e=JSON.parse(n)}catch{e=null}}return e}},Td=(n,t)=>!rg(n,t),Ad={attribute:!0,type:String,converter:ha,reflect:!1,useDefault:!1,hasChanged:Td};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Ie.litPropertyMetadata??(Ie.litPropertyMetadata=new WeakMap);var be=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=Ad){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){let r=Symbol(),o=this.getPropertyDescriptor(t,r,e);o!==void 0&&og(this.prototype,t,o)}}static getPropertyDescriptor(t,e,r){let{get:o,set:i}=ig(this.prototype,t)??{get(){return this[e]},set(s){this[e]=s}};return{get:o,set(s){let a=o?.call(this);i?.call(this,s),this.requestUpdate(t,a,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Ad}static _$Ei(){if(this.hasOwnProperty(xr("elementProperties")))return;let t=lg(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(xr("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(xr("properties"))){let e=this.properties,r=[...sg(e),...ag(e)];for(let o of r)this.createProperty(o,e[o])}let t=this[Symbol.metadata];if(t!==null){let e=litPropertyMetadata.get(t);if(e!==void 0)for(let[r,o]of e)this.elementProperties.set(r,o)}this._$Eh=new Map;for(let[e,r]of this.elementProperties){let o=this._$Eu(e,r);o!==void 0&&this._$Eh.set(o,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let e=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let o of r)e.unshift(ua(o))}else t!==void 0&&e.push(ua(t));return e}static _$Eu(t,e){let r=e.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){let t=new Map,e=this.constructor.elementProperties;for(let r of e.keys())this.hasOwnProperty(r)&&(t.set(r,this[r]),delete this[r]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Ed(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,r){this._$AK(t,r)}_$ET(t,e){let r=this.constructor.elementProperties.get(t),o=this.constructor._$Eu(t,r);if(o!==void 0&&r.reflect===!0){let i=(r.converter?.toAttribute!==void 0?r.converter:ha).toAttribute(e,r.type);this._$Em=t,i==null?this.removeAttribute(o):this.setAttribute(o,i),this._$Em=null}}_$AK(t,e){let r=this.constructor,o=r._$Eh.get(t);if(o!==void 0&&this._$Em!==o){let i=r.getPropertyOptions(o),s=typeof i.converter=="function"?{fromAttribute:i.converter}:i.converter?.fromAttribute!==void 0?i.converter:ha;this._$Em=o;let a=s.fromAttribute(e,i.type);this[o]=a??this._$Ej?.get(o)??a,this._$Em=null}}requestUpdate(t,e,r){if(t!==void 0){let o=this.constructor,i=this[t];if(r??(r=o.getPropertyOptions(t)),!((r.hasChanged??Td)(i,e)||r.useDefault&&r.reflect&&i===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,r))))return;this.C(t,e,r)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,e,{useDefault:r,reflect:o,wrapped:i},s){r&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,s??e??this[t]),i!==!0||s!==void 0)||(this._$AL.has(t)||(this.hasUpdated||r||(e=void 0),this._$AL.set(t,e)),o===!0&&this._$Em!==t&&(this._$Eq??(this._$Eq=new Set)).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(let[o,i]of this._$Ep)this[o]=i;this._$Ep=void 0}let r=this.constructor.elementProperties;if(r.size>0)for(let[o,i]of r){let{wrapped:s}=i,a=this[o];s!==!0||this._$AL.has(o)||a===void 0||this.C(o,void 0,i,a)}}let t=!1,e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(r=>r.hostUpdate?.()),this.update(e)):this._$EM()}catch(r){throw t=!1,this._$EM(),r}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&(this._$Eq=this._$Eq.forEach(e=>this._$ET(e,this[e]))),this._$EM()}updated(t){}firstUpdated(t){}};be.elementStyles=[],be.shadowRootOptions={mode:"open"},be[xr("elementProperties")]=new Map,be[xr("finalized")]=new Map,dg?.({ReactiveElement:be}),(Ie.reactiveElementVersions??(Ie.reactiveElementVersions=[])).push("2.1.1");var vr=globalThis,te=class extends be{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;let t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=To(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Jt}};te._$litElement$=!0,te.finalized=!0,vr.litElementHydrateSupport?.({LitElement:te});var ug=vr.litElementPolyfillSupport;ug?.({LitElement:te});(vr.litElementVersions??(vr.litElementVersions=[])).push("4.2.1");var hg=Y`
:host,
.trix-content {
/* General tokens */
--rhino-focus-ring: 0px 0px 1px 1px var(--rhino-button-active-border-color);
--rhino-border-radius: 4px;
--rhino-danger-border-color: red;
--rhino-danger-background-color: #ffdddd;
/* Editor tokens */
--rhino-text-color: #374151;
--rhino-dark-text-color: white;
--rhino-border-color: #cecece;
--rhino-placeholder-text-color: #cecece;
--rhino-dark-placeholder-text-color: gray;
/* Regular buttons */
--rhino-button-text-color: #889;
--rhino-button-dark-text-color: #eee;
--rhino-button-border-color: #cecece;
/** Disabled Buttons */
--rhino-button-disabled-text-color: #d1d5db;
--rhino-button-disabled-border-color: #d1d5db;
--rhino-button-disabled-background-color: #d1d5db;
/** Active buttons */
--rhino-button-active-border-color: #005a9c;
--rhino-button-active-background-color: rgb(226 239 255);
--rhino-toolbar-text-color: hsl(219, 6%, 43%);
--rhino-toolbar-icon-size: 1em;
--rhino-dialog-border-color: hsl(
var(--rhino-button-focus-background-color-hsl) / 50%
);
/** Focus buttons */
--rhino-button-focus-background-color: hsl(
var(--rhino-button-focus-background-color-hsl)
);
--rhino-button-focus-background-color-hsl: 219 26% 95%;
/**
* Override "--rhino-fake-selection-color" to change the color of .rhino-selection when the editor is not focused.
*/
--rhino-fake-selection-color: rgb(220, 220, 220);
display: block;
color: var(--rhino-text-color);
color: light-dark(var(--rhino-text-color), var(--rhino-dark-text-color));
}
`,Bk=Y`
/**
* Cursor styles that are useful for providing a more "pleasant" editor experience.
*/
/**
* https://github.com/curvenote/editor/blob/main/packages/prosemirror-codemark/src/codemark.css
*/
@keyframes rhino-blink {
49% {
border-color: unset;
}
50% {
border-color: Canvas;
}
99% {
border-color: Canvas;
}
}
.rhino-editor .no-cursor {
caret-color: transparent;
}
:where(.rhino-editor) .fake-cursor {
margin: 0;
padding: 0;
margin-right: -1px;
border-left-width: 1px;
border-left-style: solid;
animation: rhino-blink 1s;
animation-iteration-count: infinite;
position: relative;
z-index: 1;
}
/** This is for actual "selection" which are highlighting more than 1 character. */
:where(.rhino-editor .ProseMirror):not(:focus-within) .rhino-selection {
background: var(--rhino-fake-selection-color);
}
.ProseMirror-separator {
display: none !important;
}
`,Cd=Y`
.rhino-toolbar-button {
appearance: none;
-webkit-appearance: none;
border: 1px solid var(--rhino-border-color);
border-radius: var(--rhino-border-radius);
padding: 0.4em;
color: var(--rhino-button-text-color);
color: light-dark(
var(--rhino-button-text-color),
var(--rhino-button-dark-text-color)
);
background: Canvas;
font-size: inherit;
display: inline-grid;
}
.rhino-toolbar-button:is([aria-disabled="true"], :disabled) {
color: var(--rhino-button-disabled-text-color);
border-color: var(--rhino-button-disabled-border-color);
}
.rhino-toolbar-button[aria-disabled="true"]:focus {
border-color: var(--rhino-button-disabled-border-color);
}
.rhino-toolbar-button svg {
min-height: var(--rhino-toolbar-icon-size);
min-width: var(--rhino-toolbar-icon-size);
/* max-height / max-width needs to be set for safari */
max-height: var(--rhino-toolbar-icon-size);
max-width: var(--rhino-toolbar-icon-size);
}
.rhino-toolbar-button:is(:focus, :hover):not(
[aria-disabled="true"],
:disabled
) {
outline: transparent;
border-color: var(--rhino-button-active-border-color);
}
.rhino-toolbar-button:is(:focus):not([aria-disabled="true"], :disabled) {
box-shadow: var(--rhino-focus-ring);
}
/* Only change the background color in certain scenarios */
.rhino-toolbar-button:is(:hover):not(
[aria-disabled="true"],
:disabled,
[aria-pressed="true"],
[part~="toolbar__button--active"]
) {
background-color: var(--rhino-button-focus-background-color);
background-color: light-dark(
var(--rhino-button-focus-background-color),
gray
);
}
.rhino-toolbar-button:is([aria-disabled="true"], :disabled):not(
[part~="toolbar__button--active"]
) {
color: var(--rhino-button-disabled-text-color);
color: light-dark(var(--rhino-button-disabled-text-color), gray);
border-color: var(--rhino-button-disabled-border-color);
}
.rhino-toolbar-button:is(:focus, :hover):is(
[aria-disabled="true"],
:disabled
):not([part~="toolbar__button--active"]) {
outline: transparent;
color: var(--rhino-button-disabled-text-color);
color: light-dark(var(--rhino-button-disabled-text-color), gray);
border-color: var(--rhino-button-disabled-border-color);
box-shadow: 0 0 0 1px var(--rhino-button-disabled-border-color);
box-shadow: 0 0 0 1px
light-dark(var(--rhino-button-disabled-border-color), transparent);
}
`,_d=Y`
${hg}
[part~="toolbar"] {
color: var(--rhino-toolbar-text-color);
}
[part~="toolbar"]::part(base) {
border-color: var(--rhino-border-color);
border-bottom-color: transparent;
border-width: 1px;
border-radius: 4px;
border-bottom-right-radius: 0px;
border-bottom-left-radius: 0px;
display: flex;
align-items: center;
overflow: auto;
}
[part~="toolbar"][part~="bubble-menu__toolbar"]::part(base) {
border: 1px solid var(--rhino-border-color);
border-radius: 4px;
padding: 4px;
background: Canvas;
}
[part~="toolbar"]::part(base):is(:focus-visible, :focus-within) {
border-color: var(--rhino-button-active-border-color);
outline: transparent;
}
.rhino-toolbar-button[part~="toolbar__button--active"],
.rhino-toolbar-button[part~="toolbar__button--active"]:is(
:hover,
:focus-within
) {
background-color: var(--rhino-button-active-background-color);
}
slot[name="toolbar"]
:is(
[part~="toolbar__button--link"],
[part~="toolbar__button--increase-indentation"]
) {
margin-inline-end: 1rem;
}
[part~="toolbar__button--attach-files"] {
margin-inline-end: auto;
}
role-anchored-region {
font-size: 0.8em;
--background: transparent;
--border-color: transparent;
}
role-anchored-region::part(popover) {
border: none;
}
.link-dialog__container {
display: flex;
align-items: center;
max-width: 600px;
border: 1px solid gray;
padding: 0.4em;
background: Canvas;
border-radius: 8px;
}
.link-dialog__input {
border: 1px solid var(--rhino-border-color);
border-radius: var(--rhino-border-radius);
padding: 0.4em 0.6em;
flex: 1 1 auto;
}
.link-dialog__input:is(:focus) {
outline: transparent;
border-color: var(--rhino-button-active-border-color);
}
.link-validate:invalid {
outline: transparent;
background-color: var(--rhino-danger-background-color);
border-color: var(--rhino-danger-border-color);
box-shadow: none;
}
.rhino-toolbar-button.link-dialog__button {
padding: 0.4em 0.6em;
border: 1px solid var(--rhino-button-border-color);
border-radius: var(--rhino-border-radius);
}
.link-dialog__buttons {
margin-inline-start: 0.5em;
}
.editor-wrapper {
position: relative;
}
.trix-content {
border: 1px solid var(--rhino-border-color);
border-radius: 0px 0px var(--rhino-border-radius) var(--rhino-border-radius);
margin: 0;
padding: 0.4em 0.6em;
min-height: 200px;
outline: transparent;
white-space: pre-wrap;
}
role-tooltip {
position: fixed;
top: 0;
left: 0;
font-size: 0.75em;
--background: CanvasText;
color: Canvas;
--border-color: CanvasText;
}
role-tooltip::part(popover) {
padding: 0.4em 0.6em;
}
svg,
::slotted(svg) {
height: var(--rhino-toolbar-icon-size);
width: var(--rhino-toolbar-icon-size);
}
`;var rn=class extends te{static define(t,e,r){t==null&&(t=this.baseName),e==null&&(e=this),!this.customElementRegistry.get(t)&&this.customElementRegistry.define(t,fg(e),r)}constructor(){super();try{this.internals=this.attachInternals()}catch(t){console.error(t)}}addCustomState(t){try{this.internals?.states.add(t)}catch{}}deleteCustomState(t){try{this.internals?.states.delete(t)}catch{}}hasCustomState(t){try{return this.internals?.states.has(t)}catch{return!1}}toggleCustomState(t,e){if(e==null){this.hasCustomState(t)?this.deleteCustomState(t):this.addCustomState(t);return}e===!0?this.addCustomState(t):this.deleteCustomState(t)}};rn.customElementRegistry=window.customElements;function fg(n){return class extends n{}}function mt(n){this.content=n}mt.prototype={constructor:mt,find:function(n){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===n)return t;return-1},get:function(n){var t=this.find(n);return t==-1?void 0:this.content[t+1]},update:function(n,t,e){var r=e&&e!=n?this.remove(e):this,o=r.find(n),i=r.content.slice();return o==-1?i.push(e||n,t):(i[o+1]=t,e&&(i[o]=e)),new mt(i)},remove:function(n){var t=this.find(n);if(t==-1)return this;var e=this.content.slice();return e.splice(t,2),new mt(e)},addToStart:function(n,t){return new mt([n,t].concat(this.remove(n).content))},addToEnd:function(n,t){var e=this.remove(n).content.slice();return e.push(n,t),new mt(e)},addBefore:function(n,t,e){var r=this.remove(t),o=r.content.slice(),i=r.find(n);return o.splice(i==-1?o.length:i,0,t,e),new mt(o)},forEach:function(n){for(var t=0;t<this.content.length;t+=2)n(this.content[t],this.content[t+1])},prepend:function(n){return n=mt.from(n),n.size?new mt(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=mt.from(n),n.size?new mt(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var t=this;n=mt.from(n);for(var e=0;e<n.content.length;e+=2)t=t.remove(n.content[e]);return t},toObject:function(){var n={};return this.forEach(function(t,e){n[t]=e}),n},get size(){return this.content.length>>1}};mt.from=function(n){if(n instanceof mt)return n;var t=[];if(n)for(var e in n)t.push(e,n[e]);return new mt(t)};var fa=mt;function zd(n,t,e){for(let r=0;;r++){if(r==n.childCount||r==t.childCount)return n.childCount==t.childCount?null:e;let o=n.child(r),i=t.child(r);if(o==i){e+=o.nodeSize;continue}if(!o.sameMarkup(i))return e;if(o.isText&&o.text!=i.text){for(let s=0;o.text[s]==i.text[s];s++)e++;return e}if(o.content.size||i.content.size){let s=zd(o.content,i.content,e+1);if(s!=null)return s}e+=o.nodeSize}}function Fd(n,t,e,r){for(let o=n.childCount,i=t.childCount;;){if(o==0||i==0)return o==i?null:{a:e,b:r};let s=n.child(--o),a=t.child(--i),l=s.nodeSize;if(s==a){e-=l,r-=l;continue}if(!s.sameMarkup(a))return{a:e,b:r};if(s.isText&&s.text!=a.text){let c=0,d=Math.min(s.text.length,a.text.length);for(;c<d&&s.text[s.text.length-c-1]==a.text[a.text.length-c-1];)c++,e--,r--;return{a:e,b:r}}if(s.content.size||a.content.size){let c=Fd(s.content,a.content,e-1,r-1);if(c)return c}e-=l,r-=l}}var w=class n{constructor(t,e){if(this.content=t,this.size=e||0,e==null)for(let r=0;r<t.length;r++)this.size+=t[r].nodeSize}nodesBetween(t,e,r,o=0,i){for(let s=0,a=0;a<e;s++){let l=this.content[s],c=a+l.nodeSize;if(c>t&&r(l,o+a,i||null,s)!==!1&&l.content.size){let d=a+1;l.nodesBetween(Math.max(0,t-d),Math.min(l.content.size,e-d),r,o+d)}a=c}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,r,o){let i="",s=!0;return this.nodesBetween(t,e,(a,l)=>{let c=a.isText?a.text.slice(Math.max(t,l)-l,e-l):a.isLeaf?o?typeof o=="function"?o(a):o:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,r=t.firstChild,o=this.content.slice(),i=0;for(e.isText&&e.sameMarkup(r)&&(o[o.length-1]=e.withText(e.text+r.text),i=1);i<t.content.length;i++)o.push(t.content[i]);return new n(o,this.size+t.size)}cut(t,e=this.size){if(t==0&&e==this.size)return this;let r=[],o=0;if(e>t)for(let i=0,s=0;s<e;i++){let a=this.content[i],l=s+a.nodeSize;l>t&&((s<t||l>e)&&(a.isText?a=a.cut(Math.max(0,t-s),Math.min(a.text.length,e-s)):a=a.cut(Math.max(0,t-s-1),Math.min(a.content.size,e-s-1))),r.push(a),o+=a.nodeSize),s=l}return new n(r,o)}cutByIndex(t,e){return t==e?n.empty:t==0&&e==this.content.length?this:new n(this.content.slice(t,e))}replaceChild(t,e){let r=this.content[t];if(r==e)return this;let o=this.content.slice(),i=this.size+e.nodeSize-r.nodeSize;return o[t]=e,new n(o,i)}addToStart(t){return new n([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new n(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,r=0;e<this.content.length;e++){let o=this.content[e];t(o,r,e),r+=o.nodeSize}}findDiffStart(t,e=0){return zd(this,t,e)}findDiffEnd(t,e=this.size,r=t.size){return Fd(this,t,e,r)}findIndex(t){if(t==0)return Po(0,t);if(t==this.size)return Po(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let e=0,r=0;;e++){let o=this.child(e),i=r+o.nodeSize;if(i>=t)return i==t?Po(e+1,i):Po(e,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,e){if(!e)return n.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new n(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return n.empty;let e,r=0;for(let o=0;o<t.length;o++){let i=t[o];r+=i.nodeSize,o&&i.isText&&t[o-1].sameMarkup(i)?(e||(e=t.slice(0,o)),e[e.length-1]=i.withText(e[e.length-1].text+i.text)):e&&e.push(i)}return new n(e||t,r)}static from(t){if(!t)return n.empty;if(t instanceof n)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new n([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};w.empty=new w([],0);var pa={index:0,offset:0};function Po(n,t){return pa.index=n,pa.offset=t,pa}function Ro(n,t){if(n===t)return!0;if(!(n&&typeof n=="object")||!(t&&typeof t=="object"))return!1;let e=Array.isArray(n);if(Array.isArray(t)!=e)return!1;if(e){if(n.length!=t.length)return!1;for(let r=0;r<n.length;r++)if(!Ro(n[r],t[r]))return!1}else{for(let r in n)if(!(r in t)||!Ro(n[r],t[r]))return!1;for(let r in t)if(!(r in n))return!1}return!0}var F=class n{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,r=!1;for(let o=0;o<t.length;o++){let i=t[o];if(this.eq(i))return t;if(this.type.excludes(i.type))e||(e=t.slice(0,o));else{if(i.type.excludes(this.type))return t;!r&&i.type.rank>this.type.rank&&(e||(e=t.slice(0,o)),e.push(this),r=!0),e&&e.push(i)}}return e||(e=t.slice()),r||e.push(this),e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1}eq(t){return this==t||this.type==t.type&&Ro(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let r=t.marks[e.type];if(!r)throw new RangeError(`There is no mark type ${e.type} in this schema`);let o=r.create(e.attrs);return r.checkAttrs(o.attrs),o}static sameSet(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].eq(e[r]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return n.none;if(t instanceof n)return[t];let e=t.slice();return e.sort((r,o)=>r.type.rank-o.type.rank),e}};F.none=[];var an=class extends Error{},A=class n{constructor(t,e,r){this.content=t,this.openStart=e,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let r=Vd(this.content,t+this.openStart,e);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(t,e){return new n(Hd(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,e){if(!e)return n.empty;let r=e.openStart||0,o=e.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(w.fromJSON(t,e.content),r,o)}static maxOpen(t,e=!0){let r=0,o=0;for(let i=t.firstChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=t.lastChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.lastChild)o++;return new n(t,r,o)}};A.empty=new A(w.empty,0,0);function Hd(n,t,e){let{index:r,offset:o}=n.findIndex(t),i=n.maybeChild(r),{index:s,offset:a}=n.findIndex(e);if(o==t||i.isText){if(a!=e&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,t).append(n.cut(e))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(Hd(i.content,t-o-1,e-o-1)))}function Vd(n,t,e,r){let{index:o,offset:i}=n.findIndex(t),s=n.maybeChild(o);if(i==t||s.isText)return r&&!r.canReplace(o,o,e)?null:n.cut(0,t).append(e).append(n.cut(t));let a=Vd(s.content,t-i-1,e,s);return a&&n.replaceChild(o,s.copy(a))}function pg(n,t,e){if(e.openStart>n.depth)throw new an("Inserted content deeper than insertion position");if(n.depth-e.openStart!=t.depth-e.openEnd)throw new an("Inconsistent open depths");return Ud(n,t,e,0)}function Ud(n,t,e,r){let o=n.index(r),i=n.node(r);if(o==t.index(r)&&r<n.depth-e.openStart){let s=Ud(n,t,e,r+1);return i.copy(i.content.replaceChild(o,s))}else if(e.content.size)if(!e.openStart&&!e.openEnd&&n.depth==r&&t.depth==r){let s=n.parent,a=s.content;return sn(s,a.cut(0,n.parentOffset).append(e.content).append(a.cut(t.parentOffset)))}else{let{start:s,end:a}=mg(e,n);return sn(i,jd(n,s,a,t,r))}else return sn(i,$o(n,t,r))}function Kd(n,t){if(!t.type.compatibleContent(n.type))throw new an("Cannot join "+t.type.name+" onto "+n.type.name)}function ga(n,t,e){let r=n.node(e);return Kd(r,t.node(e)),r}function on(n,t){let e=t.length-1;e>=0&&n.isText&&n.sameMarkup(t[e])?t[e]=n.withText(t[e].text+n.text):t.push(n)}function kr(n,t,e,r){let o=(t||n).node(e),i=0,s=t?t.index(e):o.childCount;n&&(i=n.index(e),n.depth>e?i++:n.textOffset&&(on(n.nodeAfter,r),i++));for(let a=i;a<s;a++)on(o.child(a),r);t&&t.depth==e&&t.textOffset&&on(t.nodeBefore,r)}function sn(n,t){return n.type.checkContent(t),n.copy(t)}function jd(n,t,e,r,o){let i=n.depth>o&&ga(n,t,o+1),s=r.depth>o&&ga(e,r,o+1),a=[];return kr(null,n,o,a),i&&s&&t.index(o)==e.index(o)?(Kd(i,s),on(sn(i,jd(n,t,e,r,o+1)),a)):(i&&on(sn(i,$o(n,t,o+1)),a),kr(t,e,o,a),s&&on(sn(s,$o(e,r,o+1)),a)),kr(r,null,o,a),new w(a)}function $o(n,t,e){let r=[];if(kr(null,n,e,r),n.depth>e){let o=ga(n,t,e+1);on(sn(o,$o(n,t,e+1)),r)}return kr(t,null,e,r),new w(r)}function mg(n,t){let e=t.depth-n.openStart,o=t.node(e).copy(n.content);for(let i=e-1;i>=0;i--)o=t.node(i).copy(w.from(o));return{start:o.resolveNoCache(n.openStart+e),end:o.resolveNoCache(o.content.size-n.openEnd-e)}}var Io=class n{constructor(t,e,r){this.pos=t,this.path=e,this.parentOffset=r,this.depth=e.length/3-1}resolveDepth(t){return t==null?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){return t=this.resolveDepth(t),t==0?0:this.path[t*3-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=t.child(e);return r?t.child(e).cut(r):o}get nodeBefore(){let t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):t==0?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let r=this.path[e*3],o=e==0?0:this.path[e*3-1]+1;for(let i=0;i<t;i++)o+=r.child(i).nodeSize;return o}marks(){let t=this.parent,e=this.index();if(t.content.size==0)return F.none;if(this.textOffset)return t.child(e).marks;let r=t.maybeChild(e-1),o=t.maybeChild(e);if(!r){let a=r;r=o,o=a}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!o||!i[s].isInSet(o.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let r=e.marks,o=t.parent.maybeChild(t.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!o||!r[i].isInSet(o.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);r>=0;r--)if(t.pos<=this.end(r)&&(!e||e(this.node(r))))return new ln(this,t,r);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let r=[],o=0,i=e;for(let s=t;;){let{index:a,offset:l}=s.content.findIndex(i),c=i-l;if(r.push(s,a,o+l),!c||(s=s.child(a),s.isText))break;i=c-1,o+=l+1}return new n(e,r,i)}static resolveCached(t,e){let r=Od.get(t);if(r)for(let i=0;i<r.elts.length;i++){let s=r.elts[i];if(s.pos==e)return s}else Od.set(t,r=new ba);let o=r.elts[r.i]=n.resolve(t,e);return r.i=(r.i+1)%gg,o}},ba=class{constructor(){this.elts=[],this.i=0}},gg=12,Od=new WeakMap,ln=class{constructor(t,e,r){this.$from=t,this.$to=e,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},bg=Object.create(null),At=class n{constructor(t,e,r,o=F.none){this.type=t,this.attrs=e,this.marks=o,this.content=r||w.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,r,o=0){this.content.nodesBetween(t,e,r,o,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,r,o){return this.content.textBetween(t,e,r,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,r){return this.type==t&&Ro(this.attrs,e||t.defaultAttrs||bg)&&F.sameSet(this.marks,r||F.none)}copy(t=null){return t==this.content?this:new n(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new n(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){return t==0&&e==this.content.size?this:this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,r=!1){if(t==e)return A.empty;let o=this.resolve(t),i=this.resolve(e),s=r?0:o.sharedDepth(e),a=o.start(s),c=o.node(s).content.cut(o.pos-a,i.pos-a);return new A(c,o.depth-s,i.depth-s)}replace(t,e,r){return pg(this.resolve(t),this.resolve(e),r)}nodeAt(t){for(let e=this;;){let{index:r,offset:o}=e.content.findIndex(t);if(e=e.maybeChild(r),!e)return null;if(o==t||e.isText)return e;t-=o+1}}childAfter(t){let{index:e,offset:r}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:r}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:e,offset:r}=this.content.findIndex(t);if(r<t)return{node:this.content.child(e),index:e,offset:r};let o=this.content.child(e-1);return{node:o,index:e-1,offset:r-o.nodeSize}}resolve(t){return Io.resolveCached(this,t)}resolveNoCache(t){return Io.resolve(this,t)}rangeHasMark(t,e,r){let o=!1;return e>t&&this.nodesBetween(t,e,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),Wd(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,r=w.empty,o=0,i=r.childCount){let s=this.contentMatchAt(t).matchFragment(r,o,i),a=s&&s.matchFragment(this.content,e);if(!a||!a.validEnd)return!1;for(let l=o;l<i;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(t,e,r,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(t).matchType(r),s=i&&i.matchFragment(this.content,e);return s?s.validEnd:!1}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=F.none;for(let e=0;e<this.marks.length;e++){let r=this.marks[e];r.type.checkAttrs(r.attrs),t=r.addToSet(t)}if(!F.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map(e=>e.toJSON())),t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let r;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=e.marks.map(t.markFromJSON)}if(e.type=="text"){if(typeof e.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(e.text,r)}let o=w.fromJSON(t,e.content),i=t.nodeType(e.type).create(e.attrs,o,r);return i.type.checkAttrs(i.attrs),i}};At.prototype.text=void 0;var ya=class n extends At{constructor(t,e,r,o){if(super(t,e,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Wd(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new n(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new n(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){return t==0&&e==this.text.length?this:this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}};function Wd(n,t){for(let e=n.length-1;e>=0;e--)t=n[e].type.name+"("+t+")";return t}var cn=class n{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let r=new xa(t,e);if(r.next==null)return n.empty;let o=qd(r);r.next&&r.err("Unexpected trailing text");let i=Eg(wg(o));return Mg(i,r),i}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,r=t.childCount){let o=this;for(let i=e;o&&i<r;i++)o=o.matchType(t.child(i).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!(e.isText||e.hasRequiredAttrs()))return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let r=0;r<t.next.length;r++)if(this.next[e].type==t.next[r].type)return!0;return!1}fillBefore(t,e=!1,r=0){let o=[this];function i(s,a){let l=s.matchFragment(t,r);if(l&&(!e||l.validEnd))return w.from(a.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:d,next:u}=s.next[c];if(!(d.isText||d.hasRequiredAttrs())&&o.indexOf(u)==-1){o.push(u);let h=i(u,a.concat(d));if(h)return h}}return null}return i(this,[])}findWrapping(t){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==t)return this.wrapCache[r+1];let e=this.computeWrapping(t);return this.wrapCache.push(t,e),e}computeWrapping(t){let e=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),i=o.match;if(i.matchType(t)){let s=[];for(let a=o;a.type;a=a.via)s.push(a.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:a,next:l}=i.next[s];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in e)&&(!o.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:o}),e[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function e(r){t.push(r);for(let o=0;o<r.next.length;o++)t.indexOf(r.next[o].next)==-1&&e(r.next[o].next)}return e(this),t.map((r,o)=>{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)i+=(s?", ":"")+r.next[s].type.name+"->"+t.indexOf(r.next[s].next);return i}).join(`
`)}};cn.empty=new cn(!0);var xa=class{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}};function qd(n){let t=[];do t.push(yg(n));while(n.eat("|"));return t.length==1?t[0]:{type:"choice",exprs:t}}function yg(n){let t=[];do t.push(xg(n));while(n.next&&n.next!=")"&&n.next!="|");return t.length==1?t[0]:{type:"seq",exprs:t}}function xg(n){let t=Sg(n);for(;;)if(n.eat("+"))t={type:"plus",expr:t};else if(n.eat("*"))t={type:"star",expr:t};else if(n.eat("?"))t={type:"opt",expr:t};else if(n.eat("{"))t=vg(n,t);else break;return t}function Nd(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let t=Number(n.next);return n.pos++,t}function vg(n,t){let e=Nd(n),r=e;return n.eat(",")&&(n.next!="}"?r=Nd(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:e,max:r,expr:t}}function kg(n,t){let e=n.nodeTypes,r=e[t];if(r)return[r];let o=[];for(let i in e){let s=e[i];s.isInGroup(t)&&o.p