mailery 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/spa/{index-CjQTOX9H.js → index-B3ndbezm.js} +3 -3
- package/dist/admin/spa/index-B3ndbezm.js.map +1 -0
- package/dist/admin/spa/index.html +1 -1
- package/dist/admin/spa/{template-editor-yH0Oz4Ix.js → template-editor-DwMKy5sw.js} +3 -3
- package/dist/admin/spa/{template-editor-yH0Oz4Ix.js.map → template-editor-DwMKy5sw.js.map} +1 -1
- package/dist/index.cjs +807 -664
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +807 -664
- package/dist/index.js.map +1 -1
- package/dist/{null-B0rPgE5_.d.cts → null-CwXmiVLe.d.cts} +15 -1
- package/dist/{null-B0rPgE5_.d.ts → null-CwXmiVLe.d.ts} +15 -1
- package/dist/testing.cjs +875 -482
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +233 -13
- package/dist/testing.d.ts +233 -13
- package/dist/testing.js +869 -483
- package/dist/testing.js.map +1 -1
- package/package.json +5 -2
- package/dist/admin/spa/index-CjQTOX9H.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-B3ndbezm.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 dk=Object.defineProperty;var uk=(t,e,n)=>e in t?dk(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var oa=(t,e,n)=>uk(t,typeof e!="symbol"?e+"":e,n);import{r as x,R as G,a as Rf,b as sb,g as ob,j as p,c as If,u as Df,L as fk,d as Jt,P as hk,I as Va}from"./index-CjQTOX9H.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 ab(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=ab(i.content,s.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function lb(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,d=Math.min(o.text.length,a.text.length);for(;c<d&&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=lb(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 d=a+1;l.nodesBetween(Math.max(0,e-d),Math.min(l.content.size,n-d),r,i+d)}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 ab(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return lb(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 hd={index:0,offset:0};function aa(t,e){return hd.index=t,hd.offset=e,hd}function ll(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(!ll(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!ll(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Pe=class Su{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&&ll(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 Su.none;if(e instanceof Su)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};Pe.none=[];class cl extends Error{}class X{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=db(this.content,e+this.openStart,n);return r&&new X(r,this.openStart,this.openEnd)}removeBetween(e,n){return new X(cb(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 X.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 X(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 X(e,r,i)}}X.empty=new X(P.empty,0,0);function cb(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(cb(s.content,e-i-1,n-i-1)))}function db(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=db(o.content,e-s-1,n,o);return a&&t.replaceChild(i,o.copy(a))}function pk(t,e,n){if(n.openStart>t.depth)throw new cl("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new cl("Inconsistent open depths");return ub(t,e,n,0)}function ub(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=ub(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 ei(o,a.cut(0,t.parentOffset).append(n.content).append(a.cut(e.parentOffset)))}else{let{start:o,end:a}=mk(n,t);return ei(s,hb(t,o,a,e,r))}else return ei(s,dl(t,e,r))}function fb(t,e){if(!e.type.compatibleContent(t.type))throw new cl("Cannot join "+e.type.name+" onto "+t.type.name)}function Cu(t,e,n){let r=t.node(n);return fb(r,e.node(n)),r}function Qr(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&&(Qr(t.nodeAfter,r),s++));for(let a=s;a<o;a++)Qr(i.child(a),r);e&&e.depth==n&&e.textOffset&&Qr(e.nodeBefore,r)}function ei(t,e){return t.type.checkContent(e),t.copy(e)}function hb(t,e,n,r,i){let s=t.depth>i&&Cu(t,e,i+1),o=r.depth>i&&Cu(n,r,i+1),a=[];return Us(null,t,i,a),s&&o&&e.index(i)==n.index(i)?(fb(s,o),Qr(ei(s,hb(t,e,n,r,i+1)),a)):(s&&Qr(ei(s,dl(t,e,i+1)),a),Us(e,n,i,a),o&&Qr(ei(o,dl(n,r,i+1)),a)),Us(r,null,i,a),new P(a)}function dl(t,e,n){let r=[];if(Us(null,t,n,r),t.depth>n){let i=Cu(t,e,n+1);Qr(ei(i,dl(t,e,n+1)),r)}return Us(e,null,n,r),new P(r)}function mk(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 Pe.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=Sp.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 Sp.set(e,r=new gk);let i=r.elts[r.i]=oo.resolve(e,n);return r.i=(r.i+1)%yk,i}}class gk{constructor(){this.elts=[],this.i=0}}const yk=12,Sp=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 bk=Object.create(null);let Sr=class _u{constructor(e,n,r,i=Pe.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&&ll(this.attrs,n||e.defaultAttrs||bk)&&Pe.sameSet(this.marks,r||Pe.none)}copy(e=null){return e==this.content?this:new _u(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new _u(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 X.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 X(c,i.depth-o,s.depth-o)}replace(e,n,r){return pk(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()+")"),pb(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=Pe.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(!Pe.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}};Sr.prototype.text=void 0;class ul extends Sr{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):pb(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 ul(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new ul(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 pb(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class li{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new vk(e,n);if(r.next==null)return li.empty;let i=mb(r);r.next&&r.err("Unexpected trailing text");let s=_k(Ck(i));return Nk(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:d,next:u}=o.next[c];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(u)==-1){i.push(u);let f=s(u,a.concat(d));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 dk=Object.defineProperty;var uk=(t,e,n)=>e in t?dk(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var oa=(t,e,n)=>uk(t,typeof e!="symbol"?e+"":e,n);import{r as x,R as G,a as Rf,b as sb,g as ob,j as p,c as If,u as Df,L as fk,d as Jt,P as hk,I as Va}from"./index-B3ndbezm.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 ab(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=ab(i.content,s.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function lb(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,d=Math.min(o.text.length,a.text.length);for(;c<d&&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=lb(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 d=a+1;l.nodesBetween(Math.max(0,e-d),Math.min(l.content.size,n-d),r,i+d)}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 ab(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return lb(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 hd={index:0,offset:0};function aa(t,e){return hd.index=t,hd.offset=e,hd}function ll(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(!ll(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!ll(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Pe=class Su{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&&ll(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 Su.none;if(e instanceof Su)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};Pe.none=[];class cl extends Error{}class X{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=db(this.content,e+this.openStart,n);return r&&new X(r,this.openStart,this.openEnd)}removeBetween(e,n){return new X(cb(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 X.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 X(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 X(e,r,i)}}X.empty=new X(P.empty,0,0);function cb(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(cb(s.content,e-i-1,n-i-1)))}function db(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=db(o.content,e-s-1,n,o);return a&&t.replaceChild(i,o.copy(a))}function pk(t,e,n){if(n.openStart>t.depth)throw new cl("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new cl("Inconsistent open depths");return ub(t,e,n,0)}function ub(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=ub(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 ei(o,a.cut(0,t.parentOffset).append(n.content).append(a.cut(e.parentOffset)))}else{let{start:o,end:a}=mk(n,t);return ei(s,hb(t,o,a,e,r))}else return ei(s,dl(t,e,r))}function fb(t,e){if(!e.type.compatibleContent(t.type))throw new cl("Cannot join "+e.type.name+" onto "+t.type.name)}function Cu(t,e,n){let r=t.node(n);return fb(r,e.node(n)),r}function Qr(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&&(Qr(t.nodeAfter,r),s++));for(let a=s;a<o;a++)Qr(i.child(a),r);e&&e.depth==n&&e.textOffset&&Qr(e.nodeBefore,r)}function ei(t,e){return t.type.checkContent(e),t.copy(e)}function hb(t,e,n,r,i){let s=t.depth>i&&Cu(t,e,i+1),o=r.depth>i&&Cu(n,r,i+1),a=[];return Us(null,t,i,a),s&&o&&e.index(i)==n.index(i)?(fb(s,o),Qr(ei(s,hb(t,e,n,r,i+1)),a)):(s&&Qr(ei(s,dl(t,e,i+1)),a),Us(e,n,i,a),o&&Qr(ei(o,dl(n,r,i+1)),a)),Us(r,null,i,a),new P(a)}function dl(t,e,n){let r=[];if(Us(null,t,n,r),t.depth>n){let i=Cu(t,e,n+1);Qr(ei(i,dl(t,e,n+1)),r)}return Us(e,null,n,r),new P(r)}function mk(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 Pe.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=Sp.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 Sp.set(e,r=new gk);let i=r.elts[r.i]=oo.resolve(e,n);return r.i=(r.i+1)%yk,i}}class gk{constructor(){this.elts=[],this.i=0}}const yk=12,Sp=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 bk=Object.create(null);let Sr=class _u{constructor(e,n,r,i=Pe.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&&ll(this.attrs,n||e.defaultAttrs||bk)&&Pe.sameSet(this.marks,r||Pe.none)}copy(e=null){return e==this.content?this:new _u(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new _u(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 X.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 X(c,i.depth-o,s.depth-o)}replace(e,n,r){return pk(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()+")"),pb(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=Pe.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(!Pe.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}};Sr.prototype.text=void 0;class ul extends Sr{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):pb(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 ul(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new ul(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 pb(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class li{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new vk(e,n);if(r.next==null)return li.empty;let i=mb(r);r.next&&r.err("Unexpected trailing text");let s=_k(Ck(i));return Nk(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:d,next:u}=o.next[c];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(u)==-1){i.push(u);let f=s(u,a.concat(d));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
|
`)}}li.empty=new li(!0);class vk{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 mb(t){let e=[];do e.push(xk(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function xk(t){let e=[];do e.push(wk(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function wk(t){let e=Sk(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=Ek(t,e);else break;return e}function Cp(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Ek(t,e){let n=Cp(t),r=n;return t.eat(",")&&(t.next!="}"?r=Cp(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function kk(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 Sk(t){if(t.eat("(")){let e=mb(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=kk(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 Ck(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 d=n();i(s(o.expr,l),d),l=d}if(o.max==-1)i(s(o.expr,l),l);else for(let c=o.min;c<o.max;c++){let d=n();r(l,d),i(s(o.expr,l),d),l=d}return[r(l)]}else{if(o.type=="name")return[r(a,void 0,o.value)];throw new Error("Unknown expr type")}}}}function gb(t,e){return e-t}function _p(t,e){let n=[];return r(e),n.sort(gb);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 _k(t){let e=Object.create(null);return n(_p(t,0));function n(r){let i=[];r.forEach(o=>{t[o].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let d=0;d<i.length;d++)i[d][0]==a&&(c=i[d][1]);_p(t,l).forEach(d=>{c||i.push([a,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let s=e[r.join(",")]=new li(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let a=i[o][1].sort(gb);s.next.push({type:i[o][0],next:e[a.join(",")]||n(a)})}return s}}function Nk(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 yb(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 bb(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 vb(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 xb(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new Ak(t,r,e[r]);return n}let Np=class wb{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=xb(e,r.attrs),this.defaultAttrs=yb(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==li.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:bb(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Sr(this,this.computeAttrs(e),P.from(n),Pe.setFrom(r))}createChecked(e=null,n,r){return n=P.from(n),this.checkContent(n),new Sr(this,this.computeAttrs(e),n,Pe.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 Sr(this,e,n.append(s),Pe.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){vb(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:Pe.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,o)=>r[s]=new wb(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 Tk(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 Ak{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Tk(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class bc{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=xb(e,i.attrs),this.excluded=null;let s=yb(this.attrs);this.instance=s?new Pe(this,s):null}create(e=null){return!e&&this.instance?this.instance:new Pe(this,bb(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new bc(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){vb(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}let Eb=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=Np.compile(this.spec.nodes,this),this.marks=bc.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]=li.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?Tp(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==""?[]:Tp(this,o.split(" "))}this.nodeFromJSON=i=>Sr.fromJSON(this,i),this.markFromJSON=i=>Pe.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 Np){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 ul(r,r.defaultAttrs,e,Pe.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 Tp(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 Mk(t){return t.tag!=null}function Ok(t){return t.style!=null}let Vs=class Nu{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(Mk(i))this.tags.push(i);else if(Ok(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 Mp(this,n,!1);return r.addAll(e,Pe.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Mp(this,n,!0);return r.addAll(e,Pe.none,n.from,n.to),X.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(Dk(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=Op(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=Op(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Nu(e,Nu.schemaRules(e)))}};const kb={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},Rk={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Sb={ol:!0,ul:!0},lo=1,Tu=2,Ks=4;function Ap(t,e,n){return e!=null?(e?lo:0)|(e==="full"?Tu:0):t&&t.whitespace=="pre"?lo|Tu:n&~Ks}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=Pe.none,this.match=s||(o&Ks?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&&!kb.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Mp{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=Ap(null,n.preserveWhitespace,0)|(r?Ks:0);i?s=new la(i.type,i.attrs,Pe.none,!0,n.topMatch||i.type.contentMatch,o):r?s=new la(null,null,Pe.none,!0,null,o):s=new la(e.schema.topNodeType,null,Pe.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&Tu?"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;Sb.hasOwnProperty(o)&&this.parser.normalizeLists&&Ik(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:Rk.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,d=this.needsBlock;if(kb.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 u=l&&l.skip?n:this.readStyles(e,n);u&&this.addAll(e,u),c&&this.sync(s),this.needsBlock=d}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=Pe.none;for(let a of i.concat(e.marks))(s.type?s.type.allowsMarkType(a.type):Rp(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=Ap(e,s,o.options);o.options&Ks&&o.content.length==0&&(a|=Ks);let l=Pe.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):Rp(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 d=l>0||l==0&&i?this.nodes[l].type:r&&l>=s?r.node(l-s).type:null;if(!d||d.name!=c&&!d.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 Ik(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Sb.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Dk(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Op(t){let e={};for(let n in t)e[n]=t[n];return e}function Rp(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:d}=a.edge(l);if(c==e||s.indexOf(d)<0&&o(d))return!0}};if(o(i.contentMatch))return!0}}class mi{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=pd(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++],d=this.serializeMark(c,o.isInline,n);d&&(s.push([c,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=Ka(pd(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&&Ka(pd(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return Ka(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new mi(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Ip(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Ip(e.marks)}}function Ip(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function pd(t){return t.document||window.document}const Dp=new WeakMap;function Lk(t){let e=Dp.get(t);return e===void 0&&Dp.set(t,e=Pk(t)),e}function Pk(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 Ka(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=Lk(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],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?l.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):u=="style"&&l.style?l.style.cssText=c[u]:l.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let f=e[u];if(f===0){if(u<e.length-1||u>d)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}=Ka(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 Cb=65535,_b=Math.pow(2,16);function Bk(t,e){return t+e*_b}function Lp(t){return t&Cb}function $k(t){return(t-(t&Cb))/_b}const Nb=1,Tb=2,Wa=4,Ab=8;class Au{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Ab)>0}get deletedBefore(){return(this.delInfo&(Nb|Wa))>0}get deletedAfter(){return(this.delInfo&(Tb|Wa))>0}get deletedAcross(){return(this.delInfo&Wa)>0}}class Ft{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ft.empty)return Ft.empty}recover(e){let n=0,r=Lp(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+$k(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],d=this.ranges[a+o],u=l+c;if(e<=u){let f=c?e==l?-1:e==u?1:n:n,h=l+i+(f<0?0:d);if(r)return h;let m=e==(n<0?l:u)?null:Bk(a/3,e-l),g=e==l?Tb:e==u?Nb:Wa;return(n<0?e!=l:e!=u)&&(g|=Ab),new Au(h,g,m)}i+=d-c}return r?e+i:new Au(e+i,0,null)}touches(e,n){let r=0,i=Lp(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],d=l+c;if(e<=d&&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],d=this.ranges[i+r];e(a,a+c,l,l+d),s+=d-c}}invert(){return new Ft(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ft.empty:new Ft(e<0?[0,-e,0]:[0,0,e])}}Ft.empty=new Ft([]);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 Au(e,i,null)}}const md=Object.create(null);class kt{getMap(){return Ft.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=md[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 md)throw new RangeError("Duplicate use of step JSON ID "+e);return md[e]=n,n.prototype.jsonID=e,n}}class Qe{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Qe(e,null)}static fail(e){return new Qe(null,e)}static fromReplace(e,n,r,i){try{return Qe.ok(e.replace(n,r,i))}catch(s){if(s instanceof cl)return Qe.fail(s.message);throw s}}}function Lf(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(Lf(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return P.fromArray(r)}class br extends kt{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 X(Lf(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 Qe.fromReplace(e,this.from,this.to,s)}invert(){return new Sn(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 br(n.pos,r.pos,this.mark)}merge(e){return e instanceof br&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new br(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 br(n.from,n.to,e.markFromJSON(n.mark))}}kt.jsonID("addMark",br);class Sn extends kt{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 X(Lf(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Qe.fromReplace(e,this.from,this.to,r)}invert(){return new br(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 Sn(n.pos,r.pos,this.mark)}merge(e){return e instanceof Sn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Sn(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 Sn(n.from,n.to,e.markFromJSON(n.mark))}}kt.jsonID("removeMark",Sn);class vr extends kt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Qe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Qe.fromReplace(e,this.pos,this.pos+1,new X(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 vr(this.pos,n.marks[i]);return new vr(this.pos,this.mark)}}return new ci(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new vr(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 vr(n.pos,e.markFromJSON(n.mark))}}kt.jsonID("addNodeMark",vr);class ci extends kt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Qe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Qe.fromReplace(e,this.pos,this.pos+1,new X(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 vr(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ci(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 ci(n.pos,e.markFromJSON(n.mark))}}kt.jsonID("removeNodeMark",ci);class Ze extends kt{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&Mu(e,this.from,this.to)?Qe.fail("Structure replace would overwrite content"):Qe.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ft([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ze(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&&Ze.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new Ze(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ze)||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?X.empty:new X(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ze(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?X.empty:new X(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ze(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 Ze(n.from,n.to,X.fromJSON(e,n.slice),!!n.structure)}}Ze.MAP_BIAS=1;kt.jsonID("replace",Ze);class st extends kt{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&&(Mu(e,this.from,this.gapFrom)||Mu(e,this.gapTo,this.to)))return Qe.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Qe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Qe.fromReplace(e,this.from,this.to,r):Qe.fail("Content does not fit in gap")}getMap(){return new Ft([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 st(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 st(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 st(n.from,n.to,n.gapFrom,n.gapTo,X.fromJSON(e,n.slice),n.insert,!!n.structure)}}kt.jsonID("replaceAround",st);function Mu(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 jk(t,e,n,r){let i=[],s=[],o,a;t.doc.nodesBetween(e,n,(l,c,d)=>{if(!l.isInline)return;let u=l.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+l.nodeSize,n),m=r.addToSet(u);for(let g=0;g<u.length;g++)u[g].isInSet(m)||(o&&o.to==f&&o.mark.eq(u[g])?o.to=h:i.push(o=new Sn(f,h,u[g])));a&&a.to==f?a.to=h:s.push(a=new br(f,h,r))}}),i.forEach(l=>t.step(l)),s.forEach(l=>t.step(l))}function Fk(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 bc){let c=o.marks,d;for(;d=r.isInSet(c);)(l||(l=[])).push(d),c=d.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 d=0;d<l.length;d++){let u=l[d],f;for(let h=0;h<i.length;h++){let m=i[h];m.step==s-1&&u.eq(i[h].style)&&(f=m)}f?(f.to=c,f.step=s):i.push({style:u,from:Math.max(a,e),to:c,step:s})}}}),i.forEach(o=>t.step(new Sn(o.from,o.to,o.style)))}function Pf(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),d=a+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new Ze(a,d,X.empty));else{r=u;for(let f=0;f<c.marks.length;f++)n.allowsMarkType(c.marks[f].type)||t.step(new Sn(a,d,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 X(P.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),o.push(new Ze(a+f.index,a+f.index+f[0].length,m))}}a=d}if(!r.validEnd){let l=r.fillBefore(P.empty,!0);t.replace(a,a,new X(l,0,0))}for(let l=o.length-1;l>=0;l--)t.step(o[l])}function Hk(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function ws(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||!Hk(o,a,l))break;a&&(i=1),l<o.childCount&&(s=1)}return null}function zk(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,d=P.empty,u=0;for(let m=s,g=!1;m>n;m--)g||r.index(m)>0?(g=!0,d=P.from(r.node(m).copy(d)),u++):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 st(l,c,o,a,new X(d.append(f),u,h),d.size-u,!0))}function Bf(t,e,n=null,r=t){let i=Uk(t,e),s=i&&Vk(r,e);return s?i.map(Pp).concat({type:e,attrs:n}).concat(s.map(Pp)):null}function Pp(t){return{type:t,attrs:null}}function Uk(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 Vk(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 Kk(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 st(i,s,i,s,new X(r,0,0),n.length,!0))}function Wk(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)&&Gk(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&&Ob(t,o,a,s),Pf(t,t.mapping.slice(s).map(a,1),r,void 0,c===null);let d=t.mapping.slice(s),u=d.map(a,1),f=d.map(a+o.nodeSize,1);return t.step(new st(u,f,u+1,f-1,new X(P.from(r.create(l,null,o.marks)),0,0),1,!0)),c===!0&&Mb(t,o,a,s),!1}})}function Mb(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 Ob(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(`
|
|
@@ -498,5 +498,5 @@ You can check out the documentation for more information: https://github.com/ari
|
|
|
498
498
|
margin-top: 0;
|
|
499
499
|
margin-bottom: 0;
|
|
500
500
|
}
|
|
501
|
-
`),c.adoptedStyleSheets=[d];const u=document.createElement("div");u.innerHTML=o,c.appendChild(u)},contentEditable:!1,onClick:()=>{a&&n({activeTab:"code"})}})]})}var YF=q5.extend({addStorage(){return{colors:new Set}}}),JF=["ltr","rtl"],un="ltr",XF=ap.extend({addAttributes(){var t;return ce(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:et,parseHTML:e=>e.getAttribute("data-show-if-key")||et,renderHTML(e){return e.showIfKey?{"data-show-if-key":e.showIfKey}:{}}}})},addCommands(){var t;return ce(z({},(t=this.parent)==null?void 0:t.call(this)),{setTextDirection:e=>({commands:n})=>n.updateAttributes(this.name,{textDirection:e})})}}),nb=Je.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",Ie(this.options.HTMLAttributes,t,{class:"footer mly:block mly:text-[13px] mly:text-slate-500 mly:relative"}),0]}}),ZF=hj.extend({addAttributes(){var t;return ce(z({},(t=this.parent)==null?void 0:t.call(this)),{isUrlVariable:{default:!1}})},addCommands(){var t;return ce(z({},(t=this.parent)==null?void 0:t.call(this)),{setIsUrlVariable:e=>({chain:n})=>n().setMark("link",{isUrlVariable:e}).run()})}}),QF=op.extend({addAttributes(){var t;return ce(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:et,parseHTML:e=>e.getAttribute("data-show-if-key")||et,renderHTML(e){return e.showIfKey?{"data-show-if-key":e.showIfKey}:{}}}})}});function eH(t){const{editor:e,getPos:n}=t;return p.jsxs(yi,{"data-type":"repeat",draggable:e.isEditable,"data-drag-handle":e.isEditable,className:"mly:relative",children:[p.jsx(bv,{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(kx,{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 rk=Je.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:et,parseHTML:t=>t.getAttribute("data-show-if-key")||et,renderHTML(t){return t.showIfKey?{"data-show-if-key":t.showIfKey}:{}}}}},parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML({HTMLAttributes:t}){return["div",Ie(t,{"data-type":this.name}),0]},addCommands(){return{setRepeat:()=>({commands:t})=>t.insertContent({type:this.name,attrs:{},content:[{type:"paragraph"}]}),updateRepeat:t=>Ms(this.name,t)}},addNodeView(){return bi(eH,{contentDOMElementTag:"div",className:"mly:relative"})}}),tH=We.create({name:"maily-kit",addOptions(){return{link:{HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:"mly:no-underline"},openOnClick:!1}}},addExtensions(){const t=[Z1.extend({content:"(block|columns)+"}),j$.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}),H$,YF.configure({types:[xy.name,sE.name]}),xy.configure(),F$.configure({types:[ap.name,op.name,nb.name]}),JE,nb,z$,Q1.configure({color:"#555",width:3,class:"ProseMirror-dropcursor"}),QF.configure({levels:[1,2,3],HTMLAttributes:{class:"mly:relative"}}),XF.configure({HTMLAttributes:{class:"mly:relative"}})];return this.options.linkCard!==!1&&t.push(ek.configure(this.options.linkCard)),this.options.repeat!==!1&&t.push(rk),this.options.section!==!1&&t.push(jE),this.options.columns!==!1&&t.push(YE),this.options.column!==!1&&t.push(yE),this.options.button!==!1&&t.push(tk),this.options.spacer!==!1&&t.push(ZE),this.options.logo!==!1&&t.push(UE),this.options.image!==!1&&t.push(nk),this.options.link!==!1&&t.push(ZF.configure(this.options.link)),t}}),nH=pj.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}),rH=We.create({name:"slash-command",addOptions(){return{suggestion:{char:"/",command:({editor:t,range:e,props:n})=>{n.command({editor:t,range:e})}}}},addProseMirrorPlugins(){return[n1(z({editor:this.editor},this.options.suggestion))]}});function iH(t){var e;const{item:n,groupIndex:r,commandIndex:i,selectedGroupIndex:s,selectedCommandIndex:o,editor:a,activeCommandRef:l,selectItem:c,hoveredItemKey:d,onHover:u}=t,[f,h]=x.useState(!1),m=r===s&&i===o,g=`${r}-${i}`,y=d===g,b=n&&"commands"in n,w=!!(n!=null&&n.preview)&&(y||m&&!d),v=typeof n.render=="function"?(e=n.render)==null?void 0:e.call(n,a):null;let S=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(GR,{className:"mly:size-3.5 mly:stroke-[2.5]"})})]});v!==null&&v!==!0&&(S=v);const k=x.useRef(0),C=x.useCallback(()=>{window.clearTimeout(k.current);const T=200;k.current=window.setTimeout(()=>{h(!0),k.current=0},T)},[h]);return x.useEffect(()=>{w?C():(window.clearTimeout(k.current),k.current=0,h(!1))},[w]),x.useEffect(()=>()=>{k.current&&(window.clearTimeout(k.current),k.current=0)},[]),p.jsxs(Tt,{open:f,children:[p.jsx(At,{asChild:!0,children:p.jsx("button",{className:xe("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:()=>u(!0),onMouseLeave:()=>u(!1),type:"button",ref:m?l:null,children:S})}),p.jsx(Et,{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 sH(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,d=oH(e,c);if(d){const u=s.slice(l.length),f=d.commands.filter(h=>!u||ol(h,u));return f.length?[ce(z({},d),{commands:f})]:[]}}return i.map(l=>ce(z({},l),{commands:l.commands.flatMap(c=>lH({item:c,search:s,editor:r}))})).filter(l=>l.commands.length>0)}function oH(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 wu(t,e){return t?t.toLowerCase().includes(e.toLowerCase()):!1}function ol(t,e){var n,r;return wu(t.title,e)||wu(t.description,e)||((r=(n=t.searchTerms)==null?void 0:n.some(i=>wu(i,e)))!=null?r:!1)}function aH(t){return"commands"in t&&Array.isArray(t.commands)&&!!t.id}function lH(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(aH(s)){const d=ce(z({},s),{command:h=>{const{editor:m,range:g}=h;m.chain().focus().insertContentAt(g,`/${s.id}.`).run()}});return ol(d,o)?[d]:((r=(n=d==null?void 0:d.commands)==null?void 0:n.some(h=>ol(h,o)))!=null?r:!1)?(i=d==null?void 0:d.commands)!=null?i:[]:[]}return!c||ol(s,o)?[s]:[]}var cH=x.forwardRef((t,e)=>{const{items:n,command:r,editor:i,range:s,query:o}=t,[a,l]=x.useState(0),[c,d]=x.useState(0),[u,f]=x.useState(null),h=x.useRef(""),m=x.useRef(0),g=x.useRef(0),y=x.useCallback((E,v)=>{const S=n[E].commands[v];S&&r(S)},[r]);x.useImperativeHandle(e,()=>({onKeyDown:({event:E})=>{var v,S,k,C;if(["ArrowUp","ArrowDown","Enter","ArrowLeft","ArrowRight"].includes(E.key)){let M=c,D=a;switch(E.key){case"ArrowLeft":E.preventDefault();const B=n==null?void 0:n[a];return B&&"id"in B?(i.chain().focus().insertContentAt(s,`/${h.current}`).run(),setTimeout(()=>{l(m.current),d(g.current)},0),!0):!1;case"ArrowRight":E.preventDefault();const F=(S=(v=n==null?void 0:n[a])==null?void 0:v.commands)==null?void 0:S[c];return F&&"commands"in F?(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,D=a,M<0&&(D=a-1,M=((k=n[D])==null?void 0:k.commands.length)-1||0),D<0&&(D=n.length-1,M=((C=n[D])==null?void 0:C.commands.length)-1||0),l(D),d(M),!0):!1;case"ArrowDown":if(!n.length)return!1;const J=n[a].commands;return M=c+1,D=a,J.length-1<M&&(M=0,D=a+1),n.length-1<D&&(D=0),l(D),d(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:S,offsetHeight:k}=v;E.style.transition="none",E.scrollTop=S-k},[a,c,b,w]),x.useEffect(()=>{l(0),d(0)},[n]),x.useEffect(()=>()=>{h.current="",m.current=0,g.current=0},[]),!n||n.length===0?null:p.jsx(Kt,{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:xe("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((S,k)=>{const C=`${v}-${k}`;return p.jsx(iH,{item:S,groupIndex:v,commandIndex:k,selectedGroupIndex:a,selectedCommandIndex:c,selectItem:()=>y(v,k),editor:i,activeCommandRef:w,hoveredItemKey:u,onHover:T=>f(T?C:null)},C)})})]},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 dH(t=vp){return{items:({query:e,editor:n})=>sH({query:e,editor:n,groups:t}),allow:({editor:e})=>!e.isActive("htmlCodeBlock"),render:()=>{let e,n=null;return{onStart:r=>{e=new hh(cH,{props:r,editor:r.editor}),n=$r("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 ik=x.forwardRef((t,e)=>{var n;const{items:r=[],editor:i}=t,s=x.useRef(null),o=(n=wi(i))==null?void 0:n.variableSuggestionsPopover;return x.useImperativeHandle(e,()=>({onKeyDown:({event:a})=>{if(!s.current)return!1;const{moveUp:l,moveDown:c,select:d}=s.current||{};return a.key==="ArrowUp"?(a.preventDefault(),l(),!0):a.key==="ArrowDown"?(a.preventDefault(),c(),!0):a.key==="Enter"?(d(),!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})});ik.displayName="VariableList";function uH(t=xp){return{char:t,items:({query:e,editor:n})=>{var r;const i=(r=ME(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 hh(ik,{props:r,editor:r.editor}),r.clientRect&&(n=$r("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 sk=K5(Y4);sk.register("html",E1);var ok=A3.extend({name:"htmlCodeBlock",content:"(text|variable)*",addAttributes(){var t;return ce(z({},(t=this.parent)==null?void 0:t.call(this)),{activeTab:"code",showIfKey:{default:et,parseHTML:e=>e.getAttribute("data-show-if-key")||et,renderHTML(e){return e.showIfKey?{"data-show-if-key":e.showIfKey}:{}}}})},addNodeView(){return bi(qF,{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=>Ms(this.name,t)}},addKeyboardShortcuts(){var t;return ce(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 d=s;d>0;d--)if(r.node(d).type.name===this.name){s=d;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 d=e.state.tr.setSelection(me.between(l,c));return e.view.dispatch(d),!0}return!1}})}}).configure({lowlight:sk}),fH=(t,e)=>[JE.name,Yh.name,ZE.name,nk.name,GE.name,ek.name,UE.name,tk.name,ok.name,qE.name].some(r=>t.isActive(r));function hH(t){return p.jsxs("svg",ce(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 pH(t){return p.jsxs("svg",ce(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 mH(t){const{direction:e,onDirectionChange:n}=t,r=JF.includes(e)?e:"ltr",i={ltr:{icon:hH,tooltip:"Left to Right",onClick:()=>{n("ltr")}},rtl:{icon:pH,tooltip:"Right to Left",onClick:()=>{n("rtl")}}},s=i[r];return p.jsxs(sn,{children:[p.jsxs(Tt,{children:[p.jsx(At,{asChild:!0,children:p.jsx(on,{className:xe("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(Et,{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(dn,{icon:a.icon,tooltip:a.tooltip,command:a.onClick,isActive:()=>o===r},o))})]})}var gH="#374151",yH=t=>Dn({editor:t,selector:n=>{var r,i,s,o,a,l,c,d,u,f,h,m;return{currentTextColor:n.editor.getAttributes("textStyle").color||gH,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)||((d=n.editor.getAttributes("footer"))==null?void 0:d.textDirection)||un,isFooterActive:n.editor.isActive("footer"),footerTextDirection:((u=n.editor.getAttributes("footer"))==null?void 0:u.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:jr});function ak(t){var e,n,r,i;const{editor:s,showListMenu:o=!0}=t,a=yH(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:[],d=[{name:"bold",isActive:()=>s==null?void 0:s.isActive("bold"),command:()=>s==null?void 0:s.chain().focus().toggleBold().run(),icon:dx,tooltip:"Bold"},{name:"italic",isActive:()=>s==null?void 0:s.isActive("italic"),command:()=>s==null?void 0:s.chain().focus().toggleItalic().run(),icon:xx,tooltip:"Italic"},{name:"underline",isActive:()=>s==null?void 0:s.isActive("underline"),command:()=>s==null?void 0:s.chain().focus().toggleUnderline().run(),icon:_x,tooltip:"Underline"},{name:"strike",isActive:()=>s==null?void 0:s.isActive("strike"),command:()=>s==null?void 0:s.chain().focus().toggleStrike().run(),icon:Sx,tooltip:"Strikethrough"},{name:"code",isActive:()=>s==null?void 0:s.isActive("code"),command:()=>s==null?void 0:s.chain().focus().toggleCode().run(),icon:ZR,tooltip:"Code"}];return p.jsxs(p.Fragment,{children:[d.map((u,f)=>p.jsx(dn,z({},u),f)),p.jsx(cd,{alignment:a.textAlign,onAlignmentChange:u=>{s==null||s.chain().focus().setTextAlign(u).run()}}),p.jsx(mH,{direction:a.textDirection,onDirectionChange:u=>{a.isFooterActive?s==null||s.chain().focus().setFooterTextDirection(u).run():a.isHeadingActive?s==null||s.chain().focus().updateAttributes("heading",{textDirection:u}).run():s==null||s.chain().focus().setTextDirection(u).run()}}),!a.isListActive&&o&&p.jsxs(p.Fragment,{children:[p.jsx(dn,{icon:Oh,command:()=>{s.chain().focus().toggleBulletList().run()},tooltip:"Bullet List"}),p.jsx(dn,{icon:Mh,command:()=>{s.chain().focus().toggleOrderedList().run()},tooltip:"Ordered List"})]}),p.jsx(xs,{defaultValue:(i=a==null?void 0:a.linkUrl)!=null?i:"",onValueChange:(u,f)=>{if(!u){s==null||s.chain().focus().extendMarkRange("link").unsetLink().unsetUnderline().run();return}s==null||s.chain().extendMarkRange("link").setLink({href:u}).setIsUrlVariable(f??!1).setUnderline().run()},tooltip:"External URL",editor:s,isVariable:a.isUrlVariable}),p.jsx(Ue,{}),p.jsx(Uo,{color:a.currentTextColor,onColorChange:u=>{s==null||s.chain().setColor(u).run()},tooltip:"Text Color",suggestedColors:c,children:p.jsx(Dt,{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 bH=t=>t.type==="option",vH=t=>t.type==="category";function xH(t){const{options:e}=t,n=x.useMemo(()=>e.find(i=>i.type==="option"&&i.isActive()),[e]),{icon:r=wx}=n||{};return p.jsxs(sn,{children:[p.jsxs(Tt,{children:[p.jsx(At,{asChild:!0,children:p.jsxs(on,{className:xe("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(ux,{className:"mly:h-3 mly:w-3 mly:shrink-0 mly:stroke-[2.5]"})]})}),p.jsx(Et,{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(bH(i))return p.jsxs(Dt,{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(vH(i))return p.jsx("label",{className:xe("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 wH(t){return Dn({editor:t,selector:({editor:e})=>[{type:"category",label:"Hierarchy",id:"hierarchy"},{icon:wx,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:Th,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:gx,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:yx,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:Nh,onClick:()=>{e.chain().focus().liftListItem("listItem").setFooter().run()},disabled:()=>!e.can().setFooter(),isActive:()=>e.isActive("footer")},{type:"category",label:"Lists",id:"lists"},{icon:Oh,onClick:()=>e.chain().focus().toggleBulletList().run(),id:"bulletList",disabled:()=>!e.can().toggleBulletList(),isActive:()=>e.isActive("bulletList"),label:"Bullet list",type:"option"},{icon:Mh,onClick:()=>e.chain().focus().toggleOrderedList().run(),id:"orderedList",disabled:()=>!e.can().toggleOrderedList(),isActive:()=>e.isActive("orderedList"),label:"Numbered list",type:"option"}]})}function EH(t){const{editor:e,appendTo:n}=t;if(!e)return null;const r=ce(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,u=a.nodeDOM(o||0)||c;if(fH(s)||!s.isEditable)return!1;const h=[rk.name,jE.name,YE.name,yE.name].some(m=>s.isActive(m))&&((l=u==null?void 0:u.classList)==null?void 0:l.contains("ProseMirror-selectednode"));return ld(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=wH(e);return p.jsx(rr,ce(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(Kt,{children:[p.jsx(xH,{options:i}),p.jsx(Ue,{className:"mly:mx-0"}),p.jsx(ak,{editor:e})]})}))}function kH(t){const{editor:e,appendTo:n}=t;if(!e)return null;const r=ce(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:[gi],sticky:"popper",maxWidth:"100%",appendTo:()=>(n==null?void 0:n.current)||"parent",placement:"top-start"}});return p.jsx(rr,ce(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(Kt,{children:p.jsx(ak,{showListMenu:!1,editor:e})})}))}var SH=We.create({name:"selection",addProseMirrorPlugins(){const{editor:t}=this;return[new $e({key:new Be("selection"),props:{decorations(e){return e.selection.empty||t.isFocused===!0?null:ze.create(e.doc,[mt.inline(e.selection.from,e.selection.to,{class:"selection mly:bg-blue-200 mly:inline mly:py-1"})])}}})]}});function CH(t){const{blocks:e,extensions:n=[]}=t;return[...[tH,rH.configure({suggestion:dH(e)}),GE.configure({suggestion:uH()}),ok,qE,nH,SH].filter(i=>!n.some(s=>s.name===i.name)),...n]}function rb(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)||XE),i.attrs=ce(z({},i.attrs),{height:s})}i.content&&r.push(...i.content)}}return t}function _H(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:d,extensions:u,contentHtml:f,contentJson:h,blocks:m=vp,editable:g=!0,placeholderUrl:y=dd,scrollThreshold:b=40,scrollMargin:w=40}=t,E=x.useMemo(()=>{if(h){const k=(h==null?void 0:h.type)==="doc"?h:{type:"doc",content:h};return rb(k)}else return f||{type:"doc",content:[{type:"paragraph",content:[]}]}},[f,h,rb]),v=x.useRef(null),S=aM({editorProps:{scrollThreshold:b,scrollMargin:w,attributes:{class:xe("mly:prose mly:w-full",n),spellCheck:o?"true":"false"}},immediatelyRender:l,onCreate:({editor:k})=>{c==null||c(k)},onUpdate:({editor:k})=>{d==null||d(k)},extensions:CH({extensions:u,blocks:m}),content:E,autofocus:a,editable:g});return S?p.jsx(pF,{placeholderUrl:y,children:p.jsxs("div",{id:"mly-editor",className:xe("mly-editor mly:antialiased",S.isEditable?"mly-editable":"mly-not-editable",e),ref:v,children:[i&&p.jsx(g9,{config:t.config,editor:S}),p.jsxs("div",{className:xe("mly:mt-4 mly:rounded mly:border mly:border-gray-200 mly:bg-white mly:p-4",r),children:[p.jsx(EH,{editor:S,appendTo:v}),p.jsx(EF,{editor:S,appendTo:v}),p.jsx(IF,{editor:S,appendTo:v}),p.jsx(ZA,{editor:S}),p.jsx(OF,{editor:S,appendTo:v}),p.jsx(l9,{editor:S,appendTo:v}),!s&&p.jsx(m9,{editor:S}),p.jsx(kH,{editor:S,appendTo:v}),p.jsx(_F,{editor:S,appendTo:v}),p.jsx(b9,{editor:S,appendTo:v}),p.jsx(SF,{editor:S,appendTo:v})]})]})}):null}function ib({value:t,onChange:e,paths:n,className:r,placeholder:i}){const s=G.useRef(null),[o,a]=G.useState(null),l=G.useMemo(()=>{if(!o)return[];const f=o.query.toLowerCase();return n.filter(h=>h.path.toLowerCase().includes(f)).slice(0,8)},[o,n]);function c(f,h){if(e(f),h==null){a(null);return}const m=f.slice(0,h),g=m.lastIndexOf("{{");if(g===-1||m.slice(g).includes("}}")){a(null);return}const y=m.slice(g+2).trimStart();if(/[{}]/.test(y)){a(null);return}a({anchor:g,query:y,selected:0})}function d(f){if(!o)return;const h=s.current,m=(h==null?void 0:h.selectionStart)??t.length,g=t.slice(0,o.anchor),y=t.slice(m),b=`{{${f.path}}}`,w=`${g}${b}${y}`;e(w),a(null),requestAnimationFrame(()=>{const E=g.length+b.length;h==null||h.setSelectionRange(E,E),h==null||h.focus()})}function u(f){!o||l.length===0||(f.key==="ArrowDown"?(f.preventDefault(),a({...o,selected:(o.selected+1)%l.length})):f.key==="ArrowUp"?(f.preventDefault(),a({...o,selected:(o.selected-1+l.length)%l.length})):f.key==="Enter"||f.key==="Tab"?(f.preventDefault(),d(l[Math.min(o.selected,l.length-1)])):f.key==="Escape"&&(f.preventDefault(),a(null)))}return p.jsxs("div",{style:{position:"relative"},children:[p.jsx("input",{ref:s,className:r??"input",value:t,placeholder:i,onChange:f=>c(f.target.value,f.target.selectionStart),onKeyDown:u,onBlur:()=>setTimeout(()=>a(null),150),onClick:f=>c(t,f.target.selectionStart)}),o&&l.length>0&&p.jsx("div",{className:"card",role:"listbox",style:{position:"absolute",top:"100%",left:0,right:0,zIndex:40,marginTop:4,maxHeight:240,overflow:"auto",padding:4,boxShadow:"0 8px 24px rgba(0,0,0,0.18)"},children:l.map((f,h)=>p.jsxs("div",{role:"option","aria-selected":h===o.selected,onMouseDown:m=>{m.preventDefault(),d(f)},onMouseEnter:()=>a({...o,selected:h}),style:{display:"flex",justifyContent:"space-between",gap:12,padding:"6px 8px",borderRadius:4,cursor:"pointer",background:h===o.selected?"var(--bg-sunken)":"transparent"},children:[p.jsx("span",{className:"mono text-xs",children:`{{${f.path}}}`}),p.jsx("span",{className:"text-xs subtle",children:f.type})]},f.path))})]})}const NH=[{path:"unsubscribeUrl",type:"string",description:"One-click unsubscribe link (required in marketing templates)"},{path:"event",type:"object",description:"Properties of the event that triggered the flow run, e.g. event.accountId"},{path:"senderAddress",type:"string",description:"Configured postal address (CAN-SPAM)"},{path:"contact.email",type:"string"},{path:"contact.externalId",type:"string"},{path:"contact.timezone",type:"string"},{path:"contact.locale",type:"string"}],TH=5;function AH(t){if(!t)return[];const e=[];return Of(t,"",e,0),e}function Of(t,e,n,r){if(!t||typeof t!="object"||r>TH)return;const i=t,s=i.anyOf??i.oneOf;if(Array.isArray(s)){const o=s.some(c=>c&&c.type==="null"),a=s.find(c=>c&&(c.type==="object"||c.properties));if(a){e&&n.push({path:e,type:o?"object | null":"object",description:i.description}),Of(a,e,n,r);return}const l=s.map(c=>al(c)).filter(Boolean);e&&n.push({path:e,type:Array.from(new Set(l)).join(" | "),description:i.description});return}if(i.type==="object"||i.properties){if(e&&!i.properties){n.push({path:e,type:"object",description:i.description});return}for(const[o,a]of Object.entries(i.properties??{})){const l=e?`${e}.${o}`:o,c=a;c&&(c.type==="object"||c.properties||Array.isArray(c.anyOf??c.oneOf))?Of(c,l,n,r+1):n.push({path:l,type:al(c),description:c==null?void 0:c.description})}return}e&&n.push({path:e,type:al(i),description:i.description})}function al(t){if(!t||typeof t!="object")return"unknown";if(t.type==="array"){const e=al(t.items);return e==="unknown"?"array":`${e}[]`}return Array.isArray(t.type)?t.type.join(" | "):t.enum?t.enum.map(e=>JSON.stringify(e)).join(" | "):typeof t.type=="string"?t.type:"unknown"}const MH={type:"doc",content:[{type:"paragraph"}]};function KH({slug:t}){const{data:e,loading:n,error:r,refetch:i}=Df(()=>Jt.template(t),[t]);return p.jsx(fk,{loading:n&&!e,error:r,empty:!e,emptyLabel:"Template not found.",retry:i,children:e&&p.jsx(OH,{tpl:e,slug:t,refetch:i})})}function OH({tpl:t,slug:e,refetch:n}){var V,O,L,Y,pe,Oe,bt,or,R,re,ge;const[r,i]=G.useState("design"),[s,o]=G.useState(MH),[a,l]=G.useState(((V=t.draft)==null?void 0:V.subject)??t.subject??""),[c,d]=G.useState(((O=t.draft)==null?void 0:O.preheader)??t.preheader??""),[u,f]=G.useState(((L=t.draft)==null?void 0:L.fromName)??t.fromName??""),[h,m]=G.useState(((Y=t.draft)==null?void 0:Y.fromEmail)??t.fromEmail??""),[g,y]=G.useState(((pe=t.draft)==null?void 0:pe.replyTo)??t.replyTo??""),[b,w]=G.useState(!1),[E,v]=G.useState(""),[S,k]=G.useState(!1),C=G.useRef(null),T=G.useRef(!1),[M,D]=G.useState(!1),{data:B}=Df(()=>Jt.varsSchema(),[]),$=G.useMemo(()=>[...AH((B==null?void 0:B.schema)??null),...NH],[B]),[F,q]=G.useState(null),[J,A]=G.useState(null),[N,_]=G.useState([]),[I,j]=G.useState(void 0),[U,ne]=G.useState(null),[ae,W]=G.useState(!1),[Z,ye]=G.useState(!1),[he,Re]=G.useState(""),[_e,Se]=G.useState(null),[Me,Te]=G.useState(!1);async function Ce(K){W(!0);try{const le=await Jt.previewTemplate(e,{useDraft:!0,contactId:K});q(le),A(null)}catch(le){A(String((le==null?void 0:le.message)??le))}finally{W(!1)}}async function Ke(){A(null),v("Generating preview…");try{let K=N;if(K.length===0){const le=await Jt.contacts();K=le.contacts,_(le.contacts),j(le.nextCursor)}K.length>0?(ne(0),await Ce(String(K[0].externalId))):(ne(null),await Ce()),v("")}catch(K){A(String((K==null?void 0:K.message)??K)),v("")}}const Ae=G.useCallback(async K=>{if(ae||K<0)return;let le=N;if(K>=le.length){if(!I)return;const Xe=await Jt.contacts(I);if(le=[...le,...Xe.contacts],_(le),j(Xe.nextCursor),K>=le.length)return}ne(K),await Ce(String(le[K].externalId))},[ae,N,I,e]);G.useEffect(()=>{if(!F||U==null)return;function K(le){le.key==="ArrowRight"?(le.preventDefault(),Ae(U+1)):le.key==="ArrowLeft"&&(le.preventDefault(),Ae(U-1))}return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[F,U,Ae]);async function fe(){if(!(!he.trim()||Me)){Te(!0),Se("Sending…");try{const K=U!=null&&N[U]?String(N[U].externalId):void 0;await Jt.sendTestTemplate(e,{to:he.trim(),contactId:K}),Se(`Sent test to ${he.trim()}`)}catch(K){Se(`Failed: ${(K==null?void 0:K.message)??K}`)}finally{Te(!1)}}}const je=t.kind??"marketing",Q=t.name??e,se=t.slug??e,Ne=((Oe=t.body)==null?void 0:Oe.mjml)??((bt=t.draft)==null?void 0:bt.mjml)??"",ue=((or=t.body)==null?void 0:or.plainText)??"",be=RH(e,{subject:a,preheader:c,editorJson:M?s:null,fromEmail:h||t.fromEmail,kind:je}),Ge=(((R=be.data)==null?void 0:R.errors.length)??0)>0;G.useEffect(()=>{var le,Xe;if(T.current)return;T.current=!0;const K=((le=t.draft)==null?void 0:le.editorJson)??((Xe=t.body)==null?void 0:Xe.editorJson);K&&(o(K),D(!0))},[t]);async function nt(){v("Saving draft…"),await Jt.updateTemplateDraft(e,{subject:a,preheader:c,...M?{editorJson:s}:Ne?{mjml:Ne}:{},fromName:u||void 0,fromEmail:h||void 0,replyTo:g||void 0})}async function Mt(){k(!0);try{await nt(),v("Publishing…");const K=await Jt.publishTemplate(e);v(`Published v${K.version}`),w(!1),n()}catch(K){v(`Error: ${(K==null?void 0:K.message)??String(K)}`)}finally{k(!1)}}return p.jsxs(p.Fragment,{children:[p.jsx(hk,{title:Q,desc:p.jsxs(p.Fragment,{children:[p.jsxs("span",{className:"mono",children:["templates/",se]})," · ",p.jsx("span",{className:"pill "+(je==="transactional"?"blue":"neutral"),style:{marginLeft:4},children:je})]}),actions:p.jsxs(p.Fragment,{children:[p.jsxs("button",{className:"btn",onClick:Ke,children:[p.jsx(Va.Eye,{size:14}),"Preview"]}),p.jsxs("button",{className:"btn",onClick:()=>{ye(!0),Se(null)},children:[p.jsx(Va.Send,{size:14}),"Test send"]}),p.jsxs("button",{className:"btn btn-primary",disabled:S||Ge,onClick:Mt,title:Ge?"Resolve content-lint errors before publishing.":void 0,children:[p.jsx(Va.Rocket,{size:14}),"Publish"]}),be.data&&p.jsx("span",{className:"text-xs subtle",style:{marginLeft:8},children:p.jsx(lk,{data:be.data})}),E&&p.jsx("span",{className:"text-xs subtle",style:{marginLeft:8},children:E})]})}),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"+(r==="design"?" active":""),onClick:()=>i("design"),children:"Design"}),p.jsx("span",{className:"seg-item"+(r==="source"?" active":""),onClick:()=>i("source"),children:"MJML"}),p.jsx("span",{className:"seg-item"+(r==="plaintext"?" active":""),onClick:()=>i("plaintext"),children:"Plain text"})]}),p.jsx("div",{className:"card-actions",children:p.jsx("span",{className:"text-xs subtle",children:b?"Unsaved changes":E.startsWith("Published")||E==="Saved"?E:""})})]}),p.jsxs("div",{style:{padding:16},children:[p.jsxs("div",{className:"field",children:[p.jsx("label",{className:"field-label",children:"Subject"}),p.jsx(ib,{value:a,paths:$,onChange:K=>{l(K),w(!0)}})]}),p.jsxs("div",{className:"field",children:[p.jsx("label",{className:"field-label",children:"Preheader"}),p.jsx(ib,{value:c,paths:$,onChange:K=>{d(K),w(!0)}})]})]}),r==="design"&&p.jsx("div",{className:"maily-host",style:{padding:16,background:"var(--bg-sunken)",minHeight:480},children:p.jsx(_H,{contentJson:s,onCreate:K=>{C.current=K},onUpdate:K=>{C.current=K,o(K.getJSON()),D(!0),w(!0)},config:{hasMenuBar:!0,contentClassName:"mly-content",wrapClassName:"mly-wrap",bodyClassName:"mly-body",spellCheck:!0}})}),r==="source"&&p.jsx("pre",{className:"code",style:{margin:16,padding:16,maxHeight:520,overflow:"auto",whiteSpace:"pre-wrap"},children:Ne||"/* No MJML stored for this template (Maily-authored). Switch to Design to edit. */"}),r==="plaintext"&&p.jsx("pre",{className:"code",style:{margin:16,padding:16,maxHeight:520,overflow:"auto",whiteSpace:"pre-wrap"},children:ue||"/* Plain text is auto-derived on publish. */"})]}),p.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[p.jsx(DH,{lint:be}),p.jsx(IH,{paths:$,hasSchema:!!(B!=null&&B.schema)}),p.jsx(LH,{slug:e,refetchTemplate:n}),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",value:u,placeholder:"(default from mailer config)",onChange:K=>{f(K.target.value),w(!0)}})]}),p.jsxs("div",{className:"field",children:[p.jsx("label",{className:"field-label",children:"From email"}),p.jsx("input",{className:"input",value:h,placeholder:"(default from mailer config)",onChange:K=>{m(K.target.value),w(!0)}})]}),p.jsxs("div",{className:"field",style:{marginBottom:0},children:[p.jsx("label",{className:"field-label",children:"Reply-to"}),p.jsx("input",{className:"input",value:g,placeholder:"(same as From)",onChange:K=>{y(K.target.value),w(!0)}})]})]})]})]})]}),F&&p.jsxs(ku,{onClose:()=>{q(null),ne(null)},title:"Preview",children:[U!=null&&N.length>0&&p.jsxs("div",{className:"hstack",style:{gap:8,alignItems:"center",marginBottom:10},children:[p.jsx("button",{className:"btn btn-xs",disabled:ae||U===0,onClick:()=>Ae(U-1),title:"Previous contact (←)",children:"←"}),p.jsx("span",{className:"text-xs mono",children:((re=F.contact)==null?void 0:re.email)??((ge=N[U])==null?void 0:ge.email)}),p.jsxs("span",{className:"text-xs subtle",children:[U+1," / ",N.length,I?"+":""]}),p.jsx("button",{className:"btn btn-xs",disabled:ae,onClick:()=>Ae(U+1),title:"Next contact (→)",children:"→"}),ae&&p.jsx("span",{className:"text-xs subtle",children:"Rendering…"})]}),p.jsx("div",{className:"text-sm f500",children:F.subject}),p.jsx("div",{className:"text-xs subtle",style:{marginBottom:8},children:F.preheader}),p.jsx("iframe",{title:"preview",sandbox:"",srcDoc:F.html,style:{width:"100%",minHeight:480,border:"1px solid var(--border)",borderRadius:6,background:"#fff"}})]}),J&&p.jsx(ku,{onClose:()=>A(null),title:"Preview failed",children:p.jsx("div",{className:"text-sm",style:{color:"var(--red-fg)"},children:J})}),Z&&p.jsx(ku,{onClose:()=>ye(!1),title:"Send test email",children:p.jsxs("div",{className:"vstack",style:{gap:12},children:[p.jsxs("div",{className:"field",style:{marginBottom:0},children:[p.jsx("label",{className:"field-label",children:"To"}),p.jsx("input",{className:"input",type:"email",placeholder:"you@example.com",value:he,onChange:K=>Re(K.target.value)}),p.jsx("div",{className:"field-hint",children:"Uses the published version (publish first if you want to test recent edits)."})]}),_e&&p.jsx("div",{className:"text-xs",children:_e}),p.jsxs("div",{className:"hstack",style:{gap:8},children:[p.jsx("button",{className:"btn btn-primary",onClick:fe,disabled:!he.trim()||Me,children:Me?"Sending…":"Send"}),p.jsx("button",{className:"btn",onClick:()=>ye(!1),children:"Close"})]})]})})]})}function RH(t,e){const[n,r]=G.useState({data:null,loading:!1,error:null}),i=JSON.stringify(e),s=G.useRef(e);return s.current=e,G.useEffect(()=>{const o=new AbortController;r(l=>({...l,loading:!0}));const a=setTimeout(async()=>{try{const l=await Jt.lintTemplate(t,s.current,o.signal);r({data:l,loading:!1,error:null})}catch(l){if((l==null?void 0:l.name)==="AbortError")return;r(c=>({data:c.data,loading:!1,error:String((l==null?void 0:l.message)??l)}))}},500);return()=>{o.abort(),clearTimeout(a)}},[i,t]),n}function IH({paths:t,hasSchema:e}){const[n,r]=G.useState(null);function i(s){var o;(o=navigator.clipboard)==null||o.writeText(`{{${s}}}`),r(s),setTimeout(()=>r(a=>a===s?null:a),1200)}return 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:e?"Click to copy":"Built-ins only"})]}),p.jsxs("div",{className:"card-body",style:{padding:0},children:[!e&&p.jsxs("div",{className:"text-xs subtle",style:{padding:12},children:["No ",p.jsx("code",{children:"varsAdapter"})," configured — define one with ",p.jsx("code",{children:"defineVars()"})," in ",p.jsx("code",{children:"Mailer.init"})," to expose host data (","{{user.name}}",", …) to templates."]}),p.jsx("div",{style:{maxHeight:280,overflow:"auto"},children:t.map(s=>p.jsxs("div",{onClick:()=>i(s.path),title:s.description??`{{${s.path}}}`,style:{display:"flex",justifyContent:"space-between",gap:12,cursor:"pointer",padding:"6px 12px",borderTop:"1px solid var(--border)"},children:[p.jsx("span",{className:"mono text-xs",children:n===s.path?"Copied!":`{{${s.path}}}`}),p.jsx("span",{className:"text-xs subtle",children:s.type})]},s.path))})]})]})}function lk({data:t}){const{errors:e,warnings:n,infos:r}=t;return e.length+n.length+r.length===0?p.jsxs("span",{style:{color:"var(--green-fg)"},children:[p.jsx("span",{className:"dot"}),"Lint: clean"]}):p.jsxs("span",{className:"hstack",style:{gap:6},children:[e.length>0&&p.jsxs("span",{style:{color:"var(--red-fg)"},children:[e.length," error",e.length===1?"":"s"]}),n.length>0&&p.jsxs("span",{style:{color:"var(--amber-fg)"},children:[n.length," warning",n.length===1?"":"s"]}),r.length>0&&p.jsxs("span",{style:{color:"var(--fg-muted)"},children:[r.length," info"]})]})}function DH({lint:t}){const e=t.data;return p.jsxs("div",{className:"card",children:[p.jsxs("div",{className:"card-head",children:[p.jsx("span",{className:"card-title",children:"Issues"}),p.jsx("span",{className:"card-sub",children:t.loading&&!e?"Checking…":e?p.jsx(lk,{data:e}):"—"})]}),p.jsxs("div",{className:"card-body",style:{padding:0},children:[t.error&&p.jsx("div",{className:"text-xs",style:{padding:12,color:"var(--red-fg)"},children:t.error}),e&&e.compileFailed&&p.jsx("div",{className:"text-xs",style:{padding:12,color:"var(--red-fg)"},children:"Template compile failed — see error below."}),e&&p.jsxs("div",{style:{maxHeight:360,overflow:"auto"},children:[e.errors.map(n=>p.jsx(Eu,{issue:n},`e-${n.rule}`)),e.warnings.map(n=>p.jsx(Eu,{issue:n},`w-${n.rule}`)),e.infos.map(n=>p.jsx(Eu,{issue:n},`n-${n.rule}`)),e.errors.length===0&&e.warnings.length===0&&e.infos.length===0&&p.jsx("div",{className:"text-xs subtle",style:{padding:12},children:"No issues."})]})]})]})}function Eu({issue:t}){const e=t.severity==="error"?"var(--red-fg)":t.severity==="warning"?"var(--amber-fg)":"var(--fg-muted)";return p.jsxs("div",{style:{padding:"8px 12px",borderTop:"1px solid var(--border)",display:"grid",gap:4},children:[p.jsxs("div",{className:"text-xs",style:{color:e,fontWeight:500},children:[t.severity.toUpperCase()," · ",t.rule]}),p.jsx("div",{className:"text-xs",children:t.message}),t.hint&&p.jsx("div",{className:"text-xs subtle",children:t.hint})]})}function LH({slug:t,refetchTemplate:e}){const{data:n,refetch:r}=Df(()=>Jt.mailTesterStatus(t),[t]),[i,s]=G.useState(!1),[o,a]=G.useState(null),[l,c]=G.useState(null),[d,u]=G.useState(null),f=G.useRef(r),h=G.useRef(e);f.current=r,h.current=e,G.useEffect(()=>{if(!o)return;let w=!1,E=0;const v=30,S=setInterval(async()=>{E++;try{const k=await Jt.fetchMailTesterResult(t,o.checkId);if(w)return;k.status==="ready"&&k.score?(u(k.score),a(null),s(!1),f.current(),h.current()):E>=v&&(c("Timed out waiting for Mail-Tester to score the message. It may still be processing — refresh to check."),a(null),s(!1))}catch(k){if(w)return;c(String((k==null?void 0:k.message)??k)),a(null),s(!1)}},3e3);return()=>{w=!0,clearInterval(S)}},[o,t]);async function m(){s(!0),c(null),u(null);try{const w=await Jt.startMailTesterCheck(t);if(w.status==="ready"&&w.score){u(w.score),s(!1),r();return}w.checkId&&w.contentKey?a({checkId:w.checkId,contentKey:w.contentKey}):(c("Unexpected response from server."),s(!1))}catch(w){c(String((w==null?void 0:w.message)??w)),s(!1)}}const g=d??(n==null?void 0:n.score)??null,y=(n==null?void 0:n.minScore)??8,b=g!=null&&g.score<y;return p.jsxs("div",{className:"card",children:[p.jsxs("div",{className:"card-head",children:[p.jsx("span",{className:"card-title",children:"Deliverability check"}),p.jsx("span",{className:"card-sub",children:n?n.configured?g?`Cached for ${n.cacheHours}h after each check`:"Run a Mail-Tester check before publishing":"Mail-Tester not configured":"Loading…"}),(n==null?void 0:n.configured)&&p.jsx("div",{className:"card-actions",children:p.jsx("button",{className:"btn btn-xs",disabled:i,onClick:m,children:i?o?"Waiting for score…":"Sending…":g?"Re-run check":"Run check"})})]}),p.jsxs("div",{className:"card-body",style:{display:"grid",gap:10},children:[!(n!=null&&n.configured)&&p.jsxs("div",{className:"text-xs subtle",children:["Set ",p.jsx("code",{children:"mailer.config.mailTester.apiKey"})," to enable. Mail-Tester runs SpamAssassin + DNS auth checks + content red-flag scoring against a real receipt of this template."]}),l&&p.jsx("div",{className:"text-xs",style:{color:"var(--red-fg)"},children:l}),g&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"hstack",style:{gap:16,alignItems:"baseline"},children:[p.jsxs("div",{children:[p.jsx("div",{className:"text-xs subtle",children:"Score"}),p.jsxs("div",{style:{fontSize:28,fontWeight:600,color:b?"var(--red-fg)":g.score>=9?"var(--green-fg)":"var(--amber-fg)"},children:[g.score.toFixed(1)," ",p.jsx("span",{className:"text-xs subtle",children:"/ 10"})]})]}),p.jsxs("div",{children:[p.jsx("div",{className:"text-xs subtle",children:"Threshold"}),p.jsx("div",{className:"text-sm mono",children:y.toFixed(1)})]}),p.jsxs("div",{children:[p.jsx("div",{className:"text-xs subtle",children:"Checked"}),p.jsx("div",{className:"text-xs",children:new Date(g.fetchedAt).toLocaleString()})]})]}),b&&p.jsxs("div",{className:"text-xs",style:{color:"var(--red-fg)"},children:["Score below threshold — publish will be blocked. Address the feedback below or override with ",p.jsx("code",{children:"bypassMailTester: true"})," on the publish call."]}),g.feedback.length>0&&p.jsxs("div",{style:{display:"grid",gap:6,marginTop:4},children:[g.feedback.slice(0,12).map((w,E)=>p.jsxs("div",{className:"text-xs",style:{display:"grid",gap:2},children:[p.jsxs("div",{style:{color:w.severity==="error"?"var(--red-fg)":w.severity==="warning"?"var(--amber-fg)":"var(--fg-muted)",fontWeight:500},children:[w.severity.toUpperCase()," · ",w.category]}),p.jsx("div",{children:w.message})]},E)),g.feedback.length>12&&p.jsxs("div",{className:"text-xs subtle",children:["+ ",g.feedback.length-12," more items in raw report"]})]})]})]})]})}function ku({title:t,onClose:e,children:n}){const r=G.useId(),i=G.useRef(null);return G.useEffect(()=>{var a;const s=i.current;function o(l){if(l.key==="Escape"){e();return}if(l.key!=="Tab"||!s)return;const c=s.querySelectorAll('a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])');if(c.length===0)return;const d=c[0],u=c[c.length-1],f=document.activeElement;l.shiftKey&&(f===d||!s.contains(f))?(l.preventDefault(),u.focus()):!l.shiftKey&&f===u&&(l.preventDefault(),d.focus())}return document.addEventListener("keydown",o),(a=i.current)==null||a.focus(),()=>document.removeEventListener("keydown",o)},[e]),p.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":r,onClick:e,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.45)",display:"grid",placeItems:"center",zIndex:50},children:p.jsxs("div",{ref:i,tabIndex:-1,onClick:s=>s.stopPropagation(),className:"card",style:{width:"min(680px, 90vw)",maxHeight:"85vh",overflow:"auto",padding:0},children:[p.jsxs("div",{className:"card-head",children:[p.jsx("span",{className:"card-title",id:r,children:t}),p.jsx("span",{className:"grow"}),p.jsx("button",{className:"icon-btn","aria-label":"Close",onClick:e,children:p.jsx(Va.X,{size:14})})]}),p.jsx("div",{className:"card-body",children:n})]})})}export{KH as TemplateEditor};
|
|
502
|
-
//# sourceMappingURL=template-editor-
|
|
501
|
+
`),c.adoptedStyleSheets=[d];const u=document.createElement("div");u.innerHTML=o,c.appendChild(u)},contentEditable:!1,onClick:()=>{a&&n({activeTab:"code"})}})]})}var YF=q5.extend({addStorage(){return{colors:new Set}}}),JF=["ltr","rtl"],un="ltr",XF=ap.extend({addAttributes(){var t;return ce(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:et,parseHTML:e=>e.getAttribute("data-show-if-key")||et,renderHTML(e){return e.showIfKey?{"data-show-if-key":e.showIfKey}:{}}}})},addCommands(){var t;return ce(z({},(t=this.parent)==null?void 0:t.call(this)),{setTextDirection:e=>({commands:n})=>n.updateAttributes(this.name,{textDirection:e})})}}),nb=Je.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",Ie(this.options.HTMLAttributes,t,{class:"footer mly:block mly:text-[13px] mly:text-slate-500 mly:relative"}),0]}}),ZF=hj.extend({addAttributes(){var t;return ce(z({},(t=this.parent)==null?void 0:t.call(this)),{isUrlVariable:{default:!1}})},addCommands(){var t;return ce(z({},(t=this.parent)==null?void 0:t.call(this)),{setIsUrlVariable:e=>({chain:n})=>n().setMark("link",{isUrlVariable:e}).run()})}}),QF=op.extend({addAttributes(){var t;return ce(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:et,parseHTML:e=>e.getAttribute("data-show-if-key")||et,renderHTML(e){return e.showIfKey?{"data-show-if-key":e.showIfKey}:{}}}})}});function eH(t){const{editor:e,getPos:n}=t;return p.jsxs(yi,{"data-type":"repeat",draggable:e.isEditable,"data-drag-handle":e.isEditable,className:"mly:relative",children:[p.jsx(bv,{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(kx,{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 rk=Je.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:et,parseHTML:t=>t.getAttribute("data-show-if-key")||et,renderHTML(t){return t.showIfKey?{"data-show-if-key":t.showIfKey}:{}}}}},parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML({HTMLAttributes:t}){return["div",Ie(t,{"data-type":this.name}),0]},addCommands(){return{setRepeat:()=>({commands:t})=>t.insertContent({type:this.name,attrs:{},content:[{type:"paragraph"}]}),updateRepeat:t=>Ms(this.name,t)}},addNodeView(){return bi(eH,{contentDOMElementTag:"div",className:"mly:relative"})}}),tH=We.create({name:"maily-kit",addOptions(){return{link:{HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:"mly:no-underline"},openOnClick:!1}}},addExtensions(){const t=[Z1.extend({content:"(block|columns)+"}),j$.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}),H$,YF.configure({types:[xy.name,sE.name]}),xy.configure(),F$.configure({types:[ap.name,op.name,nb.name]}),JE,nb,z$,Q1.configure({color:"#555",width:3,class:"ProseMirror-dropcursor"}),QF.configure({levels:[1,2,3],HTMLAttributes:{class:"mly:relative"}}),XF.configure({HTMLAttributes:{class:"mly:relative"}})];return this.options.linkCard!==!1&&t.push(ek.configure(this.options.linkCard)),this.options.repeat!==!1&&t.push(rk),this.options.section!==!1&&t.push(jE),this.options.columns!==!1&&t.push(YE),this.options.column!==!1&&t.push(yE),this.options.button!==!1&&t.push(tk),this.options.spacer!==!1&&t.push(ZE),this.options.logo!==!1&&t.push(UE),this.options.image!==!1&&t.push(nk),this.options.link!==!1&&t.push(ZF.configure(this.options.link)),t}}),nH=pj.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}),rH=We.create({name:"slash-command",addOptions(){return{suggestion:{char:"/",command:({editor:t,range:e,props:n})=>{n.command({editor:t,range:e})}}}},addProseMirrorPlugins(){return[n1(z({editor:this.editor},this.options.suggestion))]}});function iH(t){var e;const{item:n,groupIndex:r,commandIndex:i,selectedGroupIndex:s,selectedCommandIndex:o,editor:a,activeCommandRef:l,selectItem:c,hoveredItemKey:d,onHover:u}=t,[f,h]=x.useState(!1),m=r===s&&i===o,g=`${r}-${i}`,y=d===g,b=n&&"commands"in n,w=!!(n!=null&&n.preview)&&(y||m&&!d),v=typeof n.render=="function"?(e=n.render)==null?void 0:e.call(n,a):null;let S=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(GR,{className:"mly:size-3.5 mly:stroke-[2.5]"})})]});v!==null&&v!==!0&&(S=v);const k=x.useRef(0),C=x.useCallback(()=>{window.clearTimeout(k.current);const T=200;k.current=window.setTimeout(()=>{h(!0),k.current=0},T)},[h]);return x.useEffect(()=>{w?C():(window.clearTimeout(k.current),k.current=0,h(!1))},[w]),x.useEffect(()=>()=>{k.current&&(window.clearTimeout(k.current),k.current=0)},[]),p.jsxs(Tt,{open:f,children:[p.jsx(At,{asChild:!0,children:p.jsx("button",{className:xe("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:()=>u(!0),onMouseLeave:()=>u(!1),type:"button",ref:m?l:null,children:S})}),p.jsx(Et,{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 sH(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,d=oH(e,c);if(d){const u=s.slice(l.length),f=d.commands.filter(h=>!u||ol(h,u));return f.length?[ce(z({},d),{commands:f})]:[]}}return i.map(l=>ce(z({},l),{commands:l.commands.flatMap(c=>lH({item:c,search:s,editor:r}))})).filter(l=>l.commands.length>0)}function oH(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 wu(t,e){return t?t.toLowerCase().includes(e.toLowerCase()):!1}function ol(t,e){var n,r;return wu(t.title,e)||wu(t.description,e)||((r=(n=t.searchTerms)==null?void 0:n.some(i=>wu(i,e)))!=null?r:!1)}function aH(t){return"commands"in t&&Array.isArray(t.commands)&&!!t.id}function lH(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(aH(s)){const d=ce(z({},s),{command:h=>{const{editor:m,range:g}=h;m.chain().focus().insertContentAt(g,`/${s.id}.`).run()}});return ol(d,o)?[d]:((r=(n=d==null?void 0:d.commands)==null?void 0:n.some(h=>ol(h,o)))!=null?r:!1)?(i=d==null?void 0:d.commands)!=null?i:[]:[]}return!c||ol(s,o)?[s]:[]}var cH=x.forwardRef((t,e)=>{const{items:n,command:r,editor:i,range:s,query:o}=t,[a,l]=x.useState(0),[c,d]=x.useState(0),[u,f]=x.useState(null),h=x.useRef(""),m=x.useRef(0),g=x.useRef(0),y=x.useCallback((E,v)=>{const S=n[E].commands[v];S&&r(S)},[r]);x.useImperativeHandle(e,()=>({onKeyDown:({event:E})=>{var v,S,k,C;if(["ArrowUp","ArrowDown","Enter","ArrowLeft","ArrowRight"].includes(E.key)){let M=c,D=a;switch(E.key){case"ArrowLeft":E.preventDefault();const B=n==null?void 0:n[a];return B&&"id"in B?(i.chain().focus().insertContentAt(s,`/${h.current}`).run(),setTimeout(()=>{l(m.current),d(g.current)},0),!0):!1;case"ArrowRight":E.preventDefault();const F=(S=(v=n==null?void 0:n[a])==null?void 0:v.commands)==null?void 0:S[c];return F&&"commands"in F?(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,D=a,M<0&&(D=a-1,M=((k=n[D])==null?void 0:k.commands.length)-1||0),D<0&&(D=n.length-1,M=((C=n[D])==null?void 0:C.commands.length)-1||0),l(D),d(M),!0):!1;case"ArrowDown":if(!n.length)return!1;const J=n[a].commands;return M=c+1,D=a,J.length-1<M&&(M=0,D=a+1),n.length-1<D&&(D=0),l(D),d(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:S,offsetHeight:k}=v;E.style.transition="none",E.scrollTop=S-k},[a,c,b,w]),x.useEffect(()=>{l(0),d(0)},[n]),x.useEffect(()=>()=>{h.current="",m.current=0,g.current=0},[]),!n||n.length===0?null:p.jsx(Kt,{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:xe("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((S,k)=>{const C=`${v}-${k}`;return p.jsx(iH,{item:S,groupIndex:v,commandIndex:k,selectedGroupIndex:a,selectedCommandIndex:c,selectItem:()=>y(v,k),editor:i,activeCommandRef:w,hoveredItemKey:u,onHover:T=>f(T?C:null)},C)})})]},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 dH(t=vp){return{items:({query:e,editor:n})=>sH({query:e,editor:n,groups:t}),allow:({editor:e})=>!e.isActive("htmlCodeBlock"),render:()=>{let e,n=null;return{onStart:r=>{e=new hh(cH,{props:r,editor:r.editor}),n=$r("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 ik=x.forwardRef((t,e)=>{var n;const{items:r=[],editor:i}=t,s=x.useRef(null),o=(n=wi(i))==null?void 0:n.variableSuggestionsPopover;return x.useImperativeHandle(e,()=>({onKeyDown:({event:a})=>{if(!s.current)return!1;const{moveUp:l,moveDown:c,select:d}=s.current||{};return a.key==="ArrowUp"?(a.preventDefault(),l(),!0):a.key==="ArrowDown"?(a.preventDefault(),c(),!0):a.key==="Enter"?(d(),!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})});ik.displayName="VariableList";function uH(t=xp){return{char:t,items:({query:e,editor:n})=>{var r;const i=(r=ME(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 hh(ik,{props:r,editor:r.editor}),r.clientRect&&(n=$r("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 sk=K5(Y4);sk.register("html",E1);var ok=A3.extend({name:"htmlCodeBlock",content:"(text|variable)*",addAttributes(){var t;return ce(z({},(t=this.parent)==null?void 0:t.call(this)),{activeTab:"code",showIfKey:{default:et,parseHTML:e=>e.getAttribute("data-show-if-key")||et,renderHTML(e){return e.showIfKey?{"data-show-if-key":e.showIfKey}:{}}}})},addNodeView(){return bi(qF,{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=>Ms(this.name,t)}},addKeyboardShortcuts(){var t;return ce(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 d=s;d>0;d--)if(r.node(d).type.name===this.name){s=d;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 d=e.state.tr.setSelection(me.between(l,c));return e.view.dispatch(d),!0}return!1}})}}).configure({lowlight:sk}),fH=(t,e)=>[JE.name,Yh.name,ZE.name,nk.name,GE.name,ek.name,UE.name,tk.name,ok.name,qE.name].some(r=>t.isActive(r));function hH(t){return p.jsxs("svg",ce(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 pH(t){return p.jsxs("svg",ce(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 mH(t){const{direction:e,onDirectionChange:n}=t,r=JF.includes(e)?e:"ltr",i={ltr:{icon:hH,tooltip:"Left to Right",onClick:()=>{n("ltr")}},rtl:{icon:pH,tooltip:"Right to Left",onClick:()=>{n("rtl")}}},s=i[r];return p.jsxs(sn,{children:[p.jsxs(Tt,{children:[p.jsx(At,{asChild:!0,children:p.jsx(on,{className:xe("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(Et,{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(dn,{icon:a.icon,tooltip:a.tooltip,command:a.onClick,isActive:()=>o===r},o))})]})}var gH="#374151",yH=t=>Dn({editor:t,selector:n=>{var r,i,s,o,a,l,c,d,u,f,h,m;return{currentTextColor:n.editor.getAttributes("textStyle").color||gH,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)||((d=n.editor.getAttributes("footer"))==null?void 0:d.textDirection)||un,isFooterActive:n.editor.isActive("footer"),footerTextDirection:((u=n.editor.getAttributes("footer"))==null?void 0:u.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:jr});function ak(t){var e,n,r,i;const{editor:s,showListMenu:o=!0}=t,a=yH(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:[],d=[{name:"bold",isActive:()=>s==null?void 0:s.isActive("bold"),command:()=>s==null?void 0:s.chain().focus().toggleBold().run(),icon:dx,tooltip:"Bold"},{name:"italic",isActive:()=>s==null?void 0:s.isActive("italic"),command:()=>s==null?void 0:s.chain().focus().toggleItalic().run(),icon:xx,tooltip:"Italic"},{name:"underline",isActive:()=>s==null?void 0:s.isActive("underline"),command:()=>s==null?void 0:s.chain().focus().toggleUnderline().run(),icon:_x,tooltip:"Underline"},{name:"strike",isActive:()=>s==null?void 0:s.isActive("strike"),command:()=>s==null?void 0:s.chain().focus().toggleStrike().run(),icon:Sx,tooltip:"Strikethrough"},{name:"code",isActive:()=>s==null?void 0:s.isActive("code"),command:()=>s==null?void 0:s.chain().focus().toggleCode().run(),icon:ZR,tooltip:"Code"}];return p.jsxs(p.Fragment,{children:[d.map((u,f)=>p.jsx(dn,z({},u),f)),p.jsx(cd,{alignment:a.textAlign,onAlignmentChange:u=>{s==null||s.chain().focus().setTextAlign(u).run()}}),p.jsx(mH,{direction:a.textDirection,onDirectionChange:u=>{a.isFooterActive?s==null||s.chain().focus().setFooterTextDirection(u).run():a.isHeadingActive?s==null||s.chain().focus().updateAttributes("heading",{textDirection:u}).run():s==null||s.chain().focus().setTextDirection(u).run()}}),!a.isListActive&&o&&p.jsxs(p.Fragment,{children:[p.jsx(dn,{icon:Oh,command:()=>{s.chain().focus().toggleBulletList().run()},tooltip:"Bullet List"}),p.jsx(dn,{icon:Mh,command:()=>{s.chain().focus().toggleOrderedList().run()},tooltip:"Ordered List"})]}),p.jsx(xs,{defaultValue:(i=a==null?void 0:a.linkUrl)!=null?i:"",onValueChange:(u,f)=>{if(!u){s==null||s.chain().focus().extendMarkRange("link").unsetLink().unsetUnderline().run();return}s==null||s.chain().extendMarkRange("link").setLink({href:u}).setIsUrlVariable(f??!1).setUnderline().run()},tooltip:"External URL",editor:s,isVariable:a.isUrlVariable}),p.jsx(Ue,{}),p.jsx(Uo,{color:a.currentTextColor,onColorChange:u=>{s==null||s.chain().setColor(u).run()},tooltip:"Text Color",suggestedColors:c,children:p.jsx(Dt,{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 bH=t=>t.type==="option",vH=t=>t.type==="category";function xH(t){const{options:e}=t,n=x.useMemo(()=>e.find(i=>i.type==="option"&&i.isActive()),[e]),{icon:r=wx}=n||{};return p.jsxs(sn,{children:[p.jsxs(Tt,{children:[p.jsx(At,{asChild:!0,children:p.jsxs(on,{className:xe("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(ux,{className:"mly:h-3 mly:w-3 mly:shrink-0 mly:stroke-[2.5]"})]})}),p.jsx(Et,{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(bH(i))return p.jsxs(Dt,{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(vH(i))return p.jsx("label",{className:xe("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 wH(t){return Dn({editor:t,selector:({editor:e})=>[{type:"category",label:"Hierarchy",id:"hierarchy"},{icon:wx,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:Th,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:gx,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:yx,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:Nh,onClick:()=>{e.chain().focus().liftListItem("listItem").setFooter().run()},disabled:()=>!e.can().setFooter(),isActive:()=>e.isActive("footer")},{type:"category",label:"Lists",id:"lists"},{icon:Oh,onClick:()=>e.chain().focus().toggleBulletList().run(),id:"bulletList",disabled:()=>!e.can().toggleBulletList(),isActive:()=>e.isActive("bulletList"),label:"Bullet list",type:"option"},{icon:Mh,onClick:()=>e.chain().focus().toggleOrderedList().run(),id:"orderedList",disabled:()=>!e.can().toggleOrderedList(),isActive:()=>e.isActive("orderedList"),label:"Numbered list",type:"option"}]})}function EH(t){const{editor:e,appendTo:n}=t;if(!e)return null;const r=ce(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,u=a.nodeDOM(o||0)||c;if(fH(s)||!s.isEditable)return!1;const h=[rk.name,jE.name,YE.name,yE.name].some(m=>s.isActive(m))&&((l=u==null?void 0:u.classList)==null?void 0:l.contains("ProseMirror-selectednode"));return ld(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=wH(e);return p.jsx(rr,ce(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(Kt,{children:[p.jsx(xH,{options:i}),p.jsx(Ue,{className:"mly:mx-0"}),p.jsx(ak,{editor:e})]})}))}function kH(t){const{editor:e,appendTo:n}=t;if(!e)return null;const r=ce(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:[gi],sticky:"popper",maxWidth:"100%",appendTo:()=>(n==null?void 0:n.current)||"parent",placement:"top-start"}});return p.jsx(rr,ce(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(Kt,{children:p.jsx(ak,{showListMenu:!1,editor:e})})}))}var SH=We.create({name:"selection",addProseMirrorPlugins(){const{editor:t}=this;return[new $e({key:new Be("selection"),props:{decorations(e){return e.selection.empty||t.isFocused===!0?null:ze.create(e.doc,[mt.inline(e.selection.from,e.selection.to,{class:"selection mly:bg-blue-200 mly:inline mly:py-1"})])}}})]}});function CH(t){const{blocks:e,extensions:n=[]}=t;return[...[tH,rH.configure({suggestion:dH(e)}),GE.configure({suggestion:uH()}),ok,qE,nH,SH].filter(i=>!n.some(s=>s.name===i.name)),...n]}function rb(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)||XE),i.attrs=ce(z({},i.attrs),{height:s})}i.content&&r.push(...i.content)}}return t}function _H(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:d,extensions:u,contentHtml:f,contentJson:h,blocks:m=vp,editable:g=!0,placeholderUrl:y=dd,scrollThreshold:b=40,scrollMargin:w=40}=t,E=x.useMemo(()=>{if(h){const k=(h==null?void 0:h.type)==="doc"?h:{type:"doc",content:h};return rb(k)}else return f||{type:"doc",content:[{type:"paragraph",content:[]}]}},[f,h,rb]),v=x.useRef(null),S=aM({editorProps:{scrollThreshold:b,scrollMargin:w,attributes:{class:xe("mly:prose mly:w-full",n),spellCheck:o?"true":"false"}},immediatelyRender:l,onCreate:({editor:k})=>{c==null||c(k)},onUpdate:({editor:k})=>{d==null||d(k)},extensions:CH({extensions:u,blocks:m}),content:E,autofocus:a,editable:g});return S?p.jsx(pF,{placeholderUrl:y,children:p.jsxs("div",{id:"mly-editor",className:xe("mly-editor mly:antialiased",S.isEditable?"mly-editable":"mly-not-editable",e),ref:v,children:[i&&p.jsx(g9,{config:t.config,editor:S}),p.jsxs("div",{className:xe("mly:mt-4 mly:rounded mly:border mly:border-gray-200 mly:bg-white mly:p-4",r),children:[p.jsx(EH,{editor:S,appendTo:v}),p.jsx(EF,{editor:S,appendTo:v}),p.jsx(IF,{editor:S,appendTo:v}),p.jsx(ZA,{editor:S}),p.jsx(OF,{editor:S,appendTo:v}),p.jsx(l9,{editor:S,appendTo:v}),!s&&p.jsx(m9,{editor:S}),p.jsx(kH,{editor:S,appendTo:v}),p.jsx(_F,{editor:S,appendTo:v}),p.jsx(b9,{editor:S,appendTo:v}),p.jsx(SF,{editor:S,appendTo:v})]})]})}):null}function ib({value:t,onChange:e,paths:n,className:r,placeholder:i}){const s=G.useRef(null),[o,a]=G.useState(null),l=G.useMemo(()=>{if(!o)return[];const f=o.query.toLowerCase();return n.filter(h=>h.path.toLowerCase().includes(f)).slice(0,8)},[o,n]);function c(f,h){if(e(f),h==null){a(null);return}const m=f.slice(0,h),g=m.lastIndexOf("{{");if(g===-1||m.slice(g).includes("}}")){a(null);return}const y=m.slice(g+2).trimStart();if(/[{}]/.test(y)){a(null);return}a({anchor:g,query:y,selected:0})}function d(f){if(!o)return;const h=s.current,m=(h==null?void 0:h.selectionStart)??t.length,g=t.slice(0,o.anchor),y=t.slice(m),b=`{{${f.path}}}`,w=`${g}${b}${y}`;e(w),a(null),requestAnimationFrame(()=>{const E=g.length+b.length;h==null||h.setSelectionRange(E,E),h==null||h.focus()})}function u(f){!o||l.length===0||(f.key==="ArrowDown"?(f.preventDefault(),a({...o,selected:(o.selected+1)%l.length})):f.key==="ArrowUp"?(f.preventDefault(),a({...o,selected:(o.selected-1+l.length)%l.length})):f.key==="Enter"||f.key==="Tab"?(f.preventDefault(),d(l[Math.min(o.selected,l.length-1)])):f.key==="Escape"&&(f.preventDefault(),a(null)))}return p.jsxs("div",{style:{position:"relative"},children:[p.jsx("input",{ref:s,className:r??"input",value:t,placeholder:i,onChange:f=>c(f.target.value,f.target.selectionStart),onKeyDown:u,onBlur:()=>setTimeout(()=>a(null),150),onClick:f=>c(t,f.target.selectionStart)}),o&&l.length>0&&p.jsx("div",{className:"card",role:"listbox",style:{position:"absolute",top:"100%",left:0,right:0,zIndex:40,marginTop:4,maxHeight:240,overflow:"auto",padding:4,boxShadow:"0 8px 24px rgba(0,0,0,0.18)"},children:l.map((f,h)=>p.jsxs("div",{role:"option","aria-selected":h===o.selected,onMouseDown:m=>{m.preventDefault(),d(f)},onMouseEnter:()=>a({...o,selected:h}),style:{display:"flex",justifyContent:"space-between",gap:12,padding:"6px 8px",borderRadius:4,cursor:"pointer",background:h===o.selected?"var(--bg-sunken)":"transparent"},children:[p.jsx("span",{className:"mono text-xs",children:`{{${f.path}}}`}),p.jsx("span",{className:"text-xs subtle",children:f.type})]},f.path))})]})}const NH=[{path:"unsubscribeUrl",type:"string",description:"One-click unsubscribe link (required in marketing templates)"},{path:"event",type:"object",description:"Properties of the event that triggered the flow run, e.g. event.accountId"},{path:"senderAddress",type:"string",description:"Configured postal address (CAN-SPAM)"},{path:"contact.email",type:"string"},{path:"contact.externalId",type:"string"},{path:"contact.timezone",type:"string"},{path:"contact.locale",type:"string"}],TH=5;function AH(t){if(!t)return[];const e=[];return Of(t,"",e,0),e}function Of(t,e,n,r){if(!t||typeof t!="object"||r>TH)return;const i=t,s=i.anyOf??i.oneOf;if(Array.isArray(s)){const o=s.some(c=>c&&c.type==="null"),a=s.find(c=>c&&(c.type==="object"||c.properties));if(a){e&&n.push({path:e,type:o?"object | null":"object",description:i.description}),Of(a,e,n,r);return}const l=s.map(c=>al(c)).filter(Boolean);e&&n.push({path:e,type:Array.from(new Set(l)).join(" | "),description:i.description});return}if(i.type==="object"||i.properties){if(e&&!i.properties){n.push({path:e,type:"object",description:i.description});return}for(const[o,a]of Object.entries(i.properties??{})){const l=e?`${e}.${o}`:o,c=a;c&&(c.type==="object"||c.properties||Array.isArray(c.anyOf??c.oneOf))?Of(c,l,n,r+1):n.push({path:l,type:al(c),description:c==null?void 0:c.description})}return}e&&n.push({path:e,type:al(i),description:i.description})}function al(t){if(!t||typeof t!="object")return"unknown";if(t.type==="array"){const e=al(t.items);return e==="unknown"?"array":`${e}[]`}return Array.isArray(t.type)?t.type.join(" | "):t.enum?t.enum.map(e=>JSON.stringify(e)).join(" | "):typeof t.type=="string"?t.type:"unknown"}const MH={type:"doc",content:[{type:"paragraph"}]};function KH({slug:t}){const{data:e,loading:n,error:r,refetch:i}=Df(()=>Jt.template(t),[t]);return p.jsx(fk,{loading:n&&!e,error:r,empty:!e,emptyLabel:"Template not found.",retry:i,children:e&&p.jsx(OH,{tpl:e,slug:t,refetch:i})})}function OH({tpl:t,slug:e,refetch:n}){var V,O,L,Y,pe,Oe,bt,or,R,re,ge;const[r,i]=G.useState("design"),[s,o]=G.useState(MH),[a,l]=G.useState(((V=t.draft)==null?void 0:V.subject)??t.subject??""),[c,d]=G.useState(((O=t.draft)==null?void 0:O.preheader)??t.preheader??""),[u,f]=G.useState(((L=t.draft)==null?void 0:L.fromName)??t.fromName??""),[h,m]=G.useState(((Y=t.draft)==null?void 0:Y.fromEmail)??t.fromEmail??""),[g,y]=G.useState(((pe=t.draft)==null?void 0:pe.replyTo)??t.replyTo??""),[b,w]=G.useState(!1),[E,v]=G.useState(""),[S,k]=G.useState(!1),C=G.useRef(null),T=G.useRef(!1),[M,D]=G.useState(!1),{data:B}=Df(()=>Jt.varsSchema(),[]),$=G.useMemo(()=>[...AH((B==null?void 0:B.schema)??null),...NH],[B]),[F,q]=G.useState(null),[J,A]=G.useState(null),[N,_]=G.useState([]),[I,j]=G.useState(void 0),[U,ne]=G.useState(null),[ae,W]=G.useState(!1),[Z,ye]=G.useState(!1),[he,Re]=G.useState(""),[_e,Se]=G.useState(null),[Me,Te]=G.useState(!1);async function Ce(K){W(!0);try{const le=await Jt.previewTemplate(e,{useDraft:!0,contactId:K});q(le),A(null)}catch(le){A(String((le==null?void 0:le.message)??le))}finally{W(!1)}}async function Ke(){A(null),v("Generating preview…");try{let K=N;if(K.length===0){const le=await Jt.contacts();K=le.contacts,_(le.contacts),j(le.nextCursor)}K.length>0?(ne(0),await Ce(String(K[0].externalId))):(ne(null),await Ce()),v("")}catch(K){A(String((K==null?void 0:K.message)??K)),v("")}}const Ae=G.useCallback(async K=>{if(ae||K<0)return;let le=N;if(K>=le.length){if(!I)return;const Xe=await Jt.contacts(I);if(le=[...le,...Xe.contacts],_(le),j(Xe.nextCursor),K>=le.length)return}ne(K),await Ce(String(le[K].externalId))},[ae,N,I,e]);G.useEffect(()=>{if(!F||U==null)return;function K(le){le.key==="ArrowRight"?(le.preventDefault(),Ae(U+1)):le.key==="ArrowLeft"&&(le.preventDefault(),Ae(U-1))}return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[F,U,Ae]);async function fe(){if(!(!he.trim()||Me)){Te(!0),Se("Sending…");try{const K=U!=null&&N[U]?String(N[U].externalId):void 0;await Jt.sendTestTemplate(e,{to:he.trim(),contactId:K}),Se(`Sent test to ${he.trim()}`)}catch(K){Se(`Failed: ${(K==null?void 0:K.message)??K}`)}finally{Te(!1)}}}const je=t.kind??"marketing",Q=t.name??e,se=t.slug??e,Ne=((Oe=t.body)==null?void 0:Oe.mjml)??((bt=t.draft)==null?void 0:bt.mjml)??"",ue=((or=t.body)==null?void 0:or.plainText)??"",be=RH(e,{subject:a,preheader:c,editorJson:M?s:null,fromEmail:h||t.fromEmail,kind:je}),Ge=(((R=be.data)==null?void 0:R.errors.length)??0)>0;G.useEffect(()=>{var le,Xe;if(T.current)return;T.current=!0;const K=((le=t.draft)==null?void 0:le.editorJson)??((Xe=t.body)==null?void 0:Xe.editorJson);K&&(o(K),D(!0))},[t]);async function nt(){v("Saving draft…"),await Jt.updateTemplateDraft(e,{subject:a,preheader:c,...M?{editorJson:s}:Ne?{mjml:Ne}:{},fromName:u||void 0,fromEmail:h||void 0,replyTo:g||void 0})}async function Mt(){k(!0);try{await nt(),v("Publishing…");const K=await Jt.publishTemplate(e);v(`Published v${K.version}`),w(!1),n()}catch(K){v(`Error: ${(K==null?void 0:K.message)??String(K)}`)}finally{k(!1)}}return p.jsxs(p.Fragment,{children:[p.jsx(hk,{title:Q,desc:p.jsxs(p.Fragment,{children:[p.jsxs("span",{className:"mono",children:["templates/",se]})," · ",p.jsx("span",{className:"pill "+(je==="transactional"?"blue":"neutral"),style:{marginLeft:4},children:je})]}),actions:p.jsxs(p.Fragment,{children:[p.jsxs("button",{className:"btn",onClick:Ke,children:[p.jsx(Va.Eye,{size:14}),"Preview"]}),p.jsxs("button",{className:"btn",onClick:()=>{ye(!0),Se(null)},children:[p.jsx(Va.Send,{size:14}),"Test send"]}),p.jsxs("button",{className:"btn btn-primary",disabled:S||Ge,onClick:Mt,title:Ge?"Resolve content-lint errors before publishing.":void 0,children:[p.jsx(Va.Rocket,{size:14}),"Publish"]}),be.data&&p.jsx("span",{className:"text-xs subtle",style:{marginLeft:8},children:p.jsx(lk,{data:be.data})}),E&&p.jsx("span",{className:"text-xs subtle",style:{marginLeft:8},children:E})]})}),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"+(r==="design"?" active":""),onClick:()=>i("design"),children:"Design"}),p.jsx("span",{className:"seg-item"+(r==="source"?" active":""),onClick:()=>i("source"),children:"MJML"}),p.jsx("span",{className:"seg-item"+(r==="plaintext"?" active":""),onClick:()=>i("plaintext"),children:"Plain text"})]}),p.jsx("div",{className:"card-actions",children:p.jsx("span",{className:"text-xs subtle",children:b?"Unsaved changes":E.startsWith("Published")||E==="Saved"?E:""})})]}),p.jsxs("div",{style:{padding:16},children:[p.jsxs("div",{className:"field",children:[p.jsx("label",{className:"field-label",children:"Subject"}),p.jsx(ib,{value:a,paths:$,onChange:K=>{l(K),w(!0)}})]}),p.jsxs("div",{className:"field",children:[p.jsx("label",{className:"field-label",children:"Preheader"}),p.jsx(ib,{value:c,paths:$,onChange:K=>{d(K),w(!0)}})]})]}),r==="design"&&p.jsx("div",{className:"maily-host",style:{padding:16,background:"var(--bg-sunken)",minHeight:480},children:p.jsx(_H,{contentJson:s,onCreate:K=>{C.current=K},onUpdate:K=>{C.current=K,o(K.getJSON()),D(!0),w(!0)},config:{hasMenuBar:!0,contentClassName:"mly-content",wrapClassName:"mly-wrap",bodyClassName:"mly-body",spellCheck:!0}})}),r==="source"&&p.jsx("pre",{className:"code",style:{margin:16,padding:16,maxHeight:520,overflow:"auto",whiteSpace:"pre-wrap"},children:Ne||"/* No MJML stored for this template (Maily-authored). Switch to Design to edit. */"}),r==="plaintext"&&p.jsx("pre",{className:"code",style:{margin:16,padding:16,maxHeight:520,overflow:"auto",whiteSpace:"pre-wrap"},children:ue||"/* Plain text is auto-derived on publish. */"})]}),p.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[p.jsx(DH,{lint:be}),p.jsx(IH,{paths:$,hasSchema:!!(B!=null&&B.schema)}),p.jsx(LH,{slug:e,refetchTemplate:n}),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",value:u,placeholder:"(default from mailer config)",onChange:K=>{f(K.target.value),w(!0)}})]}),p.jsxs("div",{className:"field",children:[p.jsx("label",{className:"field-label",children:"From email"}),p.jsx("input",{className:"input",value:h,placeholder:"(default from mailer config)",onChange:K=>{m(K.target.value),w(!0)}})]}),p.jsxs("div",{className:"field",style:{marginBottom:0},children:[p.jsx("label",{className:"field-label",children:"Reply-to"}),p.jsx("input",{className:"input",value:g,placeholder:"(same as From)",onChange:K=>{y(K.target.value),w(!0)}})]})]})]})]})]}),F&&p.jsxs(ku,{onClose:()=>{q(null),ne(null)},title:"Preview",children:[U!=null&&N.length>0&&p.jsxs("div",{className:"hstack",style:{gap:8,alignItems:"center",marginBottom:10},children:[p.jsx("button",{className:"btn btn-xs",disabled:ae||U===0,onClick:()=>Ae(U-1),title:"Previous contact (←)",children:"←"}),p.jsx("span",{className:"text-xs mono",children:((re=F.contact)==null?void 0:re.email)??((ge=N[U])==null?void 0:ge.email)}),p.jsxs("span",{className:"text-xs subtle",children:[U+1," / ",N.length,I?"+":""]}),p.jsx("button",{className:"btn btn-xs",disabled:ae,onClick:()=>Ae(U+1),title:"Next contact (→)",children:"→"}),ae&&p.jsx("span",{className:"text-xs subtle",children:"Rendering…"})]}),p.jsx("div",{className:"text-sm f500",children:F.subject}),p.jsx("div",{className:"text-xs subtle",style:{marginBottom:8},children:F.preheader}),p.jsx("iframe",{title:"preview",sandbox:"",srcDoc:F.html,style:{width:"100%",minHeight:480,border:"1px solid var(--border)",borderRadius:6,background:"#fff"}})]}),J&&p.jsx(ku,{onClose:()=>A(null),title:"Preview failed",children:p.jsx("div",{className:"text-sm",style:{color:"var(--red-fg)"},children:J})}),Z&&p.jsx(ku,{onClose:()=>ye(!1),title:"Send test email",children:p.jsxs("div",{className:"vstack",style:{gap:12},children:[p.jsxs("div",{className:"field",style:{marginBottom:0},children:[p.jsx("label",{className:"field-label",children:"To"}),p.jsx("input",{className:"input",type:"email",placeholder:"you@example.com",value:he,onChange:K=>Re(K.target.value)}),p.jsx("div",{className:"field-hint",children:"Uses the published version (publish first if you want to test recent edits)."})]}),_e&&p.jsx("div",{className:"text-xs",children:_e}),p.jsxs("div",{className:"hstack",style:{gap:8},children:[p.jsx("button",{className:"btn btn-primary",onClick:fe,disabled:!he.trim()||Me,children:Me?"Sending…":"Send"}),p.jsx("button",{className:"btn",onClick:()=>ye(!1),children:"Close"})]})]})})]})}function RH(t,e){const[n,r]=G.useState({data:null,loading:!1,error:null}),i=JSON.stringify(e),s=G.useRef(e);return s.current=e,G.useEffect(()=>{const o=new AbortController;r(l=>({...l,loading:!0}));const a=setTimeout(async()=>{try{const l=await Jt.lintTemplate(t,s.current,o.signal);r({data:l,loading:!1,error:null})}catch(l){if((l==null?void 0:l.name)==="AbortError")return;r(c=>({data:c.data,loading:!1,error:String((l==null?void 0:l.message)??l)}))}},500);return()=>{o.abort(),clearTimeout(a)}},[i,t]),n}function IH({paths:t,hasSchema:e}){const[n,r]=G.useState(null);function i(s){var o;(o=navigator.clipboard)==null||o.writeText(`{{${s}}}`),r(s),setTimeout(()=>r(a=>a===s?null:a),1200)}return 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:e?"Click to copy":"Built-ins only"})]}),p.jsxs("div",{className:"card-body",style:{padding:0},children:[!e&&p.jsxs("div",{className:"text-xs subtle",style:{padding:12},children:["No ",p.jsx("code",{children:"varsAdapter"})," configured — define one with ",p.jsx("code",{children:"defineVars()"})," in ",p.jsx("code",{children:"Mailer.init"})," to expose host data (","{{user.name}}",", …) to templates."]}),p.jsx("div",{style:{maxHeight:280,overflow:"auto"},children:t.map(s=>p.jsxs("div",{onClick:()=>i(s.path),title:s.description??`{{${s.path}}}`,style:{display:"flex",justifyContent:"space-between",gap:12,cursor:"pointer",padding:"6px 12px",borderTop:"1px solid var(--border)"},children:[p.jsx("span",{className:"mono text-xs",children:n===s.path?"Copied!":`{{${s.path}}}`}),p.jsx("span",{className:"text-xs subtle",children:s.type})]},s.path))})]})]})}function lk({data:t}){const{errors:e,warnings:n,infos:r}=t;return e.length+n.length+r.length===0?p.jsxs("span",{style:{color:"var(--green-fg)"},children:[p.jsx("span",{className:"dot"}),"Lint: clean"]}):p.jsxs("span",{className:"hstack",style:{gap:6},children:[e.length>0&&p.jsxs("span",{style:{color:"var(--red-fg)"},children:[e.length," error",e.length===1?"":"s"]}),n.length>0&&p.jsxs("span",{style:{color:"var(--amber-fg)"},children:[n.length," warning",n.length===1?"":"s"]}),r.length>0&&p.jsxs("span",{style:{color:"var(--fg-muted)"},children:[r.length," info"]})]})}function DH({lint:t}){const e=t.data;return p.jsxs("div",{className:"card",children:[p.jsxs("div",{className:"card-head",children:[p.jsx("span",{className:"card-title",children:"Issues"}),p.jsx("span",{className:"card-sub",children:t.loading&&!e?"Checking…":e?p.jsx(lk,{data:e}):"—"})]}),p.jsxs("div",{className:"card-body",style:{padding:0},children:[t.error&&p.jsx("div",{className:"text-xs",style:{padding:12,color:"var(--red-fg)"},children:t.error}),e&&e.compileFailed&&p.jsx("div",{className:"text-xs",style:{padding:12,color:"var(--red-fg)"},children:"Template compile failed — see error below."}),e&&p.jsxs("div",{style:{maxHeight:360,overflow:"auto"},children:[e.errors.map(n=>p.jsx(Eu,{issue:n},`e-${n.rule}`)),e.warnings.map(n=>p.jsx(Eu,{issue:n},`w-${n.rule}`)),e.infos.map(n=>p.jsx(Eu,{issue:n},`n-${n.rule}`)),e.errors.length===0&&e.warnings.length===0&&e.infos.length===0&&p.jsx("div",{className:"text-xs subtle",style:{padding:12},children:"No issues."})]})]})]})}function Eu({issue:t}){const e=t.severity==="error"?"var(--red-fg)":t.severity==="warning"?"var(--amber-fg)":"var(--fg-muted)";return p.jsxs("div",{style:{padding:"8px 12px",borderTop:"1px solid var(--border)",display:"grid",gap:4},children:[p.jsxs("div",{className:"text-xs",style:{color:e,fontWeight:500},children:[t.severity.toUpperCase()," · ",t.rule]}),p.jsx("div",{className:"text-xs",children:t.message}),t.hint&&p.jsx("div",{className:"text-xs subtle",children:t.hint})]})}function LH({slug:t,refetchTemplate:e}){const{data:n,refetch:r}=Df(()=>Jt.mailTesterStatus(t),[t]),[i,s]=G.useState(!1),[o,a]=G.useState(null),[l,c]=G.useState(null),[d,u]=G.useState(null),f=G.useRef(r),h=G.useRef(e);f.current=r,h.current=e,G.useEffect(()=>{if(!o)return;let w=!1,E=0;const v=30,S=setInterval(async()=>{E++;try{const k=await Jt.fetchMailTesterResult(t,o.checkId);if(w)return;k.status==="ready"&&k.score?(u(k.score),a(null),s(!1),f.current(),h.current()):E>=v&&(c("Timed out waiting for Mail-Tester to score the message. It may still be processing — refresh to check."),a(null),s(!1))}catch(k){if(w)return;c(String((k==null?void 0:k.message)??k)),a(null),s(!1)}},3e3);return()=>{w=!0,clearInterval(S)}},[o,t]);async function m(){s(!0),c(null),u(null);try{const w=await Jt.startMailTesterCheck(t);if(w.status==="ready"&&w.score){u(w.score),s(!1),r();return}w.checkId&&w.contentKey?a({checkId:w.checkId,contentKey:w.contentKey}):(c("Unexpected response from server."),s(!1))}catch(w){c(String((w==null?void 0:w.message)??w)),s(!1)}}const g=d??(n==null?void 0:n.score)??null,y=(n==null?void 0:n.minScore)??8,b=g!=null&&g.score<y;return p.jsxs("div",{className:"card",children:[p.jsxs("div",{className:"card-head",children:[p.jsx("span",{className:"card-title",children:"Deliverability check"}),p.jsx("span",{className:"card-sub",children:n?n.configured?g?`Cached for ${n.cacheHours}h after each check`:"Run a Mail-Tester check before publishing":"Mail-Tester not configured":"Loading…"}),(n==null?void 0:n.configured)&&p.jsx("div",{className:"card-actions",children:p.jsx("button",{className:"btn btn-xs",disabled:i,onClick:m,children:i?o?"Waiting for score…":"Sending…":g?"Re-run check":"Run check"})})]}),p.jsxs("div",{className:"card-body",style:{display:"grid",gap:10},children:[!(n!=null&&n.configured)&&p.jsxs("div",{className:"text-xs subtle",children:["Set ",p.jsx("code",{children:"mailer.config.mailTester.apiKey"})," to enable. Mail-Tester runs SpamAssassin + DNS auth checks + content red-flag scoring against a real receipt of this template."]}),l&&p.jsx("div",{className:"text-xs",style:{color:"var(--red-fg)"},children:l}),(n==null?void 0:n.configured)&&n.requireScore&&!g&&p.jsxs("div",{className:"text-xs",style:{color:"var(--amber-fg)"},children:[p.jsx("code",{children:"requireScore"})," is on — publish is blocked until this exact content has a score. Editing the subject or body after a check invalidates it."]}),g&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"hstack",style:{gap:16,alignItems:"baseline"},children:[p.jsxs("div",{children:[p.jsx("div",{className:"text-xs subtle",children:"Score"}),p.jsxs("div",{style:{fontSize:28,fontWeight:600,color:b?"var(--red-fg)":g.score>=9?"var(--green-fg)":"var(--amber-fg)"},children:[g.score.toFixed(1)," ",p.jsx("span",{className:"text-xs subtle",children:"/ 10"})]})]}),p.jsxs("div",{children:[p.jsx("div",{className:"text-xs subtle",children:"Threshold"}),p.jsx("div",{className:"text-sm mono",children:y.toFixed(1)})]}),p.jsxs("div",{children:[p.jsx("div",{className:"text-xs subtle",children:"Checked"}),p.jsx("div",{className:"text-xs",children:new Date(g.fetchedAt).toLocaleString()})]})]}),b&&p.jsxs("div",{className:"text-xs",style:{color:"var(--red-fg)"},children:["Score below threshold — publish will be blocked. Address the feedback below or override with ",p.jsx("code",{children:"bypassMailTester: true"})," on the publish call."]}),g.feedback.length>0&&p.jsxs("div",{style:{display:"grid",gap:6,marginTop:4},children:[g.feedback.slice(0,12).map((w,E)=>p.jsxs("div",{className:"text-xs",style:{display:"grid",gap:2},children:[p.jsxs("div",{style:{color:w.severity==="error"?"var(--red-fg)":w.severity==="warning"?"var(--amber-fg)":"var(--fg-muted)",fontWeight:500},children:[w.severity.toUpperCase()," · ",w.category]}),p.jsx("div",{children:w.message})]},E)),g.feedback.length>12&&p.jsxs("div",{className:"text-xs subtle",children:["+ ",g.feedback.length-12," more items in raw report"]})]})]})]})]})}function ku({title:t,onClose:e,children:n}){const r=G.useId(),i=G.useRef(null);return G.useEffect(()=>{var a;const s=i.current;function o(l){if(l.key==="Escape"){e();return}if(l.key!=="Tab"||!s)return;const c=s.querySelectorAll('a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])');if(c.length===0)return;const d=c[0],u=c[c.length-1],f=document.activeElement;l.shiftKey&&(f===d||!s.contains(f))?(l.preventDefault(),u.focus()):!l.shiftKey&&f===u&&(l.preventDefault(),d.focus())}return document.addEventListener("keydown",o),(a=i.current)==null||a.focus(),()=>document.removeEventListener("keydown",o)},[e]),p.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":r,onClick:e,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.45)",display:"grid",placeItems:"center",zIndex:50},children:p.jsxs("div",{ref:i,tabIndex:-1,onClick:s=>s.stopPropagation(),className:"card",style:{width:"min(680px, 90vw)",maxHeight:"85vh",overflow:"auto",padding:0},children:[p.jsxs("div",{className:"card-head",children:[p.jsx("span",{className:"card-title",id:r,children:t}),p.jsx("span",{className:"grow"}),p.jsx("button",{className:"icon-btn","aria-label":"Close",onClick:e,children:p.jsx(Va.X,{size:14})})]}),p.jsx("div",{className:"card-body",children:n})]})})}export{KH as TemplateEditor};
|
|
502
|
+
//# sourceMappingURL=template-editor-DwMKy5sw.js.map
|