@jant/core 1.0.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/lib/site-snapshot.js +10 -0
- package/dist/{app-Gt7_skt6.js → app-CbOZ2Irh.js} +8704 -5180
- package/dist/client/.vite/manifest.json +125 -85
- package/dist/client/_assets/chunks/{confirm-D7GrwsCN.js → confirm-CMe01lne.js} +1 -1
- package/dist/client/_assets/chunks/{create-editor-5Y49x7h5.js → create-editor-hWapNE40.js} +26 -26
- package/dist/client/_assets/chunks/footnote-rail-9zwl6jtV.js +2 -0
- package/dist/client/_assets/chunks/{jant-locale-picker-DL6mIOT5.js → jant-locale-picker-2L4rkDaz.js} +1 -1
- package/dist/client/_assets/chunks/lit-Bw_voPoW.js +2 -0
- package/dist/client/_assets/chunks/preload-helper-Czpn1I53.js +1 -0
- package/dist/client/_assets/chunks/runtime-paths-y0_gHowM.js +1 -0
- package/dist/client/_assets/chunks/{settings-paths-h6RjIe3C.js → settings-paths-BBVT8zKj.js} +1 -1
- package/dist/client/_assets/chunks/slug-format-BuCPjSrB.js +1 -0
- package/dist/client/_assets/chunks/sortable-list-DJXwkaOv.js +2 -0
- package/dist/client/_assets/chunks/types-DrYFqJH2.js +1 -0
- package/dist/client/_assets/chunks/{unsafe-html-B5ZEXaxg.js → unsafe-html-CWos3v6N.js} +1 -1
- package/dist/client/_assets/chunks/unsafe-svg-CUrgo4Xg.js +1 -0
- package/dist/client/_assets/client-BO8GOFfT.js +354 -0
- package/dist/client/_assets/client-D8Rrsd73.css +2 -0
- package/dist/client/_assets/client-auth-CsUGM718.js +859 -0
- package/dist/client/_assets/client-author-QPm1whbO.css +2 -0
- package/dist/client/_assets/client-compose-BB4U7Wz0.js +2004 -0
- package/dist/client/_assets/{client-manage-C1eDB1Rc.js → client-manage-CI9-eh-8.js} +176 -176
- package/dist/client/_assets/{client-settings-DIM44Zqh.js → client-settings-BnGPuqwc.js} +166 -166
- package/dist/client/_assets/client-share-0DICJjAc.css +1 -0
- package/dist/client/_assets/client-share-C59mOLJ1.js +149 -0
- package/dist/index.js +1 -1
- package/dist/node.js +3 -2
- package/package.json +2 -1
- package/src/app.tsx +9 -0
- package/src/client/components/compose-types.ts +1 -0
- package/src/client/components/jant-compose-dialog.ts +1 -0
- package/src/client/components/jant-compose-editor.ts +30 -0
- package/src/client/components/jant-compose-fullscreen.ts +1 -0
- package/src/client/components/jant-post-menu.ts +80 -13
- package/src/client/components/jant-share-dialog.ts +422 -0
- package/src/client/components/jant-share-menu.ts +188 -0
- package/src/client/compose-bridge.ts +61 -1
- package/src/client/feed-video-player.ts +6 -0
- package/src/client/lazy-entries.ts +21 -1
- package/src/client/post-menu-shared.ts +100 -0
- package/src/client/share-capture.ts +443 -0
- package/src/client/share-launch.ts +133 -0
- package/src/client/tiptap/bubble-menu.ts +25 -2
- package/src/client/tiptap/create-editor.ts +2 -0
- package/src/client/tiptap/extensions.ts +4 -0
- package/src/client/video-processor.ts +106 -52
- package/src/client/view-confirm.ts +108 -0
- package/src/client-share.ts +8 -0
- package/src/client.ts +2 -0
- package/src/db/migrations/0035_brainy_next_avengers.sql +9 -0
- package/src/db/migrations/0036_gorgeous_smasher.sql +7 -0
- package/src/db/migrations/meta/0035_snapshot.json +2877 -0
- package/src/db/migrations/meta/0036_snapshot.json +2924 -0
- package/src/db/migrations/meta/_journal.json +14 -0
- package/src/db/migrations/pg/0033_cute_magdalene.sql +10 -0
- package/src/db/migrations/pg/0034_material_agent_brand.sql +8 -0
- package/src/db/migrations/pg/meta/0033_snapshot.json +3719 -0
- package/src/db/migrations/pg/meta/0034_snapshot.json +3766 -0
- package/src/db/migrations/pg/meta/_journal.json +14 -0
- package/src/db/pg/schema.ts +40 -0
- package/src/db/schema.ts +61 -0
- package/src/i18n/locales/public/en.po +5 -0
- package/src/i18n/locales/public/en.ts +1 -1
- package/src/i18n/locales/public/zh-Hans.po +5 -0
- package/src/i18n/locales/public/zh-Hans.ts +1 -1
- package/src/i18n/locales/public/zh-Hant.po +5 -0
- package/src/i18n/locales/public/zh-Hant.ts +1 -1
- package/src/i18n/locales/settings/en.po +149 -0
- package/src/i18n/locales/settings/en.ts +1 -1
- package/src/i18n/locales/settings/zh-Hans.po +149 -0
- package/src/i18n/locales/settings/zh-Hans.ts +1 -1
- package/src/i18n/locales/settings/zh-Hant.po +149 -0
- package/src/i18n/locales/settings/zh-Hant.ts +1 -1
- package/src/lib/discover.ts +31 -0
- package/src/lib/env.ts +20 -0
- package/src/lib/github-app-state.ts +1 -1
- package/src/lib/github-app.ts +183 -1
- package/src/lib/markdown-manager.ts +129 -1
- package/src/lib/post-meta.ts +13 -3
- package/src/lib/referrer-aliases.ts +311 -0
- package/src/lib/render.tsx +10 -0
- package/src/lib/resolve-config.ts +14 -0
- package/src/lib/share-card.ts +653 -0
- package/src/lib/summary.ts +152 -54
- package/src/lib/tiptap-render.ts +1 -0
- package/src/lib/upload.ts +21 -1
- package/src/lib/version.ts +2 -0
- package/src/lib/video-playback.ts +55 -0
- package/src/lib/view-buffer.ts +201 -0
- package/src/lib/view-counting.ts +539 -0
- package/src/lib/view-token.ts +177 -0
- package/src/lib/view.ts +13 -1
- package/src/middleware/view-counter.ts +140 -0
- package/src/node/runtime.ts +4 -0
- package/src/preset.css +31 -14
- package/src/routes/api/media.ts +21 -3
- package/src/routes/auth/setup.tsx +37 -1
- package/src/routes/dash/settings.tsx +433 -168
- package/src/routes/pages/archive.tsx +1 -0
- package/src/routes/pages/collection.tsx +6 -0
- package/src/routes/pages/collections.tsx +1 -0
- package/src/routes/pages/featured.tsx +1 -0
- package/src/routes/pages/home.tsx +1 -0
- package/src/routes/pages/page.tsx +3 -0
- package/src/routes/pages/partials.tsx +23 -0
- package/src/routes/pages/smart-collection.tsx +2 -0
- package/src/routes/pages/subscribe.tsx +1 -0
- package/src/routes/view-confirm.ts +63 -0
- package/src/services/export-theme/assets/client-site.js +1 -1
- package/src/services/export-theme/styles/main.css +39 -21
- package/src/services/export.ts +2 -0
- package/src/services/index.ts +17 -0
- package/src/services/mcp.ts +31 -1
- package/src/services/media.ts +63 -0
- package/src/services/stats.ts +1130 -0
- package/src/style-share.css +16 -0
- package/src/styles/components-author.css +177 -0
- package/src/styles/components.css +25 -3
- package/src/styles/share.css +1103 -0
- package/src/styles/tokens.css +65 -30
- package/src/styles/ui.css +62 -13
- package/src/types/app-context.ts +9 -0
- package/src/types/bindings.ts +5 -0
- package/src/types/config.ts +54 -0
- package/src/types/views.ts +6 -0
- package/src/ui/compose/ComposeDialog.tsx +6 -0
- package/src/ui/dash/settings/SettingsRootContent.tsx +24 -6
- package/src/ui/dash/settings/StatsContent.tsx +855 -0
- package/src/ui/font-themes.ts +39 -6
- package/src/ui/layouts/BaseLayout.tsx +11 -2
- package/src/ui/layouts/SiteLayout.tsx +9 -3
- package/src/ui/share/ShareCard.tsx +298 -0
- package/src/ui/shared/Icon.tsx +23 -3
- package/src/ui/shared/MediaGallery.tsx +31 -4
- package/src/ui/shared/PostFooter.tsx +20 -4
- package/src/ui/shared/icon-collector.ts +28 -0
- package/src/ui/shared/post-article-attributes.ts +3 -0
- package/dist/client/_assets/chunks/footnote-rail-BJwswtVQ.js +0 -1
- package/dist/client/_assets/chunks/lit-DW8VmJAT.js +0 -2
- package/dist/client/_assets/chunks/slug-format-Dsi0e9Xn.js +0 -1
- package/dist/client/_assets/chunks/sortable-list-DWNKv782.js +0 -2
- package/dist/client/_assets/chunks/types-D5iF3H1a.js +0 -1
- package/dist/client/_assets/chunks/unsafe-svg-DTZZEvLU.js +0 -2
- package/dist/client/_assets/client-BaqmpPQ-.css +0 -2
- package/dist/client/_assets/client-C6melOtG.js +0 -296
- package/dist/client/_assets/client-auth-Ccq8kSqq.js +0 -828
- package/dist/client/_assets/client-author-CGVvrNZ8.css +0 -2
- package/dist/client/_assets/client-compose-oxzPb3SS.js +0 -2004
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{d as e,f as t,r as n}from"./runtime-paths-y0_gHowM.js";import{_ as r,f as i,g as a,h as o,l as s,m as c,p as l,u}from"./types-DrYFqJH2.js";var d=`footnote`,f=/^(?: {4}|\t)/,p=/^\[\^([^\]\n]+)\]:(.*)(?:\n|$)/;function m(e){return typeof e==`string`?e.trim().replace(/\s+/g,` `):``}function h(e){return m(e).toLowerCase()}function g(e){return`[^${m(e)||d}]`}function _(e){return`${g(e)}:`}function v(e){return e.split(`
|
|
2
2
|
`).map(e=>` ${e}`).join(`
|
|
3
3
|
`)}function y(e){return e?.type===`paragraph`&&(!e.content||e.content.length===0)}function b(e){if(e.type!==`doc`||!Array.isArray(e.content)||e.content.length<2)return e;let t=[...e.content];for(;t.length>=2&&y(t[t.length-1])&&t[t.length-2]?.type===`footnoteDefinition`;)t.pop();return t.length===e.content.length?e:{...e,content:t}}function x(e){let t=e.match(p);if(!t)return null;let n=m(t[1]);if(!n)return null;let r=[],i=(t[2]??``).replace(/^ /,``);i&&r.push(i);let a=t[0],o=a.length;for(;o<e.length;){let t=e.slice(o).match(/^(.*)(\n|$)/);if(!t)break;let n=t[1]??``,i=t[0];if(f.test(n)){r.push(n.replace(f,``)),a+=i,o+=i.length;continue}if(n.trim()===``){let t=e.slice(o+i.length).match(/^(.*)(?:\n|$)/)?.[1]??``;if(f.test(t)){r.push(``),a+=i,o+=i.length;continue}}break}return{label:n,raw:a,contentMarkdown:r.join(`
|
|
4
|
-
`)}}function S(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}var C=[`https://www.youtube-nocookie.com`],w=[`https://player.vimeo.com`],T=[`https://open.spotify.com`],ee=[`https://bandcamp.com`],te=[`https://codepen.io`],ne=`allow-scripts allow-same-origin allow-popups`,re=`allow-scripts allow-same-origin allow-popups allow-presentation`;function ie(e,t,n){return{provider:`youtube`,providerName:`YouTube`,src:`https://www.youtube-nocookie.com/embed/${e}${n&&n>0?`?start=${n}`:``}`,url:``,orientation:t?`portrait`:`landscape`,sandbox:re,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share`,cspFrameSrc:C,cspScriptSrc:[]}}function ae(e){if(!e)return;if(/^\d+$/.test(e)){let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}let t=e.match(/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s?)?$/);if(!t)return;let n=Number.parseInt(t[1]??`0`,10)||0,r=Number.parseInt(t[2]??`0`,10)||0,i=Number.parseInt(t[3]??`0`,10)||0,a=n*3600+r*60+i;return a>0?a:void 0}var oe=[{id:`youtube`,name:`YouTube`,pattern:/^(?:https?:\/\/)?(?:www\.|m\.)?youtube\.com\/watch\?(?=[^#]*v=([\w-]{6,}))/i,build:(e,t)=>{let n=e[1];return n?ie(n,!1,ae(t.searchParams.get(`t`))):null}},{id:`youtube`,name:`YouTube`,pattern:/^(?:https?:\/\/)?(?:www\.|m\.)?youtube\.com\/shorts\/([\w-]{6,})/i,build:e=>e[1]?ie(e[1],!0):null},{id:`youtube`,name:`YouTube`,pattern:/^(?:https?:\/\/)?youtu\.be\/([\w-]{6,})/i,build:(e,t)=>{let n=e[1];return n?ie(n,!1,ae(t.searchParams.get(`t`))):null}},{id:`vimeo`,name:`Vimeo`,pattern:/^(?:https?:\/\/)?(?:www\.)?vimeo\.com\/(\d+)(?:\/(\w+))?/i,build:e=>{let t=e[1],n=e[2];return{provider:`vimeo`,providerName:`Vimeo`,src:`https://player.vimeo.com/video/${t}${n?`?h=${n}`:``}`,url:``,orientation:`landscape`,sandbox:re,allow:`autoplay; fullscreen; picture-in-picture`,cspFrameSrc:w,cspScriptSrc:[]}}},{id:`spotify`,name:`Spotify`,pattern:/^(?:https?:\/\/)?open\.spotify\.com\/(track|album|playlist|episode|show)\/([\w-]+)/i,build:e=>{let t=e[1];return{provider:`spotify`,providerName:`Spotify`,src:`https://open.spotify.com/embed/${t}/${e[2]}`,url:``,orientation:`auto`,heightPx:t===`track`||t===`episode`?152:352,sandbox:re,allow:`autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture`,cspFrameSrc:T,cspScriptSrc:[]}}},{id:`bandcamp`,name:`Bandcamp`,pattern:/^(?:https?:\/\/)?([a-z0-9-]+)\.bandcamp\.com\/(track|album)\/([\w-]+)/i,build:(e,t)=>({provider:`bandcamp`,providerName:`Bandcamp`,src:`https://bandcamp.com/EmbeddedPlayer/v=2/linkcol=0687f5/tracklist=false/artwork=small/url=${encodeURIComponent(t.toString())}`,url:``,orientation:`auto`,heightPx:120,sandbox:re,cspFrameSrc:ee,cspScriptSrc:[]})},{id:`codepen`,name:`CodePen`,pattern:/^(?:https?:\/\/)?codepen\.io\/([\w-]+)\/(?:pen|full|details)\/([\w-]+)/i,build:e=>({provider:`codepen`,providerName:`CodePen`,src:`https://codepen.io/${e[1]}/embed/${e[2]}?default-tab=result&theme-id=default`,url:``,orientation:`auto`,heightPx:420,sandbox:ne,cspFrameSrc:te,cspScriptSrc:[]})}];function se(e){let t=e.trim();if(!t)return null;let n;try{n=new URL(t.startsWith(`http`)?t:`https://${t}`)}catch{return null}if(n.protocol!==`https:`&&n.protocol!==`http:`)return null;for(let e of oe){let r=t.match(e.pattern);if(r){let i=e.build(r,n);if(i)return{...i,url:t}}}return n.protocol===`https:`?{provider:`iframe`,providerName:n.hostname,src:n.toString(),url:t,orientation:`landscape`,sandbox:ne,cspFrameSrc:[n.origin],cspScriptSrc:[]}:null}function ce(e){let t=se(e);return t!==null&&t.provider!==`iframe`}function le(e){let t=e.layout&&String(e.layout)!==`regular`?String(e.layout):`regular`;return{src:String(e.src??``),alt:String(e.alt??``),title:String(e.title??``),caption:String(e.caption??``),href:String(e.href??``),layout:t}}function ue(e){let t=[`src="${S(e.src)}"`];e.alt&&t.push(`alt="${S(e.alt)}"`),e.title&&t.push(`title="${S(e.title)}"`);let r=`<img ${t.join(` `)}>`,i=e.href?n(e.href):``;return`${i?`<a href="${S(i)}">${r}</a>`:r}${e.caption?`<figcaption>${S(e.caption)}</figcaption>`:``}`}function de(e){let t=le(e);return`<figure${t.layout===`regular`?``:` data-layout="${S(t.layout)}"`}>${ue(t)}</figure>`}function fe(e){let t=le(e),n=[`data-jant-node="image"`];return t.layout!==`regular`&&n.push(`data-jant-layout="${S(t.layout)}"`),`<figure ${n.join(` `)}>${ue(t)}</figure>`}function pe(e){let t=le(e);return t.caption||t.href||t.layout!==`regular`?fe(t):t.title?``:``}var me=Object.defineProperty,he=(e,t)=>{let n={};for(var r in e)me(n,r,{get:e[r],enumerable:!0});return t||me(n,Symbol.toStringTag,{value:`Module`}),n};function E(e){this.content=e}E.prototype={constructor:E,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new E(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new E(n)},addToStart:function(e,t){return new E([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new E(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new E(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=E.from(e),e.size?new E(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=E.from(e),e.size?new E(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=E.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},E.from=function(e){if(e instanceof E)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new E(t)};function ge(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&ye(e.charCodeAt(r-1))&&ve(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=ge(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function _e(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&ye(e.charCodeAt(i-1))&&ve(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=_e(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function ve(e){return e>=56320&&e<57344}function ye(e){return e>=55296&&e<56320}var D=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return ge(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return _e(this,e,t,n)}findIndex(e){if(e==0)return xe(0,e);if(e==this.size)return xe(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?xe(t+1,i):xe(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};D.empty=new D([],0);var be={index:0,offset:0};function xe(e,t){return be.index=e,be.offset=t,be}function Se(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Se(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Se(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var O=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else!n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Se(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};O.none=[];var Ce=class extends Error{},k=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Te(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(we(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(D.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};k.empty=new k(D.empty,0,0);function we(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(we(a.content,t-i-1,n-i-1)))}function Te(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=Te(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function Ee(e,t,n){if(n.openStart>e.depth)throw new Ce(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Ce(`Inconsistent open depths`);return De(e,t,n,0)}function De(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=De(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}if(!n.content.size)return Me(a,Pe(e,t,r));if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return Me(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}{let{start:i,end:o}=Fe(n,e);return Me(a,Ne(e,i,o,t,r))}}function Oe(e,t){if(!t.type.compatibleContent(e.type))throw new Ce(`Cannot join `+t.type.name+` onto `+e.type.name)}function ke(e,t,n){let r=e.node(n);return Oe(r,t.node(n)),r}function Ae(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function je(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(Ae(e.nodeAfter,r),a++));for(let e=a;e<o;e++)Ae(i.child(e),r);t&&t.depth==n&&t.textOffset&&Ae(t.nodeBefore,r)}function Me(e,t){if(!e.type.validContent(t))throw new Ce(`Invalid content for node `+e.type.name);return e.copy(t)}function Ne(e,t,n,r,i){let a=e.depth>i&&ke(e,t,i+1),o=r.depth>i&&ke(n,r,i+1),s=[];return je(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(Oe(a,o),Ae(Me(a,Ne(e,t,n,r,i+1)),s)):(a&&Ae(Me(a,Pe(e,t,i+1)),s),je(t,n,i,s),o&&Ae(Me(o,Pe(n,r,i+1)),s)),je(r,null,i,s),new D(s)}function Pe(e,t,n){let r=[];return je(null,e,n,r),e.depth>n&&Ae(Me(ke(e,t,n+1),Pe(e,t,n+1)),r),je(t,null,n,r),new D(r)}function Fe(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(D.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Ie=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return O.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Be(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=ze.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else ze.set(t,r=new Le);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%Re,i}},Le=class{constructor(){this.elts=[],this.i=0}},Re=12,ze=new WeakMap,Be=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},Ve=Object.create(null),He=class e{constructor(e,t,n,r=O.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||D.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Se(this.attrs,t||e.defaultAttrs||Ve)&&O.sameSet(this.marks,n||O.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return k.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new k(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return Ee(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Ie.resolveCached(this,e)}resolveNoCache(e){return Ie.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),We(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=D.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=O.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!O.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=D.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};He.prototype.text=void 0;var Ue=class e extends He{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):We(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function We(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var Ge=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new Ke(t,n);if(r.next==null)return e.empty;let i=qe(r);r.next&&r.err(`Unexpected trailing text`);let a=rt(et(i));return it(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return D.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
4
|
+
`)}}function S(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}var C=[`https://www.youtube-nocookie.com`],w=[`https://player.vimeo.com`],T=[`https://open.spotify.com`],ee=[`https://bandcamp.com`],te=[`https://codepen.io`],ne=`allow-scripts allow-same-origin allow-popups`,re=`allow-scripts allow-same-origin allow-popups allow-presentation`;function ie(e,t,n){return{provider:`youtube`,providerName:`YouTube`,src:`https://www.youtube-nocookie.com/embed/${e}${n&&n>0?`?start=${n}`:``}`,url:``,orientation:t?`portrait`:`landscape`,sandbox:re,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share`,cspFrameSrc:C,cspScriptSrc:[]}}function ae(e){if(!e)return;if(/^\d+$/.test(e)){let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}let t=e.match(/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s?)?$/);if(!t)return;let n=Number.parseInt(t[1]??`0`,10)||0,r=Number.parseInt(t[2]??`0`,10)||0,i=Number.parseInt(t[3]??`0`,10)||0,a=n*3600+r*60+i;return a>0?a:void 0}var oe=[{id:`youtube`,name:`YouTube`,pattern:/^(?:https?:\/\/)?(?:www\.|m\.)?youtube\.com\/watch\?(?=[^#]*v=([\w-]{6,}))/i,build:(e,t)=>{let n=e[1];return n?ie(n,!1,ae(t.searchParams.get(`t`))):null}},{id:`youtube`,name:`YouTube`,pattern:/^(?:https?:\/\/)?(?:www\.|m\.)?youtube\.com\/shorts\/([\w-]{6,})/i,build:e=>e[1]?ie(e[1],!0):null},{id:`youtube`,name:`YouTube`,pattern:/^(?:https?:\/\/)?youtu\.be\/([\w-]{6,})/i,build:(e,t)=>{let n=e[1];return n?ie(n,!1,ae(t.searchParams.get(`t`))):null}},{id:`vimeo`,name:`Vimeo`,pattern:/^(?:https?:\/\/)?(?:www\.)?vimeo\.com\/(\d+)(?:\/(\w+))?/i,build:e=>{let t=e[1],n=e[2];return{provider:`vimeo`,providerName:`Vimeo`,src:`https://player.vimeo.com/video/${t}${n?`?h=${n}`:``}`,url:``,orientation:`landscape`,sandbox:re,allow:`autoplay; fullscreen; picture-in-picture`,cspFrameSrc:w,cspScriptSrc:[]}}},{id:`spotify`,name:`Spotify`,pattern:/^(?:https?:\/\/)?open\.spotify\.com\/(track|album|playlist|episode|show)\/([\w-]+)/i,build:e=>{let t=e[1];return{provider:`spotify`,providerName:`Spotify`,src:`https://open.spotify.com/embed/${t}/${e[2]}`,url:``,orientation:`auto`,heightPx:t===`track`||t===`episode`?152:352,sandbox:re,allow:`autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture`,cspFrameSrc:T,cspScriptSrc:[]}}},{id:`bandcamp`,name:`Bandcamp`,pattern:/^(?:https?:\/\/)?([a-z0-9-]+)\.bandcamp\.com\/(track|album)\/([\w-]+)/i,build:(e,t)=>({provider:`bandcamp`,providerName:`Bandcamp`,src:`https://bandcamp.com/EmbeddedPlayer/v=2/linkcol=0687f5/tracklist=false/artwork=small/url=${encodeURIComponent(t.toString())}`,url:``,orientation:`auto`,heightPx:120,sandbox:re,cspFrameSrc:ee,cspScriptSrc:[]})},{id:`codepen`,name:`CodePen`,pattern:/^(?:https?:\/\/)?codepen\.io\/([\w-]+)\/(?:pen|full|details)\/([\w-]+)/i,build:e=>({provider:`codepen`,providerName:`CodePen`,src:`https://codepen.io/${e[1]}/embed/${e[2]}?default-tab=result&theme-id=default`,url:``,orientation:`auto`,heightPx:420,sandbox:ne,cspFrameSrc:te,cspScriptSrc:[]})}];function se(e){let t=e.trim();if(!t)return null;let n;try{n=new URL(t.startsWith(`http`)?t:`https://${t}`)}catch{return null}if(n.protocol!==`https:`&&n.protocol!==`http:`)return null;for(let e of oe){let r=t.match(e.pattern);if(r){let i=e.build(r,n);if(i)return{...i,url:t}}}return n.protocol===`https:`?{provider:`iframe`,providerName:n.hostname,src:n.toString(),url:t,orientation:`landscape`,sandbox:ne,cspFrameSrc:[n.origin],cspScriptSrc:[]}:null}function ce(e){let t=se(e);return t!==null&&t.provider!==`iframe`}function le(e){let t=e.layout&&String(e.layout)!==`regular`?String(e.layout):`regular`;return{src:String(e.src??``),alt:String(e.alt??``),title:String(e.title??``),caption:String(e.caption??``),href:String(e.href??``),layout:t}}function ue(e){let n=[`src="${S(e.src)}"`];e.alt&&n.push(`alt="${S(e.alt)}"`),e.title&&n.push(`title="${S(e.title)}"`);let r=`<img ${n.join(` `)}>`,i=e.href?t(e.href):``;return`${i?`<a href="${S(i)}">${r}</a>`:r}${e.caption?`<figcaption>${S(e.caption)}</figcaption>`:``}`}function de(e){let t=le(e);return`<figure${t.layout===`regular`?``:` data-layout="${S(t.layout)}"`}>${ue(t)}</figure>`}function fe(e){let t=le(e),n=[`data-jant-node="image"`];return t.layout!==`regular`&&n.push(`data-jant-layout="${S(t.layout)}"`),`<figure ${n.join(` `)}>${ue(t)}</figure>`}function pe(e){let t=le(e);return t.caption||t.href||t.layout!==`regular`?fe(t):t.title?``:``}var me=Object.defineProperty,he=(e,t)=>{let n={};for(var r in e)me(n,r,{get:e[r],enumerable:!0});return t||me(n,Symbol.toStringTag,{value:`Module`}),n};function E(e){this.content=e}E.prototype={constructor:E,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new E(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new E(n)},addToStart:function(e,t){return new E([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new E(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new E(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=E.from(e),e.size?new E(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=E.from(e),e.size?new E(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=E.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},E.from=function(e){if(e instanceof E)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new E(t)};function ge(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&ye(e.charCodeAt(r-1))&&ve(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=ge(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function _e(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&ye(e.charCodeAt(i-1))&&ve(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=_e(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function ve(e){return e>=56320&&e<57344}function ye(e){return e>=55296&&e<56320}var D=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return ge(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return _e(this,e,t,n)}findIndex(e){if(e==0)return xe(0,e);if(e==this.size)return xe(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?xe(t+1,i):xe(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};D.empty=new D([],0);var be={index:0,offset:0};function xe(e,t){return be.index=e,be.offset=t,be}function Se(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Se(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Se(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var O=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else!n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Se(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};O.none=[];var Ce=class extends Error{},k=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Te(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(we(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(D.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};k.empty=new k(D.empty,0,0);function we(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(we(a.content,t-i-1,n-i-1)))}function Te(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=Te(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function Ee(e,t,n){if(n.openStart>e.depth)throw new Ce(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Ce(`Inconsistent open depths`);return De(e,t,n,0)}function De(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=De(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}if(!n.content.size)return Me(a,Pe(e,t,r));if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return Me(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}{let{start:i,end:o}=Fe(n,e);return Me(a,Ne(e,i,o,t,r))}}function Oe(e,t){if(!t.type.compatibleContent(e.type))throw new Ce(`Cannot join `+t.type.name+` onto `+e.type.name)}function ke(e,t,n){let r=e.node(n);return Oe(r,t.node(n)),r}function Ae(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function je(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(Ae(e.nodeAfter,r),a++));for(let e=a;e<o;e++)Ae(i.child(e),r);t&&t.depth==n&&t.textOffset&&Ae(t.nodeBefore,r)}function Me(e,t){if(!e.type.validContent(t))throw new Ce(`Invalid content for node `+e.type.name);return e.copy(t)}function Ne(e,t,n,r,i){let a=e.depth>i&&ke(e,t,i+1),o=r.depth>i&&ke(n,r,i+1),s=[];return je(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(Oe(a,o),Ae(Me(a,Ne(e,t,n,r,i+1)),s)):(a&&Ae(Me(a,Pe(e,t,i+1)),s),je(t,n,i,s),o&&Ae(Me(o,Pe(n,r,i+1)),s)),je(r,null,i,s),new D(s)}function Pe(e,t,n){let r=[];return je(null,e,n,r),e.depth>n&&Ae(Me(ke(e,t,n+1),Pe(e,t,n+1)),r),je(t,null,n,r),new D(r)}function Fe(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(D.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Ie=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return O.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Be(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=ze.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else ze.set(t,r=new Le);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%Re,i}},Le=class{constructor(){this.elts=[],this.i=0}},Re=12,ze=new WeakMap,Be=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},Ve=Object.create(null),He=class e{constructor(e,t,n,r=O.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||D.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Se(this.attrs,t||e.defaultAttrs||Ve)&&O.sameSet(this.marks,n||O.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return k.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new k(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return Ee(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Ie.resolveCached(this,e)}resolveNoCache(e){return Ie.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),We(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=D.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=O.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!O.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=D.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};He.prototype.text=void 0;var Ue=class e extends He{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):We(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function We(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var Ge=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new Ke(t,n);if(r.next==null)return e.empty;let i=qe(r);r.next&&r.err(`Unexpected trailing text`);let a=rt(et(i));return it(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return D.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
5
5
|
`)}};Ge.empty=new Ge(!0);var Ke=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function qe(e){let t=[];do t.push(Je(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function Je(e){let t=[];do t.push(Ye(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function Ye(e){let t=$e(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=Ze(e,t);else break;return t}function Xe(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function Ze(e,t){let n=Xe(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:Xe(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function Qe(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function $e(e){if(e.eat(`(`)){let t=qe(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=Qe(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function et(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function tt(e,t){return t-e}function nt(e,t){let n=[];return r(t),n.sort(tt);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function rt(e){let t=Object.create(null);return n(nt(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);nt(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new Ge(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(tt);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function it(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function at(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function ot(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function st(e,t,n,r){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}function ct(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new dt(e,r,t[r]);return n}var lt=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=ct(e,n.attrs),this.defaultAttrs=at(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Ge.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:ot(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new He(this,this.computeAttrs(e),D.from(t),O.setFrom(n))}createChecked(e=null,t,n){return t=D.from(t),this.checkContent(t),new He(this,this.computeAttrs(e),t,O.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=D.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(D.empty,!0);return i?new He(this,e,t.append(i),O.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){st(this.attrs,e,`node`,this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:O.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function ut(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var dt=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?ut(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},ft=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=ct(e,r.attrs),this.excluded=null;let i=at(this.attrs);this.instance=i?new O(this,i):null}create(e=null){return!e&&this.instance?this.instance:new O(this,ot(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){st(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},pt=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=E.from(e.nodes),t.marks=E.from(e.marks||{}),this.nodes=lt.compile(this.spec.nodes,this),this.marks=ft.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=Ge.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?mt(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:mt(this,n.split(` `))}this.nodeFromJSON=e=>He.fromJSON(this,e),this.markFromJSON=e=>O.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof lt))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new Ue(n,n.defaultAttrs,e,O.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function mt(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function ht(e){return e.tag!=null}function gt(e){return e.style!=null}var _t=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(ht(e))this.tags.push(e);else if(gt(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new Et(this,t,!1);return n.addAll(e,O.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Et(this,t,!0);return n.addAll(e,O.none,t.from,t.to),k.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Ot(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=kt(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=kt(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},vt={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},yt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},bt={ol:!0,ul:!0},xt=1,St=2,Ct=4;function wt(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?xt:0)|(t===`full`?St:0)}var Tt=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=O.none,this.match=i||(a&Ct?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(D.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&xt)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=D.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(D.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!vt.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Et=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=wt(null,t.preserveWhitespace,0)|(n?Ct:0);i=r?new Tt(r.type,r.attrs,O.none,!0,t.topMatch||r.type.contentMatch,a):n?new Tt(null,null,O.none,!0,null,a):new Tt(e.schema.topNodeType,null,O.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&St?`full`:this.localPreserveWS||(r.options&xt)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
|
|
6
6
|
`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;bt.hasOwnProperty(a)&&this.parser.normalizeLists&&Dt(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:yt.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(vt.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
7
7
|
`),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node){if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=O.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):At(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=wt(e,i,a.options);a.options&Ct&&a.content.length==0&&(o|=Ct);let s=O.none;return n=n.filter(t=>!(a.type?a.type.allowsMarkType(t.type):At(t.type,e))||(s=t.addToSet(s),!1)),this.nodes.push(new Tt(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=xt);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function Dt(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&bt.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function Ot(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function kt(e){let t={};for(let n in e)t[n]=e[n];return t}function At(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var jt=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=Nt(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return Nt(t).createTextNode(e.text);let{dom:n,contentDOM:r}=Lt(Nt(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Lt(Nt(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:Lt(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=Mt(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return Mt(e.marks)}};function Mt(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Nt(e){return e.document||window.document}var Pt=new WeakMap;function Ft(e){let t=Pt.get(e);return t===void 0&&Pt.set(e,t=It(e)),t}function It(e){let t=null;function n(e){if(e&&typeof e==`object`){if(Array.isArray(e)){if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t])}else for(let t in e)n(e[t])}}return n(e),t}function Lt(e,t,n,r){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=Ft(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=Lt(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var Rt=65535,zt=2**16;function Bt(e,t){return e+t*zt}function Vt(e){return e&Rt}function Ht(e){return(e-(e&Rt))/zt}var Ut=1,Wt=2,Gt=4,Kt=8,qt=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Kt)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&Gt)>0}},Jt=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=Vt(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+Ht(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:Bt(o/3,e-s),f=e==s?Wt:e==u?Ut:Gt;return(t<0?e!=s:e!=u)&&(f|=Kt),new qt(a,f,d)}r+=l-c}return n?e+r:new qt(e+r,0,null)}touches(e,t){let n=0,r=Vt(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};Jt.empty=new Jt([]);var Yt=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new qt(e,r,null)}},Xt=Object.create(null),Zt=class{getMap(){return Jt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=Xt[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Xt)throw RangeError(`Duplicate use of step JSON ID `+e);return Xt[e]=t,t.prototype.jsonID=e,t}},Qt=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof Ce)return e.fail(t.message);throw t}}};function $t(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy($t(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return D.fromArray(r)}var en=class e extends Zt{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new k($t(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return Qt.fromReplace(e,this.from,this.to,i)}invert(){return new tn(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};Zt.jsonID(`addMark`,en);var tn=class e extends Zt{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new k($t(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return Qt.fromReplace(e,this.from,this.to,n)}invert(){return new en(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};Zt.jsonID(`removeMark`,tn);var nn=class e extends Zt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Qt.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Qt.fromReplace(e,this.pos,this.pos+1,new k(D.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new rn(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};Zt.jsonID(`addNodeMark`,nn);var rn=class e extends Zt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Qt.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Qt.fromReplace(e,this.pos,this.pos+1,new k(D.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new nn(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};Zt.jsonID(`removeNodeMark`,rn);var an=class e extends Zt{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&sn(e,this.from,this.to)?Qt.fail(`Structure replace would overwrite content`):Qt.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Jt([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?k.empty:new k(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?k.empty:new k(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,k.fromJSON(t,n.slice),!!n.structure)}};an.MAP_BIAS=1,Zt.jsonID(`replace`,an);var on=class e extends Zt{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(sn(e,this.from,this.gapFrom)||sn(e,this.gapTo,this.to)))return Qt.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Qt.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?Qt.fromReplace(e,this.from,this.to,n):Qt.fail(`Content does not fit in gap`)}getMap(){return new Jt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,k.fromJSON(t,n.slice),n.insert,!!n.structure)}};Zt.jsonID(`replaceAround`,on);function sn(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function cn(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new tn(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new en(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function ln(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof ft){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new tn(t.from,t.to,t.style)))}function un(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new an(s,l,k.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new tn(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new k(D.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new an(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(D.empty,!0);e.replace(s,s,new k(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function dn(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function fn(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!dn(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function pn(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=D.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=D.from(r.node(e).copy(u)),d++):c--;let f=D.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=D.from(i.node(e).copy(f)),p++):l++;e.step(new on(c,l,o,s,new k(u.append(f),d,p),u.size-d,!0))}function mn(e,t,n=null,r=e){let i=gn(e,t),a=i&&_n(r,t);return a?i.map(hn).concat({type:t,attrs:n}).concat(a.map(hn)):null}function hn(e){return{type:e,attrs:null}}function gn(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function _n(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function vn(e,t,n){let r=D.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=D.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new on(i,a,i,a,new k(r,0,0),n.length,!0))}function yn(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&Sn(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&xn(e,t,n,a),un(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new on(c,l,c+1,l-1,new k(D.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&bn(e,t,n,a),!1}})}function bn(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function xn(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
|
|
@@ -206,30 +206,30 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
206
206
|
`).slice(0,l).join(`
|
|
207
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
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`},
|
|
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=Of.create({name:`highlight`,parseHTML(){return[{tag:`mark`}]},renderHTML(){return[`mark`,0]},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleMark(this.name)}},addInputRules(){return[Qf({find:/(?<!=)==([^=\s](?:(?:=(?!=)|[^=\n])*?[^=\s])?)==$/,type:this.type})]},addPasteRules(){return[np({find:/(?<!=)==([^=\s](?:(?:=(?!=)|[^=\n])*?[^=\s])?)==(?!=)/g,type:this.type})]},markdownTokenName:`highlight`,parseMarkdown(e,t){return t.applyMark(`highlight`,t.parseInline(e.tokens??[]))},renderMarkdown(e,t){return`==${t.renderChildren(e)}==`},markdownTokenizer:{name:`highlight`,level:`inline`,start(e){return e.indexOf(`==`)},tokenize(e,t,n){let r=/^==((?:\\[^\n]|=(?!=)|[^=\\\n])+?)==(?![=])/.exec(e);if(!r)return;let[i,a=``]=r;if(a.trim()===a)return{type:`highlight`,raw:i,tokens:n.inlineTokens(a)}}}}),sC={strong:`strong`,b:`strong`,em:`em`,i:`em`,s:`del`,del:`del`},cC=/<(?:strong|b|em|i|s|del)>/i,lC=/^<(strong|b|em|i|s|del)>([\s\S]*?)<\/\1>/i,uC=H.create({name:`markdownHtmlEmphasis`,markdownTokenizer:{name:`htmlEmphasis`,level:`inline`,start(e){return e.search(cC)},tokenize(e,t,n){let r=lC.exec(e);if(!r)return;let[i,a=``,o=``]=r,s=sC[a.toLowerCase()];if(s)return{type:s,raw:i,text:o,tokens:n.inlineTokens(o)}}}}),dC=ig.extend({renderMarkdown(e,t,n){let r=n?.previousNode;return!r||r.type===`hardBreak`?`\\
|
|
210
210
|
`:`
|
|
211
|
-
`}}),
|
|
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
|
|
213
|
-
`)},markdownTokenizer:
|
|
214
|
-
`),markdownTokenizer:
|
|
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
|
|
211
|
+
`}}),fC=cg.config.renderMarkdown,pC=cg.extend({renderMarkdown(e,t,n){return KS(fC?.call(this,e,t,n)??``)}}),mC=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[]}}),hC=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 gC(){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 _C(){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 vC(){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 yC=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:vC()}),bC=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:gC()}),xC=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:_C()});function SC(){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 CC=`__jantInlineFootnoteContent`;function wC(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 TC=H.create({name:`inlineFootnote`,parseMarkdown:(e,t)=>t.createNode(`footnoteReference`,{[CC]:Array.isArray(e.tokens)?t.parseInline(e.tokens):[]}),markdownTokenizer:{name:`inlineFootnote`,level:`inline`,start(e){return e.indexOf(`^[`)},tokenize(e,t,n){let r=wC(e);if(r)return{type:`inlineFootnote`,raw:r.raw,tokens:n.inlineTokens(r.content)}}}});function EC(e){let t=m(e),n=t.match(/^\[\^([^\]]+)\]:?$/)?.[1];return m(n??t)}var DC=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:EC(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:SC()}),OC=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:EC(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(`
|
|
216
216
|
`)?a[0]?`${i} ${a[0]}`:i:`${i}\n${a.map(e=>v(e)).join(`
|
|
217
217
|
|
|
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">
|
|
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 kC(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`]}}),pC,dC,rC,iC,aC,oC,uC,mC,WS.configure({openOnClick:!1,autolink:!1,isAllowedUri:t=>e(t)!==``}),US,MS.configure({resizable:!1,HTMLAttributes:{class:`tiptap-table`}}),_S,hS,gS,hC,t.imageExtension??HS,t.moreBreakExtension??yC,t.embedExtension??bC,t.htmlBlockExtension??xC,TC,DC,OC]}function AC(e){return typeof e==`object`&&!!e&&typeof e.type==`string`}function jC(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??[])jC(n,t)}function MC(e){if(e.type!==`doc`)return e;let t=new Set;jC(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?.[CC];if(e.type===`footnoteReference`&&Array.isArray(t)){let r=i(),o={...e.attrs??{},label:r};delete o[CC];let s=t.filter(AC).map(e=>a(NC(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 NC(e){let t={...e};if(t.content&&=t.content.map(NC),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`?MC(t):t}function PC(e){return e}function FC(e,t){return e.replace(/={2,}/g,e=>t.repeat(e.length)).replace(/^(\s*)=/,(e,n)=>`${n}${t}`).replace(/=(\s*)$/,(e,n)=>`${t}${n}`)}var IC=class extends Km{serialize(e){let t=JSON.stringify(e),n=`JANTLITERALEQUALS`;for(;t.includes(n);)n+=`X`;let r=(e,t=!1)=>{let i=t||e.type===`codeBlock`||e.marks?.some(e=>e.type===`code`);return{...e,...e.text&&!i?{text:FC(e.text,n)}:{},...e.content?{content:e.content.map(e=>r(e,i))}:{}}};return super.serialize(r(e)).split(n).join(`\\=`)}};function LC(e=kC()){return new IC({extensions:e,markedOptions:NS})}var RC=null;function zC(){return RC??=LC(),RC}var BC=null;function VC(){return BC??=Mu(kC()),BC}function HC(e){let t=e.type?VC().nodes[e.type]:void 0;if(!t||t.isLeaf)return e;let n=e.content?.map(HC);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 UC(e){return HC(NC(zC().parse(e)))}function WC(e){return PC(zC().serialize(b(tC(HC(e)))))}var GC=mb,KC=Math.min,qC=Math.max,JC=Math.round,YC=Math.floor,XC=e=>({x:e,y:e}),ZC={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function QC(e,t){return typeof e==`function`?e(t):e}function $C(e){return e.split(`-`)[0]}function ew(e){return e.split(`-`)[1]}function tw(e){return e===`x`?`y`:`x`}function nw(e){return e===`y`?`height`:`width`}function rw(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function iw(e){return tw(rw(e))}function aw(e,t,n){n===void 0&&(n=!1);let r=ew(e),i=iw(e),a=nw(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=mw(o)),[o,mw(o)]}function ow(e){let t=mw(e);return[sw(e),t,sw(t)]}function sw(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var cw=[`left`,`right`],lw=[`right`,`left`],uw=[`top`,`bottom`],dw=[`bottom`,`top`];function fw(e,t,n){switch(e){case`top`:case`bottom`:return n?t?lw:cw:t?cw:lw;case`left`:case`right`:return t?uw:dw;default:return[]}}function pw(e,t,n,r){let i=ew(e),a=fw($C(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(sw)))),a}function mw(e){let t=$C(e);return ZC[t]+e.slice(t.length)}function hw(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function gw(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:hw(e)}function _w(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 vw(e,t,n){let{reference:r,floating:i}=e,a=rw(t),o=iw(t),s=nw(o),c=$C(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=ew(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function yw(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}=QC(t,e),p=gw(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=_w(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=_w(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 bw=50,xw=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:yw},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=vw(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<bw&&(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}=vw(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Sw=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}=QC(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=$C(r),_=rw(o),v=$C(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[mw(o)]:ow(o)),x=p!==`none`;!d&&x&&b.push(...pw(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=aw(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`||_===rw(t)||T.every(e=>rw(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=rw(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{}}}},Cw=new Set([`left`,`top`]);async function ww(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=$C(n),s=ew(n),c=rw(n)===`y`,l=Cw.has(o)?-1:1,u=a&&c?-1:1,d=QC(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 Tw=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 ww(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 Ew(){return typeof window<`u`}function Dw(e){return Aw(e)?(e.nodeName||``).toLowerCase():`#document`}function Ow(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function kw(e){return((Aw(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Aw(e){return Ew()?e instanceof Node||e instanceof Ow(e).Node:!1}function jw(e){return Ew()?e instanceof Element||e instanceof Ow(e).Element:!1}function Mw(e){return Ew()?e instanceof HTMLElement||e instanceof Ow(e).HTMLElement:!1}function Nw(e){return!Ew()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Ow(e).ShadowRoot}function Pw(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Gw(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Fw(e){return/^(table|td|th)$/.test(Dw(e))}function Iw(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Lw=/transform|translate|scale|rotate|perspective|filter/,Rw=/paint|layout|strict|content/,zw=e=>!!e&&e!==`none`,Bw;function Vw(e){let t=jw(e)?Gw(e):e;return zw(t.transform)||zw(t.translate)||zw(t.scale)||zw(t.rotate)||zw(t.perspective)||!Uw()&&(zw(t.backdropFilter)||zw(t.filter))||Lw.test(t.willChange||``)||Rw.test(t.contain||``)}function Hw(e){let t=qw(e);for(;Mw(t)&&!Ww(t);){if(Vw(t))return t;if(Iw(t))return null;t=qw(t)}return null}function Uw(){return Bw??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Bw}function Ww(e){return/^(html|body|#document)$/.test(Dw(e))}function Gw(e){return Ow(e).getComputedStyle(e)}function Kw(e){return jw(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function qw(e){if(Dw(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Nw(e)&&e.host||kw(e);return Nw(t)?t.host:t}function Jw(e){let t=qw(e);return Ww(t)?(e.ownerDocument||e).body:Mw(t)&&Pw(t)?t:Jw(t)}function Yw(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Jw(e),i=r===e.ownerDocument?.body,a=Ow(r);if(i){let e=Xw(a);return t.concat(a,a.visualViewport||[],Pw(r)?r:[],e&&n?Yw(e):[])}return t.concat(r,Yw(r,[],n))}function Xw(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Zw(e){let t=Gw(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Mw(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=JC(n)!==a||JC(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Qw(e){return jw(e)?e:e.contextElement}function $w(e){let t=Qw(e);if(!Mw(t))return XC(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Zw(t),o=(a?JC(n.width):n.width)/r,s=(a?JC(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var eT=XC(0);function tT(e){let t=Ow(e);return!Uw()||!t.visualViewport?eT:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function nT(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Ow(e)}function rT(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Qw(e),o=XC(1);t&&(r?jw(r)&&(o=$w(r)):o=$w(e));let s=nT(a,n,r)?tT(a):XC(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=Ow(a),t=jw(r)?Ow(r):r,n=e,i=Xw(n);for(;i&&t!==n;){let e=$w(i),t=i.getBoundingClientRect(),r=Gw(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=Ow(i),i=Xw(n)}}return _w({width:u,height:d,x:c,y:l})}function iT(e,t){let n=Kw(e).scrollLeft;return t?t.left+n:rT(kw(e)).left+n}function aT(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-iT(e,n),y:n.top+t.scrollTop}}function oT(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=kw(r),s=t?Iw(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=XC(1),u=XC(0),d=Mw(r);if((d||!a)&&((Dw(r)!==`body`||Pw(o))&&(c=Kw(r)),d)){let e=rT(r);l=$w(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?aT(o,c):XC(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 sT(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function cT(e){let t=Kw(e),n=e.ownerDocument.body,r=qC(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=qC(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+iT(e),o=-t.scrollTop;return Gw(n).direction===`rtl`&&(a+=qC(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var lT=25;function uT(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=Ow(e),a=kw(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Uw()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(iT(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<=lT&&(s-=o)}return{width:s,height:c,x:l,y:u}}function dT(e,t){let n=rT(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=$w(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function fT(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=uT(e,n,t);else if(t===`document`)r=cT(kw(e));else if(jw(t))r=dT(t,n);else{let n=tT(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return _w(r)}function pT(e,t){let n=t.get(e);if(n)return n;let r=Yw(e,[],!1).filter(e=>jw(e)&&Dw(e)!==`body`),i=null,a=Gw(e).position===`fixed`,o=a?qw(e):e;for(;jw(o)&&!Ww(o);){let e=Gw(o),t=Vw(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=qw(o)}return t.set(e,r),r}function mT(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Iw(t)?[]:pT(t,this._c):[].concat(n),r],o=fT(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=fT(t,a[e],i);s=qC(n.top,s),c=KC(n.right,c),l=KC(n.bottom,l),u=qC(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function hT(e){let{width:t,height:n}=Zw(e);return{width:t,height:n}}function gT(e,t,n){let r=Mw(t),i=kw(t),a=n===`fixed`,o=rT(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=XC(0);if((r||!a)&&((Dw(t)!==`body`||Pw(i))&&(s=Kw(t)),r)){let e=rT(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=iT(i));let l=i&&!r&&!a?aT(i,s):XC(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 _T(e){return Gw(e).position===`static`}function vT(e,t){if(!Mw(e)||Gw(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return kw(e)===n&&(n=n.ownerDocument.body),n}function yT(e,t){let n=Ow(e);if(Iw(e))return n;if(!Mw(e)){let t=qw(e);for(;t&&!Ww(t);){if(jw(t)&&!_T(t))return t;t=qw(t)}return n}let r=vT(e,t);for(;r&&Fw(r)&&_T(r);)r=vT(r,t);return r&&Ww(r)&&_T(r)&&!Vw(r)?n:r||Hw(e)||n}var bT=async function(e){let t=this.getOffsetParent||yT,n=this.getDimensions,r=await n(e.floating);return{reference:gT(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function xT(e){return Gw(e).direction===`rtl`}var ST={convertOffsetParentRelativeRectToViewportRelativeRect:oT,getDocumentElement:kw,getClippingRect:mT,getOffsetParent:yT,getElementRects:bT,getClientRects:sT,getDimensions:hT,getScale:$w,isElement:jw,isRTL:xT};function CT(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function wT(e,t,n){let r=null,i,a=kw(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=YC(d),h=YC(a.clientWidth-(u+f)),g=YC(a.clientHeight-(d+p)),_=YC(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:qC(0,KC(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!CT(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=Ow(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function TT(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=Qw(e),u=i||a?[...l?Yw(l):[],...t?Yw(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?wT(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?rT(e):null;c&&g();function g(){let t=rT(e);h&&!CT(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 ET=Tw,DT=Sw,OT=(e,t,n)=>{let r=new Map,i=n??{},a={...ST,...i.platform,_c:r};return xw(e,t,{...i,platform:a})};function kT(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 AT(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 jT(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 MT(e,t,n,r){return n?()=>{let n=r.getState(e.state)?.decorationId;return t.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:jT(e)}function NT({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&&!AT(r)}function PT({view:e,pluginKeyRef:t}){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function FT({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 IT({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 LT({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 RT({placement:e,offset:t,flip:n,floatingUi:r}){var i;let a=[ET({mainAxis:t.mainAxis??4,crossAxis:t.crossAxis??0})];return n&&a.push(DT()),r!=null&&(i=r.middleware)!=null&&i.length&&a.push(...r.middleware),{placement:e,strategy:r?.strategy??`absolute`,middleware:a}}function zT(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 BT({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&&zT(r).appendChild(o),s.onPosition||(o.style.visibility=`hidden`,o.style.width=`max-content`);let d=TT(c,o,()=>{OT(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 VT({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,_=LT({editor:e,items:n}),v=RT({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:BT({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 HT=new P(`suggestion`);function UT({pluginKey:e=HT,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=kT,shouldShow:T,shouldResetDismissed:ee}){let te=S?.(),ne=r&&!i,re=(n,r)=>MT(t,n,r,e);function ie(e){return NT({...e,editor:t,shouldResetDismissed:ee,effectiveAllowSpaces:ne})}let ae=t=>PT({view:t,pluginKeyRef:e});return new N({key:e,view:()=>VT({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:IT({editor:t,char:n,effectiveAllowSpaces:ne,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,findSuggestionMatch:w,allow:C,shouldShow:T,shouldKeepDismissed:ie,pluginKey:e}),props:FT({pluginKey:e,decorationTag:s,decorationClass:c,decorationContent:l,decorationEmptyClass:u,renderer:te,dispatchExit:ae})})}var WT=UT;function GT(e,t,n){return n<t?t:Math.min(Math.max(e,t),n)}function KT(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 qT(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 JT(e){let t=e.gap??8,n=e.padding??8,r=e.fallbackPlacement??(e.preferredPlacement===`top`?`bottom`:`top`),i=KT(e.preferredPlacement,e.anchorRect,e.containerRect,t,n),a=KT(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:GT(u-e.containerRect.left,d,f),top:GT(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 YT=new Set([`auto`,`scroll`,`hidden`,`clip`,`overlay`]);function XT(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 ZT(e,t){let n=t,r=e.parentElement;for(;r&&r!==document.body;){let e=getComputedStyle(r);if(YT.has(e.overflowY)||YT.has(e.overflowX)){let e=r.getBoundingClientRect(),t=XT(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 QT(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 $T(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 eE(e,t,n,r){let i=QT($T(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 QT([s],r)??s}function tE(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 GT(n-e.floatingLeft,r,i)}var nE={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`},rE=new P(`tableControls`),iE=`jant:table-options-open`,aE=`<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>`,oE=`<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>`,sE=`<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 cE(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 lE(e){return cE(e.state.selection.$from)}function uE(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 dE(e){let t=lE(e);if(!t)return{rows:0,columns:0};let n=Z.get(t.node);return{rows:n.height,columns:n.width}}function fE(e){return e.commands.command(({state:e,tr:t,dispatch:n})=>{let r=cE(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 pE(e){let t=e.extensionManager.extensions.find(e=>e.name===`tableControls`);return t?t.options.labels:null}var mE=H.create({name:`tableControls`,addOptions(){return{labels:nE}},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(!lE(e))return!1;let n=dE(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`:fE(e);break;case`deleteTable`:e.commands.deleteTable()}h(),b(a??e.view),r&&!lE(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,aE,`tiptap-table-control-btn`)),n.appendChild(f(`addColumnAfter`,t.addColumnAfter,oE,`tiptap-table-control-btn`)),i=document.createElement(`button`),i.type=`button`,i.className=`tiptap-table-control-btn`,i.innerHTML=sE,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(iE,{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=JT({anchorRect:i,containerRect:qT(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=uE(e);if(!t||!y(e)){_();return}v(e,t),g()}function x(e){if(!uE(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:rE,props:{handleKeyDown(e,t){return t.altKey&&t.key===`F10`?uE(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=uE(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(iE,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(iE,d),window.removeEventListener(`resize`,c),window.removeEventListener(`scroll`,c,!0),n?.remove(),n=null,r=null,i=null,s.clear(),a=null}}}})]}}),hE=8,gE=8,_E=3,vE=3,yE=null;function bE(e,t,n){return e.replaceAll(`%rows%`,String(t)).replaceAll(`%cols%`,String(n))}function xE(e,t,n){yE?.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=_E,f=vE,p=!1,m=[];function h(e,t){return bE(n.insertTableSize,e,t)}function g(e,t){d=Math.min(Math.max(e,1),hE),f=Math.min(Math.max(t,1),gE),l.textContent=`${d} × ${f}`,o.setAttribute(`aria-label`,`${n.sizePickerLabel}: ${h(d,f)}`);for(let e=1;e<=hE;e+=1)for(let t=1;t<=gE;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<=hE;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<=gE;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=JT({anchorRect:{left:t.left,right:t.right,top:t.top,bottom:t.bottom},containerRect:qT(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(),yE?.close===w&&(yE=null),t&&!e.isDestroyed&&e.view.focus())}yE={close:w},a.appendChild(o),g(_E,vE),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 SE(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 CE={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>`},wE={media:`Media`,structure:`Structure`,formatting:`Formatting`,headings:`Headings`},TE=[`media`,`structure`,`formatting`,`headings`],EE=`No matches. Try another command.`,DE={insert:`Insert`,close:`Close`},OE=[{label:`Media`,description:`Upload an image or video.`,group:`media`,keywords:[`image`,`video`,`photo`,`upload`],icon:CE.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:CE.embed,command:(e,t)=>{e.chain().focus().deleteRange(t).run(),SE().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:CE.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:CE.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:CE.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:CE.table,command:(e,t)=>{let n=pE(e);if(n){xE(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:CE.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:CE.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:CE.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:CE.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:CE.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:CE.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:CE.h3,command:(e,t)=>{e.chain().focus().deleteRange(t).toggleHeading({level:3}).run()}}];function kE(e){let t=!1;return e.state.doc.descendants(e=>e.type.name===`moreBreak`?(t=!0,!1):!t),t}function AE(e){return e&&kE(e)?OE.filter(e=>e.label!==`Read More`):OE}var $=null,jE=0,ME=[],NE=null,PE=null,FE=null,IE=null;function LE(){return $?$.querySelector(`.tiptap-slash-menu-scroll`)??$:null}function RE(){let e=document.createElement(`div`);return e.className=`tiptap-slash-menu`,e.dataset.editorFloatingUi=`true`,e.style.position=`fixed`,e}function zE(){if(!$)return;let e=LE();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 BE(){$?.querySelectorAll(`.tiptap-slash-item`).forEach((e,t)=>{let n=t===jE;e.classList.toggle(`is-selected`,n),e.setAttribute(`aria-selected`,n?`true`:`false`)}),HE(),zE()}function VE(){return ME[jE]??null}function HE(){let e=$?.querySelector(`.tiptap-slash-footer-description`);e&&(e.textContent=VE()?.description??``)}function UE(e){return`<div class="tiptap-slash-footer">
|
|
220
220
|
<span class="tiptap-slash-footer-description">${S(e?.description??``)}</span>
|
|
221
221
|
<span class="tiptap-slash-footer-actions" aria-hidden="true">
|
|
222
222
|
<span class="tiptap-slash-footer-note">
|
|
223
223
|
<span class="tiptap-slash-kbd">Enter</span>
|
|
224
|
-
<span>${S(
|
|
224
|
+
<span>${S(DE.insert)}</span>
|
|
225
225
|
</span>
|
|
226
226
|
<span class="tiptap-slash-footer-separator"></span>
|
|
227
227
|
<span class="tiptap-slash-footer-note">
|
|
228
228
|
<span class="tiptap-slash-kbd">Esc</span>
|
|
229
|
-
<span>${S(
|
|
229
|
+
<span>${S(DE.close)}</span>
|
|
230
230
|
</span>
|
|
231
231
|
</span>
|
|
232
|
-
</div>`}function
|
|
232
|
+
</div>`}function WE(e,t){let n=t===jE;return`<div
|
|
233
233
|
class="tiptap-slash-item${n?` is-selected`:``}"
|
|
234
234
|
data-index="${t}"
|
|
235
235
|
role="option"
|
|
@@ -237,25 +237,25 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
237
237
|
>
|
|
238
238
|
<span class="tiptap-slash-item-icon" aria-hidden="true">${e.icon}</span>
|
|
239
239
|
<span class="tiptap-slash-item-label">${S(e.label)}</span>
|
|
240
|
-
</div>`}function
|
|
240
|
+
</div>`}function GE(e,t){if(!$)return;if(ME=e,e.length===0){jE=0,$.dataset.empty=`true`,$.innerHTML=`<div class="tiptap-slash-menu-scroll">
|
|
241
241
|
<div class="tiptap-slash-empty-shell">
|
|
242
|
-
<div class="tiptap-slash-empty" role="status" aria-live="polite">${S(
|
|
242
|
+
<div class="tiptap-slash-empty" role="status" aria-live="polite">${S(EE)}</div>
|
|
243
243
|
</div>
|
|
244
244
|
</div>
|
|
245
|
-
${
|
|
246
|
-
<p class="tiptap-slash-group-label">${S(
|
|
247
|
-
${n.map(({item:e,index:t})=>
|
|
245
|
+
${UE(null)}`;let e=LE();e&&(e.scrollTop=0);return}delete $.dataset.empty,(jE>=e.length||Number.isNaN(jE))&&(jE=0);let n=TE.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(wE[t])}</p>
|
|
247
|
+
${n.map(({item:e,index:t})=>WE(e,t)).join(``)}
|
|
248
248
|
</section>`}).join(``);$.innerHTML=`<div class="tiptap-slash-menu-scroll">
|
|
249
249
|
${n}
|
|
250
250
|
</div>
|
|
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,`originalName`)??``,d=l(s,`url`),f=l(s,`mimeType`),p=i(s,`size`);if(!c||!d||!f||p===void 0)throw Error(`Failed to complete upload`);return{id:c,originalName:u,url:d,mimeType:f,size:p}}async function BD(e,t,n,r){let o=Math.ceil(n.size/t.partSize),s=[],c=0;for(let e=0;e<o;e+=1){let o=e*t.partSize,u=Math.min(o+t.partSize,n.size),d=e+1,f=n.slice(o,u),p=u-o,m=await PD(`${t.url}?partNumber=${d}`,f,{},e=>{r?.((c+p*e)/n.size)});if(!m.ok)throw Error(a(m.text,`Failed to upload part ${d}`));let h=FD(m.text),g=h?i(h,`partNumber`):null,_=h?l(h,`etag`):null;if(!g||!_)throw Error(`Failed to upload part ${d}`);s.push({partNumber:g,etag:_}),c+=p,r?.(c/n.size)}return s}async function VD(e,t,n){let{id:r,transport:i}=await ID(e);try{if(i.kind===`put`){let t=await PD(i.url,e,i.headers,n);if(!t.ok)throw Error(a(t.text,`Upload failed`));n?.(1)}else if(i.kind===`relay`){let t=await PD(i.url,e,{"Content-Type":e.type},n);if(!t.ok)throw Error(a(t.text,`Upload failed`));n?.(1)}let o=i.kind===`multipartRelay`?await BD(r,i,e,n):void 0;return t.poster&&await LD(r,t.poster),zD(r,{...t,parts:o})}catch(e){throw await RD(r),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(`
|
|
251
|
+
${UE(VE())}`,$.querySelectorAll(`.tiptap-slash-item`).forEach(e=>{e.addEventListener(`mousedown`,n=>{n.preventDefault(),t(parseInt(e.dataset.index??`0`,10))}),e.addEventListener(`mouseenter`,()=>{jE=parseInt(e.dataset.index??`0`,10),BE()})});let r=LE();r&&(r.scrollTop=0)}function KE(){IE&&=(document.removeEventListener(`mousedown`,IE,!0),null),$?.remove(),$=null,jE=0,ME=[],NE=null,PE=null,FE=null}function qE(e,t){if(!$)return;$.style.maxHeight=``;let n=qT(null),r=t?qT(t):n,i=JT({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 JE(){IE=e=>{if($&&!$.contains(e.target)&&PE&&FE){let{state:e,view:t}=PE;t.dispatch(e.tr.delete(FE.from,FE.to))}},document.addEventListener(`mousedown`,IE,!0)}var YE=new P(`jantSlashTyping`);function XE(){return new N({key:YE,state:{init:()=>({docChanged:!1}),apply:e=>({docChanged:e.docChanged})}})}function ZE({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 QE({state:e,range:t,isActive:n}){return ZE({state:e,range:t})?n?!0:YE.getState(e)?.docChanged??!1:!1}var $E=H.create({name:`slashCommands`,addOptions(){return{suggestion:{char:`/`,startOfLine:!1,allow:QE,items:({query:e,editor:t})=>{let n=AE(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=>{$=RE(),jE=0,NE=t.command,PE=t.editor,FE=t.range,GE(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&&qE(r,n),JE()},onUpdate:t=>{NE=t.command,FE=t.range,GE(t.items,e=>t.command({index:e}));let n=t.clientRect?.();n&&qE(n,e(t.editor)?.closest(`dialog`)??null)},onKeyDown:e=>{let{event:t,view:n,range:r}=e;return t.key===`ArrowDown`?(t.preventDefault(),ME.length===0||(jE=(jE+1)%ME.length,BE(),!0)):t.key===`ArrowUp`?(t.preventDefault(),ME.length===0||(jE=(jE-1+ME.length)%ME.length,BE(),!0)):t.key===`Enter`?(t.preventDefault(),ME.length===0||NE?.({index:jE}),!0):t.key===`Escape`&&(t.stopPropagation(),t.preventDefault(),n.dispatch(n.state.tr.delete(r.from,r.to)),!0)},onExit:()=>{KE()}}},command:({editor:e,range:t,props:n})=>{let r=ME[n.index];r&&r.command(e,t)}}}},addProseMirrorPlugins(){return[XE(),WT({editor:this.editor,...this.options.suggestion})]}}),eD=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~`.split(``),tD=(e,t)=>{var n=``;for(let r=1;r<=t;r++){let i=Math.floor(e)/83**(t-r)%83;n+=eD[Math.floor(i)]}return n},nD=e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4},rD=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)},iD=e=>e<0?-1:1,aD=(e,t)=>iD(e)*Math.abs(e)**+t,oD=class extends Error{constructor(e){super(e),this.name=`ValidationError`,this.message=e}},sD=4,cD=(e,t,n,r)=>{let i=0,a=0,o=0,s=t*sD;for(let c=0;c<t;c++){let t=sD*c;for(let l=0;l<n;l++){let n=t+l*s,u=r(c,l);i+=u*nD(e[n]),a+=u*nD(e[n+1]),o+=u*nD(e[n+2])}}let c=1/(t*n);return[i*c,a*c,o*c]},lD=e=>{let t=rD(e[0]),n=rD(e[1]),r=rD(e[2]);return(t<<16)+(n<<8)+r},uD=(e,t)=>{let n=Math.floor(Math.max(0,Math.min(18,Math.floor(aD(e[0]/t,.5)*9+9.5)))),r=Math.floor(Math.max(0,Math.min(18,Math.floor(aD(e[1]/t,.5)*9+9.5)))),i=Math.floor(Math.max(0,Math.min(18,Math.floor(aD(e[2]/t,.5)*9+9.5))));return n*19*19+r*19+i},dD=(e,t,n,r,i)=>{if(r<1||r>9||i<1||i>9)throw new oD(`BlurHash must have between 1 and 9 components`);if(t*n*4!==e.length)throw new oD(`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=cD(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+=tD(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+=tD(t,1)}else u=1,c+=tD(0,1);return c+=tD(lD(o),4),s.forEach(e=>{c+=tD(uD(e,u),2)}),c},fD={maxShortSide:1920,maxLongSide:8192,quality:.85,mimeType:`image/webp`};function pD(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 mD(e,t){return t===e?e:`image/jpeg`}function hD(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 gD="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)})}});",_D=typeof self<`u`&&self.Blob&&new Blob([`URL.revokeObjectURL(import.meta.url);`,gD],{type:`text/javascript;charset=utf-8`});function vD(e){let t;try{if(t=_D&&(self.URL||self.webkitURL).createObjectURL(_D),!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(gD),{type:`module`,name:e?.name})}}function yD(){return typeof Worker==`function`&&typeof OffscreenCanvas==`function`&&typeof createImageBitmap==`function`}function bD(){return new vD({name:`jant-image`})}var xD=null,SD=1,CD=new Map;function wD(){if(xD)return xD;let e=bD();return e.addEventListener(`message`,e=>{let t=e.data,n=CD.get(t.id);n&&(CD.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(xD!==e)return;xD=null,e.terminate();let n=[...CD.values()];CD.clear();let r=Error(t.message||`Image worker failed`);for(let e of n)e.reject(r)}),xD=e,e}function TD(e,t){let n=wD();return new Promise((r,i)=>{let a=SD++;CD.set(a,{resolve:r,reject:i});let o={id:a,file:e,options:t};n.postMessage(o)})}function ED(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 DD(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 OD(e,t,n){return new Promise((r,i)=>{e.toBlob(e=>e?r(e):i(Error(`Failed to create blob`)),t,n)})}var kD=new Map;function AD(e,t){let n=kD.get(e);return n||(n=OD(DD(1,1).canvas,e,t).then(t=>mD(e,t.type)),kD.set(e,n)),n}function jD(e){try{let{width:t,height:n}=hD(e.width,e.height),{ctx:r}=DD(t,n);return r.drawImage(e,0,0,t,n),dD(r.getImageData(0,0,t,n).data,t,n,4,3)}catch{return}}async function MD(e,t){let n=await ED(e),r=pD(n.width,n.height,t),i=jD(n);if(r.passthrough)return{blob:e,width:r.width,height:r.height,processed:!1,blurhash:i};let{canvas:a,ctx:o}=DD(r.width,r.height);return o.drawImage(n,0,0,r.width,r.height),{blob:await OD(a,await AD(t.mimeType,t.quality),t.quality),width:r.width,height:r.height,processed:!0,blurhash:i}}async function ND(e,t={}){let n={...fD,...t};if(yD())try{return await TD(e,n)}catch{}return MD(e,n)}async function PD(e,t={}){let n=await ND(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 FD={process:ND,processToFile:PD};function ID(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 LD(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 RD(e){try{let t=JSON.parse(e);return c(t)?t:null}catch{return null}}async function zD(e){let t=await fetch(n(`/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(!t.ok)throw Error(await o(t,`Failed to start upload`));let i=await r(t),a=l(i,`id`),s=ID(i.transport);if(!a||!s)throw Error(`Failed to start upload`);return{id:a,transport:s}}async function BD(e,t){let r=await fetch(n(`/api/uploads/${e}/poster`),{method:`PUT`,headers:{"Content-Type":t.type||`image/webp`},body:t});if(!r.ok)throw Error(await o(r,`Failed to upload poster`))}async function VD(e){await fetch(n(`/api/uploads/${e}/abort`),{method:`POST`}).catch(()=>{})}async function HD(e,t){let a=await fetch(n(`/api/uploads/${e}/complete`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!a.ok)throw Error(await o(a,`Failed to complete upload`));let s=await r(a),c=l(s,`id`),u=l(s,`originalName`)??``,d=l(s,`url`),f=l(s,`mimeType`),p=i(s,`size`);if(!c||!d||!f||p===void 0)throw Error(`Failed to complete upload`);return{id:c,originalName:u,url:d,mimeType:f,size:p}}async function UD(e,t,n,r){let o=Math.ceil(n.size/t.partSize),s=[],c=0;for(let e=0;e<o;e+=1){let o=e*t.partSize,u=Math.min(o+t.partSize,n.size),d=e+1,f=n.slice(o,u),p=u-o,m=await LD(`${t.url}?partNumber=${d}`,f,{},e=>{r?.((c+p*e)/n.size)});if(!m.ok)throw Error(a(m.text,`Failed to upload part ${d}`));let h=RD(m.text),g=h?i(h,`partNumber`):null,_=h?l(h,`etag`):null;if(!g||!_)throw Error(`Failed to upload part ${d}`);s.push({partNumber:g,etag:_}),c+=p,r?.(c/n.size)}return s}async function WD(e,t,n){let{id:r,transport:i}=await zD(e);try{if(i.kind===`put`){let t=await LD(i.url,e,i.headers,n);if(!t.ok)throw Error(a(t.text,`Upload failed`));n?.(1)}else if(i.kind===`relay`){let t=await LD(i.url,e,{"Content-Type":e.type},n);if(!t.ok)throw Error(a(t.text,`Upload failed`));n?.(1)}let o=i.kind===`multipartRelay`?await UD(r,i,e,n):void 0;return t.poster&&await BD(r,t.poster),HD(r,{...t,parts:o})}catch(e){throw await VD(r),e}}async function GD(e){let{file:t,width:n,height:r,blurhash:i}=await FD.processToFile(e),a=await WD(t,{width:n,height:r,blurhash:i});return{url:a.url,id:a.id}}var KD=new Map,qD=new Map;function JD(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 YD(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 XD(e,t,n){n?JD(e,t,n):t.startsWith(`blob:`)&&YD(e,t)}async function ZD(e,t,n=GD){let r=URL.createObjectURL(t);e.chain().focus().setImage({src:r}).run();let i=n(t).then(e=>e.url);KD.set(r,i);try{XD(e,r,await i)}catch{XD(e,r,null)}finally{KD.delete(r)&&URL.revokeObjectURL(r)}}async function QD(e,t){let r=await fetch(n(`/api/uploads/sideload`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e,alt:t})});if(!r.ok)throw Error(`Sideload failed: HTTP ${r.status}`);return await r.json()}async function $D(e,t,n){let r=n();KD.set(t,r);try{XD(e,t,await r)}catch{XD(e,t,null)}finally{KD.delete(t)}}function eO(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=KD.get(r)??qD.get(r);if(!i)return;KD.delete(r),qD.set(r,i);let a=r.startsWith(`blob:`),o=i.then(t=>JD(e,r,t),()=>XD(e,r,null)).finally(()=>{qD.delete(r),a&&URL.revokeObjectURL(r)});t.push(o)}),t}async function tO(e){if(!e)return e;let t=new Map;if(rO(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)}})),iO(e,n)}function nO(e){if(!e)return!1;let t=new Map;return rO(e,t),t.size>0}function rO(e,t){if(e.type===`image`&&typeof e.attrs?.src==`string`){let n=e.attrs.src,r=KD.get(n)??qD.get(n);r&&t.set(n,r)}if(e.content)for(let n of e.content)rO(n,t)}function iO(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=>iO(e,t)).filter(e=>e.type!==`__removed__`);return n===e.content?e:{...e,content:n}}var aO=new P(`pasteMedia`);function oO(e){return`${e.name}:${e.type}:${e.size}:${e.lastModified}`}function sO(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=oO(e);return!r.has(t)&&(r.add(t),!0)})}var cO=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}ZD(e.editor,t)}return r.length>0&&e.options.onPasteFiles!==void 0&&e.options.onPasteFiles(r),!0};return[new N({key:aO,props:{handlePaste(e,n){let r=sO(n.clipboardData);return r.length===0||!t(r)?!1:(n.preventDefault(),!0)},handleDrop(e,n){let r=sO(n.dataTransfer);return r.length===0||!t(r)?!1:(n.preventDefault(),!0)}}})]}}),lO=new P(`linkToolbar`),uO=`hidden`,dO=!1;function fO(){return uO===`input`&&dO}var pO=`<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 mO(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 hO=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=pO,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=()=>{dO=!0},l=()=>{requestAnimationFrame(()=>{let e=document.activeElement;(!t||!t.contains(e))&&(dO=!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=qT(t.dom.closest(`dialog`)),a=eE(t,n,r,ZT(t.dom,i)),o=e.getBoundingClientRect(),s=JT({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`,`${tE({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),uO=`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`),uO=`hidden`,dO=!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:lO,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`&&uO===`input`&&(e.preventDefault(),e.stopPropagation(),s=!0,f())};return e.dom.addEventListener(`keydown`,c),{update(e){if(o){o=!1;return}let n=mO(e.state);if(uO===`input`&&dO){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,uO===`input`&&f()},destroy(){e.dom.removeEventListener(`tiptap:open-link-input`,r),e.dom.removeEventListener(`keydown`,c),p(),t?.remove(),t=null,uO=`hidden`,dO=!1}}}})]}}),gO=new P(`bubbleMenu`),_O={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>`,highlight:`<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="m9 11 8-8 4 4-8 8-4-4Z"/><path d="m9 11-3 3 4 4 3-3M6 14l-3 7 7-3M3 21h7"/></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 vO(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 yO(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 bO(e,t,n){return t===`compose`?[{key:`bold`,icon:_O.bold,title:`Bold`,action:()=>vO(e,`bold`),isActive:()=>e.isActive(`bold`)},{key:`italic`,icon:_O.italic,title:`Italic`,action:()=>vO(e,`italic`),isActive:()=>e.isActive(`italic`)},{key:`highlight`,icon:_O.highlight,title:n,action:()=>vO(e,`highlight`),isActive:()=>e.isActive(`highlight`)},{key:`sep`,icon:``,title:``,action:()=>{},isActive:()=>!1},{key:`link`,icon:_O.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:_O.clear,title:`Clear formatting`,action:()=>yO(e),isActive:()=>!1}]:[{key:`bold`,icon:_O.bold,title:`Bold`,action:()=>vO(e,`bold`),isActive:()=>e.isActive(`bold`)},{key:`italic`,icon:_O.italic,title:`Italic`,action:()=>vO(e,`italic`),isActive:()=>e.isActive(`italic`)},{key:`highlight`,icon:_O.highlight,title:n,action:()=>vO(e,`highlight`),isActive:()=>e.isActive(`highlight`)},{key:`h1`,icon:_O.h1,title:`Heading 1`,action:()=>e.chain().focus().toggleHeading({level:1}).run(),isActive:()=>e.isActive(`heading`,{level:1})},{key:`h2`,icon:_O.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:_O.blockquote,title:`Quote`,action:()=>e.chain().focus().toggleBlockquote().run(),isActive:()=>e.isActive(`blockquote`)},{key:`link`,icon:_O.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 xO=H.create({name:`bubbleMenu`,addOptions(){return{toolbarMode:`default`,highlightLabel:`Highlight`}},addProseMirrorPlugins(){let e=this.editor,t=this.options.toolbarMode,n=this.options.highlightLabel,r=null,i=[],a=new Map;function o(){r=document.createElement(`div`),r.className=`tiptap-bubble-menu`,r.dataset.editorFloatingUi=`true`,r.style.position=`fixed`,r.style.display=`none`,i=bO(e,t,n);for(let t of i){if(t.key===`sep`){let e=document.createElement(`span`);e.className=`tiptap-bubble-sep`,r.appendChild(e);continue}let n=document.createElement(`button`);n.type=`button`,n.innerHTML=t.icon,n.title=t.title,n.setAttribute(`aria-label`,t.title),n.className=`tiptap-bubble-btn`,n.addEventListener(`mousedown`,n=>{n.preventDefault(),t.action(e.view)}),r.appendChild(n),a.set(t.key,n)}}function s(e){if(!r)return;r.style.display=`flex`;let{from:t,to:n}=e.state.selection,i=qT(e.dom.closest(`dialog`)),a=eE(e,t,n,ZT(e.dom,i)),o=r.getBoundingClientRect(),s=JT({anchorRect:a,containerRect:i,floatingWidth:o.width,floatingHeight:o.height,preferredPlacement:`top`,fallbackPlacement:`bottom`,align:`center`});r.style.left=`${s.left}px`,r.style.top=`${s.top}px`,r.dataset.placement=s.placement,r.style.setProperty(`--floating-arrow-x`,`${tE({anchorRect:a,containerRect:i,floatingLeft:s.left,floatingWidth:o.width})}px`),l()}function c(){r&&(r.style.display=`none`)}function l(){for(let t of i){if(t.key===`sep`)continue;let n=a.get(t.key);if(n){let r=t.isActive(e.view);n.classList.toggle(`is-active`,r),n.setAttribute(`aria-pressed`,String(r))}}}function u(e){let{state:t}=e,{selection:n}=t;return n.empty||fO()?!1:n instanceof ar?t.doc.textBetween(n.from,n.to,` `).trim()!==``:n instanceof j&&n.$from.parent.isTextblock}return[new N({key:gO,view(e){o();let t=e.dom.closest(`dialog`)??document.body;r&&t.appendChild(r);function n(t){let n=t.target;if(!n||e.dom.contains(n)||n.closest(`[data-editor-floating-ui]`)||r?.contains(n))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`,n),{update(e){u(e)?s(e):c()},destroy(){t.removeEventListener(`mousedown`,n),r?.remove(),r=null}}}})]}}),SO=` `,CO=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(SO,i)),!0;let u=i-c,d=a-c,f=[],p=l.lastIndexOf(`
|
|
252
252
|
`,u-1)+1;f.push(p);let m=p;for(;;){let e=l.indexOf(`
|
|
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(
|
|
254
|
-
`,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(SO,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(SO)?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(`
|
|
255
255
|
`,u-1)+1;f.push(p);let m=p;for(;;){let e=l.indexOf(`
|
|
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:
|
|
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)}},
|
|
259
|
-
`),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(SO)?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 wO(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 TO(e,t){return e.type.name===`blockquote`&&(t===`backward`?e.lastChild:e.firstChild)?.type.name===`paragraph`?`quote`:null}function EO(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`:TO(a,n)}function DO(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=wO(r);if(!i)return!1;let a=EO(r,i,t);return!a||i.kind!==`quote`&&a!==`quote`?!1:t===`backward`?e.commands.joinTextblockBackward():e.commands.joinTextblockForward()}function OO(e){let t=e?.type.name;return t===`bulletList`||t===`orderedList`}function kO(e){let t=e.depth-1;return t<=0||e.node(t).type.name!==`listItem`?null:OO(e.node(t-1))?t:null}function AO(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 jO(e){let{$from:t}=e.state.selection,n=kO(t);if(n===null)return!1;let r=t.index(n);return r===0?AO(e,n):!t.node(n).child(r-1).isTextblock&&e.commands.joinTextblockBackward()}function MO(e){let{selection:t}=e.state;return!t.empty||!t.$from.parent.isTextblock||t.$from.parentOffset!==0?!1:e.commands.undoInputRule()?!0:jO(e)||DO(e,`backward`)}function NO(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 PO(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 FO(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=NO(n);if(!r)return!1;let{nodeBefore:i,nodeAfter:a}=r;return OO(i)||OO(a)||i?.type.name===`listItem`?r.pos===n.after()&&OO(a)&&PO(e,r)?!0:e.commands.joinTextblockForward():!1}function IO(e){return DO(e,`forward`)||FO(e)}var LO=H.create({name:`structuralKeymap`,priority:1e3,addKeyboardShortcuts(){return{Backspace:({editor:e})=>MO(e),"Mod-Backspace":({editor:e})=>MO(e),"Shift-Backspace":({editor:e})=>MO(e),Delete:({editor:e})=>IO(e),"Mod-Delete":({editor:e})=>IO(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 RO(e){return e.type.name===`bulletList`||e.type.name===`orderedList`}function zO(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&&RO(a)&&a.type===o.type&&En(n,s))return s;let c=zO(o,s,n);if(c!==null)return c;i+=o.nodeSize,a=o}return null}function BO(e){let t=e.tr,n=!1,r=zO(t.doc);for(;r!==null;)t.join(r),n=!0,r=zO(t.doc);return n?t:null}var VO=H.create({name:`continuousLists`,onCreate(){let e=BO(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)?BO(n):null})]}}),HO=/\[([^\]]+)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/,UO=RegExp(HO.source+`$`),WO=RegExp(HO.source+`\\s$`),GO=/((?:https?:\/\/|mailto:|tel:|sms:)[^\s<]+)\s$/i,KO=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:GO,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:UO,handler:({state:e,range:t,match:r})=>{n(e,t,r,``)}}),new Cf({find:WO,handler:({state:e,range:t,match:r})=>{n(e,t,r,` `)}})]}});function qO(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 JO=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:qO(e,`above`)};return{ArrowUp:e,ArrowLeft:e,"Mod-Shift-Enter":({editor:e})=>qO(e,`above`),"Mod-Alt-Enter":({editor:e})=>qO(e,`below`)}}}),YO=/\[\^([^\]\n]+)\]([ \t.,!?;)]$)/,XO=/^\[\^([^\]\n]+)\]: $/,ZO=/\[\^([^\]\n]+)\]$/;function QO(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 $O(e){let t=QO(e),n=1;for(;t.has(String(n));)n+=1;return String(n)}function ek(e){let t=e.content.size;return e.forEach((e,n)=>{e.type.name===`footnoteDefinition`&&(t=n+e.nodeSize)}),t}function tk(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 nk(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 rk(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 ik(e,t){let n=e.schema.nodes.footnoteReference;return n?n.create({label:t}):null}function ak(e,t){let n=e.schema.nodes.footnoteDefinition,r=e.schema.nodes.paragraph;return!n||!r?null:n.create({label:t},[r.create()])}function ok(e,t){let n=Math.min(t+2,e.doc.content.size);e.setSelection(j.near(e.doc.resolve(n),1))}function sk(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 ck(e,t,n){let r=tk(t.doc,n);if(r!==null)return r;let i=ak(e,n);if(!i)return null;let a=ek(t.doc);return t.insert(a,i),sk(t,a+i.nodeSize),a}function lk(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 uk(e){let t=lk(e.doc);if(t.length===0)return null;let n=e.tr;for(let r of t)ck(e,n,r);return n.docChanged?n:null}function dk(e){let{selection:t}=e;return!(t instanceof M)||t.node.type.name!==`footnoteReference`?null:m(t.node.attrs.label)||null}function fk(e,t){let n=e.tr,r=ck(e,n,t);return r===null?null:(ok(n,r),n.scrollIntoView(),n)}function pk(e,t){if(t.doc.childCount>0)return;let n=e.schema.nodes.paragraph;n&&t.insert(0,n.create())}function mk(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 hk(e,t){let n=Math.min(Math.max(t,0),e.doc.content.size);e.setSelection(j.near(e.doc.resolve(n),-1))}function gk(e,t){let n=[...t].sort((e,t)=>t.from-e.from);for(let t of n)e.delete(t.from,t.to)}function _k(e,t){let n=nk(e.doc,t),r=[...rk(e.doc,t),...n?[n]:[]];if(r.length===0)return null;let i=e.tr;return gk(i,r),pk(e,i),mk(i,n),hk(i,r[0]?.from??0),i.scrollIntoView(),i}function vk(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=rk(e.doc,r),a=nk(e.doc,r),o=i.length<=1?[t,...a?[a]:[]]:[t],s=e.tr;return gk(s,o),pk(e,s),mk(s,i.length<=1?a:null),hk(s,t.from),s.scrollIntoView(),s}function yk(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 bk(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 xk(e,t,n,r,i){let a=ik(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)),ck(e,s,t)!==null}function Sk(e,t){let n=ak(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 sk(i,r.before()+n.nodeSize),ok(i,r.before()),i.scrollIntoView(),!0}function Ck(e,t){let n=ak(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),sk(u,d+n.nodeSize),ok(u,d),u.scrollIntoView(),!0}function wk(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 Tk(e){let{selection:t}=e,{$from:n}=t;if(!t.empty||wk(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(ZO),i=m(r?.[1]);return!r||!i?null:{label:i,from:t.from-r[0].length,to:t.from}}function Ek(e){let t=Tk(e);if(t){let n=ik(e,t.label);if(!n)return null;let r=e.tr.replaceWith(t.from,t.to,n),i=ck(e,r,t.label);return i===null?null:(ok(r,i),r.scrollIntoView(),r)}return null}function Dk(){return[new Cf({find:XO,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`?Ck(e,n)?void 0:null:Sk(e,n)?void 0:null}}),new Cf({find:YO,handler:({state:e,range:t,match:n})=>{let r=m(n[1]),i=n[2]??``;return!r||!i||!e.selection.$from.parent.inlineContent?null:xk(e,r,i,t.from,t.to)?void 0:null}})]}var Ok=H.create({name:`footnotes`,onCreate(){let e=uk(this.editor.state);e&&this.editor.view.dispatch(e)},addProseMirrorPlugins(){return[new N({appendTransaction:(e,t,n)=>e.some(e=>e.docChanged)?uk(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=fk(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 ok(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=$O(e.doc),r=ik(e,n),i=ak(e,n);if(!r||!i)return!1;let a=ek(e.doc),o=e.tr.replaceSelectionWith(r,!1),s=o.mapping.map(a);return o.insert(s,i),sk(o,s+i.nodeSize),ok(o,s),t&&t(o.scrollIntoView()),!0}}},addInputRules(){return Dk()},addKeyboardShortcuts(){return{Enter:({editor:e})=>{let t=dk(e.state);if(t){let n=fk(e.state,t);return n?(e.view.dispatch(n),!0):!1}let n=Ek(e.state);return n?(e.view.dispatch(n),!0):!1},Backspace:({editor:e})=>{let t=bk(e.state);if(t){let n=_k(e.state,t);return n?(e.view.dispatch(n),!0):!1}let n=yk(e.state,`backward`);if(!n)return!1;let r=vk(e.state,n);return r?(e.view.dispatch(r),!0):!1},Delete:({editor:e})=>{let t=yk(e.state,`forward`);if(!t)return!1;let n=vk(e.state,t);return n?(e.view.dispatch(n),!0):!1}}}});function kk(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 Ak=`jant:inline-image-load-state`,jk={unavailable:`Image unavailable`,delete:`Delete image`,replace:`Replace image`,open:`Open image URL`},Mk={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>`},Nk=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=Mk.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`,Mk.regular,`Content width`],[`wide`,Mk.wide,`Wide — max 1200px`],[`full`,Mk.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(Mk.link,`Add link`);y.addEventListener(`mousedown`,e=>{e.preventDefault(),this.handleLink()}),_.appendChild(y),_.appendChild(this.sep());let b=this.iconBtn(Mk.replace,`Replace image`);b.addEventListener(`mousedown`,e=>{e.preventDefault(),this.handleReplace()}),_.appendChild(b),_.appendChild(this.sep());let x=this.iconBtn(Mk.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=Pk(t),this.openBtn.disabled=!Fk(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(Ak,{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 GD(t);this.updateAttrs({src:e.url})}catch{}}),e.click()}handleOpenOriginal(){let e=String(this.node.attrs.src??``);Fk(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 Pk(e){let t=e.trim();return t?t.length>140?`${t.slice(0,137)}...`:t:``}function Fk(e){let t=e.trim();return t?/^(https?:|\/|\.\/|\.\.\/|blob:)/i.test(t):!1}var Ik=U.create({name:`image`,group:`block`,atom:!0,selectable:!0,draggable:!0,addOptions(){return{labels:jk}},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&&kk(t,e.schema),!0)).run()}}},addNodeView(){return({node:e,view:t,getPos:n,editor:r})=>new Nk(e,t,n,r,{...jk,...this.options.labels??{}})}}),Lk=`<!--more-->`,Rk=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 Lk},parseMarkdown:(e,t)=>t.createNode(`moreBreak`),renderMarkdown:()=>Lk,markdownTokenizer:vC(),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&&kk(t,e.schema),!0)).run()}}}}),zk=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??``)||Bk(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(){SE({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 Bk(e){if(!e)return`Embed`;try{return new URL(e.startsWith(`http`)?e:`https://${e}`).hostname}catch{return`Embed`}}var Vk=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:gC(),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&&kk(t,e.schema),!0)).run()}}},addNodeView(){return({node:e,view:t,getPos:n,editor:r})=>new zk(e,t,n,r)}}),Hk=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)}},Uk=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:_C(),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&&kk(t,e.schema),!0)).run()}}},addNodeView(){return({node:e,view:t,getPos:n,editor:r})=>new Hk(e,t,n,r)}}),Wk=/^https?:\/\/\S+$/i,Gk=new P(`jantEmbedPaste`),Kk=H.create({name:`embedPaste`,addProseMirrorPlugins(){let e=this.editor;return[new N({key:Gk,props:{handlePaste(t,n){let r=n.clipboardData;if(!r)return!1;let i=r.getData(`text/plain`)?.trim()??``;if(!i||!Wk.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}}})]}}),qk=50,Jk=new P(`jantRehostImages`),Yk=new Set;function Xk(e){Yk.delete(e)}var Zk=H.create({name:`rehostImages`,addOptions(){return{shouldRehost:void 0,rehost:void 0}},addProseMirrorPlugins(){let e=this.options;return[new N({key:Jk,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)||Yk.has(t)||i(t)&&(s.add(t),o.push(t)))}),o.length===0)return null;let c=o.slice(0,qk),l=o.length-c.length;l>0&&console.warn(`[jant] ${l} pasted image(s) left as external links — per-paste rehost cap of ${qk} reached.`);for(let e of c)Yk.add(e),queueMicrotask(()=>a(e));return null}})]}}),Qk=/<!--\s*obsidian\s*-->/i,$k=`section.footnotes, [data-footnotes], [role~="doc-endnotes"]`,eA=`a.footnote-backref, a.footnote-back, a[data-footnote-backref], a[role~="doc-backlink"]`;function tA(e){return e instanceof D?e:e.content}function nA(e){let{doc:t,selection:n}=e.state;return n instanceof ar||n.from===0&&n.to===t.content.size}function rA(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(`
|
|
260
260
|
|
|
261
|
-
`)}function
|
|
261
|
+
`)}function iA(e){return nA(e)?WC(e.getJSON()).trimEnd():rA(e)}function aA(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 oA(e){return Qk.test(e)}function sA(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 cA(e){return e.matches(`meta, link, style, title`)}function lA(e){if(!e.trim()||!oA(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(sA));if(r.size===0)return e;let i=n.filter(e=>!r.has(e)&&!cA(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 uA(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()&&(oA(t)||aA(t))?r:null}function dA(e,t){return(e.getAttribute(`role`)??``).split(/\s+/).includes(t)}function fA(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 pA(e){return e.getAttribute(`id`)??e.getAttribute(`data-footnote-id`)??``}function mA(e,t){let n=e.parentElement;for(;n&&n!==t;){if(n.tagName===`LI`)return!0;n=n.parentElement}return!1}function hA(e){let t=[];for(let n of e.querySelectorAll(`ol, ul`))if(!(n.closest($k)!==e||mA(n,e)))for(let e of n.children)e.tagName===`LI`&&t.push(e);return t}function gA(e){return e.matches(eA)?!1:e.hasAttribute(`data-footnote-ref`)||e.classList.contains(`footnote-ref`)||dA(e,`doc-noteref`)||e.closest(`sup.footnote-ref`)!==null}function _A(e){let t=e.getAttribute(`data-footref`)??e.getAttribute(`data-footnote-label`);return m(t)?m(t):m(e.textContent).replace(/^\[\^?/,``).replace(/\]$/,``)}function vA(e){let t=e.match(/(?:^|[-_:])fn[-_:]?(.+)$/i)?.[1];return m(t??e)}function yA(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 bA(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 xA(e){let t=e.element.ownerDocument,n=e.element.cloneNode(!0);for(let e of n.querySelectorAll(eA))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 SA(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($k)).filter(e=>!e.parentElement?.closest($k)),i=new Map,a=[];for(let e of r){let t=hA(e);if(t.length!==0){i.set(e,t);for(let n of t)a.push({container:e,element:n,targetId:pA(n)})}}for(let e of n.querySelectorAll(`[role~="doc-footnote"]`))e.closest($k)||a.push({container:null,element:e,targetId:pA(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(!gA(e))continue;let t=fA(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?_A(n):vA(e.targetId);return{...e,label:yA(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(bA(e.ownerDocument,n)),d=!0)}}let f=new Map(l.map(e=>[e.element,xA(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 CA(e){return SA(lA(e))}function wA(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 TA(e){if(e.type.name===`paragraph`)return wA(e);if(e.isLeaf||e.childCount===0)return{nodes:[e],changed:!1};let t=[],n=!1;if(e.forEach(e=>{let r=TA(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 EA(e,t){if(t)return e;let n=[],r=!1;return e.content.forEach(e=>{let t=TA(e);n.push(...t.nodes),r||=t.changed}),r?new k(D.fromArray(n),e.openStart,e.openEnd):e}function DA(e){let{schema:t}=e.type;if(e.type.name===`htmlBlock`){let n=String(e.attrs.html??``),r=n?[t.text(n)]:[],i=t.nodes.codeBlock;return i?i.create({language:`html`},r):t.node(`paragraph`,null,r)}if(e.type.name===`embed`)return e.type.create({url:e.attrs.url,provider:e.attrs.provider,providerName:e.attrs.providerName,orientation:e.attrs.orientation,caption:e.attrs.caption});if(e.isLeaf||e.childCount===0)return e;let n=[];return e.forEach(e=>n.push(DA(e))),e.copy(D.fromArray(n))}function OA(e){let t=[];return e.content.forEach(e=>t.push(DA(e))),new k(D.fromArray(t),e.openStart,e.openEnd)}var kA=H.create({name:`markdownClipboard`,priority:1e3,addProseMirrorPlugins(){return[new N({props:{clipboardTextSerializer:()=>iA(this.editor),transformPastedHTML:CA,transformPasted:(e,t,n)=>OA(EA(e,n)),handlePaste:(e,t)=>{let n=t.clipboardData;if(!n||typeof n.getData!=`function`)return!1;let r=uA(n);if(!r||!this.editor.markdown)return!1;let i=NC(this.editor.markdown.parse(r));if(i.type!==`doc`||!i.content)return!1;let a=Al(i,e.state.schema,{slice:!1}),o=OA(k.maxOpen(tA(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=NC(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(tA(t))}let a=Al(i,r.state.schema,{slice:!1});return k.maxOpen(tA(a))}}})]}}),AA=/!\[([^\]\n]*)\]\(((?:[^()\s"]|\([^()\s"]*\))+)(?:\s*"([^"\n]*)")?\)$/;function jA(e){let n=t(e.trim());return!n||/^mailto:/i.test(n)?``:n}var MA=H.create({name:`imageInputRules`,priority:1e3,addInputRules(){let e=this.editor.schema.nodes.image;return e?[new Cf({find:AA,handler:({state:t,range:n,match:r})=>{let i=jA(r[2]??``);if(!i)return null;t.tr.replaceRangeWith(n.from,n.to,e.create({src:i,alt:r[1]??``,title:r[3]??``})),kk(t.tr,t.schema)}})]:[]}}),NA=H.create({name:`reclaimModEnter`,priority:1e3,addKeyboardShortcuts(){return{"Mod-Enter":()=>!0}}});function PA(e={}){return[...kC(),qm.configure({markedOptions:NS}),GC.configure({placeholder:e.placeholder??``}),NA,KO,kA,JO,LO,VO,xO.configure({toolbarMode:`compose`}),hO]}function FA(e={}){return[...kC({imageExtension:Ik.configure({labels:e.imageNodeLabels}),moreBreakExtension:Rk,embedExtension:Vk,htmlBlockExtension:Uk}),NA,qm.configure({markedOptions:NS}),GC.configure({placeholder:e.placeholder??`Write something…`}),Ok,MA,KO,kA,$E,...e.tableControlLabels?[mE.configure({labels:e.tableControlLabels})]:[],Kk,cO.configure(e.pasteMedia??{}),Zk.configure(e.rehostImages??{}),xO.configure({toolbarMode:e.toolbarMode??`default`,...e.highlightLabel?{highlightLabel:e.highlightLabel}:{}}),hO,JO,LO,VO,CO]}function IA(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 WC(t).trimEnd()}function LA(e){return new Zf({element:e.element,extensions:FA({placeholder:e.placeholder,toolbarMode:e.toolbarMode,highlightLabel:e.highlightLabel,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 RA(e){return IA(JSON.stringify(e))}function zA(e){let t=e.content?UC(e.content):void 0;return new Zf({element:e.element,extensions:PA({placeholder:e.placeholder}),content:t,onUpdate:({editor:t})=>{e.onUpdate?.(RA(t.getJSON()))}})}export{m as C,b as S,UC as _,Xk as a,S as b,nO as c,QD as d,ZD as f,dD as g,FD as h,IA as i,$D as l,WD as m,LA as n,sO as o,GD as p,RA as r,eO as s,zA as t,tO as u,de as v,h as x,se as y};
|