@quixomatic/rpf 0.0.0-stage → 0.2.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.
- package/CHANGELOG.md +52 -0
- package/LICENSE +21 -0
- package/README.md +82 -2
- package/assets/dev-host/THIRD_PARTY_NOTICES.txt +2937 -0
- package/assets/dev-host/boot.js +250 -0
- package/assets/dev-host/boot.js.LEGAL.txt +48 -0
- package/assets/dev-host/chunks/accordion-O6VUPQ32.js +2 -0
- package/assets/dev-host/chunks/alert-PRAGKG5L.js +2 -0
- package/assets/dev-host/chunks/alert-dialog-SCBXM23J.js +2 -0
- package/assets/dev-host/chunks/avatar-WXPKQ3Z5.js +2 -0
- package/assets/dev-host/chunks/badge-KCMWGERA.js +2 -0
- package/assets/dev-host/chunks/breadcrumb-IJQJQ5JV.js +2 -0
- package/assets/dev-host/chunks/button-4JMBKYN4.js +2 -0
- package/assets/dev-host/chunks/calendar-XXLCAUPG.js +2 -0
- package/assets/dev-host/chunks/card-EY3LK2GB.js +2 -0
- package/assets/dev-host/chunks/chart-2PHC6UIE.js +2 -0
- package/assets/dev-host/chunks/chart-blocks-PZPCWCNT.js +2 -0
- package/assets/dev-host/chunks/chart-frame-MNUFXAPU.js +3 -0
- package/assets/dev-host/chunks/charts-SKK6UTYU.js +85 -0
- package/assets/dev-host/chunks/charts-SKK6UTYU.js.LEGAL.txt +48 -0
- package/assets/dev-host/chunks/chat-TTESCYES.js +2 -0
- package/assets/dev-host/chunks/checkbox-Y2UGSRR4.js +2 -0
- package/assets/dev-host/chunks/chunk-2IZ44WWI.js +2 -0
- package/assets/dev-host/chunks/chunk-2L7NK6SJ.js +2 -0
- package/assets/dev-host/chunks/chunk-33RMFA4P.js +2 -0
- package/assets/dev-host/chunks/chunk-3H6F4X7R.js +2 -0
- package/assets/dev-host/chunks/chunk-3UDEYJRG.js +2 -0
- package/assets/dev-host/chunks/chunk-4E74H7FZ.js +2 -0
- package/assets/dev-host/chunks/chunk-4UUMO65R.js +2 -0
- package/assets/dev-host/chunks/chunk-57M36GYM.js +2 -0
- package/assets/dev-host/chunks/chunk-5EK7QOB6.js +2 -0
- package/assets/dev-host/chunks/chunk-5YMOXSSM.js +2 -0
- package/assets/dev-host/chunks/chunk-5ZMYWE5S.js +2 -0
- package/assets/dev-host/chunks/chunk-6ARM5VDH.js +2 -0
- package/assets/dev-host/chunks/chunk-7OCTAHT6.js +2 -0
- package/assets/dev-host/chunks/chunk-7TG23VIV.js +2 -0
- package/assets/dev-host/chunks/chunk-AAL6V4Y3.js +2 -0
- package/assets/dev-host/chunks/chunk-APP2HKWR.js +8 -0
- package/assets/dev-host/chunks/chunk-AVSRGCSF.js +2 -0
- package/assets/dev-host/chunks/chunk-AZWODE64.js +2 -0
- package/assets/dev-host/chunks/chunk-B4MRCKT4.js +2 -0
- package/assets/dev-host/chunks/chunk-BB4IX5QA.js +2 -0
- package/assets/dev-host/chunks/chunk-BH6FGVDP.js +2 -0
- package/assets/dev-host/chunks/chunk-BJZOPTWR.js +2 -0
- package/assets/dev-host/chunks/chunk-CCXMDKVL.js +2 -0
- package/assets/dev-host/chunks/chunk-CJ5CECQT.js +1 -0
- package/assets/dev-host/chunks/chunk-CLVPTZ4G.js +2 -0
- package/assets/dev-host/chunks/chunk-CT4EH2K2.js +8 -0
- package/assets/dev-host/chunks/chunk-CT4EH2K2.js.LEGAL.txt +12 -0
- package/assets/dev-host/chunks/chunk-CWDPAB6V.js +2 -0
- package/assets/dev-host/chunks/chunk-D7BPK3AE.js +1 -0
- package/assets/dev-host/chunks/chunk-DG6LRRQT.js +2 -0
- package/assets/dev-host/chunks/chunk-DR47HKIK.js +2 -0
- package/assets/dev-host/chunks/chunk-E75HEEMN.js +2 -0
- package/assets/dev-host/chunks/chunk-EDEL6XSO.js +2 -0
- package/assets/dev-host/chunks/chunk-EGZKG2B2.js +2 -0
- package/assets/dev-host/chunks/chunk-F353PAEY.js +2 -0
- package/assets/dev-host/chunks/chunk-F5MKIWPQ.js +2 -0
- package/assets/dev-host/chunks/chunk-FJRWQRLM.js +2 -0
- package/assets/dev-host/chunks/chunk-FROPNHO5.js +2 -0
- package/assets/dev-host/chunks/chunk-FTWKUXER.js +2 -0
- package/assets/dev-host/chunks/chunk-FZPMZMFU.js +2 -0
- package/assets/dev-host/chunks/chunk-GN3SYBEC.js +2 -0
- package/assets/dev-host/chunks/chunk-GQYRJYJV.js +2 -0
- package/assets/dev-host/chunks/chunk-GWDGPUGM.js +2 -0
- package/assets/dev-host/chunks/chunk-GX72R347.js +2 -0
- package/assets/dev-host/chunks/chunk-GZJCEDUU.js +4 -0
- package/assets/dev-host/chunks/chunk-H6TI5TWN.js +2 -0
- package/assets/dev-host/chunks/chunk-HFUDOYIP.js +16 -0
- package/assets/dev-host/chunks/chunk-IAEAQCYR.js +2 -0
- package/assets/dev-host/chunks/chunk-IJQ26FTX.js +15 -0
- package/assets/dev-host/chunks/chunk-IJQ26FTX.js.LEGAL.txt +12 -0
- package/assets/dev-host/chunks/chunk-IQ2XSDFU.js +3 -0
- package/assets/dev-host/chunks/chunk-IQ2XSDFU.js.LEGAL.txt +146 -0
- package/assets/dev-host/chunks/chunk-IWEJRU22.js +2 -0
- package/assets/dev-host/chunks/chunk-JIAVZ3V7.js +3 -0
- package/assets/dev-host/chunks/chunk-K7LVVFGH.js +1 -0
- package/assets/dev-host/chunks/chunk-KAZVAX35.js +2 -0
- package/assets/dev-host/chunks/chunk-KCTKD6GV.js +2 -0
- package/assets/dev-host/chunks/chunk-KNOE7TZW.js +2 -0
- package/assets/dev-host/chunks/chunk-KOQLDUOI.js +2 -0
- package/assets/dev-host/chunks/chunk-KPP4HYUV.js +2 -0
- package/assets/dev-host/chunks/chunk-KSVOOYUA.js +2 -0
- package/assets/dev-host/chunks/chunk-KVMUXFPB.js +2 -0
- package/assets/dev-host/chunks/chunk-LTVKSGLG.js +2 -0
- package/assets/dev-host/chunks/chunk-LYT7LQS3.js +2 -0
- package/assets/dev-host/chunks/chunk-M7A47ZSM.js +2 -0
- package/assets/dev-host/chunks/chunk-MGLBTOXD.js +6 -0
- package/assets/dev-host/chunks/chunk-ML6HCGK5.js +2 -0
- package/assets/dev-host/chunks/chunk-MQ67DRDE.js +2 -0
- package/assets/dev-host/chunks/chunk-MTHCFDUE.js +2 -0
- package/assets/dev-host/chunks/chunk-NI6ZJ6DH.js +2 -0
- package/assets/dev-host/chunks/chunk-NJX7QY3Z.js +2 -0
- package/assets/dev-host/chunks/chunk-NZ73KS2Y.js +2 -0
- package/assets/dev-host/chunks/chunk-OW6AVFQA.js +2 -0
- package/assets/dev-host/chunks/chunk-OXJ6LWKI.js +3 -0
- package/assets/dev-host/chunks/chunk-OXJ6LWKI.js.LEGAL.txt +12 -0
- package/assets/dev-host/chunks/chunk-PHK25MY7.js +2 -0
- package/assets/dev-host/chunks/chunk-PQMY72VV.js +2 -0
- package/assets/dev-host/chunks/chunk-PWFHIE6D.js +2 -0
- package/assets/dev-host/chunks/chunk-PYWKHILP.js +2 -0
- package/assets/dev-host/chunks/chunk-QFN6XL4O.js +2 -0
- package/assets/dev-host/chunks/chunk-R5KQ2GRA.js +2 -0
- package/assets/dev-host/chunks/chunk-RCNX6LVJ.js +3 -0
- package/assets/dev-host/chunks/chunk-RCNX6LVJ.js.LEGAL.txt +12 -0
- package/assets/dev-host/chunks/chunk-SFI7YWVR.js +2 -0
- package/assets/dev-host/chunks/chunk-SLZI4G3N.js +2 -0
- package/assets/dev-host/chunks/chunk-SVQCDOZ3.js +2 -0
- package/assets/dev-host/chunks/chunk-T4Y5HG5P.js +4 -0
- package/assets/dev-host/chunks/chunk-T7JFBQSG.js +2 -0
- package/assets/dev-host/chunks/chunk-TIJLEKZ2.js +2 -0
- package/assets/dev-host/chunks/chunk-TNLYU77Y.js +2 -0
- package/assets/dev-host/chunks/chunk-TQPXDAVH.js +2 -0
- package/assets/dev-host/chunks/chunk-UH726PMV.js +7 -0
- package/assets/dev-host/chunks/chunk-UH726PMV.js.LEGAL.txt +12 -0
- package/assets/dev-host/chunks/chunk-URJZKT45.js +2 -0
- package/assets/dev-host/chunks/chunk-URWVHIIJ.js +2 -0
- package/assets/dev-host/chunks/chunk-UUJ5X322.js +2 -0
- package/assets/dev-host/chunks/chunk-UWANBOC6.js +2 -0
- package/assets/dev-host/chunks/chunk-UXUS6DNI.js +2 -0
- package/assets/dev-host/chunks/chunk-VKXVJGG5.js +6 -0
- package/assets/dev-host/chunks/chunk-VSM3ZOBU.js +2 -0
- package/assets/dev-host/chunks/chunk-WLBNJ4K3.js +2 -0
- package/assets/dev-host/chunks/chunk-WRHZYADJ.js +2 -0
- package/assets/dev-host/chunks/chunk-WT34MBTN.js +2 -0
- package/assets/dev-host/chunks/chunk-X34AFUS2.js +2 -0
- package/assets/dev-host/chunks/chunk-XE5RQ73V.js +2 -0
- package/assets/dev-host/chunks/chunk-XGLVZEGD.js +2 -0
- package/assets/dev-host/chunks/chunk-XIXCIQKJ.js +2 -0
- package/assets/dev-host/chunks/chunk-Z76KXEPD.js +2 -0
- package/assets/dev-host/chunks/code-block-H2ETQV3M.js +2 -0
- package/assets/dev-host/chunks/code-editor-2JYERJLS.js +2 -0
- package/assets/dev-host/chunks/collapsible-4ZOFMWLB.js +2 -0
- package/assets/dev-host/chunks/color-UDQWYS2D.js +2 -0
- package/assets/dev-host/chunks/color-picker-RRCCLR54.js +2 -0
- package/assets/dev-host/chunks/combobox-U4455OMJ.js +2 -0
- package/assets/dev-host/chunks/contrast-badge-KDF65X7J.js +2 -0
- package/assets/dev-host/chunks/core.esm-WYAV6XZS.js +2 -0
- package/assets/dev-host/chunks/date-range-picker-WJYHAHRM.js +2 -0
- package/assets/dev-host/chunks/dialog-I6AGHWB3.js +2 -0
- package/assets/dev-host/chunks/dist-T43K2TRF.js +2 -0
- package/assets/dev-host/chunks/dropdown-menu-LSOMXDWG.js +2 -0
- package/assets/dev-host/chunks/empty-NLQODUSK.js +2 -0
- package/assets/dev-host/chunks/esm-L33CRTOD.js +5 -0
- package/assets/dev-host/chunks/font-picker-3TLYYZJH.js +2 -0
- package/assets/dev-host/chunks/frame-HA7UIYZF.js +2 -0
- package/assets/dev-host/chunks/heading-7M24WKK6.js +2 -0
- package/assets/dev-host/chunks/hover-card-HSHOQPOI.js +2 -0
- package/assets/dev-host/chunks/icon-NZIMARLZ.js +2 -0
- package/assets/dev-host/chunks/image-R7XGYKVH.js +2 -0
- package/assets/dev-host/chunks/index-fn-BUQBI34R.js +5 -0
- package/assets/dev-host/chunks/index.esm-SPI7ZXRT.js +6 -0
- package/assets/dev-host/chunks/index.esm-SPI7ZXRT.js.LEGAL.txt +25 -0
- package/assets/dev-host/chunks/input-YECXNM53.js +2 -0
- package/assets/dev-host/chunks/input-group-GFKXSZM7.js +2 -0
- package/assets/dev-host/chunks/kbd-V25ZMVCM.js +2 -0
- package/assets/dev-host/chunks/label-LJT4V2CT.js +2 -0
- package/assets/dev-host/chunks/label-value-6Z6ATP55.js +2 -0
- package/assets/dev-host/chunks/legacy-4ICQWPOE.js +2 -0
- package/assets/dev-host/chunks/logo-AAMBHX2W.js +2 -0
- package/assets/dev-host/chunks/number-field-6TCQAVTR.js +2 -0
- package/assets/dev-host/chunks/pill-7L57ZNRJ.js +2 -0
- package/assets/dev-host/chunks/popover-3P6YNKH3.js +2 -0
- package/assets/dev-host/chunks/portal-code-Z5G6AEMM.js +25 -0
- package/assets/dev-host/chunks/portal-rte-7B6VXIZO.js +163 -0
- package/assets/dev-host/chunks/progress-RBCJRVM7.js +2 -0
- package/assets/dev-host/chunks/radio-group-NJWXZCX3.js +2 -0
- package/assets/dev-host/chunks/resizable-XF4P6OKR.js +2 -0
- package/assets/dev-host/chunks/rich-text-7OMYZ564.js +2 -0
- package/assets/dev-host/chunks/rich-text-editor-T6KWD4P3.js +2 -0
- package/assets/dev-host/chunks/scroll-row-LMI7JCFR.js +2 -0
- package/assets/dev-host/chunks/select-F3MZWTTS.js +2 -0
- package/assets/dev-host/chunks/separator-JRJYKM4Z.js +2 -0
- package/assets/dev-host/chunks/sheet-EXRT4MFB.js +2 -0
- package/assets/dev-host/chunks/side-panel-IBHLEANN.js +2 -0
- package/assets/dev-host/chunks/sidebar-VKQMQMF2.js +2 -0
- package/assets/dev-host/chunks/skeleton-KIRVQ4EO.js +2 -0
- package/assets/dev-host/chunks/slider-XKYDL5MR.js +2 -0
- package/assets/dev-host/chunks/sortable.esm-3VPY5PX7.js +2 -0
- package/assets/dev-host/chunks/split-button-WP6LALDS.js +2 -0
- package/assets/dev-host/chunks/stepper-KR6PXZHW.js +2 -0
- package/assets/dev-host/chunks/switch-P6NJELJJ.js +2 -0
- package/assets/dev-host/chunks/tabs-PFPRJNVZ.js +2 -0
- package/assets/dev-host/chunks/textarea-2JXA5XWS.js +2 -0
- package/assets/dev-host/chunks/toggle-group-PS7JN2JM.js +2 -0
- package/assets/dev-host/chunks/tooltip-S4RBC3O4.js +2 -0
- package/assets/dev-host/chunks/tree-NQF6ZJLH.js +2 -0
- package/assets/dev-host/chunks/utilities.esm-YYZNDLV4.js +2 -0
- package/assets/dev-host/css/shadcn-tailwind.css +637 -0
- package/assets/dev-host/css/tw-animate.css +1 -0
- package/assets/dev-host/kit-candidates.json +1 -0
- package/assets/dev-host/kit-manifest.json +435 -0
- package/assets/react-portal-lockup-on-dark.svg +11 -0
- package/assets/react-portal-lockup.svg +11 -0
- package/dist/cli.mjs +16200 -0
- package/package.json +65 -5
- package/skills/react-portal/SKILL.md +161 -0
- package/skills/react-portal/references/cli.md +141 -0
- package/skills/react-portal/references/components.md +214 -0
- package/skills/react-portal/references/rules.md +115 -0
- package/skills/react-portal/references/troubleshooting.md +58 -0
- package/skills/react-portal/references/workspace.md +178 -0
- package/skills/react-portal-theme/SKILL.md +110 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import"./chunk-KVMUXFPB.js";var Wl={name:"@tiptap/core",version:"3.34.0",description:"headless rich text editor",keywords:["headless","prosemirror","text editor","tiptap","wysiwyg"],homepage:"https://tiptap.dev",bugs:{url:"https://github.com/ueberdosis/tiptap/issues"},license:"MIT",repository:{type:"git",url:"https://github.com/ueberdosis/tiptap",directory:"packages/core"},funding:{type:"github",url:"https://github.com/sponsors/ueberdosis"},files:["src","dist","jsx-runtime","jsx-dev-runtime"],type:"module",sideEffects:!1,main:"dist/index.cjs",module:"dist/index.js",types:"dist/index.d.ts",exports:{".":{types:{import:"./dist/index.d.ts",require:"./dist/index.d.cts"},import:"./dist/index.js",require:"./dist/index.cjs"},"./jsx-runtime":{types:{import:"./jsx-runtime/index.d.ts",require:"./jsx-runtime/index.d.cts"},import:"./jsx-runtime/index.js",require:"./jsx-runtime/index.cjs"},"./jsx-dev-runtime":{types:{import:"./jsx-dev-runtime/index.d.ts",require:"./jsx-dev-runtime/index.d.cts"},import:"./jsx-dev-runtime/index.js",require:"./jsx-dev-runtime/index.cjs"}},devDependencies:{"@tiptap/pm":"^3.34.0","prosemirror-model":"^1.25.12","vite-plus":"1.3.0"},peerDependencies:{"@tiptap/pm":"3.34.0"},scripts:{build:"vp pack"}};var Vl=Object.defineProperty,_l=(t,e)=>{let n={};for(var r in t)Vl(n,r,{get:t[r],enumerable:!0});return e||Vl(n,Symbol.toStringTag,{value:"Module"}),n};function se(t){this.content=t}se.prototype={constructor:se,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,o=r.find(t),s=r.content.slice();return o==-1?s.push(n||t,e):(s[o+1]=e,n&&(s[o]=n)),new se(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new se(n)},addToStart:function(t,e){return new se([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new se(n)},addBefore:function(t,e,n){var r=this.remove(e),o=r.content.slice(),s=r.find(t);return o.splice(s==-1?o.length:s,0,e,n),new se(o)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=se.from(t),t.size?new se(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=se.from(t),t.size?new se(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=se.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};se.from=function(t){if(t instanceof se)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new se(e)};var as=se;function na(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let o=t.child(r),s=e.child(r);if(o==s){n+=o.nodeSize;continue}if(!o.sameMarkup(s))return n;if(o.isText&&o.text!=s.text){let i=o.text,l=s.text,a=0;for(;i[a]==l[a];a++)n++;return a&&a<i.length&&a<l.length&&sa(i.charCodeAt(a-1))&&oa(i.charCodeAt(a))&&n--,n}if(o.content.size||s.content.size){let i=na(o.content,s.content,n+1);if(i!=null)return i}n+=o.nodeSize}}function ra(t,e,n,r){for(let o=t.childCount,s=e.childCount;;){if(o==0||s==0)return o==s?null:{a:n,b:r};let i=t.child(--o),l=e.child(--s),a=i.nodeSize;if(i==l){n-=a,r-=a;continue}if(!i.sameMarkup(l))return{a:n,b:r};if(i.isText&&i.text!=l.text){let c=i.text,u=l.text,d=c.length,f=u.length;for(;d>0&&f>0&&c[d-1]==u[f-1];)d--,f--,n--,r--;return d&&f&&d<c.length&&sa(c.charCodeAt(d-1))&&oa(c.charCodeAt(d))&&(n++,r++),{a:n,b:r}}if(i.content.size||l.content.size){let c=ra(i.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}function oa(t){return t>=56320&&t<57344}function sa(t){return t>=55296&&t<56320}var b=class t{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,o=0,s){for(let i=0,l=0;l<n;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&r(a,o+l,s||null,i)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,n-u),r,o+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,o){let s="",i=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(i?i=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,o=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(o[o.length-1]=n.withText(n.text+r.text),s=1);s<e.content.length;s++)o.push(e.content[s]);return new t(o,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],o=0;if(n>e)for(let s=0,i=0;i<n;s++){let l=this.content[s],a=i+l.nodeSize;a>e&&((i<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,n-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,n-i-1))),r.push(l),o+=l.nodeSize),i=a}return new t(r,o)}cutByIndex(e,n){return e==n?t.empty:e==0&&n==this.content.length?this:new t(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let o=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return o[e]=n,new t(o,s)}addToStart(e){return new t([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new t(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let o=this.content[n];e(o,r,n),r+=o.nodeSize}}findDiffStart(e,n=0){return na(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return ra(this,e,n,r)}findIndex(e){if(e==0)return hr(0,e);if(e==this.size)return hr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let o=this.child(n),s=r+o.nodeSize;if(s>=e)return s==e?hr(n+1,s):hr(n,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return t.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return t.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return t.empty;let n,r=0;for(let o=0;o<e.length;o++){let s=e[o];r+=s.nodeSize,o&&s.isText&&e[o-1].sameMarkup(s)?(n||(n=e.slice(0,o)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new t(n||e,r)}static from(e){if(!e)return t.empty;if(e instanceof t)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new t([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};b.empty=new b([],0);var cs={index:0,offset:0};function hr(t,e){return cs.index=t,cs.offset=e,cs}function gr(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!gr(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!gr(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}var F=class t{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let o=0;o<e.length;o++){let s=e[o];if(this.eq(s))return e;if(this.type.excludes(s.type))n||(n=e.slice(0,o));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(n||(n=e.slice(0,o)),n.push(this),r=!0),n&&n.push(s)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&gr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);return r.create(n.attrs)}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return t.none;if(e instanceof t)return[e];let n=e.slice();return n.sort((r,o)=>r.type.rank-o.type.rank),n}};F.none=[];var nt=class extends Error{},C=class t{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=la(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new t(r,this.openStart,this.openEnd)}removeBetween(e,n){return new t(ia(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return t.empty;let r=n.openStart||0,o=n.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new t(b.fromJSON(e,n.content),r,o)}static maxOpen(e,n=!0){let r=0,o=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)o++;return new t(e,r,o)}};C.empty=new C(b.empty,0,0);function ia(t,e,n){let{index:r,offset:o}=t.findIndex(e),s=t.maybeChild(r),{index:i,offset:l}=t.findIndex(n);if(o==e||s.isText){if(l!=n&&!t.child(i).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=i)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(ia(s.content,e-o-1,n-o-1)))}function la(t,e,n,r,o,s){let{index:i,offset:l}=t.findIndex(e),a=t.maybeChild(i);if(l==e||a.isText)return s&&r<=0&&o<=0&&!s.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=la(a.content,e-l-1,n,i==0?r-1:0,i==t.childCount-1?o-1:0,a);return c&&t.replaceChild(i,a.copy(c))}function zh(t,e,n){if(n.openStart>t.depth)throw new nt("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new nt("Inconsistent open depths");return aa(t,e,n,0)}function aa(t,e,n,r){let o=t.index(r),s=t.node(r);if(o==e.index(r)&&r<t.depth-n.openStart){let i=aa(t,e,n,r+1);return s.copy(s.content.replaceChild(o,i))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let i=t.parent,l=i.content;return yt(i,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=Bh(n,t);return yt(s,ua(t,i,l,e,r))}else return yt(s,yr(t,e,r))}function ca(t,e){if(!e.type.compatibleContent(t.type))throw new nt("Cannot join "+e.type.name+" onto "+t.type.name)}function us(t,e,n){let r=t.node(n);return ca(r,e.node(n)),r}function gt(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function kn(t,e,n,r){let o=(e||t).node(n),s=0,i=e?e.index(n):o.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(gt(t.nodeAfter,r),s++));for(let l=s;l<i;l++)gt(o.child(l),r);e&&e.depth==n&&e.textOffset&>(e.nodeBefore,r)}function yt(t,e){if(!t.type.validContent(e))throw new nt("Invalid content for node "+t.type.name);return t.copy(e)}function ua(t,e,n,r,o){let s=t.depth>o&&us(t,e,o+1),i=r.depth>o&&us(n,r,o+1),l=[];return kn(null,t,o,l),s&&i&&e.index(o)==n.index(o)?(ca(s,i),gt(yt(s,ua(t,e,n,r,o+1)),l)):(s&>(yt(s,yr(t,e,o+1)),l),kn(e,n,o,l),i&>(yt(i,yr(n,r,o+1)),l)),kn(r,null,o,l),new b(l)}function yr(t,e,n){let r=[];if(kn(null,t,n,r),t.depth>n){let o=us(t,e,n+1);gt(yt(o,yr(t,e,n+1)),r)}return kn(e,null,n,r),new b(r)}function Bh(t,e){let n=e.depth-t.openStart,o=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)o=e.node(s).copy(b.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}var br=class t{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(n);return r?e.child(n).cut(r):o}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],o=n==0?0:this.path[n*3-1]+1;for(let s=0;s<e;s++)o+=r.child(s).nodeSize;return o}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return F.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),o=e.maybeChild(n);if(!r){let l=r;r=o,o=l}let s=r.marks;for(var i=0;i<s.length;i++)s[i].type.spec.inclusive===!1&&(!o||!s[i].isInSet(o.marks))&&(s=s[i--].removeFromSet(s));return s}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,o=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!o||!r[s].isInSet(o.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new bt(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],o=0,s=n;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(s),c=s-a;if(r.push(i,l,o+a),!c||(i=i.child(l),i.isText))break;s=c-1,o+=a+1}return new t(n,r,s)}static resolveCached(e,n){let r=Kl.get(e);if(r)for(let s=0;s<r.elts.length;s++){let i=r.elts[s];if(i.pos==n)return i}else Kl.set(e,r=new ds);let o=r.elts[r.i]=t.resolve(e,n);return r.i=(r.i+1)%$h,o}},ds=class{constructor(){this.elts=[],this.i=0}},$h=12,Kl=new WeakMap,bt=class{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},Hh=Object.create(null),Ee=class t{constructor(e,n,r,o=F.none){this.type=e,this.attrs=n,this.marks=o,this.content=r||b.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,o=0){this.content.nodesBetween(e,n,r,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,o){return this.content.textBetween(e,n,r,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&gr(this.attrs,n||e.defaultAttrs||Hh)&&F.sameSet(this.marks,r||F.none)}copy(e=null){return e==this.content?this:new t(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new t(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return C.empty;let o=this.resolve(e),s=this.resolve(n),i=r?0:o.sharedDepth(n),l=o.start(i),c=o.node(i).content.cut(o.pos-l,s.pos-l);return new C(c,o.depth-i,s.depth-i)}replace(e,n,r){return zh(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:o}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(o==e||n.isText)return n;e-=o+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let o=this.content.child(n-1);return{node:o,index:n-1,offset:r-o.nodeSize}}resolve(e){return br.resolveCached(this,e)}resolveNoCache(e){return br.resolve(this,e)}rangeHasMark(e,n,r){let o=!1;return n>e&&this.nodesBetween(e,n,s=>(r.isInSet(s.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),da(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=b.empty,o=0,s=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,o,s),l=i&&i.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=o;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,n,r,o){if(o&&!this.type.allowsMarks(o))return!1;let s=this.contentMatchAt(e).matchType(r),i=s&&s.matchFragment(this.content,n);return i?i.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),Jl(this.type.attrs,this.attrs,"node",this.type.name);let e=F.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];Jl(r.type.attrs,r.attrs,"mark",r.type.name),e=r.addToSet(e)}if(!F.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let o=b.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,o,r)}};Ee.prototype.text=void 0;var Ul=(()=>{let{stack:t}=new Error("/");if(!t||!/\n\s*at\s/.test(t))return n=>n;let e=Object.create(null);return n=>(e[n],n)})(),fs=class t extends Ee{constructor(e,n,r,o){if(super(e,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):da(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return Ul(this.text.slice(e,n))}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new t(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new t(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(Ul(this.text.slice(e,n)))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function da(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}function Jl(t,e,n,r){for(let o in e)if(!(o in t))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${r}`);for(let o in t)t[o].validate&&t[o].validate(e[o])}var kt=class t{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new hs(e,n);if(r.next==null)return t.empty;let o=fa(r);r.next&&r.err("Unexpected trailing text");let s=Uh(Kh(o));return Jh(s,r),s}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let o=this;for(let s=n;o&&s<r;s++)o=o.matchType(e.child(s).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let o=[this];function s(i,l){let a=i.matchFragment(e,r);if(a&&(!n||a.validEnd))return b.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:u,next:d}=i.next[c];if(!(u.isText||u.hasRequiredAttrs())&&o.indexOf(d)==-1){o.push(d);let f=s(d,l.concat(u));if(f)return f}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),s=o.match;if(s.matchType(e)){let i=[];for(let l=o;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<s.next.length;i++){let{type:l,next:a}=s.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!o.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:o}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&n(r.next[o].next)}return n(this),e.map((r,o)=>{let s=o+(r.validEnd?"*":" ")+" ";for(let i=0;i<r.next.length;i++)s+=(i?", ":"")+r.next[i].type.name+"->"+e.indexOf(r.next[i].next);return s}).join(`
|
|
2
|
+
`)}};kt.empty=new kt(!0);var hs=class{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}};function fa(t){let e=[];do e.push(Fh(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Fh(t){let e=[];do e.push(jh(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function jh(t){let e=_h(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=Wh(t,e);else break;return e}function ql(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Wh(t,e){let n=ql(t),r=n;return t.eat(",")&&(t.next!="}"?r=ql(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Vh(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let o=[];for(let s in n){let i=n[s];i.isInGroup(e)&&o.push(i)}return o.length==0&&t.err("No node type or group '"+e+"' found"),o}function _h(t){if(t.eat("(")){let e=fa(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=Vh(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Kh(t){let e=[[]];return o(s(t,0),n()),e;function n(){return e.push([])-1}function r(i,l,a){let c={term:a,to:l};return e[i].push(c),c}function o(i,l){i.forEach(a=>a.to=l)}function s(i,l){if(i.type=="choice")return i.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(i.type=="seq")for(let a=0;;a++){let c=s(i.exprs[a],l);if(a==i.exprs.length-1)return c;o(c,l=n())}else if(i.type=="star"){let a=n();return r(l,a),o(s(i.expr,a),a),[r(a)]}else if(i.type=="plus"){let a=n();return o(s(i.expr,l),a),o(s(i.expr,a),a),[r(a)]}else{if(i.type=="opt")return[r(l)].concat(s(i.expr,l));if(i.type=="range"){let a=l;for(let c=0;c<i.min;c++){let u=n();o(s(i.expr,a),u),a=u}if(i.max==-1)o(s(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let u=n();r(a,u),o(s(i.expr,a),u),a=u}return[r(a)]}else{if(i.type=="name")return[r(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function ha(t,e){return e-t}function Gl(t,e){let n=[];return r(e),n.sort(ha);function r(o){let s=t[o];if(s.length==1&&!s[0].term)return r(s[0].to);n.push(o);for(let i=0;i<s.length;i++){let{term:l,to:a}=s[i];!l&&n.indexOf(a)==-1&&r(a)}}}function Uh(t){let e=Object.create(null);return n(Gl(t,0));function n(r){let o=[];r.forEach(i=>{t[i].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<o.length;u++)o[u][0]==l&&(c=o[u][1]);Gl(t,a).forEach(u=>{c||o.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new kt(r.indexOf(t.length-1)>-1);for(let i=0;i<o.length;i++){let l=o[i][1].sort(ha);s.next.push({type:o[i][0],next:e[l.join(",")]||n(l)})}return s}}function Jh(t,e){for(let n=0,r=[t];n<r.length;n++){let o=r[n],s=!o.validEnd,i=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];i.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function pa(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function ma(t,e){let n=Object.create(null);for(let r in t){let o=t[r],s=e&&e[r];if(s===void 0)if(o.hasDefault)s=o.default;else throw new RangeError("No value supplied for attribute "+r);else o.validate&&o.validate(s);n[r]=s}return n}function ga(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new ps(t,r,e[r]);return n}var Ht=class t{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=ga(e,r.attrs),this.defaultAttrs=pa(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==kt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:ma(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ee(this,this.computeAttrs(e),b.from(n),F.setFrom(r))}createChecked(e=null,n,r){return n=b.from(n),this.checkContent(n),new Ee(this,this.computeAttrs(e),n,F.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=b.from(n),n.size){let i=this.contentMatch.fillBefore(n);if(!i)return null;n=i.append(n)}let o=this.contentMatch.matchFragment(n),s=o&&o.fillBefore(b.empty,!0);return s?new Ee(this,e,n.append(s),F.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:F.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,i)=>r[s]=new t(s,n,i));let o=n.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function qh(t,e,n){let r=n.split("|");return o=>{let s=o===null?"null":typeof o;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${s}`)}}var ps=class{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?qh(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}},Sn=class t{constructor(e,n,r,o){this.name=e,this.rank=n,this.schema=r,this.spec=o,this.attrs=ga(e,o.attrs),this.excluded=null;let s=pa(this.attrs);this.instance=s?new F(this,s):null}create(e=null){return!e&&this.instance?this.instance:new F(this,ma(this.attrs,e))}static compile(e,n){let r=Object.create(null),o=0;return e.forEach((s,i)=>r[s]=new t(s,o++,n,i)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}excludes(e){return this.excluded.indexOf(e)>-1}},wt=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let o in e)n[o]=e[o];n.nodes=as.from(e.nodes),n.marks=as.from(e.marks||{}),this.nodes=Ht.compile(this.spec.nodes,this),this.marks=Sn.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let s=this.nodes[o],i=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[i]||(r[i]=kt.parse(i,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?Xl(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let o in this.marks){let s=this.marks[o],i=s.spec.excludes;s.excluded=i==null?[s]:i==""?[]:Xl(this,i.split(" "))}this.nodeFromJSON=o=>Ee.fromJSON(this,o),this.markFromJSON=o=>F.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Ht){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,o)}text(e,n){let r=this.nodes.text;return new fs(r,r.defaultAttrs,e,F.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function Xl(t,e){let n=[];for(let r=0;r<e.length;r++){let o=e[r],s=t.marks[o],i=s;if(s)n.push(s);else for(let l in t.marks){let a=t.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&n.push(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function Gh(t){return t.tag!=null}function Xh(t){return t.style!=null}var We=class t{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(o=>{if(Gh(o))this.tags.push(o);else if(Xh(o)){let s=/[^=]*/.exec(o.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let s=e.nodes[o.node];return s.contentMatch.matchType(s)})}parse(e,n={}){let r=new kr(this,n,!1);return r.addAll(e,F.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new kr(this,n,!0);return r.addAll(e,F.none,n.from,n.to),C.maxOpen(r.finish())}matchTag(e,n,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let s=this.tags[o];if(Zh(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let i=s.getAttrs(e);if(i===!1)continue;s.attrs=i||void 0}return s}}}matchStyle(e,n,r,o){for(let s=o?this.styles.indexOf(o)+1:0;s<this.styles.length;s++){let i=this.styles[s],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!r.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(i.getAttrs){let a=i.getAttrs(n);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let n=[];function r(o){let s=o.priority==null?50:o.priority,i=0;for(;i<n.length;i++){let l=n[i];if((l.priority==null?50:l.priority)<s)break}n.splice(i,0,o)}for(let o in e.marks){let s=e.marks[o].spec.parseDOM;s&&s.forEach(i=>{r(i=Ql(i)),i.mark||i.ignore||i.clearMark||(i.mark=o)})}for(let o in e.nodes){let s=e.nodes[o].spec.parseDOM;s&&s.forEach(i=>{r(i=Ql(i)),i.node||i.ignore||i.mark||(i.node=o)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new t(e,t.schemaRules(e)))}},ya={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Yh={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ba={ol:!0,ul:!0},xn=1,ms=2,wn=4;function Yl(t,e,n){return e!=null?(e?xn:0)|(e==="full"?ms:0):t&&t.whitespace=="pre"?xn|ms:n&~wn}var $t=class{constructor(e,n,r,o,s,i){this.type=e,this.attrs=n,this.marks=r,this.solid=o,this.options=i,this.content=[],this.activeMarks=F.none,this.match=s||(i&wn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(b.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&xn)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-o[0].length))}}let n=b.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(b.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!ya.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},kr=class{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=n.topNode,s,i=Yl(null,n.preserveWhitespace,0)|(r?wn:0);o?s=new $t(o.type,o.attrs,F.none,!0,n.topMatch||o.type.contentMatch,i):r?s=new $t(null,null,F.none,!0,null,i):s=new $t(e.schema.topNodeType,null,F.none,!0,null,i),this.nodes=[s],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,o=this.top,s=o.options&ms?"full":this.localPreserveWS||(o.options&xn)>0,{schema:i}=this.parser;if(s==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
|
|
3
|
+
`);else if(i.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(i.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(i.linebreakReplacement.create(),n,!0),l[a]&&this.insertNode(i.text(l[a]),n,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=o.content[o.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(i.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let o=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i=e.nodeName.toLowerCase(),l;ba.hasOwnProperty(i)&&this.parser.normalizeLists&&Qh(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:Yh.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,n);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(ya.hasOwnProperty(i))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let d=a&&a.skip?n:this.readStyles(e,n);d&&this.addAll(e,d),c&&this.sync(s),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=o}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
4
|
+
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let s=this.parser.matchedStyles[o],i=r.getPropertyValue(s);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(s,i,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,o){let s,i;if(n.node)if(i=this.parser.schema.nodes[n.node],i.isLeaf)this.insertNode(i.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(i,n.attrs||null,r,n.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,n,r,o){let s=r||0;for(let i=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];i!=l;i=i.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(i,n);this.findAtPoint(e,s)}findPlace(e,n,r){let o,s;for(let i=this.open,l=0;i>=0;i--){let a=this.nodes[i],c=a.findWrapping(e);if(c&&(!o||o.length>c.length+l)&&(o=c,s=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!o)return null;this.sync(s);for(let i=0;i<o.length;i++)n=this.enterInner(o[i],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(n=this.enterInner(s,null,n))}let o=this.findPlace(e,n,r);if(o){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let i=F.none;for(let l of o.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):Zl(l.type,e.type))&&(i=l.addToSet(i));return s.content.push(e.mark(i)),!0}return!1}enter(e,n,r,o){let s=this.findPlace(e.create(n),r,!1);return s&&(s=this.enterInner(e,n,r,!0,o)),s}enterInner(e,n,r,o=!1,s){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=Yl(e,s,i.options);i.options&wn&&i.content.length==0&&(l|=wn);let a=F.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):Zl(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new $t(e,n,a,o,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=xn)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&n.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(o?0:1),i=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=s;a--)if(i(l-1,a))return!0;return!1}else{let u=a>0||a==0&&o?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return i(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}};function Qh(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&ba.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Zh(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Ql(t){let e={};for(let n in t)e[n]=t[n];return e}function Zl(t,e){let n=e.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(t))continue;let s=[],i=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||s.indexOf(u)<0&&i(u))return!0}};if(i(o.contentMatch))return!0}}var Ve=class t{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=pr(n).createDocumentFragment());let o=r,s=[];return e.forEach(i=>{if(s.length||i.marks.length){let l=0,a=0;for(;l<s.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)o=s.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],u=this.serializeMark(c,i.isInline,n);u&&(s.push([c,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(i,n))}),r}serializeNodeInner(e,n){if(e.isText)return pr(n).createTextNode(e.text);let{dom:r,contentDOM:o}=mr(pr(n),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,o)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let o=e.marks.length-1;o>=0;o--){let s=this.serializeMark(e.marks[o],e.isInline,n);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,n,r={}){let o=this.marks[e.type.name];return o&&mr(pr(r),o(e,n),null,e.attrs)}static renderSpec(e,n,r=null,o){return typeof n=="string"?{dom:e.createTextNode(n)}:mr(e,n,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new t(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=ea(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return ea(e.marks)}};function ea(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function pr(t){return t.document||window.document}var ta=new WeakMap;function ep(t){let e=ta.get(t);return e===void 0&&ta.set(t,e=tp(t)),e}function tp(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)n(r[o]);else for(let o in r)n(r[o])}return n(t),e}function mr(t,e,n,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let o=e[0],s;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=ep(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=o.indexOf(" ");i>0&&(n=o.slice(0,i),o=o.slice(i+1));let l,a=n?t.createElementNS(n,o):t.createElement(o),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof f=="string")a.appendChild(t.createTextNode(f));else{let{dom:h,contentDOM:p}=mr(t,f,n,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}var Ca=65535,Ma=Math.pow(2,16);function np(t,e){return t+e*Ma}function ka(t){return t&Ca}function rp(t){return(t-(t&Ca))/Ma}var va=1,Aa=2,wr=4,Ta=8,vn=class{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Ta)>0}get deletedBefore(){return(this.delInfo&(va|wr))>0}get deletedAfter(){return(this.delInfo&(Aa|wr))>0}get deletedAcross(){return(this.delInfo&wr)>0}},_e=class t{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&t.empty)return t.empty}recover(e){let n=0,r=ka(e);if(!this.inverted)for(let o=0;o<r;o++)n+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+n+rp(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let o=0,s=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+s],u=this.ranges[l+i],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:n:n,h=a+o+(f<0?0:u);if(r)return h;let p=e==(n<0?a:d)?null:np(l/3,e-a),m=0;return c&&(m|=e==a?Aa:e==d?va:wr,(n<0?e!=a:e!=d)&&(m|=Ta)),new vn(h,m,p)}o+=u-c}return r?e+o:new vn(e+o,0,null)}touches(e,n){let r=0,o=ka(n),s=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+s],u=a+c;if(e<=u&&l==o*3)return!0;r+=this.ranges[l+i]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,s=0;o<this.ranges.length;o+=3){let i=this.ranges[o],l=i-(this.inverted?s:0),a=i+(this.inverted?0:s),c=this.ranges[o+n],u=this.ranges[o+r];e(l,l+c,a,a+u),s+=u-c}}invert(){return new t(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?t.empty:new t(e<0?[0,-e,0]:[0,0,e])}};_e.empty=new _e([]);var An=class t{constructor(e,n,r=0,o=e?e.length:0){this.mirror=n,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new t(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=e.from,r=this._maps.length;n<e.to;n++){let o=e.getMirror(n);o!=null&&(o=o<n&&o>=e.from?r+(o-e.from):void 0),this.appendMap(e._maps[n],o)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.to-1,r=this._maps.length+e._maps.length;n>=e.from;n--){let o=e.getMirror(n);o!=null&&(o=o>n&&o<e.to?r-(o-e.from)-1:void 0),this.appendMap(e._maps[n].invert(),o)}}invert(){let e=new t;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let o=0;for(let s=this.from;s<this.to;s++){let i=this._maps[s],l=i.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return r?e:new vn(e,o,null)}},gs=Object.create(null),G=class{getMap(){return _e.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=gs[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in gs)throw new RangeError("Duplicate use of step JSON ID "+e);return gs[e]=n,n.prototype.jsonID=e,n}},te=class t{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new t(e,null)}static fail(e){return new t(null,e)}static fromReplace(e,n,r,o){try{return t.ok(e.replace(n,r,o))}catch(s){if(s instanceof nt)return t.fail(s.message);throw s}}};function ws(t,e,n){let r=[];for(let o=0;o<t.childCount;o++){let s=t.child(o);s.content.size&&(s=s.copy(ws(s.content,e,s))),s.isInline&&(s=e(s,n,o)),r.push(s)}return b.fromArray(r)}var St=class t extends G{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),s=new C(ws(n.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),o),n.openStart,n.openEnd);return te.fromReplace(e,this.from,this.to,s)}invert(e){let n=[];return e.nodesBetween(this.from,this.to,(r,o)=>{if(r.isInline&&r.isAtom){let s=this.mark.addToSet(r.marks);if(!F.sameSet(s,r.marks)){let i=Math.max(this.from,o),l=Math.min(this.to,o+r.nodeSize);Sr(Ie,i,l,this.mark,n);for(let a of r.marks)a.isInSet(s)||Sr(t,i,l,a,n)}}}),n.length==1?n[0]:new Tn(n)}map(e){let n=e.map(this.from,1),r=e.map(this.to,-1);return n>=r?null:new t(n,r,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};G.jsonID("addMark",St);var Ie=class t extends G{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new C(ws(n.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),n.openStart,n.openEnd);return te.fromReplace(e,this.from,this.to,r)}invert(e){let n=[];return e.nodesBetween(this.from,this.to,(r,o)=>{r.isInline&&r.isAtom&&this.mark.isInSet(r.marks)&&Sr(St,Math.max(this.from,o),Math.min(this.to,o+r.nodeSize),this.mark,n)}),n.length==1?n[0]:new Tn(n)}map(e){let n=e.map(this.from,1),r=e.map(this.to,-1);return n>=r?null:new t(n,r,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};G.jsonID("removeMark",Ie);function Sr(t,e,n,r,o){let s=o.length?o[o.length-1]:null;s&&s instanceof t&&s.to==e&&s.mark.eq(r)?o[o.length-1]=new t(s.from,n,r):o.push(new t(e,n,r))}var Tn=class t extends G{constructor(e){super(),this.steps=e}apply(e){for(let n of this.steps){let r=n.apply(e);if(!r.doc)return r;e=r.doc}return new te(e,null)}invert(e){return new t(this.steps.map(n=>n.invert(e)))}map(e){let n=[];for(let r of this.steps){let o=r.map(e);o&&n.push(o)}return n.length?new t(n):null}toJSON(){return{stepType:"markSet",steps:this.steps.map(e=>e.toJSON())}}static fromJSON(e,n){if(!Array.isArray(n.steps)||!n.steps.every(r=>r.stepType=="addMark"||r.stepType=="removeMark"))throw new RangeError("Invalid JSON for MarkSetStep");return new t(n.steps.map(r=>G.fromJSON(e,r)))}};G.jsonID("markSet",Tn);var En=class t extends G{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return te.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return te.fromReplace(e,this.pos,this.pos+1,new C(b.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let o=0;o<n.marks.length;o++)if(!n.marks[o].isInSet(r))return new t(this.pos,n.marks[o]);return new t(this.pos,this.mark)}}return new Ft(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}};G.jsonID("addNodeMark",En);var Ft=class t extends G{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return te.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return te.fromReplace(e,this.pos,this.pos+1,new C(b.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new En(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}};G.jsonID("removeNodeMark",Ft);var X=class t extends G{constructor(e,n,r,o=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=o}apply(e){return this.structure&&bs(e,this.from,this.to)?te.fail("Structure replace would overwrite content"):te.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new _e([this.from,this.to-this.from,this.slice.size])}invert(e){return new t(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&t.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new t(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof t)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?C.empty:new C(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new t(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?C.empty:new C(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new t(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new t(n.from,n.to,C.fromJSON(e,n.slice),!!n.structure)}};X.MAP_BIAS=1;G.jsonID("replace",X);var Y=class t extends G{constructor(e,n,r,o,s,i,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=o,this.slice=s,this.insert=i,this.structure=l}apply(e){if(this.structure&&(bs(e,this.from,this.gapFrom)||bs(e,this.gapTo,this.to)))return te.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return te.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?te.fromReplace(e,this.from,this.to,r):te.fail("Content does not fit in gap")}getMap(){return new _e([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new t(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||o<n.pos||s>r.pos||o>s?null:new t(n.pos,r.pos,o,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new t(n.from,n.to,n.gapFrom,n.gapTo,C.fromJSON(e,n.slice),n.insert,!!n.structure)}};G.jsonID("replaceAround",Y);function bs(t,e,n){let r=t.resolve(e),o=n-e,s=r.depth;for(;o>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,o--;if(o>0){let i=r.node(s).maybeChild(r.indexAfter(s));for(;o>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,o--}}return!1}function op(t,e,n,r){let o=[];t.doc.nodesBetween(e,n,(s,i,l)=>{if(!s.isInline)return;let a=s.marks;if(!r.isInSet(a)&&l.type.allowsMarkType(r.type)){let c=Math.max(i,e),u=Math.min(i+s.nodeSize,n);Sr(St,c,u,r,o)}}),o.forEach(s=>t.step(s))}function sp(t,e,n,r){let o=[],s=0;t.doc.nodesBetween(e,n,(i,l)=>{if(!i.isInline||!i.isAtom)return;s++;let a=null;if(r instanceof Sn){let c=i.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(i.marks)&&(a=[r]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,n);for(let u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<o.length;h++){let p=o[h];p.step==s-1&&d.eq(o[h].style)&&(f=p)}f?(f.to=c,f.step=s):o.push({style:d,from:Math.max(l,e),to:c,step:s})}}}),o.forEach(i=>t.step(new Ie(i.from,i.to,i.style)))}function Ss(t,e,n,r=n.contentMatch,o=!0){let s=t.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)i.push(new X(l,u,C.empty));else{r=d;for(let f=0;f<c.marks.length;f++)n.allowsMarkType(c.marks[f].type)||t.step(new Ie(l,u,c.marks[f]));if(o&&c.isText&&n.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new C(b.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),i.push(new X(l+f.index,l+f.index+f[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(b.empty,!0);t.replace(l,l,new C(a,0,0))}for(let a=i.length-1;a>=0;a--)t.step(i[a])}function ip(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Ue(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,o=0,s=0;;--r){let i=t.$from.node(r),l=t.$from.index(r)+o,a=t.$to.indexAfter(r)-s;if(r<t.depth&&i.canReplace(l,a,n))return r;if(r==0||i.type.spec.isolating||!ip(i,l,a))break;l&&(o=1),a<i.childCount&&(s=1)}return null}function lp(t,e,n){let{$from:r,$to:o,depth:s}=e,i=r.before(s+1),l=o.after(s+1),a=i,c=l,u=b.empty,d=0;for(let p=s,m=!1;p>n;p--)m||r.index(p)>0?(m=!0,u=b.from(r.node(p).copy(u)),d++):a--;let f=b.empty,h=0;for(let p=s,m=!1;p>n;p--)m||o.after(p+1)<o.end(p)?(m=!0,f=b.from(o.node(p).copy(f)),h++):c++;t.step(new Y(a,c,i,l,new C(u.append(f),d,h),u.size-d,!0))}function Wt(t,e,n=null,r=t){let o=ap(t,e),s=o&&cp(r,e);return s?o.map(wa).concat({type:e,attrs:n}).concat(s.map(wa)):null}function wa(t){return{type:t,attrs:null}}function ap(t,e){let{parent:n,startIndex:r,endIndex:o}=t,s=n.contentMatchAt(r).findWrapping(e);if(!s)return null;let i=s.length?s[0]:e;return n.canReplaceWith(r,o,i)?s:null}function cp(t,e){let{parent:n,startIndex:r,endIndex:o}=t,s=n.child(r),i=e.contentMatch.findWrapping(s.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:i}function up(t,e,n){let r=b.empty;for(let i=n.length-1;i>=0;i--){if(r.size){let l=n[i].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=b.from(n[i].type.create(n[i].attrs,r))}let o=e.start,s=e.end;t.step(new Y(o,s,o,s,new C(r,0,0),n.length,!0))}function dp(t,e,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,(i,l)=>{let a=typeof o=="function"?o(i):o;if(i.isTextblock&&!i.hasMarkup(r,a)&&fp(t.doc,t.mapping.slice(s).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Na(t,i,l,s),Ss(t,t.mapping.slice(s).map(l,1),r,void 0,c===null);let u=t.mapping.slice(s),d=u.map(l,1),f=u.map(l+i.nodeSize,1);return t.step(new Y(d,f,d+1,f-1,new C(b.from(r.create(a,null,i.marks)),0,0),1,!0)),c===!0&&Ea(t,i,l,s),!1}})}function Ea(t,e,n,r){e.forEach((o,s)=>{if(o.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(o.text);){let a=t.mapping.slice(r).map(n+1+s+i.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Na(t,e,n,r){e.forEach((o,s)=>{if(o.type==o.type.schema.linebreakReplacement){let i=t.mapping.slice(r).map(n+1+s);t.replaceWith(i,i+1,e.type.schema.text(`
|
|
5
|
+
`))}})}function fp(t,e,n){let r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}function hp(t,e,n,r,o){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let i=n.create(r,null,o||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,i);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Y(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new C(b.from(i),0,0),1,!0))}function Ce(t,e,n=1,r){let o=t.resolve(e),s=o.depth-n,i=r&&r[r.length-1]||o.parent;if(s<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!i.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,u=n-2;c>s;c--,u--){let d=o.node(c),f=o.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!m.type.validContent(h))return!1}let l=o.indexAfter(s),a=r&&r[0];return o.node(s).canReplaceWith(l,l,a?a.type:o.node(s+1).type)}function pp(t,e,n=1,r){let o=t.doc.resolve(e),s=b.empty,i=b.empty;for(let l=o.depth,a=o.depth-n,c=n-1;l>a;l--,c--){s=b.from(o.node(l).copy(s));let u=r&&r[c];i=b.from(u?u.type.create(u.attrs,i):o.node(l).copy(i))}t.step(new X(e,e,new C(s.append(i),n,n),!0))}function Ne(t,e){let n=t.resolve(e),r=n.index();return Oa(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function mp(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let o=0;o<e.childCount;o++){let s=e.child(o),i=s.type==r?t.type.schema.nodes.text:s.type;if(n=n.matchType(i),!n||!t.type.allowsMarks(s.marks))return!1}return n.validEnd}function Oa(t,e){return!!(t&&e&&!t.isLeaf&&mp(t,e))}function Vt(t,e,n=-1){let r=t.resolve(e);for(let o=r.depth;;o--){let s,i,l=r.index(o);if(o==r.depth?(s=r.nodeBefore,i=r.nodeAfter):n>0?(s=r.node(o+1),l++,i=r.node(o).maybeChild(l)):(s=r.node(o).maybeChild(l-1),i=r.node(o+1)),s&&!s.isTextblock&&Oa(s,i)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=n<0?r.before(o):r.after(o)}}function gp(t,e,n){let r=null,{linebreakReplacement:o}=t.doc.type.schema,s=t.doc.resolve(e-n),i=s.node().type;if(o&&i.inlineContent){let u=i.whitespace=="pre",d=!!i.contentMatch.matchType(o);u&&!d?r=!1:!u&&d&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);Na(t,u.node(),u.before(),l)}i.inlineContent&&Ss(t,e+n-1,i,s.node().contentMatchAt(s.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new X(c,a.map(e+n,-1),C.empty,!0)),r===!0){let u=t.doc.resolve(c);Ea(t,u.node(),u.before(),t.steps.length)}return t}function yp(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let s=r.index(o);if(r.node(o).canReplaceWith(s,s,n))return r.before(o+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let s=r.indexAfter(o);if(r.node(o).canReplaceWith(s,s,n))return r.after(o+1);if(s<r.node(o).childCount)return null}return null}function Mr(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let o=n.content;for(let s=0;s<n.openStart;s++)o=o.firstChild.content;for(let s=1;s<=(n.openStart==0&&n.size?2:1);s++)for(let i=r.depth;i>=0;i--){let l=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1;for(let a=0;a<2;a++){if(a){if(!l)break;l=-l}let c=r.index(i)+(l>0?1:0),u=r.node(i),d=!1;if(s==1)d=u.canReplace(c,c,o);else{let f=u.contentMatchAt(c).findWrapping(o.firstChild.type);d=f&&u.canReplaceWith(c,c,f[0])}if(d)return l==0?r.pos:l<0?r.before(i+1):r.after(i+1)}}return null}function Nn(t,e,n=e,r=C.empty){if(e==n&&!r.size)return null;let o=t.resolve(e),s=t.resolve(n);return Ra(o,s,r)?new X(e,n,r):new ks(o,s,r).fit()}function Ra(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}var ks=class{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=b.empty;for(let o=0;o<=e.depth;o++){let s=e.node(o);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=b.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let s=this.placed,i=r.depth,l=o.depth;for(;i&&l&&s.childCount==1;)s=s.firstChild.content,i--,l--;let a=new C(s,i,l);return e>-1?new Y(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new X(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let s=n.firstChild;if(n.childCount>1&&(o=0),s.type.spec.isolating&&o<=r){e=r;break}n=s.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let o,s=null;r?(s=Sa(this.unplaced.content,r-1).firstChild,o=s.content):o=this.unplaced.content;let i=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(n==1&&(i?c.matchType(i.type)||(d=c.fillBefore(b.from(i),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:d};if(n==2&&i&&(u=c.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced;return xa(e,-1)<=n?!1:(this.unplaced.size>1&&xa(e,1)>r&&r++,this.unplaced=new C(e,n+1,r),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=Sa(e,n);if(o.childCount<=1&&n>0){let s=e.size-n<=n+o.size;this.unplaced=new C(Cn(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new C(Cn(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:o,wrap:s}){for(;this.depth>n;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let i=this.unplaced,l=r?r.content:i.content,a=i.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[n];if(o){for(let m=0;m<o.childCount;m++)u.push(o.child(m));d=d.matchFragment(o)}let h=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let m=l.child(c),g=d.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(d=g,u.push(Ia(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=Mn(this.placed,n,b.from(u)),this.frontier[n].match=d,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=u[u.length-1];g&&m<h;m++)this.frontier.push({type:g.type,match:g.contentMatchAt(g.childCount)}),g=g.lastChild;this.unplaced=p?e==0?C.empty:new C(Cn(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new C(Cn(i.content,e,c),e,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!ys(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:o}=this.frontier[n],s=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),i=ys(e,n,o,r,s);if(i){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=ys(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:i,move:s?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Mn(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let o=e.node(r),s=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,s)}return e}openFrontierNode(e,n=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Mn(this.placed,this.depth,b.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(b.empty,!0);n.childCount&&(this.placed=Mn(this.placed,this.frontier.length,n))}};function Cn(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Cn(t.firstChild.content,e-1,n)))}function Mn(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Mn(t.lastChild.content,e-1,n)))}function Sa(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Ia(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Ia(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(b.empty,!0)))),t.copy(r)}function ys(t,e,n,r,o){let s=t.node(e),i=o?t.indexAfter(e):t.index(e);if(i==s.childCount&&!n.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,i);return l&&!bp(n,s.content,i)?l:null}function bp(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function kp(t){return t.spec.defining||t.spec.definingForContent}function xa(t,e){for(let n=0;;n++){let r=e<0?t.firstChild:t.lastChild;if(!r||r.isAtom)return n;t=r.content}}function wp(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let o=t.doc.resolve(e),s=t.doc.resolve(n);if(Ra(o,s,r))return t.step(new X(e,n,r));let i=La(o,s);i[i.length-1]==0&&i.pop();let l=-(o.depth+1);i.unshift(l);for(let f=o.depth,h=o.pos-1;f>0;f--,h--){let p=o.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;i.indexOf(f)>-1?l=f:o.before(f)==h&&i.splice(1,0,-f)}let a=i.indexOf(l),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=kp(h.type);if(p&&!h.sameMarkup(o.node(Math.abs(l)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m<i.length;m++){let g=i[(m+a)%i.length],y=!0;g<0&&(y=!1,g=-g);let w=o.node(g-1),k=o.index(g-1);if(w.canReplaceWith(k,k,p.type,p.marks))return t.replace(o.before(g),y?s.after(g):n,new C(Da(r.content,0,r.openStart,h),h,r.openEnd))}}let d=t.steps.length;for(let f=i.length-1;f>=0&&(t.replace(e,n,r),!(t.steps.length>d));f--){let h=i[f];h<0||(e=o.before(h),n=s.after(h))}}function Da(t,e,n,r,o){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy(Da(s.content,e+1,n,r,s)))}if(e>r){let s=o.contentMatchAt(0),i=s.fillBefore(t).append(t);t=i.append(s.matchFragment(i).fillBefore(b.empty,!0))}return t}function Sp(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let o=yp(t.doc,e,r.type);o!=null&&(e=n=o)}t.replaceRange(e,n,new C(b.from(r),0,0))}function xp(t,e,n){let r=t.doc.resolve(e),o=t.doc.resolve(n);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&r.parentOffset==0&&o.parentOffset==0){let i=r.sharedDepth(n),l=!1;for(let a=r.depth;a>i;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=o.depth;a>i;a--)o.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=o.depth;a>0&&n==o.start(a);a--)n=o.before(a);r=t.doc.resolve(e),o=t.doc.resolve(n)}}let s=La(r,o);for(let i=0;i<s.length;i++){let l=s[i],a=i==s.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),o.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return t.delete(r.before(l),o.after(l))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(e-r.start(i)==r.depth-i&&n>r.end(i)&&o.end(i)-n!=o.depth-i&&r.start(i-1)==o.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),o.index(i-1)))return t.delete(r.before(i),n);t.delete(e,n)}function La(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let o=r;o>=0;o--){let s=t.start(o);if(s<t.pos-(t.depth-o)||e.end(o)>e.pos+(e.depth-o)||t.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(s==e.start(o)||o==t.depth&&o==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==s-1)&&n.push(o)}return n}var xr=class t extends G{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return te.fail("No node at attribute step's position");let r=Object.create(null);for(let s in n.attrs)r[s]=n.attrs[s];r[this.attr]=this.value;let o=n.type.create(r,null,n.marks);return te.fromReplace(e,this.pos,this.pos+1,new C(b.from(o),0,n.isLeaf?0:1))}getMap(){return _e.empty}invert(e){return new t(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new t(n.pos,n.attr,n.value)}};G.jsonID("attr",xr);var Cr=class t extends G{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let o in e.attrs)n[o]=e.attrs[o];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return te.ok(r)}getMap(){return _e.empty}invert(e){return new t(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new t(n.attr,n.value)}};G.jsonID("docAttr",Cr);var jt=class extends Error{};jt=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};jt.prototype=Object.create(Error.prototype);jt.prototype.constructor=jt;jt.prototype.name="TransformError";var Ke=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new An}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new jt(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let o=this.mapping.maps[r];r&&(e=o.map(e,1),n=o.map(n,-1)),o.forEach((s,i,l,a)=>{e=Math.min(e,l),n=Math.max(n,a)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=C.empty){let o=Nn(this.doc,e,n,r);return o&&this.step(o),this}replaceWith(e,n,r){return this.replace(e,n,new C(b.from(r),0,0))}delete(e,n){return this.replace(e,n,C.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return wp(this,e,n,r),this}replaceRangeWith(e,n,r){return Sp(this,e,n,r),this}deleteRange(e,n){return xp(this,e,n),this}lift(e,n){return lp(this,e,n),this}join(e,n=1){return gp(this,e,n),this}wrap(e,n){return up(this,e,n),this}setBlockType(e,n=e,r,o=null){return dp(this,e,n,r,o),this}setNodeMarkup(e,n,r=null,o){return hp(this,e,n,r,o),this}setNodeAttribute(e,n,r){return this.step(new xr(e,n,r)),this}setDocAttribute(e,n){return this.step(new Cr(e,n)),this}addNodeMark(e,n){return this.step(new En(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof F)n.isInSet(r.marks)&&this.step(new Ft(e,n));else{let o=r.marks,s,i=[];for(;s=n.isInSet(o);)i.push(new Ft(e,s)),o=s.removeFromSet(o);for(let l=i.length-1;l>=0;l--)this.step(i[l])}return this}split(e,n=1,r){return pp(this,e,n,r),this}addMark(e,n,r){return op(this,e,n,r),this}removeMark(e,n,r){return sp(this,e,n,r),this}clearIncompatible(e,n,r){return Ss(this,e,n,r),this}};var xs=Object.create(null),T=class{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Kt(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=C.empty){let r=n.content.lastChild,o=null;for(let l=0;l<n.openEnd;l++)o=r,r=r.lastChild;let s=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:a,$to:c}=i[l],u=e.mapping.slice(s);e.replaceRange(u.map(a.pos),u.map(c.pos),l?C.empty:n),l==0&&Ba(e,s,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:i,$to:l}=o[s],a=e.mapping.slice(r),c=a.map(i.pos),u=a.map(l.pos);s?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),Ba(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let o=e.parent.inlineContent?new M(e):_t(e.node(0),e.parent,e.pos,e.index(),n,r);if(o)return o;for(let s=e.depth-1;s>=0;s--){let i=n<0?_t(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):_t(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,n,r);if(i)return i}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new he(e.node(0))}static atStart(e){return _t(e,e,0,0,1)||new he(e)}static atEnd(e){return _t(e,e,e.content.size,e.childCount,-1)||new he(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=xs[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in xs)throw new RangeError("Duplicate use of selection JSON ID "+e);return xs[e]=n,n.prototype.jsonID=e,n}getBookmark(){return M.between(this.$anchor,this.$head).getBookmark()}};T.prototype.visible=!0;var Kt=class{constructor(e,n){this.$from=e,this.$to=n}},Pa=!1;function za(t){!Pa&&!t.parent.inlineContent&&(Pa=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}var M=class t extends T{constructor(e,n=e){za(e),za(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return T.near(r);let o=e.resolve(n.map(this.anchor));return new t(o.parent.inlineContent?o:r,r)}replace(e,n=C.empty){if(super.replace(e,n),n==C.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof t&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Ar(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new t(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let o=e.resolve(n);return new this(o,r==n?o:e.resolve(r))}static between(e,n,r){let o=e.pos-n.pos;if((!r||o)&&(r=o>=0?1:-1),!n.parent.inlineContent){let s=T.findFrom(n,r,!0)||T.findFrom(n,-r,!0);if(s)n=s.$head;else return T.near(n,r)}return e.parent.inlineContent||(o==0?e=n:(e=(T.findFrom(e,-r,!0)||T.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=o<0&&(e=n))),new t(e,n)}};T.jsonID("text",M);var Ar=class t{constructor(e,n){this.anchor=e,this.head=n}map(e){return new t(e.map(this.anchor),e.map(this.head))}resolve(e){return M.between(e.resolve(this.anchor),e.resolve(this.head))}},v=class t extends T{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:o}=n.mapResult(this.anchor),s=e.resolve(o);return r?T.near(s):new t(s)}content(){return new C(b.from(this.node),0,0)}eq(e){return e instanceof t&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Ms(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new t(e.resolve(n.anchor))}static create(e,n){return new t(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};v.prototype.visible=!1;T.jsonID("node",v);var Ms=class t{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Ar(r,r):new t(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&v.isSelectable(r)?new v(n):T.near(n)}},he=class t extends T{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=C.empty){if(n==C.empty){e.delete(0,e.doc.content.size);let r=T.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new t(e)}map(e){return new t(e)}eq(e){return e instanceof t}getBookmark(){return Cp}};T.jsonID("all",he);var Cp={map(){return this},resolve(t){return new he(t)}};function _t(t,e,n,r,o,s=!1){if(e.inlineContent)return M.create(t,n);for(let i=r-(o>0?0:1);o>0?i<e.childCount:i>=0;i+=o){let l=e.child(i);if(l.isAtom){if(!s&&v.isSelectable(l))return v.create(t,n-(o<0?l.nodeSize:0))}else{let a=_t(t,l,n+o,o<0?l.childCount:0,o,s);if(a)return a}n+=l.nodeSize*o}return null}function Ba(t,e,n){let r=t.steps.length-1;if(r<e)return;let o=t.steps[r];if(!(o instanceof X||o instanceof Y))return;let s=t.mapping.maps[r],i;s.forEach((l,a,c,u)=>{i==null&&(i=u)}),t.setSelection(T.near(t.doc.resolve(i),n))}var $a=1,vr=2,Ha=4,vs=class extends Ke{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|$a)&~vr,this.storedMarks=null,this}get selectionSet(){return(this.updated&$a)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=vr,this}ensureMarks(e){return F.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&vr)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~vr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||F.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let o=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let s=this.storedMarks;if(!s){let i=this.doc.resolve(n);s=r==n?i.marks():i.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,o.text(e,s)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(T.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Ha,this}get scrolledIntoView(){return(this.updated&Ha)>0}};function Fa(t,e){return!e||!t?t:t.bind(e)}var xt=class{constructor(e,n,r){this.name=e,this.init=Fa(n.init,r),this.apply=Fa(n.apply,r)}},Mp=[new xt("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new xt("selection",{init(t,e){return t.selection||T.atStart(e.doc)},apply(t){return t.selection}}),new xt("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new xt("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})],On=class{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Mp.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new xt(r.key,r.spec.state,r))})}},Ct=class t{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let o=this.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),o=null;for(;;){let s=!1;for(let i=0;i<this.config.plugins.length;i++){let l=this.config.plugins[i];if(l.spec.appendTransaction){let a=o?o[i].n:0,c=o?o[i].state:this,u=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(u&&r.filterTransaction(u,i)){if(u.setMeta("appendedTransaction",e),!o){o=[];for(let d=0;d<this.config.plugins.length;d++)o.push(d<i?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),s=!0}o&&(o[i]={state:r,n:n.length})}}if(!s)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new t(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let s=r[o];n[s.name]=s.apply(e,this[s.name],this,n)}return n}get tr(){return new vs(this)}static create(e){let n=new On(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new t(n);for(let o=0;o<n.fields.length;o++)r[n.fields[o].name]=n.fields[o].init(e,r);return r}reconfigure(e){let n=new On(this.schema,e.plugins),r=n.fields,o=new t(n);for(let s=0;s<r.length;s++){let i=r[s].name;o[i]=this.hasOwnProperty(i)?this[i]:r[s].init(e,o)}return o}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],s=o.spec.state;s&&s.toJSON&&(n[r]=s.toJSON.call(o,this[o.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new On(e.schema,e.plugins),s=new t(o);return o.fields.forEach(i=>{if(i.name=="doc")s.doc=Ee.fromJSON(e.schema,n.doc);else if(i.name=="selection")s.selection=T.fromJSON(s.doc,n.selection);else if(i.name=="storedMarks")n.storedMarks&&(s.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){s[i.name]=c.fromJSON.call(a,e,n[l],s);return}}s[i.name]=i.init(e,s)}}),s}};function ja(t,e,n){for(let r in t){let o=t[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=ja(o,e,{})),n[r]=o}return n}var R=class{constructor(e){this.spec=e,this.props={},e.props&&ja(e.props,this,this.props),this.key=e.key?e.key.key:Wa("plugin")}getState(e){return e[this.key]}},Cs=Object.create(null);function Wa(t){return t in Cs?t+"$"+ ++Cs[t]:(Cs[t]=0,t+"$")}var z=class{constructor(e="key"){this.key=Wa(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var _a=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Ka(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}var Ts=(t,e,n)=>{let r=Ka(t,n);if(!r)return!1;let o=Ns(r);if(!o){let i=r.blockRange(),l=i&&Ue(i);return l==null?!1:(e&&e(t.tr.lift(i,l).scrollIntoView()),!0)}let s=o.nodeBefore;if(Qa(t,o,e,-1))return!0;if(r.parent.content.size==0&&(Ut(s,"end")||v.isSelectable(s)))for(let i=r.depth;;i--){let l=Nn(t.doc,r.before(i),r.after(i),C.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(Ut(s,"end")?T.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):v.create(a.doc,o.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(i==1||r.node(i-1).childCount>1)break}return s.isAtom&&o.depth==r.depth-1?(e&&e(t.tr.delete(o.pos-s.nodeSize,o.pos).scrollIntoView()),!0):!1},Tr=(t,e,n)=>{let r=Ka(t,n);if(!r)return!1;let o=Ns(r);return o?Ua(t,o,e):!1},Er=(t,e,n)=>{let r=Ja(t,n);if(!r)return!1;let o=Is(r);return o?Ua(t,o,e):!1};function Ua(t,e,n){let r=e.nodeBefore,o=r,s=e.pos-1;for(;!o.isTextblock;s--){if(o.type.spec.isolating)return!1;let u=o.lastChild;if(!u)return!1;o=u}let i=e.nodeAfter,l=i,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=Nn(t.doc,s,a,C.empty);if(!c||c.from!=s||c instanceof X&&c.slice.size>=a-s)return!1;if(n){let u=t.tr.step(c);u.setSelection(M.create(u.doc,s)),n(u.scrollIntoView())}return!0}function Ut(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var Es=(t,e,n)=>{let{$head:r,empty:o}=t.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;s=Ns(r)}let i=s&&s.nodeBefore;return!i||!v.isSelectable(i)?!1:(e&&e(t.tr.setSelection(v.create(t.doc,s.pos-i.nodeSize)).scrollIntoView()),!0)};function Ns(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Ja(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}var Os=(t,e,n)=>{let r=Ja(t,n);if(!r)return!1;let o=Is(r);if(!o)return!1;let s=o.nodeAfter;if(Qa(t,o,e,1))return!0;if(r.parent.content.size==0&&(Ut(s,"start")||v.isSelectable(s))){let i=Nn(t.doc,r.before(),r.after(),C.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=t.tr.step(i);l.setSelection(Ut(s,"start")?T.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):v.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&o.depth==r.depth-1?(e&&e(t.tr.delete(o.pos,o.pos+s.nodeSize).scrollIntoView()),!0):!1},Rs=(t,e,n)=>{let{$head:r,empty:o}=t.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;s=Is(r)}let i=s&&s.nodeAfter;return!i||!v.isSelectable(i)?!1:(e&&e(t.tr.setSelection(v.create(t.doc,s.pos)).scrollIntoView()),!0)};function Is(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}var qa=(t,e)=>{let n=t.selection,r=n instanceof v,o;if(r){if(n.node.isTextblock||!Ne(t.doc,n.from))return!1;o=n.from}else if(o=Vt(t.doc,n.from,-1),o==null)return!1;if(e){let s=t.tr.join(o);r&&s.setSelection(v.create(s.doc,o-t.doc.resolve(o).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},Ga=(t,e)=>{let n=t.selection,r;if(n instanceof v){if(n.node.isTextblock||!Ne(t.doc,n.to))return!1;r=n.to}else if(r=Vt(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Xa=(t,e)=>{let{$from:n,$to:r}=t.selection,o=n.blockRange(r),s=o&&Ue(o);return s==null?!1:(e&&e(t.tr.lift(o,s).scrollIntoView()),!0)},Ds=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
|
|
6
|
+
`).scrollIntoView()),!0)};function Ls(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var Ps=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),s=n.indexAfter(-1),i=Ls(o.contentMatchAt(s));if(!i||!o.canReplaceWith(s,s,i))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,i.createAndFill());a.setSelection(T.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},zs=(t,e)=>{let n=t.selection,{$from:r,$to:o}=n;if(n instanceof he||r.parent.inlineContent||o.parent.inlineContent)return!1;let s=Ls(o.parent.contentMatchAt(o.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let i=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=t.tr.insert(i,s.createAndFill());l.setSelection(M.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},Bs=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let s=n.before();if(Ce(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),o=r&&Ue(r);return o==null?!1:(e&&e(t.tr.lift(r,o).scrollIntoView()),!0)};function vp(t){return(e,n)=>{if(e.selection instanceof v&&e.selection.node.isBlock){let{$from:h}=e.selection;return!h.parentOffset||!Ce(e.doc,h.pos)?!1:(n&&n(e.tr.split(h.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof M||e.selection instanceof he)&&r.deleteSelection();let{$from:o}=r.selection,s=r.steps.length,i=[],l,a,c=!1,u=!1;for(let h=o.depth;;h--)if(o.node(h).isBlock){c=o.end(h)==o.pos+(o.depth-h),u=o.start(h)==o.pos-(o.depth-h),a=Ls(o.node(h-1).contentMatchAt(o.indexAfter(h-1)));let m=t&&t(o.parent,c,o);i.unshift(m||(c&&a?{type:a}:null)),l=h;break}else{if(h==1)return!1;i.unshift(null)}let d=o.pos,f=Ce(r.doc,d,i.length,i);if(f||(i[0]=a?{type:a}:null,f=Ce(r.doc,d,i.length,i)),!f)return!1;if(r.split(d,i.length,i),!c&&u&&o.node(l).type!=a){let h=r.mapping.slice(s),p=h.map(o.before(l)),m=r.doc.resolve(p);a&&o.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&r.setNodeMarkup(h.map(o.before(l)),a)}return n&&n(r.scrollIntoView()),!0}}var Ap=vp();var Ya=(t,e)=>{let{$from:n,to:r}=t.selection,o,s=n.sharedDepth(r);return s==0?!1:(o=n.before(s),e&&e(t.tr.setSelection(v.create(t.doc,o))),!0)},Tp=(t,e)=>(e&&e(t.tr.setSelection(new he(t.doc))),!0);function Ep(t,e,n){let r=e.nodeBefore,o=e.nodeAfter,s=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(o.isTextblock||Ne(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Qa(t,e,n,r){let o=e.nodeBefore,s=e.nodeAfter,i,l,a=o.type.spec.isolating||s.type.spec.isolating;if(!a&&Ep(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(l=o.contentMatchAt(o.childCount)).findWrapping(s.type))&&l.matchType(i[0]||s.type).validEnd){if(n){let h=e.pos+s.nodeSize,p=b.empty;for(let y=i.length-1;y>=0;y--)p=b.from(i[y].create(null,p));p=b.from(o.copy(p));let m=t.tr.step(new Y(e.pos-1,h,e.pos,h,new C(p,1,0),i.length,!0)),g=m.doc.resolve(h+2*i.length);g.nodeAfter&&g.nodeAfter.type==o.type&&Ne(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&a?null:T.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&Ue(d);if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(d,f).scrollIntoView()),!0;if(c&&Ut(s,"start",!0)&&Ut(o,"end")){let h=o,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(n){let y=b.empty;for(let k=p.length-1;k>=0;k--)y=b.from(p[k].copy(y));let w=t.tr.step(new Y(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new C(y,p.length,0),0,!0));n(w.scrollIntoView())}return!0}}return!1}function Za(t){return function(e,n){let r=e.selection,o=t<0?r.$from:r.$to,s=o.depth;for(;o.node(s).isInline;){if(!s)return!1;s--}return o.node(s).isTextblock?(n&&n(e.tr.setSelection(M.create(e.doc,t<0?o.start(s):o.end(s)))),!0):!1}}var $s=Za(-1),Hs=Za(1);function ec(t,e=null){return function(n,r){let{$from:o,$to:s}=n.selection,i=o.blockRange(s),l=i&&Wt(i,t,e);return l?(r&&r(n.tr.wrap(i,l).scrollIntoView()),!0):!1}}function Fs(t,e=null){return function(n,r){let o=!1;for(let s=0;s<n.selection.ranges.length&&!o;s++){let{$from:{pos:i},$to:{pos:l}}=n.selection.ranges[s];n.doc.nodesBetween(i,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)o=!0;else{let u=n.doc.resolve(c),d=u.index();o=u.parent.canReplaceWith(d,d+1,t)}})}if(!o)return!1;if(r){let s=n.tr;for(let i=0;i<n.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[i];s.setBlockType(l,a,t,e)}r(s.scrollIntoView())}return!0}}function js(...t){return function(e,n,r){for(let o=0;o<t.length;o++)if(t[o](e,n,r))return!0;return!1}}var As=js(_a,Ts,Es),Va=js(_a,Os,Rs),rt={Enter:js(Ds,zs,Bs,Ap),"Mod-Enter":Ps,Backspace:As,"Mod-Backspace":As,"Shift-Backspace":As,Delete:Va,"Mod-Delete":Va,"Mod-a":Tp},Np={"Ctrl-h":rt.Backspace,"Alt-Backspace":rt["Mod-Backspace"],"Ctrl-d":rt.Delete,"Ctrl-Alt-Backspace":rt["Mod-Delete"],"Alt-Delete":rt["Mod-Delete"],"Alt-d":rt["Mod-Delete"],"Ctrl-a":$s,"Ctrl-e":Hs};for(let t in rt)Np[t]=rt[t];var Cw=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1;function tc(t,e=null){return function(n,r){let{$from:o,$to:s}=n.selection,i=o.blockRange(s);if(!i)return!1;let l=r?n.tr:null;return Op(l,i,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Op(t,e,n,r=null){let o=!1,s=e,i=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=i.resolve(e.start-2);s=new bt(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new bt(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let l=Wt(s,n,r,e);return l?(t&&Rp(t,e,l,o,n),!0):!1}function Rp(t,e,n,r,o){let s=b.empty;for(let u=n.length-1;u>=0;u--)s=b.from(n[u].type.create(n[u].attrs,s));t.step(new Y(e.start-(r?2:0),e.end,e.start,e.end,new C(s,0,0),n.length,!0));let i=0;for(let u=0;u<n.length;u++)n[u].type==o&&(i=u+1);let l=n.length-i,a=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&l&&Ce(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return t}function Nr(t,e){return t instanceof Ht?e==t:t.indexOf(e)>-1}function nc(t){return function(e,n){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,i=>i.childCount>0&&Nr(t,i.firstChild.type));return s?n?Nr(t,r.node(s.depth-1).type)?Ip(e,n,s):Dp(e,n,s):!0:!1}}function Ip(t,e,n){let r=t.tr,o=n.end,s=n.$to.end(n.depth),i=n.parent.child(n.endIndex-1).type;o<s&&(r.step(new Y(o-1,s,o,s,new C(b.from(i.create(null,n.parent.copy())),1,0),1,!0)),n=new bt(r.doc.resolve(n.$from.pos),r.doc.resolve(s),n.depth));let l=Ue(n);if(l==null)return!1;r.lift(n,l);let a=r.doc.resolve(r.mapping.map(o,-1)-1);return Ne(r.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&r.join(a.pos),e(r.scrollIntoView()),!0}function Dp(t,e,n){let r=t.tr,o=n.parent;for(let h=n.end,p=n.endIndex-1,m=n.startIndex;p>m;p--)h-=o.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(n.start),i=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==o.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,i.content.append(a?b.empty:b.from(o))))return!1;let d=s.pos,f=d+i.nodeSize;return r.step(new Y(d-(l?1:0),f+(a?1:0),d+1,f-1,new C((l?b.empty:b.from(o.copy(b.empty))).append(a?b.empty:b.from(o.copy(b.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function rc(t){return function(e,n){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,c=>c.childCount>0&&Nr(t,c.firstChild.type));if(!s)return!1;let i=s.startIndex;if(i==0)return!1;let l=s.parent,a=l.child(i-1);if(!Nr(t,a.type))return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=b.from(c?a.lastChild.lastChild.type.create():null),d=new C(b.from(a.type.create(null,b.from(l.type.create(null,u)))),c?3:1,0),f=s.start,h=s.end;n(e.tr.step(new Y(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}var le=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e};function Xt(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e}var Us=null;function De(t,e,n){let r=Us||(Us=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r}function Lp(){Us=null}function Dn(t,e,n,r){return n&&(sc(t,e,n,r,-1)||sc(t,e,n,r,1))}var oc=/^(img|br|input|textarea|hr)$/i;function sc(t,e,n,r,o){for(var s;;){if(t==n&&e==r)return!0;if(e==(o<0?0:ne(t))){let i=t.parentNode;if(!i||!N(i)||zn(t)||oc.test(t.nodeName)||t.contentEditable=="false")return!1;e=le(t)+(o<0?0:1),t=i}else if(N(t)){let i=t.childNodes[e+(o<0?-1:0)];if(N(i)&&i.contentEditable=="false")if(!((s=i.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=o;else return!1;else{if(zn(i)||oc.test(i.nodeName))return!1;t=i,e=o<0?ne(t):0}}else return!1}}function ne(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function N(t){return t.nodeType==1}function Q(t){return t.nodeType==3}function Yt(t,e){return e?t.contains(N(e)?e:e.parentNode):!1}function ai(t,e){for(;;){if(Q(t)&&e)return t;if(N(t)&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=ne(t)}else if(t.parentNode&&!zn(t,!0))e=le(t),t=t.parentNode;else return null}}function ci(t,e){for(;;){if(Q(t)&&e<t.nodeValue.length)return t;if(N(t)&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!zn(t,!0))e=le(t)+1,t=t.parentNode;else return null}}function Pp(t,e,n){for(let r=e==0,o=e==ne(t);r||o;){if(t==n)return!0;let s=le(t);if(t=t.parentNode,!t)return!1;r=r&&s==0,o=o&&s==ne(t)}}function zn(t,e=!1){let n;for(let r=t;r&&!(n=r.pmViewDesc);r=r.parentNode);return n&&n.node&&(!e||n.node.isBlock)&&(n.dom==t||n.contentDOM==t)}function $r(t){return t.focusNode&&Dn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)}function Hc(t,e){t.collapse(e.anchorNode,e.anchorOffset),(e.focusNode!=e.anchorNode||e.focusOffset!=e.anchorOffset)&&t.extend(e.focusNode,e.focusOffset)}function zp(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Bp(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function $p(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(ne(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(ne(r.startContainer),r.startOffset)}}}var Pe=typeof navigator<"u"?navigator:null,ic=typeof document<"u"?document:null,Qt=Pe&&Pe.userAgent||"",Oe=/gecko\/(\d+)/i.test(Qt)&&!/edge?\//i.test(Qt);Oe&&+(/Firefox\/(\d+)/.exec(Qt)||[0,0])[1];var Js=/Chrome\/(\d+)/.exec(Qt),pe=!!Js,Fc=Js?+Js[1]:0,ae=!!Pe&&/Apple Computer/.test(Pe.vendor),Zt=ae&&(/Mobile\/\w+/.test(Qt)||!!Pe&&Pe.maxTouchPoints>2),Me=Zt||(Pe?/Mac/.test(Pe.platform):!1),jc=Pe?/Win/.test(Pe.platform):!1,qe=/Android \d/.test(Qt),Hr=!!ic&&"webkitFontSmoothing"in ic.documentElement.style,Hp=Hr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Fp(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Je(t,e){return typeof t=="number"?t:t[e]}function jp(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function lc(t,e,n){for(;;)if(n<0?e:e<ne(t)){if(Q(t))return Le(De(t,e+(n<0?-1:0),e+(n>0?1:0)),-n);let r=t.childNodes[n<0?e-1:e];if(Q(r))t=r,e=n<0?r.nodeValue.length:0;else return N(r)?Le(r,-n):null}else{if(zn(t,!0)||!t.parentNode)return null;e=le(t)+(n<0?0:1),t=t.parentNode}}function ac(t,e,n){if(!qs(e)&&e.left==0)return;let r=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let i=n||t.dom;i;){if(!N(i)){i=Xt(i);continue}let l=i==s.body,a=l?Fp(s):jp(i),c=0,u=0;if(e.top<a.top+Je(r,"top")?u=-(a.top-e.top+Je(o,"top")):e.bottom>a.bottom-Je(r,"bottom")&&(u=e.bottom-e.top>a.bottom-a.top?e.top+Je(o,"top")-a.top:e.bottom-a.bottom+Je(o,"bottom")),e.left<a.left+Je(r,"left")?c=-(a.left-e.left+Je(o,"left")):e.right>a.right-Je(r,"right")&&(c=e.right-a.right+Je(o,"right")),c||u)if(l)s.defaultView.scrollBy(c,u);else{let f=i.scrollLeft,h=i.scrollTop;u&&(i.scrollTop+=u),c&&(i.scrollLeft+=c);let p=i.scrollLeft-f,m=i.scrollTop-h;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}let d=l?"fixed":getComputedStyle(i).position;if(/^(fixed|sticky)$/.test(d))break;i=d=="absolute"?i.offsetParent:Xt(i)}}function Wp(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,o;for(let s=(e.left+e.right)/2,i=n+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=t.root.elementFromPoint(s,i);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:Wc(t.dom)}}function Wc(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Xt(r));return e}function Vp({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Vc(n,r==0?0:r-e)}function Vc(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:o,left:s}=t[n];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}var Jt=null;function _c(t){if(t.setActive)return t.setActive();if(Jt)return t.focus(Jt);let e=Wc(t);t.focus(Jt==null?{get preventScroll(){return Jt={preventScroll:!0},!0}}:void 0),Jt||(Jt=!1,Vc(e,0))}function Kc(t,e){let n,r=2e8,o,s=0,i=e.top,l=e.top,a,c;for(let u=t.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(N(u))f=u.getClientRects();else if(Q(u))f=De(u).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=i&&p.bottom>=l){i=Math.max(p.bottom,i),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<r){n=u,r=m,o=m&&Q(n)?{left:p.right<e.left?p.right:p.left,top:e.top}:e,N(u)&&m&&(s=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=d+1)}}return!n&&a&&(n=a,o=c,r=0),n&&Q(n)?_p(n,o):!n||r?{node:t,offset:s}:Kc(n,o)}function _p(t,e){let n=t.nodeValue.length,r=document.createRange(),o;for(let s=0;s<n;s++){r.setEnd(t,s+1),r.setStart(t,s);let i=Le(r,1);if(i.top!=i.bottom&&ui(e,i)){o={node:t,offset:s+(e.left>=(i.left+i.right)/2?1:0)};break}}return r.detach(),o||{node:t,offset:0}}function ui(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Kp(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function Up(t,e,n){let{node:r,offset:o}=Kc(e,n),s=-1;if(N(r)&&!r.firstChild){let i=r.getBoundingClientRect();s=i.left!=i.right&&n.left>(i.left+i.right)/2?1:-1}return{pos:t.docView.posFromDOM(r,o,s),affinity:Uc(r,o,n)}}function cc(t,e){return t<e.left?e.left-t:t>e.right?t-e.right:0}function Uc(t,e,n){let r=lc(t,e,-1),o=lc(t,e,1);return r?o?r.bottom<=o.top?n.top>(r.bottom+o.top)/2?1:-1:cc(n.left,r)<cc(n.left,o)?-1:1:-1:1}function Jp(t,e,n,r){let o=-1;for(let s=e;s!=t.dom;){let i=t.docView.nearestDesc(s,!0),l;if(!i)return null;if(N(i.dom)&&((l=i.dom.getBoundingClientRect()).width||l.height)){if(!i.contentDOM&&!i.node.isText&&r.left>=l.left&&r.left<=l.right&&r.top>=l.top&&r.top<=l.bottom){let a=i.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2;return{pos:a?i.posBefore:i.posAfter,affinity:a?1:-1}}i.node.isBlock&&i.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(i.dom.nodeName)&&(r.top<l.top||r.top>l.bottom)&&(o=r.top<l.top?i.posBefore:i.posAfter)}s=i.dom.parentNode}return o>-1?{pos:o,affinity:0}:{pos:t.docView.posFromDOM(e,n,-1),affinity:Uc(e,n,r)}}function Jc(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),s=o;;){let i=t.childNodes[s];if(N(i)){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(ui(e,c))return Jc(i,e,c)}}if((s=(s+1)%r)==o)break}return t}function qp(t,e){let n=t.dom.ownerDocument,r,o=0,s=$p(n,e.left,e.top);s&&({node:r,offset:o}=s);let i=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l,a=0;if(!i||!t.dom.contains(i)){let u=t.dom.getBoundingClientRect();if(!ui(e,u)||(i=Jc(t.dom,e,u),!i))return null}if(ae)for(let u=i;r&&u;u=Xt(u))u.draggable&&(r=void 0);if(i=Kp(i,e),r){if(Oe&&N(r)&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let d=r.childNodes[o],f;d.nodeName=="IMG"&&(f=d.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&o++}let u;if(Hr&&o&&N(r)&&N(u=r.childNodes[o-1])&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&o--,r==t.dom&&o==r.childNodes.length-1&&N(r.lastChild)&&e.top>r.lastChild.getBoundingClientRect().bottom)l=t.state.doc.content.size;else if(o==0||!N(r)||r.childNodes[o-1].nodeName!="BR"){let d=Jp(t,r,o,e);d&&({pos:l,affinity:a}=d)}}l==null&&({pos:l,affinity:a}=Up(t,i,e));let c=t.docView.nearestDesc(i,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1,affinity:a}}function qs(t){return t.top<t.bottom||t.left<t.right}function Le(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(qs(r))return r}return Array.prototype.find.call(n,qs)||t.getBoundingClientRect()}var Gp=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function qc(t,e,n){let{node:r,offset:o,atom:s}=t.docView.domFromPos(e,n<0?-1:1),i=Hr||Oe;if(Q(r))if(i&&(Gp.test(r.nodeValue)||(n<0?!o:o==r.nodeValue.length))){let a=Le(De(r,o,o),n);if(Oe&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=Le(De(r,o-1,o-1),-1);if(c.top==a.top){let u=Le(De(r,o,o+1),-1);if(u.top!=a.top)return Rn(u,u.left<c.left)}}return a}else{let a=o,c=o,u=n<0?1:-1;return n<0&&!o?(c++,u=-1):n>=0&&o==r.nodeValue.length?(a--,u=1):n<0?a--:c++,Rn(Le(De(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&o&&(n<0||o==ne(r))){let a=r.childNodes[o-1];if(N(a))return Ws(a.getBoundingClientRect(),!1)}if(s==null&&o<ne(r)){let a=r.childNodes[o];if(N(a))return Ws(a.getBoundingClientRect(),!0)}return Ws(r.getBoundingClientRect(),n>=0)}if(s==null&&o&&(n<0||o==ne(r))){let a=r.childNodes[o-1],c=Q(a)?De(a,ne(a)-(i?0:1)):N(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Rn(Le(c,1),!1)}if(s==null&&o<ne(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?Q(a)?De(a,0,i?0:1):N(a)?a:null:null;if(c)return Rn(Le(c,-1),!0)}return Rn(Le(Q(r)?De(r):r,-n),n>=0)}function Rn(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Ws(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Gc(t,e,n){let r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}function Xp(t,e,n){let r=e.selection,o=n=="up"?r.$from:r.$to;return Gc(t,e,()=>{let{node:s}=t.docView.domFromPos(o.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let i=qc(t,o.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(N(l))a=l.getClientRects();else if(Q(l))a=De(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(n=="up"?i.top-u.top>(u.bottom-i.top)*2:u.bottom-i.bottom>(i.bottom-u.top)*2))return!1}}return!0})}var Yp=/[\u0590-\u08ac]/;function Qp(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,s=!o,i=o==r.parent.content.size,l=t.domSelection();return l?!Yp.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?s:i:Gc(t,e,()=>{let a=t.domSel.readRange(),c=l.caretBidiLevel;l.modify("move",n,"character");let u=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:d,focusOffset:f}=t.domSel.readRange(),h=d&&!Yt(u,d)||a.focusNode==d&&a.focusOffset==f;return Hc(l,a),c!=null&&(l.caretBidiLevel=c),h}):r.pos==r.start()||r.pos==r.end()}var uc=null,dc=null,fc=!1;function Zp(t,e,n){return uc==e&&dc==n?fc:(uc=e,dc=n,fc=n=="up"||n=="down"?Xp(t,e,n):Qp(t,e,n))}var Et=class{constructor(e,n,r,o){this.parent=e,this.children=n,this.dom=r,this.contentDOM=o,this.damage=0,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let o=this.children[n];if(o==e)return r;r+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&Yt(this.contentDOM,e))if(r<0){let s,i;if(e==this.contentDOM)s=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(i)+i.size:this.posAtStart}else{let s,i;if(e==this.contentDOM)s=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(i):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=n>le(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let s=e.compareDocumentPosition(this.contentDOM);s&16?o=n>Array.from(e.childNodes).findIndex(i=>i.contains(this.contentDOM)):o=!(s&4)}else if(this.dom.firstChild){if(n==0)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!1;break}if(s.previousSibling)break}if(o==null&&n==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!0;break}if(s.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,o=e;o;o=o.parentNode){let s=this.getDesc(o),i;if(s&&(!n||s.node))if(r&&(i=s.nodeDOM)&&!(N(i)?Yt(i,e):i==e))r=!1;else return s}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let o=e;o;o=o.parentNode){let s=this.getDesc(o);if(s)return s.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let o=this.children[n],s=r+o.size;if(r==e&&s!=r){for(;!o.border&&o.children.length;)for(let i=0;i<o.children.length;i++){let l=o.children[i];if(l.size){o=l;break}}return o}if(e<s)return o.descAt(e-r-o.border);r=s}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let s=0;r<this.children.length;r++){let i=this.children[r],l=s+i.size;if(l>e){o=e-s;break}s=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,n);for(;r>0;r--){let s=this.children[r-1];if(s.size||!(s instanceof Rr||s instanceof Or&&s.side>=0))break}if(n<=0){let s,i=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,i=!1);return s&&n&&i&&!s.border&&!s.domAtom?s.domFromPos(s.size,n):{node:this.contentDOM,offset:s?le(s.dom)+1:0}}else{let s,i=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,i=!1);return s&&i&&!s.border&&!s.domAtom?s.domFromPos(0,n):{node:this.contentDOM,offset:s?le(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,s=-1;for(let i=r,l=0;;l++){let a=this.children[l],c=i+a.size;if(o==-1&&e<=c){let u=i+a.border;if(e>=u&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,u);e=i;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){o=le(f.dom)+1;break}e-=f.size}o==-1&&(o=0)}if(o>-1&&(c>n||l==this.children.length-1)){n=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){s=le(d.dom);break}n+=d.size}s==-1&&(s=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:n,fromOffset:o,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(!N(n)||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDamage(e){e&&(this.damage|=e,this.markParentDamage())}markParentDamage(){for(let e=this;;){let{parent:n}=e;if(!n||n.damage&1)break;n.damage|=1,e=n}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Or=class extends Et{constructor(e,n,r,o){let s,i=n.type.toDOM;if(typeof i=="function"&&(i=i(r,()=>{if(!s)return o;if(s.parent)return s.parent.posBeforeChild(s)})),!n.type.spec.raw){let l=N(i)?i:document.createElement("span");l!=i&&(l.appendChild(i),i=l),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=n,this.widget=n,s=this}matchesWidget(e){return!this.damage&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},Gs=class extends Et{constructor(e,n,r,o){super(e,[],n,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},vt=class t extends Et{constructor(e,n,r,o,s){super(e,[],r,o),this.mark=n,this.spec=s}static create(e,n,r,o){let s=o.nodeViews[n.type.name],i=s&&s(n,o,r);return(!i||!i.dom)&&(i=Ve.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new t(e,n,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.damage&4||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return!(this.damage&4)&&this.mark.eq(e)}markDamage(e){var n;this.damage|=e,(n=this.parent)===null||n===void 0||n.markDamage(2)}slice(e,n,r){let o=t.create(this.parent,this.mark,!0,r),s=this.children,i=this.size;n<i&&(s=Ys(s,n,i,r)),e>0&&(s=Ys(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=o;return o.children=s,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},lt=class t extends Et{constructor(e,n,r,o,s,i,l){super(e,[],s,i),this.node=n,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,n,r,o,s,i){let l=s.nodeViews[n.type.name],a,c=l&&l(n,s,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)},r,o),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(!Q(u))throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=Ve.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Yc(u,r,n),c?a=new Ir(e,n,r,o,u,d||null,f,c):n.isText?new Bn(e,n,r,o,u,f):new t(e,n,r,o,u,d||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let n={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(n.preserveWhitespace="full"),!this.contentDOM)n.getContent=()=>this.node.content;else if(!this.contentLost)n.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let o=this.children[r];if(this.dom.contains(o.dom.parentNode)){n.contentElement=o.dom.parentNode;break}}if(!n.contentElement){let r=e&&e.find(o=>N(o)&&e.indexOf(o.parentNode)<0&&this.dom.contains(o));r?n.contentElement=r:n.getContent=()=>b.empty}}return n}matchesNode(e,n,r){return!this.damage&&e.eq(this.node)&&Dr(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,o=n,s=e.composing?this.localCompositionInfo(e,n):null,i=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new Xs(this,i&&i.node,e),c=this.node.inlineContent,u=c&&this.node.isBlock;rm(this.node,this.innerDeco,(d,f,h)=>{d.spec.marks?a.syncToMarks(d.spec.marks,r,e,f):d.type.side>=0&&!h&&a.syncToMarks(f==this.node.childCount?F.none:this.node.child(f).marks,r,e,f),a.placeWidget(d,e,o)},(d,f,h,p)=>{a.syncToMarks(d.marks,r,e,p),u&&d.isAtom&&!d.isText&&a.addHackNode("IMG",a.top);let m;a.findNodeMatch(d,f,h,p)||l&&e.state.selection.from>o&&e.state.selection.to<o+d.nodeSize&&(m=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(d,f,h,m,e,o)||a.updateNextNode(d,f,h,e,p,o)||a.addNode(d,f,h,e,o),o+=d.nodeSize,c&&(u=d.isAtom&&!d.isText)}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.damage&2)&&(i&&this.protectLocalComposition(e,i),Xc(this.contentDOM,this.children,e),Zt&&om(this.dom))}localCompositionInfo(e,n){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof M)||r<n||o>n+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let i=s.nodeValue,l=sm(this.node.content,i,r-n,o-n);return l<0?null:{node:s,pos:l,text:i}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:o}){if(this.getDesc(n))return;let s=n;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let i=new Gs(this,s,n,o);e.input.compositionNodes.push(i),this.children=Ys(this.children,r,r+o.length,e,i)}update(e,n,r,o,s){return this.damage&4||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,o,s),!0)}updateInner(e,n,r,o,s){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,s+1),this.damage=0}updateOuterDeco(e){if(Dr(e,this.outerDeco))return;let n=!N(this.nodeDOM),r=this.dom;this.dom=di(this.dom,this.nodeDOM,$n(this.outerDeco,this.node,n),$n(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){N(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){N(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function hc(t,e,n,r,o,s){s?di(r,r,$n(s,t,!1),$n(e,t,!1)):Yc(r,e,t);let i=new lt(void 0,t,e,n,r,r,r);return i.contentDOM&&i.updateChildren(o,0),i}var Bn=class t extends lt{constructor(e,n,r,o,s,i){super(e,n,r,o,s,null,i)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,o){return this.damage&4||this.damage&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.damage&8||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.damage=0,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return!1}slice(e,n,r){let o=this.node.cut(e,n),s=document.createTextNode(o.text);return new t(this.parent,o,this.outerDeco,this.innerDeco,s,s)}get domAtom(){return!1}isText(e){return this.node.text==e}},Rr=class extends Et{parseRule(){return{ignore:!0}}matchesHack(e){return!this.damage&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Ir=class extends lt{constructor(e,n,r,o,s,i,l,a){super(e,n,r,o,s,i,l),this.spec=a}update(e,n,r,o,s){if(this.damage&4)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,o,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,o,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Xc(t,e,n){let r=t.firstChild,o=!1;for(let s=0;s<e.length;s++){let i=e[s],l=i.dom;if(l.parentNode==t){for(;l!=r;)r=pc(r),o=!0;r=r.nextSibling}else o=!0,t.insertBefore(l,r);if(i instanceof vt){let a=r?r.previousSibling:t.lastChild;Xc(i.contentDOM,i.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=pc(r),o=!0;o&&n.trackWrites==t&&(n.trackWrites=null)}var Ln=function(t){t&&(this.nodeName=t)};Ln.prototype=Object.create(null);var Mt=[new Ln];function $n(t,e,n){if(t.length==0)return Mt;let r=n?Mt[0]:new Ln,o=[r];for(let s=0;s<t.length;s++){let i=t[s].type.attrs;if(i){i.nodeName&&o.push(r=new Ln(i.nodeName));for(let l in i){let a=i[l];a!=null&&(n&&o.length==1&&o.push(r=new Ln(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return o}function di(t,e,n,r){if(n==Mt&&r==Mt)return e;let o=e;for(let s=0;s<r.length;s++){let i=r[s],l=n[s];if(s){let a;l&&l.nodeName==i.nodeName&&o!=t&&(a=o.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=Mt[0]),o=a}em(o,l||Mt[0],i)}return o}function em(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)o.indexOf(r[s])==-1&&t.classList.remove(r[s]);for(let s=0;s<o.length;s++)r.indexOf(o[s])==-1&&t.classList.add(o[s]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)t.style.removeProperty(o[1])}n.style&&(t.style.cssText+=n.style)}}function Yc(t,e,n){return di(t,t,Mt,$n(e,n,!N(t)))}function Dr(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function pc(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}var Xs=class{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=tm(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,o){let s=0,i=this.stack.length>>1,l=Math.min(i,e.length);for(;s<l&&(s==i-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<i;)this.destroyRest(),this.top.damage=0,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;o<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[i])&&!this.isLocked(d.dom)){a=u;break}}if(a<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof vt&&!(u.damage&4)&&u.mark.type==e[i].type&&u.spec.update&&!this.isLocked(u.dom)&&u.spec.update(e[i])&&(u.mark=e[i],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=vt.create(this.top,e[i],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,i++}}findNodeMatch(e,n,r,o){let s=-1,i;if(o>=this.preMatch.index&&(i=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&i.matchesNode(e,n,r))s=this.top.children.indexOf(i,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,n,r,o,s,i){let l=this.top.children[o];return l.damage&4&&l.dom==l.contentDOM&&(l.damage=2),l.update(e,n,r,s,i)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=n}}updateNextNode(e,n,r,o,s,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof lt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let u=a.dom,d,f=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&!(a.damage&4)&&Dr(n,a.outerDeco));if(!f&&a.update(e,n,r,o,i))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,n,r,o,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.damage|=2,d.updateChildren(o,i+1),d.damage=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,o,s,i){if(e.damage&3||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Dr(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=lt.create(this.top,n,r,o,s,i);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,n,r,o,s){let i=lt.create(this.top,e,n,r,o,s);i.contentDOM&&i.updateChildren(o,s+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,n,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let s=new Or(this.top,e,n,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof vt;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Bn)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ae||pe)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new Rr(this.top,[],r,null);n!=this.top?n.children.push(o):n.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||N(e)&&e.contains(this.lock.parentNode))}};function tm(t,e){let n=e,r=n.children.length,o=[],s=t.childCount,i=new Map,l=[];e:for(;s>0;){let a;for(;;)if(r){let u=n.children[r-1];if(u instanceof vt)o.push(r-1),n=u,r=u.children.length;else{a=u,r--;break}}else{if(n==e)break e;r=o.pop(),n=n.parent}let c=a.node;if(c){if(c!=t.child(s-1))break;--s,i.set(a,s),l.push(a)}}return{index:s,matched:i,matches:l.reverse()}}function nm(t,e){return t.type.side-e.type.side}function rm(t,e,n,r){let o=e.locals(t),s=0;if(o.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,o,e.forChild(s,u),c),s+=u.nodeSize}return}let i=0,l=[],a=null;for(let c=0;;){let u,d;for(;i<o.length&&o[i].to==s;){let g=o[i++];g.widget&&(u?(d||(d=[u])).push(g):u=g)}if(u)if(d){d.sort(nm);for(let g=0;g<d.length;g++)n(d[g],c,!!a)}else n(u,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<t.childCount)h=c,f=t.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;i<o.length&&o[i].from<=s&&o[i].to>s;)l.push(o[i++]);let p=s+f.nodeSize;if(f.isText){let g=p;i<o.length&&o[i].from<g&&(g=o[i].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<p&&(a=f.cut(g-s),f=f.cut(0,g-s),p=g,h=-1)}else for(;i<o.length&&o[i].to<p;)i++;let m=f.isInline&&!f.isLeaf?l.filter(g=>!g.inline):l.slice();r(f,m,e.forChild(s,f),h),s=p}}function om(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function sm(t,e,n,r){for(let o=0,s=0;o<t.childCount&&s<=r;){let i=t.child(o++),l=s;if(s+=i.nodeSize,!i.isText)continue;let a=i.text;for(;o<t.childCount;){let c=t.child(o++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=n){if(s>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Ys(t,e,n,r,o){let s=[];for(let i=0,l=0;i<t.length;i++){let a=t[i],c=l,u=l+=a.size;c>=n||u<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,r)),o&&(s.push(o),o=void 0),u>n&&s.push(a.slice(n-c,a.size,r)))}return s}function Qs(t,e){let{$anchor:n,$head:r}=t.selection,o=e>0?n.max(r):n.min(r),s=o.parent.inlineContent?o.depth?t.doc.resolve(e>0?o.after():o.before()):null:o;return s&&T.findFrom(s,e)}function ot(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function mc(t,e,n){let r=t.state.selection;if(r instanceof M)if(n.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=t.state.doc.resolve(o.pos+s.nodeSize*(e<0?-1:1));return ot(t,new M(r.$anchor,i))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let o=Qs(t.state,e);return o&&o instanceof v?ot(t,o):!1}else if(!Me||n.indexOf("m")<0){let o=r.$head,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,i;if(!s||s.isText)return!1;let l=e<0?o.pos-s.nodeSize:o.pos;return s.isAtom||(i=t.docView.descAt(l))&&!i.contentDOM?v.isSelectable(s)?ot(t,new v(e<0?t.state.doc.resolve(o.pos-s.nodeSize):o)):ot(t,new M(t.state.doc.resolve(e<0?l:l+s.nodeSize))):!1}}else return!1;else{if(r instanceof v&&r.node.isInline)return ot(t,new M(e>0?r.$to:r.$from));{let o=Qs(t.state,e);return o?ot(t,o):!1}}}function Pn(t,e){let n=t.pmViewDesc;return n?n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR"):N(t)&&t.contentEditable=="false"}function qt(t,e){return e<0?im(t):lm(t)}function im(t){let e=t.domSel.readRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o,s,i=!1;for(Oe&&N(n)&&r<ne(n)&&Pn(n.childNodes[r],-1)&&(i=!0);;)if(r>0){if(!N(n))break;let l=n.childNodes[r-1];if(Pn(l,-1))o=n,s=--r;else if(Q(l))n=l,r=n.nodeValue.length;else break}else{if(Qc(n))break;{let l=n.previousSibling;for(;l&&Pn(l,-1);)o=n.parentNode,s=le(l),l=l.previousSibling;if(l)n=l,r=ne(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}i?Zs(t,n,r):o&&Zs(t,o,s)}function lm(t){let e=t.domSel.readRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o=ne(n),s,i;for(;;)if(r<o){if(!N(n))break;let l=n.childNodes[r];if(Pn(l,1))s=n,i=++r;else break}else{if(Qc(n))break;{let l=n.nextSibling;for(;l&&Pn(l,1);)s=l.parentNode,i=le(l)+1,l=l.nextSibling;if(l)n=l,r=0,o=ne(n);else{if(n=n.parentNode,n==t.dom)break;r=o=0}}}s&&Zs(t,s,i)}function Qc(t){for(let e=t;e;e=e.parentNode){let n=e.pmViewDesc;if(n)return n.node?n.node.isBlock:!1}return!1}function Zs(t,e,n){if(!Q(e)){let i,l;(l=ci(e,n))?(e=l,n=0):(i=ai(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection(),o=t.domSel.readRange();if(!r)return;$r(o)?r.collapse(e,n):r.extend&&(r.collapse(o.anchorNode,o.anchorOffset),r.extend(e,n)),t.domSel.ignore();let{state:s}=t;setTimeout(()=>{t.state==s&&t.domSel.sync()},50)}function gc(t,e){let n=t.state.doc.resolve(e);if(!(pe||jc)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),l=(i.top+i.bottom)/2;if(l>s.top&&l<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),l=(i.top+i.bottom)/2;if(l>s.top&&l<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}let r=t.dom;for(let s=n.depth;s>0;s--)if(n.node(s).isBlock){r=t.nodeDOM(n.before(s))||r;break}return getComputedStyle(r).direction=="rtl"?"rtl":"ltr"}function yc(t,e,n){let r=t.state.selection;if(r instanceof M&&!r.empty||n.indexOf("s")>-1||Me&&n.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let i=Qs(t.state,e);if(i&&i instanceof v)return ot(t,i)}if(!o.parent.inlineContent){let i=e<0?o:s,l=r instanceof he?T.near(i,e):T.findFrom(i,e);return l?ot(t,l):!1}return!1}function bc(t,e){if(!(t.state.selection instanceof M))return!0;let{$head:n,$anchor:r,empty:o}=t.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let i=t.state.tr;return e<0?i.delete(n.pos-s.nodeSize,n.pos):i.delete(n.pos,n.pos+s.nodeSize),t.dispatch(i),!0}return!1}function kc(t,e,n){t.domObserver.stopped(()=>e.contentEditable=n)}function am(t){if(!ae||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSel.readRange();if(e&&N(e)&&n==0&&e.firstChild&&N(e.firstChild)&&e.firstChild.contentEditable=="false"){let r=e.firstChild;kc(t,r,"true"),setTimeout(()=>kc(t,r,"false"),20)}return!1}function cm(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function um(t,e){let n=e.keyCode,r=cm(e);if(n==8||Me&&n==72&&r=="c")return bc(t,-1)||qt(t,-1);if(n==46&&!e.shiftKey||Me&&n==68&&r=="c")return bc(t,1)||qt(t,1);if(n==13||n==27)return!0;if(n==37||Me&&n==66&&r=="c"){let o=n==37?gc(t,t.state.selection.from)=="ltr"?-1:1:-1;return mc(t,o,r)||qt(t,o)}else if(n==39||Me&&n==70&&r=="c"){let o=n==39?gc(t,t.state.selection.from)=="ltr"?1:-1:1;return mc(t,o,r)||qt(t,o)}else{if(n==38||Me&&n==80&&r=="c")return yc(t,-1,r)||qt(t,-1);if(n==40||Me&&n==78&&r=="c")return am(t)||yc(t,1,r)||qt(t,1);if(r==(Me?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function fi(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:o,openEnd:s}=e;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let i=t.someProp("clipboardSerializer")||Ve.fromSchema(t.state.schema),l=ou(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&N(c)&&(u=ru[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&N(c)&&c.setAttribute("data-pm-slice",`${o} ${s}${d?` -${d}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`
|
|
7
|
+
|
|
8
|
+
`);return{dom:a,text:f,slice:e}}function Zc(t,e,n,r,o){let s=o.parent.type.spec.code,i,l;if(!n&&!e)return null;let a=!!e&&(r||s||!n);if(a){if(t.someProp("transformPastedText",f=>{e=f(e,s||r,t)}),s)return l=new C(b.from(t.state.schema.text(e.replace(/\r\n?/g,`
|
|
9
|
+
`))),0,0),t.someProp("transformPasted",f=>{l=f(l,t,!0)}),l;let d=t.someProp("clipboardTextParser",f=>f(e,o,r,t));if(d)l=d;else{let f=o.marks(),{schema:h}=t.state,p=Ve.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=i.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),i=pm(n),Hr&&mm(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=i.firstChild;for(;f&&!N(f);)f=f.nextSibling;if(!f)break;i=f}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||We.fromSchema(t.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!dm.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=gm(wc(l,+u[1],+u[2]),u[4]);else if(l=C.maxOpen(fm(l.content,o),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=wc(l,d,f)}return t.someProp("transformPasted",d=>{l=d(l,t,r)}),l}var dm=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function fm(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let o=e.node(n).contentMatchAt(e.index(n)),s,i=[];if(t.forEach(l=>{if(!i)return;let a=o.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&s.length&&tu(a,s,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=nu(i[i.length-1],s.length));let u=eu(l,a);i.push(u),o=o.matchType(u.type),s=a}}),i)return b.from(i)}return t}function eu(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,b.from(t));return t}function tu(t,e,n,r,o){if(o<t.length&&o<e.length&&t[o]==e[o]){let s=tu(t,e,n,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==t.length-1?n.type:t[o+1]))return r.copy(r.content.append(b.from(eu(n,t,o+1))))}}function nu(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,nu(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(b.empty,!0);return t.copy(n.append(r))}function ei(t,e,n,r,o,s){let i=e<0?t.firstChild:t.lastChild,l=i.content;return t.childCount>1&&(s=0),o<r-1&&(l=ei(l,e,n,r,o+1,s)),o>=n&&(l=e<0?i.contentMatchAt(0).fillBefore(l,s<=o).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(b.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,i.copy(l))}function wc(t,e,n){return e<t.openStart&&(t=new C(ei(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new C(ei(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}var ru={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function ou(){return document.implementation.createHTMLDocument("title")}var In=null;function hm(t){let e=window.trustedTypes;if(!e)return t;if(!In){if(In=e.defaultPolicy)try{return In.createHTML(t)}catch{}In=e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})}return In.createHTML(t)}function pm(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=ou(),r=n.body,o=/<([a-z][^>\s]+)/i.exec(t),s;if((s=o&&ru[o[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),r.innerHTML=hm(t),s)for(let i=0;i<s.length;i++)r=r.querySelector(s[i])||r;for(let i=0;i<n.styleSheets.length;i++){let l=n.styleSheets[i];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let u=r.querySelectorAll(c.selectorText);for(let d=0;d<u.length;d++)u[d].style.cssText+=c.style.cssText}}}return r}function mm(t){let e=t.querySelectorAll(pe?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function gm(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:o,openStart:s,openEnd:i}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs()||!a.createAndFill(null,o))break;try{o=b.from(a.create(r[l+1],o))}catch{break}s++,i++}return new C(o,s,i)}var ke=class t{constructor(e,n,r,o){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=o}static from(e){return e instanceof t?e:new t(e.anchorNode,e.anchorOffset,e.focusNode,e.focusOffset)}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}};ke.null=new ke(null,0,null,0);var ti=class{constructor(e){this.view=e,this.range=ke.null,this.active=!1,this.synced=!1,this.suppress=!1,this.currentDocument=null,this.onSelectionChange=this.onSelectionChange.bind(this)}ensureListener(){let e=this.view.dom.ownerDocument;e!=this.currentDocument&&(this.currentDocument&&this.currentDocument.removeEventListener("selectionchange",this.onSelectionChange),this.currentDocument=e,e.addEventListener("selectionchange",this.onSelectionChange))}destroy(){this.currentDocument&&(this.currentDocument.removeEventListener("selectionchange",this.onSelectionChange),this.currentDocument=null),this.active=!1,this.range=ke.null}suppressChanges(){this.suppress=!0,setTimeout(()=>this.suppress=!1,50)}onSelectionChange(){if(this.suppress&&this.view.hasFocus())return this.sync();this.read()&&this.view.domObserver.flush(!1)}readRange(){let{view:e}=this,n=e.dom.isConnected!==!1&&e.domSelection();return n?ae&&e.root.nodeType===11&&Bp(e.dom.ownerDocument)==e.dom?ke.from(ym(e,n)||n):ke.from(n):ke.null}read(){this.ensureListener();let e=lu(this.view);if(!e){this.active=!1,this.range=ke.null;return}return this.active=!0,this.range.eq(e)?!1:(this.range=e,this.synced=!1,!0)}sync(e=!1){let{view:n}=this;n.docView&&(this.ensureListener(),n.domObserver.stopped(()=>{xm(n,n.state.selection);let r=n.state.selection;if(n.input.mouseSelecting||su(n)){let{desc:o,start:s}=iu(n.docView,r.from,r.to,0);n.cursorWrapper?Sm(n):o instanceof Ir&&o.spec.setSelection?o.spec.setSelection(r.anchor-s,r.head-s,n.root):bm(n,e,o,s),this.synced=this.active=!0}r.visible==n.dom.classList.contains("ProseMirror-hideselection")&&(r.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),wm(n))),this.range=this.readRange()}))}ignore(e=this.readRange()){this.range=ke.from(e),this.synced=!0}deactivate(){this.range=ke.null,this.active=this.synced=!1}};function ym(t,e){if(e.getComposedRanges){let o=e.getComposedRanges({shadowRoots:[t.root]})[0];if(o)return Sc(t,o)}let n;function r(o){o.preventDefault(),o.stopImmediatePropagation(),n=o.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Sc(t,n):null}function Sc(t,e){let n=e.startContainer,r=e.startOffset,o=e.endContainer,s=e.endOffset,i=t.domAtPos(t.state.selection.anchor);return Dn(i.node,i.offset,o,s)&&([n,r,o,s]=[o,s,n,r]),new ke(n,r,o,s)}function hi(t,e,n=null){let r=t.state.doc;if(!e.focusNode)return null;let o=t.docView.nearestDesc(e.focusNode),s=o&&o.size==0,i=t.docView.posFromDOM(e.focusNode,e.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if($r(e)){for(a=i;o&&!o.node;)o=o.parent;if(o&&o.node.isAtom&&v.isSelectable(o.node)&&o.parent&&!(o.node.isInline&&Pp(e.focusNode,e.focusOffset,o.dom))){let d=o.posBefore;c=new v(i==d?l:r.resolve(d))}else if(Oe&&n=="key"&&i>t.state.selection.to&&N(e.focusNode)&&e.focusOffset==e.focusNode.childNodes.length&&o&&o.posAtStart>t.state.selection.to)for(let d=e.focusNode;;d=d.parentNode){if(getComputedStyle(d).overflow!="visible"){c=T.findFrom(r.resolve(o.posAtStart),1);break}if(d==o.dom||d.nextSibling||!d.parentNode||!N(d.parentNode))break}}else{if(e instanceof t.dom.ownerDocument.defaultView.Selection&&e.rangeCount>1){let d=i,f=i;for(let h=0;h<e.rangeCount;h++){let p=e.getRangeAt(h);d=Math.min(d,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[a,i]=f==t.state.selection.anchor?[f,d]:[d,f],l=r.resolve(i)}else a=t.docView.posFromDOM(e.anchorNode,e.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=n=="pointer"||t.state.selection.head<l.pos&&!s?1:-1;c=en(t,u,l,d)}return c}function su(t){return t.editable?t.hasFocus():au(t,t.domSel.readRange())&&(!document.activeElement||document.activeElement.contains(t.dom))}function bm(t,e,n,r){let o=t.state.selection,{anchor:s,head:i}=o,l,a;xc&&!(o instanceof M)&&(o.$from.parent.inlineContent||(l=Cc(t,o.from)),!o.empty&&!o.$from.parent.inlineContent&&(a=Cc(t,o.to)));let c=n.domFromPos(s-r,s>r?-1:1),u=i==s?c:n.domFromPos(i-r,i>r?-1:1);km(s,i,c,u,t,e),xc&&(l&&Mc(l),a&&Mc(a))}function iu(t,e,n,r=0){for(let o=0,s=r;o<t.children.length;o++){let i=t.children[o],l=s+i.size;if(e>s&&n<l)return iu(i,e,n,s+i.border);s=l}return{desc:t,start:r}}function km(t,e,n,r,o,s){let i=!1;if((Oe||ae)&&t==e){let{node:u,offset:d}=n;if(Q(u)){if(i=!!(d&&u.nodeValue[d-1]==`
|
|
10
|
+
`),i&&d==u.nodeValue.length)for(let f=u,h;f;f=f.parentNode){if(h=f.nextSibling){h.nodeName=="BR"&&(n=r={node:h.parentNode,offset:le(h)+1});break}let p=f.pmViewDesc;if(p&&p.node&&p.node.isBlock)break}}else{let f=u.childNodes[d-1];i=f&&(f.nodeName=="BR"||f.contentEditable=="false")}}let l=o.domSel.readRange();if(Oe&&l.focusNode&&l.focusNode!=r.node&&N(l.focusNode)){let u=l.focusNode.childNodes[l.focusOffset];u&&u.contentEditable=="false"&&(s=!0)}if(!(s||i&&ae)&&Dn(n.node,n.offset,l.anchorNode,l.anchorOffset)&&Dn(r.node,r.offset,l.focusNode,l.focusOffset))return;let a=o.domSelection(),c=o.input.mouseSelecting;if(c&&c.affinity&&t==e&&c.pos==t){let{affinity:u}=c,{node:d,offset:f}=r,h,p=0;if(Q(d)&&(u>0?f<ne(d):f>0)?(h=d,p=f+u):(h=(u>0?ci:ai)(d,f),h&&(p=u>0?1:h.nodeValue.length-1)),h){a.collapse(h,p),a.modify("move",u>0?"backward":"forward","lineboundary");let{focusNode:m,focusOffset:g}=a;if(ae&&o.root.nodeType==11){let y=a.getComposedRanges({shadowRoots:[o.root]});y.length&&(m=y[0].startContainer,g=y[0].startOffset)}if(Dn(d,f,m,g))return}}Hc(a,{focusNode:r.node,focusOffset:r.offset,anchorNode:n.node,anchorOffset:n.offset})}var xc=ae||pe&&Fc<63;function Cc(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),o=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(ae&&o&&o.contentEditable=="false")return Vs(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return Vs(o);if(s)return Vs(s)}}function Vs(t){return t.contentEditable="true",ae&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Mc(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function wm(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSel.readRange(),r=n.anchorNode,o=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=o)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!su(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Sm(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom;n.nodeName=="IMG"?e.collapse(n.parentNode,le(n)+1):e.collapse(n,0)}function xm(t,e){if(e instanceof v){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(vc(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else vc(t)}function vc(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function en(t,e,n,r){let o=t.someProp("createSelectionBetween",s=>s(t,e,n))||M.between(e,n,r);return t.someProp("adjustSelectionFromDOM",s=>{o=s(t,o)}),o}function lu(t){if(t.editable&&!t.hasFocus())return null;let e=t.domSel.readRange();return e&&au(t,e)?e:null}function au(t,e){if(!e.anchorNode)return!1;try{return Yt(t.dom,e.anchorNode)&&(t.editable||Yt(t.dom,e.focusNode))}catch{return!1}}var me={},ge={},Cm={touchstart:!0,touchmove:!0},ni=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.mouseSelecting=null,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Mm(t){for(let e in me){let n=me[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Am(t,r)&&(t.input.composing&&(r.type=="keydown"||r.type=="beforeinput")&&r.isComposing===!1&&du(t,!0),!pi(t,r)&&(t.editable||!(r.type in ge))&&n(t,r))},Cm[e]?{passive:!0}:void 0)}ae&&t.dom.addEventListener("input",()=>null),ri(t)}function Fr(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function vm(t){t.input.mouseDown&&t.input.mouseDown.done(),t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function ri(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>pi(t,r))})}function pi(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Am(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function Tm(t,e){!pi(t,e)&&me[e.type]&&(t.editable||!(e.type in ge))&&me[e.type](t,e)}function st(t,e){let{input:n}=t;return n.lastKeyDispatched||t.composing?!1:(n.lastKeyDispatched=!0,typeof e=="string"&&(e=zp(e=="Backspace"?8:13,e)),t.someProp("handleKeyDown",r=>r(t,e)))}ge.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),t.input.lastKeyDispatched=!1,!(qe&&pe&&n.keyCode==13)){if(Zt&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(st(t,"Enter"),t.input.lastIOSEnter=0)},200);return}n.keyCode!=229&&t.domObserver.forceFlush(!0),st(t,n)||um(t,n)?n.preventDefault():Fr(t,"key")}};ge.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};ge.keypress=(t,e)=>{let n=e;if(Pm(t)||!n.charCode||n.ctrlKey&&!n.altKey||Me&&n.metaKey)return;if(t.someProp("handleKeyPress",o=>o(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof M)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(n.charCode),s=()=>t.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!t.someProp("handleTextInput",i=>i(t,r.$from.pos,r.$to.pos,o,s))&&t.dispatch(s()),n.preventDefault()}};function Hn(t){return{left:t.clientX,top:t.clientY}}function Em(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function mi(t,e,n,r,o){if(r==-1)return!1;let s=t.state.doc.resolve(r);for(let i=s.depth+1;i>0;i--)if(t.someProp(e,l=>i>s.depth?l(t,n,s.nodeAfter,s.before(i),o,!0):l(t,n,s.node(i),s.before(i),o,!1)))return!0;return!1}function cu(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function Nm(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&v.isSelectable(r)?(cu(t,new v(n)),!0):!1}function Om(t,e){if(e==-1)return!1;let n=t.state.selection,r,o;n instanceof v&&(r=n.node);let s=t.state.doc.resolve(e);for(let i=s.depth+1;i>0;i--){let l=i>s.depth?s.nodeAfter:s.node(i);if(v.isSelectable(l)){r&&n.$from.depth>0&&i>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?o=s.before(n.$from.depth):o=s.before(i);break}}return o!=null?(cu(t,v.create(t.state.doc,o)),!0):!1}function Rm(t,e,n,r,o){return mi(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(o?Om(t,n):Nm(t,n))}function Im(t,e,n,r){return mi(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",o=>o(t,e,r))}function Dm(t,e,n,r){return mi(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",o=>o(t,e,r))}function Ac(t,e,n){if(e==-1)return t.inlineContent?M.create(t,0,t.content.size):null;let r=t.resolve(e);for(let o=r.depth+1;o>0;o--){let s=o>r.depth?r.nodeAfter:r.node(o),i=r.before(o);if(s.inlineContent)return M.create(t,i+1,i+1+s.content.size);if(n&&v.isSelectable(s))return v.create(t,i)}return null}var oi=/[\w_\u00a1-\uffff]+/g;try{oi=new RegExp("[\\p{L}\\p{N}_]+","gu")}catch{}function Tc(t,e){let n=t.resolve(e),r=n.node(),o="",s=e,i=e;for(let m=n.indexAfter(),g=!1;m>0;m--){let y=r.child(m-1);if(!y.text)break;let w=s==e?e-n.posAtIndex(m-1):y.text.length,k=w;for(;k>0;k--)if(/\S/.test(y.text[k-1]))g=!0;else if(g)break;if(o=y.text.slice(k,w)+o,s-=w-k,k||s<e-50)break}for(let m=n.index(),g=!1;m<r.childCount;m++){let y=r.child(m);if(!y.text)break;let w=i==e?e-n.posAtIndex(m):0,k=w;for(;k<y.text.length;k++)if(/\S/.test(y.text[k]))g=!0;else if(g)break;if(o+=y.text.slice(w,k),i+=k-w,k<y.text.length||i>e+50)break}let l=s,a=i;if(Intl.Segmenter){for(let m of new Intl.Segmenter(void 0,{granularity:"word"}).segment(o))if(m.isWordLike){let g=m.index+s,y=g+m.segment.length;if(y<e)l=y;else if(g>e){a=g;break}else return M.create(t,g,y)}}else{oi.lastIndex=0;for(let m;m=oi.exec(o);){let g=m.index+s,y=g+m[0].length;if(y<e)l=y;else if(g>e){a=g;break}else return M.create(t,g,y)}}let c=o.slice(l-s,e-s),u=o.slice(e-s,a-s),d=/\S*$/.exec(c)[0].length,f=/^\S*/.exec(u)[0].length;if(d||f)return M.create(t,e-d,e+f);let h=/\s*$/.exec(c)[0].length,p=/^\s*/.exec(u)[0].length;return M.create(t,e-h,e+p)}var uu=Me?"metaKey":"ctrlKey";me.mousedown=(t,e)=>{let n=e,r=Date.now();if(t.input.shiftKey=n.shiftKey,t.input.lastTouch>r-500)return!1;Nt(t);let o="singleClick";r-t.input.lastClick.time<500&&Em(n,t.input.lastClick)&&!n[uu]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:r,x:n.clientX,y:n.clientY,type:o,button:n.button},t.input.mouseDown&&t.input.mouseDown.done();let s=t.posAtCoords(Hn(n));if(s)if(n.button==0){if(!t.hasFocus()){_c(t.dom);let l=t.root.activeElement;l&&!l.contains(t.dom)&&l.blur()}(t.input.mouseDown=new si(t,s,n,o)).mightDrag||n.preventDefault()}else Fr(t,"pointer")};var si=class{constructor(e,n,r,o){var s;this.view=e,this.startPos=n,this.event=r,this.type=o,this.didMove=!1,this.lastPos=-1,this.anchorRange=null,this.startDoc=e.state.doc,this.selectNode=!!r[uu],this.extend=r.shiftKey,this.anchorDoc=this.startDoc;let i=Ec(e);if(this.extend){let l=e.state.selection;this.anchorRange=l instanceof v?{from:l.from,to:l.to}:{from:l.anchor,to:l.anchor};let a=l instanceof v?e.nodeDOM(l.from).getBoundingClientRect():e.coordsAtPos(l.anchor);this.anchorOffset={x:(a.left+a.right)/2-i.x,y:(a.top+a.bottom)/2-i.y}}else this.anchorOffset={x:r.clientX-i.x,y:r.clientY-i.y};if(o=="singleClick"){let{selection:l}=e.state,a,c,u=!1;if(l instanceof v&&l.from<=n.pos&&l.to>=n.pos)c=l.from,a=l.node,u=!0;else if(n.inside>-1)a=e.state.doc.nodeAt(n.inside),c=n.inside;else{let d=e.state.doc.resolve(n.pos);a=d.parent,c=d.depth?d.before():-1}if(u||c>-1&&a.type.spec.draggable&&a.type.spec.selectable!==!1){let d=(s=e.docView.descAt(c))===null||s===void 0?void 0:s.nodeDOM;this.mightDrag={node:a,elt:d,pos:c,addAttr:!1},d&&!d.draggable&&(this.mightDrag.addAttr=!0,e.domObserver.stopped(()=>d.draggable=!0))}else this.mightDrag=Lm(e,r)}else this.mightDrag=!1;e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),this.mightDrag||this.select(this.startPos,!0)}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null),typeof this.mightDrag=="object"&&this.mightDrag.addAttr&&this.view.domObserver.stopped(()=>this.mightDrag.elt.removeAttribute("draggable"))}maybeRunHandler(e,n){return(this.type=="singleClick"?Rm:this.type=="doubleClick"?Im:Dm)(this.view,e.pos,e.inside,n,this.selectNode)}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.startPos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Hn(e))),n&&(this.didMove||this.maybeRunHandler(n,e)||this.select(n,!0),e.preventDefault())}move(e){if(e.buttons==0){this.done();return}if(!this.didMove&&(Math.abs(this.event.x-e.clientX)>8||Math.abs(this.event.y-e.clientY)>8)&&(this.didMove=!0,this.mightDrag=!1),!this.mightDrag){let n=this.view.posAtCoords(Hn(e));n&&this.select(n,!1)}e.preventDefault()}select(e,n){if(e.pos==this.lastPos)return;this.lastPos=e.pos;let{view:r}=this,{doc:o}=r.state,s=this.type=="singleClick"?Nc(r,o,e):this.type=="doubleClick"?Tc(o,e.pos):Ac(o,e.inside,n);s&&(n&&!this.extend?this.anchorRange=s:(!n||this.extend)&&(o.eq(this.anchorDoc)||this.restoreAnchor(),this.anchorRange&&this.anchorRange.from<s.from?s=en(r,o.resolve(this.anchorRange.from),o.resolve(s.to)):this.anchorRange&&this.anchorRange.to>s.to&&(s=en(r,o.resolve(this.anchorRange.to),o.resolve(s.from)))),s.eq(r.state.selection)||(r.input.mouseSelecting=e,r.dispatch(r.state.tr.setSelection(s).setMeta("pointer",!0).scrollIntoView()),r.input.mouseSelecting=null))}restoreAnchor(){let e=Ec(this.view),n=this.view.posAtCoords({left:this.anchorOffset.x+e.x,top:this.anchorOffset.y+e.y});if(!n)this.anchorRange=null;else{let{doc:r}=this.view.state;this.anchorRange=this.type=="singleClick"?Nc(this.view,r,n):this.type=="doubleClick"?Tc(r,n.pos):Ac(r,n.inside,!1),this.anchorDoc=this.view.state.doc}}};function Ec(t){let e=t.dom.getBoundingClientRect();return{x:e.left-t.dom.scrollLeft,y:e.top-t.dom.scrollTop}}function Nc(t,e,n){if(n.inside>-1){let o=e.nodeAt(n.inside);if(o.isAtom&&v.isSelectable(o))return v.create(e,n.inside)}let r=e.resolve(n.pos);return en(t,r,r)}function Lm(t,e){let{selection:n}=t.state;if(n.empty)return!1;let r=t.domSelection();if(!r||r.rangeCount==0)return!0;let o=r.getRangeAt(0).getClientRects();for(let s=0;s<o.length;s++){let i=o[s];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}me.touchstart=t=>{t.input.lastTouch=Date.now(),Nt(t),Fr(t,"pointer")};me.touchmove=t=>{t.input.lastTouch=Date.now(),Fr(t,"pointer")};me.contextmenu=t=>Nt(t);function Pm(t,e){return t.composing?!0:ae&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}var zm=qe?5e3:-1;ge.compositionstart=ge.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof M&&e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||pe&&jc&&Bm(t)))t.markCursor=t.state.storedMarks||n.marks(),Nt(t,!0),t.markCursor=null;else if(Nt(t,!e.selection.empty),Oe&&t.domSel.active&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length)for(let{focusNode:r,focusOffset:o}=t.domSel.range;r&&N(r)&&o!=0;){let s=o<0?r.lastChild:r.childNodes[o-1];if(!s)break;if(Q(s)){let i=t.domSelection();i&&i.collapse(s,s.nodeValue.length);break}else r=s,o=-1}t.input.composing=!0}fu(t,zm)};function Bm(t){let{focusNode:e,focusOffset:n}=t.domSel.range;if(!e||!N(e)||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return N(r)&&r.contentEditable=="false"}ge.compositionend=(t,e)=>{t.composing&&du(t)};function du(t,e=!1){t.input.composing=!1,t.input.compositionEndedAt=Date.now(),t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,e?Nt(t):fu(t,20)}function fu(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Nt(t),e))}function hu(t){t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());for(let e;e=t.input.compositionNodes.pop();)e.markParentDamage()}function $m(t){let e=t.domSel.range;if(!t.domSel.active||!e.focusNode)return null;let n=ai(e.focusNode,e.focusOffset),r=ci(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let o=r.pmViewDesc,s=t.domObserver.lastChangedTextNode;if(n==s||r==s)return s;if(!o||!o.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let i=n.pmViewDesc;if(!(!i||!i.isText(n.nodeValue)))return r}}return n||r}function Nt(t,e=!1){if(!(qe&&t.domObserver.flushingSoon>=0)&&(t.domObserver.forceFlush(),hu(t),e||t.docView&&t.docView.damage)){let n=hi(t,t.domSel.readRange()),r=t.state.selection;n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state)}}function Hm(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}var Fn=Zt&&Hp<604;me.copy=ge.cut=(t,e)=>{let n=e,r=t.state.selection,o=n.type=="cut";if(r.empty)return;let s=Fn?null:n.clipboardData,i=r.content(),{dom:l,text:a}=fi(t,i);s?(n.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Hm(t,l),o&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Fm(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function jm(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?jn(t,r.value,null,o,e):jn(t,r.textContent,r.innerHTML,o,e)},50)}function jn(t,e,n,r,o){let s=Zc(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,o,s||C.empty)))return!0;if(!s)return!1;let i=Fm(s),l=i?t.state.tr.replaceSelectionWith(i,r):t.state.tr.replaceSelection(s);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function pu(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}ge.paste=(t,e)=>{let n=e;if(t.composing&&!qe)return;let r=Fn?null:n.clipboardData,o=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&jn(t,pu(r),r.getData("text/html"),o,n)?n.preventDefault():jm(t,n)};var Lr=class{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}},Wm=Me?"altKey":"ctrlKey";function mu(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[Wm]}me.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o=t.state.selection,s=o.empty?null:t.posAtCoords(Hn(n)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof v?o.to-1:o.to))){if(r&&typeof r.mightDrag=="object")i=v.create(t.state.doc,r.mightDrag.pos);else if(n.target&&N(n.target)){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(i=v.create(t.state.doc,d.posBefore))}}let l=(i||t.state.selection).content(),{dom:a,text:c,slice:u}=fi(t,l);(!n.dataTransfer.files.length||!pe||Fc>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Fn?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Fn||n.dataTransfer.setData("text/plain",c),t.dragging=new Lr(u,mu(t,n),i)};me.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};ge.dragover=ge.dragenter=(t,e)=>e.preventDefault();ge.drop=(t,e)=>{try{Vm(t,e,t.dragging)}finally{t.dragging=null}};function Vm(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Hn(e));if(!r)return;let o=t.state.doc.resolve(r.pos),s=n&&n.slice;s?t.someProp("transformPasted",h=>{s=h(s,t,!1)}):s=Zc(t,pu(e.dataTransfer),Fn?null:e.dataTransfer.getData("text/html"),!1,o);let i=!!(n&&mu(t,e));if(t.someProp("handleDrop",h=>h(t,e,s||C.empty,i))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?Mr(t.state.doc,o.pos,s):o.pos;l==null&&(l=o.pos);let a=t.state.tr;if(i){let{node:h}=n;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,s.content.firstChild):a.replaceRange(c,c,s),a.doc.eq(d))return;let f=a.doc.resolve(c);if(u&&v.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))a.setSelection(new v(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,y)=>h=y),a.setSelection(en(t,f,a.doc.resolve(h)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}me.focus=t=>{if(t.input.lastFocus=Date.now(),!t.focused&&(t.domObserver.stopped(()=>t.dom.classList.add("ProseMirror-focused")),t.focused=!0,t.domSel.read(),!t.domSel.synced)){let e=t.domSel.range;setTimeout(()=>{let n=t.domSel.readRange();n&&e.eq(n)&&t.domSel.sync()},20)}};me.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stopped(()=>t.dom.classList.remove("ProseMirror-focused")),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domSel.deactivate(),t.focused=!1)};me.beforeinput=(t,e)=>{if(qe&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||t.domObserver.pendingRecords().length||(t.dom.blur(),t.focus(),st(t,"Backspace")))return;let{$cursor:o}=t.state.selection;o&&o.pos>0&&t.dispatch(t.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let t in ge)me[t]=ge[t];function Wn(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}var Vn=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index<this.frag.childCount;){let n=this.frag.child(this.index);if(this.off==e)return n;this.off+=n.nodeSize,this.index++}return null}},Pr=class t{constructor(e,n){this.toDOM=e,this.spec=n||Tt,this.side=this.spec.side||0}map(e,n,r,o){let{pos:s,deleted:i}=e.mapResult(n.from+o,this.side<0?-1:1);return i?null:new U(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof t&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Wn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},At=class t{constructor(e,n){this.attrs=e,this.spec=n||Tt}map(e,n,r,o){let s=e.map(n.from+o,this.spec.inclusiveStart?-1:1)-r,i=e.map(n.to+o,this.spec.inclusiveEnd?1:-1)-r;return s>=i?null:new U(s,i,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof t&&Wn(this.attrs,e.attrs)&&Wn(this.spec,e.spec)}static is(e){return e.type instanceof t}destroy(){}},ii=class t{constructor(e,n){this.attrs=e,this.spec=n||Tt}map(e,n,r,o){let s=e.mapResult(n.from+o,1);if(s.deleted)return null;let i=e.mapResult(n.to+o,-1);return i.deleted||i.pos<=s.pos?null:new U(s.pos-r,i.pos-r,this)}valid(e,n,r){let o=r.nodeAt(n.from);return!!o&&!o.isText&&n.from+o.nodeSize==n.to}eq(e){return this==e||e instanceof t&&Wn(this.attrs,e.attrs)&&Wn(this.spec,e.spec)}destroy(){}},U=class t{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new t(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new t(e,e,new Pr(n,r))}static inline(e,n,r,o){return new t(e,n,new At(r,o))}static node(e,n,r,o){return new t(e,n,new ii(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof At}get widget(){return this.type instanceof Pr}},Gt=[],Tt={},B=class t{constructor(e,n){this.local=e.length?e:Gt,this.children=n.length?n:Gt}static create(e,n){return n.length?Br(n,e,0,Tt):ie}find(e,n,r){let o=[];return this.findInner(e??0,n??1e9,o,0,r),o}findInner(e,n,r,o,s){for(let i=0;i<this.local.length;i++){let l=this.local[i];if(l.from>n)break;l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let i=0;i<this.children.length&&!(this.children[i]>=n);i+=3)if(this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,n-l,r,o+l,s)}}map(e,n,r){return this==ie||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Tt)}mapInner(e,n,r,o,s){let i;if(this.local.length){let l=new Vn(n.content);for(let a=0;a<this.local.length;a++){let c=this.local[a].map(e,r,o);c&&c.type.valid(n,c,l)?(i||(i=[])).push(c):s.onRemove&&s.onRemove(this.local[a].spec)}}return this.children.length?_m(this.children,i||[],e,n,r,o,s):i?new t(i.sort(it),Gt):ie}add(e,n){return n.length?this==ie?t.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let o,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=yu(n,l,c)){for(o||(o=this.children.slice());s<o.length&&o[s]<a;)s+=3;o[s]==a?o[s+2]=o[s+2].addInner(l,u,c+1):o.splice(s,0,a,a+l.nodeSize,Br(u,l,c+1,Tt)),s+=3}});let i=gu(s?bu(n):n,-r).sort(it);if(i.length){let l=new Vn(e.content);for(let a=0;a<i.length;a++)i[a].type.valid(e,i[a],l)||i.splice(a--,1)}return new t(i.length?this.local.concat(i).sort(it):this.local,o||this.children)}remove(e){return e.length==0||this==ie?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,o=this.local;for(let s=0;s<r.length;s+=3){let i,l=r[s]+n,a=r[s+1]+n;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(i||(i=[])).push(d));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(i,l+1);c!=ie?r[s+2]=c:(r.splice(s,3),s-=3)}if(o.length){for(let s=0,i;s<e.length;s++)if(i=e[s])for(let l=0;l<o.length;l++)o[l].eq(i,n)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new t(o,r):ie}forChild(e,n){if(this==ie)return this;if(n.isLeaf)return t.empty;let r,o,s=0,i=this.children.length/3;for(;s<i;){let c=s+i>>>1,u=c*3,d=this.children[u];if(d<e)s=c+1;else if(d>e)i=c;else{r=this.children[u+2];break}}let l=e+1,a=l+n.content.size;for(let c=0;c<this.local.length;c++){let u=this.local[c];if(u.from<a&&u.to>l&&u.type instanceof At){let d=Math.max(l,u.from)-l,f=Math.min(a,u.to)-l;d<f&&(o||(o=[])).push(u.copy(d,f))}}if(o){let c=new t(o.sort(it),Gt);return r?new zr([c,r]):c}return r||ie}eq(e){if(this==e)return!0;if(!(e instanceof t)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return gi(this.localsInner(e))}localsInner(e){if(this==ie)return Gt;if(e.inlineContent||!this.local.some(At.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof At||n.push(this.local[r]);return n}forEachSet(e){e(this)}};B.empty=new B([],[]);B.removeOverlap=gi;var ie=B.empty,zr=class t{constructor(e){this.members=e}map(e,n){let r=this.members.map(o=>o.map(e,n,Tt));return t.from(r)}forChild(e,n){if(n.isLeaf)return B.empty;let r=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(e,n);s!=ie&&(s instanceof t?r=r.concat(s.members):r.push(s))}return t.from(r)}eq(e){if(!(e instanceof t)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let o=0;o<this.members.length;o++){let s=this.members[o].localsInner(e);if(s.length)if(!n)n=s;else{r&&(n=n.slice(),r=!1);for(let i=0;i<s.length;i++)n.push(s[i])}}return n?gi(r?n:n.sort(it)):Gt}static from(e){switch(e.length){case 0:return ie;case 1:return e[0];default:return new t(e.every(n=>n instanceof B)?e:e.reduce((n,r)=>n.concat(r instanceof B?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}};function _m(t,e,n,r,o,s,i){let l=t.slice();for(let c=0,u=s;c<n.maps.length;c++){let d=0;n.maps[c].forEach((f,h,p,m)=>{let g=m-p-(h-f);for(let y=0;y<l.length;y+=3){let w=l[y+1];if(w<0||f>w+u-d)continue;let k=l[y]+u-d;h>=k?l[y+1]=f<=k?-2:-1:f>=u&&g&&(l[y]+=g,l[y+1]+=g)}d+=g}),u=n.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=n.map(t[c]+s),d=u-o;if(d<0||d>=r.content.size){a=!0;continue}let f=n.map(t[c+1]+s,-1),h=f-o,{index:p,offset:m}=r.content.findIndex(d),g=r.maybeChild(p);if(g&&m==d&&m+g.nodeSize==h){let y=l[c+2].mapInner(n,g,u+1,t[c]+s+1,i);y!=ie?(l[c]=d,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Km(l,t,e,n,o,s,i),u=Br(c,r,0,i);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new B(e.sort(it),l)}function gu(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let o=t[r];n.push(new U(o.from+e,o.to+e,o.type))}return n}function Km(t,e,n,r,o,s,i){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,o,c);d?n.push(d):i.onRemove&&i.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+s+1);return n}function yu(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,o=null;for(let s=0,i;s<t.length;s++)(i=t[s])&&i.from>n&&i.to<r&&((o||(o=[])).push(i),t[s]=null);return o}function bu(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Br(t,e,n,r){let o=[],s=!1;e.forEach((l,a)=>{let c=yu(t,l,a+n);if(c){s=!0;let u=Br(c,l,n+a+1,r);u!=ie&&o.push(a,a+l.nodeSize,u)}});let i=gu(s?bu(t):t,-n).sort(it);if(i.length){let l=new Vn(e.content);for(let a=0;a<i.length;a++)i[a].type.valid(e,i[a],l)||(r.onRemove&&r.onRemove(i[a].spec),i.splice(a--,1))}return i.length||o.length?new B(i,o):ie}function it(t,e){return t.from-e.from||t.to-e.to}function gi(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let o=n+1;o<e.length;o++){let s=e[o];if(s.from==r.from){s.to!=r.to&&(e==t&&(e=t.slice()),e[o]=s.copy(s.from,r.to),Oc(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,s.from),Oc(e,o,r.copy(s.from,r.to)));break}}}return e}function Oc(t,e,n){for(;e<t.length&&it(n,t[e])>0;)e++;t.splice(e,0,n)}function _s(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=ie&&e.push(r)}),t.cursorWrapper&&e.push(B.create(t.state.doc,[t.cursorWrapper.deco])),zr.from(e)}function Um(t,e,n,r){let{node:o,fromOffset:s,toOffset:i,from:l,to:a}=t.docView.parseRange(e,n),c=t.domSel.range,u,d=c.anchorNode;if(d&&Yt(t.dom,d)&&(u=[{node:d,offset:c.anchorOffset}],$r(c)||u.push({node:c.focusNode,offset:c.focusOffset})),pe&&t.input.lastKeyCode===8)for(let y=i;y>s;y--){let w=o.childNodes[y-1],k=w.pmViewDesc;if(w.nodeName=="BR"&&!k){i=y;break}if(!k||k.size)break}let f=t.state.doc,h=t.someProp("domParser")||We.fromSchema(t.state.schema),p=f.resolve(l),m=null,g=h.parse(o,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:s,to:i,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:Jm(r),context:p});if(u&&u[0].pos!=null){let y=u[0].pos,w=u[1]&&u[1].pos;w==null&&(w=y),m={anchor:y+l,head:w+l}}return{doc:g,sel:m,from:l,to:a}}var Jm=t=>e=>{let n=e.pmViewDesc;if(n)return n.parseRule(t);if(e.nodeName=="BR"&&e.parentNode){if(ae&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||ae&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},qm=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Gm(t,e,n,r,o,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let O=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,P=hi(t,t.domSel.range,O);if(P&&!t.state.selection.eq(P)&&t.domSel.active){if(pe&&qe&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&st(t,"Enter"))return;let D=t.state.tr.setSelection(P);O=="pointer"?D.setMeta("pointer",!0):O=="key"&&D.scrollIntoView(),i&&D.setMeta("composition",i),t.dispatch(D)}return}let l=t.state.doc.resolve(e),a=l.sharedDepth(n);e=l.before(a+1),n=t.state.doc.resolve(n).after(a+1);let c=t.state.selection,u=Um(t,e,n,s),d=t.state.doc,f=d.slice(u.from,u.to),h,p;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(h=t.state.selection.to,p="end"):(h=t.state.selection.from,p="start"),t.input.lastKeyCode=null;let m=Zm(f.content,u.doc.content,u.from,h,p);if(m&&t.input.domChangeCount++,(Zt&&t.input.lastIOSEnter>Date.now()-225||qe)&&s.some(O=>N(O)&&!qm.test(O.nodeName))&&(!m||m.endA>=m.endB)&&st(t,"Enter")){t.input.lastIOSEnter=0;return}if(!m)if(o&&c instanceof M&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let O=Rc(t,t.state.doc,u.sel);if(O&&!O.eq(t.state.selection)){let P=t.state.tr.setSelection(O);i&&P.setMeta("composition",i),t.dispatch(P)}}return}t.state.selection.from<t.state.selection.to&&m.start==m.endB&&t.state.selection instanceof M&&(m.start>t.state.selection.from&&m.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?m.start=t.state.selection.from:m.endA<t.state.selection.to&&m.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(m.endB+=t.state.selection.to-m.endA,m.endA=t.state.selection.to));let g=u.doc.resolveNoCache(m.start-u.from),y=u.doc.resolveNoCache(m.endB-u.from),w=d.resolve(m.start),k=g.sameParent(y)&&g.parent.inlineContent&&w.end()>=m.endA;if((Zt&&t.input.lastIOSEnter>Date.now()-225&&(!k||s.some(O=>O.nodeName=="DIV"||O.nodeName=="P"))||!k&&Qm(u.doc,g.pos,y.pos))&&st(t,"Enter")){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>m.start&&(k?m.endA>m.start&&m.endB==m.start:Ym(d,m.start,m.endA,g,y))&&st(t,"Backspace")){qe&&pe&&t.domSel.suppressChanges();return}pe&&m.endB==m.start&&(t.input.lastChromeDelete=Date.now()),qe&&!k&&g.start()!=y.start()&&y.parentOffset==0&&g.depth==y.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==m.endA&&(m.endB-=2,y=u.doc.resolveNoCache(m.endB-u.from),setTimeout(()=>st(t,"Enter"),20));let x=m.start,E=m.endA,V=O=>{let P=O||t.state.tr.replace(x,E,u.doc.slice(m.start-u.from,m.endB-u.from));if(u.sel){let D=Rc(t,P.doc,u.sel);D&&!(pe&&t.composing&&D.empty&&(m.start!=m.endB||t.input.lastChromeDelete<Date.now()-100)&&(D.head==x||D.head==P.mapping.map(E)-1))&&P.setSelection(D)}return i&&P.setMeta("composition",i),P.scrollIntoView()},W;if(k)if(g.pos==y.pos){let O=V(t.state.tr.delete(x,E)),P=d.resolve(m.start).marksAcross(d.resolve(m.endA));P&&O.ensureMarks(P),t.dispatch(O)}else if(m.endA==m.endB&&(W=Xm(g.parent.content.cut(g.parentOffset,y.parentOffset),w.parent.content.cut(w.parentOffset,m.endA-w.start())))){let O=V(t.state.tr);W.type=="add"?O.addMark(x,E,W.mark):O.removeMark(x,E,W.mark),t.dispatch(O)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let O=g.parent.textBetween(g.parentOffset,y.parentOffset),P=()=>V(t.state.tr.insertText(O,x,E));t.someProp("handleTextInput",D=>D(t,x,E,O,P))||t.dispatch(P())}else t.dispatch(V());else t.dispatch(V())}function Rc(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:en(t,e.resolve(n.anchor),e.resolve(n.head))}function Xm(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,o=n,s=r,i,l,a;for(let u=0;u<r.length;u++)o=r[u].removeFromSet(o);for(let u=0;u<n.length;u++)s=n[u].removeFromSet(s);if(o.length==1&&s.length==0)l=o[0],i="add",a=u=>u.mark(l.addToSet(u.marks));else if(o.length==0&&s.length==1)l=s[0],i="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(b.from(c).eq(t))return{mark:l,type:i}}function Ym(t,e,n,r,o){if(n-e<=o.pos-r.pos||Ks(r,!0,!1)<o.pos)return!1;let s=t.resolve(e);if(!r.parent.inlineContent){let l=s.nodeAfter;return l!=null&&n==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let i=t.resolve(Ks(s,!0,!0));return!i.parent.isTextblock||i.pos>n||Ks(i,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function Qm(t,e,n){let r=0,o=0;return t.nodesBetween(e,n,(s,i)=>{s.isTextblock&&i>=e&&i<n?r++:(s.isText?/\S/.test(s.text.slice(Math.max(0,e-i),Math.min(s.nodeSize,n-i))):s.isLeaf)&&o++}),o==0&&r==1}function Ks(t,e,n){let r=t.depth,o=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,o++,e=!1;if(n){let s=t.node(r).maybeChild(t.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,o++}return o}function Zm(t,e,n,r,o){let s=t.findDiffStart(e,n),i=n+t.size,l=n+e.size;if(s==null)return null;let{a,b:c}=t.findDiffEnd(e,i,l);if(o=="end"){let u=Math.max(0,s-Math.min(a,c));r-=a+u-s}if(a<s&&i<l){let u=r<=s&&r>=a?s-r:0;s-=u,c=s+(c-a),a=s}else if(c<s){let u=r<=s&&r>=c?s-r:0;s-=u,a=s+(a-c),c=s}return{start:s,endA:a,endB:c}}var eg={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},li=class{constructor(e){this.view=e,this.queue=[],this.flushingSoon=-1,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.started=!1,this.observer=new window.MutationObserver(n=>{for(let r=0;r<n.length;r++)this.queue.push(n[r]);ae&&e.composing&&n.some(r=>r.type=="childList"&&r.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()})}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(e=!1){this.flushingSoon>-1?(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush(!0)):e&&this.flush(!0)}start(){this.observer.takeRecords(),this.observer.observe(this.view.dom,eg),this.started=!0}stop(){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect(),this.started=!1}stopped(e){if(!this.started)return e();this.stop();try{return e()}finally{this.start()}}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let s=e.focusNode;s;s=Xt(s))n.add(s);for(let s=e.anchorNode;s;s=Xt(s))if(n.has(s)){r=s;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:Q(r)?r.parentNode:r}))return this.view.domSel.ignore(e),!0}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(e=!0){let{view:n}=this;if(!n.docView||this.flushingSoon>-1)return;let r=this.pendingRecords();r.length&&(this.queue=[]),e&&n.domSel.read();let o=!n.domSel.suppress&&!n.domSel.synced&&!!lu(n)&&!this.ignoreSelectionChange(n.domSel.range),s=-1,i=-1,l=!1,a=[];if(n.editable)for(let u=0;u<r.length;u++){let d=this.registerMutation(r[u],a);d&&(s=s<0?d.from:Math.min(d.from,s),i=i<0?d.to:Math.max(d.to,i),d.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(n.input.lastKeyCode==8||n.input.lastKeyCode==46||pe&&(n.composing||n.input.compositionEndedAt>Date.now()-50)&&r.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;for(;d&&N(d);){if(d.contentEditable=="false"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(Oe&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=n.domSel.range;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!d||ng(n,d)!=h)&&f.remove()}}}let c=null;s<0&&o&&n.domSel.active&&n.input.lastFocus>Date.now()-200&&n.input.lastTouch<Date.now()-300&&$r(n.domSel.range)&&(c=hi(n,n.domSel.range))&&c.eq(T.near(n.state.doc.resolve(0),1))?(n.input.lastFocus=0,n.domSel.sync(),n.scrollToSelection()):(s>-1||o)&&(s>-1&&tg(n),n.input.badSafariComposition&&(n.input.badSafariComposition=!1,rg(n,a)),Gm(this.view,s,i,o,l,a),n.docView&&n.docView.damage?n.updateState(n.state):o&&n.domSel.sync())}registerMutation(e,n){var r;if(n.indexOf(e.target)>-1)return null;let o;for(let s=e.target;s&&!(o=this.view.docView.getDesc(s));s=s.parentNode);if(e.type=="attributes"&&(o==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!o||o.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let f=e.addedNodes[d];n.push(f),Q(f)&&(this.lastChangedTextNode=f)}if(o.contentDOM&&o.contentDOM!=o.dom&&!o.contentDOM.contains(e.target))return o.markDamage(4),{from:o.posBefore,to:o.posAfter};let s=e.previousSibling,i=e.nextSibling,l=s&&s.parentNode==e.target?le(s)+1:0,a=o.localPosFromDOM(e.target,l,-1),c=i&&i.parentNode==e.target?le(i):e.target.childNodes.length,u=o.localPosFromDOM(e.target,c,1);return o.markDamage(!((r=o.contentDOM)===null||r===void 0)&&r.contains(e.target)?2:4),{from:a,to:u}}else return e.type=="attributes"?(o.markDamage(4),{from:o.posAtStart-o.border,to:o.posAtEnd+o.border}):(this.lastChangedTextNode=e.target,o.markDamage(o instanceof Bn&&e.target==o.nodeDOM?8:4),{from:o.posAtStart,to:o.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},Ic=new WeakMap,Dc=!1;function tg(t){if(!Ic.has(t)&&(Ic.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Oe,Dc)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Dc=!0}}function ng(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function rg(t,e){var n;let{focusNode:r,focusOffset:o}=t.domSel.range;for(let s of e)if(((n=s.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let i=s.nextSibling;for(;i&&i.nodeName!="TD"&&i.nodeName!="TH";)i=i.nextSibling;if(i){let l=i;for(;;){let a=l.firstChild;if(!a||!N(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(s,l.firstChild),r==s&&t.domSelection().collapse(s,o)}else s.parentNode.removeChild(s)}}var _n=class{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new ni,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach($c),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=zc(this),Pc(this),this.nodeViews=Bc(this),this.docView=hc(this.state.doc,Lc(this),_s(this),this.dom,this),this.domObserver=new li(this),this.domSel=new ti(this),this.domObserver.start(),this.domSel.read(),Mm(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ri(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach($c),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let o=this.state,s=!1,i=!1;e.storedMarks&&this.composing&&(hu(this),i=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=Bc(this);sg(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&ri(this),this.editable=zc(this),Pc(this);let a=_s(this),c=Lc(this),u=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",d=s||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(o.selection))&&(i=!0);let f=u=="preserve"&&i&&this.dom.style.overflowAnchor==null&&Wp(this);i&&this.domObserver.stopped(()=>{let h=d&&pe&&!this.composing&&!o.selection.empty&&!e.selection.empty&&og(o.selection,e.selection);if(d){let p=pe?this.trackWrites=this.domSel.range.focusNode:null;if(this.composing&&(this.input.compositionNode=$m(this)),s||!this.docView.update(e.doc,c,a,this,-1)){let m=this.docView.outerDeco;this.docView.destroy(),this.docView=hc(e.doc,c,a,this.dom,this,m)}p&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}this.domSel.sync(h)}),this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&Vp(f)}scrollToSelection(){let e=this.domSel.range.focusNode;if(!(!e||!this.domSel.active)){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof v){let n=this.docView.domAfterPos(this.state.selection.from);N(n)&&ac(this,n.getBoundingClientRect(),e)}else ac(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,o=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let s=r.from+(this.state.doc.content.size-n.doc.content.size);(s>0&&s<this.state.doc.content.size&&this.state.doc.nodeAt(s))==r.node&&(o=s)}this.dragging=new Lr(e.slice,e.move,o<0?void 0:v.create(this.state.doc,o))}someProp(e,n){let r=this._props&&this._props[e],o;if(r!=null&&(o=n?n(r):r))return o;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(o=n?n(l):l))return o}let s=this.state.plugins;if(s)for(let i=0;i<s.length;i++){let l=s[i].props[e];if(l!=null&&(o=n?n(l):l))return o}}hasFocus(){return this.root.activeElement==this.dom}focus(){this.editable&&_c(this.dom),this.domSel.sync()}get root(){let e=this.dom.isConnected!==!1;e||(this._root=null);let n=this._root;if(n==null&&e){for(let r=this.dom.parentNode;r;r=r.parentNode)if(r.nodeType==9||r.nodeType==11&&r.host)return r.getSelection||(Object.getPrototypeOf(r).getSelection=()=>r.ownerDocument.getSelection()),this._root=r}return n||document}updateRoot(){this._root=null}posAtCoords(e){return qp(this,e)}coordsAtPos(e,n=1){return qc(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let o=this.docView.posFromDOM(e,n,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,n){return Zp(this,n||this.state,e)}pasteHTML(e,n){return jn(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return jn(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return fi(this,e)}destroy(){this.docView&&(vm(this),this.domSel.destroy(),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],_s(this),this,-1),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Lp())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Tm(this,e)}domSelection(){return this.root.getSelection()}};_n.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Lc(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[U.node(0,t.state.doc.content.size,e)]}function Pc(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:U.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function zc(t){return!t.someProp("editable",e=>e(t.state)===!1)}function og(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Bc(t){let e=Object.create(null);function n(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function sg(t,e){let n=0,r=0;for(let o in t){if(t[o]!=e[o])return!0;n++}for(let o in e)r++;return n!=r}function $c(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Ge={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Wr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ig=typeof navigator<"u"&&/Mac/.test(navigator.platform),lg=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(Z=0;Z<10;Z++)Ge[48+Z]=Ge[96+Z]=String(Z);var Z;for(Z=1;Z<=24;Z++)Ge[Z+111]="F"+Z;var Z;for(Z=65;Z<=90;Z++)Ge[Z]=String.fromCharCode(Z+32),Wr[Z]=String.fromCharCode(Z);var Z;for(jr in Ge)Wr.hasOwnProperty(jr)||(Wr[jr]=Ge[jr]);var jr;function ku(t){var e=ig&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||lg&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Wr:Ge)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}var ag=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),cg=typeof navigator<"u"&&/Win/.test(navigator.platform);function ug(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,o,s,i;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))ag?i=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),o&&(n="Ctrl-"+n),i&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function dg(t){let e=Object.create(null);for(let n in t)e[ug(n)]=t[n];return e}function yi(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function wu(t){return new R({props:{handleKeyDown:Kn(t)}})}function Kn(t){let e=dg(t);return function(n,r){let o=ku(r),s,i=e[yi(o,r)];if(i&&i(n.state,n.dispatch,n))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=e[yi(o,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(cg&&r.ctrlKey&&r.altKey)&&(s=Ge[r.keyCode])&&s!=o){let l=e[yi(s,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var Vr=200,re=function(){};re.prototype.append=function(e){return e.length?(e=re.from(e),!this.length&&e||e.length<Vr&&this.leafAppend(e)||this.length<Vr&&e.leafPrepend(this)||this.appendInner(e)):this};re.prototype.prepend=function(e){return e.length?re.from(e).append(this):this};re.prototype.appendInner=function(e){return new fg(this,e)};re.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?re.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};re.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};re.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};re.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(s,i){return o.push(e(s,i))},n,r),o};re.from=function(e){return e instanceof re?e:e&&e.length?new Su(e):re.empty};var Su=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,s){return o==0&&s==this.length?this:new e(this.values.slice(o,s))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,s,i,l){for(var a=s;a<i;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,s,i,l){for(var a=s-1;a>=i;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=Vr)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=Vr)return new e(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(re);re.empty=new Su([]);var fg=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,o,s,i){var l=this.left.length;if(o<l&&this.left.forEachInner(r,o,Math.min(s,l),i)===!1||s>l&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,s)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,s,i){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(s,l)-l,i+l)===!1||s<l&&this.left.forEachInvertedInner(r,Math.min(o,l),s,i)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var s=this.left.length;return o<=s?this.left.slice(r,o):r>=s?this.right.slice(r-s,o-s):this.left.slice(r,s).append(this.right.slice(0,o-s))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(re),bi=re;var hg=500,Ot=class t{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,s;n&&(o=this.remapping(r,this.items.length),s=o.maps.length);let i=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){o||(o=this.remapping(r,f+1),s=o.maps.length),s--,u.push(d);return}if(o){u.push(new ze(d.map));let h=d.step.map(o.slice(s)),p;h&&i.maybeStep(h).doc&&(p=i.mapping.maps[i.mapping.maps.length-1],c.push(new ze(p,void 0,void 0,c.length+u.length))),s--,p&&o.appendMap(p,s)}else i.maybeStep(d.step);if(d.selection)return l=o?d.selection.map(o.slice(s)):d.selection,a=new t(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,n,r,o){let s=[],i=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new ze(e.mapping.maps[u],d,n),h;(h=a&&a.merge(f))&&(f=h,u?s.pop():l=l.slice(0,l.length-1)),s.push(f),n&&(i++,n=void 0),o||(a=f)}let c=i-r.depth;return c>mg&&(l=pg(l,c),i-=c),new t(l.append(s),i)}remapping(e,n){let r=new An;return this.items.forEach((o,s)=>{let i=o.mirrorOffset!=null&&s-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,i)},e,n),r}addMaps(e){return this.eventCount==0?this:new t(this.items.append(e.map(n=>new ze(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let r=[],o=this.items.length-n,s=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},o);let a=n;this.items.forEach(f=>{let h=s.getMirror(--a);if(h==null)return;i=Math.min(i,h);let p=s.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(s.slice(a+1,h));g&&l++,r.push(new ze(p,m,g))}else r.push(new ze(p))},o);let c=[];for(let f=n;f<i;f++)c.push(new ze(s.maps[f]));let u=this.items.slice(0,o).append(c).append(r),d=new t(u,l);return d.emptyItemCount()>hg&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,o=[],s=0;return this.items.forEach((i,l)=>{if(l>=e)o.push(i),i.selection&&s++;else if(i.step){let a=i.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let u=i.selection&&i.selection.map(n.slice(r));u&&s++;let d=new ze(c.invert(),a,u),f,h=o.length-1;(f=o.length&&o[h].merge(d))?o[h]=f:o.push(d)}}else i.map&&r--},this.items.length,0),new t(bi.from(o.reverse()),s)}};Ot.empty=new Ot(bi.empty,0);function pg(t,e){let n;return t.forEach((r,o)=>{if(r.selection&&e--==0)return n=o,!1}),t.slice(n)}var ze=class t{constructor(e,n,r,o){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new t(n.getMap().invert(),n,this.selection)}}},Be=class{constructor(e,n,r,o,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=s}},mg=20;function gg(t,e,n,r){let o=n.getMeta(at),s;if(o)return o.historyState;n.getMeta(vu)&&(t=new Be(t.done,t.undone,null,0,-1));let i=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(i&&i.getMeta(at))return i.getMeta(at).redo?new Be(t.done.addTransform(n,void 0,r,_r(e)),t.undone,xu(n.mapping.maps),t.prevTime,t.prevComposition):new Be(t.done,t.undone.addTransform(n,void 0,r,_r(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!i&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!yg(n,t.prevRanges)),c=i?ki(t.prevRanges,n.mapping):xu(n.mapping.maps);return new Be(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,_r(e)),Ot.empty,c,n.time,l??t.prevComposition)}else return(s=n.getMeta("rebased"))?new Be(t.done.rebased(n,s),t.undone.rebased(n,s),ki(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Be(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),ki(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function yg(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,o)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&o>=e[s]&&(n=!0)}),n}function xu(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,o,s,i)=>e.push(s,i));return e}function ki(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let o=e.map(t[r],1),s=e.map(t[r+1],-1);o<=s&&n.push(o,s)}return n}function bg(t,e){for(let n=0;n<e.steps.length;n++){let r=e.mapping.maps[n],o=-1;if(r.forEach((s,i)=>o=i),o<0){let s=e.steps[n];(s instanceof St||s instanceof Ie)&&(o=s.to)}if(o>-1)return T.near(t.doc.resolve(o))}return t.selection}function kg(t,e,n){let r=_r(e),o=at.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,r);if(!s)return null;let i=s.selection.resolve(s.transform.doc),l=(n?t.done:t.undone).addTransform(s.transform,bg(e,s.transform).getBookmark(),o,r),a=new Be(n?l:s.remaining,n?s.remaining:l,null,0,-1);return s.transform.setSelection(i).setMeta(at,{redo:n,historyState:a})}var wi=!1,Cu=null;function _r(t){let e=t.plugins;if(Cu!=e){wi=!1,Cu=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){wi=!0;break}}return wi}function Mu(t){return t.setMeta(vu,!0)}var at=new z("history"),vu=new z("closeHistory");function Au(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new R({key:at,state:{init(){return new Be(Ot.empty,Ot.empty,null,0,-1)},apply(e,n,r){return gg(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,o=r=="historyUndo"?Si:r=="historyRedo"?xi:null;return!o||!e.editable?!1:(n.preventDefault(),o(e.state,e.dispatch))}}}})}function Kr(t,e){return(n,r)=>{let o=at.getState(n);if(!o||(t?o.undone:o.done).eventCount==0)return!1;if(r){let s=kg(o,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}var Si=Kr(!1,!0),xi=Kr(!0,!0),Qw=Kr(!1,!1),Zw=Kr(!0,!1);function Tu(t){return t.getMeta(at)!=null}function eo(t){let{state:e,transaction:n}=t,{selection:r}=n,{doc:o}=n,{storedMarks:s}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,s=n.storedMarks,n}}}var sn=class qu{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:n,state:r}=this,{view:o}=n,{tr:s}=r,i=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...u)=>{let d=a(...u)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,n=!0){let{rawCommands:r,editor:o,state:s}=this,{view:i}=o,l=[],a=!!e,c=e||s.tr,u=()=>(!a&&n&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(c),l.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...m)=>{let g=this.buildProps(c,n),y=h(...m)(g);return l.push(y),d}])),run:u};return d}static createFakeChain(){let e=new Proxy({},{get:(n,r)=>{if(r!=="then")return r==="run"?()=>!1:()=>e}});return e}createCan(e){let{rawCommands:n,state:r}=this,o=!1,s=e||r.tr,i=this.buildProps(s,o);return{...Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,o)}}static createFallbackCan(){let e=qu.createFakeChain();return new Proxy({chain:()=>e},{get:(n,r)=>{if(r!=="then")return r==="chain"?n.chain:()=>!1}})}buildProps(e,n=!0){let{rawCommands:r,editor:o,state:s}=this,{view:i}=o,l={tr:e,editor:o,view:i,state:eo({state:s,transaction:e}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(e,n),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...u)=>c(...u)(l)]))}};return l}},wg=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{if(!t.isDestroyed){var n;e.dom.blur(),(n=window)===null||n===void 0||(n=n.getSelection())===null||n===void 0||n.removeAllRanges()}}),!0),Sg=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),xg=()=>({tr:t,dispatch:e})=>{let{selection:n}=t,{ranges:r}=n;if(!e)return!0;let o=t.mapping.maps.length;return r.forEach(({$from:s,$to:i})=>{let l=s.pos,a=i.pos,c=t.mapping.slice(o),u=1;t.doc.nodesBetween(c.map(l),c.map(a),(d,f)=>{u=Math.max(u,t.doc.resolve(f).depth+1)});for(let d=0;d<u;d+=1){let f=t.doc,h=t.mapping.maps.length,p=t.mapping.slice(o),m=h,g=t.mapping.slice(h),y=p.map(l),w=p.map(a);if(f.nodesBetween(y,w,(k,x)=>{if(k.type.isText)return;t.mapping.maps.length!==m&&(m=t.mapping.maps.length,g=t.mapping.slice(h));let E=t.doc.resolve(g.map(x)),V=t.doc.resolve(g.map(x+k.nodeSize)),W=E.blockRange(V);if(!W)return;let O=Ue(W);if(k.type.isTextblock){let{defaultType:P}=E.parent.contentMatchAt(E.index()),D=t.doc.nodeAt(W.start);P&&D&&!D.hasMarkup(P)&&P.validContent(D.content)&&t.setNodeMarkup(W.start,P)}(O||O===0)&&t.lift(W,O)}),t.doc.eq(f))break}}),!0},Cg=t=>e=>t(e),Mg=()=>({state:t,dispatch:e})=>zs(t,e),vg=(t,e)=>({editor:n,tr:r})=>{let{state:o}=n,s=o.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);let i=r.mapping.map(e);return r.insert(i,s.content),r.setSelection(new M(r.doc.resolve(Math.max(i-1,0)))),!0},Ag=()=>({tr:t,dispatch:e})=>{let{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;let o=t.selection.$anchor;for(let s=o.depth;s>0;s-=1)if(o.node(s).type===r.type){if(e){let i=o.before(s),l=o.after(s);t.delete(i,l).scrollIntoView()}return!0}return!1};function ee(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var Tg=t=>({tr:e,state:n,dispatch:r})=>{let o=ee(t,n.schema),s=e.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===o){if(r){let l=s.before(i),a=s.after(i);e.delete(l,a).scrollIntoView()}return!0}return!1},Eg=t=>({tr:e,dispatch:n})=>{let{from:r,to:o}=t;return n&&e.delete(r,o),!0},Ng=t=>t.content?/^text(\*|\+)/.test(t.content):!1,Eu=(t,e,n)=>{if(!t.parent.isInline||n==="left"&&t.pos>t.start()||n==="right"&&t.pos<t.end())return t.pos;let r=e.nodes[t.parent.type.name].spec;return Ng(r)?n==="left"?t.start()-1:t.end()+1:t.pos},Og=(t,e,n)=>({from:Eu(t,n,"left"),to:Eu(e,n,"right")}),Rg=()=>({state:t,dispatch:e})=>{if(t.selection.empty)return!1;if(e){let n=t.tr,{ranges:r}=t.selection,o=t.selection instanceof M?t.selection.$from.marksAcross(t.selection.$to):null,s=n.steps.length;r.forEach(i=>{let l=n.mapping.slice(s),a=n.doc.resolve(l.map(i.$from.pos)),c=n.doc.resolve(l.map(i.$to.pos)),{from:u,to:d}=Og(a,c,t.schema);n.deleteRange(u,d)}),n.selection.empty||n.setSelection(M.near(n.doc.resolve(n.selection.from))),o&&n.ensureMarks(o),n.scrollIntoView(),e(n)}return!0},Ig=()=>({commands:t})=>t.keyboardShortcut("Enter"),Dg=()=>({state:t,dispatch:e})=>Ps(t,e);function Ti(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Qr(t,e,n={strict:!0}){let r=Object.keys(e);return r.length?r.every(o=>n.strict?e[o]===t[o]:Ti(e[o])?e[o].test(t[o]):e[o]===t[o]):!0}function Gu(t,e,n={}){return t.find(r=>r.type===e&&Qr(Object.fromEntries(Object.keys(n).map(o=>[o,r.attrs[o]])),n))}function Nu(t,e,n={}){return!!Gu(t,e,n)}function Ei(t,e,n){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(a=>a.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(a=>a.type===e))return;if(!n){let a=r.node.marks.find(c=>c.type===e);a&&(n=a.attrs)}if(!Gu([...r.node.marks],e,n))return;let o=r.index,s=t.start()+r.offset,i=o+1,l=s+r.node.nodeSize;for(;o>0&&Nu([...t.parent.child(o-1).marks],e,n);)o-=1,s-=t.parent.child(o).nodeSize;for(;i<t.parent.childCount&&Nu([...t.parent.child(i).marks],e,n);)l+=t.parent.child(i).nodeSize,i+=1;return{from:s,to:l}}function Xe(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var Lg=(t,e)=>({tr:n,state:r,dispatch:o})=>{let s=Xe(t,r.schema),{doc:i,selection:l}=n,{$from:a,from:c,to:u}=l;if(o){let d=Ei(a,s,e);if(d&&d.from<=c&&d.to>=u){let f=M.create(i,d.from,d.to);n.setSelection(f)}}return!0},Pg=t=>e=>{let n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function Xu(t){return t instanceof M}function Rt(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Ci(t,e=null){if(!e)return null;let n=T.atStart(t),r=T.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;let o=n.from,s=r.to;return e==="all"?M.create(t,Rt(0,o,s),Rt(t.content.size,o,s)):M.create(t,Rt(e,o,s),Rt(e,o,s))}function Ou(){return["Android"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function Zr(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function zg(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var Bg=(t=null,e={})=>({editor:n,view:r,tr:o,dispatch:s})=>{e={scrollIntoView:!0,...e};let i=()=>{(Zr()||Ou())&&r.dom.focus(),zg()&&!Zr()&&!Ou()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(s&&t===null&&!Xu(n.state.selection))return i(),!0;let l=Ci(o.doc,t)||n.state.selection,a=n.state.selection.eq(l);return s&&(a||o.setSelection(l),a&&o.storedMarks&&o.setStoredMarks(o.storedMarks),i()),!0},$g=(t,e)=>n=>t.every((r,o)=>e(r,{...n,index:o})),Hg=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Yu=t=>{let e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){let r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&Yu(r)}return t};function Ur(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");let e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return Yu(n)}function Qu(t){return typeof t?.nodesBetween=="function"}function ln(t,e,n){if(Qu(t))return t;let r=typeof t=="object"&&t!==null;n={slice:!0,parseOptions:{},...n};let o=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return b.fromArray(t.map(i=>e.nodeFromJSON(i)));let s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}catch(s){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",s),ln("",e,n)}if(o){if(n.errorOnInvalidContent){let i=!1,l="",a=new wt({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(i=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?We.fromSchema(a).parseSlice(Ur(t),n.parseOptions):We.fromSchema(a).parse(Ur(t),n.parseOptions),n.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let s=We.fromSchema(e);return n.slice?s.parseSlice(Ur(t),n.parseOptions).content:s.parse(Ur(t),n.parseOptions)}return ln("",e,n)}function Zu(t){return!("type"in t)}function ed(t,e,n){let r=t.steps.length-1;if(r<e)return;let o=t.steps[r];if(!(o instanceof X||o instanceof Y))return;let s=t.mapping.maps[r],i=0;s.forEach((l,a,c,u)=>{i===0&&(i=u)}),t.setSelection(T.near(t.doc.resolve(i),n))}var Fg=(t,e,n)=>({tr:r,dispatch:o,editor:s})=>{if(o){n={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l,a=g=>{s.emit("contentError",{editor:s,error:g,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{ln(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{var i;l=ln(e,s.schema,{parseOptions:c,errorOnInvalidContent:(i=n.errorOnInvalidContent)!==null&&i!==void 0?i:s.options.enableContentCheck})}catch(g){return a(g),!1}let{from:u,to:d}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,h=!0,p=Zu(l)?l.content:[l];if(p.forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),u===d&&h){let{parent:g}=r.doc.resolve(u);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(u-=1,d+=1)}let m;if(f)Array.isArray(e)?m=e.map(g=>g.text||"").join(""):Qu(e)?m=p.map(g=>{var y;return(y=g.text)!==null&&y!==void 0?y:""}).join(""):typeof e=="object"&&e&&e.text?m=e.text:m=e,r.insertText(m,u,d);else{m=b.from(p);let g=r.doc.resolve(u),y=g.node(),w=g.parentOffset===0,k=y.isText||y.isTextblock,x=y.content.size>0;w&&k&&x&&h&&(u=Math.max(0,u-1)),r.replaceWith(u,d,p)}n.updateSelection&&ed(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:m}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:m})}return!0};function td(t){for(let e=0;e<t.edgeCount;e+=1){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var jg=(t={})=>({tr:e,dispatch:n,editor:r})=>{let{pos:o,attrs:s,content:i,updateSelection:l=!0}=t,a;typeof o=="number"?a=e.doc.resolve(o):o?a=o:a=e.selection.$from;let c=td(a.parent.contentMatchAt(a.index()));if(!c)return!1;let u=Object.keys(c.spec.attrs||{}),d=s?Object.fromEntries(Object.entries(s).filter(([h])=>u.includes(h))):{},f;if(i){let h=ln(i,r.schema);f=c.createAndFill(d,h)}else f=c.createAndFill(d);return f?(n&&(e.insert(a.pos,f),l&&ed(e,e.steps.length-1,-1)),!0):!1},Wg=()=>({state:t,dispatch:e})=>qa(t,e),Vg=()=>({state:t,dispatch:e})=>Ga(t,e),_g=()=>({state:t,dispatch:e})=>Ts(t,e),Kg=()=>({state:t,dispatch:e})=>Os(t,e),nd=(t,e)=>{let n=t.resolve(e),r=n.nodeBefore,o=n.nodeAfter;return!r||!o?!1:!r.type.spec.isolating&&!o.type.spec.isolating},Ug=()=>({state:t,dispatch:e,tr:n})=>{try{let r=Vt(t.doc,t.selection.$from.pos,-1);return r==null||!nd(t.doc,r)?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Jg=()=>({state:t,dispatch:e,tr:n})=>{try{let r=Vt(t.doc,t.selection.$from.pos,1);return r==null||!nd(t.doc,r)?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},qg=()=>({state:t,dispatch:e})=>Tr(t,e),Gg=()=>({state:t,dispatch:e})=>Er(t,e);function rd(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Xg(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n==="Space"&&(n=" ");let r,o,s,i;for(let l=0;l<e.length-1;l+=1){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Zr()||rd()?i=!0:o=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),o&&(n=`Ctrl-${n}`),i&&(n=`Meta-${n}`),s&&(n=`Shift-${n}`),n}var Yg=t=>({editor:e,view:n,tr:r,dispatch:o})=>{let s=Xg(t).split(/-(?!$)/),i=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:i==="Space"?" ":i,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a?.steps.forEach(c=>{let u=c.map(r.mapping);u&&o&&r.maybeStep(u)}),!0};function $e(t,e,n={}){let{from:r,to:o,empty:s}=t.selection,i=e?ee(e,t.schema):null,l=[];t.doc.nodesBetween(r,o,(u,d)=>{if(u.isText)return;let f=Math.max(r,d),h=Math.min(o,d+u.nodeSize);l.push({node:u,from:f,to:h})});let a=o-r,c=l.filter(u=>i?i.name===u.node.type.name:!0).filter(u=>Qr(u.node.attrs,n,{strict:!1}));return s?!!c.length:c.reduce((u,d)=>u+d.to-d.from,0)>=a}var Qg=(t,e={})=>({state:n,dispatch:r})=>$e(n,ee(t,n.schema),e)?Xa(n,r):!1,Zg=()=>({state:t,dispatch:e})=>Bs(t,e),ey=t=>({state:e,dispatch:n})=>{let r=ee(t,e.schema);return nc(r)(e,n)},ty=()=>({state:t,dispatch:e})=>Ds(t,e);function to(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Ru(t,e){let n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,o)=>(n.includes(o)||(r[o]=t[o]),r),{})}var ny=(t,e)=>({tr:n,state:r,dispatch:o})=>{let s=null,i=null,l=to(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(s=ee(t,r.schema)),l==="mark"&&(i=Xe(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{s&&s===u.type&&(a=!0,o&&n.setNodeMarkup(d,void 0,Ru(u.attrs,e))),i&&u.marks.length&&u.marks.forEach(f=>{i===f.type&&(a=!0,o&&n.addMark(d,d+u.nodeSize,i.create(Ru(f.attrs,e))))})})}),a},ry=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),oy=()=>({tr:t,dispatch:e})=>{if(e){let n=new he(t.doc);t.setSelection(n)}return!0},sy=()=>({state:t,dispatch:e})=>Es(t,e),iy=()=>({state:t,dispatch:e})=>Rs(t,e),ly=()=>({state:t,dispatch:e})=>Ya(t,e),ay=()=>({state:t,dispatch:e})=>Hs(t,e),cy=()=>({state:t,dispatch:e})=>$s(t,e);function Mi(t,e,n={},r={}){return ln(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var uy=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:o,tr:s,dispatch:i,commands:l})=>{let{doc:a}=s;if(r.preserveWhitespace!=="full"){let c=Mi(t,o.schema,r,{errorOnInvalidContent:e??o.options.enableContentCheck});if(i){let u=Zu(c)?c.content:[c];s.replaceWith(0,a.content.size,u).setMeta("preventUpdate",!n)}return!0}return i&&s.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??o.options.enableContentCheck})};function od(t,e){let n=Xe(e,t.schema),{from:r,to:o,empty:s}=t.selection,i=[];s?(t.storedMarks&&i.push(...t.storedMarks),i.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,o,a=>{i.push(...a.marks)});let l=i.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function Ni(t,e){let n=new Ke(t);return e.forEach(r=>{r.steps.forEach(o=>{n.step(o)})}),n}function sd(t,e,n){let r=[];return t.nodesBetween(e.from,e.to,(o,s)=>{n(o)&&r.push({node:o,pos:s})}),r}function cn(t,e){for(let n=t.depth;n>0;n-=1){let r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function no(t){return e=>cn(e.$from,t)}function A(t,e,n){return t.config[e]===void 0&&t.parent?A(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?A(t.parent,e,n):null}):t.config[e]}function Oi(t){return t.map(e=>{let n=A(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return n?[e,...Oi(n())]:e}).flat(10)}function Ri(t,e){let n=Ve.fromSchema(e).serializeFragment(t),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function id(t,e){let n=new Map;for(let o of t){var r;let s=(r=n.get(o.type))!==null&&r!==void 0?r:new Map;s.set(o.name,o),n.set(o.type,s)}return[...Object.values(e.nodes),...Object.values(e.marks)].flatMap(o=>{var s;return Object.entries((s=o.spec.attrs)!==null&&s!==void 0?s:{}).map(([i,l])=>{var a;let c=(a=n.get(o.name))===null||a===void 0?void 0:a.get(i),u=Object.hasOwn(l,"default");return{type:o.name,name:i,attribute:{rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,...c?.attribute,default:l.default,isRequired:!u,validate:l.validate}}})})}var dy={content:"string",marks:"string",group:"string",inline:"boolean",atom:"boolean",selectable:"boolean",draggable:"boolean",code:"boolean",whitespace:["pre","normal"],definingAsContext:"boolean",definingForContent:"boolean",defining:"boolean",isolating:"boolean",linebreakReplacement:"boolean"},fy={inclusive:"boolean",excludes:"string",group:"string",spanning:"boolean",code:"boolean"};function hy(t,e,n){return Object.fromEntries(Object.entries(e).flatMap(([r,o])=>{let s=t[r];if(s===void 0)return[];if(!(typeof o=="string"?typeof s===o:typeof s=="string"&&o.includes(s)))throw new RangeError(`Invalid schemaSpec field '${n}.${r}'`);return[[r,s]]}))}function Iu(t,e,n,r){return{...Object.fromEntries(Object.entries(e).filter(([o])=>o!=="attrs"&&!Object.hasOwn(r,o))),...hy(n,r,t),attrs:n.attrs}}function Du(t,e,n){for(let r of Object.keys(e))if(!Object.hasOwn(t,r))throw new RangeError(`schemaSpec requires a local ${n} extension named '${r}'`);for(let r of Object.keys(t))if(!Object.hasOwn(e,r))throw new RangeError(`Local ${n} extension '${r}' is not in schemaSpec`)}function py(t,e){Du(t.nodes,e.nodes,"node"),Du(t.marks,e.marks,"mark");let n=e.spec.nodes,r=e.spec.marks;return e.spec.nodes.forEach((o,s)=>{n=n.update(o,Iu(o,t.nodes[o],s,dy))}),e.spec.marks.forEach((o,s)=>{r=r.update(o,Iu(o,t.marks[o],s,fy))}),{topNode:e.topNodeType.name,nodes:n,marks:r}}function ld(t){let e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function an(t){return{baseExtensions:t.filter(e=>e.type==="extension"),nodeExtensions:t.filter(e=>e.type==="node"),markExtensions:t.filter(e=>e.type==="mark")}}function Ii(t){let e=[],{nodeExtensions:n,markExtensions:r}=an(t),o=[...n,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},i=n.filter(c=>c.name!=="text").map(c=>c.name),l=r.map(c=>c.name),a=[...i,...l];return t.forEach(c=>{let u=A(c,"addGlobalAttributes",{name:c.name,options:c.options,storage:c.storage,extensions:o});u&&u().forEach(d=>{let f;Array.isArray(d.types)?f=d.types:d.types==="*"?f=a:d.types==="nodes"?f=i:d.types==="marks"?f=l:f=[],f.forEach(h=>{Object.entries(d.attributes).forEach(([p,m])=>{e.push({type:h,name:p,attribute:{...s,...m}})})})})}),o.forEach(c=>{let u=A(c,"addAttributes",{name:c.name,options:c.options,storage:c.storage});if(!u)return;let d=u();Object.entries(d).forEach(([f,h])=>{let p={...s,...h};typeof p?.default=="function"&&(p.default=p.default()),p?.isRequired&&p?.default===void 0&&delete p.default,e.push({type:c.name,name:f,attribute:p})})}),e}function vi(t){return typeof t=="function"}function j(t,e=void 0,...n){return vi(t)?e?t.bind(e)(...n):t(...n):t}function my(t={}){return Object.keys(t).length===0&&t.constructor===Object}function gy(t){let e=[],n="",r=!1,o=!1,s=0,i=t.length;for(let l=0;l<i;l+=1){let a=t[l];if(a==="'"&&!o){r=!r,n+=a;continue}if(a==='"'&&!r){o=!o,n+=a;continue}if(!r&&!o){if(a==="("){s+=1,n+=a;continue}if(a===")"&&s>0){s-=1,n+=a;continue}if(a===";"&&s===0){e.push(n),n="";continue}}n+=a}return n&&e.push(n),e}function Lu(t){let e=[],n=gy(t||""),r=n.length;for(let o=0;o<r;o+=1){let s=n[o],i=s.indexOf(":");if(i===-1)continue;let l=s.slice(0,i).trim(),a=s.slice(i+1).trim();l&&a&&e.push([l,a])}return e}function I(...t){return t.filter(e=>!!e).reduce((e,n)=>{let r={...e};return Object.entries(n).forEach(([o,s])=>{if(o==="__proto__"){Object.defineProperty(r,o,{configurable:!0,enumerable:!0,value:s,writable:!0});return}if(!r[o]){r[o]=s;return}if(o==="class"){let i=s?String(s).split(" "):[],l=r[o]?r[o].split(" "):[],a=i.filter(c=>!l.includes(c));r[o]=[...l,...a].join(" ")}else if(o==="style"){let i=new Map([...Lu(r[o]),...Lu(s)]);r[o]=Array.from(i.entries()).map(([l,a])=>`${l}: ${a}`).join("; ")}else r[o]=s}),r},{})}function ct(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>I(n,r),{})}function yy(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Pu(t,e){return"style"in t?t:{...t,getAttrs:n=>{let r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;let o=e.reduce((s,i)=>{let l=i.attribute.parseHTML?i.attribute.parseHTML(n):yy(n.getAttribute(i.name));return l==null?s:{...s,[i.name]:l}},{});return{...r,...o}}}}function zu(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&my(n)?!1:n!=null))}function Bu(t){var e,n;let r={};return!(!(t==null||(e=t.attribute)===null||e===void 0)&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),(t==null||(n=t.attribute)===null||n===void 0?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function $u(t,e,n=Ii(t)){var r;let{nodeExtensions:o,markExtensions:s}=an(t);return{topNode:(r=o.find(i=>A(i,"topNode")))===null||r===void 0?void 0:r.name,nodes:Object.fromEntries(o.map(i=>{let l=n.filter(h=>h.type===i.name),a={name:i.name,options:i.options,storage:i.storage,editor:e},c=zu({...t.reduce((h,p)=>{let m=A(p,"extendNodeSchema",a);return{...h,...m?m(i):{}}},{}),content:j(A(i,"content",a)),marks:j(A(i,"marks",a)),group:j(A(i,"group",a)),inline:j(A(i,"inline",a)),atom:j(A(i,"atom",a)),selectable:j(A(i,"selectable",a)),draggable:j(A(i,"draggable",a)),code:j(A(i,"code",a)),whitespace:j(A(i,"whitespace",a)),linebreakReplacement:j(A(i,"linebreakReplacement",a)),defining:j(A(i,"defining",a)),isolating:j(A(i,"isolating",a)),attrs:Object.fromEntries(l.map(Bu))}),u=j(A(i,"parseHTML",a));u&&(c.parseDOM=u.map(h=>Pu(h,l)));let d=A(i,"renderHTML",a);d&&(c.toDOM=h=>d({node:h,HTMLAttributes:ct(h,l)}));let f=A(i,"renderText",a);return f&&(c.toText=f),[i.name,c]})),marks:Object.fromEntries(s.map(i=>{let l=n.filter(f=>f.type===i.name),a={name:i.name,options:i.options,storage:i.storage,editor:e},c=zu({...t.reduce((f,h)=>{let p=A(h,"extendMarkSchema",a);return{...f,...p?p(i):{}}},{}),inclusive:j(A(i,"inclusive",a)),excludes:j(A(i,"excludes",a)),group:j(A(i,"group",a)),spanning:j(A(i,"spanning",a)),code:j(A(i,"code",a)),attrs:Object.fromEntries(l.map(Bu))}),u=j(A(i,"parseHTML",a));u&&(c.parseDOM=u.map(f=>Pu(f,l)));let d=A(i,"renderHTML",a);return d&&(c.toDOM=f=>d({mark:f,HTMLAttributes:ct(f,l)})),[i.name,c]}))}}function ad(t,e,n){if(n===void 0)return new wt($u(t,e));let r=ld(t.filter(i=>i.type!=="extension").map(i=>i.name));if(r.length)throw new RangeError(`Duplicate local schema types: ${r.join(", ")}`);let o=new wt(n),s=$u(t,e,id(Ii(t),o));return new wt(py(s,o))}function qn(t){return t.sort((n,r)=>{let o=A(n,"priority")||100,s=A(r,"priority")||100;return o>s?-1:o<s?1:0})}function Di(t){let e=qn(Oi(t)),n=ld(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function ro(t,e){return ad(Di(t),e)}function cd(t,e,n){let{from:r,to:o}=e,{blockSeparator:s=`
|
|
11
|
+
|
|
12
|
+
`,textSerializers:i={}}=n||{},l="";return t.nodesBetween(r,o,(a,c,u,d)=>{a.isBlock&&c>r&&(l+=s);let f=i?.[a.type.name];if(f)return u&&(l+=f({node:a,pos:c,parent:u,index:d,range:e})),!1;if(a.isText){var h;l+=a==null||(h=a.text)===null||h===void 0?void 0:h.slice(Math.max(r,c)-c,o-c)}}),l}function by(t,e){return cd(t,{from:0,to:t.content.size},e)}function ud(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function ky(t,e){let n=ee(e,t.schema),{from:r,to:o}=t.selection,s=[];t.doc.nodesBetween(r,o,l=>{s.push(l)});let i=s.reverse().find(l=>l.type.name===n.name);return i?{...i.attrs}:{}}function Li(t,e){let n=to(typeof e=="string"?e:e.name,t.schema);return n==="node"?ky(t,e):n==="mark"?od(t,e):{}}function wy(t,e=JSON.stringify){let n={};return t.filter(r=>{let o=e(r);return Object.prototype.hasOwnProperty.call(n,o)?!1:n[o]=!0})}function Sy(t){let e=wy(t);return e.length===1?e:e.filter((n,r)=>!e.filter((o,s)=>s!==r).some(o=>n.oldRange.from>=o.oldRange.from&&n.oldRange.to<=o.oldRange.to&&n.newRange.from>=o.newRange.from&&n.newRange.to<=o.newRange.to))}function un(t){let{mapping:e,steps:n}=t,r=[],o=e.invert();return e.maps.forEach((s,i)=>{let l=[];if(s.ranges.length)s.forEach((c,u)=>{l.push({from:c,to:u})});else{let{from:c,to:u}=n[i];if(c===void 0||u===void 0)return;l.push({from:c,to:u})}let a=e.slice(i);l.forEach(({from:c,to:u})=>{let d=a.map(c,-1),f=a.map(u),h=o.map(d,-1),p=o.map(f);r.push({oldRange:{from:h,to:p},newRange:{from:d,to:f}})})}),Sy(r)}function Gn(t,e,n){let r=[];return t===e?n.resolve(t).marks().forEach(o=>{let s=Ei(n.resolve(t),o.type);s&&r.push({mark:o,...s})}):n.nodesBetween(t,e,(o,s)=>{!o||o?.nodeSize===void 0||r.push(...o.marks.map(i=>({from:s,to:s+o.nodeSize,mark:i})))}),r}var dd=(t,e,n,r=20)=>{let o=t.doc.resolve(n),s=r,i=null;for(;s>0&&i===null;){let l=o.node(s);l?.type.name===e?i=l:s-=1}return[i,s]},fd=t=>{let e=t.depth-1;if(e<0)return null;let n=t.index(e);return n===0?null:t.node(e).child(n-1)};function tn(t,e){return e.nodes[t]||e.marks[t]||null}function Yr(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{let o=t.find(s=>s.type===e&&s.name===r);return o?o.attribute.keepOnSplit:!1}))}var xy=(t,e=500)=>{let n="",r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(o,s,i,l)=>{var a,c;let u=((a=(c=o.type.spec).toText)===null||a===void 0?void 0:a.call(c,{node:o,pos:s,parent:i,index:l}))||o.textContent||"%leaf%";n+=o.isAtom&&!o.isText?u:u.slice(0,Math.max(0,r-s))}),n};function Ai(t,e,n={}){let{empty:r,ranges:o}=t.selection,s=e?Xe(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(u=>s?s.name===u.type.name:!0).find(u=>Qr(u.attrs,n,{strict:!1}));let i=0,l=[];if(o.forEach(({$from:u,$to:d})=>{let f=u.pos,h=d.pos;t.doc.nodesBetween(f,h,(p,m)=>{if(s&&p.inlineContent&&!p.type.allowsMarkType(s))return!1;if(!p.isText&&!p.marks.length)return;let g=Math.max(f,m),y=Math.min(h,m+p.nodeSize),w=y-g;i+=w,l.push(...p.marks.map(k=>({mark:k,from:g,to:y})))})}),i===0)return!1;let a=l.filter(u=>s?s.name===u.mark.type.name:!0).filter(u=>Qr(u.mark.attrs,n,{strict:!1})).reduce((u,d)=>u+d.to-d.from,0),c=l.filter(u=>s?u.mark.type!==s&&u.mark.type.excludes(s):!0).reduce((u,d)=>u+d.to-d.from,0);return(a>0?a+c:a)>=i}function Cy(t,e,n={}){if(!e)return $e(t,null,n)||Ai(t,null,n);let r=to(e,t.schema);return r==="node"?$e(t,e,n):r==="mark"?Ai(t,e,n):!1}var hd=(t,e)=>{let{$from:n,$to:r,$anchor:o}=t.selection;if(e){let s=no(l=>l.type.name===e)(t.selection);if(!s)return!1;let i=t.doc.resolve(s.pos+1);return o.pos+1===i.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},pd=t=>{let{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function Hu(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Un(t,e){let{nodeExtensions:n}=an(e),r=n.find(s=>s.name===t);if(!r)return!1;let o=j(A(r,"group",{name:r.name,options:r.options,storage:r.storage}));return typeof o!="string"?!1:o.split(" ").includes("list")}function dn(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){if(n){if(t.type.name==="hardBreak")return!0;if(t.isText){var r;return!/\S/.test((r=t.text)!==null&&r!==void 0?r:"")}}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let o=!0;return t.content.forEach(s=>{o!==!1&&(dn(s,{ignoreWhitespace:n,checkChildren:e})||(o=!1))}),o}return!1}function oo(t){return t instanceof v}function My(t){if(t===null||typeof t!="object")return!1;let e=t;return!(typeof e.apply!="function"||typeof e.getMap!="function"||typeof e.invert!="function"||typeof e.map!="function"||typeof e.merge!="function"||typeof e.toJSON!="function")}function vy(t){if(t===null||typeof t!="object")return!1;let e=t;if(!My(e))return!1;let n=e.toJSON();return!(n===null||typeof n!="object"||n.stepType!=="replace")}var md=class gd{constructor(e){this.position=e}static fromJSON(e){return new gd(e.position)}toJSON(){return{position:this.position}}};function Ay(t,e){let n=e.mapping.mapResult(t.position);return{position:new md(n.pos),mapResult:n}}function Ty(t){return new md(t)}function Ey(t,e,n){let{selection:r}=e,o=null;if(Xu(r)&&(o=r.$cursor),o){var s;let l=(s=t.storedMarks)!==null&&s!==void 0?s:o.marks();return o.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(a=>a.type.excludes(n)))}let{ranges:i}=r;return i.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){let h=!f||f.type.allowsMarkType(n),p=!!n.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(n));c=h&&p}return!c}),c})}var Ny=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let{selection:s}=n,{empty:i,ranges:l}=s,a=Xe(t,r.schema);if(o)if(i){let c=od(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{let u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,h)=>{let p=Math.max(h,u),m=Math.min(h+f.nodeSize,d);f.marks.find(g=>g.type===a)?f.marks.forEach(g=>{a===g.type&&n.addMark(p,m,a.create({...g.attrs,...e}))}):n.addMark(p,m,a.create(e))})});return Ey(r,n,a)},Oy=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Ry=(t,e={})=>({state:n,dispatch:r,chain:o})=>{let s=ee(t,n.schema),i;return n.selection.$anchor.sameParent(n.selection.$head)&&(i=n.selection.$anchor.parent.attrs),s.isTextblock?o().command(({commands:l})=>Fs(s,{...i,...e})(n)?!0:l.clearNodes()).command(({state:l})=>Fs(s,{...i,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Iy=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,o=Rt(t,0,r.content.size),s=v.create(r,o);e.setSelection(s)}return!0},Dy=(t,e)=>({tr:n,state:r,dispatch:o})=>{let{selection:s}=r,i,l;return typeof e=="number"?(i=e,l=e):e&&"from"in e&&"to"in e?(i=e.from,l=e.to):(i=s.from,l=s.to),o&&n.doc.nodesBetween(i,l,(a,c)=>{a.isText||n.setNodeMarkup(c,void 0,{...a.attrs,dir:t})}),!0},Ly=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,{from:o,to:s}=typeof t=="number"?{from:t,to:t}:t,i=M.atStart(r).from,l=M.atEnd(r).to,a=Rt(o,i,l),c=Rt(s,i,l),u=M.create(r,a,c);e.setSelection(u)}return!0},Py=t=>({state:e,dispatch:n})=>{let r=ee(t,e.schema);return rc(r)(e,n)};function Fu(t,e){let n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){let r=n.filter(o=>e?.includes(o.type.name));t.tr.ensureMarks(r)}}var zy=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:o})=>{let{selection:s,doc:i}=e,{$from:l,$to:a}=s,c=o.extensionManager.attributes,u=Yr(c,l.node().type.name,l.node().attrs);if(s instanceof v&&s.node.isBlock)return!l.parentOffset||!Ce(i,l.pos)?!1:(r&&(t&&Fu(n,o.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let d=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:td(l.node(-1).contentMatchAt(l.indexAfter(-1))),h=d&&f?[{type:f,attrs:u}]:void 0,p=s instanceof M&&!s.empty?Ct.create({doc:e.doc,selection:s}).tr.deleteSelection():null,m=p?p.doc:e.doc,g=p?p.mapping.map(l.pos):l.pos,y=Ce(m,g,1,h);if(!h&&!y&&Ce(m,g,1,f?[{type:f}]:void 0)&&(y=!0,h=f?[{type:f,attrs:u}]:void 0),r){if(y){let w=e.steps.length;if(s instanceof M&&e.deleteSelection(),e.split(e.mapping.slice(w).map(l.pos),1,h),f&&!d&&!l.parentOffset&&l.parent.type!==f){let k=e.mapping.slice(w).map(l.before()),x=e.doc.resolve(k);l.node(-1).canReplaceWith(x.index(),x.index()+1,f)&&e.setNodeMarkup(e.mapping.slice(w).map(l.before()),f)}}t&&Fu(n,o.extensionManager.splittableMarks),e.scrollIntoView()}return y},By=(t,e={})=>({tr:n,state:r,dispatch:o,editor:s})=>{let i=ee(t,r.schema),{$from:l,$to:a}=r.selection,c=r.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(a))return!1;let u=l.node(-1);if(u.type!==i)return!1;let d=s.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==i||l.index(-2)!==l.node(-2).childCount-1)return!1;if(o){var f;let x=b.empty,E=l.index(-1)?1:l.index(-2)?2:3;for(let xe=l.depth-E;xe>=l.depth-3;xe-=1)x=b.from(l.node(xe).copy(x));let V=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,W={...Yr(d,l.node().type.name,l.node().attrs),...e},O=((f=i.contentMatch.defaultType)===null||f===void 0?void 0:f.createAndFill(W))||void 0;x=x.append(b.from(i.createAndFill(null,O)||void 0));let P=l.before(l.depth-(E-1));n.replace(P,l.after(-V),new C(x,4-E,0));let D=-1;n.doc.nodesBetween(P,n.doc.content.size,(xe,pt)=>{if(D>-1)return!1;xe.isTextblock&&xe.content.size===0&&(D=pt+1)}),D>-1&&n.setSelection(M.near(n.doc.resolve(D))),n.scrollIntoView()}return!0}let h=a.pos===l.end()?u.contentMatchAt(0).defaultType:null,p={...Yr(d,u.type.name,u.attrs),...e},m={...Yr(d,l.node().type.name,l.node().attrs),...e},g=l.parentOffset===0&&l.index(-1)===0,y=l.before(-1);n.delete(l.pos,a.pos);let w=g?u.attrs:p,k=h?[{type:i,attrs:w},{type:h,attrs:m}]:[{type:i,attrs:w}];if(!Ce(n.doc,l.pos,2))return!1;if(o){let{selection:x,storedMarks:E}=r,{splittableMarks:V}=s.extensionManager,W=E||x.$to.parentOffset&&x.$from.marks();if(n.split(l.pos,2,k).scrollIntoView(),g&&n.setNodeMarkup(y,void 0,p),!W||!o)return!0;let O=W.filter(P=>V.includes(P.type.name));n.ensureMarks(O)}return!0};function yd(t,e,n){if(!t.validContent(e))return null;try{return t.create(n,e)}catch{return null}}function Pi(t,e){if(t.pendingContent.length===0)return!0;let n=yd(e,b.from(t.pendingContent));return n?(t.items.push(n),t.pendingContent=[],!0):!1}function $y(t,e,n){return n.validContent(b.from([...e.pendingContent,t]))?(e.pendingContent.push(t),!0):!Pi(e,n)||!n.validContent(b.from(t))?!1:(e.pendingContent.push(t),!0)}function Hy(t,e,n,r){let o=r(t,n);if(!o)return!1;let s=yd(n.listType,b.from(o),t.attrs);return s?n.itemType.validContent(b.from([...e.pendingContent,s]))?(e.pendingContent.push(s),!0):Pi(e,n.itemType)?(e.items.push(...o),!0):!1:!1}function Fy(t,e,n){let r={items:[],pendingContent:[]};for(let o=0;o<t.childCount;o+=1){let s=t.child(o);if(!(e.isListNode(s)?Hy(s,r,e,n):$y(s,r,e.itemType)))return null}return Pi(r,e.itemType)?r.items:null}function bd(t,e){let n=[];for(let r=0;r<t.childCount;r+=1){let o=Fy(t.child(r),e,bd);if(!o)return null;n.push(...o)}return n}function ju(t,e){let n=null;return t.descendants((r,o)=>r!==e?!0:(n=o,!1)),n}function Wu(t){return!t||t==="1"?null:t}function kd(t,e){return Wu(t)===Wu(e)}var Jr=(t,e)=>{let n=no(s=>s.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let o=t.doc.nodeAt(r);return!(n.node.type===o?.type&&Ne(t.doc,n.pos))||!kd(n.node.attrs.type,o?.attrs.type)||t.join(n.pos),!0},qr=(t,e)=>{let n=no(s=>s.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let o=t.doc.nodeAt(r);return!(n.node.type===o?.type&&Ne(t.doc,r))||!kd(n.node.attrs.type,o?.attrs.type)||t.join(r),!0};function jy(t){let e=t.doc,n=e.firstChild;if(!n)return null;let r=e.resolve(1),o=e.resolve(n.nodeSize-1);return M.between(r,o)}var Wy=(t,e,n,r={})=>({editor:o,tr:s,state:i,dispatch:l,chain:a,commands:c,can:u})=>{let{extensions:d,splittableMarks:f}=o.extensionManager,h=ee(t,i.schema),p=ee(e,i.schema),{selection:m,storedMarks:g}=i,{$from:y,$to:w}=m,k=y.blockRange(w),x=g||m.$to.parentOffset&&m.$from.marks();if(!k)return!1;let E=no(de=>Un(de.type.name,d))(m),V=m.from===0&&m.to===i.doc.content.size,W=i.doc.content.content,O=W.length===1?W[0]:null,P=V&&O&&Un(O.type.name,d)?{node:O,pos:0,depth:0}:null,D=E??P,xe=!!E&&k.depth>=1&&k.depth-E.depth<=1,pt=!!P;if((xe||pt)&&D){if(D.node.type===h)return V&&pt?a().command(({tr:de,dispatch:ye})=>{let fe=jy(de);return fe?(de.setSelection(fe),ye&&ye(de),!0):!1}).liftListItem(p).run():c.liftListItem(p);if(Un(D.node.type.name,d)&&h.validContent(D.node.content))return a().command(()=>(s.setNodeMarkup(D.pos,h),!0)).command(()=>Jr(s,h)).command(()=>qr(s,h)).run();if(Un(D.node.type.name,d)){var mt;let de=(mt=D.node.firstChild)===null||mt===void 0?void 0:mt.type;if(de&&de!==p){let ye=bd(D.node,{listType:h,itemType:p,isListNode:dr=>Un(dr.type.name,d)}),fe=ye?b.from(ye):null;return!fe||!h.validContent(fe)?!1:a().command(()=>{let{$anchor:dr,$head:Bl}=s.selection,$l=dr.parent,Hl=Bl.parent,Rh=dr.parentOffset,Ih=Bl.parentOffset,fr;try{fr=h.create(r,fe)}catch{return!1}if(s.replaceWith(D.pos,D.pos+D.node.nodeSize,fr),$l.inlineContent&&Hl.inlineContent){let Fl=ju(fr,$l),jl=ju(fr,Hl);if(Fl!==null&&jl!==null){let Dh=D.pos+Fl+2+Rh,Lh=D.pos+jl+2+Ih;s.setSelection(M.create(s.doc,Dh,Lh))}}return!0}).command(()=>Jr(s,h)).command(()=>qr(s,h)).run()}}}return!n||!x||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Jr(s,h)).command(()=>qr(s,h)).run():a().command(()=>{let de=u().wrapInList(h,r),ye=x.filter(fe=>f.includes(fe.type.name));return s.ensureMarks(ye),de?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Jr(s,h)).command(()=>qr(s,h)).run()},Vy=(t,e={},n={})=>({state:r,commands:o})=>{let{extendEmptyMarkRange:s=!1}=n,i=Xe(t,r.schema);return Ai(r,i,e)?o.unsetMark(i,{extendEmptyMarkRange:s}):o.setMark(i,e)},_y=(t,e,n={})=>({state:r,commands:o})=>{let s=ee(t,r.schema),i=ee(e,r.schema),l=$e(r,s,n),a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?o.setNode(i,a):o.setNode(s,{...a,...n})},Ky=(t,e={})=>({state:n,commands:r})=>{let o=ee(t,n.schema);return $e(n,o,e)?r.lift(o):r.wrapIn(o,e)},Uy=()=>({state:t,dispatch:e})=>{let n=t.plugins;for(let r=0;r<n.length;r+=1){let o=n[r],s;if(o.spec.isInputRules&&(s=o.getState(t))){if(e){let i=t.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a-=1)i.step(l.steps[a].invert(l.docs[a]));if(s.text){let a=i.doc.resolve(s.from).marks();i.replaceWith(s.from,s.to,t.schema.text(s.text,a))}else i.delete(s.from,s.to)}return!0}}return!1},Jy=(t={})=>({tr:e,dispatch:n,editor:r})=>{let{ignoreClearable:o=!1}=t,{selection:s}=e,{empty:i,ranges:l}=s;if(i)return!0;let{nonClearableMarks:a}=r.extensionManager;if(n){let c=Object.values(r.schema.marks).filter(u=>o||!a.includes(u.name));l.forEach(u=>{for(let d of c)e.removeMark(u.$from.pos,u.$to.pos,d)})}return!0},qy=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let{extendEmptyMarkRange:s=!1}=e,{selection:i}=n,l=Xe(t,r.schema),{$from:a,empty:c,ranges:u}=i;if(!o)return!0;if(c&&s){var d;let{from:f,to:h}=i,p=Ei(a,l,(d=a.marks().find(m=>m.type===l))===null||d===void 0?void 0:d.attrs);p&&(f=p.from,h=p.to),n.removeMark(f,h,l)}else u.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,l)});return n.removeStoredMark(l),!0},Gy=t=>({tr:e,state:n,dispatch:r})=>{let{selection:o}=n,s,i;return typeof t=="number"?(s=t,i=t):t&&"from"in t&&"to"in t?(s=t.from,i=t.to):(s=o.from,i=o.to),r&&e.doc.nodesBetween(s,i,(l,a)=>{if(l.isText)return;let c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},Xy=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let s=null,i=null,l=to(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(s=ee(t,r.schema)),l==="mark"&&(i=Xe(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{let u=c.$from.pos,d=c.$to.pos,f,h,p,m;n.selection.empty?r.doc.nodesBetween(u,d,(g,y)=>{s&&s===g.type&&(a=!0,p=Math.max(y,u),m=Math.min(y+g.nodeSize,d),f=y,h=g)}):r.doc.nodesBetween(u,d,(g,y)=>{y<u&&s&&s===g.type&&(a=!0,p=Math.max(y,u),m=Math.min(y+g.nodeSize,d),f=y,h=g),y>=u&&y<=d&&(s&&s===g.type&&(a=!0,o&&n.setNodeMarkup(y,void 0,{...g.attrs,...e})),i&&g.marks.length&&g.marks.forEach(w=>{if(i===w.type&&(a=!0,o)){let k=Math.max(y,u),x=Math.min(y+g.nodeSize,d);n.addMark(k,x,i.create({...w.attrs,...e}))}}))}),h&&(f!==void 0&&o&&n.setNodeMarkup(f,void 0,{...h.attrs,...e}),i&&h.marks.length&&h.marks.forEach(g=>{i===g.type&&o&&n.addMark(p,m,i.create({...g.attrs,...e}))}))}),a},rn=new z("__tiptap_decorations__"),Yy=t=>({tr:e,dispatch:n})=>(n&&e.setMeta(rn,{type:"force",name:t}),!0),Qy=(t,e={})=>({state:n,dispatch:r})=>{let o=ee(t,n.schema);return ec(o,e)(n,r)},Zy=(t,e={})=>({state:n,dispatch:r})=>{let o=ee(t,n.schema);return tc(o,e)(n,r)},e0=_l({blur:()=>wg,clearContent:()=>Sg,clearNodes:()=>xg,command:()=>Cg,createParagraphNear:()=>Mg,cut:()=>vg,deleteCurrentNode:()=>Ag,deleteNode:()=>Tg,deleteRange:()=>Eg,deleteSelection:()=>Rg,enter:()=>Ig,exitCode:()=>Dg,extendMarkRange:()=>Lg,first:()=>Pg,focus:()=>Bg,forEach:()=>$g,insertContent:()=>Hg,insertContentAt:()=>Fg,insertDefaultBlock:()=>jg,joinBackward:()=>_g,joinDown:()=>Vg,joinForward:()=>Kg,joinItemBackward:()=>Ug,joinItemForward:()=>Jg,joinTextblockBackward:()=>qg,joinTextblockForward:()=>Gg,joinUp:()=>Wg,keyboardShortcut:()=>Yg,lift:()=>Qg,liftEmptyBlock:()=>Zg,liftListItem:()=>ey,newlineInCode:()=>ty,resetAttributes:()=>ny,scrollIntoView:()=>ry,selectAll:()=>oy,selectNodeBackward:()=>sy,selectNodeForward:()=>iy,selectParentNode:()=>ly,selectTextblockEnd:()=>ay,selectTextblockStart:()=>cy,setContent:()=>uy,setMark:()=>Ny,setMeta:()=>Oy,setNode:()=>Ry,setNodeSelection:()=>Iy,setTextDirection:()=>Dy,setTextSelection:()=>Ly,sinkListItem:()=>Py,splitBlock:()=>zy,splitListItem:()=>By,toggleList:()=>Wy,toggleMark:()=>Vy,toggleNode:()=>_y,toggleWrap:()=>Ky,undoInputRule:()=>Uy,unsetAllMarks:()=>Jy,unsetMark:()=>qy,unsetTextDirection:()=>Gy,updateAttributes:()=>Xy,updateDecorations:()=>Yy,wrapIn:()=>Qy,wrapInList:()=>Zy}),on=new WeakMap;function t0(t,e){var n;on.set(t,((n=on.get(t))!==null&&n!==void 0?n:0)+1);try{return e()}finally{var r;let o=((r=on.get(t))!==null&&r!==void 0?r:1)-1;o>0?on.set(t,o):on.delete(t)}}function n0(t){return on.has(t)}var r0=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){let n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){let n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){let n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},wd=typeof process<"u"&&!0;function o0(t){return t.kind==="widget"}function Sd(t,e){let n=[],r=new Set;for(let o of t)o.kind==="widget"&&o0(o)&&r.add(o.key),n.push(o.toPMDecoration(e));return{decorations:n,widgetKeys:r}}function s0(t,e,n){let{decorations:r,widgetKeys:o}=Sd(e,n);return{set:B.create(t,r),widgetKeys:o}}function xd({position:t,from:e,to:n,docSize:r}){return t<e?!1:t<n?!0:t===n&&n===r}function i0({decorations:t,from:e,to:n,docSize:r,extensionName:o,warnedExtensions:s}){return t.filter(i=>xd({position:i.anchor,from:e,to:n,docSize:r})?!0:(i.anchor===n||s.has(o)||(s.add(o),console.warn(`[tiptap warn]: Extension "${o}" returned a decoration outside the requested range [${e}, ${n}). It was ignored.`)),!1))}function Cd(t){var e;let n=(e=t.spec)===null||e===void 0?void 0:e.key;return typeof n=="string"?n:void 0}function l0(t){let e=new Map,n=new Map;for(let i of t.find()){var r,o,s;let l=Cd(i);if(!l)continue;let a=(r=i.spec.extensionName)!==null&&r!==void 0?r:"unknown",c=(o=e.get(l))!==null&&o!==void 0?o:new Set;c.add(a),e.set(l,c),n.set(l,((s=n.get(l))!==null&&s!==void 0?s:0)+1)}return Array.from(e,([i,l])=>({key:i,extensions:l})).filter(({key:i})=>{var l;return((l=n.get(i))!==null&&l!==void 0?l:0)>1})}function Md(t){return t.jsonID==="attr"}function a0(t){let e=!1;if(t.getMap().forEach(()=>{e=!0}),e||Md(t))return!0;let n=t;return typeof n.from=="number"&&typeof n.to=="number"}function c0(t,e){let n=null,r=0,o=0;for(let s=0;s<t.childCount&&!(o>e.to);s+=1){let i=o+t.child(s).nodeSize;i>=e.from&&(n===null&&(n=o),r=i),o=i}return n===null?null:{from:n,to:r}}function u0(t,e){if(t.steps.some(s=>!a0(s)))return{type:"full"};let n=un(t).map(({newRange:s})=>s);t.steps.forEach((s,i)=>{if(!Md(s))return;let l=t.mapping.slice(i);n.push({from:l.map(s.pos,-1),to:l.map(s.pos+1)})});let r=[];for(let s of n){let i=c0(e,s);i&&r.push(i)}r.sort((s,i)=>s.from-i.from);let o=[];for(let s of r){let i=o[o.length-1];i&&s.from<=i.to?i.to=Math.max(i.to,s.to):o.push({...s})}return{type:"ranges",ranges:o}}function vd(t,e,n,r){return t.map(e,n,{onRemove:o=>{let s=o?.key;typeof s=="string"&&r.delete(s)}})}function d0(t,e,n){var r,o;let s=(r=e.decorationSetsByExtension[t])!==null&&r!==void 0?r:B.empty,i=new Set((o=e.widgetKeysByExtension[t])!==null&&o!==void 0?o:[]);return{set:vd(s,n.mapping,n.doc,i),widgetKeys:i}}function Vu(t,e){let n=Object.values(e).flatMap(r=>r.find());return B.create(t,n)}function _u(t){let e=new Set;for(let n of Object.values(t))for(let r of n)e.add(r);return e}function f0(t,e){var n;switch((n=e.update)!==null&&n!==void 0?n:"document"){case"document":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${t}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case"changedRanges":if(!e.createInRange)throw new Error(`[tiptap error]: Extension "${t}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case"manual":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${t}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(e.shouldUpdate)throw new Error(`[tiptap error]: Extension "${t}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw new Error(`[tiptap error]: Extension "${t}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function h0(t,e,n){return n?!0:t.update==="manual"?!1:t.shouldUpdate?t.shouldUpdate(e):e.tr.docChanged}var p0=new Set;var m0=class{constructor(t){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{let n=rn.getState(e);n&&this.warnDuplicateWidgetKeys(n)},this.editor=t.editor,this.entries=this.resolveEntries(t.entries),this.entries.forEach(({name:e,spec:n})=>f0(e,n)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on("beforeTransaction",this.handleBeforeTransaction)}destroy(){this.editor.off("beforeTransaction",this.handleBeforeTransaction)}liveWidgetKeys(){var t,e;return(t=(e=rn.getState(this.editor.state))===null||e===void 0?void 0:e.widgetKeys)!==null&&t!==void 0?t:p0}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(t){let e=[];for(let{name:n,addDecorations:r}of t){let o=r();o&&e.push({name:n,spec:o})}return e}createPlugin(){let{editor:t,entries:e}=this;return new R({key:rn,state:{init:(n,r)=>{let o={},s={};for(let{name:l,spec:a}of e){let{set:c,widgetKeys:u}=this.buildFullSet(l,a,r);o[l]=c,s[l]=u}let i={decorationSetsByExtension:o,widgetKeysByExtension:s,mergedDecorationSet:this.buildMergedSet(r.doc,o),widgetKeys:_u(s)};return this.warnDuplicateWidgetKeys(i),i},apply:(n,r,o,s)=>{let i=n.getMeta(rn),l=i?.type==="force"&&!i.name,a=i?.type==="force"?i.name:void 0,c={},u={},d=new Set;return t0(t,()=>{for(let{name:f,spec:h}of e){let p=l||a===f;if(h0(h,{editor:t,tr:n,oldState:o,newState:s},p))if(h.update==="changedRanges"&&n.docChanged&&!p){let m=this.applyChangedRangesRecompute(f,h,r,n,s);c[f]=m.set,u[f]=m.widgetKeys,d.add(f)}else{let{set:m,widgetKeys:g}=this.buildFullSet(f,h,s);c[f]=m,u[f]=g,d.add(f)}else{let m=d0(f,r,n);c[f]=m.set,u[f]=m.widgetKeys}}}),d.size===0&&!n.docChanged?r:{decorationSetsByExtension:c,widgetKeysByExtension:u,mergedDecorationSet:this.mergeAfterApply({entries:e,previous:r,tr:n,decorationSetsByExtension:c,recomputedNames:d}),widgetKeys:_u(u)}}},props:{decorations(n){var r,o;return(r=(o=rn.getState(n))===null||o===void 0?void 0:o.mergedDecorationSet)!==null&&r!==void 0?r:B.empty}}})}applyChangedRangesRecompute(t,e,n,r,o){let s=u0(r,o.doc);return s.type==="full"?this.buildFullSet(t,e,o):this.rebuildRanges(t,e,n,r,o,s.ranges)}rebuildRanges(t,e,n,r,o,s){var i,l;let a=(i=n.decorationSetsByExtension[t])!==null&&i!==void 0?i:B.empty,c=new Set((l=n.widgetKeysByExtension[t])!==null&&l!==void 0?l:[]),u=vd(a,r.mapping,r.doc,c),d=o.doc.content.size;for(let{from:f,to:h}of s){let p=u.find(f,h).filter(y=>xd({position:y.from,from:f,to:h,docSize:d}));for(let y of p){let w=Cd(y);w&&c.delete(w)}u=u.remove(p);let{decorations:m,widgetKeys:g}=Sd(i0({decorations:this.runCreate(t,"createInRange",()=>e.createInRange({editor:this.editor,state:o,view:this.mountedView,from:f,to:h})),from:f,to:h,docSize:d,extensionName:t,warnedExtensions:this.warnedOutOfRangeExtensions}),t);u=u.add(o.doc,m);for(let y of g)c.add(y)}return{set:u,widgetKeys:c}}buildFullSet(t,e,n){let r=this.runCreate(t,"create",()=>e.create({editor:this.editor,state:n,view:this.mountedView}));return s0(n.doc,r,t)}runCreate(t,e,n){try{return n()}catch(r){return console.error(`[tiptap error]: Extension "${t}" threw in \`addDecorations().${e}()\`. Its decorations were dropped for this update.`,r),[]}}warnDuplicateWidgetKeys(t){if(!wd)return;if(t.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let e=l0(t.mergedDecorationSet),n=new Set(e.map(({key:r})=>r));for(let{key:r,extensions:o}of e){if(this.warnedWidgetKeys.has(r))continue;let s=Array.from(o).map(i=>`"${i}"`).join(", ");console.warn(`[tiptap warn]: Duplicate widget decoration key "${r}" in extension${o.size===1?"":"s"} ${s}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \`comment-\${id}\`).`)}this.warnedWidgetKeys=n}buildMergedSet(t,e){let n=Object.keys(e);return n.length===1?e[n[0]]:Vu(t,e)}mergeAfterApply({entries:t,previous:e,tr:n,decorationSetsByExtension:r,recomputedNames:o}){return t.length===1?r[t[0].name]:o.size===0?e.mergedDecorationSet.map(n.mapping,n.doc):Vu(n.doc,r)}};function Ad(t,e){let{selection:n}=t,{$from:r}=n;if(n instanceof v){let s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let o=r.depth;for(;o>=0;){let s=r.index(o);if(r.node(o).contentMatchAt(s).matchType(e))return!0;o-=1}return!1}function g0(t,e,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(r!==null)return r;let o=document.createElement("style");return e&&o.setAttribute("nonce",e),o.setAttribute(`data-tiptap-style${n?`-${n}`:""}`,""),o.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(o),o}function y0(t){return typeof t=="number"}function b0(t){return Object.prototype.toString.call(t).slice(8,-1)}function Gr(t){return b0(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Td(t){return typeof t=="string"&&t.trim().length>0&&!/[;{}]/.test(t)}function k0(t,e){return t.replace(/^[ \t]*/,n=>{let o=0;for(let s of n)o+=s===" "?4-o%4:1;return" ".repeat(Math.max(0,o-e))})}function w0(t,e){let n=`text
|
|
13
|
+
${t}
|
|
14
|
+
`,r=e(n)[0];return(r?.type==="paragraph"||r?.type==="text")&&r.raw===n}function S0(t,e,n){var r;let o=e.split(`
|
|
15
|
+
`),s=(r=n.isParagraphContinuation)!==null&&r!==void 0?r:(l=>w0(l,n.blockTokens)),i=0;for(let l of o){if(!l.trim()||!s(l))break;i+=1}return{mainContent:[t,...o.slice(0,i).map(l=>l.trimStart())].join(`
|
|
16
|
+
`),nestedContent:o.slice(i).join(`
|
|
17
|
+
`)}}function zi(t,e,n){let r=t.split(`
|
|
18
|
+
`),o=[],s="",i=0,l=e.baseIndentSize||2;for(;i<r.length;){let u=r[i],d=u.match(e.itemPattern);if(!d){if(o.length>0)break;if(u.trim()===""){i+=1,s=`${s}${u}
|
|
19
|
+
`;continue}else return}let f=e.extractItemData(d),{indentLevel:h,mainContent:p}=f;s=`${s}${u}
|
|
20
|
+
`;let m=[p];for(i+=1;i<r.length;){var a;let k=r[i];if(k.trim()===""){var c;let x=r.slice(i+1).findIndex(E=>E.trim()!=="");if(x===-1)break;if((((c=r[i+1+x].match(/^(\s*)/))===null||c===void 0||(c=c[1])===null||c===void 0?void 0:c.length)||0)>h){m.push(k),s=`${s}${k}
|
|
21
|
+
`,i+=1;continue}else break}if((((a=k.match(/^(\s*)/))===null||a===void 0||(a=a[1])===null||a===void 0?void 0:a.length)||0)>h)m.push(k),s=`${s}${k}
|
|
22
|
+
`,i+=1;else break}let g,y=m.slice(1);if(y.length>0){let k=S0(p,y.map(E=>k0(E,h+l)).join(`
|
|
23
|
+
`),n);f.mainContent=k.mainContent;let x=k.nestedContent;x.trim()&&(e.customNestedParser?g=e.customNestedParser(x):g=n.blockTokens(x))}let w=e.createToken(f,g);o.push(w)}if(o.length!==0)return{items:o,raw:s.slice(0,t.length)}}var Ku=4;function Uu(t){let e=0;for(let n of t)e=n===" "?e+Ku-e%Ku:e+1;return e}function Bi(t,e,n,r,o){if(!t||!Array.isArray(t.content))return"";let s=typeof n=="function"?n(r):n,[i,...l]=t.content,a=e.renderChildren([i]),c=`${s}${o?.indentMainContent?a.split(`
|
|
24
|
+
`).map((u,d)=>d===0?u:e.indent(u)).join(`
|
|
25
|
+
`):a}`;return l&&l.length>0&&l.forEach((u,d)=>{var f,h;let p=(f=(h=e.renderChild)===null||h===void 0?void 0:h.call(e,u,d+1))!==null&&f!==void 0?f:e.renderChildren([u]);if(p!=null){let m=y=>{if(!o?.alignNestedToPrefix)return e.indent(y);let w=e.indent(""),k=Uu(s);return(Uu(w)>=k?w:" ".repeat(k))+y},g=p.split(`
|
|
26
|
+
`).map(y=>m(y||"")).join(`
|
|
27
|
+
`);c+=u.type==="paragraph"?`
|
|
28
|
+
|
|
29
|
+
${g}`:`
|
|
30
|
+
${g}`}}),c}function Ed(t,e){let n={...t};return Gr(t)&&Gr(e)&&Object.keys(e).forEach(r=>{Gr(e[r])&&Gr(t[r])?n[r]=Ed(t[r],e[r]):n[r]=e[r]}),n}function x0(t,e,n={}){let{state:r}=e,{doc:o,tr:s}=r,i=t;o.descendants((l,a)=>{let c=s.mapping.map(a),u=s.mapping.map(a)+l.nodeSize,d=null;if(l.marks.forEach(h=>{if(h!==i)return!1;d=h}),!d)return;let f=!1;if(Object.keys(n).forEach(h=>{n[h]!==d.attrs[h]&&(f=!0)}),f){let h=t.type.create({...t.attrs,...n});s.removeMark(c,u,t.type),s.addMark(c,u,h)}}),s.docChanged&&e.view.dispatch(s)}var fn=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!==null&&e!==void 0?e:!0}},C0=(t,e)=>{if(Ti(e))return e.exec(t);let n=e(t);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function M0(t){let{editor:e,from:n,to:r,text:o,insertText:s}=t;if(!s)return{inputTransaction:null,tr:e.view.state.tr};let i=e.view.state.tr.insertText(o,n,r);return{inputTransaction:i,tr:Ct.create({doc:i.doc,selection:i.selection,storedMarks:i.storedMarks}).tr}}function v0(t){let{editor:e,from:n,to:r,text:o,rule:s,match:i,plugin:l,insertText:a}=t,{view:c}=e,{inputTransaction:u,tr:d}=M0({editor:e,from:n,to:r,text:o,insertText:a}),f=u?n+o.length:r,h=eo({state:c.state,transaction:d}),p={from:n-(i[0].length-o.length),to:f},{commands:m,chain:g,can:y}=new sn({editor:e,state:h});return s.handler({state:h,range:p,match:i,commands:m,chain:g,can:y})===null||!d.steps.length?!1:(u&&(c.dispatch(u),!c.state.doc.eq(u.doc))||(Mu(d),d.setMeta("inputRule",!0),s.undoable&&d.setMeta(l,{transform:d,from:n,to:f,text:o}),c.dispatch(d)),!0)}function A0(t,e,n){let r=e[0].length-n.length;if(r<=0)return!0;let o=t.parentOffset-r;return o>=0&&t.parent.textBetween(o,t.parentOffset)===e[0].slice(0,r)}function Xr(t){var e;let{editor:n,from:r,to:o,text:s,rules:i,plugin:l,insertText:a}=t,{view:c}=n;if(c.composing)return!1;let u=c.state.doc.resolve(r);if(u.parent.type.spec.code||!((e=u.nodeBefore||u.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let d=xy(u)+s;for(let f of i){let h=C0(d,f.find);if(!(!h||!A0(u,h,s))&&v0({editor:n,from:r,to:o,text:s,rule:f,match:h,plugin:l,insertText:a}))return!0}return!1}function T0(t){let{editor:e,rules:n}=t,r=new R({state:{init(){return null},apply(o,s,i){var l;let a=o.getMeta(r);if(a)return a;if(s&&(!((l=o.getMeta("appendedTransaction"))===null||l===void 0)&&l.getMeta(r))){let u=new Ke(s.transform.before);for(let d of[...s.transform.steps,...o.steps])u.step(d);return{...s,transform:u}}let c=o.getMeta("applyInputRules");return c&&setTimeout(()=>{let{text:u}=c;typeof u=="string"?u=u:u=Ri(b.from(u),i.schema);let{from:d}=c,f=d+u.length;Xr({editor:e,from:d,to:f,text:u,rules:n,plugin:r})}),o.selectionSet||o.docChanged?null:s}},props:{handleTextInput(o,s,i,l){return Xr({editor:e,from:s,to:i,text:l,rules:n,plugin:r,insertText:!0})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{let{$cursor:s}=o.state.selection;s&&Xr({editor:e,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(o,s){if(s.key!=="Enter")return!1;let{$cursor:i}=o.state.selection;return i?Xr({editor:e,from:i.pos,to:i.pos,text:`
|
|
31
|
+
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var $i=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...j(A(this,"addOptions",{name:this.name}))}}get storage(){return{...j(A(this,"addStorage",{name:this.name,options:this.options}))}}configure(t={}){let e=this.extend({...this.config,addOptions:()=>Ed(this.options,t)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(t={}){let e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},oe=class Nd extends $i{constructor(...e){super(...e),this.type="mark"}static create(e={}){let n=typeof e=="function"?e():e;return new Nd(n)}static handleExit({editor:e,mark:n}){let{tr:r}=e.state,o=e.state.selection.$from;if(o.pos===o.end()){let s=o.marks();if(!s.find(l=>l?.type.name===n.name))return!1;let i=s.find(l=>l?.type.name===n.name);return i&&r.removeStoredMark(i),r.insertText(" ",o.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}},Hi=class{constructor(t){this.find=t.find,this.handler=t.handler}},E0=(t,e,n)=>{if(Ti(e))return[...t.matchAll(e)];let r=e(t,n);return r?r.map(o=>{let s=[o.text];return s.index=o.index,s.input=t,s.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(o.replaceWith)),s}):[]};function N0(t){let{editor:e,state:n,from:r,to:o,rule:s,pasteEvent:i,dropEvent:l}=t,{commands:a,chain:c,can:u}=new sn({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,o,(f,h)=>{var p,m,g,y;if(!((p=f.type)===null||p===void 0||(p=p.spec)===null||p===void 0)&&p.code||!(f.isText||f.isTextblock||f.isInline))return;let w=(m=(g=(y=f.content)===null||y===void 0?void 0:y.size)!==null&&g!==void 0?g:f.nodeSize)!==null&&m!==void 0?m:0,k=Math.max(r,h),x=Math.min(o,h+w);if(k>=x)return;let E=f.isText?f.text||"":f.textBetween(k-h,x-h,void 0,"\uFFFC");E0(E,s.find,i).forEach(V=>{if(V.index===void 0)return;let W=k+V.index+1,O=W+V[0].length,P={from:n.tr.mapping.map(W),to:n.tr.mapping.map(O)},D=s.handler({state:n,range:P,match:V,commands:a,chain:c,can:u,pasteEvent:i,dropEvent:l});d.push(D)})}),d.every(f=>f!==null)}var nn=null,O0=t=>{var e;let n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)===null||e===void 0||e.setData("text/html",t),n};function R0(t){let{editor:e,rules:n}=t,r=null,o=!1,s=!1,i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}let a=({state:c,from:u,to:d,rule:f,pasteEvt:h})=>{let p=c.tr,m=eo({state:c,transaction:p});if(!(!N0({editor:e,state:m,from:Math.max(u-1,0),to:d.b-1,rule:f,pasteEvent:h,dropEvent:l})||!p.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,p}};return e.on("destroy",()=>{nn===e&&(nn=null)}),n.map(c=>new R({view(u){let d=h=>{var p;r=!((p=u.dom.parentElement)===null||p===void 0)&&p.contains(h.target)?u.dom.parentElement:null,r&&(nn=e)},f=()=>{nn&&(nn=null)};return window.addEventListener("dragstart",d),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",d),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(u,d)=>{if(s=r===u.dom.parentElement,l=d,!s){let f=nn;f?.isEditable&&setTimeout(()=>{if(f.isDestroyed)return;let h=f.state.selection;h&&f.commands.deleteRange({from:h.from,to:h.to})},10)}return!1},paste:(u,d)=>{var f;let h=(f=d.clipboardData)===null||f===void 0?void 0:f.getData("text/html");return i=d,o=!!h?.includes("data-pm-slice"),!1}}},appendTransaction:(u,d,f)=>{let h=u[0],p=h.getMeta("uiEvent")==="paste"&&!o,m=h.getMeta("uiEvent")==="drop"&&!s,g=h.getMeta("applyPasteRules"),y=!!g;if(!p&&!m&&!y)return;if(y){let{text:x}=g;typeof x=="string"?x=x:x=Ri(b.from(x),f.schema);let{from:E}=g,V=E+x.length,W=O0(x);return a({rule:c,state:f,from:E,to:{b:V},pasteEvt:W})}let w=d.doc.content.findDiffStart(f.doc.content),k=d.doc.content.findDiffEnd(f.doc.content);if(!(!y0(w)||!k||w===k.b))return a({rule:c,state:f,from:w,to:k,pasteEvt:i})}}))}var so=class{constructor(t,e){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=e,this.baseExtensions=t,this.extensions=Di(t),this.hasSchemaSpec=e.options.schemaSpec!==void 0,this.schema=ad(this.extensions,e,e.options.schemaSpec),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{let n=A(e,"addCommands",{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:tn(e.name,this.schema)});return n?{...t,...n()}:t},{})}get plugins(){let{editor:t}=this,e=qn([...this.extensions].reverse()).flatMap(r=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:tn(r.name,this.schema)},s=[],i=A(r,"addKeyboardShortcuts",o),l={};if(r.type==="mark"&&A(r,"exitable",o)&&(l.ArrowRight=()=>oe.handleExit({editor:t,mark:r})),i){let f=Object.fromEntries(Object.entries(i()).map(([h,p])=>[h,()=>p({editor:t})]));l={...l,...f}}let a=wu(l);s.push(a);let c=A(r,"addInputRules",o);if(Hu(r,t.options.enableInputRules)&&c){let f=c();if(f&&f.length){let h=T0({editor:t,rules:f}),p=Array.isArray(h)?h:[h];s.push(...p)}}let u=A(r,"addPasteRules",o);if(Hu(r,t.options.enablePasteRules)&&u){let f=u();if(f&&f.length){let h=R0({editor:t,rules:f});s.push(...h)}}let d=A(r,"addProseMirrorPlugins",o);if(d){let f=d();s.push(...f)}return s}),n=this.createDecorationPlugin();return n&&e.push(n),e}createDecorationPlugin(){var t;let{editor:e}=this;(t=this.decorationManager)===null||t===void 0||t.destroy();let n=[];return this.extensions.forEach(r=>{let o=A(r,"addDecorations",{name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:tn(r.name,this.schema)});o&&n.push({name:r.name,addDecorations:o})}),this.decorationManager=new m0({editor:e,entries:n}),this.decorationManager.plugin}get attributes(){let t=Ii(this.extensions);return this.hasSchemaSpec?id(t,this.schema):t}get nodeViews(){let{editor:t}=this,{nodeExtensions:e}=an(this.extensions);return Object.fromEntries(e.filter(n=>!!A(n,"addNodeView")).map(n=>{let r=this.attributes.filter(l=>l.type===n.name),o=A(n,"addNodeView",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:ee(n.name,this.schema)});if(!o)return[];let s=o();if(!s)return[];let i=(l,a,c,u,d)=>{let f=ct(l,r);return s({node:l,view:a,getPos:c,decorations:u,innerDecorations:d,editor:t,extension:n,HTMLAttributes:f})};return[n.name,i]}))}dispatchTransaction(t){let{editor:e}=this;return qn([...this.extensions].reverse()).reduceRight((n,r)=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:tn(r.name,this.schema)},s=A(r,"dispatchTransaction",o);return s?i=>{s.call(o,{transaction:i,next:n})}:n},t)}transformPastedHTML(t){let{editor:e}=this;return qn([...this.extensions]).reduce((n,r)=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:tn(r.name,this.schema)},s=A(r,"transformPastedHTML",o);return s?(i,l)=>{let a=n(i,l);return s.call(o,a)}:n},t||(n=>n))}get markViews(){let{editor:t}=this,{markExtensions:e}=an(this.extensions);return Object.fromEntries(e.filter(n=>!!A(n,"addMarkView")).map(n=>{let r=this.attributes.filter(i=>i.type===n.name),o=A(n,"addMarkView",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Xe(n.name,this.schema)});if(!o)return[];let s=(i,l,a)=>{let c=ct(i,r);return o()({mark:i,view:l,inline:a,editor:t,extension:n,HTMLAttributes:c,updateAttributes:u=>{x0(i,t,u)}})};return[n.name,s]}))}destroy(){var t;(t=this.decorationManager)===null||t===void 0||t.destroy(),this.extensions.forEach(e=>{let n=e;for(;n.parent;){let r=n.parent;r.child===n&&(r.child=null),n=r}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}setupExtensions(){let t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{let n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:tn(e.name,this.schema)};if(e.type==="mark"){var r,o;(!((r=j(A(e,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(e.name),!((o=j(A(e,"clearable",n)))!==null&&o!==void 0)||o||this.nonClearableMarks.push(e.name)}let s=A(e,"onBeforeCreate",n),i=A(e,"onCreate",n),l=A(e,"onUpdate",n),a=A(e,"onSelectionUpdate",n),c=A(e,"onTransaction",n),u=A(e,"onFocus",n),d=A(e,"onBlur",n),f=A(e,"onDestroy",n);s&&this.editor.on("beforeCreate",s),i&&this.editor.on("create",i),l&&this.editor.on("update",l),a&&this.editor.on("selectionUpdate",a),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};so.resolve=Di;so.sort=qn;so.flatten=Oi;var $=class Od extends $i{constructor(...e){super(...e),this.type="extension"}static create(e={}){let n=typeof e=="function"?e():e;return new Od(n)}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}},I0=$.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new R({key:new z("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:o}=e,s=ud(n),{blockSeparator:i}=this.options,l={...i!==void 0?{blockSeparator:i}:{},textSerializers:s};return[...o.ranges].sort((a,c)=>a.$from.pos-c.$from.pos).map(({$from:a,$to:c})=>cd(r,{from:a.pos,to:c.pos},l)).join(i??`
|
|
32
|
+
|
|
33
|
+
`)}}})]}}),D0=$.create({name:"commands",addCommands(){return{...e0}}}),L0=$.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r;let o=()=>{var s,i,l;if((s=(i=this.editor.options.coreExtensionOptions)===null||i===void 0||(i=i.delete)===null||i===void 0||(l=i.filterTransaction)===null||l===void 0?void 0:l.call(i,t))!==null&&s!==void 0?s:t.getMeta("y-sync$"))return;let a=Ni(t.before,[t,...e]);un(a).forEach(u=>{a.mapping.mapResult(u.oldRange.from).deletedAfter&&a.mapping.mapResult(u.oldRange.to).deletedBefore&&a.before.nodesBetween(u.oldRange.from,u.oldRange.to,(d,f)=>{let h=f+d.nodeSize-2,p=u.oldRange.from<=f&&h<=u.oldRange.to;this.editor.emit("delete",{type:"node",node:d,from:f,to:h,newFrom:a.mapping.map(f),newTo:a.mapping.map(h),deletedRange:u.oldRange,newRange:u.newRange,partial:!p,editor:this.editor,transaction:t,combinedTransform:a})})});let c=a.mapping;a.steps.forEach((u,d)=>{if(u instanceof Ie){var f,h;let p=c.slice(d).map(u.from,-1),m=c.slice(d).map(u.to),g=c.invert().map(p,-1),y=c.invert().map(m),w=p>0?(f=a.doc.nodeAt(p-1))===null||f===void 0?void 0:f.marks.some(x=>x.eq(u.mark)):!1,k=(h=a.doc.nodeAt(m))===null||h===void 0?void 0:h.marks.some(x=>x.eq(u.mark));this.editor.emit("delete",{type:"mark",mark:u.mark,from:u.from,to:u.to,deletedRange:{from:g,to:y},newRange:{from:p,to:m},partial:!!(k||w),editor:this.editor,transaction:t,combinedTransform:a})}})};!((n=(r=this.editor.options.coreExtensionOptions)===null||r===void 0||(r=r.delete)===null||r===void 0?void 0:r.async)!==null&&n!==void 0)||n?setTimeout(o,0):o()}}),P0=$.create({name:"drop",addProseMirrorPlugins(){return[new R({key:new z("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),z0=$.create({name:"editable",addProseMirrorPlugins(){return[new R({key:new z("editable"),props:{editable:()=>this.editor.options.editable}})]}}),B0=new z("focusEvents"),$0=$.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:t}=this;return[new R({key:B0,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;let r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;let r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}});function H0(t){let{empty:e,from:n,to:r}=t.selection;return e?!1:n===T.atStart(t.doc).from&&r===T.atEnd(t.doc).to}var F0=$.create({name:"keymap",addKeyboardShortcuts(){let t=()=>this.editor.commands.first(({commands:i})=>[()=>i.undoInputRule(),()=>i.command(({tr:l})=>{let{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:f,parent:h}=d,p=d.parent.isTextblock&&f>0?l.doc.resolve(f-1):d,m=p.parent.type.spec.isolating,g=d.pos-d.parentOffset,y=m&&p.parent.childCount===1?g===d.pos:T.atStart(c).from===f;return!u||!h.type.isTextblock||h.textContent.length||!y||y&&d.parent.type.name==="paragraph"?!1:i.clearNodes()}),()=>i.deleteSelection(),()=>i.joinBackward(),()=>i.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.deleteCurrentNode(),()=>i.joinForward(),()=>i.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},o={...r},s={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Zr()||rd()?s:o},addProseMirrorPlugins(){return[new R({key:new z("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(a=>a.getMeta("composition")))return;let r=t.some(a=>a.docChanged)&&!e.doc.eq(n.doc),o=t.some(a=>a.getMeta("preventClearDocument"));if(!r||o||!H0(e)||!dn(n.doc))return;let s=n.tr,i=eo({state:n,transaction:s}),{commands:l}=new sn({editor:this.editor,state:i});if(l.clearNodes(),!(!s.steps.length&&!n.storedMarks))return s.setStoredMarks(null)}})]}}),j0=$.create({name:"paste",addProseMirrorPlugins(){return[new R({key:new z("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),W0=$.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new R({key:new z("tabindex"),props:{attributes:()=>{var t;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(t=this.options.value)!==null&&t!==void 0?t:"0"}}}})]}}),V0=$.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:t}=an(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new R({key:new z("textDirection"),props:{attributes:()=>{let t=this.options.direction;return t?{dir:t}:{}}}})]}});var Ju=!1;function _0(t){if(Ju)return;Ju=!0;let e;try{let n=X.fromJSON(t,{from:0,to:0});if(!vy(n))return;e=n.slice.content}catch{return}e instanceof b||console.warn("[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.")}var K0=class Jn{get name(){return this.node.type.name}constructor(e,n,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=o}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;let e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new Jn(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Jn(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Jn(e,this.editor)}get children(){let e=[];return this.node.content.forEach((n,r)=>{let o=n.isBlock&&!n.isTextblock,s=n.isAtom&&!n.isText,i=n.isInline,l=this.pos+r+(s?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;let a=this.resolvedPos.doc.resolve(l);if(!o&&!i&&a.depth<=this.depth)return;let c=new Jn(a,this.editor,o,o||i?n:null);o&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,o=this.parent;for(;o&&!r;){if(o.node.type.name===e)if(Object.keys(n).length>0){let s=o.node.attrs,i=Object.keys(n);for(let l=0;l<i.length;l+=1){let a=i[l];if(s[a]!==n[a])break}}else r=o;o=o.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let o=[];if(!this.children||this.children.length===0)return o;let s=Object.keys(n);return this.children.forEach(i=>{r&&o.length>0||(i.node.type.name===e&&s.every(l=>n[l]===i.node.attrs[l])&&o.push(i),!(r&&o.length>0)&&(o=o.concat(i.querySelectorAll(e,n,r))))}),o}setAttribute(e){let{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},U0=`.ProseMirror {
|
|
34
|
+
position: relative;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.ProseMirror {
|
|
38
|
+
word-wrap: break-word;
|
|
39
|
+
white-space: pre-wrap;
|
|
40
|
+
white-space: break-spaces;
|
|
41
|
+
-webkit-font-variant-ligatures: none;
|
|
42
|
+
font-variant-ligatures: none;
|
|
43
|
+
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.ProseMirror [contenteditable="false"] {
|
|
47
|
+
white-space: normal;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
51
|
+
white-space: pre-wrap;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.ProseMirror pre {
|
|
55
|
+
white-space: pre-wrap;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
img.ProseMirror-separator {
|
|
59
|
+
display: inline !important;
|
|
60
|
+
border: none !important;
|
|
61
|
+
margin: 0 !important;
|
|
62
|
+
width: 0 !important;
|
|
63
|
+
height: 0 !important;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.ProseMirror-gapcursor {
|
|
67
|
+
display: none;
|
|
68
|
+
pointer-events: none;
|
|
69
|
+
position: absolute;
|
|
70
|
+
margin: 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.ProseMirror-gapcursor:after {
|
|
74
|
+
content: "";
|
|
75
|
+
display: block;
|
|
76
|
+
position: absolute;
|
|
77
|
+
top: -2px;
|
|
78
|
+
width: 20px;
|
|
79
|
+
border-top: 1px solid black;
|
|
80
|
+
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@keyframes ProseMirror-cursor-blink {
|
|
84
|
+
to {
|
|
85
|
+
visibility: hidden;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.ProseMirror-hideselection *::selection {
|
|
90
|
+
background: transparent;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.ProseMirror-hideselection *::-moz-selection {
|
|
94
|
+
background: transparent;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.ProseMirror-hideselection * {
|
|
98
|
+
caret-color: transparent;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
102
|
+
display: block;
|
|
103
|
+
}`,Xn=class extends r0{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:n})=>{throw n},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Ay,createMappablePosition:Ty},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:n,slice:r,moved:o})=>this.options.onDrop(n,r,o)),this.on("paste",({event:n,slice:r})=>this.options.onPaste(n,r)),this.on("delete",this.options.onDelete);let e=this.createDoc();if(!this.editorState){let n=Ci(e,this.options.autofocus);this.editorState=Ct.create({doc:e,schema:this.schema,selection:n||void 0})}_0(this.schema),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;let t=this.editorView.dom;t?.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager?this.commandManager.chain():sn.createFakeChain()}can(){return this.commandManager?this.commandManager.can():sn.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=g0(U0,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps({...this.options.editorProps,attributes:this.getEditorViewAttributes()}),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return wd&&!this.hasWarnedStaleDecorationRead&&n0(this)&&(this.hasWarnedStaleDecorationRead=!0,console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")),this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){let n=vi(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;let e=this.state.plugins,n=e;if([].concat(t).forEach(o=>{let s=typeof o=="string"?`${o}$`:o.key;n=n.filter(i=>!i.key.startsWith(s))}),e.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;let n=[...this.options.enableCoreExtensions?[z0,I0.configure({blockSeparator:(t=this.options.coreExtensionOptions)===null||t===void 0||(t=t.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),D0,$0,F0,W0.configure({value:(e=this.options.coreExtensionOptions)===null||e===void 0||(e=e.tabindex)===null||e===void 0?void 0:e.value}),P0,j0,L0,V0.configure({direction:this.options.textDirection})].filter(r=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[r.name]!==!1:!0):[],...this.options.extensions].filter(r=>["extension","node","mark"].includes(r?.type));this.extensionManager=new so(n,this)}createCommandManager(){this.commandManager=new sn({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Mi(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;let n=Mi(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=Ct.create({doc:n,schema:this.schema,selection:Ci(n,this.options.autofocus)||void 0}),this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(r=>r.name!=="collaboration"),this.createExtensionManager()}}),this.editorState.doc}return t}getEditorViewAttributes(){var t;let e=(t=this.options.editorProps)===null||t===void 0?void 0:t.attributes;return vi(e)?n=>({role:"textbox",...e(n)}):{role:"textbox",...e}}createView(t){let{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),o=n?this.extensionManager.dispatchTransaction(r):r,s=e.transformPastedHTML,i=this.extensionManager.transformPastedHTML(s);this.editorView=new _n(t,{...e,attributes:this.getEditorViewAttributes(),dispatchTransaction:o,transformPastedHTML:i,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();let a=this.view.dom;a.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;let e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var u;return(u=this.capturedTransaction)===null||u===void 0?void 0:u.step(c)});return}let{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),o=n.includes(t),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!o)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});let i=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=i?.getMeta("focus"),a=i?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:i}),a&&this.emit("blur",{editor:this,event:a.event,transaction:i}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Li(this.state,t)}isActive(t,e){let n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return Cy(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Ri(this.state.doc.content,this.schema)}getText(t){let{blockSeparator:e=`
|
|
104
|
+
|
|
105
|
+
`,textSerializers:n={}}=t||{};return by(this.state.doc,{blockSeparator:e,textSerializers:{...ud(this.schema),...n}})}get isEmpty(){return dn(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var t,e;return(t=(e=this.editorView)===null||e===void 0?void 0:e.isDestroyed)!==null&&t!==void 0?t:!0}$node(t,e){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelectorAll(t,e))||null}$pos(t){let e=this.state.doc.resolve(t),n=t>0&&e.nodeAfter&&!e.nodeAfter.isText&&e.nodeAfter.isAtom?e.nodeAfter:null;return new K0(e,this,!1,n)}get $doc(){return this.$pos(0)}};function ve(t){return new fn({find:t.find,handler:({state:e,range:n,match:r})=>{let o=j(t.getAttributes,void 0,r);if(o===!1||o===null)return null;let{tr:s}=e,i=r[r.length-1],l=r[0];if(i){let a=l.search(/\S/),c=n.from+l.indexOf(i),u=c+i.length;if(Gn(n.from,n.to,e.doc).filter(f=>f.mark.type.excluded.find(h=>h===t.type&&h!==f.mark.type)).filter(f=>f.to>c).length)return null;u<n.to&&s.delete(u,n.to),c>n.from&&s.delete(n.from+a,c);let d=n.from+a+i.length;s.addMark(n.from+a,d,t.type.create(o||{})),s.removeStoredMark(t.type)}},undoable:t.undoable})}function io(t){return new fn({find:t.find,handler:({state:e,range:n,match:r})=>{let o=j(t.getAttributes,void 0,r)||{},{tr:s}=e,i=n.from,l=n.to,a=t.type.create(o);if(r[1]){let c=i+r[0].lastIndexOf(r[1]);c>l?c=l:l=c+r[1].length;let u=r[0][r[0].length-1];s.insertText(u,i+r[0].length-1),s.replaceWith(c,l,a)}else if(r[0]){let c=t.type.isInline?i:i-1;s.insert(c,t.type.create(o)).delete(s.mapping.map(i),s.mapping.map(l))}s.scrollIntoView()},undoable:t.undoable})}function Yn(t){return new fn({find:t.find,handler:({state:e,range:n,match:r})=>{let o=e.doc.resolve(n.from),s=j(t.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,s)},undoable:t.undoable})}function ut(t){return new fn({find:t.find,handler:({state:e,range:n,match:r,chain:o})=>{let s=j(t.getAttributes,void 0,r)||{},i=e.tr.delete(n.from,n.to),l=i.doc.resolve(n.from).blockRange(),a=l&&Wt(l,t.type,s);if(!a)return null;if(i.wrap(l,a),t.keepMarks&&t.editor){let{selection:u,storedMarks:d}=e,{splittableMarks:f}=t.editor.extensionManager,h=d||u.$to.parentOffset&&u.$from.marks();if(h){let p=h.filter(m=>f.includes(m.type.name));i.ensureMarks(p)}}if(t.keepAttributes){let u=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(u,s).run()}let c=i.doc.resolve(n.from-1).nodeBefore;c&&c.type===t.type&&Ne(i.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,c))&&i.join(n.from-1)},undoable:t.undoable})}var J0=t=>"touches"in t,Rd=class{constructor(t){var e,n,r,o,s,i;this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleEditorUpdate=()=>{let l=this.editor.isEditable;l!==this.lastEditableState&&(this.lastEditableState=l,l?l&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())},this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.clientX-this.startX,c=l.clientY-this.startY;this.handleResize(a,c)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.touches[0];if(!a)return;let c=a.clientX-this.startX,u=a.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;let l=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(l,a),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)},this.node=t.node,this.editor=t.editor,this.element=t.element,this.element.draggable=!1,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,!((e=t.options)===null||e===void 0)&&e.min&&(this.minSize={...this.minSize,...t.options.min}),!((n=t.options)===null||n===void 0)&&n.max&&(this.maxSize=t.options.max),!(t==null||(r=t.options)===null||r===void 0)&&r.directions&&(this.directions=t.options.directions),!((o=t.options)===null||o===void 0)&&o.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),!((s=t.options)===null||s===void 0)&&s.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),!((i=t.options)===null||i===void 0)&&i.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate)}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!==null&&t!==void 0?t:null}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate),this.container.remove()}createContainer(){let t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display=this.node.type.isInline?"inline-flex":"flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){let t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){let e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){let n=e.includes("top"),r=e.includes("bottom"),o=e.includes("left"),s=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),o&&(t.style.left="0"),s&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){let t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,J0(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;let n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:o}=this.calculateNewDimensions(this.activeHandle,t,e),s=this.applyConstraints(r,o,n);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,o=this.startHeight,s=t.includes("right"),i=t.includes("left"),l=t.includes("bottom"),a=t.includes("top");return s?r=this.startWidth+e:i&&(r=this.startWidth-e),l?o=this.startHeight+n:a&&(o=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(s?e:-e)),(t==="top"||t==="bottom")&&(o=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,o,t):{width:r,height:o}}applyConstraints(t,e,n){var r,o;if(!n){var s,i;let c=Math.max(this.minSize.width,t),u=Math.max(this.minSize.height,e);return!((s=this.maxSize)===null||s===void 0)&&s.width&&(c=Math.min(this.maxSize.width,c)),!((i=this.maxSize)===null||i===void 0)&&i.height&&(u=Math.min(this.maxSize.height,u)),{width:c,height:u}}let l=t,a=e;return l<this.minSize.width&&(l=this.minSize.width,a=l/this.aspectRatio),a<this.minSize.height&&(a=this.minSize.height,l=a*this.aspectRatio),!((r=this.maxSize)===null||r===void 0)&&r.width&&l>this.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),!((o=this.maxSize)===null||o===void 0)&&o.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(t,e,n){let r=n==="left"||n==="right",o=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:o?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};var H=class Id extends $i{constructor(...e){super(...e),this.type="node"}static create(e={}){let n=typeof e=="function"?e():e;return new Id(n)}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}};function we(t){return new Hi({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:o})=>{let s=j(t.getAttributes,void 0,r,o);if(s===!1||s===null)return null;let{tr:i}=e,l=r[r.length-1],a=r[0],c=n.to;if(l){let u=a.search(/\S/),d=n.from+a.indexOf(l),f=d+l.length;if(Gn(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(p=>p===t.type&&p!==h.mark.type)).filter(h=>h.to>d).length)return null;f<n.to&&i.delete(f,n.to),d>n.from&&i.delete(n.from+u,d),c=n.from+u+l.length,i.addMark(n.from+u,c,t.type.create(s||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||i.removeStoredMark(t.type)}}})}var Dd=new WeakSet,Ld=new WeakSet;function It(t){let e=t;return Dd.add(e),e}function Fi(t){return Array.isArray(t)&&Dd.has(t)}function Pd(t){return t.flatMap(e=>e==null?[]:Array.isArray(e)&&Ld.has(e)&&!Fi(e)?Pd(e):[e])}function q0(t,e){if(t==="slot")return 0;if(t instanceof Function){let o=t(e);return Array.isArray(o)&&!Fi(o)&&!Ld.has(o)?It(o):o}let{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");if(Array.isArray(n)){if(Fi(n))return It([t,r,n]);if(n.length===0)return It([t,r]);let o=Pd(n);return o.length===0?It([t,r]):It([t,r,...o])}return n!=null?It([t,r,n]):It([t,r])}var hn=(t,e)=>q0(t,e);var G0=(t,e)=>{var n;let{state:r}=t,{selection:o}=r;if(!o.empty)return!1;let{$from:s}=o;if(s.parentOffset!==0)return!1;let i=s.depth-1;if(i<0)return!1;let l=s.node(i),a=s.index(i);if(a===0)return!1;if(l.type===e)return t.commands.lift(e.name);let c=l.child(a-1);if(c.type!==e||!(!((n=c.lastChild)===null||n===void 0)&&n.isTextblock))return!1;let u=s.before()-1-1;return t.commands.command(({tr:d,dispatch:f})=>{if(!f)return!0;let h=s.parent.content,p=new C(h,0,0);return d.replace(u,s.after(),p),d.setSelection(M.create(d.doc,u)),d.scrollIntoView(),f(d),!0})},X0=/^\s*>\s$/,zd=H.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return hn("blockquote",{...I(this.options.HTMLAttributes,t),children:hn("slot",{})})},parseMarkdown:(t,e)=>{var n;let r=(n=e.parseBlockChildren)!==null&&n!==void 0?n:e.parseChildren;return e.createNode("blockquote",void 0,r(t.tokens||[]))},renderMarkdown:(t,e)=>{if(!t.content)return"";let n=">",r=[];return t.content.forEach((o,s)=>{var i,l;let a=((i=(l=e.renderChild)===null||l===void 0?void 0:l.call(e,o,s))!==null&&i!==void 0?i:e.renderChildren([o])).split(`
|
|
106
|
+
`).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(a.join(`
|
|
107
|
+
`))}),r.join(`
|
|
108
|
+
${n}
|
|
109
|
+
`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>G0(this.editor,this.type)}},addInputRules(){return[ut({find:X0,type:this.type})]}});var Y0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Q0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Z0=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,eb=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Bd=oe.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return hn("strong",{...I(this.options.HTMLAttributes,t),children:hn("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[ve({find:Y0,type:this.type}),ve({find:Z0,type:this.type})]},addPasteRules(){return[we({find:Q0,type:this.type}),we({find:eb,type:this.type})]}});var tb=t=>{let e=/`([^`]+)`(?!`)$/.exec(t);return!e||e.index>0&&t[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},nb=t=>{let e=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=e.exec(t))!==null;)r.index>0&&t[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n};function rb(t){let e=new Set((t.match(/`+/g)||[]).map(r=>r.length)),n=1;for(;e.has(n);)n+=1;return n}var $d=oe.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",I(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e,n)=>{var r;if(!t.content)return"";let o=typeof(n==null||(r=n.meta)===null||r===void 0?void 0:r.markText)=="string"?n.meta.markText:"",s="`".repeat(rb(o)),i=o.startsWith("`")||o.endsWith("`")?" ":"";return`${s}${i}${e.renderChildren(t.content)}${i}${s}`},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[ve({find:tb,type:this.type})]},addPasteRules(){return[we({find:nb,type:this.type})]}});var ji=4,ob=/^```([a-z]+)?[\s\n]$/,sb=/^~~~([a-z]+)?[\s\n]$/,Wi=H.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:ji,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;let{languageClassPrefix:n}=this.options;if(!n)return null;let r=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return r||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",I(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)===null||n===void 0?void 0:n.startsWith("```"))===!1&&((r=t.raw)===null||r===void 0?void 0:r.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="",o=((n=t.attrs)===null||n===void 0?void 0:n.language)||"";return t.content?r=[`\`\`\`${o}`,e.renderChildren(t.content),"```"].join(`
|
|
110
|
+
`):r=`\`\`\`${o}
|
|
111
|
+
|
|
112
|
+
\`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;let n=(e=this.options.tabSize)!==null&&e!==void 0?e:ji,{state:r}=t,{selection:o}=r,{$from:s,empty:i}=o;if(s.parent.type!==this.type)return!1;let l=" ".repeat(n);return i?t.commands.insertContent(l):t.commands.command(({tr:a})=>{let{from:c,to:u}=o,d=r.doc.textBetween(c,u,`
|
|
113
|
+
`,`
|
|
114
|
+
`).split(`
|
|
115
|
+
`).map(f=>l+f).join(`
|
|
116
|
+
`);return a.replaceWith(c,u,r.schema.text(d)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;let n=(e=this.options.tabSize)!==null&&e!==void 0?e:ji,{state:r}=t,{selection:o}=r,{$from:s,empty:i}=o;return s.parent.type!==this.type?!1:i?t.commands.command(({tr:l})=>{var a;let{pos:c}=s,u=s.start(),d=s.end(),f=r.doc.textBetween(u,d,`
|
|
117
|
+
`,`
|
|
118
|
+
`).split(`
|
|
119
|
+
`),h=0,p=0,m=c-u;for(let k=0;k<f.length;k+=1){if(p+f[k].length>=m){h=k;break}p+=f[k].length+1}let g=((a=f[h].match(/^ */))===null||a===void 0?void 0:a[0])||"",y=Math.min(g.length,n);if(y===0)return!0;let w=u;for(let k=0;k<h;k+=1)w+=f[k].length+1;return l.delete(w,w+y),c-w<=y&&l.setSelection(M.create(l.doc,w)),!0}):t.commands.command(({tr:l})=>{let{from:a,to:c}=o,u=r.doc.textBetween(a,c,`
|
|
120
|
+
`,`
|
|
121
|
+
`).split(`
|
|
122
|
+
`).map(d=>{var f;let h=((f=d.match(/^ */))===null||f===void 0?void 0:f[0])||"",p=Math.min(h.length,n);return d.slice(p)}).join(`
|
|
123
|
+
`);return l.replaceWith(a,c,r.schema.text(u)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:e}=t,{selection:n}=e,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type)return!1;let s=r.parentOffset===r.parent.nodeSize-2,i=r.parent.textContent.endsWith(`
|
|
124
|
+
|
|
125
|
+
`);return!s||!i?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:t})=>{if(!this.options.exitOnArrowUp)return!1;let{state:e}=t,{selection:n}=e,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type||r.parentOffset!==0)return!1;let s=r.before();return s>0?!1:t.commands.insertDefaultBlock({pos:s})},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;let{state:e}=t,{selection:n,doc:r}=e,{$from:o,empty:s}=n;if(!s||o.parent.type!==this.type||o.parentOffset!==o.parent.nodeSize-2)return!1;let i=o.after();return i===void 0?!1:r.nodeAt(i)?t.commands.command(({tr:l})=>(l.setSelection(T.near(r.resolve(i))),!0)):t.commands.exitCode()}}},addInputRules(){return[Yn({find:ob,type:this.type,getAttributes:t=>({language:t[1]})}),Yn({find:sb,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new R({key:new z("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;let n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),o=r?JSON.parse(r):void 0,s=o?.mode;if(!n||!s)return!1;let{tr:i,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,`
|
|
126
|
+
`));return i.replaceSelectionWith(this.type.create({language:s},a)),i.selection.$from.parent.type!==this.type&&i.setSelection(M.near(i.doc.resolve(Math.max(0,i.selection.from-2)))),i.setMeta("paste",!0),t.dispatch(i),!0}}})]}}),Vi=Wi;var Hd=H.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
127
|
+
|
|
128
|
+
`):""});var Fd=H.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",I(this.options.HTMLAttributes,t)]},renderText(){return`
|
|
129
|
+
`},renderMarkdown:()=>`
|
|
130
|
+
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{let{selection:o,storedMarks:s}=n;if(o.$from.parent.type.spec.isolating)return!1;let{keepMarks:i}=this.options,{splittableMarks:l}=r.extensionManager,a=s||o.$to.parentOffset&&o.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&i){let d=a.filter(f=>l.includes(f.type.name));c.ensureMarks(d)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var jd=H.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(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,I(this.options.HTMLAttributes,e),0]},parseMarkdown(t,e){let n=t.depth||1;return this.options.levels.includes(n)?e.createNode("heading",{level:n},e.parseInline(t.tokens||[])):e.createNode("paragraph",void 0,e.parseInline(t.tokens||[]))},renderMarkdown:(t,e)=>{var n;let r=!((n=t.attrs)===null||n===void 0)&&n.level?parseInt(t.attrs.level,10):1,o="#".repeat(r);return t.content?`${o} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Yn({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var Wd=H.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",I(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!Ad(e,e.schema.nodes[this.name]))return!1;let{selection:n}=e,{$to:r}=n,o=t();return oo(n)?o.insertContentAt(r.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({state:s,tr:i,dispatch:l})=>{if(l){let{$to:a}=i.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?i.setSelection(M.create(i.doc,a.pos+1)):a.nodeAfter.isBlock?i.setSelection(v.create(i.doc,a.pos)):i.setSelection(M.create(i.doc,a.pos));else{let u=s.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,d=u?.create();d&&(i.insert(c,d),i.setSelection(M.create(i.doc,c+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[io({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var ib=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,lb=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,ab=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,cb=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Vd=oe.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",I(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ve({find:ib,type:this.type}),ve({find:ab,type:this.type})]},addPasteRules(){return[we({find:lb,type:this.type}),we({find:cb,type:this.type})]}});var ub="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos6kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12b0cam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",db="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",Gi="numeric",Xi="ascii",Yi="alpha",Zn="asciinumeric",Qn="alphanumeric",Qi="domain",Gd="emoji",fb="scheme",hb="slashscheme",_i="whitespace";function pb(t,e){return t in e||(e[t]=[]),e[t]}function Lt(t,e,n){e[Gi]&&(e[Zn]=!0,e[Qn]=!0),e[Xi]&&(e[Zn]=!0,e[Yi]=!0),e[Zn]&&(e[Qn]=!0),e[Yi]&&(e[Qn]=!0),e[Qn]&&(e[Qi]=!0),e[Gd]&&(e[Qi]=!0);for(let r in e){let o=pb(r,n);o.indexOf(t)<0&&o.push(t)}}function mb(t,e){let n={};for(let r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function be(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}be.groups={};be.prototype={accepts(){return!!this.t},go(t){let e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){let o=e.jr[r][0],s=e.jr[r][1];if(s&&o.test(t))return s}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let o=0;o<t.length;o++)this.tt(t[o],e,n,r)},tr(t,e,n,r){r=r||be.groups;let o;return e&&e.j?o=e:(o=new be(e),n&&r&&Lt(e,n,r)),this.jr.push([t,o]),o},ts(t,e,n,r){let o=this,s=t.length;if(!s)return o;for(let i=0;i<s-1;i++)o=o.tt(t[i]);return o.tt(t[s-1],e,n,r)},tt(t,e,n,r){r=r||be.groups;let o=this;if(e&&e.j)return o.j[t]=e,e;let s=e,i,l=o.go(t);if(l?(i=new be,Object.assign(i.j,l.j),i.jr.push.apply(i.jr,l.jr),i.jd=l.jd,i.t=l.t):i=new be,s){if(r)if(i.t&&typeof i.t=="string"){let a=Object.assign(mb(i.t,r),n);Lt(s,a,r)}else n&&Lt(s,n,r);i.t=s}return o.j[t]=i,i}};var L=(t,e,n,r,o)=>t.ta(e,n,r,o),J=(t,e,n,r,o)=>t.tr(e,n,r,o),_d=(t,e,n,r,o)=>t.ts(e,n,r,o),S=(t,e,n,r,o)=>t.tt(e,n,r,o),Ze="WORD",Zi="UWORD",Xd="ASCIINUMERICAL",Yd="ALPHANUMERICAL",or="LOCALHOST",el="TLD",tl="UTLD",uo="SCHEME",pn="SLASH_SCHEME",rl="NUM",nl="WS",ol="NL",er="OPENBRACE",tr="CLOSEBRACE",ho="OPENBRACKET",po="CLOSEBRACKET",mo="OPENPAREN",go="CLOSEPAREN",yo="OPENANGLEBRACKET",bo="CLOSEANGLEBRACKET",ko="FULLWIDTHLEFTPAREN",wo="FULLWIDTHRIGHTPAREN",So="LEFTCORNERBRACKET",xo="RIGHTCORNERBRACKET",Co="LEFTWHITECORNERBRACKET",Mo="RIGHTWHITECORNERBRACKET",vo="FULLWIDTHLESSTHAN",Ao="FULLWIDTHGREATERTHAN",To="AMPERSAND",Eo="APOSTROPHE",No="ASTERISK",ft="AT",Oo="BACKSLASH",Ro="BACKTICK",Io="CARET",Pt="COLON",sl="COMMA",Do="DOLLAR",He="DOT",Lo="EQUALS",il="EXCLAMATION",Te="HYPHEN",nr="PERCENT",Po="PIPE",zo="PLUS",gn="POUND",Dt="QUERY",ll="QUOTE",Qd="FULLWIDTHMIDDLEDOT",al="SEMI",Fe="SLASH",rr="TILDE",Bo="UNDERSCORE",Zd="EMOJI",$o="SYM",ef=Object.freeze({__proto__:null,ALPHANUMERICAL:Yd,AMPERSAND:To,APOSTROPHE:Eo,ASCIINUMERICAL:Xd,ASTERISK:No,AT:ft,BACKSLASH:Oo,BACKTICK:Ro,CARET:Io,CLOSEANGLEBRACKET:bo,CLOSEBRACE:tr,CLOSEBRACKET:po,CLOSEPAREN:go,COLON:Pt,COMMA:sl,DOLLAR:Do,DOT:He,EMOJI:Zd,EQUALS:Lo,EXCLAMATION:il,FULLWIDTHGREATERTHAN:Ao,FULLWIDTHLEFTPAREN:ko,FULLWIDTHLESSTHAN:vo,FULLWIDTHMIDDLEDOT:Qd,FULLWIDTHRIGHTPAREN:wo,HYPHEN:Te,LEFTCORNERBRACKET:So,LEFTWHITECORNERBRACKET:Co,LOCALHOST:or,NL:ol,NUM:rl,OPENANGLEBRACKET:yo,OPENBRACE:er,OPENBRACKET:ho,OPENPAREN:mo,PERCENT:nr,PIPE:Po,PLUS:zo,POUND:gn,QUERY:Dt,QUOTE:ll,RIGHTCORNERBRACKET:xo,RIGHTWHITECORNERBRACKET:Mo,SCHEME:uo,SEMI:al,SLASH:Fe,SLASH_SCHEME:pn,SYM:$o,TILDE:rr,TLD:el,UNDERSCORE:Bo,UTLD:tl,UWORD:Zi,WORD:Ze,WS:nl}),Ye=/[a-z]/,mn=/[a-z]/i,fo=/[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}]|\u{FE0F}/u;try{mn=new RegExp("\\p{L}","u"),fo=new RegExp("\\p{Emoji}","u")}catch{}var Qe=/\d/,Ki=/\s/;var Kd="\r",Ui=`
|
|
131
|
+
`,gb="\uFE0F",yb="\u200D",Ji="\uFFFC",lo=null,ao=null;function bb(t=[]){let e={};be.groups=e;let n=new be;lo==null&&(lo=Ud(ub)),ao==null&&(ao=Ud(db)),S(n,"'",Eo),S(n,"{",er),S(n,"}",tr),S(n,"[",ho),S(n,"]",po),S(n,"(",mo),S(n,")",go),S(n,"<",yo),S(n,">",bo),S(n,"\uFF08",ko),S(n,"\uFF09",wo),S(n,"\u300C",So),S(n,"\u300D",xo),S(n,"\u300E",Co),S(n,"\u300F",Mo),S(n,"\uFF1C",vo),S(n,"\uFF1E",Ao),S(n,"&",To),S(n,"*",No),S(n,"@",ft),S(n,"`",Ro),S(n,"^",Io),S(n,":",Pt),S(n,",",sl),S(n,"$",Do),S(n,".",He),S(n,"=",Lo),S(n,"!",il),S(n,"-",Te),S(n,"%",nr),S(n,"|",Po),S(n,"+",zo),S(n,"#",gn),S(n,"?",Dt),S(n,'"',ll),S(n,"/",Fe),S(n,";",al),S(n,"~",rr),S(n,"_",Bo),S(n,"\\",Oo),S(n,"\u30FB",Qd);let r=J(n,Qe,rl,{[Gi]:!0});J(r,Qe,r);let o=J(r,Ye,Xd,{[Zn]:!0}),s=J(r,mn,Yd,{[Qn]:!0}),i=J(n,Ye,Ze,{[Xi]:!0});J(i,Qe,o),J(i,Ye,i),J(o,Qe,o),J(o,Ye,o);let l=J(n,mn,Zi,{[Yi]:!0});J(l,Ye),J(l,Qe,s),J(l,mn,l),J(s,Qe,s),J(s,Ye),J(s,mn,s);let a=S(n,Ui,ol,{[_i]:!0}),c=S(n,Kd,nl,{[_i]:!0}),u=J(n,Ki,nl,{[_i]:!0});S(n,Ji,u),S(c,Ui,a),S(c,Ji,u),J(c,Ki,u),S(u,Kd),S(u,Ui),J(u,Ki,u),S(u,Ji,u);let d=J(n,fo,Zd,{[Gd]:!0});S(d,"#"),J(d,fo,d),S(d,gb,d);let f=S(d,yb);S(f,"#"),J(f,fo,d);let h=[[Ye,i],[Qe,o]],p=[[Ye,null],[mn,l],[Qe,s]];for(let m=0;m<lo.length;m++)dt(n,lo[m],el,Ze,h);for(let m=0;m<ao.length;m++)dt(n,ao[m],tl,Zi,p);Lt(el,{tld:!0,ascii:!0},e),Lt(tl,{utld:!0,alpha:!0},e),dt(n,"file",uo,Ze,h),dt(n,"mailto",uo,Ze,h),dt(n,"http",pn,Ze,h),dt(n,"https",pn,Ze,h),dt(n,"ftp",pn,Ze,h),dt(n,"ftps",pn,Ze,h),Lt(uo,{scheme:!0,ascii:!0},e),Lt(pn,{slashscheme:!0,ascii:!0},e),t=t.sort((m,g)=>m[0]>g[0]?1:-1);for(let m=0;m<t.length;m++){let g=t[m][0],w=t[m][1]?{[fb]:!0}:{[hb]:!0};g.indexOf("-")>=0?w[Qi]=!0:Ye.test(g)?Qe.test(g)?w[Zn]=!0:w[Xi]=!0:w[Gi]=!0,_d(n,g,g,w)}return _d(n,"localhost",or,{ascii:!0}),n.jd=new be($o),{start:n,tokens:Object.assign({groups:e},ef)}}function tf(t,e){let n=kb(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,o=[],s=0,i=0;for(;i<r;){let l=t,a=null,c=0,u=null,d=-1,f=-1;for(;i<r&&(a=l.go(n[i]));)l=a,l.accepts()?(d=0,f=0,u=l):d>=0&&(d+=n[i].length,f++),c+=n[i].length,s+=n[i].length,i++;s-=d,i-=f,c-=d,o.push({t:u.t,v:e.slice(s-c,s),s:s-c,e:s})}return o}function kb(t){let e=[],n=t.length,r=0;for(;r<n;){let o=t.charCodeAt(r),s,i=o<55296||o>56319||r+1===n||(s=t.charCodeAt(r+1))<56320||s>57343?t[r]:t.slice(r,r+2);e.push(i),r+=i.length}return e}function dt(t,e,n,r,o){let s,i=e.length;for(let l=0;l<i-1;l++){let a=e[l];t.j[a]?s=t.j[a]:(s=new be(r),s.jr=o.slice(),t.j[a]=s),t=s}return s=new be(n),s.jr=o.slice(),t.j[e[i-1]]=s,s}function Ud(t){let e=[],n=[],r=0,o="0123456789";for(;r<t.length;){let s=0;for(;o.indexOf(t[r+s])>=0;)s++;if(s>0){e.push(n.join(""));for(let i=parseInt(t.substring(r,r+s),10);i>0;i--)n.pop();r+=s}else n.push(t[r]),r++}return e}var sr={defaultProtocol:"http",events:null,format:Jd,formatHref:Jd,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],ignoreClasses:[],render:null};function cl(t,e=null){let n=Object.assign({},sr);t&&(n=Object.assign(n,t instanceof cl?t.o:t));let r=n.ignoreTags,o=[];for(let s=0;s<r.length;s++)o.push(r[s].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=o,this.ignoreClasses=n.ignoreClasses.slice()}cl.prototype={o:sr,ignoreTags:[],ignoreClasses:[],isIgnoredClass(t){if(typeof t!="string"||this.ignoreClasses.length===0)return!1;let e=t.split(/\s+/);for(let n=0;n<e.length;n++)if(this.ignoreClasses.indexOf(e[n])>=0)return!0;return!1},defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){let r=e!=null,o=this.o[t];return o&&(typeof o=="object"?(o=n.t in o?o[n.t]:sr[t],typeof o=="function"&&r&&(o=o(e,n))):typeof o=="function"&&r&&(o=o(e,n.t,n)),o)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){let e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function Jd(t){return t}function nf(t,e){this.t="token",this.v=t,this.tk=e}nf.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){let e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"\u2026":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=sr.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){let e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),o=t.get("tagName",n,e),s=this.toFormattedString(t),i={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),d=t.getObj("events",n,e);return i.href=r,l&&(i.class=l),a&&(i.target=a),c&&(i.rel=c),u&&Object.assign(i,u),{tagName:o,attributes:i,content:s,eventListeners:d}}};function Ho(t,e){class n extends nf{constructor(o,s){super(o,s),this.t=t}}for(let r in e)n.prototype[r]=e[r];return n.t=t,n}var wb=Ho("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),qd=Ho("text"),Sb=Ho("nl"),co=Ho("url",{isLink:!0,toHref(t=sr.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){let t=this.tk;return t.length>=2&&t[0].t!==or&&t[1].t===Pt}});var Ae=t=>new be(t);function xb({groups:t}){let e=t.domain.concat([To,No,ft,Oo,Ro,Io,Do,Lo,Te,rl,nr,Po,zo,gn,Fe,$o,rr,Bo]),n=[Eo,Pt,sl,He,il,nr,Dt,ll,al,yo,bo,er,tr,po,ho,mo,go,ko,wo,So,xo,Co,Mo,vo,Ao],r=[To,Eo,No,Oo,Ro,Io,Do,Lo,Te,er,tr,nr,Po,zo,gn,Dt,Fe,$o,rr,Bo],o=Ae(),s=S(o,rr);L(s,r,s),L(s,t.domain,s);let i=Ae(),l=Ae(),a=Ae();L(o,t.domain,i),L(o,t.scheme,l),L(o,t.slashscheme,a),L(i,r,s),L(i,t.domain,i);let c=S(i,ft);S(s,ft,c),S(l,ft,c),S(a,ft,c);let u=S(s,He);L(u,r,s),L(u,t.domain,s);let d=Ae();L(c,t.domain,d),L(d,t.domain,d);let f=S(d,He);L(f,t.domain,d);let h=Ae(wb);L(f,t.tld,h),L(f,t.utld,h),S(c,or,h);let p=S(d,Te);S(p,Te,p),L(p,t.domain,d),L(h,t.domain,d),S(h,He,f),S(h,Te,p);let m=S(i,Te),g=S(i,He);S(m,Te,m),L(m,t.domain,i),L(g,r,s),L(g,t.domain,i);let y=Ae(co);L(g,t.tld,y),L(g,t.utld,y),L(y,t.domain,i),L(y,r,s),S(y,He,g),S(y,Te,m),S(y,ft,c);let w=S(y,Pt),k=Ae(co);L(w,t.numeric,k);let x=Ae(co),E=Ae();L(x,e,x),L(x,n,E),L(E,e,x),L(E,n,E),S(y,Fe,x),S(k,Fe,x),S(y,Dt,E),S(y,gn,x),S(k,Dt,E),S(k,gn,x);let V=S(l,Pt),W=S(a,Pt),O=S(W,Fe),P=S(O,Fe);L(l,t.domain,i),S(l,He,g),S(l,Te,m),L(a,t.domain,i),S(a,He,g),S(a,Te,m),L(V,t.domain,x),S(V,Fe,x),S(V,Dt,x),L(P,t.domain,x),L(P,e,x),S(P,Fe,x);let D=[[er,tr],[ho,po],[mo,go],[yo,bo],[ko,wo],[So,xo],[Co,Mo],[vo,Ao]];for(let xe=0;xe<D.length;xe++){let[pt,mt]=D[xe],de=S(x,pt);S(E,pt,de);let ye=Ae(co);L(de,e,ye);let fe=Ae();L(de,n,fe),S(de,mt,x),L(ye,e,ye),L(ye,n,fe),L(fe,e,ye),L(fe,n,fe),S(ye,mt,x),S(fe,mt,x)}return S(o,or,y),S(o,ol,Sb),{start:o,tokens:ef}}function Cb(t,e,n){let r=n.length,o=0,s=[],i=[],l=[];for(;o<r;){let a=t,c=null,u=null,d=0,f=null,h=-1,p=[];for(;o<r&&!(c=a.go(n[o].t));)i.push(n[o++]);for(;o<r&&(u=c||a.go(n[o].t));)if(c=null,a=u,o++,d++,a.accepts())h=0,f=a,p=[];else if(h>=0&&h++,p.push(a),l[o]&&l[o].has(a))break;for(let m=0,g=o-p.length+1;m<p.length;m++,g++)(l[g]||(l[g]=new Set)).add(p[m]);if(h<0)o-=d,o<r&&(i.push(n[o]),o++);else{i.length>0&&(s.push(qi(qd,e,i)),i=[]),o-=h,d-=h;let m=f.t,g=n.slice(o-d,o);s.push(qi(m,e,g))}}return i.length>0&&s.push(qi(qd,e,i)),s}function qi(t,e,n){let r=n[0].s,o=n[n.length-1].e,s=e.slice(r,o);return new t(s,n)}var Mb=typeof console<"u"&&console&&console.warn||(()=>{}),vb="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",K={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function rf(){return be.groups={},K.scanner=null,K.parser=null,K.tokenQueue=[],K.pluginQueue=[],K.customSchemes=[],K.initialized=!1,K}function ul(t,e=!1){if(K.initialized&&Mb(`linkifyjs: already initialized - will not register custom scheme "${t}" ${vb}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
|
|
132
|
+
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
133
|
+
2. Cannot start or end with "-"
|
|
134
|
+
3. "-" cannot repeat`);K.customSchemes.push([t,e])}function Ab(){K.scanner=bb(K.customSchemes);for(let t=0;t<K.tokenQueue.length;t++)K.tokenQueue[t][1]({scanner:K.scanner});K.parser=xb(K.scanner.tokens);for(let t=0;t<K.pluginQueue.length;t++)K.pluginQueue[t][1]({scanner:K.scanner,parser:K.parser});return K.initialized=!0,K}function Fo(t){return K.initialized||Ab(),Cb(K.parser.start,t,tf(K.scanner.start,t))}Fo.scan=tf;function dl(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}let r=new cl(n),o=Fo(t),s=[];for(let i=0;i<o.length;i++){let l=o[i];l.isLink&&(!e||l.t===e)&&r.check(l)&&s.push(l.toFormattedObject(r))}return s}var jo="[\0- \xA0\u1680\u180E\u2000-\u2029\u205F\u3000]",Tb=new RegExp(jo),Eb=new RegExp(`${jo}$`),Nb=new RegExp(`${jo}+$`),Ob=new RegExp(jo,"g");function Rb(t,e,n){var r,o;let s=t.doc.resolve(e.to);if(!(!((r=s.nodeBefore)===null||r===void 0)&&r.isText))return;let i=(o=t.doc.textBetween(e.from,e.to,"\uFFFC","\uFFFC").match(Nb))===null||o===void 0?void 0:o[0];if(!i)return;let l=e.to-i.length,a=Gn(l,e.to,t.doc).filter(d=>d.mark.type===n);if(!a.length)return;let{nodeAfter:c}=s;if(c&&a.some(d=>d.mark.isInSet(c.marks)))return;let u=t.storedMarks;t.removeMark(l,e.to,n),t.setStoredMarks(u),t.selection.empty&&t.selection.from===e.to&&t.removeStoredMark(n)}function Ib(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function Db(t){return new R({key:new z("autolink"),appendTransaction:(e,n,r)=>{let o=e.some(a=>a.docChanged)&&!n.doc.eq(r.doc),s=e.some(a=>a.getMeta("preventAutolink"));if(!o||s)return;let{tr:i}=r,l=Ni(n.doc,[...e]);if(!e.some(Tu)){let a=[];l.steps.forEach((c,u)=>{if(!(c instanceof X)||!c.slice.size)return;let d=l.mapping.slice(u+1),f=d.map(c.from,1),h=d.map(c.from+c.slice.size,-1);f<h&&a.push({from:f,to:h})}),a.sort((c,u)=>u.to-c.to),a.forEach(c=>Rb(i,c,t.type))}if(un(l).forEach(({newRange:a})=>{let c=sd(r.doc,a,f=>f.isTextblock),u,d;if(c.length>1)u=c[0],d=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(c.length){let f=r.doc.textBetween(a.from,a.to," "," ");if(!Eb.test(f))return;u=c[0],d=r.doc.textBetween(u.pos,a.to,void 0," ")}if(u&&d){let f=d.split(Tb).filter(Boolean);if(f.length<=0)return!1;let h=f[f.length-1],p=u.pos+d.lastIndexOf(h);if(!h)return!1;let m=Fo(h).map(g=>g.toObject(t.defaultProtocol));if(!Ib(m))return!1;m.filter(g=>g.isLink).map(g=>({...g,from:p+g.start+1,to:p+g.end+1})).filter(g=>r.schema.marks.code?!r.doc.rangeHasMark(g.from,g.to,r.schema.marks.code):!0).filter(g=>t.validate(g.value)).filter(g=>t.shouldAutoLink(g.value)).forEach(g=>{Gn(g.from,g.to,r.doc).some(y=>y.mark.type===t.type)||i.addMark(g.from,g.to,t.type.create({href:g.href}))})}}),!!i.steps.length)return i}})}function Lb(t){return new R({key:new z("handleClickLink"),props:{handleClick:(e,n,r)=>{if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let a=r.target;if(!a)return!1;let c=t.editor.view.dom;o=a.closest("a"),o&&!c.contains(o)&&(o=null)}if(!o)return!1;let s=!1;if(t.enableClickSelection&&(s=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){var i,l;let a=Li(e.state,t.type.name),c=(i=o.href)!==null&&i!==void 0?i:a.href,u=(l=o.target)!==null&&l!==void 0?l:a.target;c&&(window.open(c,u),s=!0)}return s}}})}var Pb=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,zb=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function of(t,e){let n=0;for(let r=e-1;r>=0&&t[r]==="\\";r-=1)n+=1;return n%2===1}function Bb(t,e){let n=0,r=0;for(;r<e;){if(t[r]!=="`"){r+=1;continue}if(n===0&&of(t,r)){r+=1;continue}let o=0;for(;r<e&&t[r]==="`";)o+=1,r+=1;n===0?n=o:o===n&&(n=0)}return n>0}function sf(t,e,n){var r,o;let[,s,i]=e;return(e.index?t[e.index-1]:void 0)==="!"||of(t,(r=e.index)!==null&&r!==void 0?r:0)||Bb(t,(o=e.index)!==null&&o!==void 0?o:0)?!1:!!s.trim()&&n(i)}function lf(t){var e,n;let[r,o,s,,i,l,a]=t,c=(e=i??l)!==null&&e!==void 0?e:a;return{index:(n=t.index)!==null&&n!==void 0?n:0,text:r,replaceWith:o,data:{href:s,title:c||null,markdown:!0}}}function $b(t,e){return t.index<e.index+e.text.length&&e.index<t.index+t.text.length}function af(t){var e,n,r;return{href:(e=t.data)===null||e===void 0?void 0:e.href,title:(n=(r=t.data)===null||r===void 0?void 0:r.title)!==null&&n!==void 0?n:null}}function Hb(t){let e=ve({find:n=>{let r=Pb.exec(n);return!r||!sf(n,r,t.isAllowedHref)?null:lf(r)},type:t.type,getAttributes:af});return new fn({find:e.find,handler:n=>{let r=e.handler(n);return r!==null&&n.state.tr.steps.length&&n.state.tr.setMeta("preventAutolink",!0),r}})}function Fb(t){let e=we({find:n=>{var r,o;let s=[];for(let l of n.matchAll(zb))sf(n,l,t.isAllowedHref)&&s.push(lf(l));let i=((r=(o=t.findPlainUrls)===null||o===void 0?void 0:o.call(t,n))!==null&&r!==void 0?r:[]).filter(l=>!s.some(a=>$b(a,l)));return[...s,...i]},type:t.type,getAttributes:af});return new Hi({find:e.find,handler:n=>{var r;let o=e.handler(n);return o!==null&&n.state.tr.steps.length&&(!((r=n.match.data)===null||r===void 0)&&r.markdown)&&n.state.tr.setMeta("preventAutolink",!0),o}})}function jb(t){return new R({key:new z("handlePasteLink"),props:{handlePaste:(e,n,r)=>{let{shouldAutoLink:o}=t,{state:s}=e,{selection:i}=s,{empty:l}=i;if(l)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});let c=dl(a,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!c||o!==void 0&&!o(c.value)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function et(t,e){let n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{let o=typeof r=="string"?r:r.scheme;o&&n.push(o)}),!t||t.replace(Ob,"").match(new RegExp(`^(?:(?:${n.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}var cf=oe.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(t=>{if(typeof t=="string"){ul(t);return}ul(t.scheme,t.optionalSlashes)})},onDestroy(){rf()},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:(t,e)=>!!et(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{let e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;let r=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){var t,e,n;return{href:{default:null,parseHTML(r){return r.getAttribute("href")}},target:{default:(t=this.options.HTMLAttributes.target)!==null&&t!==void 0?t:null},rel:{default:(e=this.options.HTMLAttributes.rel)!==null&&e!==void 0?e:null},class:{default:(n=this.options.HTMLAttributes.class)!==null&&n!==void 0?n:null},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{let e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!et(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!et(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",I(this.options.HTMLAttributes,t),0]:["a",I(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,o,s;let i=(n=(r=t.attrs)===null||r===void 0?void 0:r.href)!==null&&n!==void 0?n:"",l=(o=(s=t.attrs)===null||s===void 0?void 0:s.title)!==null&&o!==void 0?o:"",a=e.renderChildren(t);return l?`[${a}](${i} "${l}")`:`[${a}](${i})`},addCommands(){return{setLink:t=>({chain:e})=>{let{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!et(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{let{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!et(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addInputRules(){return this.options.markdownLinks?[Hb({type:this.type,isAllowedHref:t=>this.options.isAllowedUri(t,{defaultValidate:e=>!!et(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let t=e=>{let n=[];if(e){let{protocols:r,defaultProtocol:o}=this.options;dl(e,{defaultProtocol:o}).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:i=>!!et(i,r),protocols:r,defaultProtocol:o})).forEach(s=>{this.options.shouldAutoLink(s.value)&&n.push({text:s.value,data:{href:s.href},index:s.start})})}return n};return this.options.markdownLinks?[Fb({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:n=>!!et(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:t})]:[we({find:t,type:this.type,getAttributes:e=>{var n;return{href:(n=e.data)===null||n===void 0?void 0:n.href}}})]},addProseMirrorPlugins(){let t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(Db({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!et(o,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(Lb({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(jb({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}});var Wb="listItem",uf="textStyle",df=/^\s*([-+*])\s$/,fl=H.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:t}){return["ul",I(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
135
|
+
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Wb,this.editor.getAttributes(uf)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=ut({find:df,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=ut({find:df,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(uf),editor:this.editor})),[t]}}),Vb=(t,e,n)=>{let{selection:r}=t;if(!r.empty)return null;let{$from:o}=r;if(!o.parent.isTextblock||o.parentOffset!==o.parent.content.size)return null;let s=-1;for(let h=o.depth;h>0;h-=1)if(o.node(h).type.name===e){s=h;break}if(s<0)return null;let i=o.node(s),l=o.index(s);if(l+1>=i.childCount)return null;let a=i.child(l+1);if(!n.includes(a.type.name))return null;let c=t.schema.nodes[e],u=!1;if(a.forEach(h=>{h.type===c&&h.childCount>1&&(u=!0)}),!u)return null;let d=t.doc.resolve(o.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(h=>{f.push(h)}),f.length===0?null:{listItemDepth:s,nestedList:d,nestedListPos:o.after(),insertPos:o.after(s),items:f}},_b=(t,e,n,r)=>{let o=Vb(t,n,r);if(!o)return!1;let{selection:s}=t,{nestedList:i,nestedListPos:l,insertPos:a,items:c}=o,u=t.tr;u.delete(l,l+i.nodeSize);let d=u.mapping.map(a);return u.insert(d,b.from(c)),u.setSelection(s.map(u.doc,u.mapping)),e&&e(u),!0},Kb=(t,e,n)=>_b(t.state,t.view.dispatch,e,n),wf=(t,e)=>$.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>Kb(this.editor,t,e);return{Delete:n,"Mod-Delete":n}}}),Sf=[[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"]],Wo="abcdefghijklmnopqrstuvwxyz",xf=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function Ko(t){let e=t,n="";for(let[r,o]of Sf)for(;e>=r;)n+=o,e-=r;return n}function hl(t){return Ko(t).toUpperCase()}function Cf(t){let e=t.toLowerCase(),n=0,r=0;for(;n<e.length;){let o=!1;for(let[s,i]of Sf)if(e.startsWith(i,n)){r+=s,n+=i.length,o=!0;break}if(!o)return 0}return r}function Ub(t){if(!/^[ivxlcdmIVXLCDM]+$/.test(t))return!1;let e=Cf(t);return e<=0?!1:(t===t.toLowerCase()?Ko(e):hl(e))===t}function Jb(t){let e=t.toLowerCase();if(e.length===1)return e.charCodeAt(0)-97+1;if(e.length===2){let n=e.charCodeAt(0)-97,r=e.charCodeAt(1)-97;return(n+1)*26+r+1}return 0}function Vo(t){if(t<=26)return Wo[t-1];let e=Math.floor((t-1)/26)-1,n=(t-1)%26;return e<0?Wo[n]:Wo[e]+Wo[n]}function Uo(t){if(!(!t||/^\d+$/.test(t))){if(Ub(t))return t===t.toLowerCase()?"i":"I";if(/^[a-z]{1,2}$/.test(t))return"a";if(/^[A-Z]{1,2}$/.test(t))return"A"}}function pl(t){if(/^\d+$/.test(t))return parseInt(t,10);let e=Uo(t);if(e==="i"||e==="I")return Cf(t);if(e==="a"||e==="A"){let r=Jb(t);return r>0?r:1}let n=parseInt(t,10);return Number.isNaN(n)?1:n}function qb(t,e){if(t==="numeric")return String(e);switch(t){case"a":return Vo(e);case"A":return Vo(e).toUpperCase();case"i":return Ko(e);case"I":return hl(e);default:return String(e)}}function Gb(t){var e;if(t.length===0)return!1;let n=(e=Uo(t[0]))!==null&&e!==void 0?e:"numeric",r=pl(t[0]);if(r<1)return!1;for(let o=0;o<t.length;o++){let s=qb(n,r+o);if(t[o]!==s)return!1}return!0}function Xb(t){return{type:Uo(t),start:pl(t)}}function Yb(t){let{type:e,start:n}=Xb(t),r={};return e&&(r.type=e),n!==1&&(r.start=n),r}function Qb(t,e,n=". "){let r=e+1;if(!t||t==="1")return`${r}${n}`;switch(t){case"a":return`${Vo(r)}${n}`;case"A":return`${Vo(r).toUpperCase()}${n}`;case"i":return`${Ko(r)}${n}`;case"I":return`${hl(r)}${n}`;default:return`${r}${n}`}}function Zb(t){return!t[0]||t[0].type==="paragraph"?t:[{type:"paragraph",content:[]},...t]}function ek(t){var e,n;let r=(e=t.content)===null||e===void 0?void 0:e[0];return r?.type==="paragraph"&&!(!((n=r.content)===null||n===void 0)&&n.length)}var tk=" ",ff=1,nk=t=>{var e;return((e=t?.level)!==null&&e!==void 0?e:ff)>ff};function rk(t){var e,n;let r=(e=t.tokens)===null||e===void 0?void 0:e[0];return!!(t.text&&((n=t.tokens)===null||n===void 0?void 0:n.length)===1&&r?.type==="list"&&r.ordered&&r.raw===t.text)}function ok(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}var ml=H.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",I(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var n;if(t.type!=="list_item")return[];let r=(n=e.parseBlockChildren)!==null&&n!==void 0?n:e.parseChildren,o=[];if(t.tokens&&t.tokens.length>0){if(rk(t))return{type:"listItem",content:[{type:"paragraph",content:ok(t.text||"",e)}]};let[i,...l]=t.tokens;if(i.type==="heading"){var s;return{type:"listItem",content:[{type:"paragraph",content:e.parseInline((s=i.tokens)!==null&&s!==void 0?s:[])},...l.length>0?r(l):[]]}}if(t.tokens.some(a=>a.type==="paragraph"))o=r(t.tokens);else if(i.type==="text"&&i.tokens&&i.tokens.length>0){if(o=[{type:"paragraph",content:e.parseInline(i.tokens)}],t.tokens.length>1){let a=r(t.tokens.slice(1));o.push(...a)}}else o=r(t.tokens)}return o.length===0&&(o=[{type:"paragraph",content:[]}]),{type:"listItem",content:Zb(o)}},renderMarkdown:(t,e,n)=>{let r=i=>{if(i.parentType==="bulletList")return"- ";if(i.parentType==="orderedList"){var l,a;let c=((l=i.meta)===null||l===void 0||(l=l.parentAttrs)===null||l===void 0?void 0:l.start)||1;return Qb((a=i.meta)===null||a===void 0||(a=a.parentAttrs)===null||a===void 0?void 0:a.type,c-1+(i.index||0),". ")}return"- "},o=Bi(t,e,r,n,{alignNestedToPrefix:n?.parentType==="orderedList"});if(!ek(t)||!nk(n))return o;let s=r(n);return`${s}${tk}${o.slice(s.length)}`},addExtensions(){return[wf(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)}}}),gl=(t,e)=>{let{$from:n}=e.selection,r=ee(t,e.schema),o=null,s=n.depth,i=n.pos,l=null;for(;s>0&&l===null;)o=n.node(s),o.type===r?l=s:(s-=1,i-=1);return l===null?null:{$pos:e.doc.resolve(i),depth:l}},Mf=(t,e)=>{let n=gl(t,e);if(!n)return!1;let[,r]=dd(e,t,n.$pos.pos+4);return r},sk=(t,e,n)=>{let{$anchor:r}=t.selection,o=Math.max(0,r.pos-2),s=t.doc.resolve(o).node();return!(!s||!n.includes(s.type.name))},hf=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!$e(t.state,e)&&sk(t.state,e,n)){let{$anchor:s}=t.state.selection,i=t.state.doc.resolve(s.before()-1),l=[];i.node().descendants((u,d)=>{u.type.name===e&&l.push({node:u,pos:d})});let a=l.at(-1);if(!a)return!1;let c=t.state.doc.resolve(i.start()+a.pos+1);return t.chain().command(({tr:u})=>{let d=c.end();return u.delete(s.before(),s.after()).insert(d,s.parent),u.setSelection(M.create(u.doc,d+1)),!0}).command(({state:u,dispatch:d})=>(Tr(u,d),!0)).run()}if(!$e(t.state,e)||!pd(t.state))return!1;let{$from:r}=t.state.selection,o=r.depth-1;return r.node(o).type!==t.schema.nodes[e]||r.index(o)!==0?!1:t.chain().liftListItem(e).run()},ik=(t,e)=>{let n=Mf(t,e),r=gl(t,e);return!r||!n?!1:n>r.depth},lk=(t,e)=>{let n=Mf(t,e),r=gl(t,e);return!r||!n?!1:n<r.depth},pf=(t,e)=>!$e(t.state,e)||!hd(t.state,e)||!t.state.selection.empty?!1:ik(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():lk(e,t.state)?t.commands.command(({state:n,dispatch:r})=>Er(n,r)):t.commands.joinItemForward(),ak=(t,e,n)=>{let{state:r}=t,{selection:o}=r;if(!o.empty)return!1;let{$from:s}=o;if(s.parentOffset!==0||!s.parent.isTextblock||$e(r,e))return!1;let i=fd(s);if(!i||!n.includes(i.type.name))return!1;let l=i.lastChild;if(!l||l.type.name!==e)return!1;let a=s.parent;if(!l.canReplace(l.childCount,l.childCount,b.from(a)))return!1;let c=s.before(),u=s.after(),d=c-2;return t.commands.command(({tr:f,dispatch:h})=>(h&&(f.delete(c,u).insert(d,b.from(a)),f.setSelection(M.create(f.doc,d+1)),f.scrollIntoView()),!0))};var yl=$.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&pf(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&pf(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&hf(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&hf(t,n,r)&&(e=!0)}),e},Tab:({editor:t})=>{for(let{itemName:e,wrapperNames:n}of this.options.listTypes)if(t.state.schema.nodes[e]!==void 0&&ak(t,e,n))return!0;return!1}}}}),_o=new RegExp(`^(\\s*)(${xf})([.)])\\s+(.*)$`),ck=/^\s/,yn={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function uk(t){return _o.test(t.trimStart())}function dk(t){let e=t.trimStart();return yn.bulletItem.test(e)||uk(e)||yn.heading.test(e)||yn.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||yn.codeFence.test(e)||yn.blockMath.test(e)}function fk(t){return Object.values(yn).some(e=>e.test(t))}function hk(t){let e=[],n=[],r=!1;return t.forEach(o=>{if(r){n.push(o);return}if(o.trim()===""){r=!0,n.push(o);return}if(e.length>0&&dk(o)){r=!0,n.push(o);return}e.push(o)}),{paragraphLines:e,blockLines:n}}function mf(t){let e=[],n=0,r=0;for(;n<t.length;){let o=t[n],s=o.match(_o);if(!s)break;let[,i,l,a,c]=s,u=i.length,d=parseInt(l,10),f=isNaN(d)?Uo(l):void 0,h=isNaN(d)?pl(l):d,p=[c],m=n+1,g=[o],y=!1;for(;m<t.length;){let w=t[m];if(w.match(_o))break;if(w.trim()==="")g.push(w),p.push(""),y=!0,m+=1;else if(w.match(ck)){let k=w.length-w.trimStart().length,x=u+l.length+1;g.push(w),p.push(w.slice(Math.min(k,x))),m+=1}else{if(y||fk(w))break;g.push(w),p.push(w),m+=1}}e.push({indent:u,number:h,type:f,content:p.join(`
|
|
136
|
+
`).trim(),contentLines:p,raw:g.join(`
|
|
137
|
+
`)}),r=m,n=m}return[e,r]}var pk=new RegExp(`^(${xf})([.)])\\s+(.+)$`);function mk(t){let e=t.split(`
|
|
138
|
+
`).filter(r=>r.trim().length>0);if(e.length===0)return null;let n=[];for(let r of e){let o=r.trim().match(pk);if(!o)return null;n.push({marker:o[1],content:o[3]})}return Gb(n.map(r=>r.marker))?{type:"orderedList",attrs:Yb(n[0].marker),content:n.map(r=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:r.content}]}]}))}:null}function vf(t,e,n){let r=[],o=0;for(;o<t.length;){let s=t[o];if(s.indent===e){let{paragraphLines:i,blockLines:l}=hk(s.contentLines),a=i.join(`
|
|
139
|
+
`).trim(),c=[];a&&c.push({type:"paragraph",raw:a,tokens:n.inlineTokens(a)});let u=l.join(`
|
|
140
|
+
`).trim();if(u){let h=n.blockTokens(u);c.push(...h)}let d=o+1,f=[];for(;d<t.length&&t[d].indent>e;)f.push(t[d]),d+=1;if(f.length>0){let h=vf(f,Math.min(...f.map(p=>p.indent)),n);c.push({type:"list",ordered:!0,start:f[0].number,typeMarker:f[0].type,items:h,raw:f.map(p=>p.raw).join(`
|
|
141
|
+
`)})}r.push({type:"list_item",raw:s.raw,tokens:c}),o=d}else o+=1}return r}function gk(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];let r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(o=>{if(o.type==="paragraph"||o.type==="list"||o.type==="blockquote"||o.type==="code")r.push(...e.parseChildren([o]));else if(o.type==="text"&&o.tokens){let s=e.parseChildren([o]);r.push({type:"paragraph",content:s})}else{let s=e.parseChildren([o]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}var yk=64;function gf(t,e){let n=[],r=0;for(;n.length<e;){let o=t.indexOf(`
|
|
142
|
+
`,r);if(o===-1)return n.push(t.slice(r)),n;n.push(t.slice(r,o)),r=o+1}return n}function bk(t){let e=t.indexOf(`
|
|
143
|
+
`),n=e===-1?t:t.slice(0,e);if(!_o.test(n))return[[],0,[]];let r=yk,o=gf(t,r),s=mf(o);for(;s[1]===o.length&&o.length===r;)r*=2,o=gf(t,r),s=mf(o);return[s[0],s[1],o]}var kk="listItem",yf="textStyle",bf=/^(\d+)\.\s$/;function kf(t){let e=t.match(/list-style-type\s*:\s*([^;]+)/i);if(!e)return null;switch(e[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 bl=H.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:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>{let e=t.getAttribute("type");if(e)return e;let n=t.getAttribute("style");if(n){let o=kf(n);if(o)return o}let r=t.querySelector("li");if(r){let o=r.getAttribute("style");if(o){let s=kf(o);if(s)return s}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){let{start:e,type:n,...r}=t,o=I(this.options.HTMLAttributes,r);return e!==1&&(o.start=e),n&&n!=="1"&&(o.type=n),["ol",o,0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];let n=t.start||1,r=t.typeMarker,o=t.items?gk(t.items,e):[],s={};return n!==1&&(s.start=n),r&&(s.type=r),Object.keys(s).length>0?{type:"orderedList",attrs:s,content:o}:{type:"orderedList",content:o}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
144
|
+
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(t,e,n)=>{var r,o;let[s,i,l]=bk(t);if(s.length===0)return;let a=vf(s,s[0].indent,n);if(a.length!==0)return{type:"list",ordered:!0,start:((r=s[0])===null||r===void 0?void 0:r.number)||1,typeMarker:(o=s[0])===null||o===void 0?void 0:o.type,items:a,raw:l.slice(0,i).join(`
|
|
145
|
+
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(kk,this.editor.getAttributes(yf)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new R({props:{handlePaste:(t,e)=>{var n,r;let o=(n=e.clipboardData)===null||n===void 0?void 0:n.getData("text/html");if(o?.trim())return!1;let s=(r=e.clipboardData)===null||r===void 0?void 0:r.getData("text/plain");if(!s)return!1;let i=mk(s);if(!i)return!1;try{let l=t.state.schema.nodeFromJSON(i),a=t.state.tr.replaceSelectionWith(l);return t.dispatch(a),!0}catch{return!1}}}})]},addInputRules(){let t=(n,r)=>(!r.attrs.type||r.attrs.type==="1")&&r.childCount+r.attrs.start===+n[1],e=ut({find:bf,type:this.type,getAttributes:n=>({start:+n[1]}),joinPredicate:t});return(this.options.keepMarks||this.options.keepAttributes)&&(e=ut({find:bf,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:n=>({start:+n[1],...this.editor.getAttributes(yf)}),joinPredicate:t,editor:this.editor})),[e]}}),wk=/^\s*(\[([( |x])?\])\s$/,Sk="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",xk=(t,e,n)=>{var r;return(n==null||(r=n.checkboxLabel)===null||r===void 0?void 0:r.call(n,t,e))||`Task item checkbox for ${t.textContent||"empty task item"}`},Ck=H.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:t=>{let e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:t=>{var e;return(e=t.querySelector("div"))!==null&&e!==void 0?e:t}}]},renderHTML({node:t,HTMLAttributes:e}){return["li",I(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{let n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){let r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;let r=`- [${!((n=t.attrs)===null||n===void 0)&&n.checked?"x":" "}] `;return Bi(t,e,r,void 0,{indentMainContent:!0})},addExtensions(){return this.options.nested?[wf(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{let o=document.createElement("li"),s=document.createElement("label"),i=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div");i.style.cssText=Sk;let c=d=>{let f=xk(d,d.attrs.checked,this.options.a11y);l.setAttribute("aria-label",f),i.textContent=f};c(t),s.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}let{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{let p=n();if(typeof p!="number")return!1;let m=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...m?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{o.setAttribute(d,f)}),o.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,s.append(l,i),o.append(s,a),Object.entries(e).forEach(([d,f])=>{o.setAttribute(d,f)});let u=new Set(Object.keys(e));return{dom:o,contentDOM:a,update:d=>{if(d.type!==this.type)return!1;o.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,c(d);let f=r.extensionManager.attributes,h=ct(d,f),p=new Set(Object.keys(h)),m=this.options.HTMLAttributes;return u.forEach(g=>{p.has(g)||(g in m?o.setAttribute(g,m[g]):o.removeAttribute(g))}),Object.entries(h).forEach(([g,y])=>{y==null?g in m?o.setAttribute(g,m[g]):o.removeAttribute(g):o.setAttribute(g,y)}),u=p,!0}}}},addInputRules(){return[ut({find:wk,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),Mk=H.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:t}){return["ul",I(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
146
|
+
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;let n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))===null||e===void 0?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){let r=s=>{let i=zi(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);if(i){let l={type:"taskList",raw:i.raw,items:i.items},a=s.slice(i.raw.length);return a.trim()?[l,...n.blockTokens(a)]:[l]}return n.blockTokens(s)},o=zi(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,i)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:n.inlineTokens(s.mainContent),nestedTokens:i}),customNestedParser:r},n);if(o)return{type:"taskList",raw:o.raw,items:o.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),ix=$.create({name:"listKit",addExtensions(){let t=[];return this.options.bulletList!==!1&&t.push(fl.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(ml.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(yl.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(bl.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Ck.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Mk.configure(this.options.taskList)),t}});var Jo=" ",kl="\xA0",Af=H.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",I(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{let n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);let r=e.parseInline(n);return n.length===1&&n[0].type==="text"&&(n[0].raw===Jo||n[0].text===Jo||n[0].raw===kl||n[0].text===kl)&&r.length===1&&r[0].type==="text"&&(r[0].text===Jo||r[0].text===kl)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e,n)=>{if(!t)return"";let r=Array.isArray(t.content)?t.content:[];if(r.length===0){var o,s;let i=Array.isArray(n==null||(o=n.previousNode)===null||o===void 0?void 0:o.content)?n.previousNode.content:[];return(n==null||(s=n.previousNode)===null||s===void 0?void 0:s.type)==="paragraph"&&i.length===0?Jo:""}return e.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var vk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Ak=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Tf=oe.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",I(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ve({find:vk,type:this.type})]},addPasteRules(){return[we({find:Ak,type:this.type})]}});var Ef=H.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""});var Nf=oe.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",I(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`<u>${e.renderChildren(t)}</u>`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.toLowerCase().indexOf("<u>")},tokenize(t,e,n){if(!/^<u>/i.test(t))return;let r=/\\[\s\S]|`+|<\/u>/gi;r.lastIndex=3;let o=r.exec(t);for(;o;){if(o[0].startsWith("`")){let s=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/.exec(t.slice(o.index));s&&(r.lastIndex=o.index+s[0].length)}else if(!o[0].startsWith("\\")){let s=t.slice(3,o.index);return s?{type:"underline",raw:t.slice(0,r.lastIndex),text:s,tokens:n.inlineTokens(s)}:void 0}o=r.exec(t)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function Of(t={}){return new R({view(e){return new wl(e,t)}})}var wl=class{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let s=i=>{this[o](i)};return e.dom.addEventListener(o,s),{name:o,handler:s}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){if(this.cursorPos!=null&&n.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}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),n=!e.parent.inlineContent,r,o=this.editorView.dom,s=o.getBoundingClientRect(),i=s.width/o.offsetWidth,l=s.height/o.offsetHeight;if(n){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let p=h.getBoundingClientRect(),m=d?p.bottom:p.top;d&&f&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*i;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.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",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),o=r&&r.type.spec.disableDropCursor,s=typeof o=="function"?o(this.editorView,n,e):o;if(!n||s)return null;let i=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Mr(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}return i}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let n=this.computeTarget(e);n!=null&&(this.setCursor(n),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var ce=class t extends T{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return t.valid(r)?new t(r):T.near(r)}content(){return C.empty}eq(e){return e instanceof t&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new t(e.resolve(n.pos))}getBookmark(){return new Sl(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!Tk(e)||!Ek(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let o=n.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&t.valid(e))return e;let o=e.pos,s=null;for(let i=e.depth;;i--){let l=e.node(i);if(n>0?e.indexAfter(i)<l.childCount:e.index(i)>0){s=l.child(n>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;o+=n;let a=e.doc.resolve(o);if(t.valid(a))return a}for(;;){let i=n>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!v.isSelectable(s)){e=e.doc.resolve(o+s.nodeSize*n),r=!1;continue e}break}s=i,o+=n;let l=e.doc.resolve(o);if(t.valid(l))return l}return null}}};ce.prototype.visible=!1;ce.findFrom=ce.findGapCursorFrom;T.jsonID("gapcursor",ce);var Sl=class t{constructor(e){this.pos=e}map(e){return new t(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ce.valid(n)?new ce(n):T.near(n)}};function Rf(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Tk(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||Rf(o.type))return!0;if(o.inlineContent)return!1}}return!0}function Ek(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||Rf(o.type))return!0;if(o.inlineContent)return!1}}return!0}function If(){return new R({props:{decorations:Ik,createSelectionBetween(t,e,n){return e.pos==n.pos&&ce.valid(n)?new ce(n):null},handleClick:Ok,handleKeyDown:Nk,handleDOMEvents:{beforeinput:Rk}}})}var Nk=Kn({ArrowLeft:qo("horiz",-1),ArrowRight:qo("horiz",1),ArrowUp:qo("vert",-1),ArrowDown:qo("vert",1)});function qo(t,e){let n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,s){let i=r.selection,l=e>0?i.$to:i.$from,a=i.empty;if(i instanceof M){if(!s.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=ce.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new ce(c))),!0):!1}}function Ok(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!ce.valid(r))return!1;let o=t.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&v.isSelectable(t.state.doc.nodeAt(o.inside))?!1:(t.dispatch(t.state.tr.setSelection(new ce(r))),!0)}function Rk(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof ce))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let o=b.empty;for(let i=r.length-1;i>=0;i--)o=b.from(r[i].createAndFill(null,o));let s=t.state.tr.replace(n.pos,n.pos,new C(o,0,0));return s.setSelection(M.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function Ik(t){if(!(t.selection instanceof ce))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",B.create(t.doc,[U.widget(t.selection.head,e,{key:"gapcursor"})])}var Lx=$.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{let e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){let n=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(n)}return e.nodeSize},this.storage.words=t=>{let e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new R({key:new z("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;let o=this.options.limit,s=this.options.autoTrim;if(o==null||o===0||s===!1){t=!0;return}let i=this.storage.characters({node:r.doc});if(i>o){let l=i-o,a=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);let u=r.tr.deleteRange(a,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{let r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;let o=this.storage.characters({node:n.doc}),s=this.storage.characters({node:e.doc});if(s<=r||o>r&&s>r&&s<=o)return!0;if(o>r&&s>r&&s>o||!e.getMeta("paste"))return!1;let i=e.selection.$head.pos,l=i-(s-r),a=i;return e.deleteRange(l,a),!(this.storage.characters({node:e.doc})>r)}})]}}),Pf=$.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Of(this.options)]}}),Px=$.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new R({key:new z("focus"),props:{decorations:({doc:t,selection:e})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:o}=e,s=[];if(!n||!r)return B.create(t,[]);let i=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(!a.isText){if(!(o>=c&&o<=c+a.nodeSize-1))return!1;i+=1}});let l=0;return t.descendants((a,c)=>{if(a.isText||!(o>=c&&o<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&i-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";s.push(U.node(c,c+a.nodeSize,{class:this.options.className}))}),B.create(t,s)}}})]}}),zf=$.create({name:"gapCursor",addProseMirrorPlugins(){return[If()]},extendNodeSchema(t){var e;let n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=j(A(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),Bf="placeholder",Df=new z("tiptap__placeholder");function $f(t){let{editor:e,placeholder:n,dataAttribute:r,pos:o,node:s,isEmptyDoc:i,hasAnchor:l,classes:{emptyNode:a,emptyEditor:c}}=t,u=[a];return i&&u.push(c),U.node(o,o+s.nodeSize,{class:u.join(" "),[r]:typeof n=="function"?n({editor:e,node:s,pos:o,hasAnchor:l}):n})}function Hf(t,e){return typeof t=="function"?t(e):t}function Ff({editor:t,options:e,dataAttribute:n,doc:r,selection:o,from:s,to:i}){let{anchor:l}=o,a=[],c=t.isEmpty;return r.nodesBetween(s,i,(u,d)=>{let f=l>=d&&l<=d+u.nodeSize,h=!u.isLeaf&&dn(u);return u.type.isTextblock&&(f||!e.showOnlyCurrent)&&h&&a.push($f({editor:t,isEmptyDoc:c,dataAttribute:n,hasAnchor:f,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Hf(e.emptyNodeClass,{editor:t,node:u,pos:d,hasAnchor:f})},node:u,pos:d})),e.includeChildren}),a}function jf({editor:t,options:e,dataAttribute:n,doc:r,selection:o}){if(!(t.isEditable||!e.showOnlyWhenEditable))return null;let{anchor:s}=o,i=[],l=t.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){let a=r.resolve(s),c=a.depth>0?a.node(1):a.nodeAfter,u=a.depth>0?a.before(1):s;if(c&&c.type.isTextblock&&dn(c)){let d=s>=u&&s<=u+c.nodeSize;i.push($f({editor:t,isEmptyDoc:l,dataAttribute:n,hasAnchor:d,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Hf(e.emptyNodeClass,{editor:t,node:c,pos:u,hasAnchor:d})},node:c,pos:u}))}}else i.push(...Ff({editor:t,options:e,dataAttribute:n,doc:r,selection:o,from:0,to:r.content.size}));return B.create(r,i)}function ir(t,e){let n=t.resolve(e);if(n.depth===0){var r;let s=(r=n.nodeAfter)!==null&&r!==void 0?r:n.nodeBefore;if(!s)return{from:e,to:e};let i=n.nodeAfter?e:e-s.nodeSize;return{from:i,to:i+s.nodeSize}}let o=n.before(1);return{from:o,to:o+n.node(1).nodeSize}}function lr(t,e){return{from:Math.max(0,e.from),to:Math.min(t.content.size,e.to)}}function Dk(t,e,n){let r=[];return t.forEach((o,s)=>{let i=s,l=i+o.nodeSize,a=i+1,c=l+1;a<n&&c>e&&r.push({from:i,to:l})}),r}function Lk(t){if(t.length===0)return[];let e=[...t].sort((r,o)=>r.from-o.from),n=[{...e[0]}];for(let r=1;r<e.length;r+=1){let o=n[n.length-1],s=e[r];s.from<=o.to?o.to=Math.max(o.to,s.to):n.push({...s})}return n}function Pk(t,e){let n=Dk(t,e.from,e.to);return n.push(lr(t,ir(t,e.from))),e.to>e.from?n.push(lr(t,ir(t,Math.min(e.to,t.content.size+1)-1))):e.from<t.content.size+1&&n.push(lr(t,ir(t,Math.min(e.from+1,t.content.size)))),n}function zk(t,e,n){let r=[];if(t.docChanged){let o=un(t);for(let s of o)r.push(...Pk(n.doc,s.newRange))}return t.selectionSet&&(r.push(lr(n.doc,ir(n.doc,t.mapping.map(e.selection.anchor)))),r.push(lr(n.doc,ir(n.doc,n.selection.anchor)))),Lk(r)}function Bk(t,e,n){let r=Math.max(0,Math.min(t,n.content.size));return{from:r,to:Math.max(r,Math.min(e,n.content.size))}}function $k({decorations:t,ranges:e,editor:n,options:r,dataAttribute:o,doc:s,selection:i}){let l=t;for(let a of e){let{from:c,to:u}=Bk(a.from,a.to,s),d=l.find(c,u).filter(h=>h.from>=c&&h.to<=u);d.length&&(l=l.remove(d));let f=Ff({editor:n,options:r,dataAttribute:o,doc:s,selection:i,from:c,to:u});f.length&&(l=l.add(s,f))}return l}function Hk({editor:t,options:e,dataAttribute:n}){return{init(r,o){let s=jf({editor:t,options:e,dataAttribute:n,doc:o.doc,selection:o.selection});return s??B.empty},apply(r,o,s,i){return!r.docChanged&&!r.selectionSet?o:$k({decorations:o.map(r.mapping,r.doc),ranges:zk(r,s,i),editor:t,options:e,dataAttribute:n,doc:i.doc,selection:i.selection})}}}function Fk(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function jk({editor:t,options:e}){let n=e.dataAttribute?`data-${Fk(e.dataAttribute)}`:`data-${Bf}`,r=e.showOnlyCurrent&&!e.includeChildren;return new R({key:Df,...r?{}:{state:Hk({editor:t,options:e,dataAttribute:n})},props:{decorations:r?({doc:o,selection:s})=>jf({editor:t,options:e,dataAttribute:n,doc:o,selection:s}):o=>{var s;return e.showOnlyWhenEditable&&!t.isEditable?B.empty:(s=Df.getState(o))!==null&&s!==void 0?s:B.empty}}})}var Cl=$.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Bf,placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[jk({editor:this.editor,options:this.options})]}});function xl(t,e){return!t.selection.empty&&!oo(t.selection)&&e.isEditable}function Wk(t,e){return xl(t,e)&&!e.isFocused&&!e.view.dragging}function Vk(){var t;(t=window.getSelection())===null||t===void 0||t.removeAllRanges()}function _k(t){t.focus()}var zx=$.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){let{editor:t,options:e}=this;return[new R({key:new z("selection"),props:{decorations(n){return Wk(n,t)?B.create(n.doc,[U.inline(n.selection.from,n.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(n){return xl(n.state,t)&&Vk(),!1},focus(n){return xl(n.state,t)&&requestAnimationFrame(()=>{!t.isDestroyed&&n.hasFocus()&&_k(n)}),!1}}}})]}});function Lf({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var Wf=$.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;let e=new z(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)===null||t===void 0?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(n).includes(o.name));return[new R({key:e,appendTransaction:(o,s,i)=>{let{doc:l,tr:a,schema:c}=i,u=e.getState(i),d=l.content.size,f=c.nodes[n];if(!o.some(h=>h.getMeta("skipTrailingNode"))&&u)return a.insert(d,f.create())},state:{init:(o,s)=>{let i=s.tr.doc.lastChild;return!Lf({node:i,types:r})},apply:(o,s)=>{if(!o.docChanged||o.getMeta("__uniqueIDTransaction"))return s;let i=o.doc.lastChild;return!Lf({node:i,types:r})}}})]}}),Vf=$.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Si(t,e),redo:()=>({state:t,dispatch:e})=>xi(t,e)}},addProseMirrorPlugins(){return[Au(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var Kk=$.create({name:"starterKit",addExtensions(){let t=[];if(this.options.bold!==!1&&t.push(Bd.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(zd.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(fl.configure(this.options.bulletList)),this.options.code!==!1&&t.push($d.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(Wi.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(Hd.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(Pf.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(zf.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(Fd.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(jd.configure(this.options.heading)),this.options.undoRedo!==!1&&t.push(Vf.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&t.push(Wd.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(Vd.configure(this.options.italic)),this.options.listItem!==!1&&t.push(ml.configure(this.options.listItem)),this.options.listKeymap!==!1){var e;t.push(yl.configure((e=this.options)===null||e===void 0?void 0:e.listKeymap))}if(this.options.link!==!1){var n;t.push(cf.configure((n=this.options)===null||n===void 0?void 0:n.link))}if(this.options.orderedList!==!1&&t.push(bl.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(Af.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(Tf.configure(this.options.strike)),this.options.text!==!1&&t.push(Ef.configure(this.options.text)),this.options.underline!==!1){var r;t.push(Nf.configure((r=this.options)===null||r===void 0?void 0:r.underline))}if(this.options.trailingNode!==!1){var o;t.push(Wf.configure((o=this.options)===null||o===void 0?void 0:o.trailingNode))}return t}}),ar=Kk;var Uk=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Jk=H.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",I(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,o,s,i;let l=(e=(n=t.attrs)===null||n===void 0?void 0:n.src)!==null&&e!==void 0?e:"",a=(r=(o=t.attrs)===null||o===void 0?void 0:o.alt)!==null&&r!==void 0?r:"",c=(s=(i=t.attrs)===null||i===void 0?void 0:i.title)!==null&&s!==void 0?s:"";return c?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;let{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize,o=new Set(["src","width","height"]);return({node:s,getPos:i,HTMLAttributes:l,editor:a})=>{let c=document.createElement("img");c.draggable=!1;let u=I(this.options.HTMLAttributes,l);Object.entries(u).forEach(([y,w])=>{if(w!=null)switch(y){case"src":case"width":case"height":break;default:c.setAttribute(y,w)}}),u.src!==null&&(c.src=u.src);let d={...l},f=y=>{if(typeof y=="string"&&y!==""){c.getAttribute("src")!==y&&(c.src=y);return}c.hasAttribute("src")&&c.removeAttribute("src"),c.src!==""&&(c.src="")};f(l.src);let h=y=>{if(y.type!==s.type)return!1;let w=a.extensionManager.attributes.filter(x=>x.type===y.type.name),k=ct(y,w);return Object.keys(d).forEach(x=>{!o.has(x)&&!(x in k)&&c.removeAttribute(x)}),Object.entries(k).forEach(([x,E])=>{o.has(x)||(E!=null?c.setAttribute(x,E):c.removeAttribute(x))}),f(k.src),d=k,!0},p=new Rd({element:c,editor:a,node:s,getPos:i,onResize:(y,w)=>{c.style.width=`${y}px`,c.style.height=`${w}px`},onCommit:(y,w)=>{let k=i();k!==void 0&&this.editor.chain().setNodeSelection(k).updateAttributes(this.name,{width:y,height:w}).run()},onUpdate:h,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),m=p.dom,g=()=>{m.style.visibility="",m.style.pointerEvents=""};return m.style.visibility="hidden",m.style.pointerEvents="none",c.complete&&c.naturalWidth>0?g():(c.onload=g,c.onerror=g),p}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[io({find:Uk,type:this.type,getAttributes:t=>{let[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),cr=Jk;var vl,Al;if(typeof WeakMap<"u"){let t=new WeakMap;vl=e=>t.get(e),Al=(e,n)=>(t.set(e,n),n)}else{let t=[],n=0;vl=r=>{for(let o=0;o<t.length;o+=2)if(t[o]==r)return t[o+1]},Al=(r,o)=>(n==10&&(n=0),t[n++]=r,t[n++]=o)}var q=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){let n=this.map[e];if(n!=t)continue;let r=e%this.width,o=e/this.width|0,s=r+1,i=o+1;for(let l=1;s<this.width&&this.map[e+l]==n;l++)s++;for(let l=1;i<this.height&&this.map[e+this.width*l]==n;l++)i++;return{left:r,top:o,right:s,bottom:i}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){let{left:r,right:o,top:s,bottom:i}=this.findCell(t);return e=="horiz"?(n<0?r==0:o==this.width)?null:this.map[s*this.width+(n<0?r-1:o)]:(n<0?s==0:i==this.height)?null:this.map[r+this.width*(n<0?s-1:i)]}rectBetween(t,e){let{left:n,right:r,top:o,bottom:s}=this.findCell(t),{left:i,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(n,i),top:Math.min(o,a),right:Math.max(r,l),bottom:Math.max(s,c)}}cellsInRect(t){let e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let o=t.left;o<t.right;o++){let s=r*this.width+o,i=this.map[s];n[i]||(n[i]=!0,!(o==t.left&&o&&this.map[s-1]==i||r==t.top&&r&&this.map[s-this.width]==i)&&e.push(i))}return e}positionAt(t,e,n){for(let r=0,o=0;;r++){let s=o+n.child(r).nodeSize;if(r==t){let i=e+t*this.width,l=(t+1)*this.width;for(;i<l&&this.map[i]<o;)i++;return i==l?s-1:this.map[i]}o=s}}static get(t){return vl(t)||Al(t,qk(t))}};function qk(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);let e=Gk(t),n=t.childCount,r=[],o=0,s=null,i=[];for(let c=0,u=e*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){let d=t.child(c);u++;for(let p=0;;p++){for(;o<r.length&&r[o]!=0;)o++;if(p==d.childCount)break;let m=d.child(p),{colspan:g,rowspan:y,colwidth:w}=m.attrs;for(let k=0;k<y;k++){if(k+c>=n){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:y-k});break}let x=o+k*e;for(let E=0;E<g;E++){r[x+E]==0?r[x+E]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:g-E});let V=w&&w[E];if(V){let W=(x+E)%e*2,O=i[W];O==null||O!=V&&i[W+1]==1?(i[W]=V,i[W+1]=1):O==V&&i[W+1]++}}}o+=g,u+=m.nodeSize}let f=(c+1)*e,h=0;for(;o<f;)r[o++]==0&&h++;h&&(s||(s=[])).push({type:"missing",row:c,n:h}),u++}(e===0||n===0)&&(s||(s=[])).push({type:"zero_sized"});let l=new q(e,n,r,s),a=!1;for(let c=0;!a&&c<i.length;c+=2)i[c]!=null&&i[c+1]<n&&(a=!0);return a&&Xk(l,i,t),l}function Gk(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){let o=t.child(r),s=0;if(n)for(let i=0;i<r;i++){let l=t.child(i);for(let a=0;a<l.childCount;a++){let c=l.child(a);i+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let i=0;i<o.childCount;i++){let l=o.child(i);s+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function Xk(t,e,n){t.problems||(t.problems=[]);let r={};for(let o=0;o<t.map.length;o++){let s=t.map[o];if(r[s])continue;r[s]=!0;let i=n.nodeAt(s);if(!i)throw new RangeError(`No cell with offset ${s} found`);let l=null,a=i.attrs;for(let c=0;c<a.colspan;c++){let u=e[(o+c)%t.width*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=Yk(a)))[c]=u)}l&&t.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function Yk(t){if(t.colwidth)return t.colwidth.slice();let e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function ue(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(let n in t.nodes){let r=t.nodes[n],o=r.spec.tableRole;o&&(e[o]=r)}}return e}var ht=new z("selectingCells");function zt(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Qk(t){for(let e=t.depth;e>0;e--){let n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function Re(t){let e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function es(t){let e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;let n=zt(e.$head)||Zk(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function Zk(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Tl(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function e1(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Ol(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Zf(t,e,n){let r=t.node(-1),o=q.get(r),s=t.start(-1),i=o.nextCell(t.pos-s,e,n);return i==null?null:t.node(0).resolve(s+i)}function Bt(t,e,n=1){let r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function eh(t,e,n=1){let r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<n;o++)r.colwidth.splice(e,0,0)}return r}function t1(t,e,n){let r=ue(e.type.schema).header_cell;for(let o=0;o<t.height;o++)if(e.nodeAt(t.map[n+o*t.width]).type!=r)return!1;return!0}var _=class tt extends T{constructor(e,n=e){let r=e.node(-1),o=q.get(r),s=e.start(-1),i=o.rectBetween(e.pos-s,n.pos-s),l=e.node(0),a=o.cellsInRect(i).filter(u=>u!=n.pos-s);a.unshift(n.pos-s);let c=a.map(u=>{let d=r.nodeAt(u);if(!d)throw new RangeError(`No cell with offset ${u} found`);let f=s+u+1;return new Kt(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){let r=e.resolve(n.map(this.$anchorCell.pos)),o=e.resolve(n.map(this.$headCell.pos));if(Tl(r)&&Tl(o)&&Ol(r,o)){let s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?tt.rowSelection(r,o):s&&this.isColSelection()?tt.colSelection(r,o):new tt(r,o)}return M.between(r,o)}content(){let e=this.$anchorCell.node(-1),n=q.get(e),r=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},i=[];for(let a=o.top;a<o.bottom;a++){let c=[];for(let u=a*n.width+o.left,d=o.left;d<o.right;d++,u++){let f=n.map[u];if(s[f])continue;s[f]=!0;let h=n.findCell(f),p=e.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);let m=o.left-h.left,g=h.right-o.right;if(m>0||g>0){let y=p.attrs;if(m>0&&(y=Bt(y,0,m)),g>0&&(y=Bt(y,y.colspan-g,g)),h.left<o.left){if(p=p.type.createAndFill(y),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else p=p.type.create(y,p.content)}if(h.top<o.top||h.bottom>o.bottom){let y={...p.attrs,rowspan:Math.min(h.bottom,o.bottom)-Math.max(h.top,o.top)};h.top<o.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}i.push(e.child(a).copy(b.from(c)))}let l=this.isColSelection()&&this.isRowSelection()?e:i;return new C(b.from(l),1,1)}replace(e,n=C.empty){let r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:l,$to:a}=o[i],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),i?C.empty:n)}let s=T.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,n){this.replace(e,new C(b.from(n),0,0))}forEachCell(e){let n=this.$anchorCell.node(-1),r=q.get(n),o=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let i=0;i<s.length;i++)e(n.nodeAt(s[i]),o+s[i])}isColSelection(){let e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){let r=e.node(-1),o=q.get(r),s=e.start(-1),i=o.findCell(e.pos-s),l=o.findCell(n.pos-s),a=e.node(0);return i.top<=l.top?(i.top>0&&(e=a.resolve(s+o.map[i.left])),l.bottom<o.height&&(n=a.resolve(s+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(s+o.map[l.left])),i.bottom<o.height&&(e=a.resolve(s+o.map[o.width*(o.height-1)+i.right-1]))),new tt(e,n)}isRowSelection(){let e=this.$anchorCell.node(-1),n=q.get(e),r=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-r),s=n.colCount(this.$headCell.pos-r);if(Math.min(o,s)>0)return!1;let i=o+this.$anchorCell.nodeAfter.attrs.colspan,l=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,l)==n.width}eq(e){return e instanceof tt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){let r=e.node(-1),o=q.get(r),s=e.start(-1),i=o.findCell(e.pos-s),l=o.findCell(n.pos-s),a=e.node(0);return i.left<=l.left?(i.left>0&&(e=a.resolve(s+o.map[i.top*o.width])),l.right<o.width&&(n=a.resolve(s+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(s+o.map[l.top*o.width])),i.right<o.width&&(e=a.resolve(s+o.map[o.width*(i.top+1)-1]))),new tt(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new tt(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new tt(e.resolve(n),e.resolve(r))}getBookmark(){return new n1(this.$anchorCell.pos,this.$headCell.pos)}};_.prototype.visible=!1;T.jsonID("cell",_);var n1=class th{constructor(e,n){this.anchor=e,this.head=n}map(e){return new th(e.map(this.anchor),e.map(this.head))}resolve(e){let n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&Ol(n,r)?new _(n,r):T.near(r,1)}};function r1(t){if(!(t.selection instanceof _))return null;let e=[];return t.selection.forEachCell((n,r)=>{e.push(U.node(r,r+n.nodeSize,{class:"selectedCell"}))}),B.create(t.doc,e)}function o1({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,o=t.depth;for(;o>=0&&!(t.after(o+1)<t.end(o));o--,n++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return n==r&&/row|table/.test(t.node(o).type.spec.tableRole)}function s1({$from:t,$to:e}){let n,r;for(let o=t.depth;o>0;o--){let s=t.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){n=s;break}}for(let o=e.depth;o>0;o--){let s=e.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return n!==r&&e.parentOffset===0}function i1(t,e,n){let r=(e||t).selection,o=(e||t).doc,s,i;if(r instanceof v&&(i=r.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")s=_.create(o,r.from);else if(i=="row"){let l=o.resolve(r.from+1);s=_.rowSelection(l,l)}else if(!n){let l=q.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=_.create(o,a+1,c)}}else r instanceof M&&o1(r)?s=M.create(o,r.from):r instanceof M&&s1(r)&&(s=M.create(o,r.$from.start(),r.$from.end()));return s&&(e||(e=t.tr)).setSelection(s),e}var l1=new z("fix-tables");function nh(t,e,n,r){let o=t.childCount,s=e.childCount;e:for(let i=0,l=0;i<s;i++){let a=e.child(i);for(let c=l,u=Math.min(o,i+3);c<u;c++)if(t.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<o&&t.child(l).sameMarkup(a)?nh(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function Rl(t,e){let n,r=(o,s)=>{o.type.spec.tableRole=="table"&&(n=a1(t,o,s,n))};return e?e.doc!=t.doc&&nh(e.doc,t.doc,0,r):t.doc.descendants(r),n}function a1(t,e,n,r){let o=q.get(e);if(!o.problems)return r;r||(r=t.tr);let s=[];for(let a=0;a<o.height;a++)s.push(0);for(let a=0;a<o.problems.length;a++){let c=o.problems[a];if(c.type=="collision"){let u=e.nodeAt(c.pos);if(!u)continue;let d=u.attrs;for(let f=0;f<d.rowspan;f++)s[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,Bt(d,d.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){let u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){let u=r.mapping.map(n);r.delete(u,u+e.nodeSize)}}let i,l;for(let a=0;a<s.length;a++)s[a]&&(i==null&&(i=a),l=a);for(let a=0,c=n+1;a<o.height;a++){let u=e.child(a),d=c+u.nodeSize,f=s[a];if(f>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);let p=[];for(let g=0;g<f;g++){let y=ue(t.schema)[h].createAndFill();y&&p.push(y)}let m=(a==0||i==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(m),p)}c=d}return r.setMeta(l1,{fixTables:!0})}function je(t){let e=t.selection,n=es(t),r=n.node(-1),o=n.start(-1),s=q.get(r);return{...e instanceof _?s.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):s.findCell(n.pos-o),tableStart:o,map:s,table:r}}function rh(t,{map:e,tableStart:n,table:r},o){let s=o>0?-1:0;t1(e,r,o+s)&&(s=o==0||o==e.width?null:0);for(let i=0;i<e.height;i++){let l=i*e.width+o;if(o>0&&o<e.width&&e.map[l-1]==e.map[l]){let a=e.map[l],c=r.nodeAt(a);t.setNodeMarkup(t.mapping.map(n+a),null,eh(c.attrs,o-e.colCount(a))),i+=c.attrs.rowspan-1}else{let a=s==null?ue(r.type.schema).cell:r.nodeAt(e.map[l+s]).type,c=e.positionAt(i,o,r);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function oh(t,e){if(!Re(t))return!1;if(e){let n=je(t);e(rh(t.tr,n,n.left))}return!0}function sh(t,e){if(!Re(t))return!1;if(e){let n=je(t);e(rh(t.tr,n,n.right))}return!0}function c1(t,{map:e,table:n,tableStart:r},o){let s=t.mapping.maps.length;for(let i=0;i<e.height;){let l=i*e.width+o,a=e.map[l],c=n.nodeAt(a),u=c.attrs;if(o>0&&e.map[l-1]==a||o<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(s).map(r+a),null,Bt(u,o-e.colCount(a)));else{let d=t.mapping.slice(s).map(r+a);t.delete(d,d+c.nodeSize)}i+=u.rowspan}}function ih(t,e){if(!Re(t))return!1;if(e){let n=je(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let o=n.right-1;c1(r,n,o),o!=n.left;o--){let s=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!s)throw new RangeError("No table found");n.table=s,n.map=q.get(s)}e(r)}return!0}function u1(t,e,n){var r;let o=ue(e.type.schema).header_cell;for(let s=0;s<t.width;s++)if(((r=e.nodeAt(t.map[s+n*t.width]))===null||r===void 0?void 0:r.type)!=o)return!1;return!0}function lh(t,{map:e,tableStart:n,table:r},o){let s=n;for(let c=0;c<o;c++)s+=r.child(c).nodeSize;let i=[],l=o>0?-1:0;u1(e,r,o+l)&&(l=o==0||o==e.height?null:0);for(let c=0,u=e.width*o;c<e.width;c++,u++)if(o>0&&o<e.height&&e.map[u]==e.map[u-e.width]){let d=e.map[u],f=r.nodeAt(d).attrs;t.setNodeMarkup(n+d,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{var a;let d=l==null?ue(r.type.schema).cell:(a=r.nodeAt(e.map[u+l*e.width]))===null||a===void 0?void 0:a.type,f=d?.createAndFill();f&&i.push(f)}return t.insert(s,ue(r.type.schema).row.create(null,i)),t}function ah(t,e){if(!Re(t))return!1;if(e){let n=je(t);e(lh(t.tr,n,n.top))}return!0}function ch(t,e){if(!Re(t))return!1;if(e){let n=je(t);e(lh(t.tr,n,n.bottom))}return!0}function d1(t,{map:e,table:n,tableStart:r},o){let s=0;for(let c=0;c<o;c++)s+=n.child(c).nodeSize;let i=s+n.child(o).nodeSize,l=t.mapping.maps.length;t.delete(s+r,i+r);let a=new Set;for(let c=0,u=o*e.width;c<e.width;c++,u++){let d=e.map[u];if(!a.has(d)){if(a.add(d),o>0&&d==e.map[u-e.width]){let f=n.nodeAt(d).attrs;t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(o<e.height&&d==e.map[u+e.width]){let f=n.nodeAt(d),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),m=e.positionAt(o+1,c,n);t.insert(t.mapping.slice(l).map(r+m),p),c+=h.colspan-1}}}}function uh(t,e){if(!Re(t))return!1;if(e){let n=je(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let o=n.bottom-1;d1(r,n,o),o!=n.top;o--){let s=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!s)throw new RangeError("No table found");n.table=s,n.map=q.get(n.table)}e(r)}return!0}function _f(t){let e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function f1({width:t,height:e,map:n},r){let o=r.top*t+r.left,s=o,i=(r.bottom-1)*t+r.left,l=o+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[s]==n[s-1]||r.right<t&&n[l]==n[l+1])return!0;s+=t,l+=t}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[o]==n[o-t]||r.bottom<e&&n[i]==n[i+t])return!0;o++,i++}return!1}function Il(t,e){let n=t.selection;if(!(n instanceof _)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=je(t),{map:o}=r;if(f1(o,r))return!1;if(e){let s=t.tr,i={},l=b.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){let f=o.map[u*o.width+d],h=r.table.nodeAt(f);if(!(i[f]||!h))if(i[f]=!0,a==null)a=f,c=h;else{_f(h)||(l=l.append(h.content));let p=s.mapping.map(f+r.tableStart);s.delete(p,p+h.nodeSize)}}if(a==null||c==null)return!0;if(s.setNodeMarkup(a+r.tableStart,null,{...eh(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){let u=a+1+c.content.size,d=_f(c)?a+1:u;s.replaceWith(d+r.tableStart,u+r.tableStart,l)}s.setSelection(new _(s.doc.resolve(a+r.tableStart))),e(s)}return!0}function Dl(t,e){let n=ue(t.schema);return h1(({node:r})=>n[r.type.spec.tableRole])(t,e)}function h1(t){return(e,n)=>{let r=e.selection,o,s;if(r instanceof _){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{var i;if(o=Qk(r.$from),!o)return!1;s=(i=zt(r.$from))===null||i===void 0?void 0:i.pos}if(o==null||s==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let l=o.attrs,a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});let u=je(e),d=e.tr;for(let h=0;h<u.right-u.left;h++)a.push(c?{...l,colwidth:c&&c[h]?[c[h]]:null}:l);let f;for(let h=u.top;h<u.bottom;h++){let p=u.map.positionAt(h,u.left,u.table);h==u.top&&(p+=o.nodeSize);for(let m=u.left,g=0;m<u.right;m++,g++)m==u.left&&h==u.top||d.insert(f=d.mapping.map(p+u.tableStart,1),t({node:o,row:h,col:m}).createAndFill(a[g]))}d.setNodeMarkup(s,t({node:o,row:u.top,col:u.left}),a[0]),r instanceof _&&d.setSelection(new _(d.doc.resolve(r.$anchorCell.pos),f?d.doc.resolve(f):void 0)),n(d)}return!0}}function dh(t,e){return function(n,r){if(!Re(n))return!1;let o=es(n);if(o.nodeAfter.attrs[t]===e)return!1;if(r){let s=n.tr;n.selection instanceof _?n.selection.forEachCell((i,l)=>{i.attrs[t]!==e&&s.setNodeMarkup(l,null,{...i.attrs,[t]:e})}):s.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[t]:e}),r(s)}return!0}}function p1(t){return function(e,n){if(!Re(e))return!1;if(n){let r=ue(e.schema),o=je(e),s=e.tr,i=o.map.cellsInRect(t=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:t=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=i.map(a=>o.table.nodeAt(a));for(let a=0;a<i.length;a++)l[a].type==r.header_cell&&s.setNodeMarkup(o.tableStart+i[a],r.cell,l[a].attrs);if(s.steps.length===0)for(let a=0;a<i.length;a++)s.setNodeMarkup(o.tableStart+i[a],r.header_cell,l[a].attrs);n(s)}return!0}}function Kf(t,e,n){let r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let o=0;o<r.length;o++){let s=e.table.nodeAt(r[o]);if(s&&s.type!==n.header_cell)return!1}return!0}function bn(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?p1(t):function(n,r){if(!Re(n))return!1;if(r){let o=ue(n.schema),s=je(n),i=n.tr,l=Kf("row",s,o),a=Kf("column",s,o),c=(t==="column"?l:t==="row"&&a)?1:0,u=t=="column"?{left:0,top:c,right:1,bottom:s.map.height}:t=="row"?{left:c,top:0,right:s.map.width,bottom:1}:s,d=t=="column"?a?o.cell:o.header_cell:t=="row"?l?o.cell:o.header_cell:o.cell;s.map.cellsInRect(u).forEach(f=>{let h=f+s.tableStart,p=i.doc.nodeAt(h);p&&i.setNodeMarkup(h,d,p.attrs)}),r(i)}return!0}}var cC=bn("row",{useDeprecatedLogic:!0}),uC=bn("column",{useDeprecatedLogic:!0}),fh=bn("cell",{useDeprecatedLogic:!0});function m1(t,e){if(e<0){let n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,o=t.before();r>=0;r--){let s=t.node(-1).child(r),i=s.lastChild;if(i)return o-1-i.nodeSize;o-=s.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;let n=t.node(-1);for(let r=t.indexAfter(-1),o=t.after();r<n.childCount;r++){let s=n.child(r);if(s.childCount)return o+1;o+=s.nodeSize}}return null}function Ll(t){return function(e,n){if(!Re(e))return!1;let r=m1(es(e),t);if(r==null)return!1;if(n){let o=e.doc.resolve(r);n(e.tr.setSelection(M.between(o,e1(o))).scrollIntoView())}return!0}}function hh(t,e){let n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Go(t,e){let n=t.selection;if(!(n instanceof _))return!1;if(e){let r=t.tr,o=ue(t.schema).cell.createAndFill().content;n.forEachCell((s,i)=>{s.content.eq(o)||r.replace(r.mapping.map(i+1),r.mapping.map(i+s.nodeSize-1),new C(o,0,0))}),r.docChanged&&e(r)}return!0}function g1(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;let o=e.child(0),s=o.type.spec.tableRole,i=o.type.schema,l=[];if(s=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content,u=a?0:Math.max(0,n-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=El(ue(i).row,new C(c,u,d)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(n||r?El(ue(i).row,new C(e,n,r)).content:e);else return null;return y1(i,l)}function y1(t,e){let n=[];for(let o=0;o<e.length;o++){let s=e[o];for(let i=s.childCount-1;i>=0;i--){let{rowspan:l,colspan:a}=s.child(i).attrs;for(let c=o;c<o+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let o=0;o<n.length;o++)r=Math.max(r,n[o]);for(let o=0;o<n.length;o++)if(o>=e.length&&e.push(b.empty),n[o]<r){let s=ue(t).cell.createAndFill(),i=[];for(let l=n[o];l<r;l++)i.push(s);e[o]=e[o].append(b.from(i))}return{height:e.length,width:r,rows:e}}function El(t,e){let n=t.createAndFill();return new Ke(n).replace(0,n.content.size,e).doc}function b1({width:t,height:e,rows:n},r,o){if(t!=r){let s=[],i=[];for(let l=0;l<n.length;l++){let a=n[l],c=[];for(let u=s[l]||0,d=0;u<r;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>r&&(f=f.type.createChecked(Bt(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)s[l+h]=(s[l+h]||0)+f.attrs.colspan}i.push(b.from(c))}n=i,t=r}if(e!=o){let s=[];for(let i=0,l=0;i<o;i++,l++){let a=[],c=n[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);i+d.attrs.rowspan>o&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,o-d.attrs.rowspan)},d.content)),a.push(d)}s.push(b.from(a))}n=s,e=o}return{width:t,height:e,rows:n}}function k1(t,e,n,r,o,s,i){let l=t.doc.type.schema,a=ue(l),c,u;if(o>e.width)for(let d=0,f=0;d<e.height;d++){let h=n.child(d);f+=h.nodeSize;let p=[],m;h.lastChild==null||h.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=u||(u=a.header_cell.createAndFill());for(let g=e.width;g<o;g++)p.push(m);t.insert(t.mapping.slice(i).map(f-1+r),p)}if(s>e.height){let d=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,o);p++){let g=p>=e.width?!1:n.nodeAt(e.map[m+p]).type==a.header_cell;d.push(g?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,b.from(d)),h=[];for(let p=e.height;p<s;p++)h.push(f);t.insert(t.mapping.slice(i).map(r+n.nodeSize-2),h)}return!!(c||u)}function Uf(t,e,n,r,o,s,i,l){if(i==0||i==e.height)return!1;let a=!1;for(let c=o;c<s;c++){let u=i*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;let f=n.nodeAt(d),{top:h,left:p}=e.findCell(d);t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...f.attrs,rowspan:i-h}),t.insert(t.mapping.slice(l).map(e.positionAt(i,p,n)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-i})),c+=f.attrs.colspan-1}}return a}function Jf(t,e,n,r,o,s,i,l){if(i==0||i==e.width)return!1;let a=!1;for(let c=o;c<s;c++){let u=c*e.width+i,d=e.map[u];if(e.map[u-1]==d){a=!0;let f=n.nodeAt(d),h=e.colCount(d),p=t.mapping.slice(l).map(d+r);t.setNodeMarkup(p,null,Bt(f.attrs,i-h,f.attrs.colspan-(i-h))),t.insert(p+f.nodeSize,f.type.createAndFill(Bt(f.attrs,0,i-h))),c+=f.attrs.rowspan-1}}return a}function qf(t,e,n,r,o){let s=n?t.doc.nodeAt(n-1):t.doc;if(!s)throw new Error("No table found");let i=q.get(s),{top:l,left:a}=r,c=a+o.width,u=l+o.height,d=t.tr,f=0;function h(){if(s=n?d.doc.nodeAt(n-1):d.doc,!s)throw new Error("No table found");i=q.get(s),f=d.mapping.maps.length}k1(d,i,s,n,c,u,f)&&h(),Uf(d,i,s,n,a,c,l,f)&&h(),Uf(d,i,s,n,a,c,u,f)&&h(),Jf(d,i,s,n,l,u,a,f)&&h(),Jf(d,i,s,n,l,u,c,f)&&h();for(let p=l;p<u;p++){let m=i.positionAt(p,a,s),g=i.positionAt(p,c,s);d.replace(d.mapping.slice(f).map(m+n),d.mapping.slice(f).map(g+n),new C(o.rows[p-l],0,0))}h(),d.setSelection(new _(d.doc.resolve(n+i.positionAt(l,a,s)),d.doc.resolve(n+i.positionAt(u-1,c-1,s)))),e(d)}var w1=Kn({ArrowLeft:Xo("horiz",-1),ArrowRight:Xo("horiz",1),ArrowUp:Xo("vert",-1),ArrowDown:Xo("vert",1),"Shift-ArrowLeft":Yo("horiz",-1),"Shift-ArrowRight":Yo("horiz",1),"Shift-ArrowUp":Yo("vert",-1),"Shift-ArrowDown":Yo("vert",1),Backspace:Go,"Mod-Backspace":Go,Delete:Go,"Mod-Delete":Go});function Qo(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Xo(t,e){return(n,r,o)=>{if(!o)return!1;let s=n.selection;if(s instanceof _)return Qo(n,r,T.near(s.$headCell,e));if(t!="horiz"&&!s.empty)return!1;let i=ph(o,t,e);if(i==null)return!1;if(t=="horiz")return Qo(n,r,T.near(n.doc.resolve(s.head+e),e));{let l=n.doc.resolve(i),a=Zf(l,t,e),c;return a?c=T.near(a,1):e<0?c=T.near(n.doc.resolve(l.before(-1)),-1):c=T.near(n.doc.resolve(l.after(-1)),1),Qo(n,r,c)}}}function Yo(t,e){return(n,r,o)=>{if(!o)return!1;let s=n.selection,i;if(s instanceof _)i=s;else{let a=ph(o,t,e);if(a==null)return!1;i=new _(n.doc.resolve(a))}let l=Zf(i.$headCell,t,e);return l?Qo(n,r,new _(i.$anchorCell,l)):!1}}function S1(t,e){let n=t.state.doc,r=zt(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new _(r))),!0):!1}function x1(t,e,n){if(!Re(t.state))return!1;let r=g1(n),o=t.state.selection;if(o instanceof _){r||(r={width:1,height:1,rows:[b.from(El(ue(t.state.schema).cell,n))]});let s=o.$anchorCell.node(-1),i=o.$anchorCell.start(-1),l=q.get(s).rectBetween(o.$anchorCell.pos-i,o.$headCell.pos-i);return r=b1(r,l.right-l.left,l.bottom-l.top),qf(t.state,t.dispatch,i,l,r),!0}else if(r){let s=es(t.state),i=s.start(-1);return qf(t.state,t.dispatch,i,q.get(s.node(-1)).findCell(s.pos-i),r),!0}else return!1}function C1(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;let r=Gf(t,e.target),o;if(e.shiftKey&&t.state.selection instanceof _)s(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=zt(t.state.selection.$anchor))!=null&&((n=Ml(t,e))===null||n===void 0?void 0:n.pos)!=o.pos)s(o,e),e.preventDefault();else if(!r)return;function s(a,c){let u=Ml(t,c),d=ht.getState(t.state)==null;if(!u||!Ol(a,u))if(d)u=a;else return;let f=new _(a,u);if(d||!t.state.selection.eq(f)){let h=t.state.tr.setSelection(f);d&&h.setMeta(ht,a.pos),t.dispatch(h)}}function i(){t.root.removeEventListener("mouseup",i),t.root.removeEventListener("dragstart",i),t.root.removeEventListener("mousemove",l),ht.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(ht,-1))}function l(a){let c=a,u=ht.getState(t.state),d;if(u!=null)d=t.state.doc.resolve(u);else if(Gf(t,c.target)!=r&&(d=Ml(t,e),!d))return i();d&&s(d,c)}t.root.addEventListener("mouseup",i),t.root.addEventListener("dragstart",i),t.root.addEventListener("mousemove",l)}function ph(t,e,n){if(!(t.state.selection instanceof M))return null;let{$head:r}=t.state.selection;for(let o=r.depth-1;o>=0;o--){let s=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){let i=r.before(o),l=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(l)?i:null}}return null}function Gf(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Ml(t,e){let n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:o}=n;return r>=0&&zt(t.state.doc.resolve(r))||zt(t.state.doc.resolve(o))}var M1=class{constructor(t,e){this.node=t,this.defaultCellMinWidth=e,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",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Nl(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,Nl(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function Nl(t,e,n,r,o,s){let i=0,l=!0,a=e.firstChild,c=t.firstChild;if(c){for(let d=0,f=0;d<c.childCount;d++){let{colspan:h,colwidth:p}=c.child(d).attrs;for(let m=0;m<h;m++,f++){let g=o==f?s:p&&p[m],y=g?g+"px":"";if(i+=g||r,g||(l=!1),a)a.style.width!=y&&(a.style.width=y),a=a.nextSibling;else{let w=document.createElement("col");w.style.width=y,e.appendChild(w)}}}for(;a;){var u;let d=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=d}l?(n.style.width=i+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=i+"px")}}var Se=new z("tableColumnResizing");function mh({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=M1,lastColumnResizable:o=!0}={}){let s=new R({key:Se,state:{init(i,l){var a;let c=(a=s.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,u=ue(l.schema).table.name;return r&&c&&(c[u]=(d,f)=>new r(d,n,f)),new v1(-1,!1)},apply(i,l){return l.apply(i)}},props:{attributes:i=>{let l=Se.getState(i);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(i,l)=>{A1(i,l,t,o)},mouseleave:i=>{T1(i)},mousedown:(i,l)=>{E1(i,l,e,n)}},decorations:i=>{let l=Se.getState(i);if(l&&l.activeHandle>-1)return D1(i,l.activeHandle)},nodeViews:{}}});return s}var v1=class Zo{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){let n=this,r=e.getMeta(Se);if(r&&r.setHandle!=null)return new Zo(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Zo(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let o=e.mapping.map(n.activeHandle,-1);return Tl(e.doc.resolve(o))||(o=-1),new Zo(o,n.dragging)}return n}};function A1(t,e,n,r){if(!t.editable)return;let o=Se.getState(t.state);if(o&&!o.dragging){let s=O1(e.target),i=-1;if(s){let{left:l,right:a}=s.getBoundingClientRect();e.clientX-l<=n?i=Xf(t,e,"left",n):a-e.clientX<=n&&(i=Xf(t,e,"right",n))}if(i!=o.activeHandle){if(!r&&i!==-1){let l=t.state.doc.resolve(i),a=l.node(-1),c=q.get(a),u=l.start(-1);if(c.colCount(l.pos-u)+l.nodeAfter.attrs.colspan-1==c.width-1)return}gh(t,i)}}}function T1(t){if(!t.editable)return;let e=Se.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&gh(t,-1)}function E1(t,e,n,r){var o;if(!t.editable)return!1;let s=(o=t.dom.ownerDocument.defaultView)!==null&&o!==void 0?o:window,i=Se.getState(t.state);if(!i||i.activeHandle==-1||i.dragging)return!1;let l=t.state.doc.nodeAt(i.activeHandle),a=N1(t,i.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(Se,{setDragging:{startX:e.clientX,startWidth:a}}));function c(d){s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",u);let f=Se.getState(t.state);f?.dragging&&(R1(t,f.activeHandle,Yf(f.dragging,d,n)),t.dispatch(t.state.tr.setMeta(Se,{setDragging:null})))}function u(d){if(!d.which)return c(d);let f=Se.getState(t.state);if(f&&f.dragging){let h=Yf(f.dragging,d,n);Qf(t,f.activeHandle,h,r)}}return Qf(t,i.activeHandle,a,r),s.addEventListener("mouseup",c),s.addEventListener("mousemove",u),e.preventDefault(),!0}function N1(t,e,{colspan:n,colwidth:r}){let o=r&&r[r.length-1];if(o)return o;let s=t.domAtPos(e),i=s.node.childNodes[s.offset].offsetWidth,l=n;if(r)for(let a=0;a<n;a++)r[a]&&(i-=r[a],l--);return i/l}function O1(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Xf(t,e,n,r){let o=n=="right"?-r:r,s=t.posAtCoords({left:e.clientX+o,top:e.clientY});if(!s)return-1;let{pos:i}=s,l=zt(t.state.doc.resolve(i));if(!l)return-1;if(n=="right")return l.pos;let a=q.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function Yf(t,e,n){let r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function gh(t,e){t.dispatch(t.state.tr.setMeta(Se,{setHandle:e}))}function R1(t,e,n){let r=t.state.doc.resolve(e),o=r.node(-1),s=q.get(o),i=r.start(-1),l=s.colCount(r.pos-i)+r.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let c=0;c<s.height;c++){let u=c*s.width+l;if(c&&s.map[u]==s.map[u-s.width])continue;let d=s.map[u],f=o.nodeAt(d).attrs,h=f.colspan==1?0:l-s.colCount(d);if(f.colwidth&&f.colwidth[h]==n)continue;let p=f.colwidth?f.colwidth.slice():I1(f.colspan);p[h]=n,a.setNodeMarkup(i+d,null,{...f,colwidth:p})}a.docChanged&&t.dispatch(a)}function Qf(t,e,n,r){let o=t.state.doc.resolve(e),s=o.node(-1),i=o.start(-1),l=q.get(s).colCount(o.pos-i)+o.nodeAfter.attrs.colspan-1,a=t.domAtPos(o.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&Nl(s,a.firstChild,a,r,l,n)}function I1(t){return Array(t).fill(0)}function D1(t,e){let n=[],r=t.doc.resolve(e),o=r.node(-1);if(!o)return B.empty;let s=q.get(o),i=r.start(-1),l=s.colCount(r.pos-i)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<s.height;c++){let u=l+c*s.width;if((l==s.width-1||s.map[u]!=s.map[u+1])&&(c==0||s.map[u]!=s.map[u-s.width])){var a;let d=s.map[u],f=i+d+o.nodeAt(d).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",!((a=Se.getState(t))===null||a===void 0)&&a.dragging&&n.push(U.node(i+d,i+d+o.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),n.push(U.widget(f,h))}}return B.create(t.doc,n)}function yh({allowTableNodeSelection:t=!1}={}){return new R({key:ht,state:{init(){return null},apply(e,n){let r=e.getMeta(ht);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;let{deleted:o,pos:s}=e.mapping.mapResult(n);return o?null:s}},props:{decorations:r1,handleDOMEvents:{mousedown:C1},createSelectionBetween(e){return ht.getState(e.state)!=null?e.state.selection:null},handleTripleClick:S1,handleKeyDown:w1,handlePaste:x1},appendTransaction(e,n,r){return i1(r,Rl(r,n),t)}})}function ur(t){return t==="left"||t==="right"||t==="center"?t:null}function L1(t){let e=(t.style.textAlign||"").trim().toLowerCase(),n=(t.getAttribute("align")||"").trim().toLowerCase();return ur(e||n)}function P1(t){return ur(t?.align)}function xh(){return{default:null,parseHTML:t=>L1(t),renderHTML:t=>{let e=ur(t.align);return Td(e)?{style:`text-align: ${e}`}:{}}}}function z1(t){var e;let n=t.parentElement,r=t.closest("table");if(!n||!r)return null;let o=Array.from(n.children).indexOf(t),s=(e=r.querySelectorAll("colgroup > col")[o])===null||e===void 0?void 0:e.getAttribute("width");return s?[parseInt(s,10)]:null}function Ch(t){let e=t.getAttribute("colwidth");return e?e.split(",").map(n=>parseInt(n,10)):z1(t)}var B1=/[ \t\r\n\f]+/g;function Mh(t){var e;return t.children.length>0?!1:((e=t.textContent)!==null&&e!==void 0?e:"").replace(B1,"")===""}function vh(t){let e=t.createAndFill();if(!e)throw new Error(`[tiptap error]: "${t.name}" has no default content to backfill.`);return e.content}function ns(t,e,n){if(!(n in e))return;let r=e[n];(r===1||r==="1"||r===null||r===void 0)&&delete t[n]}var rs=H.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:Ch},align:xh()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td",getAttrs:t=>Mh(t)?{}:!1,getContent:(t,e)=>vh(e.nodes[this.name])},{tag:"td"}]},renderHTML({HTMLAttributes:t}){let e=I(this.options.HTMLAttributes,t);return ns(e,t,"colspan"),ns(e,t,"rowspan"),["td",e,0]}}),ss=H.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:Ch},align:xh()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th",getAttrs:t=>Mh(t)?{}:!1,getContent:(t,e)=>vh(e.nodes[this.name])},{tag:"th"}]},renderHTML({HTMLAttributes:t}){let e=I(this.options.HTMLAttributes,t);return ns(e,t,"colspan"),ns(e,t,"rowspan"),["th",e,0]}}),is=H.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",I(this.options.HTMLAttributes,t),0]}});function Pl(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function bh(t,e,n,r,o,s){let i=0,l=!0,a=e.firstChild,c=t.firstChild;if(c!==null)for(let f=0,h=0;f<c.childCount;f+=1){let{colspan:p,colwidth:m}=c.child(f).attrs;for(let g=0;g<p;g+=1,h+=1){let y=o===h?s:m&&m[g],w=y?`${y}px`:"";if(i+=y||r,y||(l=!1),a){if(a.style.width!==w){let[k,x]=Pl(r,y);a.style.setProperty(k,x)}a=a.nextSibling}else{let k=document.createElement("col"),[x,E]=Pl(r,y);k.style.setProperty(x,E),e.appendChild(k)}}}for(;a;){var u;let f=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=f}let d=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);l&&!d?(n.style.width=`${i}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${i}px`)}var $1=class{constructor(t,e,n,r={}){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table"));for(let[o,s]of Object.entries(r))s!=null&&(o==="style"?this.table.style.cssText=String(s):this.table.setAttribute(o,String(s)));t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),bh(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.sameMarkup(this.node)?(this.node=t,bh(t,this.colgroup,this.table,this.cellMinWidth),!0):!1}ignoreMutation(t){let e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(n&&!r&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function H1(t,e,n,r){let o=0,s=!0,i=[],l=t.firstChild;if(!l)return{};for(let u=0,d=0;u<l.childCount;u+=1){let{colspan:f,colwidth:h}=l.child(u).attrs;for(let p=0;p<f;p+=1,d+=1){let m=n===d?r:h&&h[p];o+=m||e,m||(s=!1);let[g,y]=Pl(e,m);i.push(["col",{style:`${g}: ${y}`}])}}let a=s?`${o}px`:"",c=s?"":`${o}px`;return{colgroup:["colgroup",{},...i],tableWidth:a,tableMinWidth:c}}function kh(t,e){return e?t.createChecked(null,e):t.createAndFill()}function F1(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;let e={};return Object.keys(t.nodes).forEach(n=>{let r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function j1(t,e,n,r,o){let s=F1(t),i=[],l=[];for(let c=0;c<n;c+=1){let u=kh(s.cell,o);if(u&&l.push(u),r){let d=kh(s.header_cell,o);d&&i.push(d)}}let a=[];for(let c=0;c<e;c+=1)a.push(s.row.createChecked(null,r&&c===0?i:l));return s.table.createChecked(null,a)}function Ah(t){return t instanceof _}var ts=({editor:t})=>{let{selection:e}=t.state;if(!Ah(e))return!1;let n=0,r=cn(e.ranges[0].$from,o=>o.type.name==="table");return r?.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(n+=1)}),n!==e.ranges.length?!1:(t.commands.deleteTable(),!0)};function wh(t,e){let n=t.mapping.map(e),r=cn(t.selection.$from,i=>i.type.name==="table");if(r?.pos===n)return;let o=t.doc.nodeAt(n);if(!o)return;let s=n+o.nodeSize-1;t.setSelection(M.near(t.doc.resolve(s),-1))}function W1(t){let e="",n=0;for(;n<t.length;){if(t[n]==="\\"&&n+1<t.length){e+=t[n]+t[n+1],n+=2;continue}if(t[n]!=="`"){e+=t[n++];continue}let r=0;for(;n+r<t.length&&t[n+r]==="`";)r+=1;let o=n+r,s=!1;for(;o<t.length;){if(t[o]!=="`"){o+=1;continue}let i=0;for(;o+i<t.length&&t[o+i]==="`";)i+=1;if(i===r){let l=t.slice(n+r,o);e+=t.slice(n,n+r)+l.replace(/\\\||\|/g,a=>a==="|"?"\\|":a)+t.slice(o,o+r),n=o+r,s=!0;break}o+=i}s||(e+=t.slice(n,n+r),n+=r)}return e}function V1(t){return t.split(`
|
|
147
|
+
`).map(e=>!e.includes("|")||!e.includes("`")?e:W1(e)).join(`
|
|
148
|
+
`)}function _1(t){return(t||"").replaceAll(""," ").replace(/\s+/g," ").trim()}function Sh(t,e){return e?t.split(e).join(`
|
|
149
|
+
`):t}function K1(t){return t.replace(/\\.|\|/g,e=>e==="|"?"\\|":e)}function U1(t,e,n={}){if(!t||!t.content||t.content.length===0)return"";let r=[];t.content.forEach(f=>{let h=[];f.content&&f.content.forEach(p=>{let m="";p.content&&Array.isArray(p.content)&&p.content.length>1?m=p.content.map(k=>Sh(e.renderChildren(k),n.cellLineSeparator)).join(`
|
|
150
|
+
`):m=Sh(p.content?e.renderChildren(p.content):"",n.cellLineSeparator);let g=K1(_1(m.replace(/[ \t]*\r?\n[ \t]*/g,"<br>"))),y=p.type==="tableHeader",w=P1(p.attrs);h.push({text:g,isHeader:y,align:w})}),r.push(h)});let o=r.reduce((f,h)=>Math.max(f,h.length),0);if(o===0)return"";let s=Array.from({length:o}).fill(0);r.forEach(f=>{for(let p=0;p<o;p+=1){var h;let m=(((h=f[p])===null||h===void 0?void 0:h.text)||"").length;m>s[p]&&(s[p]=m),s[p]<3&&(s[p]=3)}});let i=(f,h)=>f+" ".repeat(Math.max(0,h-f.length)),l=r[0],a=l.some(f=>f.isHeader),c=Array.from({length:o}).fill(null);r.forEach(f=>{for(let p=0;p<o;p+=1){var h;!c[p]&&(!((h=f[p])===null||h===void 0)&&h.align)&&(c[p]=f[p].align)}});let u=`
|
|
151
|
+
`,d=Array.from({length:o}).map((f,h)=>a&&l[h]&&l[h].text||"");return u+=`| ${d.map((f,h)=>i(f,s[h])).join(" | ")} |
|
|
152
|
+
`,u+=`| ${s.map((f,h)=>{let p=Math.max(3,f),m=c[h];return m==="left"?`:${"-".repeat(p)}`:m==="right"?`${"-".repeat(p)}:`:m==="center"?`:${"-".repeat(p)}:`:"-".repeat(p)}).join(" | ")} |
|
|
153
|
+
`,(a?r.slice(1):r).forEach(f=>{u+=`| ${Array.from({length:o}).fill(0).map((h,p)=>i(f[p]&&f[p].text||"",s[p])).join(" | ")} |
|
|
154
|
+
`}),u}var J1=new z("preserveCellSelectionOnContextMenu");function q1(t,e){let n=t.posAtCoords({left:e.clientX,top:e.clientY});if(n)return n.pos;if(!(e.target instanceof Node))return null;try{return t.posAtDOM(e.target,0)}catch{return null}}function G1(t,e){let n=!1;return t.forEachCell((r,o)=>{e>=o&&e<o+r.nodeSize&&(n=!0)}),n}function X1(){return new R({key:J1,props:{handleDOMEvents:{mousedown(t,e){if(e.button!==2)return!1;let{selection:n}=t.state;if(!Ah(n)||n.ranges.length<2)return!1;let r=q1(t,e);return r==null||!G1(n,r)?!1:(e.preventDefault(),!0)}}}})}var ls=H.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:$1,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){let{colgroup:n,tableWidth:r,tableMinWidth:o}=H1(t,this.options.cellMinWidth),s=e.style;function i(){return s||(r?`width: ${r}`:`min-width: ${o}`)}let l=["table",I(this.options.HTMLAttributes,e,{style:i()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},l]:l},parseMarkdown:(t,e)=>{let n=[],r=Array.isArray(t.align)?t.align:[];if(t.header){let o=[];t.header.forEach((s,i)=>{var l;let a=ur((l=r[i])!==null&&l!==void 0?l:s.align),c=a?{align:a}:{};o.push(e.createNode("tableHeader",c,[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),n.push(e.createNode("tableRow",{},o))}return t.rows&&t.rows.forEach(o=>{let s=[];o.forEach((i,l)=>{var a;let c=ur((a=r[l])!==null&&a!==void 0?a:i.align),u=c?{align:c}:{};s.push(e.createNode("tableCell",u,[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},s))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>U1(t,e),markdownTokenizer:{name:"table",level:"block",start:t=>{let e=t.split(`
|
|
155
|
+
`);if(e.length<2)return-1;let n=e[1];return!/^[ \t|:]*-[ \t|:-]*$/.test(n)||!n.includes("|")?-1:e[0].includes("|")?0:-1},tokenize(t,e,n){let r=t.indexOf(`
|
|
156
|
+
|
|
157
|
+
`),o=r>=0?t.slice(0,r):t,s=o.split(`
|
|
158
|
+
`);if(s.length<2)return;let i=s[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(i)||!i.includes("|"))return;let l=V1(o);if(l===o)return;let a=n.blockTokens(l)[0];if(a?.type!=="table"||!a.raw)return;let c=a.raw.split(`
|
|
159
|
+
`).length,u=t.split(`
|
|
160
|
+
`).slice(0,c).join(`
|
|
161
|
+
`);return{...a,raw:u}}},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:s})=>{let i=j1(s.schema,t,e,n);if(o){let l=r.selection.from+1;r.replaceSelectionWith(i).scrollIntoView().setSelection(M.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>oh(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>sh(t,e),deleteColumn:()=>({state:t,dispatch:e})=>{let n=cn(t.selection.$from,r=>r.type.name==="table");return ih(t,e&&(r=>{n&&wh(r,n.pos),e(r)}))},addRowBefore:()=>({state:t,dispatch:e})=>ah(t,e),addRowAfter:()=>({state:t,dispatch:e})=>ch(t,e),deleteRow:()=>({state:t,dispatch:e})=>{let n=cn(t.selection.$from,r=>r.type.name==="table");return uh(t,e&&(r=>{n&&wh(r,n.pos),e(r)}))},deleteTable:()=>({state:t,dispatch:e})=>hh(t,e),mergeCells:()=>({state:t,dispatch:e})=>Il(t,e),splitCell:()=>({state:t,dispatch:e})=>Dl(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>bn("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>bn("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>fh(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Il(t,e)?!0:Dl(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>dh(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Ll(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Ll(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&Rl(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){let r=_.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}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:ts,"Mod-Backspace":ts,Delete:ts,"Mod-Delete":ts}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[mh({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],yh({allowTableNodeSelection:this.options.allowTableNodeSelection}),X1()]},addNodeView(){let t=this.options.View;return t?({node:e,view:n,HTMLAttributes:r})=>{let o=I(this.options.HTMLAttributes,r);return new t(e,this.options.cellMinWidth,n,o)}:null},extendNodeSchema(t){let e={name:t.name,options:t.options,storage:t.storage};return{tableRole:j(A(t,"tableRole",e))}}}),kC=$.create({name:"tableKit",addExtensions(){let t=[];return this.options.table!==!1&&t.push(ls.configure(this.options.table)),this.options.tableCell!==!1&&t.push(rs.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(ss.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(is.configure(this.options.tableRow)),t}});var zl=Wl.version;var BC="tiptap",$C=zl,Y1=Object.freeze({version:zl,Editor:Xn,Extension:$,Mark:oe,Node:H,mergeAttributes:I,getSchema:ro,StarterKit:ar,Image:cr,Plugin:R,PluginKey:z,Decoration:U,DecorationSet:B,TextSelection:M}),Q1=["onUpdate","onSelectionUpdate","onTransaction","onFocus","onBlur"];function Nh(t){let e={};return Q1.forEach(n=>{typeof t[n]=="function"&&(e[n]=t[n])}),e}function Z1(t){return Array.from(t||[]).filter(e=>e&&/^image\//.test(e.type))}function ew(t){let e=t||{},n=typeof e.sanitize=="function"?e.sanitize:u=>u,r=$.create({name:"rpShortcuts",addKeyboardShortcuts(){return{"Mod-k":()=>(e.onShortcut&&e.onShortcut("link"),!0),"Alt-F10":()=>(e.onShortcut&&e.onShortcut("toolbar"),!0)}}}),o=(u,d)=>{let f=Z1(u);return!f.length||typeof e.onImageFiles!="function"?!1:e.onImageFiles(f,{pos:d})!==!1},s=(u,d)=>!!d.defaultValidate(u)&&(typeof e.isAllowedUri!="function"||e.isAllowedUri(u)),i=e.starterKit||{},l=i.link===!1?!1:{openOnClick:!1,autolink:!0,linkOnPaste:!0,defaultProtocol:"https",protocols:["http","https","mailto","tel"],HTMLAttributes:{rel:"noopener noreferrer",target:null,class:null},...i.link&&typeof i.link=="object"?i.link:{},isAllowedUri:(u,d)=>s(u,d)&&(!i.link||typeof i.link.isAllowedUri!="function"||!!i.link.isAllowedUri(u,d))},a=typeof e.extensions=="function"?e.extensions(Y1):e.extensions,c=e.editorProps||{};return new Xn({element:e.element,content:e.content||"",editable:e.editable!==!1,autofocus:e.autofocus||!1,injectCSS:!1,extensions:[ar.configure({heading:{levels:[1,2,3,4]},...i,link:l}),e.image===!1?null:cr.configure({inline:!1,allowBase64:!1}),Cl.configure({placeholder:e.placeholder||""}),r].concat(Array.isArray(a)?a:[]).filter(Boolean),editorProps:{...c,attributes:e.attributes||{},transformPastedHTML:u=>n(typeof c.transformPastedHTML=="function"?c.transformPastedHTML(u):u),handlePaste:(u,d,f)=>o(d.clipboardData&&d.clipboardData.files,u.state.selection.from)||typeof c.handlePaste=="function"&&c.handlePaste(u,d,f)===!0,handleDrop:(u,d,f,h)=>{if(!h){let p=u.posAtCoords({left:d.clientX,top:d.clientY});if(o(d.dataTransfer&&d.dataTransfer.files,p?p.pos:u.state.selection.from))return d.preventDefault(),!0}return typeof c.handleDrop=="function"&&c.handleDrop(u,d,f,h)===!0}},...Nh(e)})}var HC=ew,tw=$.create({name:"rpMarkdownAttributes",addGlobalAttributes(){return[{types:["bulletList"],attributes:{bullet:{default:"-",rendered:!1},tight:{default:!0,rendered:!1}}},{types:["orderedList"],attributes:{delimiter:{default:".",rendered:!1},tight:{default:!0,rendered:!1}}},{types:["tableHeader","tableCell"],attributes:{align:{default:null,parseHTML:t=>t.style.textAlign||null,renderHTML:t=>t.align?{style:"text-align:"+t.align}:{}}}}]}}),nw=Vi.extend({addAttributes(){return{...this.parent(),meta:{default:null,rendered:!1}}}}),rw=H.create({name:"callout",group:"block",content:"block+",defining:!0,addAttributes(){return{kind:{default:"note",rendered:!1},label:{default:"Note",rendered:!1},form:{default:"bold",rendered:!1}}},parseHTML(){return[{tag:"div[data-rp-callout]"}]},renderHTML({node:t}){return["div",{"data-rp-callout":"","data-kind":t.attrs.kind,class:"rpe-callout"},["div",{class:"rpe-callout-label",contenteditable:"false"},t.attrs.label],["div",{class:"rpe-callout-body"},0]]}}),ow=oe.create({name:"code",excludes:"",code:!0,parseHTML(){return[{tag:"code"}]},renderHTML(){return["code",0]},addCommands(){return{toggleCode:()=>({commands:t})=>t.toggleMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}}}),Th=new z("rpCodeBreaks");function Eh(t){let e=[];return t.descendants((n,r)=>{if(!n.isText||!n.marks.some(s=>s.type.name==="code"))return;let o=n.text||"";for(let s=0;s<o.length-1;s++)(o[s]==="."||o[s]==="/")&&o[s+1]!=="."&&o[s+1]!=="/"&&e.push(U.widget(r+s+1,()=>document.createElement("wbr"),{side:-1,ignoreSelection:!0,key:"wbr"}))}),B.create(t,e)}var sw=$.create({name:"rpCodeBreaks",addProseMirrorPlugins(){return[new R({key:Th,state:{init:(t,e)=>Eh(e.doc),apply:(t,e)=>t.docChanged?Eh(t.doc):e},props:{decorations(t){return Th.getState(t)}}})]}}),iw=H.create({name:"rawMarkdown",group:"block",atom:!0,selectable:!0,draggable:!1,addAttributes(){return{source:{default:"",rendered:!1}}},parseHTML(){return[{tag:"div[data-rp-raw-md]"}]},renderHTML(){return["div",{"data-rp-raw-md":""}]},addNodeView(){return({node:t,getPos:e,editor:n})=>{let r=document.createElement("div");r.className="rpe-raw",r.setAttribute("data-rp-raw-md","");let o=document.createElement("div");o.className="rpe-raw-label",o.textContent="Markdown block (kept as source)";let s=document.createElement("textarea");s.className="rpe-raw-source",s.spellcheck=!1,s.value=t.attrs.source;let i=()=>{s.style.height="auto",s.style.height=s.scrollHeight+2+"px"};return s.rows=Math.max(1,String(t.attrs.source).split(`
|
|
162
|
+
`).length),s.readOnly=!n.isEditable,s.addEventListener("input",()=>{i();let l=typeof e=="function"?e():null;l!=null&&n.view.dispatch(n.view.state.tr.setNodeMarkup(l,void 0,{...t.attrs,source:s.value}))}),r.appendChild(o),r.appendChild(s),setTimeout(i,0),{dom:r,update(l){return l.type.name!=="rawMarkdown"?!1:(t=l,s.value!==l.attrs.source&&(s.value=l.attrs.source),s.readOnly=!n.isEditable,!0)},stopEvent:l=>l.target===s,ignoreMutation:()=>!0}}}});function Oh(t){return[ar.configure({heading:{levels:[1,2,3,4,5,6]},code:!1,codeBlock:!1,underline:!1,trailingNode:!1,link:{openOnClick:!1,autolink:!1,linkOnPaste:!0,HTMLAttributes:{rel:null,target:null,class:null},isAllowedUri:e=>!/^\s*(javascript|data|vbscript):/i.test(String(e||""))}}),ow,nw,cr.configure({inline:!1,allowBase64:!1}),ls.configure({resizable:!1}),is,ss,rs,rw,iw,tw,sw].concat(t||[])}function FC(){return ro(Oh())}function jC(t){let e=t||{},n=$.create({name:"rpDocsShortcuts",addKeyboardShortcuts(){return{"Mod-k":()=>(e.onShortcut&&e.onShortcut("link"),!0)}}});return new Xn({element:e.element,content:e.content||{type:"doc",content:[{type:"paragraph"}]},editable:e.editable!==!1,autofocus:!1,injectCSS:!1,enableContentCheck:!0,extensions:Oh([n]),editorProps:{attributes:e.attributes||{}},...Nh(e)})}export{BC as ENGINE,$C as ENGINE_VERSION,ew as createEditor,jC as createMarkdownEditor,HC as default,FC as markdownSchema,Y1 as tiptap};
|
|
163
|
+
//# sourceMappingURL=portal-rte-7B6VXIZO.js.map
|