@jant/core 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/commands/export.js +3 -1
- package/bin/commands/import-site.js +689 -216
- package/bin/commands/setup.js +136 -0
- package/bin/commands/site/export.js +71 -34
- package/bin/commands/site/pull-media.js +2 -6
- package/bin/commands/site/snapshot/export.js +18 -60
- package/bin/commands/site/snapshot/import.js +22 -23
- package/bin/lib/d1-query.js +87 -2
- package/bin/lib/hugo-markdown.js +4 -0
- package/bin/lib/site-pull-media.js +21 -28
- package/bin/lib/site-selection.js +10 -1
- package/bin/lib/site-snapshot.js +338 -3
- package/bin/lib/sql-export.js +68 -5
- package/bin/lib/wrangler-cli.js +9 -0
- package/bin/lib/zip-archive.js +187 -0
- package/dist/{app-K_Aa1MMn.js → app-ZcaI1kPN.js} +732 -217
- package/dist/client/.vite/manifest.json +20 -20
- package/dist/client/_assets/chunks/{create-editor-CD3FhrOB.js → create-editor-B-m7X7S5.js} +50 -46
- package/dist/client/_assets/chunks/{sortable-list-CgaL2jCs.js → sortable-list-BJyd-LXE.js} +1 -1
- package/dist/client/_assets/chunks/{unsafe-svg-0QCkP0vZ.js → unsafe-svg-BkscJx69.js} +2 -2
- package/dist/client/_assets/{client-GiYENVw8.css → client-DAhoqPdr.css} +1 -1
- package/dist/client/_assets/{client-auth-k8gJ6QJj.js → client-auth-CAMfTrKW.js} +1 -1
- package/dist/client/_assets/{client-compose-B_kDtWkW.js → client-compose-D6rExKVK.js} +1 -1
- package/dist/client/_assets/{client-VnFxJN7G.js → client-knSEyUJO.js} +1 -1
- package/dist/client/_assets/{client-manage-M90aSTOk.js → client-manage-sVOkqVbH.js} +1 -1
- package/dist/client/_assets/{client-settings-DfYs9n1F.js → client-settings-CGR_nZ78.js} +7 -7
- package/dist/{github-sync-BPAvT999.js → github-sync-Gw4orAHk.js} +799 -110
- package/dist/index.js +2 -2
- package/dist/node.js +9 -5
- package/package.json +13 -3
- package/src/__tests__/dev-scripts.test.ts +203 -0
- package/src/__tests__/export-collection-order.test.ts +276 -0
- package/src/__tests__/export-feed-ids.test.ts +184 -0
- package/src/__tests__/export-feed-order.test.ts +294 -0
- package/src/__tests__/export-hugo-build.test.ts +130 -0
- package/src/__tests__/export-import-roundtrip.test.ts +94 -0
- package/src/__tests__/export-service.test.ts +611 -28
- package/src/__tests__/export-smart-collection.test.ts +329 -0
- package/src/__tests__/helpers/hugo-site.ts +146 -0
- package/src/__tests__/import-site-command.test.ts +487 -1
- package/src/__tests__/mise-config.test.ts +75 -4
- package/src/__tests__/node-dev-tasks.test.ts +264 -0
- package/src/__tests__/site-export-canonical-import.test.ts +149 -0
- package/src/__tests__/snapshot-canonical-replay.test.ts +179 -0
- package/src/__tests__/snapshot-settings.test.ts +97 -0
- package/src/__tests__/snapshot-tables.test.ts +219 -0
- package/src/__tests__/sql-export.test.ts +173 -0
- package/src/__tests__/zip-archive.test.ts +106 -0
- package/src/app.tsx +15 -6
- package/src/client/components/__tests__/jant-settings-avatar.test.ts +1 -1
- package/src/client/components/__tests__/jant-settings-general.test.ts +21 -1
- package/src/client/components/jant-repo-picker-types.ts +6 -1
- package/src/client/components/jant-repo-picker.ts +4 -7
- package/src/client/components/jant-settings-general.ts +17 -12
- package/src/client/tiptap/__tests__/list-editing.test.ts +224 -86
- package/src/client/tiptap/__tests__/mark-exit.test.ts +1 -2
- package/src/client/tiptap/__tests__/markdown-clipboard.test.ts +26 -0
- package/src/client/tiptap/extensions.ts +0 -3
- package/src/client/tiptap/structural-keymap.ts +158 -47
- package/src/db/__tests__/d1-query.test.ts +56 -1
- package/src/i18n/locales/settings/en.po +8 -8
- package/src/i18n/locales/settings/en.ts +1 -1
- package/src/i18n/locales/settings/zh-Hans.po +8 -8
- package/src/i18n/locales/settings/zh-Hans.ts +1 -1
- package/src/i18n/locales/settings/zh-Hant.po +8 -8
- package/src/i18n/locales/settings/zh-Hant.ts +1 -1
- package/src/lib/__tests__/github-sync-repo-name.test.ts +40 -0
- package/src/lib/__tests__/image.test.ts +27 -1
- package/src/lib/__tests__/markdown-to-tiptap.test.ts +105 -0
- package/src/lib/__tests__/markdown.test.ts +10 -0
- package/src/lib/__tests__/resolve-config.test.ts +67 -0
- package/src/lib/__tests__/schemas.test.ts +27 -1
- package/src/lib/__tests__/timeline.test.ts +87 -0
- package/src/lib/__tests__/tiptap-to-markdown.test.ts +172 -4
- package/src/lib/discover.ts +3 -1
- package/src/lib/github-sync-repo-name.ts +45 -0
- package/src/lib/hugo-markdown.ts +46 -0
- package/src/lib/image.ts +17 -4
- package/src/lib/markdown-manager.ts +392 -2
- package/src/lib/post-body-html.ts +11 -4
- package/src/lib/resolve-config.ts +58 -1
- package/src/lib/schemas.ts +50 -5
- package/src/lib/thread-fold.ts +3 -3
- package/src/lib/timeline.ts +1 -1
- package/src/lib/tiptap-to-markdown.ts +13 -7
- package/src/lib/url.ts +20 -0
- package/src/lib/view.ts +2 -2
- package/src/node/__tests__/cli-setup.test.ts +163 -0
- package/src/node/__tests__/cli-site-snapshot.test.ts +67 -0
- package/src/node/__tests__/cli-snapshot-meta.test.ts +20 -0
- package/src/node/__tests__/runtime.test.ts +38 -0
- package/src/node/index.ts +2 -0
- package/src/node/request-handler.ts +3 -1
- package/src/routes/api/__tests__/posts.test.ts +24 -0
- package/src/routes/api/__tests__/upload.test.ts +34 -0
- package/src/routes/api/export.ts +3 -3
- package/src/routes/api/internal/sites.ts +0 -1
- package/src/routes/api/posts.ts +2 -0
- package/src/routes/api/public/posts.ts +21 -1
- package/src/routes/api/upload.ts +10 -3
- package/src/routes/compose.tsx +4 -0
- package/src/routes/dash/__tests__/github-sync-app.test.ts +365 -0
- package/src/routes/dash/settings.tsx +212 -70
- package/src/routes/pages/__tests__/post-page-round-trips.test.ts +211 -0
- package/src/routes/pages/__tests__/thread-order.test.ts +179 -0
- package/src/routes/pages/archive.tsx +17 -11
- package/src/routes/pages/featured.tsx +11 -5
- package/src/routes/pages/page.tsx +53 -31
- package/src/routes/pages/search.tsx +4 -2
- package/src/runtime/__tests__/readiness.test.ts +23 -0
- package/src/runtime/node.ts +49 -0
- package/src/runtime/readiness.ts +15 -0
- package/src/services/__tests__/bootstrap-setup-instance.test.ts +230 -0
- package/src/services/__tests__/custom-url.test.ts +34 -0
- package/src/services/__tests__/github-app-installations.test.ts +153 -0
- package/src/services/__tests__/github-sync-push.test.ts +46 -0
- package/src/services/__tests__/media.test.ts +31 -0
- package/src/services/__tests__/path.test.ts +56 -0
- package/src/services/__tests__/post-timeline.test.ts +127 -0
- package/src/services/__tests__/post.test.ts +74 -0
- package/src/services/bootstrap.ts +263 -44
- package/src/services/custom-url.ts +2 -2
- package/src/services/export-theme/layouts/_default/alias.html +27 -1
- package/src/services/export-theme/layouts/_default/list.html +2 -63
- package/src/services/export-theme/layouts/_default/rss.xml +27 -38
- package/src/services/export-theme/layouts/collections/list.html +3 -3
- package/src/services/export-theme/layouts/featured/list.html +1 -4
- package/src/services/export-theme/layouts/index.html +40 -26
- package/src/services/export-theme/layouts/partials/collection-members.html +100 -0
- package/src/services/export-theme/layouts/partials/collection-threads.html +33 -0
- package/src/services/export-theme/layouts/partials/featured-members.html +35 -0
- package/src/services/export-theme/layouts/partials/featured-thread.html +1 -1
- package/src/services/export-theme/layouts/partials/footer.html +1 -1
- package/src/services/export-theme/layouts/partials/head.html +1 -1
- package/src/services/export-theme/layouts/partials/header.html +5 -3
- package/src/services/export-theme/layouts/partials/jant-data.html +23 -0
- package/src/services/export-theme/layouts/partials/latest-members.html +48 -0
- package/src/services/export-theme/layouts/partials/smart-collection-members.html +129 -0
- package/src/services/export-theme/layouts/partials/thread-preview.html +1 -1
- package/src/services/export-theme/layouts/post/list.html +1 -1
- package/src/services/export-theme/layouts/smart_collection/list.html +24 -0
- package/src/services/export-theme/styles/main.css +0 -1
- package/src/services/export-theme/theme.toml +1 -1
- package/src/services/export.ts +620 -71
- package/src/services/github-app-installations.ts +171 -4
- package/src/services/github-sync.ts +69 -15
- package/src/services/mcp.ts +19 -1
- package/src/services/media.ts +8 -1
- package/src/services/path.ts +34 -1
- package/src/services/post.ts +214 -39
- package/src/services/site-admin.ts +3 -7
- package/src/services/site.ts +83 -31
- package/src/styles/ui.css +7 -1
- package/src/types/app-context.ts +16 -0
- package/src/types/bindings.ts +5 -0
- package/src/types/operations.ts +10 -0
- package/src/ui/dash/settings/GeneralContent.tsx +10 -8
- package/src/client/tiptap/exitable-marks.ts +0 -73
|
@@ -170,62 +170,66 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
170
170
|
`);return e.replaceWith(i,a,n.schema.text(o)),!0}):!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;let a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
|
171
171
|
|
|
172
172
|
`);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:e})=>{if(!this.options.exitOnArrowUp)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type||r.parentOffset!==0)return!1;let a=r.before();return a>0?!1:e.commands.insertDefaultBlock({pos:a})},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(A.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[ep({find:Ym,type:this.type,getAttributes:e=>({language:e[1]})}),ep({find:Xm,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new N({key:new P(`codeBlockVSCodeHandler`),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData(`text/plain`),r=t.clipboardData.getData(`vscode-editor-data`),i=(r?JSON.parse(r):void 0)?.mode;if(!n||!i)return!1;let{tr:a,schema:o}=e.state,s=o.text(n.replace(/\r\n?/g,`
|
|
173
|
-
`));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(j.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),Qm=Zm,$m=`
|
|
174
|
-
|
|
173
|
+
`));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(j.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),Qm=Zm,$m=`listItem`,eh=`textStyle`,th=/^\s*([-+*])\s$/,nh=U.create({name:`bulletList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul`}]},renderHTML({HTMLAttributes:e}){return[`ul`,V(this.options.HTMLAttributes,e),0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>e.type!==`list`||e.ordered?[]:{type:`bulletList`,content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
174
|
+
`):``,markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes($m,this.editor.getAttributes(eh)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=tp({find:th,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=tp({find:th,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(eh),editor:this.editor})),[e]}}),rh=(e,t,n)=>{let{selection:r}=e;if(!r.empty)return null;let{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let a=-1;for(let e=i.depth;e>0;--e)if(i.node(e).type.name===t){a=e;break}if(a<0)return null;let o=i.node(a),s=i.index(a);if(s+1>=o.childCount)return null;let c=o.child(s+1);if(!n.includes(c.type.name))return null;let l=e.schema.nodes[t],u=!1;if(c.forEach(e=>{e.type===l&&e.childCount>1&&(u=!0)}),!u)return null;let d=e.doc.resolve(i.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(e=>{f.push(e)}),f.length===0?null:{listItemDepth:a,nestedList:d,nestedListPos:i.after(),insertPos:i.after(a),items:f}},ih=(e,t,n,r)=>{let i=rh(e,n,r);if(!i)return!1;let{selection:a}=e,{nestedList:o,nestedListPos:s,insertPos:c,items:l}=i,u=e.tr;u.delete(s,s+o.nodeSize);let d=u.mapping.map(c);return u.insert(d,D.from(l)),u.setSelection(a.map(u.doc,u.mapping)),t&&t(u),!0},ah=(e,t,n)=>ih(e.state,e.view.dispatch,t,n),oh=(e,t)=>H.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>ah(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),sh=[[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`]],ch=`abcdefghijklmnopqrstuvwxyz`,lh=String.raw`\d+|[ivxlcdmIVXLCDM]+|${`[a-zA-Z]{1,2}`}`;function uh(e){let t=e,n=``;for(let[e,r]of sh)for(;t>=e;)n+=r,t-=e;return n}function dh(e){return uh(e).toUpperCase()}function fh(e){let t=e.toLowerCase(),n=0,r=0;for(;n<t.length;){let e=!1;for(let[i,a]of sh)if(t.startsWith(a,n)){r+=i,n+=a.length,e=!0;break}if(!e)return 0}return r}function ph(e){if(!/^[ivxlcdmIVXLCDM]+$/.test(e))return!1;let t=fh(e);return t<=0?!1:(e===e.toLowerCase()?uh(t):dh(t))===e}function mh(e){let t=e.toLowerCase();if(t.length===1)return t.charCodeAt(0)-97+1;if(t.length===2){let e=t.charCodeAt(0)-97,n=t.charCodeAt(1)-97;return(e+1)*26+n+1}return 0}function hh(e){if(e<=26)return ch[e-1];let t=Math.floor((e-1)/26)-1,n=(e-1)%26;return t<0?ch[n]:ch[t]+ch[n]}function gh(e){if(e&&!/^\d+$/.test(e)){if(ph(e))return e===e.toLowerCase()?`i`:`I`;if(/^[a-z]{1,2}$/.test(e))return`a`;if(/^[A-Z]{1,2}$/.test(e))return`A`}}function _h(e){if(/^\d+$/.test(e))return parseInt(e,10);let t=gh(e);if(t===`i`||t===`I`)return fh(e);if(t===`a`||t===`A`){let t=mh(e);return t>0?t:1}let n=parseInt(e,10);return Number.isNaN(n)?1:n}function vh(e,t){if(e===`numeric`)return String(t);switch(e){case`a`:return hh(t);case`A`:return hh(t).toUpperCase();case`i`:return uh(t);case`I`:return dh(t);default:return String(t)}}function yh(e){if(e.length===0)return!1;let t=gh(e[0])??`numeric`,n=_h(e[0]);if(n<1)return!1;for(let r=0;r<e.length;r++){let i=vh(t,n+r);if(e[r]!==i)return!1}return!0}function bh(e){return{type:gh(e),start:_h(e)}}function xh(e){let{type:t,start:n}=bh(e),r={};return t&&(r.type=t),n!==1&&(r.start=n),r}function Sh(e,t,n=`. `){let r=t+1;if(!e||e===`1`)return`${r}${n}`;switch(e){case`a`:return`${hh(r)}${n}`;case`A`:return`${hh(r).toUpperCase()}${n}`;case`i`:return`${uh(r)}${n}`;case`I`:return`${dh(r)}${n}`;default:return`${r}${n}`}}function Ch(e){let t=e.tokens?.[0];return!!(e.text&&e.tokens?.length===1&&t?.type===`list`&&t.ordered&&t.raw===e.text)}function wh(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:`text`,raw:e,text:e}])}var Th=U.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,V(this.options.HTMLAttributes,e),0]},markdownTokenName:`list_item`,parseMarkdown:(e,t)=>{if(e.type!==`list_item`)return[];let n=t.parseBlockChildren??t.parseChildren,r=[];if(e.tokens&&e.tokens.length>0){if(Ch(e))return{type:`listItem`,content:[{type:`paragraph`,content:wh(e.text||``,t)}]};if(e.tokens.some(e=>e.type===`paragraph`))r=n(e.tokens);else{let i=e.tokens[0];if(i&&i.type===`text`&&i.tokens&&i.tokens.length>0){if(r=[{type:`paragraph`,content:t.parseInline(i.tokens)}],e.tokens.length>1){let t=n(e.tokens.slice(1));r.push(...t)}}else r=n(e.tokens)}}return r.length===0&&(r=[{type:`paragraph`,content:[]}]),{type:`listItem`,content:r}},renderMarkdown:(e,t,n)=>vf(e,t,e=>{if(e.parentType===`bulletList`)return`- `;if(e.parentType===`orderedList`){var t,n;let r=((t=e.meta)==null||(t=t.parentAttrs)==null?void 0:t.start)||1;return Sh((n=e.meta)==null||(n=n.parentAttrs)==null?void 0:n.type,r-1+(e.index||0),`. `)}return`- `},n,{alignNestedToPrefix:n?.parentType===`orderedList`}),addExtensions(){return[oh(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)}}}),Eh=(e,t)=>{let{$from:n}=t.selection,r=R(e,t.schema),i=null,a=n.depth,o=n.pos,s=null;for(;a>0&&s===null;)i=n.node(a),i.type===r?s=a:(--a,--o);return s===null?null:{$pos:t.doc.resolve(o),depth:s}},Dh=(e,t)=>{let n=Eh(e,t);if(!n)return!1;let[,r]=Uu(t,e,n.$pos.pos+4);return r},Oh=(e,t,n)=>{let{$anchor:r}=e.selection,i=Math.max(0,r.pos-2),a=e.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},kh=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!ql(e.state,t)&&Oh(e.state,t,n)){let{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),i=[];r.node().descendants((e,n)=>{e.type.name===t&&i.push({node:e,pos:n})});let a=i.at(-1);if(!a)return!1;let o=e.state.doc.resolve(r.start()+a.pos+1);return e.chain().cut({from:n.start()-1,to:n.end()+1},o.end()).joinForward().run()}if(!ql(e.state,t)||!Zu(e.state))return!1;let{$from:r}=e.state.selection,i=r.depth-1;return r.node(i).type!==e.schema.nodes[t]||r.index(i)!==0?!1:e.chain().liftListItem(t).run()},Ah=(e,t)=>{let n=Dh(e,t),r=Eh(e,t);return!r||!n?!1:n>r.depth},jh=(e,t)=>{let n=Dh(e,t),r=Eh(e,t);return!r||!n?!1:n<r.depth},Mh=(e,t)=>{if(!ql(e.state,t)||!Xu(e.state,t))return!1;let{selection:n}=e.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:Ah(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():jh(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward()},Nh=(e,t,n)=>{let{state:r}=e,{selection:i}=r;if(!i.empty)return!1;let{$from:a}=i;if(a.parentOffset!==0||!a.parent.isTextblock||ql(r,t))return!1;let o=Wu(a);if(!o||!n.includes(o.type.name))return!1;let s=o.lastChild;if(!s||s.type.name!==t)return!1;let c=a.parent;if(!s.canReplace(s.childCount,s.childCount,D.from(c)))return!1;let l=a.before(),u=a.after(),d=l-2;return e.commands.command(({tr:e,dispatch:t})=>(t&&(e.delete(l,u).insert(d,D.from(c)),e.setSelection(j.create(e.doc,d+1)),e.scrollIntoView()),!0))},Ph=H.create({name:`listKeymap`,addOptions(){return{listTypes:[{itemName:`listItem`,wrapperNames:[`bulletList`,`orderedList`]},{itemName:`taskItem`,wrapperNames:[`taskList`]}]}},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&Mh(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&Mh(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&kh(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&kh(e,n,r)&&(t=!0)}),t},Tab:({editor:e})=>{for(let{itemName:t,wrapperNames:n}of this.options.listTypes)if(e.state.schema.nodes[t]!==void 0&&Nh(e,t,n))return!0;return!1}}}}),Fh=RegExp(`^(\\s*)(${lh})([.)])\\s+(.*)$`),Ih=/^\s/,Lh={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function Rh(e){return Fh.test(e.trimStart())}function zh(e){let t=e.trimStart();return Lh.bulletItem.test(t)||Rh(t)||Lh.heading.test(t)||Lh.thematicBreak.test(t)&&!t.startsWith(`-`)||/^>\s?/.test(t)||Lh.codeFence.test(t)||Lh.blockMath.test(t)}function Bh(e){return Object.values(Lh).some(t=>t.test(e))}function Vh(e){let t=[],n=[],r=!1;return e.forEach(e=>{if(r){n.push(e);return}if(e.trim()===``){r=!0,n.push(e);return}if(t.length>0&&zh(e)){r=!0,n.push(e);return}t.push(e)}),{paragraphLines:t,blockLines:n}}function Hh(e){let t=[],n=0,r=0;for(;n<e.length;){let i=e[n],a=i.match(Fh);if(!a)break;let[,o,s,c,l]=a,u=o.length,d=parseInt(s,10),f=isNaN(d)?gh(s):void 0,p=isNaN(d)?_h(s):d,m=[l],h=n+1,g=[i],_=!1;for(;h<e.length;){let t=e[h];if(t.match(Fh))break;if(t.trim()===``)g.push(t),m.push(``),_=!0,h+=1;else if(t.match(Ih)){let e=t.length-t.trimStart().length,n=u+s.length+1;g.push(t),m.push(t.slice(Math.min(e,n))),h+=1}else{if(_||Bh(t))break;g.push(t),m.push(t),h+=1}}t.push({indent:u,number:p,type:f,content:m.join(`
|
|
175
|
+
`).trim(),contentLines:m,raw:g.join(`
|
|
176
|
+
`)}),r=h,n=h}return[t,r]}var Uh=RegExp(`^(${lh})([.)])\\s+(.+)$`);function Wh(e){let t=e.split(`
|
|
177
|
+
`).filter(e=>e.trim().length>0);if(t.length===0)return null;let n=[];for(let e of t){let t=e.trim().match(Uh);if(!t)return null;n.push({marker:t[1],content:t[3]})}return yh(n.map(e=>e.marker))?{type:`orderedList`,attrs:xh(n[0].marker),content:n.map(e=>({type:`listItem`,content:[{type:`paragraph`,content:[{type:`text`,text:e.content}]}]}))}:null}function Gh(e,t,n){let r=[],i=0;for(;i<e.length;){let a=e[i];if(a.indent===t){let{paragraphLines:o,blockLines:s}=Vh(a.contentLines),c=o.join(`
|
|
178
|
+
`).trim(),l=[];c&&l.push({type:`paragraph`,raw:c,tokens:n.inlineTokens(c)});let u=s.join(`
|
|
179
|
+
`).trim();if(u){let e=n.blockTokens(u);l.push(...e)}let d=i+1,f=[];for(;d<e.length&&e[d].indent>t;)f.push(e[d]),d+=1;if(f.length>0){let e=Gh(f,Math.min(...f.map(e=>e.indent)),n);l.push({type:`list`,ordered:!0,start:f[0].number,typeMarker:f[0].type,items:e,raw:f.map(e=>e.raw).join(`
|
|
180
|
+
`)})}r.push({type:`list_item`,raw:a.raw,tokens:l}),i=d}else i+=1}return r}function Kh(e,t){return e.map(e=>{if(e.type!==`list_item`)return t.parseChildren([e])[0];let n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if(e.type===`paragraph`||e.type===`list`||e.type===`blockquote`||e.type===`code`)n.push(...t.parseChildren([e]));else if(e.type===`text`&&e.tokens){let r=t.parseChildren([e]);n.push({type:`paragraph`,content:r})}else{let r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:`listItem`,content:n}})}var qh=`listItem`,Jh=`textStyle`,Yh=/^(\d+)\.\s$/;function Xh(e){let t=e.match(/list-style-type\s*:\s*([^;]+)/i);if(!t)return null;switch(t[1].trim().toLowerCase()){case`upper-roman`:return`I`;case`lower-roman`:return`i`;case`upper-alpha`:case`upper-latin`:return`A`;case`lower-alpha`:case`lower-latin`:return`a`;default:return null}}var Zh=U.create({name:`orderedList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute(`start`)?parseInt(e.getAttribute(`start`)||``,10):1},type:{default:null,parseHTML:e=>{let t=e.getAttribute(`type`);if(t)return t;let n=e.getAttribute(`style`);if(n){let e=Xh(n);if(e)return e}let r=e.querySelector(`li`);if(r){let e=r.getAttribute(`style`);if(e){let t=Xh(e);if(t)return t}}return null}}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,type:n,...r}=e,i=V(this.options.HTMLAttributes,r);return t!==1&&(i.start=t),n&&n!==`1`&&(i.type=n),[`ol`,i,0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>{if(e.type!==`list`||!e.ordered)return[];let n=e.start||1,r=e.typeMarker,i=e.items?Kh(e.items,t):[],a={};return n!==1&&(a.start=n),r&&(a.type=r),Object.keys(a).length>0?{type:`orderedList`,attrs:a,content:i}:{type:`orderedList`,content:i}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
181
|
+
`):``,markdownTokenizer:{name:`orderedList`,level:`block`,start:()=>-1,tokenize:(e,t,n)=>{let r=e.split(`
|
|
182
|
+
`),[i,a]=Hh(r);if(i.length===0)return;let o=Gh(i,i[0].indent,n);if(o.length!==0)return{type:`list`,ordered:!0,start:i[0]?.number||1,typeMarker:i[0]?.type,items:o,raw:r.slice(0,a).join(`
|
|
183
|
+
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(qh,this.editor.getAttributes(Jh)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new N({props:{handlePaste:(e,t)=>{if((t.clipboardData?.getData(`text/html`))?.trim())return!1;let n=t.clipboardData?.getData(`text/plain`);if(!n)return!1;let r=Wh(n);if(!r)return!1;try{let t=e.state.schema.nodeFromJSON(r),n=e.state.tr.replaceSelectionWith(t);return e.dispatch(n),!0}catch{return!1}}}})]},addInputRules(){let e=(e,t)=>(!t.attrs.type||t.attrs.type===`1`)&&t.childCount+t.attrs.start===+e[1],t=tp({find:Yh,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=tp({find:Yh,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Jh)}),joinPredicate:e,editor:this.editor})),[t]}}),Qh=/^\s*(\[([( |x])?\])\s$/,$h=`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,eg=(e,t,n)=>{var r;return(n==null||(r=n.checkboxLabel)==null?void 0:r.call(n,e,t))||`Task item checkbox for ${e.textContent||`empty task item`}`},tg=U.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:e=>e.querySelector(`div`)??e}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,V(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>vf(e,t,`- [${e.attrs?.checked?`x`:` `}] `),addExtensions(){return this.options.nested?[oh(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`);o.style.cssText=$h;let l=e=>{let t=eg(e,e.attrs.checked,this.options.a11y);s.setAttribute(`aria-label`,t),o.textContent=t};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=Cu(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[tp({find:Qh,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),ng=U.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return[`ul`,V(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode(`taskList`,{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
184
|
+
`):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=hf(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(t){let r={type:`taskList`,raw:t.raw,items:t.items},i=e.slice(t.raw.length);return i.trim()?[r,...n.blockTokens(i)]:[r]}return n.blockTokens(e)},i=hf(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});H.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(nh.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(Th.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(Ph.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(Zh.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(tg.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(ng.configure(this.options.taskList)),e}});var rg=U.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,V(this.options.HTMLAttributes,e)]},renderText(){return`
|
|
185
|
+
`},renderMarkdown:()=>`
|
|
186
|
+
`,parseMarkdown:()=>({type:`hardBreak`}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),ig=rg,ag=` `,og=`\xA0`,sg=U.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,V(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===ag||n[0].text===ag||n[0].raw===og||n[0].text===og)&&r.length===1&&r[0].type===`text`&&(r[0].text===ag||r[0].text===og)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){var i,a;let e=Array.isArray(n==null||(i=n.previousNode)==null?void 0:i.content)?n.previousNode.content:[];return(n==null||(a=n.previousNode)==null?void 0:a.type)===`paragraph`&&e.length===0?ag:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),cg=sg,lg=new WeakSet,ug=new WeakSet;function dg(e){let t=e;return lg.add(t),t}function fg(e){return Array.isArray(e)&&lg.has(e)}function pg(e){return e.flatMap(e=>e==null?[]:Array.isArray(e)&&ug.has(e)&&!fg(e)?pg(e):[e])}function mg(e,t){if(e===`slot`)return 0;if(e instanceof Function){let n=e(t);return Array.isArray(n)&&!fg(n)&&!ug.has(n)?dg(n):n}let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);if(Array.isArray(n)){if(fg(n))return dg([e,r,n]);if(n.length===0)return dg([e,r]);let t=pg(n);return t.length===0?dg([e,r]):dg([e,r,...t])}return dg(n==null?[e,r]:[e,r,n])}var hg=(e,t)=>mg(e,t),gg=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,_g=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,vg=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,yg=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,bg=Of.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return hg(`strong`,{...V(this.options.HTMLAttributes,e),children:hg(`slot`,{})})},markdownTokenName:`strong`,parseMarkdown:(e,t)=>t.applyMark(`bold`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<strong>`,close:`</strong>`}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Qf({find:gg,type:this.type}),Qf({find:vg,type:this.type})]},addPasteRules(){return[np({find:_g,type:this.type}),np({find:yg,type:this.type})]}}),xg=bg,Sg=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Cg=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,wg=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Tg=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Eg=Of.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,V(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<em>`,close:`</em>`}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Qf({find:Sg,type:this.type}),Qf({find:wg,type:this.type})]},addPasteRules(){return[np({find:Cg,type:this.type}),np({find:Tg,type:this.type})]}}),Dg=Eg,Og=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,kg=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Ag=Of.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,V(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Qf({find:Og,type:this.type})]},addPasteRules(){return[np({find:kg,type:this.type})]}}),jg=Ag,Mg=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,Ng=`ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2`,Pg=`numeric`,Fg=`ascii`,Ig=`alpha`,Lg=`asciinumeric`,Rg=`alphanumeric`,zg=`domain`,Bg=`emoji`,Vg=`scheme`,Hg=`slashscheme`,Ug=`whitespace`;function Wg(e,t){return e in t||(t[e]=[]),t[e]}function Gg(e,t,n){t[Pg]&&(t[Lg]=!0,t[Rg]=!0),t[Fg]&&(t[Lg]=!0,t[Ig]=!0),t[Lg]&&(t[Rg]=!0),t[Ig]&&(t[Rg]=!0),t[Rg]&&(t[zg]=!0),t[Bg]&&(t[zg]=!0);for(let r in t){let t=Wg(r,n);t.indexOf(e)<0&&t.push(e)}}function Kg(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function qg(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}qg.groups={},qg.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;n<t.jr.length;n++){let r=t.jr[n][0],i=t.jr[n][1];if(i&&r.test(e))return i}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let i=0;i<e.length;i++)this.tt(e[i],t,n,r)},tr(e,t,n,r){r||=qg.groups;let i;return t&&t.j?i=t:(i=new qg(t),n&&r&&Gg(t,n,r)),this.jr.push([e,i]),i},ts(e,t,n,r){let i=this,a=e.length;if(!a)return i;for(let t=0;t<a-1;t++)i=i.tt(e[t]);return i.tt(e[a-1],t,n,r)},tt(e,t,n,r){r||=qg.groups;let i=this;if(t&&t.j)return i.j[e]=t,t;let a=t,o,s=i.go(e);return s?(o=new qg,Object.assign(o.j,s.j),o.jr.push.apply(o.jr,s.jr),o.jd=s.jd,o.t=s.t):o=new qg,a&&(r&&(o.t&&typeof o.t==`string`?Gg(a,Object.assign(Kg(o.t,r),n),r):n&&Gg(a,n,r)),o.t=a),i.j[e]=o,o}};var K=(e,t,n,r,i)=>e.ta(t,n,r,i),q=(e,t,n,r,i)=>e.tr(t,n,r,i),Jg=(e,t,n,r,i)=>e.ts(t,n,r,i),J=(e,t,n,r,i)=>e.tt(t,n,r,i),Yg=`WORD`,Xg=`UWORD`,Zg=`ASCIINUMERICAL`,Qg=`ALPHANUMERICAL`,$g=`LOCALHOST`,e_=`TLD`,t_=`UTLD`,n_=`SCHEME`,r_=`SLASH_SCHEME`,i_=`NUM`,a_=`WS`,o_=`NL`,s_=`OPENBRACE`,c_=`CLOSEBRACE`,l_=`OPENBRACKET`,u_=`CLOSEBRACKET`,d_=`OPENPAREN`,f_=`CLOSEPAREN`,p_=`OPENANGLEBRACKET`,m_=`CLOSEANGLEBRACKET`,h_=`FULLWIDTHLEFTPAREN`,g_=`FULLWIDTHRIGHTPAREN`,__=`LEFTCORNERBRACKET`,v_=`RIGHTCORNERBRACKET`,y_=`LEFTWHITECORNERBRACKET`,b_=`RIGHTWHITECORNERBRACKET`,x_=`FULLWIDTHLESSTHAN`,S_=`FULLWIDTHGREATERTHAN`,C_=`AMPERSAND`,w_=`APOSTROPHE`,T_=`ASTERISK`,E_=`AT`,D_=`BACKSLASH`,O_=`BACKTICK`,k_=`CARET`,A_=`COLON`,j_=`COMMA`,M_=`DOLLAR`,N_=`DOT`,P_=`EQUALS`,F_=`EXCLAMATION`,I_=`HYPHEN`,L_=`PERCENT`,R_=`PIPE`,z_=`PLUS`,B_=`POUND`,V_=`QUERY`,H_=`QUOTE`,U_=`FULLWIDTHMIDDLEDOT`,W_=`SEMI`,G_=`SLASH`,K_=`TILDE`,q_=`UNDERSCORE`,J_=`EMOJI`,Y_=`SYM`,X_=Object.freeze({__proto__:null,ALPHANUMERICAL:Qg,AMPERSAND:C_,APOSTROPHE:w_,ASCIINUMERICAL:Zg,ASTERISK:T_,AT:E_,BACKSLASH:D_,BACKTICK:O_,CARET:k_,CLOSEANGLEBRACKET:m_,CLOSEBRACE:c_,CLOSEBRACKET:u_,CLOSEPAREN:f_,COLON:A_,COMMA:j_,DOLLAR:M_,DOT:N_,EMOJI:J_,EQUALS:P_,EXCLAMATION:F_,FULLWIDTHGREATERTHAN:S_,FULLWIDTHLEFTPAREN:h_,FULLWIDTHLESSTHAN:x_,FULLWIDTHMIDDLEDOT:U_,FULLWIDTHRIGHTPAREN:g_,HYPHEN:I_,LEFTCORNERBRACKET:__,LEFTWHITECORNERBRACKET:y_,LOCALHOST:$g,NL:o_,NUM:i_,OPENANGLEBRACKET:p_,OPENBRACE:s_,OPENBRACKET:l_,OPENPAREN:d_,PERCENT:L_,PIPE:R_,PLUS:z_,POUND:B_,QUERY:V_,QUOTE:H_,RIGHTCORNERBRACKET:v_,RIGHTWHITECORNERBRACKET:b_,SCHEME:n_,SEMI:W_,SLASH:G_,SLASH_SCHEME:r_,SYM:Y_,TILDE:K_,TLD:e_,UNDERSCORE:q_,UTLD:t_,UWORD:Xg,WORD:Yg,WS:a_}),Z_=/[a-z]/,Q_=/\p{L}/u,$_=/\p{Emoji}/u,ev=/\d/,tv=/\s/,nv=`\r`,rv=`
|
|
187
|
+
`,iv=`️`,av=``,ov=``,sv=null,cv=null;function lv(e=[]){let t={};qg.groups=t;let n=new qg;sv??=pv(Mg),cv??=pv(Ng),J(n,`'`,w_),J(n,`{`,s_),J(n,`}`,c_),J(n,`[`,l_),J(n,`]`,u_),J(n,`(`,d_),J(n,`)`,f_),J(n,`<`,p_),J(n,`>`,m_),J(n,`(`,h_),J(n,`)`,g_),J(n,`「`,__),J(n,`」`,v_),J(n,`『`,y_),J(n,`』`,b_),J(n,`<`,x_),J(n,`>`,S_),J(n,`&`,C_),J(n,`*`,T_),J(n,`@`,E_),J(n,"`",O_),J(n,`^`,k_),J(n,`:`,A_),J(n,`,`,j_),J(n,`$`,M_),J(n,`.`,N_),J(n,`=`,P_),J(n,`!`,F_),J(n,`-`,I_),J(n,`%`,L_),J(n,`|`,R_),J(n,`+`,z_),J(n,`#`,B_),J(n,`?`,V_),J(n,`"`,H_),J(n,`/`,G_),J(n,`;`,W_),J(n,`~`,K_),J(n,`_`,q_),J(n,`\\`,D_),J(n,`・`,U_);let r=q(n,ev,i_,{[Pg]:!0});q(r,ev,r);let i=q(r,Z_,Zg,{[Lg]:!0}),a=q(r,Q_,Qg,{[Rg]:!0}),o=q(n,Z_,Yg,{[Fg]:!0});q(o,ev,i),q(o,Z_,o),q(i,ev,i),q(i,Z_,i);let s=q(n,Q_,Xg,{[Ig]:!0});q(s,Z_),q(s,ev,a),q(s,Q_,s),q(a,ev,a),q(a,Z_),q(a,Q_,a);let c=J(n,rv,o_,{[Ug]:!0}),l=J(n,nv,a_,{[Ug]:!0}),u=q(n,tv,a_,{[Ug]:!0});J(n,ov,u),J(l,rv,c),J(l,ov,u),q(l,tv,u),J(u,nv),J(u,rv),q(u,tv,u),J(u,ov,u);let d=q(n,$_,J_,{[Bg]:!0});J(d,`#`),q(d,$_,d),J(d,iv,d);let f=J(d,av);J(f,`#`),q(f,$_,d);let p=[[Z_,o],[ev,i]],m=[[Z_,null],[Q_,s],[ev,a]];for(let e=0;e<sv.length;e++)fv(n,sv[e],e_,Yg,p);for(let e=0;e<cv.length;e++)fv(n,cv[e],t_,Xg,m);Gg(e_,{tld:!0,ascii:!0},t),Gg(t_,{utld:!0,alpha:!0},t),fv(n,`file`,n_,Yg,p),fv(n,`mailto`,n_,Yg,p),fv(n,`http`,r_,Yg,p),fv(n,`https`,r_,Yg,p),fv(n,`ftp`,r_,Yg,p),fv(n,`ftps`,r_,Yg,p),Gg(n_,{scheme:!0,ascii:!0},t),Gg(r_,{slashscheme:!0,ascii:!0},t),e=e.sort((e,t)=>e[0]>t[0]?1:-1);for(let t=0;t<e.length;t++){let r=e[t][0],i=e[t][1]?{[Vg]:!0}:{[Hg]:!0};r.indexOf(`-`)>=0?i[zg]=!0:Z_.test(r)?ev.test(r)?i[Lg]=!0:i[Fg]=!0:i[Pg]=!0,Jg(n,r,r,i)}return Jg(n,`localhost`,$g,{ascii:!0}),n.jd=new qg(Y_),{start:n,tokens:Object.assign({groups:t},X_)}}function uv(e,t){let n=dv(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o<r;){let s=e,c=null,l=0,u=null,d=-1,f=-1;for(;o<r&&(c=s.go(n[o]));)s=c,s.accepts()?(d=0,f=0,u=s):d>=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function dv(e){let t=[],n=e.length,r=0;for(;r<n;){let i=e.charCodeAt(r),a,o=i<55296||i>56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function fv(e,t,n,r,i){let a,o=t.length;for(let n=0;n<o-1;n++){let o=t[n];e.j[o]?a=e.j[o]:(a=new qg(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new qg(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function pv(e){let t=[],n=[],r=0;for(;r<e.length;){let i=0;for(;`0123456789`.indexOf(e[r+i])>=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var mv={defaultProtocol:`http`,events:null,format:gv,formatHref:gv,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function hv(e,t=null){let n=Object.assign({},mv);e&&(n=Object.assign(n,e instanceof hv?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e<r.length;e++)i.push(r[e].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=i}hv.prototype={o:mv,ignoreTags:[],defaultRender(e){return e},check(e){return this.get(`validate`,e.toString(),e)},get(e,t,n){let r=t!=null,i=this.o[e];return i&&(typeof i==`object`?(i=n.t in i?i[n.t]:mv[e],typeof i==`function`&&r&&(i=i(t,n))):typeof i==`function`&&r&&(i=i(t,n.t,n)),i)},getObj(e,t,n){let r=this.o[e];return typeof r==`function`&&t!=null&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get(`render`,null,e)||this.defaultRender)(t,e.t,e)}};function gv(e){return e}function _v(e,t){this.t=`token`,this.v=e,this.tk=t}_v.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get(`truncate`,t,this),r=e.get(`format`,t,this);return n&&r.length>n?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=mv.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);return o.href=r,s&&(o.class=s),c&&(o.target=c),l&&(o.rel=l),u&&Object.assign(o,u),{tagName:i,attributes:o,content:a,eventListeners:d}}};function vv(e,t){class n extends _v{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}var yv=vv(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),bv=vv(`text`),xv=vv(`nl`),Sv=vv(`url`,{isLink:!0,toHref(e=mv.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==$g&&e[1].t===A_}}),Cv=e=>new qg(e);function wv({groups:e}){let t=e.domain.concat([C_,T_,E_,D_,O_,k_,M_,P_,I_,i_,L_,R_,z_,B_,G_,Y_,K_,q_]),n=[w_,A_,j_,N_,F_,L_,V_,H_,W_,p_,m_,s_,c_,u_,l_,d_,f_,h_,g_,__,v_,y_,b_,x_,S_],r=[C_,w_,T_,D_,O_,k_,M_,P_,I_,s_,c_,L_,R_,z_,B_,V_,G_,Y_,K_,q_],i=Cv(),a=J(i,K_);K(a,r,a),K(a,e.domain,a);let o=Cv(),s=Cv(),c=Cv();K(i,e.domain,o),K(i,e.scheme,s),K(i,e.slashscheme,c),K(o,r,a),K(o,e.domain,o);let l=J(o,E_);J(a,E_,l),J(s,E_,l),J(c,E_,l);let u=J(a,N_);K(u,r,a),K(u,e.domain,a);let d=Cv();K(l,e.domain,d),K(d,e.domain,d);let f=J(d,N_);K(f,e.domain,d);let p=Cv(yv);K(f,e.tld,p),K(f,e.utld,p),J(l,$g,p);let m=J(d,I_);J(m,I_,m),K(m,e.domain,d),K(p,e.domain,d),J(p,N_,f),J(p,I_,m);let h=J(o,I_),g=J(o,N_);J(h,I_,h),K(h,e.domain,o),K(g,r,a),K(g,e.domain,o);let _=Cv(Sv);K(g,e.tld,_),K(g,e.utld,_),K(_,e.domain,o),K(_,r,a),J(_,N_,g),J(_,I_,h),J(_,E_,l);let v=J(_,A_),y=Cv(Sv);K(v,e.numeric,y);let b=Cv(Sv),x=Cv();K(b,t,b),K(b,n,x),K(x,t,b),K(x,n,x),J(_,G_,b),J(y,G_,b);let S=J(s,A_),C=J(J(J(c,A_),G_),G_);K(s,e.domain,o),J(s,N_,g),J(s,I_,h),K(c,e.domain,o),J(c,N_,g),J(c,I_,h),K(S,e.domain,b),J(S,G_,b),J(S,V_,b),K(C,e.domain,b),K(C,t,b),J(C,G_,b);let w=[[s_,c_],[l_,u_],[d_,f_],[p_,m_],[h_,g_],[__,v_],[y_,b_],[x_,S_]];for(let e=0;e<w.length;e++){let[r,i]=w[e],a=J(b,r);J(x,r,a);let o=Cv(Sv);K(a,t,o);let s=Cv();K(a,n,s),J(a,i,b),K(o,t,o),K(o,n,s),K(s,t,o),K(s,n,s),J(o,i,b),J(s,i,b)}return J(i,$g,_),J(i,o_,xv),{start:i,tokens:X_}}function Tv(e,t,n){let r=n.length,i=0,a=[],o=[];for(;i<r;){let s=e,c=null,l=null,u=0,d=null,f=-1;for(;i<r&&!(c=s.go(n[i].t));)o.push(n[i++]);for(;i<r&&(l=c||s.go(n[i].t));)c=null,s=l,s.accepts()?(f=0,d=s):f>=0&&f++,i++,u++;if(f<0)i-=u,i<r&&(o.push(n[i]),i++);else{o.length>0&&(a.push(Ev(bv,t,o)),o=[]),i-=f,u-=f;let e=d.t,r=n.slice(i-u,i);a.push(Ev(e,t,r))}}return o.length>0&&a.push(Ev(bv,t,o)),a}function Ev(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var Dv=typeof console<`u`&&console&&console.warn||(()=>{}),Ov=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,Y={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function kv(){return qg.groups={},Y.scanner=null,Y.parser=null,Y.tokenQueue=[],Y.pluginQueue=[],Y.customSchemes=[],Y.initialized=!1,Y}function Av(e,t=!1){if(Y.initialized&&Dv(`linkifyjs: already initialized - will not register custom scheme "${e}" ${Ov}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format.
|
|
175
188
|
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
176
189
|
2. Cannot start or end with "-"
|
|
177
|
-
3. "-" cannot repeat`);Y.customSchemes.push([e,t])}function Qg(){Y.scanner=Ag(Y.customSchemes);for(let e=0;e<Y.tokenQueue.length;e++)Y.tokenQueue[e][1]({scanner:Y.scanner});Y.parser=Gg(Y.scanner.tokens);for(let e=0;e<Y.pluginQueue.length;e++)Y.pluginQueue[e][1]({scanner:Y.scanner,parser:Y.parser});return Y.initialized=!0,Y}function $g(e){return Y.initialized||Qg(),Kg(Y.parser.start,e,jg(Y.scanner.start,e))}$g.scan=jg;function e_(e,t=null,n=null){if(t&&typeof t==`object`){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new Ig(n),i=$g(e),a=[];for(let e=0;e<i.length;e++){let n=i[e];n.isLink&&(!t||n.t===t)&&r.check(n)&&a.push(n.toFormattedObject(r))}return a}var t_=`[\0- \xA0 -\u2029 ]`,n_=new RegExp(t_),r_=RegExp(`${t_}$`),i_=new RegExp(t_,`g`);function a_(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function o_(e){return new N({key:new P(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r;if(Vu(du(n.doc,[...t])).forEach(({newRange:t})=>{let n=fu(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!r_.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(n_).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=$g(n).map(t=>t.toObject(e.defaultProtocol));if(!a_(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{Hu(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function s_(e){return new N({key:new P(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.editor.view.dom;i=t.closest(`a`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){let n=Ru(t.state,e.type.name),r=i.href??n.href,o=i.target??n.target;r&&(window.open(r,o),a=!0)}return a}}})}var c_=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,l_=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function u_(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function d_(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"){r+=1;continue}if(n===0&&u_(e,r)){r+=1;continue}let i=0;for(;r<t&&e[r]==="`";)i+=1,r+=1;n===0?n=i:i===n&&(n=0)}return n>0}function f_(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||u_(e,t.index??0)||d_(e,t.index??0)?!1:!!r.trim()&&n(i)}function p_(e){let[t,n,r,,i,a,o]=e,s=i??a??o;return{index:e.index??0,text:t,replaceWith:n,data:{href:r,title:s||null,markdown:!0}}}function m_(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function h_(e){return{href:e.data?.href,title:e.data?.title??null}}function g_(e){let t=Qf({find:t=>{let n=c_.exec(t);return!n||!f_(t,n,e.isAllowedHref)?null:p_(n)},type:e.type,getAttributes:h_});return new Cf({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function __(e){let t=np({find:t=>{let n=[];for(let r of t.matchAll(l_))f_(t,r,e.isAllowedHref)&&n.push(p_(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>m_(t,e)));return[...n,...r]},type:e.type,getAttributes:h_});return new kf({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.match.data?.markdown&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function v_(e){return new N({key:new P(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i}=e,{state:a}=t,{selection:o}=a,{empty:s}=o;if(s)return!1;let c=``;r.content.forEach(e=>{c+=e.textContent});let l=e_(c,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===c);return!c||!l||i!==void 0&&!i(l.value)?!1:e.editor.commands.setMark(e.type,{href:l.href})}}})}function y_(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(i_,``).match(RegExp(`^(?:(?:${n.map(e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)).join(`|`)}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,`i`))}var b_=Of.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{if(typeof e==`string`){Zg(e);return}Zg(e.scheme,e.optionalSlashes)})},onDestroy(){Xg()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,class:null},isAllowedUri:(e,t)=>!!y_(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes(`@`))return!0;let r=(e.includes(`@`)?e.split(`@`).pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target??null},rel:{default:this.options.HTMLAttributes.rel??null},class:{default:this.options.HTMLAttributes.class??null},title:{default:null}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!y_(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!y_(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,V(this.options.HTMLAttributes,e),0]:[`a`,V(this.options.HTMLAttributes,{...e,href:``}),0]},markdownTokenName:`link`,parseMarkdown:(e,t)=>t.applyMark(`link`,t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{let n=e.attrs?.href??``,r=e.attrs?.title??``,i=t.renderChildren(e);return r?`[${i}](${n} "${r}")`:`[${i}](${n})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!y_(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!y_(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addInputRules(){return this.options.markdownLinks?[g_({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!y_(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let e=e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options;e_(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!y_(e,n),protocols:n,defaultProtocol:r})).forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t};return this.options.markdownLinks?[__({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!y_(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[np({find:e,type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(o_({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!y_(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(s_({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(v_({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),x_=b_,S_=new WeakSet,C_=new WeakSet;function w_(e){let t=e;return S_.add(t),t}function T_(e){return Array.isArray(e)&&S_.has(e)}function E_(e){return e.flatMap(e=>e==null?[]:Array.isArray(e)&&C_.has(e)&&!T_(e)?E_(e):[e])}function D_(e,t){if(e===`slot`)return 0;if(e instanceof Function){let n=e(t);return Array.isArray(n)&&!T_(n)&&!C_.has(n)?w_(n):n}let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);if(Array.isArray(n)){if(T_(n))return w_([e,r,n]);if(n.length===0)return w_([e,r]);let t=E_(n);return t.length===0?w_([e,r]):w_([e,r,...t])}return w_(n==null?[e,r]:[e,r,n])}var O_=(e,t)=>D_(e,t),k_=(e,t)=>{let{state:n}=e,{selection:r}=n;if(!r.empty)return!1;let{$from:i}=r;if(i.parentOffset!==0)return!1;let a=i.depth-1;if(a<0)return!1;let o=i.node(a),s=i.index(a);if(s===0)return!1;if(o.type===t)return e.commands.lift(t.name);let c=o.child(s-1);if(c.type!==t||!c.lastChild?.isTextblock)return!1;let l=i.before()-1-1;return e.commands.command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=i.parent.content,r=new k(n,0,0);return e.replace(l,i.after(),r),e.setSelection(j.create(e.doc,l+n.size)),e.scrollIntoView(),t(e),!0})},A_=/^\s*>\s$/,j_=U.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return O_(`blockquote`,{...V(this.options.HTMLAttributes,e),children:O_(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(`
|
|
190
|
+
3. "-" cannot repeat`);Y.customSchemes.push([e,t])}function jv(){Y.scanner=lv(Y.customSchemes);for(let e=0;e<Y.tokenQueue.length;e++)Y.tokenQueue[e][1]({scanner:Y.scanner});Y.parser=wv(Y.scanner.tokens);for(let e=0;e<Y.pluginQueue.length;e++)Y.pluginQueue[e][1]({scanner:Y.scanner,parser:Y.parser});return Y.initialized=!0,Y}function Mv(e){return Y.initialized||jv(),Tv(Y.parser.start,e,uv(Y.scanner.start,e))}Mv.scan=uv;function Nv(e,t=null,n=null){if(t&&typeof t==`object`){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new hv(n),i=Mv(e),a=[];for(let e=0;e<i.length;e++){let n=i[e];n.isLink&&(!t||n.t===t)&&r.check(n)&&a.push(n.toFormattedObject(r))}return a}var Pv=`[\0- \xA0 -\u2029 ]`,Fv=new RegExp(Pv),Iv=RegExp(`${Pv}$`),Lv=new RegExp(Pv,`g`);function Rv(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function zv(e){return new N({key:new P(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r;if(Vu(du(n.doc,[...t])).forEach(({newRange:t})=>{let n=fu(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!Iv.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(Fv).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=Mv(n).map(t=>t.toObject(e.defaultProtocol));if(!Rv(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{Hu(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function Bv(e){return new N({key:new P(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.editor.view.dom;i=t.closest(`a`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){let n=Ru(t.state,e.type.name),r=i.href??n.href,o=i.target??n.target;r&&(window.open(r,o),a=!0)}return a}}})}var Vv=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,Hv=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function Uv(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function Wv(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"){r+=1;continue}if(n===0&&Uv(e,r)){r+=1;continue}let i=0;for(;r<t&&e[r]==="`";)i+=1,r+=1;n===0?n=i:i===n&&(n=0)}return n>0}function Gv(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||Uv(e,t.index??0)||Wv(e,t.index??0)?!1:!!r.trim()&&n(i)}function Kv(e){let[t,n,r,,i,a,o]=e,s=i??a??o;return{index:e.index??0,text:t,replaceWith:n,data:{href:r,title:s||null,markdown:!0}}}function qv(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function Jv(e){return{href:e.data?.href,title:e.data?.title??null}}function Yv(e){let t=Qf({find:t=>{let n=Vv.exec(t);return!n||!Gv(t,n,e.isAllowedHref)?null:Kv(n)},type:e.type,getAttributes:Jv});return new Cf({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function Xv(e){let t=np({find:t=>{let n=[];for(let r of t.matchAll(Hv))Gv(t,r,e.isAllowedHref)&&n.push(Kv(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>qv(t,e)));return[...n,...r]},type:e.type,getAttributes:Jv});return new kf({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.match.data?.markdown&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function Zv(e){return new N({key:new P(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i}=e,{state:a}=t,{selection:o}=a,{empty:s}=o;if(s)return!1;let c=``;r.content.forEach(e=>{c+=e.textContent});let l=Nv(c,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===c);return!c||!l||i!==void 0&&!i(l.value)?!1:e.editor.commands.setMark(e.type,{href:l.href})}}})}function Qv(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(Lv,``).match(RegExp(`^(?:(?:${n.map(e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)).join(`|`)}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,`i`))}var $v=Of.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{if(typeof e==`string`){Av(e);return}Av(e.scheme,e.optionalSlashes)})},onDestroy(){kv()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,class:null},isAllowedUri:(e,t)=>!!Qv(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes(`@`))return!0;let r=(e.includes(`@`)?e.split(`@`).pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target??null},rel:{default:this.options.HTMLAttributes.rel??null},class:{default:this.options.HTMLAttributes.class??null},title:{default:null}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!Qv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!Qv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,V(this.options.HTMLAttributes,e),0]:[`a`,V(this.options.HTMLAttributes,{...e,href:``}),0]},markdownTokenName:`link`,parseMarkdown:(e,t)=>t.applyMark(`link`,t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{let n=e.attrs?.href??``,r=e.attrs?.title??``,i=t.renderChildren(e);return r?`[${i}](${n} "${r}")`:`[${i}](${n})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!Qv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!Qv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addInputRules(){return this.options.markdownLinks?[Yv({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!Qv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let e=e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options;Nv(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!Qv(e,n),protocols:n,defaultProtocol:r})).forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t};return this.options.markdownLinks?[Xv({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!Qv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[np({find:e,type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(zv({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!Qv(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(Bv({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(Zv({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),ey=$v,ty=(e,t)=>{let{state:n}=e,{selection:r}=n;if(!r.empty)return!1;let{$from:i}=r;if(i.parentOffset!==0)return!1;let a=i.depth-1;if(a<0)return!1;let o=i.node(a),s=i.index(a);if(s===0)return!1;if(o.type===t)return e.commands.lift(t.name);let c=o.child(s-1);if(c.type!==t||!c.lastChild?.isTextblock)return!1;let l=i.before()-1-1;return e.commands.command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=i.parent.content,r=new k(n,0,0);return e.replace(l,i.after(),r),e.setSelection(j.create(e.doc,l+n.size)),e.scrollIntoView(),t(e),!0})},ny=/^\s*>\s$/,ry=U.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return hg(`blockquote`,{...V(this.options.HTMLAttributes,e),children:hg(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(`
|
|
178
191
|
`).map(e=>e.trim()===``?`>`:`> ${e}`);n.push(i.join(`
|
|
179
192
|
`))}),n.join(`
|
|
180
193
|
>
|
|
181
|
-
`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>
|
|
194
|
+
`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>ty(this.editor,this.type)}},addInputRules(){return[tp({find:ny,type:this.type})]}}),iy=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},ay=e=>{let t=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=t.exec(e))!==null;)r.index>0&&e[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n},oy=Of.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,V(this.options.HTMLAttributes,e),0]},markdownTokenName:`codespan`,parseMarkdown:(e,t)=>t.applyMark(`code`,[{type:`text`,text:e.text||``}]),renderMarkdown:(e,t)=>e.content?`\`${t.renderChildren(e.content)}\``:``,addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Qf({find:iy,type:this.type})]},addPasteRules(){return[np({find:ay,type:this.type})]}}),sy=U.create({name:`doc`,topNode:!0,content:`block+`,renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
182
195
|
|
|
183
|
-
`):``}),V_=U.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,V(this.options.HTMLAttributes,e)]},renderText(){return`
|
|
184
|
-
`
|
|
185
|
-
|
|
186
|
-
`)
|
|
187
|
-
`).
|
|
188
|
-
`)}),r=h,n=h}return[t,r]}var zv=RegExp(`^(${av})([.)])\\s+(.+)$`);function Bv(e){let t=e.split(`
|
|
189
|
-
`).filter(e=>e.trim().length>0);if(t.length===0)return null;let n=[];for(let e of t){let t=e.trim().match(zv);if(!t)return null;n.push({marker:t[1],content:t[3]})}return hv(n.map(e=>e.marker))?{type:`orderedList`,attrs:_v(n[0].marker),content:n.map(e=>({type:`listItem`,content:[{type:`paragraph`,content:[{type:`text`,text:e.content}]}]}))}:null}function Vv(e,t,n){let r=[],i=0;for(;i<e.length;){let a=e[i];if(a.indent===t){let{paragraphLines:o,blockLines:s}=Lv(a.contentLines),c=o.join(`
|
|
190
|
-
`).trim(),l=[];c&&l.push({type:`paragraph`,raw:c,tokens:n.inlineTokens(c)});let u=s.join(`
|
|
191
|
-
`).trim();if(u){let e=n.blockTokens(u);l.push(...e)}let d=i+1,f=[];for(;d<e.length&&e[d].indent>t;)f.push(e[d]),d+=1;if(f.length>0){let e=Vv(f,Math.min(...f.map(e=>e.indent)),n);l.push({type:`list`,ordered:!0,start:f[0].number,typeMarker:f[0].type,items:e,raw:f.map(e=>e.raw).join(`
|
|
192
|
-
`)})}r.push({type:`list_item`,raw:a.raw,tokens:l}),i=d}else i+=1}return r}function Hv(e,t){return e.map(e=>{if(e.type!==`list_item`)return t.parseChildren([e])[0];let n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if(e.type===`paragraph`||e.type===`list`||e.type===`blockquote`||e.type===`code`)n.push(...t.parseChildren([e]));else if(e.type===`text`&&e.tokens){let r=t.parseChildren([e]);n.push({type:`paragraph`,content:r})}else{let r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:`listItem`,content:n}})}var Uv=`listItem`,Wv=`textStyle`,Gv=/^(\d+)\.\s$/;function Kv(e){let t=e.match(/list-style-type\s*:\s*([^;]+)/i);if(!t)return null;switch(t[1].trim().toLowerCase()){case`upper-roman`:return`I`;case`lower-roman`:return`i`;case`upper-alpha`:case`upper-latin`:return`A`;case`lower-alpha`:case`lower-latin`:return`a`;default:return null}}var qv=U.create({name:`orderedList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute(`start`)?parseInt(e.getAttribute(`start`)||``,10):1},type:{default:null,parseHTML:e=>{let t=e.getAttribute(`type`);if(t)return t;let n=e.getAttribute(`style`);if(n){let e=Kv(n);if(e)return e}let r=e.querySelector(`li`);if(r){let e=r.getAttribute(`style`);if(e){let t=Kv(e);if(t)return t}}return null}}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,type:n,...r}=e,i=V(this.options.HTMLAttributes,r);return t!==1&&(i.start=t),n&&n!==`1`&&(i.type=n),[`ol`,i,0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>{if(e.type!==`list`||!e.ordered)return[];let n=e.start||1,r=e.typeMarker,i=e.items?Hv(e.items,t):[],a={};return n!==1&&(a.start=n),r&&(a.type=r),Object.keys(a).length>0?{type:`orderedList`,attrs:a,content:i}:{type:`orderedList`,content:i}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
193
|
-
`):``,markdownTokenizer:{name:`orderedList`,level:`block`,start:()=>-1,tokenize:(e,t,n)=>{let r=e.split(`
|
|
194
|
-
`),[i,a]=Rv(r);if(i.length===0)return;let o=Vv(i,i[0].indent,n);if(o.length!==0)return{type:`list`,ordered:!0,start:i[0]?.number||1,typeMarker:i[0]?.type,items:o,raw:r.slice(0,a).join(`
|
|
195
|
-
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Uv,this.editor.getAttributes(Wv)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new N({props:{handlePaste:(e,t)=>{if((t.clipboardData?.getData(`text/html`))?.trim())return!1;let n=t.clipboardData?.getData(`text/plain`);if(!n)return!1;let r=Bv(n);if(!r)return!1;try{let t=e.state.schema.nodeFromJSON(r),n=e.state.tr.replaceSelectionWith(t);return e.dispatch(n),!0}catch{return!1}}}})]},addInputRules(){let e=(e,t)=>(!t.attrs.type||t.attrs.type===`1`)&&t.childCount+t.attrs.start===+e[1],t=tp({find:Gv,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=tp({find:Gv,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Wv)}),joinPredicate:e,editor:this.editor})),[t]}}),Jv=/^\s*(\[([( |x])?\])\s$/,Yv=`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,Xv=(e,t,n)=>{var r;return(n==null||(r=n.checkboxLabel)==null?void 0:r.call(n,e,t))||`Task item checkbox for ${e.textContent||`empty task item`}`},Zv=U.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:e=>e.querySelector(`div`)??e}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,V(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>vf(e,t,`- [${e.attrs?.checked?`x`:` `}] `),addExtensions(){return this.options.nested?[nv(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`);o.style.cssText=Yv;let l=e=>{let t=Xv(e,e.attrs.checked,this.options.a11y);s.setAttribute(`aria-label`,t),o.textContent=t};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=Cu(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[tp({find:Jv,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),Qv=U.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return[`ul`,V(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode(`taskList`,{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
196
|
-
`):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=hf(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(t){let r={type:`taskList`,raw:t.raw,items:t.items},i=e.slice(t.raw.length);return i.trim()?[r,...n.blockTokens(i)]:[r]}return n.blockTokens(e)},i=hf(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});H.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(Q_.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(xv.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(Av.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(qv.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(Zv.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(Qv.configure(this.options.taskList)),e}});var $v=` `,ey=`\xA0`,ty=U.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,V(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===$v||n[0].text===$v||n[0].raw===ey||n[0].text===ey)&&r.length===1&&r[0].type===`text`&&(r[0].text===$v||r[0].text===ey)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){var i,a;let e=Array.isArray(n==null||(i=n.previousNode)==null?void 0:i.content)?n.previousNode.content:[];return(n==null||(a=n.previousNode)==null?void 0:a.type)===`paragraph`&&e.length===0?$v:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),ny=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,ry=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,iy=Of.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,V(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Qf({find:ny,type:this.type})]},addPasteRules(){return[np({find:ry,type:this.type})]}}),ay=U.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),oy=Of.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,V(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.indexOf(`++`)},tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let i=r[2].trim();return{type:`underline`,raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function sy(e={}){return new N({view(t){return new cy(t,e)}})}var cy=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc){if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(!t||i)return null;let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=Mn(this.editorView.state.doc,a,this.editorView.dragging.slice);e!=null&&(a=e)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},ly=class e extends A{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):A.near(r)}content(){return k.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new uy(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!fy(e)||!py(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!M.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};ly.prototype.visible=!1,ly.findFrom=ly.findGapCursorFrom,A.jsonID(`gapcursor`,ly);var uy=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ly.valid(t)?new ly(t):A.near(t)}};function dy(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function fy(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||dy(e.type))return!0;if(e.inlineContent)return!1}}return!0}function py(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||dy(e.type))return!0;if(e.inlineContent)return!1}}return!0}function my(){return new N({props:{decorations:yy,createSelectionBetween(e,t,n){return t.pos==n.pos&&ly.valid(n)?new ly(n):null},handleClick:_y,handleKeyDown:hy,handleDOMEvents:{beforeinput:vy}}})}var hy=Kc({ArrowLeft:gy(`horiz`,-1),ArrowRight:gy(`horiz`,1),ArrowUp:gy(`vert`,-1),ArrowDown:gy(`vert`,1)});function gy(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof j){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=ly.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new ly(c))),!0):!1}}function _y(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!ly.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&M.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new ly(r))),!0)}function vy(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof ly))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=D.empty;for(let e=r.length-1;e>=0;e--)i=D.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new k(i,0,0));return a.setSelection(j.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function yy(e){if(!(e.selection instanceof ly))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,L.create(e.doc,[Ws.widget(e.selection.head,t,{key:`gapcursor`})])}var by=200,X=function(){};X.prototype.append=function(e){return e.length?(e=X.from(e),!this.length&&e||e.length<by&&this.leafAppend(e)||this.length<by&&e.leafPrepend(this)||this.appendInner(e)):this},X.prototype.prepend=function(e){return e.length?X.from(e).append(this):this},X.prototype.appendInner=function(e){return new Sy(this,e)},X.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?X.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},X.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},X.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},X.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},X.from=function(e){return e instanceof X?e:e&&e.length?new xy(e):X.empty};var xy=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=by)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=by)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(X);X.empty=new xy([]);var Sy=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(X),Cy=500,wy=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new Ey(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new Ey(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new Ey(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>Oy&&(s=Ty(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new Yt;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new Ey(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new Ey(i,o,l))}else r.push(new Ey(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new Ey(a.maps[e]));let u=this.items.slice(0,i).append(l).append(r),d=new e(u,s);return d.emptyItemCount()>Cy&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new Ey(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(X.from(i.reverse()),a)}};wy.empty=new wy(X.empty,0);function Ty(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var Ey=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},Dy=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},Oy=20;function ky(e,t,n,r){let i=n.getMeta(Ry),a;if(i)return i.historyState;n.getMeta(zy)&&(e=new Dy(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(Ry))return o.getMeta(Ry).redo?new Dy(e.done.addTransform(n,void 0,r,Iy(t)),e.undone,jy(n.mapping.maps),e.prevTime,e.prevComposition):new Dy(e.done,e.undone.addTransform(n,void 0,r,Iy(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!Ay(n,e.prevRanges)),s=o?My(e.prevRanges,n.mapping):jy(n.mapping.maps);return new Dy(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,Iy(t)),wy.empty,s,n.time,i??e.prevComposition)}return(a=n.getMeta(`rebased`))?new Dy(e.done.rebased(n,a),e.undone.rebased(n,a),My(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new Dy(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),My(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function Ay(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function jy(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function My(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function Ny(e,t,n){let r=Iy(t),i=Ry.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new Dy(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(Ry,{redo:n,historyState:c})}var Py=!1,Fy=null;function Iy(e){let t=e.plugins;if(Fy!=t){Py=!1,Fy=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){Py=!0;break}}return Py}function Ly(e){return e.setMeta(zy,!0)}var Ry=new P(`history`),zy=new P(`closeHistory`);function By(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new N({key:Ry,state:{init(){return new Dy(wy.empty,wy.empty,null,0,-1)},apply(t,n,r){return ky(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?Hy:n==`historyRedo`?Uy:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Vy(e,t){return(n,r)=>{let i=Ry.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=Ny(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var Hy=Vy(!1,!0),Uy=Vy(!0,!0);H.create({name:`characterCount`,addOptions(){return{limit:null,autoTrim:!0,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new N({key:new P(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit,a=this.options.autoTrim;if(i==null||i===0||a===!1){e=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){let t=o-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var Wy=H.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[sy(this.options)]}});H.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new N({key:new P(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return L.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(Ws.node(t,t+e.nodeSize,{class:this.options.className}))}),L.create(e,a)}}})]}});var Gy=H.create({name:`gapCursor`,addProseMirrorPlugins(){return[my()]},extendNodeSchema(e){return{allowGapCursor:B(z(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),Ky=`placeholder`,qy=new P(`tiptap__placeholder`);function Jy(e){let{editor:t,placeholder:n,dataAttribute:r,pos:i,node:a,isEmptyDoc:o,hasAnchor:s,classes:{emptyNode:c,emptyEditor:l}}=e,u=[c];return o&&u.push(l),Ws.node(i,i+a.nodeSize,{class:u.join(` `),[r]:typeof n==`function`?n({editor:t,node:a,pos:i,hasAnchor:s}):n})}function Yy(e,t){return typeof e==`function`?e(t):e}function Xy({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:a,to:o}){let{anchor:s}=i,c=[],l=e.isEmpty;return r.nodesBetween(a,o,(r,i)=>{let a=s>=i&&s<=i+r.nodeSize,o=!r.isLeaf&&ed(r);return r.type.isTextblock&&(a||!t.showOnlyCurrent)&&o&&c.push(Jy({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:a,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Yy(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:a})},node:r,pos:i})),t.includeChildren}),c}function Zy({editor:e,options:t,dataAttribute:n,doc:r,selection:i}){if(!e.isEditable&&t.showOnlyWhenEditable)return null;let{anchor:a}=i,o=[],s=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let i=r.resolve(a),c=i.depth>0?i.node(1):i.nodeAfter,l=i.depth>0?i.before(1):a;if(c&&c.type.isTextblock&&ed(c)){let r=a>=l&&a<=l+c.nodeSize;o.push(Jy({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Yy(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else o.push(...Xy({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return L.create(r,o)}function Qy(e,t){let n=e.resolve(t);if(n.depth===0){let e=n.nodeAfter??n.nodeBefore;if(!e)return{from:t,to:t};let r=n.nodeAfter?t:t-e.nodeSize;return{from:r,to:r+e.nodeSize}}let r=n.before(1);return{from:r,to:r+n.node(1).nodeSize}}function $y(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function eb(e,t,n){let r=[];return e.forEach((e,i)=>{let a=i,o=a+e.nodeSize,s=a+1,c=o+1;s<n&&c>t&&r.push({from:a,to:o})}),r}function tb(e){if(e.length===0)return[];let t=[...e].sort((e,t)=>e.from-t.from),n=[{...t[0]}];for(let e=1;e<t.length;e+=1){let r=n[n.length-1],i=t[e];i.from<=r.to?r.to=Math.max(r.to,i.to):n.push({...i})}return n}function nb(e,t){let n=eb(e,t.from,t.to);return n.push($y(e,Qy(e,t.from))),t.to>t.from?n.push($y(e,Qy(e,Math.min(t.to,e.content.size+1)-1))):t.from<e.content.size+1&&n.push($y(e,Qy(e,Math.min(t.from+1,e.content.size)))),n}function rb(e,t,n){let r=[];if(e.docChanged){let t=Vu(e);for(let e of t)r.push(...nb(n.doc,e.newRange))}return e.selectionSet&&(r.push($y(n.doc,Qy(n.doc,e.mapping.map(t.selection.anchor)))),r.push($y(n.doc,Qy(n.doc,n.selection.anchor)))),tb(r)}function ib(e,t,n){let r=Math.max(0,Math.min(e,n.content.size));return{from:r,to:Math.max(r,Math.min(t,n.content.size))}}function ab({decorations:e,ranges:t,editor:n,options:r,dataAttribute:i,doc:a,selection:o}){let s=e;for(let e of t){let{from:t,to:c}=ib(e.from,e.to,a),l=s.find(t,c).filter(e=>e.from>=t&&e.to<=c);l.length&&(s=s.remove(l));let u=Xy({editor:n,options:r,dataAttribute:i,doc:a,selection:o,from:t,to:c});u.length&&(s=s.add(a,u))}return s}function ob({editor:e,options:t,dataAttribute:n}){return{init(r,i){return Zy({editor:e,options:t,dataAttribute:n,doc:i.doc,selection:i.selection})??L.empty},apply(r,i,a,o){return!r.docChanged&&!r.selectionSet?i:ab({decorations:i.map(r.mapping,r.doc),ranges:rb(r,a,o),editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function sb(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function cb({editor:e,options:t}){let n=t.dataAttribute?`data-${sb(t.dataAttribute)}`:`data-${Ky}`,r=t.showOnlyCurrent&&!t.includeChildren;return new N({key:qy,...r?{}:{state:ob({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:r,selection:i})=>Zy({editor:e,options:t,dataAttribute:n,doc:r,selection:i}):n=>t.showOnlyWhenEditable&&!e.isEditable?L.empty:qy.getState(n)??L.empty}})}var lb=H.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:Ky,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[cb({editor:this.editor,options:this.options})]}});function ub(e,t){return!e.selection.empty&&!td(e.selection)&&t.isEditable}function db(e,t){return ub(e,t)&&!t.isFocused&&!t.view.dragging}function fb(){var e;(e=window.getSelection())==null||e.removeAllRanges()}function pb(e){e.focus()}H.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new N({key:new P(`selection`),props:{decorations(n){return db(n,e)?L.create(n.doc,[Ws.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(t){return ub(t.state,e)&&fb(),!1},focus(t){return ub(t.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&t.hasFocus()&&pb(t)}),!1}}}})]}});function mb({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var hb=H.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new P(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new N({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!mb({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!mb({node:r,types:n})}}})]}}),gb=H.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>Hy(e,t),redo:()=>({state:e,dispatch:t})=>Uy(e,t)}},addProseMirrorPlugins(){return[By(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),_b=H.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(I_.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(j_.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(Q_.configure(this.options.bulletList)),this.options.code!==!1&&e.push(z_.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(Zm.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(B_.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(Wy.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(Gy.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(V_.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(H_.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(gb.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(U_.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(J_.configure(this.options.italic)),this.options.listItem!==!1&&e.push(xv.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(Av.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(b_.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(qv.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(ty.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(iy.configure(this.options.strike)),this.options.text!==!1&&e.push(ay.configure(this.options.text)),this.options.underline!==!1&&e.push(oy.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(hb.configure(this.options?.trailingNode)),e}}),vb,yb;if(typeof WeakMap<`u`){let e=new WeakMap;vb=t=>e.get(t),yb=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;vb=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},yb=(n,r)=>(t==10&&(t=0),e[t++]=n,e[t++]=r)}var Z=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,i=t/this.width|0,a=r+1,o=i+1;for(let e=1;a<this.width&&this.map[t+e]==n;e++)a++;for(let e=1;o<this.height&&this.map[t+this.width*e]==n;e++)o++;return{left:r,top:i,right:a,bottom:o}}throw RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:i,top:a,bottom:o}=this.findCell(e);return t==`horiz`?(n<0?r==0:i==this.width)?null:this.map[a*this.width+(n<0?r-1:i)]:(n<0?a==0:o==this.height)?null:this.map[r+this.width*(n<0?a-1:o)]}rectBetween(e,t){let{left:n,right:r,top:i,bottom:a}=this.findCell(e),{left:o,right:s,top:c,bottom:l}=this.findCell(t);return{left:Math.min(n,o),top:Math.min(i,c),right:Math.max(r,s),bottom:Math.max(a,l)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){let a=r*this.width+i,o=this.map[a];n[o]||(n[o]=!0,!(i==e.left&&i&&this.map[a-1]==o||r==e.top&&r&&this.map[a-this.width]==o)&&t.push(o))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){let a=i+n.child(r).nodeSize;if(r==e){let n=t+e*this.width,r=(e+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?a-1:this.map[n]}i=a}}static get(e){return vb(e)||yb(e,bb(e))}};function bb(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=xb(e),n=e.childCount,r=[],i=0,a=null,o=[];for(let e=0,i=t*n;e<i;e++)r[e]=0;for(let s=0,c=0;s<n;s++){let l=e.child(s);c++;for(let e=0;;e++){for(;i<r.length&&r[i]!=0;)i++;if(e==l.childCount)break;let u=l.child(e),{colspan:d,rowspan:f,colwidth:p}=u.attrs;for(let e=0;e<f;e++){if(e+s>=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;e<d;e++){r[l+e]==0?r[l+e]=c:(a||=[]).push({type:`collision`,row:s,pos:c,n:d-e});let n=p&&p[e];if(n){let r=(l+e)%t*2,i=o[r];i==null||i!=n&&o[r+1]==1?(o[r]=n,o[r+1]=1):i==n&&o[r+1]++}}}i+=d,c+=u.nodeSize}let u=(s+1)*t,d=0;for(;i<u;)r[i++]==0&&d++;d&&(a||=[]).push({type:`missing`,row:s,n:d}),c++}(t===0||n===0)&&(a||=[]).push({type:`zero_sized`});let s=new Z(t,n,r,a),c=!1;for(let e=0;!c&&e<o.length;e+=2)o[e]!=null&&o[e+1]<n&&(c=!0);return c&&Sb(s,o,e),s}function xb(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let i=e.child(r),a=0;if(n)for(let t=0;t<r;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++){let i=n.child(e);t+i.attrs.rowspan>r&&(a+=i.attrs.colspan)}}for(let e=0;e<i.childCount;e++){let t=i.child(e);a+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function Sb(e,t,n){e.problems||=[];let r={};for(let i=0;i<e.map.length;i++){let a=e.map[i];if(r[a])continue;r[a]=!0;let o=n.nodeAt(a);if(!o)throw RangeError(`No cell with offset ${a} found`);let s=null,c=o.attrs;for(let n=0;n<c.colspan;n++){let r=t[(i+n)%e.width*2];r!=null&&(!c.colwidth||c.colwidth[n]!=r)&&((s||=Cb(c))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function Cb(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function wb(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}var Tb=new P(`selectingCells`);function Eb(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function Db(e){for(let t=e.depth;t>0;t--){let n=e.node(t).type.spec.tableRole;if(n===`cell`||n===`header_cell`)return e.node(t)}return null}function Ob(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function kb(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=Eb(t.$head)||Ab(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function Ab(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function jb(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function Mb(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function Nb(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function Pb(e,t,n){let r=e.node(-1),i=Z.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function Fb(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function Ib(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}function Lb(e,t,n){let r=wb(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0}var Q=class e extends A{constructor(e,t=e){let n=e.node(-1),r=Z.get(n),i=e.start(-1),a=r.rectBetween(e.pos-i,t.pos-i),o=e.node(0),s=r.cellsInRect(a).filter(e=>e!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new er(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(jb(r)&&jb(i)&&Nb(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return j.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=Z.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n<r.bottom;n++){let o=[];for(let a=n*t.width+r.left,s=r.left;s<r.right;s++,a++){let n=t.map[a];if(i[n])continue;i[n]=!0;let s=t.findCell(n),c=e.nodeAt(n);if(!c)throw RangeError(`No cell with offset ${n} found`);let l=r.left-s.left,u=s.right-r.right;if(l>0||u>0){let e=c.attrs;if(l>0&&(e=Fb(e,0,l)),u>0&&(e=Fb(e,e.colspan-u,u)),s.left<r.left){if(c=c.type.createAndFill(e),!c)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else c=c.type.create(e,c.content)}if(s.top<r.top||s.bottom>r.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top<r.top?c.type.createAndFill(e):c.type.create(e,c.content)}o.push(c)}a.push(e.child(n).copy(D.from(o)))}let o=this.isColSelection()&&this.isRowSelection()?e:a;return new k(D.from(o),1,1)}replace(e,t=k.empty){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n);e.replace(s.map(a.pos),s.map(o.pos),i?k.empty:t)}let i=A.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new k(D.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=Z.get(t),r=this.$anchorCell.start(-1),i=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<i.length;n++)e(t.nodeAt(i[n]),r+i[n])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=Z.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom<i.height&&(n=c.resolve(a+i.map[i.width*(i.height-1)+s.right-1]))):(s.top>0&&(n=c.resolve(a+i.map[s.left])),o.bottom<i.height&&(t=c.resolve(a+i.map[i.width*(i.height-1)+o.right-1]))),new e(t,n)}isRowSelection(){let e=this.$anchorCell.node(-1),t=Z.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),i=t.colCount(this.$headCell.pos-n);if(Math.min(r,i)>0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=Z.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right<i.width&&(n=c.resolve(a+i.map[i.width*(s.top+1)-1]))):(s.left>0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right<i.width&&(t=c.resolve(a+i.map[i.width*(o.top+1)-1]))),new e(t,n)}toJSON(){return{type:`cell`,anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new Rb(this.$anchorCell.pos,this.$headCell.pos)}};Q.prototype.visible=!1,A.jsonID(`cell`,Q);var Rb=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){let t=e.resolve(this.anchor),n=e.resolve(this.head);return t.parent.type.spec.tableRole==`row`&&n.parent.type.spec.tableRole==`row`&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&Nb(t,n)?new Q(t,n):A.near(n,1)}};function zb(e){if(!(e.selection instanceof Q))return null;let t=[];return e.selection.forEachCell((e,n)=>{t.push(Ws.node(n,n+e.nodeSize,{class:`selectedCell`}))}),L.create(e.doc,t)}function Bb({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function Vb({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function Hb(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof M&&(o=r.node.type.spec.tableRole)){if(o==`cell`||o==`header_cell`)a=Q.create(i,r.from);else if(o==`row`){let e=i.resolve(r.from+1);a=Q.rowSelection(e,e)}else if(!n){let e=Z.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];a=Q.create(i,t+1,n)}}else r instanceof j&&Bb(r)?a=j.create(i,r.from):r instanceof j&&Vb(r)&&(a=j.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var Ub=new P(`fix-tables`);function Wb(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o<a;o++){let a=t.child(o);for(let t=s,r=Math.min(i,o+3);t<r;t++)if(e.child(t)==a){s=t+1,n+=a.nodeSize;continue outer}r(a,n),s<i&&e.child(s).sameMarkup(a)?Wb(e.child(s),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function Gb(e,t){let n,r=(t,r)=>{t.type.spec.tableRole==`table`&&(n=Kb(e,t,r,n))};return t?t.doc!=e.doc&&Wb(t.doc,e.doc,0,r):e.doc.descendants(r),n}function Kb(e,t,n,r){let i=Z.get(t);if(!i.problems)return r;r||=e.tr;let a=[];for(let e=0;e<i.height;e++)a.push(0);for(let e=0;e<i.problems.length;e++){let o=i.problems[e];if(o.type==`collision`){let e=t.nodeAt(o.pos);if(!e)continue;let i=e.attrs;for(let e=0;e<i.rowspan;e++)a[o.row+e]+=o.n;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,Fb(i,i.colspan-o.n,o.n))}else if(o.type==`missing`)a[o.row]+=o.n;else if(o.type==`overlong_rowspan`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-o.n})}else if(o.type==`colwidth mismatch`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,colwidth:o.colwidth})}else if(o.type==`zero_sized`){let e=r.mapping.map(n);r.delete(e,e+t.nodeSize)}}let o,s;for(let e=0;e<a.length;e++)a[e]&&(o??=e,s=e);for(let c=0,l=n+1;c<i.height;c++){let n=t.child(c),i=l+n.nodeSize,u=a[c];if(u>0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n<u;n++){let n=wb(e.schema)[t].createAndFill();n&&a.push(n)}let d=(c==0||o==c-1)&&s==c?l+1:i-1;r.insert(r.mapping.map(d),a)}l=i}return r.setMeta(Ub,{fixTables:!0})}function qb(e){let t=e.selection,n=kb(e),r=n.node(-1),i=n.start(-1),a=Z.get(r);return{...t instanceof Q?a.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):a.findCell(n.pos-i),tableStart:i,map:a,table:r}}function Jb(e,{map:t,tableStart:n,table:r},i){let a=i>0?-1:0;Lb(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o<t.height;o++){let s=o*t.width+i;if(i>0&&i<t.width&&t.map[s-1]==t.map[s]){let a=t.map[s],c=r.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,Ib(c.attrs,i-t.colCount(a))),o+=c.attrs.rowspan-1}else{let c=a==null?wb(r.type.schema).cell:r.nodeAt(t.map[s+a]).type,l=t.positionAt(o,i,r);e.insert(e.mapping.map(n+l),c.createAndFill())}}return e}function Yb(e,t){if(!Ob(e))return!1;if(t){let n=qb(e);t(Jb(e.tr,n,n.left))}return!0}function Xb(e,t){if(!Ob(e))return!1;if(t){let n=qb(e);t(Jb(e.tr,n,n.right))}return!0}function Zb(e,{map:t,table:n,tableStart:r},i){let a=e.mapping.maps.length;for(let o=0;o<t.height;){let s=o*t.width+i,c=t.map[s],l=n.nodeAt(c),u=l.attrs;if(i>0&&t.map[s-1]==c||i<t.width-1&&t.map[s+1]==c)e.setNodeMarkup(e.mapping.slice(a).map(r+c),null,Fb(u,i-t.colCount(c)));else{let t=e.mapping.slice(a).map(r+c);e.delete(t,t+l.nodeSize)}o+=u.rowspan}}function Qb(e,t){if(!Ob(e))return!1;if(t){let n=qb(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let e=n.right-1;Zb(r,n,e),e!=n.left;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=Z.get(e)}t(r)}return!0}function $b(e,t,n){let r=wb(t.type.schema).header_cell;for(let i=0;i<e.width;i++)if(t.nodeAt(e.map[i+n*e.width])?.type!=r)return!1;return!0}function ex(e,{map:t,tableStart:n,table:r},i){let a=n;for(let e=0;e<i;e++)a+=r.child(e).nodeSize;let o=[],s=i>0?-1:0;$b(t,r,i+s)&&(s=i==0||i==t.height?null:0);for(let a=0,c=t.width*i;a<t.width;a++,c++)if(i>0&&i<t.height&&t.map[c]==t.map[c-t.width]){let i=t.map[c],o=r.nodeAt(i).attrs;e.setNodeMarkup(n+i,null,{...o,rowspan:o.rowspan+1}),a+=o.colspan-1}else{let e=(s==null?wb(r.type.schema).cell:r.nodeAt(t.map[c+s*t.width])?.type)?.createAndFill();e&&o.push(e)}return e.insert(a,wb(r.type.schema).row.create(null,o)),e}function tx(e,t){if(!Ob(e))return!1;if(t){let n=qb(e);t(ex(e.tr,n,n.top))}return!0}function nx(e,t){if(!Ob(e))return!1;if(t){let n=qb(e);t(ex(e.tr,n,n.bottom))}return!0}function rx(e,{map:t,table:n,tableStart:r},i){let a=0;for(let e=0;e<i;e++)a+=n.child(e).nodeSize;let o=a+n.child(i).nodeSize,s=e.mapping.maps.length;e.delete(a+r,o+r);let c=new Set;for(let a=0,o=i*t.width;a<t.width;a++,o++){let l=t.map[o];if(!c.has(l)){if(c.add(l),i>0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i<t.height&&l==t.map[o+t.width]){let o=n.nodeAt(l),c=o.attrs,u=o.type.create({...c,rowspan:o.attrs.rowspan-1},o.content),d=t.positionAt(i+1,a,n);e.insert(e.mapping.slice(s).map(r+d),u),a+=c.colspan-1}}}}function ix(e,t){if(!Ob(e))return!1;if(t){let n=qb(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;rx(r,n,e),e!=n.top;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=Z.get(n.table)}t(r)}return!0}function ax(e){let t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function ox({width:e,height:t,map:n},r){let i=r.top*e+r.left,a=i,o=(r.bottom-1)*e+r.left,s=i+(r.right-r.left-1);for(let t=r.top;t<r.bottom;t++){if(r.left>0&&n[a]==n[a-1]||r.right<e&&n[s]==n[s+1])return!0;a+=e,s+=e}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[i]==n[i-e]||r.bottom<t&&n[o]==n[o+e])return!0;i++,o++}return!1}function sx(e,t){let n=e.selection;if(!(n instanceof Q)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=qb(e),{map:i}=r;if(ox(i,r))return!1;if(t){let n=e.tr,a={},o=D.empty,s,c;for(let e=r.top;e<r.bottom;e++)for(let t=r.left;t<r.right;t++){let l=i.map[e*i.width+t],u=r.table.nodeAt(l);if(!a[l]&&u){if(a[l]=!0,s==null)s=l,c=u;else{ax(u)||(o=o.append(u.content));let e=n.mapping.map(l+r.tableStart);n.delete(e,e+u.nodeSize)}}}if(s==null||c==null)return!0;if(n.setNodeMarkup(s+r.tableStart,null,{...Ib(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),o.size>0){let e=s+1+c.content.size,t=ax(c)?s+1:e;n.replaceWith(t+r.tableStart,e+r.tableStart,o)}n.setSelection(new Q(n.doc.resolve(s+r.tableStart))),t(n)}return!0}function cx(e,t){let n=wb(e.schema);return lx(({node:e})=>n[e.type.spec.tableRole])(e,t)}function lx(e){return(t,n)=>{let r=t.selection,i,a;if(r instanceof Q){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,a=r.$anchorCell.pos}else{if(i=Db(r.$from),!i)return!1;a=Eb(r.$from)?.pos}if(i==null||a==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let o=i.attrs,s=[],c=o.colwidth;o.rowspan>1&&(o={...o,rowspan:1}),o.colspan>1&&(o={...o,colspan:1});let l=qb(t),u=t.tr;for(let e=0;e<l.right-l.left;e++)s.push(c?{...o,colwidth:c&&c[e]?[c[e]]:null}:o);let d;for(let t=l.top;t<l.bottom;t++){let n=l.map.positionAt(t,l.left,l.table);t==l.top&&(n+=i.nodeSize);for(let r=l.left,a=0;r<l.right;r++,a++)(r!=l.left||t!=l.top)&&u.insert(d=u.mapping.map(n+l.tableStart,1),e({node:i,row:t,col:r}).createAndFill(s[a]))}u.setNodeMarkup(a,e({node:i,row:l.top,col:l.left}),s[0]),r instanceof Q&&u.setSelection(new Q(u.doc.resolve(r.$anchorCell.pos),d?u.doc.resolve(d):void 0)),n(u)}return!0}}function ux(e,t){return function(n,r){if(!Ob(n))return!1;let i=kb(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){let a=n.tr;n.selection instanceof Q?n.selection.forEachCell((n,r)=>{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function dx(e){return function(t,n){if(!Ob(t))return!1;if(n){let r=wb(t.schema),i=qb(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e<o.length;e++)s[e].type==r.header_cell&&a.setNodeMarkup(i.tableStart+o[e],r.cell,s[e].attrs);if(a.steps.length===0)for(let e=0;e<o.length;e++)a.setNodeMarkup(i.tableStart+o[e],r.header_cell,s[e].attrs);n(a)}return!0}}function fx(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e==`row`?t.map.width:1,bottom:e==`column`?t.map.height:1});for(let e=0;e<r.length;e++){let i=t.table.nodeAt(r[e]);if(i&&i.type!==n.header_cell)return!1}return!0}function px(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?dx(e):function(t,n){if(!Ob(t))return!1;if(n){let r=wb(t.schema),i=qb(t),a=t.tr,o=fx(`row`,i,r),s=fx(`column`,i,r),c=(e===`column`?o:e===`row`&&s)?1:0,l=e==`column`?{left:0,top:c,right:1,bottom:i.map.height}:e==`row`?{left:c,top:0,right:i.map.width,bottom:1}:i,u=e==`column`?s?r.cell:r.header_cell:e==`row`?o?r.cell:r.header_cell:r.cell;i.map.cellsInRect(l).forEach(e=>{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}px(`row`,{useDeprecatedLogic:!0}),px(`column`,{useDeprecatedLogic:!0});var mx=px(`cell`,{useDeprecatedLogic:!0});function hx(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let t=e.node(-1);for(let n=e.indexAfter(-1),r=e.after();n<t.childCount;n++){let e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}function gx(e){return function(t,n){if(!Ob(t))return!1;let r=hx(kb(t),e);if(r==null)return!1;if(n){let e=t.doc.resolve(r);n(t.tr.setSelection(j.between(e,Mb(e))).scrollIntoView())}return!0}}function _x(e,t){let n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function vx(e,t){let n=e.selection;if(!(n instanceof Q))return!1;if(t){let r=e.tr,i=wb(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new k(i,0,0))}),r.docChanged&&t(r)}return!0}function yx(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole==`table`);)n--,r--,t=t.child(0).content;let i=t.child(0),a=i.type.spec.tableRole,o=i.type.schema,s=[];if(a==`row`)for(let e=0;e<t.childCount;e++){let i=t.child(e).content,a=e?0:Math.max(0,n-1),c=e<t.childCount-1?0:Math.max(0,r-1);(a||c)&&(i=xx(wb(o).row,new k(i,a,c)).content),s.push(i)}else if(a==`cell`||a==`header_cell`)s.push(n||r?xx(wb(o).row,new k(t,n,r)).content:t);else return null;return bx(o,s)}function bx(e,t){let n=[];for(let e=0;e<t.length;e++){let r=t[e];for(let t=r.childCount-1;t>=0;t--){let{rowspan:i,colspan:a}=r.child(t).attrs;for(let t=e;t<e+i;t++)n[t]=(n[t]||0)+a}}let r=0;for(let e=0;e<n.length;e++)r=Math.max(r,n[e]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(D.empty),n[i]<r){let a=wb(e).cell.createAndFill(),o=[];for(let e=n[i];e<r;e++)o.push(a);t[i]=t[i].append(D.from(o))}return{height:t.length,width:r,rows:t}}function xx(e,t){let n=e.createAndFill();return new Qn(n).replace(0,n.content.size,t).doc}function Sx({width:e,height:t,rows:n},r,i){if(e!=r){let t=[],i=[];for(let e=0;e<n.length;e++){let a=n[e],o=[];for(let n=t[e]||0,i=0;n<r;i++){let s=a.child(i%a.childCount);n+s.attrs.colspan>r&&(s=s.type.createChecked(Fb(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),o.push(s),n+=s.attrs.colspan;for(let n=1;n<s.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+s.attrs.colspan}i.push(D.from(o))}n=i,e=r}if(t!=i){let e=[];for(let r=0,a=0;r<i;r++,a++){let o=[],s=n[a%t];for(let e=0;e<s.childCount;e++){let t=s.child(e);r+t.attrs.rowspan>i&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),o.push(t)}e.push(D.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function Cx(e,t,n,r,i,a,o){let s=e.doc.type.schema,c=wb(s),l,u;if(i>t.width)for(let a=0,s=0;a<t.height;a++){let d=n.child(a);s+=d.nodeSize;let f=[],p;p=d.lastChild==null||d.lastChild.type==c.cell?l||=c.cell.createAndFill():u||=c.header_cell.createAndFill();for(let e=t.width;e<i;e++)f.push(p);e.insert(e.mapping.slice(o).map(s-1+r),f)}if(a>t.height){let s=[];for(let e=0,r=(t.height-1)*t.width;e<Math.max(t.width,i);e++){let i=e>=t.width?!1:n.nodeAt(t.map[r+e]).type==c.header_cell;s.push(i?u||=c.header_cell.createAndFill():l||=c.cell.createAndFill())}let d=c.row.create(null,D.from(s)),f=[];for(let e=t.height;e<a;e++)f.push(d);e.insert(e.mapping.slice(o).map(r+n.nodeSize-2),f)}return!!(l||u)}function wx(e,t,n,r,i,a,o,s){if(o==0||o==t.height)return!1;let c=!1;for(let l=i;l<a;l++){let i=o*t.width+l,a=t.map[i];if(t.map[i-t.width]==a){c=!0;let i=n.nodeAt(a),{top:u,left:d}=t.findCell(a);e.setNodeMarkup(e.mapping.slice(s).map(a+r),null,{...i.attrs,rowspan:o-u}),e.insert(e.mapping.slice(s).map(t.positionAt(o,d,n)),i.type.createAndFill({...i.attrs,rowspan:u+i.attrs.rowspan-o})),l+=i.attrs.colspan-1}}return c}function Tx(e,t,n,r,i,a,o,s){if(o==0||o==t.width)return!1;let c=!1;for(let l=i;l<a;l++){let i=l*t.width+o,a=t.map[i];if(t.map[i-1]==a){c=!0;let i=n.nodeAt(a),u=t.colCount(a),d=e.mapping.slice(s).map(a+r);e.setNodeMarkup(d,null,Fb(i.attrs,o-u,i.attrs.colspan-(o-u))),e.insert(d+i.nodeSize,i.type.createAndFill(Fb(i.attrs,0,o-u))),l+=i.attrs.rowspan-1}}return c}function Ex(e,t,n,r,i){let a=n?e.doc.nodeAt(n-1):e.doc;if(!a)throw Error(`No table found`);let o=Z.get(a),{top:s,left:c}=r,l=c+i.width,u=s+i.height,d=e.tr,f=0;function p(){if(a=n?d.doc.nodeAt(n-1):d.doc,!a)throw Error(`No table found`);o=Z.get(a),f=d.mapping.maps.length}Cx(d,o,a,n,l,u,f)&&p(),wx(d,o,a,n,c,l,s,f)&&p(),wx(d,o,a,n,c,l,u,f)&&p(),Tx(d,o,a,n,s,u,c,f)&&p(),Tx(d,o,a,n,s,u,l,f)&&p();for(let e=s;e<u;e++){let t=o.positionAt(e,c,a),r=o.positionAt(e,l,a);d.replace(d.mapping.slice(f).map(t+n),d.mapping.slice(f).map(r+n),new k(i.rows[e-s],0,0))}p(),d.setSelection(new Q(d.doc.resolve(n+o.positionAt(s,c,a)),d.doc.resolve(n+o.positionAt(u-1,l-1,a)))),t(d)}var Dx=Kc({ArrowLeft:kx(`horiz`,-1),ArrowRight:kx(`horiz`,1),ArrowUp:kx(`vert`,-1),ArrowDown:kx(`vert`,1),"Shift-ArrowLeft":Ax(`horiz`,-1),"Shift-ArrowRight":Ax(`horiz`,1),"Shift-ArrowUp":Ax(`vert`,-1),"Shift-ArrowDown":Ax(`vert`,1),Backspace:vx,"Mod-Backspace":vx,Delete:vx,"Mod-Delete":vx});function Ox(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function kx(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection;if(a instanceof Q)return Ox(n,r,A.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=Px(i,e,t);if(o==null)return!1;if(e==`horiz`)return Ox(n,r,A.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=Pb(i,e,t),s;return s=a?A.near(a,1):t<0?A.near(n.doc.resolve(i.before(-1)),-1):A.near(n.doc.resolve(i.after(-1)),1),Ox(n,r,s)}}}function Ax(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof Q)o=a;else{let r=Px(i,e,t);if(r==null)return!1;o=new Q(n.doc.resolve(r))}let s=Pb(o.$headCell,e,t);return s?Ox(n,r,new Q(o.$anchorCell,s)):!1}}function jx(e,t){let n=e.state.doc,r=Eb(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new Q(r))),!0):!1}function Mx(e,t,n){if(!Ob(e.state))return!1;let r=yx(n),i=e.state.selection;if(i instanceof Q){r||={width:1,height:1,rows:[D.from(xx(wb(e.state.schema).cell,n))]};let t=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),o=Z.get(t).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=Sx(r,o.right-o.left,o.bottom-o.top),Ex(e.state,e.dispatch,a,o,r),!0}if(r){let t=kb(e.state),n=t.start(-1);return Ex(e.state,e.dispatch,n,Z.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function Nx(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=Fx(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof Q)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=Eb(e.state.selection.$anchor))!=null&&Ix(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=Ix(e,n),i=Tb.getState(e.state)==null;if(!r||!Nb(t,r)){if(i)r=t;else return}let a=new Q(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(Tb,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),Tb.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(Tb,-1))}function o(r){let o=r,s=Tb.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(Fx(e,o.target)!=n&&(c=Ix(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function Px(e,t,n){if(!(e.state.selection instanceof j))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function Fx(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function Ix(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&Eb(e.state.doc.resolve(r))||Eb(e.state.doc.resolve(i))}var Lx=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`)),this.table.style.setProperty(`--default-cell-min-width`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),Rx(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type&&(this.node=e,Rx(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function Rx(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;e<l.childCount;e++){let{colspan:u,colwidth:d}=l.child(e).attrs;for(let e=0;e<u;e++,n++){let l=i==n?a:d&&d[e],u=l?l+`px`:``;if(o+=l||r,l||(s=!1),c)c.style.width!=u&&(c.style.width=u),c=c.nextSibling;else{let e=document.createElement(`col`);e.style.width=u,t.appendChild(e)}}}for(;c;){var u;let e=c.nextSibling;(u=c.parentNode)==null||u.removeChild(c),c=e}s?(n.style.width=o+`px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=o+`px`)}}var zx=new P(`tableColumnResizing`);function Bx({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=Lx,lastColumnResizable:i=!0}={}){let a=new N({key:zx,state:{init(e,t){var i;let o=(i=a.spec)==null||(i=i.props)==null?void 0:i.nodeViews,s=wb(t.schema).table.name;return r&&o&&(o[s]=(e,t)=>new r(e,n,t)),new Vx(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=zx.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{Hx(t,n,e,i)},mouseleave:e=>{Ux(e)},mousedown:(e,r)=>{Wx(e,r,t,n)}},decorations:e=>{let t=zx.getState(e);if(t&&t.activeHandle>-1)return $x(e,t.activeHandle)},nodeViews:{}}});return a}var Vx=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(zx);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return jb(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function Hx(e,t,n,r){if(!e.editable)return;let i=zx.getState(e.state);if(i&&!i.dragging){let a=Kx(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=qx(e,t,`left`,n):i-t.clientX<=n&&(o=qx(e,t,`right`,n))}if(o!=i.activeHandle){if(!r&&o!==-1){let t=e.state.doc.resolve(o),n=t.node(-1),r=Z.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}Yx(e,o)}}}function Ux(e){if(!e.editable)return;let t=zx.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&Yx(e,-1)}function Wx(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=zx.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=Gx(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(zx,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=zx.getState(e.state);r?.dragging&&(Xx(e,r.activeHandle,Jx(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(zx,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=zx.getState(e.state);if(i&&i.dragging){let a=Jx(i.dragging,t,n);Zx(e,i.activeHandle,a,r)}}return Zx(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function Gx(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;e<n;e++)r[e]&&(o-=r[e],s--);return o/s}function Kx(e){for(;e&&e.nodeName!=`TD`&&e.nodeName!=`TH`;)e=e.classList&&e.classList.contains(`ProseMirror`)?null:e.parentNode;return e}function qx(e,t,n,r){let i=n==`right`?-r:r,a=e.posAtCoords({left:t.clientX+i,top:t.clientY});if(!a)return-1;let{pos:o}=a,s=Eb(e.state.doc.resolve(o));if(!s)return-1;if(n==`right`)return s.pos;let c=Z.get(s.node(-1)),l=s.start(-1),u=c.map.indexOf(s.pos-l);return u%c.width==0?-1:l+c.map[u-1]}function Jx(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function Yx(e,t){e.dispatch(e.state.tr.setMeta(zx,{setHandle:t}))}function Xx(e,t,n){let r=e.state.doc.resolve(t),i=r.node(-1),a=Z.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,c=e.state.tr;for(let e=0;e<a.height;e++){let t=e*a.width+s;if(e&&a.map[t]==a.map[t-a.width])continue;let r=a.map[t],l=i.nodeAt(r).attrs,u=l.colspan==1?0:s-a.colCount(r);if(l.colwidth&&l.colwidth[u]==n)continue;let d=l.colwidth?l.colwidth.slice():Qx(l.colspan);d[u]=n,c.setNodeMarkup(o+r,null,{...l,colwidth:d})}c.docChanged&&e.dispatch(c)}function Zx(e,t,n,r){let i=e.state.doc.resolve(t),a=i.node(-1),o=i.start(-1),s=Z.get(a).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1,c=e.domAtPos(i.start(-1)).node;for(;c&&c.nodeName!=`TABLE`;)c=c.parentNode;c&&Rx(a,c.firstChild,c,r,s,n)}function Qx(e){return Array(e).fill(0)}function $x(e,t){let n=[],r=e.doc.resolve(t),i=r.node(-1);if(!i)return L.empty;let a=Z.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let t=0;t<a.height;t++){let r=s+t*a.width;if((s==a.width-1||a.map[r]!=a.map[r+1])&&(t==0||a.map[r]!=a.map[r-a.width])){let t=a.map[r],s=o+t+i.nodeAt(t).nodeSize-1,c=document.createElement(`div`);c.className=`column-resize-handle`,zx.getState(e)?.dragging&&n.push(Ws.node(o+t,o+t+i.nodeAt(t).nodeSize,{class:`column-resize-dragging`})),n.push(Ws.widget(s,c))}}return L.create(e.doc,n)}function eS({allowTableNodeSelection:e=!1}={}){return new N({key:Tb,state:{init(){return null},apply(e,t){let n=e.getMeta(Tb);if(n!=null)return n==-1?null:n;if(t==null||!e.docChanged)return t;let{deleted:r,pos:i}=e.mapping.mapResult(t);return r?null:i}},props:{decorations:zb,handleDOMEvents:{mousedown:Nx},createSelectionBetween(e){return Tb.getState(e.state)==null?null:e.state.selection},handleTripleClick:jx,handleKeyDown:Dx,handlePaste:Mx},appendTransaction(t,n,r){return Hb(r,Gb(r,n),e)}})}function tS(e){return e===`left`||e===`right`||e===`center`?e:null}function nS(e){let t=(e.style.textAlign||``).trim().toLowerCase(),n=(e.getAttribute(`align`)||``).trim().toLowerCase();return tS(t||n)}function rS(e){return tS(e?.align)}function iS(){return{default:null,parseHTML:e=>nS(e),renderHTML:e=>e.align?{style:`text-align: ${e.align}`}:{}}}function aS(e){let t=e.parentElement,n=e.closest(`table`);if(!t||!n)return null;let r=Array.from(t.children).indexOf(e),i=n.querySelectorAll(`colgroup > col`)[r]?.getAttribute(`width`);return i?[parseInt(i,10)]:null}function oS(e){let t=e.getAttribute(`colwidth`);return t?t.split(`,`).map(e=>parseInt(e,10)):aS(e)}var sS=/[ \t\r\n\f]+/g;function cS(e){return e.children.length>0?!1:(e.textContent??``).replace(sS,``)===``}function lS(e){let t=e.createAndFill();if(!t)throw Error(`[tiptap error]: "${e.name}" has no default content to backfill.`);return t.content}var uS=U.create({name:`tableCell`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:oS},align:iS()}},tableRole:`cell`,isolating:!0,parseHTML(){return[{tag:`td`,getAttrs:e=>cS(e)?{}:!1,getContent:(e,t)=>lS(t.nodes[this.name])},{tag:`td`}]},renderHTML({HTMLAttributes:e}){return[`td`,V(this.options.HTMLAttributes,e),0]}}),dS=U.create({name:`tableHeader`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:oS},align:iS()}},tableRole:`header_cell`,isolating:!0,parseHTML(){return[{tag:`th`,getAttrs:e=>cS(e)?{}:!1,getContent:(e,t)=>lS(t.nodes[this.name])},{tag:`th`}]},renderHTML({HTMLAttributes:e}){return[`th`,V(this.options.HTMLAttributes,e),0]}}),fS=U.create({name:`tableRow`,addOptions(){return{HTMLAttributes:{}}},content:`(tableCell | tableHeader)*`,tableRole:`row`,parseHTML(){return[{tag:`tr`}]},renderHTML({HTMLAttributes:e}){return[`tr`,V(this.options.HTMLAttributes,e),0]}});function pS(e,t){return t?[`width`,`${Math.max(t,e)}px`]:[`min-width`,`${e}px`]}function mS(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l!==null)for(let e=0,n=0;e<l.childCount;e+=1){let{colspan:u,colwidth:d}=l.child(e).attrs;for(let e=0;e<u;e+=1,n+=1){let l=i===n?a:d&&d[e],u=l?`${l}px`:``;if(o+=l||r,l||(s=!1),c){if(c.style.width!==u){let[e,t]=pS(r,l);c.style.setProperty(e,t)}c=c.nextSibling}else{let e=document.createElement(`col`),[n,i]=pS(r,l);e.style.setProperty(n,i),t.appendChild(e)}}}for(;c;){var u;let e=c.nextSibling;(u=c.parentNode)==null||u.removeChild(c),c=e}let d=e.attrs.style&&typeof e.attrs.style==`string`&&/\bwidth\s*:/i.test(e.attrs.style);s&&!d?(n.style.width=`${o}px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=`${o}px`)}var hS=class{constructor(e,t,n,r={}){this.node=e,this.cellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`));for(let[e,t]of Object.entries(r))t!=null&&(e===`style`?this.table.style.cssText=String(t):this.table.setAttribute(e,String(t)));e.attrs.style&&(this.table.style.cssText=e.attrs.style),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),mS(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type===this.node.type&&(this.node=e,mS(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){let t=e.target,n=this.dom.contains(t),r=this.contentDOM.contains(t);return!(!n||r||e.type!==`attributes`&&e.type!==`childList`&&e.type!==`characterData`)}};function gS(e,t,n,r){let i=0,a=!0,o=[],s=e.firstChild;if(!s)return{};for(let e=0,c=0;e<s.childCount;e+=1){let{colspan:l,colwidth:u}=s.child(e).attrs;for(let e=0;e<l;e+=1,c+=1){let s=n===c?r:u&&u[e];i+=s||t,s||(a=!1);let[l,d]=pS(t,s);o.push([`col`,{style:`${l}: ${d}`}])}}let c=a?`${i}px`:``,l=a?``:`${i}px`;return{colgroup:[`colgroup`,{},...o],tableWidth:c,tableMinWidth:l}}function _S(e,t){return t?e.createChecked(null,t):e.createAndFill()}function vS(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;let t={};return Object.keys(e.nodes).forEach(n=>{let r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function yS(e,t,n,r,i){let a=vS(e),o=[],s=[];for(let e=0;e<n;e+=1){let e=_S(a.cell,i);if(e&&s.push(e),r){let e=_S(a.header_cell,i);e&&o.push(e)}}let c=[];for(let e=0;e<t;e+=1)c.push(a.row.createChecked(null,r&&e===0?o:s));return a.table.createChecked(null,c)}function bS(e){return e instanceof Q}var xS=({editor:e})=>{let{selection:t}=e.state;if(!bS(t))return!1;let n=0;return pu(t.ranges[0].$from,e=>e.type.name===`table`)?.node.descendants(e=>{if(e.type.name===`table`)return!1;[`tableCell`,`tableHeader`].includes(e.type.name)&&(n+=1)}),n===t.ranges.length&&(e.commands.deleteTable(),!0)};function SS(e,t){let n=e.mapping.map(t);if(pu(e.selection.$from,e=>e.type.name===`table`)?.pos===n)return;let r=e.doc.nodeAt(n);if(!r)return;let i=n+r.nodeSize-1;e.setSelection(j.near(e.doc.resolve(i),-1))}function CS(e){let t=``,n=0;for(;n<e.length;){if(e[n]===`\\`&&n+1<e.length){t+=e[n]+e[n+1],n+=2;continue}if(e[n]!=="`"){t+=e[n++];continue}let r=0;for(;n+r<e.length&&e[n+r]==="`";)r+=1;let i=n+r,a=!1;for(;i<e.length;){if(e[i]!=="`"){i+=1;continue}let o=0;for(;i+o<e.length&&e[i+o]==="`";)o+=1;if(o===r){let o=e.slice(n+r,i);t+=e.slice(n,n+r)+o.replace(/\\\||\|/g,e=>e===`|`?`\\|`:e)+e.slice(i,i+r),n=i+r,a=!0;break}i+=o}a||(t+=e.slice(n,n+r),n+=r)}return t}function wS(e){return e.split(`
|
|
197
|
-
`).map(e=>!e.includes(`|`)||!e.includes("`")?e:CS(e)).join(`
|
|
198
|
-
`)}function TS(e){return(e||``).replace(/\s+/g,` `).trim()}function ES(e,t,n={}){let r=n.cellLineSeparator??``;if(!e||!e.content||e.content.length===0)return``;let i=[];e.content.forEach(e=>{let n=[];e.content&&e.content.forEach(e=>{let i=``;i=e.content&&Array.isArray(e.content)&&e.content.length>1?e.content.map(e=>t.renderChildren(e)).join(r):e.content?t.renderChildren(e.content):``;let a=TS(i.split(r).join(`
|
|
199
|
-
`).replace(/[ \t]*\r?\n[ \t]*/g,`<br>`)),o=e.type===`tableHeader`,s=rS(e.attrs);n.push({text:a,isHeader:o,align:s})}),i.push(n)});let a=i.reduce((e,t)=>Math.max(e,t.length),0);if(a===0)return``;let o=Array.from({length:a}).fill(0);i.forEach(e=>{for(let t=0;t<a;t+=1){let n=(e[t]?.text||``).length;n>o[t]&&(o[t]=n),o[t]<3&&(o[t]=3)}});let s=(e,t)=>e+` `.repeat(Math.max(0,t-e.length)),c=i[0],l=c.some(e=>e.isHeader),u=Array.from({length:a}).fill(null);i.forEach(e=>{for(let t=0;t<a;t+=1)!u[t]&&e[t]?.align&&(u[t]=e[t].align)});let d=`
|
|
200
|
-
`,f=Array.from({length:a}).map((e,t)=>l&&c[t]&&c[t].text||``);return d+=`| ${f.map((e,t)=>s(e,o[t])).join(` | `)} |\n`,d+=`| ${o.map((e,t)=>{let n=Math.max(3,e),r=u[t];return r===`left`?`:${`-`.repeat(n)}`:r===`right`?`${`-`.repeat(n)}:`:r===`center`?`:${`-`.repeat(n)}:`:`-`.repeat(n)}).join(` | `)} |\n`,(l?i.slice(1):i).forEach(e=>{d+=`| ${Array.from({length:a}).fill(0).map((t,n)=>s(e[n]&&e[n].text||``,o[n])).join(` | `)} |\n`}),d}var DS=U.create({name:`table`,addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:hS,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:`tableRow+`,tableRole:`table`,isolating:!0,group:`block`,parseHTML(){return[{tag:`table`}]},renderHTML({node:e,HTMLAttributes:t}){let{colgroup:n,tableWidth:r,tableMinWidth:i}=gS(e,this.options.cellMinWidth),a=t.style;function o(){return a||(r?`width: ${r}`:`min-width: ${i}`)}let s=[`table`,V(this.options.HTMLAttributes,t,{style:o()}),n,[`tbody`,0]];return this.options.renderWrapper?[`div`,{class:`tableWrapper`},s]:s},parseMarkdown:(e,t)=>{let n=[],r=Array.isArray(e.align)?e.align:[];if(e.header){let i=[];e.header.forEach((e,n)=>{let a=tS(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableHeader`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}return e.rows&&e.rows.forEach(e=>{let i=[];e.forEach((e,n)=>{let a=tS(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableCell`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}),t.createNode(`table`,void 0,n)},renderMarkdown:(e,t)=>ES(e,t),markdownTokenizer:{name:`table`,level:`block`,start:e=>{let t=e.split(`
|
|
196
|
+
`):``}),cy=U.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,V(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode(`heading`,{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{let n=e.attrs?.level?parseInt(e.attrs.level,10):1,r=`#`.repeat(n);return e.content?`${r} ${t.renderChildren(e.content)}`:``},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>ep({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),ly=U.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,V(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!sf(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return td(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(j.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(M.create(t.doc,n.pos)):t.setSelection(j.create(t.doc,n.pos));else{let i=(e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType)?.create();i&&(t.insert(r,i),t.setSelection(j.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[$f({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),uy=U.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),dy=Of.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,V(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.indexOf(`++`)},tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let i=r[2].trim();return{type:`underline`,raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function fy(e={}){return new N({view(t){return new py(t,e)}})}var py=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc){if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(!t||i)return null;let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=Mn(this.editorView.state.doc,a,this.editorView.dragging.slice);e!=null&&(a=e)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},my=class e extends A{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):A.near(r)}content(){return k.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new hy(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!_y(e)||!vy(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!M.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};my.prototype.visible=!1,my.findFrom=my.findGapCursorFrom,A.jsonID(`gapcursor`,my);var hy=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return my.valid(t)?new my(t):A.near(t)}};function gy(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function _y(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||gy(e.type))return!0;if(e.inlineContent)return!1}}return!0}function vy(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||gy(e.type))return!0;if(e.inlineContent)return!1}}return!0}function yy(){return new N({props:{decorations:wy,createSelectionBetween(e,t,n){return t.pos==n.pos&&my.valid(n)?new my(n):null},handleClick:Sy,handleKeyDown:by,handleDOMEvents:{beforeinput:Cy}}})}var by=Kc({ArrowLeft:xy(`horiz`,-1),ArrowRight:xy(`horiz`,1),ArrowUp:xy(`vert`,-1),ArrowDown:xy(`vert`,1)});function xy(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof j){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=my.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new my(c))),!0):!1}}function Sy(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!my.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&M.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new my(r))),!0)}function Cy(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof my))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=D.empty;for(let e=r.length-1;e>=0;e--)i=D.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new k(i,0,0));return a.setSelection(j.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function wy(e){if(!(e.selection instanceof my))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,L.create(e.doc,[Ws.widget(e.selection.head,t,{key:`gapcursor`})])}var Ty=200,X=function(){};X.prototype.append=function(e){return e.length?(e=X.from(e),!this.length&&e||e.length<Ty&&this.leafAppend(e)||this.length<Ty&&e.leafPrepend(this)||this.appendInner(e)):this},X.prototype.prepend=function(e){return e.length?X.from(e).append(this):this},X.prototype.appendInner=function(e){return new Dy(this,e)},X.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?X.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},X.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},X.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},X.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},X.from=function(e){return e instanceof X?e:e&&e.length?new Ey(e):X.empty};var Ey=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Ty)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Ty)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(X);X.empty=new Ey([]);var Dy=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(X),Oy=500,ky=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new jy(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new jy(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new jy(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>Ny&&(s=Ay(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new Yt;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new jy(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new jy(i,o,l))}else r.push(new jy(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new jy(a.maps[e]));let u=this.items.slice(0,i).append(l).append(r),d=new e(u,s);return d.emptyItemCount()>Oy&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new jy(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(X.from(i.reverse()),a)}};ky.empty=new ky(X.empty,0);function Ay(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var jy=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},My=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},Ny=20;function Py(e,t,n,r){let i=n.getMeta(Uy),a;if(i)return i.historyState;n.getMeta(Wy)&&(e=new My(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(Uy))return o.getMeta(Uy).redo?new My(e.done.addTransform(n,void 0,r,Vy(t)),e.undone,Iy(n.mapping.maps),e.prevTime,e.prevComposition):new My(e.done,e.undone.addTransform(n,void 0,r,Vy(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!Fy(n,e.prevRanges)),s=o?Ly(e.prevRanges,n.mapping):Iy(n.mapping.maps);return new My(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,Vy(t)),ky.empty,s,n.time,i??e.prevComposition)}return(a=n.getMeta(`rebased`))?new My(e.done.rebased(n,a),e.undone.rebased(n,a),Ly(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new My(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Ly(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function Fy(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function Iy(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function Ly(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function Ry(e,t,n){let r=Vy(t),i=Uy.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new My(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(Uy,{redo:n,historyState:c})}var zy=!1,By=null;function Vy(e){let t=e.plugins;if(By!=t){zy=!1,By=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){zy=!0;break}}return zy}function Hy(e){return e.setMeta(Wy,!0)}var Uy=new P(`history`),Wy=new P(`closeHistory`);function Gy(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new N({key:Uy,state:{init(){return new My(ky.empty,ky.empty,null,0,-1)},apply(t,n,r){return Py(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?qy:n==`historyRedo`?Jy:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Ky(e,t){return(n,r)=>{let i=Uy.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=Ry(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var qy=Ky(!1,!0),Jy=Ky(!0,!0);H.create({name:`characterCount`,addOptions(){return{limit:null,autoTrim:!0,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new N({key:new P(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit,a=this.options.autoTrim;if(i==null||i===0||a===!1){e=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){let t=o-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var Yy=H.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[fy(this.options)]}});H.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new N({key:new P(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return L.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(Ws.node(t,t+e.nodeSize,{class:this.options.className}))}),L.create(e,a)}}})]}});var Xy=H.create({name:`gapCursor`,addProseMirrorPlugins(){return[yy()]},extendNodeSchema(e){return{allowGapCursor:B(z(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),Zy=`placeholder`,Qy=new P(`tiptap__placeholder`);function $y(e){let{editor:t,placeholder:n,dataAttribute:r,pos:i,node:a,isEmptyDoc:o,hasAnchor:s,classes:{emptyNode:c,emptyEditor:l}}=e,u=[c];return o&&u.push(l),Ws.node(i,i+a.nodeSize,{class:u.join(` `),[r]:typeof n==`function`?n({editor:t,node:a,pos:i,hasAnchor:s}):n})}function eb(e,t){return typeof e==`function`?e(t):e}function tb({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:a,to:o}){let{anchor:s}=i,c=[],l=e.isEmpty;return r.nodesBetween(a,o,(r,i)=>{let a=s>=i&&s<=i+r.nodeSize,o=!r.isLeaf&&ed(r);return r.type.isTextblock&&(a||!t.showOnlyCurrent)&&o&&c.push($y({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:a,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:eb(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:a})},node:r,pos:i})),t.includeChildren}),c}function nb({editor:e,options:t,dataAttribute:n,doc:r,selection:i}){if(!e.isEditable&&t.showOnlyWhenEditable)return null;let{anchor:a}=i,o=[],s=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let i=r.resolve(a),c=i.depth>0?i.node(1):i.nodeAfter,l=i.depth>0?i.before(1):a;if(c&&c.type.isTextblock&&ed(c)){let r=a>=l&&a<=l+c.nodeSize;o.push($y({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:eb(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else o.push(...tb({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return L.create(r,o)}function rb(e,t){let n=e.resolve(t);if(n.depth===0){let e=n.nodeAfter??n.nodeBefore;if(!e)return{from:t,to:t};let r=n.nodeAfter?t:t-e.nodeSize;return{from:r,to:r+e.nodeSize}}let r=n.before(1);return{from:r,to:r+n.node(1).nodeSize}}function ib(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function ab(e,t,n){let r=[];return e.forEach((e,i)=>{let a=i,o=a+e.nodeSize,s=a+1,c=o+1;s<n&&c>t&&r.push({from:a,to:o})}),r}function ob(e){if(e.length===0)return[];let t=[...e].sort((e,t)=>e.from-t.from),n=[{...t[0]}];for(let e=1;e<t.length;e+=1){let r=n[n.length-1],i=t[e];i.from<=r.to?r.to=Math.max(r.to,i.to):n.push({...i})}return n}function sb(e,t){let n=ab(e,t.from,t.to);return n.push(ib(e,rb(e,t.from))),t.to>t.from?n.push(ib(e,rb(e,Math.min(t.to,e.content.size+1)-1))):t.from<e.content.size+1&&n.push(ib(e,rb(e,Math.min(t.from+1,e.content.size)))),n}function cb(e,t,n){let r=[];if(e.docChanged){let t=Vu(e);for(let e of t)r.push(...sb(n.doc,e.newRange))}return e.selectionSet&&(r.push(ib(n.doc,rb(n.doc,e.mapping.map(t.selection.anchor)))),r.push(ib(n.doc,rb(n.doc,n.selection.anchor)))),ob(r)}function lb(e,t,n){let r=Math.max(0,Math.min(e,n.content.size));return{from:r,to:Math.max(r,Math.min(t,n.content.size))}}function ub({decorations:e,ranges:t,editor:n,options:r,dataAttribute:i,doc:a,selection:o}){let s=e;for(let e of t){let{from:t,to:c}=lb(e.from,e.to,a),l=s.find(t,c).filter(e=>e.from>=t&&e.to<=c);l.length&&(s=s.remove(l));let u=tb({editor:n,options:r,dataAttribute:i,doc:a,selection:o,from:t,to:c});u.length&&(s=s.add(a,u))}return s}function db({editor:e,options:t,dataAttribute:n}){return{init(r,i){return nb({editor:e,options:t,dataAttribute:n,doc:i.doc,selection:i.selection})??L.empty},apply(r,i,a,o){return!r.docChanged&&!r.selectionSet?i:ub({decorations:i.map(r.mapping,r.doc),ranges:cb(r,a,o),editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function fb(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function pb({editor:e,options:t}){let n=t.dataAttribute?`data-${fb(t.dataAttribute)}`:`data-${Zy}`,r=t.showOnlyCurrent&&!t.includeChildren;return new N({key:Qy,...r?{}:{state:db({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:r,selection:i})=>nb({editor:e,options:t,dataAttribute:n,doc:r,selection:i}):n=>t.showOnlyWhenEditable&&!e.isEditable?L.empty:Qy.getState(n)??L.empty}})}var mb=H.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:Zy,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[pb({editor:this.editor,options:this.options})]}});function hb(e,t){return!e.selection.empty&&!td(e.selection)&&t.isEditable}function gb(e,t){return hb(e,t)&&!t.isFocused&&!t.view.dragging}function _b(){var e;(e=window.getSelection())==null||e.removeAllRanges()}function vb(e){e.focus()}H.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new N({key:new P(`selection`),props:{decorations(n){return gb(n,e)?L.create(n.doc,[Ws.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(t){return hb(t.state,e)&&_b(),!1},focus(t){return hb(t.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&t.hasFocus()&&vb(t)}),!1}}}})]}});function yb({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var bb=H.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new P(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new N({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!yb({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!yb({node:r,types:n})}}})]}}),xb=H.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>qy(e,t),redo:()=>({state:e,dispatch:t})=>Jy(e,t)}},addProseMirrorPlugins(){return[Gy(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Sb=H.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(bg.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(ry.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(nh.configure(this.options.bulletList)),this.options.code!==!1&&e.push(oy.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(Zm.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(sy.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(Yy.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(Xy.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(rg.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(cy.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(xb.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(ly.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(Eg.configure(this.options.italic)),this.options.listItem!==!1&&e.push(Th.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(Ph.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push($v.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(Zh.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(sg.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(Ag.configure(this.options.strike)),this.options.text!==!1&&e.push(uy.configure(this.options.text)),this.options.underline!==!1&&e.push(dy.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(bb.configure(this.options?.trailingNode)),e}}),Cb,wb;if(typeof WeakMap<`u`){let e=new WeakMap;Cb=t=>e.get(t),wb=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;Cb=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},wb=(n,r)=>(t==10&&(t=0),e[t++]=n,e[t++]=r)}var Z=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,i=t/this.width|0,a=r+1,o=i+1;for(let e=1;a<this.width&&this.map[t+e]==n;e++)a++;for(let e=1;o<this.height&&this.map[t+this.width*e]==n;e++)o++;return{left:r,top:i,right:a,bottom:o}}throw RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:i,top:a,bottom:o}=this.findCell(e);return t==`horiz`?(n<0?r==0:i==this.width)?null:this.map[a*this.width+(n<0?r-1:i)]:(n<0?a==0:o==this.height)?null:this.map[r+this.width*(n<0?a-1:o)]}rectBetween(e,t){let{left:n,right:r,top:i,bottom:a}=this.findCell(e),{left:o,right:s,top:c,bottom:l}=this.findCell(t);return{left:Math.min(n,o),top:Math.min(i,c),right:Math.max(r,s),bottom:Math.max(a,l)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){let a=r*this.width+i,o=this.map[a];n[o]||(n[o]=!0,!(i==e.left&&i&&this.map[a-1]==o||r==e.top&&r&&this.map[a-this.width]==o)&&t.push(o))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){let a=i+n.child(r).nodeSize;if(r==e){let n=t+e*this.width,r=(e+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?a-1:this.map[n]}i=a}}static get(e){return Cb(e)||wb(e,Tb(e))}};function Tb(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=Eb(e),n=e.childCount,r=[],i=0,a=null,o=[];for(let e=0,i=t*n;e<i;e++)r[e]=0;for(let s=0,c=0;s<n;s++){let l=e.child(s);c++;for(let e=0;;e++){for(;i<r.length&&r[i]!=0;)i++;if(e==l.childCount)break;let u=l.child(e),{colspan:d,rowspan:f,colwidth:p}=u.attrs;for(let e=0;e<f;e++){if(e+s>=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;e<d;e++){r[l+e]==0?r[l+e]=c:(a||=[]).push({type:`collision`,row:s,pos:c,n:d-e});let n=p&&p[e];if(n){let r=(l+e)%t*2,i=o[r];i==null||i!=n&&o[r+1]==1?(o[r]=n,o[r+1]=1):i==n&&o[r+1]++}}}i+=d,c+=u.nodeSize}let u=(s+1)*t,d=0;for(;i<u;)r[i++]==0&&d++;d&&(a||=[]).push({type:`missing`,row:s,n:d}),c++}(t===0||n===0)&&(a||=[]).push({type:`zero_sized`});let s=new Z(t,n,r,a),c=!1;for(let e=0;!c&&e<o.length;e+=2)o[e]!=null&&o[e+1]<n&&(c=!0);return c&&Db(s,o,e),s}function Eb(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let i=e.child(r),a=0;if(n)for(let t=0;t<r;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++){let i=n.child(e);t+i.attrs.rowspan>r&&(a+=i.attrs.colspan)}}for(let e=0;e<i.childCount;e++){let t=i.child(e);a+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function Db(e,t,n){e.problems||=[];let r={};for(let i=0;i<e.map.length;i++){let a=e.map[i];if(r[a])continue;r[a]=!0;let o=n.nodeAt(a);if(!o)throw RangeError(`No cell with offset ${a} found`);let s=null,c=o.attrs;for(let n=0;n<c.colspan;n++){let r=t[(i+n)%e.width*2];r!=null&&(!c.colwidth||c.colwidth[n]!=r)&&((s||=Ob(c))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function Ob(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function kb(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}var Ab=new P(`selectingCells`);function jb(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function Mb(e){for(let t=e.depth;t>0;t--){let n=e.node(t).type.spec.tableRole;if(n===`cell`||n===`header_cell`)return e.node(t)}return null}function Nb(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function Pb(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=jb(t.$head)||Fb(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function Fb(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function Ib(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function Lb(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function Rb(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function zb(e,t,n){let r=e.node(-1),i=Z.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function Bb(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function Vb(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}function Hb(e,t,n){let r=kb(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0}var Q=class e extends A{constructor(e,t=e){let n=e.node(-1),r=Z.get(n),i=e.start(-1),a=r.rectBetween(e.pos-i,t.pos-i),o=e.node(0),s=r.cellsInRect(a).filter(e=>e!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new er(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(Ib(r)&&Ib(i)&&Rb(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return j.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=Z.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n<r.bottom;n++){let o=[];for(let a=n*t.width+r.left,s=r.left;s<r.right;s++,a++){let n=t.map[a];if(i[n])continue;i[n]=!0;let s=t.findCell(n),c=e.nodeAt(n);if(!c)throw RangeError(`No cell with offset ${n} found`);let l=r.left-s.left,u=s.right-r.right;if(l>0||u>0){let e=c.attrs;if(l>0&&(e=Bb(e,0,l)),u>0&&(e=Bb(e,e.colspan-u,u)),s.left<r.left){if(c=c.type.createAndFill(e),!c)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else c=c.type.create(e,c.content)}if(s.top<r.top||s.bottom>r.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top<r.top?c.type.createAndFill(e):c.type.create(e,c.content)}o.push(c)}a.push(e.child(n).copy(D.from(o)))}let o=this.isColSelection()&&this.isRowSelection()?e:a;return new k(D.from(o),1,1)}replace(e,t=k.empty){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n);e.replace(s.map(a.pos),s.map(o.pos),i?k.empty:t)}let i=A.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new k(D.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=Z.get(t),r=this.$anchorCell.start(-1),i=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<i.length;n++)e(t.nodeAt(i[n]),r+i[n])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=Z.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom<i.height&&(n=c.resolve(a+i.map[i.width*(i.height-1)+s.right-1]))):(s.top>0&&(n=c.resolve(a+i.map[s.left])),o.bottom<i.height&&(t=c.resolve(a+i.map[i.width*(i.height-1)+o.right-1]))),new e(t,n)}isRowSelection(){let e=this.$anchorCell.node(-1),t=Z.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),i=t.colCount(this.$headCell.pos-n);if(Math.min(r,i)>0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=Z.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right<i.width&&(n=c.resolve(a+i.map[i.width*(s.top+1)-1]))):(s.left>0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right<i.width&&(t=c.resolve(a+i.map[i.width*(o.top+1)-1]))),new e(t,n)}toJSON(){return{type:`cell`,anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new Ub(this.$anchorCell.pos,this.$headCell.pos)}};Q.prototype.visible=!1,A.jsonID(`cell`,Q);var Ub=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){let t=e.resolve(this.anchor),n=e.resolve(this.head);return t.parent.type.spec.tableRole==`row`&&n.parent.type.spec.tableRole==`row`&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&Rb(t,n)?new Q(t,n):A.near(n,1)}};function Wb(e){if(!(e.selection instanceof Q))return null;let t=[];return e.selection.forEachCell((e,n)=>{t.push(Ws.node(n,n+e.nodeSize,{class:`selectedCell`}))}),L.create(e.doc,t)}function Gb({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function Kb({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function qb(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof M&&(o=r.node.type.spec.tableRole)){if(o==`cell`||o==`header_cell`)a=Q.create(i,r.from);else if(o==`row`){let e=i.resolve(r.from+1);a=Q.rowSelection(e,e)}else if(!n){let e=Z.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];a=Q.create(i,t+1,n)}}else r instanceof j&&Gb(r)?a=j.create(i,r.from):r instanceof j&&Kb(r)&&(a=j.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var Jb=new P(`fix-tables`);function Yb(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o<a;o++){let a=t.child(o);for(let t=s,r=Math.min(i,o+3);t<r;t++)if(e.child(t)==a){s=t+1,n+=a.nodeSize;continue outer}r(a,n),s<i&&e.child(s).sameMarkup(a)?Yb(e.child(s),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function Xb(e,t){let n,r=(t,r)=>{t.type.spec.tableRole==`table`&&(n=Zb(e,t,r,n))};return t?t.doc!=e.doc&&Yb(t.doc,e.doc,0,r):e.doc.descendants(r),n}function Zb(e,t,n,r){let i=Z.get(t);if(!i.problems)return r;r||=e.tr;let a=[];for(let e=0;e<i.height;e++)a.push(0);for(let e=0;e<i.problems.length;e++){let o=i.problems[e];if(o.type==`collision`){let e=t.nodeAt(o.pos);if(!e)continue;let i=e.attrs;for(let e=0;e<i.rowspan;e++)a[o.row+e]+=o.n;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,Bb(i,i.colspan-o.n,o.n))}else if(o.type==`missing`)a[o.row]+=o.n;else if(o.type==`overlong_rowspan`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-o.n})}else if(o.type==`colwidth mismatch`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,colwidth:o.colwidth})}else if(o.type==`zero_sized`){let e=r.mapping.map(n);r.delete(e,e+t.nodeSize)}}let o,s;for(let e=0;e<a.length;e++)a[e]&&(o??=e,s=e);for(let c=0,l=n+1;c<i.height;c++){let n=t.child(c),i=l+n.nodeSize,u=a[c];if(u>0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n<u;n++){let n=kb(e.schema)[t].createAndFill();n&&a.push(n)}let d=(c==0||o==c-1)&&s==c?l+1:i-1;r.insert(r.mapping.map(d),a)}l=i}return r.setMeta(Jb,{fixTables:!0})}function Qb(e){let t=e.selection,n=Pb(e),r=n.node(-1),i=n.start(-1),a=Z.get(r);return{...t instanceof Q?a.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):a.findCell(n.pos-i),tableStart:i,map:a,table:r}}function $b(e,{map:t,tableStart:n,table:r},i){let a=i>0?-1:0;Hb(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o<t.height;o++){let s=o*t.width+i;if(i>0&&i<t.width&&t.map[s-1]==t.map[s]){let a=t.map[s],c=r.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,Vb(c.attrs,i-t.colCount(a))),o+=c.attrs.rowspan-1}else{let c=a==null?kb(r.type.schema).cell:r.nodeAt(t.map[s+a]).type,l=t.positionAt(o,i,r);e.insert(e.mapping.map(n+l),c.createAndFill())}}return e}function ex(e,t){if(!Nb(e))return!1;if(t){let n=Qb(e);t($b(e.tr,n,n.left))}return!0}function tx(e,t){if(!Nb(e))return!1;if(t){let n=Qb(e);t($b(e.tr,n,n.right))}return!0}function nx(e,{map:t,table:n,tableStart:r},i){let a=e.mapping.maps.length;for(let o=0;o<t.height;){let s=o*t.width+i,c=t.map[s],l=n.nodeAt(c),u=l.attrs;if(i>0&&t.map[s-1]==c||i<t.width-1&&t.map[s+1]==c)e.setNodeMarkup(e.mapping.slice(a).map(r+c),null,Bb(u,i-t.colCount(c)));else{let t=e.mapping.slice(a).map(r+c);e.delete(t,t+l.nodeSize)}o+=u.rowspan}}function rx(e,t){if(!Nb(e))return!1;if(t){let n=Qb(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let e=n.right-1;nx(r,n,e),e!=n.left;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=Z.get(e)}t(r)}return!0}function ix(e,t,n){let r=kb(t.type.schema).header_cell;for(let i=0;i<e.width;i++)if(t.nodeAt(e.map[i+n*e.width])?.type!=r)return!1;return!0}function ax(e,{map:t,tableStart:n,table:r},i){let a=n;for(let e=0;e<i;e++)a+=r.child(e).nodeSize;let o=[],s=i>0?-1:0;ix(t,r,i+s)&&(s=i==0||i==t.height?null:0);for(let a=0,c=t.width*i;a<t.width;a++,c++)if(i>0&&i<t.height&&t.map[c]==t.map[c-t.width]){let i=t.map[c],o=r.nodeAt(i).attrs;e.setNodeMarkup(n+i,null,{...o,rowspan:o.rowspan+1}),a+=o.colspan-1}else{let e=(s==null?kb(r.type.schema).cell:r.nodeAt(t.map[c+s*t.width])?.type)?.createAndFill();e&&o.push(e)}return e.insert(a,kb(r.type.schema).row.create(null,o)),e}function ox(e,t){if(!Nb(e))return!1;if(t){let n=Qb(e);t(ax(e.tr,n,n.top))}return!0}function sx(e,t){if(!Nb(e))return!1;if(t){let n=Qb(e);t(ax(e.tr,n,n.bottom))}return!0}function cx(e,{map:t,table:n,tableStart:r},i){let a=0;for(let e=0;e<i;e++)a+=n.child(e).nodeSize;let o=a+n.child(i).nodeSize,s=e.mapping.maps.length;e.delete(a+r,o+r);let c=new Set;for(let a=0,o=i*t.width;a<t.width;a++,o++){let l=t.map[o];if(!c.has(l)){if(c.add(l),i>0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i<t.height&&l==t.map[o+t.width]){let o=n.nodeAt(l),c=o.attrs,u=o.type.create({...c,rowspan:o.attrs.rowspan-1},o.content),d=t.positionAt(i+1,a,n);e.insert(e.mapping.slice(s).map(r+d),u),a+=c.colspan-1}}}}function lx(e,t){if(!Nb(e))return!1;if(t){let n=Qb(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;cx(r,n,e),e!=n.top;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=Z.get(n.table)}t(r)}return!0}function ux(e){let t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function dx({width:e,height:t,map:n},r){let i=r.top*e+r.left,a=i,o=(r.bottom-1)*e+r.left,s=i+(r.right-r.left-1);for(let t=r.top;t<r.bottom;t++){if(r.left>0&&n[a]==n[a-1]||r.right<e&&n[s]==n[s+1])return!0;a+=e,s+=e}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[i]==n[i-e]||r.bottom<t&&n[o]==n[o+e])return!0;i++,o++}return!1}function fx(e,t){let n=e.selection;if(!(n instanceof Q)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=Qb(e),{map:i}=r;if(dx(i,r))return!1;if(t){let n=e.tr,a={},o=D.empty,s,c;for(let e=r.top;e<r.bottom;e++)for(let t=r.left;t<r.right;t++){let l=i.map[e*i.width+t],u=r.table.nodeAt(l);if(!a[l]&&u){if(a[l]=!0,s==null)s=l,c=u;else{ux(u)||(o=o.append(u.content));let e=n.mapping.map(l+r.tableStart);n.delete(e,e+u.nodeSize)}}}if(s==null||c==null)return!0;if(n.setNodeMarkup(s+r.tableStart,null,{...Vb(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),o.size>0){let e=s+1+c.content.size,t=ux(c)?s+1:e;n.replaceWith(t+r.tableStart,e+r.tableStart,o)}n.setSelection(new Q(n.doc.resolve(s+r.tableStart))),t(n)}return!0}function px(e,t){let n=kb(e.schema);return mx(({node:e})=>n[e.type.spec.tableRole])(e,t)}function mx(e){return(t,n)=>{let r=t.selection,i,a;if(r instanceof Q){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,a=r.$anchorCell.pos}else{if(i=Mb(r.$from),!i)return!1;a=jb(r.$from)?.pos}if(i==null||a==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let o=i.attrs,s=[],c=o.colwidth;o.rowspan>1&&(o={...o,rowspan:1}),o.colspan>1&&(o={...o,colspan:1});let l=Qb(t),u=t.tr;for(let e=0;e<l.right-l.left;e++)s.push(c?{...o,colwidth:c&&c[e]?[c[e]]:null}:o);let d;for(let t=l.top;t<l.bottom;t++){let n=l.map.positionAt(t,l.left,l.table);t==l.top&&(n+=i.nodeSize);for(let r=l.left,a=0;r<l.right;r++,a++)(r!=l.left||t!=l.top)&&u.insert(d=u.mapping.map(n+l.tableStart,1),e({node:i,row:t,col:r}).createAndFill(s[a]))}u.setNodeMarkup(a,e({node:i,row:l.top,col:l.left}),s[0]),r instanceof Q&&u.setSelection(new Q(u.doc.resolve(r.$anchorCell.pos),d?u.doc.resolve(d):void 0)),n(u)}return!0}}function hx(e,t){return function(n,r){if(!Nb(n))return!1;let i=Pb(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){let a=n.tr;n.selection instanceof Q?n.selection.forEachCell((n,r)=>{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function gx(e){return function(t,n){if(!Nb(t))return!1;if(n){let r=kb(t.schema),i=Qb(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e<o.length;e++)s[e].type==r.header_cell&&a.setNodeMarkup(i.tableStart+o[e],r.cell,s[e].attrs);if(a.steps.length===0)for(let e=0;e<o.length;e++)a.setNodeMarkup(i.tableStart+o[e],r.header_cell,s[e].attrs);n(a)}return!0}}function _x(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e==`row`?t.map.width:1,bottom:e==`column`?t.map.height:1});for(let e=0;e<r.length;e++){let i=t.table.nodeAt(r[e]);if(i&&i.type!==n.header_cell)return!1}return!0}function vx(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?gx(e):function(t,n){if(!Nb(t))return!1;if(n){let r=kb(t.schema),i=Qb(t),a=t.tr,o=_x(`row`,i,r),s=_x(`column`,i,r),c=(e===`column`?o:e===`row`&&s)?1:0,l=e==`column`?{left:0,top:c,right:1,bottom:i.map.height}:e==`row`?{left:c,top:0,right:i.map.width,bottom:1}:i,u=e==`column`?s?r.cell:r.header_cell:e==`row`?o?r.cell:r.header_cell:r.cell;i.map.cellsInRect(l).forEach(e=>{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}vx(`row`,{useDeprecatedLogic:!0}),vx(`column`,{useDeprecatedLogic:!0});var yx=vx(`cell`,{useDeprecatedLogic:!0});function bx(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let t=e.node(-1);for(let n=e.indexAfter(-1),r=e.after();n<t.childCount;n++){let e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}function xx(e){return function(t,n){if(!Nb(t))return!1;let r=bx(Pb(t),e);if(r==null)return!1;if(n){let e=t.doc.resolve(r);n(t.tr.setSelection(j.between(e,Lb(e))).scrollIntoView())}return!0}}function Sx(e,t){let n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Cx(e,t){let n=e.selection;if(!(n instanceof Q))return!1;if(t){let r=e.tr,i=kb(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new k(i,0,0))}),r.docChanged&&t(r)}return!0}function wx(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole==`table`);)n--,r--,t=t.child(0).content;let i=t.child(0),a=i.type.spec.tableRole,o=i.type.schema,s=[];if(a==`row`)for(let e=0;e<t.childCount;e++){let i=t.child(e).content,a=e?0:Math.max(0,n-1),c=e<t.childCount-1?0:Math.max(0,r-1);(a||c)&&(i=Ex(kb(o).row,new k(i,a,c)).content),s.push(i)}else if(a==`cell`||a==`header_cell`)s.push(n||r?Ex(kb(o).row,new k(t,n,r)).content:t);else return null;return Tx(o,s)}function Tx(e,t){let n=[];for(let e=0;e<t.length;e++){let r=t[e];for(let t=r.childCount-1;t>=0;t--){let{rowspan:i,colspan:a}=r.child(t).attrs;for(let t=e;t<e+i;t++)n[t]=(n[t]||0)+a}}let r=0;for(let e=0;e<n.length;e++)r=Math.max(r,n[e]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(D.empty),n[i]<r){let a=kb(e).cell.createAndFill(),o=[];for(let e=n[i];e<r;e++)o.push(a);t[i]=t[i].append(D.from(o))}return{height:t.length,width:r,rows:t}}function Ex(e,t){let n=e.createAndFill();return new Qn(n).replace(0,n.content.size,t).doc}function Dx({width:e,height:t,rows:n},r,i){if(e!=r){let t=[],i=[];for(let e=0;e<n.length;e++){let a=n[e],o=[];for(let n=t[e]||0,i=0;n<r;i++){let s=a.child(i%a.childCount);n+s.attrs.colspan>r&&(s=s.type.createChecked(Bb(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),o.push(s),n+=s.attrs.colspan;for(let n=1;n<s.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+s.attrs.colspan}i.push(D.from(o))}n=i,e=r}if(t!=i){let e=[];for(let r=0,a=0;r<i;r++,a++){let o=[],s=n[a%t];for(let e=0;e<s.childCount;e++){let t=s.child(e);r+t.attrs.rowspan>i&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),o.push(t)}e.push(D.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function Ox(e,t,n,r,i,a,o){let s=e.doc.type.schema,c=kb(s),l,u;if(i>t.width)for(let a=0,s=0;a<t.height;a++){let d=n.child(a);s+=d.nodeSize;let f=[],p;p=d.lastChild==null||d.lastChild.type==c.cell?l||=c.cell.createAndFill():u||=c.header_cell.createAndFill();for(let e=t.width;e<i;e++)f.push(p);e.insert(e.mapping.slice(o).map(s-1+r),f)}if(a>t.height){let s=[];for(let e=0,r=(t.height-1)*t.width;e<Math.max(t.width,i);e++){let i=e>=t.width?!1:n.nodeAt(t.map[r+e]).type==c.header_cell;s.push(i?u||=c.header_cell.createAndFill():l||=c.cell.createAndFill())}let d=c.row.create(null,D.from(s)),f=[];for(let e=t.height;e<a;e++)f.push(d);e.insert(e.mapping.slice(o).map(r+n.nodeSize-2),f)}return!!(l||u)}function kx(e,t,n,r,i,a,o,s){if(o==0||o==t.height)return!1;let c=!1;for(let l=i;l<a;l++){let i=o*t.width+l,a=t.map[i];if(t.map[i-t.width]==a){c=!0;let i=n.nodeAt(a),{top:u,left:d}=t.findCell(a);e.setNodeMarkup(e.mapping.slice(s).map(a+r),null,{...i.attrs,rowspan:o-u}),e.insert(e.mapping.slice(s).map(t.positionAt(o,d,n)),i.type.createAndFill({...i.attrs,rowspan:u+i.attrs.rowspan-o})),l+=i.attrs.colspan-1}}return c}function Ax(e,t,n,r,i,a,o,s){if(o==0||o==t.width)return!1;let c=!1;for(let l=i;l<a;l++){let i=l*t.width+o,a=t.map[i];if(t.map[i-1]==a){c=!0;let i=n.nodeAt(a),u=t.colCount(a),d=e.mapping.slice(s).map(a+r);e.setNodeMarkup(d,null,Bb(i.attrs,o-u,i.attrs.colspan-(o-u))),e.insert(d+i.nodeSize,i.type.createAndFill(Bb(i.attrs,0,o-u))),l+=i.attrs.rowspan-1}}return c}function jx(e,t,n,r,i){let a=n?e.doc.nodeAt(n-1):e.doc;if(!a)throw Error(`No table found`);let o=Z.get(a),{top:s,left:c}=r,l=c+i.width,u=s+i.height,d=e.tr,f=0;function p(){if(a=n?d.doc.nodeAt(n-1):d.doc,!a)throw Error(`No table found`);o=Z.get(a),f=d.mapping.maps.length}Ox(d,o,a,n,l,u,f)&&p(),kx(d,o,a,n,c,l,s,f)&&p(),kx(d,o,a,n,c,l,u,f)&&p(),Ax(d,o,a,n,s,u,c,f)&&p(),Ax(d,o,a,n,s,u,l,f)&&p();for(let e=s;e<u;e++){let t=o.positionAt(e,c,a),r=o.positionAt(e,l,a);d.replace(d.mapping.slice(f).map(t+n),d.mapping.slice(f).map(r+n),new k(i.rows[e-s],0,0))}p(),d.setSelection(new Q(d.doc.resolve(n+o.positionAt(s,c,a)),d.doc.resolve(n+o.positionAt(u-1,l-1,a)))),t(d)}var Mx=Kc({ArrowLeft:Px(`horiz`,-1),ArrowRight:Px(`horiz`,1),ArrowUp:Px(`vert`,-1),ArrowDown:Px(`vert`,1),"Shift-ArrowLeft":Fx(`horiz`,-1),"Shift-ArrowRight":Fx(`horiz`,1),"Shift-ArrowUp":Fx(`vert`,-1),"Shift-ArrowDown":Fx(`vert`,1),Backspace:Cx,"Mod-Backspace":Cx,Delete:Cx,"Mod-Delete":Cx});function Nx(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function Px(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection;if(a instanceof Q)return Nx(n,r,A.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=zx(i,e,t);if(o==null)return!1;if(e==`horiz`)return Nx(n,r,A.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=zb(i,e,t),s;return s=a?A.near(a,1):t<0?A.near(n.doc.resolve(i.before(-1)),-1):A.near(n.doc.resolve(i.after(-1)),1),Nx(n,r,s)}}}function Fx(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof Q)o=a;else{let r=zx(i,e,t);if(r==null)return!1;o=new Q(n.doc.resolve(r))}let s=zb(o.$headCell,e,t);return s?Nx(n,r,new Q(o.$anchorCell,s)):!1}}function Ix(e,t){let n=e.state.doc,r=jb(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new Q(r))),!0):!1}function Lx(e,t,n){if(!Nb(e.state))return!1;let r=wx(n),i=e.state.selection;if(i instanceof Q){r||={width:1,height:1,rows:[D.from(Ex(kb(e.state.schema).cell,n))]};let t=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),o=Z.get(t).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=Dx(r,o.right-o.left,o.bottom-o.top),jx(e.state,e.dispatch,a,o,r),!0}if(r){let t=Pb(e.state),n=t.start(-1);return jx(e.state,e.dispatch,n,Z.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function Rx(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=Bx(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof Q)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=jb(e.state.selection.$anchor))!=null&&Vx(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=Vx(e,n),i=Ab.getState(e.state)==null;if(!r||!Rb(t,r)){if(i)r=t;else return}let a=new Q(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(Ab,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),Ab.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(Ab,-1))}function o(r){let o=r,s=Ab.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(Bx(e,o.target)!=n&&(c=Vx(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function zx(e,t,n){if(!(e.state.selection instanceof j))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function Bx(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function Vx(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&jb(e.state.doc.resolve(r))||jb(e.state.doc.resolve(i))}var Hx=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`)),this.table.style.setProperty(`--default-cell-min-width`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),Ux(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type&&(this.node=e,Ux(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function Ux(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;e<l.childCount;e++){let{colspan:u,colwidth:d}=l.child(e).attrs;for(let e=0;e<u;e++,n++){let l=i==n?a:d&&d[e],u=l?l+`px`:``;if(o+=l||r,l||(s=!1),c)c.style.width!=u&&(c.style.width=u),c=c.nextSibling;else{let e=document.createElement(`col`);e.style.width=u,t.appendChild(e)}}}for(;c;){var u;let e=c.nextSibling;(u=c.parentNode)==null||u.removeChild(c),c=e}s?(n.style.width=o+`px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=o+`px`)}}var Wx=new P(`tableColumnResizing`);function Gx({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=Hx,lastColumnResizable:i=!0}={}){let a=new N({key:Wx,state:{init(e,t){var i;let o=(i=a.spec)==null||(i=i.props)==null?void 0:i.nodeViews,s=kb(t.schema).table.name;return r&&o&&(o[s]=(e,t)=>new r(e,n,t)),new Kx(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=Wx.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{qx(t,n,e,i)},mouseleave:e=>{Jx(e)},mousedown:(e,r)=>{Yx(e,r,t,n)}},decorations:e=>{let t=Wx.getState(e);if(t&&t.activeHandle>-1)return iS(e,t.activeHandle)},nodeViews:{}}});return a}var Kx=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(Wx);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return Ib(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function qx(e,t,n,r){if(!e.editable)return;let i=Wx.getState(e.state);if(i&&!i.dragging){let a=Zx(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=Qx(e,t,`left`,n):i-t.clientX<=n&&(o=Qx(e,t,`right`,n))}if(o!=i.activeHandle){if(!r&&o!==-1){let t=e.state.doc.resolve(o),n=t.node(-1),r=Z.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}eS(e,o)}}}function Jx(e){if(!e.editable)return;let t=Wx.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&eS(e,-1)}function Yx(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=Wx.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=Xx(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(Wx,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=Wx.getState(e.state);r?.dragging&&(tS(e,r.activeHandle,$x(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(Wx,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=Wx.getState(e.state);if(i&&i.dragging){let a=$x(i.dragging,t,n);nS(e,i.activeHandle,a,r)}}return nS(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function Xx(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;e<n;e++)r[e]&&(o-=r[e],s--);return o/s}function Zx(e){for(;e&&e.nodeName!=`TD`&&e.nodeName!=`TH`;)e=e.classList&&e.classList.contains(`ProseMirror`)?null:e.parentNode;return e}function Qx(e,t,n,r){let i=n==`right`?-r:r,a=e.posAtCoords({left:t.clientX+i,top:t.clientY});if(!a)return-1;let{pos:o}=a,s=jb(e.state.doc.resolve(o));if(!s)return-1;if(n==`right`)return s.pos;let c=Z.get(s.node(-1)),l=s.start(-1),u=c.map.indexOf(s.pos-l);return u%c.width==0?-1:l+c.map[u-1]}function $x(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function eS(e,t){e.dispatch(e.state.tr.setMeta(Wx,{setHandle:t}))}function tS(e,t,n){let r=e.state.doc.resolve(t),i=r.node(-1),a=Z.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,c=e.state.tr;for(let e=0;e<a.height;e++){let t=e*a.width+s;if(e&&a.map[t]==a.map[t-a.width])continue;let r=a.map[t],l=i.nodeAt(r).attrs,u=l.colspan==1?0:s-a.colCount(r);if(l.colwidth&&l.colwidth[u]==n)continue;let d=l.colwidth?l.colwidth.slice():rS(l.colspan);d[u]=n,c.setNodeMarkup(o+r,null,{...l,colwidth:d})}c.docChanged&&e.dispatch(c)}function nS(e,t,n,r){let i=e.state.doc.resolve(t),a=i.node(-1),o=i.start(-1),s=Z.get(a).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1,c=e.domAtPos(i.start(-1)).node;for(;c&&c.nodeName!=`TABLE`;)c=c.parentNode;c&&Ux(a,c.firstChild,c,r,s,n)}function rS(e){return Array(e).fill(0)}function iS(e,t){let n=[],r=e.doc.resolve(t),i=r.node(-1);if(!i)return L.empty;let a=Z.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let t=0;t<a.height;t++){let r=s+t*a.width;if((s==a.width-1||a.map[r]!=a.map[r+1])&&(t==0||a.map[r]!=a.map[r-a.width])){let t=a.map[r],s=o+t+i.nodeAt(t).nodeSize-1,c=document.createElement(`div`);c.className=`column-resize-handle`,Wx.getState(e)?.dragging&&n.push(Ws.node(o+t,o+t+i.nodeAt(t).nodeSize,{class:`column-resize-dragging`})),n.push(Ws.widget(s,c))}}return L.create(e.doc,n)}function aS({allowTableNodeSelection:e=!1}={}){return new N({key:Ab,state:{init(){return null},apply(e,t){let n=e.getMeta(Ab);if(n!=null)return n==-1?null:n;if(t==null||!e.docChanged)return t;let{deleted:r,pos:i}=e.mapping.mapResult(t);return r?null:i}},props:{decorations:Wb,handleDOMEvents:{mousedown:Rx},createSelectionBetween(e){return Ab.getState(e.state)==null?null:e.state.selection},handleTripleClick:Ix,handleKeyDown:Mx,handlePaste:Lx},appendTransaction(t,n,r){return qb(r,Xb(r,n),e)}})}function oS(e){return e===`left`||e===`right`||e===`center`?e:null}function sS(e){let t=(e.style.textAlign||``).trim().toLowerCase(),n=(e.getAttribute(`align`)||``).trim().toLowerCase();return oS(t||n)}function cS(e){return oS(e?.align)}function lS(){return{default:null,parseHTML:e=>sS(e),renderHTML:e=>e.align?{style:`text-align: ${e.align}`}:{}}}function uS(e){let t=e.parentElement,n=e.closest(`table`);if(!t||!n)return null;let r=Array.from(t.children).indexOf(e),i=n.querySelectorAll(`colgroup > col`)[r]?.getAttribute(`width`);return i?[parseInt(i,10)]:null}function dS(e){let t=e.getAttribute(`colwidth`);return t?t.split(`,`).map(e=>parseInt(e,10)):uS(e)}var fS=/[ \t\r\n\f]+/g;function pS(e){return e.children.length>0?!1:(e.textContent??``).replace(fS,``)===``}function mS(e){let t=e.createAndFill();if(!t)throw Error(`[tiptap error]: "${e.name}" has no default content to backfill.`);return t.content}var hS=U.create({name:`tableCell`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:dS},align:lS()}},tableRole:`cell`,isolating:!0,parseHTML(){return[{tag:`td`,getAttrs:e=>pS(e)?{}:!1,getContent:(e,t)=>mS(t.nodes[this.name])},{tag:`td`}]},renderHTML({HTMLAttributes:e}){return[`td`,V(this.options.HTMLAttributes,e),0]}}),gS=U.create({name:`tableHeader`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:dS},align:lS()}},tableRole:`header_cell`,isolating:!0,parseHTML(){return[{tag:`th`,getAttrs:e=>pS(e)?{}:!1,getContent:(e,t)=>mS(t.nodes[this.name])},{tag:`th`}]},renderHTML({HTMLAttributes:e}){return[`th`,V(this.options.HTMLAttributes,e),0]}}),_S=U.create({name:`tableRow`,addOptions(){return{HTMLAttributes:{}}},content:`(tableCell | tableHeader)*`,tableRole:`row`,parseHTML(){return[{tag:`tr`}]},renderHTML({HTMLAttributes:e}){return[`tr`,V(this.options.HTMLAttributes,e),0]}});function vS(e,t){return t?[`width`,`${Math.max(t,e)}px`]:[`min-width`,`${e}px`]}function yS(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l!==null)for(let e=0,n=0;e<l.childCount;e+=1){let{colspan:u,colwidth:d}=l.child(e).attrs;for(let e=0;e<u;e+=1,n+=1){let l=i===n?a:d&&d[e],u=l?`${l}px`:``;if(o+=l||r,l||(s=!1),c){if(c.style.width!==u){let[e,t]=vS(r,l);c.style.setProperty(e,t)}c=c.nextSibling}else{let e=document.createElement(`col`),[n,i]=vS(r,l);e.style.setProperty(n,i),t.appendChild(e)}}}for(;c;){var u;let e=c.nextSibling;(u=c.parentNode)==null||u.removeChild(c),c=e}let d=e.attrs.style&&typeof e.attrs.style==`string`&&/\bwidth\s*:/i.test(e.attrs.style);s&&!d?(n.style.width=`${o}px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=`${o}px`)}var bS=class{constructor(e,t,n,r={}){this.node=e,this.cellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`));for(let[e,t]of Object.entries(r))t!=null&&(e===`style`?this.table.style.cssText=String(t):this.table.setAttribute(e,String(t)));e.attrs.style&&(this.table.style.cssText=e.attrs.style),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),yS(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type===this.node.type&&(this.node=e,yS(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){let t=e.target,n=this.dom.contains(t),r=this.contentDOM.contains(t);return!(!n||r||e.type!==`attributes`&&e.type!==`childList`&&e.type!==`characterData`)}};function xS(e,t,n,r){let i=0,a=!0,o=[],s=e.firstChild;if(!s)return{};for(let e=0,c=0;e<s.childCount;e+=1){let{colspan:l,colwidth:u}=s.child(e).attrs;for(let e=0;e<l;e+=1,c+=1){let s=n===c?r:u&&u[e];i+=s||t,s||(a=!1);let[l,d]=vS(t,s);o.push([`col`,{style:`${l}: ${d}`}])}}let c=a?`${i}px`:``,l=a?``:`${i}px`;return{colgroup:[`colgroup`,{},...o],tableWidth:c,tableMinWidth:l}}function SS(e,t){return t?e.createChecked(null,t):e.createAndFill()}function CS(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;let t={};return Object.keys(e.nodes).forEach(n=>{let r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function wS(e,t,n,r,i){let a=CS(e),o=[],s=[];for(let e=0;e<n;e+=1){let e=SS(a.cell,i);if(e&&s.push(e),r){let e=SS(a.header_cell,i);e&&o.push(e)}}let c=[];for(let e=0;e<t;e+=1)c.push(a.row.createChecked(null,r&&e===0?o:s));return a.table.createChecked(null,c)}function TS(e){return e instanceof Q}var ES=({editor:e})=>{let{selection:t}=e.state;if(!TS(t))return!1;let n=0;return pu(t.ranges[0].$from,e=>e.type.name===`table`)?.node.descendants(e=>{if(e.type.name===`table`)return!1;[`tableCell`,`tableHeader`].includes(e.type.name)&&(n+=1)}),n===t.ranges.length&&(e.commands.deleteTable(),!0)};function DS(e,t){let n=e.mapping.map(t);if(pu(e.selection.$from,e=>e.type.name===`table`)?.pos===n)return;let r=e.doc.nodeAt(n);if(!r)return;let i=n+r.nodeSize-1;e.setSelection(j.near(e.doc.resolve(i),-1))}function OS(e){let t=``,n=0;for(;n<e.length;){if(e[n]===`\\`&&n+1<e.length){t+=e[n]+e[n+1],n+=2;continue}if(e[n]!=="`"){t+=e[n++];continue}let r=0;for(;n+r<e.length&&e[n+r]==="`";)r+=1;let i=n+r,a=!1;for(;i<e.length;){if(e[i]!=="`"){i+=1;continue}let o=0;for(;i+o<e.length&&e[i+o]==="`";)o+=1;if(o===r){let o=e.slice(n+r,i);t+=e.slice(n,n+r)+o.replace(/\\\||\|/g,e=>e===`|`?`\\|`:e)+e.slice(i,i+r),n=i+r,a=!0;break}i+=o}a||(t+=e.slice(n,n+r),n+=r)}return t}function kS(e){return e.split(`
|
|
197
|
+
`).map(e=>!e.includes(`|`)||!e.includes("`")?e:OS(e)).join(`
|
|
198
|
+
`)}function AS(e){return(e||``).replace(/\s+/g,` `).trim()}function jS(e,t,n={}){let r=n.cellLineSeparator??``;if(!e||!e.content||e.content.length===0)return``;let i=[];e.content.forEach(e=>{let n=[];e.content&&e.content.forEach(e=>{let i=``;i=e.content&&Array.isArray(e.content)&&e.content.length>1?e.content.map(e=>t.renderChildren(e)).join(r):e.content?t.renderChildren(e.content):``;let a=AS(i.split(r).join(`
|
|
199
|
+
`).replace(/[ \t]*\r?\n[ \t]*/g,`<br>`)),o=e.type===`tableHeader`,s=cS(e.attrs);n.push({text:a,isHeader:o,align:s})}),i.push(n)});let a=i.reduce((e,t)=>Math.max(e,t.length),0);if(a===0)return``;let o=Array.from({length:a}).fill(0);i.forEach(e=>{for(let t=0;t<a;t+=1){let n=(e[t]?.text||``).length;n>o[t]&&(o[t]=n),o[t]<3&&(o[t]=3)}});let s=(e,t)=>e+` `.repeat(Math.max(0,t-e.length)),c=i[0],l=c.some(e=>e.isHeader),u=Array.from({length:a}).fill(null);i.forEach(e=>{for(let t=0;t<a;t+=1)!u[t]&&e[t]?.align&&(u[t]=e[t].align)});let d=`
|
|
200
|
+
`,f=Array.from({length:a}).map((e,t)=>l&&c[t]&&c[t].text||``);return d+=`| ${f.map((e,t)=>s(e,o[t])).join(` | `)} |\n`,d+=`| ${o.map((e,t)=>{let n=Math.max(3,e),r=u[t];return r===`left`?`:${`-`.repeat(n)}`:r===`right`?`${`-`.repeat(n)}:`:r===`center`?`:${`-`.repeat(n)}:`:`-`.repeat(n)}).join(` | `)} |\n`,(l?i.slice(1):i).forEach(e=>{d+=`| ${Array.from({length:a}).fill(0).map((t,n)=>s(e[n]&&e[n].text||``,o[n])).join(` | `)} |\n`}),d}var MS=U.create({name:`table`,addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:bS,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:`tableRow+`,tableRole:`table`,isolating:!0,group:`block`,parseHTML(){return[{tag:`table`}]},renderHTML({node:e,HTMLAttributes:t}){let{colgroup:n,tableWidth:r,tableMinWidth:i}=xS(e,this.options.cellMinWidth),a=t.style;function o(){return a||(r?`width: ${r}`:`min-width: ${i}`)}let s=[`table`,V(this.options.HTMLAttributes,t,{style:o()}),n,[`tbody`,0]];return this.options.renderWrapper?[`div`,{class:`tableWrapper`},s]:s},parseMarkdown:(e,t)=>{let n=[],r=Array.isArray(e.align)?e.align:[];if(e.header){let i=[];e.header.forEach((e,n)=>{let a=oS(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableHeader`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}return e.rows&&e.rows.forEach(e=>{let i=[];e.forEach((e,n)=>{let a=oS(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableCell`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}),t.createNode(`table`,void 0,n)},renderMarkdown:(e,t)=>jS(e,t),markdownTokenizer:{name:`table`,level:`block`,start:e=>{let t=e.split(`
|
|
201
201
|
`);if(t.length<2)return-1;let n=t[1];return!/^[ \t|:]*-[ \t|:-]*$/.test(n)||!n.includes(`|`)?-1:t[0].includes(`|`)?0:-1},tokenize(e,t,n){let r=e.indexOf(`
|
|
202
202
|
|
|
203
203
|
`),i=r>=0?e.slice(0,r):e,a=i.split(`
|
|
204
|
-
`);if(a.length<2)return;let o=a[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(o)||!o.includes(`|`))return;let s=
|
|
204
|
+
`);if(a.length<2)return;let o=a[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(o)||!o.includes(`|`))return;let s=kS(i);if(s===i)return;let c=n.blockTokens(s)[0];if(c?.type!==`table`||!c.raw)return;let l=c.raw.split(`
|
|
205
205
|
`).length,u=e.split(`
|
|
206
206
|
`).slice(0,l).join(`
|
|
207
|
-
`);return{...c,raw:u}}},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:a})=>{let o=
|
|
208
|
-
`).map(e=>
|
|
209
|
-
`)}
|
|
210
|
-
|
|
211
|
-
|
|
207
|
+
`);return{...c,raw:u}}},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:a})=>{let o=wS(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(j.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>ex(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>tx(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=pu(e.selection.$from,e=>e.type.name===`table`);return rx(e,t&&(e=>{n&&DS(e,n.pos),t(e)}))},addRowBefore:()=>({state:e,dispatch:t})=>ox(e,t),addRowAfter:()=>({state:e,dispatch:t})=>sx(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=pu(e.selection.$from,e=>e.type.name===`table`);return lx(e,t&&(e=>{n&&DS(e,n.pos),t(e)}))},deleteTable:()=>({state:e,dispatch:t})=>Sx(e,t),mergeCells:()=>({state:e,dispatch:t})=>fx(e,t),splitCell:()=>({state:e,dispatch:t})=>px(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>vx(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>vx(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>yx(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>fx(e,t)?!0:px(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>hx(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>xx(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>xx(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&Xb(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=Q.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:ES,"Mod-Backspace":ES,Delete:ES,"Mod-Delete":ES}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Gx({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],aS({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){let e=this.options.resizable&&this.editor.isEditable,t=this.options.View;return e||!t?null:({node:e,view:n,HTMLAttributes:r})=>{let i=V(this.options.HTMLAttributes,r);return new t(e,this.options.cellMinWidth,n,i)}},extendNodeSchema(e){return{tableRole:B(z(e,`tableRole`,{name:e.name,options:e.options,storage:e.storage}))}}});H.create({name:`tableKit`,addExtensions(){let e=[];return this.options.table!==!1&&e.push(MS.configure(this.options.table)),this.options.tableCell!==!1&&e.push(hS.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(gS.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(_S.configure(this.options.tableRow)),e}});var NS={gfm:!0,breaks:!1},PS=`<!--more-->`,FS=[`Read More ↓`,`Read More`],IS=/^(?:<!--more-->|Read More ↓|Read More)[ \t]*(?:\n|$)/;function LS(e){let t=Math.max(2,...Array.from(e.matchAll(/`+/g),e=>e[0].length));return"`".repeat(Math.max(3,t+1))}function RS(e){let t=e.querySelector(`img`),n=e.querySelector(`figcaption`),r=e.querySelector(`a`);return{src:t?.getAttribute(`src`)??``,alt:t?.getAttribute(`alt`)??``,title:t?.getAttribute(`title`)??``,caption:n?.textContent??``,href:r?.getAttribute(`href`)??``,layout:e.getAttribute(`data-layout`)??`regular`}}function zS(e,t){return e.match(RegExp(`${t}="([^"]*)"`,`i`))?.[1]??null}function BS(e){return e.replace(/"/g,`"`).replace(/'/g,`'`).replace(/</g,`<`).replace(/>/g,`>`).replace(/&/g,`&`)}function VS(e){let t=e.trim().match(/^<figure\b([^>]*)data-jant-node="image"([^>]*)>([\s\S]*?)<\/figure>$/i);if(!t)return null;let n=`${t[1]??``} ${t[2]??``}`,r=t[3]??``,i=zS(n,`data-jant-layout`)||zS(n,`data-layout`)||void 0,a=r.match(/<a\b[^>]*href="([^"]*)"[^>]*>/i)?.[1],o=r.match(/<img\b([^>]*)>/i);if(!o)return null;let s=o[1]??``,c=zS(s,`src`);if(!c)return null;let l=r.match(/<figcaption>([\s\S]*?)<\/figcaption>/i)?.[1],u=l?BS(l.trim()):void 0,d={src:BS(c)},f=zS(s,`alt`),p=zS(s,`title`);return f&&(d.alt=BS(f)),p&&(d.title=BS(p)),u&&(d.caption=u),a&&(d.href=BS(a)),i&&i!==`regular`&&(d.layout=BS(i)),d}var HS=U.create({name:`image`,group:`block`,atom:!0,selectable:!0,draggable:!0,addAttributes(){return{src:{default:``},alt:{default:``},title:{default:``},caption:{default:``},href:{default:``},layout:{default:`regular`}}},parseHTML(){return[{tag:`figure[data-image]`,getAttrs(e){return RS(e)}},{tag:`figure`,getAttrs(e){let t=e;return t.querySelector(`img`)?RS(t):!1}},{tag:`img[src]`,getAttrs(e){let t=e;return{src:t.getAttribute(`src`)??``,alt:t.getAttribute(`alt`)??``,title:t.getAttribute(`title`)??``}}}]},renderHTML({node:e}){let t={"data-image":``};e.attrs.layout&&e.attrs.layout!==`regular`&&(t[`data-layout`]=e.attrs.layout);let n={src:e.attrs.src};e.attrs.alt&&(n.alt=e.attrs.alt),e.attrs.title&&(n.title=e.attrs.title);let r=[`img`,n],i=[];return e.attrs.href?i.push([`a`,{href:e.attrs.href},r]):i.push(r),e.attrs.caption&&i.push([`figcaption`,{},e.attrs.caption]),[`figure`,t,...i]},parseMarkdown:(e,t)=>t.createNode(`image`,{src:e.href,title:e.title??``,alt:e.text??``}),renderMarkdown:e=>pe(e.attrs??{})}),US=Qm.extend({renderMarkdown(e,t){let n=e.attrs?.language?String(e.attrs.language):``,r=t.renderChildren(e.content??[]),i=LS(r);return`${i}${n}\n${r}\n${i}`}}),WS=ey.extend({clearable:!1}),GS=[[/^([ \t]{0,3})(\d{1,9})([.)])(?=[ \t]|$)/,`$1$2\\$3`],[/^([ \t]{0,3})([-+])(?=[ \t]|$)/,`$1\\$2`],[/^([ \t]{0,3})(#{1,6})(?=[ \t]|$)/,`$1\\$2`],[/^([ \t]{0,3})([-=])(?=[-= \t]*$)/,`$1\\$2`]];function KS(e){return e.split(`
|
|
208
|
+
`).map(e=>GS.reduce((e,[t,n])=>e.replace(t,n),e)).join(`
|
|
209
|
+
`)}var qS={bold:`strong`,italic:`em`,strike:`s`},JS=Object.keys(qS),YS=new Set([...JS,`code`,`link`]),XS=`markdownAsHtml`;function ZS(e){return e===void 0||/\s/u.test(e)?`space`:/[\p{P}\p{S}]/u.test(e)?`punctuation`:`other`}function QS(e,t){return e?.marks?.some(e=>e.type===t)??!1}function $S(e,t,n,r){let i=e[t],a=e[n===`start`?t-1:t+1],o=[...i?.text??``],s=n===`start`?o:o.slice().reverse(),c=s.find(e=>!/\s/u.test(e)),l=i?.marks?.some(e=>e.type!==r&&YS.has(e.type)&&!QS(a,e.type))??!1?`punctuation`:ZS(c),u;if(s[0]!==void 0&&/\s/u.test(s[0]))u=`space`;else if(!a||a.type===`hardBreak`)u=`space`;else if(a.type===`text`){let e=[...a.text??``];u=ZS(n===`start`?e.at(-1):e[0])}else u=`punctuation`;return l!==`space`&&(l!==`punctuation`||u!==`other`)}function eC(e){let t=e.map(e=>({...e}));for(let e of JS){let n=0;for(;n<t.length;){if(t[n]?.type!==`text`||!QS(t[n],e)){n+=1;continue}let r=n;for(;t[r+1]?.type===`text`&&QS(t[r+1],e);)r+=1;if(!$S(t,n,`start`,e)||!$S(t,r,`end`,e))for(let i=n;i<=r;i+=1){let n=t[i];n.marks=n.marks?.map(t=>t.type===e?{...t,attrs:{...t.attrs,[XS]:!0}}:t)}n=r+1}}return t}function tC(e){if(!e.content||e.type===`codeBlock`)return e;let t=e.content.map(tC),n=t.some(e=>e.type===`text`||e.type===`hardBreak`);return{...e,content:n?eC(t):t}}function nC(e,t,n,r){if(!e.attrs?.[XS])return`${r}${t}${r}`;let i=qS[n];return`<${i}>${t}</${i}>`}var rC=xg.extend({renderMarkdown(e,t){return nC(e,t.renderChildren(e),`bold`,`**`)}}),iC=Dg.extend({renderMarkdown(e,t){return nC(e,t.renderChildren(e),`italic`,`*`)}}),aC=jg.extend({renderMarkdown(e,t){return nC(e,t.renderChildren(e),`strike`,`~~`)}}),oC={strong:`strong`,b:`strong`,em:`em`,i:`em`,s:`del`,del:`del`},sC=/<(?:strong|b|em|i|s|del)>/i,cC=/^<(strong|b|em|i|s|del)>([\s\S]*?)<\/\1>/i,lC=H.create({name:`markdownHtmlEmphasis`,markdownTokenizer:{name:`htmlEmphasis`,level:`inline`,start(e){return e.search(sC)},tokenize(e,t,n){let r=cC.exec(e);if(!r)return;let[i,a=``,o=``]=r,s=oC[a.toLowerCase()];if(s)return{type:s,raw:i,text:o,tokens:n.inlineTokens(o)}}}}),uC=ig.extend({renderMarkdown(e,t,n){let r=n?.previousNode;return!r||r.type===`hardBreak`?`\\
|
|
210
|
+
`:`
|
|
211
|
+
`}}),dC=cg.config.renderMarkdown,fC=cg.extend({renderMarkdown(e,t,n){return KS(dC?.call(this,e,t,n)??``)}}),pC=Zh.extend({markdownTokenizer:{name:`orderedList`,level:`block`,start:()=>-1,tokenize:()=>void 0},parseMarkdown:(e,t)=>{if(e.type!==`list`||!e.ordered)return[];let n=typeof e.start==`number`?e.start:1;return{type:`orderedList`,...n===1?{}:{attrs:{start:n}},content:e.items?t.parseChildren(e.items):[]}},addProseMirrorPlugins(){return[]}}),mC=H.create({name:`markdownFigureImageSupport`,markdownTokenName:`imageFigure`,parseMarkdown:(e,t)=>t.createNode(`image`,e.attrs??{}),markdownTokenizer:{name:`imageFigure`,level:`block`,start(e){return e.indexOf(`<figure`)},tokenize(e){let t=e.match(/^<figure\b[^>]*data-jant-node="image"[\s\S]*?<\/figure>(?:\n|$)?/i);if(!t)return;let n=VS(t[0]);if(n)return{type:`imageFigure`,raw:t[0],attrs:n}}}});function hC(){return{name:`embed`,level:`block`,start(e){return e.indexOf("```jant-embed")},tokenize(e){let t=e.match(/^```jant-embed[ \t]*\n([\s\S]*?)\n?```(?:\n|$)/);if(!t)return;let n=(t[1]??``).split(`
|
|
212
|
+
`).map(e=>e.trim()).filter(Boolean),r=n[0]??``,i={};for(let e=1;e<n.length;e+=1){let t=n[e];if(!t)continue;let r=t.indexOf(`=`);if(r<=0)continue;let a=t.slice(0,r).trim(),o=t.slice(r+1).trim();a&&(i[a]=o)}return{type:`embed`,raw:t[0],url:r,attrs:i}}}}function gC(){return{name:`htmlBlock`,level:`block`,start(e){return e.indexOf("```jant-html")},tokenize(e){let t=e.match(/^```jant-html[ \t]*\n([\s\S]*?)\n?```(?:\n|$)/);if(t)return{type:`htmlBlock`,raw:t[0],html:t[1]??``}}}}function _C(){return{name:`moreBreak`,level:`block`,start(e){let t=e.indexOf(PS);for(let n of FS){let r=e.indexOf(n);r!==-1&&(t=t===-1?r:Math.min(t,r))}return t},tokenize(e){let t=e.match(IS);if(t)return{type:`moreBreak`,raw:t[0]}}}}var vC=U.create({name:`moreBreak`,group:`block`,atom:!0,selectable:!0,draggable:!1,parseHTML(){return[{tag:`div[data-more-break]`}]},renderHTML(){return[`div`,{"data-more-break":``,class:`tiptap-more-break`},`Read More ↓`]},parseMarkdown:(e,t)=>t.createNode(`moreBreak`),renderMarkdown:()=>PS,markdownTokenizer:_C()}),yC=U.create({name:`embed`,group:`block`,atom:!0,selectable:!0,draggable:!0,addAttributes(){return{url:{default:``},provider:{default:``},providerName:{default:``},src:{default:``},orientation:{default:`landscape`},heightPx:{default:null},sandbox:{default:``},allow:{default:``},caption:{default:``}}},parseHTML(){return[{tag:`figure[data-jant-node="embed"]`,getAttrs(e){let t=e,n=t.getAttribute(`data-provider`)??``;return{url:t.getAttribute(`data-url`)??t.querySelector(`a`)?.getAttribute(`href`)??``,provider:n,providerName:t.getAttribute(`data-provider-name`)??``,src:t.getAttribute(`data-src`)??``,orientation:t.getAttribute(`data-orientation`)??`landscape`}}}]},renderHTML({node:e}){let t={"data-jant-node":`embed`};return e.attrs.provider&&(t[`data-provider`]=String(e.attrs.provider)),e.attrs.providerName&&(t[`data-provider-name`]=String(e.attrs.providerName)),e.attrs.url&&(t[`data-url`]=String(e.attrs.url)),e.attrs.src&&(t[`data-src`]=String(e.attrs.src)),e.attrs.orientation&&(t[`data-orientation`]=String(e.attrs.orientation)),[`figure`,t]},parseMarkdown:(e,t)=>{let n=typeof e.url==`string`?e.url:``,r=e.attrs&&typeof e.attrs==`object`?e.attrs:{};return t.createNode(`embed`,{url:n,caption:r.caption??``})},renderMarkdown:e=>{let t=e.attrs??{},n=typeof t.url==`string`?t.url.trim():``;if(!n)return``;let r=[n],i=typeof t.caption==`string`?t.caption.trim():``;return i&&r.push(`caption=${i}`),["```jant-embed",...r,"```"].join(`
|
|
213
|
+
`)},markdownTokenizer:hC()}),bC=U.create({name:`htmlBlock`,group:`block`,atom:!0,selectable:!0,draggable:!0,addAttributes(){return{html:{default:``}}},parseHTML(){return[{tag:`div[data-jant-node="html-block"]`,getAttrs(e){return{html:e.textContent??``}}}]},renderHTML({node:e}){return[`div`,{"data-jant-node":`html-block`},String(e.attrs.html??``)]},parseMarkdown:(e,t)=>{let n=typeof e.html==`string`?e.html:``;return t.createNode(`htmlBlock`,{html:n})},renderMarkdown:e=>["```jant-html",typeof e.attrs?.html==`string`?e.attrs.html:``,"```"].join(`
|
|
214
|
+
`),markdownTokenizer:gC()});function xC(){return{name:`footnoteReference`,level:`inline`,start(e){return e.indexOf(`[^`)},tokenize(e){let t=e.match(/^\[\^([^\]\n]+)\]/),n=m(t?.[1]);if(t&&n)return{type:`footnoteReference`,raw:t[0],label:n}}}}var SC=`__jantInlineFootnoteContent`;function CC(e){if(!e.startsWith(`^[`))return null;let t=1,n=0;for(let r=2;r<e.length;r+=1){let i=e[r];if(i===`
|
|
215
|
+
`||i===`\r`)return null;if(i===`\\`&&n===0){r+=1;continue}if(i==="`"){let t=1;for(;e[r+t]==="`";)t+=1;n===0?n=t:n===t&&(n=0),r+=t-1;continue}if(n>0)continue;if(i===`[`){t+=1;continue}if(i!==`]`||(--t,t!==0))continue;let a=e.slice(2,r);return a.trim()?{content:a,raw:e.slice(0,r+1)}:null}return null}var wC=H.create({name:`inlineFootnote`,parseMarkdown:(e,t)=>t.createNode(`footnoteReference`,{[SC]:Array.isArray(e.tokens)?t.parseInline(e.tokens):[]}),markdownTokenizer:{name:`inlineFootnote`,level:`inline`,start(e){return e.indexOf(`^[`)},tokenize(e,t,n){let r=CC(e);if(r)return{type:`inlineFootnote`,raw:r.raw,tokens:n.inlineTokens(r.content)}}}});function TC(e){let t=m(e),n=t.match(/^\[\^([^\]]+)\]:?$/)?.[1];return m(n??t)}var EC=U.create({name:`footnoteReference`,group:`inline`,inline:!0,atom:!0,selectable:!0,draggable:!1,addAttributes(){return{label:{default:``}}},parseHTML(){return[{tag:`sup[data-footnote-reference]`,getAttrs(e){return{label:TC(e.getAttribute(`data-footnote-label`))}}}]},renderHTML({node:e}){let t=m(e.attrs.label);return[`sup`,{"data-footnote-reference":``,"data-footnote-label":t,class:`tiptap-footnote-reference`},g(t)]},parseMarkdown:(e,t)=>t.createNode(`footnoteReference`,{label:m(e.label)}),renderMarkdown:e=>g(e.attrs?.label),markdownTokenizer:xC()}),DC=U.create({name:`footnoteDefinition`,group:`block`,content:`block+`,defining:!0,isolating:!0,selectable:!1,draggable:!1,addAttributes(){return{label:{default:``}}},parseHTML(){return[{tag:`div[data-footnote-definition]`,getAttrs(e){return{label:TC(e.getAttribute(`data-footnote-label`))}}}]},renderHTML({node:e}){return[`div`,{"data-footnote-definition":``,"data-footnote-label":m(e.attrs.label),class:`tiptap-footnote-definition`},0]},parseMarkdown:(e,t)=>{let n=Array.isArray(e.tokens)&&typeof t.parseBlockChildren==`function`?t.parseBlockChildren(e.tokens):[];return t.createNode(`footnoteDefinition`,{label:m(e.label)},n.length>0?n:[t.createNode(`paragraph`)])},renderMarkdown:(e,t)=>{let n=m(e.attrs?.label),r=Array.isArray(e.content)?e.content:[],i=_(n);if(r.length===0)return i;let a=r.map((e,n)=>typeof t.renderChild==`function`?t.renderChild(e,n):``);return r.length===1&&r[0]?.type===`paragraph`&&!a[0]?.includes(`
|
|
212
216
|
`)?a[0]?`${i} ${a[0]}`:i:`${i}\n${a.map(e=>v(e)).join(`
|
|
213
217
|
|
|
214
|
-
`)}`},markdownTokenizer:{name:`footnoteDefinition`,level:`block`,start(e){return e.indexOf(`[^`)},tokenize(e,t,n){let r=x(e);if(r)return{type:`footnoteDefinition`,raw:r.raw,label:r.label,tokens:r.contentMarkdown?n.blockTokens(r.contentMarkdown):[]}}}});function eC(t={}){return[_b.configure({heading:{levels:[1,2,3]},link:!1,codeBlock:!1,trailingNode:{notAfter:[`footnoteDefinition`]}}),zS.configure({openOnClick:!1,autolink:!1,isAllowedUri:t=>e(t)!==``}),RS,DS.configure({resizable:!1,HTMLAttributes:{class:`tiptap-table`}}),fS,uS,dS,BS,t.imageExtension??LS,t.moreBreakExtension??WS,t.embedExtension??GS,t.htmlBlockExtension??KS,XS,QS,$S]}function tC(e){return typeof e==`object`&&!!e&&typeof e.type==`string`}function nC(e,t){if(e.type===`footnoteReference`||e.type===`footnoteDefinition`){let n=m(e.attrs?.label);n&&t.add(h(n))}for(let n of e.content??[])nC(n,t)}function rC(e){if(e.type!==`doc`)return e;let t=new Set;nC(e,t);let n=[],r=1,i=()=>{for(;t.has(h(String(r)));)r+=1;let e=String(r);return t.add(h(e)),r+=1,e},a=e=>{let t=e.attrs?.[JS];if(e.type===`footnoteReference`&&Array.isArray(t)){let r=i(),o={...e.attrs??{},label:r};delete o[JS];let s=t.filter(tC).map(e=>a(iC(e)));return n.push({type:`footnoteDefinition`,attrs:{label:r},content:[s.length>0?{type:`paragraph`,content:s}:{type:`paragraph`}]}),{...e,attrs:o}}return e.content?{...e,content:e.content.map(a)}:e},o=a(e);return n.length===0?o:{...o,content:[...o.content??[],...n]}}function iC(e){let t={...e};if(t.content&&=t.content.map(iC),t.marks&&=t.marks.map(e=>{if(!e||typeof e!=`object`)return e;let t={...e,attrs:e.type===`link`?{...e.attrs??{},target:typeof e.attrs?.target==`string`?e.attrs.target:`_blank`}:e.attrs};return t.attrs&&Object.keys(t.attrs).length===0&&delete t.attrs,t}),t.attrs&&typeof t.attrs==`object`){let e={...t.attrs};t.type===`codeBlock`&&e.language==null&&delete e.language,Object.keys(e).length>0?t.attrs=e:delete t.attrs}if(t.type===`doc`&&(!t.content||t.content.length===0)&&(t.content=[{type:`paragraph`}]),t.type===`paragraph`&&t.content){let e=[];for(let n=0;n<t.content.length;n+=1){let r=t.content[n],i=t.content[n+1];if(r?.type===`text`&&typeof r.text==`string`&&i?.type===`footnoteReference`&&/\n[ \t]*$/.test(r.text)){let t=r.text.replace(/\n[ \t]*$/,``);t&&e.push({...r,text:t});continue}r&&e.push(r)}t.content=e}return t.type===`doc`?rC(t):t}function aC(e){return e}function oC(e=eC()){return new Km({extensions:e,markedOptions:OS})}var sC=null;function cC(){return sC??=oC(),sC}function lC(e){return iC(cC().parse(e))}function uC(e){return aC(cC().serialize(b(e)))}var dC=lb,fC=Math.min,pC=Math.max,mC=Math.round,hC=Math.floor,gC=e=>({x:e,y:e}),_C={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function vC(e,t){return typeof e==`function`?e(t):e}function yC(e){return e.split(`-`)[0]}function bC(e){return e.split(`-`)[1]}function xC(e){return e===`x`?`y`:`x`}function SC(e){return e===`y`?`height`:`width`}function CC(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function wC(e){return xC(CC(e))}function TC(e,t,n){n===void 0&&(n=!1);let r=bC(e),i=wC(e),a=SC(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=PC(o)),[o,PC(o)]}function EC(e){let t=PC(e);return[DC(e),t,DC(t)]}function DC(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var OC=[`left`,`right`],kC=[`right`,`left`],AC=[`top`,`bottom`],jC=[`bottom`,`top`];function MC(e,t,n){switch(e){case`top`:case`bottom`:return n?t?kC:OC:t?OC:kC;case`left`:case`right`:return t?AC:jC;default:return[]}}function NC(e,t,n,r){let i=bC(e),a=MC(yC(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(DC)))),a}function PC(e){let t=yC(e);return _C[t]+e.slice(t.length)}function FC(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function IC(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:FC(e)}function LC(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function RC(e,t,n){let{reference:r,floating:i}=e,a=CC(t),o=wC(t),s=SC(o),c=yC(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=bC(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function zC(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=vC(t,e),p=IC(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=LC(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=LC(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var BC=50,VC=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:zC},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=RC(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<BC&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=RC(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},HC=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=vC(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=yC(r),_=CC(o),v=yC(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[PC(o)]:EC(o)),x=p!==`none`;!d&&x&&b.push(...NC(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=TC(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===CC(t)||T.every(e=>CC(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=CC(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},UC=new Set([`left`,`top`]);async function WC(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=yC(n),s=bC(n),c=CC(n)===`y`,l=UC.has(o)?-1:1,u=a&&c?-1:1,d=vC(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var GC=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await WC(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}};function KC(){return typeof window<`u`}function qC(e){return XC(e)?(e.nodeName||``).toLowerCase():`#document`}function JC(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function YC(e){return((XC(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function XC(e){return KC()?e instanceof Node||e instanceof JC(e).Node:!1}function ZC(e){return KC()?e instanceof Element||e instanceof JC(e).Element:!1}function QC(e){return KC()?e instanceof HTMLElement||e instanceof JC(e).HTMLElement:!1}function $C(e){return!KC()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof JC(e).ShadowRoot}function ew(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=dw(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function tw(e){return/^(table|td|th)$/.test(qC(e))}function nw(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var rw=/transform|translate|scale|rotate|perspective|filter/,iw=/paint|layout|strict|content/,aw=e=>!!e&&e!==`none`,ow;function sw(e){let t=ZC(e)?dw(e):e;return aw(t.transform)||aw(t.translate)||aw(t.scale)||aw(t.rotate)||aw(t.perspective)||!lw()&&(aw(t.backdropFilter)||aw(t.filter))||rw.test(t.willChange||``)||iw.test(t.contain||``)}function cw(e){let t=pw(e);for(;QC(t)&&!uw(t);){if(sw(t))return t;if(nw(t))return null;t=pw(t)}return null}function lw(){return ow??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),ow}function uw(e){return/^(html|body|#document)$/.test(qC(e))}function dw(e){return JC(e).getComputedStyle(e)}function fw(e){return ZC(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function pw(e){if(qC(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||$C(e)&&e.host||YC(e);return $C(t)?t.host:t}function mw(e){let t=pw(e);return uw(t)?(e.ownerDocument||e).body:QC(t)&&ew(t)?t:mw(t)}function hw(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=mw(e),i=r===e.ownerDocument?.body,a=JC(r);if(i){let e=gw(a);return t.concat(a,a.visualViewport||[],ew(r)?r:[],e&&n?hw(e):[])}return t.concat(r,hw(r,[],n))}function gw(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function _w(e){let t=dw(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=QC(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=mC(n)!==a||mC(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function vw(e){return ZC(e)?e:e.contextElement}function yw(e){let t=vw(e);if(!QC(t))return gC(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=_w(t),o=(a?mC(n.width):n.width)/r,s=(a?mC(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var bw=gC(0);function xw(e){let t=JC(e);return!lw()||!t.visualViewport?bw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Sw(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===JC(e)}function Cw(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=vw(e),o=gC(1);t&&(r?ZC(r)&&(o=yw(r)):o=yw(e));let s=Sw(a,n,r)?xw(a):gC(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=JC(a),t=ZC(r)?JC(r):r,n=e,i=gw(n);for(;i&&t!==n;){let e=yw(i),t=i.getBoundingClientRect(),r=dw(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=JC(i),i=gw(n)}}return LC({width:u,height:d,x:c,y:l})}function ww(e,t){let n=fw(e).scrollLeft;return t?t.left+n:Cw(YC(e)).left+n}function Tw(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-ww(e,n),y:n.top+t.scrollTop}}function Ew(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=YC(r),s=t?nw(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=gC(1),u=gC(0),d=QC(r);if((d||!a)&&((qC(r)!==`body`||ew(o))&&(c=fw(r)),d)){let e=Cw(r);l=yw(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Tw(o,c):gC(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Dw(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Ow(e){let t=fw(e),n=e.ownerDocument.body,r=pC(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=pC(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+ww(e),o=-t.scrollTop;return dw(n).direction===`rtl`&&(a+=pC(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var kw=25;function Aw(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=JC(e),a=YC(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!lw()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(ww(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=kw&&(s-=o)}return{width:s,height:c,x:l,y:u}}function jw(e,t){let n=Cw(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=yw(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Mw(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Aw(e,n,t);else if(t===`document`)r=Ow(YC(e));else if(ZC(t))r=jw(t,n);else{let n=xw(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return LC(r)}function Nw(e,t){let n=t.get(e);if(n)return n;let r=hw(e,[],!1).filter(e=>ZC(e)&&qC(e)!==`body`),i=null,a=dw(e).position===`fixed`,o=a?pw(e):e;for(;ZC(o)&&!uw(o);){let e=dw(o),t=sw(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=pw(o)}return t.set(e,r),r}function Pw(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?nw(t)?[]:Nw(t,this._c):[].concat(n),r],o=Mw(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Mw(t,a[e],i);s=pC(n.top,s),c=fC(n.right,c),l=fC(n.bottom,l),u=pC(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Fw(e){let{width:t,height:n}=_w(e);return{width:t,height:n}}function Iw(e,t,n){let r=QC(t),i=YC(t),a=n===`fixed`,o=Cw(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=gC(0);if((r||!a)&&((qC(t)!==`body`||ew(i))&&(s=fw(t)),r)){let e=Cw(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=ww(i));let l=i&&!r&&!a?Tw(i,s):gC(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function Lw(e){return dw(e).position===`static`}function Rw(e,t){if(!QC(e)||dw(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return YC(e)===n&&(n=n.ownerDocument.body),n}function zw(e,t){let n=JC(e);if(nw(e))return n;if(!QC(e)){let t=pw(e);for(;t&&!uw(t);){if(ZC(t)&&!Lw(t))return t;t=pw(t)}return n}let r=Rw(e,t);for(;r&&tw(r)&&Lw(r);)r=Rw(r,t);return r&&uw(r)&&Lw(r)&&!sw(r)?n:r||cw(e)||n}var Bw=async function(e){let t=this.getOffsetParent||zw,n=this.getDimensions,r=await n(e.floating);return{reference:Iw(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Vw(e){return dw(e).direction===`rtl`}var Hw={convertOffsetParentRelativeRectToViewportRelativeRect:Ew,getDocumentElement:YC,getClippingRect:Pw,getOffsetParent:zw,getElementRects:Bw,getClientRects:Dw,getDimensions:Fw,getScale:yw,isElement:ZC,isRTL:Vw};function Uw(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ww(e,t,n){let r=null,i,a=YC(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=hC(d),h=hC(a.clientWidth-(u+f)),g=hC(a.clientHeight-(d+p)),_=hC(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:pC(0,fC(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Uw(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=JC(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Gw(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=vw(e),u=i||a?[...l?hw(l):[],...t?hw(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Ww(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Cw(e):null;c&&g();function g(){let t=Cw(e);h&&!Uw(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Kw=GC,qw=HC,Jw=(e,t,n)=>{let r=new Map,i=n??{},a={...Hw,...i.platform,_c:r};return VC(e,t,{...i,platform:a})};function Yw(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=lf(t),l=RegExp(`\\s${c}$`),u=a?`^`:``,d=r?``:c,f=RegExp(s?`${u}${c}.*?(?=\\s${d}|$)`:`${u}(?:^)?${c}[^\\s${d}]*`,`gm`),p=o.nodeBefore?.isText&&o.nodeBefore.text;if(!p)return null;let m=o.pos-p.length,h=Array.from(p.matchAll(f)).pop();if(!h||h.input===void 0||h.index===void 0)return null;let g=h.input.slice(Math.max(0,h.index-1),h.index),_=RegExp(`^[${i?.join(``)}\0]?$`).test(g);if(i!==null&&!_)return null;let v=m+h.index,y=v+h[0].length;return s&&l.test(p.slice(y-1,y+1))&&(h[0]+=` `,y+=1),v<o.pos&&y>=o.pos?{range:{from:v,to:y},query:h[0].slice(t.length),text:h[0]}:null}function Xw(e){return e.docChanged?e.steps.some(e=>{let t=e.slice;if(!t?.content)return!1;let n=t.content.textBetween(0,t.content.size,`
|
|
215
|
-
`);return/\s/.test(n)}):!1}function Zw(e){return()=>{let t=e.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=e.view.coordsAtPos(t);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}}}function Qw(e,t,n,r){return n?()=>{let n=r.getState(e.state)?.decorationId;return t.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:Zw(e)}function $w({match:e,dismissedRange:t,state:n,transaction:r,editor:i,shouldResetDismissed:a,effectiveAllowSpaces:o}){return a?.({editor:i,state:n,range:t,match:e,transaction:r,allowSpaces:o})?!1:o?e.range.from===t.from:e.range.from===t.from&&!Xw(r)}function eT({view:e,pluginKeyRef:t}){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function tT({pluginKey:e,decorationTag:t,decorationClass:n,decorationContent:r,decorationEmptyClass:i,renderer:a,dispatchExit:o}){return{handleKeyDown(t,n){var r;let i=e.getState(t.state);if(!i.active)return!1;if(n.key===`Escape`||n.key===`Esc`){var s;return a==null||(s=a.onKeyDown)==null||s.call(a,{view:t,event:n,range:i.range}),o(t),!0}return(a==null||(r=a.onKeyDown)==null?void 0:r.call(a,{view:t,event:n,range:i.range}))||!1},decorations(a){let{active:o,range:s,decorationId:c,query:l}=e.getState(a);if(!o)return null;let u=!l?.length,d=[n];return u&&d.push(i),L.create(a.doc,[Ws.inline(s.from,s.to,{nodeName:t,class:d.join(` `),"data-decoration-id":c||void 0,"data-decoration-content":r})])}}}function nT({editor:e,char:t,effectiveAllowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,findSuggestionMatch:o,allow:s,shouldShow:c,shouldKeepDismissed:l,pluginKey:u}){return{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(d,f,p,m){let{isEditable:h}=e,{composing:g}=e.view,{selection:_}=d,{empty:v,from:y}=_,b={...f},x=d.getMeta(u);if(x&&x.exit)return b.active=!1,b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null,b.dismissedRange=f.active?{...f.range}:f.dismissedRange,b;if(b.composing=g,d.docChanged&&b.dismissedRange!==null&&(b.dismissedRange={from:d.mapping.map(b.dismissedRange.from),to:d.mapping.map(b.dismissedRange.to)}),h&&(v||e.view.composing)){(y<f.range.from||y>f.range.to)&&!g&&!f.composing&&(b.active=!1);let u=o({char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:_.$from}),p=`id_${Math.floor(Math.random()*4294967295)}`;u&&s({editor:e,state:m,range:u.range,isActive:f.active})&&(!c||c({editor:e,range:u.range,query:u.query,text:u.text,transaction:d}))?(b.dismissedRange!==null&&!l({match:u,dismissedRange:b.dismissedRange,state:m,transaction:d})&&(b.dismissedRange=null),b.dismissedRange===null?(b.active=!0,b.decorationId=f.decorationId||p,b.range=u.range,b.query=u.query,b.text=u.text):b.active=!1):(u||(b.dismissedRange=null),b.active=!1)}else b.active=!1;return b.active||(b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null),b}}}function rT({editor:e,items:t}){let n=null,r=null,i=null,a=()=>{r!==null&&(clearTimeout(r),r=null),i?.(),i=null},o=e=>new Promise(t=>{i=t,r=setTimeout(()=>{r=null;let e=i;i=null,e?.()},e)}),s=()=>{n?.abort(),a(),n=null};return{abort:s,fetch:async(r,i)=>{s(),n=new AbortController;let a=n;if(i>0&&await o(i),n!==a||a.signal.aborted)return{status:`aborted`};try{let i=await t({editor:e,query:r,signal:a.signal});return n!==a||a.signal.aborted?{status:`aborted`}:{status:`resolved`,items:i}}catch{return n!==a||a.signal.aborted?{status:`aborted`}:{status:`error`}}}}}function iT({placement:e,offset:t,flip:n,floatingUi:r}){var i;let a=[Kw({mainAxis:t.mainAxis??4,crossAxis:t.crossAxis??0})];return n&&a.push(qw()),r!=null&&(i=r.middleware)!=null&&i.length&&a.push(...r.middleware),{placement:e,strategy:r?.strategy??`absolute`,middleware:a}}function aT(e){if(e instanceof HTMLElement)return e;if(typeof e==`string`)try{let t=document.querySelector(e);if(t)return t}catch{return document.body}return document.body}function oT({getReferenceRect:e,contextElement:t,config:n,container:r,dismissOnOutsideClick:i,dismiss:a}){return(o,s={})=>{let c={getBoundingClientRect:()=>e()??new DOMRect,contextElement:t},l=!1,u=!o.isConnected;u&&aT(r).appendChild(o),s.onPosition||(o.style.visibility=`hidden`,o.style.width=`max-content`);let d=Gw(c,o,()=>{Jw(c,o,{placement:n.placement,strategy:n.strategy,middleware:n.middleware}).then(({x:e,y:t,placement:n,strategy:r})=>{if(s.onPosition){s.onPosition({x:e,y:t,placement:n,strategy:r});return}Object.assign(o.style,{position:r,left:`${e}px`,top:`${t}px`}),l||(l=!0,o.style.visibility=``)})},s.autoUpdate),f;return i&&(f=e=>{let n=e.target;!(n instanceof Node)||o.contains(n)||t.contains(n)||a()},document.addEventListener(`pointerdown`,f,!0)),()=>{d(),f&&document.removeEventListener(`pointerdown`,f,!0),u&&o.remove()}}}function sT({editor:e,pluginKey:t,items:n,renderer:r,minQueryLength:i,debounce:a,initialItems:o,placement:s,offset:c,container:l,flip:u,floatingUi:d,dismissOnOutsideClick:f,command:p,clientRectFor:m,dispatchExit:h}){let g,_=rT({editor:e,items:n}),v=iT({placement:s,offset:c,flip:u,floatingUi:d});function y(e,t){switch(e){case`started`:var n;r==null||(n=r.onStart)==null||n.call(r,t);break;case`updated`:var i;r==null||(i=r.onUpdate)==null||i.call(r,t);break;case`stopped`:var a;r==null||(a=r.onExit)==null||a.call(r,t)}}return{update:async(n,d)=>{let b=t.getState(d),x=t.getState(n.state);if(!b||!x)return;let S=null,C=b.query!==x.query,w=b.text!==x.text,T=b.range.from!==x.range.from||b.range.to!==x.range.to,ee=C||w||T;if(!b.active&&x.active)S=`started`;else if(b.active&&!x.active)S=`stopped`;else if(x.active&&ee)S=`updated`;else return;let te=S===`stopped`?b:x,ne=n.dom.querySelector(`[data-decoration-id="${te.decorationId}"]`),re=m(n,ne),ie=i===0||(te.query?te.query.length>=i:!1),ae=(S===`started`||S===`updated`)&&ie;if(g={editor:e,range:te.range,query:te.query||``,text:te.text||``,items:o??[],command:t=>p({editor:e,range:te.range,props:t}),decorationNode:ne,clientRect:re,loading:ae,placement:s,offset:{mainAxis:c.mainAxis??4,crossAxis:c.crossAxis??0},container:l,flip:u,floatingUi:v,mount:oT({getReferenceRect:re,contextElement:n.dom,config:v,container:l,dismissOnOutsideClick:f,dismiss:()=>h(e.view)})},S===`started`){var oe;r==null||(oe=r.onBeforeStart)==null||oe.call(r,g)}if(S===`updated`){var se;r==null||(se=r.onBeforeUpdate)==null||se.call(r,g)}if(S===`started`&&y(S,g),S===`started`||S===`updated`){if(!ae)_.abort(),g={...g,items:o??[],loading:!1};else{g={...g,items:o??[],loading:!0},S=`updated`,y(S,g);let e=await _.fetch(te.query||``,a);if(e.status===`aborted`)return;if(!t.getState(n.state)?.active){_.abort();return}g=e.status===`resolved`?{...g,items:e.items,loading:!1}:{...g,loading:!1}}}if(S===`stopped`){_.abort(),y(S,g),g=void 0;return}S===`updated`&&y(S,g)},destroy:()=>{var e;_.abort(),g&&(r==null||(e=r.onExit)==null||e.call(r,g))}}}var cT=new P(`suggestion`);function lT({pluginKey:e=cT,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],minQueryLength:p=0,debounce:m=0,initialItems:h,placement:g=`bottom-start`,offset:_={},container:v,flip:y=!0,floatingUi:b,dismissOnOutsideClick:x=!0,render:S=()=>({}),allow:C=()=>!0,findSuggestionMatch:w=Yw,shouldShow:T,shouldResetDismissed:ee}){let te=S?.(),ne=r&&!i,re=(n,r)=>Qw(t,n,r,e);function ie(e){return $w({...e,editor:t,shouldResetDismissed:ee,effectiveAllowSpaces:ne})}let ae=t=>eT({view:t,pluginKeyRef:e});return new N({key:e,view:()=>sT({editor:t,pluginKey:e,items:f,renderer:te,minQueryLength:p,debounce:m,initialItems:h,placement:g,offset:_,container:v,flip:y,floatingUi:b,dismissOnOutsideClick:x,command:d,clientRectFor:re,dispatchExit:ae}),state:nT({editor:t,char:n,effectiveAllowSpaces:ne,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,findSuggestionMatch:w,allow:C,shouldShow:T,shouldKeepDismissed:ie,pluginKey:e}),props:tT({pluginKey:e,decorationTag:s,decorationClass:c,decorationContent:l,decorationEmptyClass:u,renderer:te,dispatchExit:ae})})}var uT=lT;function dT(e,t,n){return n<t?t:Math.min(Math.max(e,t),n)}function fT(e,t,n,r,i){let a=n.top,o=n.top+n.height;return Math.max(e===`top`?t.top-a-r-i:o-t.bottom-r-i,0)}function pT(e){if(!e||e===document.body)return{left:0,top:0,width:window.innerWidth,height:window.innerHeight};let t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}function mT(e){let t=e.gap??8,n=e.padding??8,r=e.fallbackPlacement??(e.preferredPlacement===`top`?`bottom`:`top`),i=fT(e.preferredPlacement,e.anchorRect,e.containerRect,t,n),a=fT(r,e.anchorRect,e.containerRect,t,n),o=e.floatingHeight<=i||i>=a?e.preferredPlacement:r,s=o===e.preferredPlacement?i:a,c=s>0&&e.floatingHeight>s?s:null,l=c??e.floatingHeight,u=e.align===`center`?(e.anchorRect.left+e.anchorRect.right)/2-e.floatingWidth/2:e.anchorRect.left,d=n,f=e.containerRect.width-e.floatingWidth-n;return{left:dT(u-e.containerRect.left,d,f),top:dT(o===`top`?e.anchorRect.top-e.containerRect.top-l-t:e.anchorRect.bottom-e.containerRect.top+t,n,e.containerRect.height-l-n),placement:o,maxHeight:c}}var hT=new Set([`auto`,`scroll`,`hidden`,`clip`,`overlay`]);function gT(e,t){let n=Math.max(e.left,t.left),r=Math.max(e.top,t.top),i=Math.min(e.left+e.width,t.left+t.width),a=Math.min(e.top+e.height,t.top+t.height);return{left:n,top:r,width:i-n,height:a-r}}function _T(e,t){let n=t,r=e.parentElement;for(;r&&r!==document.body;){let e=getComputedStyle(r);if(hT.has(e.overflowY)||hT.has(e.overflowX)){let e=r.getBoundingClientRect(),t=gT(n,{left:e.left,top:e.top,width:e.width,height:e.height});t.width>0&&t.height>0&&(n=t)}r=r.parentElement}return n}function vT(e,t){let n=t.left+t.width,r=t.top+t.height,i=1/0,a=-1/0,o=1/0,s=1/0,c=!1;for(let l of e){let e=Math.max(l.top,t.top),u=Math.min(l.bottom,r);if(u<=e)continue;let d=Math.max(l.left,t.left),f=Math.min(l.right,n);f<d||(i=Math.min(i,d),a=Math.max(a,f),o=Math.min(o,e),s=Math.min(s,u),c=!0)}return c?{left:i,right:a,top:o,bottom:s}:null}function yT(e,t,n){if(typeof document>`u`||!document.createRange)return[];try{let r=e.domAtPos(t),i=e.domAtPos(n),a=document.createRange();a.setStart(r.node,r.offset),a.setEnd(i.node,i.offset);let o=a.getClientRects?.();return o?Array.from(o):[]}catch{return[]}}function bT(e,t,n,r){let i=vT(yT(e,t,n),r);if(i)return i;let a=e.coordsAtPos(t),o=e.coordsAtPos(n),s={left:Math.min(a.left,o.left),right:Math.max(a.right,o.right),top:a.top,bottom:a.bottom};return vT([s],r)??s}function xT(e){let t=e.inset??10,n=(e.anchorRect.left+e.anchorRect.right)/2-e.containerRect.left,r=Math.min(t,e.floatingWidth/2),i=Math.max(e.floatingWidth-t,r);return dT(n-e.floatingLeft,r,i)}var ST={toolbarLabel:`Table controls`,addRowAbove:`Add row above`,addRowBelow:`Add row below`,addColumnBefore:`Add column before`,addColumnAfter:`Add column after`,options:`Table options`,deleteRow:`Delete row`,deleteColumn:`Delete column`,toggleHeaderRow:`Toggle header row`,deleteTable:`Delete table`,sizePickerLabel:`Choose table size`,insertTableSize:`Insert %rows% by %cols% table`},CT=new P(`tableControls`),wT=`jant:table-options-open`,TT=`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="4" y="3" width="16" height="11" rx="2"/><path d="M4 8.5h16M12 3v11M12 18v4M10 20h4"/></svg>`,ET=`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="4" width="11" height="16" rx="2"/><path d="M8.5 4v16M3 12h11M18 12h4M20 10v4"/></svg>`,DT=`<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><circle cx="5" cy="12" r="1.7"/><circle cx="12" cy="12" r="1.7"/><circle cx="19" cy="12" r="1.7"/></svg>`;function OT(e){for(let t=e.depth;t>0;--t){let n=e.node(t);if(n.type.name===`table`)return{node:n,pos:e.before(t)}}return null}function kT(e){return OT(e.state.selection.$from)}function AT(e){let{node:t}=e.domAtPos(e.state.selection.from),n=(t instanceof HTMLElement?t:t.parentElement)?.closest(`table`);return n instanceof globalThis.HTMLTableElement&&e.dom.contains(n)?n:null}function jT(e){let t=kT(e);if(!t)return{rows:0,columns:0};let n=Z.get(t.node);return{rows:n.height,columns:n.width}}function MT(e){return e.commands.command(({state:e,tr:t,dispatch:n})=>{let r=OT(e.selection.$from),i=r?.node.firstChild,a=e.schema.nodes.tableHeader,o=e.schema.nodes.tableCell;if(!r||!i||!a||!o)return!1;let s=i.firstChild?.type!==a,c=r.pos+2;return i.forEach(e=>{t.setNodeMarkup(c,s?a:o,e.attrs),c+=e.nodeSize}),n?.(t),!0})}function NT(e){let t=e.extensionManager.extensions.find(e=>e.name===`tableControls`);return t?t.options.labels:null}var PT=H.create({name:`tableControls`,addOptions(){return{labels:ST}},addProseMirrorPlugins(){let e=this.editor,t=this.options.labels,n=null,r=null,i=null,a=null,o=!1,s=new Map,c=[{key:`addRowAbove`,label:t.addRowAbove},{key:`addRowBelow`,label:t.addRowBelow},{key:`addColumnBefore`,label:t.addColumnBefore},{key:`addColumnAfter`,label:t.addColumnAfter},{key:`deleteRow`,label:t.deleteRow,separatorBefore:!0},{key:`deleteColumn`,label:t.deleteColumn},{key:`toggleHeaderRow`,label:t.toggleHeaderRow},{key:`deleteTable`,label:t.deleteTable,destructive:!0,separatorBefore:!0}];function l(t){if(!kT(e))return!1;let n=jT(e);switch(t){case`addRowAbove`:return e.can().addRowBefore();case`addRowBelow`:return e.can().addRowAfter();case`addColumnBefore`:return e.can().addColumnBefore();case`addColumnAfter`:return e.can().addColumnAfter();case`deleteRow`:return n.rows>1&&e.can().deleteRow();case`deleteColumn`:return n.columns>1&&e.can().deleteColumn();case`toggleHeaderRow`:return!0;case`deleteTable`:return e.can().deleteTable()}}function u(t){if(!l(t))return;let r=!!(document.activeElement&&n?.contains(document.activeElement));switch(t){case`addRowAbove`:e.commands.addRowBefore();break;case`addRowBelow`:e.commands.addRowAfter();break;case`addColumnBefore`:e.commands.addColumnBefore();break;case`addColumnAfter`:e.commands.addColumnAfter();break;case`deleteRow`:e.commands.deleteRow();break;case`deleteColumn`:e.commands.deleteColumn();break;case`toggleHeaderRow`:MT(e);break;case`deleteTable`:e.commands.deleteTable()}h(),b(a??e.view),r&&!kT(e)&&e.view.focus()}function d(e,t){let n=s.get(e)??[];n.push(t),s.set(e,n)}function f(e,t,n,r=`tiptap-table-menu-item`){let i=document.createElement(`button`);return i.type=`button`,i.className=r,i.title=t,i.setAttribute(`aria-label`,t),n?i.innerHTML=n:(i.textContent=t,i.setAttribute(`role`,`menuitem`)),i.addEventListener(`mousedown`,e=>{e.preventDefault()}),i.addEventListener(`click`,()=>u(e)),d(e,i),i}function p(){n=document.createElement(`div`),n.className=`tiptap-table-controls`,n.dataset.editorFloatingUi=`true`,n.style.position=`fixed`,n.style.display=`none`,n.setAttribute(`role`,`toolbar`),n.setAttribute(`aria-label`,t.toolbarLabel),n.appendChild(f(`addRowBelow`,t.addRowBelow,TT,`tiptap-table-control-btn`)),n.appendChild(f(`addColumnAfter`,t.addColumnAfter,ET,`tiptap-table-control-btn`)),i=document.createElement(`button`),i.type=`button`,i.className=`tiptap-table-control-btn`,i.innerHTML=DT,i.title=t.options,i.setAttribute(`aria-label`,t.options),i.setAttribute(`aria-haspopup`,`menu`),i.setAttribute(`aria-expanded`,`false`),i.addEventListener(`mousedown`,e=>{e.preventDefault()}),i.addEventListener(`click`,e=>{if(o){h();return}m(e.detail===0)}),n.appendChild(i),r=document.createElement(`div`),r.className=`tiptap-table-options`,r.dataset.editorFloatingUi=`true`,r.setAttribute(`role`,`menu`),r.hidden=!0;for(let e of c){if(e.separatorBefore){let e=document.createElement(`div`);e.className=`tiptap-table-options-separator`,e.setAttribute(`role`,`separator`),r.appendChild(e)}let t=f(e.key,e.label);e.destructive&&t.classList.add(`is-destructive`),r.appendChild(t)}n.appendChild(r),n.addEventListener(`keydown`,t=>{if(t.key===`Escape`){if(t.preventDefault(),t.stopPropagation(),o){h(),i?.focus();return}e.view.focus()}})}function m(e){r&&i&&n&&(document.dispatchEvent(new CustomEvent(wT,{detail:{source:n}})),o=!0,r.hidden=!1,i.setAttribute(`aria-expanded`,`true`),g(),e&&r.querySelector(`button:not(:disabled)`)?.focus())}function h(){r&&i&&(o=!1,r.hidden=!0,i.setAttribute(`aria-expanded`,`false`))}function g(){for(let[e,t]of s){let n=l(e);for(let e of t)e.disabled=!n,e.setAttribute(`aria-disabled`,String(!n))}}function _(){h(),n&&(n.style.display=`none`)}function v(e,t){if(!n)return;n.style.display=`flex`,n.style.visibility=`hidden`;let r=e.dom.closest(`dialog`),i=t.getBoundingClientRect(),a=n.getBoundingClientRect(),o=mT({anchorRect:i,containerRect:pT(r),floatingWidth:a.width,floatingHeight:a.height,preferredPlacement:`top`,fallbackPlacement:`bottom`,align:`center`,gap:6});n.style.left=`${o.left}px`,n.style.top=`${o.top}px`,n.dataset.placement=o.placement,n.style.visibility=`visible`}function y(e){let t=document.activeElement;return e.hasFocus()||!!(t&&n?.contains(t))}function b(e){a=e;let t=AT(e);if(!t||!y(e)){_();return}v(e,t),g()}function x(e){if(!AT(e))return!1;n&&(n.style.display=`flex`),b(e);let t=n?.querySelector(`:scope > button:not(:disabled)`);return t?.focus(),!!t}return[new N({key:CT,props:{handleKeyDown(e,t){return t.altKey&&t.key===`F10`?AT(e)?(t.preventDefault(),t.stopPropagation(),x(e)):!1:t.key===`Escape`&&o?(t.preventDefault(),t.stopPropagation(),h(),!0):!1}},view(e){a=e,p();let t=e.dom.closest(`dialog`)??document.body;n&&t.appendChild(n);let o=()=>{requestAnimationFrame(()=>{a&&b(a)})},c=()=>{if(a&&n&&n.style.display!==`none`){let e=AT(a);e&&v(a,e)}},l=t=>{let r=t.target;if(r instanceof Node&&!n?.contains(r)){if(e.dom.contains(r)){h();return}_()}},u=t=>{let r=t.target;if(r instanceof Node){if(n?.contains(r)||e.dom.contains(r)){o();return}_()}},d=e=>{e.detail.source!==n&&h()};return e.dom.addEventListener(`focusin`,o),e.dom.addEventListener(`focusout`,o),document.addEventListener(`mousedown`,l,!0),document.addEventListener(`focusin`,u,!0),document.addEventListener(wT,d),window.addEventListener(`resize`,c),window.addEventListener(`scroll`,c,!0),o(),{update(e){b(e)},destroy(){e.dom.removeEventListener(`focusin`,o),e.dom.removeEventListener(`focusout`,o),document.removeEventListener(`mousedown`,l,!0),document.removeEventListener(`focusin`,u,!0),document.removeEventListener(wT,d),window.removeEventListener(`resize`,c),window.removeEventListener(`scroll`,c,!0),n?.remove(),n=null,r=null,i=null,s.clear(),a=null}}}})]}}),FT=8,IT=8,LT=3,RT=3,zT=null;function BT(e,t,n){return e.replaceAll(`%rows%`,String(t)).replaceAll(`%cols%`,String(n))}function VT(e,t,n){zT?.close(!1),e.chain().focus().deleteRange(t).run();let r=e.state.selection.from,i=e.view.dom.closest(`dialog`),a=i??document.body,o=document.createElement(`div`);o.className=`tiptap-table-size-picker`,o.dataset.editorFloatingUi=`true`,o.style.position=`fixed`,o.setAttribute(`role`,`dialog`),o.setAttribute(`aria-label`,n.sizePickerLabel);let s=document.createElement(`div`);s.className=`tiptap-table-size-picker-header`;let c=document.createElement(`span`);c.textContent=n.sizePickerLabel;let l=document.createElement(`output`);l.className=`tiptap-table-size-picker-dimensions`,l.setAttribute(`aria-live`,`polite`),s.appendChild(c),s.appendChild(l),o.appendChild(s);let u=document.createElement(`div`);u.className=`tiptap-table-size-grid`,u.setAttribute(`role`,`grid`),u.setAttribute(`aria-label`,n.sizePickerLabel),o.appendChild(u);let d=LT,f=RT,p=!1,m=[];function h(e,t){return BT(n.insertTableSize,e,t)}function g(e,t){d=Math.min(Math.max(e,1),FT),f=Math.min(Math.max(t,1),IT),l.textContent=`${d} × ${f}`,o.setAttribute(`aria-label`,`${n.sizePickerLabel}: ${h(d,f)}`);for(let e=1;e<=FT;e+=1)for(let t=1;t<=IT;t+=1){let n=m[e-1]?.[t-1];if(!n)continue;let r=e===d&&t===f;n.classList.toggle(`is-selected`,e<=d&&t<=f),n.classList.toggle(`is-current`,r),n.tabIndex=r?0:-1,n.setAttribute(`aria-selected`,String(r))}}function _(){m[d-1]?.[f-1]?.focus()}function v(){p||(w(!1),e.chain().focus().setTextSelection(r).insertTable({rows:d,cols:f,withHeaderRow:!0}).run())}function y(e){let t=d,n=f;if(e.key===`ArrowUp`)--t;else if(e.key===`ArrowDown`)t+=1;else if(e.key===`ArrowLeft`)--n;else if(e.key===`ArrowRight`)n+=1;else if(e.key===`Enter`||e.key===` `){e.preventDefault(),e.stopPropagation(),v();return}else if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),w(!0);return}else return;e.preventDefault(),e.stopPropagation(),g(t,n),_()}for(let e=1;e<=FT;e+=1){let t=document.createElement(`div`);t.className=`tiptap-table-size-grid-row`,t.setAttribute(`role`,`row`);let n=[];for(let r=1;r<=IT;r+=1){let i=document.createElement(`button`);i.type=`button`,i.className=`tiptap-table-size-cell`,i.dataset.row=String(e),i.dataset.column=String(r),i.setAttribute(`role`,`gridcell`),i.setAttribute(`aria-label`,h(e,r)),i.addEventListener(`pointerenter`,()=>{g(e,r)}),i.addEventListener(`focus`,()=>{g(e,r)}),i.addEventListener(`keydown`,y),i.addEventListener(`click`,v),t.appendChild(i),n.push(i)}m.push(n),u.appendChild(t)}function b(){if(p)return;let t=e.view.coordsAtPos(r),n=o.getBoundingClientRect(),a=mT({anchorRect:{left:t.left,right:t.right,top:t.top,bottom:t.bottom},containerRect:pT(i),floatingWidth:n.width,floatingHeight:n.height,preferredPlacement:`bottom`,fallbackPlacement:`top`,align:`start`});o.style.left=`${a.left}px`,o.style.top=`${a.top}px`,o.dataset.placement=a.placement}function x(e){let t=e.target;t instanceof Node&&!o.contains(t)&&w(!1)}function S(t){let n=t.target;n instanceof Node&&!o.contains(n)&&!e.view.dom.contains(n)&&w(!1)}function C(){w(!1)}function w(t=!1){p||(p=!0,document.removeEventListener(`mousedown`,x,!0),document.removeEventListener(`focusin`,S,!0),window.removeEventListener(`resize`,b),window.removeEventListener(`scroll`,b,!0),e.off(`destroy`,C),o.remove(),zT?.close===w&&(zT=null),t&&!e.isDestroyed&&e.view.focus())}zT={close:w},a.appendChild(o),g(LT,RT),b(),window.addEventListener(`resize`,b),window.addEventListener(`scroll`,b,!0),e.on(`destroy`,C),setTimeout(()=>{p||(document.addEventListener(`mousedown`,x,!0),document.addEventListener(`focusin`,S,!0),_())},0)}function HT(e={}){return new Promise(t=>{let n=document.createElement(`dialog`);n.className=`dialog tiptap-embed-dialog`;let r=document.createElement(`div`);r.className=`tiptap-embed-dialog-panel`,r.tabIndex=-1,n.appendChild(r);let i=document.createElement(`h2`);i.className=`tiptap-embed-dialog-title`,i.textContent=`Insert embed`,r.appendChild(i);let a=document.createElement(`div`);a.className=`tiptap-embed-dialog-field`,r.appendChild(a);let o=document.createElement(`label`);o.className=`tiptap-embed-dialog-label`,o.textContent=`URL`,a.appendChild(o);let s=document.createElement(`input`);s.type=`url`,s.className=`input tiptap-embed-dialog-input`,s.placeholder=`https://www.youtube.com/watch?v=…`,s.value=e.initialUrl??``,o.appendChild(s);let c=document.createElement(`p`);c.className=`tiptap-embed-dialog-hint`,a.appendChild(c);let l=document.createElement(`div`);l.className=`tiptap-embed-dialog-field`,r.appendChild(l);let u=document.createElement(`label`);u.className=`tiptap-embed-dialog-label`,u.textContent=`Caption (optional)`,l.appendChild(u);let d=document.createElement(`input`);d.type=`text`,d.className=`input tiptap-embed-dialog-input`,d.value=e.initialCaption??``,u.appendChild(d);let f=document.createElement(`div`);f.className=`tiptap-embed-dialog-field`,f.hidden=!0,r.appendChild(f);let p=document.createElement(`label`);p.className=`tiptap-embed-dialog-label`,p.textContent=`Raw HTML`,f.appendChild(p);let m=document.createElement(`textarea`);m.className=`textarea tiptap-embed-dialog-textarea`,m.rows=8,m.placeholder=`<script data-letterbirduser="you" src="https://letterbird.co/embed/v1.js"><\/script>`,m.value=e.initialHtml??``,p.appendChild(m);let h=document.createElement(`p`);h.className=`tiptap-embed-dialog-warning`,h.textContent=`Anything you paste here runs in your visitors' browsers. Only use code you trust.`,f.appendChild(h);let g=document.createElement(`button`);g.type=`button`,g.className=`tiptap-embed-dialog-toggle`,r.appendChild(g);let _=e.initialMode??`url`;function v(){_===`url`?(i.textContent=`Insert embed`,a.hidden=!1,l.hidden=!1,f.hidden=!0,g.textContent=`Paste raw HTML instead`):(i.textContent=`Paste raw HTML`,a.hidden=!0,l.hidden=!0,f.hidden=!1,g.textContent=`Use a URL instead`),y(),w(),queueMicrotask(()=>{_===`url`?s.focus():m.focus()})}function y(){if(_!==`url`){c.textContent=``;return}let e=s.value.trim();if(!e){c.textContent=`YouTube, Vimeo, Spotify, CodePen, or any HTTPS page.`;return}let t=se(e);if(!t){c.textContent=`Not a valid URL.`;return}c.textContent=t.provider===`iframe`?`Generic iframe — ${t.providerName}`:`Detected: ${t.providerName}`}g.addEventListener(`click`,e=>{e.preventDefault(),_=_===`url`?`html`:`url`,v()}),s.addEventListener(`input`,()=>{y(),w()});let b=document.createElement(`div`);b.className=`tiptap-embed-dialog-actions`,r.appendChild(b);let x=document.createElement(`button`);x.type=`button`,x.className=`tiptap-embed-dialog-link-instead`,x.textContent=`Insert as link instead`,x.addEventListener(`click`,e=>{e.preventDefault();let t=s.value.trim();if(!t){s.focus();return}ie({kind:`link`,url:t})}),b.appendChild(x);let S=document.createElement(`button`);S.type=`button`,S.className=`btn-outline`,S.textContent=`Cancel`,S.addEventListener(`click`,e=>{e.preventDefault(),ie(null)}),b.appendChild(S);let C=document.createElement(`button`);C.type=`button`,C.className=`btn`,C.textContent=`Insert`,C.addEventListener(`click`,e=>{e.preventDefault(),T()}),b.appendChild(C);function w(){let e=_===`url`&&s.value.trim().length>0;x.hidden=!e}function T(){if(_===`url`){let e=s.value.trim();if(!e){s.focus();return}if(!se(e)){c.textContent=`Not a valid URL.`,s.focus();return}ie({kind:`embed`,url:e,caption:d.value.trim()||void 0})}else{if(!m.value.trim()){m.focus();return}ie({kind:`html`,html:m.value})}}function ee(e){if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),ie(null);return}if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey){if(e.target instanceof HTMLTextAreaElement)return;e.preventDefault(),T()}}function te(e){e.target===n&&ie(null)}function ne(e){e.preventDefault(),ie(null)}let re=!1;function ie(e){re||(re=!0,n.removeEventListener(`cancel`,ne),n.removeEventListener(`click`,te),n.removeEventListener(`keydown`,ee),n.open&&n.close(),n.remove(),t(e))}n.addEventListener(`cancel`,ne),n.addEventListener(`click`,te),n.addEventListener(`keydown`,ee),document.body.appendChild(n),v(),n.showModal(),r.focus()})}var UT={image:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>`,embed:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="14" x="2" y="3" rx="2" ry="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/><polygon points="10 8 15 11 10 14 10 8" fill="currentColor"/></svg>`,divider:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12h18"/></svg>`,readMore:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12h18"/><path d="m9 18 3 3 3-3"/><path d="m9 6-3-3-3 3"/><path d="M3 6h18"/></svg>`,footnote:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7 4h10"/><path d="M12 4v11"/><path d="M9 9h6"/><path d="M16 20h4"/><path d="M18 14v6"/></svg>`,table:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3v18"/><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M3 9h18"/><path d="M3 15h18"/></svg>`,code:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>`,blockquote:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1z"/><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z"/></svg>`,bulletList:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="8" x2="21" y1="6" y2="6"/><line x1="8" x2="21" y1="12" y2="12"/><line x1="8" x2="21" y1="18" y2="18"/><line x1="3" x2="3.01" y1="6" y2="6"/><line x1="3" x2="3.01" y1="12" y2="12"/><line x1="3" x2="3.01" y1="18" y2="18"/></svg>`,orderedList:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="10" x2="21" y1="6" y2="6"/><line x1="10" x2="21" y1="12" y2="12"/><line x1="10" x2="21" y1="18" y2="18"/><path d="M4 6h1v4"/><path d="M4 10h2"/><path d="M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"/></svg>`,h1:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12h8"/><path d="M4 18V6"/><path d="M12 18V6"/><path d="M17 12l3-2v10"/></svg>`,h2:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12h8"/><path d="M4 18V6"/><path d="M12 18V6"/><path d="M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"/></svg>`,h3:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12h8"/><path d="M4 18V6"/><path d="M12 18V6"/><path d="M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2"/><path d="M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2"/></svg>`},WT={media:`Media`,structure:`Structure`,formatting:`Formatting`,headings:`Headings`},GT=[`media`,`structure`,`formatting`,`headings`],KT=`No matches. Try another command.`,qT={insert:`Insert`,close:`Close`},JT=[{label:`Media`,description:`Upload an image or video.`,group:`media`,keywords:[`image`,`video`,`photo`,`upload`],icon:UT.image,command:(e,t)=>{e.chain().focus().deleteRange(t).run(),document.dispatchEvent(new CustomEvent(`jant:slash-image`,{bubbles:!0}))}},{label:`Embed`,description:`Embed a YouTube video, tweet, or any HTTPS page.`,group:`media`,keywords:[`embed`,`youtube`,`vimeo`,`spotify`,`video`,`iframe`,`html`,`letterbird`],icon:UT.embed,command:(e,t)=>{e.chain().focus().deleteRange(t).run(),HT().then(t=>{if(!t){e.commands.focus();return}t.kind===`embed`?e.chain().focus().setEmbed({url:t.url,caption:t.caption}).run():t.kind===`link`?e.chain().focus().insertContent({type:`text`,text:t.url,marks:[{type:`link`,attrs:{href:t.url}}]}).run():e.chain().focus().setHtmlBlock({html:t.html}).run()})}},{label:`Divider`,description:`Separate one thought from the next.`,group:`structure`,keywords:[`line`,`rule`,`separator`,`break`,`hr`],icon:UT.divider,command:(e,t)=>{e.chain().focus().deleteRange(t).setHorizontalRule().run()}},{label:`Read More`,description:`Collapse the rest of a longer post.`,group:`structure`,keywords:[`excerpt`,`continue`,`teaser`,`more`,`break`],icon:UT.readMore,command:(e,t)=>{e.chain().focus().deleteRange(t).insertMoreBreak().run()}},{label:`Footnote`,description:`Insert a numbered footnote and jump to its note.`,group:`structure`,keywords:[`footnote`,`note`,`citation`,`reference`,`superscript`],icon:UT.footnote,command:(e,t)=>{e.chain().focus().deleteRange(t).insertFootnote().run()}},{label:`Table`,description:`Insert a table.`,group:`structure`,keywords:[`grid`,`rows`,`columns`,`spreadsheet`],icon:UT.table,command:(e,t)=>{let n=NT(e);if(n){VT(e,t,n);return}e.chain().focus().deleteRange(t).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},{label:`Code Block`,description:`Format a block of code or monospace text.`,group:`formatting`,keywords:[`code`,`snippet`,`pre`,`monospace`],icon:UT.code,command:(e,t)=>{e.chain().focus().deleteRange(t).toggleCodeBlock().run()}},{label:`Blockquote`,description:`Set off quoted text or a pull quote.`,group:`formatting`,keywords:[`quote`,`citation`,`excerpt`,`callout`],icon:UT.blockquote,command:(e,t)=>{e.chain().focus().deleteRange(t).toggleBlockquote().run()}},{label:`Bullet List`,description:`Start an unordered list.`,group:`formatting`,keywords:[`list`,`bullets`,`unordered`,`ul`],icon:UT.bulletList,command:(e,t)=>{e.chain().focus().deleteRange(t).toggleBulletList().run()}},{label:`Ordered List`,description:`Start a numbered list.`,group:`formatting`,keywords:[`list`,`numbered`,`ordered`,`ol`],icon:UT.orderedList,command:(e,t)=>{e.chain().focus().deleteRange(t).toggleOrderedList().run()}},{label:`Heading 1`,description:`Insert the largest section heading.`,group:`headings`,keywords:[`title`,`h1`,`large heading`,`section title`],icon:UT.h1,command:(e,t)=>{e.chain().focus().deleteRange(t).toggleHeading({level:1}).run()}},{label:`Heading 2`,description:`Insert a medium section heading.`,group:`headings`,keywords:[`subtitle`,`h2`,`section heading`],icon:UT.h2,command:(e,t)=>{e.chain().focus().deleteRange(t).toggleHeading({level:2}).run()}},{label:`Heading 3`,description:`Insert a small section heading.`,group:`headings`,keywords:[`subheading`,`h3`,`small heading`],icon:UT.h3,command:(e,t)=>{e.chain().focus().deleteRange(t).toggleHeading({level:3}).run()}}];function YT(e){let t=!1;return e.state.doc.descendants(e=>e.type.name===`moreBreak`?(t=!0,!1):!t),t}function XT(e){return e&&YT(e)?JT.filter(e=>e.label!==`Read More`):JT}var $=null,ZT=0,QT=[],$T=null,eE=null,tE=null,nE=null;function rE(){return $?$.querySelector(`.tiptap-slash-menu-scroll`)??$:null}function iE(){let e=document.createElement(`div`);return e.className=`tiptap-slash-menu`,e.dataset.editorFloatingUi=`true`,e.style.position=`fixed`,e}function aE(){if(!$)return;let e=rE();if(!e)return;let t=$.querySelector(`.tiptap-slash-item.is-selected`);if(!t)return;let n=t.offsetTop-e.offsetTop,r=n+t.offsetHeight,i=e.scrollTop,a=i+e.clientHeight;n<i?e.scrollTop=n:r>a&&(e.scrollTop=r-e.clientHeight)}function oE(){$?.querySelectorAll(`.tiptap-slash-item`).forEach((e,t)=>{let n=t===ZT;e.classList.toggle(`is-selected`,n),e.setAttribute(`aria-selected`,n?`true`:`false`)}),cE(),aE()}function sE(){return QT[ZT]??null}function cE(){let e=$?.querySelector(`.tiptap-slash-footer-description`);e&&(e.textContent=sE()?.description??``)}function lE(e){return`<div class="tiptap-slash-footer">
|
|
218
|
+
`)}`},markdownTokenizer:{name:`footnoteDefinition`,level:`block`,start(e){return e.indexOf(`[^`)},tokenize(e,t,n){let r=x(e);if(r)return{type:`footnoteDefinition`,raw:r.raw,label:r.label,tokens:r.contentMarkdown?n.blockTokens(r.contentMarkdown):[]}}}});function OC(t={}){return[Sb.configure({heading:{levels:[1,2,3]},link:!1,codeBlock:!1,orderedList:!1,paragraph:!1,hardBreak:!1,bold:!1,italic:!1,strike:!1,trailingNode:{notAfter:[`footnoteDefinition`]}}),fC,uC,rC,iC,aC,lC,pC,WS.configure({openOnClick:!1,autolink:!1,isAllowedUri:t=>e(t)!==``}),US,MS.configure({resizable:!1,HTMLAttributes:{class:`tiptap-table`}}),_S,hS,gS,mC,t.imageExtension??HS,t.moreBreakExtension??vC,t.embedExtension??yC,t.htmlBlockExtension??bC,wC,EC,DC]}function kC(e){return typeof e==`object`&&!!e&&typeof e.type==`string`}function AC(e,t){if(e.type===`footnoteReference`||e.type===`footnoteDefinition`){let n=m(e.attrs?.label);n&&t.add(h(n))}for(let n of e.content??[])AC(n,t)}function jC(e){if(e.type!==`doc`)return e;let t=new Set;AC(e,t);let n=[],r=1,i=()=>{for(;t.has(h(String(r)));)r+=1;let e=String(r);return t.add(h(e)),r+=1,e},a=e=>{let t=e.attrs?.[SC];if(e.type===`footnoteReference`&&Array.isArray(t)){let r=i(),o={...e.attrs??{},label:r};delete o[SC];let s=t.filter(kC).map(e=>a(MC(e)));return n.push({type:`footnoteDefinition`,attrs:{label:r},content:[s.length>0?{type:`paragraph`,content:s}:{type:`paragraph`}]}),{...e,attrs:o}}return e.content?{...e,content:e.content.map(a)}:e},o=a(e);return n.length===0?o:{...o,content:[...o.content??[],...n]}}function MC(e){let t={...e};if(t.content&&=t.content.map(MC),t.marks&&=t.marks.map(e=>{if(!e||typeof e!=`object`)return e;let t={...e,attrs:e.type===`link`?{...e.attrs??{},target:typeof e.attrs?.target==`string`?e.attrs.target:`_blank`}:e.attrs};return t.attrs&&Object.keys(t.attrs).length===0&&delete t.attrs,t}),t.attrs&&typeof t.attrs==`object`){let e={...t.attrs};t.type===`codeBlock`&&e.language==null&&delete e.language,Object.keys(e).length>0?t.attrs=e:delete t.attrs}if(t.type===`doc`&&(!t.content||t.content.length===0)&&(t.content=[{type:`paragraph`}]),t.type===`paragraph`&&t.content){let e=[];for(let n=0;n<t.content.length;n+=1){let r=t.content[n],i=t.content[n+1];if(r?.type===`text`&&typeof r.text==`string`&&i?.type===`footnoteReference`&&/\n[ \t]*$/.test(r.text)){let t=r.text.replace(/\n[ \t]*$/,``);t&&e.push({...r,text:t});continue}r&&e.push(r)}t.content=e}return t.type===`doc`?jC(t):t}function NC(e){return e}function PC(e=OC()){return new Km({extensions:e,markedOptions:NS})}var FC=null;function IC(){return FC??=PC(),FC}var LC=null;function RC(){return LC??=Mu(OC()),LC}function zC(e){let t=e.type?RC().nodes[e.type]:void 0;if(!t||t.isLeaf)return e;let n=e.content?.map(zC);if((n?.length??0)===0&&!t.contentMatch.validEnd){let n=t.contentMatch.fillBefore(D.empty,!0);if(n)return{...e,content:n.toJSON()}}return n?{...e,content:n}:e}function BC(e){return zC(MC(IC().parse(e)))}function VC(e){return NC(IC().serialize(b(tC(zC(e)))))}var HC=mb,UC=Math.min,WC=Math.max,GC=Math.round,KC=Math.floor,qC=e=>({x:e,y:e}),JC={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function YC(e,t){return typeof e==`function`?e(t):e}function XC(e){return e.split(`-`)[0]}function ZC(e){return e.split(`-`)[1]}function QC(e){return e===`x`?`y`:`x`}function $C(e){return e===`y`?`height`:`width`}function ew(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function tw(e){return QC(ew(e))}function nw(e,t,n){n===void 0&&(n=!1);let r=ZC(e),i=tw(e),a=$C(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=dw(o)),[o,dw(o)]}function rw(e){let t=dw(e);return[iw(e),t,iw(t)]}function iw(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var aw=[`left`,`right`],ow=[`right`,`left`],sw=[`top`,`bottom`],cw=[`bottom`,`top`];function lw(e,t,n){switch(e){case`top`:case`bottom`:return n?t?ow:aw:t?aw:ow;case`left`:case`right`:return t?sw:cw;default:return[]}}function uw(e,t,n,r){let i=ZC(e),a=lw(XC(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(iw)))),a}function dw(e){let t=XC(e);return JC[t]+e.slice(t.length)}function fw(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function pw(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:fw(e)}function mw(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function hw(e,t,n){let{reference:r,floating:i}=e,a=ew(t),o=tw(t),s=$C(o),c=XC(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=ZC(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function gw(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=YC(t,e),p=pw(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=mw(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=mw(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var _w=50,vw=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:gw},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=hw(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<_w&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=hw(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},yw=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=YC(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=XC(r),_=ew(o),v=XC(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[dw(o)]:rw(o)),x=p!==`none`;!d&&x&&b.push(...uw(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=nw(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===ew(t)||T.every(e=>ew(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=ew(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},bw=new Set([`left`,`top`]);async function xw(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=XC(n),s=ZC(n),c=ew(n)===`y`,l=bw.has(o)?-1:1,u=a&&c?-1:1,d=YC(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Sw=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await xw(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}};function Cw(){return typeof window<`u`}function ww(e){return Dw(e)?(e.nodeName||``).toLowerCase():`#document`}function Tw(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ew(e){return((Dw(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Dw(e){return Cw()?e instanceof Node||e instanceof Tw(e).Node:!1}function Ow(e){return Cw()?e instanceof Element||e instanceof Tw(e).Element:!1}function kw(e){return Cw()?e instanceof HTMLElement||e instanceof Tw(e).HTMLElement:!1}function Aw(e){return!Cw()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Tw(e).ShadowRoot}function jw(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Hw(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Mw(e){return/^(table|td|th)$/.test(ww(e))}function Nw(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Pw=/transform|translate|scale|rotate|perspective|filter/,Fw=/paint|layout|strict|content/,Iw=e=>!!e&&e!==`none`,Lw;function Rw(e){let t=Ow(e)?Hw(e):e;return Iw(t.transform)||Iw(t.translate)||Iw(t.scale)||Iw(t.rotate)||Iw(t.perspective)||!Bw()&&(Iw(t.backdropFilter)||Iw(t.filter))||Pw.test(t.willChange||``)||Fw.test(t.contain||``)}function zw(e){let t=Ww(e);for(;kw(t)&&!Vw(t);){if(Rw(t))return t;if(Nw(t))return null;t=Ww(t)}return null}function Bw(){return Lw??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Lw}function Vw(e){return/^(html|body|#document)$/.test(ww(e))}function Hw(e){return Tw(e).getComputedStyle(e)}function Uw(e){return Ow(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ww(e){if(ww(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Aw(e)&&e.host||Ew(e);return Aw(t)?t.host:t}function Gw(e){let t=Ww(e);return Vw(t)?(e.ownerDocument||e).body:kw(t)&&jw(t)?t:Gw(t)}function Kw(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Gw(e),i=r===e.ownerDocument?.body,a=Tw(r);if(i){let e=qw(a);return t.concat(a,a.visualViewport||[],jw(r)?r:[],e&&n?Kw(e):[])}return t.concat(r,Kw(r,[],n))}function qw(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Jw(e){let t=Hw(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=kw(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=GC(n)!==a||GC(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Yw(e){return Ow(e)?e:e.contextElement}function Xw(e){let t=Yw(e);if(!kw(t))return qC(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Jw(t),o=(a?GC(n.width):n.width)/r,s=(a?GC(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Zw=qC(0);function Qw(e){let t=Tw(e);return!Bw()||!t.visualViewport?Zw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function $w(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Tw(e)}function eT(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Yw(e),o=qC(1);t&&(r?Ow(r)&&(o=Xw(r)):o=Xw(e));let s=$w(a,n,r)?Qw(a):qC(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=Tw(a),t=Ow(r)?Tw(r):r,n=e,i=qw(n);for(;i&&t!==n;){let e=Xw(i),t=i.getBoundingClientRect(),r=Hw(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Tw(i),i=qw(n)}}return mw({width:u,height:d,x:c,y:l})}function tT(e,t){let n=Uw(e).scrollLeft;return t?t.left+n:eT(Ew(e)).left+n}function nT(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-tT(e,n),y:n.top+t.scrollTop}}function rT(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Ew(r),s=t?Nw(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=qC(1),u=qC(0),d=kw(r);if((d||!a)&&((ww(r)!==`body`||jw(o))&&(c=Uw(r)),d)){let e=eT(r);l=Xw(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?nT(o,c):qC(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function iT(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function aT(e){let t=Uw(e),n=e.ownerDocument.body,r=WC(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=WC(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+tT(e),o=-t.scrollTop;return Hw(n).direction===`rtl`&&(a+=WC(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var oT=25;function sT(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=Tw(e),a=Ew(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Bw()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(tT(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=oT&&(s-=o)}return{width:s,height:c,x:l,y:u}}function cT(e,t){let n=eT(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Xw(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function lT(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=sT(e,n,t);else if(t===`document`)r=aT(Ew(e));else if(Ow(t))r=cT(t,n);else{let n=Qw(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return mw(r)}function uT(e,t){let n=t.get(e);if(n)return n;let r=Kw(e,[],!1).filter(e=>Ow(e)&&ww(e)!==`body`),i=null,a=Hw(e).position===`fixed`,o=a?Ww(e):e;for(;Ow(o)&&!Vw(o);){let e=Hw(o),t=Rw(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Ww(o)}return t.set(e,r),r}function dT(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Nw(t)?[]:uT(t,this._c):[].concat(n),r],o=lT(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=lT(t,a[e],i);s=WC(n.top,s),c=UC(n.right,c),l=UC(n.bottom,l),u=WC(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function fT(e){let{width:t,height:n}=Jw(e);return{width:t,height:n}}function pT(e,t,n){let r=kw(t),i=Ew(t),a=n===`fixed`,o=eT(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=qC(0);if((r||!a)&&((ww(t)!==`body`||jw(i))&&(s=Uw(t)),r)){let e=eT(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=tT(i));let l=i&&!r&&!a?nT(i,s):qC(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function mT(e){return Hw(e).position===`static`}function hT(e,t){if(!kw(e)||Hw(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Ew(e)===n&&(n=n.ownerDocument.body),n}function gT(e,t){let n=Tw(e);if(Nw(e))return n;if(!kw(e)){let t=Ww(e);for(;t&&!Vw(t);){if(Ow(t)&&!mT(t))return t;t=Ww(t)}return n}let r=hT(e,t);for(;r&&Mw(r)&&mT(r);)r=hT(r,t);return r&&Vw(r)&&mT(r)&&!Rw(r)?n:r||zw(e)||n}var _T=async function(e){let t=this.getOffsetParent||gT,n=this.getDimensions,r=await n(e.floating);return{reference:pT(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function vT(e){return Hw(e).direction===`rtl`}var yT={convertOffsetParentRelativeRectToViewportRelativeRect:rT,getDocumentElement:Ew,getClippingRect:dT,getOffsetParent:gT,getElementRects:_T,getClientRects:iT,getDimensions:fT,getScale:Xw,isElement:Ow,isRTL:vT};function bT(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function xT(e,t,n){let r=null,i,a=Ew(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=KC(d),h=KC(a.clientWidth-(u+f)),g=KC(a.clientHeight-(d+p)),_=KC(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:WC(0,UC(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!bT(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=Tw(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function ST(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Yw(e),u=i||a?[...l?Kw(l):[],...t?Kw(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?xT(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?eT(e):null;c&&g();function g(){let t=eT(e);h&&!bT(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var CT=Sw,wT=yw,TT=(e,t,n)=>{let r=new Map,i=n??{},a={...yT,...i.platform,_c:r};return vw(e,t,{...i,platform:a})};function ET(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=lf(t),l=RegExp(`\\s${c}$`),u=a?`^`:``,d=r?``:c,f=RegExp(s?`${u}${c}.*?(?=\\s${d}|$)`:`${u}(?:^)?${c}[^\\s${d}]*`,`gm`),p=o.nodeBefore?.isText&&o.nodeBefore.text;if(!p)return null;let m=o.pos-p.length,h=Array.from(p.matchAll(f)).pop();if(!h||h.input===void 0||h.index===void 0)return null;let g=h.input.slice(Math.max(0,h.index-1),h.index),_=RegExp(`^[${i?.join(``)}\0]?$`).test(g);if(i!==null&&!_)return null;let v=m+h.index,y=v+h[0].length;return s&&l.test(p.slice(y-1,y+1))&&(h[0]+=` `,y+=1),v<o.pos&&y>=o.pos?{range:{from:v,to:y},query:h[0].slice(t.length),text:h[0]}:null}function DT(e){return e.docChanged?e.steps.some(e=>{let t=e.slice;if(!t?.content)return!1;let n=t.content.textBetween(0,t.content.size,`
|
|
219
|
+
`);return/\s/.test(n)}):!1}function OT(e){return()=>{let t=e.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=e.view.coordsAtPos(t);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}}}function kT(e,t,n,r){return n?()=>{let n=r.getState(e.state)?.decorationId;return t.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:OT(e)}function AT({match:e,dismissedRange:t,state:n,transaction:r,editor:i,shouldResetDismissed:a,effectiveAllowSpaces:o}){return a?.({editor:i,state:n,range:t,match:e,transaction:r,allowSpaces:o})?!1:o?e.range.from===t.from:e.range.from===t.from&&!DT(r)}function jT({view:e,pluginKeyRef:t}){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function MT({pluginKey:e,decorationTag:t,decorationClass:n,decorationContent:r,decorationEmptyClass:i,renderer:a,dispatchExit:o}){return{handleKeyDown(t,n){var r;let i=e.getState(t.state);if(!i.active)return!1;if(n.key===`Escape`||n.key===`Esc`){var s;return a==null||(s=a.onKeyDown)==null||s.call(a,{view:t,event:n,range:i.range}),o(t),!0}return(a==null||(r=a.onKeyDown)==null?void 0:r.call(a,{view:t,event:n,range:i.range}))||!1},decorations(a){let{active:o,range:s,decorationId:c,query:l}=e.getState(a);if(!o)return null;let u=!l?.length,d=[n];return u&&d.push(i),L.create(a.doc,[Ws.inline(s.from,s.to,{nodeName:t,class:d.join(` `),"data-decoration-id":c||void 0,"data-decoration-content":r})])}}}function NT({editor:e,char:t,effectiveAllowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,findSuggestionMatch:o,allow:s,shouldShow:c,shouldKeepDismissed:l,pluginKey:u}){return{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(d,f,p,m){let{isEditable:h}=e,{composing:g}=e.view,{selection:_}=d,{empty:v,from:y}=_,b={...f},x=d.getMeta(u);if(x&&x.exit)return b.active=!1,b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null,b.dismissedRange=f.active?{...f.range}:f.dismissedRange,b;if(b.composing=g,d.docChanged&&b.dismissedRange!==null&&(b.dismissedRange={from:d.mapping.map(b.dismissedRange.from),to:d.mapping.map(b.dismissedRange.to)}),h&&(v||e.view.composing)){(y<f.range.from||y>f.range.to)&&!g&&!f.composing&&(b.active=!1);let u=o({char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:_.$from}),p=`id_${Math.floor(Math.random()*4294967295)}`;u&&s({editor:e,state:m,range:u.range,isActive:f.active})&&(!c||c({editor:e,range:u.range,query:u.query,text:u.text,transaction:d}))?(b.dismissedRange!==null&&!l({match:u,dismissedRange:b.dismissedRange,state:m,transaction:d})&&(b.dismissedRange=null),b.dismissedRange===null?(b.active=!0,b.decorationId=f.decorationId||p,b.range=u.range,b.query=u.query,b.text=u.text):b.active=!1):(u||(b.dismissedRange=null),b.active=!1)}else b.active=!1;return b.active||(b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null),b}}}function PT({editor:e,items:t}){let n=null,r=null,i=null,a=()=>{r!==null&&(clearTimeout(r),r=null),i?.(),i=null},o=e=>new Promise(t=>{i=t,r=setTimeout(()=>{r=null;let e=i;i=null,e?.()},e)}),s=()=>{n?.abort(),a(),n=null};return{abort:s,fetch:async(r,i)=>{s(),n=new AbortController;let a=n;if(i>0&&await o(i),n!==a||a.signal.aborted)return{status:`aborted`};try{let i=await t({editor:e,query:r,signal:a.signal});return n!==a||a.signal.aborted?{status:`aborted`}:{status:`resolved`,items:i}}catch{return n!==a||a.signal.aborted?{status:`aborted`}:{status:`error`}}}}}function FT({placement:e,offset:t,flip:n,floatingUi:r}){var i;let a=[CT({mainAxis:t.mainAxis??4,crossAxis:t.crossAxis??0})];return n&&a.push(wT()),r!=null&&(i=r.middleware)!=null&&i.length&&a.push(...r.middleware),{placement:e,strategy:r?.strategy??`absolute`,middleware:a}}function IT(e){if(e instanceof HTMLElement)return e;if(typeof e==`string`)try{let t=document.querySelector(e);if(t)return t}catch{return document.body}return document.body}function LT({getReferenceRect:e,contextElement:t,config:n,container:r,dismissOnOutsideClick:i,dismiss:a}){return(o,s={})=>{let c={getBoundingClientRect:()=>e()??new DOMRect,contextElement:t},l=!1,u=!o.isConnected;u&&IT(r).appendChild(o),s.onPosition||(o.style.visibility=`hidden`,o.style.width=`max-content`);let d=ST(c,o,()=>{TT(c,o,{placement:n.placement,strategy:n.strategy,middleware:n.middleware}).then(({x:e,y:t,placement:n,strategy:r})=>{if(s.onPosition){s.onPosition({x:e,y:t,placement:n,strategy:r});return}Object.assign(o.style,{position:r,left:`${e}px`,top:`${t}px`}),l||(l=!0,o.style.visibility=``)})},s.autoUpdate),f;return i&&(f=e=>{let n=e.target;!(n instanceof Node)||o.contains(n)||t.contains(n)||a()},document.addEventListener(`pointerdown`,f,!0)),()=>{d(),f&&document.removeEventListener(`pointerdown`,f,!0),u&&o.remove()}}}function RT({editor:e,pluginKey:t,items:n,renderer:r,minQueryLength:i,debounce:a,initialItems:o,placement:s,offset:c,container:l,flip:u,floatingUi:d,dismissOnOutsideClick:f,command:p,clientRectFor:m,dispatchExit:h}){let g,_=PT({editor:e,items:n}),v=FT({placement:s,offset:c,flip:u,floatingUi:d});function y(e,t){switch(e){case`started`:var n;r==null||(n=r.onStart)==null||n.call(r,t);break;case`updated`:var i;r==null||(i=r.onUpdate)==null||i.call(r,t);break;case`stopped`:var a;r==null||(a=r.onExit)==null||a.call(r,t)}}return{update:async(n,d)=>{let b=t.getState(d),x=t.getState(n.state);if(!b||!x)return;let S=null,C=b.query!==x.query,w=b.text!==x.text,T=b.range.from!==x.range.from||b.range.to!==x.range.to,ee=C||w||T;if(!b.active&&x.active)S=`started`;else if(b.active&&!x.active)S=`stopped`;else if(x.active&&ee)S=`updated`;else return;let te=S===`stopped`?b:x,ne=n.dom.querySelector(`[data-decoration-id="${te.decorationId}"]`),re=m(n,ne),ie=i===0||(te.query?te.query.length>=i:!1),ae=(S===`started`||S===`updated`)&&ie;if(g={editor:e,range:te.range,query:te.query||``,text:te.text||``,items:o??[],command:t=>p({editor:e,range:te.range,props:t}),decorationNode:ne,clientRect:re,loading:ae,placement:s,offset:{mainAxis:c.mainAxis??4,crossAxis:c.crossAxis??0},container:l,flip:u,floatingUi:v,mount:LT({getReferenceRect:re,contextElement:n.dom,config:v,container:l,dismissOnOutsideClick:f,dismiss:()=>h(e.view)})},S===`started`){var oe;r==null||(oe=r.onBeforeStart)==null||oe.call(r,g)}if(S===`updated`){var se;r==null||(se=r.onBeforeUpdate)==null||se.call(r,g)}if(S===`started`&&y(S,g),S===`started`||S===`updated`){if(!ae)_.abort(),g={...g,items:o??[],loading:!1};else{g={...g,items:o??[],loading:!0},S=`updated`,y(S,g);let e=await _.fetch(te.query||``,a);if(e.status===`aborted`)return;if(!t.getState(n.state)?.active){_.abort();return}g=e.status===`resolved`?{...g,items:e.items,loading:!1}:{...g,loading:!1}}}if(S===`stopped`){_.abort(),y(S,g),g=void 0;return}S===`updated`&&y(S,g)},destroy:()=>{var e;_.abort(),g&&(r==null||(e=r.onExit)==null||e.call(r,g))}}}var zT=new P(`suggestion`);function BT({pluginKey:e=zT,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],minQueryLength:p=0,debounce:m=0,initialItems:h,placement:g=`bottom-start`,offset:_={},container:v,flip:y=!0,floatingUi:b,dismissOnOutsideClick:x=!0,render:S=()=>({}),allow:C=()=>!0,findSuggestionMatch:w=ET,shouldShow:T,shouldResetDismissed:ee}){let te=S?.(),ne=r&&!i,re=(n,r)=>kT(t,n,r,e);function ie(e){return AT({...e,editor:t,shouldResetDismissed:ee,effectiveAllowSpaces:ne})}let ae=t=>jT({view:t,pluginKeyRef:e});return new N({key:e,view:()=>RT({editor:t,pluginKey:e,items:f,renderer:te,minQueryLength:p,debounce:m,initialItems:h,placement:g,offset:_,container:v,flip:y,floatingUi:b,dismissOnOutsideClick:x,command:d,clientRectFor:re,dispatchExit:ae}),state:NT({editor:t,char:n,effectiveAllowSpaces:ne,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,findSuggestionMatch:w,allow:C,shouldShow:T,shouldKeepDismissed:ie,pluginKey:e}),props:MT({pluginKey:e,decorationTag:s,decorationClass:c,decorationContent:l,decorationEmptyClass:u,renderer:te,dispatchExit:ae})})}var VT=BT;function HT(e,t,n){return n<t?t:Math.min(Math.max(e,t),n)}function UT(e,t,n,r,i){let a=n.top,o=n.top+n.height;return Math.max(e===`top`?t.top-a-r-i:o-t.bottom-r-i,0)}function WT(e){if(!e||e===document.body)return{left:0,top:0,width:window.innerWidth,height:window.innerHeight};let t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}function GT(e){let t=e.gap??8,n=e.padding??8,r=e.fallbackPlacement??(e.preferredPlacement===`top`?`bottom`:`top`),i=UT(e.preferredPlacement,e.anchorRect,e.containerRect,t,n),a=UT(r,e.anchorRect,e.containerRect,t,n),o=e.floatingHeight<=i||i>=a?e.preferredPlacement:r,s=o===e.preferredPlacement?i:a,c=s>0&&e.floatingHeight>s?s:null,l=c??e.floatingHeight,u=e.align===`center`?(e.anchorRect.left+e.anchorRect.right)/2-e.floatingWidth/2:e.anchorRect.left,d=n,f=e.containerRect.width-e.floatingWidth-n;return{left:HT(u-e.containerRect.left,d,f),top:HT(o===`top`?e.anchorRect.top-e.containerRect.top-l-t:e.anchorRect.bottom-e.containerRect.top+t,n,e.containerRect.height-l-n),placement:o,maxHeight:c}}var KT=new Set([`auto`,`scroll`,`hidden`,`clip`,`overlay`]);function qT(e,t){let n=Math.max(e.left,t.left),r=Math.max(e.top,t.top),i=Math.min(e.left+e.width,t.left+t.width),a=Math.min(e.top+e.height,t.top+t.height);return{left:n,top:r,width:i-n,height:a-r}}function JT(e,t){let n=t,r=e.parentElement;for(;r&&r!==document.body;){let e=getComputedStyle(r);if(KT.has(e.overflowY)||KT.has(e.overflowX)){let e=r.getBoundingClientRect(),t=qT(n,{left:e.left,top:e.top,width:e.width,height:e.height});t.width>0&&t.height>0&&(n=t)}r=r.parentElement}return n}function YT(e,t){let n=t.left+t.width,r=t.top+t.height,i=1/0,a=-1/0,o=1/0,s=1/0,c=!1;for(let l of e){let e=Math.max(l.top,t.top),u=Math.min(l.bottom,r);if(u<=e)continue;let d=Math.max(l.left,t.left),f=Math.min(l.right,n);f<d||(i=Math.min(i,d),a=Math.max(a,f),o=Math.min(o,e),s=Math.min(s,u),c=!0)}return c?{left:i,right:a,top:o,bottom:s}:null}function XT(e,t,n){if(typeof document>`u`||!document.createRange)return[];try{let r=e.domAtPos(t),i=e.domAtPos(n),a=document.createRange();a.setStart(r.node,r.offset),a.setEnd(i.node,i.offset);let o=a.getClientRects?.();return o?Array.from(o):[]}catch{return[]}}function ZT(e,t,n,r){let i=YT(XT(e,t,n),r);if(i)return i;let a=e.coordsAtPos(t),o=e.coordsAtPos(n),s={left:Math.min(a.left,o.left),right:Math.max(a.right,o.right),top:a.top,bottom:a.bottom};return YT([s],r)??s}function QT(e){let t=e.inset??10,n=(e.anchorRect.left+e.anchorRect.right)/2-e.containerRect.left,r=Math.min(t,e.floatingWidth/2),i=Math.max(e.floatingWidth-t,r);return HT(n-e.floatingLeft,r,i)}var $T={toolbarLabel:`Table controls`,addRowAbove:`Add row above`,addRowBelow:`Add row below`,addColumnBefore:`Add column before`,addColumnAfter:`Add column after`,options:`Table options`,deleteRow:`Delete row`,deleteColumn:`Delete column`,toggleHeaderRow:`Toggle header row`,deleteTable:`Delete table`,sizePickerLabel:`Choose table size`,insertTableSize:`Insert %rows% by %cols% table`},eE=new P(`tableControls`),tE=`jant:table-options-open`,nE=`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="4" y="3" width="16" height="11" rx="2"/><path d="M4 8.5h16M12 3v11M12 18v4M10 20h4"/></svg>`,rE=`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="4" width="11" height="16" rx="2"/><path d="M8.5 4v16M3 12h11M18 12h4M20 10v4"/></svg>`,iE=`<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><circle cx="5" cy="12" r="1.7"/><circle cx="12" cy="12" r="1.7"/><circle cx="19" cy="12" r="1.7"/></svg>`;function aE(e){for(let t=e.depth;t>0;--t){let n=e.node(t);if(n.type.name===`table`)return{node:n,pos:e.before(t)}}return null}function oE(e){return aE(e.state.selection.$from)}function sE(e){let{node:t}=e.domAtPos(e.state.selection.from),n=(t instanceof HTMLElement?t:t.parentElement)?.closest(`table`);return n instanceof globalThis.HTMLTableElement&&e.dom.contains(n)?n:null}function cE(e){let t=oE(e);if(!t)return{rows:0,columns:0};let n=Z.get(t.node);return{rows:n.height,columns:n.width}}function lE(e){return e.commands.command(({state:e,tr:t,dispatch:n})=>{let r=aE(e.selection.$from),i=r?.node.firstChild,a=e.schema.nodes.tableHeader,o=e.schema.nodes.tableCell;if(!r||!i||!a||!o)return!1;let s=i.firstChild?.type!==a,c=r.pos+2;return i.forEach(e=>{t.setNodeMarkup(c,s?a:o,e.attrs),c+=e.nodeSize}),n?.(t),!0})}function uE(e){let t=e.extensionManager.extensions.find(e=>e.name===`tableControls`);return t?t.options.labels:null}var dE=H.create({name:`tableControls`,addOptions(){return{labels:$T}},addProseMirrorPlugins(){let e=this.editor,t=this.options.labels,n=null,r=null,i=null,a=null,o=!1,s=new Map,c=[{key:`addRowAbove`,label:t.addRowAbove},{key:`addRowBelow`,label:t.addRowBelow},{key:`addColumnBefore`,label:t.addColumnBefore},{key:`addColumnAfter`,label:t.addColumnAfter},{key:`deleteRow`,label:t.deleteRow,separatorBefore:!0},{key:`deleteColumn`,label:t.deleteColumn},{key:`toggleHeaderRow`,label:t.toggleHeaderRow},{key:`deleteTable`,label:t.deleteTable,destructive:!0,separatorBefore:!0}];function l(t){if(!oE(e))return!1;let n=cE(e);switch(t){case`addRowAbove`:return e.can().addRowBefore();case`addRowBelow`:return e.can().addRowAfter();case`addColumnBefore`:return e.can().addColumnBefore();case`addColumnAfter`:return e.can().addColumnAfter();case`deleteRow`:return n.rows>1&&e.can().deleteRow();case`deleteColumn`:return n.columns>1&&e.can().deleteColumn();case`toggleHeaderRow`:return!0;case`deleteTable`:return e.can().deleteTable()}}function u(t){if(!l(t))return;let r=!!(document.activeElement&&n?.contains(document.activeElement));switch(t){case`addRowAbove`:e.commands.addRowBefore();break;case`addRowBelow`:e.commands.addRowAfter();break;case`addColumnBefore`:e.commands.addColumnBefore();break;case`addColumnAfter`:e.commands.addColumnAfter();break;case`deleteRow`:e.commands.deleteRow();break;case`deleteColumn`:e.commands.deleteColumn();break;case`toggleHeaderRow`:lE(e);break;case`deleteTable`:e.commands.deleteTable()}h(),b(a??e.view),r&&!oE(e)&&e.view.focus()}function d(e,t){let n=s.get(e)??[];n.push(t),s.set(e,n)}function f(e,t,n,r=`tiptap-table-menu-item`){let i=document.createElement(`button`);return i.type=`button`,i.className=r,i.title=t,i.setAttribute(`aria-label`,t),n?i.innerHTML=n:(i.textContent=t,i.setAttribute(`role`,`menuitem`)),i.addEventListener(`mousedown`,e=>{e.preventDefault()}),i.addEventListener(`click`,()=>u(e)),d(e,i),i}function p(){n=document.createElement(`div`),n.className=`tiptap-table-controls`,n.dataset.editorFloatingUi=`true`,n.style.position=`fixed`,n.style.display=`none`,n.setAttribute(`role`,`toolbar`),n.setAttribute(`aria-label`,t.toolbarLabel),n.appendChild(f(`addRowBelow`,t.addRowBelow,nE,`tiptap-table-control-btn`)),n.appendChild(f(`addColumnAfter`,t.addColumnAfter,rE,`tiptap-table-control-btn`)),i=document.createElement(`button`),i.type=`button`,i.className=`tiptap-table-control-btn`,i.innerHTML=iE,i.title=t.options,i.setAttribute(`aria-label`,t.options),i.setAttribute(`aria-haspopup`,`menu`),i.setAttribute(`aria-expanded`,`false`),i.addEventListener(`mousedown`,e=>{e.preventDefault()}),i.addEventListener(`click`,e=>{if(o){h();return}m(e.detail===0)}),n.appendChild(i),r=document.createElement(`div`),r.className=`tiptap-table-options`,r.dataset.editorFloatingUi=`true`,r.setAttribute(`role`,`menu`),r.hidden=!0;for(let e of c){if(e.separatorBefore){let e=document.createElement(`div`);e.className=`tiptap-table-options-separator`,e.setAttribute(`role`,`separator`),r.appendChild(e)}let t=f(e.key,e.label);e.destructive&&t.classList.add(`is-destructive`),r.appendChild(t)}n.appendChild(r),n.addEventListener(`keydown`,t=>{if(t.key===`Escape`){if(t.preventDefault(),t.stopPropagation(),o){h(),i?.focus();return}e.view.focus()}})}function m(e){r&&i&&n&&(document.dispatchEvent(new CustomEvent(tE,{detail:{source:n}})),o=!0,r.hidden=!1,i.setAttribute(`aria-expanded`,`true`),g(),e&&r.querySelector(`button:not(:disabled)`)?.focus())}function h(){r&&i&&(o=!1,r.hidden=!0,i.setAttribute(`aria-expanded`,`false`))}function g(){for(let[e,t]of s){let n=l(e);for(let e of t)e.disabled=!n,e.setAttribute(`aria-disabled`,String(!n))}}function _(){h(),n&&(n.style.display=`none`)}function v(e,t){if(!n)return;n.style.display=`flex`,n.style.visibility=`hidden`;let r=e.dom.closest(`dialog`),i=t.getBoundingClientRect(),a=n.getBoundingClientRect(),o=GT({anchorRect:i,containerRect:WT(r),floatingWidth:a.width,floatingHeight:a.height,preferredPlacement:`top`,fallbackPlacement:`bottom`,align:`center`,gap:6});n.style.left=`${o.left}px`,n.style.top=`${o.top}px`,n.dataset.placement=o.placement,n.style.visibility=`visible`}function y(e){let t=document.activeElement;return e.hasFocus()||!!(t&&n?.contains(t))}function b(e){a=e;let t=sE(e);if(!t||!y(e)){_();return}v(e,t),g()}function x(e){if(!sE(e))return!1;n&&(n.style.display=`flex`),b(e);let t=n?.querySelector(`:scope > button:not(:disabled)`);return t?.focus(),!!t}return[new N({key:eE,props:{handleKeyDown(e,t){return t.altKey&&t.key===`F10`?sE(e)?(t.preventDefault(),t.stopPropagation(),x(e)):!1:t.key===`Escape`&&o?(t.preventDefault(),t.stopPropagation(),h(),!0):!1}},view(e){a=e,p();let t=e.dom.closest(`dialog`)??document.body;n&&t.appendChild(n);let o=()=>{requestAnimationFrame(()=>{a&&b(a)})},c=()=>{if(a&&n&&n.style.display!==`none`){let e=sE(a);e&&v(a,e)}},l=t=>{let r=t.target;if(r instanceof Node&&!n?.contains(r)){if(e.dom.contains(r)){h();return}_()}},u=t=>{let r=t.target;if(r instanceof Node){if(n?.contains(r)||e.dom.contains(r)){o();return}_()}},d=e=>{e.detail.source!==n&&h()};return e.dom.addEventListener(`focusin`,o),e.dom.addEventListener(`focusout`,o),document.addEventListener(`mousedown`,l,!0),document.addEventListener(`focusin`,u,!0),document.addEventListener(tE,d),window.addEventListener(`resize`,c),window.addEventListener(`scroll`,c,!0),o(),{update(e){b(e)},destroy(){e.dom.removeEventListener(`focusin`,o),e.dom.removeEventListener(`focusout`,o),document.removeEventListener(`mousedown`,l,!0),document.removeEventListener(`focusin`,u,!0),document.removeEventListener(tE,d),window.removeEventListener(`resize`,c),window.removeEventListener(`scroll`,c,!0),n?.remove(),n=null,r=null,i=null,s.clear(),a=null}}}})]}}),fE=8,pE=8,mE=3,hE=3,gE=null;function _E(e,t,n){return e.replaceAll(`%rows%`,String(t)).replaceAll(`%cols%`,String(n))}function vE(e,t,n){gE?.close(!1),e.chain().focus().deleteRange(t).run();let r=e.state.selection.from,i=e.view.dom.closest(`dialog`),a=i??document.body,o=document.createElement(`div`);o.className=`tiptap-table-size-picker`,o.dataset.editorFloatingUi=`true`,o.style.position=`fixed`,o.setAttribute(`role`,`dialog`),o.setAttribute(`aria-label`,n.sizePickerLabel);let s=document.createElement(`div`);s.className=`tiptap-table-size-picker-header`;let c=document.createElement(`span`);c.textContent=n.sizePickerLabel;let l=document.createElement(`output`);l.className=`tiptap-table-size-picker-dimensions`,l.setAttribute(`aria-live`,`polite`),s.appendChild(c),s.appendChild(l),o.appendChild(s);let u=document.createElement(`div`);u.className=`tiptap-table-size-grid`,u.setAttribute(`role`,`grid`),u.setAttribute(`aria-label`,n.sizePickerLabel),o.appendChild(u);let d=mE,f=hE,p=!1,m=[];function h(e,t){return _E(n.insertTableSize,e,t)}function g(e,t){d=Math.min(Math.max(e,1),fE),f=Math.min(Math.max(t,1),pE),l.textContent=`${d} × ${f}`,o.setAttribute(`aria-label`,`${n.sizePickerLabel}: ${h(d,f)}`);for(let e=1;e<=fE;e+=1)for(let t=1;t<=pE;t+=1){let n=m[e-1]?.[t-1];if(!n)continue;let r=e===d&&t===f;n.classList.toggle(`is-selected`,e<=d&&t<=f),n.classList.toggle(`is-current`,r),n.tabIndex=r?0:-1,n.setAttribute(`aria-selected`,String(r))}}function _(){m[d-1]?.[f-1]?.focus()}function v(){p||(w(!1),e.chain().focus().setTextSelection(r).insertTable({rows:d,cols:f,withHeaderRow:!0}).run())}function y(e){let t=d,n=f;if(e.key===`ArrowUp`)--t;else if(e.key===`ArrowDown`)t+=1;else if(e.key===`ArrowLeft`)--n;else if(e.key===`ArrowRight`)n+=1;else if(e.key===`Enter`||e.key===` `){e.preventDefault(),e.stopPropagation(),v();return}else if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),w(!0);return}else return;e.preventDefault(),e.stopPropagation(),g(t,n),_()}for(let e=1;e<=fE;e+=1){let t=document.createElement(`div`);t.className=`tiptap-table-size-grid-row`,t.setAttribute(`role`,`row`);let n=[];for(let r=1;r<=pE;r+=1){let i=document.createElement(`button`);i.type=`button`,i.className=`tiptap-table-size-cell`,i.dataset.row=String(e),i.dataset.column=String(r),i.setAttribute(`role`,`gridcell`),i.setAttribute(`aria-label`,h(e,r)),i.addEventListener(`pointerenter`,()=>{g(e,r)}),i.addEventListener(`focus`,()=>{g(e,r)}),i.addEventListener(`keydown`,y),i.addEventListener(`click`,v),t.appendChild(i),n.push(i)}m.push(n),u.appendChild(t)}function b(){if(p)return;let t=e.view.coordsAtPos(r),n=o.getBoundingClientRect(),a=GT({anchorRect:{left:t.left,right:t.right,top:t.top,bottom:t.bottom},containerRect:WT(i),floatingWidth:n.width,floatingHeight:n.height,preferredPlacement:`bottom`,fallbackPlacement:`top`,align:`start`});o.style.left=`${a.left}px`,o.style.top=`${a.top}px`,o.dataset.placement=a.placement}function x(e){let t=e.target;t instanceof Node&&!o.contains(t)&&w(!1)}function S(t){let n=t.target;n instanceof Node&&!o.contains(n)&&!e.view.dom.contains(n)&&w(!1)}function C(){w(!1)}function w(t=!1){p||(p=!0,document.removeEventListener(`mousedown`,x,!0),document.removeEventListener(`focusin`,S,!0),window.removeEventListener(`resize`,b),window.removeEventListener(`scroll`,b,!0),e.off(`destroy`,C),o.remove(),gE?.close===w&&(gE=null),t&&!e.isDestroyed&&e.view.focus())}gE={close:w},a.appendChild(o),g(mE,hE),b(),window.addEventListener(`resize`,b),window.addEventListener(`scroll`,b,!0),e.on(`destroy`,C),setTimeout(()=>{p||(document.addEventListener(`mousedown`,x,!0),document.addEventListener(`focusin`,S,!0),_())},0)}function yE(e={}){return new Promise(t=>{let n=document.createElement(`dialog`);n.className=`dialog tiptap-embed-dialog`;let r=document.createElement(`div`);r.className=`tiptap-embed-dialog-panel`,r.tabIndex=-1,n.appendChild(r);let i=document.createElement(`h2`);i.className=`tiptap-embed-dialog-title`,i.textContent=`Insert embed`,r.appendChild(i);let a=document.createElement(`div`);a.className=`tiptap-embed-dialog-field`,r.appendChild(a);let o=document.createElement(`label`);o.className=`tiptap-embed-dialog-label`,o.textContent=`URL`,a.appendChild(o);let s=document.createElement(`input`);s.type=`url`,s.className=`input tiptap-embed-dialog-input`,s.placeholder=`https://www.youtube.com/watch?v=…`,s.value=e.initialUrl??``,o.appendChild(s);let c=document.createElement(`p`);c.className=`tiptap-embed-dialog-hint`,a.appendChild(c);let l=document.createElement(`div`);l.className=`tiptap-embed-dialog-field`,r.appendChild(l);let u=document.createElement(`label`);u.className=`tiptap-embed-dialog-label`,u.textContent=`Caption (optional)`,l.appendChild(u);let d=document.createElement(`input`);d.type=`text`,d.className=`input tiptap-embed-dialog-input`,d.value=e.initialCaption??``,u.appendChild(d);let f=document.createElement(`div`);f.className=`tiptap-embed-dialog-field`,f.hidden=!0,r.appendChild(f);let p=document.createElement(`label`);p.className=`tiptap-embed-dialog-label`,p.textContent=`Raw HTML`,f.appendChild(p);let m=document.createElement(`textarea`);m.className=`textarea tiptap-embed-dialog-textarea`,m.rows=8,m.placeholder=`<script data-letterbirduser="you" src="https://letterbird.co/embed/v1.js"><\/script>`,m.value=e.initialHtml??``,p.appendChild(m);let h=document.createElement(`p`);h.className=`tiptap-embed-dialog-warning`,h.textContent=`Anything you paste here runs in your visitors' browsers. Only use code you trust.`,f.appendChild(h);let g=document.createElement(`button`);g.type=`button`,g.className=`tiptap-embed-dialog-toggle`,r.appendChild(g);let _=e.initialMode??`url`;function v(){_===`url`?(i.textContent=`Insert embed`,a.hidden=!1,l.hidden=!1,f.hidden=!0,g.textContent=`Paste raw HTML instead`):(i.textContent=`Paste raw HTML`,a.hidden=!0,l.hidden=!0,f.hidden=!1,g.textContent=`Use a URL instead`),y(),w(),queueMicrotask(()=>{_===`url`?s.focus():m.focus()})}function y(){if(_!==`url`){c.textContent=``;return}let e=s.value.trim();if(!e){c.textContent=`YouTube, Vimeo, Spotify, CodePen, or any HTTPS page.`;return}let t=se(e);if(!t){c.textContent=`Not a valid URL.`;return}c.textContent=t.provider===`iframe`?`Generic iframe — ${t.providerName}`:`Detected: ${t.providerName}`}g.addEventListener(`click`,e=>{e.preventDefault(),_=_===`url`?`html`:`url`,v()}),s.addEventListener(`input`,()=>{y(),w()});let b=document.createElement(`div`);b.className=`tiptap-embed-dialog-actions`,r.appendChild(b);let x=document.createElement(`button`);x.type=`button`,x.className=`tiptap-embed-dialog-link-instead`,x.textContent=`Insert as link instead`,x.addEventListener(`click`,e=>{e.preventDefault();let t=s.value.trim();if(!t){s.focus();return}ie({kind:`link`,url:t})}),b.appendChild(x);let S=document.createElement(`button`);S.type=`button`,S.className=`btn-outline`,S.textContent=`Cancel`,S.addEventListener(`click`,e=>{e.preventDefault(),ie(null)}),b.appendChild(S);let C=document.createElement(`button`);C.type=`button`,C.className=`btn`,C.textContent=`Insert`,C.addEventListener(`click`,e=>{e.preventDefault(),T()}),b.appendChild(C);function w(){let e=_===`url`&&s.value.trim().length>0;x.hidden=!e}function T(){if(_===`url`){let e=s.value.trim();if(!e){s.focus();return}if(!se(e)){c.textContent=`Not a valid URL.`,s.focus();return}ie({kind:`embed`,url:e,caption:d.value.trim()||void 0})}else{if(!m.value.trim()){m.focus();return}ie({kind:`html`,html:m.value})}}function ee(e){if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),ie(null);return}if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey){if(e.target instanceof HTMLTextAreaElement)return;e.preventDefault(),T()}}function te(e){e.target===n&&ie(null)}function ne(e){e.preventDefault(),ie(null)}let re=!1;function ie(e){re||(re=!0,n.removeEventListener(`cancel`,ne),n.removeEventListener(`click`,te),n.removeEventListener(`keydown`,ee),n.open&&n.close(),n.remove(),t(e))}n.addEventListener(`cancel`,ne),n.addEventListener(`click`,te),n.addEventListener(`keydown`,ee),document.body.appendChild(n),v(),n.showModal(),r.focus()})}var bE={image:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>`,embed:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="14" x="2" y="3" rx="2" ry="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/><polygon points="10 8 15 11 10 14 10 8" fill="currentColor"/></svg>`,divider:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12h18"/></svg>`,readMore:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12h18"/><path d="m9 18 3 3 3-3"/><path d="m9 6-3-3-3 3"/><path d="M3 6h18"/></svg>`,footnote:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7 4h10"/><path d="M12 4v11"/><path d="M9 9h6"/><path d="M16 20h4"/><path d="M18 14v6"/></svg>`,table:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3v18"/><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M3 9h18"/><path d="M3 15h18"/></svg>`,code:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>`,blockquote:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1z"/><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z"/></svg>`,bulletList:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="8" x2="21" y1="6" y2="6"/><line x1="8" x2="21" y1="12" y2="12"/><line x1="8" x2="21" y1="18" y2="18"/><line x1="3" x2="3.01" y1="6" y2="6"/><line x1="3" x2="3.01" y1="12" y2="12"/><line x1="3" x2="3.01" y1="18" y2="18"/></svg>`,orderedList:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="10" x2="21" y1="6" y2="6"/><line x1="10" x2="21" y1="12" y2="12"/><line x1="10" x2="21" y1="18" y2="18"/><path d="M4 6h1v4"/><path d="M4 10h2"/><path d="M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"/></svg>`,h1:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12h8"/><path d="M4 18V6"/><path d="M12 18V6"/><path d="M17 12l3-2v10"/></svg>`,h2:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12h8"/><path d="M4 18V6"/><path d="M12 18V6"/><path d="M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"/></svg>`,h3:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12h8"/><path d="M4 18V6"/><path d="M12 18V6"/><path d="M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2"/><path d="M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2"/></svg>`},xE={media:`Media`,structure:`Structure`,formatting:`Formatting`,headings:`Headings`},SE=[`media`,`structure`,`formatting`,`headings`],CE=`No matches. Try another command.`,wE={insert:`Insert`,close:`Close`},TE=[{label:`Media`,description:`Upload an image or video.`,group:`media`,keywords:[`image`,`video`,`photo`,`upload`],icon:bE.image,command:(e,t)=>{e.chain().focus().deleteRange(t).run(),document.dispatchEvent(new CustomEvent(`jant:slash-image`,{bubbles:!0}))}},{label:`Embed`,description:`Embed a YouTube video, tweet, or any HTTPS page.`,group:`media`,keywords:[`embed`,`youtube`,`vimeo`,`spotify`,`video`,`iframe`,`html`,`letterbird`],icon:bE.embed,command:(e,t)=>{e.chain().focus().deleteRange(t).run(),yE().then(t=>{if(!t){e.commands.focus();return}t.kind===`embed`?e.chain().focus().setEmbed({url:t.url,caption:t.caption}).run():t.kind===`link`?e.chain().focus().insertContent({type:`text`,text:t.url,marks:[{type:`link`,attrs:{href:t.url}}]}).run():e.chain().focus().setHtmlBlock({html:t.html}).run()})}},{label:`Divider`,description:`Separate one thought from the next.`,group:`structure`,keywords:[`line`,`rule`,`separator`,`break`,`hr`],icon:bE.divider,command:(e,t)=>{e.chain().focus().deleteRange(t).setHorizontalRule().run()}},{label:`Read More`,description:`Collapse the rest of a longer post.`,group:`structure`,keywords:[`excerpt`,`continue`,`teaser`,`more`,`break`],icon:bE.readMore,command:(e,t)=>{e.chain().focus().deleteRange(t).insertMoreBreak().run()}},{label:`Footnote`,description:`Insert a numbered footnote and jump to its note.`,group:`structure`,keywords:[`footnote`,`note`,`citation`,`reference`,`superscript`],icon:bE.footnote,command:(e,t)=>{e.chain().focus().deleteRange(t).insertFootnote().run()}},{label:`Table`,description:`Insert a table.`,group:`structure`,keywords:[`grid`,`rows`,`columns`,`spreadsheet`],icon:bE.table,command:(e,t)=>{let n=uE(e);if(n){vE(e,t,n);return}e.chain().focus().deleteRange(t).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},{label:`Code Block`,description:`Format a block of code or monospace text.`,group:`formatting`,keywords:[`code`,`snippet`,`pre`,`monospace`],icon:bE.code,command:(e,t)=>{e.chain().focus().deleteRange(t).toggleCodeBlock().run()}},{label:`Blockquote`,description:`Set off quoted text or a pull quote.`,group:`formatting`,keywords:[`quote`,`citation`,`excerpt`,`callout`],icon:bE.blockquote,command:(e,t)=>{e.chain().focus().deleteRange(t).toggleBlockquote().run()}},{label:`Bullet List`,description:`Start an unordered list.`,group:`formatting`,keywords:[`list`,`bullets`,`unordered`,`ul`],icon:bE.bulletList,command:(e,t)=>{e.chain().focus().deleteRange(t).toggleBulletList().run()}},{label:`Ordered List`,description:`Start a numbered list.`,group:`formatting`,keywords:[`list`,`numbered`,`ordered`,`ol`],icon:bE.orderedList,command:(e,t)=>{e.chain().focus().deleteRange(t).toggleOrderedList().run()}},{label:`Heading 1`,description:`Insert the largest section heading.`,group:`headings`,keywords:[`title`,`h1`,`large heading`,`section title`],icon:bE.h1,command:(e,t)=>{e.chain().focus().deleteRange(t).toggleHeading({level:1}).run()}},{label:`Heading 2`,description:`Insert a medium section heading.`,group:`headings`,keywords:[`subtitle`,`h2`,`section heading`],icon:bE.h2,command:(e,t)=>{e.chain().focus().deleteRange(t).toggleHeading({level:2}).run()}},{label:`Heading 3`,description:`Insert a small section heading.`,group:`headings`,keywords:[`subheading`,`h3`,`small heading`],icon:bE.h3,command:(e,t)=>{e.chain().focus().deleteRange(t).toggleHeading({level:3}).run()}}];function EE(e){let t=!1;return e.state.doc.descendants(e=>e.type.name===`moreBreak`?(t=!0,!1):!t),t}function DE(e){return e&&EE(e)?TE.filter(e=>e.label!==`Read More`):TE}var $=null,OE=0,kE=[],AE=null,jE=null,ME=null,NE=null;function PE(){return $?$.querySelector(`.tiptap-slash-menu-scroll`)??$:null}function FE(){let e=document.createElement(`div`);return e.className=`tiptap-slash-menu`,e.dataset.editorFloatingUi=`true`,e.style.position=`fixed`,e}function IE(){if(!$)return;let e=PE();if(!e)return;let t=$.querySelector(`.tiptap-slash-item.is-selected`);if(!t)return;let n=t.offsetTop-e.offsetTop,r=n+t.offsetHeight,i=e.scrollTop,a=i+e.clientHeight;n<i?e.scrollTop=n:r>a&&(e.scrollTop=r-e.clientHeight)}function LE(){$?.querySelectorAll(`.tiptap-slash-item`).forEach((e,t)=>{let n=t===OE;e.classList.toggle(`is-selected`,n),e.setAttribute(`aria-selected`,n?`true`:`false`)}),zE(),IE()}function RE(){return kE[OE]??null}function zE(){let e=$?.querySelector(`.tiptap-slash-footer-description`);e&&(e.textContent=RE()?.description??``)}function BE(e){return`<div class="tiptap-slash-footer">
|
|
216
220
|
<span class="tiptap-slash-footer-description">${S(e?.description??``)}</span>
|
|
217
221
|
<span class="tiptap-slash-footer-actions" aria-hidden="true">
|
|
218
222
|
<span class="tiptap-slash-footer-note">
|
|
219
223
|
<span class="tiptap-slash-kbd">Enter</span>
|
|
220
|
-
<span>${S(
|
|
224
|
+
<span>${S(wE.insert)}</span>
|
|
221
225
|
</span>
|
|
222
226
|
<span class="tiptap-slash-footer-separator"></span>
|
|
223
227
|
<span class="tiptap-slash-footer-note">
|
|
224
228
|
<span class="tiptap-slash-kbd">Esc</span>
|
|
225
|
-
<span>${S(
|
|
229
|
+
<span>${S(wE.close)}</span>
|
|
226
230
|
</span>
|
|
227
231
|
</span>
|
|
228
|
-
</div>`}function
|
|
232
|
+
</div>`}function VE(e,t){let n=t===OE;return`<div
|
|
229
233
|
class="tiptap-slash-item${n?` is-selected`:``}"
|
|
230
234
|
data-index="${t}"
|
|
231
235
|
role="option"
|
|
@@ -233,25 +237,25 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
233
237
|
>
|
|
234
238
|
<span class="tiptap-slash-item-icon" aria-hidden="true">${e.icon}</span>
|
|
235
239
|
<span class="tiptap-slash-item-label">${S(e.label)}</span>
|
|
236
|
-
</div>`}function
|
|
240
|
+
</div>`}function HE(e,t){if(!$)return;if(kE=e,e.length===0){OE=0,$.dataset.empty=`true`,$.innerHTML=`<div class="tiptap-slash-menu-scroll">
|
|
237
241
|
<div class="tiptap-slash-empty-shell">
|
|
238
|
-
<div class="tiptap-slash-empty" role="status" aria-live="polite">${S(
|
|
242
|
+
<div class="tiptap-slash-empty" role="status" aria-live="polite">${S(CE)}</div>
|
|
239
243
|
</div>
|
|
240
244
|
</div>
|
|
241
|
-
${
|
|
242
|
-
<p class="tiptap-slash-group-label">${S(
|
|
243
|
-
${n.map(({item:e,index:t})=>
|
|
245
|
+
${BE(null)}`;let e=PE();e&&(e.scrollTop=0);return}delete $.dataset.empty,(OE>=e.length||Number.isNaN(OE))&&(OE=0);let n=SE.map(t=>{let n=e.map((e,t)=>({item:e,index:t})).filter(({item:e})=>e.group===t);return n.length===0?``:`<section class="tiptap-slash-group" data-group="${t}">
|
|
246
|
+
<p class="tiptap-slash-group-label">${S(xE[t])}</p>
|
|
247
|
+
${n.map(({item:e,index:t})=>VE(e,t)).join(``)}
|
|
244
248
|
</section>`}).join(``);$.innerHTML=`<div class="tiptap-slash-menu-scroll">
|
|
245
249
|
${n}
|
|
246
250
|
</div>
|
|
247
|
-
${lE(sE())}`,$.querySelectorAll(`.tiptap-slash-item`).forEach(e=>{e.addEventListener(`mousedown`,n=>{n.preventDefault(),t(parseInt(e.dataset.index??`0`,10))}),e.addEventListener(`mouseenter`,()=>{ZT=parseInt(e.dataset.index??`0`,10),oE()})});let r=rE();r&&(r.scrollTop=0)}function fE(){nE&&=(document.removeEventListener(`mousedown`,nE,!0),null),$?.remove(),$=null,ZT=0,QT=[],$T=null,eE=null,tE=null}function pE(e,t){if(!$)return;$.style.maxHeight=``;let n=pT(null),r=t?pT(t):n,i=mT({anchorRect:{left:e.left,right:e.left,top:e.top,bottom:e.bottom},containerRect:n,floatingWidth:$.offsetWidth,floatingHeight:$.offsetHeight,preferredPlacement:`bottom`,fallbackPlacement:`top`,align:`start`,gap:6});$.style.left=`${i.left-r.left}px`,$.style.top=`${i.top-r.top}px`,$.style.maxHeight=i.maxHeight===null?``:`${i.maxHeight}px`}function mE(){nE=e=>{if($&&!$.contains(e.target)&&eE&&tE){let{state:e,view:t}=eE;t.dispatch(e.tr.delete(tE.from,tE.to))}},document.addEventListener(`mousedown`,nE,!0)}var hE=new P(`jantSlashTyping`);function gE(){return new N({key:hE,state:{init:()=>({docChanged:!1}),apply:e=>({docChanged:e.docChanged})}})}function _E({state:e,range:t}){let n=e.doc.resolve(t.to),r=n.parent,i=t.to-n.start();if(i>=r.content.size)return!0;let a=r.textBetween(i,i+1,` `,` `);return!a||/\s/.test(a)}function vE({state:e,range:t,isActive:n}){return _E({state:e,range:t})?n?!0:hE.getState(e)?.docChanged??!1:!1}var yE=H.create({name:`slashCommands`,addOptions(){return{suggestion:{char:`/`,startOfLine:!1,allow:vE,items:({query:e,editor:t})=>{let n=XT(t),r=u(e);return r?n.map((e,t)=>({item:e,index:t,rank:s([e.label,e.description,...e.keywords],r)})).filter(e=>e.rank!==null).sort((e,t)=>e.rank-t.rank||e.index-t.index).map(e=>e.item):n},render:()=>{function e(e){let t=e.options.element;return t instanceof globalThis.Element?t:null}return{onStart:t=>{$=iE(),ZT=0,$T=t.command,eE=t.editor,tE=t.range,dE(t.items,e=>t.command({index:e})),document.dispatchEvent(new CustomEvent(`jant:slash-command-discovered`,{bubbles:!0}));let n=e(t.editor)?.closest(`dialog`)??null;(n??document.body).appendChild($);let r=t.clientRect?.();r&&pE(r,n),mE()},onUpdate:t=>{$T=t.command,tE=t.range,dE(t.items,e=>t.command({index:e}));let n=t.clientRect?.();n&&pE(n,e(t.editor)?.closest(`dialog`)??null)},onKeyDown:e=>{let{event:t,view:n,range:r}=e;return t.key===`ArrowDown`?(t.preventDefault(),QT.length===0||(ZT=(ZT+1)%QT.length,oE(),!0)):t.key===`ArrowUp`?(t.preventDefault(),QT.length===0||(ZT=(ZT-1+QT.length)%QT.length,oE(),!0)):t.key===`Enter`?(t.preventDefault(),QT.length===0||$T?.({index:ZT}),!0):t.key===`Escape`&&(t.stopPropagation(),t.preventDefault(),n.dispatch(n.state.tr.delete(r.from,r.to)),!0)},onExit:()=>{fE()}}},command:({editor:e,range:t,props:n})=>{let r=QT[n.index];r&&r.command(e,t)}}}},addProseMirrorPlugins(){return[gE(),uT({editor:this.editor,...this.options.suggestion})]}}),bE=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~`.split(``),xE=(e,t)=>{var n=``;for(let r=1;r<=t;r++){let i=Math.floor(e)/83**(t-r)%83;n+=bE[Math.floor(i)]}return n},SE=e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4},CE=e=>{let t=Math.max(0,Math.min(1,e));return Math.trunc(t<=.0031308?t*12.92*255+.5:(1.055*t**.4166666666666667-.055)*255+.5)},wE=e=>e<0?-1:1,TE=(e,t)=>wE(e)*Math.abs(e)**+t,EE=class extends Error{constructor(e){super(e),this.name=`ValidationError`,this.message=e}},DE=4,OE=(e,t,n,r)=>{let i=0,a=0,o=0,s=t*DE;for(let c=0;c<t;c++){let t=DE*c;for(let l=0;l<n;l++){let n=t+l*s,u=r(c,l);i+=u*SE(e[n]),a+=u*SE(e[n+1]),o+=u*SE(e[n+2])}}let c=1/(t*n);return[i*c,a*c,o*c]},kE=e=>{let t=CE(e[0]),n=CE(e[1]),r=CE(e[2]);return(t<<16)+(n<<8)+r},AE=(e,t)=>{let n=Math.floor(Math.max(0,Math.min(18,Math.floor(TE(e[0]/t,.5)*9+9.5)))),r=Math.floor(Math.max(0,Math.min(18,Math.floor(TE(e[1]/t,.5)*9+9.5)))),i=Math.floor(Math.max(0,Math.min(18,Math.floor(TE(e[2]/t,.5)*9+9.5))));return n*19*19+r*19+i},jE=(e,t,n,r,i)=>{if(r<1||r>9||i<1||i>9)throw new EE(`BlurHash must have between 1 and 9 components`);if(t*n*4!==e.length)throw new EE(`Width and height must match the pixels array`);let a=[];for(let o=0;o<i;o++)for(let i=0;i<r;i++){let r=i==0&&o==0?1:2,s=OE(e,t,n,(e,a)=>r*Math.cos(Math.PI*i*e/t)*Math.cos(Math.PI*o*a/n));a.push(s)}let o=a[0],s=a.slice(1),c=``,l=r-1+(i-1)*9;c+=xE(l,1);let u;if(s.length>0){let e=Math.max(...s.map(e=>Math.max(...e))),t=Math.floor(Math.max(0,Math.min(82,Math.floor(e*166-.5))));u=(t+1)/166,c+=xE(t,1)}else u=1,c+=xE(0,1);return c+=xE(kE(o),4),s.forEach(e=>{c+=xE(AE(e,u),2)}),c},ME={maxShortSide:1920,maxLongSide:8192,quality:.85,mimeType:`image/webp`};function NE(e,t,n){if(Math.max(e,t)>n.maxLongSide)return{passthrough:!0,width:e,height:t};let r=Math.min(e,t);if(r<=n.maxShortSide)return{passthrough:!1,width:e,height:t};let i=n.maxShortSide/r;return{passthrough:!1,width:Math.round(e*i),height:Math.round(t*i)}}function PE(e,t){return t===e?e:`image/jpeg`}function FE(e,t){let n=Math.min(32/e,32/t,1);return{width:Math.max(Math.round(e*n),1),height:Math.max(Math.round(t*n),1)}}var IE="var e=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~`.split(``),t=(t,n)=>{var r=``;for(let i=1;i<=n;i++){let a=Math.floor(t)/83**(n-i)%83;r+=e[Math.floor(a)]}return r},n=e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4},r=e=>{let t=Math.max(0,Math.min(1,e));return Math.trunc(t<=.0031308?t*12.92*255+.5:(1.055*t**.4166666666666667-.055)*255+.5)},i=e=>e<0?-1:1,a=(e,t)=>i(e)*Math.abs(e)**+t,o=class extends Error{constructor(e){super(e),this.name=`ValidationError`,this.message=e}},s=4,c=(e,t,r,i)=>{let a=0,o=0,c=0,l=t*s;for(let u=0;u<t;u++){let t=s*u;for(let s=0;s<r;s++){let r=t+s*l,d=i(u,s);a+=d*n(e[r]),o+=d*n(e[r+1]),c+=d*n(e[r+2])}}let u=1/(t*r);return[a*u,o*u,c*u]},l=e=>{let t=r(e[0]),n=r(e[1]),i=r(e[2]);return(t<<16)+(n<<8)+i},u=(e,t)=>{let n=Math.floor(Math.max(0,Math.min(18,Math.floor(a(e[0]/t,.5)*9+9.5)))),r=Math.floor(Math.max(0,Math.min(18,Math.floor(a(e[1]/t,.5)*9+9.5)))),i=Math.floor(Math.max(0,Math.min(18,Math.floor(a(e[2]/t,.5)*9+9.5))));return n*19*19+r*19+i},d=(e,n,r,i,a)=>{if(i<1||i>9||a<1||a>9)throw new o(`BlurHash must have between 1 and 9 components`);if(n*r*4!==e.length)throw new o(`Width and height must match the pixels array`);let s=[];for(let t=0;t<a;t++)for(let a=0;a<i;a++){let i=a==0&&t==0?1:2,o=c(e,n,r,(e,o)=>i*Math.cos(Math.PI*a*e/n)*Math.cos(Math.PI*t*o/r));s.push(o)}let d=s[0],f=s.slice(1),p=``,m=i-1+(a-1)*9;p+=t(m,1);let h;if(f.length>0){let e=Math.max(...f.map(e=>Math.max(...e))),n=Math.floor(Math.max(0,Math.min(82,Math.floor(e*166-.5))));h=(n+1)/166,p+=t(n,1)}else h=1,p+=t(0,1);return p+=t(l(d),4),f.forEach(e=>{p+=t(u(e,h),2)}),p};function f(e,t,n){if(Math.max(e,t)>n.maxLongSide)return{passthrough:!0,width:e,height:t};let r=Math.min(e,t);if(r<=n.maxShortSide)return{passthrough:!1,width:e,height:t};let i=n.maxShortSide/r;return{passthrough:!1,width:Math.round(e*i),height:Math.round(t*i)}}function p(e,t){return t===e?e:`image/jpeg`}function m(e,t){let n=Math.min(32/e,32/t,1);return{width:Math.max(Math.round(e*n),1),height:Math.max(Math.round(t*n),1)}}const h=self,g=new Map;function _(e,t){let n=g.get(e);if(!n){let{canvas:r}=v(null,1,1);n=r.convertToBlob({type:e,quality:t}).then(t=>p(e,t.type)),g.set(e,n)}return n}function v(e,t,n){let r=new OffscreenCanvas(t,n),i=r.getContext(`2d`);if(!i)throw Error(`Failed to get canvas context`);return e&&i.drawImage(e,0,0,t,n),{canvas:r,ctx:i}}function y(e){try{let{width:t,height:n}=m(e.width,e.height),{ctx:r}=v(e,t,n);return d(r.getImageData(0,0,t,n).data,t,n,4,3)}catch{return}}async function b(e,t){let n=await createImageBitmap(e,{imageOrientation:`from-image`});try{let r=f(n.width,n.height,t),i=y(n);if(r.passthrough)return{blob:e,width:r.width,height:r.height,processed:!1,blurhash:i};let{canvas:a}=v(n,r.width,r.height),o=await _(t.mimeType,t.quality);return{blob:await a.convertToBlob({type:o,quality:t.quality}),width:r.width,height:r.height,processed:!0,blurhash:i}}finally{n.close()}}h.addEventListener(`message`,async e=>{let{id:t,file:n,options:r}=e.data;try{h.postMessage({id:t,ok:!0,...await b(n,r)})}catch(e){h.postMessage({id:t,ok:!1,error:e instanceof Error?e.message:String(e)})}});",LE=typeof self<`u`&&self.Blob&&new Blob([`URL.revokeObjectURL(import.meta.url);`,IE],{type:`text/javascript;charset=utf-8`});function RE(e){let t;try{if(t=LE&&(self.URL||self.webkitURL).createObjectURL(LE),!t)throw``;let n=new Worker(t,{type:`module`,name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(IE),{type:`module`,name:e?.name})}}function zE(){return typeof Worker==`function`&&typeof OffscreenCanvas==`function`&&typeof createImageBitmap==`function`}function BE(){return new RE({name:`jant-image`})}var VE=null,HE=1,UE=new Map;function WE(){if(VE)return VE;let e=BE();return e.addEventListener(`message`,e=>{let t=e.data,n=UE.get(t.id);n&&(UE.delete(t.id),t.ok?n.resolve({blob:t.blob,width:t.width,height:t.height,processed:t.processed,blurhash:t.blurhash}):n.reject(Error(t.error)))}),e.addEventListener(`error`,t=>{if(VE!==e)return;VE=null,e.terminate();let n=[...UE.values()];UE.clear();let r=Error(t.message||`Image worker failed`);for(let e of n)e.reject(r)}),VE=e,e}function GE(e,t){let n=WE();return new Promise((r,i)=>{let a=HE++;UE.set(a,{resolve:r,reject:i});let o={id:a,file:e,options:t};n.postMessage(o)})}function KE(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>{URL.revokeObjectURL(r.src),t(r)},r.onerror=()=>n(Error(`Failed to load image`)),r.src=URL.createObjectURL(e)})}function qE(e,t){let n=document.createElement(`canvas`);n.width=e,n.height=t;let r=n.getContext(`2d`);if(!r)throw Error(`Failed to get canvas context`);return{canvas:n,ctx:r}}function JE(e,t,n){return new Promise((r,i)=>{e.toBlob(e=>e?r(e):i(Error(`Failed to create blob`)),t,n)})}var YE=new Map;function XE(e,t){let n=YE.get(e);return n||(n=JE(qE(1,1).canvas,e,t).then(t=>PE(e,t.type)),YE.set(e,n)),n}function ZE(e){try{let{width:t,height:n}=FE(e.width,e.height),{ctx:r}=qE(t,n);return r.drawImage(e,0,0,t,n),jE(r.getImageData(0,0,t,n).data,t,n,4,3)}catch{return}}async function QE(e,t){let n=await KE(e),r=NE(n.width,n.height,t),i=ZE(n);if(r.passthrough)return{blob:e,width:r.width,height:r.height,processed:!1,blurhash:i};let{canvas:a,ctx:o}=qE(r.width,r.height);return o.drawImage(n,0,0,r.width,r.height),{blob:await JE(a,await XE(t.mimeType,t.quality),t.quality),width:r.width,height:r.height,processed:!0,blurhash:i}}async function $E(e,t={}){let n={...ME,...t};if(zE())try{return await GE(e,n)}catch{}return QE(e,n)}async function eD(e,t={}){let n=await $E(e,t);if(!n.processed)return{file:e,width:n.width,height:n.height,blurhash:n.blurhash};let r={"image/webp":`webp`,"image/jpeg":`jpg`,"image/png":`png`}[n.blob.type]??`png`,i=`${e.name.replace(/\.[^.]+$/,``)}.${r}`;return{file:new File([n.blob],i,{type:n.blob.type}),width:n.width,height:n.height,blurhash:n.blurhash}}var tD={process:$E,processToFile:eD};function nD(e){if(!c(e))return null;let t=l(e,`kind`),n=l(e,`method`),r=l(e,`url`);if(!t||n!==`PUT`||!r)return null;if(t===`relay`)return{kind:t,method:`PUT`,url:r};if(t===`multipartRelay`){let n=i(e,`partSize`);return n?{kind:t,method:`PUT`,url:r,partSize:n}:null}if(t===`put`){let n=i(e,`expiresAt`),a=e.headers;if(!n||!c(a))return null;let o={};for(let[e,t]of Object.entries(a))typeof t==`string`&&(o[e]=t);return{kind:t,method:`PUT`,url:r,headers:o,expiresAt:n}}return null}function rD(e,t,n,r){return new Promise((i,a)=>{let o=new globalThis.XMLHttpRequest;o.open(`PUT`,e);for(let[e,t]of Object.entries(n))o.setRequestHeader(e,t);o.upload.addEventListener(`progress`,e=>{e.lengthComputable&&r&&r(e.loaded/e.total)}),o.addEventListener(`load`,()=>{i({status:o.status,ok:o.status>=200&&o.status<300,text:o.responseText})}),o.addEventListener(`error`,()=>a(Error(`Network error`))),o.addEventListener(`abort`,()=>a(Error(`Upload aborted`))),o.send(t)})}function iD(e){try{let t=JSON.parse(e);return c(t)?t:null}catch{return null}}async function aD(e){let n=await fetch(t(`/api/uploads/init`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({filename:e.name,contentType:e.type||`application/octet-stream`,size:e.size})});if(!n.ok)throw Error(await o(n,`Failed to start upload`));let i=await r(n),a=l(i,`id`),s=nD(i.transport);if(!a||!s)throw Error(`Failed to start upload`);return{id:a,transport:s}}async function oD(e,n){let r=await fetch(t(`/api/uploads/${e}/poster`),{method:`PUT`,headers:{"Content-Type":n.type||`image/webp`},body:n});if(!r.ok)throw Error(await o(r,`Failed to upload poster`))}async function sD(e){await fetch(t(`/api/uploads/${e}/abort`),{method:`POST`}).catch(()=>{})}async function cD(e,n){let a=await fetch(t(`/api/uploads/${e}/complete`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!a.ok)throw Error(await o(a,`Failed to complete upload`));let s=await r(a),c=l(s,`id`),u=l(s,`filename`),d=l(s,`url`),f=l(s,`mimeType`),p=i(s,`size`);if(!c||!u||!d||!f||p===void 0)throw Error(`Failed to complete upload`);return{id:c,filename:u,url:d,mimeType:f,size:p}}async function lD(e,n,r,o){let s=Math.ceil(r.size/n.partSize),c=[],u=0;for(let e=0;e<s;e+=1){let s=e*n.partSize,d=Math.min(s+n.partSize,r.size),f=e+1,p=r.slice(s,d),m=d-s,h=await rD(t(`${n.url}?partNumber=${f}`),p,{},e=>{o?.((u+m*e)/r.size)});if(!h.ok)throw Error(a(h.text,`Failed to upload part ${f}`));let g=iD(h.text),_=g?i(g,`partNumber`):null,v=g?l(g,`etag`):null;if(!_||!v)throw Error(`Failed to upload part ${f}`);c.push({partNumber:_,etag:v}),u+=m,o?.(u/r.size)}return c}async function uD(e,n,r){let{id:i,transport:o}=await aD(e);try{if(o.kind===`put`){let t=await rD(o.url,e,o.headers,r);if(!t.ok)throw Error(a(t.text,`Upload failed`));r?.(1)}else if(o.kind===`relay`){let n=await rD(t(o.url),e,{"Content-Type":e.type},r);if(!n.ok)throw Error(a(n.text,`Upload failed`));r?.(1)}let s=o.kind===`multipartRelay`?await lD(i,o,e,r):void 0;return n.poster&&await oD(i,n.poster),cD(i,{...n,parts:s})}catch(e){throw await sD(i),e}}async function dD(e){let{file:t,width:n,height:r,blurhash:i}=await tD.processToFile(e),a=await uD(t,{width:n,height:r,blurhash:i});return{url:a.url,id:a.id}}var fD=new Map,pD=new Map;function mD(e,t,n){if(e.isDestroyed)return;let{doc:r}=e.state;r.descendants((r,i)=>{r.type.name===`image`&&r.attrs.src===t&&e.chain().command(({tr:e})=>(e.setNodeMarkup(i,void 0,{...r.attrs,src:n}),!0)).run()})}function hD(e,t){if(e.isDestroyed)return;let{doc:n}=e.state;n.descendants((n,r)=>{n.type.name===`image`&&n.attrs.src===t&&e.chain().command(({tr:e})=>(e.delete(r,r+n.nodeSize),!0)).run()})}function gD(e,t,n){n?mD(e,t,n):t.startsWith(`blob:`)&&hD(e,t)}async function _D(e,t,n=dD){let r=URL.createObjectURL(t);e.chain().focus().setImage({src:r}).run();let i=n(t).then(e=>e.url);fD.set(r,i);try{gD(e,r,await i)}catch{gD(e,r,null)}finally{fD.delete(r)&&URL.revokeObjectURL(r)}}async function vD(e,n){let r=await fetch(t(`/api/uploads/sideload`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e,alt:n})});if(!r.ok)throw Error(`Sideload failed: HTTP ${r.status}`);return await r.json()}async function yD(e,t,n){let r=n();fD.set(t,r);try{gD(e,t,await r)}catch{gD(e,t,null)}finally{fD.delete(t)}}function bD(e){let t=[],{doc:n}=e.state;return n.descendants(n=>{if(n.type.name!==`image`)return;let r=n.attrs.src;if(typeof r!=`string`)return;let i=fD.get(r)??pD.get(r);if(!i)return;fD.delete(r),pD.set(r,i);let a=r.startsWith(`blob:`),o=i.then(t=>mD(e,r,t),()=>gD(e,r,null)).finally(()=>{pD.delete(r),a&&URL.revokeObjectURL(r)});t.push(o)}),t}async function xD(e){if(!e)return e;let t=new Map;if(CD(e,t),t.size===0)return e;let n=new Map;return await Promise.allSettled(Array.from(t.entries()).map(async([e,t])=>{try{n.set(e,await t)}catch{n.set(e,null)}})),wD(e,n)}function SD(e){if(!e)return!1;let t=new Map;return CD(e,t),t.size>0}function CD(e,t){if(e.type===`image`&&typeof e.attrs?.src==`string`){let n=e.attrs.src,r=fD.get(n)??pD.get(n);r&&t.set(n,r)}if(e.content)for(let n of e.content)CD(n,t)}function wD(e,t){if(e.type===`image`&&typeof e.attrs?.src==`string`&&t.has(e.attrs.src)){let n=e.attrs.src,r=t.get(n);return r?{...e,attrs:{...e.attrs,src:r}}:n.startsWith(`blob:`)?{type:`__removed__`}:e}if(!e.content)return e;let n=e.content.map(e=>wD(e,t)).filter(e=>e.type!==`__removed__`);return n===e.content?e:{...e,content:n}}var TD=new P(`pasteMedia`);function ED(e){return`${e.name}:${e.type}:${e.size}:${e.lastModified}`}function DD(e){if(!e)return[];let t=Array.from(e.items??[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e!==null),n=t.length>0?t:Array.from(e.files??[]),r=new Set;return n.filter(e=>{let t=ED(e);return!r.has(t)&&(r.add(t),!0)})}var OD=H.create({name:`pasteMedia`,addOptions(){return{shouldInsertInline:void 0,onPasteFiles:void 0}},addProseMirrorPlugins(){let e=this,t=t=>{let n=t.filter(t=>e.options.shouldInsertInline?.(t)===!0),r=t.filter(e=>!n.includes(e));if(n.length===0&&(r.length===0||e.options.onPasteFiles===void 0))return!1;for(let t of n){let n=e.options.uploadInlineImage;if(n){n(t);continue}_D(e.editor,t)}return r.length>0&&e.options.onPasteFiles!==void 0&&e.options.onPasteFiles(r),!0};return[new N({key:TD,props:{handlePaste(e,n){let r=DD(n.clipboardData);return r.length===0||!t(r)?!1:(n.preventDefault(),!0)},handleDrop(e,n){let r=DD(n.dataTransfer);return r.length===0||!t(r)?!1:(n.preventDefault(),!0)}}})]}}),kD=new P(`linkToolbar`),AD=`hidden`,jD=!1;function MD(){return AD===`input`&&jD}var ND=`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 10 4 15 9 20"/><path d="M20 4v7a4 4 0 0 1-4 4H4"/></svg>`;function PD(e){let{selection:t}=e;if(!t.empty)return null;let n=t.$from,r=e.schema.marks.link;if(!r)return null;let i=n.marks().find(e=>e.type===r);if(!i)return null;let a=n.parent,o=n.start(),s=0,c=0,l=!1,u=0;for(let e=0;e<a.childCount;e++){let t=a.child(e),n=o+u,d=n+t.nodeSize;if(t.marks.some(e=>e.type===r&&e.attrs.href===i.attrs.href))l||=(s=n,!0),c=d;else if(l)break;u+=t.nodeSize}return l?{from:s,to:c,href:i.attrs.href}:null}var FD=H.create({name:`linkToolbar`,addProseMirrorPlugins(){let e=this.editor,t=null,n=null,r=null,i=0,a=0,o=!1,s=!1,c=null;function l(){t=document.createElement(`div`),t.className=`tiptap-link-input`,t.dataset.editorFloatingUi=`true`,t.style.display=`none`;let i=document.createElement(`div`);i.className=`tiptap-link-input-fields`,r=document.createElement(`input`),r.type=`text`,r.className=`tiptap-link-input-text`,r.placeholder=`Link text`,n=document.createElement(`input`),n.type=`url`,n.className=`tiptap-link-input-field`,n.placeholder=`https:// (empty to unlink)`,i.appendChild(r),i.appendChild(n);let a=document.createElement(`button`);a.type=`button`,a.className=`tiptap-link-input-confirm`,a.innerHTML=ND,a.title=`Apply link`,t.appendChild(i),t.appendChild(a);let o=t=>{t.key===`Enter`?(t.preventDefault(),t.stopPropagation(),m()):t.key===`Escape`&&(t.preventDefault(),t.stopPropagation(),s=!0,f(),e.commands.focus())};r.addEventListener(`keydown`,o),n.addEventListener(`keydown`,o);let c=()=>{jD=!0},l=()=>{requestAnimationFrame(()=>{let e=document.activeElement;(!t||!t.contains(e))&&(jD=!1)})};r.addEventListener(`focus`,c),n.addEventListener(`focus`,c),r.addEventListener(`blur`,l),n.addEventListener(`blur`,l),a.addEventListener(`mousedown`,e=>{e.preventDefault(),m()}),t.addEventListener(`mousedown`,e=>{e.stopPropagation()})}function u(e,t,n,r){e.style.display=`flex`;let i=pT(t.dom.closest(`dialog`)),a=bT(t,n,r,_T(t.dom,i)),o=e.getBoundingClientRect(),s=mT({anchorRect:a,containerRect:i,floatingWidth:o.width,floatingHeight:o.height,preferredPlacement:`top`,fallbackPlacement:`bottom`,align:`center`});e.style.left=`${s.left}px`,e.style.top=`${s.top}px`,e.dataset.placement=s.placement,e.style.setProperty(`--floating-arrow-x`,`${xT({anchorRect:a,containerRect:i,floatingLeft:s.left,floatingWidth:o.width})}px`)}function d(e,o){if(t&&n&&r){if(o.from!==void 0&&o.to!==void 0?(i=o.from,a=o.to):(i=e.state.selection.from,a=e.state.selection.to),AD=`input`,n.value=o.href,r.value=o.text??e.state.doc.textBetween(i,a,``),u(t,e,i,a),o.focus){let e=r.value.length>0?n:r;requestAnimationFrame(()=>{e.focus(),e.select()})}p(),c=e=>{t&&!t.contains(e.target)&&(s=!0,f())},setTimeout(()=>{c&&document.addEventListener(`mousedown`,c,!0)},0)}}function f(){t&&(t.style.display=`none`),AD=`hidden`,jD=!1,p()}function p(){c&&=(document.removeEventListener(`mousedown`,c,!0),null)}function m(){if(!n||!r)return;let t=n.value.trim(),s=e.state.doc.textBetween(i,a,``),c=r.value,l=c.length>0?c:t;if(f(),!t){e.chain().focus().setTextSelection({from:i,to:a}).unsetLink().setTextSelection(a).run(),o=!0;return}let u=l!==s,d=i+l.length;u?e.chain().focus().command(({tr:e})=>(e.insertText(l,i,a),!0)).setTextSelection({from:i,to:d}).setLink({href:t}).setTextSelection(d).run():e.chain().focus().setTextSelection({from:i,to:a}).setLink({href:t}).setTextSelection(a).run(),o=!0}function h(e,t){if(t.button!==0)return;let n=t.target?.closest(`a`);if(!n||!e.dom.contains(n))return;let r=e.state.schema.marks.link;if(!r||!e.state.selection.empty)return;let i=e.state.selection.from,a=t=>e.state.doc.resolve(t).marks().some(e=>e.type===r),o=i;if(!a(i)){try{o=e.posAtDOM(n,0)+1}catch{return}if(o<0||o>e.state.doc.content.size||!a(o))return}s=!1,e.dispatch(e.state.tr.setSelection(j.create(e.state.doc,o)))}return[new N({key:kD,props:{handleDOMEvents:{click:(e,t)=>(h(e,t),!1)}},view(e){l();let n=e.dom.closest(`dialog`);t&&(n??document.body).appendChild(t);let r=()=>{s=!1,o=!0,d(e,{href:``,focus:!0})};e.dom.addEventListener(`tiptap:open-link-input`,r);let c=e=>{e.key===`Escape`&&AD===`input`&&(e.preventDefault(),e.stopPropagation(),s=!0,f())};return e.dom.addEventListener(`keydown`,c),{update(e){if(o){o=!1;return}let n=PD(e.state);if(AD===`input`&&jD){t&&u(t,e,i,a);return}if(n){if(s)return;d(e,{href:n.href,from:n.from,to:n.to,focus:!1})}else s=!1,AD===`input`&&f()},destroy(){e.dom.removeEventListener(`tiptap:open-link-input`,r),e.dom.removeEventListener(`keydown`,c),p(),t?.remove(),t=null,AD=`hidden`,jD=!1}}}})]}}),ID=new P(`bubbleMenu`),LD={bold:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M6 12h9a4 4 0 0 1 0 8H6V4h8a4 4 0 0 1 0 8"/></svg>`,italic:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="19" y1="4" x2="10" y2="4"/><line x1="14" y1="20" x2="5" y2="20"/><line x1="15" y1="4" x2="9" y2="20"/></svg>`,h1:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12h8"/><path d="M4 18V6"/><path d="M12 18V6"/><path d="M17 12l3-2v10"/></svg>`,h2:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12h8"/><path d="M4 18V6"/><path d="M12 18V6"/><path d="M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"/></svg>`,blockquote:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1z"/><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z"/></svg>`,link:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,clear:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m16 22-1-4"/><path d="M19 14a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2h-3a1 1 0 0 1-1-1V4a2 2 0 0 0-4 0v5a1 1 0 0 1-1 1H6a2 2 0 0 0-2 2v1a1 1 0 0 0 1 1"/><path d="M19 14H5l-1.973 6.767A1 1 0 0 0 4 22h16a1 1 0 0 0 .973-1.233z"/><path d="m8 22 1-4"/></svg>`};function RD(e,t){let{to:n,empty:r}=e.state.selection;if(r){e.chain().focus().toggleMark(t).run();return}let i=e.schema.marks[t];e.chain().focus().toggleMark(t).setTextSelection(n).command(({tr:e})=>(i&&e.removeStoredMark(i),!0)).run()}function zD(e){let{doc:t,selection:n}=e.state,{from:r,to:i}=n,a=[],o=[];t.nodesBetween(r,i,(t,n)=>{t.type===e.schema.nodes.heading&&a.push(n),t.type===e.schema.nodes.blockquote&&o.push({from:Math.max(r,n+1),to:Math.min(i,n+t.nodeSize-1)})}),e.chain().focus().unsetAllMarks().command(({tr:t})=>{let n=e.schema.nodes.heading,r=e.schema.nodes.paragraph;if(n&&r)for(let e of a){let i=t.mapping.map(e);if(t.doc.nodeAt(i)?.type!==n)continue;let a=t.doc.resolve(i),o=a.index();a.parent.canReplaceWith(o,o+1,r)&&t.setNodeMarkup(i,r)}let s=e.schema.nodes.blockquote;if(s)for(let e=o.length-1;e>=0;--e){let n=o[e];if(!n)continue;let r=t.mapping.map(n.from,1),i=t.mapping.map(n.to,-1);if(r>i)continue;let a=t.doc.resolve(r).blockRange(t.doc.resolve(i),e=>e.type===s);if(!a)continue;let c=fn(a);c!==null&&t.lift(a,c)}let c=t.mapping.map(i,-1);return t.setSelection(j.create(t.doc,c)),!0}).run()}function BD(e,t){return t===`compose`?[{key:`bold`,icon:LD.bold,title:`Bold`,action:()=>RD(e,`bold`),isActive:()=>e.isActive(`bold`)},{key:`italic`,icon:LD.italic,title:`Italic`,action:()=>RD(e,`italic`),isActive:()=>e.isActive(`italic`)},{key:`sep`,icon:``,title:``,action:()=>{},isActive:()=>!1},{key:`link`,icon:LD.link,title:`Link`,action:t=>{e.isActive(`link`)?e.chain().focus().unsetLink().run():t.dom.dispatchEvent(new CustomEvent(`tiptap:open-link-input`))},isActive:()=>e.isActive(`link`)},{key:`clear`,icon:LD.clear,title:`Clear formatting`,action:()=>zD(e),isActive:()=>!1}]:[{key:`bold`,icon:LD.bold,title:`Bold`,action:()=>RD(e,`bold`),isActive:()=>e.isActive(`bold`)},{key:`italic`,icon:LD.italic,title:`Italic`,action:()=>RD(e,`italic`),isActive:()=>e.isActive(`italic`)},{key:`h1`,icon:LD.h1,title:`Heading 1`,action:()=>e.chain().focus().toggleHeading({level:1}).run(),isActive:()=>e.isActive(`heading`,{level:1})},{key:`h2`,icon:LD.h2,title:`Heading 2`,action:()=>e.chain().focus().toggleHeading({level:2}).run(),isActive:()=>e.isActive(`heading`,{level:2})},{key:`sep`,icon:``,title:``,action:()=>{},isActive:()=>!1},{key:`blockquote`,icon:LD.blockquote,title:`Quote`,action:()=>e.chain().focus().toggleBlockquote().run(),isActive:()=>e.isActive(`blockquote`)},{key:`link`,icon:LD.link,title:`Link`,action:t=>{e.isActive(`link`)?e.chain().focus().unsetLink().run():t.dom.dispatchEvent(new CustomEvent(`tiptap:open-link-input`))},isActive:()=>e.isActive(`link`)}]}var VD=H.create({name:`bubbleMenu`,addOptions(){return{toolbarMode:`default`}},addProseMirrorPlugins(){let e=this.editor,t=this.options.toolbarMode,n=null,r=[],i=new Map;function a(){n=document.createElement(`div`),n.className=`tiptap-bubble-menu`,n.dataset.editorFloatingUi=`true`,n.style.position=`fixed`,n.style.display=`none`,r=BD(e,t);for(let t of r){if(t.key===`sep`){let e=document.createElement(`span`);e.className=`tiptap-bubble-sep`,n.appendChild(e);continue}let r=document.createElement(`button`);r.type=`button`,r.innerHTML=t.icon,r.title=t.title,r.className=`tiptap-bubble-btn`,r.addEventListener(`mousedown`,n=>{n.preventDefault(),t.action(e.view)}),n.appendChild(r),i.set(t.key,r)}}function o(e){if(!n)return;n.style.display=`flex`;let{from:t,to:r}=e.state.selection,i=pT(e.dom.closest(`dialog`)),a=bT(e,t,r,_T(e.dom,i)),o=n.getBoundingClientRect(),s=mT({anchorRect:a,containerRect:i,floatingWidth:o.width,floatingHeight:o.height,preferredPlacement:`top`,fallbackPlacement:`bottom`,align:`center`});n.style.left=`${s.left}px`,n.style.top=`${s.top}px`,n.dataset.placement=s.placement,n.style.setProperty(`--floating-arrow-x`,`${xT({anchorRect:a,containerRect:i,floatingLeft:s.left,floatingWidth:o.width})}px`),c()}function s(){n&&(n.style.display=`none`)}function c(){for(let t of r){if(t.key===`sep`)continue;let n=i.get(t.key);n&&n.classList.toggle(`is-active`,t.isActive(e.view))}}function l(e){let{state:t}=e,{selection:n}=t;return n.empty||MD()?!1:n instanceof ar?t.doc.textBetween(n.from,n.to,` `).trim()!==``:n instanceof j&&n.$from.parent.isTextblock}return[new N({key:ID,view(e){a();let t=e.dom.closest(`dialog`)??document.body;n&&t.appendChild(n);function r(t){let r=t.target;if(!r||e.dom.contains(r)||r.closest(`[data-editor-floating-ui]`)||n?.contains(r))return;let{state:i}=e,a=i.selection.from;e.dispatch(i.tr.setSelection(A.near(i.doc.resolve(a)))),e.dom.blur()}return t.addEventListener(`mousedown`,r),{update(e){l(e)?o(e):s()},destroy(){t.removeEventListener(`mousedown`,r),n?.remove(),n=null}}}})]}}),HD=new Set([`bold`,`italic`,`strike`,`code`,`underline`]);function UD(e){return e.filter(e=>HD.has(e.type.name))}var WD=H.create({name:`exitableMarks`,addKeyboardShortcuts(){return{ArrowRight:({editor:e})=>{let{selection:t}=e.state,{$from:n}=t;if(!t.empty||n.pos!==n.end())return!1;let r=UD(n.marks());if(!r.length)return!1;let{tr:i}=e.state;for(let e of r)i.removeStoredMark(e);return e.view.dispatch(i),!0},Enter:({editor:e})=>{let{selection:t}=e.state,{$from:n}=t;return!t.empty||n.parent.textContent.length>0||!UD(e.state.storedMarks??n.marks()).length||requestAnimationFrame(()=>{let{tr:t}=e.state;t.setStoredMarks([]),e.view.dispatch(t)}),!1}}}}),GD=` `,KD=H.create({name:`codeBlockIndent`,addKeyboardShortcuts(){return{Tab:({editor:e})=>{if(e.isActive(`codeBlock`)){let{state:t,dispatch:n}=e.view,{selection:r}=t,{from:i,to:a}=r,o=t.doc.resolve(i),s=o.parent;if(s.type.name!==`codeBlock`)return!1;let c=o.start(),l=s.textContent;if(i===a)return n(t.tr.insertText(GD,i)),!0;let u=i-c,d=a-c,f=[],p=l.lastIndexOf(`
|
|
251
|
+
${BE(RE())}`,$.querySelectorAll(`.tiptap-slash-item`).forEach(e=>{e.addEventListener(`mousedown`,n=>{n.preventDefault(),t(parseInt(e.dataset.index??`0`,10))}),e.addEventListener(`mouseenter`,()=>{OE=parseInt(e.dataset.index??`0`,10),LE()})});let r=PE();r&&(r.scrollTop=0)}function UE(){NE&&=(document.removeEventListener(`mousedown`,NE,!0),null),$?.remove(),$=null,OE=0,kE=[],AE=null,jE=null,ME=null}function WE(e,t){if(!$)return;$.style.maxHeight=``;let n=WT(null),r=t?WT(t):n,i=GT({anchorRect:{left:e.left,right:e.left,top:e.top,bottom:e.bottom},containerRect:n,floatingWidth:$.offsetWidth,floatingHeight:$.offsetHeight,preferredPlacement:`bottom`,fallbackPlacement:`top`,align:`start`,gap:6});$.style.left=`${i.left-r.left}px`,$.style.top=`${i.top-r.top}px`,$.style.maxHeight=i.maxHeight===null?``:`${i.maxHeight}px`}function GE(){NE=e=>{if($&&!$.contains(e.target)&&jE&&ME){let{state:e,view:t}=jE;t.dispatch(e.tr.delete(ME.from,ME.to))}},document.addEventListener(`mousedown`,NE,!0)}var KE=new P(`jantSlashTyping`);function qE(){return new N({key:KE,state:{init:()=>({docChanged:!1}),apply:e=>({docChanged:e.docChanged})}})}function JE({state:e,range:t}){let n=e.doc.resolve(t.to),r=n.parent,i=t.to-n.start();if(i>=r.content.size)return!0;let a=r.textBetween(i,i+1,` `,` `);return!a||/\s/.test(a)}function YE({state:e,range:t,isActive:n}){return JE({state:e,range:t})?n?!0:KE.getState(e)?.docChanged??!1:!1}var XE=H.create({name:`slashCommands`,addOptions(){return{suggestion:{char:`/`,startOfLine:!1,allow:YE,items:({query:e,editor:t})=>{let n=DE(t),r=u(e);return r?n.map((e,t)=>({item:e,index:t,rank:s([e.label,e.description,...e.keywords],r)})).filter(e=>e.rank!==null).sort((e,t)=>e.rank-t.rank||e.index-t.index).map(e=>e.item):n},render:()=>{function e(e){let t=e.options.element;return t instanceof globalThis.Element?t:null}return{onStart:t=>{$=FE(),OE=0,AE=t.command,jE=t.editor,ME=t.range,HE(t.items,e=>t.command({index:e})),document.dispatchEvent(new CustomEvent(`jant:slash-command-discovered`,{bubbles:!0}));let n=e(t.editor)?.closest(`dialog`)??null;(n??document.body).appendChild($);let r=t.clientRect?.();r&&WE(r,n),GE()},onUpdate:t=>{AE=t.command,ME=t.range,HE(t.items,e=>t.command({index:e}));let n=t.clientRect?.();n&&WE(n,e(t.editor)?.closest(`dialog`)??null)},onKeyDown:e=>{let{event:t,view:n,range:r}=e;return t.key===`ArrowDown`?(t.preventDefault(),kE.length===0||(OE=(OE+1)%kE.length,LE(),!0)):t.key===`ArrowUp`?(t.preventDefault(),kE.length===0||(OE=(OE-1+kE.length)%kE.length,LE(),!0)):t.key===`Enter`?(t.preventDefault(),kE.length===0||AE?.({index:OE}),!0):t.key===`Escape`&&(t.stopPropagation(),t.preventDefault(),n.dispatch(n.state.tr.delete(r.from,r.to)),!0)},onExit:()=>{UE()}}},command:({editor:e,range:t,props:n})=>{let r=kE[n.index];r&&r.command(e,t)}}}},addProseMirrorPlugins(){return[qE(),VT({editor:this.editor,...this.options.suggestion})]}}),ZE=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~`.split(``),QE=(e,t)=>{var n=``;for(let r=1;r<=t;r++){let i=Math.floor(e)/83**(t-r)%83;n+=ZE[Math.floor(i)]}return n},$E=e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4},eD=e=>{let t=Math.max(0,Math.min(1,e));return Math.trunc(t<=.0031308?t*12.92*255+.5:(1.055*t**.4166666666666667-.055)*255+.5)},tD=e=>e<0?-1:1,nD=(e,t)=>tD(e)*Math.abs(e)**+t,rD=class extends Error{constructor(e){super(e),this.name=`ValidationError`,this.message=e}},iD=4,aD=(e,t,n,r)=>{let i=0,a=0,o=0,s=t*iD;for(let c=0;c<t;c++){let t=iD*c;for(let l=0;l<n;l++){let n=t+l*s,u=r(c,l);i+=u*$E(e[n]),a+=u*$E(e[n+1]),o+=u*$E(e[n+2])}}let c=1/(t*n);return[i*c,a*c,o*c]},oD=e=>{let t=eD(e[0]),n=eD(e[1]),r=eD(e[2]);return(t<<16)+(n<<8)+r},sD=(e,t)=>{let n=Math.floor(Math.max(0,Math.min(18,Math.floor(nD(e[0]/t,.5)*9+9.5)))),r=Math.floor(Math.max(0,Math.min(18,Math.floor(nD(e[1]/t,.5)*9+9.5)))),i=Math.floor(Math.max(0,Math.min(18,Math.floor(nD(e[2]/t,.5)*9+9.5))));return n*19*19+r*19+i},cD=(e,t,n,r,i)=>{if(r<1||r>9||i<1||i>9)throw new rD(`BlurHash must have between 1 and 9 components`);if(t*n*4!==e.length)throw new rD(`Width and height must match the pixels array`);let a=[];for(let o=0;o<i;o++)for(let i=0;i<r;i++){let r=i==0&&o==0?1:2,s=aD(e,t,n,(e,a)=>r*Math.cos(Math.PI*i*e/t)*Math.cos(Math.PI*o*a/n));a.push(s)}let o=a[0],s=a.slice(1),c=``,l=r-1+(i-1)*9;c+=QE(l,1);let u;if(s.length>0){let e=Math.max(...s.map(e=>Math.max(...e))),t=Math.floor(Math.max(0,Math.min(82,Math.floor(e*166-.5))));u=(t+1)/166,c+=QE(t,1)}else u=1,c+=QE(0,1);return c+=QE(oD(o),4),s.forEach(e=>{c+=QE(sD(e,u),2)}),c},lD={maxShortSide:1920,maxLongSide:8192,quality:.85,mimeType:`image/webp`};function uD(e,t,n){if(Math.max(e,t)>n.maxLongSide)return{passthrough:!0,width:e,height:t};let r=Math.min(e,t);if(r<=n.maxShortSide)return{passthrough:!1,width:e,height:t};let i=n.maxShortSide/r;return{passthrough:!1,width:Math.round(e*i),height:Math.round(t*i)}}function dD(e,t){return t===e?e:`image/jpeg`}function fD(e,t){let n=Math.min(32/e,32/t,1);return{width:Math.max(Math.round(e*n),1),height:Math.max(Math.round(t*n),1)}}var pD="var e=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~`.split(``),t=(t,n)=>{var r=``;for(let i=1;i<=n;i++){let a=Math.floor(t)/83**(n-i)%83;r+=e[Math.floor(a)]}return r},n=e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4},r=e=>{let t=Math.max(0,Math.min(1,e));return Math.trunc(t<=.0031308?t*12.92*255+.5:(1.055*t**.4166666666666667-.055)*255+.5)},i=e=>e<0?-1:1,a=(e,t)=>i(e)*Math.abs(e)**+t,o=class extends Error{constructor(e){super(e),this.name=`ValidationError`,this.message=e}},s=4,c=(e,t,r,i)=>{let a=0,o=0,c=0,l=t*s;for(let u=0;u<t;u++){let t=s*u;for(let s=0;s<r;s++){let r=t+s*l,d=i(u,s);a+=d*n(e[r]),o+=d*n(e[r+1]),c+=d*n(e[r+2])}}let u=1/(t*r);return[a*u,o*u,c*u]},l=e=>{let t=r(e[0]),n=r(e[1]),i=r(e[2]);return(t<<16)+(n<<8)+i},u=(e,t)=>{let n=Math.floor(Math.max(0,Math.min(18,Math.floor(a(e[0]/t,.5)*9+9.5)))),r=Math.floor(Math.max(0,Math.min(18,Math.floor(a(e[1]/t,.5)*9+9.5)))),i=Math.floor(Math.max(0,Math.min(18,Math.floor(a(e[2]/t,.5)*9+9.5))));return n*19*19+r*19+i},d=(e,n,r,i,a)=>{if(i<1||i>9||a<1||a>9)throw new o(`BlurHash must have between 1 and 9 components`);if(n*r*4!==e.length)throw new o(`Width and height must match the pixels array`);let s=[];for(let t=0;t<a;t++)for(let a=0;a<i;a++){let i=a==0&&t==0?1:2,o=c(e,n,r,(e,o)=>i*Math.cos(Math.PI*a*e/n)*Math.cos(Math.PI*t*o/r));s.push(o)}let d=s[0],f=s.slice(1),p=``,m=i-1+(a-1)*9;p+=t(m,1);let h;if(f.length>0){let e=Math.max(...f.map(e=>Math.max(...e))),n=Math.floor(Math.max(0,Math.min(82,Math.floor(e*166-.5))));h=(n+1)/166,p+=t(n,1)}else h=1,p+=t(0,1);return p+=t(l(d),4),f.forEach(e=>{p+=t(u(e,h),2)}),p};function f(e,t,n){if(Math.max(e,t)>n.maxLongSide)return{passthrough:!0,width:e,height:t};let r=Math.min(e,t);if(r<=n.maxShortSide)return{passthrough:!1,width:e,height:t};let i=n.maxShortSide/r;return{passthrough:!1,width:Math.round(e*i),height:Math.round(t*i)}}function p(e,t){return t===e?e:`image/jpeg`}function m(e,t){let n=Math.min(32/e,32/t,1);return{width:Math.max(Math.round(e*n),1),height:Math.max(Math.round(t*n),1)}}const h=self,g=new Map;function _(e,t){let n=g.get(e);if(!n){let{canvas:r}=v(null,1,1);n=r.convertToBlob({type:e,quality:t}).then(t=>p(e,t.type)),g.set(e,n)}return n}function v(e,t,n){let r=new OffscreenCanvas(t,n),i=r.getContext(`2d`);if(!i)throw Error(`Failed to get canvas context`);return e&&i.drawImage(e,0,0,t,n),{canvas:r,ctx:i}}function y(e){try{let{width:t,height:n}=m(e.width,e.height),{ctx:r}=v(e,t,n);return d(r.getImageData(0,0,t,n).data,t,n,4,3)}catch{return}}async function b(e,t){let n=await createImageBitmap(e,{imageOrientation:`from-image`});try{let r=f(n.width,n.height,t),i=y(n);if(r.passthrough)return{blob:e,width:r.width,height:r.height,processed:!1,blurhash:i};let{canvas:a}=v(n,r.width,r.height),o=await _(t.mimeType,t.quality);return{blob:await a.convertToBlob({type:o,quality:t.quality}),width:r.width,height:r.height,processed:!0,blurhash:i}}finally{n.close()}}h.addEventListener(`message`,async e=>{let{id:t,file:n,options:r}=e.data;try{h.postMessage({id:t,ok:!0,...await b(n,r)})}catch(e){h.postMessage({id:t,ok:!1,error:e instanceof Error?e.message:String(e)})}});",mD=typeof self<`u`&&self.Blob&&new Blob([`URL.revokeObjectURL(import.meta.url);`,pD],{type:`text/javascript;charset=utf-8`});function hD(e){let t;try{if(t=mD&&(self.URL||self.webkitURL).createObjectURL(mD),!t)throw``;let n=new Worker(t,{type:`module`,name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(pD),{type:`module`,name:e?.name})}}function gD(){return typeof Worker==`function`&&typeof OffscreenCanvas==`function`&&typeof createImageBitmap==`function`}function _D(){return new hD({name:`jant-image`})}var vD=null,yD=1,bD=new Map;function xD(){if(vD)return vD;let e=_D();return e.addEventListener(`message`,e=>{let t=e.data,n=bD.get(t.id);n&&(bD.delete(t.id),t.ok?n.resolve({blob:t.blob,width:t.width,height:t.height,processed:t.processed,blurhash:t.blurhash}):n.reject(Error(t.error)))}),e.addEventListener(`error`,t=>{if(vD!==e)return;vD=null,e.terminate();let n=[...bD.values()];bD.clear();let r=Error(t.message||`Image worker failed`);for(let e of n)e.reject(r)}),vD=e,e}function SD(e,t){let n=xD();return new Promise((r,i)=>{let a=yD++;bD.set(a,{resolve:r,reject:i});let o={id:a,file:e,options:t};n.postMessage(o)})}function CD(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>{URL.revokeObjectURL(r.src),t(r)},r.onerror=()=>n(Error(`Failed to load image`)),r.src=URL.createObjectURL(e)})}function wD(e,t){let n=document.createElement(`canvas`);n.width=e,n.height=t;let r=n.getContext(`2d`);if(!r)throw Error(`Failed to get canvas context`);return{canvas:n,ctx:r}}function TD(e,t,n){return new Promise((r,i)=>{e.toBlob(e=>e?r(e):i(Error(`Failed to create blob`)),t,n)})}var ED=new Map;function DD(e,t){let n=ED.get(e);return n||(n=TD(wD(1,1).canvas,e,t).then(t=>dD(e,t.type)),ED.set(e,n)),n}function OD(e){try{let{width:t,height:n}=fD(e.width,e.height),{ctx:r}=wD(t,n);return r.drawImage(e,0,0,t,n),cD(r.getImageData(0,0,t,n).data,t,n,4,3)}catch{return}}async function kD(e,t){let n=await CD(e),r=uD(n.width,n.height,t),i=OD(n);if(r.passthrough)return{blob:e,width:r.width,height:r.height,processed:!1,blurhash:i};let{canvas:a,ctx:o}=wD(r.width,r.height);return o.drawImage(n,0,0,r.width,r.height),{blob:await TD(a,await DD(t.mimeType,t.quality),t.quality),width:r.width,height:r.height,processed:!0,blurhash:i}}async function AD(e,t={}){let n={...lD,...t};if(gD())try{return await SD(e,n)}catch{}return kD(e,n)}async function jD(e,t={}){let n=await AD(e,t);if(!n.processed)return{file:e,width:n.width,height:n.height,blurhash:n.blurhash};let r={"image/webp":`webp`,"image/jpeg":`jpg`,"image/png":`png`}[n.blob.type]??`png`,i=`${e.name.replace(/\.[^.]+$/,``)}.${r}`;return{file:new File([n.blob],i,{type:n.blob.type}),width:n.width,height:n.height,blurhash:n.blurhash}}var MD={process:AD,processToFile:jD};function ND(e){if(!c(e))return null;let t=l(e,`kind`),n=l(e,`method`),r=l(e,`url`);if(!t||n!==`PUT`||!r)return null;if(t===`relay`)return{kind:t,method:`PUT`,url:r};if(t===`multipartRelay`){let n=i(e,`partSize`);return n?{kind:t,method:`PUT`,url:r,partSize:n}:null}if(t===`put`){let n=i(e,`expiresAt`),a=e.headers;if(!n||!c(a))return null;let o={};for(let[e,t]of Object.entries(a))typeof t==`string`&&(o[e]=t);return{kind:t,method:`PUT`,url:r,headers:o,expiresAt:n}}return null}function PD(e,t,n,r){return new Promise((i,a)=>{let o=new globalThis.XMLHttpRequest;o.open(`PUT`,e);for(let[e,t]of Object.entries(n))o.setRequestHeader(e,t);o.upload.addEventListener(`progress`,e=>{e.lengthComputable&&r&&r(e.loaded/e.total)}),o.addEventListener(`load`,()=>{i({status:o.status,ok:o.status>=200&&o.status<300,text:o.responseText})}),o.addEventListener(`error`,()=>a(Error(`Network error`))),o.addEventListener(`abort`,()=>a(Error(`Upload aborted`))),o.send(t)})}function FD(e){try{let t=JSON.parse(e);return c(t)?t:null}catch{return null}}async function ID(e){let n=await fetch(t(`/api/uploads/init`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({filename:e.name,contentType:e.type||`application/octet-stream`,size:e.size})});if(!n.ok)throw Error(await o(n,`Failed to start upload`));let i=await r(n),a=l(i,`id`),s=ND(i.transport);if(!a||!s)throw Error(`Failed to start upload`);return{id:a,transport:s}}async function LD(e,n){let r=await fetch(t(`/api/uploads/${e}/poster`),{method:`PUT`,headers:{"Content-Type":n.type||`image/webp`},body:n});if(!r.ok)throw Error(await o(r,`Failed to upload poster`))}async function RD(e){await fetch(t(`/api/uploads/${e}/abort`),{method:`POST`}).catch(()=>{})}async function zD(e,n){let a=await fetch(t(`/api/uploads/${e}/complete`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!a.ok)throw Error(await o(a,`Failed to complete upload`));let s=await r(a),c=l(s,`id`),u=l(s,`filename`),d=l(s,`url`),f=l(s,`mimeType`),p=i(s,`size`);if(!c||!u||!d||!f||p===void 0)throw Error(`Failed to complete upload`);return{id:c,filename:u,url:d,mimeType:f,size:p}}async function BD(e,n,r,o){let s=Math.ceil(r.size/n.partSize),c=[],u=0;for(let e=0;e<s;e+=1){let s=e*n.partSize,d=Math.min(s+n.partSize,r.size),f=e+1,p=r.slice(s,d),m=d-s,h=await PD(t(`${n.url}?partNumber=${f}`),p,{},e=>{o?.((u+m*e)/r.size)});if(!h.ok)throw Error(a(h.text,`Failed to upload part ${f}`));let g=FD(h.text),_=g?i(g,`partNumber`):null,v=g?l(g,`etag`):null;if(!_||!v)throw Error(`Failed to upload part ${f}`);c.push({partNumber:_,etag:v}),u+=m,o?.(u/r.size)}return c}async function VD(e,n,r){let{id:i,transport:o}=await ID(e);try{if(o.kind===`put`){let t=await PD(o.url,e,o.headers,r);if(!t.ok)throw Error(a(t.text,`Upload failed`));r?.(1)}else if(o.kind===`relay`){let n=await PD(t(o.url),e,{"Content-Type":e.type},r);if(!n.ok)throw Error(a(n.text,`Upload failed`));r?.(1)}let s=o.kind===`multipartRelay`?await BD(i,o,e,r):void 0;return n.poster&&await LD(i,n.poster),zD(i,{...n,parts:s})}catch(e){throw await RD(i),e}}async function HD(e){let{file:t,width:n,height:r,blurhash:i}=await MD.processToFile(e),a=await VD(t,{width:n,height:r,blurhash:i});return{url:a.url,id:a.id}}var UD=new Map,WD=new Map;function GD(e,t,n){if(e.isDestroyed)return;let{doc:r}=e.state;r.descendants((r,i)=>{r.type.name===`image`&&r.attrs.src===t&&e.chain().command(({tr:e})=>(e.setNodeMarkup(i,void 0,{...r.attrs,src:n}),!0)).run()})}function KD(e,t){if(e.isDestroyed)return;let{doc:n}=e.state;n.descendants((n,r)=>{n.type.name===`image`&&n.attrs.src===t&&e.chain().command(({tr:e})=>(e.delete(r,r+n.nodeSize),!0)).run()})}function qD(e,t,n){n?GD(e,t,n):t.startsWith(`blob:`)&&KD(e,t)}async function JD(e,t,n=HD){let r=URL.createObjectURL(t);e.chain().focus().setImage({src:r}).run();let i=n(t).then(e=>e.url);UD.set(r,i);try{qD(e,r,await i)}catch{qD(e,r,null)}finally{UD.delete(r)&&URL.revokeObjectURL(r)}}async function YD(e,n){let r=await fetch(t(`/api/uploads/sideload`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e,alt:n})});if(!r.ok)throw Error(`Sideload failed: HTTP ${r.status}`);return await r.json()}async function XD(e,t,n){let r=n();UD.set(t,r);try{qD(e,t,await r)}catch{qD(e,t,null)}finally{UD.delete(t)}}function ZD(e){let t=[],{doc:n}=e.state;return n.descendants(n=>{if(n.type.name!==`image`)return;let r=n.attrs.src;if(typeof r!=`string`)return;let i=UD.get(r)??WD.get(r);if(!i)return;UD.delete(r),WD.set(r,i);let a=r.startsWith(`blob:`),o=i.then(t=>GD(e,r,t),()=>qD(e,r,null)).finally(()=>{WD.delete(r),a&&URL.revokeObjectURL(r)});t.push(o)}),t}async function QD(e){if(!e)return e;let t=new Map;if(eO(e,t),t.size===0)return e;let n=new Map;return await Promise.allSettled(Array.from(t.entries()).map(async([e,t])=>{try{n.set(e,await t)}catch{n.set(e,null)}})),tO(e,n)}function $D(e){if(!e)return!1;let t=new Map;return eO(e,t),t.size>0}function eO(e,t){if(e.type===`image`&&typeof e.attrs?.src==`string`){let n=e.attrs.src,r=UD.get(n)??WD.get(n);r&&t.set(n,r)}if(e.content)for(let n of e.content)eO(n,t)}function tO(e,t){if(e.type===`image`&&typeof e.attrs?.src==`string`&&t.has(e.attrs.src)){let n=e.attrs.src,r=t.get(n);return r?{...e,attrs:{...e.attrs,src:r}}:n.startsWith(`blob:`)?{type:`__removed__`}:e}if(!e.content)return e;let n=e.content.map(e=>tO(e,t)).filter(e=>e.type!==`__removed__`);return n===e.content?e:{...e,content:n}}var nO=new P(`pasteMedia`);function rO(e){return`${e.name}:${e.type}:${e.size}:${e.lastModified}`}function iO(e){if(!e)return[];let t=Array.from(e.items??[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e!==null),n=t.length>0?t:Array.from(e.files??[]),r=new Set;return n.filter(e=>{let t=rO(e);return!r.has(t)&&(r.add(t),!0)})}var aO=H.create({name:`pasteMedia`,addOptions(){return{shouldInsertInline:void 0,onPasteFiles:void 0}},addProseMirrorPlugins(){let e=this,t=t=>{let n=t.filter(t=>e.options.shouldInsertInline?.(t)===!0),r=t.filter(e=>!n.includes(e));if(n.length===0&&(r.length===0||e.options.onPasteFiles===void 0))return!1;for(let t of n){let n=e.options.uploadInlineImage;if(n){n(t);continue}JD(e.editor,t)}return r.length>0&&e.options.onPasteFiles!==void 0&&e.options.onPasteFiles(r),!0};return[new N({key:nO,props:{handlePaste(e,n){let r=iO(n.clipboardData);return r.length===0||!t(r)?!1:(n.preventDefault(),!0)},handleDrop(e,n){let r=iO(n.dataTransfer);return r.length===0||!t(r)?!1:(n.preventDefault(),!0)}}})]}}),oO=new P(`linkToolbar`),sO=`hidden`,cO=!1;function lO(){return sO===`input`&&cO}var uO=`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 10 4 15 9 20"/><path d="M20 4v7a4 4 0 0 1-4 4H4"/></svg>`;function dO(e){let{selection:t}=e;if(!t.empty)return null;let n=t.$from,r=e.schema.marks.link;if(!r)return null;let i=n.marks().find(e=>e.type===r);if(!i)return null;let a=n.parent,o=n.start(),s=0,c=0,l=!1,u=0;for(let e=0;e<a.childCount;e++){let t=a.child(e),n=o+u,d=n+t.nodeSize;if(t.marks.some(e=>e.type===r&&e.attrs.href===i.attrs.href))l||=(s=n,!0),c=d;else if(l)break;u+=t.nodeSize}return l?{from:s,to:c,href:i.attrs.href}:null}var fO=H.create({name:`linkToolbar`,addProseMirrorPlugins(){let e=this.editor,t=null,n=null,r=null,i=0,a=0,o=!1,s=!1,c=null;function l(){t=document.createElement(`div`),t.className=`tiptap-link-input`,t.dataset.editorFloatingUi=`true`,t.style.display=`none`;let i=document.createElement(`div`);i.className=`tiptap-link-input-fields`,r=document.createElement(`input`),r.type=`text`,r.className=`tiptap-link-input-text`,r.placeholder=`Link text`,n=document.createElement(`input`),n.type=`url`,n.className=`tiptap-link-input-field`,n.placeholder=`https:// (empty to unlink)`,i.appendChild(r),i.appendChild(n);let a=document.createElement(`button`);a.type=`button`,a.className=`tiptap-link-input-confirm`,a.innerHTML=uO,a.title=`Apply link`,t.appendChild(i),t.appendChild(a);let o=t=>{t.key===`Enter`?(t.preventDefault(),t.stopPropagation(),m()):t.key===`Escape`&&(t.preventDefault(),t.stopPropagation(),s=!0,f(),e.commands.focus())};r.addEventListener(`keydown`,o),n.addEventListener(`keydown`,o);let c=()=>{cO=!0},l=()=>{requestAnimationFrame(()=>{let e=document.activeElement;(!t||!t.contains(e))&&(cO=!1)})};r.addEventListener(`focus`,c),n.addEventListener(`focus`,c),r.addEventListener(`blur`,l),n.addEventListener(`blur`,l),a.addEventListener(`mousedown`,e=>{e.preventDefault(),m()}),t.addEventListener(`mousedown`,e=>{e.stopPropagation()})}function u(e,t,n,r){e.style.display=`flex`;let i=WT(t.dom.closest(`dialog`)),a=ZT(t,n,r,JT(t.dom,i)),o=e.getBoundingClientRect(),s=GT({anchorRect:a,containerRect:i,floatingWidth:o.width,floatingHeight:o.height,preferredPlacement:`top`,fallbackPlacement:`bottom`,align:`center`});e.style.left=`${s.left}px`,e.style.top=`${s.top}px`,e.dataset.placement=s.placement,e.style.setProperty(`--floating-arrow-x`,`${QT({anchorRect:a,containerRect:i,floatingLeft:s.left,floatingWidth:o.width})}px`)}function d(e,o){if(t&&n&&r){if(o.from!==void 0&&o.to!==void 0?(i=o.from,a=o.to):(i=e.state.selection.from,a=e.state.selection.to),sO=`input`,n.value=o.href,r.value=o.text??e.state.doc.textBetween(i,a,``),u(t,e,i,a),o.focus){let e=r.value.length>0?n:r;requestAnimationFrame(()=>{e.focus(),e.select()})}p(),c=e=>{t&&!t.contains(e.target)&&(s=!0,f())},setTimeout(()=>{c&&document.addEventListener(`mousedown`,c,!0)},0)}}function f(){t&&(t.style.display=`none`),sO=`hidden`,cO=!1,p()}function p(){c&&=(document.removeEventListener(`mousedown`,c,!0),null)}function m(){if(!n||!r)return;let t=n.value.trim(),s=e.state.doc.textBetween(i,a,``),c=r.value,l=c.length>0?c:t;if(f(),!t){e.chain().focus().setTextSelection({from:i,to:a}).unsetLink().setTextSelection(a).run(),o=!0;return}let u=l!==s,d=i+l.length;u?e.chain().focus().command(({tr:e})=>(e.insertText(l,i,a),!0)).setTextSelection({from:i,to:d}).setLink({href:t}).setTextSelection(d).run():e.chain().focus().setTextSelection({from:i,to:a}).setLink({href:t}).setTextSelection(a).run(),o=!0}function h(e,t){if(t.button!==0)return;let n=t.target?.closest(`a`);if(!n||!e.dom.contains(n))return;let r=e.state.schema.marks.link;if(!r||!e.state.selection.empty)return;let i=e.state.selection.from,a=t=>e.state.doc.resolve(t).marks().some(e=>e.type===r),o=i;if(!a(i)){try{o=e.posAtDOM(n,0)+1}catch{return}if(o<0||o>e.state.doc.content.size||!a(o))return}s=!1,e.dispatch(e.state.tr.setSelection(j.create(e.state.doc,o)))}return[new N({key:oO,props:{handleDOMEvents:{click:(e,t)=>(h(e,t),!1)}},view(e){l();let n=e.dom.closest(`dialog`);t&&(n??document.body).appendChild(t);let r=()=>{s=!1,o=!0,d(e,{href:``,focus:!0})};e.dom.addEventListener(`tiptap:open-link-input`,r);let c=e=>{e.key===`Escape`&&sO===`input`&&(e.preventDefault(),e.stopPropagation(),s=!0,f())};return e.dom.addEventListener(`keydown`,c),{update(e){if(o){o=!1;return}let n=dO(e.state);if(sO===`input`&&cO){t&&u(t,e,i,a);return}if(n){if(s)return;d(e,{href:n.href,from:n.from,to:n.to,focus:!1})}else s=!1,sO===`input`&&f()},destroy(){e.dom.removeEventListener(`tiptap:open-link-input`,r),e.dom.removeEventListener(`keydown`,c),p(),t?.remove(),t=null,sO=`hidden`,cO=!1}}}})]}}),pO=new P(`bubbleMenu`),mO={bold:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M6 12h9a4 4 0 0 1 0 8H6V4h8a4 4 0 0 1 0 8"/></svg>`,italic:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="19" y1="4" x2="10" y2="4"/><line x1="14" y1="20" x2="5" y2="20"/><line x1="15" y1="4" x2="9" y2="20"/></svg>`,h1:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12h8"/><path d="M4 18V6"/><path d="M12 18V6"/><path d="M17 12l3-2v10"/></svg>`,h2:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12h8"/><path d="M4 18V6"/><path d="M12 18V6"/><path d="M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"/></svg>`,blockquote:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1z"/><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z"/></svg>`,link:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,clear:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m16 22-1-4"/><path d="M19 14a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2h-3a1 1 0 0 1-1-1V4a2 2 0 0 0-4 0v5a1 1 0 0 1-1 1H6a2 2 0 0 0-2 2v1a1 1 0 0 0 1 1"/><path d="M19 14H5l-1.973 6.767A1 1 0 0 0 4 22h16a1 1 0 0 0 .973-1.233z"/><path d="m8 22 1-4"/></svg>`};function hO(e,t){let{to:n,empty:r}=e.state.selection;if(r){e.chain().focus().toggleMark(t).run();return}let i=e.schema.marks[t];e.chain().focus().toggleMark(t).setTextSelection(n).command(({tr:e})=>(i&&e.removeStoredMark(i),!0)).run()}function gO(e){let{doc:t,selection:n}=e.state,{from:r,to:i}=n,a=[],o=[];t.nodesBetween(r,i,(t,n)=>{t.type===e.schema.nodes.heading&&a.push(n),t.type===e.schema.nodes.blockquote&&o.push({from:Math.max(r,n+1),to:Math.min(i,n+t.nodeSize-1)})}),e.chain().focus().unsetAllMarks().command(({tr:t})=>{let n=e.schema.nodes.heading,r=e.schema.nodes.paragraph;if(n&&r)for(let e of a){let i=t.mapping.map(e);if(t.doc.nodeAt(i)?.type!==n)continue;let a=t.doc.resolve(i),o=a.index();a.parent.canReplaceWith(o,o+1,r)&&t.setNodeMarkup(i,r)}let s=e.schema.nodes.blockquote;if(s)for(let e=o.length-1;e>=0;--e){let n=o[e];if(!n)continue;let r=t.mapping.map(n.from,1),i=t.mapping.map(n.to,-1);if(r>i)continue;let a=t.doc.resolve(r).blockRange(t.doc.resolve(i),e=>e.type===s);if(!a)continue;let c=fn(a);c!==null&&t.lift(a,c)}let c=t.mapping.map(i,-1);return t.setSelection(j.create(t.doc,c)),!0}).run()}function _O(e,t){return t===`compose`?[{key:`bold`,icon:mO.bold,title:`Bold`,action:()=>hO(e,`bold`),isActive:()=>e.isActive(`bold`)},{key:`italic`,icon:mO.italic,title:`Italic`,action:()=>hO(e,`italic`),isActive:()=>e.isActive(`italic`)},{key:`sep`,icon:``,title:``,action:()=>{},isActive:()=>!1},{key:`link`,icon:mO.link,title:`Link`,action:t=>{e.isActive(`link`)?e.chain().focus().unsetLink().run():t.dom.dispatchEvent(new CustomEvent(`tiptap:open-link-input`))},isActive:()=>e.isActive(`link`)},{key:`clear`,icon:mO.clear,title:`Clear formatting`,action:()=>gO(e),isActive:()=>!1}]:[{key:`bold`,icon:mO.bold,title:`Bold`,action:()=>hO(e,`bold`),isActive:()=>e.isActive(`bold`)},{key:`italic`,icon:mO.italic,title:`Italic`,action:()=>hO(e,`italic`),isActive:()=>e.isActive(`italic`)},{key:`h1`,icon:mO.h1,title:`Heading 1`,action:()=>e.chain().focus().toggleHeading({level:1}).run(),isActive:()=>e.isActive(`heading`,{level:1})},{key:`h2`,icon:mO.h2,title:`Heading 2`,action:()=>e.chain().focus().toggleHeading({level:2}).run(),isActive:()=>e.isActive(`heading`,{level:2})},{key:`sep`,icon:``,title:``,action:()=>{},isActive:()=>!1},{key:`blockquote`,icon:mO.blockquote,title:`Quote`,action:()=>e.chain().focus().toggleBlockquote().run(),isActive:()=>e.isActive(`blockquote`)},{key:`link`,icon:mO.link,title:`Link`,action:t=>{e.isActive(`link`)?e.chain().focus().unsetLink().run():t.dom.dispatchEvent(new CustomEvent(`tiptap:open-link-input`))},isActive:()=>e.isActive(`link`)}]}var vO=H.create({name:`bubbleMenu`,addOptions(){return{toolbarMode:`default`}},addProseMirrorPlugins(){let e=this.editor,t=this.options.toolbarMode,n=null,r=[],i=new Map;function a(){n=document.createElement(`div`),n.className=`tiptap-bubble-menu`,n.dataset.editorFloatingUi=`true`,n.style.position=`fixed`,n.style.display=`none`,r=_O(e,t);for(let t of r){if(t.key===`sep`){let e=document.createElement(`span`);e.className=`tiptap-bubble-sep`,n.appendChild(e);continue}let r=document.createElement(`button`);r.type=`button`,r.innerHTML=t.icon,r.title=t.title,r.className=`tiptap-bubble-btn`,r.addEventListener(`mousedown`,n=>{n.preventDefault(),t.action(e.view)}),n.appendChild(r),i.set(t.key,r)}}function o(e){if(!n)return;n.style.display=`flex`;let{from:t,to:r}=e.state.selection,i=WT(e.dom.closest(`dialog`)),a=ZT(e,t,r,JT(e.dom,i)),o=n.getBoundingClientRect(),s=GT({anchorRect:a,containerRect:i,floatingWidth:o.width,floatingHeight:o.height,preferredPlacement:`top`,fallbackPlacement:`bottom`,align:`center`});n.style.left=`${s.left}px`,n.style.top=`${s.top}px`,n.dataset.placement=s.placement,n.style.setProperty(`--floating-arrow-x`,`${QT({anchorRect:a,containerRect:i,floatingLeft:s.left,floatingWidth:o.width})}px`),c()}function s(){n&&(n.style.display=`none`)}function c(){for(let t of r){if(t.key===`sep`)continue;let n=i.get(t.key);n&&n.classList.toggle(`is-active`,t.isActive(e.view))}}function l(e){let{state:t}=e,{selection:n}=t;return n.empty||lO()?!1:n instanceof ar?t.doc.textBetween(n.from,n.to,` `).trim()!==``:n instanceof j&&n.$from.parent.isTextblock}return[new N({key:pO,view(e){a();let t=e.dom.closest(`dialog`)??document.body;n&&t.appendChild(n);function r(t){let r=t.target;if(!r||e.dom.contains(r)||r.closest(`[data-editor-floating-ui]`)||n?.contains(r))return;let{state:i}=e,a=i.selection.from;e.dispatch(i.tr.setSelection(A.near(i.doc.resolve(a)))),e.dom.blur()}return t.addEventListener(`mousedown`,r),{update(e){l(e)?o(e):s()},destroy(){t.removeEventListener(`mousedown`,r),n?.remove(),n=null}}}})]}}),yO=` `,bO=H.create({name:`codeBlockIndent`,addKeyboardShortcuts(){return{Tab:({editor:e})=>{if(e.isActive(`codeBlock`)){let{state:t,dispatch:n}=e.view,{selection:r}=t,{from:i,to:a}=r,o=t.doc.resolve(i),s=o.parent;if(s.type.name!==`codeBlock`)return!1;let c=o.start(),l=s.textContent;if(i===a)return n(t.tr.insertText(yO,i)),!0;let u=i-c,d=a-c,f=[],p=l.lastIndexOf(`
|
|
248
252
|
`,u-1)+1;f.push(p);let m=p;for(;;){let e=l.indexOf(`
|
|
249
|
-
`,m);if(e===-1||e>=d)break;f.push(e+1),m=e+1}let h=t.tr,g=0;for(let e of f)h=h.insertText(
|
|
250
|
-
`,e-1)+1,a=l.slice(r),o=a.startsWith(
|
|
253
|
+
`,m);if(e===-1||e>=d)break;f.push(e+1),m=e+1}let h=t.tr,g=0;for(let e of f)h=h.insertText(yO,c+e+g),g+=2;let _=i+2,v=a+g;return h.setSelection(j.create(h.doc,_,v)),n(h),!0}return!1},"Shift-Tab":({editor:e})=>{if(e.isActive(`codeBlock`)){let{state:t,dispatch:n}=e.view,{selection:r}=t,{from:i,to:a}=r,o=t.doc.resolve(i),s=o.parent;if(s.type.name!==`codeBlock`)return!1;let c=o.start(),l=s.textContent;if(i===a){let e=i-c,r=l.lastIndexOf(`
|
|
254
|
+
`,e-1)+1,a=l.slice(r),o=a.startsWith(yO)?2:+!!a.startsWith(` `);return o===0||n(t.tr.delete(c+r,c+r+o)),!0}let u=i-c,d=a-c,f=[],p=l.lastIndexOf(`
|
|
251
255
|
`,u-1)+1;f.push(p);let m=p;for(;;){let e=l.indexOf(`
|
|
252
|
-
`,m);if(e===-1||e>=d)break;f.push(e+1),m=e+1}let h=t.tr,g=0,_=0;for(let e=0;e<f.length;e++){let t=f[e],n=l.slice(t),r=n.startsWith(GD)?2:+!!n.startsWith(` `);if(r>0){let n=c+t+g;h=h.delete(n,n+r),g-=r,e===0&&(_=r)}}if(g<0){let e=Math.max(i-_,c),t=a+g;h.setSelection(j.create(h.doc,e,Math.max(t,e)))}return n(h),!0}return!1}}}});function qD(e){let{schema:t}=e.doc.type;return e.parent.type===t.nodes.paragraph?e.depth===1?{kind:`plain`,topIndex:e.index(0)}:e.depth===2&&e.node(1).type===t.nodes.blockquote?{kind:`quote`,topIndex:e.index(0),quoteChildIndex:e.index(1)}:null:null}function JD(e,t){return e.type.name===`blockquote`&&(t===`backward`?e.lastChild:e.firstChild)?.type.name===`paragraph`?`quote`:null}function YD(e,t,n){let r=n===`backward`?-1:1;if(t.kind===`quote`){let n=e.doc.child(t.topIndex),i=t.quoteChildIndex;if(i===void 0)return null;let a=i+r;if(a>=0&&a<n.childCount)return n.child(a).type.name===`paragraph`?`quote`:null}let i=t.topIndex+r;if(i<0||i>=e.doc.childCount)return null;let a=e.doc.child(i);return a.type.name===`paragraph`?`plain`:JD(a,n)}function XD(e,t){let{selection:n}=e.state;if(!n.empty)return!1;let{$from:r}=n;if(!(t===`backward`?r.parentOffset===0:r.parentOffset===r.parent.content.size))return!1;let i=qD(r);if(!i)return!1;let a=YD(r,i,t);return!a||i.kind!==`quote`&&a!==`quote`?!1:t===`backward`?e.commands.joinTextblockBackward():e.commands.joinTextblockForward()}function ZD(e){let t=e.depth-1;if(t<=0||e.node(t).type.name!==`listItem`)return null;let n=t-1,r=e.node(n).type.name;return r===`bulletList`||r===`orderedList`?t:null}function QD(e){let{selection:t}=e.state;if(!t.empty)return!1;let{$from:n}=t;if(n.parentOffset!==0||!n.parent.isTextblock)return!1;let r=ZD(n);if(r===null)return!1;let i=n.node(r),a=n.index(r);if(a>0)return!i.child(a-1).isTextblock||e.commands.joinTextblockBackward();let o=r-1;return n.index(o)!==0&&(e.commands.joinItemBackward()||e.commands.joinBackward(),!0)}function $D(e){let{selection:t}=e.state;return!t.empty||!t.$from.parent.isTextblock||t.$from.parentOffset!==0?!1:e.commands.undoInputRule()?!0:QD(e)||XD(e,`backward`)}var eO=H.create({name:`structuralKeymap`,priority:1e3,addKeyboardShortcuts(){return{Backspace:({editor:e})=>$D(e),"Mod-Backspace":({editor:e})=>$D(e),"Shift-Backspace":({editor:e})=>$D(e),Delete:({editor:e})=>XD(e,`forward`),"Mod-Delete":({editor:e})=>XD(e,`forward`),Tab:({editor:e})=>e.isActive(`listItem`)?(e.commands.sinkListItem(`listItem`),!0):!1,"Shift-Tab":({editor:e})=>e.isActive(`listItem`)?(e.commands.liftListItem(`listItem`),!0):!1}}});function tO(e){return e.type.name===`bulletList`||e.type.name===`orderedList`}function nO(e,t=-1,n=e){let r=t+1,i=0,a=null;for(let t=0;t<e.childCount;t+=1){let o=e.child(t),s=r+i;if(a&&tO(a)&&a.type===o.type&&En(n,s))return s;let c=nO(o,s,n);if(c!==null)return c;i+=o.nodeSize,a=o}return null}function rO(e){let t=e.tr,n=!1,r=nO(t.doc);for(;r!==null;)t.join(r),n=!0,r=nO(t.doc);return n?t:null}var iO=H.create({name:`continuousLists`,onCreate(){let e=rO(this.editor.state);e&&this.editor.view.dispatch(e.setMeta(`addToHistory`,!1))},addProseMirrorPlugins(){return[new N({appendTransaction:(e,t,n)=>e.some(e=>e.docChanged)?rO(n):null})]}}),aO=/\[([^\]]+)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/,oO=RegExp(aO.source+`$`),sO=RegExp(aO.source+`\\s$`),cO=/((?:https?:\/\/|mailto:|tel:|sms:)[^\s<]+)\s$/i,lO=H.create({name:`linkInputRules`,addInputRules(){let t=this.editor.schema.marks.link;if(!t)return[];function n(n,r,i,a){let o=i[1]?.trim(),s=e(i[2]??``);if(!o||!s)return null;let c=a?o+a:o;n.tr.insertText(c,r.from,r.to),n.tr.addMark(r.from,r.from+o.length,t.create({href:s})),n.tr.removeStoredMark(t)}return[new Cf({find:cO,handler:({state:n,range:r,match:i})=>{let a=e(i[1]??``);if(!a)return null;let o=r.from+a.length;if(n.doc.rangeHasMark(r.from,o,t))return null;n.tr.addMark(r.from,o,t.create({href:a})),n.tr.removeStoredMark(t)}}),new Cf({find:oO,handler:({state:e,range:t,match:r})=>{n(e,t,r,``)}}),new Cf({find:sO,handler:({state:e,range:t,match:r})=>{n(e,t,r,` `)}})]}});function uO(e,t){let{state:n}=e,r=n.schema.nodes.paragraph;if(!r)return!1;let{selection:i}=n,{$from:a,$to:o}=i,s;s=a.depth===0?t===`above`?i.from:i.to:t===`above`?a.before(1):o.after(1);let c=n.tr.insert(s,r.create());return c.setSelection(j.create(c.doc,s+1)),e.view.dispatch(c.scrollIntoView()),!0}var dO=H.create({name:`insertParagraphAround`,addKeyboardShortcuts(){let e=({editor:e})=>{let{state:t}=e,{selection:n}=t;if(!n.empty)return!1;let{$from:r}=n;if(r.depth<1||r.pos!==r.depth)return!1;let i=t.doc.firstChild;return!i||i.type.name===`paragraph`?!1:uO(e,`above`)};return{ArrowUp:e,ArrowLeft:e,"Mod-Shift-Enter":({editor:e})=>uO(e,`above`),"Mod-Alt-Enter":({editor:e})=>uO(e,`below`)}}}),fO=/\[\^([^\]\n]+)\]([ \t.,!?;)]$)/,pO=/^\[\^([^\]\n]+)\]: $/,mO=/\[\^([^\]\n]+)\]$/;function hO(e){let t=new Set;return e.descendants(e=>{if(e.type.name!==`footnoteReference`&&e.type.name!==`footnoteDefinition`)return!0;let n=m(e.attrs.label);return n&&t.add(h(n)),!0}),t}function gO(e){let t=hO(e),n=1;for(;t.has(String(n));)n+=1;return String(n)}function _O(e){let t=e.content.size;return e.forEach((e,n)=>{e.type.name===`footnoteDefinition`&&(t=n+e.nodeSize)}),t}function vO(e,t){let n=h(t),r=null;return e.forEach((e,t)=>{r===null&&e.type.name===`footnoteDefinition`&&h(e.attrs.label)===n&&(r=t)}),r}function yO(e,t){let n=h(t),r=null;return e.forEach((e,t)=>{r===null&&e.type.name===`footnoteDefinition`&&h(e.attrs.label)===n&&(r={from:t,to:t+e.nodeSize})}),r}function bO(e,t){let n=h(t),r=[];return e.descendants((e,t)=>(e.type.name===`footnoteReference`&&h(e.attrs.label)===n&&r.push({from:t,to:t+e.nodeSize}),!0)),r}function xO(e,t){let n=e.schema.nodes.footnoteReference;return n?n.create({label:t}):null}function SO(e,t){let n=e.schema.nodes.footnoteDefinition,r=e.schema.nodes.paragraph;return!n||!r?null:n.create({label:t},[r.create()])}function CO(e,t){let n=Math.min(t+2,e.doc.content.size);e.setSelection(j.near(e.doc.resolve(n),1))}function wO(e,t){let n=null,r=null;e.doc.forEach((e,i)=>{i===t&&e.type.name===`paragraph`&&e.content.size===0&&(n=i,r=i+e.nodeSize)}),n!==null&&r!==null&&e.delete(n,r)}function TO(e,t,n){let r=vO(t.doc,n);if(r!==null)return r;let i=SO(e,n);if(!i)return null;let a=_O(t.doc);return t.insert(a,i),wO(t,a+i.nodeSize),a}function EO(e){let t=new Set,n=new Set,r=[];return e.forEach(e=>{if(e.type.name!==`footnoteDefinition`)return;let n=m(e.attrs.label);n&&t.add(h(n))}),e.descendants(e=>{if(e.type.name!==`footnoteReference`)return!0;let i=m(e.attrs.label),a=h(i);return i&&!t.has(a)&&!n.has(a)&&(n.add(a),r.push(i)),!0}),r}function DO(e){let t=EO(e.doc);if(t.length===0)return null;let n=e.tr;for(let r of t)TO(e,n,r);return n.docChanged?n:null}function OO(e){let{selection:t}=e;return!(t instanceof M)||t.node.type.name!==`footnoteReference`?null:m(t.node.attrs.label)||null}function kO(e,t){let n=e.tr,r=TO(e,n,t);return r===null?null:(CO(n,r),n.scrollIntoView(),n)}function AO(e,t){if(t.doc.childCount>0)return;let n=e.schema.nodes.paragraph;n&&t.insert(0,n.create())}function jO(e,t){if(!t||e.doc.childCount<2)return;let n=e.doc.lastChild,r=e.doc.child(e.doc.childCount-2);n?.type.name===`paragraph`&&n.content.size===0&&r.type.name!==`footnoteDefinition`&&e.delete(e.doc.content.size-n.nodeSize,e.doc.content.size)}function MO(e,t){let n=Math.min(Math.max(t,0),e.doc.content.size);e.setSelection(j.near(e.doc.resolve(n),-1))}function NO(e,t){let n=[...t].sort((e,t)=>t.from-e.from);for(let t of n)e.delete(t.from,t.to)}function PO(e,t){let n=yO(e.doc,t),r=[...bO(e.doc,t),...n?[n]:[]];if(r.length===0)return null;let i=e.tr;return NO(i,r),AO(e,i),jO(i,n),MO(i,r[0]?.from??0),i.scrollIntoView(),i}function FO(e,t){let n=e.doc.nodeAt(t.from);if(!n||n.type.name!==`footnoteReference`)return null;let r=m(n.attrs.label);if(!r)return null;let i=bO(e.doc,r),a=yO(e.doc,r),o=i.length<=1?[t,...a?[a]:[]]:[t],s=e.tr;return NO(s,o),AO(e,s),jO(s,i.length<=1?a:null),MO(s,t.from),s.scrollIntoView(),s}function IO(e,t){let{selection:n}=e;if(n instanceof M)return n.node.type.name===`footnoteReference`?{from:n.from,to:n.to}:null;if(!n.empty)return null;let{$from:r}=n,i=t===`backward`?r.nodeBefore:r.nodeAfter;if(!i||i.type.name!==`footnoteReference`)return null;let a=t===`backward`?n.from-i.nodeSize:n.from;return{from:a,to:a+i.nodeSize}}function LO(e){let{selection:t}=e;if(t instanceof M)return t.node.type.name===`footnoteDefinition`?m(t.node.attrs.label):null;if(!t.empty)return null;let{$from:n}=t,r=-1;for(let e=n.depth;e>0;--e)if(n.node(e).type.name===`footnoteDefinition`){r=e;break}return r===-1||n.parent.type.name!==`paragraph`||n.parentOffset!==0||n.index(r)!==0?null:m(n.node(r).attrs.label)}function RO(e,t,n,r,i){let a=xO(e,t);if(!a)return!1;let o=[a];n&&o.push(e.schema.text(n));let s=e.tr;return s.replaceWith(r,i,D.fromArray(o)),TO(e,s,t)!==null}function zO(e,t){let n=SO(e,t);if(!n)return!1;let{$from:r}=e.selection;if(r.depth!==1||r.parent.type.name!==`paragraph`)return!1;let i=e.tr.replaceWith(r.before(),r.after(),n);return wO(i,r.before()+n.nodeSize),CO(i,r.before()),i.scrollIntoView(),!0}function BO(e,t){let n=SO(e,t);if(!n)return!1;let{$from:r}=e.selection;if(r.parent.type.name!==`paragraph`||r.depth<2||r.node(r.depth-1).type.name!==`footnoteDefinition`)return!1;let i=r.depth,a=r.before(i),o=r.after(i),s=i-1,c=r.node(s),l=r.after(s),u=e.tr;c.childCount===1?u.delete(a+1,o-1):u.delete(a,o);let d=u.mapping.map(l);return u.insert(d,n),wO(u,d+n.nodeSize),CO(u,d),u.scrollIntoView(),!0}function VO(e){let{$from:t}=e.selection;for(let e=t.depth;e>0;--e)if(t.node(e).type.name===`footnoteDefinition`)return!0;return!1}function HO(e){let{selection:t}=e,{$from:n}=t;if(!t.empty||VO(e)||!n.parent.inlineContent||n.parent.type.name!==`paragraph`||n.parentOffset!==n.parent.content.size)return null;let r=n.parent.textBetween(0,n.parentOffset,void 0,``).match(mO),i=m(r?.[1]);return!r||!i?null:{label:i,from:t.from-r[0].length,to:t.from}}function UO(e){let t=HO(e);if(t){let n=xO(e,t.label);if(!n)return null;let r=e.tr.replaceWith(t.from,t.to,n),i=TO(e,r,t.label);return i===null?null:(CO(r,i),r.scrollIntoView(),r)}return null}function WO(){return[new Cf({find:pO,handler:({state:e,match:t})=>{let n=m(t[1]);if(!n)return null;let{$from:r}=e.selection;return r.depth!==1||r.parent.type.name!==`paragraph`?BO(e,n)?void 0:null:zO(e,n)?void 0:null}}),new Cf({find:fO,handler:({state:e,range:t,match:n})=>{let r=m(n[1]),i=n[2]??``;return!r||!i||!e.selection.$from.parent.inlineContent?null:RO(e,r,i,t.from,t.to)?void 0:null}})]}var GO=H.create({name:`footnotes`,onCreate(){let e=DO(this.editor.state);e&&this.editor.view.dispatch(e)},addProseMirrorPlugins(){return[new N({appendTransaction:(e,t,n)=>e.some(e=>e.docChanged)?DO(n):null,props:{handleClickOn:(e,t,n,r,i,a)=>{if(!a||n.type.name!==`footnoteReference`)return!1;let o=m(n.attrs.label);if(!o)return!1;let s=kO(e.state,o);return s?(e.dispatch(s),e.focus(),!0):!1},handleClick:(e,t)=>{let n=e.state.doc.resolve(t);if(n.nodeBefore?.type.name!==`footnoteDefinition`||n.nodeAfter?.type.name!==`footnoteDefinition`)return!1;let r=e.state.tr;return CO(r,t),e.dispatch(r.scrollIntoView()),e.focus(),!0}}})]},addCommands(){return{insertFootnote:()=>({state:e,dispatch:t})=>{if(!e.selection.$from.parent.inlineContent)return!1;let n=gO(e.doc),r=xO(e,n),i=SO(e,n);if(!r||!i)return!1;let a=_O(e.doc),o=e.tr.replaceSelectionWith(r,!1),s=o.mapping.map(a);return o.insert(s,i),wO(o,s+i.nodeSize),CO(o,s),t&&t(o.scrollIntoView()),!0}}},addInputRules(){return WO()},addKeyboardShortcuts(){return{Enter:({editor:e})=>{let t=OO(e.state);if(t){let n=kO(e.state,t);return n?(e.view.dispatch(n),!0):!1}let n=UO(e.state);return n?(e.view.dispatch(n),!0):!1},Backspace:({editor:e})=>{let t=LO(e.state);if(t){let n=PO(e.state,t);return n?(e.view.dispatch(n),!0):!1}let n=IO(e.state,`backward`);if(!n)return!1;let r=FO(e.state,n);return r?(e.view.dispatch(r),!0):!1},Delete:({editor:e})=>{let t=IO(e.state,`forward`);if(!t)return!1;let n=FO(e.state,t);return n?(e.view.dispatch(n),!0):!1}}}});function KO(e,t,n=`paragraph`){let{$to:r}=e.selection,i=r.end();if(r.nodeAfter)r.nodeAfter.isTextblock?e.setSelection(j.create(e.doc,r.pos+1)):r.nodeAfter.isBlock?e.setSelection(M.create(e.doc,r.pos)):e.setSelection(j.create(e.doc,r.pos));else{let a=(t.nodes[n]??r.parent.type.contentMatch.defaultType)?.create();a&&(e.insert(i,a),e.setSelection(j.create(e.doc,i+1)))}e.scrollIntoView()}var qO=`jant:inline-image-load-state`,JO={unavailable:`Image unavailable`,delete:`Delete image`,replace:`Replace image`,open:`Open image URL`},YO={imageBroken:`<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="16" rx="2.5"/><circle cx="8.5" cy="9.5" r="1.5"/><path d="m5 17 4.25-4.25 2.5 2.5 1.75-1.75L19 19"/><path d="m4 4 16 16"/></svg>`,regular:`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><rect x="3" y="3" width="10" height="10" rx="1.5"/></svg>`,wide:`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><rect x="1.5" y="4" width="13" height="8" rx="1.5"/></svg>`,full:`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><rect x="0.75" y="3" width="14.5" height="10" rx="1"/><path d="M4 8h8M4 6l-1.5 2L4 10M12 6l1.5 2L12 10"/></svg>`,link:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,replace:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/><path d="M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16"/><path d="M16 16h5v5"/></svg>`,expand:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h6v6"/><path d="M9 21H3v-6"/><path d="M21 3l-7 7"/><path d="M3 21l7-7"/></svg>`},XO=class{dom;img;missingPanel;missingSource;openBtn;figcaption;captionInput;altBtn;toolbar;captionBar;layoutBtns=new Map;node;view;getPos;editor;labels;editingAlt=!1;missing=!1;currentSrc=``;constructor(e,t,n,r,i){this.node=e,this.view=t,this.getPos=n,this.editor=r,this.labels=i;let a=document.createElement(`figure`);a.className=`tiptap-image-figure`,a.dataset.selected=`false`,a.dataset.layout=String(e.attrs.layout||`regular`),a.dataset.loadState=`loading`,this.dom=a;let o=document.createElement(`div`);o.className=`tiptap-image-container`,a.appendChild(o);let s=document.createElement(`img`);s.draggable=!1,s.addEventListener(`load`,()=>this.setMissing(!1)),s.addEventListener(`error`,()=>this.setMissing(!0)),o.appendChild(s),this.img=s;let c=document.createElement(`div`);c.className=`tiptap-image-missing`,c.role=`group`,c.tabIndex=0,c.setAttribute(`aria-label`,i.unavailable),c.addEventListener(`keydown`,e=>{(e.key===`Delete`||e.key===`Backspace`)&&(e.preventDefault(),this.deleteNode())}),o.appendChild(c),this.missingPanel=c;let l=document.createElement(`span`);l.className=`tiptap-image-missing-icon`,l.setAttribute(`aria-hidden`,`true`),l.innerHTML=YO.imageBroken,c.appendChild(l);let u=document.createElement(`span`);u.className=`tiptap-image-missing-copy`,c.appendChild(u);let d=document.createElement(`strong`);d.textContent=i.unavailable,u.appendChild(d);let f=document.createElement(`span`);f.className=`tiptap-image-missing-source`,u.appendChild(f),this.missingSource=f;let p=document.createElement(`span`);p.className=`tiptap-image-missing-actions`,c.appendChild(p);let m=document.createElement(`button`);m.type=`button`,m.className=`tiptap-image-missing-delete`,m.textContent=i.delete,m.addEventListener(`mousedown`,e=>{e.preventDefault(),this.deleteNode()}),p.appendChild(m);let h=document.createElement(`button`);h.type=`button`,h.textContent=i.replace,h.addEventListener(`mousedown`,e=>{e.preventDefault(),this.handleReplace()}),p.appendChild(h);let g=document.createElement(`button`);g.type=`button`,g.textContent=i.open,g.addEventListener(`mousedown`,e=>{e.preventDefault(),this.handleOpenOriginal()}),p.appendChild(g),this.openBtn=g;let _=document.createElement(`div`);_.className=`tiptap-image-toolbar`,o.appendChild(_),this.toolbar=_;let v=[[`regular`,YO.regular,`Content width`],[`wide`,YO.wide,`Wide — max 1200px`],[`full`,YO.full,`Full width — edge to edge`]];for(let[t,n,r]of v){this.layoutBtns.size>0&&_.appendChild(this.sep());let i=document.createElement(`button`);i.type=`button`,i.innerHTML=n,i.title=r,i.dataset.layout=t,t===(e.attrs.layout||`regular`)&&(i.className=`is-active`),i.addEventListener(`mousedown`,e=>{e.preventDefault(),this.updateAttrs({layout:t})}),_.appendChild(i),this.layoutBtns.set(t,i)}_.appendChild(this.sep());let y=this.iconBtn(YO.link,`Add link`);y.addEventListener(`mousedown`,e=>{e.preventDefault(),this.handleLink()}),_.appendChild(y),_.appendChild(this.sep());let b=this.iconBtn(YO.replace,`Replace image`);b.addEventListener(`mousedown`,e=>{e.preventDefault(),this.handleReplace()}),_.appendChild(b),_.appendChild(this.sep());let x=this.iconBtn(YO.expand,`Preview fullscreen`);x.addEventListener(`mousedown`,e=>{e.preventDefault(),this.handleExpand()}),_.appendChild(x);let S=document.createElement(`div`);S.className=`tiptap-image-caption-bar`,a.appendChild(S),this.captionBar=S;let C=document.createElement(`input`);C.type=`text`,C.placeholder=`Add a caption…`,C.value=String(e.attrs.caption??``),C.addEventListener(`input`,()=>{this.editingAlt?this.updateAttrs({alt:C.value}):this.updateAttrs({caption:C.value})}),C.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this.view.focus())}),S.appendChild(C),this.captionInput=C;let w=document.createElement(`button`);w.type=`button`,w.className=`tiptap-image-alt-btn`,w.textContent=`Alt`,w.addEventListener(`mousedown`,e=>{e.preventDefault(),this.toggleAltMode()}),S.appendChild(w),this.altBtn=w;let T=document.createElement(`figcaption`);T.className=`tiptap-image-figcaption`,T.textContent=String(e.attrs.caption??``),a.appendChild(T),this.figcaption=T,this.syncImageAttrs(e)}update(e){if(e.type!==this.node.type)return!1;this.node=e,this.syncImageAttrs(e),this.dom.dataset.layout=String(e.attrs.layout||`regular`),this.layoutBtns.forEach((t,n)=>{t.classList.toggle(`is-active`,n===(e.attrs.layout||`regular`))});let t=String(e.attrs.caption??``);return this.figcaption.textContent=t,document.activeElement!==this.captionInput&&(this.editingAlt?this.captionInput.value=String(e.attrs.alt??``):this.captionInput.value=t),!0}selectNode(){this.dom.dataset.selected=`true`}deselectNode(){this.dom.dataset.selected=`false`,this.editingAlt=!1,this.altBtn.classList.remove(`is-active`),this.captionInput.placeholder=`Add a caption…`,this.captionInput.value=String(this.node.attrs.caption??``)}stopEvent(e){let t=e.target;return!!(t.closest(`.tiptap-image-toolbar`)||t.closest(`.tiptap-image-caption-bar`)||t.closest(`.tiptap-image-missing`))}ignoreMutation(){return!0}destroy(){}sep(){let e=document.createElement(`span`);return e.className=`tiptap-toolbar-sep`,e}iconBtn(e,t){let n=document.createElement(`button`);return n.type=`button`,n.innerHTML=e,n.title=t,n}updateAttrs(e){let t=this.getPos();if(t===void 0)return;let n=this.view.state.tr.setNodeMarkup(t,void 0,{...this.node.attrs,...e});this.view.dispatch(n)}syncImageAttrs(e){let t=String(e.attrs.src??``);if(this.img.alt=String(e.attrs.alt??``),this.img.title=String(e.attrs.title??``),this.missingSource.textContent=ZO(t),this.openBtn.disabled=!QO(t),t!==this.currentSrc){this.currentSrc=t,this.setMissing(!1),this.dom.dataset.loadState=`loading`,this.img.setAttribute(`src`,t),this.checkCachedImageState();return}this.checkCachedImageState()}checkCachedImageState(){queueMicrotask(()=>{this.img.complete&&this.img.getAttribute(`src`)===this.currentSrc&&this.setMissing(this.img.naturalWidth===0)})}setMissing(e){if(this.missing===e){this.dom.dataset.loadState=e?`missing`:`loaded`;return}this.missing=e,this.dom.dataset.loadState=e?`missing`:`loaded`,this.dom.dispatchEvent(new CustomEvent(qO,{bubbles:!0,composed:!0,detail:{src:this.currentSrc,missing:e}}))}deleteNode(){let e=this.getPos();if(e===void 0)return;let t=this.view.state.tr.delete(e,e+this.node.nodeSize);this.view.dispatch(t),this.view.focus()}handleLink(){if(String(this.node.attrs.href??``))this.updateAttrs({href:``});else{let e=globalThis.prompt(`Enter URL`);e&&this.updateAttrs({href:e})}}handleReplace(){let e=document.createElement(`input`);e.type=`file`,e.accept=`image/*`,e.addEventListener(`change`,async()=>{let t=e.files?.[0];if(t)try{let e=await dD(t);this.updateAttrs({src:e.url})}catch{}}),e.click()}handleOpenOriginal(){let e=String(this.node.attrs.src??``);QO(e)&&window.open(e,`_blank`,`noopener,noreferrer`)}handleExpand(){let e=document.querySelector(`jant-media-lightbox`);e&&e.open([{url:String(this.node.attrs.src??``),alt:String(this.node.attrs.alt??``)}],0)}toggleAltMode(){this.editingAlt=!this.editingAlt,this.altBtn.classList.toggle(`is-active`,this.editingAlt),this.editingAlt?(this.captionInput.placeholder=`Add alt text…`,this.captionInput.value=String(this.node.attrs.alt??``)):(this.captionInput.placeholder=`Add a caption…`,this.captionInput.value=String(this.node.attrs.caption??``)),this.captionInput.focus()}};function ZO(e){let t=e.trim();return t?t.length>140?`${t.slice(0,137)}...`:t:``}function QO(e){let t=e.trim();return t?/^(https?:|\/|\.\/|\.\.\/|blob:)/i.test(t):!1}var $O=U.create({name:`image`,group:`block`,atom:!0,selectable:!0,draggable:!0,addOptions(){return{labels:JO}},addAttributes(){return{src:{default:``},alt:{default:``},title:{default:``},caption:{default:``},href:{default:``},layout:{default:`regular`}}},parseHTML(){return[{tag:`figure[data-image]`,getAttrs(e){let t=e,n=t.querySelector(`img`),r=t.querySelector(`figcaption`),i=t.querySelector(`a`);return{src:n?.getAttribute(`src`)??``,alt:n?.getAttribute(`alt`)??``,title:n?.getAttribute(`title`)??``,caption:r?.textContent??``,href:i?.getAttribute(`href`)??``,layout:t.dataset.layout??`regular`}}},{tag:`figure`,getAttrs(e){let t=e,n=t.querySelector(`img`);if(!n)return!1;let r=t.querySelector(`figcaption`),i=t.querySelector(`a`);return{src:n.getAttribute(`src`)??``,alt:n.getAttribute(`alt`)??``,title:n.getAttribute(`title`)??``,caption:r?.textContent??``,href:i?.getAttribute(`href`)??``,layout:t.dataset.layout??`regular`}}},{tag:`img[src]`,getAttrs(e){let t=e;return{src:t.getAttribute(`src`)??``,alt:t.getAttribute(`alt`)??``,title:t.getAttribute(`title`)??``}}}]},renderHTML({node:e}){let t={};e.attrs.layout&&e.attrs.layout!==`regular`&&(t[`data-layout`]=e.attrs.layout),t[`data-image`]=``;let n={src:e.attrs.src};e.attrs.alt&&(n.alt=e.attrs.alt),e.attrs.title&&(n.title=e.attrs.title);let r=[`img`,n],i=[];return e.attrs.href?i.push([`a`,{href:e.attrs.href},r]):i.push(r),e.attrs.caption&&i.push([`figcaption`,{},e.attrs.caption]),[`figure`,t,...i]},parseMarkdown:(e,t)=>t.createNode(`image`,{src:e.href,title:e.title??``,alt:e.text??``}),renderMarkdown:e=>pe(e.attrs??{}),addCommands(){return{setImage:e=>({chain:t,state:n})=>{if(!sf(n,n.schema.nodes[this.name]))return!1;let{$to:r}=n.selection,i=t();return td(n.selection)?i.insertContentAt(r.pos,{type:this.name,attrs:e}):i.insertContent({type:this.name,attrs:e}),i.command(({state:e,tr:t,dispatch:n})=>(n&&KO(t,e.schema),!0)).run()}}},addNodeView(){return({node:e,view:t,getPos:n,editor:r})=>new XO(e,t,n,r,{...JO,...this.options.labels??{}})}}),ek=`<!--more-->`,tk=U.create({name:`moreBreak`,group:`block`,atom:!0,selectable:!0,draggable:!1,parseHTML(){return[{tag:`div[data-more-break]`}]},renderHTML(){return[`div`,{"data-more-break":``,class:`tiptap-more-break`},`Read More ↓`]},renderText(){return ek},parseMarkdown:(e,t)=>t.createNode(`moreBreak`),renderMarkdown:()=>ek,markdownTokenizer:US(),addCommands(){return{insertMoreBreak:()=>({chain:e,state:t})=>{if(!sf(t,t.schema.nodes[this.name]))return!1;let{$to:n}=t.selection,r=e();return td(t.selection)?r.insertContentAt(n.pos,{type:this.name}):r.insertContent({type:this.name}),r.command(({state:e,tr:t,dispatch:n})=>(n&&KO(t,e.schema),!0)).run()}}}}),nk=class{dom;node;view;getPos;editor;providerLabel;urlLink;captionInput;constructor(e,t,n,r){this.node=e,this.view=t,this.getPos=n,this.editor=r;let i=document.createElement(`div`);i.className=`tiptap-embed-card`,i.dataset.selected=`false`,this.dom=i;let a=document.createElement(`div`);a.className=`tiptap-embed-card-header`,i.appendChild(a);let o=document.createElement(`span`);o.className=`tiptap-embed-card-provider`,a.appendChild(o),this.providerLabel=o;let s=document.createElement(`span`);s.className=`tiptap-embed-card-actions`,a.appendChild(s);let c=document.createElement(`button`);c.type=`button`,c.textContent=`Edit`,c.className=`tiptap-embed-card-btn`,c.addEventListener(`mousedown`,e=>{e.preventDefault(),this.requestEdit()}),s.appendChild(c);let l=document.createElement(`a`);l.className=`tiptap-embed-card-url`,l.target=`_blank`,l.rel=`noopener noreferrer`,i.appendChild(l),this.urlLink=l;let u=document.createElement(`input`);u.type=`text`,u.placeholder=`Add a caption…`,u.className=`tiptap-embed-card-caption`,u.value=String(e.attrs.caption??``),u.addEventListener(`input`,()=>{this.updateAttrs({caption:u.value})}),u.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this.view.focus())}),i.appendChild(u),this.captionInput=u,this.refresh()}update(e){return e.type===this.node.type&&(this.node=e,document.activeElement!==this.captionInput&&(this.captionInput.value=String(e.attrs.caption??``)),this.refresh(),!0)}selectNode(){this.dom.dataset.selected=`true`}deselectNode(){this.dom.dataset.selected=`false`}stopEvent(e){let t=e.target;return!!(t.closest(`.tiptap-embed-card-header`)||t.closest(`.tiptap-embed-card-caption`))}ignoreMutation(){return!0}destroy(){}refresh(){let e=String(this.node.attrs.url??``),t=String(this.node.attrs.providerName??``)||rk(e);this.providerLabel.textContent=t,this.urlLink.href=e,this.urlLink.textContent=e}updateAttrs(e){let t=this.getPos();if(t===void 0)return;let n=this.view.state.tr.setNodeMarkup(t,void 0,{...this.node.attrs,...e});this.view.dispatch(n)}requestEdit(){HT({initialUrl:String(this.node.attrs.url??``),initialCaption:String(this.node.attrs.caption??``)}).then(e=>{if(!e)return;let t=this.getPos();if(t===void 0)return;if(e.kind===`link`){let n=t,r=t+this.node.nodeSize;this.editor.chain().focus().insertContentAt({from:n,to:r},{type:`paragraph`,content:[{type:`text`,text:e.url,marks:[{type:`link`,attrs:{href:e.url}}]}]}).run();return}if(e.kind!==`embed`)return;let n=se(e.url),r=n?{url:n.url||e.url,provider:n.provider,providerName:n.providerName,src:n.src,orientation:n.orientation,heightPx:n.heightPx??null,sandbox:n.sandbox,allow:n.allow??``,caption:e.caption??``}:{...this.node.attrs,url:e.url,caption:e.caption??``},i=this.view.state.tr.setNodeMarkup(t,void 0,r);this.view.dispatch(i)})}};function rk(e){if(!e)return`Embed`;try{return new URL(e.startsWith(`http`)?e:`https://${e}`).hostname}catch{return`Embed`}}var ik=U.create({name:`embed`,group:`block`,atom:!0,selectable:!0,draggable:!0,addAttributes(){return{url:{default:``},provider:{default:``},providerName:{default:``},src:{default:``},orientation:{default:`landscape`},heightPx:{default:null},sandbox:{default:``},allow:{default:``},caption:{default:``}}},parseHTML(){return[{tag:`figure[data-jant-node="embed"]`,getAttrs(e){let t=e;return{url:t.getAttribute(`data-url`)??``,provider:t.getAttribute(`data-provider`)??``,providerName:t.getAttribute(`data-provider-name`)??``,src:t.getAttribute(`data-src`)??``,orientation:t.getAttribute(`data-orientation`)??`landscape`}}}]},renderHTML({node:e}){let t={"data-jant-node":`embed`};return e.attrs.provider&&(t[`data-provider`]=String(e.attrs.provider)),e.attrs.providerName&&(t[`data-provider-name`]=String(e.attrs.providerName)),e.attrs.url&&(t[`data-url`]=String(e.attrs.url)),e.attrs.src&&(t[`data-src`]=String(e.attrs.src)),e.attrs.orientation&&(t[`data-orientation`]=String(e.attrs.orientation)),[`figure`,t]},parseMarkdown:(e,t)=>{let n=typeof e.url==`string`?e.url:``,r=e.attrs&&typeof e.attrs==`object`?e.attrs:{};return t.createNode(`embed`,{url:n,caption:r.caption??``})},renderMarkdown:e=>{let t=e.attrs??{},n=typeof t.url==`string`?t.url.trim():``;if(!n)return``;let r=[n],i=typeof t.caption==`string`?t.caption.trim():``;return i&&r.push(`caption=${i}`),["```jant-embed",...r,"```"].join(`
|
|
253
|
-
`)},markdownTokenizer:
|
|
254
|
-
`).length),o.addEventListener(`input`,()=>{this.updateAttrs({html:o.value}),this.autoGrow()}),i.appendChild(o),this.textarea=o;let s=document.createElement(`p`);s.className=`tiptap-html-block-hint`,s.textContent=`Renders on the published page only.`,i.appendChild(s),queueMicrotask(()=>this.autoGrow())}update(e){return e.type===this.node.type&&(this.node=e,document.activeElement!==this.textarea&&(this.textarea.value=String(e.attrs.html??``),this.autoGrow()),!0)}selectNode(){this.dom.dataset.selected=`true`}deselectNode(){this.dom.dataset.selected=`false`}stopEvent(e){return e.target.closest(`.tiptap-html-block-textarea`)!==null}ignoreMutation(){return!0}destroy(){}autoGrow(){this.textarea.style.height=`auto`,this.textarea.style.height=`${this.textarea.scrollHeight}px`}updateAttrs(e){let t=this.getPos();if(t===void 0)return;let n=this.view.state.tr.setNodeMarkup(t,void 0,{...this.node.attrs,...e});this.view.dispatch(n)}},
|
|
255
|
-
`),markdownTokenizer:
|
|
256
|
+
`,m);if(e===-1||e>=d)break;f.push(e+1),m=e+1}let h=t.tr,g=0,_=0;for(let e=0;e<f.length;e++){let t=f[e],n=l.slice(t),r=n.startsWith(yO)?2:+!!n.startsWith(` `);if(r>0){let n=c+t+g;h=h.delete(n,n+r),g-=r,e===0&&(_=r)}}if(g<0){let e=Math.max(i-_,c),t=a+g;h.setSelection(j.create(h.doc,e,Math.max(t,e)))}return n(h),!0}return!1}}}});function xO(e){let{schema:t}=e.doc.type;return e.parent.type===t.nodes.paragraph?e.depth===1?{kind:`plain`,topIndex:e.index(0)}:e.depth===2&&e.node(1).type===t.nodes.blockquote?{kind:`quote`,topIndex:e.index(0),quoteChildIndex:e.index(1)}:null:null}function SO(e,t){return e.type.name===`blockquote`&&(t===`backward`?e.lastChild:e.firstChild)?.type.name===`paragraph`?`quote`:null}function CO(e,t,n){let r=n===`backward`?-1:1;if(t.kind===`quote`){let n=e.doc.child(t.topIndex),i=t.quoteChildIndex;if(i===void 0)return null;let a=i+r;if(a>=0&&a<n.childCount)return n.child(a).type.name===`paragraph`?`quote`:null}let i=t.topIndex+r;if(i<0||i>=e.doc.childCount)return null;let a=e.doc.child(i);return a.type.name===`paragraph`?`plain`:SO(a,n)}function wO(e,t){let{selection:n}=e.state;if(!n.empty)return!1;let{$from:r}=n;if(!(t===`backward`?r.parentOffset===0:r.parentOffset===r.parent.content.size))return!1;let i=xO(r);if(!i)return!1;let a=CO(r,i,t);return!a||i.kind!==`quote`&&a!==`quote`?!1:t===`backward`?e.commands.joinTextblockBackward():e.commands.joinTextblockForward()}function TO(e){let t=e?.type.name;return t===`bulletList`||t===`orderedList`}function EO(e){let t=e.depth-1;return t<=0||e.node(t).type.name!==`listItem`?null:TO(e.node(t-1))?t:null}function DO(e,t){let{state:n}=e,{$from:r}=n.selection;if(r.node(t-2).type.name!==`listItem`)return!1;let i=new Be(n.doc.resolve(r.start(t)),n.doc.resolve(r.end(t)),t),a=fn(i);return a!==null&&(e.view.dispatch(n.tr.lift(i,a).scrollIntoView()),!0)}function OO(e){let{$from:t}=e.state.selection,n=EO(t);if(n===null)return!1;let r=t.index(n);return r===0?DO(e,n):!t.node(n).child(r-1).isTextblock&&e.commands.joinTextblockBackward()}function kO(e){let{selection:t}=e.state;return!t.empty||!t.$from.parent.isTextblock||t.$from.parentOffset!==0?!1:e.commands.undoInputRule()?!0:OO(e)||wO(e,`backward`)}function AO(e){if(e.parent.type.spec.isolating)return null;for(let t=e.depth-1;t>=0;--t){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}function jO(e,t){let{state:n}=e,{$from:r}=n.selection,i=t.nodeAfter,a=i?.firstChild,o=a?.firstChild;if(!i||!a||a.childCount<2||!o?.isTextblock||r.parent.type.spec.code)return!1;let s=a.content.cut(o.nodeSize),c=i.content.cut(a.nodeSize),l=c.size>0?s.addToEnd(i.copy(c)):s,u=t.index();if(!t.parent.canReplace(u,u+1,l))return!1;let d=n.tr.replaceWith(t.pos,t.pos+i.nodeSize,l).insert(r.pos,D.from(o.content));return d.setSelection(j.create(d.doc,r.pos)),e.view.dispatch(d.scrollIntoView()),!0}function MO(e){let{selection:t}=e.state;if(!t.empty)return!1;let{$from:n}=t;if(!n.parent.isTextblock||n.parentOffset!==n.parent.content.size)return!1;let r=AO(n);if(!r)return!1;let{nodeBefore:i,nodeAfter:a}=r;return TO(i)||TO(a)||i?.type.name===`listItem`?r.pos===n.after()&&TO(a)&&jO(e,r)?!0:e.commands.joinTextblockForward():!1}function NO(e){return wO(e,`forward`)||MO(e)}var PO=H.create({name:`structuralKeymap`,priority:1e3,addKeyboardShortcuts(){return{Backspace:({editor:e})=>kO(e),"Mod-Backspace":({editor:e})=>kO(e),"Shift-Backspace":({editor:e})=>kO(e),Delete:({editor:e})=>NO(e),"Mod-Delete":({editor:e})=>NO(e),Tab:({editor:e})=>e.isActive(`listItem`)?(e.commands.sinkListItem(`listItem`),!0):!1,"Shift-Tab":({editor:e})=>e.isActive(`listItem`)?(e.commands.liftListItem(`listItem`),!0):!1}}});function FO(e){return e.type.name===`bulletList`||e.type.name===`orderedList`}function IO(e,t=-1,n=e){let r=t+1,i=0,a=null;for(let t=0;t<e.childCount;t+=1){let o=e.child(t),s=r+i;if(a&&FO(a)&&a.type===o.type&&En(n,s))return s;let c=IO(o,s,n);if(c!==null)return c;i+=o.nodeSize,a=o}return null}function LO(e){let t=e.tr,n=!1,r=IO(t.doc);for(;r!==null;)t.join(r),n=!0,r=IO(t.doc);return n?t:null}var RO=H.create({name:`continuousLists`,onCreate(){let e=LO(this.editor.state);e&&this.editor.view.dispatch(e.setMeta(`addToHistory`,!1))},addProseMirrorPlugins(){return[new N({appendTransaction:(e,t,n)=>e.some(e=>e.docChanged)?LO(n):null})]}}),zO=/\[([^\]]+)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/,BO=RegExp(zO.source+`$`),VO=RegExp(zO.source+`\\s$`),HO=/((?:https?:\/\/|mailto:|tel:|sms:)[^\s<]+)\s$/i,UO=H.create({name:`linkInputRules`,addInputRules(){let t=this.editor.schema.marks.link;if(!t)return[];function n(n,r,i,a){let o=i[1]?.trim(),s=e(i[2]??``);if(!o||!s)return null;let c=a?o+a:o;n.tr.insertText(c,r.from,r.to),n.tr.addMark(r.from,r.from+o.length,t.create({href:s})),n.tr.removeStoredMark(t)}return[new Cf({find:HO,handler:({state:n,range:r,match:i})=>{let a=e(i[1]??``);if(!a)return null;let o=r.from+a.length;if(n.doc.rangeHasMark(r.from,o,t))return null;n.tr.addMark(r.from,o,t.create({href:a})),n.tr.removeStoredMark(t)}}),new Cf({find:BO,handler:({state:e,range:t,match:r})=>{n(e,t,r,``)}}),new Cf({find:VO,handler:({state:e,range:t,match:r})=>{n(e,t,r,` `)}})]}});function WO(e,t){let{state:n}=e,r=n.schema.nodes.paragraph;if(!r)return!1;let{selection:i}=n,{$from:a,$to:o}=i,s;s=a.depth===0?t===`above`?i.from:i.to:t===`above`?a.before(1):o.after(1);let c=n.tr.insert(s,r.create());return c.setSelection(j.create(c.doc,s+1)),e.view.dispatch(c.scrollIntoView()),!0}var GO=H.create({name:`insertParagraphAround`,addKeyboardShortcuts(){let e=({editor:e})=>{let{state:t}=e,{selection:n}=t;if(!n.empty)return!1;let{$from:r}=n;if(r.depth<1||r.pos!==r.depth)return!1;let i=t.doc.firstChild;return!i||i.type.name===`paragraph`?!1:WO(e,`above`)};return{ArrowUp:e,ArrowLeft:e,"Mod-Shift-Enter":({editor:e})=>WO(e,`above`),"Mod-Alt-Enter":({editor:e})=>WO(e,`below`)}}}),KO=/\[\^([^\]\n]+)\]([ \t.,!?;)]$)/,qO=/^\[\^([^\]\n]+)\]: $/,JO=/\[\^([^\]\n]+)\]$/;function YO(e){let t=new Set;return e.descendants(e=>{if(e.type.name!==`footnoteReference`&&e.type.name!==`footnoteDefinition`)return!0;let n=m(e.attrs.label);return n&&t.add(h(n)),!0}),t}function XO(e){let t=YO(e),n=1;for(;t.has(String(n));)n+=1;return String(n)}function ZO(e){let t=e.content.size;return e.forEach((e,n)=>{e.type.name===`footnoteDefinition`&&(t=n+e.nodeSize)}),t}function QO(e,t){let n=h(t),r=null;return e.forEach((e,t)=>{r===null&&e.type.name===`footnoteDefinition`&&h(e.attrs.label)===n&&(r=t)}),r}function $O(e,t){let n=h(t),r=null;return e.forEach((e,t)=>{r===null&&e.type.name===`footnoteDefinition`&&h(e.attrs.label)===n&&(r={from:t,to:t+e.nodeSize})}),r}function ek(e,t){let n=h(t),r=[];return e.descendants((e,t)=>(e.type.name===`footnoteReference`&&h(e.attrs.label)===n&&r.push({from:t,to:t+e.nodeSize}),!0)),r}function tk(e,t){let n=e.schema.nodes.footnoteReference;return n?n.create({label:t}):null}function nk(e,t){let n=e.schema.nodes.footnoteDefinition,r=e.schema.nodes.paragraph;return!n||!r?null:n.create({label:t},[r.create()])}function rk(e,t){let n=Math.min(t+2,e.doc.content.size);e.setSelection(j.near(e.doc.resolve(n),1))}function ik(e,t){let n=null,r=null;e.doc.forEach((e,i)=>{i===t&&e.type.name===`paragraph`&&e.content.size===0&&(n=i,r=i+e.nodeSize)}),n!==null&&r!==null&&e.delete(n,r)}function ak(e,t,n){let r=QO(t.doc,n);if(r!==null)return r;let i=nk(e,n);if(!i)return null;let a=ZO(t.doc);return t.insert(a,i),ik(t,a+i.nodeSize),a}function ok(e){let t=new Set,n=new Set,r=[];return e.forEach(e=>{if(e.type.name!==`footnoteDefinition`)return;let n=m(e.attrs.label);n&&t.add(h(n))}),e.descendants(e=>{if(e.type.name!==`footnoteReference`)return!0;let i=m(e.attrs.label),a=h(i);return i&&!t.has(a)&&!n.has(a)&&(n.add(a),r.push(i)),!0}),r}function sk(e){let t=ok(e.doc);if(t.length===0)return null;let n=e.tr;for(let r of t)ak(e,n,r);return n.docChanged?n:null}function ck(e){let{selection:t}=e;return!(t instanceof M)||t.node.type.name!==`footnoteReference`?null:m(t.node.attrs.label)||null}function lk(e,t){let n=e.tr,r=ak(e,n,t);return r===null?null:(rk(n,r),n.scrollIntoView(),n)}function uk(e,t){if(t.doc.childCount>0)return;let n=e.schema.nodes.paragraph;n&&t.insert(0,n.create())}function dk(e,t){if(!t||e.doc.childCount<2)return;let n=e.doc.lastChild,r=e.doc.child(e.doc.childCount-2);n?.type.name===`paragraph`&&n.content.size===0&&r.type.name!==`footnoteDefinition`&&e.delete(e.doc.content.size-n.nodeSize,e.doc.content.size)}function fk(e,t){let n=Math.min(Math.max(t,0),e.doc.content.size);e.setSelection(j.near(e.doc.resolve(n),-1))}function pk(e,t){let n=[...t].sort((e,t)=>t.from-e.from);for(let t of n)e.delete(t.from,t.to)}function mk(e,t){let n=$O(e.doc,t),r=[...ek(e.doc,t),...n?[n]:[]];if(r.length===0)return null;let i=e.tr;return pk(i,r),uk(e,i),dk(i,n),fk(i,r[0]?.from??0),i.scrollIntoView(),i}function hk(e,t){let n=e.doc.nodeAt(t.from);if(!n||n.type.name!==`footnoteReference`)return null;let r=m(n.attrs.label);if(!r)return null;let i=ek(e.doc,r),a=$O(e.doc,r),o=i.length<=1?[t,...a?[a]:[]]:[t],s=e.tr;return pk(s,o),uk(e,s),dk(s,i.length<=1?a:null),fk(s,t.from),s.scrollIntoView(),s}function gk(e,t){let{selection:n}=e;if(n instanceof M)return n.node.type.name===`footnoteReference`?{from:n.from,to:n.to}:null;if(!n.empty)return null;let{$from:r}=n,i=t===`backward`?r.nodeBefore:r.nodeAfter;if(!i||i.type.name!==`footnoteReference`)return null;let a=t===`backward`?n.from-i.nodeSize:n.from;return{from:a,to:a+i.nodeSize}}function _k(e){let{selection:t}=e;if(t instanceof M)return t.node.type.name===`footnoteDefinition`?m(t.node.attrs.label):null;if(!t.empty)return null;let{$from:n}=t,r=-1;for(let e=n.depth;e>0;--e)if(n.node(e).type.name===`footnoteDefinition`){r=e;break}return r===-1||n.parent.type.name!==`paragraph`||n.parentOffset!==0||n.index(r)!==0?null:m(n.node(r).attrs.label)}function vk(e,t,n,r,i){let a=tk(e,t);if(!a)return!1;let o=[a];n&&o.push(e.schema.text(n));let s=e.tr;return s.replaceWith(r,i,D.fromArray(o)),ak(e,s,t)!==null}function yk(e,t){let n=nk(e,t);if(!n)return!1;let{$from:r}=e.selection;if(r.depth!==1||r.parent.type.name!==`paragraph`)return!1;let i=e.tr.replaceWith(r.before(),r.after(),n);return ik(i,r.before()+n.nodeSize),rk(i,r.before()),i.scrollIntoView(),!0}function bk(e,t){let n=nk(e,t);if(!n)return!1;let{$from:r}=e.selection;if(r.parent.type.name!==`paragraph`||r.depth<2||r.node(r.depth-1).type.name!==`footnoteDefinition`)return!1;let i=r.depth,a=r.before(i),o=r.after(i),s=i-1,c=r.node(s),l=r.after(s),u=e.tr;c.childCount===1?u.delete(a+1,o-1):u.delete(a,o);let d=u.mapping.map(l);return u.insert(d,n),ik(u,d+n.nodeSize),rk(u,d),u.scrollIntoView(),!0}function xk(e){let{$from:t}=e.selection;for(let e=t.depth;e>0;--e)if(t.node(e).type.name===`footnoteDefinition`)return!0;return!1}function Sk(e){let{selection:t}=e,{$from:n}=t;if(!t.empty||xk(e)||!n.parent.inlineContent||n.parent.type.name!==`paragraph`||n.parentOffset!==n.parent.content.size)return null;let r=n.parent.textBetween(0,n.parentOffset,void 0,``).match(JO),i=m(r?.[1]);return!r||!i?null:{label:i,from:t.from-r[0].length,to:t.from}}function Ck(e){let t=Sk(e);if(t){let n=tk(e,t.label);if(!n)return null;let r=e.tr.replaceWith(t.from,t.to,n),i=ak(e,r,t.label);return i===null?null:(rk(r,i),r.scrollIntoView(),r)}return null}function wk(){return[new Cf({find:qO,handler:({state:e,match:t})=>{let n=m(t[1]);if(!n)return null;let{$from:r}=e.selection;return r.depth!==1||r.parent.type.name!==`paragraph`?bk(e,n)?void 0:null:yk(e,n)?void 0:null}}),new Cf({find:KO,handler:({state:e,range:t,match:n})=>{let r=m(n[1]),i=n[2]??``;return!r||!i||!e.selection.$from.parent.inlineContent?null:vk(e,r,i,t.from,t.to)?void 0:null}})]}var Tk=H.create({name:`footnotes`,onCreate(){let e=sk(this.editor.state);e&&this.editor.view.dispatch(e)},addProseMirrorPlugins(){return[new N({appendTransaction:(e,t,n)=>e.some(e=>e.docChanged)?sk(n):null,props:{handleClickOn:(e,t,n,r,i,a)=>{if(!a||n.type.name!==`footnoteReference`)return!1;let o=m(n.attrs.label);if(!o)return!1;let s=lk(e.state,o);return s?(e.dispatch(s),e.focus(),!0):!1},handleClick:(e,t)=>{let n=e.state.doc.resolve(t);if(n.nodeBefore?.type.name!==`footnoteDefinition`||n.nodeAfter?.type.name!==`footnoteDefinition`)return!1;let r=e.state.tr;return rk(r,t),e.dispatch(r.scrollIntoView()),e.focus(),!0}}})]},addCommands(){return{insertFootnote:()=>({state:e,dispatch:t})=>{if(!e.selection.$from.parent.inlineContent)return!1;let n=XO(e.doc),r=tk(e,n),i=nk(e,n);if(!r||!i)return!1;let a=ZO(e.doc),o=e.tr.replaceSelectionWith(r,!1),s=o.mapping.map(a);return o.insert(s,i),ik(o,s+i.nodeSize),rk(o,s),t&&t(o.scrollIntoView()),!0}}},addInputRules(){return wk()},addKeyboardShortcuts(){return{Enter:({editor:e})=>{let t=ck(e.state);if(t){let n=lk(e.state,t);return n?(e.view.dispatch(n),!0):!1}let n=Ck(e.state);return n?(e.view.dispatch(n),!0):!1},Backspace:({editor:e})=>{let t=_k(e.state);if(t){let n=mk(e.state,t);return n?(e.view.dispatch(n),!0):!1}let n=gk(e.state,`backward`);if(!n)return!1;let r=hk(e.state,n);return r?(e.view.dispatch(r),!0):!1},Delete:({editor:e})=>{let t=gk(e.state,`forward`);if(!t)return!1;let n=hk(e.state,t);return n?(e.view.dispatch(n),!0):!1}}}});function Ek(e,t,n=`paragraph`){let{$to:r}=e.selection,i=r.end();if(r.nodeAfter)r.nodeAfter.isTextblock?e.setSelection(j.create(e.doc,r.pos+1)):r.nodeAfter.isBlock?e.setSelection(M.create(e.doc,r.pos)):e.setSelection(j.create(e.doc,r.pos));else{let a=(t.nodes[n]??r.parent.type.contentMatch.defaultType)?.create();a&&(e.insert(i,a),e.setSelection(j.create(e.doc,i+1)))}e.scrollIntoView()}var Dk=`jant:inline-image-load-state`,Ok={unavailable:`Image unavailable`,delete:`Delete image`,replace:`Replace image`,open:`Open image URL`},kk={imageBroken:`<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="16" rx="2.5"/><circle cx="8.5" cy="9.5" r="1.5"/><path d="m5 17 4.25-4.25 2.5 2.5 1.75-1.75L19 19"/><path d="m4 4 16 16"/></svg>`,regular:`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><rect x="3" y="3" width="10" height="10" rx="1.5"/></svg>`,wide:`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><rect x="1.5" y="4" width="13" height="8" rx="1.5"/></svg>`,full:`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><rect x="0.75" y="3" width="14.5" height="10" rx="1"/><path d="M4 8h8M4 6l-1.5 2L4 10M12 6l1.5 2L12 10"/></svg>`,link:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,replace:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/><path d="M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16"/><path d="M16 16h5v5"/></svg>`,expand:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h6v6"/><path d="M9 21H3v-6"/><path d="M21 3l-7 7"/><path d="M3 21l7-7"/></svg>`},Ak=class{dom;img;missingPanel;missingSource;openBtn;figcaption;captionInput;altBtn;toolbar;captionBar;layoutBtns=new Map;node;view;getPos;editor;labels;editingAlt=!1;missing=!1;currentSrc=``;constructor(e,t,n,r,i){this.node=e,this.view=t,this.getPos=n,this.editor=r,this.labels=i;let a=document.createElement(`figure`);a.className=`tiptap-image-figure`,a.dataset.selected=`false`,a.dataset.layout=String(e.attrs.layout||`regular`),a.dataset.loadState=`loading`,this.dom=a;let o=document.createElement(`div`);o.className=`tiptap-image-container`,a.appendChild(o);let s=document.createElement(`img`);s.draggable=!1,s.addEventListener(`load`,()=>this.setMissing(!1)),s.addEventListener(`error`,()=>this.setMissing(!0)),o.appendChild(s),this.img=s;let c=document.createElement(`div`);c.className=`tiptap-image-missing`,c.role=`group`,c.tabIndex=0,c.setAttribute(`aria-label`,i.unavailable),c.addEventListener(`keydown`,e=>{(e.key===`Delete`||e.key===`Backspace`)&&(e.preventDefault(),this.deleteNode())}),o.appendChild(c),this.missingPanel=c;let l=document.createElement(`span`);l.className=`tiptap-image-missing-icon`,l.setAttribute(`aria-hidden`,`true`),l.innerHTML=kk.imageBroken,c.appendChild(l);let u=document.createElement(`span`);u.className=`tiptap-image-missing-copy`,c.appendChild(u);let d=document.createElement(`strong`);d.textContent=i.unavailable,u.appendChild(d);let f=document.createElement(`span`);f.className=`tiptap-image-missing-source`,u.appendChild(f),this.missingSource=f;let p=document.createElement(`span`);p.className=`tiptap-image-missing-actions`,c.appendChild(p);let m=document.createElement(`button`);m.type=`button`,m.className=`tiptap-image-missing-delete`,m.textContent=i.delete,m.addEventListener(`mousedown`,e=>{e.preventDefault(),this.deleteNode()}),p.appendChild(m);let h=document.createElement(`button`);h.type=`button`,h.textContent=i.replace,h.addEventListener(`mousedown`,e=>{e.preventDefault(),this.handleReplace()}),p.appendChild(h);let g=document.createElement(`button`);g.type=`button`,g.textContent=i.open,g.addEventListener(`mousedown`,e=>{e.preventDefault(),this.handleOpenOriginal()}),p.appendChild(g),this.openBtn=g;let _=document.createElement(`div`);_.className=`tiptap-image-toolbar`,o.appendChild(_),this.toolbar=_;let v=[[`regular`,kk.regular,`Content width`],[`wide`,kk.wide,`Wide — max 1200px`],[`full`,kk.full,`Full width — edge to edge`]];for(let[t,n,r]of v){this.layoutBtns.size>0&&_.appendChild(this.sep());let i=document.createElement(`button`);i.type=`button`,i.innerHTML=n,i.title=r,i.dataset.layout=t,t===(e.attrs.layout||`regular`)&&(i.className=`is-active`),i.addEventListener(`mousedown`,e=>{e.preventDefault(),this.updateAttrs({layout:t})}),_.appendChild(i),this.layoutBtns.set(t,i)}_.appendChild(this.sep());let y=this.iconBtn(kk.link,`Add link`);y.addEventListener(`mousedown`,e=>{e.preventDefault(),this.handleLink()}),_.appendChild(y),_.appendChild(this.sep());let b=this.iconBtn(kk.replace,`Replace image`);b.addEventListener(`mousedown`,e=>{e.preventDefault(),this.handleReplace()}),_.appendChild(b),_.appendChild(this.sep());let x=this.iconBtn(kk.expand,`Preview fullscreen`);x.addEventListener(`mousedown`,e=>{e.preventDefault(),this.handleExpand()}),_.appendChild(x);let S=document.createElement(`div`);S.className=`tiptap-image-caption-bar`,a.appendChild(S),this.captionBar=S;let C=document.createElement(`input`);C.type=`text`,C.placeholder=`Add a caption…`,C.value=String(e.attrs.caption??``),C.addEventListener(`input`,()=>{this.editingAlt?this.updateAttrs({alt:C.value}):this.updateAttrs({caption:C.value})}),C.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this.view.focus())}),S.appendChild(C),this.captionInput=C;let w=document.createElement(`button`);w.type=`button`,w.className=`tiptap-image-alt-btn`,w.textContent=`Alt`,w.addEventListener(`mousedown`,e=>{e.preventDefault(),this.toggleAltMode()}),S.appendChild(w),this.altBtn=w;let T=document.createElement(`figcaption`);T.className=`tiptap-image-figcaption`,T.textContent=String(e.attrs.caption??``),a.appendChild(T),this.figcaption=T,this.syncImageAttrs(e)}update(e){if(e.type!==this.node.type)return!1;this.node=e,this.syncImageAttrs(e),this.dom.dataset.layout=String(e.attrs.layout||`regular`),this.layoutBtns.forEach((t,n)=>{t.classList.toggle(`is-active`,n===(e.attrs.layout||`regular`))});let t=String(e.attrs.caption??``);return this.figcaption.textContent=t,document.activeElement!==this.captionInput&&(this.editingAlt?this.captionInput.value=String(e.attrs.alt??``):this.captionInput.value=t),!0}selectNode(){this.dom.dataset.selected=`true`}deselectNode(){this.dom.dataset.selected=`false`,this.editingAlt=!1,this.altBtn.classList.remove(`is-active`),this.captionInput.placeholder=`Add a caption…`,this.captionInput.value=String(this.node.attrs.caption??``)}stopEvent(e){let t=e.target;return!!(t.closest(`.tiptap-image-toolbar`)||t.closest(`.tiptap-image-caption-bar`)||t.closest(`.tiptap-image-missing`))}ignoreMutation(){return!0}destroy(){}sep(){let e=document.createElement(`span`);return e.className=`tiptap-toolbar-sep`,e}iconBtn(e,t){let n=document.createElement(`button`);return n.type=`button`,n.innerHTML=e,n.title=t,n}updateAttrs(e){let t=this.getPos();if(t===void 0)return;let n=this.view.state.tr.setNodeMarkup(t,void 0,{...this.node.attrs,...e});this.view.dispatch(n)}syncImageAttrs(e){let t=String(e.attrs.src??``);if(this.img.alt=String(e.attrs.alt??``),this.img.title=String(e.attrs.title??``),this.missingSource.textContent=jk(t),this.openBtn.disabled=!Mk(t),t!==this.currentSrc){this.currentSrc=t,this.setMissing(!1),this.dom.dataset.loadState=`loading`,this.img.setAttribute(`src`,t),this.checkCachedImageState();return}this.checkCachedImageState()}checkCachedImageState(){queueMicrotask(()=>{this.img.complete&&this.img.getAttribute(`src`)===this.currentSrc&&this.setMissing(this.img.naturalWidth===0)})}setMissing(e){if(this.missing===e){this.dom.dataset.loadState=e?`missing`:`loaded`;return}this.missing=e,this.dom.dataset.loadState=e?`missing`:`loaded`,this.dom.dispatchEvent(new CustomEvent(Dk,{bubbles:!0,composed:!0,detail:{src:this.currentSrc,missing:e}}))}deleteNode(){let e=this.getPos();if(e===void 0)return;let t=this.view.state.tr.delete(e,e+this.node.nodeSize);this.view.dispatch(t),this.view.focus()}handleLink(){if(String(this.node.attrs.href??``))this.updateAttrs({href:``});else{let e=globalThis.prompt(`Enter URL`);e&&this.updateAttrs({href:e})}}handleReplace(){let e=document.createElement(`input`);e.type=`file`,e.accept=`image/*`,e.addEventListener(`change`,async()=>{let t=e.files?.[0];if(t)try{let e=await HD(t);this.updateAttrs({src:e.url})}catch{}}),e.click()}handleOpenOriginal(){let e=String(this.node.attrs.src??``);Mk(e)&&window.open(e,`_blank`,`noopener,noreferrer`)}handleExpand(){let e=document.querySelector(`jant-media-lightbox`);e&&e.open([{url:String(this.node.attrs.src??``),alt:String(this.node.attrs.alt??``)}],0)}toggleAltMode(){this.editingAlt=!this.editingAlt,this.altBtn.classList.toggle(`is-active`,this.editingAlt),this.editingAlt?(this.captionInput.placeholder=`Add alt text…`,this.captionInput.value=String(this.node.attrs.alt??``)):(this.captionInput.placeholder=`Add a caption…`,this.captionInput.value=String(this.node.attrs.caption??``)),this.captionInput.focus()}};function jk(e){let t=e.trim();return t?t.length>140?`${t.slice(0,137)}...`:t:``}function Mk(e){let t=e.trim();return t?/^(https?:|\/|\.\/|\.\.\/|blob:)/i.test(t):!1}var Nk=U.create({name:`image`,group:`block`,atom:!0,selectable:!0,draggable:!0,addOptions(){return{labels:Ok}},addAttributes(){return{src:{default:``},alt:{default:``},title:{default:``},caption:{default:``},href:{default:``},layout:{default:`regular`}}},parseHTML(){return[{tag:`figure[data-image]`,getAttrs(e){let t=e,n=t.querySelector(`img`),r=t.querySelector(`figcaption`),i=t.querySelector(`a`);return{src:n?.getAttribute(`src`)??``,alt:n?.getAttribute(`alt`)??``,title:n?.getAttribute(`title`)??``,caption:r?.textContent??``,href:i?.getAttribute(`href`)??``,layout:t.dataset.layout??`regular`}}},{tag:`figure`,getAttrs(e){let t=e,n=t.querySelector(`img`);if(!n)return!1;let r=t.querySelector(`figcaption`),i=t.querySelector(`a`);return{src:n.getAttribute(`src`)??``,alt:n.getAttribute(`alt`)??``,title:n.getAttribute(`title`)??``,caption:r?.textContent??``,href:i?.getAttribute(`href`)??``,layout:t.dataset.layout??`regular`}}},{tag:`img[src]`,getAttrs(e){let t=e;return{src:t.getAttribute(`src`)??``,alt:t.getAttribute(`alt`)??``,title:t.getAttribute(`title`)??``}}}]},renderHTML({node:e}){let t={};e.attrs.layout&&e.attrs.layout!==`regular`&&(t[`data-layout`]=e.attrs.layout),t[`data-image`]=``;let n={src:e.attrs.src};e.attrs.alt&&(n.alt=e.attrs.alt),e.attrs.title&&(n.title=e.attrs.title);let r=[`img`,n],i=[];return e.attrs.href?i.push([`a`,{href:e.attrs.href},r]):i.push(r),e.attrs.caption&&i.push([`figcaption`,{},e.attrs.caption]),[`figure`,t,...i]},parseMarkdown:(e,t)=>t.createNode(`image`,{src:e.href,title:e.title??``,alt:e.text??``}),renderMarkdown:e=>pe(e.attrs??{}),addCommands(){return{setImage:e=>({chain:t,state:n})=>{if(!sf(n,n.schema.nodes[this.name]))return!1;let{$to:r}=n.selection,i=t();return td(n.selection)?i.insertContentAt(r.pos,{type:this.name,attrs:e}):i.insertContent({type:this.name,attrs:e}),i.command(({state:e,tr:t,dispatch:n})=>(n&&Ek(t,e.schema),!0)).run()}}},addNodeView(){return({node:e,view:t,getPos:n,editor:r})=>new Ak(e,t,n,r,{...Ok,...this.options.labels??{}})}}),Pk=`<!--more-->`,Fk=U.create({name:`moreBreak`,group:`block`,atom:!0,selectable:!0,draggable:!1,parseHTML(){return[{tag:`div[data-more-break]`}]},renderHTML(){return[`div`,{"data-more-break":``,class:`tiptap-more-break`},`Read More ↓`]},renderText(){return Pk},parseMarkdown:(e,t)=>t.createNode(`moreBreak`),renderMarkdown:()=>Pk,markdownTokenizer:_C(),addCommands(){return{insertMoreBreak:()=>({chain:e,state:t})=>{if(!sf(t,t.schema.nodes[this.name]))return!1;let{$to:n}=t.selection,r=e();return td(t.selection)?r.insertContentAt(n.pos,{type:this.name}):r.insertContent({type:this.name}),r.command(({state:e,tr:t,dispatch:n})=>(n&&Ek(t,e.schema),!0)).run()}}}}),Ik=class{dom;node;view;getPos;editor;providerLabel;urlLink;captionInput;constructor(e,t,n,r){this.node=e,this.view=t,this.getPos=n,this.editor=r;let i=document.createElement(`div`);i.className=`tiptap-embed-card`,i.dataset.selected=`false`,this.dom=i;let a=document.createElement(`div`);a.className=`tiptap-embed-card-header`,i.appendChild(a);let o=document.createElement(`span`);o.className=`tiptap-embed-card-provider`,a.appendChild(o),this.providerLabel=o;let s=document.createElement(`span`);s.className=`tiptap-embed-card-actions`,a.appendChild(s);let c=document.createElement(`button`);c.type=`button`,c.textContent=`Edit`,c.className=`tiptap-embed-card-btn`,c.addEventListener(`mousedown`,e=>{e.preventDefault(),this.requestEdit()}),s.appendChild(c);let l=document.createElement(`a`);l.className=`tiptap-embed-card-url`,l.target=`_blank`,l.rel=`noopener noreferrer`,i.appendChild(l),this.urlLink=l;let u=document.createElement(`input`);u.type=`text`,u.placeholder=`Add a caption…`,u.className=`tiptap-embed-card-caption`,u.value=String(e.attrs.caption??``),u.addEventListener(`input`,()=>{this.updateAttrs({caption:u.value})}),u.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this.view.focus())}),i.appendChild(u),this.captionInput=u,this.refresh()}update(e){return e.type===this.node.type&&(this.node=e,document.activeElement!==this.captionInput&&(this.captionInput.value=String(e.attrs.caption??``)),this.refresh(),!0)}selectNode(){this.dom.dataset.selected=`true`}deselectNode(){this.dom.dataset.selected=`false`}stopEvent(e){let t=e.target;return!!(t.closest(`.tiptap-embed-card-header`)||t.closest(`.tiptap-embed-card-caption`))}ignoreMutation(){return!0}destroy(){}refresh(){let e=String(this.node.attrs.url??``),t=String(this.node.attrs.providerName??``)||Lk(e);this.providerLabel.textContent=t,this.urlLink.href=e,this.urlLink.textContent=e}updateAttrs(e){let t=this.getPos();if(t===void 0)return;let n=this.view.state.tr.setNodeMarkup(t,void 0,{...this.node.attrs,...e});this.view.dispatch(n)}requestEdit(){yE({initialUrl:String(this.node.attrs.url??``),initialCaption:String(this.node.attrs.caption??``)}).then(e=>{if(!e)return;let t=this.getPos();if(t===void 0)return;if(e.kind===`link`){let n=t,r=t+this.node.nodeSize;this.editor.chain().focus().insertContentAt({from:n,to:r},{type:`paragraph`,content:[{type:`text`,text:e.url,marks:[{type:`link`,attrs:{href:e.url}}]}]}).run();return}if(e.kind!==`embed`)return;let n=se(e.url),r=n?{url:n.url||e.url,provider:n.provider,providerName:n.providerName,src:n.src,orientation:n.orientation,heightPx:n.heightPx??null,sandbox:n.sandbox,allow:n.allow??``,caption:e.caption??``}:{...this.node.attrs,url:e.url,caption:e.caption??``},i=this.view.state.tr.setNodeMarkup(t,void 0,r);this.view.dispatch(i)})}};function Lk(e){if(!e)return`Embed`;try{return new URL(e.startsWith(`http`)?e:`https://${e}`).hostname}catch{return`Embed`}}var Rk=U.create({name:`embed`,group:`block`,atom:!0,selectable:!0,draggable:!0,addAttributes(){return{url:{default:``},provider:{default:``},providerName:{default:``},src:{default:``},orientation:{default:`landscape`},heightPx:{default:null},sandbox:{default:``},allow:{default:``},caption:{default:``}}},parseHTML(){return[{tag:`figure[data-jant-node="embed"]`,getAttrs(e){let t=e;return{url:t.getAttribute(`data-url`)??``,provider:t.getAttribute(`data-provider`)??``,providerName:t.getAttribute(`data-provider-name`)??``,src:t.getAttribute(`data-src`)??``,orientation:t.getAttribute(`data-orientation`)??`landscape`}}}]},renderHTML({node:e}){let t={"data-jant-node":`embed`};return e.attrs.provider&&(t[`data-provider`]=String(e.attrs.provider)),e.attrs.providerName&&(t[`data-provider-name`]=String(e.attrs.providerName)),e.attrs.url&&(t[`data-url`]=String(e.attrs.url)),e.attrs.src&&(t[`data-src`]=String(e.attrs.src)),e.attrs.orientation&&(t[`data-orientation`]=String(e.attrs.orientation)),[`figure`,t]},parseMarkdown:(e,t)=>{let n=typeof e.url==`string`?e.url:``,r=e.attrs&&typeof e.attrs==`object`?e.attrs:{};return t.createNode(`embed`,{url:n,caption:r.caption??``})},renderMarkdown:e=>{let t=e.attrs??{},n=typeof t.url==`string`?t.url.trim():``;if(!n)return``;let r=[n],i=typeof t.caption==`string`?t.caption.trim():``;return i&&r.push(`caption=${i}`),["```jant-embed",...r,"```"].join(`
|
|
257
|
+
`)},markdownTokenizer:hC(),addCommands(){return{setEmbed:e=>({chain:t,state:n})=>{if(!sf(n,n.schema.nodes[this.name]))return!1;let r=se(e.url),i=r?{url:r.url||e.url,provider:r.provider,providerName:r.providerName,src:r.src,orientation:r.orientation,heightPx:r.heightPx??null,sandbox:r.sandbox,allow:r.allow??``,caption:e.caption??``}:{url:e.url,caption:e.caption??``},{$to:a}=n.selection,o=t();return td(n.selection)?o.insertContentAt(a.pos,{type:this.name,attrs:i}):o.insertContent({type:this.name,attrs:i}),o.command(({state:e,tr:t,dispatch:n})=>(n&&Ek(t,e.schema),!0)).run()}}},addNodeView(){return({node:e,view:t,getPos:n,editor:r})=>new Ik(e,t,n,r)}}),zk=class{dom;node;view;getPos;editor;textarea;constructor(e,t,n,r){this.node=e,this.view=t,this.getPos=n,this.editor=r;let i=document.createElement(`div`);i.className=`tiptap-html-block-card`,i.dataset.selected=`false`,this.dom=i;let a=document.createElement(`div`);a.className=`tiptap-html-block-header`,a.textContent=`Raw HTML`,i.appendChild(a);let o=document.createElement(`textarea`);o.className=`tiptap-html-block-textarea`,o.spellcheck=!1,o.value=String(e.attrs.html??``),o.rows=Math.max(3,o.value.split(`
|
|
258
|
+
`).length),o.addEventListener(`input`,()=>{this.updateAttrs({html:o.value}),this.autoGrow()}),i.appendChild(o),this.textarea=o;let s=document.createElement(`p`);s.className=`tiptap-html-block-hint`,s.textContent=`Renders on the published page only.`,i.appendChild(s),queueMicrotask(()=>this.autoGrow())}update(e){return e.type===this.node.type&&(this.node=e,document.activeElement!==this.textarea&&(this.textarea.value=String(e.attrs.html??``),this.autoGrow()),!0)}selectNode(){this.dom.dataset.selected=`true`}deselectNode(){this.dom.dataset.selected=`false`}stopEvent(e){return e.target.closest(`.tiptap-html-block-textarea`)!==null}ignoreMutation(){return!0}destroy(){}autoGrow(){this.textarea.style.height=`auto`,this.textarea.style.height=`${this.textarea.scrollHeight}px`}updateAttrs(e){let t=this.getPos();if(t===void 0)return;let n=this.view.state.tr.setNodeMarkup(t,void 0,{...this.node.attrs,...e});this.view.dispatch(n)}},Bk=U.create({name:`htmlBlock`,group:`block`,atom:!0,selectable:!0,draggable:!0,addAttributes(){return{html:{default:``}}},parseHTML(){return[{tag:`div[data-jant-node="html-block"]`,getAttrs(e){return{html:e.textContent??``}}}]},renderHTML({node:e}){return[`div`,{"data-jant-node":`html-block`},String(e.attrs.html??``)]},parseMarkdown:(e,t)=>{let n=typeof e.html==`string`?e.html:``;return t.createNode(`htmlBlock`,{html:n})},renderMarkdown:e=>["```jant-html",typeof e.attrs?.html==`string`?e.attrs.html:``,"```"].join(`
|
|
259
|
+
`),markdownTokenizer:gC(),addCommands(){return{setHtmlBlock:e=>({chain:t,state:n})=>{if(!sf(n,n.schema.nodes[this.name]))return!1;let r={html:e.html},{$to:i}=n.selection,a=t();return td(n.selection)?a.insertContentAt(i.pos,{type:this.name,attrs:r}):a.insertContent({type:this.name,attrs:r}),a.command(({state:e,tr:t,dispatch:n})=>(n&&Ek(t,e.schema),!0)).run()}}},addNodeView(){return({node:e,view:t,getPos:n,editor:r})=>new zk(e,t,n,r)}}),Vk=/^https?:\/\/\S+$/i,Hk=new P(`jantEmbedPaste`),Uk=H.create({name:`embedPaste`,addProseMirrorPlugins(){let e=this.editor;return[new N({key:Hk,props:{handlePaste(t,n){let r=n.clipboardData;if(!r)return!1;let i=r.getData(`text/plain`)?.trim()??``;if(!i||!Vk.test(i))return!1;let{selection:a}=t.state;if(!a.empty)return!1;let o=a.$from,s=o.parent;if(s.type.name!==`paragraph`||s.content.size>0||!ce(i)||!se(i))return!1;n.preventDefault();let c=t.state.schema.marks.link,l=o.pos,u=t.state.tr.insertText(i,l);return c&&u.addMark(l,l+i.length,c.create({href:i})),t.dispatch(u),queueMicrotask(()=>{let n=l,r=l+i.length,a=Hy(t.state.tr).delete(n,r);t.dispatch(a),e.commands.setEmbed({url:i})}),!0}}})]}}),Wk=50,Gk=new P(`jantRehostImages`),Kk=new Set;function qk(e){Kk.delete(e)}var Jk=H.create({name:`rehostImages`,addOptions(){return{shouldRehost:void 0,rehost:void 0}},addProseMirrorPlugins(){let e=this.options;return[new N({key:Gk,appendTransaction(t,n,r){if(!t.some(e=>e.docChanged&&e.getMeta(`paste`)))return null;let{shouldRehost:i,rehost:a}=e;if(!i||!a)return null;let o=[],s=new Set;if(r.doc.descendants(e=>{if(e.type.name!==`image`)return;let t=e.attrs.src;typeof t==`string`&&t&&(s.has(t)||Kk.has(t)||i(t)&&(s.add(t),o.push(t)))}),o.length===0)return null;let c=o.slice(0,Wk),l=o.length-c.length;l>0&&console.warn(`[jant] ${l} pasted image(s) left as external links — per-paste rehost cap of ${Wk} reached.`);for(let e of c)Kk.add(e),queueMicrotask(()=>a(e));return null}})]}}),Yk=/<!--\s*obsidian\s*-->/i,Xk=`section.footnotes, [data-footnotes], [role~="doc-endnotes"]`,Zk=`a.footnote-backref, a.footnote-back, a[data-footnote-backref], a[role~="doc-backlink"]`;function Qk(e){return e instanceof D?e:e.content}function $k(e){let{doc:t,selection:n}=e.state;return n instanceof ar||n.from===0&&n.to===t.content.size}function eA(e){let{doc:t,schema:n,selection:r}=e.state,i=Iu(n);return[...r.ranges].sort((e,t)=>e.$from.pos-t.$from.pos).map(({$from:e,$to:n})=>Pu(t,{from:e.pos,to:n.pos},{textSerializers:i})).join(`
|
|
256
260
|
|
|
257
|
-
`)}function
|
|
261
|
+
`)}function tA(e){return $k(e)?VC(e.getJSON()).trimEnd():eA(e)}function nA(e){if(/data-vscode-/i.test(e))return!0;let t=e.match(/^[^<]*(?:<(?:meta|html|head|body)\b[^>]*>\s*)*<(?:div|pre)\b[^>]*style="([^"]*)"/i);if(t){let e=t[1]??``,n=/font-family:[^;"]*\b(?:monospace|Menlo|Monaco|Consolas|Courier|JetBrains Mono|Fira Code|Source Code Pro)\b/i.test(e),r=/white-space:\s*pre\b/i.test(e);if(n&&r)return!0}return!1}function rA(e){return Yk.test(e)}function iA(e){return e.tagName===`P`&&e.attributes.length===0&&Array.from(e.childNodes).every(e=>e.nodeType===globalThis.Node.TEXT_NODE&&/^[\t\n\f\r ]*$/.test(e.textContent??``))}function aA(e){return e.matches(`meta, link, style, title`)}function oA(e){if(!e.trim()||!rA(e)||typeof document>`u`)return e;let t=document.createElement(`template`);t.innerHTML=e;let n=Array.from(t.content.children),r=new Set(n.filter(iA));if(r.size===0)return e;let i=n.filter(e=>!r.has(e)&&!aA(e)).map(e=>n.indexOf(e)),a=!1;for(let e of r){let t=n.indexOf(e),r=i.some(e=>e<t),o=i.some(e=>e>t);r&&o&&(e.remove(),a=!0)}return a?t.innerHTML:e}function sA(e){let t=e.getData(`text/html`),n=e.getData(`text/markdown`);if(n.trim())return n;let r=e.getData(`text/plain`);return r.trim()&&(rA(t)||nA(t))?r:null}function cA(e,t){return(e.getAttribute(`role`)??``).split(/\s+/).includes(t)}function lA(e){let t=e.getAttribute(`href`)??``;if(!t.startsWith(`#`)||t.length===1)return null;let n=t.slice(1);try{return decodeURIComponent(n)}catch{return n}}function uA(e){return e.getAttribute(`id`)??e.getAttribute(`data-footnote-id`)??``}function dA(e,t){let n=e.parentElement;for(;n&&n!==t;){if(n.tagName===`LI`)return!0;n=n.parentElement}return!1}function fA(e){let t=[];for(let n of e.querySelectorAll(`ol, ul`))if(!(n.closest(Xk)!==e||dA(n,e)))for(let e of n.children)e.tagName===`LI`&&t.push(e);return t}function pA(e){return e.matches(Zk)?!1:e.hasAttribute(`data-footnote-ref`)||e.classList.contains(`footnote-ref`)||cA(e,`doc-noteref`)||e.closest(`sup.footnote-ref`)!==null}function mA(e){let t=e.getAttribute(`data-footref`)??e.getAttribute(`data-footnote-label`);return m(t)?m(t):m(e.textContent).replace(/^\[\^?/,``).replace(/\]$/,``)}function hA(e){let t=e.match(/(?:^|[-_:])fn[-_:]?(.+)$/i)?.[1];return m(t??e)}function gA(e,t,n){let r=m(e)||String(t+1),i=r,a=2;for(;n.has(h(i));)i=`${r}-${a}`,a+=1;return n.add(h(i)),i}function _A(e,t){let n=e.createElement(`sup`);return n.setAttribute(`data-footnote-reference`,``),n.setAttribute(`data-footnote-label`,t),n.className=`tiptap-footnote-reference`,n.textContent=g(t),n}function vA(e){let t=e.element.ownerDocument,n=e.element.cloneNode(!0);for(let e of n.querySelectorAll(Zk))e.remove();for(let e of Array.from(n.querySelectorAll(`p, span`)).reverse())!e.textContent?.trim()&&!e.querySelector(`img, video, audio, iframe, svg, math, br, hr, input, table`)&&e.remove();let r=t.createElement(`div`);for(r.setAttribute(`data-footnote-definition`,``),r.setAttribute(`data-footnote-label`,e.label),r.className=`tiptap-footnote-definition`;n.firstChild;)r.appendChild(n.firstChild);return r.hasChildNodes()||r.appendChild(t.createElement(`p`)),r}function yA(e){if(!e.trim()||typeof document>`u`)return e;let t=document.createElement(`template`);t.innerHTML=e;let n=t.content,r=Array.from(n.querySelectorAll(Xk)).filter(e=>!e.parentElement?.closest(Xk)),i=new Map,a=[];for(let e of r){let t=fA(e);if(t.length!==0){i.set(e,t);for(let n of t)a.push({container:e,element:n,targetId:uA(n)})}}for(let e of n.querySelectorAll(`[role~="doc-footnote"]`))e.closest(Xk)||a.push({container:null,element:e,targetId:uA(e)});if(a.length===0)return e;let o=new Map;for(let e of a)e.targetId&&!o.has(e.targetId)&&o.set(e.targetId,e);let s=new Map;for(let e of n.querySelectorAll(`a[href]`)){if(!pA(e))continue;let t=lA(e);if(!t||!o.has(t))continue;let n=s.get(t)??[];n.push(e),s.set(t,n)}let c=new Set,l=a.map((e,t)=>{let n=e.targetId?s.get(e.targetId)?.[0]:void 0,r=n?mA(n):hA(e.targetId);return{...e,label:gA(r,t,c)}}),u=new Map(l.filter(e=>e.targetId).map(e=>[e.targetId,e.label])),d=!1;for(let[e,t]of s){let n=u.get(e);if(n)for(let e of t){let t=e.closest(`sup`),r=t?.contains(e)?t:e;r.parentNode&&(r.replaceWith(_A(e.ownerDocument,n)),d=!0)}}let f=new Map(l.map(e=>[e.element,vA(e)]));for(let[e,t]of i){if(!e.parentNode)continue;let n=e.ownerDocument.createDocumentFragment();for(let e of t){let t=f.get(e);t&&n.appendChild(t)}let r=e.previousElementSibling;r?.matches(`hr.footnotes-sep, hr[data-footnotes-separator]`)&&r.remove(),e.replaceWith(n),d=!0}for(let e of l){if(e.container||!e.element.parentNode)continue;let t=f.get(e.element);t&&(e.element.replaceWith(t),d=!0)}return d?t.innerHTML:e}function bA(e){return yA(oA(e))}function xA(e){let t=[];e.forEach(e=>t.push(e));let n=[],r=[],i=!1;for(let e=0;e<t.length;e+=1){let a=t[e];if(a?.type.name!==`hardBreak`){a&&r.push(a);continue}let o=e+1;for(;t[o]?.type.name===`hardBreak`;)o+=1;if(o-e===1){r.push(a);continue}i=!0,r.length>0&&n.push(r),r=[],e=o-1}return i?(r.length>0&&n.push(r),n.length===0&&n.push([]),{nodes:n.map(t=>e.copy(D.fromArray(t))),changed:!0}):{nodes:[e],changed:!1}}function SA(e){if(e.type.name===`paragraph`)return xA(e);if(e.isLeaf||e.childCount===0)return{nodes:[e],changed:!1};let t=[],n=!1;if(e.forEach(e=>{let r=SA(e);t.push(...r.nodes),n||=r.changed}),!n)return{nodes:[e],changed:!1};let r=D.fromArray(t);return e.type.validContent(r)?{nodes:[e.copy(r)],changed:!0}:{nodes:[e],changed:!1}}function CA(e,t){if(t)return e;let n=[],r=!1;return e.content.forEach(e=>{let t=SA(e);n.push(...t.nodes),r||=t.changed}),r?new k(D.fromArray(n),e.openStart,e.openEnd):e}var wA=H.create({name:`markdownClipboard`,priority:1e3,addProseMirrorPlugins(){return[new N({props:{clipboardTextSerializer:()=>tA(this.editor),transformPastedHTML:bA,transformPasted:(e,t,n)=>CA(e,n),handlePaste:(e,t)=>{let n=t.clipboardData;if(!n||typeof n.getData!=`function`)return!1;let r=sA(n);if(!r||!this.editor.markdown)return!1;let i=MC(this.editor.markdown.parse(r));if(i.type!==`doc`||!i.content)return!1;let a=Al(i,e.state.schema,{slice:!1}),o=k.maxOpen(Qk(a));return t.preventDefault(),e.dispatch(e.state.tr.replaceSelection(o).scrollIntoView()),!0},clipboardTextParser:(e,t,n,r)=>{if(!e.trim()||!this.editor.markdown)return k.empty;let i=MC(this.editor.markdown.parse(e));if(i.type!==`doc`||!i.content)return k.empty;if(i.content.length===1&&i.content[0]?.type===`paragraph`){let e=i.content[0];if(!e?.content)return k.empty;let t=Al(e.content,r.state.schema,{slice:!0});return k.maxOpen(Qk(t))}let a=Al(i,r.state.schema,{slice:!1});return k.maxOpen(Qk(a))}}})]}}),TA=/!\[([^\]\n]*)\]\(((?:[^()\s"]|\([^()\s"]*\))+)(?:\s*"([^"\n]*)")?\)$/;function EA(e){let t=n(e.trim());return!t||/^mailto:/i.test(t)?``:t}var DA=H.create({name:`imageInputRules`,priority:1e3,addInputRules(){let e=this.editor.schema.nodes.image;return e?[new Cf({find:TA,handler:({state:t,range:n,match:r})=>{let i=EA(r[2]??``);if(!i)return null;t.tr.replaceRangeWith(n.from,n.to,e.create({src:i,alt:r[1]??``,title:r[3]??``})),Ek(t.tr,t.schema)}})]:[]}}),OA=H.create({name:`reclaimModEnter`,priority:1e3,addKeyboardShortcuts(){return{"Mod-Enter":()=>!0}}});function kA(e={}){return[...OC(),qm.configure({markedOptions:NS}),HC.configure({placeholder:e.placeholder??``}),OA,UO,wA,GO,PO,RO,vO.configure({toolbarMode:`compose`}),fO]}function AA(e={}){return[...OC({imageExtension:Nk.configure({labels:e.imageNodeLabels}),moreBreakExtension:Fk,embedExtension:Rk,htmlBlockExtension:Bk}),OA,qm.configure({markedOptions:NS}),HC.configure({placeholder:e.placeholder??`Write something…`}),Tk,DA,UO,wA,XE,...e.tableControlLabels?[dE.configure({labels:e.tableControlLabels})]:[],Uk,aO.configure(e.pasteMedia??{}),Jk.configure(e.rehostImages??{}),vO.configure({toolbarMode:e.toolbarMode??`default`}),fO,GO,PO,RO,bO]}function jA(e){let t=JSON.parse(e);if(t.type!==`doc`)throw Error(`A TipTap body's root must be a doc node, not ${JSON.stringify(t.type)}.`);return VC(t).trimEnd()}function MA(e){return new Zf({element:e.element,extensions:AA({placeholder:e.placeholder,toolbarMode:e.toolbarMode,pasteMedia:e.pasteMedia,rehostImages:e.rehostImages,imageNodeLabels:e.imageNodeLabels,tableControlLabels:e.tableControlLabels}),content:e.content??void 0,editorProps:{scrollMargin:{top:5,right:5,bottom:80,left:5},scrollThreshold:{top:5,right:5,bottom:80,left:5}},onUpdate:({editor:t})=>{e.onUpdate?.(b(t.getJSON()))},onFocus:()=>{e.onFocus?.()},onBlur:()=>{e.onBlur?.()},onSelectionUpdate:({editor:t})=>{e.onSelectionUpdate?.({from:t.state.selection.from,to:t.state.selection.to})}})}function NA(e){return jA(JSON.stringify(e))}function PA(e){let t=e.content?BC(e.content):void 0;return new Zf({element:e.element,extensions:kA({placeholder:e.placeholder}),content:t,onUpdate:({editor:t})=>{e.onUpdate?.(NA(t.getJSON()))}})}export{m as C,b as S,BC as _,qk as a,S as b,$D as c,YD as d,JD as f,cD as g,MD as h,jA as i,XD as l,VD as m,MA as n,iO as o,HD as p,NA as r,ZD as s,PA as t,QD as u,de as v,h as x,se as y};
|