@jant/core 1.0.1 → 1.1.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/dist/{app-Gt7_skt6.js → app-CKQ9PqAr.js} +791 -89
- package/dist/client/.vite/manifest.json +115 -75
- package/dist/client/_assets/chunks/{confirm-D7GrwsCN.js → confirm-CMe01lne.js} +1 -1
- package/dist/client/_assets/chunks/{create-editor-5Y49x7h5.js → create-editor-BQkrw8Ax.js} +4 -4
- package/dist/client/_assets/chunks/footnote-rail-B08scyhW.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-B0bNUaih.js} +1 -1
- package/dist/client/_assets/chunks/slug-format-CYmQE5ln.js +1 -0
- package/dist/client/_assets/chunks/{sortable-list-DWNKv782.js → sortable-list-t11Ma1Ek.js} +1 -1
- package/dist/client/_assets/chunks/{unsafe-html-B5ZEXaxg.js → unsafe-html-CWos3v6N.js} +1 -1
- package/dist/client/_assets/chunks/unsafe-svg-DZl-yjas.js +1 -0
- package/dist/client/_assets/client-B0-s9sqx.css +2 -0
- package/dist/client/_assets/client-Dp46QSht.js +354 -0
- package/dist/client/_assets/client-auth-CG55rWb5.js +859 -0
- package/dist/client/_assets/{client-compose-oxzPb3SS.js → client-compose-DkUTuavR.js} +261 -261
- package/dist/client/_assets/{client-manage-C1eDB1Rc.js → client-manage-DnYdQAhf.js} +176 -176
- package/dist/client/_assets/{client-settings-DIM44Zqh.js → client-settings-CHgsIqXJ.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 +2 -2
- package/package.json +2 -1
- 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/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-share.ts +8 -0
- package/src/client.ts +1 -0
- package/src/lib/discover.ts +31 -0
- package/src/lib/share-card.ts +653 -0
- package/src/lib/version.ts +2 -0
- package/src/routes/auth/setup.tsx +37 -1
- package/src/routes/pages/partials.tsx +23 -0
- package/src/style-share.css +16 -0
- package/src/styles/components.css +14 -0
- package/src/styles/share.css +1103 -0
- package/src/styles/ui.css +6 -0
- package/src/ui/layouts/BaseLayout.tsx +7 -0
- package/src/ui/layouts/SiteLayout.tsx +1 -0
- package/src/ui/share/ShareCard.tsx +298 -0
- package/src/ui/shared/Icon.tsx +23 -3
- package/src/ui/shared/MediaGallery.tsx +12 -1
- 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/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
|
@@ -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-D5iF3H1a.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(`
|
|
@@ -248,7 +248,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
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
|
+
${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 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=ND(i.transport);if(!a||!s)throw Error(`Failed to start upload`);return{id:a,transport:s}}async function LD(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 RD(e){await fetch(n(`/api/uploads/${e}/abort`),{method:`POST`}).catch(()=>{})}async function zD(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 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,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 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(`
|
|
252
252
|
`,u-1)+1;f.push(p);let m=p;for(;;){let e=l.indexOf(`
|
|
253
253
|
`,m);if(e===-1||e>=d)break;f.push(e+1),m=e+1}let h=t.tr,g=0;for(let e of f)h=h.insertText(yO,c+e+g),g+=2;let _=i+2,v=a+g;return h.setSelection(j.create(h.doc,_,v)),n(h),!0}return!1},"Shift-Tab":({editor:e})=>{if(e.isActive(`codeBlock`)){let{state:t,dispatch:n}=e.view,{selection:r}=t,{from:i,to:a}=r,o=t.doc.resolve(i),s=o.parent;if(s.type.name!==`codeBlock`)return!1;let c=o.start(),l=s.textContent;if(i===a){let e=i-c,r=l.lastIndexOf(`
|
|
254
254
|
`,e-1)+1,a=l.slice(r),o=a.startsWith(yO)?2:+!!a.startsWith(` `);return o===0||n(t.tr.delete(c+r,c+r+o)),!0}let u=i-c,d=a-c,f=[],p=l.lastIndexOf(`
|
|
@@ -258,4 +258,4 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
258
258
|
`).length),o.addEventListener(`input`,()=>{this.updateAttrs({html:o.value}),this.autoGrow()}),i.appendChild(o),this.textarea=o;let s=document.createElement(`p`);s.className=`tiptap-html-block-hint`,s.textContent=`Renders on the published page only.`,i.appendChild(s),queueMicrotask(()=>this.autoGrow())}update(e){return e.type===this.node.type&&(this.node=e,document.activeElement!==this.textarea&&(this.textarea.value=String(e.attrs.html??``),this.autoGrow()),!0)}selectNode(){this.dom.dataset.selected=`true`}deselectNode(){this.dom.dataset.selected=`false`}stopEvent(e){return e.target.closest(`.tiptap-html-block-textarea`)!==null}ignoreMutation(){return!0}destroy(){}autoGrow(){this.textarea.style.height=`auto`,this.textarea.style.height=`${this.textarea.scrollHeight}px`}updateAttrs(e){let t=this.getPos();if(t===void 0)return;let n=this.view.state.tr.setNodeMarkup(t,void 0,{...this.node.attrs,...e});this.view.dispatch(n)}},Bk=U.create({name:`htmlBlock`,group:`block`,atom:!0,selectable:!0,draggable:!0,addAttributes(){return{html:{default:``}}},parseHTML(){return[{tag:`div[data-jant-node="html-block"]`,getAttrs(e){return{html:e.textContent??``}}}]},renderHTML({node:e}){return[`div`,{"data-jant-node":`html-block`},String(e.attrs.html??``)]},parseMarkdown:(e,t)=>{let n=typeof e.html==`string`?e.html:``;return t.createNode(`htmlBlock`,{html:n})},renderMarkdown:e=>["```jant-html",typeof e.attrs?.html==`string`?e.attrs.html:``,"```"].join(`
|
|
259
259
|
`),markdownTokenizer:gC(),addCommands(){return{setHtmlBlock:e=>({chain:t,state:n})=>{if(!sf(n,n.schema.nodes[this.name]))return!1;let r={html:e.html},{$to:i}=n.selection,a=t();return td(n.selection)?a.insertContentAt(i.pos,{type:this.name,attrs:r}):a.insertContent({type:this.name,attrs:r}),a.command(({state:e,tr:t,dispatch:n})=>(n&&Ek(t,e.schema),!0)).run()}}},addNodeView(){return({node:e,view:t,getPos:n,editor:r})=>new zk(e,t,n,r)}}),Vk=/^https?:\/\/\S+$/i,Hk=new P(`jantEmbedPaste`),Uk=H.create({name:`embedPaste`,addProseMirrorPlugins(){let e=this.editor;return[new N({key:Hk,props:{handlePaste(t,n){let r=n.clipboardData;if(!r)return!1;let i=r.getData(`text/plain`)?.trim()??``;if(!i||!Vk.test(i))return!1;let{selection:a}=t.state;if(!a.empty)return!1;let o=a.$from,s=o.parent;if(s.type.name!==`paragraph`||s.content.size>0||!ce(i)||!se(i))return!1;n.preventDefault();let c=t.state.schema.marks.link,l=o.pos,u=t.state.tr.insertText(i,l);return c&&u.addMark(l,l+i.length,c.create({href:i})),t.dispatch(u),queueMicrotask(()=>{let n=l,r=l+i.length,a=Hy(t.state.tr).delete(n,r);t.dispatch(a),e.commands.setEmbed({url:i})}),!0}}})]}}),Wk=50,Gk=new P(`jantRehostImages`),Kk=new Set;function qk(e){Kk.delete(e)}var Jk=H.create({name:`rehostImages`,addOptions(){return{shouldRehost:void 0,rehost:void 0}},addProseMirrorPlugins(){let e=this.options;return[new N({key:Gk,appendTransaction(t,n,r){if(!t.some(e=>e.docChanged&&e.getMeta(`paste`)))return null;let{shouldRehost:i,rehost:a}=e;if(!i||!a)return null;let o=[],s=new Set;if(r.doc.descendants(e=>{if(e.type.name!==`image`)return;let t=e.attrs.src;typeof t==`string`&&t&&(s.has(t)||Kk.has(t)||i(t)&&(s.add(t),o.push(t)))}),o.length===0)return null;let c=o.slice(0,Wk),l=o.length-c.length;l>0&&console.warn(`[jant] ${l} pasted image(s) left as external links — per-paste rehost cap of ${Wk} reached.`);for(let e of c)Kk.add(e),queueMicrotask(()=>a(e));return null}})]}}),Yk=/<!--\s*obsidian\s*-->/i,Xk=`section.footnotes, [data-footnotes], [role~="doc-endnotes"]`,Zk=`a.footnote-backref, a.footnote-back, a[data-footnote-backref], a[role~="doc-backlink"]`;function Qk(e){return e instanceof D?e:e.content}function $k(e){let{doc:t,selection:n}=e.state;return n instanceof ar||n.from===0&&n.to===t.content.size}function eA(e){let{doc:t,schema:n,selection:r}=e.state,i=Iu(n);return[...r.ranges].sort((e,t)=>e.$from.pos-t.$from.pos).map(({$from:e,$to:n})=>Pu(t,{from:e.pos,to:n.pos},{textSerializers:i})).join(`
|
|
260
260
|
|
|
261
|
-
`)}function tA(e){return $k(e)?VC(e.getJSON()).trimEnd():eA(e)}function nA(e){if(/data-vscode-/i.test(e))return!0;let t=e.match(/^[^<]*(?:<(?:meta|html|head|body)\b[^>]*>\s*)*<(?:div|pre)\b[^>]*style="([^"]*)"/i);if(t){let e=t[1]??``,n=/font-family:[^;"]*\b(?:monospace|Menlo|Monaco|Consolas|Courier|JetBrains Mono|Fira Code|Source Code Pro)\b/i.test(e),r=/white-space:\s*pre\b/i.test(e);if(n&&r)return!0}return!1}function rA(e){return Yk.test(e)}function iA(e){return e.tagName===`P`&&e.attributes.length===0&&Array.from(e.childNodes).every(e=>e.nodeType===globalThis.Node.TEXT_NODE&&/^[\t\n\f\r ]*$/.test(e.textContent??``))}function aA(e){return e.matches(`meta, link, style, title`)}function oA(e){if(!e.trim()||!rA(e)||typeof document>`u`)return e;let t=document.createElement(`template`);t.innerHTML=e;let n=Array.from(t.content.children),r=new Set(n.filter(iA));if(r.size===0)return e;let i=n.filter(e=>!r.has(e)&&!aA(e)).map(e=>n.indexOf(e)),a=!1;for(let e of r){let t=n.indexOf(e),r=i.some(e=>e<t),o=i.some(e=>e>t);r&&o&&(e.remove(),a=!0)}return a?t.innerHTML:e}function sA(e){let t=e.getData(`text/html`),n=e.getData(`text/markdown`);if(n.trim())return n;let r=e.getData(`text/plain`);return r.trim()&&(rA(t)||nA(t))?r:null}function cA(e,t){return(e.getAttribute(`role`)??``).split(/\s+/).includes(t)}function lA(e){let t=e.getAttribute(`href`)??``;if(!t.startsWith(`#`)||t.length===1)return null;let n=t.slice(1);try{return decodeURIComponent(n)}catch{return n}}function uA(e){return e.getAttribute(`id`)??e.getAttribute(`data-footnote-id`)??``}function dA(e,t){let n=e.parentElement;for(;n&&n!==t;){if(n.tagName===`LI`)return!0;n=n.parentElement}return!1}function fA(e){let t=[];for(let n of e.querySelectorAll(`ol, ul`))if(!(n.closest(Xk)!==e||dA(n,e)))for(let e of n.children)e.tagName===`LI`&&t.push(e);return t}function pA(e){return e.matches(Zk)?!1:e.hasAttribute(`data-footnote-ref`)||e.classList.contains(`footnote-ref`)||cA(e,`doc-noteref`)||e.closest(`sup.footnote-ref`)!==null}function mA(e){let t=e.getAttribute(`data-footref`)??e.getAttribute(`data-footnote-label`);return m(t)?m(t):m(e.textContent).replace(/^\[\^?/,``).replace(/\]$/,``)}function hA(e){let t=e.match(/(?:^|[-_:])fn[-_:]?(.+)$/i)?.[1];return m(t??e)}function gA(e,t,n){let r=m(e)||String(t+1),i=r,a=2;for(;n.has(h(i));)i=`${r}-${a}`,a+=1;return n.add(h(i)),i}function _A(e,t){let n=e.createElement(`sup`);return n.setAttribute(`data-footnote-reference`,``),n.setAttribute(`data-footnote-label`,t),n.className=`tiptap-footnote-reference`,n.textContent=g(t),n}function vA(e){let t=e.element.ownerDocument,n=e.element.cloneNode(!0);for(let e of n.querySelectorAll(Zk))e.remove();for(let e of Array.from(n.querySelectorAll(`p, span`)).reverse())!e.textContent?.trim()&&!e.querySelector(`img, video, audio, iframe, svg, math, br, hr, input, table`)&&e.remove();let r=t.createElement(`div`);for(r.setAttribute(`data-footnote-definition`,``),r.setAttribute(`data-footnote-label`,e.label),r.className=`tiptap-footnote-definition`;n.firstChild;)r.appendChild(n.firstChild);return r.hasChildNodes()||r.appendChild(t.createElement(`p`)),r}function yA(e){if(!e.trim()||typeof document>`u`)return e;let t=document.createElement(`template`);t.innerHTML=e;let n=t.content,r=Array.from(n.querySelectorAll(Xk)).filter(e=>!e.parentElement?.closest(Xk)),i=new Map,a=[];for(let e of r){let t=fA(e);if(t.length!==0){i.set(e,t);for(let n of t)a.push({container:e,element:n,targetId:uA(n)})}}for(let e of n.querySelectorAll(`[role~="doc-footnote"]`))e.closest(Xk)||a.push({container:null,element:e,targetId:uA(e)});if(a.length===0)return e;let o=new Map;for(let e of a)e.targetId&&!o.has(e.targetId)&&o.set(e.targetId,e);let s=new Map;for(let e of n.querySelectorAll(`a[href]`)){if(!pA(e))continue;let t=lA(e);if(!t||!o.has(t))continue;let n=s.get(t)??[];n.push(e),s.set(t,n)}let c=new Set,l=a.map((e,t)=>{let n=e.targetId?s.get(e.targetId)?.[0]:void 0,r=n?mA(n):hA(e.targetId);return{...e,label:gA(r,t,c)}}),u=new Map(l.filter(e=>e.targetId).map(e=>[e.targetId,e.label])),d=!1;for(let[e,t]of s){let n=u.get(e);if(n)for(let e of t){let t=e.closest(`sup`),r=t?.contains(e)?t:e;r.parentNode&&(r.replaceWith(_A(e.ownerDocument,n)),d=!0)}}let f=new Map(l.map(e=>[e.element,vA(e)]));for(let[e,t]of i){if(!e.parentNode)continue;let n=e.ownerDocument.createDocumentFragment();for(let e of t){let t=f.get(e);t&&n.appendChild(t)}let r=e.previousElementSibling;r?.matches(`hr.footnotes-sep, hr[data-footnotes-separator]`)&&r.remove(),e.replaceWith(n),d=!0}for(let e of l){if(e.container||!e.element.parentNode)continue;let t=f.get(e.element);t&&(e.element.replaceWith(t),d=!0)}return d?t.innerHTML:e}function bA(e){return yA(oA(e))}function xA(e){let t=[];e.forEach(e=>t.push(e));let n=[],r=[],i=!1;for(let e=0;e<t.length;e+=1){let a=t[e];if(a?.type.name!==`hardBreak`){a&&r.push(a);continue}let o=e+1;for(;t[o]?.type.name===`hardBreak`;)o+=1;if(o-e===1){r.push(a);continue}i=!0,r.length>0&&n.push(r),r=[],e=o-1}return i?(r.length>0&&n.push(r),n.length===0&&n.push([]),{nodes:n.map(t=>e.copy(D.fromArray(t))),changed:!0}):{nodes:[e],changed:!1}}function SA(e){if(e.type.name===`paragraph`)return xA(e);if(e.isLeaf||e.childCount===0)return{nodes:[e],changed:!1};let t=[],n=!1;if(e.forEach(e=>{let r=SA(e);t.push(...r.nodes),n||=r.changed}),!n)return{nodes:[e],changed:!1};let r=D.fromArray(t);return e.type.validContent(r)?{nodes:[e.copy(r)],changed:!0}:{nodes:[e],changed:!1}}function CA(e,t){if(t)return e;let n=[],r=!1;return e.content.forEach(e=>{let t=SA(e);n.push(...t.nodes),r||=t.changed}),r?new k(D.fromArray(n),e.openStart,e.openEnd):e}function wA(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(wA(e))),e.copy(D.fromArray(n))}function TA(e){let t=[];return e.content.forEach(e=>t.push(wA(e))),new k(D.fromArray(t),e.openStart,e.openEnd)}var EA=H.create({name:`markdownClipboard`,priority:1e3,addProseMirrorPlugins(){return[new N({props:{clipboardTextSerializer:()=>tA(this.editor),transformPastedHTML:bA,transformPasted:(e,t,n)=>TA(CA(e,n)),handlePaste:(e,t)=>{let n=t.clipboardData;if(!n||typeof n.getData!=`function`)return!1;let r=sA(n);if(!r||!this.editor.markdown)return!1;let i=MC(this.editor.markdown.parse(r));if(i.type!==`doc`||!i.content)return!1;let a=Al(i,e.state.schema,{slice:!1}),o=TA(k.maxOpen(Qk(a)));return t.preventDefault(),e.dispatch(e.state.tr.replaceSelection(o).scrollIntoView()),!0},clipboardTextParser:(e,t,n,r)=>{if(!e.trim()||!this.editor.markdown)return k.empty;let i=MC(this.editor.markdown.parse(e));if(i.type!==`doc`||!i.content)return k.empty;if(i.content.length===1&&i.content[0]?.type===`paragraph`){let e=i.content[0];if(!e?.content)return k.empty;let t=Al(e.content,r.state.schema,{slice:!0});return k.maxOpen(Qk(t))}let a=Al(i,r.state.schema,{slice:!1});return k.maxOpen(Qk(a))}}})]}}),DA=/!\[([^\]\n]*)\]\(((?:[^()\s"]|\([^()\s"]*\))+)(?:\s*"([^"\n]*)")?\)$/;function OA(e){let t
|
|
261
|
+
`)}function tA(e){return $k(e)?VC(e.getJSON()).trimEnd():eA(e)}function nA(e){if(/data-vscode-/i.test(e))return!0;let t=e.match(/^[^<]*(?:<(?:meta|html|head|body)\b[^>]*>\s*)*<(?:div|pre)\b[^>]*style="([^"]*)"/i);if(t){let e=t[1]??``,n=/font-family:[^;"]*\b(?:monospace|Menlo|Monaco|Consolas|Courier|JetBrains Mono|Fira Code|Source Code Pro)\b/i.test(e),r=/white-space:\s*pre\b/i.test(e);if(n&&r)return!0}return!1}function rA(e){return Yk.test(e)}function iA(e){return e.tagName===`P`&&e.attributes.length===0&&Array.from(e.childNodes).every(e=>e.nodeType===globalThis.Node.TEXT_NODE&&/^[\t\n\f\r ]*$/.test(e.textContent??``))}function aA(e){return e.matches(`meta, link, style, title`)}function oA(e){if(!e.trim()||!rA(e)||typeof document>`u`)return e;let t=document.createElement(`template`);t.innerHTML=e;let n=Array.from(t.content.children),r=new Set(n.filter(iA));if(r.size===0)return e;let i=n.filter(e=>!r.has(e)&&!aA(e)).map(e=>n.indexOf(e)),a=!1;for(let e of r){let t=n.indexOf(e),r=i.some(e=>e<t),o=i.some(e=>e>t);r&&o&&(e.remove(),a=!0)}return a?t.innerHTML:e}function sA(e){let t=e.getData(`text/html`),n=e.getData(`text/markdown`);if(n.trim())return n;let r=e.getData(`text/plain`);return r.trim()&&(rA(t)||nA(t))?r:null}function cA(e,t){return(e.getAttribute(`role`)??``).split(/\s+/).includes(t)}function lA(e){let t=e.getAttribute(`href`)??``;if(!t.startsWith(`#`)||t.length===1)return null;let n=t.slice(1);try{return decodeURIComponent(n)}catch{return n}}function uA(e){return e.getAttribute(`id`)??e.getAttribute(`data-footnote-id`)??``}function dA(e,t){let n=e.parentElement;for(;n&&n!==t;){if(n.tagName===`LI`)return!0;n=n.parentElement}return!1}function fA(e){let t=[];for(let n of e.querySelectorAll(`ol, ul`))if(!(n.closest(Xk)!==e||dA(n,e)))for(let e of n.children)e.tagName===`LI`&&t.push(e);return t}function pA(e){return e.matches(Zk)?!1:e.hasAttribute(`data-footnote-ref`)||e.classList.contains(`footnote-ref`)||cA(e,`doc-noteref`)||e.closest(`sup.footnote-ref`)!==null}function mA(e){let t=e.getAttribute(`data-footref`)??e.getAttribute(`data-footnote-label`);return m(t)?m(t):m(e.textContent).replace(/^\[\^?/,``).replace(/\]$/,``)}function hA(e){let t=e.match(/(?:^|[-_:])fn[-_:]?(.+)$/i)?.[1];return m(t??e)}function gA(e,t,n){let r=m(e)||String(t+1),i=r,a=2;for(;n.has(h(i));)i=`${r}-${a}`,a+=1;return n.add(h(i)),i}function _A(e,t){let n=e.createElement(`sup`);return n.setAttribute(`data-footnote-reference`,``),n.setAttribute(`data-footnote-label`,t),n.className=`tiptap-footnote-reference`,n.textContent=g(t),n}function vA(e){let t=e.element.ownerDocument,n=e.element.cloneNode(!0);for(let e of n.querySelectorAll(Zk))e.remove();for(let e of Array.from(n.querySelectorAll(`p, span`)).reverse())!e.textContent?.trim()&&!e.querySelector(`img, video, audio, iframe, svg, math, br, hr, input, table`)&&e.remove();let r=t.createElement(`div`);for(r.setAttribute(`data-footnote-definition`,``),r.setAttribute(`data-footnote-label`,e.label),r.className=`tiptap-footnote-definition`;n.firstChild;)r.appendChild(n.firstChild);return r.hasChildNodes()||r.appendChild(t.createElement(`p`)),r}function yA(e){if(!e.trim()||typeof document>`u`)return e;let t=document.createElement(`template`);t.innerHTML=e;let n=t.content,r=Array.from(n.querySelectorAll(Xk)).filter(e=>!e.parentElement?.closest(Xk)),i=new Map,a=[];for(let e of r){let t=fA(e);if(t.length!==0){i.set(e,t);for(let n of t)a.push({container:e,element:n,targetId:uA(n)})}}for(let e of n.querySelectorAll(`[role~="doc-footnote"]`))e.closest(Xk)||a.push({container:null,element:e,targetId:uA(e)});if(a.length===0)return e;let o=new Map;for(let e of a)e.targetId&&!o.has(e.targetId)&&o.set(e.targetId,e);let s=new Map;for(let e of n.querySelectorAll(`a[href]`)){if(!pA(e))continue;let t=lA(e);if(!t||!o.has(t))continue;let n=s.get(t)??[];n.push(e),s.set(t,n)}let c=new Set,l=a.map((e,t)=>{let n=e.targetId?s.get(e.targetId)?.[0]:void 0,r=n?mA(n):hA(e.targetId);return{...e,label:gA(r,t,c)}}),u=new Map(l.filter(e=>e.targetId).map(e=>[e.targetId,e.label])),d=!1;for(let[e,t]of s){let n=u.get(e);if(n)for(let e of t){let t=e.closest(`sup`),r=t?.contains(e)?t:e;r.parentNode&&(r.replaceWith(_A(e.ownerDocument,n)),d=!0)}}let f=new Map(l.map(e=>[e.element,vA(e)]));for(let[e,t]of i){if(!e.parentNode)continue;let n=e.ownerDocument.createDocumentFragment();for(let e of t){let t=f.get(e);t&&n.appendChild(t)}let r=e.previousElementSibling;r?.matches(`hr.footnotes-sep, hr[data-footnotes-separator]`)&&r.remove(),e.replaceWith(n),d=!0}for(let e of l){if(e.container||!e.element.parentNode)continue;let t=f.get(e.element);t&&(e.element.replaceWith(t),d=!0)}return d?t.innerHTML:e}function bA(e){return yA(oA(e))}function xA(e){let t=[];e.forEach(e=>t.push(e));let n=[],r=[],i=!1;for(let e=0;e<t.length;e+=1){let a=t[e];if(a?.type.name!==`hardBreak`){a&&r.push(a);continue}let o=e+1;for(;t[o]?.type.name===`hardBreak`;)o+=1;if(o-e===1){r.push(a);continue}i=!0,r.length>0&&n.push(r),r=[],e=o-1}return i?(r.length>0&&n.push(r),n.length===0&&n.push([]),{nodes:n.map(t=>e.copy(D.fromArray(t))),changed:!0}):{nodes:[e],changed:!1}}function SA(e){if(e.type.name===`paragraph`)return xA(e);if(e.isLeaf||e.childCount===0)return{nodes:[e],changed:!1};let t=[],n=!1;if(e.forEach(e=>{let r=SA(e);t.push(...r.nodes),n||=r.changed}),!n)return{nodes:[e],changed:!1};let r=D.fromArray(t);return e.type.validContent(r)?{nodes:[e.copy(r)],changed:!0}:{nodes:[e],changed:!1}}function CA(e,t){if(t)return e;let n=[],r=!1;return e.content.forEach(e=>{let t=SA(e);n.push(...t.nodes),r||=t.changed}),r?new k(D.fromArray(n),e.openStart,e.openEnd):e}function wA(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(wA(e))),e.copy(D.fromArray(n))}function TA(e){let t=[];return e.content.forEach(e=>t.push(wA(e))),new k(D.fromArray(t),e.openStart,e.openEnd)}var EA=H.create({name:`markdownClipboard`,priority:1e3,addProseMirrorPlugins(){return[new N({props:{clipboardTextSerializer:()=>tA(this.editor),transformPastedHTML:bA,transformPasted:(e,t,n)=>TA(CA(e,n)),handlePaste:(e,t)=>{let n=t.clipboardData;if(!n||typeof n.getData!=`function`)return!1;let r=sA(n);if(!r||!this.editor.markdown)return!1;let i=MC(this.editor.markdown.parse(r));if(i.type!==`doc`||!i.content)return!1;let a=Al(i,e.state.schema,{slice:!1}),o=TA(k.maxOpen(Qk(a)));return t.preventDefault(),e.dispatch(e.state.tr.replaceSelection(o).scrollIntoView()),!0},clipboardTextParser:(e,t,n,r)=>{if(!e.trim()||!this.editor.markdown)return k.empty;let i=MC(this.editor.markdown.parse(e));if(i.type!==`doc`||!i.content)return k.empty;if(i.content.length===1&&i.content[0]?.type===`paragraph`){let e=i.content[0];if(!e?.content)return k.empty;let t=Al(e.content,r.state.schema,{slice:!0});return k.maxOpen(Qk(t))}let a=Al(i,r.state.schema,{slice:!1});return k.maxOpen(Qk(a))}}})]}}),DA=/!\[([^\]\n]*)\]\(((?:[^()\s"]|\([^()\s"]*\))+)(?:\s*"([^"\n]*)")?\)$/;function OA(e){let n=t(e.trim());return!n||/^mailto:/i.test(n)?``:n}var kA=H.create({name:`imageInputRules`,priority:1e3,addInputRules(){let e=this.editor.schema.nodes.image;return e?[new Cf({find:DA,handler:({state:t,range:n,match:r})=>{let i=OA(r[2]??``);if(!i)return null;t.tr.replaceRangeWith(n.from,n.to,e.create({src:i,alt:r[1]??``,title:r[3]??``})),Ek(t.tr,t.schema)}})]:[]}}),AA=H.create({name:`reclaimModEnter`,priority:1e3,addKeyboardShortcuts(){return{"Mod-Enter":()=>!0}}});function jA(e={}){return[...OC(),qm.configure({markedOptions:NS}),HC.configure({placeholder:e.placeholder??``}),AA,UO,EA,GO,PO,RO,vO.configure({toolbarMode:`compose`}),fO]}function MA(e={}){return[...OC({imageExtension:Nk.configure({labels:e.imageNodeLabels}),moreBreakExtension:Fk,embedExtension:Rk,htmlBlockExtension:Bk}),AA,qm.configure({markedOptions:NS}),HC.configure({placeholder:e.placeholder??`Write something…`}),Tk,kA,UO,EA,XE,...e.tableControlLabels?[dE.configure({labels:e.tableControlLabels})]:[],Uk,aO.configure(e.pasteMedia??{}),Jk.configure(e.rehostImages??{}),vO.configure({toolbarMode:e.toolbarMode??`default`}),fO,GO,PO,RO,bO]}function NA(e){let t=JSON.parse(e);if(t.type!==`doc`)throw Error(`A TipTap body's root must be a doc node, not ${JSON.stringify(t.type)}.`);return VC(t).trimEnd()}function PA(e){return new Zf({element:e.element,extensions:MA({placeholder:e.placeholder,toolbarMode:e.toolbarMode,pasteMedia:e.pasteMedia,rehostImages:e.rehostImages,imageNodeLabels:e.imageNodeLabels,tableControlLabels:e.tableControlLabels}),content:e.content??void 0,editorProps:{scrollMargin:{top:5,right:5,bottom:80,left:5},scrollThreshold:{top:5,right:5,bottom:80,left:5}},onUpdate:({editor:t})=>{e.onUpdate?.(b(t.getJSON()))},onFocus:()=>{e.onFocus?.()},onBlur:()=>{e.onBlur?.()},onSelectionUpdate:({editor:t})=>{e.onSelectionUpdate?.({from:t.state.selection.from,to:t.state.selection.to})}})}function FA(e){return NA(JSON.stringify(e))}function IA(e){let t=e.content?BC(e.content):void 0;return new Zf({element:e.element,extensions:jA({placeholder:e.placeholder}),content:t,onUpdate:({editor:t})=>{e.onUpdate?.(FA(t.getJSON()))}})}export{m as C,b as S,BC as _,qk as a,S as b,$D as c,YD as d,JD as f,cD as g,MD as h,NA as i,XD as l,VD as m,PA as n,iO as o,HD as p,FA as r,ZD as s,IA as t,QD as u,de as v,h as x,se as y};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_assets/client-compose-DkUTuavR.js","_assets/chunks/runtime-paths-y0_gHowM.js","_assets/chunks/lit-Bw_voPoW.js","_assets/chunks/unsafe-html-CWos3v6N.js","_assets/chunks/preload-helper-Czpn1I53.js","_assets/chunks/unsafe-svg-DZl-yjas.js","_assets/chunks/types-D5iF3H1a.js","_assets/chunks/slug-format-CYmQE5ln.js","_assets/chunks/sortable-list-t11Ma1Ek.js","_assets/chunks/create-editor-BQkrw8Ax.js","_assets/client-settings-CHgsIqXJ.js","_assets/chunks/jant-locale-picker-2L4rkDaz.js","_assets/chunks/confirm-CMe01lne.js","_assets/client-manage-DnYdQAhf.js","_assets/chunks/site-header-nav-DzXsFk05.js","_assets/chunks/settings-paths-B0bNUaih.js","_assets/client-share-C59mOLJ1.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{t as e}from"./preload-helper-Czpn1I53.js";var t=null,n=0,r=!1,i=null,a=null,o=0;function s(e){return!isFinite(e)||e<0?`0:00`:`${Math.floor(e/60)}:${String(Math.floor(e%60)).padStart(2,`0`)}`}function c(e){return e.querySelector(`audio.media-audio-el`)}function l(e){return e.querySelector(`[data-audio-range]`)}function u(e){return e.querySelector(`[data-audio-waveform]`)}function d(e,t){let n=`${(t*100).toFixed(1)}%`;e.style.background=`linear-gradient(to right, var(--site-text-primary) ${n}, transparent ${n})`}var f=new WeakMap,p=new WeakSet;async function ee(e,t){let n=await(await fetch(e)).arrayBuffer(),r=new AudioContext;try{let e=(await r.decodeAudioData(n)).getChannelData(0),i=Math.max(1,Math.floor(e.length/t)),a=Array(t);for(let n=0;n<t;n++){let t=0,r=n*i,o=Math.min(r+i,e.length);for(let n=r;n<o;n++){let r=Math.abs(e[n]);r>t&&(t=r)}a[n]=t}let o=0;for(let e of a)e>o&&(o=e);if(o>0)for(let e=0;e<t;e++)a[e]/=o;return a}finally{await r.close()}}function m(e=document){let t=e.querySelectorAll(`[data-audio-peaks]`),n=[];for(let e of t){let t=e.dataset.audioPeaks;if(!t)continue;let r=e.closest(`.media-audio-card`);if(r&&!f.has(r))try{let e=JSON.parse(t);if(!Array.isArray(e))continue;f.set(r,e),r.classList.add(`has-waveform`),n.push(r)}catch{}}n.length>0&&requestAnimationFrame(()=>{for(let e of n)g(e,0)})}async function h(e){if(f.has(e)||p.has(e))return;p.add(e);let t=e.querySelector(`audio.media-audio-el source`),n=u(e);if(!t?.src||!n)return;let r=n.getBoundingClientRect().width,i=Math.max(20,Math.floor(r/3));try{let n=await ee(t.src,i);f.set(e,n),e.classList.add(`has-waveform`);let r=c(e),a=r?.duration??0;g(e,r&&isFinite(a)&&a>0?r.currentTime/a:0)}catch{}}function g(e,t){let n=f.get(e),r=u(e);if(!n||!r)return;let i=window.devicePixelRatio||1,a=r.getBoundingClientRect(),o=Math.round(a.width*i),s=Math.round(a.height*i);if(o===0||s===0)return;(r.width!==o||r.height!==s)&&(r.width=o,r.height=s);let c=r.getContext(`2d`);if(!c)return;c.clearRect(0,0,o,s);let l=n.length,d=o/l,p=Math.max(1,Math.round(d*.6)),ee=Math.round(2*i),m=s*.85,h=getComputedStyle(r).getPropertyValue(`--site-text-primary`).trim()||`#000`;for(let e=0;e<l;e++){let r=Math.round(e*d+(d-p)/2),a=Math.max(ee,Math.round(n[e]*m)),o=Math.round((s-a)/2);c.globalAlpha=(e+.5)/l<=t?.9:.2,c.fillStyle=h;let u=Math.min(p/2,i);c.beginPath(),c.roundRect(r,o,p,a,u),c.fill()}c.globalAlpha=1}function te(e,t){let{currentTime:n,duration:i}=t,a=isFinite(i)&&i>0,o=a?n/i:0;if(!r){let t=l(e);t&&a&&(t.value=String(Math.round(o*1e3)),d(t,o)),f.has(e)&&g(e,o);let r=e.querySelector(`[data-audio-time]`);r&&(r.textContent=a?`${s(n)} / ${s(i)}`:s(n))}}function _(){if(!t)return;let e=c(t);e&&!e.paused&&(te(t,e),n=requestAnimationFrame(_))}function v(){if(t){let e=c(t);e&&!e.paused&&e.pause(),t.classList.remove(`is-playing`),t=null}cancelAnimationFrame(n)}async function ne(e){let r=c(e);if(r){if(t&&t!==e&&v(),r.paused){t=e,e.classList.add(`is-playing`);try{await r.play()}catch{e.classList.remove(`is-playing`),t=null;return}n=requestAnimationFrame(_),h(e)}else r.pause(),e.classList.remove(`is-playing`),cancelAnimationFrame(n),t=null}}function re(e){let t=e.closest(`.media-audio-card`);if(!t)return;let n=c(t);if(!n)return;let r=Number(e.value)/1e3,i=n.duration;isFinite(i)&&i>0&&(n.currentTime=r*i)}function y(e,t){let n=e.getBoundingClientRect();o=Math.max(0,Math.min(1,(t.clientX-n.left)/n.width));let r=e.closest(`.media-audio-card`);if(!r)return;g(r,o);let i=c(r),a=r.querySelector(`[data-audio-time]`);if(i&&a){let e=i.duration;isFinite(e)&&e>0&&(a.textContent=`${s(o*e)} / ${s(e)}`)}}async function ie(e){let r=e.closest(`.media-audio-card`);if(!r)return;let i=c(r);if(i){if(i.paused){t&&t!==r&&v(),t=r,r.classList.add(`is-playing`);try{await i.play()}catch{r.classList.remove(`is-playing`),t=null;return}let e=i.duration;isFinite(e)&&e>0&&(i.currentTime=o*e),n=requestAnimationFrame(_),h(r)}else{let e=i.duration;isFinite(e)&&e>0&&(i.currentTime=o*e)}}}document.addEventListener(`pointerdown`,e=>{let t=e.target;t.matches(`[data-audio-range]`)?(r=!0,i=t):t.matches(`[data-audio-waveform]`)&&(r=!0,a=t,y(t,e))},!0),document.addEventListener(`pointermove`,e=>{r&&a&&y(a,e)},!0),document.addEventListener(`pointerup`,()=>{r&&(i?(re(i),i=null):a&&=(ie(a),null)),r=!1},!0),document.addEventListener(`pointercancel`,()=>{i=null,a=null,r=!1},!0),document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-audio-play]`);if(!t)return;e.preventDefault();let n=t.closest(`.media-audio-card`);n&&ne(n)}),document.addEventListener(`input`,e=>{let t=e.target;if(!t.matches(`[data-audio-range]`))return;let n=t.closest(`.media-audio-card`);if(!n)return;let r=c(n);if(!r)return;let i=Number(t.value)/1e3;d(t,i);let a=r.duration,o=n.querySelector(`[data-audio-time]`);o&&isFinite(a)&&a>0&&(o.textContent=`${s(i*a)} / ${s(a)}`)},!0),document.addEventListener(`ended`,e=>{let r=e.target;if(!r.closest)return;let i=r.closest(`.media-audio-card`);if(!i)return;i.classList.remove(`is-playing`),cancelAnimationFrame(n),t=null;let a=l(i);a&&(a.value=`0`,d(a,0)),f.has(i)&&g(i,0);let o=i.querySelector(`[data-audio-time]`);o&&(o.textContent=`0:00`)},!0),document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>m()):m();var ae=`jant:media-lightbox-toggle`,oe=`jant:media-video-playback-intent`,b=new Set;function x(e){let t=e?.trim();return!!t&&b.has(t)}function S(e,t){let n=e?.trim();n&&(t?b.add(n):b.delete(n),document.dispatchEvent(new CustomEvent(oe,{detail:{mediaId:n,paused:t}})))}var se=`75% 0px`,C=.6,w=.25,ce=160,T=new Set,le=new WeakMap,ue=new WeakSet,E=null,D=null,O=null,k=!1,A=null,j=null,M=null;function de(e){return e.length===0?null:[...e].sort((e,t)=>t.visibleArea===e.visibleArea?e.centerDistance===t.centerDistance?t.intersectionRatio-e.intersectionRatio:e.centerDistance-t.centerDistance:t.visibleArea-e.visibleArea)[0]??null}function fe(){return{x:(globalThis.innerWidth||document.documentElement.clientWidth||0)/2,y:(globalThis.innerHeight||document.documentElement.clientHeight||0)/2}}function N(e){return le.get(e)}function pe(e){return x(e)}function P(e){return pe(e.dataset.feedVideoId)}function me(e){return e.closest(`.media-video-wrap`)?.querySelector(`[data-feed-video-mute-toggle]`)??null}function F(e){let t=me(e);if(!t)return;let n=O!==e||e.muted;t.dataset.muted=n?`true`:`false`,t.setAttribute(`aria-label`,n?`Play with sound`:`Mute video`)}function he(){for(let e of T)F(e)}function ge(e){if(ue.has(e))return;let t=e.dataset.videoSrc;t&&(e.getAttribute(`src`)!==t&&(e.src=t),e.load(),ue.add(e))}function I(e){e?.pause()}function _e(e){if(P(e)){I(e);return}ge(e),e.muted=O!==e,e.playsInline=!0,e.loop=!0,F(e),e.play().catch(()=>{})}function ve(){for(let e of T)e.isConnected||(j?.unobserve(e),M?.unobserve(e),T.delete(e),e===E&&(E=null),e===D&&(D=null),e===O&&(O=null))}function ye(){if(A=null,ve(),document.hidden||k){I(E);return}let e=[];for(let t of T){let n=N(t);n&&(P(t)||n.intersectionRatio<C||e.push({video:t,...n}))}let t=null;if(D?.isConnected&&!P(D)){let e=N(D);e&&e.intersectionRatio>w?t=D:(!e||e.intersectionRatio<=w)&&(D=null)}else D&&P(D)&&(D=null);if(t||=de(e)?.video??null,!t){let e=E?N(E):void 0;if(E&&!P(E)&&e&&e.intersectionRatio>w)return;I(E),E=null;return}t!==E&&(I(E),E=t),_e(t);for(let e of T)e!==t&&(I(e),F(e))}function L(){A!==null&&globalThis.clearTimeout(A),A=globalThis.setTimeout(ye,ce)}function be(e){let t=fe();for(let n of e){let e=n.target,r=n.boundingClientRect,i=r.left+r.width/2,a=r.top+r.height/2,o=n.intersectionRect.width*n.intersectionRect.height,s=Math.hypot(i-t.x,a-t.y);le.set(e,{intersectionRatio:n.intersectionRatio,visibleArea:o,centerDistance:s})}L()}function xe(e){for(let t of e)t.isIntersecting&&ge(t.target)}function Se(){j&&M||globalThis.IntersectionObserver!==void 0&&(j=new globalThis.IntersectionObserver(be,{threshold:[0,w,C,1]}),M=new globalThis.IntersectionObserver(xe,{rootMargin:se,threshold:0}))}function Ce(e){T.has(e)||(Se(),j&&M&&(T.add(e),j.observe(e),M.observe(e),me(e)?.addEventListener(`click`,we),F(e)))}function we(e){e.preventDefault(),e.stopPropagation();let t=e.currentTarget.closest(`.media-video-wrap`)?.querySelector(`[data-feed-short-video]`);if(!t)return;let n=t.dataset.feedVideoId?.trim();n&&S(n,!1),D=t,O!==t||t.muted?(O&&O!==t&&(O.muted=!0),O=t,E!==t&&(I(E),E=t),_e(t)):(O=null,t.muted=!0,F(t)),he(),L()}function R(e=document){let t=e.querySelectorAll(`[data-feed-short-video]`);for(let e of t)Ce(e);L()}document.addEventListener(ae,e=>{k=e.detail?.open===!0,k&&I(E),L()}),document.addEventListener(oe,e=>{let t=e.detail,n=t?.mediaId?.trim();if(n&&typeof t.paused==`boolean`){for(let e of T)e.dataset.feedVideoId?.trim()===n&&t.paused&&(I(e),E===e&&(E=null),D===e&&(D=null));L()}}),document.addEventListener(`visibilitychange`,()=>{document.hidden&&I(E),L()}),document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>R(),{once:!0}):queueMicrotask(()=>R());function Te(e){if(!(!Number.isFinite(e)||!e||e<=0))return Math.ceil(e)}function Ee(e){if(!e.mimeType?.startsWith(`video/`)||!Number.isFinite(e.durationSeconds)||!e.durationSeconds||e.durationSeconds<=0||e.durationSeconds>15)return!1;let t=e.size;return!(typeof t==`number`&&t>12582912)}function z(e){let t;return()=>t??=e().then(()=>void 0,e=>{throw t=void 0,e})}var B=z(()=>e(()=>import(`../client-compose-DkUTuavR.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),De=z(()=>e(()=>import(`../client-settings-CHgsIqXJ.js`),__vite__mapDeps([10,1,11,2,12,6,9]))),Oe=z(()=>e(()=>import(`../client-manage-DnYdQAhf.js`),__vite__mapDeps([13,1,2,3,14,12,6,7,15,4,8,9]))),ke=z(()=>e(()=>import(`../client-share-C59mOLJ1.js`),__vite__mapDeps([16,2,3]))),Ae=[{selector:`.compose-page`,load:B},{selector:[`jant-settings-general`,`jant-settings-language`,`jant-settings-avatar`,`jant-config-editor`,`jant-repo-picker`].join(`, `),load:De},{selector:[`jant-nav-manager`,`jant-collections-manager`,`[data-collection-page-actions]`,`[data-smart-collection-page-actions]`,`[data-custom-url-actions]`].join(`, `),load:Oe}];function je(){let e=new Set(Ae),t=new globalThis.MutationObserver(n);function n(){for(let t of e)document.querySelector(t.selector)&&(e.delete(t),t.load());e.size===0&&t.disconnect()}n(),e.size>0&&t.observe(document.body,{childList:!0,subtree:!0})}var Me=8;function Ne(e,t){let n=Number.parseFloat(e);return Number.isFinite(n)?n:t}function Pe(e){return Ne(getComputedStyle(e).getPropertyValue(`--site-thread-context-max-height`).trim(),240)}function Fe(e){if(e.dataset.threadContextToggleBound===`1`)return;e.dataset.threadContextToggleBound=`1`;let t=e.previousElementSibling;if(!(t instanceof HTMLElement)||t.dataset.threadContext===void 0)return;let n=e.querySelector(`.thread-context-toggle-label`),r=e.dataset.labelMore??`Show more`,i=e.dataset.labelLess??`Show less`,a=!1,o=t=>{e.setAttribute(`aria-expanded`,t?`true`:`false`),n&&(n.textContent=t?i:r)},s=()=>Array.from(t.querySelectorAll(`img`)).every(e=>e.complete),c=()=>{if(a)return;let n=Pe(t),r=t.scrollHeight>n+Me;t.dataset.collapsed===void 0&&(t.dataset.collapsed=``),r?(e.hidden=!1,o(!1)):s()&&(e.hidden=!0)};if(c(),t.querySelectorAll(`img`).forEach(e=>{e.complete||(e.addEventListener(`load`,c,{once:!0}),e.addEventListener(`error`,c,{once:!0}))}),`ResizeObserver`in globalThis){let e=0;new globalThis.ResizeObserver(()=>{cancelAnimationFrame(e),e=requestAnimationFrame(c)}).observe(t)}let l=()=>{let e=!1,n=r=>{e||r&&r.propertyName!==`max-height`||(e=!0,t.removeEventListener(`transitionend`,n),t.dataset.collapsed===void 0&&(t.style.maxHeight=``))};t.addEventListener(`transitionend`,n),window.setTimeout(n,600)};e.addEventListener(`click`,()=>{a=!0,t.dataset.collapsed===void 0?(t.style.maxHeight=`${t.scrollHeight}px`,t.offsetHeight,requestAnimationFrame(()=>{t.dataset.collapsed=``,t.style.maxHeight=``}),o(!1)):(t.style.maxHeight=`${t.scrollHeight}px`,t.offsetHeight,delete t.dataset.collapsed,o(!0)),l()})}function V(e=document){e.querySelectorAll(`[data-thread-context-toggle]`).forEach(Fe)}function Ie(e){let t=e.closest(`.thread-group-detail`);return t?t.querySelector(`.thread-detail-item`)===e:!1}function Le(){return globalThis.location.hash===`#continue`}function Re(e=document){let t=e.querySelector(`[data-post-current]`);if(!(t instanceof HTMLElement))return;let n=Le();if(globalThis.location.hash&&!n)return;let r=n?`auto`:`smooth`,i=Ie(t);requestAnimationFrame(()=>{(!i||n)&&t.scrollIntoView({behavior:r,block:`start`})})}document.addEventListener(`DOMContentLoaded`,()=>{V(document),Re(document)});var H=[`[data-post-view] .post-detail [data-post-body].post-detail-body`,`[data-timeline-item] article[data-post] > [data-post-body].prose`].join(`, `),ze=`[data-post-view], [data-timeline-item]`,Be=`--jant-footnote-rail-enabled`,U=12,Ve=160,He=.5,W=.5,G=new Map,K=!1;function q(e,t){return Number.isFinite(e)?e:t}function Ue(e,t){let n=Math.max(0,q(t,U)),r=[],i=0;for(let[t,a]of e.entries()){let e=Math.max(0,q(a.anchorTop,0)),o=Math.max(0,q(a.blockSize,0)),s=t===0?e:Math.max(e,i+n);r.push(s),i=s+o}return{offsets:r,blockSize:i}}function We(e){if(!e.startsWith(`#`)||e.length===1)return null;try{return decodeURIComponent(e.slice(1))}catch{return e.slice(1)}}function Ge(e,t){return(e.getAttribute(`role`)??``).split(/\s+/).includes(t)}function Ke(e){let t=Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.classList.contains(`footnote-endnotes`)&&Ge(e,`doc-endnotes`));if(t.length!==1)return null;let n=t[0];if(!n)return null;let r=Array.from(n.children).filter(e=>e instanceof globalThis.HTMLOListElement&&e.classList.contains(`footnote-list`));if(r.length!==1)return null;let i=r[0];if(!i)return null;let a=Array.from(i.children).filter(e=>e instanceof globalThis.HTMLLIElement&&e.classList.contains(`footnote`));if(a.length===0||a.length!==i.children.length)return null;let o=new Map;for(let e of a){if(!e.id||o.has(e.id)||document.getElementById(e.id)!==e)return null;o.set(e.id,e)}let s=new Map;for(let t of e.querySelectorAll(`a[role~="doc-noteref"][href^="#"]`)){let e=We(t.getAttribute(`href`)??``);e&&o.has(e)&&!s.has(e)&&s.set(e,t)}let c=[];for(let e of a){let t=s.get(e.id);if(!t)return null;c.push({reference:t,note:e})}return{section:n,list:i,pairs:c}}function qe(e){return q((Array.isArray(e.contentBoxSize)?e.contentBoxSize[0]:e.contentBoxSize)?.inlineSize??e.contentRect.width,0)}function J(e){return`${Math.round(e*1e3)/1e3}px`}function Y(e){e.body.classList.remove(`footnote-rail-measuring`,`footnote-rail-ready`),e.body.style.removeProperty(`min-block-size`),e.list.style.removeProperty(`--footnote-rail-block-size`);for(let{note:t}of e.pairs)t.style.removeProperty(`--footnote-rail-y`),t.style.removeProperty(`--footnote-rail-number`)}function Je(e){let t=e.list.start;for(let{note:n}of e.pairs)n.hasAttribute(`value`)&&(t=n.value),n.style.setProperty(`--footnote-rail-number`,`"${t}"`),t+=1}function Ye(e){let t=Number.parseFloat(getComputedStyle(e).rowGap);return Number.isFinite(t)?t:U}function Xe(e,t){return Math.max(0,t-e)<=Math.max(Ve,e*He)+W}function Ze(e){if(e.correctedInitialHash)return;e.correctedInitialHash=!0;let t=We(globalThis.location.hash);if(!t)return;let n=e.pairs.find(({note:e})=>e.id===t)?.note;n&&requestAnimationFrame(()=>{e.body.classList.contains(`footnote-rail-ready`)&&n.scrollIntoView({behavior:`auto`,block:`nearest`})})}function Qe(e){return!K&&getComputedStyle(e).getPropertyValue(Be).trim()===`1`}function $e(e){if(!e.body.isConnected){Z(e);return}if(!Qe(e.body)){Y(e);return}Y(e),e.body.classList.add(`footnote-rail-measuring`),Je(e);let t=e.body.getBoundingClientRect(),n=Math.max(0,t.height),r=e.pairs.map(({reference:e,note:n})=>({anchorTop:e.getBoundingClientRect().top-t.top,blockSize:n.getBoundingClientRect().height}));if(r.some(({blockSize:e})=>e<=W)){Y(e);return}let i=Ue(r,Ye(e.list));if(!Xe(n,i.blockSize)){Y(e);return}for(let[t,{note:n}]of e.pairs.entries())n.style.setProperty(`--footnote-rail-y`,J(i.offsets[t]??0));e.list.style.setProperty(`--footnote-rail-block-size`,J(i.blockSize)),e.body.style.setProperty(`min-block-size`,J(Math.max(n,i.blockSize))),e.body.classList.remove(`footnote-rail-measuring`),e.body.classList.add(`footnote-rail-ready`),Ze(e)}function X(e){e.rafId===0&&(e.rafId=requestAnimationFrame(()=>{e.rafId=0,$e(e)}))}function Z(e){e.rafId!==0&&cancelAnimationFrame(e.rafId),e.observer.disconnect(),e.abortController.abort(),Y(e),G.delete(e.body)}function et(e,t){return e.section===t.section&&e.list===t.list&&e.pairs.length===t.pairs.length&&e.pairs.every((e,n)=>e.note===t.pairs[n]?.note&&e.reference===t.pairs[n]?.reference)}function tt(e,t){if(!(`ResizeObserver`in globalThis))return null;let n=e.closest(ze);if(!n)return null;let r=new AbortController,i=new globalThis.ResizeObserver(t=>{let r=G.get(e);if(!r)return;let i=!1;for(let e of t)if(e.target===n){let t=qe(e);(r.containerInlineSize===null||Math.abs(r.containerInlineSize-t)>W)&&(r.containerInlineSize=t,i=!0)}else i=!0;i&&X(r)}),a={body:e,container:n,...t,observer:i,abortController:r,rafId:0,containerInlineSize:null,correctedInitialHash:!1};i.observe(n);for(let n of e.children)n!==t.section&&i.observe(n);for(let t of e.querySelectorAll(`img`))t.complete||(t.addEventListener(`load`,()=>X(a),{once:!0,signal:r.signal}),t.addEventListener(`error`,()=>X(a),{once:!0,signal:r.signal}));return G.set(e,a),X(a),a}function nt(e){let t=[];return e instanceof globalThis.Element&&e.matches(H)&&t.push(e),t.push(...e.querySelectorAll(H)),t}function Q(e=document){for(let e of G.values())e.body.isConnected||Z(e);for(let t of nt(e)){let e=Ke(t),n=G.get(t);if(!e){n&&Z(n);continue}if(n&&et(n,e)){X(n);continue}n&&Z(n),tt(t,e)}}function $(){for(let e of G.values())X(e)}globalThis.addEventListener(`beforeprint`,()=>{K=!0;for(let e of G.values())Y(e)}),globalThis.addEventListener(`afterprint`,()=>{K=!1,$()}),document.fonts&&(document.fonts.ready.then($),document.fonts.addEventListener(`loadingdone`,$)),document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>Q(document),{once:!0}):Q(document);export{je as a,R as c,S as d,m as f,ke as i,ae as l,V as n,Te as o,B as r,Ee as s,Q as t,x as u};
|
package/dist/client/_assets/chunks/{jant-locale-picker-DL6mIOT5.js → jant-locale-picker-2L4rkDaz.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,n as t,t as n}from"./lit-
|
|
1
|
+
import{i as e,n as t,t as n}from"./lit-Bw_voPoW.js";var r=`data-copy-field`,i=`data-copy-field-failed`,a=`data-copy-field-value`,o=`input w-full pr-20 font-mono text-sm`,s=`btn-sm-outline absolute right-2 top-1/2 h-7 -translate-y-1/2 px-2.5 text-xs`,c=`relative`,l=`flex min-w-0 flex-col gap-1`,u=`flex h-9 w-full cursor-pointer items-center rounded-md border border-input bg-transparent bg-[image:var(--chevron-down-icon-50)] bg-position-[center_right_0.75rem] bg-size-[1rem] bg-no-repeat py-2 pl-3 pr-9 text-left text-sm shadow-xs outline-none transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,d=0,f=class extends n{static properties={locales:{type:Array},value:{type:String},exclude:{type:Array},labels:{type:Object},triggerLabel:{type:String,attribute:`trigger-label`},triggerClass:{type:String,attribute:`trigger-class`},labelledby:{type:String},htmlFor:{type:String,attribute:`for`},fullWidth:{type:Boolean,attribute:`full-width`},open:{type:Boolean,reflect:!0},_query:{state:!0},_active:{state:!0}};#e=`locale-picker-${++d}`;createRenderRoot(){return this.innerHTML=``,this}constructor(){super(),this.locales=[],this.value=``,this.exclude=[],this.labels={search:`Search…`,empty:`No matches.`},this.triggerLabel=``,this.triggerClass=u,this.labelledby=``,this.htmlFor=``,this.fullWidth=!1,this.open=!1,this._query=``,this._active=0}connectedCallback(){super.connectedCallback(),document.addEventListener(`click`,this.#u),document.addEventListener(`keydown`,this.#d,!0),this.#n()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener(`click`,this.#u),document.removeEventListener(`keydown`,this.#d,!0)}#t(){if(!this.htmlFor)return null;let e=document.getElementById(this.htmlFor);return e&&`value`in e?e:null}#n(){let e=this.#t();e&&(e.hidden=!0,this.value||=e.value)}#r(e){let t=this.#t();t&&t.value!==e&&(t.value=e,t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.dispatchEvent(new Event(`change`,{bubbles:!0})))}#i(e){return this.locales.find(t=>t.tag===e)??{tag:e,native:e,english:e,coverage:0}}#a(e){let t=this.#i(e);return t.native||t.tag}#o(){let e=this._query.trim().toLowerCase();return this.locales.filter(t=>this.exclude.includes(t.tag)?!1:!e||t.tag.toLowerCase().includes(e)||t.native.toLowerCase().includes(e)||t.english.toLowerCase().includes(e))}#s(){if(this.open){this.#c();return}this.open=!0,this._query=``;let e=this.#o().findIndex(e=>e.tag===this.value);this._active=e>=0?e:0,this.updateComplete.then(()=>{this.querySelector(`[data-language-search]`)?.focus()})}#c(e){this.open&&(this.open=!1,this._query=``,this._active=0,e?.focusTrigger&&this.updateComplete.then(()=>{this.querySelector(`[data-language-trigger]`)?.focus()}))}#l(e){this.value=e,this.#r(e),this.dispatchEvent(new CustomEvent(`locale-select`,{detail:{tag:e},bubbles:!0,composed:!0})),this.#c({focusTrigger:!0})}#u=e=>{if(!this.open)return;let t=e.target;t&&this.contains(t)||this.#c()};#d=e=>{let t=e.target,n=t!==null&&this.contains(t);if(!this.open){n&&e.key===`Enter`&&e.stopPropagation();return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this.#c({focusTrigger:!0});return}if(e.key===`Enter`){e.preventDefault(),e.stopPropagation();let t=this.#o(),n=t[this._active]??t[0];n&&this.#l(n.tag);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let r=this.#o();if(r.length===0)return;e.preventDefault(),e.stopPropagation();let i=e.key===`ArrowDown`?1:-1;this._active=(this._active+i+r.length)%r.length,this.updateComplete.then(()=>{this.querySelector(`[data-language-option][data-active]`)?.scrollIntoView({block:`nearest`})})};render(){let n=this.open?this.#o():[],r=`${this.#e}-list`,i=this.triggerLabel||this.#a(this.value);return e`
|
|
2
2
|
<div
|
|
3
3
|
class=${this.fullWidth?`relative w-full`:`relative w-fit max-w-full`}
|
|
4
4
|
data-language-picker
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=`jant.pendingToast`;function t(){let e=[...document.querySelectorAll(`dialog[open]`)];try{let t=e.filter(e=>e.matches(`:modal`));if(t.length>0)return t}catch{}return e}function n(e){let n=t().at(-1)??document.body;e.parentElement!==n&&n.appendChild(e)}function r(e){n(e),typeof e.showPopover==`function`&&(e.matches(`:popover-open`)&&document.querySelector(`dialog[open]`)&&e.hidePopover(),e.matches(`:popover-open`)||e.showPopover())}function i(){let e=document.getElementById(`toast-container`);if(e)return e;if(!document.body)return null;let t=document.createElement(`div`);return t.id=`toast-container`,t.className=`toast-container`,t.setAttribute(`popover`,`manual`),t.setAttribute(`aria-live`,`polite`),t.setAttribute(`aria-relevant`,`additions text`),document.body.appendChild(t),t}function a(){try{return globalThis.sessionStorage!==void 0}catch{return!1}}function o(){if(!a())return null;let t=globalThis.sessionStorage.getItem(e);if(!t)return null;try{let n=JSON.parse(t);return typeof n.message!=`string`||n.type!==`success`&&n.type!==`error`||n.action&&(typeof n.action.label!=`string`||typeof n.action.href!=`string`)?(globalThis.sessionStorage.removeItem(e),null):{message:n.message,type:n.type,action:n.action}}catch{return globalThis.sessionStorage.removeItem(e),null}}var s={success:`<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><path d="m9 11 3 3L22 4"/></svg>`,error:`<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6M9 9l6 6"/></svg>`},c=3e3,l=5e3,u=1e3;function d(e,t,n,r){e.innerHTML=s[t];let i=document.createElement(`span`);if(i.textContent=n,e.appendChild(i),r){let t=document.createElement(`a`);t.href=r.href,t.className=`toast-action`,t.textContent=r.label,e.appendChild(t)}}function f(e,t){let n=t,r=0,i=null,a=!1,o=!1,s=()=>{i!==null&&(clearTimeout(i),i=null,n=Math.max(n-(Date.now()-r),u))},c=()=>{i===null&&(r=Date.now(),i=setTimeout(()=>{e.classList.add(`toast-out`),e.addEventListener(`animationend`,()=>e.remove())},n))},l=()=>{a||o?s():c()};e.addEventListener(`pointerenter`,()=>{a=!0,l()}),e.addEventListener(`pointerleave`,()=>{a=!1,l()}),e.addEventListener(`focusin`,()=>{o=!0,l()}),e.addEventListener(`focusout`,()=>{o=!1,l()}),c()}function p(e,t=`success`){if(!e)return;let n=i();if(!n)return;r(n);let a=document.createElement(`div`);a.className=`toast toast-${t}`,d(a,t,e),n.appendChild(a),f(a,c)}function m(e,t,n=`success`){if(!e)return;let a=i();if(!a)return;r(a);let o=document.createElement(`div`);o.className=`toast toast-${n}`,d(o,n,e,t),a.appendChild(o),f(o,l)}function ee(e,t,n=`success`){let a=i();if(!a)return null;r(a);let o=document.createElement(`div`);return o.className=`toast toast-${n}`,o.id=`toast-${e}`,d(o,n,t),a.appendChild(o),o}function te(e,t){let n=document.getElementById(`toast-${e}`);if(!n)return;let r=n.querySelector(`span`);r&&(r.textContent=t)}function ne(e){let t=e.parentElement;t&&r(t)}function re(e,t,n=`success`){let r=document.getElementById(`toast-${e}`);if(!r){p(t,n);return}ne(r),r.className=`toast toast-${n}`,r.replaceChildren(),d(r,n,t),f(r,c)}function ie(t,n=`success`,r){t&&a()&&globalThis.sessionStorage.setItem(e,JSON.stringify({message:t,type:n,action:r}))}function ae(){let t=o();return!t||!i()?!1:(globalThis.sessionStorage.removeItem(e),t.action?m(t.message,t.action,t.type):p(t.message,t.type),!0)}function oe(){document.addEventListener(`close`,e=>{let t=e.target;if(!(t instanceof HTMLDialogElement))return;let n=document.getElementById(`toast-container`);n&&t.contains(n)&&r(n)},!0)}function se(){let e=()=>{ae()};if(document.readyState===`loading`){document.addEventListener(`DOMContentLoaded`,e,{once:!0});return}e()}oe(),se();var h=globalThis,g=h.ShadowRoot&&(h.ShadyCSS===void 0||h.ShadyCSS.nativeShadow)&&`adoptedStyleSheets`in Document.prototype&&`replace`in CSSStyleSheet.prototype,ce=Symbol(),_=new WeakMap,le=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==ce)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(g&&e===void 0){let n=t!==void 0&&t.length===1;n&&(e=_.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&_.set(t,e))}return e}toString(){return this.cssText}},ue=e=>new le(typeof e==`string`?e:e+``,void 0,ce),de=(e,t)=>{if(g)e.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let n of t){let t=document.createElement(`style`),r=h.litNonce;r!==void 0&&t.setAttribute(`nonce`,r),t.textContent=n.cssText,e.appendChild(t)}},v=g?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t=``;for(let n of e.cssRules)t+=n.cssText;return ue(t)})(e):e,{is:fe,defineProperty:pe,getOwnPropertyDescriptor:me,getOwnPropertyNames:he,getOwnPropertySymbols:ge,getPrototypeOf:_e}=Object,y=globalThis,ve=y.trustedTypes,ye=ve?ve.emptyScript:``,be=y.reactiveElementPolyfillSupport,b=(e,t)=>e,x={toAttribute(e,t){switch(t){case Boolean:e=e?ye:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},xe=(e,t)=>!fe(e,t),Se={attribute:!0,type:String,converter:x,reflect:!1,useDefault:!1,hasChanged:xe};Symbol.metadata??=Symbol(`metadata`),y.litPropertyMetadata??=new WeakMap;var S=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=Se){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let n=Symbol(),r=this.getPropertyDescriptor(e,n,t);r!==void 0&&pe(this.prototype,e,r)}}static getPropertyDescriptor(e,t,n){let{get:r,set:i}=me(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:r,set(t){let a=r?.call(this);i?.call(this,t),this.requestUpdate(e,a,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Se}static _$Ei(){if(this.hasOwnProperty(b(`elementProperties`)))return;let e=_e(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(b(`finalized`)))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(b(`properties`))){let e=this.properties,t=[...he(e),...ge(e)];for(let n of t)this.createProperty(n,e[n])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[e,n]of t)this.elementProperties.set(e,n)}this._$Eh=new Map;for(let[e,t]of this.elementProperties){let n=this._$Eu(e,t);n!==void 0&&this._$Eh.set(n,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let n=new Set(e.flat(1/0).reverse());for(let e of n)t.unshift(v(e))}else e!==void 0&&t.push(v(e));return t}static _$Eu(e,t){let n=t.attribute;return!1===n?void 0:typeof n==`string`?n:typeof e==`string`?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return de(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$ET(e,t){let n=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,n);if(r!==void 0&&!0===n.reflect){let i=(n.converter?.toAttribute===void 0?x:n.converter).toAttribute(t,n.type);this._$Em=e,i==null?this.removeAttribute(r):this.setAttribute(r,i),this._$Em=null}}_$AK(e,t){let n=this.constructor,r=n._$Eh.get(e);if(r!==void 0&&this._$Em!==r){let e=n.getPropertyOptions(r),i=typeof e.converter==`function`?{fromAttribute:e.converter}:e.converter?.fromAttribute===void 0?x:e.converter;this._$Em=r;let a=i.fromAttribute(t,e.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(e,t,n,r=!1,i){if(e!==void 0){let a=this.constructor;if(!1===r&&(i=this[e]),n??=a.getPropertyOptions(e),!((n.hasChanged??xe)(i,t)||n.useDefault&&n.reflect&&i===this._$Ej?.get(e)&&!this.hasAttribute(a._$Eu(e,n))))return;this.C(e,t,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:n,reflect:r,wrapped:i},a){n&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,a??t??this[e]),!0!==i||a!==void 0)||(this._$AL.has(e)||(this.hasUpdated||n||(t=void 0),this._$AL.set(e,t)),!0===r&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}let e=this.constructor.elementProperties;if(e.size>0)for(let[t,n]of e){let{wrapped:e}=n,r=this[t];!0!==e||this._$AL.has(t)||r===void 0||this.C(t,void 0,n,r)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(e=>e.hostUpdate?.()),this.update(t)):this._$EM()}catch(t){throw e=!1,this._$EM(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(e){}firstUpdated(e){}};S.elementStyles=[],S.shadowRootOptions={mode:`open`},S[b(`elementProperties`)]=new Map,S[b(`finalized`)]=new Map,be?.({ReactiveElement:S}),(y.reactiveElementVersions??=[]).push(`2.1.2`);var C=globalThis,w=e=>e,T=C.trustedTypes,Ce=T?T.createPolicy(`lit-html`,{createHTML:e=>e}):void 0,E=`$lit$`,D=`lit$${Math.random().toFixed(9).slice(2)}$`,O=`?`+D,we=`<${O}>`,k=document,A=()=>k.createComment(``),j=e=>e===null||typeof e!=`object`&&typeof e!=`function`,M=Array.isArray,N=e=>M(e)||typeof e?.[Symbol.iterator]==`function`,P=`[
|
|
2
|
+
\f\r]`,F=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,I=/-->/g,L=/>/g,R=RegExp(`>|${P}(?:([^\\s"'>=/]+)(${P}*=${P}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,`g`),z=/'/g,B=/"/g,V=/^(?:script|style|textarea|title)$/i,H=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),Te=H(1),Ee=H(2),U=Symbol.for(`lit-noChange`),W=Symbol.for(`lit-nothing`),G=new WeakMap,K=k.createTreeWalker(k,129);function q(e,t){if(!M(e)||!e.hasOwnProperty(`raw`))throw Error(`invalid template strings array`);return Ce===void 0?t:Ce.createHTML(t)}var De=(e,t)=>{let n=e.length-1,r=[],i,a=t===2?`<svg>`:t===3?`<math>`:``,o=F;for(let t=0;t<n;t++){let n=e[t],s,c,l=-1,u=0;for(;u<n.length&&(o.lastIndex=u,c=o.exec(n),c!==null);)u=o.lastIndex,o===F?c[1]===`!--`?o=I:c[1]===void 0?c[2]===void 0?c[3]!==void 0&&(o=R):(V.test(c[2])&&(i=RegExp(`</`+c[2],`g`)),o=R):o=L:o===R?c[0]===`>`?(o=i??F,l=-1):c[1]===void 0?l=-2:(l=o.lastIndex-c[2].length,s=c[1],o=c[3]===void 0?R:c[3]===`"`?B:z):o===B||o===z?o=R:o===I||o===L?o=F:(o=R,i=void 0);let d=o===R&&e[t+1].startsWith(`/>`)?` `:``;a+=o===F?n+we:l>=0?(r.push(s),n.slice(0,l)+E+n.slice(l)+D+d):n+D+(l===-2?t:d)}return[q(e,a+(e[n]||`<?>`)+(t===2?`</svg>`:t===3?`</math>`:``)),r]},J=class e{constructor({strings:t,_$litType$:n},r){let i;this.parts=[];let a=0,o=0,s=t.length-1,c=this.parts,[l,u]=De(t,n);if(this.el=e.createElement(l,r),K.currentNode=this.el.content,n===2||n===3){let e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;(i=K.nextNode())!==null&&c.length<s;){if(i.nodeType===1){if(i.hasAttributes())for(let e of i.getAttributeNames())if(e.endsWith(E)){let t=u[o++],n=i.getAttribute(e).split(D),r=/([.?@])?(.*)/.exec(t);c.push({type:1,index:a,name:r[2],strings:n,ctor:r[1]===`.`?ke:r[1]===`?`?Ae:r[1]===`@`?je:Z}),i.removeAttribute(e)}else e.startsWith(D)&&(c.push({type:6,index:a}),i.removeAttribute(e));if(V.test(i.tagName)){let e=i.textContent.split(D),t=e.length-1;if(t>0){i.textContent=T?T.emptyScript:``;for(let n=0;n<t;n++)i.append(e[n],A()),K.nextNode(),c.push({type:2,index:++a});i.append(e[t],A())}}}else if(i.nodeType===8){if(i.data===O)c.push({type:2,index:a});else{let e=-1;for(;(e=i.data.indexOf(D,e+1))!==-1;)c.push({type:7,index:a}),e+=D.length-1}}a++}}static createElement(e,t){let n=k.createElement(`template`);return n.innerHTML=e,n}};function Y(e,t,n=e,r){if(t===U)return t;let i=r===void 0?n._$Cl:n._$Co?.[r],a=j(t)?void 0:t._$litDirective$;return i?.constructor!==a&&(i?._$AO?.(!1),a===void 0?i=void 0:(i=new a(e),i._$AT(e,n,r)),r===void 0?n._$Cl=i:(n._$Co??=[])[r]=i),i!==void 0&&(t=Y(e,i._$AS(e,t.values),i,r)),t}var Oe=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:n}=this._$AD,r=(e?.creationScope??k).importNode(t,!0);K.currentNode=r;let i=K.nextNode(),a=0,o=0,s=n[0];for(;s!==void 0;){if(a===s.index){let t;s.type===2?t=new X(i,i.nextSibling,this,e):s.type===1?t=new s.ctor(i,s.name,s.strings,this,e):s.type===6&&(t=new Me(i,this,e)),this._$AV.push(t),s=n[++o]}a!==s?.index&&(i=K.nextNode(),a++)}return K.currentNode=k,r}p(e){let t=0;for(let n of this._$AV)n!==void 0&&(n.strings===void 0?n._$AI(e[t]):(n._$AI(e,n,t),t+=n.strings.length-2)),t++}},X=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,r){this.type=2,this._$AH=W,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=Y(this,e,t),j(e)?e===W||e==null||e===``?(this._$AH!==W&&this._$AR(),this._$AH=W):e!==this._$AH&&e!==U&&this._(e):e._$litType$===void 0?e.nodeType===void 0?N(e)?this.k(e):this._(e):this.T(e):this.$(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==W&&j(this._$AH)?this._$AA.nextSibling.data=e:this.T(k.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:n}=e,r=typeof n==`number`?this._$AC(e):(n.el===void 0&&(n.el=J.createElement(q(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(t);else{let e=new Oe(r,this),n=e.u(this.options);e.p(t),this.T(n),this._$AH=e}}_$AC(e){let t=G.get(e.strings);return t===void 0&&G.set(e.strings,t=new J(e)),t}k(t){M(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,r,i=0;for(let a of t)i===n.length?n.push(r=new e(this.O(A()),this.O(A()),this,this.options)):r=n[i],r._$AI(a),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let t=w(e).nextSibling;w(e).remove(),e=t}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},Z=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,r,i){this.type=1,this._$AH=W,this._$AN=void 0,this.element=e,this.name=t,this._$AM=r,this.options=i,n.length>2||n[0]!==``||n[1]!==``?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=W}_$AI(e,t=this,n,r){let i=this.strings,a=!1;if(i===void 0)e=Y(this,e,t,0),a=!j(e)||e!==this._$AH&&e!==U,a&&(this._$AH=e);else{let r=e,o,s;for(e=i[0],o=0;o<i.length-1;o++)s=Y(this,r[n+o],t,o),s===U&&(s=this._$AH[o]),a||=!j(s)||s!==this._$AH[o],s===W?e=W:e!==W&&(e+=(s??``)+i[o+1]),this._$AH[o]=s}a&&!r&&this.j(e)}j(e){e===W?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??``)}},ke=class extends Z{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===W?void 0:e}},Ae=class extends Z{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==W)}},je=class extends Z{constructor(e,t,n,r,i){super(e,t,n,r,i),this.type=5}_$AI(e,t=this){if((e=Y(this,e,t,0)??W)===U)return;let n=this._$AH,r=e===W&&n!==W||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,i=e!==W&&(n===W||r);r&&this.element.removeEventListener(this.name,this,n),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH==`function`?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},Me=class{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){Y(this,e)}},Ne={M:E,P:D,A:O,C:1,L:De,R:Oe,D:N,V:Y,I:X,H:Z,N:Ae,U:je,B:ke,F:Me},Pe=C.litHtmlPolyfillSupport;Pe?.(J,X),(C.litHtmlVersions??=[]).push(`3.3.3`);var Fe=(e,t,n)=>{let r=n?.renderBefore??t,i=r._$litPart$;if(i===void 0){let e=n?.renderBefore??null;r._$litPart$=i=new X(t.insertBefore(A(),e),e,void 0,n??{})}return i._$AI(e),i},Q=globalThis,$=class extends S{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Fe(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return U}};$._$litElement$=!0,$.finalized=!0,Q.litElementHydrateSupport?.({LitElement:$});var Ie=Q.litElementPolyfillSupport;Ie?.({LitElement:$}),(Q.litElementVersions??=[]).push(`4.2.2`);export{Ne as a,re as c,m as d,te as f,Te as i,ee as l,W as n,Ee as o,U as r,ie as s,$ as t,p as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=function(e){return`/`+e},t={},n=function(n,r,i){let a=Promise.resolve();if(r&&r.length>0){let n=document.getElementsByTagName(`link`),o=document.querySelector(`meta[property=csp-nonce]`),s=o?.nonce||o?.getAttribute(`nonce`);function c(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function l(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}a=c(r.map(r=>{if(r=e(r,i),r=l(r),r in t)return;t[r]=!0;let a=r.endsWith(`.css`);for(let e=n.length-1;e>=0;e--){let t=n[e];if(t.href===r&&(!a||t.rel===`stylesheet`))return}let o=document.createElement(`link`);if(o.rel=a?`stylesheet`:`modulepreload`,a||(o.as=`script`),o.crossOrigin=``,o.href=r,s&&o.setAttribute(`nonce`,s),document.head.appendChild(o),a)return new Promise((e,t)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>t(Error(`Unable to preload CSS for ${r}`)))})}))}function o(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return a.then(e=>{for(let t of e||[])t.status===`rejected`&&o(t.reason);return n().catch(o)})};export{n as t};
|