videobook 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/chat-router.js +1 -1
  3. package/dist/guides/seedance_2_prompting_guide.md +1 -1
  4. package/dist/image-edit-models.js +1 -0
  5. package/dist/jobs/generate-media.js +18 -6
  6. package/dist/jobs/run-notebook.js +23 -4
  7. package/dist/media/adapters/fal.js +7 -0
  8. package/dist/media/catalog.js +4 -2
  9. package/dist/media/cost.js +2 -2
  10. package/dist/media/refs.js +13 -0
  11. package/dist/media/request.js +7 -0
  12. package/dist/media/seedance-edit.js +9 -0
  13. package/dist/provider-usage.js +3 -1
  14. package/dist/tools/estimate-cost.js +4 -1
  15. package/dist/tools/generate-media.js +2 -1
  16. package/dist/tools/reconcile-project-work.js +2 -1
  17. package/package.json +13 -13
  18. package/ui/assets/{alive-captions-e-n3xmCd.js → alive-captions-C48o6dfv.js} +1 -1
  19. package/ui/assets/confirm-bodies-aq6Az8Md.js +1 -0
  20. package/ui/assets/{fullscreen-VY7f4mJ-.js → fullscreen-4m0qtZ7w.js} +1 -1
  21. package/ui/assets/{goal-ui-B__NgZYz.js → goal-ui-2pUWP_B2.js} +2 -2
  22. package/ui/assets/{index-BPco0HoT.js → index-DmDH4gYr.js} +2 -2
  23. package/ui/assets/{inspector-BBuZIaqg.js → inspector-CnKySYc5.js} +1 -1
  24. package/ui/assets/{jobs-ui-vmEH4zBT.js → jobs-ui-lRoS1MbL.js} +1 -1
  25. package/ui/assets/{music-video-CklLKD1R.js → music-video-BQnnPp-X.js} +1 -1
  26. package/ui/assets/ui-OHFUngrc.js +2 -0
  27. package/ui/assets/{vendor-flow-DY81i6dC.js → vendor-flow-zBavaNEW.js} +1 -1
  28. package/ui/assets/{vendor-mcp-BsGNAD4I.js → vendor-mcp-DQ7EusT9.js} +1 -1
  29. package/ui/assets/vendor-yctIZ9Dz.js +19 -0
  30. package/ui/assets/{videobook-lhLK6e6Q.js → videobook-DZ58pKW5.js} +12 -12
  31. package/ui/index.html +11 -11
  32. package/ui/assets/confirm-bodies-DS6jh0Kb.js +0 -1
  33. package/ui/assets/ui-CtYXY_po.js +0 -2
  34. package/ui/assets/vendor-OClqq_Da.js +0 -19
@@ -0,0 +1,19 @@
1
+ import{s as a,_ as h,o as u,a as k,r as z,u as K,b as y,n as x,l as f,d as Te,c as P,t as cs,e as lc,f as $i}from"./vendor-mcp-DQ7EusT9.js";const us="(?:a[a-z]|b[a-l]|[a-z])[1-8]",ps=new RegExp(`^@?(${us})$`,"iu"),cc=new RegExp(`@(${us})(?![\\w-])`,"giu");function nn(n){return n.trim().replace(/^@/u,"").toLowerCase()}function ik(n){return ps.test(nn(n))}function rk(n){return[...n.matchAll(cc)].map(e=>{const t=e[0];return{raw:t,reference:nn(e[1]??t),index:e.index,end:e.index+t.length}})}function sk(n){const e=n.match(/@([a-z0-9]*)$/iu);return e?nn(e[1]??""):void 0}function ds(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ak(n,e){let t=n;const o=[...e].map(({reference:i,replacement:r})=>({reference:nn(i),replacement:r})).filter(({reference:i})=>i.length>0).sort((i,r)=>r.reference.length-i.reference.length);for(const{reference:i,replacement:r}of o)t=t.replace(new RegExp(`@${ds(i)}(?![\\w-])`,"giu"),r);return t}function lk(n,e){let t=n;const o=e.map(nn).filter(i=>i.length>0).sort((i,r)=>r.length-i.length);for(const i of o)t=t.replace(new RegExp(` ?@${ds(i)}(?![\\w-])`,"giu"),"");return t}const Me=64,ve=8,ck=Me*ve,uc="@a1-@bl8",ms="Notebook grid is full",Fo=26,hs=97;function pc(n){return n.type==="timeline"?Array.from({length:ve},(e,t)=>({row:n.slot.row,column:t})):[n.slot]}function uk(n){return n.flatMap(pc)}function pk(n){const e=new Set([...n].map(t=>t.row));for(let t=0;t<Me;t+=1)if(!e.has(t))return{row:t,column:0};throw new Error("Notebook has no completely empty row for a timeline")}function dc(n){return Number.isInteger(n.row)&&n.row>=0&&n.row<Me&&Number.isInteger(n.column)&&n.column>=0&&n.column<ve}function $n(n,e="Notebook grid slot"){if(!dc(n))throw new Error(`${e} must be within ${uc}`)}function mc(n){let e="",t=n+1;for(;t>0;){const o=(t-1)%Fo;e=String.fromCharCode(hs+o)+e,t=Math.floor((t-1)/Fo)}return e}function hc(n){let e=0;for(const t of n.toLowerCase())e=e*Fo+(t.charCodeAt(0)-hs+1);return e-1}function fc(n){return $n(n),`${mc(n.row)}${n.column+1}`}function dk(n){return`@${fc(n)}`}function mk(n){const e=ps.exec(n.trim());if(!e)return;const t=e[1],o=t.replace(/\d+$/u,"");return{row:hc(o),column:Number(t.slice(o.length))-1}}function on(n){const e=new Set;for(const t of n)$n(t),e.add(`${t.row}:${t.column}`);return e}function hk(n){return gc(n,1)[0]}function gc(n,e){if(!Number.isInteger(e)||e<0)throw new Error("Notebook grid slot count must be a nonnegative integer");if(e===0)return[];const t=on(n),o=[];for(let i=0;i<Me;i+=1)for(let r=0;r<ve;r+=1)if(!t.has(`${i}:${r}`)&&(o.push({row:i,column:r}),o.length===e))return o;if(o.length===e)return o;throw new Error(ms)}function ii(n){const e=on(n);let t=null,o=Number.POSITIVE_INFINITY;for(let i=0;i<Me;i+=1)for(let r=0;r<ve;r+=1){if(e.has(`${i}:${r}`))continue;const s=i+r;(t===null||s<o||s===o&&(i<t.row||i===t.row&&r<t.column))&&(t={row:i,column:r},o=s)}if(!t)throw new Error(ms);return t}function fk(n,e){$n(n);const t=on(e);for(let o=n.row;o<Me;o+=1)if(!t.has(`${o}:${n.column}`))return{row:o,column:n.column};for(let o=n.column+1;o<ve;o+=1)for(let i=n.row;i<Me;i+=1)if(!t.has(`${i}:${o}`))return{row:i,column:o};return ii(e)}function gk(n,e){$n(n);const t=on(e);for(let o=n.column;o<ve;o+=1)if(!t.has(`${n.row}:${o}`))return{row:n.row,column:o};for(let o=n.row+1;o<Me;o+=1)for(let i=n.column;i<ve;i+=1)if(!t.has(`${o}:${i}`))return{row:o,column:i};return ii(e)}function xk(n,e,t){const o=on(t),i=Math.min(Math.max(0,Math.trunc(n)),Me-1),r=Math.min(Math.max(0,Math.trunc(e)),ve-1);for(let s=i;s+1<Me;s+=1)for(let l=r;l<ve;l+=1)if(!o.has(`${s}:${l}`)&&!o.has(`${s+1}:${l}`))return{row:s,column:l};return ii(t)}function xc(n){if(typeof n=="string"||typeof n=="number")return""+n;let e="";if(Array.isArray(n))for(let t=0,o;t<n.length;t++)(o=xc(n[t]))!==""&&(e+=(e&&" ")+o);else for(let t in n)n[t]&&(e+=(e&&" ")+t);return e}const X=[];for(let n=0;n<256;++n)X.push((n+256).toString(16).slice(1));function yc(n,e=0){return(X[n[e+0]]+X[n[e+1]]+X[n[e+2]]+X[n[e+3]]+"-"+X[n[e+4]]+X[n[e+5]]+"-"+X[n[e+6]]+X[n[e+7]]+"-"+X[n[e+8]]+X[n[e+9]]+"-"+X[n[e+10]]+X[n[e+11]]+X[n[e+12]]+X[n[e+13]]+X[n[e+14]]+X[n[e+15]]).toLowerCase()}const Sc=new Uint8Array(16);function bc(){return crypto.getRandomValues(Sc)}const ko={};function yk(n,e,t){let o;{const i=Date.now(),r=bc();kc(ko,i,r),o=_c(r,ko.msecs,ko.seq,e,t)}return e??yc(o)}function kc(n,e,t){return n.msecs??=-1/0,n.seq??=0,e>n.msecs?(n.seq=t[6]<<23|t[7]<<16|t[8]<<8|t[9],n.msecs=e):(n.seq=n.seq+1|0,n.seq===0&&n.msecs++),n}function _c(n,e,t,o,i=0){if(n.length<16)throw new Error("Random bytes length must be >= 16");if(!o)o=new Uint8Array(16),i=0;else if(i<0||i+16>o.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);return e??=Date.now(),t??=n[6]*127<<24|n[7]<<16|n[8]<<8|n[9],o[i++]=e/1099511627776&255,o[i++]=e/4294967296&255,o[i++]=e/16777216&255,o[i++]=e/65536&255,o[i++]=e/256&255,o[i++]=e&255,o[i++]=112|t>>>28&15,o[i++]=t>>>20&255,o[i++]=128|t>>>14&63,o[i++]=t>>>6&255,o[i++]=t<<2&255|n[10]&3,o[i++]=n[11],o[i++]=n[12],o[i++]=n[13],o[i++]=n[14],o[i++]=n[15],o}const Sk=["people","places","editing","custom"],ji=64,wc=new RegExp("\\p{Cc}","u");function Tc(n){if(typeof n!="string")throw new Error("Tag label is required");const e=n.normalize("NFKC").replace(/\s+/gu," ").trim();if(!e)throw new Error("Tag label is required");if(wc.test(e))throw new Error("Tag label must not contain control characters");const t=[...e].length;if(t>ji)throw new Error(`Tag label must be at most ${ji} characters; received ${t}`);return e}function bk(n){return Tc(n).toLowerCase()}function ri(n,e,t,o){for(const i of n.edges){if(i.source!==e||i.targetInput!=="media")continue;const r=n.cells.find(s=>s.id===i.target);if(r?.type===t&&r.inputs?.mediaRole===o)return{outputCell:r,outputEdge:i};if(r?.type===t&&r.inputs?.producerCellId===e)return{outputCell:r,outputEdge:i}}for(const i of n.edges){if(i.source!==e||i.targetInput!=="media")continue;const r=n.cells.find(s=>s.id===i.target);if(r?.type===t)return{outputCell:r,outputEdge:i}}return null}function Ic(n,e){return ri(n,e,"video","generate-video-output")}function Cc(n,e){return ri(n,e,"image","generate-image-output")}function Rc(n,e){return ri(n,e,"audio","generate-audio-output")}function Oc(n){if(typeof n.outputArtifactId=="string")return n.outputArtifactId;if(typeof n.outputEntityId=="string")return n.outputEntityId}function Mc(n,e){const t=e.type==="generate_video"?Ic(n,e.id):e.type==="generate_image"?Cc(n,e.id):e.type==="generate_audio"?Rc(n,e.id):null;if(typeof t?.outputCell.outputArtifactId=="string")return t.outputCell.outputArtifactId}function vc(n,e){return Mc(n,e)??Oc(e)}function kk(n,e){return vc(n,e)}function Y(n){this.content=n}Y.prototype={constructor:Y,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var o=t&&t!=n?this.remove(t):this,i=o.find(n),r=o.content.slice();return i==-1?r.push(t||n,e):(r[i+1]=e,t&&(r[i]=t)),new Y(r)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Y(t)},addToStart:function(n,e){return new Y([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Y(t)},addBefore:function(n,e,t){var o=this.remove(e),i=o.content.slice(),r=o.find(n);return i.splice(r==-1?i.length:r,0,e,t),new Y(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Y.from(n),n.size?new Y(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Y.from(n),n.size?new Y(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Y.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};Y.from=function(n){if(n instanceof Y)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Y(e)};function fs(n,e,t){for(let o=0;;o++){if(o==n.childCount||o==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(o),r=e.child(o);if(i==r){t+=i.nodeSize;continue}if(!i.sameMarkup(r))return t;if(i.isText&&i.text!=r.text){let s=i.text,l=r.text,c=0;for(;s[c]==l[c];c++)t++;return c&&c<s.length&&c<l.length&&ys(s.charCodeAt(c-1))&&xs(s.charCodeAt(c))&&t--,t}if(i.content.size||r.content.size){let s=fs(i.content,r.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function gs(n,e,t,o){for(let i=n.childCount,r=e.childCount;;){if(i==0||r==0)return i==r?null:{a:t,b:o};let s=n.child(--i),l=e.child(--r),c=s.nodeSize;if(s==l){t-=c,o-=c;continue}if(!s.sameMarkup(l))return{a:t,b:o};if(s.isText&&s.text!=l.text){let p=s.text,d=l.text,m=p.length,g=d.length;for(;m>0&&g>0&&p[m-1]==d[g-1];)m--,g--,t--,o--;return m&&g&&m<p.length&&ys(p.charCodeAt(m-1))&&xs(p.charCodeAt(m))&&(t++,o++),{a:t,b:o}}if(s.content.size||l.content.size){let p=gs(s.content,l.content,t-1,o-1);if(p)return p}t-=c,o-=c}}function xs(n){return n>=56320&&n<57344}function ys(n){return n>=55296&&n<56320}class C{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let o=0;o<e.length;o++)this.size+=e[o].nodeSize}nodesBetween(e,t,o,i=0,r){for(let s=0,l=0;l<t;s++){let c=this.content[s],p=l+c.nodeSize;if(p>e&&o(c,i+l,r||null,s)!==!1&&c.content.size){let d=l+1;c.nodesBetween(Math.max(0,e-d),Math.min(c.content.size,t-d),o,i+d)}l=p}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,o,i){let r="",s=!0;return this.nodesBetween(e,t,(l,c)=>{let p=l.isText?l.text.slice(Math.max(e,c)-c,t-c):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&p||l.isTextblock)&&o&&(s?s=!1:r+=o),r+=p},0),r}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,o=e.firstChild,i=this.content.slice(),r=0;for(t.isText&&t.sameMarkup(o)&&(i[i.length-1]=t.withText(t.text+o.text),r=1);r<e.content.length;r++)i.push(e.content[r]);return new C(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let o=[],i=0;if(t>e)for(let r=0,s=0;s<t;r++){let l=this.content[r],c=s+l.nodeSize;c>e&&((s<e||c>t)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),o.push(l),i+=l.nodeSize),s=c}return new C(o,i)}cutByIndex(e,t){return e==t?C.empty:e==0&&t==this.content.length?this:new C(this.content.slice(e,t))}replaceChild(e,t){let o=this.content[e];if(o==t)return this;let i=this.content.slice(),r=this.size+t.nodeSize-o.nodeSize;return i[e]=t,new C(i,r)}addToStart(e){return new C([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new C(this.content.concat(e),this.size+e.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 new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,o=0;t<this.content.length;t++){let i=this.content[t];e(i,o,t),o+=i.nodeSize}}findDiffStart(e,t=0){return fs(this,e,t)}findDiffEnd(e,t=this.size,o=e.size){return gs(this,e,t,o)}findIndex(e){if(e==0)return wn(0,e);if(e==this.size)return wn(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,o=0;;t++){let i=this.child(t),r=o+i.nodeSize;if(r>=e)return r==e?wn(t+1,r):wn(t,o);o=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return C.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return C.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return C.empty;let t,o=0;for(let i=0;i<e.length;i++){let r=e[i];o+=r.nodeSize,i&&r.isText&&e[i-1].sameMarkup(r)?(t||(t=e.slice(0,i)),t[t.length-1]=r.withText(t[t.length-1].text+r.text)):t&&t.push(r)}return new C(t||e,o)}static from(e){if(!e)return C.empty;if(e instanceof C)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new C([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}C.empty=new C([],0);const _o={index:0,offset:0};function wn(n,e){return _o.index=n,_o.offset=e,_o}function Dn(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let o=0;o<n.length;o++)if(!Dn(n[o],e[o]))return!1}else{for(let o in n)if(!(o in e)||!Dn(n[o],e[o]))return!1;for(let o in e)if(!(o in n))return!1}return!0}class q{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,o=!1;for(let i=0;i<e.length;i++){let r=e[i];if(this.eq(r))return e;if(this.type.excludes(r.type))t||(t=e.slice(0,i));else{if(r.type.excludes(this.type))return e;!o&&r.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),o=!0),t&&t.push(r)}}return t||(t=e.slice()),o||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&&Dn(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 new RangeError("Invalid input for Mark.fromJSON");let o=e.marks[t.type];if(!o)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=o.create(t.attrs);return o.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let o=0;o<e.length;o++)if(!e[o].eq(t[o]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return q.none;if(e instanceof q)return[e];let t=e.slice();return t.sort((o,i)=>o.type.rank-i.type.rank),t}}q.none=[];class jt extends Error{}class A{constructor(e,t,o){this.content=e,this.openStart=t,this.openEnd=o}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let o=bs(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return o&&new A(o,this.openStart,this.openEnd)}removeBetween(e,t){return new A(Ss(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return A.empty;let o=t.openStart||0,i=t.openEnd||0;if(typeof o!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new A(C.fromJSON(e,t.content),o,i)}static maxOpen(e,t=!0){let o=0,i=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)o++;for(let r=e.lastChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.lastChild)i++;return new A(e,o,i)}}A.empty=new A(C.empty,0,0);function Ss(n,e,t){let{index:o,offset:i}=n.findIndex(e),r=n.maybeChild(o),{index:s,offset:l}=n.findIndex(t);if(i==e||r.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(o!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(o,r.copy(Ss(r.content,e-i-1,t-i-1)))}function bs(n,e,t,o,i,r){let{index:s,offset:l}=n.findIndex(e),c=n.maybeChild(s);if(l==e||c.isText)return r&&o<=0&&i<=0&&!r.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let p=bs(c.content,e-l-1,t,s==0?o-1:0,s==n.childCount-1?i-1:0,c);return p&&n.replaceChild(s,c.copy(p))}function Ec(n,e,t){if(t.openStart>n.depth)throw new jt("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new jt("Inconsistent open depths");return ks(n,e,t,0)}function ks(n,e,t,o){let i=n.index(o),r=n.node(o);if(i==e.index(o)&&o<n.depth-t.openStart){let s=ks(n,e,t,o+1);return r.copy(r.content.replaceChild(i,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==o&&e.depth==o){let s=n.parent,l=s.content;return ut(s,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=Ac(t,n);return ut(r,ws(n,s,l,e,o))}else return ut(r,Bn(n,e,o))}function _s(n,e){if(!e.type.compatibleContent(n.type))throw new jt("Cannot join "+e.type.name+" onto "+n.type.name)}function qo(n,e,t){let o=n.node(t);return _s(o,e.node(t)),o}function ct(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Ut(n,e,t,o){let i=(e||n).node(t),r=0,s=e?e.index(t):i.childCount;n&&(r=n.index(t),n.depth>t?r++:n.textOffset&&(ct(n.nodeAfter,o),r++));for(let l=r;l<s;l++)ct(i.child(l),o);e&&e.depth==t&&e.textOffset&&ct(e.nodeBefore,o)}function ut(n,e){if(!n.type.validContent(e))throw new jt("Invalid content for node "+n.type.name);return n.copy(e)}function ws(n,e,t,o,i){let r=n.depth>i&&qo(n,e,i+1),s=o.depth>i&&qo(t,o,i+1),l=[];return Ut(null,n,i,l),r&&s&&e.index(i)==t.index(i)?(_s(r,s),ct(ut(r,ws(n,e,t,o,i+1)),l)):(r&&ct(ut(r,Bn(n,e,i+1)),l),Ut(e,t,i,l),s&&ct(ut(s,Bn(t,o,i+1)),l)),Ut(o,null,i,l),new C(l)}function Bn(n,e,t){let o=[];if(Ut(null,n,t,o),n.depth>t){let i=qo(n,e,t+1);ct(ut(i,Bn(n,e,t+1)),o)}return Ut(e,null,t,o),new C(o)}function Ac(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let r=t-1;r>=0;r--)i=e.node(r).copy(C.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Ht{constructor(e,t,o){this.pos=e,this.path=t,this.parentOffset=o,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 new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let o=this.pos-this.path[this.path.length-1],i=e.child(t);return o?e.child(t).cut(o):i}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 o=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let r=0;r<e;r++)i+=o.child(r).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return q.none;if(this.textOffset)return e.child(t).marks;let o=e.maybeChild(t-1),i=e.maybeChild(t);if(!o){let l=o;o=i,i=l}let r=o.marks;for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let o=t.marks,i=e.parent.maybeChild(e.index());for(var r=0;r<o.length;r++)o[r].type.spec.inclusive===!1&&(!i||!o[r].isInSet(i.marks))&&(o=o[r--].removeFromSet(o));return o}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 o=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);o>=0;o--)if(e.pos<=this.end(o)&&(!t||t(this.node(o))))return new Bc(this,e,o);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(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let o=[],i=0,r=t;for(let s=e;;){let{index:l,offset:c}=s.content.findIndex(r),p=r-c;if(o.push(s,l,i+c),!p||(s=s.child(l),s.isText))break;r=p-1,i+=c+1}return new Ht(t,o,r)}static resolveCached(e,t){let o=Hi.get(e);if(o)for(let r=0;r<o.elts.length;r++){let s=o.elts[r];if(s.pos==t)return s}else Hi.set(e,o=new Nc);let i=o.elts[o.i]=Ht.resolve(e,t);return o.i=(o.i+1)%Dc,i}}class Nc{constructor(){this.elts=[],this.i=0}}const Dc=12,Hi=new WeakMap;class Bc{constructor(e,t,o){this.$from=e,this.$to=t,this.depth=o}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)}}const Vc=Object.create(null);class Oe{constructor(e,t,o,i=q.none){this.type=e,this.attrs=t,this.marks=i,this.content=o||C.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,o,i=0){this.content.nodesBetween(e,t,o,i,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,o,i){return this.content.textBetween(e,t,o,i)}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,o){return this.type==e&&Dn(this.attrs,t||e.defaultAttrs||Vc)&&q.sameSet(this.marks,o||q.none)}copy(e=null){return e==this.content?this:new Oe(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Oe(this.type,this.attrs,this.content,e)}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,o=!1){if(e==t)return A.empty;let i=this.resolve(e),r=this.resolve(t),s=o?0:i.sharedDepth(t),l=i.start(s),p=i.node(s).content.cut(i.pos-l,r.pos-l);return new A(p,i.depth-s,r.depth-s)}replace(e,t,o){return Ec(this.resolve(e),this.resolve(t),o)}nodeAt(e){for(let t=this;;){let{index:o,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(o),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:o}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:o}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:o}=this.content.findIndex(e);if(o<e)return{node:this.content.child(t),index:t,offset:o};let i=this.content.child(t-1);return{node:i,index:t-1,offset:o-i.nodeSize}}resolve(e){return Ht.resolveCached(this,e)}resolveNoCache(e){return Ht.resolve(this,e)}rangeHasMark(e,t,o){let i=!1;return t>e&&this.nodesBetween(e,t,r=>(o.isInSet(r.marks)&&(i=!0),!i)),i}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()+")"),Ts(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,o=C.empty,i=0,r=o.childCount){let s=this.contentMatchAt(e).matchFragment(o,i,r),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let c=i;c<r;c++)if(!this.type.allowsMarks(o.child(c).marks))return!1;return!0}canReplaceWith(e,t,o,i){if(i&&!this.type.allowsMarks(i))return!1;let r=this.contentMatchAt(e).matchType(o),s=r&&r.matchFragment(this.content,t);return s?s.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=q.none;for(let t=0;t<this.marks.length;t++){let o=this.marks[t];o.type.checkAttrs(o.attrs),e=o.addToSet(e)}if(!q.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.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(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let o;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");o=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,o)}let i=C.fromJSON(e,t.content),r=e.nodeType(t.type).create(t.attrs,i,o);return r.type.checkAttrs(r.attrs),r}}Oe.prototype.text=void 0;class Vn extends Oe{constructor(e,t,o,i){if(super(e,t,null,i),!o)throw new RangeError("Empty text nodes are not allowed");this.text=o}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ts(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(e){return e==this.marks?this:new Vn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Vn(this.type,this.attrs,e,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 Ts(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class ht{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let o=new Pc(e,t);if(o.next==null)return ht.empty;let i=Is(o);o.next&&o.err("Unexpected trailing text");let r=Lc(Gc(i));return Wc(r,o),r}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,o=e.childCount){let i=this;for(let r=t;i&&r<o;r++)i=i.matchType(e.child(r).type);return i}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 o=0;o<e.next.length;o++)if(this.next[t].type==e.next[o].type)return!0;return!1}fillBefore(e,t=!1,o=0){let i=[this];function r(s,l){let c=s.matchFragment(e,o);if(c&&(!t||c.validEnd))return C.from(l.map(p=>p.createAndFill()));for(let p=0;p<s.next.length;p++){let{type:d,next:m}=s.next[p];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(m)==-1){i.push(m);let g=r(m,l.concat(d));if(g)return g}}return null}return r(this,[])}findWrapping(e){for(let o=0;o<this.wrapCache.length;o+=2)if(this.wrapCache[o]==e)return this.wrapCache[o+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),o=[{match:this,type:null,via:null}];for(;o.length;){let i=o.shift(),r=i.match;if(r.matchType(e)){let s=[];for(let l=i;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<r.next.length;s++){let{type:l,next:c}=r.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||c.validEnd)&&(o.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(o){e.push(o);for(let i=0;i<o.next.length;i++)e.indexOf(o.next[i].next)==-1&&t(o.next[i].next)}return t(this),e.map((o,i)=>{let r=i+(o.validEnd?"*":" ")+" ";for(let s=0;s<o.next.length;s++)r+=(s?", ":"")+o.next[s].type.name+"->"+e.indexOf(o.next[s].next);return r}).join(`
2
+ `)}}ht.empty=new ht(!0);class Pc{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 new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Is(n){let e=[];do e.push(Kc(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Kc(n){let e=[];do e.push(zc(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function zc(n){let e=Uc(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Fc(n,e);else break;return e}function Ji(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Fc(n,e){let t=Ji(n),o=t;return n.eat(",")&&(n.next!="}"?o=Ji(n):o=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:o,expr:e}}function qc(n,e){let t=n.nodeTypes,o=t[e];if(o)return[o];let i=[];for(let r in t){let s=t[r];s.isInGroup(e)&&i.push(s)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function Uc(n){if(n.eat("(")){let e=Is(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=qc(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Gc(n){let e=[[]];return i(r(n,0),t()),e;function t(){return e.push([])-1}function o(s,l,c){let p={term:c,to:l};return e[s].push(p),p}function i(s,l){s.forEach(c=>c.to=l)}function r(s,l){if(s.type=="choice")return s.exprs.reduce((c,p)=>c.concat(r(p,l)),[]);if(s.type=="seq")for(let c=0;;c++){let p=r(s.exprs[c],l);if(c==s.exprs.length-1)return p;i(p,l=t())}else if(s.type=="star"){let c=t();return o(l,c),i(r(s.expr,c),c),[o(c)]}else if(s.type=="plus"){let c=t();return i(r(s.expr,l),c),i(r(s.expr,c),c),[o(c)]}else{if(s.type=="opt")return[o(l)].concat(r(s.expr,l));if(s.type=="range"){let c=l;for(let p=0;p<s.min;p++){let d=t();i(r(s.expr,c),d),c=d}if(s.max==-1)i(r(s.expr,c),c);else for(let p=s.min;p<s.max;p++){let d=t();o(c,d),i(r(s.expr,c),d),c=d}return[o(c)]}else{if(s.type=="name")return[o(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function Cs(n,e){return e-n}function Qi(n,e){let t=[];return o(e),t.sort(Cs);function o(i){let r=n[i];if(r.length==1&&!r[0].term)return o(r[0].to);t.push(i);for(let s=0;s<r.length;s++){let{term:l,to:c}=r[s];!l&&t.indexOf(c)==-1&&o(c)}}}function Lc(n){let e=Object.create(null);return t(Qi(n,0));function t(o){let i=[];o.forEach(s=>{n[s].forEach(({term:l,to:c})=>{if(!l)return;let p;for(let d=0;d<i.length;d++)i[d][0]==l&&(p=i[d][1]);Qi(n,c).forEach(d=>{p||i.push([l,p=[]]),p.indexOf(d)==-1&&p.push(d)})})});let r=e[o.join(",")]=new ht(o.indexOf(n.length-1)>-1);for(let s=0;s<i.length;s++){let l=i[s][1].sort(Cs);r.next.push({type:i[s][0],next:e[l.join(",")]||t(l)})}return r}}function Wc(n,e){for(let t=0,o=[n];t<o.length;t++){let i=o[t],r=!i.validEnd,s=[];for(let l=0;l<i.next.length;l++){let{type:c,next:p}=i.next[l];s.push(c.name),r&&!(c.isText||c.hasRequiredAttrs())&&(r=!1),o.indexOf(p)==-1&&o.push(p)}r&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Rs(n){let e=Object.create(null);for(let t in n){let o=n[t];if(!o.hasDefault)return null;e[t]=o.default}return e}function Os(n,e){let t=Object.create(null);for(let o in n){let i=e&&e[o];if(i===void 0){let r=n[o];if(r.hasDefault)i=r.default;else throw new RangeError("No value supplied for attribute "+o)}t[o]=i}return t}function Ms(n,e,t,o){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${o}`);for(let i in n)n[i].validate&&n[i].validate(e[i])}function vs(n,e){let t=Object.create(null);if(e)for(let o in e)t[o]=new jc(n,o,e[o]);return t}let Xi=class Es{constructor(e,t,o){this.name=e,this.schema=t,this.spec=o,this.markSet=null,this.groups=o.group?o.group.split(" "):[],this.attrs=vs(e,o.attrs),this.defaultAttrs=Rs(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(o.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ht.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:Os(this.attrs,e)}create(e=null,t,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Oe(this,this.computeAttrs(e),C.from(t),q.setFrom(o))}createChecked(e=null,t,o){return t=C.from(t),this.checkContent(t),new Oe(this,this.computeAttrs(e),t,q.setFrom(o))}createAndFill(e=null,t,o){if(e=this.computeAttrs(e),t=C.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let i=this.contentMatch.matchFragment(t),r=i&&i.fillBefore(C.empty,!0);return r?new Oe(this,e,t.append(r),q.setFrom(o)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let o=0;o<e.childCount;o++)if(!this.allowsMarks(e.child(o).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Ms(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 o=0;o<e.length;o++)this.allowsMarkType(e[o].type)?t&&t.push(e[o]):t||(t=e.slice(0,o));return t?t.length?t:q.none:e}static compile(e,t){let o=Object.create(null);e.forEach((r,s)=>o[r]=new Es(r,t,s));let i=t.spec.topNode||"doc";if(!o[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!o.text)throw new RangeError("Every schema needs a 'text' type");for(let r in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o}};function $c(n,e,t){let o=t.split("|");return i=>{let r=i===null?"null":typeof i;if(o.indexOf(r)<0)throw new RangeError(`Expected value of type ${o} for attribute ${e} on type ${n}, got ${r}`)}}class jc{constructor(e,t,o){this.hasDefault=Object.prototype.hasOwnProperty.call(o,"default"),this.default=o.default,this.validate=typeof o.validate=="string"?$c(e,t,o.validate):o.validate}get isRequired(){return!this.hasDefault}}class jn{constructor(e,t,o,i){this.name=e,this.rank=t,this.schema=o,this.spec=i,this.attrs=vs(e,i.attrs),this.excluded=null;let r=Rs(this.attrs);this.instance=r?new q(this,r):null}create(e=null){return!e&&this.instance?this.instance:new q(this,Os(this.attrs,e))}static compile(e,t){let o=Object.create(null),i=0;return e.forEach((r,s)=>o[r]=new jn(r,i++,t,s)),o}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){Ms(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class _k{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=Y.from(e.nodes),t.marks=Y.from(e.marks||{}),this.nodes=Xi.compile(this.spec.nodes,this),this.marks=jn.compile(this.spec.marks,this);let o=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let r=this.nodes[i],s=r.spec.content||"",l=r.spec.marks;if(r.contentMatch=o[s]||(o[s]=ht.parse(s,this.nodes)),r.inlineContent=r.contentMatch.inlineContent,r.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!r.isInline||!r.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=r}r.markSet=l=="_"?null:l?Yi(this,l.split(" ")):l==""||!r.inlineContent?[]:null}for(let i in this.marks){let r=this.marks[i],s=r.spec.excludes;r.excluded=s==null?[r]:s==""?[]:Yi(this,s.split(" "))}this.nodeFromJSON=i=>Oe.fromJSON(this,i),this.markFromJSON=i=>q.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,o,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Xi){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,o,i)}text(e,t){let o=this.nodes.text;return new Vn(o,o.defaultAttrs,e,q.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 new RangeError("Unknown node type: "+e);return t}}function Yi(n,e){let t=[];for(let o=0;o<e.length;o++){let i=e[o],r=n.marks[i],s=r;if(r)t.push(r);else for(let l in n.marks){let c=n.marks[l];(i=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(i)>-1)&&t.push(s=c)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return t}function Hc(n){return n.tag!=null}function Jc(n){return n.style!=null}class Jt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let o=this.matchedStyles=[];t.forEach(i=>{if(Hc(i))this.tags.push(i);else if(Jc(i)){let r=/[^=]*/.exec(i.style)[0];o.indexOf(r)<0&&o.push(r),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let r=e.nodes[i.node];return r.contentMatch.matchType(r)})}parse(e,t={}){let o=new er(this,t,!1);return o.addAll(e,q.none,t.from,t.to),o.finish()}parseSlice(e,t={}){let o=new er(this,t,!0);return o.addAll(e,q.none,t.from,t.to),A.maxOpen(o.finish())}matchTag(e,t,o){for(let i=o?this.tags.indexOf(o)+1:0;i<this.tags.length;i++){let r=this.tags[i];if(Yc(e,r.tag)&&(r.namespace===void 0||e.namespaceURI==r.namespace)&&(!r.context||t.matchesContext(r.context))){if(r.getAttrs){let s=r.getAttrs(e);if(s===!1)continue;r.attrs=s||void 0}return r}}}matchStyle(e,t,o,i){for(let r=i?this.styles.indexOf(i)+1:0;r<this.styles.length;r++){let s=this.styles[r],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!o.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let c=s.getAttrs(t);if(c===!1)continue;s.attrs=c||void 0}return s}}}static schemaRules(e){let t=[];function o(i){let r=i.priority==null?50:i.priority,s=0;for(;s<t.length;s++){let l=t[s];if((l.priority==null?50:l.priority)<r)break}t.splice(s,0,i)}for(let i in e.marks){let r=e.marks[i].spec.parseDOM;r&&r.forEach(s=>{o(s=tr(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let r=e.nodes[i].spec.parseDOM;r&&r.forEach(s=>{o(s=tr(s)),s.node||s.ignore||s.mark||(s.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Jt(e,Jt.schemaRules(e)))}}const As={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},Qc={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ns={ol:!0,ul:!0},Qt=1,Uo=2,Gt=4;function Zi(n,e,t){return e!=null?(e?Qt:0)|(e==="full"?Uo:0):n&&n.whitespace=="pre"?Qt|Uo:t&~Gt}class Tn{constructor(e,t,o,i,r,s){this.type=e,this.attrs=t,this.marks=o,this.solid=i,this.options=s,this.content=[],this.activeMarks=q.none,this.match=r||(s&Gt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(C.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let o=this.type.contentMatch,i;return(i=o.findWrapping(e.type))?(this.match=o,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Qt)){let o=this.content[this.content.length-1],i;if(o&&o.isText&&(i=/[ \t\r\n\u000c]+$/.exec(o.text))){let r=o;o.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-i[0].length))}}let t=C.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(C.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&&!As.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class er{constructor(e,t,o){this.parser=e,this.options=t,this.isOpen=o,this.open=0,this.localPreserveWS=!1;let i=t.topNode,r,s=Zi(null,t.preserveWhitespace,0)|(o?Gt:0);i?r=new Tn(i.type,i.attrs,q.none,!0,t.topMatch||i.type.contentMatch,s):o?r=new Tn(null,null,q.none,!0,null,s):r=new Tn(e.schema.topNodeType,null,q.none,!0,null,s),this.nodes=[r],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 o=e.nodeValue,i=this.top,r=i.options&Uo?"full":this.localPreserveWS||(i.options&Qt)>0,{schema:s}=this.parser;if(r==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(o)){if(r)if(r==="full")o=o.replace(/\r\n?/g,`
3
+ `);else if(s.linebreakReplacement&&/[\r\n]/.test(o)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=o.split(/\r?\n|\r/);for(let c=0;c<l.length;c++)c&&this.insertNode(s.linebreakReplacement.create(),t,!0),l[c]&&this.insertNode(s.text(l[c]),t,!/\S/.test(l[c]));o=""}else o=o.replace(/\r?\n|\r/g," ");else if(o=o.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(o)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],c=e.previousSibling;(!l||c&&c.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(o=o.slice(1))}o&&this.insertNode(s.text(o),t,!/\S/.test(o)),this.findInText(e)}else this.findInside(e)}addElement(e,t,o){let i=this.localPreserveWS,r=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;Ns.hasOwnProperty(s)&&this.parser.normalizeLists&&Xc(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,o));e:if(c?c.ignore:Qc.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(e=c.skip);let p,d=this.needsBlock;if(As.hasOwnProperty(s))r.content.length&&r.content[0].isInline&&this.open&&(this.open--,r=this.top),p=!0,r.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let m=c&&c.skip?t:this.readStyles(e,t);m&&this.addAll(e,m),p&&this.sync(r),this.needsBlock=d}else{let p=this.readStyles(e,t);p&&this.addElementByRule(e,c,p,c.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
4
+ `),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 o=e.style;if(o&&o.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let r=this.parser.matchedStyles[i],s=o.getPropertyValue(r);if(s)for(let l=void 0;;){let c=this.parser.matchStyle(r,s,this,l);if(!c)break;if(c.ignore)return null;if(c.clearMark?t=t.filter(p=>!c.clearMark(p)):t=t.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)l=c;else break}}return t}addElementByRule(e,t,o,i){let r,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),o,e.nodeName=="BR")||this.leafFallback(e,o);else{let c=this.enter(s,t.attrs||null,o,t.preserveWhitespace);c&&(r=!0,o=c)}else{let c=this.parser.schema.marks[t.mark];o=o.concat(c.create(t.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,o,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,o,!1));else{let c=e;typeof t.contentElement=="string"?c=e.querySelector(t.contentElement):typeof t.contentElement=="function"?c=t.contentElement(e):t.contentElement&&(c=t.contentElement),this.findAround(e,c,!0),this.addAll(c,o),this.findAround(e,c,!1)}r&&this.sync(l)&&this.open--}addAll(e,t,o,i){let r=o||0;for(let s=o?e.childNodes[o]:e.firstChild,l=i==null?null:e.childNodes[i];s!=l;s=s.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(s,t);this.findAtPoint(e,r)}findPlace(e,t,o){let i,r;for(let s=this.open,l=0;s>=0;s--){let c=this.nodes[s],p=c.findWrapping(e);if(p&&(!i||i.length>p.length+l)&&(i=p,r=c,!p.length))break;if(c.solid){if(o)break;l+=2}}if(!i)return null;this.sync(r);for(let s=0;s<i.length;s++)t=this.enterInner(i[s],null,t,!1);return t}insertNode(e,t,o){if(e.isInline&&this.needsBlock&&!this.top.type){let r=this.textblockFromContext();r&&(t=this.enterInner(r,null,t))}let i=this.findPlace(e,t,o);if(i){this.closeExtra();let r=this.top;r.match&&(r.match=r.match.matchType(e.type));let s=q.none;for(let l of i.concat(e.marks))(r.type?r.type.allowsMarkType(l.type):nr(l.type,e.type))&&(s=l.addToSet(s));return r.content.push(e.mark(s)),!0}return!1}enter(e,t,o,i){let r=this.findPlace(e.create(t),o,!1);return r&&(r=this.enterInner(e,t,o,!0,i)),r}enterInner(e,t,o,i=!1,r){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=Zi(e,r,s.options);s.options&Gt&&s.content.length==0&&(l|=Gt);let c=q.none;return o=o.filter(p=>(s.type?s.type.allowsMarkType(p.type):nr(p.type,e))?(c=p.addToSet(c),!1):!0),this.nodes.push(new Tn(e,t,c,i,null,l)),this.open++,o}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;this.localPreserveWS&&(this.nodes[t].options|=Qt)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let o=this.nodes[t].content;for(let i=o.length-1;i>=0;i--)e+=o[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let o=0;o<this.find.length;o++)this.find[o].node==e&&this.find[o].offset==t&&(this.find[o].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,o){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(o?2:4)&&(this.find[i].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("/"),o=this.options.context,i=!this.isOpen&&(!o||o.parent.type==this.nodes[0].type),r=-(o?o.depth+1:0)+(i?0:1),s=(l,c)=>{for(;l>=0;l--){let p=t[l];if(p==""){if(l==t.length-1||l==0)continue;for(;c>=r;c--)if(s(l-1,c))return!0;return!1}else{let d=c>0||c==0&&i?this.nodes[c].type:o&&c>=r?o.node(c-r).type:null;if(!d||d.name!=p&&!d.isInGroup(p))return!1;c--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(o&&o.isTextblock&&o.defaultAttrs)return o}for(let t in this.parser.schema.nodes){let o=this.parser.schema.nodes[t];if(o.isTextblock&&o.defaultAttrs)return o}}}function Xc(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let o=e.nodeType==1?e.nodeName.toLowerCase():null;o&&Ns.hasOwnProperty(o)&&t?(t.appendChild(e),e=t):o=="li"?t=e:o&&(t=null)}}function Yc(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function tr(n){let e={};for(let t in n)e[t]=n[t];return e}function nr(n,e){let t=e.schema.nodes;for(let o in t){let i=t[o];if(!i.allowsMarkType(n))continue;let r=[],s=l=>{r.push(l);for(let c=0;c<l.edgeCount;c++){let{type:p,next:d}=l.edge(c);if(p==e||r.indexOf(d)<0&&s(d))return!0}};if(s(i.contentMatch))return!0}}class vt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},o){o||(o=In(t).createDocumentFragment());let i=o,r=[];return e.forEach(s=>{if(r.length||s.marks.length){let l=0,c=0;for(;l<r.length&&c<s.marks.length;){let p=s.marks[c];if(!this.marks[p.type.name]){c++;continue}if(!p.eq(r[l][0])||p.type.spec.spanning===!1)break;l++,c++}for(;l<r.length;)i=r.pop()[1];for(;c<s.marks.length;){let p=s.marks[c++],d=this.serializeMark(p,s.isInline,t);d&&(r.push([p,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(s,t))}),o}serializeNodeInner(e,t){if(e.isText)return In(t).createTextNode(e.text);let{dom:o,contentDOM:i}=vn(In(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return o}serializeNode(e,t={}){let o=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let r=this.serializeMark(e.marks[i],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(o),o=r.dom)}return o}serializeMark(e,t,o={}){let i=this.marks[e.type.name];return i&&vn(In(o),i(e,t),null,e.attrs)}static renderSpec(e,t,o=null,i){return typeof t=="string"?{dom:e.createTextNode(t)}:vn(e,t,o,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new vt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=or(e.nodes);return t.text||(t.text=o=>o.text),t}static marksFromSchema(e){return or(e.marks)}}function or(n){let e={};for(let t in n){let o=n[t].spec.toDOM;o&&(e[t]=o)}return e}function In(n){return n.document||window.document}const ir=new WeakMap;function Zc(n){let e=ir.get(n);return e===void 0&&ir.set(n,e=eu(n)),e}function eu(n){let e=null;function t(o){if(o&&typeof o=="object")if(Array.isArray(o))if(typeof o[0]=="string")e||(e=[]),e.push(o);else for(let i=0;i<o.length;i++)t(o[i]);else for(let i in o)t(o[i])}return t(n),e}function vn(n,e,t,o){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let i=e[0],r;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(o&&(r=Zc(o))&&r.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(t=i.slice(0,s),i=i.slice(s+1));let l,c=t?n.createElementNS(t,i):n.createElement(i),p=e[1],d=1;if(p&&typeof p=="object"&&p.nodeType==null&&!Array.isArray(p)){d=2;for(let m in p)if(p[m]!=null){let g=m.indexOf(" ");g>0?c.setAttributeNS(m.slice(0,g),m.slice(g+1),p[m]):m=="style"&&c.style?c.style.cssText=p[m]:c.setAttribute(m,p[m])}}for(let m=d;m<e.length;m++){let g=e[m];if(g===0){if(m<e.length-1||m>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else if(typeof g=="string")c.appendChild(n.createTextNode(g));else{let{dom:S,contentDOM:b}=vn(n,g,t,o);if(c.appendChild(S),b){if(l)throw new RangeError("Multiple content holes");l=b}}}return{dom:c,contentDOM:l}}const Ds=65535,Bs=Math.pow(2,16);function tu(n,e){return n+e*Bs}function rr(n){return n&Ds}function nu(n){return(n-(n&Ds))/Bs}const Vs=1,Ps=2,En=4,Ks=8;class Go{constructor(e,t,o){this.pos=e,this.delInfo=t,this.recover=o}get deleted(){return(this.delInfo&Ks)>0}get deletedBefore(){return(this.delInfo&(Vs|En))>0}get deletedAfter(){return(this.delInfo&(Ps|En))>0}get deletedAcross(){return(this.delInfo&En)>0}}class de{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&de.empty)return de.empty}recover(e){let t=0,o=rr(e);if(!this.inverted)for(let i=0;i<o;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[o*3]+t+nu(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,o){let i=0,r=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?i:0);if(c>e)break;let p=this.ranges[l+r],d=this.ranges[l+s],m=c+p;if(e<=m){let g=p?e==c?-1:e==m?1:t:t,S=c+i+(g<0?0:d);if(o)return S;let b=e==(t<0?c:m)?null:tu(l/3,e-c),_=e==c?Ps:e==m?Vs:En;return(t<0?e!=c:e!=m)&&(_|=Ks),new Go(S,_,b)}i+=d-p}return o?e+i:new Go(e+i,0,null)}touches(e,t){let o=0,i=rr(t),r=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?o:0);if(c>e)break;let p=this.ranges[l+r],d=c+p;if(e<=d&&l==i*3)return!0;o+=this.ranges[l+s]-p}return!1}forEach(e){let t=this.inverted?2:1,o=this.inverted?1:2;for(let i=0,r=0;i<this.ranges.length;i+=3){let s=this.ranges[i],l=s-(this.inverted?r:0),c=s+(this.inverted?0:r),p=this.ranges[i+t],d=this.ranges[i+o];e(l,l+p,c,c+d),r+=d-p}}invert(){return new de(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?de.empty:new de(e<0?[0,-e,0]:[0,0,e])}}de.empty=new de([]);class Xt{constructor(e,t,o=0,i=e?e.length:0){this.mirror=t,this.from=o,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Xt(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,o=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?o+i: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=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,o=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?o-i-1:void 0)}}invert(){let e=new Xt;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let o=this.from;o<this.to;o++)e=this._maps[o].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,o){let i=0;for(let r=this.from;r<this.to;r++){let s=this._maps[r],l=s.mapResult(e,t);if(l.recover!=null){let c=this.getMirror(r);if(c!=null&&c>r&&c<this.to){r=c,e=this._maps[c].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return o?e:new Go(e,i,null)}}const wo=Object.create(null);class re{getMap(){return de.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let o=wo[t.stepType];if(!o)throw new RangeError(`No step type ${t.stepType} defined`);return o.fromJSON(e,t)}static jsonID(e,t){if(e in wo)throw new RangeError("Duplicate use of step JSON ID "+e);return wo[e]=t,t.prototype.jsonID=e,t}}class W{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new W(e,null)}static fail(e){return new W(null,e)}static fromReplace(e,t,o,i){try{return W.ok(e.replace(t,o,i))}catch(r){if(r instanceof jt)return W.fail(r.message);throw r}}}function si(n,e,t){let o=[];for(let i=0;i<n.childCount;i++){let r=n.child(i);r.content.size&&(r=r.copy(si(r.content,e,r))),r.isInline&&(r=e(r,t,i)),o.push(r)}return C.fromArray(o)}class $e extends re{constructor(e,t,o){super(),this.from=e,this.to=t,this.mark=o}apply(e){let t=e.slice(this.from,this.to),o=e.resolve(this.from),i=o.node(o.sharedDepth(this.to)),r=new A(si(t.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return W.fromReplace(e,this.from,this.to,r)}invert(){return new Re(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return t.deleted&&o.deleted||t.pos>=o.pos?null:new $e(t.pos,o.pos,this.mark)}merge(e){return e instanceof $e&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new $e(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new $e(t.from,t.to,e.markFromJSON(t.mark))}}re.jsonID("addMark",$e);class Re extends re{constructor(e,t,o){super(),this.from=e,this.to=t,this.mark=o}apply(e){let t=e.slice(this.from,this.to),o=new A(si(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return W.fromReplace(e,this.from,this.to,o)}invert(){return new $e(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return t.deleted&&o.deleted||t.pos>=o.pos?null:new Re(t.pos,o.pos,this.mark)}merge(e){return e instanceof Re&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Re(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Re(t.from,t.to,e.markFromJSON(t.mark))}}re.jsonID("removeMark",Re);class je extends re{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return W.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return W.fromReplace(e,this.pos,this.pos+1,new A(C.from(o),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let o=this.mark.addToSet(t.marks);if(o.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(o))return new je(this.pos,t.marks[i]);return new je(this.pos,this.mark)}}return new ft(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new je(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new je(t.pos,e.markFromJSON(t.mark))}}re.jsonID("addNodeMark",je);class ft extends re{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return W.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return W.fromReplace(e,this.pos,this.pos+1,new A(C.from(o),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new je(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ft(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new ft(t.pos,e.markFromJSON(t.mark))}}re.jsonID("removeNodeMark",ft);class H extends re{constructor(e,t,o,i=!1){super(),this.from=e,this.to=t,this.slice=o,this.structure=i}apply(e){return this.structure&&Lo(e,this.from,this.to)?W.fail("Structure replace would overwrite content"):W.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new de([this.from,this.to-this.from,this.slice.size])}invert(e){return new H(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),o=this.from==this.to&&H.MAP_BIAS<0?t:e.mapResult(this.from,1);return o.deletedAcross&&t.deletedAcross?null:new H(o.pos,Math.max(o.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof H)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?A.empty:new A(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new H(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?A.empty:new A(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new H(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new H(t.from,t.to,A.fromJSON(e,t.slice),!!t.structure)}}H.MAP_BIAS=1;re.jsonID("replace",H);class me extends re{constructor(e,t,o,i,r,s,l=!1){super(),this.from=e,this.to=t,this.gapFrom=o,this.gapTo=i,this.slice=r,this.insert=s,this.structure=l}apply(e){if(this.structure&&(Lo(e,this.from,this.gapFrom)||Lo(e,this.gapTo,this.to)))return W.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return W.fail("Gap is not a flat range");let o=this.slice.insertAt(this.insert,t.content);return o?W.fromReplace(e,this.from,this.to,o):W.fail("Content does not fit in gap")}getMap(){return new de([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new me(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),r=this.to==this.gapTo?o.pos:e.map(this.gapTo,1);return t.deletedAcross&&o.deletedAcross||i<t.pos||r>o.pos?null:new me(t.pos,o.pos,i,r,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new me(t.from,t.to,t.gapFrom,t.gapTo,A.fromJSON(e,t.slice),t.insert,!!t.structure)}}re.jsonID("replaceAround",me);function Lo(n,e,t){let o=n.resolve(e),i=t-e,r=o.depth;for(;i>0&&r>0&&o.indexAfter(r)==o.node(r).childCount;)r--,i--;if(i>0){let s=o.node(r).maybeChild(o.indexAfter(r));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function ou(n,e,t,o){let i=[],r=[],s,l;n.doc.nodesBetween(e,t,(c,p,d)=>{if(!c.isInline)return;let m=c.marks;if(!o.isInSet(m)&&d.type.allowsMarkType(o.type)){let g=Math.max(p,e),S=Math.min(p+c.nodeSize,t),b=o.addToSet(m);for(let _=0;_<m.length;_++)m[_].isInSet(b)||(s&&s.to==g&&s.mark.eq(m[_])?s.to=S:i.push(s=new Re(g,S,m[_])));l&&l.to==g?l.to=S:r.push(l=new $e(g,S,o))}}),i.forEach(c=>n.step(c)),r.forEach(c=>n.step(c))}function iu(n,e,t,o){let i=[],r=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;r++;let c=null;if(o instanceof jn){let p=s.marks,d;for(;d=o.isInSet(p);)(c||(c=[])).push(d),p=d.removeFromSet(p)}else o?o.isInSet(s.marks)&&(c=[o]):c=s.marks;if(c&&c.length){let p=Math.min(l+s.nodeSize,t);for(let d=0;d<c.length;d++){let m=c[d],g;for(let S=0;S<i.length;S++){let b=i[S];b.step==r-1&&m.eq(i[S].style)&&(g=b)}g?(g.to=p,g.step=r):i.push({style:m,from:Math.max(l,e),to:p,step:r})}}}),i.forEach(s=>n.step(new Re(s.from,s.to,s.style)))}function ai(n,e,t,o=t.contentMatch,i=!0){let r=n.doc.nodeAt(e),s=[],l=e+1;for(let c=0;c<r.childCount;c++){let p=r.child(c),d=l+p.nodeSize,m=o.matchType(p.type);if(!m)s.push(new H(l,d,A.empty));else{o=m;for(let g=0;g<p.marks.length;g++)t.allowsMarkType(p.marks[g].type)||n.step(new Re(l,d,p.marks[g]));if(i&&p.isText&&t.whitespace!="pre"){let g,S=/\r?\n|\r/g,b;for(;g=S.exec(p.text);)b||(b=new A(C.from(t.schema.text(" ",t.allowedMarks(p.marks))),0,0)),s.push(new H(l+g.index,l+g.index+g[0].length,b))}}l=d}if(!o.validEnd){let c=o.fillBefore(C.empty,!0);n.replace(l,l,new A(c,0,0))}for(let c=s.length-1;c>=0;c--)n.step(s[c])}function ru(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function li(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let o=n.depth,i=0,r=0;;--o){let s=n.$from.node(o),l=n.$from.index(o)+i,c=n.$to.indexAfter(o)-r;if(o<n.depth&&s.canReplace(l,c,t))return o;if(o==0||s.type.spec.isolating||!ru(s,l,c))break;l&&(i=1),c<s.childCount&&(r=1)}return null}function su(n,e,t){let{$from:o,$to:i,depth:r}=e,s=o.before(r+1),l=i.after(r+1),c=s,p=l,d=C.empty,m=0;for(let b=r,_=!1;b>t;b--)_||o.index(b)>0?(_=!0,d=C.from(o.node(b).copy(d)),m++):c--;let g=C.empty,S=0;for(let b=r,_=!1;b>t;b--)_||i.after(b+1)<i.end(b)?(_=!0,g=C.from(i.node(b).copy(g)),S++):p++;n.step(new me(c,p,s,l,new A(d.append(g),m,S),d.size-m,!0))}function au(n,e,t){let o=C.empty;for(let s=t.length-1;s>=0;s--){if(o.size){let l=t[s].type.contentMatch.matchFragment(o);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=C.from(t[s].type.create(t[s].attrs,o))}let i=e.start,r=e.end;n.step(new me(i,r,i,r,new A(o,0,0),t.length,!0))}function lu(n,e,t,o,i){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let r=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{let c=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(o,c)&&cu(n.doc,n.mapping.slice(r).map(l),o)){let p=null;if(o.schema.linebreakReplacement){let S=o.whitespace=="pre",b=!!o.contentMatch.matchType(o.schema.linebreakReplacement);S&&!b?p=!1:!S&&b&&(p=!0)}p===!1&&Fs(n,s,l,r),ai(n,n.mapping.slice(r).map(l,1),o,void 0,p===null);let d=n.mapping.slice(r),m=d.map(l,1),g=d.map(l+s.nodeSize,1);return n.step(new me(m,g,m+1,g-1,new A(C.from(o.create(c,null,s.marks)),0,0),1,!0)),p===!0&&zs(n,s,l,r),!1}})}function zs(n,e,t,o){e.forEach((i,r)=>{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(i.text);){let c=n.mapping.slice(o).map(t+1+r+s.index);n.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function Fs(n,e,t,o){e.forEach((i,r)=>{if(i.type==i.type.schema.linebreakReplacement){let s=n.mapping.slice(o).map(t+1+r);n.replaceWith(s,s+1,e.type.schema.text(`
5
+ `))}})}function cu(n,e,t){let o=n.resolve(e),i=o.index();return o.parent.canReplaceWith(i,i+1,t)}function uu(n,e,t,o,i){let r=n.doc.nodeAt(e);if(!r)throw new RangeError("No node at given position");t||(t=r.type);let s=t.create(o,null,i||r.marks);if(r.isLeaf)return n.replaceWith(e,e+r.nodeSize,s);if(!t.validContent(r.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new me(e,e+r.nodeSize,e+1,e+r.nodeSize-1,new A(C.from(s),0,0),1,!0))}function An(n,e,t=1,o){let i=n.resolve(e),r=i.depth-t,s=o&&o[o.length-1]||i.parent;if(r<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let p=i.depth-1,d=t-2;p>r;p--,d--){let m=i.node(p),g=i.index(p);if(m.type.spec.isolating)return!1;let S=m.content.cutByIndex(g,m.childCount),b=o&&o[d+1];b&&(S=S.replaceChild(0,b.type.create(b.attrs)));let _=o&&o[d]||m;if(!m.canReplace(g+1,m.childCount)||!_.type.validContent(S))return!1}let l=i.indexAfter(r),c=o&&o[0];return i.node(r).canReplaceWith(l,l,c?c.type:i.node(r+1).type)}function pu(n,e,t=1,o){let i=n.doc.resolve(e),r=C.empty,s=C.empty;for(let l=i.depth,c=i.depth-t,p=t-1;l>c;l--,p--){r=C.from(i.node(l).copy(r));let d=o&&o[p];s=C.from(d?d.type.create(d.attrs,s):i.node(l).copy(s))}n.step(new H(e,e,new A(r.append(s),t,t),!0))}function qs(n,e){let t=n.resolve(e),o=t.index();return mu(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(o,o+1)}function du(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:o}=n.type.schema;for(let i=0;i<e.childCount;i++){let r=e.child(i),s=r.type==o?n.type.schema.nodes.text:r.type;if(t=t.matchType(s),!t||!n.type.allowsMarks(r.marks))return!1}return t.validEnd}function mu(n,e){return!!(n&&e&&!n.isLeaf&&du(n,e))}function hu(n,e,t){let o=null,{linebreakReplacement:i}=n.doc.type.schema,r=n.doc.resolve(e-t),s=r.node().type;if(i&&s.inlineContent){let d=s.whitespace=="pre",m=!!s.contentMatch.matchType(i);d&&!m?o=!1:!d&&m&&(o=!0)}let l=n.steps.length;if(o===!1){let d=n.doc.resolve(e+t);Fs(n,d.node(),d.before(),l)}s.inlineContent&&ai(n,e+t-1,s,r.node().contentMatchAt(r.index()),o==null);let c=n.mapping.slice(l),p=c.map(e-t);if(n.step(new H(p,c.map(e+t,-1),A.empty,!0)),o===!0){let d=n.doc.resolve(p);zs(n,d.node(),d.before(),n.steps.length)}return n}function fu(n,e,t){let o=n.resolve(e);if(o.parent.canReplaceWith(o.index(),o.index(),t))return e;if(o.parentOffset==0)for(let i=o.depth-1;i>=0;i--){let r=o.index(i);if(o.node(i).canReplaceWith(r,r,t))return o.before(i+1);if(r>0)return null}if(o.parentOffset==o.parent.content.size)for(let i=o.depth-1;i>=0;i--){let r=o.indexAfter(i);if(o.node(i).canReplaceWith(r,r,t))return o.after(i+1);if(r<o.node(i).childCount)return null}return null}function gu(n,e,t){let o=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let r=0;r<t.openStart;r++)i=i.firstChild.content;for(let r=1;r<=(t.openStart==0&&t.size?2:1);r++)for(let s=o.depth;s>=0;s--){let l=s==o.depth?0:o.pos<=(o.start(s+1)+o.end(s+1))/2?-1:1,c=o.index(s)+(l>0?1:0),p=o.node(s),d=!1;if(r==1)d=p.canReplace(c,c,i);else{let m=p.contentMatchAt(c).findWrapping(i.firstChild.type);d=m&&p.canReplaceWith(c,c,m[0])}if(d)return l==0?o.pos:l<0?o.before(s+1):o.after(s+1)}return null}function ci(n,e,t=e,o=A.empty){if(e==t&&!o.size)return null;let i=n.resolve(e),r=n.resolve(t);return Us(i,r,o)?new H(e,t,o):new xu(i,r,o).fit()}function Us(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class xu{constructor(e,t,o){this.$from=e,this.$to=t,this.unplaced=o,this.frontier=[],this.placed=C.empty;for(let i=0;i<=e.depth;i++){let r=e.node(i);this.frontier.push({type:r.type,match:r.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=C.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let p=this.findFittable();p?this.placeNodes(p):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,o=this.$from,i=this.close(e<0?this.$to:o.doc.resolve(e));if(!i)return null;let r=this.placed,s=o.depth,l=i.depth;for(;s&&l&&r.childCount==1;)r=r.firstChild.content,s--,l--;let c=new A(r,s,l);return e>-1?new me(o.pos,e,this.$to.pos,this.$to.end(),c,t):c.size||o.pos!=this.$to.pos?new H(o.pos,i.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,o=0,i=this.unplaced.openEnd;o<e;o++){let r=t.firstChild;if(t.childCount>1&&(i=0),r.type.spec.isolating&&i<=o){e=o;break}t=r.content}for(let t=1;t<=2;t++)for(let o=t==1?e:this.unplaced.openStart;o>=0;o--){let i,r=null;o?(r=sr(this.unplaced.content,o-1).firstChild,i=r.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:p}=this.frontier[l],d,m=null;if(t==1&&(s?p.matchType(s.type)||(m=p.fillBefore(C.from(s),!1)):r&&c.compatibleContent(r.type)))return{sliceDepth:o,frontierDepth:l,parent:r,inject:m};if(t==2&&s&&(d=p.findWrapping(s.type)))return{sliceDepth:o,frontierDepth:l,parent:r,wrap:d};if(r&&p.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:o}=this.unplaced;return ar(e,-1)<=t?!1:(this.unplaced.size>1&&ar(e,1)>o&&o++,this.unplaced=new A(e,t+1,o),!0)}dropNode(){let{content:e,openStart:t,openEnd:o}=this.unplaced,i=sr(e,t);if(i.childCount<=1&&t>0){let r=e.size-t<=t+i.size;this.unplaced=new A(Kt(e,t-1,1),t-1,r?t-1:o)}else this.unplaced=new A(Kt(e,t,1),t,o)}placeNodes({sliceDepth:e,frontierDepth:t,parent:o,inject:i,wrap:r}){for(;this.depth>t;)this.closeFrontierNode();if(r)for(let _=0;_<r.length;_++)this.openFrontierNode(r[_]);let s=this.unplaced,l=o?o.content:s.content,c=s.openStart-e,p=0,d=[],{match:m,type:g}=this.frontier[t];if(i){for(let _=0;_<i.childCount;_++)d.push(i.child(_));m=m.matchFragment(i)}let S=l.size+e-(s.content.size-s.openEnd);for(;p<l.childCount;){let _=l.child(p),w=m.matchType(_.type);if(!w)break;p++,(p>1||c==0||_.content.size)&&(m=w,d.push(Gs(_.mark(g.allowedMarks(_.marks)),p==1?c:0,p==l.childCount?S:-1)))}let b=p==l.childCount;b||(S=-1),this.placed=zt(this.placed,t,C.from(d)),this.frontier[t].match=m,b&&S<0&&o&&o.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let _=0,w=l;_<S;_++){let v=w.lastChild;this.frontier.push({type:v.type,match:v.contentMatchAt(v.childCount)}),w=v.content}this.unplaced=b?e==0?A.empty:new A(Kt(s.content,e-1,1),e-1,S<0?s.openEnd:e-1):new A(Kt(s.content,e,p),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!To(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:o}=this.$to,i=this.$to.after(o);for(;o>1&&i==this.$to.end(--o);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:o,type:i}=this.frontier[t],r=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=To(e,t,i,o,r);if(s){for(let l=t-1;l>=0;l--){let{match:c,type:p}=this.frontier[l],d=To(e,l,p,c,!0);if(!d||d.childCount)continue e}return{depth:t,fit:s,move:r?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=zt(this.placed,t.depth,t.fit)),e=t.move;for(let o=t.depth+1;o<=e.depth;o++){let i=e.node(o),r=i.type.contentMatch.fillBefore(i.content,!0,e.index(o));this.openFrontierNode(i.type,i.attrs,r)}return e}openFrontierNode(e,t=null,o){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=zt(this.placed,this.depth,C.from(e.create(t,o))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(C.empty,!0);t.childCount&&(this.placed=zt(this.placed,this.frontier.length,t))}}function Kt(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Kt(n.firstChild.content,e-1,t)))}function zt(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(zt(n.lastChild.content,e-1,t)))}function sr(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Gs(n,e,t){if(e<=0)return n;let o=n.content;return e>1&&(o=o.replaceChild(0,Gs(o.firstChild,e-1,o.childCount==1?t-1:0))),e>0&&(o=n.type.contentMatch.fillBefore(o).append(o),t<=0&&(o=o.append(n.type.contentMatch.matchFragment(o).fillBefore(C.empty,!0)))),n.copy(o)}function To(n,e,t,o,i){let r=n.node(e),s=i?n.indexAfter(e):n.index(e);if(s==r.childCount&&!t.compatibleContent(r.type))return null;let l=o.fillBefore(r.content,!0,s);return l&&!yu(t,r.content,s)?l:null}function yu(n,e,t){for(let o=t;o<e.childCount;o++)if(!n.allowsMarks(e.child(o).marks))return!0;return!1}function Su(n){return n.spec.defining||n.spec.definingForContent}function ar(n,e){for(let t=0;;t++){let o=e<0?n.firstChild:n.lastChild;if(!o||o.isAtom)return t;n=o.content}}function bu(n,e,t,o){if(!o.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),r=n.doc.resolve(t);if(Us(i,r,o))return n.step(new H(e,t,o));let s=Ws(i,r);s[s.length-1]==0&&s.pop();let l=-(i.depth+1);s.unshift(l);for(let g=i.depth,S=i.pos-1;g>0;g--,S--){let b=i.node(g).type.spec;if(b.defining||b.definingAsContext||b.isolating)break;s.indexOf(g)>-1?l=g:i.before(g)==S&&s.splice(1,0,-g)}let c=s.indexOf(l),p=[],d=o.openStart;for(let g=o.content,S=0;;S++){let b=g.firstChild;if(p.push(b),S==o.openStart)break;g=b.content}for(let g=d-1;g>=0;g--){let S=p[g],b=Su(S.type);if(b&&!S.sameMarkup(i.node(Math.abs(l)-1)))d=g;else if(b||!S.type.isTextblock)break}for(let g=o.openStart;g>=0;g--){let S=(g+d+1)%(o.openStart+1),b=p[S];if(b)for(let _=0;_<s.length;_++){let w=s[(_+c)%s.length],v=!0;w<0&&(v=!1,w=-w);let L=i.node(w-1),F=i.index(w-1);if(L.canReplaceWith(F,F,b.type,b.marks))return n.replace(i.before(w),v?r.after(w):t,new A(Ls(o.content,0,o.openStart,S),S,o.openEnd))}}let m=n.steps.length;for(let g=s.length-1;g>=0&&(n.replace(e,t,o),!(n.steps.length>m));g--){let S=s[g];S<0||(e=i.before(S),t=r.after(S))}}function Ls(n,e,t,o,i){if(e<t){let r=n.firstChild;n=n.replaceChild(0,r.copy(Ls(r.content,e+1,t,o,r)))}if(e>o){let r=i.contentMatchAt(0),s=r.fillBefore(n).append(n);n=s.append(r.matchFragment(s).fillBefore(C.empty,!0))}return n}function ku(n,e,t,o){if(!o.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=fu(n.doc,e,o.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new A(C.from(o),0,0))}function _u(n,e,t){let o=n.doc.resolve(e),i=n.doc.resolve(t);if(o.parent.isTextblock&&i.parent.isTextblock&&o.start()!=i.start()&&o.parentOffset==0&&i.parentOffset==0){let s=o.sharedDepth(t),l=!1;for(let c=o.depth;c>s;c--)o.node(c).type.spec.isolating&&(l=!0);for(let c=i.depth;c>s;c--)i.node(c).type.spec.isolating&&(l=!0);if(!l){for(let c=o.depth;c>0&&e==o.start(c);c--)e=o.before(c);for(let c=i.depth;c>0&&t==i.start(c);c--)t=i.before(c);o=n.doc.resolve(e),i=n.doc.resolve(t)}}let r=Ws(o,i);for(let s=0;s<r.length;s++){let l=r[s],c=s==r.length-1;if(c&&l==0||o.node(l).type.contentMatch.validEnd)return n.delete(o.start(l),i.end(l));if(l>0&&(c||o.node(l-1).canReplace(o.index(l-1),i.indexAfter(l-1))))return n.delete(o.before(l),i.after(l))}for(let s=1;s<=o.depth&&s<=i.depth;s++)if(e-o.start(s)==o.depth-s&&t>o.end(s)&&i.end(s)-t!=i.depth-s&&o.start(s-1)==i.start(s-1)&&o.node(s-1).canReplace(o.index(s-1),i.index(s-1)))return n.delete(o.before(s),t);n.delete(e,t)}function Ws(n,e){let t=[],o=Math.min(n.depth,e.depth);for(let i=o;i>=0;i--){let r=n.start(i);if(r<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(r==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==r-1)&&t.push(i)}return t}class It extends re{constructor(e,t,o){super(),this.pos=e,this.attr=t,this.value=o}apply(e){let t=e.nodeAt(this.pos);if(!t)return W.fail("No node at attribute step's position");let o=Object.create(null);for(let r in t.attrs)o[r]=t.attrs[r];o[this.attr]=this.value;let i=t.type.create(o,null,t.marks);return W.fromReplace(e,this.pos,this.pos+1,new A(C.from(i),0,t.isLeaf?0:1))}getMap(){return de.empty}invert(e){return new It(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new It(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new It(t.pos,t.attr,t.value)}}re.jsonID("attr",It);class Yt extends re{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let o=e.type.create(t,e.content,e.marks);return W.ok(o)}getMap(){return de.empty}invert(e){return new Yt(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Yt(t.attr,t.value)}}re.jsonID("docAttr",Yt);let Ct=class extends Error{};Ct=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Ct.prototype=Object.create(Error.prototype);Ct.prototype.constructor=Ct;Ct.prototype.name="TransformError";class wu{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Xt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Ct(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let o=0;o<this.mapping.maps.length;o++){let i=this.mapping.maps[o];o&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((r,s,l,c)=>{e=Math.min(e,l),t=Math.max(t,c)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,o=A.empty){let i=ci(this.doc,e,t,o);return i&&this.step(i),this}replaceWith(e,t,o){return this.replace(e,t,new A(C.from(o),0,0))}delete(e,t){return this.replace(e,t,A.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,o){return bu(this,e,t,o),this}replaceRangeWith(e,t,o){return ku(this,e,t,o),this}deleteRange(e,t){return _u(this,e,t),this}lift(e,t){return su(this,e,t),this}join(e,t=1){return hu(this,e,t),this}wrap(e,t){return au(this,e,t),this}setBlockType(e,t=e,o,i=null){return lu(this,e,t,o,i),this}setNodeMarkup(e,t,o=null,i){return uu(this,e,t,o,i),this}setNodeAttribute(e,t,o){return this.step(new It(e,t,o)),this}setDocAttribute(e,t){return this.step(new Yt(e,t)),this}addNodeMark(e,t){return this.step(new je(e,t)),this}removeNodeMark(e,t){let o=this.doc.nodeAt(e);if(!o)throw new RangeError("No node at position "+e);if(t instanceof q)t.isInSet(o.marks)&&this.step(new ft(e,t));else{let i=o.marks,r,s=[];for(;r=t.isInSet(i);)s.push(new ft(e,r)),i=r.removeFromSet(i);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,t=1,o){return pu(this,e,t,o),this}addMark(e,t,o){return ou(this,e,t,o),this}removeMark(e,t,o){return iu(this,e,t,o),this}clearIncompatible(e,t,o){return ai(this,e,t,o),this}}const Io=Object.create(null);class G{constructor(e,t,o){this.$anchor=e,this.$head=t,this.ranges=o||[new Tu(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=A.empty){let o=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=o,o=o.lastChild;let r=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:c,$to:p}=s[l],d=e.mapping.slice(r);e.replaceRange(d.map(c.pos),d.map(p.pos),l?A.empty:t),l==0&&ur(e,r,(o?o.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let o=e.steps.length,i=this.ranges;for(let r=0;r<i.length;r++){let{$from:s,$to:l}=i[r],c=e.mapping.slice(o),p=c.map(s.pos),d=c.map(l.pos);r?e.deleteRange(p,d):(e.replaceRangeWith(p,d,t),ur(e,o,t.isInline?-1:1))}}static findFrom(e,t,o=!1){let i=e.parent.inlineContent?new U(e):wt(e.node(0),e.parent,e.pos,e.index(),t,o);if(i)return i;for(let r=e.depth-1;r>=0;r--){let s=t<0?wt(e.node(0),e.node(r),e.before(r+1),e.index(r),t,o):wt(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,o);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new he(e.node(0))}static atStart(e){return wt(e,e,0,0,1)||new he(e)}static atEnd(e){return wt(e,e,e.content.size,e.childCount,-1)||new he(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let o=Io[t.type];if(!o)throw new RangeError(`No selection type ${t.type} defined`);return o.fromJSON(e,t)}static jsonID(e,t){if(e in Io)throw new RangeError("Duplicate use of selection JSON ID "+e);return Io[e]=t,t.prototype.jsonID=e,t}getBookmark(){return U.between(this.$anchor,this.$head).getBookmark()}}G.prototype.visible=!0;class Tu{constructor(e,t){this.$from=e,this.$to=t}}let lr=!1;function cr(n){!lr&&!n.parent.inlineContent&&(lr=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class U extends G{constructor(e,t=e){cr(e),cr(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let o=e.resolve(t.map(this.head));if(!o.parent.inlineContent)return G.near(o);let i=e.resolve(t.map(this.anchor));return new U(i.parent.inlineContent?i:o,o)}replace(e,t=A.empty){if(super.replace(e,t),t==A.empty){let o=this.$from.marksAcross(this.$to);o&&e.ensureMarks(o)}}eq(e){return e instanceof U&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Hn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new U(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,o=t){let i=e.resolve(t);return new this(i,o==t?i:e.resolve(o))}static between(e,t,o){let i=e.pos-t.pos;if((!o||i)&&(o=i>=0?1:-1),!t.parent.inlineContent){let r=G.findFrom(t,o,!0)||G.findFrom(t,-o,!0);if(r)t=r.$head;else return G.near(t,o)}return e.parent.inlineContent||(i==0?e=t:(e=(G.findFrom(e,-o,!0)||G.findFrom(e,o,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new U(e,t)}}G.jsonID("text",U);class Hn{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Hn(e.map(this.anchor),e.map(this.head))}resolve(e){return U.between(e.resolve(this.anchor),e.resolve(this.head))}}class B extends G{constructor(e){let t=e.nodeAfter,o=e.node(0).resolve(e.pos+t.nodeSize);super(e,o),this.node=t}map(e,t){let{deleted:o,pos:i}=t.mapResult(this.anchor),r=e.resolve(i);return o?G.near(r):new B(r)}content(){return new A(C.from(this.node),0,0)}eq(e){return e instanceof B&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ui(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new B(e.resolve(t.anchor))}static create(e,t){return new B(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}B.prototype.visible=!1;G.jsonID("node",B);class ui{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:o}=e.mapResult(this.anchor);return t?new Hn(o,o):new ui(o)}resolve(e){let t=e.resolve(this.anchor),o=t.nodeAfter;return o&&B.isSelectable(o)?new B(t):G.near(t)}}class he extends G{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=A.empty){if(t==A.empty){e.delete(0,e.doc.content.size);let o=G.atStart(e.doc);o.eq(e.selection)||e.setSelection(o)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new he(e)}map(e){return new he(e)}eq(e){return e instanceof he}getBookmark(){return Iu}}G.jsonID("all",he);const Iu={map(){return this},resolve(n){return new he(n)}};function wt(n,e,t,o,i,r=!1){if(e.inlineContent)return U.create(n,t);for(let s=o-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let l=e.child(s);if(l.isAtom){if(!r&&B.isSelectable(l))return B.create(n,t-(i<0?l.nodeSize:0))}else{let c=wt(n,l,t+i,i<0?l.childCount:0,i,r);if(c)return c}t+=l.nodeSize*i}return null}function ur(n,e,t){let o=n.steps.length-1;if(o<e)return;let i=n.steps[o];if(!(i instanceof H||i instanceof me))return;let r=n.mapping.maps[o],s;r.forEach((l,c,p,d)=>{s==null&&(s=d)}),n.setSelection(G.near(n.doc.resolve(s),t))}const pr=1,Cn=2,dr=4;class Cu extends wu{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|pr)&~Cn,this.storedMarks=null,this}get selectionSet(){return(this.updated&pr)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Cn,this}ensureMarks(e){return q.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Cn)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Cn,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let o=this.selection;return t&&(e=e.mark(this.storedMarks||(o.empty?o.$from.marks():o.$from.marksAcross(o.$to)||q.none))),o.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,o){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(o==null&&(o=t),!e)return this.deleteRange(t,o);let r=this.storedMarks;if(!r){let s=this.doc.resolve(t);r=o==t?s.marks():s.marksAcross(this.doc.resolve(o))}return this.replaceRangeWith(t,o,i.text(e,r)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(G.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=dr,this}get scrolledIntoView(){return(this.updated&dr)>0}}function mr(n,e){return!e||!n?n:n.bind(e)}class Ft{constructor(e,t,o){this.name=e,this.init=mr(t.init,o),this.apply=mr(t.apply,o)}}const Ru=[new Ft("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Ft("selection",{init(n,e){return n.selection||G.atStart(e.doc)},apply(n){return n.selection}}),new Ft("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,o){return o.selection.$cursor?n.storedMarks:null}}),new Ft("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Co{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Ru.slice(),t&&t.forEach(o=>{if(this.pluginsByKey[o.key])throw new RangeError("Adding different instances of a keyed plugin ("+o.key+")");this.plugins.push(o),this.pluginsByKey[o.key]=o,o.spec.state&&this.fields.push(new Ft(o.key,o.spec.state,o))})}}class qt{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let o=0;o<this.config.plugins.length;o++)if(o!=t){let i=this.config.plugins[o];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],o=this.applyInner(e),i=null;for(;;){let r=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let c=i?i[s].n:0,p=i?i[s].state:this,d=c<t.length&&l.spec.appendTransaction.call(l,c?t.slice(c):t,p,o);if(d&&o.filterTransaction(d,s)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let m=0;m<this.config.plugins.length;m++)i.push(m<s?{state:o,n:t.length}:{state:this,n:0})}t.push(d),o=o.applyInner(d),r=!0}i&&(i[s]={state:o,n:t.length})}}if(!r)return{state:o,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new qt(this.config),o=this.config.fields;for(let i=0;i<o.length;i++){let r=o[i];t[r.name]=r.apply(e,this[r.name],this,t)}return t}get tr(){return new Cu(this)}static create(e){let t=new Co(e.doc?e.doc.type.schema:e.schema,e.plugins),o=new qt(t);for(let i=0;i<t.fields.length;i++)o[t.fields[i].name]=t.fields[i].init(e,o);return o}reconfigure(e){let t=new Co(this.schema,e.plugins),o=t.fields,i=new qt(t);for(let r=0;r<o.length;r++){let s=o[r].name;i[s]=this.hasOwnProperty(s)?this[s]:o[r].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(o=>o.toJSON())),e&&typeof e=="object")for(let o in e){if(o=="doc"||o=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[o],r=i.spec.state;r&&r.toJSON&&(t[o]=r.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,o){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Co(e.schema,e.plugins),r=new qt(i);return i.fields.forEach(s=>{if(s.name=="doc")r.doc=Oe.fromJSON(e.schema,t.doc);else if(s.name=="selection")r.selection=G.fromJSON(r.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(r.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(o)for(let l in o){let c=o[l],p=c.spec.state;if(c.key==s.name&&p&&p.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){r[s.name]=p.fromJSON.call(c,e,t[l],r);return}}r[s.name]=s.init(e,r)}}),r}}function $s(n,e,t){for(let o in n){let i=n[o];i instanceof Function?i=i.bind(e):o=="handleDOMEvents"&&(i=$s(i,e,{})),t[o]=i}return t}class js{constructor(e){this.spec=e,this.props={},e.props&&$s(e.props,this,this.props),this.key=e.key?e.key.key:Hs("plugin")}getState(e){return e[this.key]}}const Ro=Object.create(null);function Hs(n){return n in Ro?n+"$"+ ++Ro[n]:(Ro[n]=0,n+"$")}class Js{constructor(e="key"){this.key=Hs(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Z=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Rt=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Wo=null;const Be=function(n,e,t){let o=Wo||(Wo=document.createRange());return o.setEnd(n,t??n.nodeValue.length),o.setStart(n,e||0),o},Ou=function(){Wo=null},gt=function(n,e,t,o){return t&&(hr(n,e,t,o,-1)||hr(n,e,t,o,1))},Mu=/^(img|br|input|textarea|hr)$/i;function hr(n,e,t,o,i){for(var r;;){if(n==t&&e==o)return!0;if(e==(i<0?0:xe(n))){let s=n.parentNode;if(!s||s.nodeType!=1||rn(n)||Mu.test(n.nodeName)||n.contentEditable=="false")return!1;e=Z(n)+(i<0?0:1),n=s}else if(n.nodeType==1){let s=n.childNodes[e+(i<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((r=s.pmViewDesc)===null||r===void 0)&&r.ignoreForSelection)e+=i;else return!1;else n=s,e=i<0?xe(n):0}else return!1}}function xe(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function vu(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=xe(n)}else if(n.parentNode&&!rn(n))e=Z(n),n=n.parentNode;else return null}}function Eu(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!rn(n))e=Z(n)+1,n=n.parentNode;else return null}}function Au(n,e,t){for(let o=e==0,i=e==xe(n);o||i;){if(n==t)return!0;let r=Z(n);if(n=n.parentNode,!n)return!1;o=o&&r==0,i=i&&r==xe(n)}}function rn(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Jn=function(n){return n.focusNode&&gt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function st(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Nu(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Du(n,e,t){if(n.caretPositionFromPoint)try{let o=n.caretPositionFromPoint(e,t);if(o)return{node:o.offsetNode,offset:Math.min(xe(o.offsetNode),o.offset)}}catch{}if(n.caretRangeFromPoint){let o=n.caretRangeFromPoint(e,t);if(o)return{node:o.startContainer,offset:Math.min(xe(o.startContainer),o.startOffset)}}}const Ee=typeof navigator<"u"?navigator:null,fr=typeof document<"u"?document:null,Ze=Ee&&Ee.userAgent||"",$o=/Edge\/(\d+)/.exec(Ze),Qs=/MSIE \d/.exec(Ze),jo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ze),ue=!!(Qs||jo||$o),He=Qs?document.documentMode:jo?+jo[1]:$o?+$o[1]:0,ye=!ue&&/gecko\/(\d+)/i.test(Ze);ye&&+(/Firefox\/(\d+)/.exec(Ze)||[0,0])[1];const Ho=!ue&&/Chrome\/(\d+)/.exec(Ze),te=!!Ho,Xs=Ho?+Ho[1]:0,ie=!ue&&!!Ee&&/Apple Computer/.test(Ee.vendor),Ot=ie&&(/Mobile\/\w+/.test(Ze)||!!Ee&&Ee.maxTouchPoints>2),ge=Ot||(Ee?/Mac/.test(Ee.platform):!1),Ys=Ee?/Win/.test(Ee.platform):!1,Pe=/Android \d/.test(Ze),sn=!!fr&&"webkitFontSmoothing"in fr.documentElement.style,Bu=sn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Vu(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Ne(n,e){return typeof n=="number"?n:n[e]}function Pu(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,o=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*o}}function gr(n,e,t){if(!Jo(e)&&e.left==0)return;let o=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,r=n.dom.ownerDocument;for(let s=t||n.dom;s;){if(s.nodeType!=1){s=Rt(s);continue}let l=s,c=l==r.body,p=c?Vu(r):Pu(l),d=0,m=0;if(e.top<p.top+Ne(o,"top")?m=-(p.top-e.top+Ne(i,"top")):e.bottom>p.bottom-Ne(o,"bottom")&&(m=e.bottom-e.top>p.bottom-p.top?e.top+Ne(i,"top")-p.top:e.bottom-p.bottom+Ne(i,"bottom")),e.left<p.left+Ne(o,"left")?d=-(p.left-e.left+Ne(i,"left")):e.right>p.right-Ne(o,"right")&&(d=e.right-p.right+Ne(i,"right")),d||m)if(c)r.defaultView.scrollBy(d,m);else{let S=l.scrollLeft,b=l.scrollTop;m&&(l.scrollTop+=m),d&&(l.scrollLeft+=d);let _=l.scrollLeft-S,w=l.scrollTop-b;e={left:e.left-_,top:e.top-w,right:e.right-_,bottom:e.bottom-w}}let g=c?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(g))break;s=g=="absolute"?s.offsetParent:Rt(s)}}function Ku(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),o,i;for(let r=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=n.root.elementFromPoint(r,s);if(!l||l==n.dom||!n.dom.contains(l))continue;let c=l.getBoundingClientRect();if(c.top>=t-20){o=l,i=c.top;break}}return{refDOM:o,refTop:i,stack:Zs(n.dom)}}function Zs(n){let e=[],t=n.ownerDocument;for(let o=n;o&&(e.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),n!=t);o=Rt(o));return e}function zu({refDOM:n,refTop:e,stack:t}){let o=n?n.getBoundingClientRect().top:0;ea(t,o==0?0:o-e)}function ea(n,e){for(let t=0;t<n.length;t++){let{dom:o,top:i,left:r}=n[t];o.scrollTop!=i+e&&(o.scrollTop=i+e),o.scrollLeft!=r&&(o.scrollLeft=r)}}let kt=null;function Fu(n){if(n.setActive)return n.setActive();if(kt)return n.focus(kt);let e=Zs(n);n.focus(kt==null?{get preventScroll(){return kt={preventScroll:!0},!0}}:void 0),kt||(kt=!1,ea(e,0))}function ta(n,e){let t,o=2e8,i,r=0,s=e.top,l=e.top,c,p;for(let d=n.firstChild,m=0;d;d=d.nextSibling,m++){let g;if(d.nodeType==1)g=d.getClientRects();else if(d.nodeType==3)g=Be(d).getClientRects();else continue;for(let S=0;S<g.length;S++){let b=g[S];if(b.top<=s&&b.bottom>=l){s=Math.max(b.bottom,s),l=Math.min(b.top,l);let _=b.left>e.left?b.left-e.left:b.right<e.left?e.left-b.right:0;if(_<o){t=d,o=_,i=_&&t.nodeType==3?{left:b.right<e.left?b.right:b.left,top:e.top}:e,d.nodeType==1&&_&&(r=m+(e.left>=(b.left+b.right)/2?1:0));continue}}else b.top>e.top&&!c&&b.left<=e.left&&b.right>=e.left&&(c=d,p={left:Math.max(b.left,Math.min(b.right,e.left)),top:b.top});!t&&(e.left>=b.right&&e.top>=b.top||e.left>=b.left&&e.top>=b.bottom)&&(r=m+1)}}return!t&&c&&(t=c,i=p,o=0),t&&t.nodeType==3?qu(t,i):!t||o&&t.nodeType==1?{node:n,offset:r}:ta(t,i)}function qu(n,e){let t=n.nodeValue.length,o=document.createRange(),i;for(let r=0;r<t;r++){o.setEnd(n,r+1),o.setStart(n,r);let s=Ue(o,1);if(s.top!=s.bottom&&pi(e,s)){i={node:n,offset:r+(e.left>=(s.left+s.right)/2?1:0)};break}}return o.detach(),i||{node:n,offset:0}}function pi(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Uu(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Gu(n,e,t){let{node:o,offset:i}=ta(e,t),r=-1;if(o.nodeType==1&&!o.firstChild){let s=o.getBoundingClientRect();r=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(o,i,r)}function Lu(n,e,t,o){let i=-1;for(let r=e,s=!1;r!=n.dom;){let l=n.docView.nearestDesc(r,!0),c;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((c=l.dom.getBoundingClientRect()).width||c.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&c.left>o.left||c.top>o.top?i=l.posBefore:(!s&&c.right<o.left||c.bottom<o.top)&&(i=l.posAfter),s=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?o.top<(c.top+c.bottom)/2:o.left<(c.left+c.right)/2)?l.posBefore:l.posAfter;r=l.dom.parentNode}return i>-1?i:n.docView.posFromDOM(e,t,-1)}function na(n,e,t){let o=n.childNodes.length;if(o&&t.top<t.bottom)for(let i=Math.max(0,Math.min(o-1,Math.floor(o*(e.top-t.top)/(t.bottom-t.top))-2)),r=i;;){let s=n.childNodes[r];if(s.nodeType==1){let l=s.getClientRects();for(let c=0;c<l.length;c++){let p=l[c];if(pi(e,p))return na(s,e,p)}}if((r=(r+1)%o)==i)break}return n}function Wu(n,e){let t=n.dom.ownerDocument,o,i=0,r=Du(t,e.left,e.top);r&&({node:o,offset:i}=r);let s=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!s||!n.dom.contains(s.nodeType!=1?s.parentNode:s)){let p=n.dom.getBoundingClientRect();if(!pi(e,p)||(s=na(n.dom,e,p),!s))return null}if(ie)for(let p=s;o&&p;p=Rt(p))p.draggable&&(o=void 0);if(s=Uu(s,e),o){if(ye&&o.nodeType==1&&(i=Math.min(i,o.childNodes.length),i<o.childNodes.length)){let d=o.childNodes[i],m;d.nodeName=="IMG"&&(m=d.getBoundingClientRect()).right<=e.left&&m.bottom>e.top&&i++}let p;sn&&i&&o.nodeType==1&&(p=o.childNodes[i-1]).nodeType==1&&p.contentEditable=="false"&&p.getBoundingClientRect().top>=e.top&&i--,o==n.dom&&i==o.childNodes.length-1&&o.lastChild.nodeType==1&&e.top>o.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||o.nodeType!=1||o.childNodes[i-1].nodeName!="BR")&&(l=Lu(n,o,i,e))}l==null&&(l=Gu(n,s,e));let c=n.docView.nearestDesc(s,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function Jo(n){return n.top<n.bottom||n.left<n.right}function Ue(n,e){let t=n.getClientRects();if(t.length){let o=t[e<0?0:t.length-1];if(Jo(o))return o}return Array.prototype.find.call(t,Jo)||n.getBoundingClientRect()}const $u=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function oa(n,e,t){let{node:o,offset:i,atom:r}=n.docView.domFromPos(e,t<0?-1:1),s=sn||ye;if(o.nodeType==3)if(s&&($u.test(o.nodeValue)||(t<0?!i:i==o.nodeValue.length))){let c=Ue(Be(o,i,i),t);if(ye&&i&&/\s/.test(o.nodeValue[i-1])&&i<o.nodeValue.length){let p=Ue(Be(o,i-1,i-1),-1);if(p.top==c.top){let d=Ue(Be(o,i,i+1),-1);if(d.top!=c.top)return Dt(d,d.left<p.left)}}return c}else{let c=i,p=i,d=t<0?1:-1;return t<0&&!i?(p++,d=-1):t>=0&&i==o.nodeValue.length?(c--,d=1):t<0?c--:p++,Dt(Ue(Be(o,c,p),d),d<0)}if(!n.state.doc.resolve(e-(r||0)).parent.inlineContent){if(r==null&&i&&(t<0||i==xe(o))){let c=o.childNodes[i-1];if(c.nodeType==1)return Oo(c.getBoundingClientRect(),!1)}if(r==null&&i<xe(o)){let c=o.childNodes[i];if(c.nodeType==1)return Oo(c.getBoundingClientRect(),!0)}return Oo(o.getBoundingClientRect(),t>=0)}if(r==null&&i&&(t<0||i==xe(o))){let c=o.childNodes[i-1],p=c.nodeType==3?Be(c,xe(c)-(s?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(p)return Dt(Ue(p,1),!1)}if(r==null&&i<xe(o)){let c=o.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let p=c?c.nodeType==3?Be(c,0,s?0:1):c.nodeType==1?c:null:null;if(p)return Dt(Ue(p,-1),!0)}return Dt(Ue(o.nodeType==3?Be(o):o,-t),t>=0)}function Dt(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Oo(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function ia(n,e,t){let o=n.state,i=n.root.activeElement;o!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{o!=e&&n.updateState(o),i!=n.dom&&i&&i.focus()}}function ju(n,e,t){let o=e.selection,i=t=="up"?o.$from:o.$to;return ia(n,e,()=>{let{node:r}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(r,!0);if(!l)break;if(l.node.isBlock){r=l.contentDOM||l.dom;break}r=l.dom.parentNode}let s=oa(n,i.pos,1);for(let l=r.firstChild;l;l=l.nextSibling){let c;if(l.nodeType==1)c=l.getClientRects();else if(l.nodeType==3)c=Be(l,0,l.nodeValue.length).getClientRects();else continue;for(let p=0;p<c.length;p++){let d=c[p];if(d.bottom>d.top+1&&(t=="up"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}const Hu=/[\u0590-\u08ac]/;function Ju(n,e,t){let{$head:o}=e.selection;if(!o.parent.isTextblock)return!1;let i=o.parentOffset,r=!i,s=i==o.parent.content.size,l=n.domSelection();return l?!Hu.test(o.parent.textContent)||!l.modify?t=="left"||t=="backward"?r:s:ia(n,e,()=>{let{focusNode:c,focusOffset:p,anchorNode:d,anchorOffset:m}=n.domSelectionRange(),g=l.caretBidiLevel;l.modify("move",t,"character");let S=o.depth?n.docView.domAfterPos(o.before()):n.dom,{focusNode:b,focusOffset:_}=n.domSelectionRange(),w=b&&!S.contains(b.nodeType==1?b:b.parentNode)||c==b&&p==_;try{l.collapse(d,m),c&&(c!=d||p!=m)&&l.extend&&l.extend(c,p)}catch{}return g!=null&&(l.caretBidiLevel=g),w}):o.pos==o.start()||o.pos==o.end()}let xr=null,yr=null,Sr=!1;function Qu(n,e,t){return xr==e&&yr==t?Sr:(xr=e,yr=t,Sr=t=="up"||t=="down"?ju(n,e,t):Ju(n,e,t))}const Se=0,br=1,at=2,we=3;class an{constructor(e,t,o,i){this.parent=e,this.children=t,this.dom=o,this.contentDOM=i,this.dirty=Se,o.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,o){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,o=this.posAtStart;;t++){let i=this.children[t];if(i==e)return o;o+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,o){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(o<0){let r,s;if(e==this.contentDOM)r=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.previousSibling}for(;r&&!((s=r.pmViewDesc)&&s.parent==this);)r=r.previousSibling;return r?this.posBeforeChild(s)+s.size:this.posAtStart}else{let r,s;if(e==this.contentDOM)r=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.nextSibling}for(;r&&!((s=r.pmViewDesc)&&s.parent==this);)r=r.nextSibling;return r?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>Z(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let r=e;;r=r.parentNode){if(r==this.dom){i=!1;break}if(r.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let r=e;;r=r.parentNode){if(r==this.dom){i=!0;break}if(r.nextSibling)break}}return i??o>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let o=!0,i=e;i;i=i.parentNode){let r=this.getDesc(i),s;if(r&&(!t||r.node))if(o&&(s=r.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))o=!1;else return r}}getDesc(e){let t=e.pmViewDesc;for(let o=t;o;o=o.parent)if(o==this)return t}posFromDOM(e,t,o){for(let i=e;i;i=i.parentNode){let r=this.getDesc(i);if(r)return r.localPosFromDOM(e,t,o)}return-1}descAt(e){for(let t=0,o=0;t<this.children.length;t++){let i=this.children[t],r=o+i.size;if(o==e&&r!=o){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let l=i.children[s];if(l.size){i=l;break}}return i}if(e<r)return i.descAt(e-o-i.border);o=r}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let o=0,i=0;for(let r=0;o<this.children.length;o++){let s=this.children[o],l=r+s.size;if(l>e||s instanceof sa){i=e-r;break}r=l}if(i)return this.children[o].domFromPos(i-this.children[o].border,t);for(let r;o&&!(r=this.children[o-1]).size&&r instanceof ra&&r.side>=0;o--);if(t<=0){let r,s=!0;for(;r=o?this.children[o-1]:null,!(!r||r.dom.parentNode==this.contentDOM);o--,s=!1);return r&&t&&s&&!r.border&&!r.domAtom?r.domFromPos(r.size,t):{node:this.contentDOM,offset:r?Z(r.dom)+1:0}}else{let r,s=!0;for(;r=o<this.children.length?this.children[o]:null,!(!r||r.dom.parentNode==this.contentDOM);o++,s=!1);return r&&s&&!r.border&&!r.domAtom?r.domFromPos(0,t):{node:this.contentDOM,offset:r?Z(r.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,o=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,r=-1;for(let s=o,l=0;;l++){let c=this.children[l],p=s+c.size;if(i==-1&&e<=p){let d=s+c.border;if(e>=d&&t<=p-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,t,d);e=s;for(let m=l;m>0;m--){let g=this.children[m-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){i=Z(g.dom)+1;break}e-=g.size}i==-1&&(i=0)}if(i>-1&&(p>t||l==this.children.length-1)){t=p;for(let d=l+1;d<this.children.length;d++){let m=this.children[d];if(m.size&&m.dom.parentNode==this.contentDOM&&!m.emptyChildAt(-1)){r=Z(m.dom);break}t+=m.size}r==-1&&(r=this.contentDOM.childNodes.length);break}s=p}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:r}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:o}=this.domFromPos(e,0);if(t.nodeType!=1||o==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[o]}setSelection(e,t,o,i=!1){let r=Math.min(e,t),s=Math.max(e,t);for(let S=0,b=0;S<this.children.length;S++){let _=this.children[S],w=b+_.size;if(r>b&&s<w)return _.setSelection(e-b-_.border,t-b-_.border,o,i);b=w}let l=this.domFromPos(e,e?-1:1),c=t==e?l:this.domFromPos(t,t?-1:1),p=o.root.getSelection(),d=o.domSelectionRange(),m=!1;if((ye||ie)&&e==t){let{node:S,offset:b}=l;if(S.nodeType==3){if(m=!!(b&&S.nodeValue[b-1]==`
6
+ `),m&&b==S.nodeValue.length)for(let _=S,w;_;_=_.parentNode){if(w=_.nextSibling){w.nodeName=="BR"&&(l=c={node:w.parentNode,offset:Z(w)+1});break}let v=_.pmViewDesc;if(v&&v.node&&v.node.isBlock)break}}else{let _=S.childNodes[b-1];m=_&&(_.nodeName=="BR"||_.contentEditable=="false")}}if(ye&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let S=d.focusNode.childNodes[d.focusOffset];S&&S.contentEditable=="false"&&(i=!0)}if(!(i||m&&ie)&&gt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&gt(c.node,c.offset,d.focusNode,d.focusOffset))return;let g=!1;if((p.extend||e==t)&&!(m&&ye)){p.collapse(l.node,l.offset);try{e!=t&&p.extend(c.node,c.offset),g=!0}catch{}}if(!g){if(e>t){let b=l;l=c,c=b}let S=document.createRange();S.setEnd(c.node,c.offset),S.setStart(l.node,l.offset),p.removeAllRanges(),p.addRange(S)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let o=0,i=0;i<this.children.length;i++){let r=this.children[i],s=o+r.size;if(o==s?e<=s&&t>=o:e<s&&t>o){let l=o+r.border,c=s-r.border;if(e>=l&&t<=c){this.dirty=e==o||t==s?at:br,e==l&&t==c&&(r.contentLost||r.dom.parentNode!=this.contentDOM)?r.dirty=we:r.markDirty(e-l,t-l);return}else r.dirty=r.dom==r.contentDOM&&r.dom.parentNode==this.contentDOM&&!r.children.length?at:we}o=s}this.dirty=at}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let o=e==1?at:br;t.dirty<o&&(t.dirty=o)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class ra extends an{constructor(e,t,o,i){let r,s=t.type.toDOM;if(typeof s=="function"&&(s=s(o,()=>{if(!r)return i;if(r.parent)return r.parent.posBeforeChild(r)})),!t.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.hasAttribute("contenteditable")||(s.contentEditable="false"),s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return this.dirty==Se&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class Xu extends an{constructor(e,t,o,i){super(e,[],t,null),this.textDOM=o,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Je extends an{constructor(e,t,o,i,r){super(e,[],o,i),this.mark=t,this.spec=r}static create(e,t,o,i){let r=i.nodeViews[t.type.name],s=r&&r(t,i,o);return(!s||!s.dom)&&(s=vt.renderSpec(document,t.type.spec.toDOM(t,o),null,t.attrs)),new Je(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&we||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=we&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Se){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=Se}}slice(e,t,o){let i=Je.create(this.parent,this.mark,!0,o),r=this.children,s=this.size;t<s&&(r=Xo(r,t,s,o)),e>0&&(r=Xo(r,0,e,o));for(let l=0;l<r.length;l++)r[l].parent=i;return i.children=r,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Qe extends an{constructor(e,t,o,i,r,s,l){super(e,[],r,s),this.node=t,this.outerDeco=o,this.innerDeco=i,this.nodeDOM=l}static create(e,t,o,i,r,s){let l=r.nodeViews[t.type.name],c,p=l&&l(t,r,()=>{if(!c)return s;if(c.parent)return c.parent.posBeforeChild(c)},o,i),d=p&&p.dom,m=p&&p.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:m}=vt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!m&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let g=d;return d=ca(d,o,t),p?c=new Yu(e,t,o,i,d,m||null,g,p):t.isText?new Qn(e,t,o,i,d,g):new Qe(e,t,o,i,d,m||null,g)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let o=this.children.length-1;o>=0;o--){let i=this.children[o];if(this.dom.contains(i.dom.parentNode)){t.contentElement=i.dom.parentNode;break}}if(!t.contentElement){let o=e&&e.find(i=>i.nodeType==1&&e.indexOf(i.parentNode)<0&&this.dom.contains(i));o?t.contentElement=o:t.getContent=()=>C.empty}}return t}matchesNode(e,t,o){return this.dirty==Se&&e.eq(this.node)&&Pn(t,this.outerDeco)&&o.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let o=this.node.inlineContent,i=t,r=e.composing?this.localCompositionInfo(e,t):null,s=r&&r.pos>-1?r:null,l=r&&r.pos<0,c=new ep(this,s&&s.node,e);op(this.node,this.innerDeco,(p,d,m)=>{p.spec.marks?c.syncToMarks(p.spec.marks,o,e,d):p.type.side>=0&&!m&&c.syncToMarks(d==this.node.childCount?q.none:this.node.child(d).marks,o,e,d),c.placeWidget(p,e,i)},(p,d,m,g)=>{c.syncToMarks(p.marks,o,e,g);let S;c.findNodeMatch(p,d,m,g)||l&&e.state.selection.from>i&&e.state.selection.to<i+p.nodeSize&&(S=c.findIndexWithChild(r.node))>-1&&c.updateNodeAt(p,d,m,S,e)||c.updateNextNode(p,d,m,e,g,i)||c.addNode(p,d,m,e,i),i+=p.nodeSize}),c.syncToMarks([],o,e,0),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==at)&&(s&&this.protectLocalComposition(e,s),aa(this.contentDOM,this.children,e),Ot&&ip(this.dom))}localCompositionInfo(e,t){let{from:o,to:i}=e.state.selection;if(!(e.state.selection instanceof U)||o<t||i>t+this.node.content.size)return null;let r=e.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let s=r.nodeValue,l=rp(this.node.content,s,o-t,i-t);return l<0?null:{node:r,pos:l,text:s}}else return{node:r,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:o,text:i}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let s=new Xu(this,r,t,i);e.input.compositionNodes.push(s),this.children=Xo(this.children,o,o+i.length,e,s)}update(e,t,o,i){return this.dirty==we||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,o,i),!0)}updateInner(e,t,o,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=o,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Se}updateOuterDeco(e){if(Pn(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,o=this.dom;this.dom=la(this.dom,this.nodeDOM,Qo(this.outerDeco,this.node,t),Qo(e,this.node,t)),this.dom!=o&&(o.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function kr(n,e,t,o,i){ca(o,e,n);let r=new Qe(void 0,n,e,t,o,o,o);return r.contentDOM&&r.updateChildren(i,0),r}class Qn extends Qe{constructor(e,t,o,i,r,s){super(e,t,o,i,r,null,s)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,o,i){return this.dirty==we||this.dirty!=Se&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Se||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Se,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,o){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,o)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,o){let i=this.node.cut(e,t),r=document.createTextNode(i.text);return new Qn(this.parent,i,this.outerDeco,this.innerDeco,r,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=we)}get domAtom(){return!1}isText(e){return this.node.text==e}}class sa extends an{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Se&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Yu extends Qe{constructor(e,t,o,i,r,s,l,c){super(e,t,o,i,r,s,l),this.spec=c}update(e,t,o,i){if(this.dirty==we)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let r=this.spec.update(e,t,o);return r&&this.updateInner(e,t,o,i),r}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,o,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,o,i){this.spec.setSelection?this.spec.setSelection(e,t,o.root):super.setSelection(e,t,o,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function aa(n,e,t){let o=n.firstChild,i=!1;for(let r=0;r<e.length;r++){let s=e[r],l=s.dom;if(l.parentNode==n){for(;l!=o;)o=_r(o),i=!0;o=o.nextSibling}else i=!0,n.insertBefore(l,o);if(s instanceof Je){let c=o?o.previousSibling:n.lastChild;aa(s.contentDOM,s.children,t),o=c?c.nextSibling:n.firstChild}}for(;o;)o=_r(o),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const Lt=function(n){n&&(this.nodeName=n)};Lt.prototype=Object.create(null);const lt=[new Lt];function Qo(n,e,t){if(n.length==0)return lt;let o=t?lt[0]:new Lt,i=[o];for(let r=0;r<n.length;r++){let s=n[r].type.attrs;if(s){s.nodeName&&i.push(o=new Lt(s.nodeName));for(let l in s){let c=s[l];c!=null&&(t&&i.length==1&&i.push(o=new Lt(e.isInline?"span":"div")),l=="class"?o.class=(o.class?o.class+" ":"")+c:l=="style"?o.style=(o.style?o.style+";":"")+c:l!="nodeName"&&(o[l]=c))}}}return i}function la(n,e,t,o){if(t==lt&&o==lt)return e;let i=e;for(let r=0;r<o.length;r++){let s=o[r],l=t[r];if(r){let c;l&&l.nodeName==s.nodeName&&i!=n&&(c=i.parentNode)&&c.nodeName.toLowerCase()==s.nodeName||(c=document.createElement(s.nodeName),c.pmIsDeco=!0,c.appendChild(i),l=lt[0]),i=c}Zu(i,l||lt[0],s)}return i}function Zu(n,e,t){for(let o in e)o!="class"&&o!="style"&&o!="nodeName"&&!(o in t)&&n.removeAttribute(o);for(let o in t)o!="class"&&o!="style"&&o!="nodeName"&&t[o]!=e[o]&&n.setAttribute(o,t[o]);if(e.class!=t.class){let o=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let r=0;r<o.length;r++)i.indexOf(o[r])==-1&&n.classList.remove(o[r]);for(let r=0;r<i.length;r++)o.indexOf(i[r])==-1&&n.classList.add(i[r]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=o.exec(e.style);)n.style.removeProperty(i[1])}t.style&&(n.style.cssText+=t.style)}}function ca(n,e,t){return la(n,n,lt,Qo(e,t,n.nodeType!=1))}function Pn(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function _r(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class ep{constructor(e,t,o){this.lock=t,this.view=o,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=tp(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let o=e;o<t;o++)this.top.children[o].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,o,i){let r=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;r<l&&(r==s-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&e[r].type.spec.spanning!==!1;)r++;for(;r<s;)this.destroyRest(),this.top.dirty=Se,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let c=-1,p=this.top.children.length;i<this.preMatch.index&&(p=Math.min(this.index+3,p));for(let d=this.index;d<p;d++){let m=this.top.children[d];if(m.matchesMark(e[s])&&!this.isLocked(m.dom)){c=d;break}}if(c<0&&this.index<this.top.children.length){let d=this.top.children[this.index];d instanceof Je&&d.dirty!=we&&d.mark.type==e[s].type&&d.spec.update&&!this.isLocked(d.dom)&&d.spec.update(e[s])&&(d.mark=e[s],c=this.index,this.changed=!0)}if(c>-1)c>this.index&&(this.changed=!0,this.destroyBetween(this.index,c)),this.top=this.top.children[this.index];else{let d=Je.create(this.top,e[s],t,o);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,o,i){let r=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,o))r=this.top.children.indexOf(s,this.index);else for(let l=this.index,c=Math.min(this.top.children.length,l+5);l<c;l++){let p=this.top.children[l];if(p.matchesNode(e,t,o)&&!this.preMatch.matched.has(p)){r=l;break}}return r<0?!1:(this.destroyBetween(this.index,r),this.index++,!0)}updateNodeAt(e,t,o,i,r){let s=this.top.children[i];return s.dirty==we&&s.dom==s.contentDOM&&(s.dirty=at),s.update(e,t,o,r)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let o=e.pmViewDesc;if(o){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==o)return i}return-1}e=t}}updateNextNode(e,t,o,i,r,s){for(let l=this.index;l<this.top.children.length;l++){let c=this.top.children[l];if(c instanceof Qe){let p=this.preMatch.matched.get(c);if(p!=null&&p!=r)return!1;let d=c.dom,m,g=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=we&&Pn(t,c.outerDeco));if(!g&&c.update(e,t,o,i))return this.destroyBetween(this.index,l),c.dom!=d&&(this.changed=!0),this.index++,!0;if(!g&&(m=this.recreateWrapper(c,e,t,o,i,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=m,m.contentDOM&&(m.dirty=at,m.updateChildren(i,s+1),m.dirty=Se),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,o,i,r,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Pn(o,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Qe.create(this.top,t,o,i,r,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let c of l.children)c.parent=l}return e.destroy(),l}addNode(e,t,o,i,r){let s=Qe.create(this.top,e,t,o,i,r);s.contentDOM&&s.updateChildren(i,r+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,o){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let r=new ra(this.top,e,t,o);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Je;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Qn)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ie||te)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let o=document.createElement(e);e=="IMG"&&(o.className="ProseMirror-separator",o.alt=""),e=="BR"&&(o.className="ProseMirror-trailingBreak");let i=new sa(this.top,[],o,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function tp(n,e){let t=e,o=t.children.length,i=n.childCount,r=new Map,s=[];e:for(;i>0;){let l;for(;;)if(o){let p=t.children[o-1];if(p instanceof Je)t=p,o=p.children.length;else{l=p,o--;break}}else{if(t==e)break e;o=t.parent.children.indexOf(t),t=t.parent}let c=l.node;if(c){if(c!=n.child(i-1))break;--i,r.set(l,i),s.push(l)}}return{index:i,matched:r,matches:s.reverse()}}function np(n,e){return n.type.side-e.type.side}function op(n,e,t,o){let i=e.locals(n),r=0;if(i.length==0){for(let p=0;p<n.childCount;p++){let d=n.child(p);o(d,i,e.forChild(r,d),p),r+=d.nodeSize}return}let s=0,l=[],c=null;for(let p=0;;){let d,m;for(;s<i.length&&i[s].to==r;){let w=i[s++];w.widget&&(d?(m||(m=[d])).push(w):d=w)}if(d)if(m){m.sort(np);for(let w=0;w<m.length;w++)t(m[w],p,!!c)}else t(d,p,!!c);let g,S;if(c)S=-1,g=c,c=null;else if(p<n.childCount)S=p,g=n.child(p++);else break;for(let w=0;w<l.length;w++)l[w].to<=r&&l.splice(w--,1);for(;s<i.length&&i[s].from<=r&&i[s].to>r;)l.push(i[s++]);let b=r+g.nodeSize;if(g.isText){let w=b;s<i.length&&i[s].from<w&&(w=i[s].from);for(let v=0;v<l.length;v++)l[v].to<w&&(w=l[v].to);w<b&&(c=g.cut(w-r),g=g.cut(0,w-r),b=w,S=-1)}else for(;s<i.length&&i[s].to<b;)s++;let _=g.isInline&&!g.isLeaf?l.filter(w=>!w.inline):l.slice();o(g,_,e.forChild(r,g),S),r=b}}function ip(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function rp(n,e,t,o){for(let i=0,r=0;i<n.childCount&&r<=o;){let s=n.child(i++),l=r;if(r+=s.nodeSize,!s.isText)continue;let c=s.text;for(;i<n.childCount;){let p=n.child(i++);if(r+=p.nodeSize,!p.isText)break;c+=p.text}if(r>=t){if(r>=o&&c.slice(o-e.length-l,o-l)==e)return o-e.length;let p=l<o?c.lastIndexOf(e,o-l-1):-1;if(p>=0&&p+e.length+l>=t)return l+p;if(t==o&&c.length>=o+e.length-l&&c.slice(o-l,o-l+e.length)==e)return o}}return-1}function Xo(n,e,t,o,i){let r=[];for(let s=0,l=0;s<n.length;s++){let c=n[s],p=l,d=l+=c.size;p>=t||d<=e?r.push(c):(p<e&&r.push(c.slice(0,e-p,o)),i&&(r.push(i),i=void 0),d>t&&r.push(c.slice(t-p,c.size,o)))}return r}function di(n,e=null){let t=n.domSelectionRange(),o=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),r=i&&i.size==0,s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=o.resolve(s),c,p;if(Jn(t)){for(c=s;i&&!i.node;)i=i.parent;let m=i.node;if(i&&m.isAtom&&B.isSelectable(m)&&i.parent&&!(m.isInline&&Au(t.focusNode,t.focusOffset,i.dom))){let g=i.posBefore;p=new B(s==g?l:o.resolve(g))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let m=s,g=s;for(let S=0;S<t.rangeCount;S++){let b=t.getRangeAt(S);m=Math.min(m,n.docView.posFromDOM(b.startContainer,b.startOffset,1)),g=Math.max(g,n.docView.posFromDOM(b.endContainer,b.endOffset,-1))}if(m<0)return null;[c,s]=g==n.state.selection.anchor?[g,m]:[m,g],l=o.resolve(s)}else c=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(c<0)return null}let d=o.resolve(c);if(!p){let m=e=="pointer"||n.state.selection.head<l.pos&&!r?1:-1;p=mi(n,d,l,m)}return p}function ua(n){return n.editable?n.hasFocus():da(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function ze(n,e=!1){let t=n.state.selection;if(pa(n,t),!ua(n))return;let o=n.input.mouseDown;if(!e&&te&&o){let i=n.domSelectionRange(),r=n.domObserver.currentSelection;if(i.anchorNode&&r.anchorNode&&gt(i.anchorNode,i.anchorOffset,r.anchorNode,r.anchorOffset)&&o.delaySelUpdate()){n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)ap(n);else{let{anchor:i,head:r}=t,s,l;wr&&!(t instanceof U)&&(t.$from.parent.inlineContent||(s=Tr(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(l=Tr(n,t.to))),n.docView.setSelection(i,r,n,e),wr&&(s&&Ir(s),l&&Ir(l)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&sp(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}const wr=ie||te&&Xs<63;function Tr(n,e){let{node:t,offset:o}=n.docView.domFromPos(e,0),i=o<t.childNodes.length?t.childNodes[o]:null,r=o?t.childNodes[o-1]:null;if(ie&&i&&i.contentEditable=="false")return Mo(i);if((!i||i.contentEditable=="false")&&(!r||r.contentEditable=="false")){if(i)return Mo(i);if(r)return Mo(r)}}function Mo(n){return n.contentEditable="true",ie&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Ir(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function sp(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),o=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=o||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!ua(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function ap(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,o=t.nodeName=="IMG";o?e.collapse(t.parentNode,Z(t)+1):e.collapse(t,0),!o&&!n.state.selection.visible&&ue&&He<=11&&(t.disabled=!0,t.disabled=!1)}function pa(n,e){if(e instanceof B){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Cr(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Cr(n)}function Cr(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function mi(n,e,t,o){return n.someProp("createSelectionBetween",i=>i(n,e,t))||U.between(e,t,o)}function Rr(n){return n.editable&&!n.hasFocus()?!1:da(n)}function da(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function lp(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return gt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Yo(n,e){let{$anchor:t,$head:o}=n.selection,i=e>0?t.max(o):t.min(o),r=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return r&&G.findFrom(r,e)}function Ge(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Or(n,e,t){let o=n.state.selection;if(o instanceof U)if(t.indexOf("s")>-1){let{$head:i}=o,r=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let s=n.state.doc.resolve(i.pos+r.nodeSize*(e<0?-1:1));return Ge(n,new U(o.$anchor,s))}else if(o.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Yo(n.state,e);return i&&i instanceof B?Ge(n,i):!1}else if(!(ge&&t.indexOf("m")>-1)){let i=o.$head,r=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!r||r.isText)return!1;let l=e<0?i.pos-r.nodeSize:i.pos;return r.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?B.isSelectable(r)?Ge(n,new B(e<0?n.state.doc.resolve(i.pos-r.nodeSize):i)):sn?Ge(n,new U(n.state.doc.resolve(e<0?l:l+r.nodeSize))):!1:!1}}else return!1;else{if(o instanceof B&&o.node.isInline)return Ge(n,new U(e>0?o.$to:o.$from));{let i=Yo(n.state,e);return i?Ge(n,i):!1}}}function Kn(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Wt(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function _t(n,e){return e<0?cp(n):up(n)}function cp(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let i,r,s=!1;for(ye&&t.nodeType==1&&o<Kn(t)&&Wt(t.childNodes[o],-1)&&(s=!0);;)if(o>0){if(t.nodeType!=1)break;{let l=t.childNodes[o-1];if(Wt(l,-1))i=t,r=--o;else if(l.nodeType==3)t=l,o=t.nodeValue.length;else break}}else{if(ma(t))break;{let l=t.previousSibling;for(;l&&Wt(l,-1);)i=t.parentNode,r=Z(l),l=l.previousSibling;if(l)t=l,o=Kn(t);else{if(t=t.parentNode,t==n.dom)break;o=0}}}s?Zo(n,t,o):i&&Zo(n,i,r)}function up(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let i=Kn(t),r,s;for(;;)if(o<i){if(t.nodeType!=1)break;let l=t.childNodes[o];if(Wt(l,1))r=t,s=++o;else break}else{if(ma(t))break;{let l=t.nextSibling;for(;l&&Wt(l,1);)r=l.parentNode,s=Z(l)+1,l=l.nextSibling;if(l)t=l,o=0,i=Kn(t);else{if(t=t.parentNode,t==n.dom)break;o=i=0}}}r&&Zo(n,r,s)}function ma(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function pp(n,e){for(;n&&e==n.childNodes.length&&!rn(n);)e=Z(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function dp(n,e){for(;n&&!e&&!rn(n);)e=Z(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Zo(n,e,t){if(e.nodeType!=3){let r,s;(s=pp(e,t))?(e=s,t=0):(r=dp(e,t))&&(e=r,t=r.nodeValue.length)}let o=n.domSelection();if(!o)return;if(Jn(o)){let r=document.createRange();r.setEnd(e,t),r.setStart(e,t),o.removeAllRanges(),o.addRange(r)}else o.extend&&o.extend(e,t);n.domObserver.setCurSelection();let{state:i}=n;setTimeout(()=>{n.state==i&&ze(n)},50)}function Mr(n,e){let t=n.state.doc.resolve(e);if(!(te||Ys)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let r=n.coordsAtPos(e-1),s=(r.top+r.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(r.left-i.left)>1)return r.left<i.left?"ltr":"rtl"}if(e<t.end()){let r=n.coordsAtPos(e+1),s=(r.top+r.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(r.left-i.left)>1)return r.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function vr(n,e,t){let o=n.state.selection;if(o instanceof U&&!o.empty||t.indexOf("s")>-1||ge&&t.indexOf("m")>-1)return!1;let{$from:i,$to:r}=o;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=Yo(n.state,e);if(s&&s instanceof B)return Ge(n,s)}if(!i.parent.inlineContent){let s=e<0?i:r,l=o instanceof he?G.near(s,e):G.findFrom(s,e);return l?Ge(n,l):!1}return!1}function Er(n,e){if(!(n.state.selection instanceof U))return!0;let{$head:t,$anchor:o,empty:i}=n.state.selection;if(!t.sameParent(o))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let r=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(r&&!r.isText){let s=n.state.tr;return e<0?s.delete(t.pos-r.nodeSize,t.pos):s.delete(t.pos,t.pos+r.nodeSize),n.dispatch(s),!0}return!1}function Ar(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function mp(n){if(!ie||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let o=e.firstChild;Ar(n,o,"true"),setTimeout(()=>Ar(n,o,"false"),20)}return!1}function hp(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function fp(n,e){let t=e.keyCode,o=hp(e);if(t==8||ge&&t==72&&o=="c")return Er(n,-1)||_t(n,-1);if(t==46&&!e.shiftKey||ge&&t==68&&o=="c")return Er(n,1)||_t(n,1);if(t==13||t==27)return!0;if(t==37||ge&&t==66&&o=="c"){let i=t==37?Mr(n,n.state.selection.from)=="ltr"?-1:1:-1;return Or(n,i,o)||_t(n,i)}else if(t==39||ge&&t==70&&o=="c"){let i=t==39?Mr(n,n.state.selection.from)=="ltr"?1:-1:1;return Or(n,i,o)||_t(n,i)}else{if(t==38||ge&&t==80&&o=="c")return vr(n,-1,o)||_t(n,-1);if(t==40||ge&&t==78&&o=="c")return mp(n)||vr(n,1,o)||_t(n,1);if(o==(ge?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function hi(n,e){n.someProp("transformCopied",S=>{e=S(e,n)});let t=[],{content:o,openStart:i,openEnd:r}=e;for(;i>1&&r>1&&o.childCount==1&&o.firstChild.childCount==1;){i--,r--;let S=o.firstChild;t.push(S.type.name,S.attrs!=S.type.defaultAttrs?S.attrs:null),o=S.content}let s=n.someProp("clipboardSerializer")||vt.fromSchema(n.state.schema),l=Sa(),c=l.createElement("div");c.appendChild(s.serializeFragment(o,{document:l}));let p=c.firstChild,d,m=0;for(;p&&p.nodeType==1&&(d=ya[p.nodeName.toLowerCase()]);){for(let S=d.length-1;S>=0;S--){let b=l.createElement(d[S]);for(;c.firstChild;)b.appendChild(c.firstChild);c.appendChild(b),m++}p=c.firstChild}p&&p.nodeType==1&&p.setAttribute("data-pm-slice",`${i} ${r}${m?` -${m}`:""} ${JSON.stringify(t)}`);let g=n.someProp("clipboardTextSerializer",S=>S(e,n))||e.content.textBetween(0,e.content.size,`
7
+
8
+ `);return{dom:c,text:g,slice:e}}function ha(n,e,t,o,i){let r=i.parent.type.spec.code,s,l;if(!t&&!e)return null;let c=!!e&&(o||r||!t);if(c){if(n.someProp("transformPastedText",g=>{e=g(e,r||o,n)}),r)return l=new A(C.from(n.state.schema.text(e.replace(/\r\n?/g,`
9
+ `))),0,0),n.someProp("transformPasted",g=>{l=g(l,n,!0)}),l;let m=n.someProp("clipboardTextParser",g=>g(e,i,o,n));if(m)l=m;else{let g=i.marks(),{schema:S}=n.state,b=vt.fromSchema(S);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(_=>{let w=s.appendChild(document.createElement("p"));_&&w.appendChild(b.serializeNode(S.text(_,g)))})}}else n.someProp("transformPastedHTML",m=>{t=m(t,n)}),s=Sp(t),sn&&bp(s);let p=s&&s.querySelector("[data-pm-slice]"),d=p&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(p.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let m=+d[3];m>0;m--){let g=s.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;s=g}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Jt.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!gp.test(g.parentNode.nodeName)?{ignore:!0}:null}})),d)l=kp(Nr(l,+d[1],+d[2]),d[4]);else if(l=A.maxOpen(xp(l.content,i),!0),l.openStart||l.openEnd){let m=0,g=0;for(let S=l.content.firstChild;m<l.openStart&&!S.type.spec.isolating;m++,S=S.firstChild);for(let S=l.content.lastChild;g<l.openEnd&&!S.type.spec.isolating;g++,S=S.lastChild);l=Nr(l,m,g)}return n.someProp("transformPasted",m=>{l=m(l,n,c)}),l}const gp=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function xp(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),r,s=[];if(n.forEach(l=>{if(!s)return;let c=i.findWrapping(l.type),p;if(!c)return s=null;if(p=s.length&&r.length&&ga(c,r,l,s[s.length-1],0))s[s.length-1]=p;else{s.length&&(s[s.length-1]=xa(s[s.length-1],r.length));let d=fa(l,c);s.push(d),i=i.matchType(d.type),r=c}}),s)return C.from(s)}return n}function fa(n,e,t=0){for(let o=e.length-1;o>=t;o--)n=e[o].create(null,C.from(n));return n}function ga(n,e,t,o,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let r=ga(n,e,t,o.lastChild,i+1);if(r)return o.copy(o.content.replaceChild(o.childCount-1,r));if(o.contentMatchAt(o.childCount).matchType(i==n.length-1?t.type:n[i+1]))return o.copy(o.content.append(C.from(fa(t,n,i+1))))}}function xa(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,xa(n.lastChild,e-1)),o=n.contentMatchAt(n.childCount).fillBefore(C.empty,!0);return n.copy(t.append(o))}function ei(n,e,t,o,i,r){let s=e<0?n.firstChild:n.lastChild,l=s.content;return n.childCount>1&&(r=0),i<o-1&&(l=ei(l,e,t,o,i+1,r)),i>=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,r<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(C.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function Nr(n,e,t){return e<n.openStart&&(n=new A(ei(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new A(ei(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const ya={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function Sa(){return document.implementation.createHTMLDocument("title")}let Bt=null;function yp(n){let e=window.trustedTypes;if(!e)return n;if(!Bt){if(Bt=e.defaultPolicy)try{return Bt.createHTML(n)}catch{}Bt=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return Bt.createHTML(n)}function Sp(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Sa(),o=t.body,i=/<([a-z][^>\s]+)/i.exec(n),r;if((r=i&&ya[i[1].toLowerCase()])&&(n=r.map(s=>"<"+s+">").join("")+n+r.map(s=>"</"+s+">").reverse().join("")),o.innerHTML=yp(n),r)for(let s=0;s<r.length;s++)o=o.querySelector(r[s])||o;for(let s=0;s<t.styleSheets.length;s++){let l=t.styleSheets[s];for(let c=0;c<l.rules.length;c++){let p=l.rules[c];if(p instanceof CSSStyleRule){let d=o.querySelectorAll(p.selectorText);for(let m=0;m<d.length;m++)d[m].style.cssText+=p.style.cssText}}}return o}function bp(n){let e=n.querySelectorAll(te?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let o=e[t];o.childNodes.length==1&&o.textContent==" "&&o.parentNode&&o.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),o)}}function kp(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,o;try{o=JSON.parse(e)}catch{return n}let{content:i,openStart:r,openEnd:s}=n;for(let l=o.length-2;l>=0;l-=2){let c=t.nodes[o[l]];if(!c||c.hasRequiredAttrs())break;try{c.checkAttrs(o[l+1])}catch{break}i=C.from(c.create(o[l+1],i)),r++,s++}return new A(i,r,s)}const le={},ce={},_p={touchstart:!0,touchmove:!0};class wp{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Tp(n){for(let e in le){let t=le[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=o=>{Cp(n,o)&&!fi(n,o)&&(n.editable||!(o.type in ce))&&t(n,o)},_p[e]?{passive:!0}:void 0)}ie&&n.dom.addEventListener("input",()=>null),ti(n)}function Ke(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Ip(n){n.input.mouseDown&&n.input.mouseDown.done(),n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function ti(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=o=>fi(n,o))})}function fi(n,e){return n.someProp("handleDOMEvents",t=>{let o=t[e.type];return o?o(n,e)||e.defaultPrevented:!1})}function Cp(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Rp(n,e){!fi(n,e)&&le[e.type]&&(n.editable||!(e.type in ce))&&le[e.type](n,e)}ce.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!wa(n)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Pe&&te&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Ot&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let o=Date.now();n.input.lastIOSEnter=o,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==o&&(n.someProp("handleKeyDown",i=>i(n,st(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",o=>o(n,t))||fp(n,t)?t.preventDefault():Ke(n,"key")};ce.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};ce.keypress=(n,e)=>{let t=e;if(wa(n)||!t.charCode||t.ctrlKey&&!t.altKey||ge&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let o=n.state.selection;if(!(o instanceof U)||!o.$from.sameParent(o.$to)){let i=String.fromCharCode(t.charCode),r=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",s=>s(n,o.$from.pos,o.$to.pos,i,r))&&n.dispatch(r()),t.preventDefault()}};function ln(n){return{left:n.clientX,top:n.clientY}}function Op(n,e){let t=e.x-n.clientX,o=e.y-n.clientY;return t*t+o*o<100}function gi(n,e,t,o,i){if(o==-1)return!1;let r=n.state.doc.resolve(o);for(let s=r.depth+1;s>0;s--)if(n.someProp(e,l=>s>r.depth?l(n,t,r.nodeAfter,r.before(s),i,!0):l(n,t,r.node(s),r.before(s),i,!1)))return!0;return!1}function cn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let o=n.state.tr.setSelection(e);o.setMeta("pointer",!0),n.dispatch(o)}function Mp(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),o=t.nodeAfter;return o&&o.isAtom&&B.isSelectable(o)?(cn(n,new B(t)),!0):!1}function vp(n,e){if(e==-1)return!1;let t=n.state.selection,o,i;t instanceof B&&(o=t.node);let r=n.state.doc.resolve(e);for(let s=r.depth+1;s>0;s--){let l=s>r.depth?r.nodeAfter:r.node(s);if(B.isSelectable(l)){o&&t.$from.depth>0&&s>=t.$from.depth&&r.before(t.$from.depth+1)==t.$from.pos?i=r.before(t.$from.depth):i=r.before(s);break}}return i!=null?(cn(n,B.create(n.state.doc,i)),!0):!1}function Ep(n,e,t,o,i){return gi(n,"handleClickOn",e,t,o)||n.someProp("handleClick",r=>r(n,e,o))||(i?vp(n,t):Mp(n,t))}function Ap(n,e,t,o){return gi(n,"handleDoubleClickOn",e,t,o)||n.someProp("handleDoubleClick",i=>i(n,e,o))}function Np(n,e,t,o){return gi(n,"handleTripleClickOn",e,t,o)||n.someProp("handleTripleClick",i=>i(n,e,o))||Dp(n,t,o)}function Dp(n,e,t){if(t.button!=0)return!1;let o=ba(n,e,!0),i=n.state.doc;return o?(cn(n,o),o instanceof U&&i.eq(n.state.doc)&&(n.input.mouseDown=new Vp(n,o)),!0):!1}function ba(n,e,t){let o=n.state.doc;if(e==-1)return o.inlineContent?U.create(o,0,o.content.size):null;let i=o.resolve(e);for(let r=i.depth+1;r>0;r--){let s=r>i.depth?i.nodeAfter:i.node(r),l=i.before(r);if(s.inlineContent)return U.create(o,l+1,l+1+s.content.size);if(t&&B.isSelectable(s))return B.create(o,l)}return null}function xi(n){return zn(n)}const ka=ge?"metaKey":"ctrlKey";le.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let o=xi(n),i=Date.now(),r="singleClick";i-n.input.lastClick.time<500&&Op(t,n.input.lastClick)&&!t[ka]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?r="doubleClick":n.input.lastClick.type=="doubleClick"&&(r="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:r,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let s=n.posAtCoords(ln(t));s&&(r=="singleClick"?n.input.mouseDown=new Bp(n,s,t,!!o):(r=="doubleClick"?Ap:Np)(n,s.pos,s.inside,t)?t.preventDefault():Ke(n,"pointer"))};class _a{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class Bp extends _a{constructor(e,t,o,i){super(e),this.pos=t,this.event=o,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!o[ka],this.allowDefault=o.shiftKey;let r,s;if(t.inside>-1)r=e.state.doc.nodeAt(t.inside),s=t.inside;else{let d=e.state.doc.resolve(t.pos);r=d.parent,s=d.depth?d.before():0}const l=i?null:o.target,c=l?e.docView.nearestDesc(l,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:p}=e.state;o.button==0&&(r.type.spec.draggable&&r.type.spec.selectable!==!1||p instanceof B&&p.from<=s&&p.to>s)&&(this.mightDrag={node:r,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ye&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),Ke(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||ze(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(ln(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ke(this.view,"pointer"):Ep(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ie&&this.mightDrag&&!this.mightDrag.node.isAtom||te&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(cn(this.view,G.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Ke(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ke(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}}class Vp extends _a{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),Ke(this.view,"pointer");let t=this.view.posAtCoords(ln(e)),o=t&&ba(this.view,t.inside,!1);if(!o)return;let{doc:i}=this.view.state,r=this.startSelection,[s,l]=o.from<r.from?[r.to,o.from]:[r.from,o.to];cn(this.view,U.create(i,s,l))}}le.touchstart=n=>{n.input.lastTouch=Date.now(),xi(n),Ke(n,"pointer")};le.touchmove=n=>{n.input.lastTouch=Date.now(),Ke(n,"pointer")};le.contextmenu=n=>xi(n);function wa(n,e){return n.composing?!0:ie&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Pp=Pe?5e3:-1;ce.compositionstart=ce.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof U&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(o=>o.type.spec.inclusive===!1)||te&&Ys&&Kp(n)))n.markCursor=n.state.storedMarks||t.marks(),zn(n,!0),n.markCursor=null;else if(zn(n,!e.selection.empty),ye&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let o=n.domSelectionRange();for(let i=o.focusNode,r=o.focusOffset;i&&i.nodeType==1&&r!=0;){let s=r<0?i.lastChild:i.childNodes[r-1];if(!s)break;if(s.nodeType==3){let l=n.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else i=s,r=-1}}n.input.composing=!0}Ta(n,Pp)};function Kp(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let o=e.childNodes[t];return o.nodeType==1&&o.contentEditable=="false"}ce.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now(),n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Ta(n,20))};function Ta(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>zn(n),e))}function Ia(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function zp(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=vu(e.focusNode,e.focusOffset),o=Eu(e.focusNode,e.focusOffset);if(t&&o&&t!=o){let i=o.pmViewDesc,r=n.domObserver.lastChangedTextNode;if(t==r||o==r)return r;if(!i||!i.isText(o.nodeValue))return o;if(n.input.compositionNode==o){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return o}}return t||o}function zn(n,e=!1){if(!(Pe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Ia(n),e||n.docView&&n.docView.dirty){let t=di(n),o=n.state.selection;return t&&!t.eq(o)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!o.$from.node(o.$from.sharedDepth(o.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Fp(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let o=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),o.removeAllRanges(),o.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Zt=ue&&He<15||Ot&&Bu<604;le.copy=ce.cut=(n,e)=>{let t=e,o=n.state.selection,i=t.type=="cut";if(o.empty)return;let r=Zt?null:t.clipboardData,s=o.content(),{dom:l,text:c}=hi(n,s);r?(t.preventDefault(),r.clearData(),r.setData("text/html",l.innerHTML),r.setData("text/plain",c)):Fp(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function qp(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Up(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,o=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),o.parentNode&&o.parentNode.removeChild(o),t?en(n,o.value,null,i,e):en(n,o.textContent,o.innerHTML,i,e)},50)}function en(n,e,t,o,i){let r=ha(n,e,t,o,n.state.selection.$from);if(n.someProp("handlePaste",c=>c(n,i,r||A.empty)))return!0;if(!r)return!1;let s=qp(r),l=s?n.state.tr.replaceSelectionWith(s,o):n.state.tr.replaceSelection(r);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Ca(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}ce.paste=(n,e)=>{let t=e;if(n.composing&&!Pe)return;let o=Zt?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;o&&en(n,Ca(o),o.getData("text/html"),i,t)?t.preventDefault():Up(n,t)};class Ra{constructor(e,t,o){this.slice=e,this.move=t,this.node=o}}const Gp=ge?"altKey":"ctrlKey";function Oa(n,e){let t;return n.someProp("dragCopies",o=>{t=t||o(e)}),t!=null?!t:!e[Gp]}le.dragstart=(n,e)=>{let t=e,o=n.input.mouseDown;if(o&&o.done(),!t.dataTransfer)return;let i=n.state.selection,r=i.empty?null:n.posAtCoords(ln(t)),s;if(!(r&&r.pos>=i.from&&r.pos<=(i instanceof B?i.to-1:i.to))){if(o&&o.mightDrag)s=B.create(n.state.doc,o.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let m=n.docView.nearestDesc(t.target,!0);m&&m.node.type.spec.draggable&&m!=n.docView&&(s=B.create(n.state.doc,m.posBefore))}}let l=(s||n.state.selection).content(),{dom:c,text:p,slice:d}=hi(n,l);(!t.dataTransfer.files.length||!te||Xs>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Zt?"Text":"text/html",c.innerHTML),t.dataTransfer.effectAllowed="copyMove",Zt||t.dataTransfer.setData("text/plain",p),n.dragging=new Ra(d,Oa(n,t),s)};le.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};ce.dragover=ce.dragenter=(n,e)=>e.preventDefault();ce.drop=(n,e)=>{try{Lp(n,e,n.dragging)}finally{n.dragging=null}};function Lp(n,e,t){if(!e.dataTransfer)return;let o=n.posAtCoords(ln(e));if(!o)return;let i=n.state.doc.resolve(o.pos),r=t&&t.slice;r?n.someProp("transformPasted",S=>{r=S(r,n,!1)}):r=ha(n,Ca(e.dataTransfer),Zt?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(t&&Oa(n,e));if(n.someProp("handleDrop",S=>S(n,e,r||A.empty,s))){e.preventDefault();return}if(!r)return;e.preventDefault();let l=r?gu(n.state.doc,i.pos,r):i.pos;l==null&&(l=i.pos);let c=n.state.tr;if(s){let{node:S}=t;S?S.replace(c):c.deleteSelection()}let p=c.mapping.map(l),d=r.openStart==0&&r.openEnd==0&&r.content.childCount==1,m=c.doc;if(d?c.replaceRangeWith(p,p,r.content.firstChild):c.replaceRange(p,p,r),c.doc.eq(m))return;let g=c.doc.resolve(p);if(d&&B.isSelectable(r.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(r.content.firstChild))c.setSelection(new B(g));else{let S=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((b,_,w,v)=>S=v),c.setSelection(mi(n,g,c.doc.resolve(S)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))}le.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&ze(n)},20))};le.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};le.beforeinput=(n,e)=>{if(Pe&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:o}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=o||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",r=>r(n,st(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in ce)le[n]=ce[n];function tn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Fn{constructor(e,t){this.toDOM=e,this.spec=t||pt,this.side=this.spec.side||0}map(e,t,o,i){let{pos:r,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new _e(r-o,r-o,this)}valid(){return!0}eq(e){return this==e||e instanceof Fn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&tn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Xe{constructor(e,t){this.attrs=e,this.spec=t||pt}map(e,t,o,i){let r=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-o,s=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-o;return r>=s?null:new _e(r,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Xe&&tn(this.attrs,e.attrs)&&tn(this.spec,e.spec)}static is(e){return e.type instanceof Xe}destroy(){}}class yi{constructor(e,t){this.attrs=e,this.spec=t||pt}map(e,t,o,i){let r=e.mapResult(t.from+i,1);if(r.deleted)return null;let s=e.mapResult(t.to+i,-1);return s.deleted||s.pos<=r.pos?null:new _e(r.pos-o,s.pos-o,this)}valid(e,t){let{index:o,offset:i}=e.content.findIndex(t.from),r;return i==t.from&&!(r=e.child(o)).isText&&i+r.nodeSize==t.to}eq(e){return this==e||e instanceof yi&&tn(this.attrs,e.attrs)&&tn(this.spec,e.spec)}destroy(){}}class _e{constructor(e,t,o){this.from=e,this.to=t,this.type=o}copy(e,t){return new _e(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,o){return this.type.map(e,this,t,o)}static widget(e,t,o){return new _e(e,e,new Fn(t,o))}static inline(e,t,o,i){return new _e(e,t,new Xe(o,i))}static node(e,t,o,i){return new _e(e,t,new yi(o,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Xe}get widget(){return this.type instanceof Fn}}const Tt=[],pt={};class J{constructor(e,t){this.local=e.length?e:Tt,this.children=t.length?t:Tt}static create(e,t){return t.length?qn(t,e,0,pt):oe}find(e,t,o){let i=[];return this.findInner(e??0,t??1e9,i,0,o),i}findInner(e,t,o,i,r){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=t&&l.to>=e&&(!r||r(l.spec))&&o.push(l.copy(l.from+i,l.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,o,i+l,r)}}map(e,t,o){return this==oe||e.maps.length==0?this:this.mapInner(e,t,0,0,o||pt)}mapInner(e,t,o,i,r){let s;for(let l=0;l<this.local.length;l++){let c=this.local[l].map(e,o,i);c&&c.type.valid(t,c)?(s||(s=[])).push(c):r.onRemove&&r.onRemove(this.local[l].spec)}return this.children.length?Wp(this.children,s||[],e,t,o,i,r):s?new J(s.sort(dt),Tt):oe}add(e,t){return t.length?this==oe?J.create(e,t):this.addInner(e,t,0):this}addInner(e,t,o){let i,r=0;e.forEach((l,c)=>{let p=c+o,d;if(d=va(t,l,p)){for(i||(i=this.children.slice());r<i.length&&i[r]<c;)r+=3;i[r]==c?i[r+2]=i[r+2].addInner(l,d,p+1):i.splice(r,0,c,c+l.nodeSize,qn(d,l,p+1,pt)),r+=3}});let s=Ma(r?Ea(t):t,-o);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new J(s.length?this.local.concat(s).sort(dt):this.local,i||this.children)}remove(e){return e.length==0||this==oe?this:this.removeInner(e,0)}removeInner(e,t){let o=this.children,i=this.local;for(let r=0;r<o.length;r+=3){let s,l=o[r]+t,c=o[r+1]+t;for(let d=0,m;d<e.length;d++)(m=e[d])&&m.from>l&&m.to<c&&(e[d]=null,(s||(s=[])).push(m));if(!s)continue;o==this.children&&(o=this.children.slice());let p=o[r+2].removeInner(s,l+1);p!=oe?o[r+2]=p:(o.splice(r,3),r-=3)}if(i.length){for(let r=0,s;r<e.length;r++)if(s=e[r])for(let l=0;l<i.length;l++)i[l].eq(s,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return o==this.children&&i==this.local?this:i.length||o.length?new J(i,o):oe}forChild(e,t){if(this==oe)return this;if(t.isLeaf)return J.empty;let o,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(o=this.children[l+2]);break}let r=e+1,s=r+t.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<s&&c.to>r&&c.type instanceof Xe){let p=Math.max(r,c.from)-r,d=Math.min(s,c.to)-r;p<d&&(i||(i=[])).push(c.copy(p,d))}}if(i){let l=new J(i.sort(dt),Tt);return o?new We([l,o]):l}return o||oe}eq(e){if(this==e)return!0;if(!(e instanceof J)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Si(this.localsInner(e))}localsInner(e){if(this==oe)return Tt;if(e.inlineContent||!this.local.some(Xe.is))return this.local;let t=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof Xe||t.push(this.local[o]);return t}forEachSet(e){e(this)}}J.empty=new J([],[]);J.removeOverlap=Si;const oe=J.empty;class We{constructor(e){this.members=e}map(e,t){const o=this.members.map(i=>i.map(e,t,pt));return We.from(o)}forChild(e,t){if(t.isLeaf)return J.empty;let o=[];for(let i=0;i<this.members.length;i++){let r=this.members[i].forChild(e,t);r!=oe&&(r instanceof We?o=o.concat(r.members):o.push(r))}return We.from(o)}eq(e){if(!(e instanceof We)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,o=!0;for(let i=0;i<this.members.length;i++){let r=this.members[i].localsInner(e);if(r.length)if(!t)t=r;else{o&&(t=t.slice(),o=!1);for(let s=0;s<r.length;s++)t.push(r[s])}}return t?Si(o?t:t.sort(dt)):Tt}static from(e){switch(e.length){case 0:return oe;case 1:return e[0];default:return new We(e.every(t=>t instanceof J)?e:e.reduce((t,o)=>t.concat(o instanceof J?o:o.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Wp(n,e,t,o,i,r,s){let l=n.slice();for(let p=0,d=r;p<t.maps.length;p++){let m=0;t.maps[p].forEach((g,S,b,_)=>{let w=_-b-(S-g);for(let v=0;v<l.length;v+=3){let L=l[v+1];if(L<0||g>L+d-m)continue;let F=l[v]+d-m;S>=F?l[v+1]=g<=F?-2:-1:g>=d&&w&&(l[v]+=w,l[v+1]+=w)}m+=w}),d=t.maps[p].map(d,-1)}let c=!1;for(let p=0;p<l.length;p+=3)if(l[p+1]<0){if(l[p+1]==-2){c=!0,l[p+1]=-1;continue}let d=t.map(n[p]+r),m=d-i;if(m<0||m>=o.content.size){c=!0;continue}let g=t.map(n[p+1]+r,-1),S=g-i,{index:b,offset:_}=o.content.findIndex(m),w=o.maybeChild(b);if(w&&_==m&&_+w.nodeSize==S){let v=l[p+2].mapInner(t,w,d+1,n[p]+r+1,s);v!=oe?(l[p]=m,l[p+1]=S,l[p+2]=v):(l[p+1]=-2,c=!0)}else c=!0}if(c){let p=$p(l,n,e,t,i,r,s),d=qn(p,o,0,s);e=d.local;for(let m=0;m<l.length;m+=3)l[m+1]<0&&(l.splice(m,3),m-=3);for(let m=0,g=0;m<d.children.length;m+=3){let S=d.children[m];for(;g<l.length&&l[g]<S;)g+=3;l.splice(g,0,d.children[m],d.children[m+1],d.children[m+2])}}return new J(e.sort(dt),l)}function Ma(n,e){if(!e||!n.length)return n;let t=[];for(let o=0;o<n.length;o++){let i=n[o];t.push(new _e(i.from+e,i.to+e,i.type))}return t}function $p(n,e,t,o,i,r,s){function l(c,p){for(let d=0;d<c.local.length;d++){let m=c.local[d].map(o,i,p);m?t.push(m):s.onRemove&&s.onRemove(c.local[d].spec)}for(let d=0;d<c.children.length;d+=3)l(c.children[d+2],c.children[d]+p+1)}for(let c=0;c<n.length;c+=3)n[c+1]==-1&&l(n[c+2],e[c]+r+1);return t}function va(n,e,t){if(e.isLeaf)return null;let o=t+e.nodeSize,i=null;for(let r=0,s;r<n.length;r++)(s=n[r])&&s.from>t&&s.to<o&&((i||(i=[])).push(s),n[r]=null);return i}function Ea(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function qn(n,e,t,o){let i=[],r=!1;e.forEach((l,c)=>{let p=va(n,l,c+t);if(p){r=!0;let d=qn(p,l,t+c+1,o);d!=oe&&i.push(c,c+l.nodeSize,d)}});let s=Ma(r?Ea(n):n,-t).sort(dt);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(o.onRemove&&o.onRemove(s[l].spec),s.splice(l--,1));return s.length||i.length?new J(s,i):oe}function dt(n,e){return n.from-e.from||n.to-e.to}function Si(n){let e=n;for(let t=0;t<e.length-1;t++){let o=e[t];if(o.from!=o.to)for(let i=t+1;i<e.length;i++){let r=e[i];if(r.from==o.from){r.to!=o.to&&(e==n&&(e=n.slice()),e[i]=r.copy(r.from,o.to),Dr(e,i+1,r.copy(o.to,r.to)));continue}else{r.from<o.to&&(e==n&&(e=n.slice()),e[t]=o.copy(o.from,r.from),Dr(e,i,o.copy(r.from,o.to)));break}}}return e}function Dr(n,e,t){for(;e<n.length&&dt(t,n[e])>0;)e++;n.splice(e,0,t)}function vo(n){let e=[];return n.someProp("decorations",t=>{let o=t(n.state);o&&o!=oe&&e.push(o)}),n.cursorWrapper&&e.push(J.create(n.state.doc,[n.cursorWrapper.deco])),We.from(e)}const jp={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Hp=ue&&He<=11;class Jp{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Qp{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Jp,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(o=>{for(let i=0;i<o.length;i++)this.queue.push(o[i]);ue&&He<=11&&o.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():ie&&e.composing&&o.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Hp&&(this.onCharData=o=>{this.queue.push({target:o.target,type:"characterData",oldValue:o.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,jp)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Rr(this.view)){if(this.suppressingSelectionUpdates)return ze(this.view);if(ue&&He<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&gt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,o;for(let r=e.focusNode;r;r=Rt(r))t.add(r);for(let r=e.anchorNode;r;r=Rt(r))if(t.has(r)){o=r;break}let i=o&&this.view.docView.nearestDesc(o);if(i&&i.ignoreMutation({type:"selection",target:o.nodeType==3?o.parentNode:o}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let o=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(o)&&Rr(e)&&!this.ignoreSelectionChange(o),r=-1,s=-1,l=!1,c=[];if(e.editable)for(let d=0;d<t.length;d++){let m=this.registerMutation(t[d],c);m&&(r=r<0?m.from:Math.min(m.from,r),s=s<0?m.to:Math.max(m.to,s),m.typeOver&&(l=!0))}if(c.some(d=>d.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||te&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(d=>d.type=="childList"&&d.removedNodes.length))){for(let d of c)if(d.nodeName=="BR"&&d.parentNode){let m=d.nextSibling;for(;m&&m.nodeType==1;){if(m.contentEditable=="false"){d.parentNode.removeChild(d);break}m=m.firstChild}}}else if(ye&&c.length){let d=c.filter(m=>m.nodeName=="BR");if(d.length==2){let[m,g]=d;m.parentNode&&m.parentNode.parentNode==g.parentNode?g.remove():m.remove()}else{let{focusNode:m}=this.currentSelection;for(let g of d){let S=g.parentNode;S&&S.nodeName=="LI"&&(!m||Zp(e,m)!=S)&&g.remove()}}}let p=null;r<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Jn(o)&&(p=di(e))&&p.eq(G.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ze(e),this.currentSelection.set(o),e.scrollToSelection()):(r>-1||i)&&(r>-1&&(e.docView.markDirty(r,s),Xp(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,ed(e,c)),this.handleDOMChange(r,s,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(o)||ze(e),this.currentSelection.set(o))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let o=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(o==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!o||o.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let m=e.addedNodes[d];t.push(m),m.nodeType==3&&(this.lastChangedTextNode=m)}if(o.contentDOM&&o.contentDOM!=o.dom&&!o.contentDOM.contains(e.target))return{from:o.posBefore,to:o.posAfter};let i=e.previousSibling,r=e.nextSibling;if(ue&&He<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:m,nextSibling:g}=e.addedNodes[d];(!m||Array.prototype.indexOf.call(e.addedNodes,m)<0)&&(i=m),(!g||Array.prototype.indexOf.call(e.addedNodes,g)<0)&&(r=g)}let s=i&&i.parentNode==e.target?Z(i)+1:0,l=o.localPosFromDOM(e.target,s,-1),c=r&&r.parentNode==e.target?Z(r):e.target.childNodes.length,p=o.localPosFromDOM(e.target,c,1);return{from:l,to:p}}else return e.type=="attributes"?{from:o.posAtStart-o.border,to:o.posAtEnd+o.border}:(this.lastChangedTextNode=e.target,{from:o.posAtStart,to:o.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Br=new WeakMap,Vr=!1;function Xp(n){if(!Br.has(n)&&(Br.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=ye,Vr)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Vr=!0}}function Pr(n,e){let t=e.startContainer,o=e.startOffset,i=e.endContainer,r=e.endOffset,s=n.domAtPos(n.state.selection.anchor);return gt(s.node,s.offset,i,r)&&([t,o,i,r]=[i,r,t,o]),{anchorNode:t,anchorOffset:o,focusNode:i,focusOffset:r}}function Yp(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return Pr(n,i)}let t;function o(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",o,!0),t?Pr(n,t):null}function Zp(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let o=n.docView.nearestDesc(t,!0);if(o&&o.node.isBlock)return t}return null}function ed(n,e){var t;let{focusNode:o,focusOffset:i}=n.domSelectionRange();for(let r of e)if(((t=r.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let s=r.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let c=l.firstChild;if(!c||c.nodeType!=1||c.contentEditable=="false"||/^(BR|IMG)$/.test(c.nodeName))break;l=c}l.insertBefore(r,l.firstChild),o==r&&n.domSelection().collapse(r,i)}else r.parentNode.removeChild(r)}}function td(n,e,t,o){let{node:i,fromOffset:r,toOffset:s,from:l,to:c}=n.docView.parseRange(e,t),p=n.domSelectionRange(),d,m=p.anchorNode;if(m&&n.dom.contains(m.nodeType==1?m:m.parentNode)&&(d=[{node:m,offset:p.anchorOffset}],Jn(p)||d.push({node:p.focusNode,offset:p.focusOffset})),te&&n.input.lastKeyCode===8)for(let v=s;v>r;v--){let L=i.childNodes[v-1],F=L.pmViewDesc;if(L.nodeName=="BR"&&!F){s=v;break}if(!F||F.size)break}let g=n.state.doc,S=n.someProp("domParser")||Jt.fromSchema(n.state.schema),b=g.resolve(l),_=null,w=S.parse(i,{topNode:b.parent,topMatch:b.parent.contentMatchAt(b.index()),topOpen:!0,from:r,to:s,preserveWhitespace:b.parent.type.whitespace=="pre"?"full":!0,findPositions:d,ruleFromNode:nd(o),context:b});if(d&&d[0].pos!=null){let v=d[0].pos,L=d[1]&&d[1].pos;L==null&&(L=v),_={anchor:v+l,head:L+l}}return{doc:w,sel:_,from:l,to:c}}const nd=n=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(n);if(e.nodeName=="BR"&&e.parentNode){if(ie&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let o=document.createElement("div");return o.appendChild(document.createElement("li")),{skip:o}}else if(e.parentNode.lastChild==e||ie&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},od=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function id(n,e,t,o,i){let r=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let R=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,T=di(n,R);if(T&&!n.state.selection.eq(T)){if(te&&Pe&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",pe=>pe(n,st(13,"Enter"))))return;let D=n.state.tr.setSelection(T);R=="pointer"?D.setMeta("pointer",!0):R=="key"&&D.scrollIntoView(),r&&D.setMeta("composition",r),n.dispatch(D)}return}let s=n.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=n.state.doc.resolve(t).after(l+1);let c=n.state.selection,p=td(n,e,t,i),d=n.state.doc,m=d.slice(p.from,p.to),g,S;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(g=n.state.selection.to,S="end"):(g=n.state.selection.from,S="start"),n.input.lastKeyCode=null;let b=ad(m.content,p.doc.content,p.from,g,S);if(b&&n.input.domChangeCount++,(Ot&&n.input.lastIOSEnter>Date.now()-225||Pe)&&i.some(R=>R.nodeType==1&&!od.test(R.nodeName))&&(!b||b.endA>=b.endB)&&n.someProp("handleKeyDown",R=>R(n,st(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!b)if(o&&c instanceof U&&!c.empty&&c.$head.sameParent(c.$anchor)&&!n.composing&&!(p.sel&&p.sel.anchor!=p.sel.head))b={start:c.from,endA:c.to,endB:c.to};else{if(p.sel){let R=Kr(n,n.state.doc,p.sel);if(R&&!R.eq(n.state.selection)){let T=n.state.tr.setSelection(R);r&&T.setMeta("composition",r),n.dispatch(T)}}return}n.state.selection.from<n.state.selection.to&&b.start==b.endB&&n.state.selection instanceof U&&(b.start>n.state.selection.from&&b.start<=n.state.selection.from+2&&n.state.selection.from>=p.from?b.start=n.state.selection.from:b.endA<n.state.selection.to&&b.endA>=n.state.selection.to-2&&n.state.selection.to<=p.to&&(b.endB+=n.state.selection.to-b.endA,b.endA=n.state.selection.to)),ue&&He<=11&&b.endB==b.start+1&&b.endA==b.start&&b.start>p.from&&p.doc.textBetween(b.start-p.from-1,b.start-p.from+1)=="  "&&(b.start--,b.endA--,b.endB--);let _=p.doc.resolveNoCache(b.start-p.from),w=p.doc.resolveNoCache(b.endB-p.from),v=d.resolve(b.start),L=_.sameParent(w)&&_.parent.inlineContent&&v.end()>=b.endA;if((Ot&&n.input.lastIOSEnter>Date.now()-225&&(!L||i.some(R=>R.nodeName=="DIV"||R.nodeName=="P"))||!L&&_.pos<p.doc.content.size&&(!_.sameParent(w)||!_.parent.inlineContent)&&_.pos<w.pos&&!/\S/.test(p.doc.textBetween(_.pos,w.pos,"","")))&&n.someProp("handleKeyDown",R=>R(n,st(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>b.start&&sd(d,b.start,b.endA,_,w)&&n.someProp("handleKeyDown",R=>R(n,st(8,"Backspace")))){Pe&&te&&n.domObserver.suppressSelectionUpdates();return}te&&b.endB==b.start&&(n.input.lastChromeDelete=Date.now()),Pe&&!L&&_.start()!=w.start()&&w.parentOffset==0&&_.depth==w.depth&&p.sel&&p.sel.anchor==p.sel.head&&p.sel.head==b.endA&&(b.endB-=2,w=p.doc.resolveNoCache(b.endB-p.from),setTimeout(()=>{n.someProp("handleKeyDown",function(R){return R(n,st(13,"Enter"))})},20));let F=b.start,ne=b.endA,O=R=>{let T=R||n.state.tr.replace(F,ne,p.doc.slice(b.start-p.from,b.endB-p.from));if(p.sel){let D=Kr(n,T.doc,p.sel);D&&!(te&&n.composing&&D.empty&&(b.start!=b.endB||n.input.lastChromeDelete<Date.now()-100)&&(D.head==F||D.head==T.mapping.map(ne)-1)||ue&&D.empty&&D.head==F)&&T.setSelection(D)}return r&&T.setMeta("composition",r),T.scrollIntoView()},I;if(L)if(_.pos==w.pos){ue&&He<=11&&_.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>ze(n),20));let R=O(n.state.tr.delete(F,ne)),T=d.resolve(b.start).marksAcross(d.resolve(b.endA));T&&R.ensureMarks(T),n.dispatch(R)}else if(b.endA==b.endB&&(I=rd(_.parent.content.cut(_.parentOffset,w.parentOffset),v.parent.content.cut(v.parentOffset,b.endA-v.start())))){let R=O(n.state.tr);I.type=="add"?R.addMark(F,ne,I.mark):R.removeMark(F,ne,I.mark),n.dispatch(R)}else if(_.parent.child(_.index()).isText&&_.index()==w.index()-(w.textOffset?0:1)){let R=_.parent.textBetween(_.parentOffset,w.parentOffset),T=()=>O(n.state.tr.insertText(R,F,ne));n.someProp("handleTextInput",D=>D(n,F,ne,R,T))||n.dispatch(T())}else n.dispatch(O());else n.dispatch(O())}function Kr(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:mi(n,e.resolve(t.anchor),e.resolve(t.head))}function rd(n,e){let t=n.firstChild.marks,o=e.firstChild.marks,i=t,r=o,s,l,c;for(let d=0;d<o.length;d++)i=o[d].removeFromSet(i);for(let d=0;d<t.length;d++)r=t[d].removeFromSet(r);if(i.length==1&&r.length==0)l=i[0],s="add",c=d=>d.mark(l.addToSet(d.marks));else if(i.length==0&&r.length==1)l=r[0],s="remove",c=d=>d.mark(l.removeFromSet(d.marks));else return null;let p=[];for(let d=0;d<e.childCount;d++)p.push(c(e.child(d)));if(C.from(p).eq(n))return{mark:l,type:s}}function sd(n,e,t,o,i){if(t-e<=i.pos-o.pos||Eo(o,!0,!1)<i.pos)return!1;let r=n.resolve(e);if(!o.parent.isTextblock){let l=r.nodeAfter;return l!=null&&t==e+l.nodeSize}if(r.parentOffset<r.parent.content.size||!r.parent.isTextblock)return!1;let s=n.resolve(Eo(r,!0,!0));return!s.parent.isTextblock||s.pos>t||Eo(s,!0,!1)<t?!1:o.parent.content.cut(o.parentOffset).eq(s.parent.content)}function Eo(n,e,t){let o=n.depth,i=e?n.end():n.pos;for(;o>0&&(e||n.indexAfter(o)==n.node(o).childCount);)o--,i++,e=!1;if(t){let r=n.node(o).maybeChild(n.indexAfter(o));for(;r&&!r.isLeaf;)r=r.firstChild,i++}return i}function ad(n,e,t,o,i){let r=n.findDiffStart(e,t),s=t+n.size,l=t+e.size;if(r==null)return null;let{a:c,b:p}=n.findDiffEnd(e,s,l);if(i=="end"){let d=Math.max(0,r-Math.min(c,p));o-=c+d-r}if(c<r&&s<l){let d=o<=r&&o>=c?r-o:0;r-=d,p=r+(p-c),c=r}else if(p<r){let d=o<=r&&o>=p?r-o:0;r-=d,c=r+(c-p),p=r}return{start:r,endA:c,endB:p}}class ld{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new wp,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Gr),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=qr(this),Fr(this),this.nodeViews=Ur(this),this.docView=kr(this.state.doc,zr(this),vo(this),this.dom,this),this.domObserver=new Qp(this,(o,i,r,s)=>id(this,o,i,r,s)),this.domObserver.start(),Tp(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ti(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Gr),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let o in this._props)t[o]=this._props[o];t.state=this.state;for(let o in e)t[o]=e[o];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var o;let i=this.state,r=!1,s=!1;e.storedMarks&&this.composing&&(Ia(this),s=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let S=Ur(this);ud(S,this.nodeViews)&&(this.nodeViews=S,r=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&ti(this),this.editable=qr(this),Fr(this);let c=vo(this),p=zr(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",m=r||!this.docView.matchesNode(e.doc,p,c);(m||!e.selection.eq(i.selection))&&(s=!0);let g=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Ku(this);if(s){this.domObserver.stop();let S=m&&(ue||te)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&cd(i.selection,e.selection);if(m){let _=te?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=zp(this)),(r||!this.docView.update(e.doc,p,c,this))&&(this.docView.updateOuterDeco(p),this.docView.destroy(),this.docView=kr(e.doc,p,c,this.dom,this)),_&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(S=!0)}let b=this.input.mouseDown;S||!(b&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&lp(this)&&b.delaySelUpdate())?ze(this,S):(pa(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((o=this.dragging)===null||o===void 0)&&o.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():g&&zu(g)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof B){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&gr(this,t.getBoundingClientRect(),e)}else gr(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let o=this.directPlugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let o=this.state.plugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let o=this.pluginViews[t];o.update&&o.update(this,e)}}updateDraggedNode(e,t){let o=e.node,i=-1;if(o.from<this.state.doc.content.size&&this.state.doc.nodeAt(o.from)==o.node)i=o.from;else{let r=o.from+(this.state.doc.content.size-t.doc.content.size);(r>0&&r<this.state.doc.content.size&&this.state.doc.nodeAt(r))==o.node&&(i=r)}this.dragging=new Ra(e.slice,e.move,i<0?void 0:B.create(this.state.doc,i))}someProp(e,t){let o=this._props&&this._props[e],i;if(o!=null&&(i=t?t(o):o))return i;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(i=t?t(l):l))return i}let r=this.state.plugins;if(r)for(let s=0;s<r.length;s++){let l=r[s].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(ue){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Fu(this.dom),ze(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Wu(this,e)}coordsAtPos(e,t=1){return oa(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,o=-1){let i=this.docView.posFromDOM(e,t,o);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return Qu(this,t||this.state,e)}pasteHTML(e,t){return en(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return en(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return hi(this,e)}destroy(){this.docView&&(Ip(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],vo(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ou())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Rp(this,e)}domSelectionRange(){let e=this.domSelection();return e?ie&&this.root.nodeType===11&&Nu(this.dom.ownerDocument)==this.dom&&Yp(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}ld.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function zr(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let o in t)o=="class"?e.class+=" "+t[o]:o=="style"?e.style=(e.style?e.style+";":"")+t[o]:!e[o]&&o!="contenteditable"&&o!="nodeName"&&(e[o]=String(t[o]))}),e.translate||(e.translate="no"),[_e.node(0,n.state.doc.content.size,e)]}function Fr(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:_e.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function qr(n){return!n.someProp("editable",e=>e(n.state)===!1)}function cd(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Ur(n){let e=Object.create(null);function t(o){for(let i in o)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=o[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function ud(n,e){let t=0,o=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)o++;return t!=o}function Gr(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}const Aa=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function pd(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const dd=(n,e,t)=>{let o=pd(n,t);if(!o)return!1;let i=Na(o);if(!i){let s=o.blockRange(),l=s&&li(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let r=i.nodeBefore;if(Ba(n,i,e,-1))return!0;if(o.parent.content.size==0&&(Mt(r,"end")||B.isSelectable(r)))for(let s=o.depth;;s--){let l=ci(n.doc,o.before(s),o.after(s),A.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=n.tr.step(l);c.setSelection(Mt(r,"end")?G.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):B.create(c.doc,i.pos-r.nodeSize)),e(c.scrollIntoView())}return!0}if(s==1||o.node(s-1).childCount>1)break}return r.isAtom&&i.depth==o.depth-1?(e&&e(n.tr.delete(i.pos-r.nodeSize,i.pos).scrollIntoView()),!0):!1};function Mt(n,e,t=!1){for(let o=n;o;o=e=="start"?o.firstChild:o.lastChild){if(o.isTextblock)return!0;if(t&&o.childCount!=1)return!1}return!1}const md=(n,e,t)=>{let{$head:o,empty:i}=n.selection,r=o;if(!i)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):o.parentOffset>0)return!1;r=Na(o)}let s=r&&r.nodeBefore;return!s||!B.isSelectable(s)?!1:(e&&e(n.tr.setSelection(B.create(n.doc,r.pos-s.nodeSize)).scrollIntoView()),!0)};function Na(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function hd(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const fd=(n,e,t)=>{let o=hd(n,t);if(!o)return!1;let i=Da(o);if(!i)return!1;let r=i.nodeAfter;if(Ba(n,i,e,1))return!0;if(o.parent.content.size==0&&(Mt(r,"start")||B.isSelectable(r))){let s=ci(n.doc,o.before(),o.after(),A.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=n.tr.step(s);l.setSelection(Mt(r,"start")?G.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):B.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return r.isAtom&&i.depth==o.depth-1?(e&&e(n.tr.delete(i.pos,i.pos+r.nodeSize).scrollIntoView()),!0):!1},gd=(n,e,t)=>{let{$head:o,empty:i}=n.selection,r=o;if(!i)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):o.parentOffset<o.parent.content.size)return!1;r=Da(o)}let s=r&&r.nodeAfter;return!s||!B.isSelectable(s)?!1:(e&&e(n.tr.setSelection(B.create(n.doc,r.pos)).scrollIntoView()),!0)};function Da(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const xd=(n,e)=>{let{$head:t,$anchor:o}=n.selection;return!t.parent.type.spec.code||!t.sameParent(o)?!1:(e&&e(n.tr.insertText(`
10
+ `).scrollIntoView()),!0)};function bi(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const yd=(n,e)=>{let{$head:t,$anchor:o}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(o))return!1;let i=t.node(-1),r=t.indexAfter(-1),s=bi(i.contentMatchAt(r));if(!s||!i.canReplaceWith(r,r,s))return!1;if(e){let l=t.after(),c=n.tr.replaceWith(l,l,s.createAndFill());c.setSelection(G.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},Sd=(n,e)=>{let t=n.selection,{$from:o,$to:i}=t;if(t instanceof he||o.parent.inlineContent||i.parent.inlineContent)return!1;let r=bi(i.parent.contentMatchAt(i.indexAfter()));if(!r||!r.isTextblock)return!1;if(e){let s=(!o.parentOffset&&i.index()<i.parent.childCount?o:i).pos,l=n.tr.insert(s,r.createAndFill());l.setSelection(U.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},bd=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let r=t.before();if(An(n.doc,r))return e&&e(n.tr.split(r).scrollIntoView()),!0}let o=t.blockRange(),i=o&&li(o);return i==null?!1:(e&&e(n.tr.lift(o,i).scrollIntoView()),!0)};function kd(n){return(e,t)=>{if(e.selection instanceof B&&e.selection.node.isBlock){let{$from:S}=e.selection;return!S.parentOffset||!An(e.doc,S.pos)?!1:(t&&t(e.tr.split(S.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let o=e.tr;!e.selection.empty&&(e.selection instanceof U||e.selection instanceof he)&&o.deleteSelection();let{$from:i}=o.selection,r=o.steps.length,s=[],l,c,p=!1,d=!1;for(let S=i.depth;;S--)if(i.node(S).isBlock){p=i.end(S)==i.pos+(i.depth-S),d=i.start(S)==i.pos-(i.depth-S),c=bi(i.node(S-1).contentMatchAt(i.indexAfter(S-1))),s.unshift(p&&c?{type:c}:null),l=S;break}else{if(S==1)return!1;s.unshift(null)}let m=i.pos,g=An(o.doc,m,s.length,s);if(g||(s[0]=c?{type:c}:null,g=An(o.doc,m,s.length,s)),!g)return!1;if(o.split(m,s.length,s),!p&&d&&i.node(l).type!=c){let S=o.mapping.slice(r),b=S.map(i.before(l)),_=o.doc.resolve(b);c&&i.node(l-1).canReplaceWith(_.index(),_.index()+1,c)&&o.setNodeMarkup(S.map(i.before(l)),c)}return t&&t(o.scrollIntoView()),!0}}const _d=kd(),wd=(n,e)=>(e&&e(n.tr.setSelection(new he(n.doc))),!0);function Td(n,e,t){let o=e.nodeBefore,i=e.nodeAfter,r=e.index();return!o||!i||!o.type.compatibleContent(i.type)?!1:!o.content.size&&e.parent.canReplace(r-1,r)?(t&&t(n.tr.delete(e.pos-o.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(r,r+1)||!(i.isTextblock||qs(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Ba(n,e,t,o){let i=e.nodeBefore,r=e.nodeAfter,s,l,c=i.type.spec.isolating||r.type.spec.isolating;if(!c&&Td(n,e,t))return!0;let p=!c&&e.parent.canReplace(e.index(),e.index()+1);if(p&&(s=(l=i.contentMatchAt(i.childCount)).findWrapping(r.type))&&l.matchType(s[0]||r.type).validEnd){if(t){let S=e.pos+r.nodeSize,b=C.empty;for(let v=s.length-1;v>=0;v--)b=C.from(s[v].create(null,b));b=C.from(i.copy(b));let _=n.tr.step(new me(e.pos-1,S,e.pos,S,new A(b,1,0),s.length,!0)),w=_.doc.resolve(S+2*s.length);w.nodeAfter&&w.nodeAfter.type==i.type&&qs(_.doc,w.pos)&&_.join(w.pos),t(_.scrollIntoView())}return!0}let d=r.type.spec.isolating||o>0&&c?null:G.findFrom(e,1),m=d&&d.$from.blockRange(d.$to),g=m&&li(m);if(g!=null&&g>=e.depth)return t&&t(n.tr.lift(m,g).scrollIntoView()),!0;if(p&&Mt(r,"start",!0)&&Mt(i,"end")){let S=i,b=[];for(;b.push(S),!S.isTextblock;)S=S.lastChild;let _=r,w=1;for(;!_.isTextblock;_=_.firstChild)w++;if(S.canReplace(S.childCount,S.childCount,_.content)){if(t){let v=C.empty;for(let F=b.length-1;F>=0;F--)v=C.from(b[F].copy(v));let L=n.tr.step(new me(e.pos-b.length,e.pos+r.nodeSize,e.pos+w,e.pos+r.nodeSize-w,new A(v,b.length,0),0,!0));t(L.scrollIntoView())}return!0}}return!1}function Va(n){return function(e,t){let o=e.selection,i=n<0?o.$from:o.$to,r=i.depth;for(;i.node(r).isInline;){if(!r)return!1;r--}return i.node(r).isTextblock?(t&&t(e.tr.setSelection(U.create(e.doc,n<0?i.start(r):i.end(r)))),!0):!1}}const Id=Va(-1),Cd=Va(1);function ki(...n){return function(e,t,o){for(let i=0;i<n.length;i++)if(n[i](e,t,o))return!0;return!1}}let Ao=ki(Aa,dd,md),Lr=ki(Aa,fd,gd);const Ve={Enter:ki(xd,Sd,bd,_d),"Mod-Enter":yd,Backspace:Ao,"Mod-Backspace":Ao,"Shift-Backspace":Ao,Delete:Lr,"Mod-Delete":Lr,"Mod-a":wd},Pa={"Ctrl-h":Ve.Backspace,"Alt-Backspace":Ve["Mod-Backspace"],"Ctrl-d":Ve.Delete,"Ctrl-Alt-Backspace":Ve["Mod-Delete"],"Alt-Delete":Ve["Mod-Delete"],"Alt-d":Ve["Mod-Delete"],"Ctrl-a":Id,"Ctrl-e":Cd};for(let n in Ve)Pa[n]=Ve[n];const Rd=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,wk=Rd?Pa:Ve;var Un=200,Q=function(){};Q.prototype.append=function(e){return e.length?(e=Q.from(e),!this.length&&e||e.length<Un&&this.leafAppend(e)||this.length<Un&&e.leafPrepend(this)||this.appendInner(e)):this};Q.prototype.prepend=function(e){return e.length?Q.from(e).append(this):this};Q.prototype.appendInner=function(e){return new Od(this,e)};Q.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Q.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};Q.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Q.prototype.forEach=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length),t<=o?this.forEachInner(e,t,o,0):this.forEachInvertedInner(e,t,o,0)};Q.prototype.map=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length);var i=[];return this.forEach(function(r,s){return i.push(e(r,s))},t,o),i};Q.from=function(e){return e instanceof Q?e:e&&e.length?new Ka(e):Q.empty};var Ka=(function(n){function e(o){n.call(this),this.values=o}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,r){return i==0&&r==this.length?this:new e(this.values.slice(i,r))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,r,s,l){for(var c=r;c<s;c++)if(i(this.values[c],l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(i,r,s,l){for(var c=r-1;c>=s;c--)if(i(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Un)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Un)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(Q);Q.empty=new Ka([]);var Od=(function(n){function e(t,o){n.call(this),this.left=t,this.right=o,this.length=t.length+o.length,this.depth=Math.max(t.depth,o.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(o){return o<this.left.length?this.left.get(o):this.right.get(o-this.left.length)},e.prototype.forEachInner=function(o,i,r,s){var l=this.left.length;if(i<l&&this.left.forEachInner(o,i,Math.min(r,l),s)===!1||r>l&&this.right.forEachInner(o,Math.max(i-l,0),Math.min(this.length,r)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,r,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(o,i-l,Math.max(r,l)-l,s+l)===!1||r<l&&this.left.forEachInvertedInner(o,Math.min(i,l),r,s)===!1)return!1},e.prototype.sliceInner=function(o,i){if(o==0&&i==this.length)return this;var r=this.left.length;return i<=r?this.left.slice(o,i):o>=r?this.right.slice(o-r,i-r):this.left.slice(o,r).append(this.right.slice(0,i-r))},e.prototype.leafAppend=function(o){var i=this.right.leafAppend(o);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(o){var i=this.left.leafPrepend(o);if(i)return new e(i,this.right)},e.prototype.appendInner=function(o){return this.left.depth>=Math.max(this.right.depth,o.depth)+1?new e(this.left,new e(this.right,o)):new e(this,o)},e})(Q);const Md=500;class ke{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let o=this.items.length;for(;;o--)if(this.items.get(o-1).selection){--o;break}let i,r;t&&(i=this.remapping(o,this.items.length),r=i.maps.length);let s=e.tr,l,c,p=[],d=[];return this.items.forEach((m,g)=>{if(!m.step){i||(i=this.remapping(o,g+1),r=i.maps.length),r--,d.push(m);return}if(i){d.push(new Ce(m.map));let S=m.step.map(i.slice(r)),b;S&&s.maybeStep(S).doc&&(b=s.mapping.maps[s.mapping.maps.length-1],p.push(new Ce(b,void 0,void 0,p.length+d.length))),r--,b&&i.appendMap(b,r)}else s.maybeStep(m.step);if(m.selection)return l=i?m.selection.map(i.slice(r)):m.selection,c=new ke(this.items.slice(0,o).append(d.reverse().concat(p)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:s,selection:l}}addTransform(e,t,o,i){let r=[],s=this.eventCount,l=this.items,c=!i&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let m=e.steps[d].invert(e.docs[d]),g=new Ce(e.mapping.maps[d],m,t),S;(S=c&&c.merge(g))&&(g=S,d?r.pop():l=l.slice(0,l.length-1)),r.push(g),t&&(s++,t=void 0),i||(c=g)}let p=s-o.depth;return p>Ed&&(l=vd(l,p),s-=p),new ke(l.append(r),s)}remapping(e,t){let o=new Xt;return this.items.forEach((i,r)=>{let s=i.mirrorOffset!=null&&r-i.mirrorOffset>=e?o.maps.length-i.mirrorOffset:void 0;o.appendMap(i.map,s)},e,t),o}addMaps(e){return this.eventCount==0?this:new ke(this.items.append(e.map(t=>new Ce(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let o=[],i=Math.max(0,this.items.length-t),r=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(g=>{g.selection&&l--},i);let c=t;this.items.forEach(g=>{let S=r.getMirror(--c);if(S==null)return;s=Math.min(s,S);let b=r.maps[S];if(g.step){let _=e.steps[S].invert(e.docs[S]),w=g.selection&&g.selection.map(r.slice(c+1,S));w&&l++,o.push(new Ce(b,_,w))}else o.push(new Ce(b))},i);let p=[];for(let g=t;g<s;g++)p.push(new Ce(r.maps[g]));let d=this.items.slice(0,i).append(p).append(o),m=new ke(d,l);return m.emptyItemCount()>Md&&(m=m.compress(this.items.length-o.length)),m}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),o=t.maps.length,i=[],r=0;return this.items.forEach((s,l)=>{if(l>=e)i.push(s),s.selection&&r++;else if(s.step){let c=s.step.map(t.slice(o)),p=c&&c.getMap();if(o--,p&&t.appendMap(p,o),c){let d=s.selection&&s.selection.map(t.slice(o));d&&r++;let m=new Ce(p.invert(),c,d),g,S=i.length-1;(g=i.length&&i[S].merge(m))?i[S]=g:i.push(m)}}else s.map&&o--},this.items.length,0),new ke(Q.from(i.reverse()),r)}}ke.empty=new ke(Q.empty,0);function vd(n,e){let t;return n.forEach((o,i)=>{if(o.selection&&e--==0)return t=i,!1}),n.slice(t)}class Ce{constructor(e,t,o,i){this.map=e,this.step=t,this.selection=o,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Ce(t.getMap().invert(),t,this.selection)}}}class Le{constructor(e,t,o,i,r){this.done=e,this.undone=t,this.prevRanges=o,this.prevTime=i,this.prevComposition=r}}const Ed=20;function Ad(n,e,t,o){let i=t.getMeta(mt),r;if(i)return i.historyState;t.getMeta(za)&&(n=new Le(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(mt))return s.getMeta(mt).redo?new Le(n.done.addTransform(t,void 0,o,Nn(e)),n.undone,Wr(t.mapping.maps),n.prevTime,n.prevComposition):new Le(n.done,n.undone.addTransform(t,void 0,o,Nn(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),c=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-o.newGroupDelay||!Nd(t,n.prevRanges)),p=s?No(n.prevRanges,t.mapping):Wr(t.mapping.maps);return new Le(n.done.addTransform(t,c?e.selection.getBookmark():void 0,o,Nn(e)),ke.empty,p,t.time,l??n.prevComposition)}else return(r=t.getMeta("rebased"))?new Le(n.done.rebased(t,r),n.undone.rebased(t,r),No(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Le(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),No(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Nd(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((o,i)=>{for(let r=0;r<e.length;r+=2)o<=e[r+1]&&i>=e[r]&&(t=!0)}),t}function Wr(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((o,i,r,s)=>e.push(r,s));return e}function No(n,e){if(!n)return null;let t=[];for(let o=0;o<n.length;o+=2){let i=e.map(n[o],1),r=e.map(n[o+1],-1);i<=r&&t.push(i,r)}return t}function Dd(n,e,t){let o=Nn(e),i=mt.get(e).spec.config,r=(t?n.undone:n.done).popEvent(e,o);if(!r)return null;let s=r.selection.resolve(r.transform.doc),l=(t?n.done:n.undone).addTransform(r.transform,e.selection.getBookmark(),i,o),c=new Le(t?l:r.remaining,t?r.remaining:l,null,0,-1);return r.transform.setSelection(s).setMeta(mt,{redo:t,historyState:c})}let Do=!1,$r=null;function Nn(n){let e=n.plugins;if($r!=e){Do=!1,$r=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Do=!0;break}}return Do}function Tk(n){return n.setMeta(za,!0)}const mt=new Js("history"),za=new Js("closeHistory");function Ik(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new js({key:mt,state:{init(){return new Le(ke.empty,ke.empty,null,0,-1)},apply(e,t,o){return Ad(t,o,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let o=t.inputType,i=o=="historyUndo"?Bd:o=="historyRedo"?Vd:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function Fa(n,e){return(t,o)=>{let i=mt.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(o){let r=Dd(i,t,n);r&&o(e?r.scrollIntoView():r)}return!0}}const Bd=Fa(!1,!0),Vd=Fa(!0,!0);var Ye={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Gn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Pd=typeof navigator<"u"&&/Mac/.test(navigator.platform),Kd=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ee=0;ee<10;ee++)Ye[48+ee]=Ye[96+ee]=String(ee);for(var ee=1;ee<=24;ee++)Ye[ee+111]="F"+ee;for(var ee=65;ee<=90;ee++)Ye[ee]=String.fromCharCode(ee+32),Gn[ee]=String.fromCharCode(ee);for(var Bo in Ye)Gn.hasOwnProperty(Bo)||(Gn[Bo]=Ye[Bo]);function zd(n){var e=Pd&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Kd&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Gn:Ye)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const Fd=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),qd=typeof navigator<"u"&&/Win/.test(navigator.platform);function Ud(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let o,i,r,s;for(let l=0;l<e.length-1;l++){let c=e[l];if(/^(cmd|meta|m)$/i.test(c))s=!0;else if(/^a(lt)?$/i.test(c))o=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))r=!0;else if(/^mod$/i.test(c))Fd?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return o&&(t="Alt-"+t),i&&(t="Ctrl-"+t),s&&(t="Meta-"+t),r&&(t="Shift-"+t),t}function Gd(n){let e=Object.create(null);for(let t in n)e[Ud(t)]=n[t];return e}function Vo(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Ck(n){return new js({props:{handleKeyDown:Ld(n)}})}function Ld(n){let e=Gd(n);return function(t,o){let i=zd(o),r,s=e[Vo(i,o)];if(s&&s(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(o.shiftKey){let l=e[Vo(i,o,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((o.altKey||o.metaKey||o.ctrlKey)&&!(qd&&o.ctrlKey&&o.altKey)&&(r=Ye[o.keyCode])&&r!=i){let l=e[Vo(r,o)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const Rk=28,qa=[{column:"notebook_id",type:"TEXT"},{column:"cell_id",type:"TEXT"},{column:"type",type:"TEXT"},{column:"label",type:"TEXT"},{column:"grid_row",type:"INTEGER"},{column:"grid_column",type:"INTEGER"},{column:"output_entity_id",type:"TEXT"},{column:"prompt",type:"TEXT"},{column:"provider",type:"TEXT"},{column:"model",type:"TEXT"},{column:"operation",type:"TEXT"},{column:"tool",type:"TEXT"},{column:"inputs_json",type:"TEXT"},{column:"output_artifact_id",type:"TEXT"}];qa.map(({column:n})=>n);function Ok(n,e){const t={notebook_id:n,cell_id:e.id,type:e.type,label:e.label??null,grid_row:e.slot.row,grid_column:e.slot.column,output_entity_id:e.outputEntityId??null,prompt:e.prompt??null,provider:e.provider??null,model:e.model??null,operation:e.operation??null,tool:e.tool??null,inputs_json:JSON.stringify(e.inputs??{}),output_artifact_id:e.outputArtifactId??null};return qa.map(({column:o,type:i})=>({column:o,type:i,value:t[o]}))}const Wd=a().regex(/^kling(?:-\d+(?:\.\d+)*)?\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,"Expected a listed model or a kie Kling alias (e.g. kling-3.5/video)"),$d=a().regex(/^kling-\d+(?:\.\d+)*-omni\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,"Expected a listed model or a kie Kling Omni alias (e.g. kling-3.5-omni/text-to-video)"),jd=a().regex(/^grok-imagine(?:\/|-)[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,"Expected a listed model or a kie Grok Imagine alias (e.g. grok-imagine/text-to-audio)"),Hd=a().regex(/^nano-banana-[a-z0-9]+(?:-[a-z0-9]+)*$/,"Expected a listed model or a kie Nano Banana alias (e.g. nano-banana-3)"),Jd=a().regex(/^gpt-image(?:\/|-)\d+(?:[.-]\d+)*(?:-[a-z][a-z0-9]*)*-(?:text|image)-to-image$/,"Expected a listed model or a kie GPT Image alias (e.g. gpt-image-3-text-to-image)"),Qd=a().regex(/^seedream\/\d+(?:\.\d+)*(?:-[a-z][a-z0-9]*)+$/,"Expected a listed model or a kie Seedream alias (e.g. seedream/6-pro-text-to-image)"),Xd=a().regex(/^qwen\d+(?:[.-]\d+)*\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,"Expected a listed model or a kie Qwen alias (e.g. qwen2-1/image-to-image)"),Yd=a().regex(/^bytedance\/seedance-\d+(?:\.\d+)*(?:-[a-z][a-z0-9]*)*$/,"Expected a listed model or a kie Seedance alias (e.g. bytedance/seedance-3)"),Zd=a().regex(/^wan\/\d+(?:-\d+)*-[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,"Expected a listed model or a kie Wan alias (e.g. wan/2-8-image-to-video)"),em=a().regex(/^happyhorse(?:-\d+(?:-\d+)*)?\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,"Expected a listed model or a kie HappyHorse alias (e.g. happyhorse-2-0/text-to-video)"),tm=a().regex(/^elevenlabs\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,"Expected a listed model or a kie ElevenLabs alias (e.g. elevenlabs/text-to-speech-flash-v3)"),nm=a().regex(/^pixverse-v\d+(?:\.\d+)*\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,"Expected a listed model or a kie PixVerse alias (e.g. pixverse-v7/text-to-video)"),om=["kling-3.0/video","kling-3.0/motion-control","kling/v3-turbo-image-to-video","kling/v3-turbo-text-to-video","kling-2.6/image-to-video","kling-2.6/motion-control","kling-2.6/text-to-video","kling/ai-avatar-pro","kling/ai-avatar-standard","kling/v2-1-master-image-to-video","kling/v2-1-master-text-to-video","kling/v2-1-pro","kling/v2-1-standard","kling/v2-5-turbo-image-to-video-pro","kling/v2-5-turbo-text-to-video-pro","kling-3.0-omni/text-to-video","kling-3.0-omni/image-to-video","kling-3.0-omni/reference-to-video","kling-3.0-omni/transformation","grok-imagine/text-to-image","grok-imagine/image-to-image","grok-imagine/text-to-video","grok-imagine/image-to-video","grok-imagine-video-1-5-preview","nano-banana-pro","nano-banana-2","nano-banana-2-1","nano-banana-2-lite","gpt-image/1.5-image-to-image","gpt-image/1.5-text-to-image","gpt-image-2-image-to-image","gpt-image-2-text-to-image","gpt-image-2-5-flare-image-to-image","gpt-image-2-5-flare-text-to-image","gpt-image-2-5-sunburst-image-to-image","gpt-image-2-5-sunburst-text-to-image","seedream/5-lite-image-to-image","seedream/5-lite-text-to-image","seedream/5-pro-image-to-image","seedream/5-pro-text-to-image","seedream/5-flash-text-to-image","seedream/5-flash-image-to-image","seedream/5-pro-layer-decomposition","seedream/5-flash-layer-decomposition","seedream/4.5-text-to-image","seedream/4.5-edit","grok-imagine/extend","grok-imagine/upscale","grok-imagine-image-2-0/text-to-image","grok-imagine-image-2-0/segment-map","grok-imagine-image-2-0/image-edit","grok-imagine-image-2-0/segment-edit","qwen2/text-to-image","qwen2/image-edit","qwen2-1/text-to-image","qwen2-1/image-to-image","qwen3/text-to-image","qwen3/image-to-image","qwen3/pro-text-to-image","qwen3/pro-image-to-image","qwen/text-to-image","qwen/image-edit","qwen/image-to-image","bytedance/seedance-2-fast","bytedance/seedance-2","bytedance/seedance-2-5","bytedance/seedance-2-mini","bytedance/seedance-1.5-pro","bytedance/seedream","bytedance/seedream-v4-edit","bytedance/seedream-v4-text-to-image","bytedance/v1-lite-image-to-video","bytedance/v1-lite-text-to-video","bytedance/v1-pro-fast-image-to-video","bytedance/v1-pro-image-to-video","bytedance/v1-pro-text-to-video","wan/3-0-video","wan/3-0-video-prime","wan/2-7-image-to-video","wan/2-7-text-to-video","wan/2-7-r2v","wan/2-7-videoedit","wan/2-7-image","wan/2-7-image-pro","wan/2-2-a14b-image-to-video-turbo","wan/2-2-a14b-speech-to-video-turbo","wan/2-2-a14b-text-to-video-turbo","wan/2-2-animate-move","wan/2-2-animate-replace","wan/2-5-image-to-video","wan/2-5-text-to-video","wan/2-6-flash-image-to-video","wan/2-6-flash-video-to-video","wan/2-6-image-to-video","wan/2-6-text-to-video","wan/2-6-video-to-video","happyhorse/text-to-video","happyhorse/image-to-video","happyhorse/reference-to-video","happyhorse/video-edit","happyhorse-1-1/text-to-video","happyhorse-1-1/image-to-video","happyhorse-1-1/reference-to-video","omnihuman-1-5","omnihuman-1-5/human-identification","omnihuman-1-5/subject-detection","volcengine/video-to-video-lip-sync","gemini-omni-video","elevenlabs/audio-isolation","elevenlabs/text-to-dialogue-v3","elevenlabs/text-to-speech-multilingual-v2","elevenlabs/text-to-speech-turbo-2-5","elevenlabs/sound-effect-v2","recraft/crisp-upscale","recraft/remove-background","pixverse-v6/text-to-video","pixverse-v6/image-to-video","pixverse-v6/transition","pixverse-v6/extend","pixverse-v6/reference-to-video","minimax-h3/text-to-video","minimax-h3/image-to-video","minimax-h3/reference-to-video","google/gemini-2-5-pro-tts","google/gemini-3-1-flash-tts","google/gemini-3-8-flash-tts","google/gemini-3-8-flash-lite-tts","google/gemini-omni-flash-1-1","google/imagen4","google/imagen4-fast","google/imagen4-ultra","google/nano-banana","google/nano-banana-edit","topaz/image-upscale","topaz/video-upscale","infinitalk/from-audio","z-image","flux-2/flex-image-to-image","flux-2/flex-text-to-image","flux-2/pro-image-to-image","flux-2/pro-text-to-image","flux-3/klein-text-to-image","flux-3/klein-edit-image","ideogram/character","ideogram/character-edit","ideogram/character-remix","ideogram/v3-edit","ideogram/v3-remix","ideogram/v3-text-to-image","hailuo/02-image-to-video-pro","hailuo/02-image-to-video-standard","hailuo/02-text-to-video-pro","hailuo/02-text-to-video-standard","hailuo/2-3-image-to-video-pro","hailuo/2-3-image-to-video-standard","vidu-q4/image-to-video","vidu-q4/reference-to-video"],im=h(om).or(Wd).or($d).or(jd).or(Hd).or(Jd).or(Qd).or(Xd).or(Yd).or(Zd).or(em).or(tm).or(nm);h(["image","video","audio","transcription"]);const rm=["achernar","achird","algenib","algieba","alnilam","aoede","autonoe","callirrhoe","charon","despina","enceladus","erinome","fenrir","gacrux","iapetus","kore","laomedeia","leda","orus","puck","pulcherrima","rasalgethi","sadachbia","sadaltager","schedar","sulafat","umbriel","vindemiatrix","zephyr","zubenelgenubi"],sm=h(rm),am=["Achernar","Achird","Algenib","Algieba","Alnilam","Aoede","Autonoe","Callirrhoe","Charon","Despina","Enceladus","Erinome","Fenrir","Gacrux","Iapetus","Kore","Laomedeia","Leda","Orus","Puck","Pulcherrima","Rasalgethi","Sadachbia","Sadaltager","Schedar","Sulafat","Umbriel","Vindemiatrix","Zephyr","Zubenelgenubi"],lm=h(am),cm=h(["Neutral","American (Gen)","American (Valley)","American (South)","British (RP)","British (Brixton)","Transatlantic","Australian"]),um=h(["Vocal Smile","Newscaster","Whisper","Empathetic","Promo/Hype","Deadpan"]),pm=h(["Natural","Rapid Fire","The Drift","Staccato"]),Xn=a().refine(n=>/^Speaker \d+$/.test(n),{message:'Expected a speaker id in "Speaker N" format (e.g. "Speaker 1")'}),jr={minimum:0,maximum:2},dm=1e4,mm=h(["user","model"]),hm=h(["low","high"]),fm=u({mime_type:a().min(1),data:a().min(1)}),gm=u({mime_type:a().min(1),file_uri:a().min(1)}),xm=u({text:a().optional(),inline_data:fm.optional(),file_data:gm.optional()}).strict().refine(n=>n.text!==void 0||n.inline_data!==void 0||n.file_data!==void 0,{message:"parts entries must include text, inline_data, or file_data"}),Yn=u({role:mm,parts:k(xm).min(1)}),ym=u({type:a().optional(),properties:z(a(),K()).optional(),required:k(a()).optional()}).passthrough(),Ua=u({name:a().min(1),description:a().optional(),parameters:ym.optional()}).passthrough(),Ga=u({}).strict();u({googleSearch:Ga}).strict();u({functionDeclarations:k(Ua).min(1)}).strict();const Zn=u({googleSearch:Ga.optional(),functionDeclarations:k(Ua).min(1).optional()}).strict().refine(n=>n.googleSearch!==void 0||n.functionDeclarations!==void 0,{message:"tools entries must include googleSearch or functionDeclarations"}),Sm=u({includeThoughts:y().optional(),thinkingLevel:hm.optional()}).strict(),eo=u({temperature:x().optional(),topP:x().optional(),topK:x().optional(),candidateCount:x().int().positive().optional(),maxOutputTokens:x().int().positive().optional(),stopSequences:k(a()).optional(),thinkingConfig:Sm.optional()}).passthrough();u({stream:y().default(!0),contents:k(Yn).min(1),tools:k(Zn).optional(),generationConfig:eo.optional()}).passthrough();u({stream:y().default(!0),contents:k(Yn).min(1),tools:k(Zn).optional(),generationConfig:eo.optional()}).passthrough();u({stream:y().default(!0),contents:k(Yn).min(1),tools:k(Zn).optional(),generationConfig:eo.optional()}).passthrough();u({stream:y().default(!0),contents:k(Yn).min(1),tools:k(Zn).optional(),generationConfig:eo.optional()}).passthrough();const bm=h(["developer","system","user","assistant","tool"]);h(["text","image_url"]);const km=h(["low","high"]),_m=h(["function"]),wm=h(["googleSearch"]),Tm=u({type:f("text"),text:a()}).strict(),Im=u({type:f("image_url"),image_url:u({url:a().url()}).strict()}).strict(),Cm=Te("type",[Tm,Im]),Rm=u({role:bm,content:P([a().min(1),k(Cm).min(1)])}).passthrough(),Om=u({type:f("object"),properties:z(a(),K()).optional(),required:k(a()).optional()}).passthrough(),Mm=u({name:wm,description:a().optional(),parameters:Om.optional()}).passthrough(),vm=u({type:_m,function:Mm}).strict();u({messages:k(Rm).min(1),stream:y().default(!1),tools:k(vm).min(0).optional(),include_thoughts:y().default(!1),reasoning_effort:km.default("high")}).passthrough();const Em=h(["developer","system","user","assistant","tool"]);h(["text","image_url"]);const Am=h(["low","high"]),Nm=h(["function"]),Dm=h(["web_search"]),Bm=u({type:f("text"),text:a()}).strict(),Vm=u({type:f("image_url"),image_url:u({url:a().url()}).strict()}).strict(),Pm=Te("type",[Bm,Vm]),Km=u({role:Em,content:P([a().min(1),k(Pm).min(1)])}).passthrough(),zm=u({type:f("object"),properties:z(a(),K()).optional(),required:k(a()).optional()}).passthrough(),Fm=u({name:Dm,description:a().optional(),parameters:zm.optional()}).passthrough(),qm=u({type:Nm,function:Fm}).strict();u({messages:k(Km).min(1),tools:k(qm).min(0).optional(),reasoning_effort:Am.default("high")}).passthrough();const Um=h(["developer","system","user","assistant","tool"]);h(["text","image_url"]);const Gm=h(["low","high"]),Lm=h(["function"]),Wm=u({type:f("text"),text:a()}).strict(),$m=u({type:f("image_url"),image_url:u({url:a().url()}).strict()}).strict(),jm=Te("type",[Wm,$m]),Hm=u({role:Um,content:k(jm).min(1)}).passthrough(),Jm=u({type:f("object"),properties:z(a(),K()).optional(),required:k(a()).optional()}).passthrough(),Qm=u({name:a().min(1),description:a().optional(),parameters:Jm.optional()}).passthrough(),Xm=u({type:Lm,function:Qm}).strict(),Ym=u({type:a().optional(),json_schema:z(a(),K()).optional(),properties:z(a(),K()).optional()}).passthrough();u({messages:k(Hm).min(1),stream:y().default(!1),tools:k(Xm).min(0).optional(),include_thoughts:y().optional(),reasoning_effort:Gm.optional(),response_format:Ym.optional()}).passthrough();const Zm=h(["developer","system","user","assistant","tool"]);h(["text","image_url"]);const eh=h(["low","high"]),th=h(["function"]),nh=u({type:f("text"),text:a()}).strict(),oh=u({type:f("image_url"),image_url:u({url:a().url()}).strict()}).strict(),ih=Te("type",[nh,oh]),rh=u({role:Zm,content:k(ih).min(1)}).passthrough(),sh=u({type:f("object"),properties:z(a(),K()).optional(),required:k(a()).optional()}).passthrough(),ah=u({name:a().min(1),description:a().optional(),parameters:sh.optional()}).passthrough(),lh=u({type:th,function:ah}).strict(),ch=u({type:a().optional(),json_schema:z(a(),K()).optional(),properties:z(a(),K()).optional()}).passthrough();u({messages:k(rh).min(1),stream:y().default(!1),tools:k(lh).min(0).optional(),include_thoughts:y().optional(),reasoning_effort:eh.optional(),response_format:ch.optional()}).passthrough();const uh=h(["developer","system","user","assistant","tool"]);h(["text","image_url"]);const ph=h(["low","high"]),dh=h(["function"]),mh=u({type:f("text"),text:a()}).strict(),hh=u({type:f("image_url"),image_url:u({url:a().url()}).strict()}).strict(),fh=Te("type",[mh,hh]),gh=u({role:uh,content:k(fh).min(1)}).passthrough(),xh=u({type:f("object"),properties:z(a(),K()).optional(),required:k(a()).optional()}).passthrough(),yh=u({name:a().min(1),description:a().optional(),parameters:xh.optional()}).passthrough(),Sh=u({type:dh,function:yh}).strict(),bh=u({type:a().optional(),json_schema:z(a(),K()).optional(),properties:z(a(),K()).optional()}).passthrough();u({messages:k(gh).min(1),stream:y().default(!1),tools:k(Sh).min(0).optional(),include_thoughts:y().optional(),reasoning_effort:ph.optional(),response_format:bh.optional()}).passthrough();const kh=h(["developer","system","user","assistant","tool"]);h(["text","image_url"]);const _h=h(["low","high"]),wh=h(["function"]),Th=u({type:f("text"),text:a()}).strict(),Ih=u({type:f("image_url"),image_url:u({url:a().url()}).strict()}).strict(),Ch=Te("type",[Th,Ih]),Rh=u({role:kh,content:k(Ch).min(1)}).passthrough(),Oh=u({type:f("object"),properties:z(a(),K()).optional(),required:k(a()).optional()}).passthrough(),Mh=u({name:a().min(1),description:a().optional(),parameters:Oh.optional()}).passthrough(),vh=u({type:wh,function:Mh}).strict(),Eh=u({type:a().optional(),json_schema:z(a(),K()).optional(),properties:z(a(),K()).optional()}).passthrough();u({messages:k(Rh).min(1),stream:y().default(!1),tools:k(vh).min(0).optional(),include_thoughts:y().optional(),reasoning_effort:_h.optional(),response_format:Eh.optional()}).passthrough();const Ah=h(["developer","system","user","assistant","tool"]);h(["text","image_url"]);const Nh=h(["low","high"]),Dh=h(["function"]),Bh=u({type:f("text"),text:a()}).strict(),Vh=u({type:f("image_url"),image_url:u({url:a().url()}).strict()}).strict(),Ph=Te("type",[Bh,Vh]),Kh=u({role:Ah,content:k(Ph).min(1)}).passthrough(),zh=u({type:f("object"),properties:z(a(),K()).optional(),required:k(a()).optional()}).passthrough(),Fh=u({name:a().min(1),description:a().optional(),parameters:zh.optional()}).passthrough(),qh=u({type:Dh,function:Fh}).strict(),Uh=u({type:a().optional(),json_schema:z(a(),K()).optional(),properties:z(a(),K()).optional()}).passthrough();u({messages:k(Kh).min(1),stream:y().default(!1),tools:k(qh).min(0).optional(),include_thoughts:y().optional(),reasoning_effort:Nh.optional(),response_format:Uh.optional()}).passthrough();const Gh=h(["developer","system","user","assistant","tool"]);h(["text","image_url"]);const Lh=h(["low","high"]),Wh=h(["function"]),$h=u({type:f("text"),text:a()}).strict(),jh=u({type:f("image_url"),image_url:u({url:a().url()}).strict()}).strict(),Hh=Te("type",[$h,jh]),Jh=u({role:Gh,content:k(Hh).min(1)}).passthrough(),Qh=u({type:f("object"),properties:z(a(),K()).optional(),required:k(a()).optional()}).passthrough(),Xh=u({name:a().min(1),description:a().optional(),parameters:Qh.optional()}).passthrough(),Yh=u({type:Wh,function:Xh}).strict(),Zh=u({type:a().optional(),json_schema:z(a(),K()).optional(),properties:z(a(),K()).optional()}).passthrough();u({messages:k(Jh).min(1),stream:y().default(!1),tools:k(Yh).min(0).optional(),include_thoughts:y().default(!1),reasoning_effort:Lh.default("high"),response_format:Zh.optional()}).passthrough();const ef=h(["developer","system","user","assistant","tool"]);h(["text","image_url"]);const tf=h(["function"]),nf=h(["low","high"]),of=u({type:f("text"),text:a()}).strict(),rf=u({type:f("image_url"),image_url:u({url:a().url()}).strict()}).strict(),sf=Te("type",[of,rf]),af=u({role:ef,content:k(sf).min(1)}).passthrough(),lf=u({type:f("object"),properties:z(a(),K()).optional(),required:k(a()).optional()}).passthrough(),cf=u({name:a().min(1),description:a().optional(),parameters:lf.optional()}).passthrough(),uf=u({type:tf,function:cf}).strict(),pf=u({type:a().optional(),json_schema:z(a(),K()).optional(),properties:z(a(),K()).optional()}).passthrough();u({messages:k(af).min(1),stream:y().default(!1),tools:k(uf).min(0).optional(),include_thoughts:y().default(!1),reasoning_effort:nf.default("high"),response_format:pf.optional()}).passthrough();const df=h(["3","4","5","6","7","8","9","10","11","12","13","14","15"]),to=h(["16:9","9:16","1:1"]),mf=h(["std","pro","4K"]),La=h(["720p","1080p"]),hf=h(["1:1","9:16","16:9"]),ff=a().regex(/^[1-9]\d*$/),gf=h(["3","4","5","6","7","8","9","10","11","12","13","14","15"]),xf=h(["fun","normal","spicy"]),yf=h(["fun","normal","spicy"]);h(["fun","normal","spicy"]);const Sf=h(["2:3","3:2","1:1","16:9","9:16"]),bf=h(["2:3","3:2","1:1","16:9","9:16"]),Wa=x().int().min(6).max(30),$a=a().regex(/^(?:[6-9]|[12][0-9]|30)$/),kf=P([Wa,$a]),_f=P([Wa,$a]),wf=h(["6","10"]),ja=h(["480p","720p","1080p"]),Ha=h(["480p","720p"]),Tf=[".jpg",".jpeg",".png",".webp"];function If(n){try{const e=new URL(n).pathname.toLowerCase();return Tf.some(t=>e.endsWith(t))}catch{return!1}}const Cf=a().url().refine(If,{message:"image_urls entries must be JPEG, PNG, or WEBP URLs"}),Rf=h(["auto","1:1","16:9","9:16","4:3","3:4","3:2","2:3"]),_i=h(["1K","2K","4K"]),wi=h(["png","jpg"]),Ja=h(["medium","high"]),Of=h(["1:1","3:4","4:3","9:16","16:9"]),Qa=h(["1K","2K"]),Mf=h(["1:1","3:2","2:3","4:3","3:4","16:9","9:16","21:9"]),vf=h(["png","jpeg"]),Xa=h(["square","square_hd","portrait_4_3","portrait_16_9","landscape_4_3","landscape_16_9"]),Ti=h(["none","regular","high"]),Ef=h(["1","2","3","4"]),no=h(["720p","1080p"]),Ii=h(["16:9","9:16","1:1","4:3","3:4"]),Af=h(["auto","origin"]),Nf=h(["1K","2K","4K"]),Df=h(["1:1","16:9","4:3","21:9","3:4","9:16","8:1","1:8"]),Bf=x().int().min(0).max(10).refine(n=>n===0||n>=2,{message:"Duration must be 0 or an integer from 2 to 10."}).describe("Duration in seconds, 0 or 2-10."),yt=h(["720p","1080p"]),Ya=h(["16:9","9:16","1:1","4:3","3:4"]),Za=h(["16:9","9:16","3:4","4:3","4:5","5:4","1:1","9:21","21:9"]),Vf=h(["auto","origin"]),Pf=3,Kf=15,Et=x().int().min(Pf).max(Kf),zf=h(["720","1080"]),Ff=h(["lite","basic"]),el=h(["4","6","8","10"]),tl=h(["16:9","9:16"]),qf=h(["720p","1080p","4k"]),Uf=h(["360p","720p","1080p","4k"]),Gf=h(["480p","720p"]),Lf=h(["16:9","4:3","1:1","3:4","9:16","21:9","adaptive"]),Wf=h(["waiting","success","fail"]),Ci=a().min(1).max(7e3),Ri=x().int().min(4).max(15),Oi=h(["768P","2K"]),nl=h(["21:9","16:9","4:3","1:1","3:4","9:16"]),$f=h(["adaptive",...nl.options]),jf=new Set(["http:","https:","oss:"]);function Hf(n){try{return jf.has(new URL(n).protocol)}catch{return!1}}const $t=a().url().refine(Hf,{message:"Expected an HTTP, HTTPS, or OSS media address"}),Hr={video:{minimum:2e3,maximum:15e3,maximumTotal:15e3},audio:{minimum:2e3,maximum:15e3,maximumTotal:15e3}};function Jr(n){return`Each file must last ${n.minimum}-${n.maximum} ms (${n.minimum/1e3}-${n.maximum/1e3} seconds), with ${n.maximumTotal} ms combined at most`}const Jf=u({name:a().min(1),description:a().min(1),element_input_urls:k(a()).optional(),element_input_video_urls:k(a()).optional()}),Qf=u({prompt:a().min(1).max(500),duration:x().int().min(1).max(12)}),oo=h(["720p","1080p","4k"]),Mi=x().int().min(3).max(15),vi=h(["16:9","9:16","1:1","auto"]),xt=a().refine(n=>/^(https?|oss):\/\//.test(n),{message:"Expected an HTTP, HTTPS, or OSS media reference"}),Xf=u({prompt:a().min(1).max(512),duration:x().int().min(1).max(15)}),Ei=k(Xf).max(6),io=u({name:a().min(1),description:a().min(1),element_input_urls:k(xt).min(1).max(4),element_input_audio_urls:k(xt).optional(),start_time:x().int().optional(),end_time:x().int().optional()}),ro=a().min(1).max(3072).refine(n=>n.trim().length>0,{message:"Prompt must contain a non-whitespace character"}),Ai=y().optional().describe("Enable intelligent shot planning; mutually exclusive with customize_multi_shots");function Ni(n,e){n.customize_multi_shots&&n.prefer_multi_shots&&e.addIssue({code:"custom",message:"customize_multi_shots and prefer_multi_shots cannot both be true",path:["input","prefer_multi_shots"]}),n.customize_multi_shots===!0&&(n.multi_prompt?.length??0)===0&&e.addIssue({code:"custom",message:"customize_multi_shots=true requires a non-empty multi_prompt array",path:["input","multi_prompt"]}),n.customize_multi_shots===!1&&(n.multi_prompt?.length??0)>0&&e.addIssue({code:"custom",message:"customize_multi_shots=false requires multi_prompt to be empty or omitted",path:["input","multi_prompt"]})}const Yf=u({hex:a().min(1),ratio:a().min(1)}),et=h(["5","10"]),At=x().min(0).max(1),Zf=u({model:f("kling-2.6/text-to-video"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(1e3),sound:y(),aspect_ratio:to,duration:et})}),eg=u({model:f("kling-2.6/image-to-video"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(1e3),image_urls:k(a().min(1)).min(1).max(1),sound:y(),duration:et})}),tg=u({model:f("kling-2.6/motion-control"),callBackUrl:a().optional(),input:u({prompt:a().max(2500).optional(),input_urls:k(a().min(1)).min(1).max(1),video_urls:k(a().min(1)).min(1).max(1),character_orientation:h(["image","video"]),mode:h(["720p","1080p"])})}),ol=u({image_url:a().min(1),audio_url:a().min(1),prompt:a().max(5e3)}),ng=u({model:f("kling/ai-avatar-pro"),callBackUrl:a().optional(),input:ol}),og=u({model:f("kling/ai-avatar-standard"),callBackUrl:a().optional(),input:ol}),ig=u({model:f("kling/v2-1-master-image-to-video"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(5e3),image_url:a().min(1),duration:et.optional(),negative_prompt:a().max(500).optional(),cfg_scale:At.optional()})}),rg=u({model:f("kling/v2-1-master-text-to-video"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(5e3),duration:et.optional(),aspect_ratio:to.optional(),negative_prompt:a().max(500).optional(),cfg_scale:At.optional()})}),sg=u({model:f("kling/v2-1-pro"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(5e3),image_url:a().min(1),duration:et.optional(),negative_prompt:a().max(500).optional(),cfg_scale:At.optional(),tail_image_url:a().min(1).optional()})}),ag=u({model:f("kling/v2-1-standard"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(5e3),image_url:a().min(1),duration:et.optional(),negative_prompt:a().max(500).optional(),cfg_scale:At.optional()})}),lg=u({model:f("kling/v2-5-turbo-image-to-video-pro"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(2500),image_url:a().min(1),tail_image_url:a().min(1).optional(),duration:et.optional(),negative_prompt:a().max(500).optional(),cfg_scale:At.optional()})}),cg=u({model:f("kling/v2-5-turbo-text-to-video-pro"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(2500),duration:et.optional(),aspect_ratio:to.optional(),negative_prompt:a().max(2500).optional(),cfg_scale:At.optional()})}),ug=u({model:f("kling-3.0/video"),callBackUrl:a().optional(),input:u({prompt:a().optional(),image_urls:k(a()).optional(),sound:y().optional(),duration:df,aspect_ratio:to.optional(),mode:mf,multi_shots:y(),multi_prompt:k(Qf).optional(),kling_elements:k(Jf).max(3).optional()})}),pg=u({model:f("kling/v3-turbo-image-to-video"),callBackUrl:a().optional(),input:u({prompt:a().min(1),image_urls:k(a().min(1)).min(1).max(1),duration:ff,resolution:La})}),dg=u({model:f("kling/v3-turbo-text-to-video"),callBackUrl:a().url().optional(),input:u({prompt:a().min(1).max(2500),duration:gf.default("5"),aspect_ratio:hf.default("16:9"),resolution:La.default("720p")})}),mg=u({model:f("kling-3.0/motion-control"),callBackUrl:a().optional(),input:u({prompt:a().optional(),input_urls:k(a()).min(1).max(1),video_urls:k(a()).min(1),mode:h(["720p","1080p"]).optional(),character_orientation:h(["video","image"]).optional(),background_source:h(["input_video","input_image"]).optional()})}),hg=u({prompt:ro,customize_multi_shots:y().default(!0).describe("Enable custom shots. Upstream defaults this to true for text-to-video, which requires a non-empty multi_prompt; explicitly pass false for a prompt-only request."),prefer_multi_shots:Ai,multi_prompt:Ei.optional(),elements:k(io).max(7).optional().describe("One-time subjects: up to 7 multi-image subjects, up to 3 video subjects, or up to 3 video plus 4 multi-image subjects"),audio:y().optional().describe("Generate audio; upstream default false"),resolution:oo.default("720p"),aspect_ratio:h(["16:9","9:16","1:1"]).default("16:9"),duration:Mi.default(5)}),fg=u({model:f("kling-3.0-omni/text-to-video"),callBackUrl:a().url().optional(),input:hg}),gg=fg.superRefine((n,e)=>{Ni(n.input,e)}),xg=u({prompt:ro,image_urls:k(xt).min(1).max(2).describe("One URL supplies the first frame; two URLs supply first and last frames"),duration:Mi.default(5),resolution:oo.default("720p"),aspect_ratio:vi.optional().describe("Output aspect ratio; upstream default auto, with fixed ratios available for custom multi-shot mode"),audio:y().optional(),customize_multi_shots:y().optional(),prefer_multi_shots:Ai,multi_prompt:Ei.optional(),elements:k(io).max(3).optional().describe("One-time subject assets, up to 3 subjects")}),yg=u({model:f("kling-3.0-omni/image-to-video"),callBackUrl:a().url().optional(),input:xg}),Sg=yg.superRefine((n,e)=>{Ni(n.input,e),n.input.aspect_ratio!==void 0&&n.input.aspect_ratio!=="auto"&&n.input.customize_multi_shots!==!0&&e.addIssue({code:"custom",message:"Image-to-video fixed aspect ratios require customize_multi_shots=true; otherwise use auto",path:["input","aspect_ratio"]})}),bg=u({prompt:ro,image_urls:k(xt).min(1).max(7).optional(),video_urls:k(xt).min(1).max(1).optional(),duration:Mi.default(5),resolution:oo.default("720p"),aspect_ratio:vi.optional().describe("Fixed ratios apply without video or with video plus images; video-only input requires explicit auto"),audio:y().optional().describe("Video-backed requests require explicit false"),customize_multi_shots:y().optional(),prefer_multi_shots:Ai,multi_prompt:Ei.optional(),elements:k(io).optional().describe("Subject assets share the reference quota; video-backed requests impose the upstream composition limits")}),kg=u({model:f("kling-3.0-omni/reference-to-video"),callBackUrl:a().url().optional(),input:bg}),_g=kg.superRefine((n,e)=>{const{input:t}=n,o=!!t.image_urls?.length,i=!!t.video_urls?.length;if(Ni(t,e),!o&&!i){e.addIssue({code:"custom",message:"reference-to-video requires a non-empty image_urls or video_urls array",path:["input","image_urls"]});return}if(!i){t.aspect_ratio==="auto"&&e.addIssue({code:"custom",message:"Reference requests without video do not accept auto",path:["input","aspect_ratio"]});return}t.audio!==!1&&e.addIssue({code:"custom",message:"Reference requests with video require audio=false",path:["input","audio"]}),!o&&t.aspect_ratio!=="auto"&&e.addIssue({code:"custom",message:"Reference requests with video only require aspect_ratio=auto",path:["input","aspect_ratio"]}),o&&t.aspect_ratio==="auto"&&e.addIssue({code:"custom",message:"Reference requests with video and images require a fixed aspect ratio when provided",path:["input","aspect_ratio"]}),(t.image_urls?.length??0)>4&&e.addIssue({code:"custom",message:"Reference requests with video accept at most 4 image_urls",path:["input","image_urls"]})}),wg=u({prompt:ro,image_urls:k(xt).min(1).max(4).optional(),video_urls:k(xt).min(1).max(1),duration:a().optional().describe("String duration supported only by the video-with-images shape"),resolution:oo.default("720p"),aspect_ratio:vi.optional().describe("Video-only input uses auto; video with images uses 16:9, 9:16, or 1:1"),audio:y().optional(),elements:k(io).max(7).optional().describe("One-time subjects: up to 7 multi-image subjects, up to 3 video subjects, or up to 3 video plus 4 multi-image subjects")}),Tg=u({model:f("kling-3.0-omni/transformation"),callBackUrl:a().url().optional(),input:wg}),Ig=Tg.superRefine((n,e)=>{const{input:t}=n,o=!!t.image_urls?.length;!o&&t.aspect_ratio!=="auto"&&e.addIssue({code:"custom",message:"Transformation requests with video only require aspect_ratio=auto",path:["input","aspect_ratio"]}),!o&&t.duration!==void 0&&e.addIssue({code:"custom",message:"Transformation duration is supported only when image_urls are present",path:["input","duration"]}),o&&t.aspect_ratio==="auto"&&e.addIssue({code:"custom",message:"Transformation requests with images do not accept aspect_ratio=auto",path:["input","aspect_ratio"]})}),Cg=u({model:f("grok-imagine/text-to-image"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(5e3),aspect_ratio:h(["2:3","3:2","1:1","16:9","9:16"]).default("16:9"),nsfw_checker:y().default(!1),enable_pro:y().optional()})}),Rg=u({model:f("qwen2/text-to-image"),callBackUrl:a().url().optional(),input:u({prompt:a().min(1).max(800),image_size:Of.default("16:9"),seed:x().int().optional(),output_format:h(["jpeg","png"]).default("png"),nsfw_checker:y().default(!1)})}),Og=u({model:f("qwen2/image-edit"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(800),image_url:a().min(1),image_size:h(["1:1","2:3","3:2","3:4","4:3","9:16","16:9","21:9"]).default("16:9"),output_format:h(["jpeg","png"]).default("png"),seed:x().multipleOf(1).optional(),nsfw_checker:y().default(!1)})}),il=h(["1:1","4:3","3:4","3:2","2:3","16:9","9:16","21:9","9:21"]),Mg=h(["1K","2K"]),vg=h(["opaque","transparent"]),Eg=h(["png","webp","jpeg"]),rl={resolution:Mg.default("1K"),background:vg.default("opaque"),output_format:Eg.default("png"),enhance_prompt:y().default(!0),seed:x().int().optional(),nsfw_checker:y().default(!1)},Ag=u({model:f("qwen2-1/text-to-image"),callBackUrl:a().url().optional(),input:u({prompt:a().min(1).max(5e3),aspect_ratio:il.default("1:1"),...rl}).strict()}),Ng=(n,e)=>{n.input.mask_url!==void 0&&(n.input.image_urls.length!==1&&e.addIssue({code:"custom",message:"mask_url requires exactly one image_urls entry (local-edit mode)",path:["input","mask_url"]}),n.input.background==="transparent"&&e.addIssue({code:"custom",message:"mask_url cannot be combined with background transparent",path:["input","background"]}))},Dg=u({model:f("qwen2-1/image-to-image"),callBackUrl:a().url().optional(),input:u({image_urls:k(a().url()).min(1).max(10),prompt:a().min(1).max(5e3),mask_url:a().url().optional(),aspect_ratio:P([f("auto"),il]).default("auto"),...rl}).strict()}).superRefine(Ng),sl={prompt:a().max(5e3),image_size:Mf.default("16:9"),output_format:vf.default("png"),prompt_extend:y().default(!0),nsfw_checker:y().default(!1),negative_prompt:a().max(5e3).optional(),seed:x().int().min(0).max(2147483647).default(1)},al=u({...sl,resolution:Qa.optional()}).strict(),ll=u({...sl,image_urls:k(a().url()).min(1).max(3),resolution:Qa.default("1K")}).strict(),Bg=u({model:f("qwen3/text-to-image"),callBackUrl:a().url().optional(),input:al}),Vg=u({model:f("qwen3/image-to-image"),callBackUrl:a().url().optional(),input:ll}),Pg=u({model:f("qwen3/pro-text-to-image"),callBackUrl:a().url().optional(),input:al}),Kg=u({model:f("qwen3/pro-image-to-image"),callBackUrl:a().url().optional(),input:ll}),zg=u({model:f("qwen/text-to-image"),callBackUrl:a().url().optional(),input:u({prompt:a().min(1).max(5e3),image_size:Xa.optional(),num_inference_steps:x().min(2).max(250).default(30),seed:x().int().optional(),guidance_scale:x().min(0).max(20).default(2.5),enable_safety_checker:y().optional(),output_format:h(["png","jpeg"]).default("png"),negative_prompt:a().max(500).optional(),acceleration:Ti.default("none"),nsfw_checker:y().default(!1)})}),Fg=u({model:f("qwen/image-edit"),callBackUrl:a().url().optional(),input:u({prompt:a().min(1).max(2e3),image_url:a().min(1),acceleration:Ti.default("none"),image_size:Xa.default("landscape_4_3"),num_inference_steps:x().min(2).max(49).default(25),seed:x().int().optional(),guidance_scale:x().min(0).max(20).default(4),sync_mode:y().optional(),num_images:Ef.optional(),enable_safety_checker:y().optional(),output_format:h(["jpeg","png"]).default("png"),negative_prompt:a().max(500).optional(),nsfw_checker:y().default(!1)})}),qg=u({model:f("qwen/image-to-image"),callBackUrl:a().url().optional(),input:u({prompt:a().min(1).max(5e3),image_url:a().min(1),strength:x().min(0).max(1).default(.8),output_format:h(["png","jpeg"]).default("png"),acceleration:Ti.default("none"),negative_prompt:a().max(500).optional(),seed:x().int().optional(),num_inference_steps:x().min(2).max(250).default(30),guidance_scale:x().min(0).max(20).default(2.5),enable_safety_checker:y().optional(),nsfw_checker:y().default(!1)})}),Ug=u({model:f("grok-imagine/image-to-image"),callBackUrl:a().optional(),input:u({prompt:a().max(39e4).optional(),image_urls:cs([a()]),nsfw_checker:y().default(!1)})}),Gg=u({model:f("grok-imagine/text-to-video"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(5e3),aspect_ratio:Sf.optional(),mode:xf.optional(),duration:kf.optional(),resolution:ja.optional(),nsfw_checker:y().default(!1)})}),Lg=u({model:f("grok-imagine/image-to-video"),callBackUrl:a().url().optional(),input:u({prompt:a().max(4096).optional(),image_urls:k(Cf).min(1).max(7,"grok-imagine/image-to-video accepts at most 7 image_urls").optional(),task_id:a().min(1).max(100).optional(),index:x().int().min(0).max(5).default(0),mode:yf.default("normal"),duration:_f.default(6),resolution:ja.default("480p"),aspect_ratio:bf.default("16:9"),nsfw_checker:y().default(!1)})}).superRefine((n,e)=>{const t=!!n.input.image_urls?.length,o=!!n.input.task_id;t===o&&e.addIssue({code:"custom",message:"grok-imagine/image-to-video requires exactly one of image_urls or task_id",path:["input","image_urls"]}),t&&n.input.mode==="spicy"&&e.addIssue({code:"custom",message:"grok-imagine/image-to-video spicy mode is unavailable with external image_urls",path:["input","mode"]}),n.input.resolution==="1080p"&&(n.input.image_urls?.length??0)>1&&e.addIssue({code:"custom",message:"grok-imagine/image-to-video accepts exactly 1 image_url at 1080p",path:["input","image_urls"]})}),Wg=u({model:f("grok-imagine-video-1-5-preview"),callBackUrl:a().optional(),input:u({prompt:a().max(4096).optional(),image_urls:k(a()).min(1),aspect_ratio:Rf.default("auto"),resolution:Ha.default("480p"),duration:x().int().min(1).max(15).default(8),nsfw_checker:y().default(!0)})}),$g=u({model:f("grok-imagine/extend"),callBackUrl:a().optional(),resolution:Ha.optional(),input:u({task_id:a().min(1).max(100),prompt:a().min(1).max(5e3),extend_at:x().min(0),extend_times:wf})}),jg=u({model:f("grok-imagine/upscale"),callBackUrl:a().optional(),input:u({task_id:a().min(1).max(100)})}),Hg=u({model:f("grok-imagine-image-2-0/text-to-image"),callBackUrl:a().url().optional(),input:u({prompt:a().min(1),aspect_ratio:h(["1:1","2:3","3:2","16:9","9:16"])}).strict()}),Jg=u({model:f("grok-imagine-image-2-0/segment-map"),callBackUrl:a().url().optional(),input:u({task_id:a().min(1)}).strict()}),Qg=u({model:f("grok-imagine-image-2-0/image-edit"),callBackUrl:a().url().optional(),input:u({prompt:a().min(1),task_id:a().min(1),mask_indexs:k(x().int().min(0)).min(1).optional()}).strict()}),Xg=u({model:f("grok-imagine-image-2-0/segment-edit"),callBackUrl:a().url().optional(),input:u({prompt:a().min(1),task_id:a().min(1),mask_indexs:k(x().int().min(1)).min(1).optional()}).strict()}),Yg=u({model:f("nano-banana-pro"),callBackUrl:a().optional(),input:u({prompt:a().min(1),image_input:k(a()).max(8).optional(),aspect_ratio:h(["1:1","2:3","3:2","3:4","4:3","4:5","5:4","9:16","16:9","21:9","auto"]).default("16:9"),resolution:_i.default("2K"),output_format:wi.optional()})}),Zg=u({prompt:a().min(3).max(2e4),first_frame_url:a().optional(),last_frame_url:a().optional(),reference_image_urls:k(a()).max(9).optional(),reference_video_urls:k(a()).max(3).optional(),reference_audio_urls:k(a()).max(3).optional(),return_last_frame:y().optional(),generate_audio:y().optional(),resolution:h(["480p","720p"]).optional(),aspect_ratio:h(["1:1","4:3","3:4","16:9","9:16","21:9","adaptive"]).optional(),duration:x().int().min(4).max(15).default(5),web_search:y().optional(),nsfw_checker:y().default(!1)}),e1=u({model:f("bytedance/seedance-2-fast"),callBackUrl:a().optional(),input:Zg}),t1=e1.refine(n=>{const e=(n.input.reference_image_urls?.length??0)>0||(n.input.reference_video_urls?.length??0)>0||(n.input.reference_audio_urls?.length??0)>0,t=!!n.input.first_frame_url||!!n.input.last_frame_url;return!(e&&t)},{message:"bytedance/seedance-2-fast does not accept reference_image_urls, reference_video_urls, or reference_audio_urls combined with first_frame_url or last_frame_url (these scenarios are mutually exclusive)",path:["input","reference_image_urls"]}),n1=u({prompt:a().min(3).max(2e4),first_frame_url:a().optional(),last_frame_url:a().optional(),reference_image_urls:k(a()).max(9).optional(),reference_video_urls:k(a()).max(3).optional(),reference_audio_urls:k(a()).max(3).optional(),return_last_frame:y().optional(),generate_audio:y().optional(),resolution:h(["480p","720p","1080p","4k"]).optional(),aspect_ratio:h(["1:1","4:3","3:4","16:9","9:16","21:9","adaptive"]).optional(),duration:x().int().min(4).max(15).default(5),web_search:y().optional(),nsfw_checker:y().default(!1)}),o1=u({model:f("bytedance/seedance-2"),callBackUrl:a().optional(),input:n1}),i1=o1.refine(n=>{const e=(n.input.reference_image_urls?.length??0)>0||(n.input.reference_video_urls?.length??0)>0||(n.input.reference_audio_urls?.length??0)>0,t=!!n.input.first_frame_url||!!n.input.last_frame_url;return!(e&&t)},{message:"bytedance/seedance-2 does not accept reference_image_urls, reference_video_urls, or reference_audio_urls combined with first_frame_url or last_frame_url (these scenarios are mutually exclusive)",path:["input","reference_image_urls"]}),Vt=a().refine(n=>{if(n.startsWith("asset://"))return/^asset:\/\/[^\s]+$/.test(n);try{return new URL(n),!0}catch{return!1}},"Expected a valid media URL or non-empty asset:// reference"),r1=u({prompt:a().max(3e4).optional(),first_frame_url:Vt.optional(),last_frame_url:Vt.optional(),reference_image_urls:k(Vt).max(30).optional(),reference_video_urls:k(Vt).max(10).optional(),reference_audio_urls:k(Vt).max(10).optional(),return_last_frame:y().default(!1),generate_audio:y().default(!0),resolution:h(["480p","720p","1080p"]).default("720p"),aspect_ratio:h(["1:1","4:3","3:4","16:9","9:16","21:9","adaptive"]).default("adaptive").describe("Output aspect ratio (default adaptive); first_frame_url or last_frame_url requires adaptive"),duration:P([f(-1),x().int().min(4).max(30)]).default(5),output_format:h(["mp4","mov"]).default("mp4"),web_search:y().optional(),nsfw_checker:y().default(!1)}),s1=u({model:f("bytedance/seedance-2-5"),callBackUrl:a().url().optional(),input:r1}),a1=s1.superRefine((n,e)=>{const{input:t}=n,o=!!t.first_frame_url,i=!!t.last_frame_url,r=o||i;if(i&&!o&&e.addIssue({code:"custom",message:"last_frame_url requires first_frame_url",path:["input","last_frame_url"]}),!!r){t.aspect_ratio!=="adaptive"&&e.addIssue({code:"custom",message:"Seedance 2.5 first-frame and first-last-frame tasks only support adaptive aspect ratio",path:["input","aspect_ratio"]});for(const s of["reference_image_urls","reference_video_urls","reference_audio_urls"])(t[s]?.length??0)>0&&e.addIssue({code:"custom",message:`${s} cannot be combined with first_frame_url or last_frame_url`,path:["input",s]})}}),l1=u({prompt:a().max(2e4).optional(),reference_image_urls:k(a()).max(9).default([]),reference_video_urls:k(a()).max(3).default([]),reference_audio_urls:k(a()).max(3).default([]),generate_audio:y().default(!0),resolution:Gf.default("720p"),aspect_ratio:Lf.default("16:9"),duration:x().int().min(4).max(15).default(5),web_search:y().default(!1),nsfw_checker:y().default(!0)}),c1=u({model:f("bytedance/seedance-2-mini"),callBackUrl:a().url().optional(),input:l1}),u1=h(["1:1","4:3","3:4","16:9","9:16","21:9"]),p1=h(["480p","720p","1080p"]),d1=u({prompt:a().min(3).max(2e4),input_urls:k(a()).max(2).optional(),aspect_ratio:u1,resolution:p1.default("720p"),duration:x().int().min(4).max(12),fixed_lens:y().default(!1),generate_audio:y().default(!1),nsfw_checker:y().default(!1)}),m1=u({model:f("bytedance/seedance-1.5-pro"),callBackUrl:a().optional(),input:d1}),h1=h(["square","square_hd","portrait_4_3","portrait_16_9","landscape_4_3","landscape_16_9"]),f1=u({prompt:a().min(3).max(5e3),image_size:h1.default("square_hd"),guidance_scale:x().min(1).max(10).default(2.5),seed:x().int().optional()}),g1=u({model:f("bytedance/seedream"),callBackUrl:a().optional(),input:f1}),cl=h(["square","square_hd","portrait_4_3","portrait_3_2","portrait_16_9","landscape_4_3","landscape_3_2","landscape_16_9","landscape_21_9"]),ul=h(["1K","2K","4K"]),x1=u({prompt:a().min(3).max(5e3),image_size:cl.default("square_hd"),image_resolution:ul.default("1K"),max_images:x().int().min(1).max(6).default(1),seed:x().int().optional(),nsfw_checker:y().default(!1)}),y1=u({model:f("bytedance/seedream-v4-text-to-image"),callBackUrl:a().optional(),input:x1}),S1=u({prompt:a().min(3).max(5e3),image_urls:k(a()).min(1).max(10),image_size:cl.default("square_hd"),image_resolution:ul.default("1K"),max_images:x().int().min(1).max(6).default(1),seed:x().int().optional(),nsfw_checker:y().default(!1)}),b1=u({model:f("bytedance/seedream-v4-edit"),callBackUrl:a().optional(),input:S1}),un=h(["5","10"]),so=h(["480p","720p","1080p"]),k1=h(["720p","1080p"]),_1=h(["16:9","4:3","1:1","3:4","9:16","9:21"]),w1=h(["21:9","16:9","4:3","1:1","3:4","9:16"]),ao=x().int().min(-1).max(2147483647).optional(),T1=u({prompt:a().min(3).max(1e4),image_url:a().min(1),resolution:so.default("720p"),duration:un.default("5"),camera_fixed:y().optional(),seed:ao,enable_safety_checker:y().optional(),end_image_url:a().optional(),nsfw_checker:y().default(!1)}),I1=u({model:f("bytedance/v1-lite-image-to-video"),callBackUrl:a().optional(),input:T1}),C1=u({prompt:a().min(3).max(1e4),aspect_ratio:_1.default("16:9"),resolution:so.default("720p"),duration:un.default("5"),camera_fixed:y().optional(),seed:ao,enable_safety_checker:y().optional(),nsfw_checker:y().default(!1)}),R1=u({model:f("bytedance/v1-lite-text-to-video"),callBackUrl:a().optional(),input:C1}),O1=u({prompt:a().min(3).max(1e4),image_url:a().min(1),resolution:k1.default("720p"),duration:un.default("5"),nsfw_checker:y().default(!1)}),M1=u({model:f("bytedance/v1-pro-fast-image-to-video"),callBackUrl:a().optional(),input:O1}),v1=u({prompt:a().min(3).max(1e4),image_url:a().min(1),resolution:so.default("720p"),duration:un.default("5"),camera_fixed:y().optional(),seed:ao,enable_safety_checker:y().optional(),nsfw_checker:y().default(!1)}),E1=u({model:f("bytedance/v1-pro-image-to-video"),callBackUrl:a().optional(),input:v1}),A1=u({prompt:a().min(3).max(1e4),aspect_ratio:w1.default("16:9"),resolution:so.default("720p"),duration:un.default("5"),camera_fixed:y().optional(),seed:ao,enable_safety_checker:y().optional(),nsfw_checker:y().default(!1)}),N1=u({model:f("bytedance/v1-pro-text-to-video"),callBackUrl:a().optional(),input:A1}),D1=u({model:f("nano-banana-2"),callBackUrl:a().url().optional(),input:u({prompt:a().min(1).max(2e4),image_input:k(a().url()).max(14).optional(),aspect_ratio:h(["1:1","1:4","1:8","2:3","3:2","3:4","4:1","4:3","4:5","5:4","8:1","9:16","16:9","21:9","auto"]).default("auto"),resolution:_i.default("1K"),output_format:wi.default("jpg")})}),pl=h(["540p","720p","1080p","2k","4k"]),dl=x().int().min(3).max(16),ni=a().refine(n=>{try{return["http:","https:"].includes(new URL(n).protocol)}catch{return!1}},"Expected an HTTP(S) media URL"),B1=u({model:f("vidu-q4/image-to-video"),callBackUrl:a().url().optional(),input:u({image_url:ni.describe("JPG/JPEG/PNG/WEBP image, up to 50 MB; output inherits its aspect ratio"),prompt:a().max(2e4).optional(),duration:dl.default(5),resolution:pl.default("720p"),audio:y().default(!0)})}),V1=h(["16:9","9:16","1:1","4:3","3:4"]),P1=u({model:f("vidu-q4/reference-to-video"),callBackUrl:a().url().optional(),input:u({prompt:a().min(1).max(2e4),reference_image_urls:k(ni).min(1).max(15).describe("JPG/JPEG/PNG/WEBP reference images, referenced in prompt by order"),reference_audio_urls:k(ni).max(3).optional().describe("MP3 references, 3-12 seconds each, up to 50 MB"),aspect_ratio:V1.default("16:9"),duration:dl.default(5),resolution:pl.default("720p"),audio:y().default(!0)})}),K1=u({model:f("nano-banana-2-1"),callBackUrl:a().url().optional(),input:u({prompt:a().min(1).max(2e4),image_input:k(a().url()).max(10).optional(),aspect_ratio:h(["1:1","1:4","1:8","2:3","3:2","3:4","4:1","4:3","4:5","5:4","8:1","9:16","16:9","21:9","auto"]).default("auto"),resolution:_i.default("1K"),output_format:wi.default("jpg")})}),z1=h(["1:1","1:4","1:8","2:3","3:2","3:4","4:1","4:3","4:5","5:4","8:1","9:16","16:9","21:9","auto"]),F1=u({model:f("nano-banana-2-lite"),callBackUrl:a().url().optional(),input:u({prompt:a().min(1).max(2e4),image_urls:k(a()).max(10).optional(),aspect_ratio:z1.default("auto")})}),q1=u({model:f("gpt-image/1.5-image-to-image"),callBackUrl:a().optional(),input:u({input_urls:k(a()).min(1).max(4),prompt:a().min(1),aspect_ratio:h(["1:1","2:3","3:2"]).optional(),quality:Ja.optional()})}),U1=h(["1:1","2:3","3:2"]),G1=u({model:f("gpt-image/1.5-text-to-image"),callBackUrl:a().optional(),input:u({prompt:a().min(1),aspect_ratio:U1,quality:Ja})}),L1=h(["auto","1:1","5:4","9:16","21:9","16:9","4:3","3:2","4:5","3:4","2:3"]),W1=h(["1K","2K","4K"]),$1=u({model:f("gpt-image-2-image-to-image"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(2e4),input_urls:k(a()).min(1).max(16),aspect_ratio:L1.default("auto"),resolution:W1.default("1K"),nsfw_checker:y().default(!1)})}),j1=h(["auto","1:1","3:2","2:3","4:3","3:4","5:4","4:5","9:16","16:9","2:1","1:2","3:1","1:3","21:9","9:21"]),H1=h(["1K","2K","4K"]),J1=u({model:f("gpt-image-2-text-to-image"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(2e4),aspect_ratio:j1.default("auto"),resolution:H1.default("1K"),nsfw_checker:y().default(!1)})}),lo=h(["auto","1:1","3:2","2:3","4:3","3:4","16:9","9:16","21:9","27:16","16:27","9:8","8:9"]),co=h(["1K","2K","4K"]),uo=h(["transparent","opaque","auto"]),Q1=new Set(["27:16","16:27","9:8","8:9"]),po=(n,e)=>{Q1.has(n.input.aspect_ratio)&&n.input.resolution!==void 0&&n.input.resolution!=="1K"&&e.addIssue({code:"custom",message:"27:16, 16:27, 9:8 and 8:9 support 1K only; 2K and 4K need another aspect_ratio",path:["input","resolution"]})},X1=u({model:f("gpt-image-2-5-flare-text-to-image"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(2e4),aspect_ratio:lo.default("auto"),resolution:co.default("1K"),background:uo.optional()})}).superRefine(po),Y1=u({model:f("gpt-image-2-5-flare-image-to-image"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(2e4),input_urls:k(a()).min(1).max(16),aspect_ratio:lo.default("auto"),resolution:co.default("1K"),background:uo.optional()})}).superRefine(po),Z1=u({model:f("gpt-image-2-5-sunburst-text-to-image"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(2e4),aspect_ratio:lo.default("auto"),resolution:co.default("1K"),background:uo.optional()})}).superRefine(po),e0=u({model:f("gpt-image-2-5-sunburst-image-to-image"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(2e4),input_urls:k(a()).min(1).max(16),aspect_ratio:lo.default("auto"),resolution:co.default("1K"),background:uo.optional()})}).superRefine(po),t0=u({model:f("seedream/5-lite-image-to-image"),callBackUrl:a().optional(),input:u({image_urls:k(a()).min(1).max(14),prompt:a().min(3).max(3e3),aspect_ratio:h(["1:1","4:3","3:4","16:9","9:16","2:3","3:2","21:9"]).default("16:9"),quality:h(["basic","high"]),nsfw_checker:y().default(!1)})}),n0=u({model:f("seedream/5-lite-text-to-image"),callBackUrl:a().optional(),input:u({prompt:a().min(3).max(3e3),aspect_ratio:h(["1:1","4:3","3:4","16:9","9:16","2:3","3:2","21:9"]).default("16:9"),quality:h(["basic","high"]),nsfw_checker:y().default(!1)})}),o0=u({model:f("seedream/5-pro-image-to-image"),callBackUrl:a().optional(),input:u({image_urls:k(a()).min(1).max(10),prompt:a().min(3).max(3e3),aspect_ratio:h(["1:1","4:3","3:4","16:9","9:16","2:3","3:2"]).default("1:1"),quality:h(["basic","high"]),output_format:h(["png","jpeg"]).default("png"),nsfw_checker:y().default(!1)})}),i0=u({model:f("seedream/5-pro-text-to-image"),callBackUrl:a().optional(),input:u({prompt:a().min(3).max(3e3),aspect_ratio:h(["1:1","4:3","3:4","16:9","9:16","2:3","3:2"]).default("1:1"),quality:h(["basic","high"]),output_format:h(["png","jpeg"]).default("png"),nsfw_checker:y().default(!1)})}),r0=u({model:f("seedream/5-flash-text-to-image"),callBackUrl:a().url().optional(),input:u({prompt:a().min(3).max(5e3),aspect_ratio:h(["1:1","4:3","3:4","16:9","9:16","2:3","3:2","21:9"]).default("1:1"),size:h(["1K","1.5K","2K"]).default("1K"),output_format:h(["png","jpeg"]).default("png"),nsfw_checker:y().optional()})}),s0=u({model:f("seedream/5-flash-image-to-image"),callBackUrl:a().url().optional(),input:u({image_urls:k(a().url()).min(1).max(10),prompt:a().min(3).max(5e3),aspect_ratio:h(["1:1","4:3","3:4","16:9","9:16","2:3","3:2","21:9"]).default("1:1"),size:h(["1K","1.5K","2K"]).default("1K"),output_format:h(["png","jpeg"]).default("png"),nsfw_checker:y().optional()})}),a0=u({model:f("seedream/5-pro-layer-decomposition"),callBackUrl:a().optional(),input:u({image_url:a().url(),prompt:a().max(5e3).optional(),size:h(["auto","1K","1.5K","2K"]).default("auto"),output_format:h(["png","jpeg"]).default("jpeg")})}),l0=u({model:f("seedream/5-flash-layer-decomposition"),callBackUrl:a().url().optional(),input:u({image_url:a().url(),prompt:a().min(3).max(5e3).optional(),size:h(["auto","1K","1.5K","2K"]).default("auto"),output_format:h(["png","jpeg"]).default("jpeg"),nsfw_checker:y().optional()})}),c0=u({model:f("seedream/4.5-text-to-image"),callBackUrl:a().optional(),input:u({prompt:a().min(3).max(3e3),aspect_ratio:h(["1:1","4:3","3:4","16:9","9:16","2:3","3:2","21:9"]).default("1:1"),quality:h(["basic","high"]),nsfw_checker:y().default(!1)})}),u0=u({model:f("seedream/4.5-edit"),callBackUrl:a().optional(),input:u({prompt:a().min(3).max(3e3),image_urls:k(a()).min(1).max(14),aspect_ratio:h(["1:1","4:3","3:4","16:9","9:16","2:3","3:2","21:9"]).default("1:1"),quality:h(["basic","high"]),nsfw_checker:y().default(!1)})}),p0=u({model:f("recraft/crisp-upscale"),callBackUrl:a().url().optional(),input:u({image:a().min(1)})}),d0=u({model:f("recraft/remove-background"),callBackUrl:a().url().optional(),input:u({image:a().min(1)})}),m0=u({model:f("happyhorse/text-to-video"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(5e3),resolution:yt.optional(),aspect_ratio:Ya.optional(),duration:Et.optional(),seed:x().int().min(0).max(2147483647).optional()})}),h0=u({model:f("happyhorse/image-to-video"),callBackUrl:a().optional(),input:u({prompt:a().max(5e3).optional(),image_urls:k(a()).min(1).max(1),resolution:yt.optional(),duration:Et.optional(),seed:x().int().min(0).max(2147483647).optional()})}),f0=u({model:f("happyhorse/reference-to-video"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(5e3),reference_image:k(a()).min(1).max(9),resolution:yt.optional(),aspect_ratio:Ya.optional(),duration:Et.optional(),seed:x().int().min(0).max(2147483647).optional()})}),g0=u({model:f("happyhorse/video-edit"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(5e3),video_url:a().min(1),reference_image:k(a()).max(5).optional(),resolution:yt.optional(),audio_setting:Vf.optional(),seed:x().int().min(0).max(2147483647).optional()})}),x0=u({model:f("happyhorse-1-1/text-to-video"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(5e3),resolution:yt.default("1080p"),aspect_ratio:Za.default("16:9"),duration:Et.default(5)})}),y0=u({model:f("happyhorse-1-1/image-to-video"),callBackUrl:a().optional(),input:u({prompt:a().max(5e3).default(""),image_urls:k(a().url()).min(1).max(1),resolution:yt.default("1080p"),duration:Et.default(5)})}),S0=u({model:f("happyhorse-1-1/reference-to-video"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(5e3),reference_image:k(a().url()).min(1).max(9),resolution:yt.default("1080p"),aspect_ratio:Za.default("16:9"),duration:Et.default(5)})});P([f(200),f(401),f(402),f(404),f(422),f(429),f(433),f(455),f(500),f(501),f(505)]);const b0=P([f(401),f(402),f(404),f(422),f(429),f(433),f(455),f(500),f(501),f(505)]);P([u({code:f(200),msg:a(),data:u({taskId:a()})}),u({code:b0,msg:a(),data:K().optional()})]);const k0=u({model:f("omnihuman-1-5"),callBackUrl:a().url().optional(),input:u({image_url:a().url(),mask_url:k(a().url()).max(5).optional(),audio_url:a().url(),prompt:a().max(1e3).optional(),output_resolution:zf.default("1080"),pe_fast_mode:y().default(!1),seed:x().int().min(-1).default(-1)})}),_0=u({model:f("omnihuman-1-5/human-identification"),callBackUrl:a().url().optional(),input:u({image_url:a().url()})}),w0=u({model:f("omnihuman-1-5/subject-detection"),callBackUrl:a().url().optional(),input:u({image_url:a().url()})}),T0=u({model:f("volcengine/video-to-video-lip-sync"),callBackUrl:a().optional(),input:u({mode:Ff,video_url:a().min(1),audio_url:a().min(1),separate_vocal:y().default(!1),open_scenedet:y().default(!1),align_audio:y().default(!0),align_audio_reverse:y().default(!1),templ_start_seconds:x().min(0).default(0)})}),I0=u({url:a().url(),start:x().min(0),ends:x().min(0)}).superRefine((n,e)=>{n.ends<=n.start&&e.addIssue({code:"custom",message:"ends must be greater than start",path:["ends"]}),n.ends-n.start>=10&&e.addIssue({code:"custom",message:"video clip duration must be less than 10 seconds",path:["ends"]})}),C0=u({model:f("gemini-omni-video"),callBackUrl:a().url().optional(),input:u({prompt:a().min(1).max(2e4),image_urls:k(a().url()).max(7).optional(),audio_ids:k(a().min(1)).max(3).optional(),video_list:k(I0).max(1).optional(),character_ids:k(a().min(1)).max(3).optional(),duration:el,aspect_ratio:tl.optional(),seed:x().int().min(0).max(2147483647).optional(),resolution:qf.default("720p")})}).superRefine((n,e)=>{const t=n.input.image_urls?.length??0,o=(n.input.video_list?.length??0)*2,i=n.input.character_ids?.length??0;t+o+i>7&&e.addIssue({code:"custom",message:"gemini-omni-video quota exceeded: image_urls + video_list * 2 + character_ids must be <= 7",path:["input","image_urls"]})}),R0=u({url:a().url(),start:x().min(0),ends:x().min(0)}).superRefine((n,e)=>{n.ends<=n.start&&e.addIssue({code:"custom",message:"ends must be greater than start",path:["ends"]}),n.ends-n.start>10&&e.addIssue({code:"custom",message:"video clip duration must not exceed 10 seconds",path:["ends"]})}),O0=u({model:f("google/gemini-omni-flash-1-1"),callBackUrl:a().url().optional(),input:u({prompt:a().min(1).max(2e4),image_urls:k(a().url()).max(7).optional(),first_frame_url:a().url().optional(),last_frame_url:a().url().optional(),audio_ids:k(a().min(1)).max(3).optional(),video_list:k(R0).max(1).optional(),character_ids:k(a().min(1)).max(7).optional(),duration:el,aspect_ratio:tl.optional(),seed:x().int().min(0).max(2147483647).optional(),resolution:Uf.default("720p")})}).superRefine((n,e)=>{const t=l=>l!==void 0&&l.length>0;n.input.last_frame_url!==void 0&&n.input.first_frame_url===void 0&&e.addIssue({code:"custom",message:"last_frame_url requires first_frame_url",path:["input","last_frame_url"]}),n.input.first_frame_url!==void 0&&(t(n.input.image_urls)&&e.addIssue({code:"custom",message:"first_frame_url cannot be combined with image_urls",path:["input","image_urls"]}),t(n.input.audio_ids)&&e.addIssue({code:"custom",message:"first_frame_url cannot be combined with audio_ids",path:["input","audio_ids"]}),t(n.input.video_list)&&e.addIssue({code:"custom",message:"first_frame_url cannot be combined with video_list",path:["input","video_list"]}),t(n.input.character_ids)&&e.addIssue({code:"custom",message:"first_frame_url cannot be combined with character_ids",path:["input","character_ids"]})),(n.input.character_ids?.length??0)>3&&(n.input.video_list?.length??0)>0&&e.addIssue({code:"custom",message:"character_ids must be <= 3 when video_list is provided",path:["input","character_ids"]});const o=n.input.image_urls?.length??0,i=(n.input.video_list?.length??0)*2,r=n.input.character_ids?.length??0;o+i+r>7&&e.addIssue({code:"custom",message:"google/gemini-omni-flash-1-1 quota exceeded: image_urls + video_list * 2 + character_ids must be <= 7",path:["input","image_urls"]})}),fe={stability:{minimum:0,maximum:1,default:.5},similarity_boost:{minimum:0,maximum:1,default:.75},style:{minimum:0,maximum:1,default:0},speed:{minimum:.7,maximum:1.2,default:1}},Rn={values:[0,.5,1],default:.5},ml=u({text:a().min(1),voice:a().min(1),stability:x().min(fe.stability.minimum).max(fe.stability.maximum).default(fe.stability.default),similarity_boost:x().min(fe.similarity_boost.minimum).max(fe.similarity_boost.maximum).default(fe.similarity_boost.default),style:x().min(fe.style.minimum).max(fe.style.maximum).default(fe.style.default),speed:x().min(fe.speed.minimum).max(fe.speed.maximum).default(fe.speed.default),timestamps:y().optional(),previous_text:a().optional(),next_text:a().optional(),language_code:a().optional()}),M0=u({model:f("elevenlabs/audio-isolation"),callBackUrl:a().optional(),input:u({audio_url:a().min(1)})}),v0=u({model:f("elevenlabs/text-to-dialogue-v3"),callBackUrl:a().optional(),input:u({dialogue:k(u({text:a().min(1),voice:a().min(1)})).min(1),stability:P([f(Rn.values[0]),f(Rn.values[1]),f(Rn.values[2])]).default(Rn.default)})}),E0=u({model:f("elevenlabs/text-to-speech-multilingual-v2"),callBackUrl:a().optional(),input:ml}),A0=u({model:f("elevenlabs/text-to-speech-turbo-2-5"),callBackUrl:a().optional(),input:ml}),N0=u({model:f("elevenlabs/sound-effect-v2"),callBackUrl:a().optional(),input:u({text:a(),loop:y().optional(),prompt_influence:x().optional(),output_format:a().optional()})}),D0=h(["480P","720P","1080P"]),B0=h(["adaptive","16:9","4:3","1:1","3:4","9:16"]),V0=P([f(-1),x().int().min(2).max(30)]),hl={prompt:a().max(2e4).optional(),first_frame_url:a().optional(),last_frame_url:a().optional(),reference_image_urls:k(a()).max(10).optional(),reference_video_urls:k(a()).max(5).optional(),reference_audio_urls:k(a()).max(5).optional(),reference_file_urls:k(a()).max(1).optional(),reference_link_urls:k(a()).max(1).optional(),resolution:D0.optional(),aspect_ratio:B0.optional(),duration:V0.optional(),audio:y().optional(),seed:x().int().min(0).max(2147483647).optional(),nsfw_checker:y().default(!1)},P0=u({model:f("wan/3-0-video"),callBackUrl:a().optional(),input:u(hl)}).refine(n=>!((n.input.first_frame_url||n.input.last_frame_url)&&(n.input.reference_image_urls?.length||n.input.reference_video_urls?.length||n.input.reference_audio_urls?.length||n.input.reference_file_urls?.length||n.input.reference_link_urls?.length)),{message:"wan/3-0-video does not accept first_frame_url or last_frame_url combined with any reference_* parameter",path:["input","first_frame_url"]}).refine(n=>!(n.input.reference_file_urls?.length&&n.input.reference_link_urls?.length),{message:"wan/3-0-video does not accept reference_file_urls combined with reference_link_urls",path:["input","reference_file_urls"]}).refine(n=>!!n.input.prompt||!!n.input.first_frame_url||!!n.input.last_frame_url||!!n.input.reference_image_urls?.length||!!n.input.reference_video_urls?.length||!!n.input.reference_audio_urls?.length||!!n.input.reference_file_urls?.length||!!n.input.reference_link_urls?.length,{message:"wan/3-0-video requires a prompt or at least one media input",path:["input","prompt"]}),K0=u({model:f("wan/3-0-video-prime"),callBackUrl:a().optional(),input:u(hl)}).refine(n=>!((n.input.first_frame_url||n.input.last_frame_url)&&(n.input.reference_image_urls?.length||n.input.reference_video_urls?.length||n.input.reference_audio_urls?.length||n.input.reference_file_urls?.length||n.input.reference_link_urls?.length)),{message:"wan/3-0-video-prime does not accept first_frame_url or last_frame_url combined with any reference_* parameter",path:["input","first_frame_url"]}).refine(n=>!(n.input.reference_file_urls?.length&&n.input.reference_link_urls?.length),{message:"wan/3-0-video-prime does not accept reference_file_urls combined with reference_link_urls",path:["input","reference_file_urls"]}).refine(n=>!!n.input.prompt||!!n.input.first_frame_url||!!n.input.last_frame_url||!!n.input.reference_image_urls?.length||!!n.input.reference_video_urls?.length||!!n.input.reference_audio_urls?.length||!!n.input.reference_file_urls?.length||!!n.input.reference_link_urls?.length,{message:"wan/3-0-video-prime requires a prompt or at least one media input",path:["input","prompt"]}),z0=u({model:f("wan/2-7-image-to-video"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(5e3),negative_prompt:a().max(500).optional(),first_frame_url:a().optional(),last_frame_url:a().optional(),first_clip_url:a().optional(),driving_audio_url:a().optional(),resolution:no.optional(),duration:x().int().min(2).max(15).optional(),prompt_extend:y().optional(),watermark:y().optional(),seed:x().int().min(0).max(2147483647).optional(),nsfw_checker:y().default(!1)})}).refine(n=>!!n.input.first_frame_url||!!n.input.last_frame_url||!!n.input.first_clip_url,{message:"wan/2-7-image-to-video requires at least one of first_frame_url, last_frame_url, or first_clip_url",path:["input","first_frame_url"]}).refine(n=>!(n.input.first_clip_url&&(n.input.first_frame_url||n.input.last_frame_url)),{message:"wan/2-7-image-to-video does not accept first_clip_url combined with first_frame_url or last_frame_url",path:["input","first_clip_url"]}),F0=u({model:f("wan/2-7-text-to-video"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(5e3),negative_prompt:a().max(500).optional(),audio_url:a().optional(),resolution:no.optional(),ratio:Ii.optional(),duration:x().int().min(2).max(15).optional(),prompt_extend:y().optional(),watermark:y().optional(),seed:x().int().min(0).max(2147483647).optional(),nsfw_checker:y().default(!1)})}),q0=u({model:f("wan/2-7-r2v"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(5e3),negative_prompt:a().max(500).optional(),reference_image:k(a()).max(5).optional(),reference_video:k(a()).max(5).optional(),first_frame:a().optional(),reference_voice:a().optional(),resolution:no.optional(),aspect_ratio:Ii.optional(),duration:x().int().min(2).max(10).optional(),prompt_extend:y().optional(),watermark:y().optional(),seed:x().int().min(0).max(2147483647).optional(),nsfw_checker:y().default(!1)})}),U0=u({model:f("wan/2-7-videoedit"),callBackUrl:a().optional(),input:u({prompt:a().max(5e3).optional(),negative_prompt:a().max(500).optional(),video_url:a().min(1),reference_image:a().optional(),resolution:no.optional(),aspect_ratio:Ii.optional(),duration:Bf.optional(),audio_setting:Af.optional(),prompt_extend:y().optional(),watermark:y().optional(),seed:x().int().min(0).max(2147483647).optional(),nsfw_checker:y().default(!1)})}),G0={prompt:a().min(1).max(5e3),input_urls:k(a()).max(9).optional(),aspect_ratio:Df.default("16:9"),enable_sequential:y().optional(),n:x().int().min(1).max(12).optional(),resolution:Nf.optional(),thinking_mode:y().optional(),color_palette:k(Yf).min(3).max(10).optional(),bbox_list:k(k(k(x().multipleOf(1)).length(4)).max(2)).optional(),watermark:y().optional(),seed:x().int().min(0).max(2147483647).optional(),nsfw_checker:y().default(!1)},fl=n=>n.input.aspect_ratio===void 0||n.input.resolution!==void 0,gl={message:"aspect_ratio requires resolution",path:["input","resolution"]},xl=n=>{if(n.input.resolution!=="4K")return!0;if(n.input.enable_sequential===!0)return!1;const e=n.input.input_urls;return!(Array.isArray(e)&&e.length>0)},yl={message:"resolution 4K is only supported for non-sequential text-to-image",path:["input","resolution"]},Sl=u(G0),L0=u({model:f("wan/2-7-image"),callBackUrl:a().optional(),input:Sl}),W0=u({model:f("wan/2-7-image-pro"),callBackUrl:a().optional(),input:Sl}),$0=L0.refine(fl,gl).refine(xl,yl),j0=W0.refine(fl,gl).refine(xl,yl),bl=h(["480p","720p"]),kl=h(["none","regular"]),H0=h(["16:9","9:16"]),Di=h(["480p","580p","720p"]),_l=h(["5","10"]),wl=h(["720p","1080p"]),J0=h(["16:9","9:16","1:1"]),Bi=h(["5","10","15"]),Tl=h(["5","10"]),pn=h(["720p","1080p"]),Il=x().int().min(0).max(2147483647).optional(),Q0=x().int().min(40).max(120).refine(n=>n%4===0,{message:"must be a multiple of 4"}),Qr=n=>x().min(1).max(10).refine(e=>Number.isInteger(e*10),{message:"must be in increments of 0.1"}).default(n),X0=u({model:f("wan/2-2-a14b-image-to-video-turbo"),callBackUrl:a().optional(),input:u({image_url:a().min(1),prompt:a().min(1).max(5e3),resolution:bl.default("720p"),enable_prompt_expansion:y().optional(),seed:Il,acceleration:kl.default("none"),nsfw_checker:y().default(!1)})}),Y0=u({model:f("wan/2-2-a14b-speech-to-video-turbo"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(5e3),image_url:a().min(1),audio_url:a().min(1),num_frames:Q0.default(80),frames_per_second:x().int().min(4).max(60).default(16),resolution:Di.default("480p"),negative_prompt:a().max(500).optional(),seed:x().int().optional(),num_inference_steps:x().int().min(2).max(40).default(27),guidance_scale:Qr(3.5),shift:Qr(5),nsfw_checker:y().default(!1)})}),Z0=u({model:f("wan/2-2-a14b-text-to-video-turbo"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(5e3),resolution:bl.default("720p"),aspect_ratio:H0.default("16:9"),enable_prompt_expansion:y().optional(),seed:Il,acceleration:kl.default("none"),nsfw_checker:y().default(!1)})}),ex=u({model:f("wan/2-2-animate-move"),callBackUrl:a().optional(),input:u({video_url:a().min(1),image_url:a().min(1),resolution:Di.default("480p"),nsfw_checker:y().default(!1)})}),tx=u({model:f("wan/2-2-animate-replace"),callBackUrl:a().optional(),input:u({video_url:a().min(1),image_url:a().min(1),resolution:Di.default("480p"),nsfw_checker:y().default(!1)})}),nx=u({model:f("wan/2-5-image-to-video"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(800),image_url:a().min(1),duration:_l,resolution:wl.optional(),negative_prompt:a().max(500).optional(),enable_prompt_expansion:y().optional(),seed:x().int().optional(),nsfw_checker:y().default(!1)})}),ox=u({model:f("wan/2-5-text-to-video"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(800),duration:_l,aspect_ratio:J0.optional(),resolution:wl.optional(),negative_prompt:a().max(500).optional(),enable_prompt_expansion:y().optional(),seed:x().int().optional(),nsfw_checker:y().default(!1)})}),ix=u({model:f("wan/2-6-flash-image-to-video"),callBackUrl:a().optional(),input:u({prompt:a().min(2).max(1500),image_urls:k(a().min(1)).min(1).max(1),duration:Bi.default("5"),resolution:pn.default("1080p"),audio:y(),multi_shots:y().optional(),nsfw_checker:y().default(!1)})}),rx=u({model:f("wan/2-6-flash-video-to-video"),callBackUrl:a().optional(),input:u({prompt:a().min(2).max(1500),video_urls:k(a().min(1)).min(1).max(3),duration:Tl.default("5"),resolution:pn.default("1080p"),audio:y().optional(),multi_shots:y().optional(),nsfw_checker:y().default(!1)})}),sx=u({model:f("wan/2-6-image-to-video"),callBackUrl:a().optional(),input:u({prompt:a().min(2).max(5e3),image_urls:k(a().min(1)).min(1).max(1),duration:Bi.default("5"),resolution:pn.default("1080p"),multi_shots:y().default(!1),nsfw_checker:y().default(!1)})}),ax=u({model:f("wan/2-6-text-to-video"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(5e3),duration:Bi.default("5"),resolution:pn.default("1080p"),multi_shots:y().default(!1),nsfw_checker:y().default(!1)})}),lx=u({model:f("wan/2-6-video-to-video"),callBackUrl:a().optional(),input:u({prompt:a().min(2).max(5e3),video_urls:k(a().min(1)).min(1).max(3),duration:Tl.default("5"),resolution:pn.default("1080p"),multi_shots:y().default(!1),nsfw_checker:y().default(!1)})}),dn=a().min(3).max(5e3),mn=h(["360p","540p","720p","1080p"]),Cl=h(["16:9","4:3","1:1","3:4","9:16","2:3","3:2","21:9"]),hn=x().int().min(1).max(15),fn=x().int().min(0).max(2147483647),cx=u({prompt:dn,aspect_ratio:Cl,quality:mn,duration:hn,generate_audio_switch:y().default(!1),generate_multi_clip_switch:y().default(!1),seed:fn.optional()}),ux=u({model:f("pixverse-v6/text-to-video"),callBackUrl:a().url().optional(),input:cx}),px=u({prompt:dn,image_urls:k(a().url()).min(1).max(2),quality:mn,duration:hn.optional(),template_id:a().min(1).optional(),generate_audio_switch:y().default(!1),generate_multi_clip_switch:y().default(!1),seed:fn.optional()}),dx=u({model:f("pixverse-v6/image-to-video"),callBackUrl:a().url().optional(),input:px}).superRefine((n,e)=>{const t=n.input.duration!==void 0,o=n.input.template_id!==void 0;t===o&&e.addIssue({code:"custom",message:"pixverse-v6/image-to-video requires exactly one of duration or template_id",path:["input","duration"]})}),mx=u({prompt:dn,first_frame_image_url:a().url(),last_frame_image_url:a().url(),quality:mn,duration:hn,generate_audio_switch:y().default(!1),seed:fn.optional()}),hx=u({model:f("pixverse-v6/transition"),callBackUrl:a().url().optional(),input:mx}),fx=u({prompt:dn,duration:hn,quality:mn,taskId:a().min(1).optional(),video_url:a().url().optional(),generate_audio_switch:y().optional(),seed:fn.optional()}),gx=u({model:f("pixverse-v6/extend"),callBackUrl:a().url().optional(),input:fx}).superRefine((n,e)=>{n.input.taskId!==void 0==(n.input.video_url!==void 0)&&e.addIssue({code:"custom",message:"pixverse-v6/extend requires exactly one of taskId or video_url",path:["input","video_url"]})}),xx=u({image_url:a().url(),type:h(["subject","background"]).default("subject"),ref_name:a().min(1).max(30).optional()}),yx=u({prompt:dn,image_references:k(xx).min(1).max(7),aspect_ratio:Cl,quality:mn,duration:hn,generate_audio_switch:y().default(!1),seed:fn.optional()}),Sx=u({model:f("pixverse-v6/reference-to-video"),callBackUrl:a().url().optional(),input:yx}).superRefine((n,e)=>{const t=new Set;for(const[o,i]of n.input.image_references.entries()){const r=i.ref_name;r!==void 0&&(t.has(r)&&e.addIssue({code:"custom",message:`pixverse-v6/reference-to-video requires unique ref_name values within image_references (duplicate: ${r})`,path:["input","image_references",o,"ref_name"]}),t.add(r))}}),bx=u({prompt:Ci,aspect_ratio:nl,duration:Ri,resolution:Oi.optional()}).strict(),kx=u({model:f("minimax-h3/text-to-video"),callBackUrl:a().url().optional(),input:bx}),_x=u({prompt:Ci,first_frame_url:$t.optional(),last_frame_url:$t.optional(),duration:Ri,resolution:Oi.optional()}).strict(),wx=u({model:f("minimax-h3/image-to-video"),callBackUrl:a().url().optional(),input:_x}).superRefine((n,e)=>{n.input.first_frame_url===void 0&&n.input.last_frame_url===void 0&&e.addIssue({code:"custom",message:"At least one of input.first_frame_url or input.last_frame_url is required",path:["input","first_frame_url"]})}),Tx=u({prompt:Ci,reference_image_urls:k($t).max(9).optional(),reference_video_urls:k($t).max(3).optional().describe(`MP4/MOV reference videos. ${Jr(Hr.video)}; Kie rejects a clip outside the per-file window at submission. URLs are not inspected locally, so check local media against MiniMaxH3ReferenceClipDurationMs.video.`),reference_audio_urls:k($t).max(3).optional().describe(`WAV/MP3 reference audio; it cannot be the sole reference. ${Jr(Hr.audio)}, as documented upstream but not yet observed at runtime. URLs are not inspected locally, so check local media against MiniMaxH3ReferenceClipDurationMs.audio.`),aspect_ratio:$f.optional(),duration:Ri,resolution:Oi.optional()}).strict(),Ix=u({model:f("minimax-h3/reference-to-video"),callBackUrl:a().url().optional(),input:Tx}).superRefine((n,e)=>{const t=!!n.input.reference_image_urls?.length,o=!!n.input.reference_video_urls?.length;!t&&!o&&e.addIssue({code:"custom",message:"At least one non-empty input.reference_image_urls or input.reference_video_urls array is required",path:["input","reference_image_urls"]})}),Cx=u({speaker_id:Xn,voice_name:lm,audio_profile:a().optional(),accent:cm,style:um.optional(),pace:pm.optional()}).strict(),Rx=u({speaker_id:Xn,text:a().min(1).max(dm)}).strict(),Rl=u({temperature:x().min(jr.minimum).max(jr.maximum).optional(),scene:a().optional(),sample_context:a().optional(),speakers:k(Cx).min(1),dialogue_turns:k(Rx).min(1)}).strict(),Ox=u({model:f("google/gemini-2-5-pro-tts"),callBackUrl:a().url().optional(),input:Rl}),Mx=u({model:f("google/gemini-3-1-flash-tts"),callBackUrl:a().url().optional(),input:Rl}),vx=["Bodi","Lumi","Sadaltager","Sola","Sulafat","Varo","Zephyr","Koda","Kore","Nika","Tavi","Zeno","Algenib","Despina","Erinome","Kira","Ludo","Mako","Rasalgethi","Rina","Alnilam","Brio","Jori","Laomedeia","Rami","Veda","Achird","Enzo","Riko","Sami","Zali","Zubenelgenubi","Algieba","Aoede","Autonoe","Callirrhoe","Enceladus","Gero","Iapetus","Neno","Olin","Tari","Umbriel","Achernar","Charon","Daro","Fola","Hali","Milo","Puck","Arlo","Cleo","Fenrir","Finn","Leda","Lora","Orus","Enya","Jett","Knox","Nyla","Sadachbia","Vindemiatrix","Cruz","Elio","Gacrux","Pulcherrima","Schedar","Tova","Zuri"],Ex=h(vx),Ax=u({speaker_id:Xn,voice_name:Ex.default("Fola")}).strict(),Nx=u({speaker_id:Xn,text:a().min(1).max(1e4),style:a().optional()}).strict(),Ol=u({temperature:x().min(0).max(2).default(1),speakers:k(Ax).min(1),filler_words:y().default(!1),dialogue_turns:k(Nx).min(1)}).strict(),Dx=u({model:f("google/gemini-3-8-flash-tts"),callBackUrl:a().url().optional(),input:Ol}),Bx=u({model:f("google/gemini-3-8-flash-lite-tts"),callBackUrl:a().url().optional(),input:Ol}),Ml=h(["1:1","16:9","9:16","3:4","4:3","auto"]),vl=u({prompt:a().min(1).max(5e3),negative_prompt:a().max(5e3).optional(),aspect_ratio:Ml.optional(),seed:a().max(500).optional()}),Vx=u({prompt:a().min(1).max(5e3),negative_prompt:a().max(5e3).optional(),aspect_ratio:Ml.optional(),seed:x().int().optional()}),Px=u({model:f("google/imagen4"),callBackUrl:a().optional(),input:vl}),Kx=u({model:f("google/imagen4-fast"),callBackUrl:a().optional(),input:Vx}),zx=u({model:f("google/imagen4-ultra"),callBackUrl:a().optional(),input:vl}),Ln=h(["1:1","9:16","16:9","3:4","4:3","3:2","2:3","5:4","4:5","21:9","auto"]),El=h(["png","jpeg"]),Fx=u({model:f("google/nano-banana"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(5e3),output_format:El.optional(),aspect_ratio:Ln.optional(),image_size:Ln.optional(),nsfw_checker:y().optional()})}),qx=u({model:f("google/nano-banana-edit"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(5e3),image_urls:k(a()).min(1).max(10),output_format:El.optional(),aspect_ratio:Ln.optional(),image_size:Ln.optional()})}),Al=h(["1","2","4"]),Ux=u({model:f("topaz/image-upscale"),callBackUrl:a().optional(),input:u({image_url:a().min(1),upscale_factor:Al})}),Gx=u({model:f("topaz/video-upscale"),callBackUrl:a().optional(),input:u({video_url:a().min(1),upscale_factor:Al.optional()})}),Lx=h(["480p","720p"]),Wx=u({model:f("infinitalk/from-audio"),callBackUrl:a().url().optional(),input:u({image_url:a().min(1),audio_url:a().min(1),prompt:a().min(1).max(5e3),resolution:Lx.optional(),seed:x().int().min(1e4).max(1e6).optional()})}),$x=h(["1:1","4:3","3:4","16:9","9:16"]),jx=u({model:f("z-image"),callBackUrl:a().url().optional(),input:u({prompt:a().min(1).max(1e3),aspect_ratio:$x,nsfw_checker:y().default(!1)})}),Nt=h(["TURBO","BALANCED","QUALITY"]),mo=h(["square","square_hd","portrait_4_3","portrait_16_9","landscape_4_3","landscape_16_9"]),ho=h(["1","2","3","4"]),Nl=h(["AUTO","GENERAL","REALISTIC","DESIGN"]),Vi=h(["AUTO","REALISTIC","FICTION"]),Hx=u({model:f("ideogram/v3-text-to-image"),callBackUrl:a().url().optional(),input:u({prompt:a().min(1).max(5e3),rendering_speed:Nt.optional(),style:Nl.optional(),expand_prompt:y().optional(),image_size:mo.optional(),seed:x().int().optional(),negative_prompt:a().max(5e3).optional()})}),Jx=u({model:f("ideogram/v3-edit"),callBackUrl:a().url().optional(),input:u({prompt:a().min(1).max(5e3),image_url:a().min(1),mask_url:a().min(1),rendering_speed:Nt.optional(),expand_prompt:y().optional(),seed:x().int().optional()})}),Qx=u({model:f("ideogram/v3-remix"),callBackUrl:a().url().optional(),input:u({prompt:a().min(1).max(5e3),image_url:a().min(1),rendering_speed:Nt.optional(),style:Nl.optional(),expand_prompt:y().optional(),image_size:mo.optional(),num_images:ho.optional(),seed:x().int().optional(),strength:x().min(.01).max(1).optional(),negative_prompt:a().max(5e3).optional()})}),Xx=u({model:f("ideogram/character"),callBackUrl:a().url().optional(),input:u({prompt:a().min(1).max(5e3),reference_image_urls:k(a().min(1)).min(1),rendering_speed:Nt.optional(),style:Vi.optional(),expand_prompt:y().optional(),num_images:ho.optional(),image_size:mo.optional(),seed:x().int().optional(),negative_prompt:a().max(5e3).optional()})}),Yx=u({model:f("ideogram/character-edit"),callBackUrl:a().url().optional(),input:u({prompt:a().min(1).max(5e3),image_url:a().min(1),mask_url:a().min(1),reference_image_urls:k(a().min(1)).min(1),rendering_speed:Nt.optional(),style:Vi.optional(),expand_prompt:y().optional(),num_images:ho.optional(),seed:x().int().optional()})}),Zx=u({model:f("ideogram/character-remix"),callBackUrl:a().url().optional(),input:u({prompt:a().min(1).max(5e3),image_url:a().min(1),reference_image_urls:k(a().min(1)).min(1),rendering_speed:Nt.optional(),style:Vi.optional(),expand_prompt:y().optional(),image_size:mo.optional(),num_images:ho.optional(),seed:x().int().optional(),strength:x().min(.1).max(1).optional(),negative_prompt:a().max(500).optional(),image_urls:k(a().min(1)).optional(),reference_mask_urls:a().optional()})}),ey=h(["1:1","4:3","3:4","16:9","9:16","3:2","2:3"]),ty=h(["1:1","4:3","3:4","16:9","9:16","3:2","2:3","auto"]),Dl=h(["1K","2K"]),Bl=u({prompt:a().min(3).max(5e3),aspect_ratio:ey,resolution:Dl,nsfw_checker:y().default(!1)}),Vl=u({input_urls:k(a()).min(1).max(8),prompt:a().min(3).max(5e3),aspect_ratio:ty,resolution:Dl,nsfw_checker:y().default(!1)}),ny=u({model:f("flux-2/pro-text-to-image"),callBackUrl:a().optional(),input:Bl}),oy=u({model:f("flux-2/flex-text-to-image"),callBackUrl:a().optional(),input:Bl}),iy=u({model:f("flux-2/pro-image-to-image"),callBackUrl:a().optional(),input:Vl}),ry=u({model:f("flux-2/flex-image-to-image"),callBackUrl:a().optional(),input:Vl}),Pl=h(["1:1","4:3","3:4","3:2","2:3","16:9","9:16","21:9","9:21"]),sy=h(["1K","2K","4K"]),Kl={prompt:a().min(1).max(5e3),resolution:sy.default("1K"),width:x().int().min(256).max(4096).optional(),height:x().int().min(256).max(4096).optional(),output_format:h(["png","jpeg","webp"]).default("png"),num_images:x().int().min(1).max(4).default(1),seed:x().int().min(0).max(2147483647).optional(),enhance_prompt:y().default(!0),nsfw_checker:y().default(!1)},zl=(n,e)=>{const{width:t,height:o}=n.input;t===void 0!=(o===void 0)?e.addIssue({code:"custom",path:["input","width"],message:"width and height must be supplied together"}):t!==void 0&&o!==void 0&&(t/o<.4||t/o>2.5)&&e.addIssue({code:"custom",path:["input","width"],message:"Custom width:height must be between 1:2.5 and 2.5:1"})},ay=u({model:f("flux-3/klein-text-to-image"),callBackUrl:a().optional(),input:u({...Kl,aspect_ratio:Pl.default("1:1")})}).superRefine(zl),ly=u({model:f("flux-3/klein-edit-image"),callBackUrl:a().optional(),input:u({...Kl,image_urls:k(a().regex(/^https?:\/\/.+/)).min(1).max(10),aspect_ratio:h([...Pl.options,"auto"]).default("auto")})}).superRefine(zl),Pi=h(["6","10"]),cy=h(["512P","768P"]),uy=h(["768P","1080P"]);function py(n,e){n.duration==="10"&&n.resolution==="1080P"&&e.addIssue({code:"custom",message:"hailuo 2-3 image-to-video does not support 10 second videos at 1080P",path:["duration"]})}const dy=u({model:f("hailuo/02-text-to-video-pro"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(1500),prompt_optimizer:y().optional(),nsfw_checker:y().default(!1)})}),my=u({model:f("hailuo/02-text-to-video-standard"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(1500),duration:Pi.optional(),prompt_optimizer:y().optional(),nsfw_checker:y().default(!1)})}),hy=u({model:f("hailuo/02-image-to-video-pro"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(1500),image_url:a().min(1),end_image_url:a().min(1).optional(),prompt_optimizer:y().optional(),nsfw_checker:y().default(!1)})}),fy=u({model:f("hailuo/02-image-to-video-standard"),callBackUrl:a().optional(),input:u({prompt:a().min(1).max(1500),image_url:a().min(1),end_image_url:a().min(1).optional(),duration:Pi.optional(),resolution:cy.optional(),prompt_optimizer:y().optional(),nsfw_checker:y().default(!1)})}),Fl=u({prompt:a().min(1).max(5e3),image_url:a().min(1),duration:Pi.optional(),resolution:uy.optional(),nsfw_checker:y().default(!1)}).superRefine(py),gy=u({model:f("hailuo/2-3-image-to-video-pro"),callBackUrl:a().optional(),input:Fl}),xy=u({model:f("hailuo/2-3-image-to-video-standard"),callBackUrl:a().optional(),input:Fl});u({resultUrls:k(a().url()).min(1),resultObject:z(a(),K()).optional()});u({resultUrls:k(a().url()).optional(),resultObject:z(a(),K()).optional()}).refine(n=>n.resultUrls!==void 0||n.resultObject!==void 0,{message:"resultJson must include resultUrls or resultObject"});const yy=u({taskId:a().min(1),model:f("bytedance/seedance-2-mini"),state:Wf,param:a().min(1),resultJson:a().optional(),failCode:a().nullable(),failMsg:a().nullable(),costTime:x().int().nullable(),completeTime:x().int().nullable(),createTime:x().int()});u({code:x().int(),msg:a(),data:yy.optional()});u({taskId:a().min(1)});const Sy=u({taskId:a().optional(),paramJson:a().optional(),completeTime:x().int().nullable().optional(),response:u({resultUrls:k(a()).optional()}).nullable().optional(),successFlag:x().int().optional(),status:h(["GENERATING","SUCCESS","CREATE_TASK_FAILED","GENERATE_FAILED"]).optional(),errorCode:x().int().nullable().optional(),errorMessage:a().nullable().optional(),createTime:x().int().nullable().optional(),progress:a().nullable().optional()});u({code:x().int(),msg:a(),data:Sy.nullable().optional()});u({code:x().int(),msg:a(),data:u({taskId:a().min(1)}).optional()});const by=lc(Blob);u({file:by,filename:a().min(1),uploadPath:a().min(1),fileName:a().optional(),mimeType:a().optional()});u({fileUrl:a().min(1),uploadPath:a().min(1),fileName:a().optional()});u({base64Data:a().min(1),uploadPath:a().min(1),fileName:a().optional(),mimeType:a().optional()});u({url:a().min(1)});u({taskId:a().min(1),url:a().min(1)});u({audio_id:sm,name:a().min(1).max(210),voice_description:a().min(1).max(2e4).optional(),example_dialogue:a().min(1).max(120).optional()});u({descriptions:a().min(1),image_urls:k(a().url()).min(1).max(1),audio_ids:k(a().min(1)).optional(),character_name:a().min(1).optional()});const ky=u({characterId:a().min(1),characterName:a().min(1),imageUrl:a().url()});u({code:x().optional(),msg:a(),data:ky.optional()});u({apiKey:a().min(1),baseURL:a().url().optional(),uploadBaseURL:a().url().optional(),timeout:x().int().positive().optional(),fetch:$i().optional(),paygate:$i().optional()});const _y=u({model:im,callBackUrl:a().optional(),input:z(a(),K())}),wy=a().regex(/^veo\d+(?:_[a-z0-9]+)*$/,"Expected a listed model or an underscored kie Veo alias (e.g. veo4_fast)"),Ty=h(["720p","1080p","4k"]),Iy=P([f(4),f(6),f(8)]);u({prompt:a().min(1),model:h(["veo3","veo3_fast","veo3_lite"]).or(wy).optional(),aspectRatio:h(["16:9","9:16","Auto"]).optional(),generationType:h(["TEXT_2_VIDEO","REFERENCE_2_VIDEO","FIRST_AND_LAST_FRAMES_2_VIDEO"]).optional(),imageUrls:k(a()).optional(),seeds:x().optional(),watermark:a().optional(),enableTranslation:y().optional(),resolution:Ty.optional(),duration:Iy.optional(),callBackUrl:a().optional(),enableFallback:y().optional()});u({taskId:a().min(1),prompt:a().min(1),model:h(["fast","quality"]).optional(),seeds:x().optional(),watermark:a().optional(),callBackUrl:a().optional()});u({taskId:a().min(1),index:x().int().min(0).optional()});u({code:x(),msg:a().optional(),data:u({resultUrl:a().url()}).nullable().optional()});u({taskId:a().min(1),index:x().int().min(0).optional(),callBackUrl:a().optional()});u({code:x(),msg:a().optional(),data:u({taskId:a().optional(),resultUrls:k(a()).nullable().optional(),imageUrls:k(a()).nullable().optional()}).nullable().optional()});u({taskId:a().min(1)});const Cy=P([f(0),f(1),f(2),f(3)]),Ry=u({taskId:a().optional(),resultUrls:k(a()).optional(),originUrls:k(a()).optional(),fullResultUrls:k(a()).optional(),resolution:a().optional(),mediaIds:k(a()).optional()}).passthrough(),Oy=u({taskId:a(),paramJson:a().optional(),completeTime:a().nullable().optional(),response:Ry.nullable().optional(),successFlag:Cy,errorCode:P([x().int(),a()]).nullable().optional(),errorMessage:a().nullable().optional(),createTime:a().optional(),fallbackFlag:y().optional()});u({code:x().int(),msg:a(),data:Oy.nullable().optional()});const My=h(["21:9","16:9","4:3","1:1","3:4","9:16"]),vy=a().regex(/^flux-kontext-[a-z0-9]+(?:-[a-z0-9]+)*$/,"Expected a listed model or a Flux Kontext alias (e.g. flux-kontext-ultra)"),Ey=["flux-kontext-pro","flux-kontext-max"],Ay=h(Ey).or(vy);u({prompt:a().min(1),enableTranslation:y().optional(),uploadCn:y().optional(),inputImage:a().url().optional(),aspectRatio:My.optional(),outputFormat:h(["jpeg","png"]).optional(),promptUpsampling:y().optional(),model:Ay.optional(),callBackUrl:a().url().optional(),safetyTolerance:x().int().min(0).max(6).optional(),watermark:a().optional()});const Ny=P([f(0),f(1),f(2),f(3)]);u({taskId:a().min(1)});const Dy=u({taskId:a(),paramJson:a().optional(),completeTime:a().nullable().optional(),response:u({originImageUrl:a().optional(),resultImageUrl:a().optional()}).nullable().optional(),successFlag:Ny,errorCode:x().int().nullable().optional(),errorMessage:a().nullable().optional(),createTime:a().optional()});u({code:x().int(),msg:a(),data:Dy.nullable().optional()});const By=h(["1:1","3:2","2:3"]),Vy=h(["GPT_IMAGE_1","FLUX_MAX"]);u({prompt:a().min(1).optional(),filesUrl:k(a().url()).max(5).optional(),size:By,maskUrl:a().url().optional(),callBackUrl:a().url().optional(),isEnhance:y().optional(),uploadCn:y().optional(),enableFallback:y().optional(),fallbackModel:Vy.optional()}).refine(n=>n.prompt!==void 0||n.filesUrl!==void 0,{message:"At least one of `prompt` or `filesUrl` must be provided"});const ql=h(["mj_txt2img","mj_img2img","mj_style_reference","mj_omni_reference","mj_video","mj_video_hd"]),Py=h(["relaxed","fast","turbo"]),Ky=h(["7","6.1","6","5.2","5.1","niji6"]),zy=h(["1:2","9:16","2:3","3:4","5:6","6:5","4:3","3:2","1:1","16:9","2:1"]),Fy=h(["high","low"]);u({prompt:a().min(1).max(2e3),taskType:ql,speed:Py.optional(),fileUrl:a().url().optional(),fileUrls:k(a().url()).optional(),aspectRatio:zy.optional(),version:Ky.optional(),variety:x().int().min(0).max(100).optional(),stylization:x().int().min(0).max(1e3).optional(),weirdness:x().int().min(0).max(3e3).optional(),ow:x().int().min(1).max(1e3).optional(),waterMark:a().optional(),enableTranslation:y().optional(),callBackUrl:a().url().optional(),videoBatchSize:P([f(1),f(2),f(4)]).optional(),motion:Fy.optional()});const qy=P([f(0),f(1),f(2),f(3)]);u({taskId:a().min(1)});const Uy=u({resultUrls:k(u({resultUrl:a()}).passthrough()).optional()}).passthrough(),Gy=u({taskId:a().optional(),taskType:ql.optional(),paramJson:a().optional(),completeTime:a().nullable().optional(),resultInfoJson:Uy.nullable().optional(),successFlag:qy.optional(),createTime:a().nullable().optional(),errorCode:x().int().nullable().optional(),errorMessage:a().nullable().optional()}).passthrough();u({code:x().int(),msg:a(),data:Gy.nullable().optional()});const Ul=h(["720p","1080p"]),Ly=h(["16:9","4:3","1:1","3:4","9:16"]),Wy=P([f(5),f(10)]);u({prompt:a().min(1).max(1800),duration:Wy,quality:Ul,imageUrl:a().url().optional(),aspectRatio:Ly.optional(),waterMark:a().optional(),callBackUrl:a().url().optional()});u({taskId:a().min(1),prompt:a().min(1),quality:Ul,waterMark:a().optional(),callBackUrl:a().url().optional()});const $y=u({videoId:a().optional(),taskId:a().optional(),videoUrl:a().optional(),imageUrl:a().optional()}),jy=u({prompt:a().optional(),imageUrl:a().optional(),expandPrompt:y().optional()}).passthrough(),Hy=u({taskId:a().optional(),parentTaskId:a().nullable().optional(),generateParam:jy.nullable().optional(),state:a().optional(),generateTime:a().nullable().optional(),videoInfo:$y.nullable().optional(),failCode:x().int().nullable().optional(),failMsg:a().nullable().optional(),expireFlag:x().int().nullable().optional()});u({code:x().int(),msg:a(),data:Hy.nullable().optional()});const tt=a().regex(/^V\d+(?:_\d+)*(?:PLUS|ALL)?$/,"Expected a listed model or a Suno version alias (e.g. V5_5PLUS)");u({prompt:a().min(1),model:h(["V3_5","V4","V4_5","V4_5PLUS","V4_5ALL","V5","V5_5"]).or(tt),instrumental:y(),customMode:y(),callBackUrl:a().min(1),style:a().optional(),negativeTags:a().optional(),title:a().optional(),vocalGender:h(["m","f"]).optional(),styleWeight:x().min(0).max(1).optional(),weirdnessConstraint:x().min(0).max(1).optional(),audioWeight:x().min(0).max(1).optional(),personaId:a().optional()});u({defaultParamFlag:y(),audioId:a().min(1),prompt:a().min(1),model:h(["V3_5","V4","V4_5","V4_5PLUS","V4_5ALL","V5","V5_5"]).or(tt),callBackUrl:a().min(1),style:a().optional(),title:a().optional(),continueAt:x().optional(),negativeTags:a().optional(),vocalGender:h(["m","f"]).optional(),styleWeight:x().min(0).max(1).optional(),weirdnessConstraint:x().min(0).max(1).optional(),audioWeight:x().min(0).max(1).optional(),personaId:a().optional()});u({taskId:a().min(1),audioId:a().min(1),callBackUrl:a().min(1)});u({taskId:a().min(1)}).passthrough();const Jy=h(["PENDING","SUCCESS","CREATE_TASK_FAILED","GENERATE_WAV_FAILED","CALLBACK_EXCEPTION"]),Qy=u({taskId:a(),musicId:a(),callbackUrl:a(),musicIndex:x().int(),completeTime:a().nullable().optional(),response:u({audioWavUrl:a()}).passthrough().nullable().optional(),successFlag:Jy,createTime:a(),errorCode:x().int().nullable(),errorMessage:a().nullable()}).passthrough();u({code:x().int(),msg:a().optional(),data:Qy.nullable().optional()}).passthrough();u({taskId:a().min(1),audioId:a().min(1),callBackUrl:a().min(1),type:h(["separate_vocal","split_stem"]).optional()});u({taskId:a().min(1)}).passthrough();const Xy=h(["PENDING","SUCCESS","CREATE_TASK_FAILED","GENERATE_AUDIO_FAILED","CALLBACK_EXCEPTION"]),Yy=u({duration:x().optional(),audio_url:a().optional(),stem_type_group_name:a().optional(),id:a().optional()}).passthrough(),Zy=u({id:a().nullable().optional(),originUrl:a().nullable().optional(),originData:k(Yy).optional(),instrumentalUrl:a().nullable().optional(),vocalUrl:a().nullable().optional(),backingVocalsUrl:a().nullable().optional(),drumsUrl:a().nullable().optional(),bassUrl:a().nullable().optional(),guitarUrl:a().nullable().optional(),pianoUrl:a().nullable().optional(),keyboardUrl:a().nullable().optional(),percussionUrl:a().nullable().optional(),stringsUrl:a().nullable().optional(),synthUrl:a().nullable().optional(),fxUrl:a().nullable().optional(),brassUrl:a().nullable().optional(),woodwindsUrl:a().nullable().optional()}).passthrough(),eS=u({taskId:a(),musicId:a().optional(),callbackUrl:a().optional(),musicIndex:x().int().optional(),completeTime:P([a(),x()]).nullable().optional(),response:Zy.nullable().optional(),successFlag:Xy.optional(),createTime:P([a(),x()]).optional(),errorCode:x().nullable().optional(),errorMessage:a().nullable().optional()}).passthrough();u({code:x().int(),msg:a().optional(),data:eS.nullable().optional()}).passthrough();u({taskId:a().min(1)}).passthrough();const Gl=h(["wait_processing","processing_validate","processing_validate_fail","wait_validating","success","fail"]),tS=u({taskId:a(),voiceId:a(),status:Gl,errorCode:x().int().nullable(),errorMessage:a().nullable()}).passthrough();u({code:x().int(),msg:a().optional(),data:tS.nullable().optional()}).passthrough();u({taskId:a().min(1)}).passthrough();const nS=u({taskId:a(),validateInfo:a(),status:Gl,errorCode:x().int().nullable(),errorMessage:a().nullable()}).passthrough();u({code:x().int(),msg:a().optional(),data:nS.nullable().optional()}).passthrough();const oS=h(["beginner","intermediate","advanced","professional"]);u({taskId:a().min(1),verifyUrl:a().min(1),voiceName:a().optional(),description:a().optional(),style:a().optional(),callBackUrl:a().optional(),singerSkillLevel:oS.optional()}).passthrough();u({voiceUrl:a().min(1),vocalStartS:x().int(),vocalEndS:x().int(),language:a().optional(),callBackUrl:a().optional()}).passthrough();const iS=u({taskId:a()}).passthrough();u({code:x().int(),msg:a().optional(),data:iS.nullable().optional()}).passthrough();u({taskId:a().min(1),calBackUrl:a().min(1)}).passthrough();const rS=u({taskId:a()}).passthrough();u({code:x().int(),msg:a().optional(),data:rS.nullable().optional()}).passthrough();u({task_id:a().min(1)}).passthrough();const sS=u({isAvailable:y()}).passthrough();u({code:x().int(),msg:a().optional(),data:sS.nullable().optional()}).passthrough();u({taskId:a().min(1),audioId:a().min(1),name:a().min(1),description:a().min(1),vocalStart:x().min(0).optional(),vocalEnd:x().min(0).optional(),style:a().optional()}).passthrough();const aS=u({personaId:a().optional(),name:a().optional(),description:a().optional()}).passthrough();u({code:x().int(),msg:a().optional(),data:aS.nullable().optional()}).passthrough();u({taskId:a().min(1),audioId:a().min(1)}).passthrough();const lS=u({word:a().optional(),success:y().optional(),startS:x().optional(),endS:x().optional(),palign:x().int().optional()}).passthrough(),cS=u({alignedWords:k(lS).optional(),waveformData:k(x()).optional(),hootCer:x().optional(),isStreamed:y().optional()}).passthrough();u({code:x().int(),msg:a().optional(),data:cS.nullable().optional()}).passthrough();u({taskId:a().min(1),callBackUrl:a().min(1)}).passthrough();u({taskId:a().min(1)}).passthrough();const uS=u({images:k(a()).optional()}).passthrough(),pS=u({taskId:a(),parentTaskId:a().optional(),callbackUrl:a().optional(),completeTime:a().nullable().optional(),response:uS.nullable().optional(),successFlag:x().int().optional(),createTime:a().optional(),errorCode:x().int().nullable().optional(),errorMessage:a().nullable().optional()}).passthrough();u({code:x().int(),msg:a().optional(),data:pS.nullable().optional()}).passthrough();u({task_id:a().min(1)}).passthrough();u({code:x().int(),msg:a().optional(),data:k(u({}).passthrough()).nullable().optional()}).passthrough();u({task_id:a().min(1),call_back_url:a().optional()});u({taskId:a().min(1),audioId:a().min(1),callBackUrl:a().min(1),author:a().max(50).optional(),domainName:a().max(50).optional()});u({taskId:a().min(1)});const dS=h(["PENDING","SUCCESS","CREATE_TASK_FAILED","GENERATE_MP4_FAILED"]),mS=u({videoUrl:a().optional()}).passthrough(),hS=u({taskId:a(),musicId:a(),callbackUrl:a(),musicIndex:x().int(),completeTime:a().nullable().optional(),response:mS.nullable().optional(),successFlag:dS,createTime:a(),errorCode:x().int().nullable().optional(),errorMessage:a().nullable().optional()}).passthrough();u({code:x().int(),msg:a().optional(),data:hS.nullable().optional()});u({prompt:a().min(1).max(200),callBackUrl:a().min(1)});u({taskId:a().min(1)});const fS=h(["PENDING","SUCCESS","CREATE_TASK_FAILED","GENERATE_LYRICS_FAILED","CALLBACK_EXCEPTION","SENSITIVE_WORD_ERROR"]),gS=u({text:a(),title:a(),status:a().optional(),errorMessage:a().optional()}).passthrough();u({code:x().int(),msg:a().optional(),data:u({taskId:a(),param:a().optional(),response:u({taskId:a().optional(),data:k(gS).optional()}).passthrough().nullable().optional(),status:fS.optional(),errorCode:x().int().nullable().optional(),errorMessage:a().nullable().optional()}).passthrough().nullable().optional()});u({content:a().min(1)});u({uploadUrl:a().min(1),prompt:a().min(1),customMode:y(),instrumental:y(),model:h(["V3_5","V4","V4_5","V4_5PLUS","V4_5ALL","V5","V5_5"]).or(tt),callBackUrl:a().min(1),style:a().optional(),title:a().optional(),negativeTags:a().optional(),vocalGender:h(["m","f"]).optional(),styleWeight:x().min(0).max(1).optional(),weirdnessConstraint:x().min(0).max(1).optional(),audioWeight:x().min(0).max(1).optional(),personaId:a().optional()});u({uploadUrl:a().min(1),defaultParamFlag:y(),instrumental:y(),continueAt:x(),model:h(["V3_5","V4","V4_5","V4_5PLUS","V4_5ALL","V5","V5_5"]).or(tt),callBackUrl:a().min(1),prompt:a().optional(),style:a().optional(),title:a().optional(),negativeTags:a().optional(),vocalGender:h(["m","f"]).optional(),styleWeight:x().min(0).max(1).optional(),weirdnessConstraint:x().min(0).max(1).optional(),audioWeight:x().min(0).max(1).optional(),personaId:a().optional()});u({taskId:a().min(1),callBackUrl:a().min(1),audioId:a().optional()});u({taskId:a().min(1)});const xS=P([f(0),f(1),f(2),f(3)]),yS=u({pitch:x(),start:x(),end:x(),velocity:x()}).passthrough(),SS=u({name:a(),notes:k(yS)}).passthrough(),bS=u({state:a().optional(),instruments:k(SS).optional()}).passthrough();u({code:x().int(),msg:a().optional(),data:u({taskId:a(),successFlag:xS,recordTaskId:x().int().optional(),audioId:a().optional(),callbackUrl:a().optional(),createTime:x().int().optional(),completeTime:x().int().nullable().optional(),errorCode:P([a(),x().int()]).nullable().optional(),errorMessage:a().nullable().optional(),midiData:bS.nullable().optional()}).passthrough().nullable().optional()}).passthrough();u({uploadUrlList:cs([a().min(1),a().min(1)]),customMode:y(),model:h(["V4","V4_5","V4_5PLUS","V4_5ALL","V5","V5_5"]).or(tt),callBackUrl:a().min(1),prompt:a().optional(),style:a().optional(),title:a().optional(),instrumental:y().optional(),vocalGender:h(["m","f"]).optional(),styleWeight:x().min(0).max(1).optional(),weirdnessConstraint:x().min(0).max(1).optional(),audioWeight:x().min(0).max(1).optional()});u({taskId:a().min(1),audioId:a().min(1),prompt:a().min(1),tags:a().min(1),title:a().min(1),infillStartS:x().min(0),infillEndS:x().min(0),negativeTags:a().optional(),fullLyrics:a().optional(),callBackUrl:a().optional()});u({prompt:a().min(1),model:h(["V5","V5_5"]).or(tt),soundLoop:y().optional(),soundTempo:x().min(1).max(300).optional(),soundKey:h(["Cm","C#m","Dm","D#m","Em","Fm","F#m","Gm","G#m","Am","A#m","Bm","C","C#","D","D#","E","F","F#","G","G#","A","A#","B"]).optional(),grabLyrics:y().optional(),callBackUrl:a().optional()});u({uploadUrl:a().min(1),title:a().min(1),tags:a().min(1),callBackUrl:a().min(1),model:h(["V3_5","V4","V4_5","V4_5PLUS","V4_5ALL","V5","V5_5"]).or(tt),negativeTags:a().optional(),vocalGender:h(["m","f"]).optional(),styleWeight:x().min(0).max(1).optional(),weirdnessConstraint:x().min(0).max(1).optional(),audioWeight:x().min(0).max(1).optional()});u({uploadUrl:a().min(1),prompt:a().min(1),title:a().min(1),style:a().min(1),negativeTags:a().min(1),callBackUrl:a().min(1),model:h(["V3_5","V4","V4_5","V4_5PLUS","V4_5ALL","V5","V5_5"]).or(tt),vocalGender:h(["m","f"]).optional(),styleWeight:x().min(0).max(1).optional(),weirdnessConstraint:x().min(0).max(1).optional(),audioWeight:x().min(0).max(1).optional()});const kS=u({type:h(["text","image_url"]),text:a().optional(),image_url:u({url:a()}).optional()}),_S=u({role:h(["user","assistant","system"]),content:P([a(),k(kS)])});u({model:a(),messages:k(_S),temperature:x().min(0).max(2).optional(),max_tokens:x().int().positive().optional(),stream:y().optional(),response_format:u({type:h(["text","json_object","json_schema"]),json_schema:z(a(),K()).optional()}).optional()});const wS=a().regex(/^gpt-\d+(?:[-.]\d+)*(?:-[a-z0-9]+)*$/,"Expected a listed model or a versioned GPT alias (e.g. gpt-5-5-mini)"),TS=["gpt-5-4","gpt-5-5","gpt-5-6-luna","gpt-5-6-sol","gpt-5-6-terra","gpt-6-astra","gpt-6-luna","gpt-6-sol"],IS=h(TS).or(wS),CS=h(["low","medium","high","xhigh"]),RS=h(["user","assistant","system","developer","tool"]),OS=u({type:f("input_text"),text:a().min(1)}),MS=u({type:f("input_image"),image_url:a().url()}),vS=u({type:f("input_file"),file_url:a().url()}),ES=Te("type",[OS,MS,vS]),gn=u({role:RS,content:k(ES).min(1)}),fo=u({effort:CS.default("low").optional()}),AS=u({type:f("web_search")}),Ll=u({type:f("function"),name:a().min(1),description:a().min(1),parameters:z(a(),K())}),NS=Te("type",[AS,Ll]),go=k(NS).superRefine((n,e)=>{const t=n.some(i=>i.type==="web_search"),o=n.some(i=>i.type==="function");t&&o&&e.addIssue({code:"custom",message:"web_search and function tools are mutually exclusive for Kie responses"})});u({model:IS,stream:y().default(!1).optional(),input:P([a().min(1),k(gn).min(1)]),reasoning:fo.optional(),tools:go.optional(),tool_choice:a().optional()});const DS=a().regex(/^grok-\d+(?:[-.]\d+)*(?:-[a-z0-9]+)*$/,"Expected a listed model or a versioned Grok alias (e.g. grok-4-5-fast)"),BS=["grok-4-5","grok-4-6","grok-4-7"],VS=h(BS).or(DS);u({model:VS,stream:y().default(!1).optional(),input:P([a().min(1),k(gn).min(1)]),reasoning:fo.optional(),tools:go.optional(),tool_choice:a().optional()});const PS=a().regex(/^grok-\d+(?:-\d+)*(?:-[a-z0-9]+)*$/,"Expected a listed model or a versioned Grok alias (e.g. grok-4-6)"),KS=["grok-4-7","grok-4-6","grok-4-5","grok-4-3"],zS=h(KS).or(PS);u({model:zS,stream:y().default(!1).optional(),input:P([a().min(1),k(gn).min(1)]),reasoning:fo.optional(),tools:go.optional(),tool_choice:a().optional()});const FS=a().regex(/^gpt-\d+(?:\.\d+)*-codex(?:-[a-z0-9]+)*$/,"Expected a listed model or a versioned GPT Codex alias (e.g. gpt-5.5-codex)"),qS=["gpt-5-codex","gpt-5.1-codex","gpt-5.2-codex","gpt-5.3-codex","gpt-5.4-codex"],US=h(qS).or(FS);u({model:US,stream:y().default(!1).optional(),input:P([a().min(1),k(gn).min(1)]),reasoning:fo.optional(),tools:go.optional(),tool_choice:a().optional()});const GS=a().regex(/^(?:kimi-k\d+|deepseek-v\d+|gpt-\d+)(?:[-.]\d+)*(?:-[a-z0-9]+)*$/,"Expected a listed model or a versioned Kimi/DeepSeek/GPT alias (e.g. kimi-k4, deepseek-v4-1 or gpt-6)"),LS=["kimi-k3","deepseek-v4-1-flash","gpt-6.1-sol","gpt-6-astra","gpt-6-sol","gpt-6-luna","gpt-5.6-sol","gpt-5.6-terra","gpt-5.6-luna","gpt-5.5","gpt-5.4"],WS=h(LS).or(GS),$S=h(["none","minimal","low","medium","high","xhigh","max"]),jS=u({type:h(["enabled","disabled","auto"]).optional()}),HS=u({type:h(["text","json_object","json_schema"]),name:a().optional(),description:a().optional(),schema:z(a(),K()).optional(),strict:y().optional()}),JS=u({format:HS}),QS=P([a(),u({type:f("function"),name:a().min(1)})]);u({model:WS,stream:y().default(!1).optional(),input:P([a().min(1),k(gn).min(1)]),instructions:a().optional(),reasoning:u({effort:$S.optional()}).optional(),thinking:jS.optional(),tools:k(Ll).optional(),tool_choice:QS.optional(),text:JS.optional()});const XS=u({type:a(),properties:z(a(),K()).optional(),required:k(a()).optional()}),YS=u({name:a(),description:a(),input_schema:XS}),ZS=u({type:a(),text:a().optional()}).passthrough(),Wl=u({role:h(["user","assistant"]),content:P([a(),k(ZS)])}),$l=a().regex(/^claude-[a-z]+(?:-\d+)+(?:-[a-z0-9]+)*$/,"Expected a listed model or a versioned Claude alias (e.g. claude-opus-5-0)");u({model:h(["claude-sonnet-4-6","claude-haiku-4-5","claude-opus-5"]).or($l),messages:k(Wl),tools:k(YS).optional(),thinkingFlag:y().optional(),stream:y().optional()});u({after_id:a().min(1).optional()});const eb=["claude-fable-5","claude-opus-5-5","claude-opus-5","claude-sonnet-5-5","claude-sonnet-5","claude-opus-4-8","claude-opus-4-7","claude-opus-4-6","claude-sonnet-4-6","claude-opus-4-5","claude-sonnet-4-5","claude-haiku-4-5"],tb=h(eb).or($l),nb=u({type:f("text"),text:a()}).passthrough(),ob=u({name:a().min(1),description:a().optional(),input_schema:u({type:a()}).passthrough()}).passthrough(),Xr=u({type:a()}).passthrough();u({model:tb,max_tokens:x().int().min(1),messages:k(Wl).min(1),system:P([a(),k(nb)]).optional(),temperature:x().min(0).max(1).optional(),top_p:x().min(0).max(1).optional(),top_k:x().int().min(0).optional(),stop_sequences:k(a()).optional(),tools:k(ob).optional(),tool_choice:Xr.optional(),thinking:Xr.optional(),metadata:u({user_id:a().optional()}).passthrough().optional(),stream:f(!1).optional()}).describe("Anthropic Messages request for KIE's Claude Code proxy. Latency: this method uses the client timeout, which defaults to 30 s (30000 ms), and KIE's agent proxy has answered it more slowly: the slowest successful call observed took 108 s (2026-09-30). Pass --timeout <ms>, for example --timeout 300000. It sets createKie's timeout, which applies to every method of that client.");const ib=["Text to Video","Image to Video","Image Editing","Text to Image","Image to Image","Speech to Video","Text to Speech","Lip Sync","Video to Video","Text to Music","Audio to Audio","Chat","Video Editing"],rb=a().regex(/^[A-Z][A-Za-z0-9]*(?: [A-Za-z0-9]+)*$/),Yr=h(ib).or(rb);u({taskType:P([Yr,k(Yr)]).optional(),provider:a().optional(),q:a().optional()});const sb=a().regex(/^[A-Za-z0-9][A-Za-z0-9._-]*(?:\/[A-Za-z0-9][A-Za-z0-9._-]*)?$/);u({model:sb});const ab=P([ug,mg,pg,dg,Zf,eg,tg,ng,og,ig,rg,sg,ag,lg,cg,gg,Sg,_g,Ig,Cg,Ug,Gg,Lg,Wg,$g,jg,Hg,Jg,Qg,Xg,Yg,D1,K1,B1,P1,F1,q1,G1,$1,J1,Y1,X1,e0,Z1,t0,n0,o0,i0,r0,s0,a0,l0,c0,u0,Rg,Og,Ag,Dg,Bg,Vg,Pg,Kg,zg,Fg,qg,t1,i1,a1,c1,m1,g1,b1,y1,I1,R1,M1,E1,N1,P0,K0,z0,F0,q0,U0,$0,j0,X0,Y0,Z0,ex,tx,nx,ox,ix,rx,sx,ax,lx,m0,h0,f0,g0,x0,y0,S0,k0,_0,w0,T0,C0,O0,M0,v0,E0,A0,N0,p0,d0,ux,dx,hx,gx,Sx,kx,wx,Ix,Ox,Mx,Dx,Bx,Px,Kx,zx,Fx,qx,Ux,Gx,Wx,jx,ay,ly,ny,oy,iy,ry,dy,my,hy,fy,gy,xy,Hx,Jx,Qx,Xx,Yx,Zx]);_y.pipe(ab);function jl(n){var e,t,o="";if(typeof n=="string"||typeof n=="number")o+=n;else if(typeof n=="object")if(Array.isArray(n)){var i=n.length;for(e=0;e<i;e++)n[e]&&(t=jl(n[e]))&&(o&&(o+=" "),o+=t)}else for(t in n)n[t]&&(o&&(o+=" "),o+=t);return o}function Mk(){for(var n,e,t=0,o="",i=arguments.length;t<i;t++)(n=arguments[t])&&(e=jl(n))&&(o&&(o+=" "),o+=e);return o}const lb=(n,e)=>{const t=new Array(n.length+e.length);for(let o=0;o<n.length;o++)t[o]=n[o];for(let o=0;o<e.length;o++)t[n.length+o]=e[o];return t},cb=(n,e)=>({classGroupId:n,validator:e}),Hl=(n=new Map,e=null,t)=>({nextPart:n,validators:e,classGroupId:t}),Wn="-",Zr=[],ub="arbitrary..",pb=n=>{const e=mb(n),{conflictingClassGroups:t,conflictingClassGroupModifiers:o}=n;return{getClassGroupId:s=>{if(s.startsWith("[")&&s.endsWith("]"))return db(s);const l=s.split(Wn),c=l[0]===""&&l.length>1?1:0;return Jl(l,c,e)},getConflictingClassGroupIds:(s,l)=>{if(l){const c=o[s],p=t[s];return c?p?lb(p,c):c:p||Zr}return t[s]||Zr}}},Jl=(n,e,t)=>{if(n.length-e===0)return t.classGroupId;const i=n[e],r=t.nextPart.get(i);if(r){const p=Jl(n,e+1,r);if(p)return p}const s=t.validators;if(s===null)return;const l=e===0?n.join(Wn):n.slice(e).join(Wn),c=s.length;for(let p=0;p<c;p++){const d=s[p];if(d.validator(l))return d.classGroupId}},db=n=>n.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=n.slice(1,-1),t=e.indexOf(":"),o=e.slice(0,t);return o?ub+o:void 0})(),mb=n=>{const{theme:e,classGroups:t}=n;return hb(t,e)},hb=(n,e)=>{const t=Hl();for(const o in n){const i=n[o];Ki(i,t,o,e)}return t},Ki=(n,e,t,o)=>{const i=n.length;for(let r=0;r<i;r++){const s=n[r];fb(s,e,t,o)}},fb=(n,e,t,o)=>{if(typeof n=="string"){gb(n,e,t);return}if(typeof n=="function"){xb(n,e,t,o);return}yb(n,e,t,o)},gb=(n,e,t)=>{const o=n===""?e:Ql(e,n);o.classGroupId=t},xb=(n,e,t,o)=>{if(Sb(n)){Ki(n(o),e,t,o);return}e.validators===null&&(e.validators=[]),e.validators.push(cb(t,n))},yb=(n,e,t,o)=>{const i=Object.entries(n),r=i.length;for(let s=0;s<r;s++){const[l,c]=i[s];Ki(c,Ql(e,l),t,o)}},Ql=(n,e)=>{let t=n;const o=e.split(Wn),i=o.length;for(let r=0;r<i;r++){const s=o[r];let l=t.nextPart.get(s);l||(l=Hl(),t.nextPart.set(s,l)),t=l}return t},Sb=n=>"isThemeGetter"in n&&n.isThemeGetter===!0,bb=n=>{if(n<1)return{get:()=>{},set:()=>{}};let e=0,t=Object.create(null),o=Object.create(null);const i=(r,s)=>{t[r]=s,e++,e>n&&(e=0,o=t,t=Object.create(null))};return{get(r){let s=t[r];if(s!==void 0)return s;if((s=o[r])!==void 0)return i(r,s),s},set(r,s){r in t?t[r]=s:i(r,s)}}},oi="!",es=":",kb=[],ts=(n,e,t,o,i)=>({modifiers:n,hasImportantModifier:e,baseClassName:t,maybePostfixModifierPosition:o,isExternal:i}),_b=n=>{const{prefix:e,experimentalParseClassName:t}=n;let o=i=>{const r=[];let s=0,l=0,c=0,p;const d=i.length;for(let _=0;_<d;_++){const w=i[_];if(s===0&&l===0){if(w===es){r.push(i.slice(c,_)),c=_+1;continue}if(w==="/"){p=_;continue}}w==="["?s++:w==="]"?s--:w==="("?l++:w===")"&&l--}const m=r.length===0?i:i.slice(c);let g=m,S=!1;m.endsWith(oi)?(g=m.slice(0,-1),S=!0):m.startsWith(oi)&&(g=m.slice(1),S=!0);const b=p&&p>c?p-c:void 0;return ts(r,S,g,b)};if(e){const i=e+es,r=o;o=s=>s.startsWith(i)?r(s.slice(i.length)):ts(kb,!1,s,void 0,!0)}if(t){const i=o;o=r=>t({className:r,parseClassName:i})}return o},wb=n=>{const e=new Map;return n.orderSensitiveModifiers.forEach((t,o)=>{e.set(t,1e6+o)}),t=>{const o=[];let i=[];for(let r=0;r<t.length;r++){const s=t[r],l=s[0]==="[",c=e.has(s);l||c?(i.length>0&&(i.sort(),o.push(...i),i=[]),o.push(s)):i.push(s)}return i.length>0&&(i.sort(),o.push(...i)),o}},Tb=n=>({cache:bb(n.cacheSize),parseClassName:_b(n),sortModifiers:wb(n),...pb(n)}),Ib=/\s+/,Cb=(n,e)=>{const{parseClassName:t,getClassGroupId:o,getConflictingClassGroupIds:i,sortModifiers:r}=e,s=[],l=n.trim().split(Ib);let c="";for(let p=l.length-1;p>=0;p-=1){const d=l[p],{isExternal:m,modifiers:g,hasImportantModifier:S,baseClassName:b,maybePostfixModifierPosition:_}=t(d);if(m){c=d+(c.length>0?" "+c:c);continue}let w=!!_,v=o(w?b.substring(0,_):b);if(!v){if(!w){c=d+(c.length>0?" "+c:c);continue}if(v=o(b),!v){c=d+(c.length>0?" "+c:c);continue}w=!1}const L=g.length===0?"":g.length===1?g[0]:r(g).join(":"),F=S?L+oi:L,ne=F+v;if(s.indexOf(ne)>-1)continue;s.push(ne);const O=i(v,w);for(let I=0;I<O.length;++I){const R=O[I];s.push(F+R)}c=d+(c.length>0?" "+c:c)}return c},Rb=(...n)=>{let e=0,t,o,i="";for(;e<n.length;)(t=n[e++])&&(o=Xl(t))&&(i&&(i+=" "),i+=o);return i},Xl=n=>{if(typeof n=="string")return n;let e,t="";for(let o=0;o<n.length;o++)n[o]&&(e=Xl(n[o]))&&(t&&(t+=" "),t+=e);return t},Ob=(n,...e)=>{let t,o,i,r;const s=c=>{const p=e.reduce((d,m)=>m(d),n());return t=Tb(p),o=t.cache.get,i=t.cache.set,r=l,l(c)},l=c=>{const p=o(c);if(p)return p;const d=Cb(c,t);return i(c,d),d};return r=s,(...c)=>r(Rb(...c))},Mb=[],$=n=>{const e=t=>t[n]||Mb;return e.isThemeGetter=!0,e},Yl=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Zl=/^\((?:(\w[\w-]*):)?(.+)\)$/i,vb=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Eb=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Ab=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Nb=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Db=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Bb=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Fe=n=>vb.test(n),V=n=>!!n&&!Number.isNaN(Number(n)),qe=n=>!!n&&Number.isInteger(Number(n)),Po=n=>n.endsWith("%")&&V(n.slice(0,-1)),De=n=>Eb.test(n),ec=()=>!0,Vb=n=>Ab.test(n)&&!Nb.test(n),zi=()=>!1,Pb=n=>Db.test(n),Kb=n=>Bb.test(n),zb=n=>!M(n)&&!E(n),Fb=n=>nt(n,oc,zi),M=n=>Yl.test(n),it=n=>nt(n,ic,Vb),ns=n=>nt(n,Hb,V),qb=n=>nt(n,sc,ec),Ub=n=>nt(n,rc,zi),is=n=>nt(n,tc,zi),Gb=n=>nt(n,nc,Kb),On=n=>nt(n,ac,Pb),E=n=>Zl.test(n),Pt=n=>St(n,ic),Lb=n=>St(n,rc),rs=n=>St(n,tc),Wb=n=>St(n,oc),$b=n=>St(n,nc),Mn=n=>St(n,ac,!0),jb=n=>St(n,sc,!0),nt=(n,e,t)=>{const o=Yl.exec(n);return o?o[1]?e(o[1]):t(o[2]):!1},St=(n,e,t=!1)=>{const o=Zl.exec(n);return o?o[1]?e(o[1]):t:!1},tc=n=>n==="position"||n==="percentage",nc=n=>n==="image"||n==="url",oc=n=>n==="length"||n==="size"||n==="bg-size",ic=n=>n==="length",Hb=n=>n==="number",rc=n=>n==="family-name",sc=n=>n==="number"||n==="weight",ac=n=>n==="shadow",Jb=()=>{const n=$("color"),e=$("font"),t=$("text"),o=$("font-weight"),i=$("tracking"),r=$("leading"),s=$("breakpoint"),l=$("container"),c=$("spacing"),p=$("radius"),d=$("shadow"),m=$("inset-shadow"),g=$("text-shadow"),S=$("drop-shadow"),b=$("blur"),_=$("perspective"),w=$("aspect"),v=$("ease"),L=$("animate"),F=()=>["auto","avoid","all","avoid-page","page","left","right","column"],ne=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],O=()=>[...ne(),E,M],I=()=>["auto","hidden","clip","visible","scroll"],R=()=>["auto","contain","none"],T=()=>[E,M,c],D=()=>[Fe,"full","auto",...T()],pe=()=>[qe,"none","subgrid",E,M],xn=()=>["auto",{span:["full",qe,E,M]},qe,E,M],bt=()=>[qe,"auto",E,M],yn=()=>["auto","min","max","fr",E,M],Ie=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],Ae=()=>["start","end","center","stretch","center-safe","end-safe"],be=()=>["auto",...T()],ot=()=>[Fe,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],xo=()=>[Fe,"screen","full","dvw","lvw","svw","min","max","fit",...T()],yo=()=>[Fe,"screen","full","lh","dvh","lvh","svh","min","max","fit",...T()],N=()=>[n,E,M],qi=()=>[...ne(),rs,is,{position:[E,M]}],Ui=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Gi=()=>["auto","cover","contain",Wb,Fb,{size:[E,M]}],So=()=>[Po,Pt,it],se=()=>["","none","full",p,E,M],ae=()=>["",V,Pt,it],Sn=()=>["solid","dashed","dotted","double"],Li=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],j=()=>[V,Po,rs,is],Wi=()=>["","none",b,E,M],bn=()=>["none",V,E,M],kn=()=>["none",V,E,M],bo=()=>[V,E,M],_n=()=>[Fe,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[De],breakpoint:[De],color:[ec],container:[De],"drop-shadow":[De],ease:["in","out","in-out"],font:[zb],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[De],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[De],shadow:[De],spacing:["px",V],text:[De],"text-shadow":[De],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Fe,M,E,w]}],container:["container"],columns:[{columns:[V,M,E,l]}],"break-after":[{"break-after":F()}],"break-before":[{"break-before":F()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:O()}],overflow:[{overflow:I()}],"overflow-x":[{"overflow-x":I()}],"overflow-y":[{"overflow-y":I()}],overscroll:[{overscroll:R()}],"overscroll-x":[{"overscroll-x":R()}],"overscroll-y":[{"overscroll-y":R()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:D()}],"inset-x":[{"inset-x":D()}],"inset-y":[{"inset-y":D()}],start:[{"inset-s":D(),start:D()}],end:[{"inset-e":D(),end:D()}],"inset-bs":[{"inset-bs":D()}],"inset-be":[{"inset-be":D()}],top:[{top:D()}],right:[{right:D()}],bottom:[{bottom:D()}],left:[{left:D()}],visibility:["visible","invisible","collapse"],z:[{z:[qe,"auto",E,M]}],basis:[{basis:[Fe,"full","auto",l,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[V,Fe,"auto","initial","none",M]}],grow:[{grow:["",V,E,M]}],shrink:[{shrink:["",V,E,M]}],order:[{order:[qe,"first","last","none",E,M]}],"grid-cols":[{"grid-cols":pe()}],"col-start-end":[{col:xn()}],"col-start":[{"col-start":bt()}],"col-end":[{"col-end":bt()}],"grid-rows":[{"grid-rows":pe()}],"row-start-end":[{row:xn()}],"row-start":[{"row-start":bt()}],"row-end":[{"row-end":bt()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":yn()}],"auto-rows":[{"auto-rows":yn()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...Ie(),"normal"]}],"justify-items":[{"justify-items":[...Ae(),"normal"]}],"justify-self":[{"justify-self":["auto",...Ae()]}],"align-content":[{content:["normal",...Ie()]}],"align-items":[{items:[...Ae(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...Ae(),{baseline:["","last"]}]}],"place-content":[{"place-content":Ie()}],"place-items":[{"place-items":[...Ae(),"baseline"]}],"place-self":[{"place-self":["auto",...Ae()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pbs:[{pbs:T()}],pbe:[{pbe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:be()}],mx:[{mx:be()}],my:[{my:be()}],ms:[{ms:be()}],me:[{me:be()}],mbs:[{mbs:be()}],mbe:[{mbe:be()}],mt:[{mt:be()}],mr:[{mr:be()}],mb:[{mb:be()}],ml:[{ml:be()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:ot()}],"inline-size":[{inline:["auto",...xo()]}],"min-inline-size":[{"min-inline":["auto",...xo()]}],"max-inline-size":[{"max-inline":["none",...xo()]}],"block-size":[{block:["auto",...yo()]}],"min-block-size":[{"min-block":["auto",...yo()]}],"max-block-size":[{"max-block":["none",...yo()]}],w:[{w:[l,"screen",...ot()]}],"min-w":[{"min-w":[l,"screen","none",...ot()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[s]},...ot()]}],h:[{h:["screen","lh",...ot()]}],"min-h":[{"min-h":["screen","lh","none",...ot()]}],"max-h":[{"max-h":["screen","lh",...ot()]}],"font-size":[{text:["base",t,Pt,it]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[o,jb,qb]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Po,M]}],"font-family":[{font:[Lb,Ub,e]}],"font-features":[{"font-features":[M]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,E,M]}],"line-clamp":[{"line-clamp":[V,"none",E,ns]}],leading:[{leading:[r,...T()]}],"list-image":[{"list-image":["none",E,M]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",E,M]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:N()}],"text-color":[{text:N()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Sn(),"wavy"]}],"text-decoration-thickness":[{decoration:[V,"from-font","auto",E,it]}],"text-decoration-color":[{decoration:N()}],"underline-offset":[{"underline-offset":[V,"auto",E,M]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",E,M]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",E,M]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:qi()}],"bg-repeat":[{bg:Ui()}],"bg-size":[{bg:Gi()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},qe,E,M],radial:["",E,M],conic:[qe,E,M]},$b,Gb]}],"bg-color":[{bg:N()}],"gradient-from-pos":[{from:So()}],"gradient-via-pos":[{via:So()}],"gradient-to-pos":[{to:So()}],"gradient-from":[{from:N()}],"gradient-via":[{via:N()}],"gradient-to":[{to:N()}],rounded:[{rounded:se()}],"rounded-s":[{"rounded-s":se()}],"rounded-e":[{"rounded-e":se()}],"rounded-t":[{"rounded-t":se()}],"rounded-r":[{"rounded-r":se()}],"rounded-b":[{"rounded-b":se()}],"rounded-l":[{"rounded-l":se()}],"rounded-ss":[{"rounded-ss":se()}],"rounded-se":[{"rounded-se":se()}],"rounded-ee":[{"rounded-ee":se()}],"rounded-es":[{"rounded-es":se()}],"rounded-tl":[{"rounded-tl":se()}],"rounded-tr":[{"rounded-tr":se()}],"rounded-br":[{"rounded-br":se()}],"rounded-bl":[{"rounded-bl":se()}],"border-w":[{border:ae()}],"border-w-x":[{"border-x":ae()}],"border-w-y":[{"border-y":ae()}],"border-w-s":[{"border-s":ae()}],"border-w-e":[{"border-e":ae()}],"border-w-bs":[{"border-bs":ae()}],"border-w-be":[{"border-be":ae()}],"border-w-t":[{"border-t":ae()}],"border-w-r":[{"border-r":ae()}],"border-w-b":[{"border-b":ae()}],"border-w-l":[{"border-l":ae()}],"divide-x":[{"divide-x":ae()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ae()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Sn(),"hidden","none"]}],"divide-style":[{divide:[...Sn(),"hidden","none"]}],"border-color":[{border:N()}],"border-color-x":[{"border-x":N()}],"border-color-y":[{"border-y":N()}],"border-color-s":[{"border-s":N()}],"border-color-e":[{"border-e":N()}],"border-color-bs":[{"border-bs":N()}],"border-color-be":[{"border-be":N()}],"border-color-t":[{"border-t":N()}],"border-color-r":[{"border-r":N()}],"border-color-b":[{"border-b":N()}],"border-color-l":[{"border-l":N()}],"divide-color":[{divide:N()}],"outline-style":[{outline:[...Sn(),"none","hidden"]}],"outline-offset":[{"outline-offset":[V,E,M]}],"outline-w":[{outline:["",V,Pt,it]}],"outline-color":[{outline:N()}],shadow:[{shadow:["","none",d,Mn,On]}],"shadow-color":[{shadow:N()}],"inset-shadow":[{"inset-shadow":["none",m,Mn,On]}],"inset-shadow-color":[{"inset-shadow":N()}],"ring-w":[{ring:ae()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:N()}],"ring-offset-w":[{"ring-offset":[V,it]}],"ring-offset-color":[{"ring-offset":N()}],"inset-ring-w":[{"inset-ring":ae()}],"inset-ring-color":[{"inset-ring":N()}],"text-shadow":[{"text-shadow":["none",g,Mn,On]}],"text-shadow-color":[{"text-shadow":N()}],opacity:[{opacity:[V,E,M]}],"mix-blend":[{"mix-blend":[...Li(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Li()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[V]}],"mask-image-linear-from-pos":[{"mask-linear-from":j()}],"mask-image-linear-to-pos":[{"mask-linear-to":j()}],"mask-image-linear-from-color":[{"mask-linear-from":N()}],"mask-image-linear-to-color":[{"mask-linear-to":N()}],"mask-image-t-from-pos":[{"mask-t-from":j()}],"mask-image-t-to-pos":[{"mask-t-to":j()}],"mask-image-t-from-color":[{"mask-t-from":N()}],"mask-image-t-to-color":[{"mask-t-to":N()}],"mask-image-r-from-pos":[{"mask-r-from":j()}],"mask-image-r-to-pos":[{"mask-r-to":j()}],"mask-image-r-from-color":[{"mask-r-from":N()}],"mask-image-r-to-color":[{"mask-r-to":N()}],"mask-image-b-from-pos":[{"mask-b-from":j()}],"mask-image-b-to-pos":[{"mask-b-to":j()}],"mask-image-b-from-color":[{"mask-b-from":N()}],"mask-image-b-to-color":[{"mask-b-to":N()}],"mask-image-l-from-pos":[{"mask-l-from":j()}],"mask-image-l-to-pos":[{"mask-l-to":j()}],"mask-image-l-from-color":[{"mask-l-from":N()}],"mask-image-l-to-color":[{"mask-l-to":N()}],"mask-image-x-from-pos":[{"mask-x-from":j()}],"mask-image-x-to-pos":[{"mask-x-to":j()}],"mask-image-x-from-color":[{"mask-x-from":N()}],"mask-image-x-to-color":[{"mask-x-to":N()}],"mask-image-y-from-pos":[{"mask-y-from":j()}],"mask-image-y-to-pos":[{"mask-y-to":j()}],"mask-image-y-from-color":[{"mask-y-from":N()}],"mask-image-y-to-color":[{"mask-y-to":N()}],"mask-image-radial":[{"mask-radial":[E,M]}],"mask-image-radial-from-pos":[{"mask-radial-from":j()}],"mask-image-radial-to-pos":[{"mask-radial-to":j()}],"mask-image-radial-from-color":[{"mask-radial-from":N()}],"mask-image-radial-to-color":[{"mask-radial-to":N()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":ne()}],"mask-image-conic-pos":[{"mask-conic":[V]}],"mask-image-conic-from-pos":[{"mask-conic-from":j()}],"mask-image-conic-to-pos":[{"mask-conic-to":j()}],"mask-image-conic-from-color":[{"mask-conic-from":N()}],"mask-image-conic-to-color":[{"mask-conic-to":N()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:qi()}],"mask-repeat":[{mask:Ui()}],"mask-size":[{mask:Gi()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",E,M]}],filter:[{filter:["","none",E,M]}],blur:[{blur:Wi()}],brightness:[{brightness:[V,E,M]}],contrast:[{contrast:[V,E,M]}],"drop-shadow":[{"drop-shadow":["","none",S,Mn,On]}],"drop-shadow-color":[{"drop-shadow":N()}],grayscale:[{grayscale:["",V,E,M]}],"hue-rotate":[{"hue-rotate":[V,E,M]}],invert:[{invert:["",V,E,M]}],saturate:[{saturate:[V,E,M]}],sepia:[{sepia:["",V,E,M]}],"backdrop-filter":[{"backdrop-filter":["","none",E,M]}],"backdrop-blur":[{"backdrop-blur":Wi()}],"backdrop-brightness":[{"backdrop-brightness":[V,E,M]}],"backdrop-contrast":[{"backdrop-contrast":[V,E,M]}],"backdrop-grayscale":[{"backdrop-grayscale":["",V,E,M]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[V,E,M]}],"backdrop-invert":[{"backdrop-invert":["",V,E,M]}],"backdrop-opacity":[{"backdrop-opacity":[V,E,M]}],"backdrop-saturate":[{"backdrop-saturate":[V,E,M]}],"backdrop-sepia":[{"backdrop-sepia":["",V,E,M]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",E,M]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[V,"initial",E,M]}],ease:[{ease:["linear","initial",v,E,M]}],delay:[{delay:[V,E,M]}],animate:[{animate:["none",L,E,M]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[_,E,M]}],"perspective-origin":[{"perspective-origin":O()}],rotate:[{rotate:bn()}],"rotate-x":[{"rotate-x":bn()}],"rotate-y":[{"rotate-y":bn()}],"rotate-z":[{"rotate-z":bn()}],scale:[{scale:kn()}],"scale-x":[{"scale-x":kn()}],"scale-y":[{"scale-y":kn()}],"scale-z":[{"scale-z":kn()}],"scale-3d":["scale-3d"],skew:[{skew:bo()}],"skew-x":[{"skew-x":bo()}],"skew-y":[{"skew-y":bo()}],transform:[{transform:[E,M,"","none","gpu","cpu"]}],"transform-origin":[{origin:O()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:_n()}],"translate-x":[{"translate-x":_n()}],"translate-y":[{"translate-y":_n()}],"translate-z":[{"translate-z":_n()}],"translate-none":["translate-none"],accent:[{accent:N()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:N()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",E,M]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mbs":[{"scroll-mbs":T()}],"scroll-mbe":[{"scroll-mbe":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pbs":[{"scroll-pbs":T()}],"scroll-pbe":[{"scroll-pbe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",E,M]}],fill:[{fill:["none",...N()]}],"stroke-w":[{stroke:[V,Pt,it,ns]}],stroke:[{stroke:["none",...N()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},vk=Ob(Jb),Ek="Project slugs must contain at least one letter (a-z) or number (0-9)";function Ak(n){return n.normalize("NFKD").replace(new RegExp("\\p{M}+","gu"),"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}const Qb="5.7.1",Nk={version:Qb};let Fi;Fi=globalThis.crypto;async function Xb(n){return(await Fi).getRandomValues(new Uint8Array(n))}async function Yb(n){const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",t=Math.pow(2,8)-Math.pow(2,8)%e.length;let o="";for(;o.length<n;){const i=await Xb(n-o.length);for(const r of i)r<t&&(o+=e[r%e.length])}return o}async function Zb(n){return await Yb(n)}async function ek(n){const e=await(await Fi).subtle.digest("SHA-256",new TextEncoder().encode(n));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function Dk(n){if(n||(n=43),n<43||n>128)throw`Expected a length between 43 and 128. Received ${n}.`;const e=await Zb(n),t=await ek(e);return{code_verifier:e,code_challenge:t}}class Ko extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}const ss=10,tk=13,rt=32;function zo(n){}function nk(n){if(typeof n=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");const{onEvent:e=zo,onError:t=zo,onRetry:o=zo,onComment:i,maxBufferSize:r}=n,s=[];let l=0,c=!0,p,d="",m=0,g,S=!1;function b(O){if(S)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,O.charCodeAt(0)===239&&O.charCodeAt(1)===187&&O.charCodeAt(2)===191&&(O=O.slice(3))),s.length===0){const T=w(O);T!==""&&(s.push(T),l=T.length),_();return}if(O.indexOf(`
11
+ `)===-1&&O.indexOf("\r")===-1){s.push(O),l+=O.length,_();return}s.push(O);const I=s.join("");s.length=0,l=0;const R=w(I);R!==""&&(s.push(R),l=R.length),_()}function _(){r!==void 0&&(l+d.length<=r||(S=!0,s.length=0,l=0,p=void 0,d="",m=0,g=void 0,t(new Ko(`Buffered data exceeded max buffer size of ${r} characters`,{type:"max-buffer-size-exceeded"}))))}function w(O){let I=0;if(O.indexOf("\r")===-1){let R=O.indexOf(`
12
+ `,I);for(;R!==-1;){if(I===R){m>0&&e({id:p,event:g,data:d}),p=void 0,d="",m=0,g=void 0,I=R+1,R=O.indexOf(`
13
+ `,I);continue}const T=O.charCodeAt(I);if(as(O,I,T)){const D=O.charCodeAt(I+5)===rt?I+6:I+5,pe=O.slice(D,R);if(m===0&&O.charCodeAt(R+1)===ss){e({id:p,event:g,data:pe}),p=void 0,d="",g=void 0,I=R+2,R=O.indexOf(`
14
+ `,I);continue}d=m===0?pe:`${d}
15
+ ${pe}`,m++}else ls(O,I,T)?g=O.slice(O.charCodeAt(I+6)===rt?I+7:I+6,R)||void 0:v(O,I,R);I=R+1,R=O.indexOf(`
16
+ `,I)}return O.slice(I)}for(;I<O.length;){const R=O.indexOf("\r",I),T=O.indexOf(`
17
+ `,I);let D=-1;if(R!==-1&&T!==-1?D=R<T?R:T:R!==-1?R===O.length-1?D=-1:D=R:T!==-1&&(D=T),D===-1)break;v(O,I,D),I=D+1,O.charCodeAt(I-1)===tk&&O.charCodeAt(I)===ss&&I++}return O.slice(I)}function v(O,I,R){if(I===R){F();return}const T=O.charCodeAt(I);if(as(O,I,T)){const Ie=O.charCodeAt(I+5)===rt?I+6:I+5,Ae=O.slice(Ie,R);d=m===0?Ae:`${d}
18
+ ${Ae}`,m++;return}if(ls(O,I,T)){g=O.slice(O.charCodeAt(I+6)===rt?I+7:I+6,R)||void 0;return}if(T===105&&O.charCodeAt(I+1)===100&&O.charCodeAt(I+2)===58){const Ie=O.slice(O.charCodeAt(I+3)===rt?I+4:I+3,R);Ie.includes("\0")||(p=Ie);return}if(T===58){if(i){const Ie=O.slice(I,R);i(Ie.slice(O.charCodeAt(I+1)===rt?2:1))}return}const D=O.slice(I,R),pe=D.indexOf(":");if(pe===-1){L(D,"",D);return}const xn=D.slice(0,pe),bt=D.charCodeAt(pe+1)===rt?2:1,yn=D.slice(pe+bt);L(xn,yn,D)}function L(O,I,R){switch(O){case"event":g=I||void 0;break;case"data":d=m===0?I:`${d}
19
+ ${I}`,m++;break;case"id":I.includes("\0")||(p=I);break;case"retry":/^\d+$/.test(I)?o(parseInt(I,10)):t(new Ko(`Invalid \`retry\` value: "${I}"`,{type:"invalid-retry",value:I,line:R}));break;default:t(new Ko(`Unknown field "${O.length>20?`${O.slice(0,20)}…`:O}"`,{type:"unknown-field",field:O,value:I,line:R}));break}}function F(){m>0&&e({id:p,event:g,data:d}),p=void 0,d="",m=0,g=void 0}function ne(O={}){if(O.consume&&s.length>0){const I=s.join("");v(I,0,I.length)}c=!0,p=void 0,d="",m=0,g=void 0,s.length=0,l=0,S=!1}return{feed:b,reset:ne}}function as(n,e,t){return t===100&&n.charCodeAt(e+1)===97&&n.charCodeAt(e+2)===116&&n.charCodeAt(e+3)===97&&n.charCodeAt(e+4)===58}function ls(n,e,t){return t===101&&n.charCodeAt(e+1)===118&&n.charCodeAt(e+2)===101&&n.charCodeAt(e+3)===110&&n.charCodeAt(e+4)===116&&n.charCodeAt(e+5)===58}class Bk extends TransformStream{constructor({onError:e,onRetry:t,onComment:o,maxBufferSize:i}={}){let r;super({start(s){r=nk({onEvent:l=>{s.enqueue(l)},onError(l){typeof e=="function"&&e(l),(e==="terminate"||l.type==="max-buffer-size-exceeded")&&s.error(l)},onRetry:t,onComment:o,maxBufferSize:i})},transform(s){r.feed(s)}})}}export{us as A,gc as B,ck as C,ms as D,Tk as E,qt as F,Ik as G,Ck as H,ld as I,Vd as J,Bd as K,wk as L,Hr as M,Me as N,vk as O,Mk as P,Ak as Q,Ek as R,_k as S,Sk as T,Nk as U,Rk as V,Bk as W,Dk as X,lk as Y,Tc as a,dk as b,xc as c,ve as d,sk as e,nn as f,U as g,pk as h,ik as i,uk as j,gk as k,hk as l,pc as m,fc as n,dc as o,xk as p,fk as q,Ok as r,rk as s,bk as t,ak as u,mk as v,vc as w,kk as x,yk as y,Ic as z};