mailery 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/spa/index-csgOs39s.js +41 -0
- package/dist/admin/spa/index-csgOs39s.js.map +1 -0
- package/dist/admin/spa/index.html +1 -1
- package/dist/admin/spa/{template-editor-DUZfzI5F.js → template-editor-BuYSO1FP.js} +2 -2
- package/dist/admin/spa/{template-editor-DUZfzI5F.js.map → template-editor-BuYSO1FP.js.map} +1 -1
- package/dist/index.cjs +316 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +316 -3
- package/dist/index.js.map +1 -1
- package/dist/{null-CWw3Gpbl.d.cts → null-DaisDvB_.d.cts} +58 -16
- package/dist/{null-CWw3Gpbl.d.ts → null-DaisDvB_.d.ts} +58 -16
- package/dist/testing.cjs +19 -0
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +19 -0
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
- package/dist/admin/spa/index-DlhleV6M.js +0 -41
- package/dist/admin/spa/index-DlhleV6M.js.map +0 -1
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
8
8
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
9
9
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet" />
|
|
10
|
-
<script type="module" crossorigin src="/admin/mailer/_assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/admin/mailer/_assets/index-csgOs39s.js"></script>
|
|
11
11
|
<link rel="stylesheet" crossorigin href="/admin/mailer/_assets/index-B6riKdpB.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ik=Object.defineProperty;var sk=(t,e,n)=>e in t?ik(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var oa=(t,e,n)=>sk(t,typeof e!="symbol"?e+"":e,n);import{r as x,R as fe,a as Tf,b as eb,g as tb,j as p,c as Af,s as vp,u as ok,P as ak,I as Bn,d as du}from"./index-DlhleV6M.js";function ut(t){this.content=t}ut.prototype={constructor:ut,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),s=r.content.slice();return i==-1?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new ut(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new ut(n)},addToStart:function(t,e){return new ut([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new ut(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),s=r.find(t);return i.splice(s==-1?i.length:s,0,e,n),new ut(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=ut.from(t),t.size?new ut(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=ut.from(t),t.size?new ut(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=ut.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};ut.from=function(t){if(t instanceof ut)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new ut(e)};function nb(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)n++;return n}if(i.content.size||s.content.size){let o=nb(i.content,s.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function rb(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:r};let o=t.child(--i),a=e.child(--s),l=o.nodeSize;if(o==a){n-=l,r-=l;continue}if(!o.sameMarkup(a))return{a:n,b:r};if(o.isText&&o.text!=a.text){let c=0,u=Math.min(o.text.length,a.text.length);for(;c<u&&o.text[o.text.length-c-1]==a.text[a.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(o.content.size||a.content.size){let c=rb(o.content,a.content,n-1,r-1);if(c)return c}n-=l,r-=l}}class P{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,s){for(let o=0,a=0;a<n;o++){let l=this.content[o],c=a+l.nodeSize;if(c>e&&r(l,i+a,s||null,o)!==!1&&l.content.size){let u=a+1;l.nodesBetween(Math.max(0,e-u),Math.min(l.content.size,n-u),r,i+u)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let s="",o=!0;return this.nodesBetween(e,n,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,n-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&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new P(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let s=0,o=0;o<n;s++){let a=this.content[s],l=o+a.nodeSize;l>e&&((o<e||l>n)&&(a.isText?a=a.cut(Math.max(0,e-o),Math.min(a.text.length,n-o)):a=a.cut(Math.max(0,e-o-1),Math.min(a.content.size,n-o-1))),r.push(a),i+=a.nodeSize),o=l}return new P(r,i)}cutByIndex(e,n){return e==n?P.empty:e==0&&n==this.content.length?this:new P(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new P(i,s)}addToStart(e){return new P([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new P(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))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(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return nb(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return rb(this,e,n,r)}findIndex(e){if(e==0)return aa(0,e);if(e==this.size)return aa(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),s=r+i.nodeSize;if(s>=e)return s==e?aa(n+1,s):aa(n,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return P.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new P(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return P.empty;let n,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(n||(n=e.slice(0,i)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new P(n||e,r)}static from(e){if(!e)return P.empty;if(e instanceof P)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new P([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}P.empty=new P([],0);const fu={index:0,offset:0};function aa(t,e){return fu.index=t,fu.offset=e,fu}function ol(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!ol(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!ol(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Le=class wd{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))n||(n=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(s)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ol(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let i=r.create(n.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return wd.none;if(e instanceof wd)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};Le.none=[];class al extends Error{}class Y{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=sb(this.content,e+this.openStart,n);return r&&new Y(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Y(ib(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return Y.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Y(P.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new Y(e,r,i)}}Y.empty=new Y(P.empty,0,0);function ib(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:a}=t.findIndex(n);if(i==e||s.isText){if(a!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(ib(s.content,e-i-1,n-i-1)))}function sb(t,e,n,r){let{index:i,offset:s}=t.findIndex(e),o=t.maybeChild(i);if(s==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=sb(o.content,e-s-1,n,o);return a&&t.replaceChild(i,o.copy(a))}function lk(t,e,n){if(n.openStart>t.depth)throw new al("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new al("Inconsistent open depths");return ob(t,e,n,0)}function ob(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=ob(t,e,n,r+1);return s.copy(s.content.replaceChild(i,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,a=o.content;return Qr(o,a.cut(0,t.parentOffset).append(n.content).append(a.cut(e.parentOffset)))}else{let{start:o,end:a}=ck(n,t);return Qr(s,lb(t,o,a,e,r))}else return Qr(s,ll(t,e,r))}function ab(t,e){if(!e.type.compatibleContent(t.type))throw new al("Cannot join "+e.type.name+" onto "+t.type.name)}function Ed(t,e,n){let r=t.node(n);return ab(r,e.node(n)),r}function Zr(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Us(t,e,n,r){let i=(e||t).node(n),s=0,o=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(Zr(t.nodeAfter,r),s++));for(let a=s;a<o;a++)Zr(i.child(a),r);e&&e.depth==n&&e.textOffset&&Zr(e.nodeBefore,r)}function Qr(t,e){return t.type.checkContent(e),t.copy(e)}function lb(t,e,n,r,i){let s=t.depth>i&&Ed(t,e,i+1),o=r.depth>i&&Ed(n,r,i+1),a=[];return Us(null,t,i,a),s&&o&&e.index(i)==n.index(i)?(ab(s,o),Zr(Qr(s,lb(t,e,n,r,i+1)),a)):(s&&Zr(Qr(s,ll(t,e,i+1)),a),Us(e,n,i,a),o&&Zr(Qr(o,ll(n,r,i+1)),a)),Us(r,null,i,a),new P(a)}function ll(t,e,n){let r=[];if(Us(null,t,n,r),t.depth>n){let i=Ed(t,e,n+1);Zr(Qr(i,ll(t,e,n+1)),r)}return Us(e,null,n,r),new P(r)}function ck(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)i=e.node(s).copy(P.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class oo{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Le.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let a=r;r=i,i=a}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new ao(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,s=n;for(let o=e;;){let{index:a,offset:l}=o.content.findIndex(s),c=s-l;if(r.push(o,a,i+l),!c||(o=o.child(a),o.isText))break;s=c-1,i+=l+1}return new oo(n,r,s)}static resolveCached(e,n){let r=xp.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==n)return o}else xp.set(e,r=new uk);let i=r.elts[r.i]=oo.resolve(e,n);return r.i=(r.i+1)%dk,i}}class uk{constructor(){this.elts=[],this.i=0}}const dk=12,xp=new WeakMap;class ao{constructor(e,n,r){this.$from=e,this.$to=n,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)}}const fk=Object.create(null);let kr=class kd{constructor(e,n,r,i=Le.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||P.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&ol(this.attrs,n||e.defaultAttrs||fk)&&Le.sameSet(this.marks,r||Le.none)}copy(e=null){return e==this.content?this:new kd(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new kd(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return Y.empty;let i=this.resolve(e),s=this.resolve(n),o=r?0:i.sharedDepth(n),a=i.start(o),c=i.node(o).content.cut(i.pos-a,s.pos-a);return new Y(c,i.depth-o,s.depth-o)}replace(e,n,r){return lk(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return oo.resolveCached(this,e)}resolveNoCache(e){return oo.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,s=>(r.isInSet(s.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 e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),cb(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=P.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),a=o&&o.matchFragment(this.content,n);if(!a||!a.validEnd)return!1;for(let l=i;l<s;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Le.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Le.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=P.fromJSON(e,n.content),s=e.nodeType(n.type).create(n.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};kr.prototype.text=void 0;class cl extends kr{constructor(e,n,r,i){if(super(e,n,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):cb(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new cl(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new cl(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function cb(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class ai{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new hk(e,n);if(r.next==null)return ai.empty;let i=ub(r);r.next&&r.err("Unexpected trailing text");let s=xk(vk(i));return wk(s,r),s}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let s=n;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function s(o,a){let l=o.matchFragment(e,r);if(l&&(!n||l.validEnd))return P.from(a.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:d}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let f=s(d,a.concat(u));if(f)return f}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let a=i;a.type;a=a.via)o.push(a.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:a,next:l}=s.next[o];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in n)&&(!i.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:i}),n[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
|
|
1
|
+
var ik=Object.defineProperty;var sk=(t,e,n)=>e in t?ik(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var oa=(t,e,n)=>sk(t,typeof e!="symbol"?e+"":e,n);import{r as x,R as fe,a as Tf,b as eb,g as tb,j as p,c as Af,s as vp,u as ok,P as ak,I as Bn,d as du}from"./index-csgOs39s.js";function ut(t){this.content=t}ut.prototype={constructor:ut,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),s=r.content.slice();return i==-1?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new ut(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new ut(n)},addToStart:function(t,e){return new ut([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new ut(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),s=r.find(t);return i.splice(s==-1?i.length:s,0,e,n),new ut(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=ut.from(t),t.size?new ut(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=ut.from(t),t.size?new ut(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=ut.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};ut.from=function(t){if(t instanceof ut)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new ut(e)};function nb(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)n++;return n}if(i.content.size||s.content.size){let o=nb(i.content,s.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function rb(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:r};let o=t.child(--i),a=e.child(--s),l=o.nodeSize;if(o==a){n-=l,r-=l;continue}if(!o.sameMarkup(a))return{a:n,b:r};if(o.isText&&o.text!=a.text){let c=0,u=Math.min(o.text.length,a.text.length);for(;c<u&&o.text[o.text.length-c-1]==a.text[a.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(o.content.size||a.content.size){let c=rb(o.content,a.content,n-1,r-1);if(c)return c}n-=l,r-=l}}class P{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,s){for(let o=0,a=0;a<n;o++){let l=this.content[o],c=a+l.nodeSize;if(c>e&&r(l,i+a,s||null,o)!==!1&&l.content.size){let u=a+1;l.nodesBetween(Math.max(0,e-u),Math.min(l.content.size,n-u),r,i+u)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let s="",o=!0;return this.nodesBetween(e,n,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,n-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&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new P(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let s=0,o=0;o<n;s++){let a=this.content[s],l=o+a.nodeSize;l>e&&((o<e||l>n)&&(a.isText?a=a.cut(Math.max(0,e-o),Math.min(a.text.length,n-o)):a=a.cut(Math.max(0,e-o-1),Math.min(a.content.size,n-o-1))),r.push(a),i+=a.nodeSize),o=l}return new P(r,i)}cutByIndex(e,n){return e==n?P.empty:e==0&&n==this.content.length?this:new P(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new P(i,s)}addToStart(e){return new P([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new P(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))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(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return nb(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return rb(this,e,n,r)}findIndex(e){if(e==0)return aa(0,e);if(e==this.size)return aa(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),s=r+i.nodeSize;if(s>=e)return s==e?aa(n+1,s):aa(n,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return P.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new P(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return P.empty;let n,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(n||(n=e.slice(0,i)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new P(n||e,r)}static from(e){if(!e)return P.empty;if(e instanceof P)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new P([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}P.empty=new P([],0);const fu={index:0,offset:0};function aa(t,e){return fu.index=t,fu.offset=e,fu}function ol(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!ol(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!ol(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Le=class wd{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))n||(n=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(s)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ol(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let i=r.create(n.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return wd.none;if(e instanceof wd)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};Le.none=[];class al extends Error{}class Y{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=sb(this.content,e+this.openStart,n);return r&&new Y(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Y(ib(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return Y.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Y(P.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new Y(e,r,i)}}Y.empty=new Y(P.empty,0,0);function ib(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:a}=t.findIndex(n);if(i==e||s.isText){if(a!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(ib(s.content,e-i-1,n-i-1)))}function sb(t,e,n,r){let{index:i,offset:s}=t.findIndex(e),o=t.maybeChild(i);if(s==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=sb(o.content,e-s-1,n,o);return a&&t.replaceChild(i,o.copy(a))}function lk(t,e,n){if(n.openStart>t.depth)throw new al("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new al("Inconsistent open depths");return ob(t,e,n,0)}function ob(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=ob(t,e,n,r+1);return s.copy(s.content.replaceChild(i,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,a=o.content;return Qr(o,a.cut(0,t.parentOffset).append(n.content).append(a.cut(e.parentOffset)))}else{let{start:o,end:a}=ck(n,t);return Qr(s,lb(t,o,a,e,r))}else return Qr(s,ll(t,e,r))}function ab(t,e){if(!e.type.compatibleContent(t.type))throw new al("Cannot join "+e.type.name+" onto "+t.type.name)}function Ed(t,e,n){let r=t.node(n);return ab(r,e.node(n)),r}function Zr(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Us(t,e,n,r){let i=(e||t).node(n),s=0,o=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(Zr(t.nodeAfter,r),s++));for(let a=s;a<o;a++)Zr(i.child(a),r);e&&e.depth==n&&e.textOffset&&Zr(e.nodeBefore,r)}function Qr(t,e){return t.type.checkContent(e),t.copy(e)}function lb(t,e,n,r,i){let s=t.depth>i&&Ed(t,e,i+1),o=r.depth>i&&Ed(n,r,i+1),a=[];return Us(null,t,i,a),s&&o&&e.index(i)==n.index(i)?(ab(s,o),Zr(Qr(s,lb(t,e,n,r,i+1)),a)):(s&&Zr(Qr(s,ll(t,e,i+1)),a),Us(e,n,i,a),o&&Zr(Qr(o,ll(n,r,i+1)),a)),Us(r,null,i,a),new P(a)}function ll(t,e,n){let r=[];if(Us(null,t,n,r),t.depth>n){let i=Ed(t,e,n+1);Zr(Qr(i,ll(t,e,n+1)),r)}return Us(e,null,n,r),new P(r)}function ck(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)i=e.node(s).copy(P.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class oo{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Le.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let a=r;r=i,i=a}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new ao(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,s=n;for(let o=e;;){let{index:a,offset:l}=o.content.findIndex(s),c=s-l;if(r.push(o,a,i+l),!c||(o=o.child(a),o.isText))break;s=c-1,i+=l+1}return new oo(n,r,s)}static resolveCached(e,n){let r=xp.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==n)return o}else xp.set(e,r=new uk);let i=r.elts[r.i]=oo.resolve(e,n);return r.i=(r.i+1)%dk,i}}class uk{constructor(){this.elts=[],this.i=0}}const dk=12,xp=new WeakMap;class ao{constructor(e,n,r){this.$from=e,this.$to=n,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)}}const fk=Object.create(null);let kr=class kd{constructor(e,n,r,i=Le.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||P.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&ol(this.attrs,n||e.defaultAttrs||fk)&&Le.sameSet(this.marks,r||Le.none)}copy(e=null){return e==this.content?this:new kd(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new kd(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return Y.empty;let i=this.resolve(e),s=this.resolve(n),o=r?0:i.sharedDepth(n),a=i.start(o),c=i.node(o).content.cut(i.pos-a,s.pos-a);return new Y(c,i.depth-o,s.depth-o)}replace(e,n,r){return lk(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return oo.resolveCached(this,e)}resolveNoCache(e){return oo.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,s=>(r.isInSet(s.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 e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),cb(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=P.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),a=o&&o.matchFragment(this.content,n);if(!a||!a.validEnd)return!1;for(let l=i;l<s;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Le.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Le.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=P.fromJSON(e,n.content),s=e.nodeType(n.type).create(n.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};kr.prototype.text=void 0;class cl extends kr{constructor(e,n,r,i){if(super(e,n,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):cb(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new cl(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new cl(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function cb(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class ai{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new hk(e,n);if(r.next==null)return ai.empty;let i=ub(r);r.next&&r.err("Unexpected trailing text");let s=xk(vk(i));return wk(s,r),s}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let s=n;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function s(o,a){let l=o.matchFragment(e,r);if(l&&(!n||l.validEnd))return P.from(a.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:d}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let f=s(d,a.concat(u));if(f)return f}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let a=i;a.type;a=a.via)o.push(a.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:a,next:l}=s.next[o];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in n)&&(!i.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:i}),n[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
|
|
2
2
|
`)}}ai.empty=new ai(!0);class hk{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.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(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function ub(t){let e=[];do e.push(pk(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function pk(t){let e=[];do e.push(mk(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function mk(t){let e=bk(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=gk(t,e);else break;return e}function wp(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function gk(t,e){let n=wp(t),r=n;return t.eat(",")&&(t.next!="}"?r=wp(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function yk(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let s in n){let o=n[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function bk(t){if(t.eat("(")){let e=ub(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=yk(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function vk(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(o,a,l){let c={term:l,to:a};return e[o].push(c),c}function i(o,a){o.forEach(l=>l.to=a)}function s(o,a){if(o.type=="choice")return o.exprs.reduce((l,c)=>l.concat(s(c,a)),[]);if(o.type=="seq")for(let l=0;;l++){let c=s(o.exprs[l],a);if(l==o.exprs.length-1)return c;i(c,a=n())}else if(o.type=="star"){let l=n();return r(a,l),i(s(o.expr,l),l),[r(l)]}else if(o.type=="plus"){let l=n();return i(s(o.expr,a),l),i(s(o.expr,l),l),[r(l)]}else{if(o.type=="opt")return[r(a)].concat(s(o.expr,a));if(o.type=="range"){let l=a;for(let c=0;c<o.min;c++){let u=n();i(s(o.expr,l),u),l=u}if(o.max==-1)i(s(o.expr,l),l);else for(let c=o.min;c<o.max;c++){let u=n();r(l,u),i(s(o.expr,l),u),l=u}return[r(l)]}else{if(o.type=="name")return[r(a,void 0,o.value)];throw new Error("Unknown expr type")}}}}function db(t,e){return e-t}function Ep(t,e){let n=[];return r(e),n.sort(db);function r(i){let s=t[i];if(s.length==1&&!s[0].term)return r(s[0].to);n.push(i);for(let o=0;o<s.length;o++){let{term:a,to:l}=s[o];!a&&n.indexOf(l)==-1&&r(l)}}}function xk(t){let e=Object.create(null);return n(Ep(t,0));function n(r){let i=[];r.forEach(o=>{t[o].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let u=0;u<i.length;u++)i[u][0]==a&&(c=i[u][1]);Ep(t,l).forEach(u=>{c||i.push([a,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new ai(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let a=i[o][1].sort(db);s.next.push({type:i[o][0],next:e[a.join(",")]||n(a)})}return s}}function wk(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],s=!i.validEnd,o=[];for(let a=0;a<i.next.length;a++){let{type:l,next:c}=i.next[a];o.push(l.name),s&&!(l.isText||l.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function fb(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function hb(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let s=t[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function pb(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let s=t[i];s.validate&&s.validate(e[i])}}function mb(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new kk(t,r,e[r]);return n}let kp=class gb{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=mb(e,r.attrs),this.defaultAttrs=fb(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ai.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:hb(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new kr(this,this.computeAttrs(e),P.from(n),Le.setFrom(r))}createChecked(e=null,n,r){return n=P.from(n),this.checkContent(n),new kr(this,this.computeAttrs(e),n,Le.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=P.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let i=this.contentMatch.matchFragment(n),s=i&&i.fillBefore(P.empty,!0);return s?new kr(this,e,n.append(s),Le.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){pb(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:Le.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,o)=>r[s]=new gb(s,n,o));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Ek(t,e,n){let r=n.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${s}`)}}class kk{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Ek(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class gc{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=mb(e,i.attrs),this.excluded=null;let s=fb(this.attrs);this.instance=s?new Le(this,s):null}create(e=null){return!e&&this.instance?this.instance:new Le(this,hb(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new gc(s,i++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){pb(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}let yb=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=ut.from(e.nodes),n.marks=ut.from(e.marks||{}),this.nodes=kp.compile(this.spec.nodes,this),this.marks=gc.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",a=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=ai.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=a=="_"?null:a?Cp(this,a.split(" ")):a==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:Cp(this,o.split(" "))}this.nodeFromJSON=i=>kr.fromJSON(this,i),this.markFromJSON=i=>Le.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof kp){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,i)}text(e,n){let r=this.nodes.text;return new cl(r,r.defaultAttrs,e,Le.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function Cp(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t.marks[i],o=s;if(s)n.push(s);else for(let a in t.marks){let l=t.marks[a];(i=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=l)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function Ck(t){return t.tag!=null}function Sk(t){return t.style!=null}let Vs=class Cd{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(Ck(i))this.tags.push(i);else if(Sk(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,n={}){let r=new _p(this,n,!1);return r.addAll(e,Le.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new _p(this,n,!0);return r.addAll(e,Le.none,n.from,n.to),Y.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(Tk(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,n,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],a=o.style;if(!(a.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=n))){if(o.getAttrs){let l=o.getAttrs(n);if(l===!1)continue;o.attrs=l||void 0}return o}}}static schemaRules(e){let n=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<n.length;o++){let a=n[o];if((a.priority==null?50:a.priority)<s)break}n.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Np(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Np(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Cd(e,Cd.schemaRules(e)))}};const bb={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},_k={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},vb={ol:!0,ul:!0},lo=1,Sd=2,Ws=4;function Sp(t,e,n){return e!=null?(e?lo:0)|(e==="full"?Sd:0):t&&t.whitespace=="pre"?lo|Sd:n&~Ws}class la{constructor(e,n,r,i,s,o){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=Le.none,this.match=s||(o&Ws?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(P.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&lo)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let n=P.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(P.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!bb.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class _p{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,s,o=Sp(null,n.preserveWhitespace,0)|(r?Ws:0);i?s=new la(i.type,i.attrs,Le.none,!0,n.topMatch||i.type.contentMatch,o):r?s=new la(null,null,Le.none,!0,null,o):s=new la(e.schema.topNodeType,null,Le.none,!0,null,o),this.nodes=[s],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,s=i.options&Sd?"full":this.localPreserveWS||(i.options&lo)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
|
|
3
3
|
`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let l=0;l<a.length;l++)l&&this.insertNode(o.linebreakReplacement.create(),n,!0),a[l]&&this.insertNode(o.text(a[l]),n,!/\S/.test(a[l]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let a=i.content[i.content.length-1],l=e.previousSibling;(!a||l&&l.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),a;vb.hasOwnProperty(o)&&this.parser.normalizeLists&&Nk(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:_k.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,u=this.needsBlock;if(bb.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let d=l&&l.skip?n:this.readStyles(e,n);d&&this.addAll(e,d),c&&this.sync(s),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,l,c,l.consuming===!1?a:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
4
4
|
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=r.getPropertyValue(s);if(o)for(let a=void 0;;){let l=this.parser.matchStyle(s,o,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(c=>!l.clearMark(c)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return n}addElementByRule(e,n,r,i){let s,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(o,n.attrs||null,r,n.preserveWhitespace);l&&(s=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let a=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}s&&this.sync(a)&&this.open--}addAll(e,n,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,a=i==null?null:e.childNodes[i];o!=a;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,n);this.findAtPoint(e,s)}findPlace(e,n,r){let i,s;for(let o=this.open,a=0;o>=0;o--){let l=this.nodes[o],c=l.findWrapping(e);if(c&&(!i||i.length>c.length+a)&&(i=c,s=l,!c.length))break;if(l.solid){if(r)break;a+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)n=this.enterInner(i[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(n=this.enterInner(s,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=Le.none;for(let a of i.concat(e.marks))(s.type?s.type.allowsMarkType(a.type):Tp(a.type,e.type))&&(o=a.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,n,r,i){let s=this.findPlace(e.create(n),r,!1);return s&&(s=this.enterInner(e,n,r,!0,i)),s}enterInner(e,n,r,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let a=Sp(e,s,o.options);o.options&Ws&&o.content.length==0&&(a|=Ws);let l=Le.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):Tp(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new la(e,n,l,i,null,a)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=lo)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(a,l)=>{for(;a>=0;a--){let c=n[a];if(c==""){if(a==n.length-1||a==0)continue;for(;l>=s;l--)if(o(a-1,l))return!0;return!1}else{let u=l>0||l==0&&i?this.nodes[l].type:r&&l>=s?r.node(l-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;l--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function Nk(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&vb.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Tk(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Np(t){let e={};for(let n in t)e[n]=t[n];return e}function Tp(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],o=a=>{s.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:u}=a.edge(l);if(c==e||s.indexOf(u)<0&&o(u))return!0}};if(o(i.contentMatch))return!0}}class pi{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=hu(n).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let a=0,l=0;for(;a<s.length&&l<o.marks.length;){let c=o.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(s[a][0])||c.type.spec.spanning===!1)break;a++,l++}for(;a<s.length;)i=s.pop()[1];for(;l<o.marks.length;){let c=o.marks[l++],u=this.serializeMark(c,o.isInline,n);u&&(s.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=Va(hu(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,n);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&Va(hu(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return Va(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new pi(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Ap(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Ap(e.marks)}}function Ap(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function hu(t){return t.document||window.document}const Mp=new WeakMap;function Ak(t){let e=Mp.get(t);return e===void 0&&Mp.set(t,e=Mk(t)),e}function Mk(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)n(r[i]);else for(let i in r)n(r[i])}return n(t),e}function Va(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=Ak(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(n=i.slice(0,o),i=i.slice(o+1));let a,l=n?t.createElementNS(n,i):t.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?l.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&l.style?l.style.cssText=c[d]:l.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:h,contentDOM:m}=Va(t,f,n,r);if(l.appendChild(h),m){if(a)throw new RangeError("Multiple content holes");a=m}}}return{dom:l,contentDOM:a}}const xb=65535,wb=Math.pow(2,16);function Ok(t,e){return t+e*wb}function Op(t){return t&xb}function Rk(t){return(t-(t&xb))/wb}const Eb=1,kb=2,Wa=4,Cb=8;class _d{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Cb)>0}get deletedBefore(){return(this.delInfo&(Eb|Wa))>0}get deletedAfter(){return(this.delInfo&(kb|Wa))>0}get deletedAcross(){return(this.delInfo&Wa)>0}}class jt{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&jt.empty)return jt.empty}recover(e){let n=0,r=Op(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+Rk(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?i:0);if(l>e)break;let c=this.ranges[a+s],u=this.ranges[a+o],d=l+c;if(e<=d){let f=c?e==l?-1:e==d?1:n:n,h=l+i+(f<0?0:u);if(r)return h;let m=e==(n<0?l:d)?null:Ok(a/3,e-l),g=e==l?kb:e==d?Eb:Wa;return(n<0?e!=l:e!=d)&&(g|=Cb),new _d(h,g,m)}i+=u-c}return r?e+i:new _d(e+i,0,null)}touches(e,n){let r=0,i=Op(n),s=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let c=this.ranges[a+s],u=l+c;if(e<=u&&a==i*3)return!0;r+=this.ranges[a+o]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],a=o-(this.inverted?s:0),l=o+(this.inverted?0:s),c=this.ranges[i+n],u=this.ranges[i+r];e(a,a+c,l,l+u),s+=u-c}}invert(){return new jt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?jt.empty:new jt(e<0?[0,-e,0]:[0,0,e])}}jt.empty=new jt([]);class co{constructor(e,n,r=0,i=e?e.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new co(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?r+i:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new co;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],a=o.mapResult(e,n);if(a.recover!=null){let l=this.getMirror(s);if(l!=null&&l>s&&l<this.to){s=l,e=this._maps[l].recover(a.recover);continue}}i|=a.delInfo,e=a.pos}return r?e:new _d(e,i,null)}}const pu=Object.create(null);class wt{getMap(){return jt.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=pu[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in pu)throw new RangeError("Duplicate use of step JSON ID "+e);return pu[e]=n,n.prototype.jsonID=e,n}}class Ze{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Ze(e,null)}static fail(e){return new Ze(null,e)}static fromReplace(e,n,r,i){try{return Ze.ok(e.replace(n,r,i))}catch(s){if(s instanceof al)return Ze.fail(s.message);throw s}}}function Mf(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(Mf(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return P.fromArray(r)}class yr extends wt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new Y(Mf(n.content,(o,a)=>!o.isAtom||!a.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),n.openStart,n.openEnd);return Ze.fromReplace(e,this.from,this.to,s)}invert(){return new kn(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new yr(n.pos,r.pos,this.mark)}merge(e){return e instanceof yr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new yr(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new yr(n.from,n.to,e.markFromJSON(n.mark))}}wt.jsonID("addMark",yr);class kn extends wt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new Y(Mf(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Ze.fromReplace(e,this.from,this.to,r)}invert(){return new yr(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new kn(n.pos,r.pos,this.mark)}merge(e){return e instanceof kn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new kn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new kn(n.from,n.to,e.markFromJSON(n.mark))}}wt.jsonID("removeMark",kn);class br extends wt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ze.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Ze.fromReplace(e,this.pos,this.pos+1,new Y(P.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new br(this.pos,n.marks[i]);return new br(this.pos,this.mark)}}return new li(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new br(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new br(n.pos,e.markFromJSON(n.mark))}}wt.jsonID("addNodeMark",br);class li extends wt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ze.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Ze.fromReplace(e,this.pos,this.pos+1,new Y(P.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new br(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new li(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new li(n.pos,e.markFromJSON(n.mark))}}wt.jsonID("removeNodeMark",li);class Xe extends wt{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&Nd(e,this.from,this.to)?Ze.fail("Structure replace would overwrite content"):Ze.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new jt([this.from,this.to-this.from,this.slice.size])}invert(e){return new Xe(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&Xe.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new Xe(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Xe)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?Y.empty:new Y(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Xe(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?Y.empty:new Y(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Xe(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Xe(n.from,n.to,Y.fromJSON(e,n.slice),!!n.structure)}}Xe.MAP_BIAS=1;wt.jsonID("replace",Xe);class rt extends wt{constructor(e,n,r,i,s,o,a=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=a}apply(e){if(this.structure&&(Nd(e,this.from,this.gapFrom)||Nd(e,this.gapTo,this.to)))return Ze.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Ze.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Ze.fromReplace(e,this.from,this.to,r):Ze.fail("Content does not fit in gap")}getMap(){return new jt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new rt(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||s>r.pos?null:new rt(n.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new rt(n.from,n.to,n.gapFrom,n.gapTo,Y.fromJSON(e,n.slice),n.insert,!!n.structure)}}wt.jsonID("replaceAround",rt);function Nd(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function Ik(t,e,n,r){let i=[],s=[],o,a;t.doc.nodesBetween(e,n,(l,c,u)=>{if(!l.isInline)return;let d=l.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+l.nodeSize,n),m=r.addToSet(d);for(let g=0;g<d.length;g++)d[g].isInSet(m)||(o&&o.to==f&&o.mark.eq(d[g])?o.to=h:i.push(o=new kn(f,h,d[g])));a&&a.to==f?a.to=h:s.push(a=new yr(f,h,r))}}),i.forEach(l=>t.step(l)),s.forEach(l=>t.step(l))}function Dk(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,(o,a)=>{if(!o.isInline)return;s++;let l=null;if(r instanceof gc){let c=o.marks,u;for(;u=r.isInSet(c);)(l||(l=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(l=[r]):l=o.marks;if(l&&l.length){let c=Math.min(a+o.nodeSize,n);for(let u=0;u<l.length;u++){let d=l[u],f;for(let h=0;h<i.length;h++){let m=i[h];m.step==s-1&&d.eq(i[h].style)&&(f=m)}f?(f.to=c,f.step=s):i.push({style:d,from:Math.max(a,e),to:c,step:s})}}}),i.forEach(o=>t.step(new kn(o.from,o.to,o.style)))}function Of(t,e,n,r=n.contentMatch,i=!0){let s=t.doc.nodeAt(e),o=[],a=e+1;for(let l=0;l<s.childCount;l++){let c=s.child(l),u=a+c.nodeSize,d=r.matchType(c.type);if(!d)o.push(new Xe(a,u,Y.empty));else{r=d;for(let f=0;f<c.marks.length;f++)n.allowsMarkType(c.marks[f].type)||t.step(new kn(a,u,c.marks[f]));if(i&&c.isText&&n.whitespace!="pre"){let f,h=/\r?\n|\r/g,m;for(;f=h.exec(c.text);)m||(m=new Y(P.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),o.push(new Xe(a+f.index,a+f.index+f[0].length,m))}}a=u}if(!r.validEnd){let l=r.fillBefore(P.empty,!0);t.replace(a,a,new Y(l,0,0))}for(let l=o.length-1;l>=0;l--)t.step(o[l])}function Lk(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function xs(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,s=0;;--r){let o=t.$from.node(r),a=t.$from.index(r)+i,l=t.$to.indexAfter(r)-s;if(r<t.depth&&o.canReplace(a,l,n))return r;if(r==0||o.type.spec.isolating||!Lk(o,a,l))break;a&&(i=1),l<o.childCount&&(s=1)}return null}function Pk(t,e,n){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),a=i.after(s+1),l=o,c=a,u=P.empty,d=0;for(let m=s,g=!1;m>n;m--)g||r.index(m)>0?(g=!0,u=P.from(r.node(m).copy(u)),d++):l--;let f=P.empty,h=0;for(let m=s,g=!1;m>n;m--)g||i.after(m+1)<i.end(m)?(g=!0,f=P.from(i.node(m).copy(f)),h++):c++;t.step(new rt(l,c,o,a,new Y(u.append(f),d,h),u.size-d,!0))}function Rf(t,e,n=null,r=t){let i=Bk(t,e),s=i&&$k(r,e);return s?i.map(Rp).concat({type:e,attrs:n}).concat(s.map(Rp)):null}function Rp(t){return{type:t,attrs:null}}function Bk(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return n.canReplaceWith(r,i,o)?s:null}function $k(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let l=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;l&&c<i;c++)l=l.matchType(n.child(c).type);return!l||!l.validEnd?null:o}function jk(t,e,n){let r=P.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let a=n[o].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=P.from(n[o].type.create(n[o].attrs,r))}let i=e.start,s=e.end;t.step(new rt(i,s,i,s,new Y(r,0,0),n.length,!0))}function Fk(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,(o,a)=>{let l=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,l)&&Hk(t.doc,t.mapping.slice(s).map(a),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!m?c=!1:!h&&m&&(c=!0)}c===!1&&_b(t,o,a,s),Of(t,t.mapping.slice(s).map(a,1),r,void 0,c===null);let u=t.mapping.slice(s),d=u.map(a,1),f=u.map(a+o.nodeSize,1);return t.step(new rt(d,f,d+1,f-1,new Y(P.from(r.create(l,null,o.marks)),0,0),1,!0)),c===!0&&Sb(t,o,a,s),!1}})}function Sb(t,e,n,r){e.forEach((i,s)=>{if(i.isText){let o,a=/\r?\n|\r/g;for(;o=a.exec(i.text);){let l=t.mapping.slice(r).map(n+1+s+o.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function _b(t,e,n,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+s);t.replaceWith(o,o+1,e.type.schema.text(`
|
|
@@ -499,4 +499,4 @@ You can check out the documentation for more information: https://github.com/ari
|
|
|
499
499
|
margin-bottom: 0;
|
|
500
500
|
}
|
|
501
501
|
`),c.adoptedStyleSheets=[u];const d=document.createElement("div");d.innerHTML=o,c.appendChild(d)},contentEditable:!1,onClick:()=>{a&&n({activeTab:"code"})}})]})}var UF=z5.extend({addStorage(){return{colors:new Set}}}),VF=["ltr","rtl"],un="ltr",WF=np.extend({addAttributes(){var t;return se(z({},((t=this==null?void 0:this.parent)==null?void 0:t.call(this))||{}),{textDirection:{default:un,parseHTML:e=>e.getAttribute("data-text-direction")||e.getAttribute("dir")||un,renderHTML(e){return!e.textDirection||e.textDirection===un?{}:{"data-text-direction":e.textDirection,dir:e.textDirection}}},showIfKey:{default:Qe,parseHTML:e=>e.getAttribute("data-show-if-key")||Qe,renderHTML(e){return e.showIfKey?{"data-show-if-key":e.showIfKey}:{}}}})},addCommands(){var t;return se(z({},(t=this.parent)==null?void 0:t.call(this)),{setTextDirection:e=>({commands:n})=>n.updateAttributes(this.name,{textDirection:e})})}}),Zy=qe.create({name:"footer",group:"block",content:"inline*",addAttributes(){return{"maily-component":{default:"footer",renderHTML:t=>({"data-maily-component":t["maily-component"]}),parseHTML:t=>t==null?void 0:t.getAttribute("data-maily-component")},textDirection:{default:un,parseHTML:t=>t.getAttribute("data-text-direction")||t.getAttribute("dir")||un,renderHTML(t){return!t.textDirection||t.textDirection===un?{}:{"data-text-direction":t.textDirection,dir:t.textDirection}}}}},addCommands(){return{setFooter:()=>({commands:t})=>t.setNode(this.name),setFooterTextDirection:t=>({commands:e})=>e.updateAttributes("footer",{textDirection:t})}},parseHTML(){return[{tag:'small[data-maily-component="footer"]'}]},renderHTML({HTMLAttributes:t}){return["small",Ne(this.options.HTMLAttributes,t,{class:"footer mly:block mly:text-[13px] mly:text-slate-500 mly:relative"}),0]}}),KF=aj.extend({addAttributes(){var t;return se(z({},(t=this.parent)==null?void 0:t.call(this)),{isUrlVariable:{default:!1}})},addCommands(){var t;return se(z({},(t=this.parent)==null?void 0:t.call(this)),{setIsUrlVariable:e=>({chain:n})=>n().setMark("link",{isUrlVariable:e}).run()})}}),GF=tp.extend({addAttributes(){var t;return se(z({},((t=this==null?void 0:this.parent)==null?void 0:t.call(this))||{}),{textDirection:{default:un,parseHTML:e=>e.getAttribute("data-text-direction")||e.getAttribute("dir")||un,renderHTML(e){return!e.textDirection||e.textDirection===un?{}:{"data-text-direction":e.textDirection,dir:e.textDirection}}},showIfKey:{default:Qe,parseHTML:e=>e.getAttribute("data-show-if-key")||Qe,renderHTML(e){return e.showIfKey?{"data-show-if-key":e.showIfKey}:{}}}})}});function qF(t){const{editor:e,getPos:n}=t;return p.jsxs(gi,{"data-type":"repeat",draggable:e.isEditable,"data-drag-handle":e.isEditable,className:"mly:relative",children:[p.jsx(hv,{className:"is-editable"}),p.jsxs("div",{role:"button","data-repeat-indicator":"",className:"mly:absolute mly:inset-y-0 mly:right-0 mly:flex mly:translate-x-full mly:cursor-pointer mly:flex-col mly:items-center mly:gap-1 mly:opacity-60",contentEditable:!1,onClick:()=>{e.commands.setNodeSelection(n())},children:[p.jsx(bx,{className:"mly:size-3 mly:stroke-[2.5] mly:text-midnight-gray"}),p.jsx("div",{className:"mly:w-[1.5px] mly:grow mly:rounded-full mly:bg-rose-300"})]})]})}var ZE=qe.create({name:"repeat",group:"block",content:"(block|columns)+",draggable:!0,isolating:!0,addAttributes(){return{each:{default:"items",parseHTML:t=>t.getAttribute("each")||"",renderHTML:t=>t.each?{each:t.each}:{}},isUpdatingKey:{default:!1},showIfKey:{default:Qe,parseHTML:t=>t.getAttribute("data-show-if-key")||Qe,renderHTML(t){return t.showIfKey?{"data-show-if-key":t.showIfKey}:{}}}}},parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML({HTMLAttributes:t}){return["div",Ne(t,{"data-type":this.name}),0]},addCommands(){return{setRepeat:()=>({commands:t})=>t.insertContent({type:this.name,attrs:{},content:[{type:"paragraph"}]}),updateRepeat:t=>As(this.name,t)}},addNodeView(){return yi(qF,{contentDOMElementTag:"div",className:"mly:relative"})}}),YF=Ve.create({name:"maily-kit",addOptions(){return{link:{HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:"mly:no-underline"},openOnClick:!1}}},addExtensions(){const t=[G1.extend({content:"(block|columns)+"}),I$.configure({code:{HTMLAttributes:{class:"mly:px-1 mly:relative mly:py-0.5 mly:bg-[#efefef] mly:text-sm mly:rounded-md mly:tracking-normal mly:font-normal"}},blockquote:{HTMLAttributes:{class:"mly:not-prose mly:border-l-4 mly:border-gray-300 mly:pl-4 mly:mt-4 mly:mb-4 mly:relative"}},bulletList:{HTMLAttributes:{class:"mly:relative"}},orderedList:{HTMLAttributes:{class:"mly:relative"}},heading:!1,paragraph:!1,horizontalRule:!1,dropcursor:!1,document:!1}),L$,UF.configure({types:[gy.name,eE.name]}),gy.configure(),D$.configure({types:[np.name,tp.name,Zy.name]}),WE,Zy,P$,q1.configure({color:"#555",width:3,class:"ProseMirror-dropcursor"}),GF.configure({levels:[1,2,3],HTMLAttributes:{class:"mly:relative"}}),WF.configure({HTMLAttributes:{class:"mly:relative"}})];return this.options.linkCard!==!1&&t.push(YE.configure(this.options.linkCard)),this.options.repeat!==!1&&t.push(ZE),this.options.section!==!1&&t.push(DE),this.options.columns!==!1&&t.push(VE),this.options.column!==!1&&t.push(fE),this.options.button!==!1&&t.push(JE),this.options.spacer!==!1&&t.push(GE),this.options.logo!==!1&&t.push($E),this.options.image!==!1&&t.push(XE),this.options.link!==!1&&t.push(KF.configure(this.options.link)),t}}),JF=lj.configure({placeholder:({node:t})=>t.type.name==="heading"?`Heading ${t.attrs.level}`:t.type.name==="htmlCodeBlock"?"Type your HTML code...":["columns","column","section","repeat","show","blockquote"].includes(t.type.name)?"":"Write something or / to see commands",includeChildren:!0}),XF=Ve.create({name:"slash-command",addOptions(){return{suggestion:{char:"/",command:({editor:t,range:e,props:n})=>{n.command({editor:t,range:e})}}}},addProseMirrorPlugins(){return[Xw(z({editor:this.editor},this.options.suggestion))]}});function ZF(t){var e;const{item:n,groupIndex:r,commandIndex:i,selectedGroupIndex:s,selectedCommandIndex:o,editor:a,activeCommandRef:l,selectItem:c,hoveredItemKey:u,onHover:d}=t,[f,h]=x.useState(!1),m=r===s&&i===o,g=`${r}-${i}`,y=u===g,b=n&&"commands"in n,w=!!(n!=null&&n.preview)&&(y||m&&!u),v=typeof n.render=="function"?(e=n.render)==null?void 0:e.call(n,a):null;let k=p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"mly:flex mly:h-6 mly:w-6 mly:shrink-0 mly:items-center mly:justify-center",children:n.icon}),p.jsxs("div",{className:"mly:grow",children:[p.jsx("p",{className:"mly:font-medium",children:n.title}),p.jsx("p",{className:"mly:text-xs mly:text-gray-400",children:n.description})]}),b&&p.jsx("span",{className:"mly:block mly:px-1 mly:text-gray-400",children:p.jsx(HR,{className:"mly:size-3.5 mly:stroke-[2.5]"})})]});v!==null&&v!==!0&&(k=v);const C=x.useRef(0),S=x.useCallback(()=>{window.clearTimeout(C.current);const T=200;C.current=window.setTimeout(()=>{h(!0),C.current=0},T)},[h]);return x.useEffect(()=>{w?S():(window.clearTimeout(C.current),C.current=0,h(!1))},[w]),x.useEffect(()=>()=>{C.current&&(window.clearTimeout(C.current),C.current=0)},[]),p.jsxs(Nt,{open:f,children:[p.jsx(Tt,{asChild:!0,children:p.jsx("button",{className:ye("mly:flex mly:w-full mly:items-center mly:gap-2 mly:rounded-md mly:px-2 mly:py-1 mly:text-left mly:text-sm mly:text-gray-900 mly:hover:bg-gray-100 mly:hover:text-gray-900",m?"mly:bg-gray-100 mly:text-gray-900":"mly:bg-transparent"),onClick:()=>c(r,i),onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),type:"button",ref:m?l:null,children:k})}),p.jsx(xt,{side:"right",sideOffset:10,className:"mly:w-52 mly:rounded-lg mly:border-none mly:p-1 mly:shadow",children:typeof n.preview=="function"?n==null?void 0:n.preview(a):p.jsxs(p.Fragment,{children:[p.jsx("figure",{className:"mly:relative mly:aspect-[2.5] mly:w-full mly:overflow-hidden mly:rounded-md mly:border mly:border-gray-200",children:p.jsx("img",{src:n==null?void 0:n.preview,alt:n==null?void 0:n.title,className:"mly:absolute mly:inset-0 mly:h-full mly:w-full mly:object-cover"})}),p.jsx("p",{className:"mly:mt-2 mly:px-0.5 mly:text-gray-500",children:n.description})]})})]},`${r}-${i}`)}function QF(t){const{groups:e,query:n,editor:r}=t,i=[...e];let s=n==null?void 0:n.toLowerCase();const o=s.match(/^([^.]+)\./);if(o){const[l,c]=o,u=eH(e,c);if(u){const d=s.slice(l.length),f=u.commands.filter(h=>!d||sl(h,d));return f.length?[se(z({},u),{commands:f})]:[]}}return i.map(l=>se(z({},l),{commands:l.commands.flatMap(c=>nH({item:c,search:s,editor:r}))})).filter(l=>l.commands.length>0)}function eH(t,e){return t.flatMap(n=>n.commands).find(n=>{var r;return"commands"in n&&((r=n.id)==null?void 0:r.toLowerCase())===e.toLowerCase()})}function xd(t,e){return t?t.toLowerCase().includes(e.toLowerCase()):!1}function sl(t,e){var n,r;return xd(t.title,e)||xd(t.description,e)||((r=(n=t.searchTerms)==null?void 0:n.some(i=>xd(i,e)))!=null?r:!1)}function tH(t){return"commands"in t&&Array.isArray(t.commands)&&!!t.id}function nH(t){var e,n,r,i;const{item:s,search:o,editor:a}=t;if(((e=s==null?void 0:s.render)==null?void 0:e.call(s,a))===null)return[];const c=o.length>0;if(tH(s)){const u=se(z({},s),{command:h=>{const{editor:m,range:g}=h;m.chain().focus().insertContentAt(g,`/${s.id}.`).run()}});return sl(u,o)?[u]:((r=(n=u==null?void 0:u.commands)==null?void 0:n.some(h=>sl(h,o)))!=null?r:!1)?(i=u==null?void 0:u.commands)!=null?i:[]:[]}return!c||sl(s,o)?[s]:[]}var rH=x.forwardRef((t,e)=>{const{items:n,command:r,editor:i,range:s,query:o}=t,[a,l]=x.useState(0),[c,u]=x.useState(0),[d,f]=x.useState(null),h=x.useRef(""),m=x.useRef(0),g=x.useRef(0),y=x.useCallback((E,v)=>{const k=n[E].commands[v];k&&r(k)},[r]);x.useImperativeHandle(e,()=>({onKeyDown:({event:E})=>{var v,k,C,S;if(["ArrowUp","ArrowDown","Enter","ArrowLeft","ArrowRight"].includes(E.key)){let M=c,L=a;switch(E.key){case"ArrowLeft":E.preventDefault();const F=n==null?void 0:n[a];return F&&"id"in F?(i.chain().focus().insertContentAt(s,`/${h.current}`).run(),setTimeout(()=>{l(m.current),u(g.current)},0),!0):!1;case"ArrowRight":E.preventDefault();const H=(k=(v=n==null?void 0:n[a])==null?void 0:v.commands)==null?void 0:k[c];return H&&"commands"in H?(y(a,c),h.current=o,m.current=a,g.current=c,!0):!1;case"Enter":return n.length?(y(a,c),h.current=o,m.current=a,g.current=c,!0):!1;case"ArrowUp":return n.length?(M=c-1,L=a,M<0&&(L=a-1,M=((C=n[L])==null?void 0:C.commands.length)-1||0),L<0&&(L=n.length-1,M=((S=n[L])==null?void 0:S.commands.length)-1||0),l(L),u(M),!0):!1;case"ArrowDown":if(!n.length)return!1;const K=n[a].commands;return M=c+1,L=a,K.length-1<M&&(M=0,L=a+1),n.length-1<L&&(L=0),l(L),u(M),!0;default:return!1}}}}));const b=x.useRef(null),w=x.useRef(null);return x.useLayoutEffect(()=>{const E=b==null?void 0:b.current,v=w==null?void 0:w.current;if(!E||!v)return;const{offsetTop:k,offsetHeight:C}=v;E.style.transition="none",E.scrollTop=k-C},[a,c,b,w]),x.useEffect(()=>{l(0),u(0)},[n]),x.useEffect(()=>()=>{h.current="",m.current=0,g.current=0},[]),!n||n.length===0?null:p.jsx(Vt,{children:p.jsxs("div",{className:"mly:z-50 mly:w-72 mly:overflow-hidden mly:rounded-md mly:border mly:border-gray-200 mly:bg-white mly:shadow-md mly:transition-all",children:[p.jsx("div",{id:"slash-command",ref:b,className:"mly:no-scrollbar mly:h-auto mly:max-h-[330px] mly:overflow-y-auto",children:n.map((E,v)=>p.jsxs(x.Fragment,{children:[p.jsx("span",{className:ye("mly:block mly:border-b mly:border-gray-200 mly:bg-soft-gray mly:p-2 mly:text-xs mly:uppercase mly:text-gray-400",v>0?"mly:border-t":""),children:E.title}),p.jsx("div",{className:"mly:space-y-0.5 mly:p-1",children:E.commands.map((k,C)=>{const S=`${v}-${C}`;return p.jsx(ZF,{item:k,groupIndex:v,commandIndex:C,selectedGroupIndex:a,selectedCommandIndex:c,selectItem:()=>y(v,C),editor:i,activeCommandRef:w,hoveredItemKey:d,onHover:T=>f(T?S:null)},S)})})]},v))}),p.jsx("div",{className:"mly:border-t mly:border-gray-200 mly:px-1 mly:py-3 mly:pl-4",children:p.jsxs("div",{className:"mly:flex mly:items-center",children:[p.jsxs("p",{className:"mly:text-center mly:text-xs mly:text-gray-400",children:[p.jsx("kbd",{className:"mly:rounded mly:border mly:border-gray-200 mly:p-1 mly:px-2 mly:font-medium",children:"↑"}),p.jsx("kbd",{className:"mly:ml-1 mly:rounded mly:border mly:border-gray-200 mly:p-1 mly:px-2 mly:font-medium",children:"↓"})," ","to navigate"]}),p.jsx("span",{"aria-hidden":"true",className:"mly:select-none mly:px-1",children:"·"}),p.jsxs("p",{className:"mly:text-center mly:text-xs mly:text-gray-400",children:[p.jsx("kbd",{className:"mly:rounded mly:border mly:border-gray-200 mly:p-1 mly:px-1.5 mly:font-medium",children:"Enter"})," ","to select"]})]})})]})})});function iH(t=pp){return{items:({query:e,editor:n})=>QF({query:e,editor:n,groups:t}),allow:({editor:e})=>!e.isActive("htmlCodeBlock"),render:()=>{let e,n=null;return{onStart:r=>{e=new lh(rH,{props:r,editor:r.editor}),n=Br("body",{getReferenceClientRect:r.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"top-start"})},onUpdate:r=>{var i;const s=n==null?void 0:n[0];!s||(i=s==null?void 0:s.state)!=null&&i.isDestroyed||(e==null||e.updateProps(r),s.setProps({getReferenceClientRect:r.clientRect}))},onKeyDown:r=>{var i,s;if(r.event.key==="Escape"){const o=n==null?void 0:n[0];return(i=o==null?void 0:o.state)!=null&&i.isDestroyed||o==null||o.destroy(),e==null||e.destroy(),!0}return(s=e==null?void 0:e.ref)==null?void 0:s.onKeyDown(r)},onExit:()=>{if(!n||!(n!=null&&n[0])||!e)return;const r=n==null?void 0:n[0];r.state.isDestroyed||r.destroy(),e==null||e.destroy()}}}}}var QE=x.forwardRef((t,e)=>{var n;const{items:r=[],editor:i}=t,s=x.useRef(null),o=(n=xi(i))==null?void 0:n.variableSuggestionsPopover;return x.useImperativeHandle(e,()=>({onKeyDown:({event:a})=>{if(!s.current)return!1;const{moveUp:l,moveDown:c,select:u}=s.current||{};return a.key==="ArrowUp"?(a.preventDefault(),l(),!0):a.key==="ArrowDown"?(a.preventDefault(),c(),!0):a.key==="Enter"?(u(),!0):!1}})),p.jsx(o,{items:r,onSelectItem:a=>{var l,c;t.command({id:a.name,required:(l=a.required)!=null?l:!0,hideDefaultValue:(c=a==null?void 0:a.hideDefaultValue)!=null?c:!1,label:a==null?void 0:a.label})},ref:s})});QE.displayName="VariableList";function sH(t=mp){return{char:t,items:({query:e,editor:n})=>{var r;const i=(r=SE(n))==null?void 0:r.variables;return na(i,{query:e,editor:n,from:"content-variable"})},render:()=>{let e,n=null;return{onStart:r=>{e=new lh(QE,{props:r,editor:r.editor}),r.clientRect&&(n=Br("body",{getReferenceClientRect:r.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start"}))},onUpdate(r){var i;e.updateProps(r),r.clientRect&&((i=n==null?void 0:n[0])==null||i.setProps({getReferenceClientRect:r.clientRect}))},onKeyDown(r){var i;return r.event.key==="Escape"?(n==null||n[0].hide(),!0):(i=e.ref)==null?void 0:i.onKeyDown(r)},onExit(){!n||!(n!=null&&n[0])||!e||(n==null||n[0].destroy(),e.destroy())}}}}}var ek=j5(U4);ek.register("html",y1);var tk=k3.extend({name:"htmlCodeBlock",content:"(text|variable)*",addAttributes(){var t;return se(z({},(t=this.parent)==null?void 0:t.call(this)),{activeTab:"code",showIfKey:{default:Qe,parseHTML:e=>e.getAttribute("data-show-if-key")||Qe,renderHTML(e){return e.showIfKey?{"data-show-if-key":e.showIfKey}:{}}}})},addNodeView(){return yi(zF,{className:"mly:relative",attrs:({node:t})=>{var e;return{"data-active-tab":((e=t==null?void 0:t.attrs)==null?void 0:e.activeTab)||"code"}}})},addCommands(){return{setHtmlCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleHtmlCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t),updateHtmlCodeBlock:t=>As(this.name,t)}},addKeyboardShortcuts(){var t;return se(z({},(t=this.parent)==null?void 0:t.call(this)),{"Mod-a":({editor:e})=>{const{selection:n}=e.state,r=n.$anchor;if(r.node(r.depth).type.name!==this.name)return!1;let s=r.depth;for(let u=s;u>0;u--)if(r.node(u).type.name===this.name){s=u;break}const o=r.before(s)+1,a=r.after(s)-1,l=e.state.doc.resolve(o),c=e.state.doc.resolve(a);if(l&&c){const u=e.state.tr.setSelection(ue.between(l,c));return e.view.dispatch(u),!0}return!1}})}}).configure({lowlight:ek}),oH=(t,e)=>[WE.name,Vh.name,GE.name,XE.name,zE.name,YE.name,$E.name,JE.name,tk.name,UE.name].some(r=>t.isActive(r));function aH(t){return p.jsxs("svg",se(z({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},t),{children:[p.jsx("path",{d:"M11 5h6"}),p.jsx("path",{d:"M11 5v14"}),p.jsx("path",{d:"M15 5v14"}),p.jsx("path",{d:"M6 18l-3-3 3-3"}),p.jsx("path",{d:"M3 15h5"})]}))}function lH(t){return p.jsxs("svg",se(z({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},t),{children:[p.jsx("path",{d:"M8 5h6"}),p.jsx("path",{d:"M10 5v14"}),p.jsx("path",{d:"M14 5v14"}),p.jsx("path",{d:"M18 18l3-3-3-3"}),p.jsx("path",{d:"M16 15h5"})]}))}function cH(t){const{direction:e,onDirectionChange:n}=t,r=VF.includes(e)?e:"ltr",i={ltr:{icon:aH,tooltip:"Left to Right",onClick:()=>{n("ltr")}},rtl:{icon:lH,tooltip:"Right to Left",onClick:()=>{n("rtl")}}},s=i[r];return p.jsxs(rn,{children:[p.jsxs(Nt,{children:[p.jsx(Tt,{asChild:!0,children:p.jsx(sn,{className:ye("mly:flex mly:size-7 mly:items-center mly:justify-center mly:gap-1 mly:rounded-md mly:px-1.5 mly:text-sm mly:data-[state=open]:bg-soft-gray mly:hover:bg-soft-gray mly:focus-visible:relative mly:focus-visible:z-10 mly:focus-visible:outline-hidden mly:focus-visible:ring-2 mly:focus-visible:ring-gray-400 mly:focus-visible:ring-offset-2"),children:p.jsx(s.icon,{className:"mly:h-3 mly:w-3 mly:stroke-[2.5]"})})}),p.jsx(xt,{sideOffset:8,children:"Text Direction"})]}),p.jsx(Wt,{className:"mly:flex mly:w-max mly:gap-0.5 mly:rounded-lg mly:p-0.5!",side:"top",sideOffset:8,align:"center",onOpenAutoFocus:o=>{o.preventDefault()},onCloseAutoFocus:o=>{o.preventDefault()},children:Object.entries(i).map(([o,a])=>p.jsx(cn,{icon:a.icon,tooltip:a.tooltip,command:a.onClick,isActive:()=>o===r},o))})]})}var uH="#374151",dH=t=>In({editor:t,selector:n=>{var r,i,s,o,a,l,c,u,d,f,h,m;return{currentTextColor:n.editor.getAttributes("textStyle").color||uH,linkUrl:(r=n.editor)==null?void 0:r.getAttributes("link").href,textAlign:(i=n.editor)!=null&&i.isActive({textAlign:"left"})?"left":(s=n.editor)!=null&&s.isActive({textAlign:"center"})?"center":(o=n.editor)!=null&&o.isActive({textAlign:"right"})?"right":(a=n.editor)!=null&&a.isActive({textAlign:"justify"})?"justify":"left",textDirection:((l=n.editor.getAttributes("paragraph"))==null?void 0:l.textDirection)||((c=n.editor.getAttributes("heading"))==null?void 0:c.textDirection)||((u=n.editor.getAttributes("footer"))==null?void 0:u.textDirection)||un,isFooterActive:n.editor.isActive("footer"),footerTextDirection:((d=n.editor.getAttributes("footer"))==null?void 0:d.textDirection)||un,isListActive:n.editor.isActive("bulletList")||n.editor.isActive("orderedList"),isUrlVariable:(f=n.editor.getAttributes("link").isUrlVariable)!=null?f:!1,isHeadingActive:n.editor.isActive("heading"),headingShowIfKey:((h=n.editor.getAttributes("heading"))==null?void 0:h.showIfKey)||"",isParagraphActive:n.editor.isActive("paragraph"),paragraphShowIfKey:((m=n.editor.getAttributes("paragraph"))==null?void 0:m.showIfKey)||""}},equalityFn:$r});function nk(t){var e,n,r,i;const{editor:s,showListMenu:o=!0}=t,a=dH(s),l=s==null?void 0:s.storage.color.colors,c=(r=(n=(e=Array==null?void 0:Array.from(l))==null?void 0:e.reverse())==null?void 0:n.slice(0,6))!=null?r:[],u=[{name:"bold",isActive:()=>s==null?void 0:s.isActive("bold"),command:()=>s==null?void 0:s.chain().focus().toggleBold().run(),icon:sx,tooltip:"Bold"},{name:"italic",isActive:()=>s==null?void 0:s.isActive("italic"),command:()=>s==null?void 0:s.chain().focus().toggleItalic().run(),icon:mx,tooltip:"Italic"},{name:"underline",isActive:()=>s==null?void 0:s.isActive("underline"),command:()=>s==null?void 0:s.chain().focus().toggleUnderline().run(),icon:wx,tooltip:"Underline"},{name:"strike",isActive:()=>s==null?void 0:s.isActive("strike"),command:()=>s==null?void 0:s.chain().focus().toggleStrike().run(),icon:vx,tooltip:"Strikethrough"},{name:"code",isActive:()=>s==null?void 0:s.isActive("code"),command:()=>s==null?void 0:s.chain().focus().toggleCode().run(),icon:KR,tooltip:"Code"}];return p.jsxs(p.Fragment,{children:[u.map((d,f)=>p.jsx(cn,z({},d),f)),p.jsx(au,{alignment:a.textAlign,onAlignmentChange:d=>{s==null||s.chain().focus().setTextAlign(d).run()}}),p.jsx(cH,{direction:a.textDirection,onDirectionChange:d=>{a.isFooterActive?s==null||s.chain().focus().setFooterTextDirection(d).run():a.isHeadingActive?s==null||s.chain().focus().updateAttributes("heading",{textDirection:d}).run():s==null||s.chain().focus().setTextDirection(d).run()}}),!a.isListActive&&o&&p.jsxs(p.Fragment,{children:[p.jsx(cn,{icon:_h,command:()=>{s.chain().focus().toggleBulletList().run()},tooltip:"Bullet List"}),p.jsx(cn,{icon:Sh,command:()=>{s.chain().focus().toggleOrderedList().run()},tooltip:"Ordered List"})]}),p.jsx(vs,{defaultValue:(i=a==null?void 0:a.linkUrl)!=null?i:"",onValueChange:(d,f)=>{if(!d){s==null||s.chain().focus().extendMarkRange("link").unsetLink().unsetUnderline().run();return}s==null||s.chain().extendMarkRange("link").setLink({href:d}).setIsUrlVariable(f??!1).setUnderline().run()},tooltip:"External URL",editor:s,isVariable:a.isUrlVariable}),p.jsx(ze,{}),p.jsx(Uo,{color:a.currentTextColor,onColorChange:d=>{s==null||s.chain().setColor(d).run()},tooltip:"Text Color",suggestedColors:c,children:p.jsx(Rt,{variant:"ghost",size:"sm",type:"button",className:"mly:h-7 mly:w-7 mly:shrink-0 mly:p-0",children:p.jsxs("div",{className:"mly:flex mly:flex-col mly:items-center mly:justify-center mly:gap-px",children:[p.jsx("span",{className:"mly:font-bolder mly:font-mono mly:text-xs mly:text-slate-700",children:"A"}),p.jsx("div",{className:"mly:h-[2px] mly:w-3",style:{backgroundColor:a.currentTextColor}})]})})})]})}var fH=t=>t.type==="option",hH=t=>t.type==="category";function pH(t){const{options:e}=t,n=x.useMemo(()=>e.find(i=>i.type==="option"&&i.isActive()),[e]),{icon:r=gx}=n||{};return p.jsxs(rn,{children:[p.jsxs(Nt,{children:[p.jsx(Tt,{asChild:!0,children:p.jsxs(sn,{className:ye("mly:flex mly:aspect-square mly:h-7 mly:items-center mly:justify-center mly:gap-1 mly:rounded-md mly:px-1.5 mly:text-sm mly:data-[state=open]:bg-soft-gray mly:hover:bg-soft-gray mly:focus-visible:relative mly:focus-visible:z-10 mly:focus-visible:outline-hidden mly:focus-visible:ring-2 mly:focus-visible:ring-gray-400 mly:focus-visible:ring-offset-2"),children:[p.jsx(r,{className:"mly:h-3 mly:w-3 mly:shrink-0 mly:stroke-[2.5]"}),p.jsx(ox,{className:"mly:h-3 mly:w-3 mly:shrink-0 mly:stroke-[2.5]"})]})}),p.jsx(xt,{sideOffset:8,children:"Turn into"})]}),p.jsx(Wt,{align:"start",side:"bottom",sideOffset:8,className:"mly:flex mly:w-[160px] mly:flex-col mly:rounded-md mly:p-1",children:e.map((i,s)=>{if(fH(i))return p.jsxs(Rt,{onClick:i.onClick,variant:"ghost",className:"mly:mb-0.5 mly:h-auto mly:justify-start mly:gap-2 mly:rounded! mly:px-2 mly:py-1 mly:text-sm mly:font-normal mly:text-midnight-gray",children:[p.jsx(i.icon,{className:"mly:size-[15px] mly:shrink-0"}),i.label]},i.id);if(hH(i))return p.jsx("label",{className:ye("mly:px-2 mly:text-xs mly:font-medium mly:text-midnight-gray/60",s===0?"mly:mb-2 mly:mt-1":"mly:my-2"),children:i.label},i.id)})})]})}function mH(t){return In({editor:t,selector:({editor:e})=>[{type:"category",label:"Hierarchy",id:"hierarchy"},{icon:gx,onClick:()=>e.chain().focus().liftListItem("listItem").setParagraph().run(),id:"paragraph",disabled:()=>!e.can().setParagraph(),isActive:()=>e.isActive("paragraph")&&!e.isActive("orderedList")&&!e.isActive("bulletList")&&!e.isActive("taskList"),label:"Paragraph",type:"option"},{icon:kh,onClick:()=>e.chain().focus().liftListItem("listItem").setHeading({level:1}).run(),id:"heading1",disabled:()=>!e.can().setHeading({level:1}),isActive:()=>e.isActive("heading",{level:1}),label:"Heading 1",type:"option"},{icon:dx,onClick:()=>e.chain().focus().liftListItem("listItem").setHeading({level:2}).run(),id:"heading2",disabled:()=>!e.can().setHeading({level:2}),isActive:()=>e.isActive("heading",{level:2}),label:"Heading 2",type:"option"},{icon:fx,onClick:()=>e.chain().focus().liftListItem("listItem").setHeading({level:3}).run(),id:"heading3",disabled:()=>!e.can().setHeading({level:3}),isActive:()=>e.isActive("heading",{level:3}),label:"Heading 3",type:"option"},{id:"footer",type:"option",label:"Footer",icon:Eh,onClick:()=>{e.chain().focus().liftListItem("listItem").setFooter().run()},disabled:()=>!e.can().setFooter(),isActive:()=>e.isActive("footer")},{type:"category",label:"Lists",id:"lists"},{icon:_h,onClick:()=>e.chain().focus().toggleBulletList().run(),id:"bulletList",disabled:()=>!e.can().toggleBulletList(),isActive:()=>e.isActive("bulletList"),label:"Bullet list",type:"option"},{icon:Sh,onClick:()=>e.chain().focus().toggleOrderedList().run(),id:"orderedList",disabled:()=>!e.can().toggleOrderedList(),isActive:()=>e.isActive("orderedList"),label:"Numbered list",type:"option"}]})}function gH(t){const{editor:e,appendTo:n}=t;if(!e)return null;const r=se(z(z({},t),n?{appendTo:n.current}:{}),{pluginKey:"text-menu",shouldShow:({editor:s,from:o,view:a})=>{var l;if(!a||s.view.dragging)return!1;const c=a.domAtPos(o||0).node,d=a.nodeDOM(o||0)||c;if(oH(s)||!s.isEditable)return!1;const h=[ZE.name,DE.name,VE.name,fE.name].some(m=>s.isActive(m))&&((l=d==null?void 0:d.classList)==null?void 0:l.contains("ProseMirror-selectednode"));return ou(s)&&!h},tippyOptions:{popperOptions:{placement:"top-start",modifiers:[{name:"preventOverflow",options:{boundary:"viewport",padding:8}},{name:"flip",options:{fallbackPlacements:["bottom-start","top-end","bottom-end"]}}]},maxWidth:"100%"}}),i=mH(e);return p.jsx(rr,se(z({},r),{className:"mly:flex mly:gap-0.5 mly:rounded-lg mly:border mly:border-gray-200 mly:bg-white mly:p-0.5 mly:shadow-md",children:p.jsxs(Vt,{children:[p.jsx(pH,{options:i}),p.jsx(ze,{className:"mly:mx-0"}),p.jsx(nk,{editor:e})]})}))}function yH(t){const{editor:e,appendTo:n}=t;if(!e)return null;const r=se(z({},t),{pluginKey:"variable-menu",shouldShow:({editor:i})=>{var s;return i.isActive("variable")&&!((s=i.storage.variable)!=null&&s.popover)},tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},plugins:[mi],sticky:"popper",maxWidth:"100%",appendTo:()=>(n==null?void 0:n.current)||"parent",placement:"top-start"}});return p.jsx(rr,se(z({},r),{className:"mly:flex mly:gap-0.5 mly:rounded-lg mly:border mly:border-slate-200 mly:bg-white mly:p-0.5 mly:shadow-md",children:p.jsx(Vt,{children:p.jsx(nk,{showListMenu:!1,editor:e})})}))}var bH=Ve.create({name:"selection",addProseMirrorPlugins(){const{editor:t}=this;return[new $e({key:new Pe("selection"),props:{decorations(e){return e.selection.empty||t.isFocused===!0?null:He.create(e.doc,[pt.inline(e.selection.from,e.selection.to,{class:"selection mly:bg-blue-200 mly:inline mly:py-1"})])}}})]}});function vH(t){const{blocks:e,extensions:n=[]}=t;return[...[YF,XF.configure({suggestion:iH(e)}),zE.configure({suggestion:sH()}),tk,UE,JF,bH].filter(i=>!n.some(s=>s.name===i.name)),...n]}function Qy(t){var e,n;const r=[t];for(;r.length;){const i=r.pop();if(i){if(i.type==="for"&&(i.type="repeat"),i.type==="spacer"){let s=(e=i.attrs)==null?void 0:e.height;typeof s=="string"&&["sm","md","lg","xl"].includes(s)&&(s=((n=zo.find(o=>o.short===s))==null?void 0:n.value)||KE),i.attrs=se(z({},i.attrs),{height:s})}i.content&&r.push(...i.content)}}return t}function xH(t){const{config:{wrapClassName:e="",contentClassName:n="",bodyClassName:r="",hasMenuBar:i=!0,hideContextMenu:s=!1,spellCheck:o=!1,autofocus:a="end",immediatelyRender:l=!1}={},onCreate:c,onUpdate:u,extensions:d,contentHtml:f,contentJson:h,blocks:m=pp,editable:g=!0,placeholderUrl:y=lu,scrollThreshold:b=40,scrollMargin:w=40}=t,E=x.useMemo(()=>{if(h){const C=(h==null?void 0:h.type)==="doc"?h:{type:"doc",content:h};return Qy(C)}else return f||{type:"doc",content:[{type:"paragraph",content:[]}]}},[f,h,Qy]),v=x.useRef(null),k=tM({editorProps:{scrollThreshold:b,scrollMargin:w,attributes:{class:ye("mly:prose mly:w-full",n),spellCheck:o?"true":"false"}},immediatelyRender:l,onCreate:({editor:C})=>{c==null||c(C)},onUpdate:({editor:C})=>{u==null||u(C)},extensions:vH({extensions:d,blocks:m}),content:E,autofocus:a,editable:g});return k?p.jsx(lF,{placeholderUrl:y,children:p.jsxs("div",{id:"mly-editor",className:ye("mly-editor mly:antialiased",k.isEditable?"mly-editable":"mly-not-editable",e),ref:v,children:[i&&p.jsx(u9,{config:t.config,editor:k}),p.jsxs("div",{className:ye("mly:mt-4 mly:rounded mly:border mly:border-gray-200 mly:bg-white mly:p-4",r),children:[p.jsx(gH,{editor:k,appendTo:v}),p.jsx(gF,{editor:k,appendTo:v}),p.jsx(NF,{editor:k,appendTo:v}),p.jsx(KA,{editor:k}),p.jsx(SF,{editor:k,appendTo:v}),p.jsx(n9,{editor:k,appendTo:v}),!s&&p.jsx(c9,{editor:k}),p.jsx(yH,{editor:k,appendTo:v}),p.jsx(xF,{editor:k,appendTo:v}),p.jsx(f9,{editor:k,appendTo:v}),p.jsx(bF,{editor:k,appendTo:v})]})]})}):null}const wH={type:"doc",content:[{type:"paragraph",attrs:{textAlign:"left"},content:[{type:"text",text:"Hey "},{type:"variable",attrs:{id:"firstName",label:null,fallback:null,showIfKey:null,each:null}},{type:"text",text:","}]},{type:"paragraph",attrs:{textAlign:"left"},content:[{type:"text",text:"Welcome — start by clicking around the admin UI, or drop a feature flag on for your team."}]},{type:"button",attrs:{text:"Open the app",url:"https://yourdomain.com",alignment:"left",variant:"filled",borderRadius:"smooth",buttonColor:"#f97316",textColor:"#ffffff",showIfKey:null}}]};function OH({slug:t="welcome-1"}){var H,W,K,A,N,_,I;const e=vp.templates.find(D=>D.slug===t)??vp.templates[0],{data:n,refetch:r}=ok(()=>du.template(t),e),[i,s]=fe.useState("design"),[o,a]=fe.useState(wH),[l,c]=fe.useState(""),[u,d]=fe.useState(""),[f,h]=fe.useState(!1),[m,g]=fe.useState(""),[y,b]=fe.useState(!1),w=fe.useRef(null),E=fe.useRef(!1),v=(n==null?void 0:n.kind)??"marketing",k=(n==null?void 0:n.name)??t,C=(n==null?void 0:n.slug)??t,S=((H=n==null?void 0:n.draft)==null?void 0:H.subject)??(n==null?void 0:n.subject)??"Welcome to Mailery, {{contact.fields.firstName}} 👋",T=((W=n==null?void 0:n.draft)==null?void 0:W.preheader)??(n==null?void 0:n.preheader)??"Three things to try in your first 5 minutes.",M=((K=n==null?void 0:n.draft)==null?void 0:K.editorJson)??((A=n==null?void 0:n.body)==null?void 0:A.editorJson)??null,L=((N=n==null?void 0:n.body)==null?void 0:N.mjml)??((_=n==null?void 0:n.draft)==null?void 0:_.mjml)??"",F=((I=n==null?void 0:n.body)==null?void 0:I.plainText)??"";fe.useEffect(()=>{E.current||n&&(E.current=!0,c(S),d(T),M&&a(M))},[n,S,T,M]);async function $(){b(!0),g("Saving draft…");try{await du.updateTemplateDraft(t,{subject:l,preheader:u,editorJson:o}),g("Publishing…");const D=await du.publishTemplate(t);g(`Published v${D.version}`),h(!1),r()}catch(D){g(`Error: ${(D==null?void 0:D.message)??String(D)}`)}finally{b(!1)}}return p.jsxs(p.Fragment,{children:[p.jsx(ak,{title:k,desc:p.jsxs(p.Fragment,{children:[p.jsxs("span",{className:"mono",children:["templates/",C]})," · ",p.jsx("span",{className:"pill "+(v==="transactional"?"blue":"neutral"),style:{marginLeft:4},children:v})]}),actions:p.jsxs(p.Fragment,{children:[p.jsxs("button",{className:"btn",children:[p.jsx(Bn.Eye,{size:14}),"Preview"]}),p.jsxs("button",{className:"btn",children:[p.jsx(Bn.Send,{size:14}),"Test send"]}),p.jsxs("button",{className:"btn",children:[p.jsx(Bn.Copy,{size:14}),"Duplicate"]}),p.jsxs("button",{className:"btn btn-primary",disabled:y,onClick:$,children:[p.jsx(Bn.Rocket,{size:14}),"Publish"]}),m&&p.jsx("span",{className:"text-xs subtle",style:{marginLeft:8},children:m})]})}),p.jsxs("div",{className:"split split-asym",style:{gap:16},children:[p.jsxs("div",{className:"card",style:{overflow:"hidden"},children:[p.jsxs("div",{className:"card-head",children:[p.jsxs("div",{className:"seg",children:[p.jsx("span",{className:"seg-item"+(i==="design"?" active":""),onClick:()=>s("design"),children:"Design"}),p.jsx("span",{className:"seg-item"+(i==="source"?" active":""),onClick:()=>s("source"),children:"MJML"}),p.jsx("span",{className:"seg-item"+(i==="plaintext"?" active":""),onClick:()=>s("plaintext"),children:"Plain text"})]}),p.jsxs("div",{className:"card-actions",children:[p.jsx("span",{className:"text-xs subtle",children:f?"Unsaved changes":"Saved"}),p.jsx("button",{className:"icon-btn",children:p.jsx(Bn.Help,{size:14})})]})]}),p.jsxs("div",{style:{padding:16},children:[p.jsxs("div",{className:"field",children:[p.jsx("label",{className:"field-label",children:"Subject"}),p.jsx("input",{className:"input",value:l,onChange:D=>{c(D.target.value),h(!0)}})]}),p.jsxs("div",{className:"field",children:[p.jsx("label",{className:"field-label",children:"Preheader"}),p.jsx("input",{className:"input",value:u,onChange:D=>{d(D.target.value),h(!0)}})]})]}),i==="design"&&p.jsx("div",{className:"maily-host",style:{padding:16,background:"var(--bg-sunken)",minHeight:480},children:p.jsx(xH,{contentJson:o,onCreate:D=>{w.current=D},onUpdate:D=>{w.current=D,a(D.getJSON()),h(!0)},config:{hasMenuBar:!0,contentClassName:"mly-content",wrapClassName:"mly-wrap",bodyClassName:"mly-body",spellCheck:!0}})}),i==="source"&&p.jsx("pre",{className:"code",style:{margin:16,padding:16,maxHeight:520,overflow:"auto",whiteSpace:"pre-wrap"},children:L||"/* No MJML stored for this template (Maily-authored). Switch to Design to edit. */"}),i==="plaintext"&&p.jsx("pre",{className:"code",style:{margin:16,padding:16,maxHeight:520,overflow:"auto",whiteSpace:"pre-wrap"},children:F||"/* Plain text is auto-derived on publish. */"})]}),p.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[p.jsxs("div",{className:"card",children:[p.jsx("div",{className:"card-head",children:p.jsx("span",{className:"card-title",children:"Sender"})}),p.jsxs("div",{className:"card-body",children:[p.jsxs("div",{className:"field",children:[p.jsx("label",{className:"field-label",children:"From name"}),p.jsx("input",{className:"input",defaultValue:(n==null?void 0:n.fromName)??"Jeff at Mailery"})]}),p.jsxs("div",{className:"field",children:[p.jsx("label",{className:"field-label",children:"From email"}),p.jsx("input",{className:"input",defaultValue:(n==null?void 0:n.fromEmail)??"hello@example.com"})]}),p.jsxs("div",{className:"field",style:{marginBottom:0},children:[p.jsx("label",{className:"field-label",children:"Reply-to"}),p.jsx("input",{className:"input",defaultValue:(n==null?void 0:n.replyTo)??"",placeholder:"(same as From)"})]})]})]}),p.jsxs("div",{className:"card",children:[p.jsxs("div",{className:"card-head",children:[p.jsx("span",{className:"card-title",children:"Variables"}),p.jsx("span",{className:"card-sub",children:"Used in subject/body"})]}),p.jsx("div",{className:"card-body",children:[["firstName","string","required"],["appUrl","url","required"],["logoUrl","url","optional · default"],["unsubscribeUrl","url","auto-injected"]].map(([D,G,ne])=>p.jsxs("div",{className:"hstack",style:{padding:"6px 0",borderBottom:"1px solid var(--border)"},children:[p.jsx("span",{className:"mono text-sm",children:D}),p.jsx("span",{className:"grow"}),p.jsx("span",{className:"tag",children:G}),p.jsx("span",{className:"text-xs subtle",children:ne})]},D))})]}),p.jsxs("div",{className:"card",children:[p.jsx("div",{className:"card-head",children:p.jsx("span",{className:"card-title",children:"Tracking & lint"})}),p.jsxs("div",{className:"card-body",style:{display:"grid",gap:8},children:[p.jsxs("div",{className:"hstack",children:[p.jsx(Bn.Check,{size:14,style:{color:"var(--green-fg)"}}),p.jsx("span",{className:"text-sm",children:"Unsubscribe link present"})]}),p.jsxs("div",{className:"hstack",children:[p.jsx(Bn.Check,{size:14,style:{color:"var(--green-fg)"}}),p.jsx("span",{className:"text-sm",children:"Postal address present"})]}),p.jsxs("div",{className:"hstack",children:[p.jsx(Bn.Check,{size:14,style:{color:"var(--green-fg)"}}),p.jsx("span",{className:"text-sm",children:"No broken merge tags"})]}),p.jsxs("div",{className:"hstack",children:[p.jsx(Bn.Warn,{size:14,style:{color:"var(--amber-fg)"}}),p.jsx("span",{className:"text-sm",children:"Open tracking enabled — beware Apple MPP"})]}),p.jsx("div",{className:"divider",style:{margin:"4px 0"}}),p.jsxs("div",{className:"hstack",children:[p.jsx("span",{className:"text-sm",children:"Track opens"}),p.jsx("span",{className:"grow"}),p.jsx("div",{className:"toggle on",children:p.jsx("div",{className:"track",children:p.jsx("div",{className:"knob"})})})]}),p.jsxs("div",{className:"hstack",children:[p.jsx("span",{className:"text-sm",children:"Track clicks"}),p.jsx("span",{className:"grow"}),p.jsx("div",{className:"toggle on",children:p.jsx("div",{className:"track",children:p.jsx("div",{className:"knob"})})})]})]})]})]})]})]})}export{OH as TemplateEditor};
|
|
502
|
-
//# sourceMappingURL=template-editor-
|
|
502
|
+
//# sourceMappingURL=template-editor-BuYSO1FP.js.map
|