UNPKG

rhino-editor

Version:

A custom element wrapped rich text editor

316 lines (271 loc) 493 kB
"use strict";var ii=Object.defineProperty;var Jp=Object.getOwnPropertyDescriptor;var Gp=Object.getOwnPropertyNames;var Yp=Object.prototype.hasOwnProperty;var Xp=(n,t,e)=>t in n?ii(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var Ic=(n,t)=>{for(var e in t)ii(n,e,{get:t[e],enumerable:!0})},Qp=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Gp(t))!Yp.call(n,i)&&i!==e&&ii(n,i,{get:()=>t[i],enumerable:!(r=Jp(t,i))||r.enumerable});return n};var Zp=n=>Qp(ii({},"__esModule",{value:!0}),n);var Z=(n,t,e)=>Xp(n,typeof t!="symbol"?t+"":t,e);var Hx={};Ic(Hx,{AttachmentManager:()=>ve,TipTapEditor:()=>ni});module.exports=Zp(Hx);var lr=globalThis,oi=lr.trustedTypes,Lc=oi?oi.createPolicy("lit-html",{createHTML:n=>n}):void 0,js="$lit$",ue=`lit$${Math.random().toFixed(9).slice(2)}$`,Ks="?"+ue,tm=`<${Ks}>`,We=document,cr=()=>We.createComment(""),dr=n=>n===null||typeof n!="object"&&typeof n!="function",Ws=Array.isArray,Uc=n=>Ws(n)||typeof n?.[Symbol.iterator]=="function",Us=`[ \f\r]`,ar=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Bc=/-->/g,zc=/>/g,je=RegExp(`>|${Us}(?:([^\\s"'>=/]+)(${Us}*=${Us}*(?:[^ \f\r"'\`<>=]|("|')|))|$)`,"g"),Hc=/'/g,Fc=/"/g,jc=/^(?:script|style|textarea|title)$/i,qs=n=>(t,...e)=>({_$litType$:n,strings:t,values:e}),T=qs(1),nt=qs(2),Vx=qs(3),Ut=Symbol.for("lit-noChange"),U=Symbol.for("lit-nothing"),Vc=new WeakMap,Ke=We.createTreeWalker(We,129);function Kc(n,t){if(!Ws(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return Lc!==void 0?Lc.createHTML(t):t}var Wc=(n,t)=>{let e=n.length-1,r=[],i,o=t===2?"<svg>":t===3?"<math>":"",s=ar;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===ar?d[1]==="!--"?s=Bc:d[1]!==void 0?s=zc:d[2]!==void 0?(jc.test(d[2])&&(i=RegExp("</"+d[2],"g")),s=je):d[3]!==void 0&&(s=je):s===je?d[0]===">"?(s=i??ar,u=-1):d[1]===void 0?u=-2:(u=s.lastIndex-d[2].length,c=d[1],s=d[3]===void 0?je:d[3]==='"'?Fc:Hc):s===Fc||s===Hc?s=je:s===Bc||s===zc?s=ar:(s=je,i=void 0);let f=s===je&&n[a+1].startsWith("/>")?" ":"";o+=s===ar?l+tm:u>=0?(r.push(c),l.slice(0,u)+js+l.slice(u)+ue+f):l+ue+(u===-2?a:f)}return[Kc(n,o+(n[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),r]},ur=class n{constructor({strings:t,_$litType$:e},r){let i;this.parts=[];let o=0,s=0,a=t.length-1,l=this.parts,[c,d]=Wc(t,e);if(this.el=n.createElement(c,r),Ke.currentNode=this.el.content,e===2||e===3){let u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(i=Ke.nextNode())!==null&&l.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(let u of i.getAttributeNames())if(u.endsWith(js)){let h=d[s++],f=i.getAttribute(u).split(ue),p=/([.?@])?(.*)/.exec(h);l.push({type:1,index:o,name:p[2],strings:f,ctor:p[1]==="."?ai:p[1]==="?"?li:p[1]==="@"?ci:Je}),i.removeAttribute(u)}else u.startsWith(ue)&&(l.push({type:6,index:o}),i.removeAttribute(u));if(jc.test(i.tagName)){let u=i.textContent.split(ue),h=u.length-1;if(h>0){i.textContent=oi?oi.emptyScript:"";for(let f=0;f<h;f++)i.append(u[f],cr()),Ke.nextNode(),l.push({type:2,index:++o});i.append(u[h],cr())}}}else if(i.nodeType===8)if(i.data===Ks)l.push({type:2,index:o});else{let u=-1;for(;(u=i.data.indexOf(ue,u+1))!==-1;)l.push({type:7,index:o}),u+=ue.length-1}o++}}static createElement(t,e){let r=We.createElement("template");return r.innerHTML=t,r}};function qe(n,t,e=n,r){if(t===Ut)return t;let i=r!==void 0?e.o?.[r]:e.l,o=dr(t)?void 0:t._$litDirective$;return i?.constructor!==o&&(i?._$AO?.(!1),o===void 0?i=void 0:(i=new o(n),i._$AT(n,e,r)),r!==void 0?(e.o??(e.o=[]))[r]=i:e.l=i),i!==void 0&&(t=qe(n,i._$AS(n,t.values),i,r)),t}var si=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,i=(t?.creationScope??We).importNode(e,!0);Ke.currentNode=i;let o=Ke.nextNode(),s=0,a=0,l=r[0];for(;l!==void 0;){if(s===l.index){let c;l.type===2?c=new En(o,o.nextSibling,this,t):l.type===1?c=new l.ctor(o,l.name,l.strings,this,t):l.type===6&&(c=new di(o,this,t)),this._$AV.push(c),l=r[++a]}s!==l?.index&&(o=Ke.nextNode(),s++)}return Ke.currentNode=We,i}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++}},En=class n{get _$AU(){return this._$AM?._$AU??this.v}constructor(t,e,r,i){this.type=2,this._$AH=U,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,this.options=i,this.v=i?.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=qe(this,t,e),dr(t)?t===U||t==null||t===""?(this._$AH!==U&&this._$AR(),this._$AH=U):t!==this._$AH&&t!==Ut&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Uc(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!==U&&dr(this._$AH)?this._$AA.nextSibling.data=t:this.T(We.createTextNode(t)),this._$AH=t}$(t){let{values:e,_$litType$:r}=t,i=typeof r=="number"?this._$AC(t):(r.el===void 0&&(r.el=ur.createElement(Kc(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===i)this._$AH.p(e);else{let o=new si(i,this),s=o.u(this.options);o.p(e),this.T(s),this._$AH=o}}_$AC(t){let e=Vc.get(t.strings);return e===void 0&&Vc.set(t.strings,e=new ur(t)),e}k(t){Ws(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,r,i=0;for(let o of t)i===e.length?e.push(r=new n(this.O(cr()),this.O(cr()),this,this.options)):r=e[i],r._$AI(o),i++;i<e.length&&(this._$AR(r&&r._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){let r=t.nextSibling;t.remove(),t=r}}setConnected(t){this._$AM===void 0&&(this.v=t,this._$AP?.(t))}},Je=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,i,o){this.type=1,this._$AH=U,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=o,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=U}_$AI(t,e=this,r,i){let o=this.strings,s=!1;if(o===void 0)t=qe(this,t,e,0),s=!dr(t)||t!==this._$AH&&t!==Ut,s&&(this._$AH=t);else{let a=t,l,c;for(t=o[0],l=0;l<o.length-1;l++)c=qe(this,a[r+l],e,l),c===Ut&&(c=this._$AH[l]),s||(s=!dr(c)||c!==this._$AH[l]),c===U?t=U:t!==U&&(t+=(c??"")+o[l+1]),this._$AH[l]=c}s&&!i&&this.j(t)}j(t){t===U?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},ai=class extends Je{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===U?void 0:t}},li=class extends Je{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==U)}},ci=class extends Je{constructor(t,e,r,i,o){super(t,e,r,i,o),this.type=5}_$AI(t,e=this){if((t=qe(this,t,e,0)??U)===Ut)return;let r=this._$AH,i=t===U&&r!==U||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,o=t!==U&&(r===U||i);i&&this.element.removeEventListener(this.name,this,r),o&&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)}},di=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){qe(this,t)}},qc={M:js,P:ue,A:Ks,C:1,L:Wc,R:si,D:Uc,V:qe,I:En,H:Je,N:li,U:ci,B:ai,F:di},em=lr.litHtmlPolyfillSupport;em?.(ur,En),(lr.litHtmlVersions??(lr.litHtmlVersions=[])).push("3.2.0");var ui=(n,t,e)=>{let r=e?.renderBefore??t,i=r._$litPart$;if(i===void 0){let o=e?.renderBefore??null;r._$litPart$=i=new En(t.insertBefore(cr(),o),o,void 0,e??{})}return i._$AI(n),i};var{I:Kx}=qc;var Jc=n=>n.strings===void 0;var An={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Ge=n=>(...t)=>({_$litDirective$:n,values:t}),Te=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,r){this.t=t,this._$AM=e,this.i=r}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};var hr=(n,t)=>{let e=n._$AN;if(e===void 0)return!1;for(let r of e)r._$AO?.(t,!1),hr(r,t);return!0},hi=n=>{let t,e;do{if((t=n._$AM)===void 0)break;e=t._$AN,e.delete(n),n=t}while(e?.size===0)},Gc=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),im(t)}};function nm(n){this._$AN!==void 0?(hi(this),this._$AM=n,Gc(this)):this._$AM=n}function rm(n,t=!1,e=0){let r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(t)if(Array.isArray(r))for(let o=e;o<r.length;o++)hr(r[o],!1),hi(r[o]);else r!=null&&(hr(r,!1),hi(r));else hr(this,n)}var im=n=>{n.type==An.CHILD&&(n._$AP??(n._$AP=rm),n._$AQ??(n._$AQ=nm))},fi=class extends Te{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,r){super._$AT(t,e,r),Gc(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(hr(this,t),hi(this))}setValue(t){if(Jc(this.t))this.t._$AI(t,this);else{let e=[...this.t._$AH];e[this.i]=t,this.t._$AI(e,this,0)}}disconnected(){}reconnected(){}};var Yc=()=>new Gs,Gs=class{},Js=new WeakMap,Xc=Ge(class extends fi{render(n){return U}update(n,[t]){let e=t!==this.Y;return e&&this.Y!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.Y=t,this.ht=n.options?.host,this.rt(this.ct=n.element)),U}rt(n){if(this.isConnected||(n=void 0),typeof this.Y=="function"){let t=this.ht??globalThis,e=Js.get(t);e===void 0&&(e=new WeakMap,Js.set(t,e)),e.get(this.Y)!==void 0&&this.Y.call(this.ht,void 0),e.set(this.Y,n),n!==void 0&&this.Y.call(this.ht,n)}else this.Y.value=n}get lt(){return typeof this.Y=="function"?Js.get(this.ht??globalThis)?.get(this.Y):this.Y?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var pi=globalThis,mi=pi.ShadowRoot&&(pi.ShadyCSS===void 0||pi.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ys=Symbol(),Qc=new WeakMap,fr=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==Ys)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(mi&&t===void 0){let r=e!==void 0&&e.length===1;r&&(t=Qc.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&Qc.set(e,t))}return t}toString(){return this.cssText}},Zc=n=>new fr(typeof n=="string"?n:n+"",void 0,Ys),G=(n,...t)=>{let e=n.length===1?n[0]:t.reduce((r,i,o)=>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.")})(i)+n[o+1],n[0]);return new fr(e,n,Ys)},Xs=(n,t)=>{if(mi)n.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let e of t){let r=document.createElement("style"),i=pi.litNonce;i!==void 0&&r.setAttribute("nonce",i),r.textContent=e.cssText,n.appendChild(r)}},gi=mi?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(let r of t.cssRules)e+=r.cssText;return Zc(e)})(n):n;var{is:om,defineProperty:sm,getOwnPropertyDescriptor:am,getOwnPropertyNames:lm,getOwnPropertySymbols:cm,getPrototypeOf:dm}=Object,Ce=globalThis,td=Ce.trustedTypes,um=td?td.emptyScript:"",hm=Ce.reactiveElementPolyfillSupport,pr=(n,t)=>n,Qs={toAttribute(n,t){switch(t){case Boolean:n=n?um: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}},nd=(n,t)=>!om(n,t),ed={attribute:!0,type:String,converter:Qs,reflect:!1,hasChanged:nd};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Ce.litPropertyMetadata??(Ce.litPropertyMetadata=new WeakMap);var he=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=ed){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){let r=Symbol(),i=this.getPropertyDescriptor(t,r,e);i!==void 0&&sm(this.prototype,t,i)}}static getPropertyDescriptor(t,e,r){let{get:i,set:o}=am(this.prototype,t)??{get(){return this[e]},set(s){this[e]=s}};return{get(){return i?.call(this)},set(s){let a=i?.call(this);o.call(this,s),this.requestUpdate(t,a,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??ed}static _$Ei(){if(this.hasOwnProperty(pr("elementProperties")))return;let t=dm(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(pr("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(pr("properties"))){let e=this.properties,r=[...lm(e),...cm(e)];for(let i of r)this.createProperty(i,e[i])}let t=this[Symbol.metadata];if(t!==null){let e=litPropertyMetadata.get(t);if(e!==void 0)for(let[r,i]of e)this.elementProperties.set(r,i)}this._$Eh=new Map;for(let[e,r]of this.elementProperties){let i=this._$Eu(e,r);i!==void 0&&this._$Eh.set(i,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 i of r)e.unshift(gi(i))}else t!==void 0&&e.push(gi(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 Xs(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)}_$EC(t,e){let r=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,r);if(i!==void 0&&r.reflect===!0){let o=(r.converter?.toAttribute!==void 0?r.converter:Qs).toAttribute(e,r.type);this._$Em=t,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(t,e){let r=this.constructor,i=r._$Eh.get(t);if(i!==void 0&&this._$Em!==i){let o=r.getPropertyOptions(i),s=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:Qs;this._$Em=i,this[i]=s.fromAttribute(e,o.type),this._$Em=null}}requestUpdate(t,e,r){if(t!==void 0){if(r??(r=this.constructor.getPropertyOptions(t)),!(r.hasChanged??nd)(this[t],e))return;this.P(t,e,r)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(t,e,r){this._$AL.has(t)||this._$AL.set(t,e),r.reflect===!0&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$ET(){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[i,o]of this._$Ep)this[i]=o;this._$Ep=void 0}let r=this.constructor.elementProperties;if(r.size>0)for(let[i,o]of r)o.wrapped!==!0||this._$AL.has(i)||this[i]===void 0||this.P(i,this[i],o)}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._$EU()}catch(r){throw t=!1,this._$EU(),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)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach(e=>this._$EC(e,this[e]))),this._$EU()}updated(t){}firstUpdated(t){}};he.elementStyles=[],he.shadowRootOptions={mode:"open"},he[pr("elementProperties")]=new Map,he[pr("finalized")]=new Map,hm?.({ReactiveElement:he}),(Ce.reactiveElementVersions??(Ce.reactiveElementVersions=[])).push("2.0.4");var Xt=class extends he{constructor(){super(...arguments),this.renderOptions={host:this},this.o=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.o=ui(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this.o?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this.o?.setConnected(!1)}render(){return Ut}};Xt._$litElement$=!0,Xt.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:Xt});var fm=globalThis.litElementPolyfillSupport;fm?.({LitElement:Xt});(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.0");var pm=G` :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)); } `,kv=G` /** * 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; } `,rd=G` .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); } `,id=G` ${pm} [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 Ye=class extends Xt{static define(t,e,r){t==null&&(t=this.baseName),e==null&&(e=this),!this.customElementRegistry.get(t)&&this.customElementRegistry.define(t,mm(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)}};Ye.customElementRegistry=window.customElements;function mm(n){return class extends n{}}function ht(n){this.content=n}ht.prototype={constructor:ht,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,i=r.find(n),o=r.content.slice();return i==-1?o.push(e||n,t):(o[i+1]=t,e&&(o[i]=e)),new ht(o)},remove:function(n){var t=this.find(n);if(t==-1)return this;var e=this.content.slice();return e.splice(t,2),new ht(e)},addToStart:function(n,t){return new ht([n,t].concat(this.remove(n).content))},addToEnd:function(n,t){var e=this.remove(n).content.slice();return e.push(n,t),new ht(e)},addBefore:function(n,t,e){var r=this.remove(t),i=r.content.slice(),o=r.find(n);return i.splice(o==-1?i.length:o,0,t,e),new ht(i)},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=ht.from(n),n.size?new ht(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=ht.from(n),n.size?new ht(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var t=this;n=ht.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}};ht.from=function(n){if(n instanceof ht)return n;var t=[];if(n)for(var e in n)t.push(e,n[e]);return new ht(t)};var Zs=ht;function pd(n,t,e){for(let r=0;;r++){if(r==n.childCount||r==t.childCount)return n.childCount==t.childCount?null:e;let i=n.child(r),o=t.child(r);if(i==o){e+=i.nodeSize;continue}if(!i.sameMarkup(o))return e;if(i.isText&&i.text!=o.text){for(let s=0;i.text[s]==o.text[s];s++)e++;return e}if(i.content.size||o.content.size){let s=pd(i.content,o.content,e+1);if(s!=null)return s}e+=i.nodeSize}}function md(n,t,e,r){for(let i=n.childCount,o=t.childCount;;){if(i==0||o==0)return i==o?null:{a:e,b:r};let s=n.child(--i),a=t.child(--o),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=md(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,i=0,o){for(let s=0,a=0;a<e;s++){let l=this.content[s],c=a+l.nodeSize;if(c>t&&r(l,i+a,o||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,i+d)}a=c}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,r,i){let o="",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?i?typeof i=="function"?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(s?s=!1:o+=r),o+=c},0),o}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,r=t.firstChild,i=this.content.slice(),o=0;for(e.isText&&e.sameMarkup(r)&&(i[i.length-1]=e.withText(e.text+r.text),o=1);o<t.content.length;o++)i.push(t.content[o]);return new n(i,this.size+t.size)}cut(t,e=this.size){if(t==0&&e==this.size)return this;let r=[],i=0;if(e>t)for(let o=0,s=0;s<e;o++){let a=this.content[o],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),i+=a.nodeSize),s=l}return new n(r,i)}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 i=this.content.slice(),o=this.size+e.nodeSize-r.nodeSize;return i[t]=e,new n(i,o)}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 i=this.content[e];t(i,r,e),r+=i.nodeSize}}findDiffStart(t,e=0){return pd(this,t,e)}findDiffEnd(t,e=this.size,r=t.size){return md(this,t,e,r)}findIndex(t,e=-1){if(t==0)return bi(0,t);if(t==this.size)return bi(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let r=0,i=0;;r++){let o=this.child(r),s=i+o.nodeSize;if(s>=t)return s==t||e>0?bi(r+1,s):bi(r,i);i=s}}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 i=0;i<t.length;i++){let o=t[i];r+=o.nodeSize,i&&o.isText&&t[i-1].sameMarkup(o)?(e||(e=t.slice(0,i)),e[e.length-1]=o.withText(e[e.length-1].text+o.text)):e&&e.push(o)}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 ta={index:0,offset:0};function bi(n,t){return ta.index=n,ta.offset=t,ta}function xi(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(!xi(n[r],t[r]))return!1}else{for(let r in n)if(!(r in t)||!xi(n[r],t[r]))return!1;for(let r in t)if(!(r in n))return!1}return!0}var z=class n{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,r=!1;for(let i=0;i<t.length;i++){let o=t[i];if(this.eq(o))return t;if(this.type.excludes(o.type))e||(e=t.slice(0,i));else{if(o.type.excludes(this.type))return t;!r&&o.type.rank>this.type.rank&&(e||(e=t.slice(0,i)),e.push(this),r=!0),e&&e.push(o)}}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&&xi(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 i=r.create(e.attrs);return r.checkAttrs(i.attrs),i}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,i)=>r.type.rank-i.type.rank),e}};z.none=[];var Ze=class extends Error{},M=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=bd(this.content,t+this.openStart,e);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(t,e){return new n(gd(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,i=e.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(w.fromJSON(t,e.content),r,i)}static maxOpen(t,e=!0){let r=0,i=0;for(let o=t.firstChild;o&&!o.isLeaf&&(e||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=t.lastChild;o&&!o.isLeaf&&(e||!o.type.spec.isolating);o=o.lastChild)i++;return new n(t,r,i)}};M.empty=new M(w.empty,0,0);function gd(n,t,e){let{index:r,offset:i}=n.findIndex(t),o=n.maybeChild(r),{index:s,offset:a}=n.findIndex(e);if(i==t||o.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,o.copy(gd(o.content,t-i-1,e-i-1)))}function bd(n,t,e,r){let{index:i,offset:o}=n.findIndex(t),s=n.maybeChild(i);if(o==t||s.isText)return r&&!r.canReplace(i,i,e)?null:n.cut(0,t).append(e).append(n.cut(t));let a=bd(s.content,t-o-1,e);return a&&n.replaceChild(i,s.copy(a))}function gm(n,t,e){if(e.openStart>n.depth)throw new Ze("Inserted content deeper than insertion position");if(n.depth-e.openStart!=t.depth-e.openEnd)throw new Ze("Inconsistent open depths");return yd(n,t,e,0)}function yd(n,t,e,r){let i=n.index(r),o=n.node(r);if(i==t.index(r)&&r<n.depth-e.openStart){let s=yd(n,t,e,r+1);return o.copy(o.content.replaceChild(i,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 Qe(s,a.cut(0,n.parentOffset).append(e.content).append(a.cut(t.parentOffset)))}else{let{start:s,end:a}=bm(e,n);return Qe(o,vd(n,s,a,t,r))}else return Qe(o,vi(n,t,r))}function xd(n,t){if(!t.type.compatibleContent(n.type))throw new Ze("Cannot join "+t.type.name+" onto "+n.type.name)}function na(n,t,e){let r=n.node(e);return xd(r,t.node(e)),r}function Xe(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 mr(n,t,e,r){let i=(t||n).node(e),o=0,s=t?t.index(e):i.childCount;n&&(o=n.index(e),n.depth>e?o++:n.textOffset&&(Xe(n.nodeAfter,r),o++));for(let a=o;a<s;a++)Xe(i.child(a),r);t&&t.depth==e&&t.textOffset&&Xe(t.nodeBefore,r)}function Qe(n,t){return n.type.checkContent(t),n.copy(t)}function vd(n,t,e,r,i){let o=n.depth>i&&na(n,t,i+1),s=r.depth>i&&na(e,r,i+1),a=[];return mr(null,n,i,a),o&&s&&t.index(i)==e.index(i)?(xd(o,s),Xe(Qe(o,vd(n,t,e,r,i+1)),a)):(o&&Xe(Qe(o,vi(n,t,i+1)),a),mr(t,e,i,a),s&&Xe(Qe(s,vi(e,r,i+1)),a)),mr(r,null,i,a),new w(a)}function vi(n,t,e){let r=[];if(mr(null,n,e,r),n.depth>e){let i=na(n,t,e+1);Xe(Qe(i,vi(n,t,e+1)),r)}return mr(t,null,e,r),new w(r)}function bm(n,t){let e=t.depth-n.openStart,i=t.node(e).copy(n.content);for(let o=e-1;o>=0;o--)i=t.node(o).copy(w.from(i));return{start:i.resolveNoCache(n.openStart+e),end:i.resolveNoCache(i.content.size-n.openEnd-e)}}var ki=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],i=t.child(e);return r?t.child(e).cut(r):i}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],i=e==0?0:this.path[e*3-1]+1;for(let o=0;o<t;o++)i+=r.child(o).nodeSize;return i}marks(){let t=this.parent,e=this.index();if(t.content.size==0)return z.none;if(this.textOffset)return t.child(e).marks;let r=t.maybeChild(e-1),i=t.maybeChild(e);if(!r){let a=r;r=i,i=a}let o=r.marks;for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!i||!o[s].isInSet(i.marks))&&(o=o[s--].removeFromSet(o));return o}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let r=e.marks,i=t.parent.maybeChild(t.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!i||!r[o].isInSet(i.marks))&&(r=r[o--].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 tn(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=[],i=0,o=e;for(let s=t;;){let{index:a,offset:l}=s.content.findIndex(o),c=o-l;if(r.push(s,a,i+l),!c||(s=s.child(a),s.isText))break;o=c-1,i+=l+1}return new n(e,r,o)}static resolveCached(t,e){let r=od.get(t);if(r)for(let o=0;o<r.elts.length;o++){let s=r.elts[o];if(s.pos==e)return s}else od.set(t,r=new ra);let i=r.elts[r.i]=n.resolve(t,e);return r.i=(r.i+1)%ym,i}},ra=class{constructor(){this.elts=[],this.i=0}},ym=12,od=new WeakMap,tn=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)}},xm=Object.create(null),jt=class n{constructor(t,e,r,i=z.none){this.type=t,this.attrs=e,this.marks=i,this.content=r||w.empty}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,i=0){this.content.nodesBetween(t,e,r,i,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,i){return this.content.textBetween(t,e,r,i)}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&&xi(this.attrs,e||t.defaultAttrs||xm)&&z.sameSet(this.marks,r||z.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 M.empty;let i=this.resolve(t),o=this.resolve(e),s=r?0:i.sharedDepth(e),a=i.start(s),c=i.node(s).content.cut(i.pos-a,o.pos-a);return new M(c,i.depth-s,o.depth-s)}replace(t,e,r){return gm(this.resolve(t),this.resolve(e),r)}nodeAt(t){for(let e=this;;){let{index:r,offset:i}=e.content.findIndex(t);if(e=e.maybeChild(r),!e)return null;if(i==t||e.isText)return e;t-=i+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 i=this.content.child(e-1);return{node:i,index:e-1,offset:r-i.nodeSize}}resolve(t){return ki.resolveCached(this,t)}resolveNoCache(t){return ki.resolve(this,t)}rangeHasMark(t,e,r){let i=!1;return e>t&&this.nodesBetween(t,e,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}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()+")"),kd(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,i=0,o=r.childCount){let s=this.contentMatchAt(t).matchFragment(r,i,o),a=s&&s.matchFragment(this.content,e);if(!a||!a.validEnd)return!1;for(let l=i;l<o;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(t,e,r,i){if(i&&!this.type.allowsMarks(i))return!1;let o=this.contentMatchAt(t).matchType(r),s=o&&o.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=z.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(!z.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 i=w.fromJSON(t,e.content),o=t.nodeType(e.type).create(e.attrs,i,r);return o.type.checkAttrs(o.attrs),o}};jt.prototype.text=void 0;var ia=class n extends jt{constructor(t,e,r,i){if(super(t,e,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):kd(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 kd(n,t){for(let e=n.length-1;e>=0;e--)t=n[e].type.name+"("+t+")";return t}var en=class n{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let r=new oa(t,e);if(r.next==null)return n.empty;let i=Sd(r);r.next&&r.err("Unexpected trailing text");let o=Mm(Am(i));return Tm(o,r),o}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 i=this;for(let o=e;i&&o<r;o++)i=i.matchType(t.child(o).type);return i}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 i=[this];function o(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())&&i.indexOf(u)==-1){i.push(u);let h=o(u,a.concat(d));if(h)return h}}return null}return o(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 i=r.shift(),o=i.match;if(o.matchType(t)){let s=[];for(let a=i;a.type;a=a.via)s.push(a.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:a,next:l}=o.next[s];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in e)&&(!i.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:i}),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 i=0;i<r.next.length;i++)t.indexOf(r.next[i].next)==-1&&e(r.next[i].next)}return e(this),t.map((r,i)=>{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)o+=(s?", ":"")+r.next[s].type.name+"->"+t.indexOf(r.next[s].next);return o}).join(` `)}};en.empty=new en(!0);var oa=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 Sd(n){let t=[];do t.push(vm(n));while(n.eat("|"));return t.length==1?t[0]:{type:"choice",exprs:t}}function vm(n){let t=[];do t.push(km(n));while(n.next&&n.next!=")"&&n.next!="|");return t.length==1?t[0]:{type:"seq",exprs:t}}function km(n){let t=Em(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=Sm(n,t);else break;return t}function sd(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let t=Number(n.next);return n.pos++,t}function Sm(n,t){let e=sd(n),r=e;return n.eat(",")&&(n.next!="}"?r=sd(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:e,max:r,expr:t}}function wm(n,t){let e=n.nodeTypes,r=e[t];if(r)return[r];let i=[];for(let o in e){let s=e[o];s.isInGroup(t)&&i.pu