@lattice-php/lattice 0.46.0 → 0.47.0

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.
Files changed (28) hide show
  1. package/dist/types/generated.d.ts +3 -3
  2. package/dist-standalone/chunks/badge-oZDK5bxm.js +1 -0
  3. package/dist-standalone/chunks/{chart-view-DghsYabe.js → chart-view-DhCVr5fn.js} +2 -2
  4. package/dist-standalone/chunks/color-CXV-Y5Qv.js +1 -0
  5. package/dist-standalone/chunks/date-picker-field-Ds1A1ipK.js +1 -0
  6. package/dist-standalone/chunks/{registry-context-BdTXNnGL.js → dist-DbKexmtw.js} +1 -1
  7. package/dist-standalone/chunks/dist-DlQDeTRF.js +106 -0
  8. package/dist-standalone/chunks/field-BQzK42M4.js +1 -0
  9. package/dist-standalone/chunks/format-context-CxuxddW6.js +1 -0
  10. package/dist-standalone/chunks/input-DAZtm5hT.js +1 -0
  11. package/dist-standalone/chunks/registry-context-Q5KtSmdi.js +1 -0
  12. package/dist-standalone/chunks/rich-editor-field-BsezbAas.js +53 -0
  13. package/dist-standalone/chunks/runtime-Bi4uPw0x.js +27 -0
  14. package/dist-standalone/chunks/{subscriptions-BICQU9ps.js → subscriptions-WYT4UqqY.js} +1 -1
  15. package/dist-standalone/chunks/{time-picker-CAwU5Rl-.js → time-picker-CMZqQpOJ.js} +1 -1
  16. package/dist-standalone/chunks/toolbar-button-DUDNmNDx.js +1 -0
  17. package/dist-standalone/chunks/translatable-D6DlHH6Q.js +1 -0
  18. package/dist-standalone/chunks/use-dependent-field-zJUDiN2l.js +41 -0
  19. package/dist-standalone/lattice.js +1 -1
  20. package/dist-standalone/manifest.json +1 -1
  21. package/dist-standalone/runtime.js +1 -1
  22. package/package.json +6 -6
  23. package/dist-standalone/chunks/date-picker-field-CaRIypsW.js +0 -1
  24. package/dist-standalone/chunks/format-context-DCYPeoEM.js +0 -1
  25. package/dist-standalone/chunks/rich-editor-field-DnkT5hlA.js +0 -158
  26. package/dist-standalone/chunks/runtime-5aZwKnpP.js +0 -27
  27. package/dist-standalone/chunks/toolbar-button-BmtWFTk1.js +0 -41
  28. package/dist-standalone/chunks/translatable-YXSlt1CF.js +0 -1
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-CwJFpaho.js";import{_ as n,m as r}from"./floating-ui.dom-CO6FyQ6K.js";import{t as i}from"./jsx-runtime-NZYk81nU.js";import{c as a}from"./instance-D6cXaqIT.js";import{W as o,_ as s,c,d as l,f as u,l as d,p as f,r as p,s as m,t as h,u as g,w as _,y as v}from"./use-dependent-field-zJUDiN2l.js";import{t as y}from"./input-DAZtm5hT.js";import{n as b,t as x}from"./badge-oZDK5bxm.js";import{R as S,a as C,d as w,i as T,n as E,o as D,r as O,s as k,t as A}from"./dist-DlQDeTRF.js";var j=e(t(),1),M=e(i(),1);function N({config:e,onChange:t,schema:n}){return(0,M.jsx)(M.Fragment,{children:n.map(n=>{let r=n.props?.name,i=n.props?.label??r,a=e[r]??n.props?.value??``,o=n=>t({...e,[r]:n});if(n.type===`field.choice`||n.type===`field.select`){let e=n.props?.options??[];return(0,M.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[i,(0,M.jsx)(b,{onChange:e=>o(e.target.value),value:a,children:e.map(e=>(0,M.jsx)(`option`,{value:e.value,children:e.label},e.value))})]},r)}return n.type===`field.number-input`||n.type===`field.text-input`?(0,M.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[i,(0,M.jsx)(y,{onChange:e=>o(e.target.value),type:n.type===`field.number-input`?`number`:`text`,value:a})]},r):null})})}function P({editor:e,extension:t,node:r,selected:i,updateAttributes:a}){let[o,s]=(0,j.useState)(!1),c=t.options.tokens,d=r.attrs.token,p=c.find(e=>e.name===d),m=r.attrs.config??{},h=p?.label??d,g=p?.schema??[],_=(0,M.jsx)(x,{className:n(`cursor-default select-none`,i&&`ring-2 ring-lt-ring`),"data-test":`pattern-token-${d}`,children:h});return g.length===0||!e.isEditable?(0,M.jsx)(C,{as:`span`,children:_}):(0,M.jsx)(C,{as:`span`,children:(0,M.jsxs)(l,{onOpenChange:s,open:o,children:[(0,M.jsx)(f,{asChild:!0,children:(0,M.jsx)(`button`,{"data-test":`pattern-token-${d}-trigger`,type:`button`,children:_})}),(0,M.jsx)(u,{className:`flex w-56 flex-col gap-2 p-3`,"data-test":`pattern-token-${d}-config`,children:(0,M.jsx)(N,{config:m,onChange:e=>a({config:e}),schema:g})})]})})}var F=w.create({name:`patternToken`,group:`inline`,inline:!0,atom:!0,selectable:!0,addOptions(){return{tokens:[]}},addAttributes(){return{token:{default:null},config:{default:{}}}},parseHTML(){return[{tag:`span[data-pattern-token]`}]},renderHTML({node:e,HTMLAttributes:t}){return[`span`,S(t,{"data-pattern-token":e.attrs.token}),e.attrs.token]},addNodeView(){return D(P)}});function I(e){return{type:`doc`,content:[{type:`paragraph`,content:e.flatMap(e=>e.type===`text`?e.value===``?[]:[{type:`text`,text:e.value}]:[{type:`patternToken`,attrs:{token:e.token,config:e.config}}])}]}}function L(e){return(e.content?.[0]?.content??[]).flatMap(e=>{if(e.type===`text`)return e.text?[{type:`text`,value:e.text}]:[];if(e.type===`patternToken`){let t=e.attrs??{};return[{type:`token`,token:t.token,config:t.config??{}}]}return[]})}function R(e){let t=new Set;return e.state.doc.descendants(e=>{e.type.name===`patternToken`&&typeof e.attrs.token==`string`&&t.add(e.attrs.token)}),t}function z(e){return Object.fromEntries(e.schema.map(e=>[e.props?.name,e.props?.value??``]))}function B({editor:e,separator:t,tokens:n}){let{t:i}=a(`lattice`),[o,s]=(0,j.useState)(!1),l=o?R(e):new Set,u=n.filter(e=>!l.has(e.name)),f=n=>{let r=e.chain().focus();t!==``&&r.insertContent(t),r.insertContent({type:`patternToken`,attrs:{token:n.name,config:z(n)}}).run()};return(0,M.jsxs)(m,{onOpenChange:s,open:o,children:[(0,M.jsx)(g,{asChild:!0,children:(0,M.jsxs)(`button`,{className:`inline-flex items-center gap-1 rounded-lt-sm border border-lt-input px-2 py-1 text-sm hover:bg-lt-accent`,"data-test":`pattern-input-insert-token`,type:`button`,children:[(0,M.jsx)(r,{"aria-hidden":`true`,name:`plus`}),i(`form.pattern-input.insert-token`,`Insert token`)]})}),(0,M.jsx)(c,{children:u.map(e=>(0,M.jsx)(d,{"data-test":`pattern-input-insert-token-${e.name}`,onClick:()=>f(e),children:e.label},e.name))})]})}var V=({node:e})=>{let{errors:t}=o(),{hidden:r,required:i,readOnly:a,disabled:c}=h(e),{change:l,blur:u}=s(),d=e.props.name,f=_(),m=v(d),g=f?f.getValue(d):m,y=f?f.scopedName(d):d,b=f?f.errorKey(d):d,x=a||c,S=(0,j.useMemo)(()=>g??[],[g]),C=(0,j.useMemo)(()=>[O,E,A,F.configure({tokens:e.props.tokens})],[e.props.tokens]),w=k({extensions:C,content:I(S),editable:!x,immediatelyRender:!1,editorProps:{attributes:{class:`px-3 py-2 outline-none`},handleKeyDown:(e,t)=>t.key===`Enter`},onUpdate:({editor:e})=>{l(d,L(e.getJSON()))},onBlur:()=>{u(d)}});if((0,j.useEffect)(()=>{w?.setEditable(!x)},[w,x]),r)return null;let D=S.length>0?JSON.stringify(S):``;return(0,M.jsx)(p,{error:t[b],helperText:e.props.helperText??void 0,tooltip:e.props.tooltip??void 0,label:e.props.label??``,id:y,required:i,children:t=>(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{...t,className:n(`overflow-hidden rounded-lt-sm border border-lt-input bg-transparent shadow-lt-xs focus-within:border-lt-ring focus-within:ring-[length:var(--lt-ring-width)] focus-within:ring-lt-ring/50`,x&&`opacity-60`),role:`group`,children:[w&&!x&&(0,M.jsx)(`div`,{className:`border-b border-lt-border p-1`,children:(0,M.jsx)(B,{editor:w,separator:e.props.separator,tokens:e.props.tokens})}),(0,M.jsx)(T,{editor:w})]}),(0,M.jsx)(`input`,{name:y,type:`hidden`,value:D})]})})};export{V as default};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-CwJFpaho.js";import{a as n}from"./locale-BZOrJtMq.js";import{r}from"./timezone-Ckl1gbqB.js";function i(e){return e==null||e===``?void 0:e}function a(e){return i(e.key)??i(e.id)}function o(e){return i(e)?.split(`.`).at(-1)}function s(e,t){let n=o(t);return n?`${e}-${n}`:void 0}function c(e,t){return s(e,a(t))}function l(e){let t=typeof e==`number`?e:Number(e);return e!=null&&e!==``&&!Number.isNaN(t)?t:null}function u(e,t,n){let r=l(e);if(r===null)return String(e??``);let i={notation:t.notation,minimumFractionDigits:t.minimumFractionDigits??void 0,maximumFractionDigits:t.maximumFractionDigits??void 0};return t.currency?(i.style=`currency`,i.currency=t.currency):t.unit&&(i.style=`unit`,i.unit=t.unit),new Intl.NumberFormat(n,i).format(r)}var d=e(t(),1);function f(){let{locale:e}=n(),{timezone:t}=r();return(0,d.useMemo)(()=>({locale:e,timezone:t}),[e,t])}export{c as a,a as i,u as n,s as o,l as r,i as s,f as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-CwJFpaho.js";import{_ as n,u as r}from"./floating-ui.dom-CO6FyQ6K.js";import{t as i}from"./jsx-runtime-NZYk81nU.js";t();var a=`focus-visible:border-lt-ring focus-visible:ring-lt-ring/50 focus-visible:ring-[length:var(--lt-ring-width)] focus-visible:ring-offset-[length:var(--lt-ring-offset)]`,o=r([`w-full min-w-0 rounded-lt-sm border border-lt-input shadow-lt-xs outline-none transition-[color,box-shadow]`,`placeholder:text-lt-muted-fg`,a,`aria-invalid:border-lt-danger aria-invalid:ring-lt-danger/20 dark:aria-invalid:ring-lt-danger/40`,`disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-lt-disabled disabled:text-lt-disabled-fg`],{variants:{density:{comfortable:`h-lt-control-md bg-transparent px-3 py-1 text-base`,compact:`h-lt-control-md bg-lt-bg px-2 text-sm font-normal`}},defaultVariants:{density:`comfortable`}}),s=e(i(),1);function c({className:e,type:t,density:r,...i}){return(0,s.jsx)(`input`,{type:t,"data-slot":`input`,className:n(o({density:r}),`file:text-lt-fg selection:bg-lt-primary selection:text-lt-primary-fg file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium`,e),...i})}export{a as n,o as r,c as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-CwJFpaho.js";var n=e(t(),1),r=(0,n.createContext)(null),i=null,a={};function o(e){i=e}function s(){return((0,n.useContext)(r)??i)?.components??a}function c(e){return((0,n.useContext)(r)??i)?.extensions[e]??a}export{c as i,o as n,s as r,r as t};
@@ -0,0 +1,53 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-CwJFpaho.js";import{_ as n}from"./floating-ui.dom-CO6FyQ6K.js";import{t as r}from"./jsx-runtime-NZYk81nU.js";import{i}from"./registry-context-Q5KtSmdi.js";import{c as a}from"./instance-D6cXaqIT.js";import{W as o,_ as s,c,d as l,f as u,l as d,p as f,r as p,s as m,t as h,u as g,w as _,y as ee}from"./use-dependent-field-zJUDiN2l.js";import{a as te,i as v,n as ne,o as re,r as ie,t as y}from"./toolbar-button-DUDNmNDx.js";import{$ as ae,A as oe,B as se,C as ce,D as le,E as ue,F as de,G as fe,H as pe,I as b,J as x,K as S,L as C,M as me,N as he,O as ge,P as _e,Q as w,R as T,S as ve,T as ye,U as be,V as xe,W as Se,X as E,Y as D,Z as Ce,_ as we,b as Te,c as O,d as k,et as Ee,f as De,g as Oe,h as ke,i as Ae,j as je,k as Me,l as Ne,m as Pe,n as Fe,nt as A,p as Ie,q as Le,r as Re,rt as j,s as ze,t as Be,tt as Ve,u as He,v as Ue,w as We,x as Ge,y as Ke,z as qe}from"./dist-DlQDeTRF.js";function Je(e={}){return new x({view(t){return new Ye(t,e)}})}var Ye=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(!t||i)return null;let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=Ve(this.editorView.state.doc,a,this.editorView.dragging.slice);e!=null&&(a=e)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},M=class e extends E{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):E.near(r)}content(){return j.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new Xe(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Qe(e)||!$e(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Le.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};M.prototype.visible=!1,M.findFrom=M.findGapCursorFrom,E.jsonID(`gapcursor`,M);var Xe=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return M.valid(t)?new M(t):E.near(t)}};function Ze(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function Qe(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||Ze(e.type))return!0;if(e.inlineContent)return!1}}return!0}function $e(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||Ze(e.type))return!0;if(e.inlineContent)return!1}}return!0}function et(){return new x({props:{decorations:at,createSelectionBetween(e,t,n){return t.pos==n.pos&&M.valid(n)?new M(n):null},handleClick:rt,handleKeyDown:tt,handleDOMEvents:{beforeinput:it}}})}var tt=Se({ArrowLeft:nt(`horiz`,-1),ArrowRight:nt(`horiz`,1),ArrowUp:nt(`vert`,-1),ArrowDown:nt(`vert`,1)});function nt(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof w){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=M.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new M(c))),!0):!1}}function rt(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!M.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Le.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new M(r))),!0)}function it(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof M))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=A.empty;for(let e=r.length-1;e>=0;e--)i=A.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new j(i,0,0));return a.setSelection(w.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function at(e){if(!(e.selection instanceof M))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,S.create(e.doc,[fe.widget(e.selection.head,t,{key:`gapcursor`})])}var ot=200,N=function(){};N.prototype.append=function(e){return e.length?(e=N.from(e),!this.length&&e||e.length<ot&&this.leafAppend(e)||this.length<ot&&e.leafPrepend(this)||this.appendInner(e)):this},N.prototype.prepend=function(e){return e.length?N.from(e).append(this):this},N.prototype.appendInner=function(e){return new ct(this,e)},N.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?N.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},N.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},N.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},N.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},N.from=function(e){return e instanceof N?e:e&&e.length?new st(e):N.empty};var st=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=ot)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=ot)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(N);N.empty=new st([]);var ct=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(N),lt=500,ut=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new ft(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new ft(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new ft(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>mt&&(s=dt(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new ae;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new ft(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new ft(i,o,l))}else r.push(new ft(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new ft(a.maps[e]));let u=this.items.slice(0,i).append(l).append(r),d=new e(u,s);return d.emptyItemCount()>lt&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new ft(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(N.from(i.reverse()),a)}};ut.empty=new ut(N.empty,0);function dt(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var ft=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},pt=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},mt=20;function ht(e,t,n,r){let i=n.getMeta(Ct),a;if(i)return i.historyState;n.getMeta(wt)&&(e=new pt(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(Ct))return o.getMeta(Ct).redo?new pt(e.done.addTransform(n,void 0,r,St(t)),e.undone,_t(n.mapping.maps),e.prevTime,e.prevComposition):new pt(e.done,e.undone.addTransform(n,void 0,r,St(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!gt(n,e.prevRanges)),s=o?vt(e.prevRanges,n.mapping):_t(n.mapping.maps);return new pt(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,St(t)),ut.empty,s,n.time,i??e.prevComposition)}return(a=n.getMeta(`rebased`))?new pt(e.done.rebased(n,a),e.undone.rebased(n,a),vt(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new pt(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),vt(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function gt(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function _t(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function vt(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function yt(e,t,n){let r=St(t),i=Ct.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new pt(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(Ct,{redo:n,historyState:c})}var bt=!1,xt=null;function St(e){let t=e.plugins;if(xt!=t){bt=!1,xt=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){bt=!0;break}}return bt}var Ct=new D(`history`),wt=new D(`closeHistory`);function Tt(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new x({key:Ct,state:{init(){return new pt(ut.empty,ut.empty,null,0,-1)},apply(t,n,r){return ht(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?Dt:n==`historyRedo`?Ot:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Et(e,t){return(n,r)=>{let i=Ct.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=yt(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var Dt=Et(!1,!0),Ot=Et(!0,!0);O.create({name:`characterCount`,addOptions(){return{limit:null,autoTrim:!0,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new x({key:new D(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit,a=this.options.autoTrim;if(i==null||i===0||a===!1){e=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){let t=o-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var kt=O.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[Je(this.options)]}});O.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new x({key:new D(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return S.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(fe.node(t,t+e.nodeSize,{class:this.options.className}))}),S.create(e,a)}}})]}});var At=O.create({name:`gapCursor`,addProseMirrorPlugins(){return[et()]},extendNodeSchema(e){let t={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:Ie(We(e,`allowGapCursor`,t))??null}}}),jt=`placeholder`,Mt=new D(`tiptap__placeholder`);function Nt(e){let{editor:t,placeholder:n,dataAttribute:r,pos:i,node:a,isEmptyDoc:o,hasAnchor:s,classes:{emptyNode:c,emptyEditor:l}}=e,u=[c];return o&&u.push(l),fe.node(i,i+a.nodeSize,{class:u.join(` `),[r]:typeof n==`function`?n({editor:t,node:a,pos:i,hasAnchor:s}):n})}function Pt(e,t){return typeof e==`function`?e(t):e}function Ft({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:a,to:o}){let{anchor:s}=i,c=[],l=e.isEmpty;return r.nodesBetween(a,o,(r,i)=>{let a=s>=i&&s<=i+r.nodeSize,o=!r.isLeaf&&_e(r);return r.type.isTextblock&&(a||!t.showOnlyCurrent)&&o&&c.push(Nt({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:a,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Pt(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:a})},node:r,pos:i})),t.includeChildren}),c}function It({editor:e,options:t,dataAttribute:n,doc:r,selection:i}){if(!(e.isEditable||!t.showOnlyWhenEditable))return null;let{anchor:a}=i,o=[],s=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let i=r.resolve(a),c=i.depth>0?i.node(1):i.nodeAfter,l=i.depth>0?i.before(1):a;if(c&&c.type.isTextblock&&_e(c)){let r=a>=l&&a<=l+c.nodeSize;o.push(Nt({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Pt(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else o.push(...Ft({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return S.create(r,o)}function Lt(e,t){let n=e.resolve(t);if(n.depth===0){let e=n.nodeAfter??n.nodeBefore;if(!e)return{from:t,to:t};let r=n.nodeAfter?t:t-e.nodeSize;return{from:r,to:r+e.nodeSize}}let r=n.before(1);return{from:r,to:r+n.node(1).nodeSize}}function Rt(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function zt(e,t,n){let r=[];return e.forEach((e,i)=>{let a=i,o=a+e.nodeSize,s=a+1,c=o+1;s<n&&c>t&&r.push({from:a,to:o})}),r}function Bt(e){if(e.length===0)return[];let t=[...e].sort((e,t)=>e.from-t.from),n=[{...t[0]}];for(let e=1;e<t.length;e+=1){let r=n[n.length-1],i=t[e];i.from<=r.to?r.to=Math.max(r.to,i.to):n.push({...i})}return n}function Vt(e,t){let n=zt(e,t.from,t.to);return n.push(Rt(e,Lt(e,t.from))),t.to>t.from?n.push(Rt(e,Lt(e,Math.min(t.to,e.content.size+1)-1))):t.from<e.content.size+1&&n.push(Rt(e,Lt(e,Math.min(t.from+1,e.content.size)))),n}function Ht(e,t,n){let r=[];if(e.docChanged){let t=ce(e);for(let e of t)r.push(...Vt(n.doc,e.newRange))}return e.selectionSet&&(r.push(Rt(n.doc,Lt(n.doc,e.mapping.map(t.selection.anchor)))),r.push(Rt(n.doc,Lt(n.doc,n.selection.anchor)))),Bt(r)}function Ut(e,t,n){let r=Math.max(0,Math.min(e,n.content.size));return{from:r,to:Math.max(r,Math.min(t,n.content.size))}}function Wt({decorations:e,ranges:t,editor:n,options:r,dataAttribute:i,doc:a,selection:o}){let s=e;for(let e of t){let{from:t,to:c}=Ut(e.from,e.to,a),l=s.find(t,c).filter(e=>e.from>=t&&e.to<=c);l.length&&(s=s.remove(l));let u=Ft({editor:n,options:r,dataAttribute:i,doc:a,selection:o,from:t,to:c});u.length&&(s=s.add(a,u))}return s}function Gt({editor:e,options:t,dataAttribute:n}){return{init(r,i){return It({editor:e,options:t,dataAttribute:n,doc:i.doc,selection:i.selection})??S.empty},apply(r,i,a,o){return!r.docChanged&&!r.selectionSet?i:Wt({decorations:i.map(r.mapping,r.doc),ranges:Ht(r,a,o),editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function Kt(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function qt({editor:e,options:t}){let n=t.dataAttribute?`data-${Kt(t.dataAttribute)}`:`data-${jt}`,r=t.showOnlyCurrent&&!t.includeChildren;return new x({key:Mt,...r?{}:{state:Gt({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:r,selection:i})=>It({editor:e,options:t,dataAttribute:n,doc:r,selection:i}):n=>t.showOnlyWhenEditable&&!e.isEditable?S.empty:Mt.getState(n)??S.empty}})}var Jt=O.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:jt,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[qt({editor:this.editor,options:this.options})]}});function Yt(e,t){return!e.selection.empty&&!de(e.selection)&&t.isEditable}function Xt(e,t){return Yt(e,t)&&!t.isFocused&&!t.view.dragging}function Zt(){var e;(e=window.getSelection())==null||e.removeAllRanges()}function Qt(e){e.focus()}O.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new x({key:new D(`selection`),props:{decorations(n){return Xt(n,e)?S.create(n.doc,[fe.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(t){return Yt(t.state,e)&&Zt(),!1},focus(t){return Yt(t.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&t.hasFocus()&&Qt(t)}),!1}}}})]}});function $t({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var en=O.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new D(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new x({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!$t({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!$t({node:r,types:n})}}})]}}),tn=O.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>Dt(e,t),redo:()=>({state:e,dispatch:t})=>Ot(e,t)}},addProseMirrorPlugins(){return[Tt(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),nn=(e,t)=>{if(e===`slot`)return 0;if(e instanceof Function)return e(t);let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);return[e,r,n]},rn=(e,t)=>{let{state:n,view:r}=e,{selection:i}=n;if(!i.empty)return!1;let{$from:a}=i;if(a.parentOffset!==0)return!1;let o=a.depth-1;if(o<0)return!1;let s=a.node(o),c=a.index(o);if(c===0)return!1;if(s.type===t)return e.commands.lift(t.name);let l=s.child(c-1);if(l.type!==t||!l.lastChild?.isTextblock)return!1;let u=a.before(),d=u-1-1,{tr:f}=n;return f.delete(u,a.after()).insert(d,a.parent.content),f.setSelection(w.create(f.doc,d)),r.dispatch(f.scrollIntoView()),!0},an=/^\s*>\s$/,on=k.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return nn(`blockquote`,{...T(this.options.HTMLAttributes,e),children:nn(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(`
2
+ `).map(e=>e.trim()===``?`>`:`> ${e}`);n.push(i.join(`
3
+ `))}),n.join(`
4
+ >
5
+ `)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>rn(this.editor,this.type)}},addInputRules(){return[be({find:an,type:this.type})]}}),sn=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,cn=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,ln=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,un=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,dn=He.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return nn(`strong`,{...T(this.options.HTMLAttributes,e),children:nn(`slot`,{})})},markdownTokenName:`strong`,parseMarkdown:(e,t)=>t.applyMark(`bold`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<strong>`,close:`</strong>`}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[b({find:sn,type:this.type}),b({find:ln,type:this.type})]},addPasteRules(){return[C({find:cn,type:this.type}),C({find:un,type:this.type})]}}),fn=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},pn=e=>{let t=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=t.exec(e))!==null;)r.index>0&&e[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n},mn=He.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,T(this.options.HTMLAttributes,e),0]},markdownTokenName:`codespan`,parseMarkdown:(e,t)=>t.applyMark(`code`,[{type:`text`,text:e.text||``}]),renderMarkdown:(e,t)=>e.content?`\`${t.renderChildren(e.content)}\``:``,addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[b({find:fn,type:this.type})]},addPasteRules(){return[C({find:pn,type:this.type})]}}),hn=4,gn=/^```([a-z]+)?[\s\n]$/,_n=/^~~~([a-z]+)?[\s\n]$/,vn=k.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:hn,HTMLAttributes:{}}},content:`text*`,marks:``,group:`block`,code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{let{languageClassPrefix:t}=this.options;return t&&[...e.firstElementChild?.classList||[]].filter(e=>e.startsWith(t)).map(e=>e.replace(t,``))[0]||null},rendered:!1}}},parseHTML(){return[{tag:`pre`,preserveWhitespace:`full`}]},renderHTML({node:e,HTMLAttributes:t}){return[`pre`,T(this.options.HTMLAttributes,t),[`code`,{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:`code`,parseMarkdown:(e,t)=>e.raw?.startsWith("```")===!1&&e.raw?.startsWith(`~~~`)===!1&&e.codeBlockStyle!==`indented`?[]:t.createNode(`codeBlock`,{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[]),renderMarkdown:(e,t)=>{let n=``,r=e.attrs?.language||``;return n=e.content?[`\`\`\`${r}`,t.renderChildren(e.content),"```"].join(`
6
+ `):`\`\`\`${r}
7
+
8
+ \`\`\``,n},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,`paragraph`,e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??hn,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;if(i.parent.type!==this.type)return!1;let o=` `.repeat(t);return a?e.commands.insertContent(o):e.commands.command(({tr:e})=>{let{from:t,to:i}=r,a=n.doc.textBetween(t,i,`
9
+ `,`
10
+ `).split(`
11
+ `).map(e=>o+e).join(`
12
+ `);return e.replaceWith(t,i,n.schema.text(a)),!0})},"Shift-Tab":({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??hn,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;return i.parent.type===this.type?a?e.commands.command(({tr:e})=>{let{pos:r}=i,a=i.start(),o=i.end(),s=n.doc.textBetween(a,o,`
13
+ `,`
14
+ `).split(`
15
+ `),c=0,l=0,u=r-a;for(let e=0;e<s.length;e+=1){if(l+s[e].length>=u){c=e;break}l+=s[e].length+1}let d=s[c].match(/^ */)?.[0]||``,f=Math.min(d.length,t);if(f===0)return!0;let p=a;for(let e=0;e<c;e+=1)p+=s[e].length+1;return e.delete(p,p+f),r-p<=f&&e.setSelection(w.create(e.doc,p)),!0}):e.commands.command(({tr:e})=>{let{from:i,to:a}=r,o=n.doc.textBetween(i,a,`
16
+ `,`
17
+ `).split(`
18
+ `).map(e=>{let n=e.match(/^ */)?.[0]||``,r=Math.min(n.length,t);return e.slice(r)}).join(`
19
+ `);return e.replaceWith(i,a,n.schema.text(o)),!0}):!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;let a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
20
+
21
+ `);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:e})=>{if(!this.options.exitOnArrowUp)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type||r.parentOffset!==0)return!1;let a=r.before();return a>0?!1:e.commands.insertDefaultBlock({pos:a})},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(E.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[pe({find:gn,type:this.type,getAttributes:e=>({language:e[1]})}),pe({find:_n,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new x({key:new D(`codeBlockVSCodeHandler`),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData(`text/plain`),r=t.clipboardData.getData(`vscode-editor-data`),i=(r?JSON.parse(r):void 0)?.mode;if(!n||!i)return!1;let{tr:a,schema:o}=e.state,s=o.text(n.replace(/\r\n?/g,`
22
+ `));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(w.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),yn=k.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,T(this.options.HTMLAttributes,e)]},renderText(){return`
23
+ `},renderMarkdown:()=>`
24
+ `,parseMarkdown:()=>({type:`hardBreak`}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),bn=k.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,T(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode(`heading`,{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{let n=e.attrs?.level?parseInt(e.attrs.level,10):1,r=`#`.repeat(n);return e.content?`${r} ${t.renderChildren(e.content)}`:``},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>pe({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),xn=k.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,T(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!Pe(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return de(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(w.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(Le.create(t.doc,n.pos)):t.setSelection(w.create(t.doc,n.pos));else{let i=(e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType)?.create();i&&(t.insert(r,i),t.setSelection(w.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[qe({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Sn=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Cn=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,wn=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Tn=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,En=He.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,T(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<em>`,close:`</em>`}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[b({find:Sn,type:this.type}),b({find:wn,type:this.type})]},addPasteRules(){return[C({find:Cn,type:this.type}),C({find:Tn,type:this.type})]}}),Dn=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,On=`ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2`,kn=`numeric`,An=`ascii`,jn=`alpha`,Mn=`asciinumeric`,Nn=`alphanumeric`,Pn=`domain`,Fn=`emoji`,In=`scheme`,Ln=`slashscheme`,Rn=`whitespace`;function zn(e,t){return e in t||(t[e]=[]),t[e]}function Bn(e,t,n){t[kn]&&(t[Mn]=!0,t[Nn]=!0),t[An]&&(t[Mn]=!0,t[jn]=!0),t[Mn]&&(t[Nn]=!0),t[jn]&&(t[Nn]=!0),t[Nn]&&(t[Pn]=!0),t[Fn]&&(t[Pn]=!0);for(let r in t){let t=zn(r,n);t.indexOf(e)<0&&t.push(e)}}function Vn(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function P(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}P.groups={},P.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;n<t.jr.length;n++){let r=t.jr[n][0],i=t.jr[n][1];if(i&&r.test(e))return i}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let i=0;i<e.length;i++)this.tt(e[i],t,n,r)},tr(e,t,n,r){r||=P.groups;let i;return t&&t.j?i=t:(i=new P(t),n&&r&&Bn(t,n,r)),this.jr.push([e,i]),i},ts(e,t,n,r){let i=this,a=e.length;if(!a)return i;for(let t=0;t<a-1;t++)i=i.tt(e[t]);return i.tt(e[a-1],t,n,r)},tt(e,t,n,r){r||=P.groups;let i=this;if(t&&t.j)return i.j[e]=t,t;let a=t,o,s=i.go(e);return s?(o=new P,Object.assign(o.j,s.j),o.jr.push.apply(o.jr,s.jr),o.jd=s.jd,o.t=s.t):o=new P,a&&(r&&(o.t&&typeof o.t==`string`?Bn(a,Object.assign(Vn(o.t,r),n),r):n&&Bn(a,n,r)),o.t=a),i.j[e]=o,o}};var F=(e,t,n,r,i)=>e.ta(t,n,r,i),I=(e,t,n,r,i)=>e.tr(t,n,r,i),Hn=(e,t,n,r,i)=>e.ts(t,n,r,i),L=(e,t,n,r,i)=>e.tt(t,n,r,i),R=`WORD`,Un=`UWORD`,Wn=`ASCIINUMERICAL`,Gn=`ALPHANUMERICAL`,Kn=`LOCALHOST`,qn=`TLD`,Jn=`UTLD`,Yn=`SCHEME`,Xn=`SLASH_SCHEME`,Zn=`NUM`,Qn=`WS`,$n=`NL`,er=`OPENBRACE`,tr=`CLOSEBRACE`,nr=`OPENBRACKET`,rr=`CLOSEBRACKET`,ir=`OPENPAREN`,ar=`CLOSEPAREN`,or=`OPENANGLEBRACKET`,sr=`CLOSEANGLEBRACKET`,cr=`FULLWIDTHLEFTPAREN`,lr=`FULLWIDTHRIGHTPAREN`,ur=`LEFTCORNERBRACKET`,dr=`RIGHTCORNERBRACKET`,fr=`LEFTWHITECORNERBRACKET`,pr=`RIGHTWHITECORNERBRACKET`,mr=`FULLWIDTHLESSTHAN`,hr=`FULLWIDTHGREATERTHAN`,gr=`AMPERSAND`,_r=`APOSTROPHE`,vr=`ASTERISK`,yr=`AT`,br=`BACKSLASH`,xr=`BACKTICK`,Sr=`CARET`,Cr=`COLON`,wr=`COMMA`,Tr=`DOLLAR`,z=`DOT`,Er=`EQUALS`,Dr=`EXCLAMATION`,B=`HYPHEN`,Or=`PERCENT`,kr=`PIPE`,Ar=`PLUS`,jr=`POUND`,Mr=`QUERY`,Nr=`QUOTE`,Pr=`FULLWIDTHMIDDLEDOT`,Fr=`SEMI`,V=`SLASH`,Ir=`TILDE`,Lr=`UNDERSCORE`,Rr=`EMOJI`,zr=`SYM`,Br=Object.freeze({__proto__:null,ALPHANUMERICAL:Gn,AMPERSAND:gr,APOSTROPHE:_r,ASCIINUMERICAL:Wn,ASTERISK:vr,AT:yr,BACKSLASH:br,BACKTICK:xr,CARET:Sr,CLOSEANGLEBRACKET:sr,CLOSEBRACE:tr,CLOSEBRACKET:rr,CLOSEPAREN:ar,COLON:Cr,COMMA:wr,DOLLAR:Tr,DOT:z,EMOJI:Rr,EQUALS:Er,EXCLAMATION:Dr,FULLWIDTHGREATERTHAN:hr,FULLWIDTHLEFTPAREN:cr,FULLWIDTHLESSTHAN:mr,FULLWIDTHMIDDLEDOT:Pr,FULLWIDTHRIGHTPAREN:lr,HYPHEN:B,LEFTCORNERBRACKET:ur,LEFTWHITECORNERBRACKET:fr,LOCALHOST:Kn,NL:$n,NUM:Zn,OPENANGLEBRACKET:or,OPENBRACE:er,OPENBRACKET:nr,OPENPAREN:ir,PERCENT:Or,PIPE:kr,PLUS:Ar,POUND:jr,QUERY:Mr,QUOTE:Nr,RIGHTCORNERBRACKET:dr,RIGHTWHITECORNERBRACKET:pr,SCHEME:Yn,SEMI:Fr,SLASH:V,SLASH_SCHEME:Xn,SYM:zr,TILDE:Ir,TLD:qn,UNDERSCORE:Lr,UTLD:Jn,UWORD:Un,WORD:R,WS:Qn}),H=/[a-z]/,Vr=/\p{L}/u,Hr=/\p{Emoji}/u,U=/\d/,Ur=/\s/,Wr=`\r`,Gr=`
25
+ `,Kr=`️`,qr=`‍`,Jr=``,Yr=null,Xr=null;function Zr(e=[]){let t={};P.groups=t;let n=new P;Yr??=ti(Dn),Xr??=ti(On),L(n,`'`,_r),L(n,`{`,er),L(n,`}`,tr),L(n,`[`,nr),L(n,`]`,rr),L(n,`(`,ir),L(n,`)`,ar),L(n,`<`,or),L(n,`>`,sr),L(n,`(`,cr),L(n,`)`,lr),L(n,`「`,ur),L(n,`」`,dr),L(n,`『`,fr),L(n,`』`,pr),L(n,`<`,mr),L(n,`>`,hr),L(n,`&`,gr),L(n,`*`,vr),L(n,`@`,yr),L(n,"`",xr),L(n,`^`,Sr),L(n,`:`,Cr),L(n,`,`,wr),L(n,`$`,Tr),L(n,`.`,z),L(n,`=`,Er),L(n,`!`,Dr),L(n,`-`,B),L(n,`%`,Or),L(n,`|`,kr),L(n,`+`,Ar),L(n,`#`,jr),L(n,`?`,Mr),L(n,`"`,Nr),L(n,`/`,V),L(n,`;`,Fr),L(n,`~`,Ir),L(n,`_`,Lr),L(n,`\\`,br),L(n,`・`,Pr);let r=I(n,U,Zn,{[kn]:!0});I(r,U,r);let i=I(r,H,Wn,{[Mn]:!0}),a=I(r,Vr,Gn,{[Nn]:!0}),o=I(n,H,R,{[An]:!0});I(o,U,i),I(o,H,o),I(i,U,i),I(i,H,i);let s=I(n,Vr,Un,{[jn]:!0});I(s,H),I(s,U,a),I(s,Vr,s),I(a,U,a),I(a,H),I(a,Vr,a);let c=L(n,Gr,$n,{[Rn]:!0}),l=L(n,Wr,Qn,{[Rn]:!0}),u=I(n,Ur,Qn,{[Rn]:!0});L(n,Jr,u),L(l,Gr,c),L(l,Jr,u),I(l,Ur,u),L(u,Wr),L(u,Gr),I(u,Ur,u),L(u,Jr,u);let d=I(n,Hr,Rr,{[Fn]:!0});L(d,`#`),I(d,Hr,d),L(d,Kr,d);let f=L(d,qr);L(f,`#`),I(f,Hr,d);let p=[[H,o],[U,i]],m=[[H,null],[Vr,s],[U,a]];for(let e=0;e<Yr.length;e++)ei(n,Yr[e],qn,R,p);for(let e=0;e<Xr.length;e++)ei(n,Xr[e],Jn,Un,m);Bn(qn,{tld:!0,ascii:!0},t),Bn(Jn,{utld:!0,alpha:!0},t),ei(n,`file`,Yn,R,p),ei(n,`mailto`,Yn,R,p),ei(n,`http`,Xn,R,p),ei(n,`https`,Xn,R,p),ei(n,`ftp`,Xn,R,p),ei(n,`ftps`,Xn,R,p),Bn(Yn,{scheme:!0,ascii:!0},t),Bn(Xn,{slashscheme:!0,ascii:!0},t),e=e.sort((e,t)=>e[0]>t[0]?1:-1);for(let t=0;t<e.length;t++){let r=e[t][0],i=e[t][1]?{[In]:!0}:{[Ln]:!0};r.indexOf(`-`)>=0?i[Pn]=!0:H.test(r)?U.test(r)?i[Mn]=!0:i[An]=!0:i[kn]=!0,Hn(n,r,r,i)}return Hn(n,`localhost`,Kn,{ascii:!0}),n.jd=new P(zr),{start:n,tokens:Object.assign({groups:t},Br)}}function Qr(e,t){let n=$r(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o<r;){let s=e,c=null,l=0,u=null,d=-1,f=-1;for(;o<r&&(c=s.go(n[o]));)s=c,s.accepts()?(d=0,f=0,u=s):d>=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function $r(e){let t=[],n=e.length,r=0;for(;r<n;){let i=e.charCodeAt(r),a,o=i<55296||i>56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function ei(e,t,n,r,i){let a,o=t.length;for(let n=0;n<o-1;n++){let o=t[n];e.j[o]?a=e.j[o]:(a=new P(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new P(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function ti(e){let t=[],n=[],r=0;for(;r<e.length;){let i=0;for(;`0123456789`.indexOf(e[r+i])>=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var ni={defaultProtocol:`http`,events:null,format:ii,formatHref:ii,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function ri(e,t=null){let n=Object.assign({},ni);e&&(n=Object.assign(n,e instanceof ri?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e<r.length;e++)i.push(r[e].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=i}ri.prototype={o:ni,ignoreTags:[],defaultRender(e){return e},check(e){return this.get(`validate`,e.toString(),e)},get(e,t,n){let r=t!=null,i=this.o[e];return i&&(typeof i==`object`?(i=n.t in i?i[n.t]:ni[e],typeof i==`function`&&r&&(i=i(t,n))):typeof i==`function`&&r&&(i=i(t,n.t,n)),i)},getObj(e,t,n){let r=this.o[e];return typeof r==`function`&&t!=null&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get(`render`,null,e)||this.defaultRender)(t,e.t,e)}};function ii(e){return e}function ai(e,t){this.t=`token`,this.v=e,this.tk=t}ai.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get(`truncate`,t,this),r=e.get(`format`,t,this);return n&&r.length>n?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=ni.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);return o.href=r,s&&(o.class=s),c&&(o.target=c),l&&(o.rel=l),u&&Object.assign(o,u),{tagName:i,attributes:o,content:a,eventListeners:d}}};function oi(e,t){class n extends ai{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}var si=oi(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),ci=oi(`text`),li=oi(`nl`),ui=oi(`url`,{isLink:!0,toHref(e=ni.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==Kn&&e[1].t===Cr}}),W=e=>new P(e);function di({groups:e}){let t=e.domain.concat([gr,vr,yr,br,xr,Sr,Tr,Er,B,Zn,Or,kr,Ar,jr,V,zr,Ir,Lr]),n=[_r,Cr,wr,z,Dr,Or,Mr,Nr,Fr,or,sr,er,tr,rr,nr,ir,ar,cr,lr,ur,dr,fr,pr,mr,hr],r=[gr,_r,vr,br,xr,Sr,Tr,Er,B,er,tr,Or,kr,Ar,jr,Mr,V,zr,Ir,Lr],i=W(),a=L(i,Ir);F(a,r,a),F(a,e.domain,a);let o=W(),s=W(),c=W();F(i,e.domain,o),F(i,e.scheme,s),F(i,e.slashscheme,c),F(o,r,a),F(o,e.domain,o);let l=L(o,yr);L(a,yr,l),L(s,yr,l),L(c,yr,l);let u=L(a,z);F(u,r,a),F(u,e.domain,a);let d=W();F(l,e.domain,d),F(d,e.domain,d);let f=L(d,z);F(f,e.domain,d);let p=W(si);F(f,e.tld,p),F(f,e.utld,p),L(l,Kn,p);let m=L(d,B);L(m,B,m),F(m,e.domain,d),F(p,e.domain,d),L(p,z,f),L(p,B,m);let h=L(o,B),g=L(o,z);L(h,B,h),F(h,e.domain,o),F(g,r,a),F(g,e.domain,o);let _=W(ui);F(g,e.tld,_),F(g,e.utld,_),F(_,e.domain,o),F(_,r,a),L(_,z,g),L(_,B,h),L(_,yr,l);let ee=L(_,Cr),te=W(ui);F(ee,e.numeric,te);let v=W(ui),ne=W();F(v,t,v),F(v,n,ne),F(ne,t,v),F(ne,n,ne),L(_,V,v),L(te,V,v);let re=L(s,Cr),ie=L(L(L(c,Cr),V),V);F(s,e.domain,o),L(s,z,g),L(s,B,h),F(c,e.domain,o),L(c,z,g),L(c,B,h),F(re,e.domain,v),L(re,V,v),L(re,Mr,v),F(ie,e.domain,v),F(ie,t,v),L(ie,V,v);let y=[[er,tr],[nr,rr],[ir,ar],[or,sr],[cr,lr],[ur,dr],[fr,pr],[mr,hr]];for(let e=0;e<y.length;e++){let[r,i]=y[e],a=L(v,r);L(ne,r,a);let o=W(ui);F(a,t,o);let s=W();F(a,n,s),L(a,i,v),F(o,t,o),F(o,n,s),F(s,t,o),F(s,n,s),L(o,i,v),L(s,i,v)}return L(i,Kn,_),L(i,$n,li),{start:i,tokens:Br}}function fi(e,t,n){let r=n.length,i=0,a=[],o=[];for(;i<r;){let s=e,c=null,l=null,u=0,d=null,f=-1;for(;i<r&&!(c=s.go(n[i].t));)o.push(n[i++]);for(;i<r&&(l=c||s.go(n[i].t));)c=null,s=l,s.accepts()?(f=0,d=s):f>=0&&f++,i++,u++;if(f<0)i-=u,i<r&&(o.push(n[i]),i++);else{o.length>0&&(a.push(pi(ci,t,o)),o=[]),i-=f,u-=f;let e=d.t,r=n.slice(i-u,i);a.push(pi(e,t,r))}}return o.length>0&&a.push(pi(ci,t,o)),a}function pi(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var mi=typeof console<`u`&&console&&console.warn||(()=>{}),hi=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,G={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function gi(){return P.groups={},G.scanner=null,G.parser=null,G.tokenQueue=[],G.pluginQueue=[],G.customSchemes=[],G.initialized=!1,G}function _i(e,t=!1){if(G.initialized&&mi(`linkifyjs: already initialized - will not register custom scheme "${e}" ${hi}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format.
26
+ 1. Must only contain digits, lowercase ASCII letters or "-"
27
+ 2. Cannot start or end with "-"
28
+ 3. "-" cannot repeat`);G.customSchemes.push([e,t])}function vi(){G.scanner=Zr(G.customSchemes);for(let e=0;e<G.tokenQueue.length;e++)G.tokenQueue[e][1]({scanner:G.scanner});G.parser=di(G.scanner.tokens);for(let e=0;e<G.pluginQueue.length;e++)G.pluginQueue[e][1]({scanner:G.scanner,parser:G.parser});return G.initialized=!0,G}function yi(e){return G.initialized||vi(),fi(G.parser.start,e,Qr(G.scanner.start,e))}yi.scan=Qr;function bi(e,t=null,n=null){if(t&&typeof t==`object`){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new ri(n),i=yi(e),a=[];for(let e=0;e<i.length;e++){let n=i[e];n.isLink&&(!t||n.t===t)&&r.check(n)&&a.push(n.toFormattedObject(r))}return a}var xi=`[\0- \xA0 ᠎ -\u2029  ]`,Si=new RegExp(xi),Ci=RegExp(`${xi}$`),wi=new RegExp(xi,`g`);function Ti(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function Ei(e){return new x({key:new D(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r,s=ke(n.doc,[...t]);if(ce(s).forEach(({newRange:t})=>{let n=Ke(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!Ci.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(Si).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=yi(n).map(t=>t.toObject(e.defaultProtocol));if(!Ti(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{ye(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function Di(e){return new x({key:new D(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.editor.view.dom;i=t.closest(`a`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){let n=ve(t.state,e.type.name),r=i.href??n.href,o=i.target??n.target;r&&(window.open(r,o),a=!0)}return a}}})}var Oi=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,ki=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function Ai(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function ji(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"){r+=1;continue}if(n===0&&Ai(e,r)){r+=1;continue}let i=0;for(;r<t&&e[r]==="`";)i+=1,r+=1;n===0?n=i:i===n&&(n=0)}return n>0}function Mi(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||Ai(e,t.index??0)||ji(e,t.index??0)?!1:!!r.trim()&&n(i)}function Ni(e){let[t,n,r,,i,a,o]=e,s=i??a??o;return{index:e.index??0,text:t,replaceWith:n,data:{href:r,title:s||null,markdown:!0}}}function Pi(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function Fi(e){return{href:e.data?.href,title:e.data?.title??null}}function Ii(e){let t=b({find:t=>{let n=Oi.exec(t);return!n||!Mi(t,n,e.isAllowedHref)?null:Ni(n)},type:e.type,getAttributes:Fi});return new Ne({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function Li(e){let t=C({find:t=>{let n=[];for(let r of t.matchAll(ki))Mi(t,r,e.isAllowedHref)&&n.push(Ni(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>Pi(t,e)));return[...n,...r]},type:e.type,getAttributes:Fi});return new De({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.match.data?.markdown&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function Ri(e){return new x({key:new D(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i}=e,{state:a}=t,{selection:o}=a,{empty:s}=o;if(s)return!1;let c=``;r.content.forEach(e=>{c+=e.textContent});let l=bi(c,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===c);return!c||!l||i!==void 0&&!i(l.value)?!1:e.editor.commands.setMark(e.type,{href:l.href})}}})}function K(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(wi,``).match(RegExp(`^(?:(?:${n.map(e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)).join(`|`)}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,`i`))}var zi=He.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{if(typeof e==`string`){_i(e);return}_i(e.scheme,e.optionalSlashes)})},onDestroy(){gi()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,class:null},isAllowedUri:(e,t)=>!!K(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes(`@`))return!0;let r=(e.includes(`@`)?e.split(`@`).pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target??null},rel:{default:this.options.HTMLAttributes.rel??null},class:{default:this.options.HTMLAttributes.class??null},title:{default:null}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!K(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!K(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,T(this.options.HTMLAttributes,e),0]:[`a`,T(this.options.HTMLAttributes,{...e,href:``}),0]},markdownTokenName:`link`,parseMarkdown:(e,t)=>t.applyMark(`link`,t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{let n=e.attrs?.href??``,r=e.attrs?.title??``,i=t.renderChildren(e);return r?`[${i}](${n} "${r}")`:`[${i}](${n})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!K(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!K(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addInputRules(){return this.options.markdownLinks?[Ii({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!K(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let e=e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options;bi(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!K(e,n),protocols:n,defaultProtocol:r})).forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t};return this.options.markdownLinks?[Li({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!K(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[C({find:e,type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(Ei({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!K(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(Di({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(Ri({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),Bi=Object.defineProperty,Vi=(e,t)=>{for(var n in t)Bi(e,n,{get:t[n],enumerable:!0})},Hi=`listItem`,Ui=`textStyle`,Wi=/^\s*([-+*])\s$/,Gi=k.create({name:`bulletList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul`}]},renderHTML({HTMLAttributes:e}){return[`ul`,T(this.options.HTMLAttributes,e),0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>e.type!==`list`||e.ordered?[]:{type:`bulletList`,content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
29
+ `):``,markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Hi,this.editor.getAttributes(Ui)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=be({find:Wi,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=be({find:Wi,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Ui),editor:this.editor})),[e]}}),Ki=(e,t,n)=>{let{selection:r}=e;if(!r.empty)return null;let{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let a=-1;for(let e=i.depth;e>0;--e)if(i.node(e).type.name===t){a=e;break}if(a<0)return null;let o=i.node(a),s=i.index(a);if(s+1>=o.childCount)return null;let c=o.child(s+1);if(!n.includes(c.type.name))return null;let l=e.schema.nodes[t],u=!1;if(c.forEach(e=>{e.type===l&&e.childCount>1&&(u=!0)}),!u)return null;let d=e.doc.resolve(i.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(e=>{f.push(e)}),f.length===0?null:{listItemDepth:a,nestedList:d,nestedListPos:i.after(),insertPos:i.after(a),items:f}},qi=(e,t,n,r)=>{let i=Ki(e,n,r);if(!i)return!1;let{selection:a}=e,{nestedList:o,nestedListPos:s,insertPos:c,items:l}=i,u=e.tr;u.delete(s,s+o.nodeSize);let d=u.mapping.map(c);return u.insert(d,A.from(l)),u.setSelection(a.map(u.doc,u.mapping)),t&&t(u),!0},Ji=(e,t,n)=>qi(e.state,e.view.dispatch,t,n),Yi=(e,t)=>O.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>Ji(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),Xi=[[1e3,`m`],[900,`cm`],[500,`d`],[400,`cd`],[100,`c`],[90,`xc`],[50,`l`],[40,`xl`],[10,`x`],[9,`ix`],[5,`v`],[4,`iv`],[1,`i`]],Zi=`abcdefghijklmnopqrstuvwxyz`,Qi=String.raw`\d+|[ivxlcdmIVXLCDM]+|${`[a-zA-Z]{1,2}`}`;function $i(e){let t=e,n=``;for(let[e,r]of Xi)for(;t>=e;)n+=r,t-=e;return n}function ea(e){return $i(e).toUpperCase()}function ta(e){let t=e.toLowerCase(),n=0,r=0;for(;n<t.length;){let e=!1;for(let[i,a]of Xi)if(t.startsWith(a,n)){r+=i,n+=a.length,e=!0;break}if(!e)return 0}return r}function na(e){if(!/^[ivxlcdmIVXLCDM]+$/.test(e))return!1;let t=ta(e);return t<=0?!1:(e===e.toLowerCase()?$i(t):ea(t))===e}function ra(e){let t=e.toLowerCase();if(t.length===1)return t.charCodeAt(0)-97+1;if(t.length===2){let e=t.charCodeAt(0)-97,n=t.charCodeAt(1)-97;return(e+1)*26+n+1}return 0}function ia(e){if(e<=26)return Zi[e-1];let t=Math.floor((e-1)/26)-1,n=(e-1)%26;return t<0?Zi[n]:Zi[t]+Zi[n]}function aa(e){if(!(!e||/^\d+$/.test(e))){if(na(e))return e===e.toLowerCase()?`i`:`I`;if(/^[a-z]{1,2}$/.test(e))return`a`;if(/^[A-Z]{1,2}$/.test(e))return`A`}}function oa(e){if(/^\d+$/.test(e))return parseInt(e,10);let t=aa(e);if(t===`i`||t===`I`)return ta(e);if(t===`a`||t===`A`){let t=ra(e);return t>0?t:1}let n=parseInt(e,10);return Number.isNaN(n)?1:n}function sa(e,t){if(e===`numeric`)return String(t);switch(e){case`a`:return ia(t);case`A`:return ia(t).toUpperCase();case`i`:return $i(t);case`I`:return ea(t);default:return String(t)}}function ca(e){if(e.length===0)return!1;let t=aa(e[0])??`numeric`,n=oa(e[0]);if(n<1)return!1;for(let r=0;r<e.length;r++){let i=sa(t,n+r);if(e[r]!==i)return!1}return!0}function la(e){return{type:aa(e),start:oa(e)}}function ua(e){let{type:t,start:n}=la(e),r={};return t&&(r.type=t),n!==1&&(r.start=n),r}function da(e,t,n=`. `){let r=t+1;if(!e||e===`1`)return`${r}${n}`;switch(e){case`a`:return`${ia(r)}${n}`;case`A`:return`${ia(r).toUpperCase()}${n}`;case`i`:return`${$i(r)}${n}`;case`I`:return`${ea(r)}${n}`;default:return`${r}${n}`}}function fa(e){let t=e.tokens?.[0];return!!(e.text&&e.tokens?.length===1&&t?.type===`list`&&t.ordered&&t.raw===e.text)}function pa(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:`text`,raw:e,text:e}])}var ma=k.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,T(this.options.HTMLAttributes,e),0]},markdownTokenName:`list_item`,parseMarkdown:(e,t)=>{if(e.type!==`list_item`)return[];let n=t.parseBlockChildren??t.parseChildren,r=[];if(e.tokens&&e.tokens.length>0){if(fa(e))return{type:`listItem`,content:[{type:`paragraph`,content:pa(e.text||``,t)}]};if(e.tokens.some(e=>e.type===`paragraph`))r=n(e.tokens);else{let i=e.tokens[0];if(i&&i.type===`text`&&i.tokens&&i.tokens.length>0){if(r=[{type:`paragraph`,content:t.parseInline(i.tokens)}],e.tokens.length>1){let t=n(e.tokens.slice(1));r.push(...t)}}else r=n(e.tokens)}}return r.length===0&&(r=[{type:`paragraph`,content:[]}]),{type:`listItem`,content:r}},renderMarkdown:(e,t,n)=>xe(e,t,e=>{if(e.parentType===`bulletList`)return`- `;if(e.parentType===`orderedList`){let t=e.meta?.parentAttrs?.start||1;return da(e.meta?.parentAttrs?.type,t-1+(e.index||0),`. `)}return`- `},n),addExtensions(){return[Yi(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});Vi({},{findListItemPos:()=>ha,getNextListDepth:()=>ga,handleBackspace:()=>va,handleDelete:()=>xa,hasListBefore:()=>_a,hasListItemAfter:()=>Sa,hasListItemBefore:()=>Ca,listItemHasSubList:()=>wa,nextListIsDeeper:()=>ya,nextListIsHigher:()=>ba});var ha=(e,t)=>{let{$from:n}=t.selection,r=le(e,t.schema),i=null,a=n.depth,o=n.pos,s=null;for(;a>0&&s===null;)i=n.node(a),i.type===r?s=a:(--a,--o);return s===null?null:{$pos:t.doc.resolve(o),depth:s}},ga=(e,t)=>{let n=ha(e,t);if(!n)return!1;let[,r]=ue(t,e,n.$pos.pos+4);return r},_a=(e,t,n)=>{let{$anchor:r}=e.selection,i=Math.max(0,r.pos-2),a=e.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},va=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!he(e.state,t)&&_a(e.state,t,n)){let{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),i=[];r.node().descendants((e,n)=>{e.type.name===t&&i.push({node:e,pos:n})});let a=i.at(-1);if(!a)return!1;let o=e.state.doc.resolve(r.start()+a.pos+1);return e.chain().cut({from:n.start()-1,to:n.end()+1},o.end()).joinForward().run()}return!he(e.state,t)||!me(e.state)?!1:e.chain().liftListItem(t).run()},ya=(e,t)=>{let n=ga(e,t),r=ha(e,t);return!r||!n?!1:n>r.depth},ba=(e,t)=>{let n=ga(e,t),r=ha(e,t);return!r||!n?!1:n<r.depth},xa=(e,t)=>{if(!he(e.state,t)||!je(e.state,t))return!1;let{selection:n}=e.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:ya(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():ba(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward()},Sa=(e,t)=>{let{$anchor:n}=t.selection,r=t.doc.resolve(n.pos-n.parentOffset-2);return r.index()!==r.parent.childCount-1&&r.nodeAfter?.type.name===e},Ca=(e,t)=>{let{$anchor:n}=t.selection,r=t.doc.resolve(n.pos-2);return r.index()!==0&&r.nodeBefore?.type.name===e},wa=(e,t,n)=>{if(!n)return!1;let r=le(e,t.schema),i=!1;return n.descendants(e=>{e.type===r&&(i=!0)}),i},Ta=O.create({name:`listKeymap`,addOptions(){return{listTypes:[{itemName:`listItem`,wrapperNames:[`bulletList`,`orderedList`]},{itemName:`taskItem`,wrapperNames:[`taskList`]}]}},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&xa(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&xa(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&va(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&va(e,n,r)&&(t=!0)}),t}}}}),Ea=RegExp(`^(\\s*)(${Qi})([.)])\\s+(.*)$`),Da=/^\s/,Oa={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function ka(e){return Ea.test(e.trimStart())}function Aa(e){let t=e.trimStart();return Oa.bulletItem.test(t)||ka(t)||Oa.heading.test(t)||Oa.thematicBreak.test(t)&&!t.startsWith(`-`)||/^>\s?/.test(t)||Oa.codeFence.test(t)}function ja(e){return Object.values(Oa).some(t=>t.test(e))}function Ma(e){let t=[],n=[],r=!1;return e.forEach(e=>{if(r){n.push(e);return}if(e.trim()===``){r=!0,n.push(e);return}if(t.length>0&&Aa(e)){r=!0,n.push(e);return}t.push(e)}),{paragraphLines:t,blockLines:n}}function Na(e){let t=[],n=0,r=0;for(;n<e.length;){let i=e[n],a=i.match(Ea);if(!a)break;let[,o,s,c,l]=a,u=o.length,d=parseInt(s,10),f=isNaN(d)?aa(s):void 0,p=isNaN(d)?oa(s):d,m=[l],h=n+1,g=[i],_=!1;for(;h<e.length;){let t=e[h];if(t.match(Ea))break;if(t.trim()===``)g.push(t),m.push(``),_=!0,h+=1;else if(t.match(Da)){let e=t.length-t.trimStart().length,n=u+s.length+1;g.push(t),m.push(t.slice(Math.min(e,n))),h+=1}else{if(_||ja(t))break;g.push(t),m.push(t),h+=1}}t.push({indent:u,number:p,type:f,content:m.join(`
30
+ `).trim(),contentLines:m,raw:g.join(`
31
+ `)}),r=h,n=h}return[t,r]}var Pa=RegExp(`^(${Qi})([.)])\\s+(.+)$`);function Fa(e){let t=e.split(`
32
+ `).filter(e=>e.trim().length>0);if(t.length===0)return null;let n=[];for(let e of t){let t=e.trim().match(Pa);if(!t)return null;n.push({marker:t[1],content:t[3]})}return ca(n.map(e=>e.marker))?{type:`orderedList`,attrs:ua(n[0].marker),content:n.map(e=>({type:`listItem`,content:[{type:`paragraph`,content:[{type:`text`,text:e.content}]}]}))}:null}function Ia(e,t,n){let r=[],i=0;for(;i<e.length;){let a=e[i];if(a.indent===t){let{paragraphLines:o,blockLines:s}=Ma(a.contentLines),c=o.join(`
33
+ `).trim(),l=[];c&&l.push({type:`paragraph`,raw:c,tokens:n.inlineTokens(c)});let u=s.join(`
34
+ `).trim();if(u){let e=n.blockTokens(u);l.push(...e)}let d=i+1,f=[];for(;d<e.length&&e[d].indent>t;)f.push(e[d]),d+=1;if(f.length>0){let e=Ia(f,Math.min(...f.map(e=>e.indent)),n);l.push({type:`list`,ordered:!0,start:f[0].number,typeMarker:f[0].type,items:e,raw:f.map(e=>e.raw).join(`
35
+ `)})}r.push({type:`list_item`,raw:a.raw,tokens:l}),i=d}else i+=1}return r}function La(e,t){return e.map(e=>{if(e.type!==`list_item`)return t.parseChildren([e])[0];let n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if(e.type===`paragraph`||e.type===`list`||e.type===`blockquote`||e.type===`code`)n.push(...t.parseChildren([e]));else if(e.type===`text`&&e.tokens){let r=t.parseChildren([e]);n.push({type:`paragraph`,content:r})}else{let r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:`listItem`,content:n}})}var Ra=`listItem`,za=`textStyle`,Ba=/^(\d+)\.\s$/;function Va(e){let t=e.match(/list-style-type\s*:\s*([^;]+)/i);if(!t)return null;switch(t[1].trim().toLowerCase()){case`upper-roman`:return`I`;case`lower-roman`:return`i`;case`upper-alpha`:case`upper-latin`:return`A`;case`lower-alpha`:case`lower-latin`:return`a`;default:return null}}var Ha=k.create({name:`orderedList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute(`start`)?parseInt(e.getAttribute(`start`)||``,10):1},type:{default:null,parseHTML:e=>{let t=e.getAttribute(`type`);if(t)return t;let n=e.getAttribute(`style`);if(n){let e=Va(n);if(e)return e}let r=e.querySelector(`li`);if(r){let e=r.getAttribute(`style`);if(e){let t=Va(e);if(t)return t}}return null}}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,type:n,...r}=e,i=T(this.options.HTMLAttributes,r);return t!==1&&(i.start=t),n&&n!==`1`&&(i.type=n),[`ol`,i,0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>{if(e.type!==`list`||!e.ordered)return[];let n=e.start||1,r=e.typeMarker,i=e.items?La(e.items,t):[],a={};return n!==1&&(a.start=n),r&&(a.type=r),Object.keys(a).length>0?{type:`orderedList`,attrs:a,content:i}:{type:`orderedList`,content:i}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
36
+ `):``,markdownTokenizer:{name:`orderedList`,level:`block`,start:()=>-1,tokenize:(e,t,n)=>{let r=e.split(`
37
+ `),[i,a]=Na(r);if(i.length===0)return;let o=Ia(i,i[0].indent,n);if(o.length!==0)return{type:`list`,ordered:!0,start:i[0]?.number||1,typeMarker:i[0]?.type,items:o,raw:r.slice(0,a).join(`
38
+ `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Ra,this.editor.getAttributes(za)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new x({props:{handlePaste:(e,t)=>{if((t.clipboardData?.getData(`text/html`))?.trim())return!1;let n=t.clipboardData?.getData(`text/plain`);if(!n)return!1;let r=Fa(n);if(!r)return!1;try{let t=e.state.schema.nodeFromJSON(r),n=e.state.tr.replaceSelectionWith(t);return e.dispatch(n),!0}catch{return!1}}}})]},addInputRules(){let e=(e,t)=>(!t.attrs.type||t.attrs.type===`1`)&&t.childCount+t.attrs.start===+e[1],t=be({find:Ba,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=be({find:Ba,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(za)}),joinPredicate:e,editor:this.editor})),[t]}}),Ua=/^\s*(\[([( |x])?\])\s$/,Wa=k.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,T(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>{let n=`- [${e.attrs?.checked?`x`:` `}] `;return xe(e,t,n)},addExtensions(){return this.options.nested?[Yi(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`),l=e=>{var t;s.ariaLabel=((t=this.options.a11y)?.checkboxLabel)?.call(t,e,s.checked)||`Task item checkbox for ${e.textContent||`empty task item`}`};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=ge(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[be({find:Ua,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),Ga=k.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return[`ul`,T(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode(`taskList`,{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
39
+ `):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=se(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(t){let r={type:`taskList`,raw:t.raw,items:t.items},i=e.slice(t.raw.length);return i.trim()?[r,...n.blockTokens(i)]:[r]}return n.blockTokens(e)},i=se(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});O.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(Gi.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(ma.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(Ta.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(Ha.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(Wa.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(Ga.configure(this.options.taskList)),e}});var Ka=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,qa=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Ja=He.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,T(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[b({find:Ka,type:this.type})]},addPasteRules(){return[C({find:qa,type:this.type})]}}),Ya=He.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,T(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.indexOf(`++`)},tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let i=r[2].trim();return{type:`underline`,raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Xa=O.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(dn.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(on.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(Gi.configure(this.options.bulletList)),this.options.code!==!1&&e.push(mn.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(vn.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(Re.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(kt.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(At.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(yn.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(bn.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(tn.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(xn.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(En.configure(this.options.italic)),this.options.listItem!==!1&&e.push(ma.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(Ta.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(zi.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(Ha.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(Fe.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(Ja.configure(this.options.strike)),this.options.text!==!1&&e.push(Be.configure(this.options.text)),this.options.underline!==!1&&e.push(Ya.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(en.configure(this.options?.trailingNode)),e}}),Za=e(t(),1),Qa=(e,t)=>{let n=t.view.domAtPos(e).node,r=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement;return r?r.offsetParent!==null:!1},$a=(e,t,n)=>{for(let r=e.depth;r>0;--r){let i=e.node(r),a=t(i),o=Qa(e.start(r),n);if(a&&o)return{pos:r>0?e.before(r):0,start:e.start(r),depth:r,node:i}}},eo=(e,t)=>{let{state:n,view:r,extensionManager:i}=e,{schema:a,selection:o}=n,{empty:s,$anchor:c}=o,l=!!i.extensions.find(e=>e.name===`gapCursor`);if(!s||c.parent.type!==a.nodes.detailsSummary||!l||t===`right`&&c.parentOffset!==c.parent.nodeSize-2)return!1;let u=Te(e=>e.type===a.nodes.details)(o);if(!u)return!1;let d=Ue(u.node,e=>e.type===a.nodes.detailsContent);if(!d.length||Qa(u.start+d[0].pos+1,e))return!1;let f=n.doc.resolve(u.pos+u.node.nodeSize),p=M.findFrom(f,1,!1);if(!p)return!1;let{tr:m}=n,h=new M(p);return m.setSelection(h),m.scrollIntoView(),r.dispatch(m),!0},to=k.create({name:`details`,content:`detailsSummary detailsContent`,group:`block`,defining:!0,isolating:!0,allowGapCursor:!1,addOptions(){return{persist:!1,openClassName:`is-open`,HTMLAttributes:{},renderToggleButton:({element:e,isOpen:t})=>{e.setAttribute(`aria-label`,t?`Collapse details content`:`Expand details content`)}}},addAttributes(){return this.options.persist?{open:{default:!1,parseHTML:e=>e.hasAttribute(`open`),renderHTML:({open:e})=>e?{open:``}:{}}}:[]},parseHTML(){return[{tag:`details`}]},renderHTML({HTMLAttributes:e}){return[`details`,T(this.options.HTMLAttributes,e),0]},...Oe({nodeName:`details`,content:`block`}),addNodeView(){return({editor:e,getPos:t,node:n,HTMLAttributes:r})=>{let i=document.createElement(`div`),a=T(this.options.HTMLAttributes,r,{"data-type":this.name});Object.entries(a).forEach(([e,t])=>i.setAttribute(e,t));let o=document.createElement(`button`);o.type=`button`;let s=e=>{this.options.renderToggleButton({element:o,...e})};i.append(o);let c=document.createElement(`div`);i.append(c);let l=e=>{let{setToValue:t,node:r=n}=e||{};if(t!==void 0)if(t){if(i.classList.contains(this.options.openClassName))return;i.classList.add(this.options.openClassName)}else{if(!i.classList.contains(this.options.openClassName))return;i.classList.remove(this.options.openClassName)}else i.classList.toggle(this.options.openClassName);let a=i.classList.contains(this.options.openClassName);s({isOpen:a,node:r});let o=new Event(`toggleDetailsContent`);c.querySelector(`:scope > div[data-type="detailsContent"]`)?.dispatchEvent(o)};return s({isOpen:!!n.attrs.open,node:n}),n.attrs.open&&setTimeout(()=>l()),o.addEventListener(`click`,()=>{if(l(),!this.options.persist){e.commands.focus(void 0,{scrollIntoView:!1});return}if(e.isEditable&&typeof t==`function`){let{from:n,to:r}=e.state.selection;e.chain().command(({tr:e})=>{let n=t();if(typeof n!=`number`)return!1;let r=e.doc.nodeAt(n);return r?.type===this.type&&(e.setNodeMarkup(n,void 0,{open:!r.attrs.open}),!0)}).setTextSelection({from:n,to:r}).focus(void 0,{scrollIntoView:!1}).run()}}),{dom:i,contentDOM:c,ignoreMutation(e){if(e.type===`selection`)return!1;let t=e.target,n=i.contains(t);return o.contains(t)||!n||i===t},update:e=>e.type===this.type&&(e.attrs.open===void 0?s({isOpen:i.classList.contains(this.options.openClassName),node:e}):l({setToValue:e.attrs.open,node:e}),!0)}}},addCommands(){return{setDetails:()=>({state:e,chain:t})=>{let{schema:n,selection:r}=e,{$from:i,$to:a}=r,o=i.blockRange(a);if(!o)return!1;let s=e.doc.slice(o.start,o.end);if(!n.nodes.detailsContent.contentMatch.matchFragment(s.content))return!1;let c=s.toJSON()?.content||[];return t().insertContentAt({from:o.start,to:o.end},{type:this.name,content:[{type:`detailsSummary`},{type:`detailsContent`,content:c}]}).setTextSelection(o.start+2).run()},unsetDetails:()=>({state:e,chain:t})=>{let{selection:n,schema:r}=e,i=Te(e=>e.type===this.type)(n);if(!i)return!1;let a=Ue(i.node,e=>e.type===r.nodes.detailsSummary),o=Ue(i.node,e=>e.type===r.nodes.detailsContent);if(!a.length||!o.length)return!1;let s=a[0],c=o[0],l=i.pos,u=e.doc.resolve(l),d={from:l,to:l+i.node.nodeSize},f=c.node.content.toJSON()||[],p=[u.parent.type.contentMatch.defaultType?.create(null,s.node.content).toJSON(),...f];return t().insertContentAt(d,p).setTextSelection(l+1).run()}}},addKeyboardShortcuts(){return{Backspace:()=>{let{schema:e,selection:t}=this.editor.state,{empty:n,$anchor:r}=t;return!n||r.parent.type!==e.nodes.detailsSummary?!1:r.parentOffset===0?this.editor.commands.unsetDetails():this.editor.commands.command(({tr:e})=>{let t=r.pos-1,n=r.pos;return e.delete(t,n),!0})},Enter:({editor:e})=>{let{state:t,view:n}=e,{schema:r,selection:i}=t,{$head:a}=i;if(a.parent.type!==r.nodes.detailsSummary)return!1;let o=Qa(a.after()+1,e),s=o?t.doc.nodeAt(a.after()):a.node(-2);if(!s)return!1;let c=o?0:a.indexAfter(-1),l=we(s.contentMatchAt(c));if(!l||!s.canReplaceWith(c,c,l))return!1;let u=l.createAndFill();if(!u)return!1;let d=o?a.after()+1:a.after(-1),f=t.tr.replaceWith(d,d,u),p=f.doc.resolve(d),m=E.near(p,1);return f.setSelection(m),f.scrollIntoView(),n.dispatch(f),!0},ArrowRight:({editor:e})=>eo(e,`right`),ArrowDown:({editor:e})=>eo(e,`down`)}},addProseMirrorPlugins(){return[new x({key:new D(`detailsSelection`),appendTransaction:(e,t,n)=>{let{editor:r,type:i}=this;if(r.view.composing||!e.some(e=>e.selectionSet)||!t.selection.empty||!n.selection.empty||!oe(n,i.name))return;let{$from:a}=n.selection;if(Qa(a.pos,r))return;let o=$a(a,e=>e.type===i,r);if(!o)return;let s=Ue(o.node,e=>e.type===n.schema.nodes.detailsSummary);if(!s.length)return;let c=s[0],l=(t.selection.from<n.selection.from?`forward`:`backward`)==`forward`?o.start+c.pos:o.pos+c.pos+c.node.nodeSize,u=w.create(n.doc,l);return n.tr.setSelection(u)}})]}}),no=k.create({name:`detailsContent`,content:`block+`,defining:!0,selectable:!1,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML({HTMLAttributes:e}){return[`div`,T(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},addNodeView(){return({HTMLAttributes:e})=>{let t=document.createElement(`div`),n=T(this.options.HTMLAttributes,e,{"data-type":this.name,hidden:`hidden`});return Object.entries(n).forEach(([e,n])=>t.setAttribute(e,n)),t.addEventListener(`toggleDetailsContent`,()=>{t.toggleAttribute(`hidden`)}),{dom:t,contentDOM:t,ignoreMutation(e){return e.type===`selection`?!1:!t.contains(e.target)||t===e.target},update:e=>e.type===this.type}}},addKeyboardShortcuts(){return{Enter:({editor:e})=>{let{state:t,view:n}=e,{selection:r}=t,{$from:i,empty:a}=r,o=Te(e=>e.type===this.type)(r);if(!a||!o||!o.node.childCount)return!1;let s=i.index(o.depth),{childCount:c}=o.node;if(c!==s+1)return!1;let l=o.node.type.contentMatch.defaultType?.createAndFill();if(!l)return!1;let u=t.doc.resolve(o.pos+1),d=c-1,f=o.node.child(d),p=u.posAtIndex(d,o.depth);if(!f.eq(l))return!1;let m=i.node(-3);if(!m)return!1;let h=i.indexAfter(-3),g=we(m.contentMatchAt(h));if(!g||!m.canReplaceWith(h,h,g))return!1;let _=g.createAndFill();if(!_)return!1;let{tr:ee}=t,te=i.after(-2);ee.replaceWith(te,te,_);let v=ee.doc.resolve(te),ne=E.near(v,1);ee.setSelection(ne);let re=p,ie=p+f.nodeSize;return ee.delete(re,ie),ee.scrollIntoView(),n.dispatch(ee),!0}}},...Oe({nodeName:`detailsContent`})}),ro=k.create({name:`detailsSummary`,content:`text*`,defining:!0,selectable:!1,isolating:!0,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`summary`}]},renderHTML({HTMLAttributes:e}){return[`summary`,T(this.options.HTMLAttributes,e),0]},...Oe({nodeName:`detailsSummary`,content:`inline`})}),io=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,ao=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,oo=He.create({name:`highlight`,addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute(`data-color`)||Me(e,`background-color`)||e.style.backgroundColor,renderHTML:e=>e.color?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:`mark`}]},renderHTML({HTMLAttributes:e}){return[`mark`,T(this.options.HTMLAttributes,e),0]},renderMarkdown:(e,t)=>`==${t.renderChildren(e)}==`,parseMarkdown:(e,t)=>t.applyMark(`highlight`,t.parseInline(e.tokens||[])),markdownTokenizer:{name:`highlight`,level:`inline`,start:e=>e.indexOf(`==`),tokenize(e,t,n){let r=/^(==)([^=]+)(==)/.exec(e);if(r){let e=r[2].trim(),t=n.inlineTokens(e);return{type:`highlight`,raw:r[0],text:e,tokens:t}}}},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[b({find:io,type:this.type})]},addPasteRules(){return[C({find:ao,type:this.type})]}}),so,co;if(typeof WeakMap<`u`){let e=new WeakMap;so=t=>e.get(t),co=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;so=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},co=(n,r)=>(t==10&&(t=0),e[t++]=n,e[t++]=r)}var q=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,i=t/this.width|0,a=r+1,o=i+1;for(let e=1;a<this.width&&this.map[t+e]==n;e++)a++;for(let e=1;o<this.height&&this.map[t+this.width*e]==n;e++)o++;return{left:r,top:i,right:a,bottom:o}}throw RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:i,top:a,bottom:o}=this.findCell(e);return t==`horiz`?(n<0?r==0:i==this.width)?null:this.map[a*this.width+(n<0?r-1:i)]:(n<0?a==0:o==this.height)?null:this.map[r+this.width*(n<0?a-1:o)]}rectBetween(e,t){let{left:n,right:r,top:i,bottom:a}=this.findCell(e),{left:o,right:s,top:c,bottom:l}=this.findCell(t);return{left:Math.min(n,o),top:Math.min(i,c),right:Math.max(r,s),bottom:Math.max(a,l)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){let a=r*this.width+i,o=this.map[a];n[o]||(n[o]=!0,!(i==e.left&&i&&this.map[a-1]==o||r==e.top&&r&&this.map[a-this.width]==o)&&t.push(o))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){let a=i+n.child(r).nodeSize;if(r==e){let n=t+e*this.width,r=(e+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?a-1:this.map[n]}i=a}}static get(e){return so(e)||co(e,lo(e))}};function lo(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=uo(e),n=e.childCount,r=[],i=0,a=null,o=[];for(let e=0,i=t*n;e<i;e++)r[e]=0;for(let s=0,c=0;s<n;s++){let l=e.child(s);c++;for(let e=0;;e++){for(;i<r.length&&r[i]!=0;)i++;if(e==l.childCount)break;let u=l.child(e),{colspan:d,rowspan:f,colwidth:p}=u.attrs;for(let e=0;e<f;e++){if(e+s>=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;e<d;e++){r[l+e]==0?r[l+e]=c:(a||=[]).push({type:`collision`,row:s,pos:c,n:d-e});let n=p&&p[e];if(n){let r=(l+e)%t*2,i=o[r];i==null||i!=n&&o[r+1]==1?(o[r]=n,o[r+1]=1):i==n&&o[r+1]++}}}i+=d,c+=u.nodeSize}let u=(s+1)*t,d=0;for(;i<u;)r[i++]==0&&d++;d&&(a||=[]).push({type:`missing`,row:s,n:d}),c++}(t===0||n===0)&&(a||=[]).push({type:`zero_sized`});let s=new q(t,n,r,a),c=!1;for(let e=0;!c&&e<o.length;e+=2)o[e]!=null&&o[e+1]<n&&(c=!0);return c&&fo(s,o,e),s}function uo(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let i=e.child(r),a=0;if(n)for(let t=0;t<r;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++){let i=n.child(e);t+i.attrs.rowspan>r&&(a+=i.attrs.colspan)}}for(let e=0;e<i.childCount;e++){let t=i.child(e);a+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function fo(e,t,n){e.problems||=[];let r={};for(let i=0;i<e.map.length;i++){let a=e.map[i];if(r[a])continue;r[a]=!0;let o=n.nodeAt(a);if(!o)throw RangeError(`No cell with offset ${a} found`);let s=null,c=o.attrs;for(let n=0;n<c.colspan;n++){let r=t[(i+n)%e.width*2];r!=null&&(!c.colwidth||c.colwidth[n]!=r)&&((s||=po(c))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function po(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function J(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}var mo=new D(`selectingCells`);function ho(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function go(e){for(let t=e.depth;t>0;t--){let n=e.node(t).type.spec.tableRole;if(n===`cell`||n===`header_cell`)return e.node(t)}return null}function Y(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function _o(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=ho(t.$head)||vo(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function vo(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function yo(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function bo(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function xo(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function So(e,t,n){let r=e.node(-1),i=q.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function Co(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function wo(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}function To(e,t,n){let r=J(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0}var X=class e extends E{constructor(e,t=e){let n=e.node(-1),r=q.get(n),i=e.start(-1),a=r.rectBetween(e.pos-i,t.pos-i),o=e.node(0),s=r.cellsInRect(a).filter(e=>e!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new Ce(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(yo(r)&&yo(i)&&xo(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return w.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=q.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n<r.bottom;n++){let o=[];for(let a=n*t.width+r.left,s=r.left;s<r.right;s++,a++){let n=t.map[a];if(i[n])continue;i[n]=!0;let s=t.findCell(n),c=e.nodeAt(n);if(!c)throw RangeError(`No cell with offset ${n} found`);let l=r.left-s.left,u=s.right-r.right;if(l>0||u>0){let e=c.attrs;if(l>0&&(e=Co(e,0,l)),u>0&&(e=Co(e,e.colspan-u,u)),s.left<r.left){if(c=c.type.createAndFill(e),!c)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else c=c.type.create(e,c.content)}if(s.top<r.top||s.bottom>r.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top<r.top?c.type.createAndFill(e):c.type.create(e,c.content)}o.push(c)}a.push(e.child(n).copy(A.from(o)))}let o=this.isColSelection()&&this.isRowSelection()?e:a;return new j(A.from(o),1,1)}replace(e,t=j.empty){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n);e.replace(s.map(a.pos),s.map(o.pos),i?j.empty:t)}let i=E.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new j(A.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=q.get(t),r=this.$anchorCell.start(-1),i=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<i.length;n++)e(t.nodeAt(i[n]),r+i[n])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=q.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom<i.height&&(n=c.resolve(a+i.map[i.width*(i.height-1)+s.right-1]))):(s.top>0&&(n=c.resolve(a+i.map[s.left])),o.bottom<i.height&&(t=c.resolve(a+i.map[i.width*(i.height-1)+o.right-1]))),new e(t,n)}isRowSelection(){let e=this.$anchorCell.node(-1),t=q.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),i=t.colCount(this.$headCell.pos-n);if(Math.min(r,i)>0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=q.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right<i.width&&(n=c.resolve(a+i.map[i.width*(s.top+1)-1]))):(s.left>0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right<i.width&&(t=c.resolve(a+i.map[i.width*(o.top+1)-1]))),new e(t,n)}toJSON(){return{type:`cell`,anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new Eo(this.$anchorCell.pos,this.$headCell.pos)}};X.prototype.visible=!1,E.jsonID(`cell`,X);var Eo=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){let t=e.resolve(this.anchor),n=e.resolve(this.head);return t.parent.type.spec.tableRole==`row`&&n.parent.type.spec.tableRole==`row`&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&xo(t,n)?new X(t,n):E.near(n,1)}};function Do(e){if(!(e.selection instanceof X))return null;let t=[];return e.selection.forEachCell((e,n)=>{t.push(fe.node(n,n+e.nodeSize,{class:`selectedCell`}))}),S.create(e.doc,t)}function Oo({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function ko({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function Ao(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof Le&&(o=r.node.type.spec.tableRole)){if(o==`cell`||o==`header_cell`)a=X.create(i,r.from);else if(o==`row`){let e=i.resolve(r.from+1);a=X.rowSelection(e,e)}else if(!n){let e=q.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];a=X.create(i,t+1,n)}}else r instanceof w&&Oo(r)?a=w.create(i,r.from):r instanceof w&&ko(r)&&(a=w.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var jo=new D(`fix-tables`);function Mo(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o<a;o++){let a=t.child(o);for(let t=s,r=Math.min(i,o+3);t<r;t++)if(e.child(t)==a){s=t+1,n+=a.nodeSize;continue outer}r(a,n),s<i&&e.child(s).sameMarkup(a)?Mo(e.child(s),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function No(e,t){let n,r=(t,r)=>{t.type.spec.tableRole==`table`&&(n=Po(e,t,r,n))};return t?t.doc!=e.doc&&Mo(t.doc,e.doc,0,r):e.doc.descendants(r),n}function Po(e,t,n,r){let i=q.get(t);if(!i.problems)return r;r||=e.tr;let a=[];for(let e=0;e<i.height;e++)a.push(0);for(let e=0;e<i.problems.length;e++){let o=i.problems[e];if(o.type==`collision`){let e=t.nodeAt(o.pos);if(!e)continue;let i=e.attrs;for(let e=0;e<i.rowspan;e++)a[o.row+e]+=o.n;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,Co(i,i.colspan-o.n,o.n))}else if(o.type==`missing`)a[o.row]+=o.n;else if(o.type==`overlong_rowspan`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-o.n})}else if(o.type==`colwidth mismatch`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,colwidth:o.colwidth})}else if(o.type==`zero_sized`){let e=r.mapping.map(n);r.delete(e,e+t.nodeSize)}}let o,s;for(let e=0;e<a.length;e++)a[e]&&(o??=e,s=e);for(let c=0,l=n+1;c<i.height;c++){let n=t.child(c),i=l+n.nodeSize,u=a[c];if(u>0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n<u;n++){let n=J(e.schema)[t].createAndFill();n&&a.push(n)}let d=(c==0||o==c-1)&&s==c?l+1:i-1;r.insert(r.mapping.map(d),a)}l=i}return r.setMeta(jo,{fixTables:!0})}function Z(e){let t=e.selection,n=_o(e),r=n.node(-1),i=n.start(-1),a=q.get(r);return{...t instanceof X?a.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):a.findCell(n.pos-i),tableStart:i,map:a,table:r}}function Fo(e,{map:t,tableStart:n,table:r},i){let a=i>0?-1:0;To(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o<t.height;o++){let s=o*t.width+i;if(i>0&&i<t.width&&t.map[s-1]==t.map[s]){let a=t.map[s],c=r.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,wo(c.attrs,i-t.colCount(a))),o+=c.attrs.rowspan-1}else{let c=a==null?J(r.type.schema).cell:r.nodeAt(t.map[s+a]).type,l=t.positionAt(o,i,r);e.insert(e.mapping.map(n+l),c.createAndFill())}}return e}function Io(e,t){if(!Y(e))return!1;if(t){let n=Z(e);t(Fo(e.tr,n,n.left))}return!0}function Lo(e,t){if(!Y(e))return!1;if(t){let n=Z(e);t(Fo(e.tr,n,n.right))}return!0}function Ro(e,{map:t,table:n,tableStart:r},i){let a=e.mapping.maps.length;for(let o=0;o<t.height;){let s=o*t.width+i,c=t.map[s],l=n.nodeAt(c),u=l.attrs;if(i>0&&t.map[s-1]==c||i<t.width-1&&t.map[s+1]==c)e.setNodeMarkup(e.mapping.slice(a).map(r+c),null,Co(u,i-t.colCount(c)));else{let t=e.mapping.slice(a).map(r+c);e.delete(t,t+l.nodeSize)}o+=u.rowspan}}function zo(e,t){if(!Y(e))return!1;if(t){let n=Z(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let e=n.right-1;Ro(r,n,e),e!=n.left;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=q.get(e)}t(r)}return!0}function Bo(e,t,n){let r=J(t.type.schema).header_cell;for(let i=0;i<e.width;i++)if(t.nodeAt(e.map[i+n*e.width])?.type!=r)return!1;return!0}function Vo(e,{map:t,tableStart:n,table:r},i){let a=n;for(let e=0;e<i;e++)a+=r.child(e).nodeSize;let o=[],s=i>0?-1:0;Bo(t,r,i+s)&&(s=i==0||i==t.height?null:0);for(let a=0,c=t.width*i;a<t.width;a++,c++)if(i>0&&i<t.height&&t.map[c]==t.map[c-t.width]){let i=t.map[c],o=r.nodeAt(i).attrs;e.setNodeMarkup(n+i,null,{...o,rowspan:o.rowspan+1}),a+=o.colspan-1}else{let e=(s==null?J(r.type.schema).cell:r.nodeAt(t.map[c+s*t.width])?.type)?.createAndFill();e&&o.push(e)}return e.insert(a,J(r.type.schema).row.create(null,o)),e}function Ho(e,t){if(!Y(e))return!1;if(t){let n=Z(e);t(Vo(e.tr,n,n.top))}return!0}function Uo(e,t){if(!Y(e))return!1;if(t){let n=Z(e);t(Vo(e.tr,n,n.bottom))}return!0}function Wo(e,{map:t,table:n,tableStart:r},i){let a=0;for(let e=0;e<i;e++)a+=n.child(e).nodeSize;let o=a+n.child(i).nodeSize,s=e.mapping.maps.length;e.delete(a+r,o+r);let c=new Set;for(let a=0,o=i*t.width;a<t.width;a++,o++){let l=t.map[o];if(!c.has(l)){if(c.add(l),i>0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i<t.height&&l==t.map[o+t.width]){let o=n.nodeAt(l),c=o.attrs,u=o.type.create({...c,rowspan:o.attrs.rowspan-1},o.content),d=t.positionAt(i+1,a,n);e.insert(e.mapping.slice(s).map(r+d),u),a+=c.colspan-1}}}}function Go(e,t){if(!Y(e))return!1;if(t){let n=Z(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;Wo(r,n,e),e!=n.top;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=q.get(n.table)}t(r)}return!0}function Ko(e){let t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function qo({width:e,height:t,map:n},r){let i=r.top*e+r.left,a=i,o=(r.bottom-1)*e+r.left,s=i+(r.right-r.left-1);for(let t=r.top;t<r.bottom;t++){if(r.left>0&&n[a]==n[a-1]||r.right<e&&n[s]==n[s+1])return!0;a+=e,s+=e}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[i]==n[i-e]||r.bottom<t&&n[o]==n[o+e])return!0;i++,o++}return!1}function Jo(e,t){let n=e.selection;if(!(n instanceof X)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=Z(e),{map:i}=r;if(qo(i,r))return!1;if(t){let n=e.tr,a={},o=A.empty,s,c;for(let e=r.top;e<r.bottom;e++)for(let t=r.left;t<r.right;t++){let l=i.map[e*i.width+t],u=r.table.nodeAt(l);if(!(a[l]||!u))if(a[l]=!0,s==null)s=l,c=u;else{Ko(u)||(o=o.append(u.content));let e=n.mapping.map(l+r.tableStart);n.delete(e,e+u.nodeSize)}}if(s==null||c==null)return!0;if(n.setNodeMarkup(s+r.tableStart,null,{...wo(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),o.size>0){let e=s+1+c.content.size,t=Ko(c)?s+1:e;n.replaceWith(t+r.tableStart,e+r.tableStart,o)}n.setSelection(new X(n.doc.resolve(s+r.tableStart))),t(n)}return!0}function Yo(e,t){let n=J(e.schema);return Xo(({node:e})=>n[e.type.spec.tableRole])(e,t)}function Xo(e){return(t,n)=>{let r=t.selection,i,a;if(r instanceof X){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,a=r.$anchorCell.pos}else{if(i=go(r.$from),!i)return!1;a=ho(r.$from)?.pos}if(i==null||a==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let o=i.attrs,s=[],c=o.colwidth;o.rowspan>1&&(o={...o,rowspan:1}),o.colspan>1&&(o={...o,colspan:1});let l=Z(t),u=t.tr;for(let e=0;e<l.right-l.left;e++)s.push(c?{...o,colwidth:c&&c[e]?[c[e]]:null}:o);let d;for(let t=l.top;t<l.bottom;t++){let n=l.map.positionAt(t,l.left,l.table);t==l.top&&(n+=i.nodeSize);for(let r=l.left,a=0;r<l.right;r++,a++)(r!=l.left||t!=l.top)&&u.insert(d=u.mapping.map(n+l.tableStart,1),e({node:i,row:t,col:r}).createAndFill(s[a]))}u.setNodeMarkup(a,e({node:i,row:l.top,col:l.left}),s[0]),r instanceof X&&u.setSelection(new X(u.doc.resolve(r.$anchorCell.pos),d?u.doc.resolve(d):void 0)),n(u)}return!0}}function Zo(e,t){return function(n,r){if(!Y(n))return!1;let i=_o(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){let a=n.tr;n.selection instanceof X?n.selection.forEachCell((n,r)=>{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function Qo(e){return function(t,n){if(!Y(t))return!1;if(n){let r=J(t.schema),i=Z(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e<o.length;e++)s[e].type==r.header_cell&&a.setNodeMarkup(i.tableStart+o[e],r.cell,s[e].attrs);if(a.steps.length===0)for(let e=0;e<o.length;e++)a.setNodeMarkup(i.tableStart+o[e],r.header_cell,s[e].attrs);n(a)}return!0}}function $o(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e==`row`?t.map.width:1,bottom:e==`column`?t.map.height:1});for(let e=0;e<r.length;e++){let i=t.table.nodeAt(r[e]);if(i&&i.type!==n.header_cell)return!1}return!0}function es(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?Qo(e):function(t,n){if(!Y(t))return!1;if(n){let r=J(t.schema),i=Z(t),a=t.tr,o=$o(`row`,i,r),s=$o(`column`,i,r),c=(e===`column`?o:e===`row`&&s)?1:0,l=e==`column`?{left:0,top:c,right:1,bottom:i.map.height}:e==`row`?{left:c,top:0,right:i.map.width,bottom:1}:i,u=e==`column`?s?r.cell:r.header_cell:e==`row`?o?r.cell:r.header_cell:r.cell;i.map.cellsInRect(l).forEach(e=>{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}es(`row`,{useDeprecatedLogic:!0}),es(`column`,{useDeprecatedLogic:!0});var ts=es(`cell`,{useDeprecatedLogic:!0});function ns(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let t=e.node(-1);for(let n=e.indexAfter(-1),r=e.after();n<t.childCount;n++){let e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}function rs(e){return function(t,n){if(!Y(t))return!1;let r=ns(_o(t),e);if(r==null)return!1;if(n){let e=t.doc.resolve(r);n(t.tr.setSelection(w.between(e,bo(e))).scrollIntoView())}return!0}}function is(e,t){let n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function as(e,t){let n=e.selection;if(!(n instanceof X))return!1;if(t){let r=e.tr,i=J(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new j(i,0,0))}),r.docChanged&&t(r)}return!0}function os(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole==`table`);)n--,r--,t=t.child(0).content;let i=t.child(0),a=i.type.spec.tableRole,o=i.type.schema,s=[];if(a==`row`)for(let e=0;e<t.childCount;e++){let i=t.child(e).content,a=e?0:Math.max(0,n-1),c=e<t.childCount-1?0:Math.max(0,r-1);(a||c)&&(i=cs(J(o).row,new j(i,a,c)).content),s.push(i)}else if(a==`cell`||a==`header_cell`)s.push(n||r?cs(J(o).row,new j(t,n,r)).content:t);else return null;return ss(o,s)}function ss(e,t){let n=[];for(let e=0;e<t.length;e++){let r=t[e];for(let t=r.childCount-1;t>=0;t--){let{rowspan:i,colspan:a}=r.child(t).attrs;for(let t=e;t<e+i;t++)n[t]=(n[t]||0)+a}}let r=0;for(let e=0;e<n.length;e++)r=Math.max(r,n[e]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(A.empty),n[i]<r){let a=J(e).cell.createAndFill(),o=[];for(let e=n[i];e<r;e++)o.push(a);t[i]=t[i].append(A.from(o))}return{height:t.length,width:r,rows:t}}function cs(e,t){let n=e.createAndFill();return new Ee(n).replace(0,n.content.size,t).doc}function ls({width:e,height:t,rows:n},r,i){if(e!=r){let t=[],i=[];for(let e=0;e<n.length;e++){let a=n[e],o=[];for(let n=t[e]||0,i=0;n<r;i++){let s=a.child(i%a.childCount);n+s.attrs.colspan>r&&(s=s.type.createChecked(Co(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),o.push(s),n+=s.attrs.colspan;for(let n=1;n<s.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+s.attrs.colspan}i.push(A.from(o))}n=i,e=r}if(t!=i){let e=[];for(let r=0,a=0;r<i;r++,a++){let o=[],s=n[a%t];for(let e=0;e<s.childCount;e++){let t=s.child(e);r+t.attrs.rowspan>i&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),o.push(t)}e.push(A.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function us(e,t,n,r,i,a,o){let s=e.doc.type.schema,c=J(s),l,u;if(i>t.width)for(let a=0,s=0;a<t.height;a++){let d=n.child(a);s+=d.nodeSize;let f=[],p;p=d.lastChild==null||d.lastChild.type==c.cell?l||=c.cell.createAndFill():u||=c.header_cell.createAndFill();for(let e=t.width;e<i;e++)f.push(p);e.insert(e.mapping.slice(o).map(s-1+r),f)}if(a>t.height){let s=[];for(let e=0,r=(t.height-1)*t.width;e<Math.max(t.width,i);e++){let i=e>=t.width?!1:n.nodeAt(t.map[r+e]).type==c.header_cell;s.push(i?u||=c.header_cell.createAndFill():l||=c.cell.createAndFill())}let d=c.row.create(null,A.from(s)),f=[];for(let e=t.height;e<a;e++)f.push(d);e.insert(e.mapping.slice(o).map(r+n.nodeSize-2),f)}return!!(l||u)}function ds(e,t,n,r,i,a,o,s){if(o==0||o==t.height)return!1;let c=!1;for(let l=i;l<a;l++){let i=o*t.width+l,a=t.map[i];if(t.map[i-t.width]==a){c=!0;let i=n.nodeAt(a),{top:u,left:d}=t.findCell(a);e.setNodeMarkup(e.mapping.slice(s).map(a+r),null,{...i.attrs,rowspan:o-u}),e.insert(e.mapping.slice(s).map(t.positionAt(o,d,n)),i.type.createAndFill({...i.attrs,rowspan:u+i.attrs.rowspan-o})),l+=i.attrs.colspan-1}}return c}function fs(e,t,n,r,i,a,o,s){if(o==0||o==t.width)return!1;let c=!1;for(let l=i;l<a;l++){let i=l*t.width+o,a=t.map[i];if(t.map[i-1]==a){c=!0;let i=n.nodeAt(a),u=t.colCount(a),d=e.mapping.slice(s).map(a+r);e.setNodeMarkup(d,null,Co(i.attrs,o-u,i.attrs.colspan-(o-u))),e.insert(d+i.nodeSize,i.type.createAndFill(Co(i.attrs,0,o-u))),l+=i.attrs.rowspan-1}}return c}function ps(e,t,n,r,i){let a=n?e.doc.nodeAt(n-1):e.doc;if(!a)throw Error(`No table found`);let o=q.get(a),{top:s,left:c}=r,l=c+i.width,u=s+i.height,d=e.tr,f=0;function p(){if(a=n?d.doc.nodeAt(n-1):d.doc,!a)throw Error(`No table found`);o=q.get(a),f=d.mapping.maps.length}us(d,o,a,n,l,u,f)&&p(),ds(d,o,a,n,c,l,s,f)&&p(),ds(d,o,a,n,c,l,u,f)&&p(),fs(d,o,a,n,s,u,c,f)&&p(),fs(d,o,a,n,s,u,l,f)&&p();for(let e=s;e<u;e++){let t=o.positionAt(e,c,a),r=o.positionAt(e,l,a);d.replace(d.mapping.slice(f).map(t+n),d.mapping.slice(f).map(r+n),new j(i.rows[e-s],0,0))}p(),d.setSelection(new X(d.doc.resolve(n+o.positionAt(s,c,a)),d.doc.resolve(n+o.positionAt(u-1,l-1,a)))),t(d)}var ms=Se({ArrowLeft:gs(`horiz`,-1),ArrowRight:gs(`horiz`,1),ArrowUp:gs(`vert`,-1),ArrowDown:gs(`vert`,1),"Shift-ArrowLeft":_s(`horiz`,-1),"Shift-ArrowRight":_s(`horiz`,1),"Shift-ArrowUp":_s(`vert`,-1),"Shift-ArrowDown":_s(`vert`,1),Backspace:as,"Mod-Backspace":as,Delete:as,"Mod-Delete":as});function hs(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function gs(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection;if(a instanceof X)return hs(n,r,E.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=xs(i,e,t);if(o==null)return!1;if(e==`horiz`)return hs(n,r,E.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=So(i,e,t),s;return s=a?E.near(a,1):t<0?E.near(n.doc.resolve(i.before(-1)),-1):E.near(n.doc.resolve(i.after(-1)),1),hs(n,r,s)}}}function _s(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof X)o=a;else{let r=xs(i,e,t);if(r==null)return!1;o=new X(n.doc.resolve(r))}let s=So(o.$headCell,e,t);return s?hs(n,r,new X(o.$anchorCell,s)):!1}}function vs(e,t){let n=e.state.doc,r=ho(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new X(r))),!0):!1}function ys(e,t,n){if(!Y(e.state))return!1;let r=os(n),i=e.state.selection;if(i instanceof X){r||={width:1,height:1,rows:[A.from(cs(J(e.state.schema).cell,n))]};let t=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),o=q.get(t).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=ls(r,o.right-o.left,o.bottom-o.top),ps(e.state,e.dispatch,a,o,r),!0}if(r){let t=_o(e.state),n=t.start(-1);return ps(e.state,e.dispatch,n,q.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function bs(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=Ss(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof X)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=ho(e.state.selection.$anchor))!=null&&Cs(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=Cs(e,n),i=mo.getState(e.state)==null;if(!r||!xo(t,r))if(i)r=t;else return;let a=new X(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(mo,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),mo.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(mo,-1))}function o(r){let o=r,s=mo.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(Ss(e,o.target)!=n&&(c=Cs(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function xs(e,t,n){if(!(e.state.selection instanceof w))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function Ss(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function Cs(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&ho(e.state.doc.resolve(r))||ho(e.state.doc.resolve(i))}var ws=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`)),this.table.style.setProperty(`--default-cell-min-width`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),Ts(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type&&(this.node=e,Ts(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function Ts(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;e<l.childCount;e++){let{colspan:u,colwidth:d}=l.child(e).attrs;for(let e=0;e<u;e++,n++){let l=i==n?a:d&&d[e],u=l?l+`px`:``;if(o+=l||r,l||(s=!1),c)c.style.width!=u&&(c.style.width=u),c=c.nextSibling;else{let e=document.createElement(`col`);e.style.width=u,t.appendChild(e)}}}for(;c;){var u;let e=c.nextSibling;(u=c.parentNode)==null||u.removeChild(c),c=e}s?(n.style.width=o+`px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=o+`px`)}}var Q=new D(`tableColumnResizing`);function Es({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=ws,lastColumnResizable:i=!0}={}){let a=new x({key:Q,state:{init(e,t){var i;let o=(i=a.spec)==null||(i=i.props)==null?void 0:i.nodeViews,s=J(t.schema).table.name;return r&&o&&(o[s]=(e,t)=>new r(e,n,t)),new Ds(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=Q.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{Os(t,n,e,i)},mouseleave:e=>{ks(e)},mousedown:(e,r)=>{As(e,r,t,n)}},decorations:e=>{let t=Q.getState(e);if(t&&t.activeHandle>-1)return zs(e,t.activeHandle)},nodeViews:{}}});return a}var Ds=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(Q);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return yo(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function Os(e,t,n,r){if(!e.editable)return;let i=Q.getState(e.state);if(i&&!i.dragging){let a=Ms(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=Ns(e,t,`left`,n):i-t.clientX<=n&&(o=Ns(e,t,`right`,n))}if(o!=i.activeHandle){if(!r&&o!==-1){let t=e.state.doc.resolve(o),n=t.node(-1),r=q.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}Fs(e,o)}}}function ks(e){if(!e.editable)return;let t=Q.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&Fs(e,-1)}function As(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=Q.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=js(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(Q,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=Q.getState(e.state);r?.dragging&&(Is(e,r.activeHandle,Ps(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(Q,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=Q.getState(e.state);if(i&&i.dragging){let a=Ps(i.dragging,t,n);Ls(e,i.activeHandle,a,r)}}return Ls(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function js(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;e<n;e++)r[e]&&(o-=r[e],s--);return o/s}function Ms(e){for(;e&&e.nodeName!=`TD`&&e.nodeName!=`TH`;)e=e.classList&&e.classList.contains(`ProseMirror`)?null:e.parentNode;return e}function Ns(e,t,n,r){let i=n==`right`?-r:r,a=e.posAtCoords({left:t.clientX+i,top:t.clientY});if(!a)return-1;let{pos:o}=a,s=ho(e.state.doc.resolve(o));if(!s)return-1;if(n==`right`)return s.pos;let c=q.get(s.node(-1)),l=s.start(-1),u=c.map.indexOf(s.pos-l);return u%c.width==0?-1:l+c.map[u-1]}function Ps(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function Fs(e,t){e.dispatch(e.state.tr.setMeta(Q,{setHandle:t}))}function Is(e,t,n){let r=e.state.doc.resolve(t),i=r.node(-1),a=q.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,c=e.state.tr;for(let e=0;e<a.height;e++){let t=e*a.width+s;if(e&&a.map[t]==a.map[t-a.width])continue;let r=a.map[t],l=i.nodeAt(r).attrs,u=l.colspan==1?0:s-a.colCount(r);if(l.colwidth&&l.colwidth[u]==n)continue;let d=l.colwidth?l.colwidth.slice():Rs(l.colspan);d[u]=n,c.setNodeMarkup(o+r,null,{...l,colwidth:d})}c.docChanged&&e.dispatch(c)}function Ls(e,t,n,r){let i=e.state.doc.resolve(t),a=i.node(-1),o=i.start(-1),s=q.get(a).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1,c=e.domAtPos(i.start(-1)).node;for(;c&&c.nodeName!=`TABLE`;)c=c.parentNode;c&&Ts(a,c.firstChild,c,r,s,n)}function Rs(e){return Array(e).fill(0)}function zs(e,t){let n=[],r=e.doc.resolve(t),i=r.node(-1);if(!i)return S.empty;let a=q.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let t=0;t<a.height;t++){let r=s+t*a.width;if((s==a.width-1||a.map[r]!=a.map[r+1])&&(t==0||a.map[r]!=a.map[r-a.width])){let t=a.map[r],s=o+t+i.nodeAt(t).nodeSize-1,c=document.createElement(`div`);c.className=`column-resize-handle`,Q.getState(e)?.dragging&&n.push(fe.node(o+t,o+t+i.nodeAt(t).nodeSize,{class:`column-resize-dragging`})),n.push(fe.widget(s,c))}}return S.create(e.doc,n)}function Bs({allowTableNodeSelection:e=!1}={}){return new x({key:mo,state:{init(){return null},apply(e,t){let n=e.getMeta(mo);if(n!=null)return n==-1?null:n;if(t==null||!e.docChanged)return t;let{deleted:r,pos:i}=e.mapping.mapResult(t);return r?null:i}},props:{decorations:Do,handleDOMEvents:{mousedown:bs},createSelectionBetween(e){return mo.getState(e.state)==null?null:e.state.selection},handleTripleClick:vs,handleKeyDown:ms,handlePaste:ys},appendTransaction(t,n,r){return Ao(r,No(r,n),e)}})}function Vs(e){return e===`left`||e===`right`||e===`center`?e:null}function Hs(e){let t=(e.style.textAlign||``).trim().toLowerCase(),n=(e.getAttribute(`align`)||``).trim().toLowerCase();return Vs(t||n)}function Us(e){return Vs(e?.align)}function Ws(){return{default:null,parseHTML:e=>Hs(e),renderHTML:e=>e.align?{style:`text-align: ${e.align}`}:{}}}function Gs(e){let t=e.parentElement,n=e.closest(`table`);if(!t||!n)return null;let r=Array.from(t.children).indexOf(e),i=n.querySelectorAll(`colgroup > col`)[r]?.getAttribute(`width`);return i?[parseInt(i,10)]:null}function Ks(e){let t=e.getAttribute(`colwidth`);return t?t.split(`,`).map(e=>parseInt(e,10)):Gs(e)}var qs=/[ \t\r\n\f]+/g;function Js(e){return e.children.length>0?!1:(e.textContent??``).replace(qs,``)===``}function Ys(e){let t=e.createAndFill();if(!t)throw Error(`[tiptap error]: "${e.name}" has no default content to backfill.`);return t.content}var Xs=k.create({name:`tableCell`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:Ks},align:Ws()}},tableRole:`cell`,isolating:!0,parseHTML(){return[{tag:`td`,getAttrs:e=>Js(e)?{}:!1,getContent:(e,t)=>Ys(t.nodes[this.name])},{tag:`td`}]},renderHTML({HTMLAttributes:e}){return[`td`,T(this.options.HTMLAttributes,e),0]}}),Zs=k.create({name:`tableHeader`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:Ks},align:Ws()}},tableRole:`header_cell`,isolating:!0,parseHTML(){return[{tag:`th`,getAttrs:e=>Js(e)?{}:!1,getContent:(e,t)=>Ys(t.nodes[this.name])},{tag:`th`}]},renderHTML({HTMLAttributes:e}){return[`th`,T(this.options.HTMLAttributes,e),0]}}),Qs=k.create({name:`tableRow`,addOptions(){return{HTMLAttributes:{}}},content:`(tableCell | tableHeader)*`,tableRole:`row`,parseHTML(){return[{tag:`tr`}]},renderHTML({HTMLAttributes:e}){return[`tr`,T(this.options.HTMLAttributes,e),0]}});function $s(e,t){return t?[`width`,`${Math.max(t,e)}px`]:[`min-width`,`${e}px`]}function ec(e,t,n,r,i,a){var o;let s=0,c=!0,l=t.firstChild,u=e.firstChild;if(u!==null)for(let e=0,n=0;e<u.childCount;e+=1){let{colspan:o,colwidth:d}=u.child(e).attrs;for(let e=0;e<o;e+=1,n+=1){let o=i===n?a:d&&d[e],u=o?`${o}px`:``;if(s+=o||r,o||(c=!1),l){if(l.style.width!==u){let[e,t]=$s(r,o);l.style.setProperty(e,t)}l=l.nextSibling}else{let e=document.createElement(`col`),[n,i]=$s(r,o);e.style.setProperty(n,i),t.appendChild(e)}}}for(;l;){let e=l.nextSibling;(o=l.parentNode)==null||o.removeChild(l),l=e}let d=e.attrs.style&&typeof e.attrs.style==`string`&&/\bwidth\s*:/i.test(e.attrs.style);c&&!d?(n.style.width=`${s}px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=`${s}px`)}var tc=class{constructor(e,t,n,r={}){this.node=e,this.cellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`));for(let[e,t]of Object.entries(r))t!=null&&(e===`style`?this.table.style.cssText=String(t):this.table.setAttribute(e,String(t)));e.attrs.style&&(this.table.style.cssText=e.attrs.style),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),ec(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type===this.node.type&&(this.node=e,ec(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){let t=e.target,n=this.dom.contains(t),r=this.contentDOM.contains(t);return!!(n&&!r&&(e.type===`attributes`||e.type===`childList`||e.type===`characterData`))}};function nc(e,t,n,r){let i=0,a=!0,o=[],s=e.firstChild;if(!s)return{};for(let e=0,c=0;e<s.childCount;e+=1){let{colspan:l,colwidth:u}=s.child(e).attrs;for(let e=0;e<l;e+=1,c+=1){let s=n===c?r:u&&u[e];i+=s||t,s||(a=!1);let[l,d]=$s(t,s);o.push([`col`,{style:`${l}: ${d}`}])}}let c=a?`${i}px`:``,l=a?``:`${i}px`;return{colgroup:[`colgroup`,{},...o],tableWidth:c,tableMinWidth:l}}function rc(e,t){return t?e.createChecked(null,t):e.createAndFill()}function ic(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;let t={};return Object.keys(e.nodes).forEach(n=>{let r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function ac(e,t,n,r,i){let a=ic(e),o=[],s=[];for(let e=0;e<n;e+=1){let e=rc(a.cell,i);if(e&&s.push(e),r){let e=rc(a.header_cell,i);e&&o.push(e)}}let c=[];for(let e=0;e<t;e+=1)c.push(a.row.createChecked(null,r&&e===0?o:s));return a.table.createChecked(null,c)}function oc(e){return e instanceof X}var sc=({editor:e})=>{let{selection:t}=e.state;if(!oc(t))return!1;let n=0;return Ge(t.ranges[0].$from,e=>e.type.name===`table`)?.node.descendants(e=>{if(e.type.name===`table`)return!1;[`tableCell`,`tableHeader`].includes(e.type.name)&&(n+=1)}),n===t.ranges.length&&(e.commands.deleteTable(),!0)};function cc(e){let t=``,n=0;for(;n<e.length;){if(e[n]===`\\`&&n+1<e.length){t+=e[n]+e[n+1],n+=2;continue}if(e[n]!=="`"){t+=e[n++];continue}let r=0;for(;n+r<e.length&&e[n+r]==="`";)r+=1;let i=n+r,a=!1;for(;i<e.length;){if(e[i]!=="`"){i+=1;continue}let o=0;for(;i+o<e.length&&e[i+o]==="`";)o+=1;if(o===r){let o=e.slice(n+r,i);t+=e.slice(n,n+r)+o.replace(/(?<!\\)\|/g,`\\|`)+e.slice(i,i+r),n=i+r,a=!0;break}i+=o}a||(t+=e.slice(n,n+r),n+=r)}return t}function lc(e){return e.split(`
40
+ `).map(e=>!e.includes(`|`)||!e.includes("`")?e:cc(e)).join(`
41
+ `)}function uc(e){return(e||``).replace(/\s+/g,` `).trim()}function dc(e,t,n={}){let r=n.cellLineSeparator??``;if(!e||!e.content||e.content.length===0)return``;let i=[];e.content.forEach(e=>{let n=[];e.content&&e.content.forEach(e=>{let i=``;i=e.content&&Array.isArray(e.content)&&e.content.length>1?e.content.map(e=>t.renderChildren(e)).join(r):e.content?t.renderChildren(e.content):``;let a=uc(i.split(r).join(`
42
+ `).replace(/[ \t]*\r?\n[ \t]*/g,`<br>`)),o=e.type===`tableHeader`,s=Us(e.attrs);n.push({text:a,isHeader:o,align:s})}),i.push(n)});let a=i.reduce((e,t)=>Math.max(e,t.length),0);if(a===0)return``;let o=Array.from({length:a}).fill(0);i.forEach(e=>{for(let t=0;t<a;t+=1){let n=(e[t]?.text||``).length;n>o[t]&&(o[t]=n),o[t]<3&&(o[t]=3)}});let s=(e,t)=>e+` `.repeat(Math.max(0,t-e.length)),c=i[0],l=c.some(e=>e.isHeader),u=Array.from({length:a}).fill(null);i.forEach(e=>{for(let t=0;t<a;t+=1)!u[t]&&e[t]?.align&&(u[t]=e[t].align)});let d=`
43
+ `,f=Array.from({length:a}).map((e,t)=>l&&c[t]&&c[t].text||``);return d+=`| ${f.map((e,t)=>s(e,o[t])).join(` | `)} |
44
+ `,d+=`| ${o.map((e,t)=>{let n=Math.max(3,e),r=u[t];return r===`left`?`:${`-`.repeat(n)}`:r===`right`?`${`-`.repeat(n)}:`:r===`center`?`:${`-`.repeat(n)}:`:`-`.repeat(n)}).join(` | `)} |
45
+ `,(l?i.slice(1):i).forEach(e=>{d+=`| ${Array.from({length:a}).fill(0).map((t,n)=>s(e[n]&&e[n].text||``,o[n])).join(` | `)} |
46
+ `}),d}var fc=dc,pc=k.create({name:`table`,addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:tc,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:`tableRow+`,tableRole:`table`,isolating:!0,group:`block`,parseHTML(){return[{tag:`table`}]},renderHTML({node:e,HTMLAttributes:t}){let{colgroup:n,tableWidth:r,tableMinWidth:i}=nc(e,this.options.cellMinWidth),a=t.style;function o(){return a||(r?`width: ${r}`:`min-width: ${i}`)}let s=[`table`,T(this.options.HTMLAttributes,t,{style:o()}),n,[`tbody`,0]];return this.options.renderWrapper?[`div`,{class:`tableWrapper`},s]:s},parseMarkdown:(e,t)=>{let n=[],r=Array.isArray(e.align)?e.align:[];if(e.header){let i=[];e.header.forEach((e,n)=>{let a=Vs(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableHeader`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}return e.rows&&e.rows.forEach(e=>{let i=[];e.forEach((e,n)=>{let a=Vs(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableCell`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}),t.createNode(`table`,void 0,n)},renderMarkdown:(e,t)=>fc(e,t),markdownTokenizer:{name:`table`,level:`block`,start:e=>{let t=e.split(`
47
+ `);if(t.length<2)return-1;let n=t[1];return!/^[ \t|:]*-[ \t|:-]*$/.test(n)||!n.includes(`|`)?-1:t[0].includes(`|`)?0:-1},tokenize(e,t,n){let r=e.indexOf(`
48
+
49
+ `),i=r>=0?e.slice(0,r):e,a=i.split(`
50
+ `);if(a.length<2)return;let o=a[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(o)||!o.includes(`|`))return;let s=lc(i);if(s===i)return;let c=n.blockTokens(s)[0];if(c?.type!==`table`||!c.raw)return;let l=c.raw.split(`
51
+ `).length,u=e.split(`
52
+ `).slice(0,l).join(`
53
+ `);return{...c,raw:u}}},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:a})=>{let o=ac(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(w.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>Io(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>Lo(e,t),deleteColumn:()=>({state:e,dispatch:t})=>zo(e,t),addRowBefore:()=>({state:e,dispatch:t})=>Ho(e,t),addRowAfter:()=>({state:e,dispatch:t})=>Uo(e,t),deleteRow:()=>({state:e,dispatch:t})=>Go(e,t),deleteTable:()=>({state:e,dispatch:t})=>is(e,t),mergeCells:()=>({state:e,dispatch:t})=>Jo(e,t),splitCell:()=>({state:e,dispatch:t})=>Yo(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>es(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>es(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>ts(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>Jo(e,t)?!0:Yo(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>Zo(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>rs(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>rs(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&No(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=X.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:sc,"Mod-Backspace":sc,Delete:sc,"Mod-Delete":sc}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Es({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Bs({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){let e=this.options.resizable&&this.editor.isEditable,t=this.options.View;return e||!t?null:({node:e,view:n,HTMLAttributes:r})=>{let i=T(this.options.HTMLAttributes,r);return new t(e,this.options.cellMinWidth,n,i)}},extendNodeSchema(e){let t={name:e.name,options:e.options,storage:e.storage};return{tableRole:Ie(We(e,`tableRole`,t))}}}),mc=O.create({name:`tableKit`,addExtensions(){let e=[];return this.options.table!==!1&&e.push(pc.configure(this.options.table)),this.options.tableCell!==!1&&e.push(Xs.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(Zs.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(Qs.configure(this.options.tableRow)),e}}),hc=O.create({name:`textAlign`,addOptions(){return{types:[],alignments:[`left`,`center`,`right`,`justify`],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{let t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>e.textAlign?{style:`text-align: ${e.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(e=>e):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,`textAlign`)).some(e=>e),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign(`left`),"Mod-Shift-e":()=>this.editor.commands.setTextAlign(`center`),"Mod-Shift-r":()=>this.editor.commands.setTextAlign(`right`),"Mod-Shift-j":()=>this.editor.commands.setTextAlign(`justify`)}}}),$=e(r(),1),gc=[1,2,3,4,5,6],_c=[`left`,`center`,`right`,`justify`],vc={left:{icon:`align-left`,key:`align-left`,label:`Align left`},center:{icon:`align-center`,key:`align-center`,label:`Align center`},right:{icon:`align-right`,key:`align-right`,label:`Align right`},justify:{icon:`align-justify`,key:`justify`,label:`Justify`}},yc=[`😀`,`😅`,`😂`,`🥳`,`😎`,`🤔`,`👍`,`🙏`,`🔥`,`🎉`,`🚀`,`💡`,`✅`,`❌`,`⭐`,`❤️`];function bc(e){let t=(e??gc).filter(e=>e>=1&&e<=6);return t.length>0?t:gc}function xc({editor:e,levels:t}){let{t:r}=a(`lattice`),i=r(`form.editor.heading`,`Heading`);return(0,$.jsxs)(m,{children:[(0,$.jsx)(g,{asChild:!0,children:(0,$.jsx)(y,{active:e.isActive(`heading`),icon:`heading`,label:i,testId:`editor-heading`})}),(0,$.jsx)(c,{className:`min-w-32`,children:t.map(t=>(0,$.jsx)(d,{className:n(e.isActive(`heading`,{level:t})&&`bg-lt-accent text-lt-accent-fg`),"data-test":`editor-heading-${t}`,onClick:()=>e.chain().focus().toggleHeading({level:t}).run(),children:r(`form.editor.heading-${t}`,`Heading ${t}`)},t))})]})}function Sc({editor:e}){let{t}=a(`lattice`),[n,r]=(0,Za.useState)(!1),[i,o]=(0,Za.useState)(``),s=()=>{i?e.chain().focus().extendMarkRange(`link`).setLink({href:i}).run():e.chain().focus().extendMarkRange(`link`).unsetLink().run(),r(!1)};return(0,$.jsxs)(l,{onOpenChange:t=>{t&&o(e.getAttributes(`link`).href??``),r(t)},open:n,children:[(0,$.jsx)(f,{asChild:!0,children:(0,$.jsx)(y,{active:e.isActive(`link`),icon:`link`,label:t(`form.editor.link`,`Link`),testId:`editor-link`})}),(0,$.jsxs)(u,{className:`flex w-72 items-center gap-1 p-2`,children:[(0,$.jsx)(`input`,{"aria-label":t(`form.editor.link-url`,`Link URL`),className:`h-7 min-w-0 flex-1 rounded-lt-sm border border-lt-input bg-transparent px-2 text-sm outline-none focus:border-lt-ring`,"data-test":`editor-link-url`,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),s())},placeholder:`https://`,type:`url`,value:i}),(0,$.jsx)(y,{icon:`check`,label:t(`form.editor.link-apply`,`Apply link`),onClick:s,testId:`editor-link-apply`}),e.isActive(`link`)&&(0,$.jsx)(y,{icon:`trash-2`,label:t(`form.editor.link-remove`,`Remove link`),onClick:()=>{e.chain().focus().extendMarkRange(`link`).unsetLink().run(),r(!1)},testId:`editor-link-remove`})]})]})}function Cc({editor:e,emojis:t}){let{t:n}=a(`lattice`),[r,i]=(0,Za.useState)(!1);return(0,$.jsxs)(l,{onOpenChange:i,open:r,children:[(0,$.jsx)(f,{asChild:!0,children:(0,$.jsx)(y,{icon:`smile`,label:n(`form.editor.insert-emoji`,`Insert emoji`),testId:`editor-emoji`})}),(0,$.jsx)(u,{className:`grid grid-cols-8 gap-0.5 p-1`,children:t.map(t=>(0,$.jsx)(`button`,{className:`inline-flex size-7 items-center justify-center rounded-lt-sm text-base hover:bg-lt-accent`,onClick:()=>{e.chain().focus().insertContent(t).run(),i(!1)},onMouseDown:e=>e.preventDefault(),type:`button`,children:t},t))})]})}function wc(e,t,n,r){return{icon:t,key:e,label:n,isActive:e=>e.isActive(r),run:e=>e.chain().focus().toggleMark(r).run()}}var Tc={bold:{group:`marks`,starterKit:()=>({bold:{}}),toolbar:()=>[wc(`bold`,`bold`,`Bold`,`bold`)]},italic:{group:`marks`,starterKit:()=>({italic:{}}),toolbar:()=>[wc(`italic`,`italic`,`Italic`,`italic`)]},strike:{group:`marks`,starterKit:()=>({strike:{}}),toolbar:()=>[wc(`strikethrough`,`strikethrough`,`Strikethrough`,`strike`)]},underline:{group:`marks`,starterKit:()=>({underline:{}}),toolbar:()=>[wc(`underline`,`underline`,`Underline`,`underline`)]},highlight:{group:`marks`,extensions:()=>[oo],toolbar:()=>[wc(`highlight`,`highlighter`,`Highlight`,`highlight`)]},code:{group:`marks`,starterKit:()=>({code:{}}),toolbar:()=>[wc(`code`,`code-xml`,`Code`,`code`)]},heading:{starterKit:e=>({heading:{levels:bc(e.levels)}}),toolbar:e=>{let t=bc(e.levels);return[{key:`heading`,component:({editor:e})=>(0,$.jsx)(xc,{editor:e,levels:t})}]}},"bullet-list":{group:`blocks`,starterKit:()=>({bulletList:{},listItem:{}}),toolbar:()=>[{icon:`list`,key:`bullet-list`,label:`Bullet list`,isActive:e=>e.isActive(`bulletList`),run:e=>e.chain().focus().toggleBulletList().run()}]},"ordered-list":{group:`blocks`,starterKit:()=>({orderedList:{},listItem:{}}),toolbar:()=>[{icon:`list-ordered`,key:`ordered-list`,label:`Ordered list`,isActive:e=>e.isActive(`orderedList`),run:e=>e.chain().focus().toggleOrderedList().run()}]},blockquote:{group:`blocks`,starterKit:()=>({blockquote:{}}),toolbar:()=>[{icon:`quote`,key:`blockquote`,label:`Blockquote`,isActive:e=>e.isActive(`blockquote`),run:e=>e.chain().focus().toggleBlockquote().run()}]},"code-block":{group:`blocks`,starterKit:()=>({codeBlock:{}}),toolbar:()=>[{icon:`code`,key:`code-block`,label:`Code block`,isActive:e=>e.isActive(`codeBlock`),run:e=>e.chain().focus().toggleCodeBlock().run()}]},"horizontal-rule":{group:`blocks`,starterKit:()=>({horizontalRule:{}}),toolbar:()=>[{icon:`minus`,key:`horizontal-rule`,label:`Horizontal rule`,isActive:()=>!1,run:e=>e.chain().focus().setHorizontalRule().run()}]},"text-align":{extensions:e=>[hc.configure({alignments:e.alignments??_c,types:[`heading`,`paragraph`]})],toolbar:e=>(e.alignments??_c).filter(e=>e in vc).map(e=>({...vc[e],isActive:t=>t.isActive({textAlign:e}),run:t=>t.chain().focus().setTextAlign(e).run()}))},link:{starterKit:e=>({link:{openOnClick:e.openOnClick??!1,...e.protocols?{protocols:e.protocols}:{}}}),toolbar:()=>[{key:`link`,component:({editor:e})=>(0,$.jsx)(Sc,{editor:e})}]},table:{group:`insert`,extensions:()=>[mc.configure({table:{resizable:!1}})],toolbar:e=>[{icon:`table`,key:`insert-table`,label:`Insert table`,isActive:e=>e.isActive(`table`),run:t=>t.chain().focus().insertTable({rows:e.rows??3,cols:e.cols??3,withHeaderRow:e.withHeaderRow??!0}).run()},{icon:`columns-3`,key:`add-column`,label:`Add column`,isActive:()=>!1,isDisabled:e=>!e.can().addColumnAfter(),run:e=>e.chain().focus().addColumnAfter().run()},{icon:`rows-3`,key:`add-row`,label:`Add row`,isActive:()=>!1,isDisabled:e=>!e.can().addRowAfter(),run:e=>e.chain().focus().addRowAfter().run()},{icon:`trash-2`,key:`delete-table`,label:`Delete table`,isActive:()=>!1,isDisabled:e=>!e.can().deleteTable(),run:e=>e.chain().focus().deleteTable().run()}]},details:{group:`insert`,extensions:()=>[to,ro,no],toolbar:()=>[{icon:`chevron-right`,key:`details`,label:`Details`,isActive:e=>e.isActive(`details`),run:e=>{if(e.isActive(`details`)){e.chain().focus().unsetDetails().run();return}e.chain().focus().setDetails().run()}}]},emoji:{toolbar:e=>{let t=e.emojis??yc;return[{key:`insert-emoji`,component:({editor:e})=>(0,$.jsx)(Cc,{editor:e,emojis:t})}]}}};function Ec({editor:e,items:t}){let{t:n}=a(`lattice`);return(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-0.5 border-b border-lt-border p-1`,children:t.map((t,r)=>{if(t===`separator`)return(0,$.jsx)(`span`,{className:`mx-1 h-5 w-px bg-lt-border`},`sep-${r}`);if(`component`in t){let n=t.component;return(0,$.jsx)(n,{editor:e},t.key)}let i=n(`form.editor.${t.key}`,t.label);return(0,$.jsx)(y,{active:t.isActive(e),disabled:t.isDisabled?.(e)??!1,icon:t.icon,label:i,onClick:()=>t.run(e),testId:`editor-${t.key}`},t.key)})})}var Dc=({node:e})=>{let t=i(ne),{errors:r}=o(),{hidden:a,required:c,readOnly:l,disabled:u}=h(e),{change:d,blur:f}=s(),m=e.props.name,g=_(),y=ee(m),ae=g?g.getValue(m):y,oe=g?g.scopedName(m):m,se=g?g.errorKey(m):m,ce=l||u,le=typeof ae==`object`&&ae?ae:e.props.value??``,ue=(0,Za.useMemo)(()=>re(e.props.extensions,{...Tc,...t}),[t,e.props.extensions]),de=(0,Za.useMemo)(()=>te(ue),[ue]),fe=(0,Za.useMemo)(()=>[Xa.configure(ie(ue)),Jt.configure({placeholder:e.props.placeholder??``}),...v(ue)],[ue,e.props.placeholder]),pe=ze({extensions:fe,content:le,editable:!ce,immediatelyRender:!1,shouldRerenderOnTransaction:!0,editorProps:{attributes:{class:`lattice-prose min-h-32 px-3 py-2 outline-none`}},onUpdate:({editor:e})=>{d(m,e.isEmpty?null:e.getJSON())},onBlur:()=>{f(m)}});if((0,Za.useEffect)(()=>{pe?.setEditable(!ce)},[pe,ce]),a)return null;let b=ae?JSON.stringify(ae):``;return(0,$.jsx)(p,{error:r[se],helperText:e.props.helperText??void 0,tooltip:e.props.tooltip??void 0,label:e.props.label??``,id:oe,required:c,children:e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{...e,className:n(`overflow-hidden rounded-lt-sm border border-lt-input bg-transparent shadow-lt-xs focus-within:border-lt-ring focus-within:ring-[length:var(--lt-ring-width)] focus-within:ring-lt-ring/50`,ce&&`opacity-60`),role:`group`,children:[pe&&!ce&&de.length>0&&(0,$.jsx)(Ec,{editor:pe,items:de}),(0,$.jsx)(Ae,{editor:pe})]}),(0,$.jsx)(`input`,{name:oe,type:`hidden`,value:b})]})})};export{Dc as default};