videobook 0.3.1 → 0.3.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.
@@ -1,19 +1,19 @@
1
- import{s,_ as h,o as u,a as k,r as z,u as K,b as x,n as y,l as f,d as Te,c as P,t as ua,e as bc,f as Sc,g as Hi}from"./vendor-mcp-BSR9acpG.js";const pa="(?:a[a-z]|b[a-l]|[a-z])[1-8]",da=new RegExp(`^@?(${pa})$`,"iu"),kc=new RegExp(`@(${pa})(?![\\w-])`,"giu");function sn(n){return n.trim().replace(/^@/u,"").toLowerCase()}function Vk(n){return da.test(sn(n))}function Pk(n){return[...n.matchAll(kc)].map(e=>{const t=e[0];return{raw:t,reference:sn(e[1]??t),index:e.index,end:e.index+t.length}})}function Kk(n){const e=n.match(/@([a-z0-9]*)$/iu);return e?sn(e[1]??""):void 0}function ma(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function zk(n,e){let t=n;const o=[...e].map(({reference:i,replacement:r})=>({reference:sn(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(`@${ma(i)}(?![\\w-])`,"giu"),r);return t}function Fk(n,e){let t=n;const o=e.map(sn).filter(i=>i.length>0).sort((i,r)=>r.length-i.length);for(const i of o)t=t.replace(new RegExp(` ?@${ma(i)}(?![\\w-])`,"giu"),"");return t}const Me=64,Oe=8,qk=Me*Oe,_c="@a1-@bl8",ha="Notebook grid is full",qo=26,fa=97;function wc(n){return n.type==="timeline"?Array.from({length:Oe},(e,t)=>({row:n.slot.row,column:t})):[n.slot]}function Uk(n){return n.flatMap(wc)}function Gk(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 Tc(n){return Number.isInteger(n.row)&&n.row>=0&&n.row<Me&&Number.isInteger(n.column)&&n.column>=0&&n.column<Oe}function $n(n,e="Notebook grid slot"){if(!Tc(n))throw new Error(`${e} must be within ${_c}`)}function Ic(n){let e="",t=n+1;for(;t>0;){const o=(t-1)%qo;e=String.fromCharCode(fa+o)+e,t=Math.floor((t-1)/qo)}return e}function Rc(n){let e=0;for(const t of n.toLowerCase())e=e*qo+(t.charCodeAt(0)-fa+1);return e-1}function Cc(n){return $n(n),`${Ic(n.row)}${n.column+1}`}function Lk(n){return`@${Cc(n)}`}function Wk(n){const e=da.exec(n.trim());if(!e)return;const t=e[1],o=t.replace(/\d+$/u,"");return{row:Rc(o),column:Number(t.slice(o.length))-1}}function ln(n){const e=new Set;for(const t of n)$n(t),e.add(`${t.row}:${t.column}`);return e}function jk(n){return vc(n,1)[0]}function vc(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=ln(n),o=[];for(let i=0;i<Me;i+=1)for(let r=0;r<Oe;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(ha)}function ri(n){const e=ln(n);let t=null,o=Number.POSITIVE_INFINITY;for(let i=0;i<Me;i+=1)for(let r=0;r<Oe;r+=1){if(e.has(`${i}:${r}`))continue;const a=i+r;(t===null||a<o||a===o&&(i<t.row||i===t.row&&r<t.column))&&(t={row:i,column:r},o=a)}if(!t)throw new Error(ha);return t}function $k(n,e){$n(n);const t=ln(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<Oe;o+=1)for(let i=n.row;i<Me;i+=1)if(!t.has(`${i}:${o}`))return{row:i,column:o};return ri(e)}function Hk(n,e){$n(n);const t=ln(e);for(let o=n.column;o<Oe;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<Oe;i+=1)if(!t.has(`${o}:${i}`))return{row:o,column:i};return ri(e)}function Jk(n,e,t){const o=ln(t),i=Math.min(Math.max(0,Math.trunc(n)),Me-1),r=Math.min(Math.max(0,Math.trunc(e)),Oe-1);for(let a=i;a+1<Me;a+=1)for(let l=r;l<Oe;l+=1)if(!o.has(`${a}:${l}`)&&!o.has(`${a+1}:${l}`))return{row:a,column:l};return ri(t)}function Mc(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=Mc(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 Oc(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 Ec=new Uint8Array(16);function Ac(){return crypto.getRandomValues(Ec)}const _o={};function Qk(n,e,t){let o;{const i=Date.now(),r=Ac();Nc(_o,i,r),o=Dc(r,_o.msecs,_o.seq,e,t)}return e??Oc(o)}function Nc(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 Dc(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 Xk=["people","places","editing","custom"],Ji=64,Bc=new RegExp("\\p{Cc}","u");function Vc(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(Bc.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 Yk(n){return Vc(n).toLowerCase()}function ai(n,e,t,o){for(const i of n.edges){if(i.source!==e||i.targetInput!=="media")continue;const r=n.cells.find(a=>a.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(a=>a.id===i.target);if(r?.type===t)return{outputCell:r,outputEdge:i}}return null}function Pc(n,e){return ai(n,e,"video","generate-video-output")}function Kc(n,e){return ai(n,e,"image","generate-image-output")}function zc(n,e){return ai(n,e,"audio","generate-audio-output")}function Fc(n){if(typeof n.outputArtifactId=="string")return n.outputArtifactId;if(typeof n.outputEntityId=="string")return n.outputEntityId}function qc(n,e){const t=e.type==="generate_video"?Pc(n,e.id):e.type==="generate_image"?Kc(n,e.id):e.type==="generate_audio"?zc(n,e.id):null;if(typeof t?.outputCell.outputArtifactId=="string")return t.outputCell.outputArtifactId}function Uc(n,e){return qc(n,e)??Fc(e)}function Zk(n,e){return Uc(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 ga(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 a=i.text,l=r.text,c=0;for(;a[c]==l[c];c++)t++;return c&&c<a.length&&c<l.length&&ba(a.charCodeAt(c-1))&&ya(a.charCodeAt(c))&&t--,t}if(i.content.size||r.content.size){let a=ga(i.content,r.content,t+1);if(a!=null)return a}t+=i.nodeSize}}function xa(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 a=n.child(--i),l=e.child(--r),c=a.nodeSize;if(a==l){t-=c,o-=c;continue}if(!a.sameMarkup(l))return{a:t,b:o};if(a.isText&&a.text!=l.text){let p=a.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&&ba(p.charCodeAt(m-1))&&ya(p.charCodeAt(m))&&(t++,o++),{a:t,b:o}}if(a.content.size||l.content.size){let p=xa(a.content,l.content,t-1,o-1);if(p)return p}t-=c,o-=c}}function ya(n){return n>=56320&&n<57344}function ba(n){return n>=55296&&n<56320}class R{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 a=0,l=0;l<t;a++){let c=this.content[a],p=l+c.nodeSize;if(p>e&&o(c,i+l,r||null,a)!==!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="",a=!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&&(a?a=!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 R(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,a=0;a<t;r++){let l=this.content[r],c=a+l.nodeSize;c>e&&((a<e||c>t)&&(l.isText?l=l.cut(Math.max(0,e-a),Math.min(l.text.length,t-a)):l=l.cut(Math.max(0,e-a-1),Math.min(l.content.size,t-a-1))),o.push(l),i+=l.nodeSize),a=c}return new R(o,i)}cutByIndex(e,t){return e==t?R.empty:e==0&&t==this.content.length?this:new R(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 R(i,r)}addToStart(e){return new R([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new R(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 ga(this,e,t)}findDiffEnd(e,t=this.size,o=e.size){return xa(this,e,t,o)}findIndex(e){if(e==0)return Tn(0,e);if(e==this.size)return Tn(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?Tn(t+1,r):Tn(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 R.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return R.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return R.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 R(t||e,o)}static from(e){if(!e)return R.empty;if(e instanceof R)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new R([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}R.empty=new R([],0);const wo={index:0,offset:0};function Tn(n,e){return wo.index=n,wo.offset=e,wo}function Bn(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(!Bn(n[o],e[o]))return!1}else{for(let o in n)if(!(o in e)||!Bn(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&&Bn(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 Xt 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=ka(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(Sa(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(R.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(R.empty,0,0);function Sa(n,e,t){let{index:o,offset:i}=n.findIndex(e),r=n.maybeChild(o),{index:a,offset:l}=n.findIndex(t);if(i==e||r.isText){if(l!=t&&!n.child(a).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(o!=a)throw new RangeError("Removing non-flat range");return n.replaceChild(o,r.copy(Sa(r.content,e-i-1,t-i-1)))}function ka(n,e,t,o,i,r){let{index:a,offset:l}=n.findIndex(e),c=n.maybeChild(a);if(l==e||c.isText)return r&&o<=0&&i<=0&&!r.canReplace(a,a,t)?null:n.cut(0,e).append(t).append(n.cut(e));let p=ka(c.content,e-l-1,t,a==0?o-1:0,a==n.childCount-1?i-1:0,c);return p&&n.replaceChild(a,c.copy(p))}function Gc(n,e,t){if(t.openStart>n.depth)throw new Xt("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Xt("Inconsistent open depths");return _a(n,e,t,0)}function _a(n,e,t,o){let i=n.index(o),r=n.node(o);if(i==e.index(o)&&o<n.depth-t.openStart){let a=_a(n,e,t,o+1);return r.copy(r.content.replaceChild(i,a))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==o&&e.depth==o){let a=n.parent,l=a.content;return pt(a,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:a,end:l}=Lc(t,n);return pt(r,Ta(n,a,l,e,o))}else return pt(r,Vn(n,e,o))}function wa(n,e){if(!e.type.compatibleContent(n.type))throw new Xt("Cannot join "+e.type.name+" onto "+n.type.name)}function Uo(n,e,t){let o=n.node(t);return wa(o,e.node(t)),o}function ut(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 jt(n,e,t,o){let i=(e||n).node(t),r=0,a=e?e.index(t):i.childCount;n&&(r=n.index(t),n.depth>t?r++:n.textOffset&&(ut(n.nodeAfter,o),r++));for(let l=r;l<a;l++)ut(i.child(l),o);e&&e.depth==t&&e.textOffset&&ut(e.nodeBefore,o)}function pt(n,e){if(!n.type.validContent(e))throw new Xt("Invalid content for node "+n.type.name);return n.copy(e)}function Ta(n,e,t,o,i){let r=n.depth>i&&Uo(n,e,i+1),a=o.depth>i&&Uo(t,o,i+1),l=[];return jt(null,n,i,l),r&&a&&e.index(i)==t.index(i)?(wa(r,a),ut(pt(r,Ta(n,e,t,o,i+1)),l)):(r&&ut(pt(r,Vn(n,e,i+1)),l),jt(e,t,i,l),a&&ut(pt(a,Vn(t,o,i+1)),l)),jt(o,null,i,l),new R(l)}function Vn(n,e,t){let o=[];if(jt(null,n,t,o),n.depth>t){let i=Uo(n,e,t+1);ut(pt(i,Vn(n,e,t+1)),o)}return jt(e,null,t,o),new R(o)}function Lc(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(R.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Yt{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 a=0;a<r.length;a++)r[a].type.spec.inclusive===!1&&(!i||!r[a].isInSet(i.marks))&&(r=r[a--].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 $c(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 a=e;;){let{index:l,offset:c}=a.content.findIndex(r),p=r-c;if(o.push(a,l,i+c),!p||(a=a.child(l),a.isText))break;r=p-1,i+=c+1}return new Yt(t,o,r)}static resolveCached(e,t){let o=Qi.get(e);if(o)for(let r=0;r<o.elts.length;r++){let a=o.elts[r];if(a.pos==t)return a}else Qi.set(e,o=new Wc);let i=o.elts[o.i]=Yt.resolve(e,t);return o.i=(o.i+1)%jc,i}}class Wc{constructor(){this.elts=[],this.i=0}}const jc=12,Qi=new WeakMap;class $c{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 Hc=Object.create(null);class ve{constructor(e,t,o,i=q.none){this.type=e,this.attrs=t,this.marks=i,this.content=o||R.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&&Bn(this.attrs,t||e.defaultAttrs||Hc)&&q.sameSet(this.marks,o||q.none)}copy(e=null){return e==this.content?this:new ve(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ve(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),a=o?0:i.sharedDepth(t),l=i.start(a),p=i.node(a).content.cut(i.pos-l,r.pos-l);return new A(p,i.depth-a,r.depth-a)}replace(e,t,o){return Gc(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 Yt.resolveCached(this,e)}resolveNoCache(e){return Yt.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()+")"),Ia(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=R.empty,i=0,r=o.childCount){let a=this.contentMatchAt(e).matchFragment(o,i,r),l=a&&a.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),a=r&&r.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=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=R.fromJSON(e,t.content),r=e.nodeType(t.type).create(t.attrs,i,o);return r.type.checkAttrs(r.attrs),r}}ve.prototype.text=void 0;class Pn extends ve{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):Ia(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 Pn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Pn(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 Ia(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class ft{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let o=new Jc(e,t);if(o.next==null)return ft.empty;let i=Ra(o);o.next&&o.err("Unexpected trailing text");let r=nu(tu(i));return ou(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(a,l){let c=a.matchFragment(e,o);if(c&&(!t||c.validEnd))return R.from(l.map(p=>p.createAndFill()));for(let p=0;p<a.next.length;p++){let{type:d,next:m}=a.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 a=[];for(let l=i;l.type;l=l.via)a.push(l.type);return a.reverse()}for(let a=0;a<r.next.length;a++){let{type:l,next:c}=r.next[a];!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 a=0;a<o.next.length;a++)r+=(a?", ":"")+o.next[a].type.name+"->"+e.indexOf(o.next[a].next);return r}).join(`
2
- `)}}ft.empty=new ft(!0);class Jc{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 Ra(n){let e=[];do e.push(Qc(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Qc(n){let e=[];do e.push(Xc(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Xc(n){let e=eu(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=Yc(n,e);else break;return e}function Xi(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Yc(n,e){let t=Xi(n),o=t;return n.eat(",")&&(n.next!="}"?o=Xi(n):o=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:o,expr:e}}function Zc(n,e){let t=n.nodeTypes,o=t[e];if(o)return[o];let i=[];for(let r in t){let a=t[r];a.isInGroup(e)&&i.push(a)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function eu(n){if(n.eat("(")){let e=Ra(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=Zc(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 tu(n){let e=[[]];return i(r(n,0),t()),e;function t(){return e.push([])-1}function o(a,l,c){let p={term:c,to:l};return e[a].push(p),p}function i(a,l){a.forEach(c=>c.to=l)}function r(a,l){if(a.type=="choice")return a.exprs.reduce((c,p)=>c.concat(r(p,l)),[]);if(a.type=="seq")for(let c=0;;c++){let p=r(a.exprs[c],l);if(c==a.exprs.length-1)return p;i(p,l=t())}else if(a.type=="star"){let c=t();return o(l,c),i(r(a.expr,c),c),[o(c)]}else if(a.type=="plus"){let c=t();return i(r(a.expr,l),c),i(r(a.expr,c),c),[o(c)]}else{if(a.type=="opt")return[o(l)].concat(r(a.expr,l));if(a.type=="range"){let c=l;for(let p=0;p<a.min;p++){let d=t();i(r(a.expr,c),d),c=d}if(a.max==-1)i(r(a.expr,c),c);else for(let p=a.min;p<a.max;p++){let d=t();o(c,d),i(r(a.expr,c),d),c=d}return[o(c)]}else{if(a.type=="name")return[o(l,void 0,a.value)];throw new Error("Unknown expr type")}}}}function Ca(n,e){return e-n}function Yi(n,e){let t=[];return o(e),t.sort(Ca);function o(i){let r=n[i];if(r.length==1&&!r[0].term)return o(r[0].to);t.push(i);for(let a=0;a<r.length;a++){let{term:l,to:c}=r[a];!l&&t.indexOf(c)==-1&&o(c)}}}function nu(n){let e=Object.create(null);return t(Yi(n,0));function t(o){let i=[];o.forEach(a=>{n[a].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]);Yi(n,c).forEach(d=>{p||i.push([l,p=[]]),p.indexOf(d)==-1&&p.push(d)})})});let r=e[o.join(",")]=new ft(o.indexOf(n.length-1)>-1);for(let a=0;a<i.length;a++){let l=i[a][1].sort(Ca);r.next.push({type:i[a][0],next:e[l.join(",")]||t(l)})}return r}}function ou(n,e){for(let t=0,o=[n];t<o.length;t++){let i=o[t],r=!i.validEnd,a=[];for(let l=0;l<i.next.length;l++){let{type:c,next:p}=i.next[l];a.push(c.name),r&&!(c.isText||c.hasRequiredAttrs())&&(r=!1),o.indexOf(p)==-1&&o.push(p)}r&&e.err("Only non-generatable nodes ("+a.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function va(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 Ma(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 Oa(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 Ea(n,e){let t=Object.create(null);if(e)for(let o in e)t[o]=new ru(n,o,e[o]);return t}let Zi=class Aa{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=Ea(e,o.attrs),this.defaultAttrs=va(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==ft.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Ma(this.attrs,e)}create(e=null,t,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ve(this,this.computeAttrs(e),R.from(t),q.setFrom(o))}createChecked(e=null,t,o){return t=R.from(t),this.checkContent(t),new ve(this,this.computeAttrs(e),t,q.setFrom(o))}createAndFill(e=null,t,o){if(e=this.computeAttrs(e),t=R.from(t),t.size){let a=this.contentMatch.fillBefore(t);if(!a)return null;t=a.append(t)}let i=this.contentMatch.matchFragment(t),r=i&&i.fillBefore(R.empty,!0);return r?new ve(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){Oa(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,a)=>o[r]=new Aa(r,t,a));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 iu(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 ru{constructor(e,t,o){this.hasDefault=Object.prototype.hasOwnProperty.call(o,"default"),this.default=o.default,this.validate=typeof o.validate=="string"?iu(e,t,o.validate):o.validate}get isRequired(){return!this.hasDefault}}class Hn{constructor(e,t,o,i){this.name=e,this.rank=t,this.schema=o,this.spec=i,this.attrs=Ea(e,i.attrs),this.excluded=null;let r=va(this.attrs);this.instance=r?new q(this,r):null}create(e=null){return!e&&this.instance?this.instance:new q(this,Ma(this.attrs,e))}static compile(e,t){let o=Object.create(null),i=0;return e.forEach((r,a)=>o[r]=new Hn(r,i++,t,a)),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){Oa(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class e_{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=Zi.compile(this.spec.nodes,this),this.marks=Hn.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],a=r.spec.content||"",l=r.spec.marks;if(r.contentMatch=o[a]||(o[a]=ft.parse(a,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?er(this,l.split(" ")):l==""||!r.inlineContent?[]:null}for(let i in this.marks){let r=this.marks[i],a=r.spec.excludes;r.excluded=a==null?[r]:a==""?[]:er(this,a.split(" "))}this.nodeFromJSON=i=>ve.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 Zi){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 Pn(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 er(n,e){let t=[];for(let o=0;o<e.length;o++){let i=e[o],r=n.marks[i],a=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(a=c)}if(!a)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return t}function au(n){return n.tag!=null}function su(n){return n.style!=null}class Zt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let o=this.matchedStyles=[];t.forEach(i=>{if(au(i))this.tags.push(i);else if(su(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 nr(this,t,!1);return o.addAll(e,q.none,t.from,t.to),o.finish()}parseSlice(e,t={}){let o=new nr(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(uu(e,r.tag)&&(r.namespace===void 0||e.namespaceURI==r.namespace)&&(!r.context||t.matchesContext(r.context))){if(r.getAttrs){let a=r.getAttrs(e);if(a===!1)continue;r.attrs=a||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 a=this.styles[r],l=a.style;if(!(l.indexOf(e)!=0||a.context&&!o.matchesContext(a.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(a.getAttrs){let c=a.getAttrs(t);if(c===!1)continue;a.attrs=c||void 0}return a}}}static schemaRules(e){let t=[];function o(i){let r=i.priority==null?50:i.priority,a=0;for(;a<t.length;a++){let l=t[a];if((l.priority==null?50:l.priority)<r)break}t.splice(a,0,i)}for(let i in e.marks){let r=e.marks[i].spec.parseDOM;r&&r.forEach(a=>{o(a=or(a)),a.mark||a.ignore||a.clearMark||(a.mark=i)})}for(let i in e.nodes){let r=e.nodes[i].spec.parseDOM;r&&r.forEach(a=>{o(a=or(a)),a.node||a.ignore||a.mark||(a.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Zt(e,Zt.schemaRules(e)))}}const Na={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},lu={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Da={ol:!0,ul:!0},en=1,Go=2,$t=4;function tr(n,e,t){return e!=null?(e?en:0)|(e==="full"?Go:0):n&&n.whitespace=="pre"?en|Go:t&~$t}class In{constructor(e,t,o,i,r,a){this.type=e,this.attrs=t,this.marks=o,this.solid=i,this.options=a,this.content=[],this.activeMarks=q.none,this.match=r||(a&$t?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(R.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&en)){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=R.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(R.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&&!Na.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class nr{constructor(e,t,o){this.parser=e,this.options=t,this.isOpen=o,this.open=0,this.localPreserveWS=!1;let i=t.topNode,r,a=tr(null,t.preserveWhitespace,0)|(o?$t:0);i?r=new In(i.type,i.attrs,q.none,!0,t.topMatch||i.type.contentMatch,a):o?r=new In(null,null,q.none,!0,null,a):r=new In(e.schema.topNodeType,null,q.none,!0,null,a),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&Go?"full":this.localPreserveWS||(i.options&en)>0,{schema:a}=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(a.linebreakReplacement&&/[\r\n]/.test(o)&&this.top.findWrapping(a.linebreakReplacement.create())){let l=o.split(/\r?\n|\r/);for(let c=0;c<l.length;c++)c&&this.insertNode(a.linebreakReplacement.create(),t,!0),l[c]&&this.insertNode(a.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(a.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 a=e.nodeName.toLowerCase(),l;Da.hasOwnProperty(a)&&this.parser.normalizeLists&&cu(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,o));e:if(c?c.ignore:lu.hasOwnProperty(a))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(Na.hasOwnProperty(a))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],a=o.getPropertyValue(r);if(a)for(let l=void 0;;){let c=this.parser.matchStyle(r,a,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,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),o,e.nodeName=="BR")||this.leafFallback(e,o);else{let c=this.enter(a,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(a&&a.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 a=o?e.childNodes[o]:e.firstChild,l=i==null?null:e.childNodes[i];a!=l;a=a.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(a,t);this.findAtPoint(e,r)}findPlace(e,t,o){let i,r;for(let a=this.open,l=0;a>=0;a--){let c=this.nodes[a],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 a=0;a<i.length;a++)t=this.enterInner(i[a],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 a=q.none;for(let l of i.concat(e.marks))(r.type?r.type.allowsMarkType(l.type):ir(l.type,e.type))&&(a=l.addToSet(a));return r.content.push(e.mark(a)),!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 a=this.top;a.match=a.match&&a.match.matchType(e);let l=tr(e,r,a.options);a.options&$t&&a.content.length==0&&(l|=$t);let c=q.none;return o=o.filter(p=>(a.type?a.type.allowsMarkType(p.type):ir(p.type,e))?(c=p.addToSet(c),!1):!0),this.nodes.push(new In(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|=en)}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),a=(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(a(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 a(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 cu(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let o=e.nodeType==1?e.nodeName.toLowerCase():null;o&&Da.hasOwnProperty(o)&&t?(t.appendChild(e),e=t):o=="li"?t=e:o&&(t=null)}}function uu(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function or(n){let e={};for(let t in n)e[t]=n[t];return e}function ir(n,e){let t=e.schema.nodes;for(let o in t){let i=t[o];if(!i.allowsMarkType(n))continue;let r=[],a=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&&a(d))return!0}};if(a(i.contentMatch))return!0}}class Et{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},o){o||(o=Rn(t).createDocumentFragment());let i=o,r=[];return e.forEach(a=>{if(r.length||a.marks.length){let l=0,c=0;for(;l<r.length&&c<a.marks.length;){let p=a.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<a.marks.length;){let p=a.marks[c++],d=this.serializeMark(p,a.isInline,t);d&&(r.push([p,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(a,t))}),o}serializeNodeInner(e,t){if(e.isText)return Rn(t).createTextNode(e.text);let{dom:o,contentDOM:i}=En(Rn(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&&En(Rn(o),i(e,t),null,e.attrs)}static renderSpec(e,t,o=null,i){return typeof t=="string"?{dom:e.createTextNode(t)}:En(e,t,o,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Et(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=rr(e.nodes);return t.text||(t.text=o=>o.text),t}static marksFromSchema(e){return rr(e.marks)}}function rr(n){let e={};for(let t in n){let o=n[t].spec.toDOM;o&&(e[t]=o)}return e}function Rn(n){return n.document||window.document}const ar=new WeakMap;function pu(n){let e=ar.get(n);return e===void 0&&ar.set(n,e=du(n)),e}function du(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 En(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=pu(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 a=i.indexOf(" ");a>0&&(t=i.slice(0,a),i=i.slice(a+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:b,contentDOM:S}=En(n,g,t,o);if(c.appendChild(b),S){if(l)throw new RangeError("Multiple content holes");l=S}}}return{dom:c,contentDOM:l}}const Ba=65535,Va=Math.pow(2,16);function mu(n,e){return n+e*Va}function sr(n){return n&Ba}function hu(n){return(n-(n&Ba))/Va}const Pa=1,Ka=2,An=4,za=8;class Lo{constructor(e,t,o){this.pos=e,this.delInfo=t,this.recover=o}get deleted(){return(this.delInfo&za)>0}get deletedBefore(){return(this.delInfo&(Pa|An))>0}get deletedAfter(){return(this.delInfo&(Ka|An))>0}get deletedAcross(){return(this.delInfo&An)>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=sr(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+hu(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,a=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+a],m=c+p;if(e<=m){let g=p?e==c?-1:e==m?1:t:t,b=c+i+(g<0?0:d);if(o)return b;let S=e==(t<0?c:m)?null:mu(l/3,e-c),_=e==c?Ka:e==m?Pa:An;return(t<0?e!=c:e!=m)&&(_|=za),new Lo(b,_,S)}i+=d-p}return o?e+i:new Lo(e+i,0,null)}touches(e,t){let o=0,i=sr(t),r=this.inverted?2:1,a=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+a]-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 a=this.ranges[i],l=a-(this.inverted?r:0),c=a+(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 tn{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 tn(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 tn;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 a=this._maps[r],l=a.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 Lo(e,i,null)}}const To=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=To[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 To)throw new RangeError("Duplicate use of step JSON ID "+e);return To[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 Xt)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 R.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,(a,l)=>!a.isAtom||!l.type.allowsMarkType(this.mark.type)?a:a.mark(this.mark.addToSet(a.marks)),i),t.openStart,t.openEnd);return W.fromReplace(e,this.from,this.to,r)}invert(){return new Ce(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 Ce 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 Ce(t.pos,o.pos,this.mark)}merge(e){return e instanceof Ce&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ce(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 Ce(t.from,t.to,e.markFromJSON(t.mark))}}re.jsonID("removeMark",Ce);class He 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(R.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 He(this.pos,t.marks[i]);return new He(this.pos,this.mark)}}return new gt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new He(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 He(t.pos,e.markFromJSON(t.mark))}}re.jsonID("addNodeMark",He);class gt 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(R.from(o),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new He(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new gt(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 gt(t.pos,e.markFromJSON(t.mark))}}re.jsonID("removeNodeMark",gt);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&&Wo(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,a,l=!1){super(),this.from=e,this.to=t,this.gapFrom=o,this.gapTo=i,this.slice=r,this.insert=a,this.structure=l}apply(e){if(this.structure&&(Wo(e,this.from,this.gapFrom)||Wo(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 Wo(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 a=o.node(r).maybeChild(o.indexAfter(r));for(;i>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,i--}}return!1}function fu(n,e,t,o){let i=[],r=[],a,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),b=Math.min(p+c.nodeSize,t),S=o.addToSet(m);for(let _=0;_<m.length;_++)m[_].isInSet(S)||(a&&a.to==g&&a.mark.eq(m[_])?a.to=b:i.push(a=new Ce(g,b,m[_])));l&&l.to==g?l.to=b:r.push(l=new $e(g,b,o))}}),i.forEach(c=>n.step(c)),r.forEach(c=>n.step(c))}function gu(n,e,t,o){let i=[],r=0;n.doc.nodesBetween(e,t,(a,l)=>{if(!a.isInline)return;r++;let c=null;if(o instanceof Hn){let p=a.marks,d;for(;d=o.isInSet(p);)(c||(c=[])).push(d),p=d.removeFromSet(p)}else o?o.isInSet(a.marks)&&(c=[o]):c=a.marks;if(c&&c.length){let p=Math.min(l+a.nodeSize,t);for(let d=0;d<c.length;d++){let m=c[d],g;for(let b=0;b<i.length;b++){let S=i[b];S.step==r-1&&m.eq(i[b].style)&&(g=S)}g?(g.to=p,g.step=r):i.push({style:m,from:Math.max(l,e),to:p,step:r})}}}),i.forEach(a=>n.step(new Ce(a.from,a.to,a.style)))}function li(n,e,t,o=t.contentMatch,i=!0){let r=n.doc.nodeAt(e),a=[],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)a.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 Ce(l,d,p.marks[g]));if(i&&p.isText&&t.whitespace!="pre"){let g,b=/\r?\n|\r/g,S;for(;g=b.exec(p.text);)S||(S=new A(R.from(t.schema.text(" ",t.allowedMarks(p.marks))),0,0)),a.push(new H(l+g.index,l+g.index+g[0].length,S))}}l=d}if(!o.validEnd){let c=o.fillBefore(R.empty,!0);n.replace(l,l,new A(c,0,0))}for(let c=a.length-1;c>=0;c--)n.step(a[c])}function xu(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function ci(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let o=n.depth,i=0,r=0;;--o){let a=n.$from.node(o),l=n.$from.index(o)+i,c=n.$to.indexAfter(o)-r;if(o<n.depth&&a.canReplace(l,c,t))return o;if(o==0||a.type.spec.isolating||!xu(a,l,c))break;l&&(i=1),c<a.childCount&&(r=1)}return null}function yu(n,e,t){let{$from:o,$to:i,depth:r}=e,a=o.before(r+1),l=i.after(r+1),c=a,p=l,d=R.empty,m=0;for(let S=r,_=!1;S>t;S--)_||o.index(S)>0?(_=!0,d=R.from(o.node(S).copy(d)),m++):c--;let g=R.empty,b=0;for(let S=r,_=!1;S>t;S--)_||i.after(S+1)<i.end(S)?(_=!0,g=R.from(i.node(S).copy(g)),b++):p++;n.step(new me(c,p,a,l,new A(d.append(g),m,b),d.size-m,!0))}function bu(n,e,t){let o=R.empty;for(let a=t.length-1;a>=0;a--){if(o.size){let l=t[a].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=R.from(t[a].type.create(t[a].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 Su(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,(a,l)=>{let c=typeof i=="function"?i(a):i;if(a.isTextblock&&!a.hasMarkup(o,c)&&ku(n.doc,n.mapping.slice(r).map(l),o)){let p=null;if(o.schema.linebreakReplacement){let b=o.whitespace=="pre",S=!!o.contentMatch.matchType(o.schema.linebreakReplacement);b&&!S?p=!1:!b&&S&&(p=!0)}p===!1&&qa(n,a,l,r),li(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+a.nodeSize,1);return n.step(new me(m,g,m+1,g-1,new A(R.from(o.create(c,null,a.marks)),0,0),1,!0)),p===!0&&Fa(n,a,l,r),!1}})}function Fa(n,e,t,o){e.forEach((i,r)=>{if(i.isText){let a,l=/\r?\n|\r/g;for(;a=l.exec(i.text);){let c=n.mapping.slice(o).map(t+1+r+a.index);n.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function qa(n,e,t,o){e.forEach((i,r)=>{if(i.type==i.type.schema.linebreakReplacement){let a=n.mapping.slice(o).map(t+1+r);n.replaceWith(a,a+1,e.type.schema.text(`
5
- `))}})}function ku(n,e,t){let o=n.resolve(e),i=o.index();return o.parent.canReplaceWith(i,i+1,t)}function _u(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 a=t.create(o,null,i||r.marks);if(r.isLeaf)return n.replaceWith(e,e+r.nodeSize,a);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(R.from(a),0,0),1,!0))}function Nn(n,e,t=1,o){let i=n.resolve(e),r=i.depth-t,a=o&&o[o.length-1]||i.parent;if(r<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!a.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 b=m.content.cutByIndex(g,m.childCount),S=o&&o[d+1];S&&(b=b.replaceChild(0,S.type.create(S.attrs)));let _=o&&o[d]||m;if(!m.canReplace(g+1,m.childCount)||!_.type.validContent(b))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 wu(n,e,t=1,o){let i=n.doc.resolve(e),r=R.empty,a=R.empty;for(let l=i.depth,c=i.depth-t,p=t-1;l>c;l--,p--){r=R.from(i.node(l).copy(r));let d=o&&o[p];a=R.from(d?d.type.create(d.attrs,a):i.node(l).copy(a))}n.step(new H(e,e,new A(r.append(a),t,t),!0))}function Ua(n,e){let t=n.resolve(e),o=t.index();return Iu(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(o,o+1)}function Tu(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),a=r.type==o?n.type.schema.nodes.text:r.type;if(t=t.matchType(a),!t||!n.type.allowsMarks(r.marks))return!1}return t.validEnd}function Iu(n,e){return!!(n&&e&&!n.isLeaf&&Tu(n,e))}function Ru(n,e,t){let o=null,{linebreakReplacement:i}=n.doc.type.schema,r=n.doc.resolve(e-t),a=r.node().type;if(i&&a.inlineContent){let d=a.whitespace=="pre",m=!!a.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);qa(n,d.node(),d.before(),l)}a.inlineContent&&li(n,e+t-1,a,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);Fa(n,d.node(),d.before(),n.steps.length)}return n}function Cu(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 vu(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 a=o.depth;a>=0;a--){let l=a==o.depth?0:o.pos<=(o.start(a+1)+o.end(a+1))/2?-1:1,c=o.index(a)+(l>0?1:0),p=o.node(a),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(a+1):o.after(a+1)}return null}function ui(n,e,t=e,o=A.empty){if(e==t&&!o.size)return null;let i=n.resolve(e),r=n.resolve(t);return Ga(i,r,o)?new H(e,t,o):new Mu(i,r,o).fit()}function Ga(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Mu{constructor(e,t,o){this.$from=e,this.$to=t,this.unplaced=o,this.frontier=[],this.placed=R.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=R.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,a=o.depth,l=i.depth;for(;a&&l&&r.childCount==1;)r=r.firstChild.content,a--,l--;let c=new A(r,a,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=lr(this.unplaced.content,o-1).firstChild,i=r.content):i=this.unplaced.content;let a=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:p}=this.frontier[l],d,m=null;if(t==1&&(a?p.matchType(a.type)||(m=p.fillBefore(R.from(a),!1)):r&&c.compatibleContent(r.type)))return{sliceDepth:o,frontierDepth:l,parent:r,inject:m};if(t==2&&a&&(d=p.findWrapping(a.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 cr(e,-1)<=t?!1:(this.unplaced.size>1&&cr(e,1)>o&&o++,this.unplaced=new A(e,t+1,o),!0)}dropNode(){let{content:e,openStart:t,openEnd:o}=this.unplaced,i=lr(e,t);if(i.childCount<=1&&t>0){let r=e.size-t<=t+i.size;this.unplaced=new A(Ut(e,t-1,1),t-1,r?t-1:o)}else this.unplaced=new A(Ut(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 a=this.unplaced,l=o?o.content:a.content,c=a.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 b=l.size+e-(a.content.size-a.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(La(_.mark(g.allowedMarks(_.marks)),p==1?c:0,p==l.childCount?b:-1)))}let S=p==l.childCount;S||(b=-1),this.placed=Gt(this.placed,t,R.from(d)),this.frontier[t].match=m,S&&b<0&&o&&o.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let _=0,w=l;_<b;_++){let O=w.lastChild;this.frontier.push({type:O.type,match:O.contentMatchAt(O.childCount)}),w=O.content}this.unplaced=S?e==0?A.empty:new A(Ut(a.content,e-1,1),e-1,b<0?a.openEnd:e-1):new A(Ut(a.content,e,p),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Io(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)),a=Io(e,t,i,o,r);if(a){for(let l=t-1;l>=0;l--){let{match:c,type:p}=this.frontier[l],d=Io(e,l,p,c,!0);if(!d||d.childCount)continue e}return{depth:t,fit:a,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=Gt(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=Gt(this.placed,this.depth,R.from(e.create(t,o))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(R.empty,!0);t.childCount&&(this.placed=Gt(this.placed,this.frontier.length,t))}}function Ut(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Ut(n.firstChild.content,e-1,t)))}function Gt(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Gt(n.lastChild.content,e-1,t)))}function lr(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function La(n,e,t){if(e<=0)return n;let o=n.content;return e>1&&(o=o.replaceChild(0,La(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(R.empty,!0)))),n.copy(o)}function Io(n,e,t,o,i){let r=n.node(e),a=i?n.indexAfter(e):n.index(e);if(a==r.childCount&&!t.compatibleContent(r.type))return null;let l=o.fillBefore(r.content,!0,a);return l&&!Ou(t,r.content,a)?l:null}function Ou(n,e,t){for(let o=t;o<e.childCount;o++)if(!n.allowsMarks(e.child(o).marks))return!0;return!1}function Eu(n){return n.spec.defining||n.spec.definingForContent}function cr(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 Au(n,e,t,o){if(!o.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),r=n.doc.resolve(t);if(Ga(i,r,o))return n.step(new H(e,t,o));let a=ja(i,r);a[a.length-1]==0&&a.pop();let l=-(i.depth+1);a.unshift(l);for(let g=i.depth,b=i.pos-1;g>0;g--,b--){let S=i.node(g).type.spec;if(S.defining||S.definingAsContext||S.isolating)break;a.indexOf(g)>-1?l=g:i.before(g)==b&&a.splice(1,0,-g)}let c=a.indexOf(l),p=[],d=o.openStart;for(let g=o.content,b=0;;b++){let S=g.firstChild;if(p.push(S),b==o.openStart)break;g=S.content}for(let g=d-1;g>=0;g--){let b=p[g],S=Eu(b.type);if(S&&!b.sameMarkup(i.node(Math.abs(l)-1)))d=g;else if(S||!b.type.isTextblock)break}for(let g=o.openStart;g>=0;g--){let b=(g+d+1)%(o.openStart+1),S=p[b];if(S)for(let _=0;_<a.length;_++){let w=a[(_+c)%a.length],O=!0;w<0&&(O=!1,w=-w);let L=i.node(w-1),F=i.index(w-1);if(L.canReplaceWith(F,F,S.type,S.marks))return n.replace(i.before(w),O?r.after(w):t,new A(Wa(o.content,0,o.openStart,b),b,o.openEnd))}}let m=n.steps.length;for(let g=a.length-1;g>=0&&(n.replace(e,t,o),!(n.steps.length>m));g--){let b=a[g];b<0||(e=i.before(b),t=r.after(b))}}function Wa(n,e,t,o,i){if(e<t){let r=n.firstChild;n=n.replaceChild(0,r.copy(Wa(r.content,e+1,t,o,r)))}if(e>o){let r=i.contentMatchAt(0),a=r.fillBefore(n).append(n);n=a.append(r.matchFragment(a).fillBefore(R.empty,!0))}return n}function Nu(n,e,t,o){if(!o.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=Cu(n.doc,e,o.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new A(R.from(o),0,0))}function Du(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 a=o.sharedDepth(t),l=!1;for(let c=o.depth;c>a;c--)o.node(c).type.spec.isolating&&(l=!0);for(let c=i.depth;c>a;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=ja(o,i);for(let a=0;a<r.length;a++){let l=r[a],c=a==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 a=1;a<=o.depth&&a<=i.depth;a++)if(e-o.start(a)==o.depth-a&&t>o.end(a)&&i.end(a)-t!=i.depth-a&&o.start(a-1)==i.start(a-1)&&o.node(a-1).canReplace(o.index(a-1),i.index(a-1)))return n.delete(o.before(a),t);n.delete(e,t)}function ja(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 Rt 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(R.from(i),0,t.isLeaf?0:1))}getMap(){return de.empty}invert(e){return new Rt(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 Rt(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 Rt(t.pos,t.attr,t.value)}}re.jsonID("attr",Rt);class nn 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 nn(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 nn(t.attr,t.value)}}re.jsonID("docAttr",nn);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 Bu{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new tn}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,a,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=ui(this.doc,e,t,o);return i&&this.step(i),this}replaceWith(e,t,o){return this.replace(e,t,new A(R.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 Au(this,e,t,o),this}replaceRangeWith(e,t,o){return Nu(this,e,t,o),this}deleteRange(e,t){return Du(this,e,t),this}lift(e,t){return yu(this,e,t),this}join(e,t=1){return Ru(this,e,t),this}wrap(e,t){return bu(this,e,t),this}setBlockType(e,t=e,o,i=null){return Su(this,e,t,o,i),this}setNodeMarkup(e,t,o=null,i){return _u(this,e,t,o,i),this}setNodeAttribute(e,t,o){return this.step(new Rt(e,t,o)),this}setDocAttribute(e,t){return this.step(new nn(e,t)),this}addNodeMark(e,t){return this.step(new He(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 gt(e,t));else{let i=o.marks,r,a=[];for(;r=t.isInSet(i);)a.push(new gt(e,r)),i=r.removeFromSet(i);for(let l=a.length-1;l>=0;l--)this.step(a[l])}return this}split(e,t=1,o){return wu(this,e,t,o),this}addMark(e,t,o){return fu(this,e,t,o),this}removeMark(e,t,o){return gu(this,e,t,o),this}clearIncompatible(e,t,o){return li(this,e,t,o),this}}const Ro=Object.create(null);class G{constructor(e,t,o){this.$anchor=e,this.$head=t,this.ranges=o||[new Vu(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,a=this.ranges;for(let l=0;l<a.length;l++){let{$from:c,$to:p}=a[l],d=e.mapping.slice(r);e.replaceRange(d.map(c.pos),d.map(p.pos),l?A.empty:t),l==0&&dr(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:a,$to:l}=i[r],c=e.mapping.slice(o),p=c.map(a.pos),d=c.map(l.pos);r?e.deleteRange(p,d):(e.replaceRangeWith(p,d,t),dr(e,o,t.isInline?-1:1))}}static findFrom(e,t,o=!1){let i=e.parent.inlineContent?new U(e):Tt(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 a=t<0?Tt(e.node(0),e.node(r),e.before(r+1),e.index(r),t,o):Tt(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,o);if(a)return a}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 Tt(e,e,0,0,1)||new he(e)}static atEnd(e){return Tt(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=Ro[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 Ro)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ro[e]=t,t.prototype.jsonID=e,t}getBookmark(){return U.between(this.$anchor,this.$head).getBookmark()}}G.prototype.visible=!0;class Vu{constructor(e,t){this.$from=e,this.$to=t}}let ur=!1;function pr(n){!ur&&!n.parent.inlineContent&&(ur=!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){pr(e),pr(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 Jn(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 Jn{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Jn(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(R.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 pi(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 pi{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:o}=e.mapResult(this.anchor);return t?new Jn(o,o):new pi(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 Pu}}G.jsonID("all",he);const Pu={map(){return this},resolve(n){return new he(n)}};function Tt(n,e,t,o,i,r=!1){if(e.inlineContent)return U.create(n,t);for(let a=o-(i>0?0:1);i>0?a<e.childCount:a>=0;a+=i){let l=e.child(a);if(l.isAtom){if(!r&&B.isSelectable(l))return B.create(n,t-(i<0?l.nodeSize:0))}else{let c=Tt(n,l,t+i,i<0?l.childCount:0,i,r);if(c)return c}t+=l.nodeSize*i}return null}function dr(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],a;r.forEach((l,c,p,d)=>{a==null&&(a=d)}),n.setSelection(G.near(n.doc.resolve(a),t))}const mr=1,Cn=2,hr=4;class Ku extends Bu{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|mr)&~Cn,this.storedMarks=null,this}get selectionSet(){return(this.updated&mr)>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 a=this.doc.resolve(t);r=o==t?a.marks():a.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|=hr,this}get scrolledIntoView(){return(this.updated&hr)>0}}function fr(n,e){return!e||!n?n:n.bind(e)}class Lt{constructor(e,t,o){this.name=e,this.init=fr(t.init,o),this.apply=fr(t.apply,o)}}const zu=[new Lt("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Lt("selection",{init(n,e){return n.selection||G.atStart(e.doc)},apply(n){return n.selection}}),new Lt("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,o){return o.selection.$cursor?n.storedMarks:null}}),new Lt("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=zu.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 Lt(o.key,o.spec.state,o))})}}class Wt{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 a=0;a<this.config.plugins.length;a++){let l=this.config.plugins[a];if(l.spec.appendTransaction){let c=i?i[a].n:0,p=i?i[a].state:this,d=c<t.length&&l.spec.appendTransaction.call(l,c?t.slice(c):t,p,o);if(d&&o.filterTransaction(d,a)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let m=0;m<this.config.plugins.length;m++)i.push(m<a?{state:o,n:t.length}:{state:this,n:0})}t.push(d),o=o.applyInner(d),r=!0}i&&(i[a]={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 Wt(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 Ku(this)}static create(e){let t=new Co(e.doc?e.doc.type.schema:e.schema,e.plugins),o=new Wt(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 Wt(t);for(let r=0;r<o.length;r++){let a=o[r].name;i[a]=this.hasOwnProperty(a)?this[a]: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 Wt(i);return i.fields.forEach(a=>{if(a.name=="doc")r.doc=ve.fromJSON(e.schema,t.doc);else if(a.name=="selection")r.selection=G.fromJSON(r.doc,t.selection);else if(a.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==a.name&&p&&p.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){r[a.name]=p.fromJSON.call(c,e,t[l],r);return}}r[a.name]=a.init(e,r)}}),r}}function $a(n,e,t){for(let o in n){let i=n[o];i instanceof Function?i=i.bind(e):o=="handleDOMEvents"&&(i=$a(i,e,{})),t[o]=i}return t}class Ha{constructor(e){this.spec=e,this.props={},e.props&&$a(e.props,this,this.props),this.key=e.key?e.key.key:Ja("plugin")}getState(e){return e[this.key]}}const vo=Object.create(null);function Ja(n){return n in vo?n+"$"+ ++vo[n]:(vo[n]=0,n+"$")}class Qa{constructor(e="key"){this.key=Ja(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},vt=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let jo=null;const Be=function(n,e,t){let o=jo||(jo=document.createRange());return o.setEnd(n,t??n.nodeValue.length),o.setStart(n,e||0),o},Fu=function(){jo=null},xt=function(n,e,t,o){return t&&(gr(n,e,t,o,-1)||gr(n,e,t,o,1))},qu=/^(img|br|input|textarea|hr)$/i;function gr(n,e,t,o,i){for(var r;;){if(n==t&&e==o)return!0;if(e==(i<0?0:xe(n))){let a=n.parentNode;if(!a||a.nodeType!=1||cn(n)||qu.test(n.nodeName)||n.contentEditable=="false")return!1;e=Z(n)+(i<0?0:1),n=a}else if(n.nodeType==1){let a=n.childNodes[e+(i<0?-1:0)];if(a.nodeType==1&&a.contentEditable=="false")if(!((r=a.pmViewDesc)===null||r===void 0)&&r.ignoreForSelection)e+=i;else return!1;else n=a,e=i<0?xe(n):0}else return!1}}function xe(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Uu(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&&!cn(n))e=Z(n),n=n.parentNode;else return null}}function Gu(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&&!cn(n))e=Z(n)+1,n=n.parentNode;else return null}}function Lu(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 cn(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 Qn=function(n){return n.focusNode&&xt(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 Wu(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function ju(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,xr=typeof document<"u"?document:null,et=Ee&&Ee.userAgent||"",$o=/Edge\/(\d+)/.exec(et),Xa=/MSIE \d/.exec(et),Ho=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(et),ue=!!(Xa||Ho||$o),Je=Xa?document.documentMode:Ho?+Ho[1]:$o?+$o[1]:0,ye=!ue&&/gecko\/(\d+)/i.test(et);ye&&+(/Firefox\/(\d+)/.exec(et)||[0,0])[1];const Jo=!ue&&/Chrome\/(\d+)/.exec(et),te=!!Jo,Ya=Jo?+Jo[1]:0,ie=!ue&&!!Ee&&/Apple Computer/.test(Ee.vendor),Mt=ie&&(/Mobile\/\w+/.test(et)||!!Ee&&Ee.maxTouchPoints>2),ge=Mt||(Ee?/Mac/.test(Ee.platform):!1),Za=Ee?/Win/.test(Ee.platform):!1,Pe=/Android \d/.test(et),un=!!xr&&"webkitFontSmoothing"in xr.documentElement.style,$u=un?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Hu(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 Ju(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 yr(n,e,t){if(!Qo(e)&&e.left==0)return;let o=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,r=n.dom.ownerDocument;for(let a=t||n.dom;a;){if(a.nodeType!=1){a=vt(a);continue}let l=a,c=l==r.body,p=c?Hu(r):Ju(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 b=l.scrollLeft,S=l.scrollTop;m&&(l.scrollTop+=m),d&&(l.scrollLeft+=d);let _=l.scrollLeft-b,w=l.scrollTop-S;e={left:e.left-_,top:e.top-w,right:e.right-_,bottom:e.bottom-w}}let g=c?"fixed":getComputedStyle(a).position;if(/^(fixed|sticky)$/.test(g))break;a=g=="absolute"?a.offsetParent:vt(a)}}function Qu(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),o,i;for(let r=(e.left+e.right)/2,a=t+1;a<Math.min(innerHeight,e.bottom);a+=5){let l=n.root.elementFromPoint(r,a);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:es(n.dom)}}function es(n){let e=[],t=n.ownerDocument;for(let o=n;o&&(e.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),n!=t);o=vt(o));return e}function Xu({refDOM:n,refTop:e,stack:t}){let o=n?n.getBoundingClientRect().top:0;ts(t,o==0?0:o-e)}function ts(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 _t=null;function Yu(n){if(n.setActive)return n.setActive();if(_t)return n.focus(_t);let e=es(n);n.focus(_t==null?{get preventScroll(){return _t={preventScroll:!0},!0}}:void 0),_t||(_t=!1,ts(e,0))}function ns(n,e){let t,o=2e8,i,r=0,a=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 b=0;b<g.length;b++){let S=g[b];if(S.top<=a&&S.bottom>=l){a=Math.max(S.bottom,a),l=Math.min(S.top,l);let _=S.left>e.left?S.left-e.left:S.right<e.left?e.left-S.right:0;if(_<o){t=d,o=_,i=_&&t.nodeType==3?{left:S.right<e.left?S.right:S.left,top:e.top}:e,d.nodeType==1&&_&&(r=m+(e.left>=(S.left+S.right)/2?1:0));continue}}else S.top>e.top&&!c&&S.left<=e.left&&S.right>=e.left&&(c=d,p={left:Math.max(S.left,Math.min(S.right,e.left)),top:S.top});!t&&(e.left>=S.right&&e.top>=S.top||e.left>=S.left&&e.top>=S.bottom)&&(r=m+1)}}return!t&&c&&(t=c,i=p,o=0),t&&t.nodeType==3?Zu(t,i):!t||o&&t.nodeType==1?{node:n,offset:r}:ns(t,i)}function Zu(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 a=Ge(o,1);if(a.top!=a.bottom&&di(e,a)){i={node:n,offset:r+(e.left>=(a.left+a.right)/2?1:0)};break}}return o.detach(),i||{node:n,offset:0}}function di(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function ep(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function tp(n,e,t){let{node:o,offset:i}=ns(e,t),r=-1;if(o.nodeType==1&&!o.firstChild){let a=o.getBoundingClientRect();r=a.left!=a.right&&t.left>(a.left+a.right)/2?1:-1}return n.docView.posFromDOM(o,i,r)}function np(n,e,t,o){let i=-1;for(let r=e,a=!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)&&(!a&&c.left>o.left||c.top>o.top?i=l.posBefore:(!a&&c.right<o.left||c.bottom<o.top)&&(i=l.posAfter),a=!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 is(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 a=n.childNodes[r];if(a.nodeType==1){let l=a.getClientRects();for(let c=0;c<l.length;c++){let p=l[c];if(di(e,p))return is(a,e,p)}}if((r=(r+1)%o)==i)break}return n}function op(n,e){let t=n.dom.ownerDocument,o,i=0,r=ju(t,e.left,e.top);r&&({node:o,offset:i}=r);let a=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!a||!n.dom.contains(a.nodeType!=1?a.parentNode:a)){let p=n.dom.getBoundingClientRect();if(!di(e,p)||(a=is(n.dom,e,p),!a))return null}if(ie)for(let p=a;o&&p;p=vt(p))p.draggable&&(o=void 0);if(a=ep(a,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;un&&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=np(n,o,i,e))}l==null&&(l=tp(n,a,e));let c=n.docView.nearestDesc(a,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function Qo(n){return n.top<n.bottom||n.left<n.right}function Ge(n,e){let t=n.getClientRects();if(t.length){let o=t[e<0?0:t.length-1];if(Qo(o))return o}return Array.prototype.find.call(t,Qo)||n.getBoundingClientRect()}const ip=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function rs(n,e,t){let{node:o,offset:i,atom:r}=n.docView.domFromPos(e,t<0?-1:1),a=un||ye;if(o.nodeType==3)if(a&&(ip.test(o.nodeValue)||(t<0?!i:i==o.nodeValue.length))){let c=Ge(Be(o,i,i),t);if(ye&&i&&/\s/.test(o.nodeValue[i-1])&&i<o.nodeValue.length){let p=Ge(Be(o,i-1,i-1),-1);if(p.top==c.top){let d=Ge(Be(o,i,i+1),-1);if(d.top!=c.top)return Kt(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++,Kt(Ge(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 Mo(c.getBoundingClientRect(),!1)}if(r==null&&i<xe(o)){let c=o.childNodes[i];if(c.nodeType==1)return Mo(c.getBoundingClientRect(),!0)}return Mo(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)-(a?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(p)return Kt(Ge(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,a?0:1):c.nodeType==1?c:null:null;if(p)return Kt(Ge(p,-1),!0)}return Kt(Ge(o.nodeType==3?Be(o):o,-t),t>=0)}function Kt(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 Mo(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 as(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 rp(n,e,t){let o=e.selection,i=t=="up"?o.$from:o.$to;return as(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 a=rs(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"?a.top-d.top>(d.bottom-a.top)*2:d.bottom-a.bottom>(a.bottom-d.top)*2))return!1}}return!0})}const ap=/[\u0590-\u08ac]/;function sp(n,e,t){let{$head:o}=e.selection;if(!o.parent.isTextblock)return!1;let i=o.parentOffset,r=!i,a=i==o.parent.content.size,l=n.domSelection();return l?!ap.test(o.parent.textContent)||!l.modify?t=="left"||t=="backward"?r:a:as(n,e,()=>{let{focusNode:c,focusOffset:p,anchorNode:d,anchorOffset:m}=n.domSelectionRange(),g=l.caretBidiLevel;l.modify("move",t,"character");let b=o.depth?n.docView.domAfterPos(o.before()):n.dom,{focusNode:S,focusOffset:_}=n.domSelectionRange(),w=S&&!b.contains(S.nodeType==1?S:S.parentNode)||c==S&&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 br=null,Sr=null,kr=!1;function lp(n,e,t){return br==e&&Sr==t?kr:(br=e,Sr=t,kr=t=="up"||t=="down"?rp(n,e,t):sp(n,e,t))}const be=0,_r=1,lt=2,we=3;class pn{constructor(e,t,o,i){this.parent=e,this.children=t,this.dom=o,this.contentDOM=i,this.dirty=be,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,a;if(e==this.contentDOM)r=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.previousSibling}for(;r&&!((a=r.pmViewDesc)&&a.parent==this);)r=r.previousSibling;return r?this.posBeforeChild(a)+a.size:this.posAtStart}else{let r,a;if(e==this.contentDOM)r=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.nextSibling}for(;r&&!((a=r.pmViewDesc)&&a.parent==this);)r=r.nextSibling;return r?this.posBeforeChild(a):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),a;if(r&&(!t||r.node))if(o&&(a=r.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==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 a=0;a<i.children.length;a++){let l=i.children[a];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 a=this.children[o],l=r+a.size;if(l>e||a instanceof ls){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 ss&&r.side>=0;o--);if(t<=0){let r,a=!0;for(;r=o?this.children[o-1]:null,!(!r||r.dom.parentNode==this.contentDOM);o--,a=!1);return r&&t&&a&&!r.border&&!r.domAtom?r.domFromPos(r.size,t):{node:this.contentDOM,offset:r?Z(r.dom)+1:0}}else{let r,a=!0;for(;r=o<this.children.length?this.children[o]:null,!(!r||r.dom.parentNode==this.contentDOM);o++,a=!1);return r&&a&&!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 a=o,l=0;;l++){let c=this.children[l],p=a+c.size;if(i==-1&&e<=p){let d=a+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=a;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}a=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),a=Math.max(e,t);for(let b=0,S=0;b<this.children.length;b++){let _=this.children[b],w=S+_.size;if(r>S&&a<w)return _.setSelection(e-S-_.border,t-S-_.border,o,i);S=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:b,offset:S}=l;if(b.nodeType==3){if(m=!!(S&&b.nodeValue[S-1]==`
6
- `),m&&S==b.nodeValue.length)for(let _=b,w;_;_=_.parentNode){if(w=_.nextSibling){w.nodeName=="BR"&&(l=c={node:w.parentNode,offset:Z(w)+1});break}let O=_.pmViewDesc;if(O&&O.node&&O.node.isBlock)break}}else{let _=b.childNodes[S-1];m=_&&(_.nodeName=="BR"||_.contentEditable=="false")}}if(ye&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let b=d.focusNode.childNodes[d.focusOffset];b&&b.contentEditable=="false"&&(i=!0)}if(!(i||m&&ie)&&xt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&xt(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 S=l;l=c,c=S}let b=document.createRange();b.setEnd(c.node,c.offset),b.setStart(l.node,l.offset),p.removeAllRanges(),p.addRange(b)}}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],a=o+r.size;if(o==a?e<=a&&t>=o:e<a&&t>o){let l=o+r.border,c=a-r.border;if(e>=l&&t<=c){this.dirty=e==o||t==a?lt:_r,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?lt:we}o=a}this.dirty=lt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let o=e==1?lt:_r;t.dirty<o&&(t.dirty=o)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class ss extends pn{constructor(e,t,o,i){let r,a=t.type.toDOM;if(typeof a=="function"&&(a=a(o,()=>{if(!r)return i;if(r.parent)return r.parent.posBeforeChild(r)})),!t.type.spec.raw){if(a.nodeType!=1){let l=document.createElement("span");l.appendChild(a),a=l}a.hasAttribute("contenteditable")||(a.contentEditable="false"),a.classList.add("ProseMirror-widget")}super(e,[],a,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return this.dirty==be&&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 cp extends pn{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 Qe extends pn{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],a=r&&r(t,i,o);return(!a||!a.dom)&&(a=Et.renderSpec(document,t.type.spec.toDOM(t,o),null,t.attrs)),new Qe(e,t,a.dom,a.contentDOM||a.dom,a)}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!=be){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=be}}slice(e,t,o){let i=Qe.create(this.parent,this.mark,!0,o),r=this.children,a=this.size;t<a&&(r=Yo(r,t,a,o)),e>0&&(r=Yo(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 Xe extends pn{constructor(e,t,o,i,r,a,l){super(e,[],r,a),this.node=t,this.outerDeco=o,this.innerDeco=i,this.nodeDOM=l}static create(e,t,o,i,r,a){let l=r.nodeViews[t.type.name],c,p=l&&l(t,r,()=>{if(!c)return a;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}=Et.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=ps(d,o,t),p?c=new up(e,t,o,i,d,m||null,g,p):t.isText?new Xn(e,t,o,i,d,g):new Xe(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=()=>R.empty}}return t}matchesNode(e,t,o){return this.dirty==be&&e.eq(this.node)&&Kn(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,a=r&&r.pos>-1?r:null,l=r&&r.pos<0,c=new dp(this,a&&a.node,e);fp(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 b;c.findNodeMatch(p,d,m,g)||l&&e.state.selection.from>i&&e.state.selection.to<i+p.nodeSize&&(b=c.findIndexWithChild(r.node))>-1&&c.updateNodeAt(p,d,m,b,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==lt)&&(a&&this.protectLocalComposition(e,a),cs(this.contentDOM,this.children,e),Mt&&gp(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 a=r.nodeValue,l=xp(this.node.content,a,o-t,i-t);return l<0?null:{node:r,pos:l,text:a}}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 a=new cp(this,r,t,i);e.input.compositionNodes.push(a),this.children=Yo(this.children,o,o+i.length,e,a)}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=be}updateOuterDeco(e){if(Kn(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,o=this.dom;this.dom=us(this.dom,this.nodeDOM,Xo(this.outerDeco,this.node,t),Xo(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 wr(n,e,t,o,i){ps(o,e,n);let r=new Xe(void 0,n,e,t,o,o,o);return r.contentDOM&&r.updateChildren(i,0),r}class Xn extends Xe{constructor(e,t,o,i,r,a){super(e,t,o,i,r,null,a)}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!=be&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=be||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=be,!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 Xn(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 ls extends pn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==be&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class up extends Xe{constructor(e,t,o,i,r,a,l,c){super(e,t,o,i,r,a,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 cs(n,e,t){let o=n.firstChild,i=!1;for(let r=0;r<e.length;r++){let a=e[r],l=a.dom;if(l.parentNode==n){for(;l!=o;)o=Tr(o),i=!0;o=o.nextSibling}else i=!0,n.insertBefore(l,o);if(a instanceof Qe){let c=o?o.previousSibling:n.lastChild;cs(a.contentDOM,a.children,t),o=c?c.nextSibling:n.firstChild}}for(;o;)o=Tr(o),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const Ht=function(n){n&&(this.nodeName=n)};Ht.prototype=Object.create(null);const ct=[new Ht];function Xo(n,e,t){if(n.length==0)return ct;let o=t?ct[0]:new Ht,i=[o];for(let r=0;r<n.length;r++){let a=n[r].type.attrs;if(a){a.nodeName&&i.push(o=new Ht(a.nodeName));for(let l in a){let c=a[l];c!=null&&(t&&i.length==1&&i.push(o=new Ht(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 us(n,e,t,o){if(t==ct&&o==ct)return e;let i=e;for(let r=0;r<o.length;r++){let a=o[r],l=t[r];if(r){let c;l&&l.nodeName==a.nodeName&&i!=n&&(c=i.parentNode)&&c.nodeName.toLowerCase()==a.nodeName||(c=document.createElement(a.nodeName),c.pmIsDeco=!0,c.appendChild(i),l=ct[0]),i=c}pp(i,l||ct[0],a)}return i}function pp(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 ps(n,e,t){return us(n,n,ct,Xo(e,t,n.nodeType!=1))}function Kn(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 Tr(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class dp{constructor(e,t,o){this.lock=t,this.view=o,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=mp(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,a=this.stack.length>>1,l=Math.min(a,e.length);for(;r<l&&(r==a-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&e[r].type.spec.spanning!==!1;)r++;for(;r<a;)this.destroyRest(),this.top.dirty=be,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<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[a])&&!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 Qe&&d.dirty!=we&&d.mark.type==e[a].type&&d.spec.update&&!this.isLocked(d.dom)&&d.spec.update(e[a])&&(d.mark=e[a],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=Qe.create(this.top,e[a],t,o);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,o,i){let r=-1,a;if(i>=this.preMatch.index&&(a=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,o))r=this.top.children.indexOf(a,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 a=this.top.children[i];return a.dirty==we&&a.dom==a.contentDOM&&(a.dirty=lt),a.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,a){for(let l=this.index;l<this.top.children.length;l++){let c=this.top.children[l];if(c instanceof Xe){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&&Kn(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,a)))return this.destroyBetween(this.index,l),this.top.children[this.index]=m,m.contentDOM&&(m.dirty=lt,m.updateChildren(i,a+1),m.dirty=be),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,o,i,r,a){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Kn(o,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Xe.create(this.top,t,o,i,r,a);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 a=Xe.create(this.top,e,t,o,i,r);a.contentDOM&&a.updateChildren(i,r+1),this.top.children.splice(this.index++,0,a),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 ss(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 Qe;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Xn)||/\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 ls(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 mp(n,e){let t=e,o=t.children.length,i=n.childCount,r=new Map,a=[];e:for(;i>0;){let l;for(;;)if(o){let p=t.children[o-1];if(p instanceof Qe)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),a.push(l)}}return{index:i,matched:r,matches:a.reverse()}}function hp(n,e){return n.type.side-e.type.side}function fp(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 a=0,l=[],c=null;for(let p=0;;){let d,m;for(;a<i.length&&i[a].to==r;){let w=i[a++];w.widget&&(d?(m||(m=[d])).push(w):d=w)}if(d)if(m){m.sort(hp);for(let w=0;w<m.length;w++)t(m[w],p,!!c)}else t(d,p,!!c);let g,b;if(c)b=-1,g=c,c=null;else if(p<n.childCount)b=p,g=n.child(p++);else break;for(let w=0;w<l.length;w++)l[w].to<=r&&l.splice(w--,1);for(;a<i.length&&i[a].from<=r&&i[a].to>r;)l.push(i[a++]);let S=r+g.nodeSize;if(g.isText){let w=S;a<i.length&&i[a].from<w&&(w=i[a].from);for(let O=0;O<l.length;O++)l[O].to<w&&(w=l[O].to);w<S&&(c=g.cut(w-r),g=g.cut(0,w-r),S=w,b=-1)}else for(;a<i.length&&i[a].to<S;)a++;let _=g.isInline&&!g.isLeaf?l.filter(w=>!w.inline):l.slice();o(g,_,e.forChild(r,g),b),r=S}}function gp(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 xp(n,e,t,o){for(let i=0,r=0;i<n.childCount&&r<=o;){let a=n.child(i++),l=r;if(r+=a.nodeSize,!a.isText)continue;let c=a.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 Yo(n,e,t,o,i){let r=[];for(let a=0,l=0;a<n.length;a++){let c=n[a],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 mi(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,a=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(a<0)return null;let l=o.resolve(a),c,p;if(Qn(t)){for(c=a;i&&!i.node;)i=i.parent;let m=i.node;if(i&&m.isAtom&&B.isSelectable(m)&&i.parent&&!(m.isInline&&Lu(t.focusNode,t.focusOffset,i.dom))){let g=i.posBefore;p=new B(a==g?l:o.resolve(g))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let m=a,g=a;for(let b=0;b<t.rangeCount;b++){let S=t.getRangeAt(b);m=Math.min(m,n.docView.posFromDOM(S.startContainer,S.startOffset,1)),g=Math.max(g,n.docView.posFromDOM(S.endContainer,S.endOffset,-1))}if(m<0)return null;[c,a]=g==n.state.selection.anchor?[g,m]:[m,g],l=o.resolve(a)}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=hi(n,d,l,m)}return p}function ds(n){return n.editable?n.hasFocus():hs(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function ze(n,e=!1){let t=n.state.selection;if(ms(n,t),!ds(n))return;let o=n.input.mouseDown;if(!e&&te&&o){let i=n.domSelectionRange(),r=n.domObserver.currentSelection;if(i.anchorNode&&r.anchorNode&&xt(i.anchorNode,i.anchorOffset,r.anchorNode,r.anchorOffset)&&o.delaySelUpdate()){n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)bp(n);else{let{anchor:i,head:r}=t,a,l;Ir&&!(t instanceof U)&&(t.$from.parent.inlineContent||(a=Rr(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(l=Rr(n,t.to))),n.docView.setSelection(i,r,n,e),Ir&&(a&&Cr(a),l&&Cr(l)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&yp(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}const Ir=ie||te&&Ya<63;function Rr(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 Oo(i);if((!i||i.contentEditable=="false")&&(!r||r.contentEditable=="false")){if(i)return Oo(i);if(r)return Oo(r)}}function Oo(n){return n.contentEditable="true",ie&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Cr(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function yp(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(()=>{(!ds(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function bp(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&&Je<=11&&(t.disabled=!0,t.disabled=!1)}function ms(n,e){if(e instanceof B){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(vr(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else vr(n)}function vr(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function hi(n,e,t,o){return n.someProp("createSelectionBetween",i=>i(n,e,t))||U.between(e,t,o)}function Mr(n){return n.editable&&!n.hasFocus()?!1:hs(n)}function hs(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 Sp(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return xt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Zo(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 Le(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 a=n.state.doc.resolve(i.pos+r.nodeSize*(e<0?-1:1));return Le(n,new U(o.$anchor,a))}else if(o.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Zo(n.state,e);return i&&i instanceof B?Le(n,i):!1}else if(!(ge&&t.indexOf("m")>-1)){let i=o.$head,r=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,a;if(!r||r.isText)return!1;let l=e<0?i.pos-r.nodeSize:i.pos;return r.isAtom||(a=n.docView.descAt(l))&&!a.contentDOM?B.isSelectable(r)?Le(n,new B(e<0?n.state.doc.resolve(i.pos-r.nodeSize):i)):un?Le(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 Le(n,new U(e>0?o.$to:o.$from));{let i=Zo(n.state,e);return i?Le(n,i):!1}}}function zn(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Jt(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function wt(n,e){return e<0?kp(n):_p(n)}function kp(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let i,r,a=!1;for(ye&&t.nodeType==1&&o<zn(t)&&Jt(t.childNodes[o],-1)&&(a=!0);;)if(o>0){if(t.nodeType!=1)break;{let l=t.childNodes[o-1];if(Jt(l,-1))i=t,r=--o;else if(l.nodeType==3)t=l,o=t.nodeValue.length;else break}}else{if(fs(t))break;{let l=t.previousSibling;for(;l&&Jt(l,-1);)i=t.parentNode,r=Z(l),l=l.previousSibling;if(l)t=l,o=zn(t);else{if(t=t.parentNode,t==n.dom)break;o=0}}}a?ei(n,t,o):i&&ei(n,i,r)}function _p(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let i=zn(t),r,a;for(;;)if(o<i){if(t.nodeType!=1)break;let l=t.childNodes[o];if(Jt(l,1))r=t,a=++o;else break}else{if(fs(t))break;{let l=t.nextSibling;for(;l&&Jt(l,1);)r=l.parentNode,a=Z(l)+1,l=l.nextSibling;if(l)t=l,o=0,i=zn(t);else{if(t=t.parentNode,t==n.dom)break;o=i=0}}}r&&ei(n,r,a)}function fs(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function wp(n,e){for(;n&&e==n.childNodes.length&&!cn(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 Tp(n,e){for(;n&&!e&&!cn(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 ei(n,e,t){if(e.nodeType!=3){let r,a;(a=wp(e,t))?(e=a,t=0):(r=Tp(e,t))&&(e=r,t=r.nodeValue.length)}let o=n.domSelection();if(!o)return;if(Qn(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 Er(n,e){let t=n.state.doc.resolve(e);if(!(te||Za)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let r=n.coordsAtPos(e-1),a=(r.top+r.bottom)/2;if(a>i.top&&a<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),a=(r.top+r.bottom)/2;if(a>i.top&&a<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 Ar(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 a=Zo(n.state,e);if(a&&a instanceof B)return Le(n,a)}if(!i.parent.inlineContent){let a=e<0?i:r,l=o instanceof he?G.near(a,e):G.findFrom(a,e);return l?Le(n,l):!1}return!1}function Nr(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 a=n.state.tr;return e<0?a.delete(t.pos-r.nodeSize,t.pos):a.delete(t.pos,t.pos+r.nodeSize),n.dispatch(a),!0}return!1}function Dr(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Ip(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;Dr(n,o,"true"),setTimeout(()=>Dr(n,o,"false"),20)}return!1}function Rp(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Cp(n,e){let t=e.keyCode,o=Rp(e);if(t==8||ge&&t==72&&o=="c")return Nr(n,-1)||wt(n,-1);if(t==46&&!e.shiftKey||ge&&t==68&&o=="c")return Nr(n,1)||wt(n,1);if(t==13||t==27)return!0;if(t==37||ge&&t==66&&o=="c"){let i=t==37?Er(n,n.state.selection.from)=="ltr"?-1:1:-1;return Or(n,i,o)||wt(n,i)}else if(t==39||ge&&t==70&&o=="c"){let i=t==39?Er(n,n.state.selection.from)=="ltr"?1:-1:1;return Or(n,i,o)||wt(n,i)}else{if(t==38||ge&&t==80&&o=="c")return Ar(n,-1,o)||wt(n,-1);if(t==40||ge&&t==78&&o=="c")return Ip(n)||Ar(n,1,o)||wt(n,1);if(o==(ge?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function fi(n,e){n.someProp("transformCopied",b=>{e=b(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 b=o.firstChild;t.push(b.type.name,b.attrs!=b.type.defaultAttrs?b.attrs:null),o=b.content}let a=n.someProp("clipboardSerializer")||Et.fromSchema(n.state.schema),l=ks(),c=l.createElement("div");c.appendChild(a.serializeFragment(o,{document:l}));let p=c.firstChild,d,m=0;for(;p&&p.nodeType==1&&(d=Ss[p.nodeName.toLowerCase()]);){for(let b=d.length-1;b>=0;b--){let S=l.createElement(d[b]);for(;c.firstChild;)S.appendChild(c.firstChild);c.appendChild(S),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",b=>b(e,n))||e.content.textBetween(0,e.content.size,`
1
+ import{s,_ as h,o as u,a as k,r as z,u as K,b as x,n as y,l as f,d as Te,c as P,t as pa,e as yc,f as bc,g as Ji}from"./vendor-mcp-9gUvOX4H.js";const da="(?:a[a-z]|b[a-l]|[a-z])[1-8]",ma=new RegExp(`^@?(${da})$`,"iu"),Sc=new RegExp(`@(${da})(?![\\w-])`,"giu");function sn(n){return n.trim().replace(/^@/u,"").toLowerCase()}function Vk(n){return ma.test(sn(n))}function Pk(n){return[...n.matchAll(Sc)].map(e=>{const t=e[0];return{raw:t,reference:sn(e[1]??t),index:e.index,end:e.index+t.length}})}function Kk(n){const e=n.match(/@([a-z0-9]*)$/iu);return e?sn(e[1]??""):void 0}function ha(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function zk(n,e){let t=n;const o=[...e].map(({reference:i,replacement:r})=>({reference:sn(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(`@${ha(i)}(?![\\w-])`,"giu"),r);return t}function Fk(n,e){let t=n;const o=e.map(sn).filter(i=>i.length>0).sort((i,r)=>r.length-i.length);for(const i of o)t=t.replace(new RegExp(` ?@${ha(i)}(?![\\w-])`,"giu"),"");return t}const Me=64,Oe=8,qk=Me*Oe,kc="@a1-@bl8",fa="Notebook grid is full",qo=26,ga=97;function _c(n){return n.type==="timeline"?Array.from({length:Oe},(e,t)=>({row:n.slot.row,column:t})):[n.slot]}function Uk(n){return n.flatMap(_c)}function Gk(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 wc(n){return Number.isInteger(n.row)&&n.row>=0&&n.row<Me&&Number.isInteger(n.column)&&n.column>=0&&n.column<Oe}function $n(n,e="Notebook grid slot"){if(!wc(n))throw new Error(`${e} must be within ${kc}`)}function Tc(n){let e="",t=n+1;for(;t>0;){const o=(t-1)%qo;e=String.fromCharCode(ga+o)+e,t=Math.floor((t-1)/qo)}return e}function Ic(n){let e=0;for(const t of n.toLowerCase())e=e*qo+(t.charCodeAt(0)-ga+1);return e-1}function Rc(n){return $n(n),`${Tc(n.row)}${n.column+1}`}function Lk(n){return`@${Rc(n)}`}function Wk(n){const e=ma.exec(n.trim());if(!e)return;const t=e[1],o=t.replace(/\d+$/u,"");return{row:Ic(o),column:Number(t.slice(o.length))-1}}function ln(n){const e=new Set;for(const t of n)$n(t),e.add(`${t.row}:${t.column}`);return e}function jk(n){return Cc(n,1)[0]}function Cc(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=ln(n),o=[];for(let i=0;i<Me;i+=1)for(let r=0;r<Oe;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(fa)}function ri(n){const e=ln(n);let t=null,o=Number.POSITIVE_INFINITY;for(let i=0;i<Me;i+=1)for(let r=0;r<Oe;r+=1){if(e.has(`${i}:${r}`))continue;const a=i+r;(t===null||a<o||a===o&&(i<t.row||i===t.row&&r<t.column))&&(t={row:i,column:r},o=a)}if(!t)throw new Error(fa);return t}function $k(n,e){$n(n);const t=ln(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<Oe;o+=1)for(let i=n.row;i<Me;i+=1)if(!t.has(`${i}:${o}`))return{row:i,column:o};return ri(e)}function Hk(n,e){$n(n);const t=ln(e);for(let o=n.column;o<Oe;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<Oe;i+=1)if(!t.has(`${o}:${i}`))return{row:o,column:i};return ri(e)}function Jk(n,e,t){const o=ln(t),i=Math.min(Math.max(0,Math.trunc(n)),Me-1),r=Math.min(Math.max(0,Math.trunc(e)),Oe-1);for(let a=i;a+1<Me;a+=1)for(let l=r;l<Oe;l+=1)if(!o.has(`${a}:${l}`)&&!o.has(`${a+1}:${l}`))return{row:a,column:l};return ri(t)}function vc(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=vc(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 Mc(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 Oc=new Uint8Array(16);function Ec(){return crypto.getRandomValues(Oc)}const _o={};function Qk(n,e,t){let o;{const i=Date.now(),r=Ec();Ac(_o,i,r),o=Nc(r,_o.msecs,_o.seq,e,t)}return e??Mc(o)}function Ac(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 Nc(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 Xk=["people","places","editing","custom"],Qi=64,Dc=new RegExp("\\p{Cc}","u");function Bc(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(Dc.test(e))throw new Error("Tag label must not contain control characters");const t=[...e].length;if(t>Qi)throw new Error(`Tag label must be at most ${Qi} characters; received ${t}`);return e}function Yk(n){return Bc(n).toLowerCase()}function ai(n,e,t,o){for(const i of n.edges){if(i.source!==e||i.targetInput!=="media")continue;const r=n.cells.find(a=>a.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(a=>a.id===i.target);if(r?.type===t)return{outputCell:r,outputEdge:i}}return null}function Vc(n,e){return ai(n,e,"video","generate-video-output")}function Pc(n,e){return ai(n,e,"image","generate-image-output")}function Kc(n,e){return ai(n,e,"audio","generate-audio-output")}function zc(n){if(typeof n.outputArtifactId=="string")return n.outputArtifactId;if(typeof n.outputEntityId=="string")return n.outputEntityId}function Fc(n,e){const t=e.type==="generate_video"?Vc(n,e.id):e.type==="generate_image"?Pc(n,e.id):e.type==="generate_audio"?Kc(n,e.id):null;if(typeof t?.outputCell.outputArtifactId=="string")return t.outputCell.outputArtifactId}function qc(n,e){return Fc(n,e)??zc(e)}function Zk(n,e){return qc(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 xa(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 a=i.text,l=r.text,c=0;for(;a[c]==l[c];c++)t++;return c&&c<a.length&&c<l.length&&Sa(a.charCodeAt(c-1))&&ba(a.charCodeAt(c))&&t--,t}if(i.content.size||r.content.size){let a=xa(i.content,r.content,t+1);if(a!=null)return a}t+=i.nodeSize}}function ya(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 a=n.child(--i),l=e.child(--r),c=a.nodeSize;if(a==l){t-=c,o-=c;continue}if(!a.sameMarkup(l))return{a:t,b:o};if(a.isText&&a.text!=l.text){let p=a.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&&Sa(p.charCodeAt(m-1))&&ba(p.charCodeAt(m))&&(t++,o++),{a:t,b:o}}if(a.content.size||l.content.size){let p=ya(a.content,l.content,t-1,o-1);if(p)return p}t-=c,o-=c}}function ba(n){return n>=56320&&n<57344}function Sa(n){return n>=55296&&n<56320}class R{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 a=0,l=0;l<t;a++){let c=this.content[a],p=l+c.nodeSize;if(p>e&&o(c,i+l,r||null,a)!==!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="",a=!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&&(a?a=!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 R(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,a=0;a<t;r++){let l=this.content[r],c=a+l.nodeSize;c>e&&((a<e||c>t)&&(l.isText?l=l.cut(Math.max(0,e-a),Math.min(l.text.length,t-a)):l=l.cut(Math.max(0,e-a-1),Math.min(l.content.size,t-a-1))),o.push(l),i+=l.nodeSize),a=c}return new R(o,i)}cutByIndex(e,t){return e==t?R.empty:e==0&&t==this.content.length?this:new R(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 R(i,r)}addToStart(e){return new R([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new R(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 xa(this,e,t)}findDiffEnd(e,t=this.size,o=e.size){return ya(this,e,t,o)}findIndex(e){if(e==0)return Tn(0,e);if(e==this.size)return Tn(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?Tn(t+1,r):Tn(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 R.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return R.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return R.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 R(t||e,o)}static from(e){if(!e)return R.empty;if(e instanceof R)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new R([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}R.empty=new R([],0);const wo={index:0,offset:0};function Tn(n,e){return wo.index=n,wo.offset=e,wo}function Bn(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(!Bn(n[o],e[o]))return!1}else{for(let o in n)if(!(o in e)||!Bn(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&&Bn(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 Xt 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=_a(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(ka(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(R.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(R.empty,0,0);function ka(n,e,t){let{index:o,offset:i}=n.findIndex(e),r=n.maybeChild(o),{index:a,offset:l}=n.findIndex(t);if(i==e||r.isText){if(l!=t&&!n.child(a).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(o!=a)throw new RangeError("Removing non-flat range");return n.replaceChild(o,r.copy(ka(r.content,e-i-1,t-i-1)))}function _a(n,e,t,o,i,r){let{index:a,offset:l}=n.findIndex(e),c=n.maybeChild(a);if(l==e||c.isText)return r&&o<=0&&i<=0&&!r.canReplace(a,a,t)?null:n.cut(0,e).append(t).append(n.cut(e));let p=_a(c.content,e-l-1,t,a==0?o-1:0,a==n.childCount-1?i-1:0,c);return p&&n.replaceChild(a,c.copy(p))}function Uc(n,e,t){if(t.openStart>n.depth)throw new Xt("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Xt("Inconsistent open depths");return wa(n,e,t,0)}function wa(n,e,t,o){let i=n.index(o),r=n.node(o);if(i==e.index(o)&&o<n.depth-t.openStart){let a=wa(n,e,t,o+1);return r.copy(r.content.replaceChild(i,a))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==o&&e.depth==o){let a=n.parent,l=a.content;return pt(a,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:a,end:l}=Gc(t,n);return pt(r,Ia(n,a,l,e,o))}else return pt(r,Vn(n,e,o))}function Ta(n,e){if(!e.type.compatibleContent(n.type))throw new Xt("Cannot join "+e.type.name+" onto "+n.type.name)}function Uo(n,e,t){let o=n.node(t);return Ta(o,e.node(t)),o}function ut(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 jt(n,e,t,o){let i=(e||n).node(t),r=0,a=e?e.index(t):i.childCount;n&&(r=n.index(t),n.depth>t?r++:n.textOffset&&(ut(n.nodeAfter,o),r++));for(let l=r;l<a;l++)ut(i.child(l),o);e&&e.depth==t&&e.textOffset&&ut(e.nodeBefore,o)}function pt(n,e){if(!n.type.validContent(e))throw new Xt("Invalid content for node "+n.type.name);return n.copy(e)}function Ia(n,e,t,o,i){let r=n.depth>i&&Uo(n,e,i+1),a=o.depth>i&&Uo(t,o,i+1),l=[];return jt(null,n,i,l),r&&a&&e.index(i)==t.index(i)?(Ta(r,a),ut(pt(r,Ia(n,e,t,o,i+1)),l)):(r&&ut(pt(r,Vn(n,e,i+1)),l),jt(e,t,i,l),a&&ut(pt(a,Vn(t,o,i+1)),l)),jt(o,null,i,l),new R(l)}function Vn(n,e,t){let o=[];if(jt(null,n,t,o),n.depth>t){let i=Uo(n,e,t+1);ut(pt(i,Vn(n,e,t+1)),o)}return jt(e,null,t,o),new R(o)}function Gc(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(R.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Yt{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 a=0;a<r.length;a++)r[a].type.spec.inclusive===!1&&(!i||!r[a].isInSet(i.marks))&&(r=r[a--].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 jc(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 a=e;;){let{index:l,offset:c}=a.content.findIndex(r),p=r-c;if(o.push(a,l,i+c),!p||(a=a.child(l),a.isText))break;r=p-1,i+=c+1}return new Yt(t,o,r)}static resolveCached(e,t){let o=Xi.get(e);if(o)for(let r=0;r<o.elts.length;r++){let a=o.elts[r];if(a.pos==t)return a}else Xi.set(e,o=new Lc);let i=o.elts[o.i]=Yt.resolve(e,t);return o.i=(o.i+1)%Wc,i}}class Lc{constructor(){this.elts=[],this.i=0}}const Wc=12,Xi=new WeakMap;class jc{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 $c=Object.create(null);class ve{constructor(e,t,o,i=q.none){this.type=e,this.attrs=t,this.marks=i,this.content=o||R.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&&Bn(this.attrs,t||e.defaultAttrs||$c)&&q.sameSet(this.marks,o||q.none)}copy(e=null){return e==this.content?this:new ve(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ve(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),a=o?0:i.sharedDepth(t),l=i.start(a),p=i.node(a).content.cut(i.pos-l,r.pos-l);return new A(p,i.depth-a,r.depth-a)}replace(e,t,o){return Uc(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 Yt.resolveCached(this,e)}resolveNoCache(e){return Yt.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()+")"),Ra(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=R.empty,i=0,r=o.childCount){let a=this.contentMatchAt(e).matchFragment(o,i,r),l=a&&a.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),a=r&&r.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=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=R.fromJSON(e,t.content),r=e.nodeType(t.type).create(t.attrs,i,o);return r.type.checkAttrs(r.attrs),r}}ve.prototype.text=void 0;class Pn extends ve{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):Ra(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 Pn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Pn(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 Ra(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class ft{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let o=new Hc(e,t);if(o.next==null)return ft.empty;let i=Ca(o);o.next&&o.err("Unexpected trailing text");let r=tu(eu(i));return nu(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(a,l){let c=a.matchFragment(e,o);if(c&&(!t||c.validEnd))return R.from(l.map(p=>p.createAndFill()));for(let p=0;p<a.next.length;p++){let{type:d,next:m}=a.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 a=[];for(let l=i;l.type;l=l.via)a.push(l.type);return a.reverse()}for(let a=0;a<r.next.length;a++){let{type:l,next:c}=r.next[a];!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 a=0;a<o.next.length;a++)r+=(a?", ":"")+o.next[a].type.name+"->"+e.indexOf(o.next[a].next);return r}).join(`
2
+ `)}}ft.empty=new ft(!0);class Hc{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 Ca(n){let e=[];do e.push(Jc(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Jc(n){let e=[];do e.push(Qc(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Qc(n){let e=Zc(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=Xc(n,e);else break;return e}function Yi(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Xc(n,e){let t=Yi(n),o=t;return n.eat(",")&&(n.next!="}"?o=Yi(n):o=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:o,expr:e}}function Yc(n,e){let t=n.nodeTypes,o=t[e];if(o)return[o];let i=[];for(let r in t){let a=t[r];a.isInGroup(e)&&i.push(a)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function Zc(n){if(n.eat("(")){let e=Ca(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=Yc(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 eu(n){let e=[[]];return i(r(n,0),t()),e;function t(){return e.push([])-1}function o(a,l,c){let p={term:c,to:l};return e[a].push(p),p}function i(a,l){a.forEach(c=>c.to=l)}function r(a,l){if(a.type=="choice")return a.exprs.reduce((c,p)=>c.concat(r(p,l)),[]);if(a.type=="seq")for(let c=0;;c++){let p=r(a.exprs[c],l);if(c==a.exprs.length-1)return p;i(p,l=t())}else if(a.type=="star"){let c=t();return o(l,c),i(r(a.expr,c),c),[o(c)]}else if(a.type=="plus"){let c=t();return i(r(a.expr,l),c),i(r(a.expr,c),c),[o(c)]}else{if(a.type=="opt")return[o(l)].concat(r(a.expr,l));if(a.type=="range"){let c=l;for(let p=0;p<a.min;p++){let d=t();i(r(a.expr,c),d),c=d}if(a.max==-1)i(r(a.expr,c),c);else for(let p=a.min;p<a.max;p++){let d=t();o(c,d),i(r(a.expr,c),d),c=d}return[o(c)]}else{if(a.type=="name")return[o(l,void 0,a.value)];throw new Error("Unknown expr type")}}}}function va(n,e){return e-n}function Zi(n,e){let t=[];return o(e),t.sort(va);function o(i){let r=n[i];if(r.length==1&&!r[0].term)return o(r[0].to);t.push(i);for(let a=0;a<r.length;a++){let{term:l,to:c}=r[a];!l&&t.indexOf(c)==-1&&o(c)}}}function tu(n){let e=Object.create(null);return t(Zi(n,0));function t(o){let i=[];o.forEach(a=>{n[a].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]);Zi(n,c).forEach(d=>{p||i.push([l,p=[]]),p.indexOf(d)==-1&&p.push(d)})})});let r=e[o.join(",")]=new ft(o.indexOf(n.length-1)>-1);for(let a=0;a<i.length;a++){let l=i[a][1].sort(va);r.next.push({type:i[a][0],next:e[l.join(",")]||t(l)})}return r}}function nu(n,e){for(let t=0,o=[n];t<o.length;t++){let i=o[t],r=!i.validEnd,a=[];for(let l=0;l<i.next.length;l++){let{type:c,next:p}=i.next[l];a.push(c.name),r&&!(c.isText||c.hasRequiredAttrs())&&(r=!1),o.indexOf(p)==-1&&o.push(p)}r&&e.err("Only non-generatable nodes ("+a.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Ma(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 Oa(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 Ea(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 Aa(n,e){let t=Object.create(null);if(e)for(let o in e)t[o]=new iu(n,o,e[o]);return t}let er=class Na{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=Aa(e,o.attrs),this.defaultAttrs=Ma(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==ft.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:Oa(this.attrs,e)}create(e=null,t,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ve(this,this.computeAttrs(e),R.from(t),q.setFrom(o))}createChecked(e=null,t,o){return t=R.from(t),this.checkContent(t),new ve(this,this.computeAttrs(e),t,q.setFrom(o))}createAndFill(e=null,t,o){if(e=this.computeAttrs(e),t=R.from(t),t.size){let a=this.contentMatch.fillBefore(t);if(!a)return null;t=a.append(t)}let i=this.contentMatch.matchFragment(t),r=i&&i.fillBefore(R.empty,!0);return r?new ve(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){Ea(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,a)=>o[r]=new Na(r,t,a));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 ou(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 iu{constructor(e,t,o){this.hasDefault=Object.prototype.hasOwnProperty.call(o,"default"),this.default=o.default,this.validate=typeof o.validate=="string"?ou(e,t,o.validate):o.validate}get isRequired(){return!this.hasDefault}}class Hn{constructor(e,t,o,i){this.name=e,this.rank=t,this.schema=o,this.spec=i,this.attrs=Aa(e,i.attrs),this.excluded=null;let r=Ma(this.attrs);this.instance=r?new q(this,r):null}create(e=null){return!e&&this.instance?this.instance:new q(this,Oa(this.attrs,e))}static compile(e,t){let o=Object.create(null),i=0;return e.forEach((r,a)=>o[r]=new Hn(r,i++,t,a)),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){Ea(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class e_{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=er.compile(this.spec.nodes,this),this.marks=Hn.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],a=r.spec.content||"",l=r.spec.marks;if(r.contentMatch=o[a]||(o[a]=ft.parse(a,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?tr(this,l.split(" ")):l==""||!r.inlineContent?[]:null}for(let i in this.marks){let r=this.marks[i],a=r.spec.excludes;r.excluded=a==null?[r]:a==""?[]:tr(this,a.split(" "))}this.nodeFromJSON=i=>ve.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 er){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 Pn(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 tr(n,e){let t=[];for(let o=0;o<e.length;o++){let i=e[o],r=n.marks[i],a=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(a=c)}if(!a)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return t}function ru(n){return n.tag!=null}function au(n){return n.style!=null}class Zt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let o=this.matchedStyles=[];t.forEach(i=>{if(ru(i))this.tags.push(i);else if(au(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 or(this,t,!1);return o.addAll(e,q.none,t.from,t.to),o.finish()}parseSlice(e,t={}){let o=new or(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(cu(e,r.tag)&&(r.namespace===void 0||e.namespaceURI==r.namespace)&&(!r.context||t.matchesContext(r.context))){if(r.getAttrs){let a=r.getAttrs(e);if(a===!1)continue;r.attrs=a||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 a=this.styles[r],l=a.style;if(!(l.indexOf(e)!=0||a.context&&!o.matchesContext(a.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(a.getAttrs){let c=a.getAttrs(t);if(c===!1)continue;a.attrs=c||void 0}return a}}}static schemaRules(e){let t=[];function o(i){let r=i.priority==null?50:i.priority,a=0;for(;a<t.length;a++){let l=t[a];if((l.priority==null?50:l.priority)<r)break}t.splice(a,0,i)}for(let i in e.marks){let r=e.marks[i].spec.parseDOM;r&&r.forEach(a=>{o(a=ir(a)),a.mark||a.ignore||a.clearMark||(a.mark=i)})}for(let i in e.nodes){let r=e.nodes[i].spec.parseDOM;r&&r.forEach(a=>{o(a=ir(a)),a.node||a.ignore||a.mark||(a.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Zt(e,Zt.schemaRules(e)))}}const Da={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},su={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ba={ol:!0,ul:!0},en=1,Go=2,$t=4;function nr(n,e,t){return e!=null?(e?en:0)|(e==="full"?Go:0):n&&n.whitespace=="pre"?en|Go:t&~$t}class In{constructor(e,t,o,i,r,a){this.type=e,this.attrs=t,this.marks=o,this.solid=i,this.options=a,this.content=[],this.activeMarks=q.none,this.match=r||(a&$t?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(R.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&en)){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=R.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(R.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&&!Da.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class or{constructor(e,t,o){this.parser=e,this.options=t,this.isOpen=o,this.open=0,this.localPreserveWS=!1;let i=t.topNode,r,a=nr(null,t.preserveWhitespace,0)|(o?$t:0);i?r=new In(i.type,i.attrs,q.none,!0,t.topMatch||i.type.contentMatch,a):o?r=new In(null,null,q.none,!0,null,a):r=new In(e.schema.topNodeType,null,q.none,!0,null,a),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&Go?"full":this.localPreserveWS||(i.options&en)>0,{schema:a}=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(a.linebreakReplacement&&/[\r\n]/.test(o)&&this.top.findWrapping(a.linebreakReplacement.create())){let l=o.split(/\r?\n|\r/);for(let c=0;c<l.length;c++)c&&this.insertNode(a.linebreakReplacement.create(),t,!0),l[c]&&this.insertNode(a.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(a.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 a=e.nodeName.toLowerCase(),l;Ba.hasOwnProperty(a)&&this.parser.normalizeLists&&lu(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,o));e:if(c?c.ignore:su.hasOwnProperty(a))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(Da.hasOwnProperty(a))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],a=o.getPropertyValue(r);if(a)for(let l=void 0;;){let c=this.parser.matchStyle(r,a,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,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),o,e.nodeName=="BR")||this.leafFallback(e,o);else{let c=this.enter(a,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(a&&a.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 a=o?e.childNodes[o]:e.firstChild,l=i==null?null:e.childNodes[i];a!=l;a=a.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(a,t);this.findAtPoint(e,r)}findPlace(e,t,o){let i,r;for(let a=this.open,l=0;a>=0;a--){let c=this.nodes[a],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 a=0;a<i.length;a++)t=this.enterInner(i[a],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 a=q.none;for(let l of i.concat(e.marks))(r.type?r.type.allowsMarkType(l.type):rr(l.type,e.type))&&(a=l.addToSet(a));return r.content.push(e.mark(a)),!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 a=this.top;a.match=a.match&&a.match.matchType(e);let l=nr(e,r,a.options);a.options&$t&&a.content.length==0&&(l|=$t);let c=q.none;return o=o.filter(p=>(a.type?a.type.allowsMarkType(p.type):rr(p.type,e))?(c=p.addToSet(c),!1):!0),this.nodes.push(new In(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|=en)}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),a=(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(a(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 a(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 lu(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let o=e.nodeType==1?e.nodeName.toLowerCase():null;o&&Ba.hasOwnProperty(o)&&t?(t.appendChild(e),e=t):o=="li"?t=e:o&&(t=null)}}function cu(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function ir(n){let e={};for(let t in n)e[t]=n[t];return e}function rr(n,e){let t=e.schema.nodes;for(let o in t){let i=t[o];if(!i.allowsMarkType(n))continue;let r=[],a=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&&a(d))return!0}};if(a(i.contentMatch))return!0}}class Et{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},o){o||(o=Rn(t).createDocumentFragment());let i=o,r=[];return e.forEach(a=>{if(r.length||a.marks.length){let l=0,c=0;for(;l<r.length&&c<a.marks.length;){let p=a.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<a.marks.length;){let p=a.marks[c++],d=this.serializeMark(p,a.isInline,t);d&&(r.push([p,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(a,t))}),o}serializeNodeInner(e,t){if(e.isText)return Rn(t).createTextNode(e.text);let{dom:o,contentDOM:i}=En(Rn(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&&En(Rn(o),i(e,t),null,e.attrs)}static renderSpec(e,t,o=null,i){return typeof t=="string"?{dom:e.createTextNode(t)}:En(e,t,o,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Et(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=ar(e.nodes);return t.text||(t.text=o=>o.text),t}static marksFromSchema(e){return ar(e.marks)}}function ar(n){let e={};for(let t in n){let o=n[t].spec.toDOM;o&&(e[t]=o)}return e}function Rn(n){return n.document||window.document}const sr=new WeakMap;function uu(n){let e=sr.get(n);return e===void 0&&sr.set(n,e=pu(n)),e}function pu(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 En(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=uu(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 a=i.indexOf(" ");a>0&&(t=i.slice(0,a),i=i.slice(a+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:b,contentDOM:S}=En(n,g,t,o);if(c.appendChild(b),S){if(l)throw new RangeError("Multiple content holes");l=S}}}return{dom:c,contentDOM:l}}const Va=65535,Pa=Math.pow(2,16);function du(n,e){return n+e*Pa}function lr(n){return n&Va}function mu(n){return(n-(n&Va))/Pa}const Ka=1,za=2,An=4,Fa=8;class Lo{constructor(e,t,o){this.pos=e,this.delInfo=t,this.recover=o}get deleted(){return(this.delInfo&Fa)>0}get deletedBefore(){return(this.delInfo&(Ka|An))>0}get deletedAfter(){return(this.delInfo&(za|An))>0}get deletedAcross(){return(this.delInfo&An)>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=lr(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+mu(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,a=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+a],m=c+p;if(e<=m){let g=p?e==c?-1:e==m?1:t:t,b=c+i+(g<0?0:d);if(o)return b;let S=e==(t<0?c:m)?null:du(l/3,e-c),_=e==c?za:e==m?Ka:An;return(t<0?e!=c:e!=m)&&(_|=Fa),new Lo(b,_,S)}i+=d-p}return o?e+i:new Lo(e+i,0,null)}touches(e,t){let o=0,i=lr(t),r=this.inverted?2:1,a=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+a]-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 a=this.ranges[i],l=a-(this.inverted?r:0),c=a+(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 tn{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 tn(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 tn;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 a=this._maps[r],l=a.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 Lo(e,i,null)}}const To=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=To[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 To)throw new RangeError("Duplicate use of step JSON ID "+e);return To[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 Xt)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 R.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,(a,l)=>!a.isAtom||!l.type.allowsMarkType(this.mark.type)?a:a.mark(this.mark.addToSet(a.marks)),i),t.openStart,t.openEnd);return W.fromReplace(e,this.from,this.to,r)}invert(){return new Ce(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 Ce 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 Ce(t.pos,o.pos,this.mark)}merge(e){return e instanceof Ce&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ce(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 Ce(t.from,t.to,e.markFromJSON(t.mark))}}re.jsonID("removeMark",Ce);class He 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(R.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 He(this.pos,t.marks[i]);return new He(this.pos,this.mark)}}return new gt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new He(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 He(t.pos,e.markFromJSON(t.mark))}}re.jsonID("addNodeMark",He);class gt 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(R.from(o),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new He(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new gt(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 gt(t.pos,e.markFromJSON(t.mark))}}re.jsonID("removeNodeMark",gt);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&&Wo(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,a,l=!1){super(),this.from=e,this.to=t,this.gapFrom=o,this.gapTo=i,this.slice=r,this.insert=a,this.structure=l}apply(e){if(this.structure&&(Wo(e,this.from,this.gapFrom)||Wo(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 Wo(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 a=o.node(r).maybeChild(o.indexAfter(r));for(;i>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,i--}}return!1}function hu(n,e,t,o){let i=[],r=[],a,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),b=Math.min(p+c.nodeSize,t),S=o.addToSet(m);for(let _=0;_<m.length;_++)m[_].isInSet(S)||(a&&a.to==g&&a.mark.eq(m[_])?a.to=b:i.push(a=new Ce(g,b,m[_])));l&&l.to==g?l.to=b:r.push(l=new $e(g,b,o))}}),i.forEach(c=>n.step(c)),r.forEach(c=>n.step(c))}function fu(n,e,t,o){let i=[],r=0;n.doc.nodesBetween(e,t,(a,l)=>{if(!a.isInline)return;r++;let c=null;if(o instanceof Hn){let p=a.marks,d;for(;d=o.isInSet(p);)(c||(c=[])).push(d),p=d.removeFromSet(p)}else o?o.isInSet(a.marks)&&(c=[o]):c=a.marks;if(c&&c.length){let p=Math.min(l+a.nodeSize,t);for(let d=0;d<c.length;d++){let m=c[d],g;for(let b=0;b<i.length;b++){let S=i[b];S.step==r-1&&m.eq(i[b].style)&&(g=S)}g?(g.to=p,g.step=r):i.push({style:m,from:Math.max(l,e),to:p,step:r})}}}),i.forEach(a=>n.step(new Ce(a.from,a.to,a.style)))}function li(n,e,t,o=t.contentMatch,i=!0){let r=n.doc.nodeAt(e),a=[],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)a.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 Ce(l,d,p.marks[g]));if(i&&p.isText&&t.whitespace!="pre"){let g,b=/\r?\n|\r/g,S;for(;g=b.exec(p.text);)S||(S=new A(R.from(t.schema.text(" ",t.allowedMarks(p.marks))),0,0)),a.push(new H(l+g.index,l+g.index+g[0].length,S))}}l=d}if(!o.validEnd){let c=o.fillBefore(R.empty,!0);n.replace(l,l,new A(c,0,0))}for(let c=a.length-1;c>=0;c--)n.step(a[c])}function gu(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function ci(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let o=n.depth,i=0,r=0;;--o){let a=n.$from.node(o),l=n.$from.index(o)+i,c=n.$to.indexAfter(o)-r;if(o<n.depth&&a.canReplace(l,c,t))return o;if(o==0||a.type.spec.isolating||!gu(a,l,c))break;l&&(i=1),c<a.childCount&&(r=1)}return null}function xu(n,e,t){let{$from:o,$to:i,depth:r}=e,a=o.before(r+1),l=i.after(r+1),c=a,p=l,d=R.empty,m=0;for(let S=r,_=!1;S>t;S--)_||o.index(S)>0?(_=!0,d=R.from(o.node(S).copy(d)),m++):c--;let g=R.empty,b=0;for(let S=r,_=!1;S>t;S--)_||i.after(S+1)<i.end(S)?(_=!0,g=R.from(i.node(S).copy(g)),b++):p++;n.step(new me(c,p,a,l,new A(d.append(g),m,b),d.size-m,!0))}function yu(n,e,t){let o=R.empty;for(let a=t.length-1;a>=0;a--){if(o.size){let l=t[a].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=R.from(t[a].type.create(t[a].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 bu(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,(a,l)=>{let c=typeof i=="function"?i(a):i;if(a.isTextblock&&!a.hasMarkup(o,c)&&Su(n.doc,n.mapping.slice(r).map(l),o)){let p=null;if(o.schema.linebreakReplacement){let b=o.whitespace=="pre",S=!!o.contentMatch.matchType(o.schema.linebreakReplacement);b&&!S?p=!1:!b&&S&&(p=!0)}p===!1&&Ua(n,a,l,r),li(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+a.nodeSize,1);return n.step(new me(m,g,m+1,g-1,new A(R.from(o.create(c,null,a.marks)),0,0),1,!0)),p===!0&&qa(n,a,l,r),!1}})}function qa(n,e,t,o){e.forEach((i,r)=>{if(i.isText){let a,l=/\r?\n|\r/g;for(;a=l.exec(i.text);){let c=n.mapping.slice(o).map(t+1+r+a.index);n.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function Ua(n,e,t,o){e.forEach((i,r)=>{if(i.type==i.type.schema.linebreakReplacement){let a=n.mapping.slice(o).map(t+1+r);n.replaceWith(a,a+1,e.type.schema.text(`
5
+ `))}})}function Su(n,e,t){let o=n.resolve(e),i=o.index();return o.parent.canReplaceWith(i,i+1,t)}function ku(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 a=t.create(o,null,i||r.marks);if(r.isLeaf)return n.replaceWith(e,e+r.nodeSize,a);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(R.from(a),0,0),1,!0))}function Nn(n,e,t=1,o){let i=n.resolve(e),r=i.depth-t,a=o&&o[o.length-1]||i.parent;if(r<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!a.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 b=m.content.cutByIndex(g,m.childCount),S=o&&o[d+1];S&&(b=b.replaceChild(0,S.type.create(S.attrs)));let _=o&&o[d]||m;if(!m.canReplace(g+1,m.childCount)||!_.type.validContent(b))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 _u(n,e,t=1,o){let i=n.doc.resolve(e),r=R.empty,a=R.empty;for(let l=i.depth,c=i.depth-t,p=t-1;l>c;l--,p--){r=R.from(i.node(l).copy(r));let d=o&&o[p];a=R.from(d?d.type.create(d.attrs,a):i.node(l).copy(a))}n.step(new H(e,e,new A(r.append(a),t,t),!0))}function Ga(n,e){let t=n.resolve(e),o=t.index();return Tu(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(o,o+1)}function wu(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),a=r.type==o?n.type.schema.nodes.text:r.type;if(t=t.matchType(a),!t||!n.type.allowsMarks(r.marks))return!1}return t.validEnd}function Tu(n,e){return!!(n&&e&&!n.isLeaf&&wu(n,e))}function Iu(n,e,t){let o=null,{linebreakReplacement:i}=n.doc.type.schema,r=n.doc.resolve(e-t),a=r.node().type;if(i&&a.inlineContent){let d=a.whitespace=="pre",m=!!a.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);Ua(n,d.node(),d.before(),l)}a.inlineContent&&li(n,e+t-1,a,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);qa(n,d.node(),d.before(),n.steps.length)}return n}function Ru(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 Cu(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 a=o.depth;a>=0;a--){let l=a==o.depth?0:o.pos<=(o.start(a+1)+o.end(a+1))/2?-1:1,c=o.index(a)+(l>0?1:0),p=o.node(a),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(a+1):o.after(a+1)}return null}function ui(n,e,t=e,o=A.empty){if(e==t&&!o.size)return null;let i=n.resolve(e),r=n.resolve(t);return La(i,r,o)?new H(e,t,o):new vu(i,r,o).fit()}function La(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class vu{constructor(e,t,o){this.$from=e,this.$to=t,this.unplaced=o,this.frontier=[],this.placed=R.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=R.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,a=o.depth,l=i.depth;for(;a&&l&&r.childCount==1;)r=r.firstChild.content,a--,l--;let c=new A(r,a,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=cr(this.unplaced.content,o-1).firstChild,i=r.content):i=this.unplaced.content;let a=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:p}=this.frontier[l],d,m=null;if(t==1&&(a?p.matchType(a.type)||(m=p.fillBefore(R.from(a),!1)):r&&c.compatibleContent(r.type)))return{sliceDepth:o,frontierDepth:l,parent:r,inject:m};if(t==2&&a&&(d=p.findWrapping(a.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 ur(e,-1)<=t?!1:(this.unplaced.size>1&&ur(e,1)>o&&o++,this.unplaced=new A(e,t+1,o),!0)}dropNode(){let{content:e,openStart:t,openEnd:o}=this.unplaced,i=cr(e,t);if(i.childCount<=1&&t>0){let r=e.size-t<=t+i.size;this.unplaced=new A(Ut(e,t-1,1),t-1,r?t-1:o)}else this.unplaced=new A(Ut(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 a=this.unplaced,l=o?o.content:a.content,c=a.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 b=l.size+e-(a.content.size-a.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(Wa(_.mark(g.allowedMarks(_.marks)),p==1?c:0,p==l.childCount?b:-1)))}let S=p==l.childCount;S||(b=-1),this.placed=Gt(this.placed,t,R.from(d)),this.frontier[t].match=m,S&&b<0&&o&&o.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let _=0,w=l;_<b;_++){let O=w.lastChild;this.frontier.push({type:O.type,match:O.contentMatchAt(O.childCount)}),w=O.content}this.unplaced=S?e==0?A.empty:new A(Ut(a.content,e-1,1),e-1,b<0?a.openEnd:e-1):new A(Ut(a.content,e,p),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Io(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)),a=Io(e,t,i,o,r);if(a){for(let l=t-1;l>=0;l--){let{match:c,type:p}=this.frontier[l],d=Io(e,l,p,c,!0);if(!d||d.childCount)continue e}return{depth:t,fit:a,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=Gt(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=Gt(this.placed,this.depth,R.from(e.create(t,o))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(R.empty,!0);t.childCount&&(this.placed=Gt(this.placed,this.frontier.length,t))}}function Ut(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Ut(n.firstChild.content,e-1,t)))}function Gt(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Gt(n.lastChild.content,e-1,t)))}function cr(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Wa(n,e,t){if(e<=0)return n;let o=n.content;return e>1&&(o=o.replaceChild(0,Wa(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(R.empty,!0)))),n.copy(o)}function Io(n,e,t,o,i){let r=n.node(e),a=i?n.indexAfter(e):n.index(e);if(a==r.childCount&&!t.compatibleContent(r.type))return null;let l=o.fillBefore(r.content,!0,a);return l&&!Mu(t,r.content,a)?l:null}function Mu(n,e,t){for(let o=t;o<e.childCount;o++)if(!n.allowsMarks(e.child(o).marks))return!0;return!1}function Ou(n){return n.spec.defining||n.spec.definingForContent}function ur(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 Eu(n,e,t,o){if(!o.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),r=n.doc.resolve(t);if(La(i,r,o))return n.step(new H(e,t,o));let a=$a(i,r);a[a.length-1]==0&&a.pop();let l=-(i.depth+1);a.unshift(l);for(let g=i.depth,b=i.pos-1;g>0;g--,b--){let S=i.node(g).type.spec;if(S.defining||S.definingAsContext||S.isolating)break;a.indexOf(g)>-1?l=g:i.before(g)==b&&a.splice(1,0,-g)}let c=a.indexOf(l),p=[],d=o.openStart;for(let g=o.content,b=0;;b++){let S=g.firstChild;if(p.push(S),b==o.openStart)break;g=S.content}for(let g=d-1;g>=0;g--){let b=p[g],S=Ou(b.type);if(S&&!b.sameMarkup(i.node(Math.abs(l)-1)))d=g;else if(S||!b.type.isTextblock)break}for(let g=o.openStart;g>=0;g--){let b=(g+d+1)%(o.openStart+1),S=p[b];if(S)for(let _=0;_<a.length;_++){let w=a[(_+c)%a.length],O=!0;w<0&&(O=!1,w=-w);let L=i.node(w-1),F=i.index(w-1);if(L.canReplaceWith(F,F,S.type,S.marks))return n.replace(i.before(w),O?r.after(w):t,new A(ja(o.content,0,o.openStart,b),b,o.openEnd))}}let m=n.steps.length;for(let g=a.length-1;g>=0&&(n.replace(e,t,o),!(n.steps.length>m));g--){let b=a[g];b<0||(e=i.before(b),t=r.after(b))}}function ja(n,e,t,o,i){if(e<t){let r=n.firstChild;n=n.replaceChild(0,r.copy(ja(r.content,e+1,t,o,r)))}if(e>o){let r=i.contentMatchAt(0),a=r.fillBefore(n).append(n);n=a.append(r.matchFragment(a).fillBefore(R.empty,!0))}return n}function Au(n,e,t,o){if(!o.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=Ru(n.doc,e,o.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new A(R.from(o),0,0))}function Nu(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 a=o.sharedDepth(t),l=!1;for(let c=o.depth;c>a;c--)o.node(c).type.spec.isolating&&(l=!0);for(let c=i.depth;c>a;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=$a(o,i);for(let a=0;a<r.length;a++){let l=r[a],c=a==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 a=1;a<=o.depth&&a<=i.depth;a++)if(e-o.start(a)==o.depth-a&&t>o.end(a)&&i.end(a)-t!=i.depth-a&&o.start(a-1)==i.start(a-1)&&o.node(a-1).canReplace(o.index(a-1),i.index(a-1)))return n.delete(o.before(a),t);n.delete(e,t)}function $a(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 Rt 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(R.from(i),0,t.isLeaf?0:1))}getMap(){return de.empty}invert(e){return new Rt(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 Rt(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 Rt(t.pos,t.attr,t.value)}}re.jsonID("attr",Rt);class nn 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 nn(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 nn(t.attr,t.value)}}re.jsonID("docAttr",nn);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 Du{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new tn}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,a,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=ui(this.doc,e,t,o);return i&&this.step(i),this}replaceWith(e,t,o){return this.replace(e,t,new A(R.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 Eu(this,e,t,o),this}replaceRangeWith(e,t,o){return Au(this,e,t,o),this}deleteRange(e,t){return Nu(this,e,t),this}lift(e,t){return xu(this,e,t),this}join(e,t=1){return Iu(this,e,t),this}wrap(e,t){return yu(this,e,t),this}setBlockType(e,t=e,o,i=null){return bu(this,e,t,o,i),this}setNodeMarkup(e,t,o=null,i){return ku(this,e,t,o,i),this}setNodeAttribute(e,t,o){return this.step(new Rt(e,t,o)),this}setDocAttribute(e,t){return this.step(new nn(e,t)),this}addNodeMark(e,t){return this.step(new He(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 gt(e,t));else{let i=o.marks,r,a=[];for(;r=t.isInSet(i);)a.push(new gt(e,r)),i=r.removeFromSet(i);for(let l=a.length-1;l>=0;l--)this.step(a[l])}return this}split(e,t=1,o){return _u(this,e,t,o),this}addMark(e,t,o){return hu(this,e,t,o),this}removeMark(e,t,o){return fu(this,e,t,o),this}clearIncompatible(e,t,o){return li(this,e,t,o),this}}const Ro=Object.create(null);class G{constructor(e,t,o){this.$anchor=e,this.$head=t,this.ranges=o||[new Bu(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,a=this.ranges;for(let l=0;l<a.length;l++){let{$from:c,$to:p}=a[l],d=e.mapping.slice(r);e.replaceRange(d.map(c.pos),d.map(p.pos),l?A.empty:t),l==0&&mr(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:a,$to:l}=i[r],c=e.mapping.slice(o),p=c.map(a.pos),d=c.map(l.pos);r?e.deleteRange(p,d):(e.replaceRangeWith(p,d,t),mr(e,o,t.isInline?-1:1))}}static findFrom(e,t,o=!1){let i=e.parent.inlineContent?new U(e):Tt(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 a=t<0?Tt(e.node(0),e.node(r),e.before(r+1),e.index(r),t,o):Tt(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,o);if(a)return a}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 Tt(e,e,0,0,1)||new he(e)}static atEnd(e){return Tt(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=Ro[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 Ro)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ro[e]=t,t.prototype.jsonID=e,t}getBookmark(){return U.between(this.$anchor,this.$head).getBookmark()}}G.prototype.visible=!0;class Bu{constructor(e,t){this.$from=e,this.$to=t}}let pr=!1;function dr(n){!pr&&!n.parent.inlineContent&&(pr=!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){dr(e),dr(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 Jn(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 Jn{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Jn(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(R.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 pi(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 pi{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:o}=e.mapResult(this.anchor);return t?new Jn(o,o):new pi(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 Vu}}G.jsonID("all",he);const Vu={map(){return this},resolve(n){return new he(n)}};function Tt(n,e,t,o,i,r=!1){if(e.inlineContent)return U.create(n,t);for(let a=o-(i>0?0:1);i>0?a<e.childCount:a>=0;a+=i){let l=e.child(a);if(l.isAtom){if(!r&&B.isSelectable(l))return B.create(n,t-(i<0?l.nodeSize:0))}else{let c=Tt(n,l,t+i,i<0?l.childCount:0,i,r);if(c)return c}t+=l.nodeSize*i}return null}function mr(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],a;r.forEach((l,c,p,d)=>{a==null&&(a=d)}),n.setSelection(G.near(n.doc.resolve(a),t))}const hr=1,Cn=2,fr=4;class Pu extends Du{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|hr)&~Cn,this.storedMarks=null,this}get selectionSet(){return(this.updated&hr)>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 a=this.doc.resolve(t);r=o==t?a.marks():a.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|=fr,this}get scrolledIntoView(){return(this.updated&fr)>0}}function gr(n,e){return!e||!n?n:n.bind(e)}class Lt{constructor(e,t,o){this.name=e,this.init=gr(t.init,o),this.apply=gr(t.apply,o)}}const Ku=[new Lt("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Lt("selection",{init(n,e){return n.selection||G.atStart(e.doc)},apply(n){return n.selection}}),new Lt("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,o){return o.selection.$cursor?n.storedMarks:null}}),new Lt("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=Ku.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 Lt(o.key,o.spec.state,o))})}}class Wt{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 a=0;a<this.config.plugins.length;a++){let l=this.config.plugins[a];if(l.spec.appendTransaction){let c=i?i[a].n:0,p=i?i[a].state:this,d=c<t.length&&l.spec.appendTransaction.call(l,c?t.slice(c):t,p,o);if(d&&o.filterTransaction(d,a)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let m=0;m<this.config.plugins.length;m++)i.push(m<a?{state:o,n:t.length}:{state:this,n:0})}t.push(d),o=o.applyInner(d),r=!0}i&&(i[a]={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 Wt(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 Pu(this)}static create(e){let t=new Co(e.doc?e.doc.type.schema:e.schema,e.plugins),o=new Wt(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 Wt(t);for(let r=0;r<o.length;r++){let a=o[r].name;i[a]=this.hasOwnProperty(a)?this[a]: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 Wt(i);return i.fields.forEach(a=>{if(a.name=="doc")r.doc=ve.fromJSON(e.schema,t.doc);else if(a.name=="selection")r.selection=G.fromJSON(r.doc,t.selection);else if(a.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==a.name&&p&&p.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){r[a.name]=p.fromJSON.call(c,e,t[l],r);return}}r[a.name]=a.init(e,r)}}),r}}function Ha(n,e,t){for(let o in n){let i=n[o];i instanceof Function?i=i.bind(e):o=="handleDOMEvents"&&(i=Ha(i,e,{})),t[o]=i}return t}class Ja{constructor(e){this.spec=e,this.props={},e.props&&Ha(e.props,this,this.props),this.key=e.key?e.key.key:Qa("plugin")}getState(e){return e[this.key]}}const vo=Object.create(null);function Qa(n){return n in vo?n+"$"+ ++vo[n]:(vo[n]=0,n+"$")}class Xa{constructor(e="key"){this.key=Qa(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},vt=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let jo=null;const Be=function(n,e,t){let o=jo||(jo=document.createRange());return o.setEnd(n,t??n.nodeValue.length),o.setStart(n,e||0),o},zu=function(){jo=null},xt=function(n,e,t,o){return t&&(xr(n,e,t,o,-1)||xr(n,e,t,o,1))},Fu=/^(img|br|input|textarea|hr)$/i;function xr(n,e,t,o,i){for(var r;;){if(n==t&&e==o)return!0;if(e==(i<0?0:xe(n))){let a=n.parentNode;if(!a||a.nodeType!=1||cn(n)||Fu.test(n.nodeName)||n.contentEditable=="false")return!1;e=Z(n)+(i<0?0:1),n=a}else if(n.nodeType==1){let a=n.childNodes[e+(i<0?-1:0)];if(a.nodeType==1&&a.contentEditable=="false")if(!((r=a.pmViewDesc)===null||r===void 0)&&r.ignoreForSelection)e+=i;else return!1;else n=a,e=i<0?xe(n):0}else return!1}}function xe(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function qu(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&&!cn(n))e=Z(n),n=n.parentNode;else return null}}function Uu(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&&!cn(n))e=Z(n)+1,n=n.parentNode;else return null}}function Gu(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 cn(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 Qn=function(n){return n.focusNode&&xt(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 Lu(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Wu(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,yr=typeof document<"u"?document:null,et=Ee&&Ee.userAgent||"",$o=/Edge\/(\d+)/.exec(et),Ya=/MSIE \d/.exec(et),Ho=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(et),ue=!!(Ya||Ho||$o),Je=Ya?document.documentMode:Ho?+Ho[1]:$o?+$o[1]:0,ye=!ue&&/gecko\/(\d+)/i.test(et);ye&&+(/Firefox\/(\d+)/.exec(et)||[0,0])[1];const Jo=!ue&&/Chrome\/(\d+)/.exec(et),te=!!Jo,Za=Jo?+Jo[1]:0,ie=!ue&&!!Ee&&/Apple Computer/.test(Ee.vendor),Mt=ie&&(/Mobile\/\w+/.test(et)||!!Ee&&Ee.maxTouchPoints>2),ge=Mt||(Ee?/Mac/.test(Ee.platform):!1),es=Ee?/Win/.test(Ee.platform):!1,Pe=/Android \d/.test(et),un=!!yr&&"webkitFontSmoothing"in yr.documentElement.style,ju=un?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function $u(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 Hu(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 br(n,e,t){if(!Qo(e)&&e.left==0)return;let o=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,r=n.dom.ownerDocument;for(let a=t||n.dom;a;){if(a.nodeType!=1){a=vt(a);continue}let l=a,c=l==r.body,p=c?$u(r):Hu(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 b=l.scrollLeft,S=l.scrollTop;m&&(l.scrollTop+=m),d&&(l.scrollLeft+=d);let _=l.scrollLeft-b,w=l.scrollTop-S;e={left:e.left-_,top:e.top-w,right:e.right-_,bottom:e.bottom-w}}let g=c?"fixed":getComputedStyle(a).position;if(/^(fixed|sticky)$/.test(g))break;a=g=="absolute"?a.offsetParent:vt(a)}}function Ju(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),o,i;for(let r=(e.left+e.right)/2,a=t+1;a<Math.min(innerHeight,e.bottom);a+=5){let l=n.root.elementFromPoint(r,a);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:ts(n.dom)}}function ts(n){let e=[],t=n.ownerDocument;for(let o=n;o&&(e.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),n!=t);o=vt(o));return e}function Qu({refDOM:n,refTop:e,stack:t}){let o=n?n.getBoundingClientRect().top:0;ns(t,o==0?0:o-e)}function ns(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 _t=null;function Xu(n){if(n.setActive)return n.setActive();if(_t)return n.focus(_t);let e=ts(n);n.focus(_t==null?{get preventScroll(){return _t={preventScroll:!0},!0}}:void 0),_t||(_t=!1,ns(e,0))}function is(n,e){let t,o=2e8,i,r=0,a=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 b=0;b<g.length;b++){let S=g[b];if(S.top<=a&&S.bottom>=l){a=Math.max(S.bottom,a),l=Math.min(S.top,l);let _=S.left>e.left?S.left-e.left:S.right<e.left?e.left-S.right:0;if(_<o){t=d,o=_,i=_&&t.nodeType==3?{left:S.right<e.left?S.right:S.left,top:e.top}:e,d.nodeType==1&&_&&(r=m+(e.left>=(S.left+S.right)/2?1:0));continue}}else S.top>e.top&&!c&&S.left<=e.left&&S.right>=e.left&&(c=d,p={left:Math.max(S.left,Math.min(S.right,e.left)),top:S.top});!t&&(e.left>=S.right&&e.top>=S.top||e.left>=S.left&&e.top>=S.bottom)&&(r=m+1)}}return!t&&c&&(t=c,i=p,o=0),t&&t.nodeType==3?Yu(t,i):!t||o&&t.nodeType==1?{node:n,offset:r}:is(t,i)}function Yu(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 a=Ge(o,1);if(a.top!=a.bottom&&di(e,a)){i={node:n,offset:r+(e.left>=(a.left+a.right)/2?1:0)};break}}return o.detach(),i||{node:n,offset:0}}function di(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Zu(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function ep(n,e,t){let{node:o,offset:i}=is(e,t),r=-1;if(o.nodeType==1&&!o.firstChild){let a=o.getBoundingClientRect();r=a.left!=a.right&&t.left>(a.left+a.right)/2?1:-1}return n.docView.posFromDOM(o,i,r)}function tp(n,e,t,o){let i=-1;for(let r=e,a=!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)&&(!a&&c.left>o.left||c.top>o.top?i=l.posBefore:(!a&&c.right<o.left||c.bottom<o.top)&&(i=l.posAfter),a=!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 rs(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 a=n.childNodes[r];if(a.nodeType==1){let l=a.getClientRects();for(let c=0;c<l.length;c++){let p=l[c];if(di(e,p))return rs(a,e,p)}}if((r=(r+1)%o)==i)break}return n}function np(n,e){let t=n.dom.ownerDocument,o,i=0,r=Wu(t,e.left,e.top);r&&({node:o,offset:i}=r);let a=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!a||!n.dom.contains(a.nodeType!=1?a.parentNode:a)){let p=n.dom.getBoundingClientRect();if(!di(e,p)||(a=rs(n.dom,e,p),!a))return null}if(ie)for(let p=a;o&&p;p=vt(p))p.draggable&&(o=void 0);if(a=Zu(a,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;un&&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=tp(n,o,i,e))}l==null&&(l=ep(n,a,e));let c=n.docView.nearestDesc(a,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function Qo(n){return n.top<n.bottom||n.left<n.right}function Ge(n,e){let t=n.getClientRects();if(t.length){let o=t[e<0?0:t.length-1];if(Qo(o))return o}return Array.prototype.find.call(t,Qo)||n.getBoundingClientRect()}const op=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function as(n,e,t){let{node:o,offset:i,atom:r}=n.docView.domFromPos(e,t<0?-1:1),a=un||ye;if(o.nodeType==3)if(a&&(op.test(o.nodeValue)||(t<0?!i:i==o.nodeValue.length))){let c=Ge(Be(o,i,i),t);if(ye&&i&&/\s/.test(o.nodeValue[i-1])&&i<o.nodeValue.length){let p=Ge(Be(o,i-1,i-1),-1);if(p.top==c.top){let d=Ge(Be(o,i,i+1),-1);if(d.top!=c.top)return Kt(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++,Kt(Ge(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 Mo(c.getBoundingClientRect(),!1)}if(r==null&&i<xe(o)){let c=o.childNodes[i];if(c.nodeType==1)return Mo(c.getBoundingClientRect(),!0)}return Mo(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)-(a?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(p)return Kt(Ge(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,a?0:1):c.nodeType==1?c:null:null;if(p)return Kt(Ge(p,-1),!0)}return Kt(Ge(o.nodeType==3?Be(o):o,-t),t>=0)}function Kt(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 Mo(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 ss(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 ip(n,e,t){let o=e.selection,i=t=="up"?o.$from:o.$to;return ss(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 a=as(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"?a.top-d.top>(d.bottom-a.top)*2:d.bottom-a.bottom>(a.bottom-d.top)*2))return!1}}return!0})}const rp=/[\u0590-\u08ac]/;function ap(n,e,t){let{$head:o}=e.selection;if(!o.parent.isTextblock)return!1;let i=o.parentOffset,r=!i,a=i==o.parent.content.size,l=n.domSelection();return l?!rp.test(o.parent.textContent)||!l.modify?t=="left"||t=="backward"?r:a:ss(n,e,()=>{let{focusNode:c,focusOffset:p,anchorNode:d,anchorOffset:m}=n.domSelectionRange(),g=l.caretBidiLevel;l.modify("move",t,"character");let b=o.depth?n.docView.domAfterPos(o.before()):n.dom,{focusNode:S,focusOffset:_}=n.domSelectionRange(),w=S&&!b.contains(S.nodeType==1?S:S.parentNode)||c==S&&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 Sr=null,kr=null,_r=!1;function sp(n,e,t){return Sr==e&&kr==t?_r:(Sr=e,kr=t,_r=t=="up"||t=="down"?ip(n,e,t):ap(n,e,t))}const be=0,wr=1,lt=2,we=3;class pn{constructor(e,t,o,i){this.parent=e,this.children=t,this.dom=o,this.contentDOM=i,this.dirty=be,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,a;if(e==this.contentDOM)r=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.previousSibling}for(;r&&!((a=r.pmViewDesc)&&a.parent==this);)r=r.previousSibling;return r?this.posBeforeChild(a)+a.size:this.posAtStart}else{let r,a;if(e==this.contentDOM)r=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.nextSibling}for(;r&&!((a=r.pmViewDesc)&&a.parent==this);)r=r.nextSibling;return r?this.posBeforeChild(a):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),a;if(r&&(!t||r.node))if(o&&(a=r.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==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 a=0;a<i.children.length;a++){let l=i.children[a];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 a=this.children[o],l=r+a.size;if(l>e||a instanceof cs){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 ls&&r.side>=0;o--);if(t<=0){let r,a=!0;for(;r=o?this.children[o-1]:null,!(!r||r.dom.parentNode==this.contentDOM);o--,a=!1);return r&&t&&a&&!r.border&&!r.domAtom?r.domFromPos(r.size,t):{node:this.contentDOM,offset:r?Z(r.dom)+1:0}}else{let r,a=!0;for(;r=o<this.children.length?this.children[o]:null,!(!r||r.dom.parentNode==this.contentDOM);o++,a=!1);return r&&a&&!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 a=o,l=0;;l++){let c=this.children[l],p=a+c.size;if(i==-1&&e<=p){let d=a+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=a;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}a=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),a=Math.max(e,t);for(let b=0,S=0;b<this.children.length;b++){let _=this.children[b],w=S+_.size;if(r>S&&a<w)return _.setSelection(e-S-_.border,t-S-_.border,o,i);S=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:b,offset:S}=l;if(b.nodeType==3){if(m=!!(S&&b.nodeValue[S-1]==`
6
+ `),m&&S==b.nodeValue.length)for(let _=b,w;_;_=_.parentNode){if(w=_.nextSibling){w.nodeName=="BR"&&(l=c={node:w.parentNode,offset:Z(w)+1});break}let O=_.pmViewDesc;if(O&&O.node&&O.node.isBlock)break}}else{let _=b.childNodes[S-1];m=_&&(_.nodeName=="BR"||_.contentEditable=="false")}}if(ye&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let b=d.focusNode.childNodes[d.focusOffset];b&&b.contentEditable=="false"&&(i=!0)}if(!(i||m&&ie)&&xt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&xt(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 S=l;l=c,c=S}let b=document.createRange();b.setEnd(c.node,c.offset),b.setStart(l.node,l.offset),p.removeAllRanges(),p.addRange(b)}}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],a=o+r.size;if(o==a?e<=a&&t>=o:e<a&&t>o){let l=o+r.border,c=a-r.border;if(e>=l&&t<=c){this.dirty=e==o||t==a?lt:wr,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?lt:we}o=a}this.dirty=lt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let o=e==1?lt:wr;t.dirty<o&&(t.dirty=o)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class ls extends pn{constructor(e,t,o,i){let r,a=t.type.toDOM;if(typeof a=="function"&&(a=a(o,()=>{if(!r)return i;if(r.parent)return r.parent.posBeforeChild(r)})),!t.type.spec.raw){if(a.nodeType!=1){let l=document.createElement("span");l.appendChild(a),a=l}a.hasAttribute("contenteditable")||(a.contentEditable="false"),a.classList.add("ProseMirror-widget")}super(e,[],a,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return this.dirty==be&&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 lp extends pn{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 Qe extends pn{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],a=r&&r(t,i,o);return(!a||!a.dom)&&(a=Et.renderSpec(document,t.type.spec.toDOM(t,o),null,t.attrs)),new Qe(e,t,a.dom,a.contentDOM||a.dom,a)}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!=be){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=be}}slice(e,t,o){let i=Qe.create(this.parent,this.mark,!0,o),r=this.children,a=this.size;t<a&&(r=Yo(r,t,a,o)),e>0&&(r=Yo(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 Xe extends pn{constructor(e,t,o,i,r,a,l){super(e,[],r,a),this.node=t,this.outerDeco=o,this.innerDeco=i,this.nodeDOM=l}static create(e,t,o,i,r,a){let l=r.nodeViews[t.type.name],c,p=l&&l(t,r,()=>{if(!c)return a;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}=Et.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=ds(d,o,t),p?c=new cp(e,t,o,i,d,m||null,g,p):t.isText?new Xn(e,t,o,i,d,g):new Xe(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=()=>R.empty}}return t}matchesNode(e,t,o){return this.dirty==be&&e.eq(this.node)&&Kn(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,a=r&&r.pos>-1?r:null,l=r&&r.pos<0,c=new pp(this,a&&a.node,e);hp(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 b;c.findNodeMatch(p,d,m,g)||l&&e.state.selection.from>i&&e.state.selection.to<i+p.nodeSize&&(b=c.findIndexWithChild(r.node))>-1&&c.updateNodeAt(p,d,m,b,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==lt)&&(a&&this.protectLocalComposition(e,a),us(this.contentDOM,this.children,e),Mt&&fp(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 a=r.nodeValue,l=gp(this.node.content,a,o-t,i-t);return l<0?null:{node:r,pos:l,text:a}}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 a=new lp(this,r,t,i);e.input.compositionNodes.push(a),this.children=Yo(this.children,o,o+i.length,e,a)}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=be}updateOuterDeco(e){if(Kn(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,o=this.dom;this.dom=ps(this.dom,this.nodeDOM,Xo(this.outerDeco,this.node,t),Xo(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 Tr(n,e,t,o,i){ds(o,e,n);let r=new Xe(void 0,n,e,t,o,o,o);return r.contentDOM&&r.updateChildren(i,0),r}class Xn extends Xe{constructor(e,t,o,i,r,a){super(e,t,o,i,r,null,a)}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!=be&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=be||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=be,!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 Xn(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 cs extends pn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==be&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class cp extends Xe{constructor(e,t,o,i,r,a,l,c){super(e,t,o,i,r,a,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 us(n,e,t){let o=n.firstChild,i=!1;for(let r=0;r<e.length;r++){let a=e[r],l=a.dom;if(l.parentNode==n){for(;l!=o;)o=Ir(o),i=!0;o=o.nextSibling}else i=!0,n.insertBefore(l,o);if(a instanceof Qe){let c=o?o.previousSibling:n.lastChild;us(a.contentDOM,a.children,t),o=c?c.nextSibling:n.firstChild}}for(;o;)o=Ir(o),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const Ht=function(n){n&&(this.nodeName=n)};Ht.prototype=Object.create(null);const ct=[new Ht];function Xo(n,e,t){if(n.length==0)return ct;let o=t?ct[0]:new Ht,i=[o];for(let r=0;r<n.length;r++){let a=n[r].type.attrs;if(a){a.nodeName&&i.push(o=new Ht(a.nodeName));for(let l in a){let c=a[l];c!=null&&(t&&i.length==1&&i.push(o=new Ht(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 ps(n,e,t,o){if(t==ct&&o==ct)return e;let i=e;for(let r=0;r<o.length;r++){let a=o[r],l=t[r];if(r){let c;l&&l.nodeName==a.nodeName&&i!=n&&(c=i.parentNode)&&c.nodeName.toLowerCase()==a.nodeName||(c=document.createElement(a.nodeName),c.pmIsDeco=!0,c.appendChild(i),l=ct[0]),i=c}up(i,l||ct[0],a)}return i}function up(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 ds(n,e,t){return ps(n,n,ct,Xo(e,t,n.nodeType!=1))}function Kn(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 Ir(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class pp{constructor(e,t,o){this.lock=t,this.view=o,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=dp(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,a=this.stack.length>>1,l=Math.min(a,e.length);for(;r<l&&(r==a-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&e[r].type.spec.spanning!==!1;)r++;for(;r<a;)this.destroyRest(),this.top.dirty=be,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<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[a])&&!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 Qe&&d.dirty!=we&&d.mark.type==e[a].type&&d.spec.update&&!this.isLocked(d.dom)&&d.spec.update(e[a])&&(d.mark=e[a],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=Qe.create(this.top,e[a],t,o);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,o,i){let r=-1,a;if(i>=this.preMatch.index&&(a=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,o))r=this.top.children.indexOf(a,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 a=this.top.children[i];return a.dirty==we&&a.dom==a.contentDOM&&(a.dirty=lt),a.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,a){for(let l=this.index;l<this.top.children.length;l++){let c=this.top.children[l];if(c instanceof Xe){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&&Kn(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,a)))return this.destroyBetween(this.index,l),this.top.children[this.index]=m,m.contentDOM&&(m.dirty=lt,m.updateChildren(i,a+1),m.dirty=be),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,o,i,r,a){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Kn(o,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Xe.create(this.top,t,o,i,r,a);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 a=Xe.create(this.top,e,t,o,i,r);a.contentDOM&&a.updateChildren(i,r+1),this.top.children.splice(this.index++,0,a),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 ls(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 Qe;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Xn)||/\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 cs(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 dp(n,e){let t=e,o=t.children.length,i=n.childCount,r=new Map,a=[];e:for(;i>0;){let l;for(;;)if(o){let p=t.children[o-1];if(p instanceof Qe)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),a.push(l)}}return{index:i,matched:r,matches:a.reverse()}}function mp(n,e){return n.type.side-e.type.side}function hp(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 a=0,l=[],c=null;for(let p=0;;){let d,m;for(;a<i.length&&i[a].to==r;){let w=i[a++];w.widget&&(d?(m||(m=[d])).push(w):d=w)}if(d)if(m){m.sort(mp);for(let w=0;w<m.length;w++)t(m[w],p,!!c)}else t(d,p,!!c);let g,b;if(c)b=-1,g=c,c=null;else if(p<n.childCount)b=p,g=n.child(p++);else break;for(let w=0;w<l.length;w++)l[w].to<=r&&l.splice(w--,1);for(;a<i.length&&i[a].from<=r&&i[a].to>r;)l.push(i[a++]);let S=r+g.nodeSize;if(g.isText){let w=S;a<i.length&&i[a].from<w&&(w=i[a].from);for(let O=0;O<l.length;O++)l[O].to<w&&(w=l[O].to);w<S&&(c=g.cut(w-r),g=g.cut(0,w-r),S=w,b=-1)}else for(;a<i.length&&i[a].to<S;)a++;let _=g.isInline&&!g.isLeaf?l.filter(w=>!w.inline):l.slice();o(g,_,e.forChild(r,g),b),r=S}}function fp(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 gp(n,e,t,o){for(let i=0,r=0;i<n.childCount&&r<=o;){let a=n.child(i++),l=r;if(r+=a.nodeSize,!a.isText)continue;let c=a.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 Yo(n,e,t,o,i){let r=[];for(let a=0,l=0;a<n.length;a++){let c=n[a],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 mi(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,a=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(a<0)return null;let l=o.resolve(a),c,p;if(Qn(t)){for(c=a;i&&!i.node;)i=i.parent;let m=i.node;if(i&&m.isAtom&&B.isSelectable(m)&&i.parent&&!(m.isInline&&Gu(t.focusNode,t.focusOffset,i.dom))){let g=i.posBefore;p=new B(a==g?l:o.resolve(g))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let m=a,g=a;for(let b=0;b<t.rangeCount;b++){let S=t.getRangeAt(b);m=Math.min(m,n.docView.posFromDOM(S.startContainer,S.startOffset,1)),g=Math.max(g,n.docView.posFromDOM(S.endContainer,S.endOffset,-1))}if(m<0)return null;[c,a]=g==n.state.selection.anchor?[g,m]:[m,g],l=o.resolve(a)}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=hi(n,d,l,m)}return p}function ms(n){return n.editable?n.hasFocus():fs(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function ze(n,e=!1){let t=n.state.selection;if(hs(n,t),!ms(n))return;let o=n.input.mouseDown;if(!e&&te&&o){let i=n.domSelectionRange(),r=n.domObserver.currentSelection;if(i.anchorNode&&r.anchorNode&&xt(i.anchorNode,i.anchorOffset,r.anchorNode,r.anchorOffset)&&o.delaySelUpdate()){n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)yp(n);else{let{anchor:i,head:r}=t,a,l;Rr&&!(t instanceof U)&&(t.$from.parent.inlineContent||(a=Cr(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(l=Cr(n,t.to))),n.docView.setSelection(i,r,n,e),Rr&&(a&&vr(a),l&&vr(l)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&xp(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}const Rr=ie||te&&Za<63;function Cr(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 Oo(i);if((!i||i.contentEditable=="false")&&(!r||r.contentEditable=="false")){if(i)return Oo(i);if(r)return Oo(r)}}function Oo(n){return n.contentEditable="true",ie&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function vr(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function xp(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(()=>{(!ms(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function yp(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&&Je<=11&&(t.disabled=!0,t.disabled=!1)}function hs(n,e){if(e instanceof B){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Mr(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Mr(n)}function Mr(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function hi(n,e,t,o){return n.someProp("createSelectionBetween",i=>i(n,e,t))||U.between(e,t,o)}function Or(n){return n.editable&&!n.hasFocus()?!1:fs(n)}function fs(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 bp(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return xt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Zo(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 Le(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Er(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 a=n.state.doc.resolve(i.pos+r.nodeSize*(e<0?-1:1));return Le(n,new U(o.$anchor,a))}else if(o.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Zo(n.state,e);return i&&i instanceof B?Le(n,i):!1}else if(!(ge&&t.indexOf("m")>-1)){let i=o.$head,r=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,a;if(!r||r.isText)return!1;let l=e<0?i.pos-r.nodeSize:i.pos;return r.isAtom||(a=n.docView.descAt(l))&&!a.contentDOM?B.isSelectable(r)?Le(n,new B(e<0?n.state.doc.resolve(i.pos-r.nodeSize):i)):un?Le(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 Le(n,new U(e>0?o.$to:o.$from));{let i=Zo(n.state,e);return i?Le(n,i):!1}}}function zn(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Jt(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function wt(n,e){return e<0?Sp(n):kp(n)}function Sp(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let i,r,a=!1;for(ye&&t.nodeType==1&&o<zn(t)&&Jt(t.childNodes[o],-1)&&(a=!0);;)if(o>0){if(t.nodeType!=1)break;{let l=t.childNodes[o-1];if(Jt(l,-1))i=t,r=--o;else if(l.nodeType==3)t=l,o=t.nodeValue.length;else break}}else{if(gs(t))break;{let l=t.previousSibling;for(;l&&Jt(l,-1);)i=t.parentNode,r=Z(l),l=l.previousSibling;if(l)t=l,o=zn(t);else{if(t=t.parentNode,t==n.dom)break;o=0}}}a?ei(n,t,o):i&&ei(n,i,r)}function kp(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let i=zn(t),r,a;for(;;)if(o<i){if(t.nodeType!=1)break;let l=t.childNodes[o];if(Jt(l,1))r=t,a=++o;else break}else{if(gs(t))break;{let l=t.nextSibling;for(;l&&Jt(l,1);)r=l.parentNode,a=Z(l)+1,l=l.nextSibling;if(l)t=l,o=0,i=zn(t);else{if(t=t.parentNode,t==n.dom)break;o=i=0}}}r&&ei(n,r,a)}function gs(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function _p(n,e){for(;n&&e==n.childNodes.length&&!cn(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 wp(n,e){for(;n&&!e&&!cn(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 ei(n,e,t){if(e.nodeType!=3){let r,a;(a=_p(e,t))?(e=a,t=0):(r=wp(e,t))&&(e=r,t=r.nodeValue.length)}let o=n.domSelection();if(!o)return;if(Qn(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 Ar(n,e){let t=n.state.doc.resolve(e);if(!(te||es)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let r=n.coordsAtPos(e-1),a=(r.top+r.bottom)/2;if(a>i.top&&a<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),a=(r.top+r.bottom)/2;if(a>i.top&&a<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 Nr(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 a=Zo(n.state,e);if(a&&a instanceof B)return Le(n,a)}if(!i.parent.inlineContent){let a=e<0?i:r,l=o instanceof he?G.near(a,e):G.findFrom(a,e);return l?Le(n,l):!1}return!1}function Dr(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 a=n.state.tr;return e<0?a.delete(t.pos-r.nodeSize,t.pos):a.delete(t.pos,t.pos+r.nodeSize),n.dispatch(a),!0}return!1}function Br(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Tp(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;Br(n,o,"true"),setTimeout(()=>Br(n,o,"false"),20)}return!1}function Ip(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Rp(n,e){let t=e.keyCode,o=Ip(e);if(t==8||ge&&t==72&&o=="c")return Dr(n,-1)||wt(n,-1);if(t==46&&!e.shiftKey||ge&&t==68&&o=="c")return Dr(n,1)||wt(n,1);if(t==13||t==27)return!0;if(t==37||ge&&t==66&&o=="c"){let i=t==37?Ar(n,n.state.selection.from)=="ltr"?-1:1:-1;return Er(n,i,o)||wt(n,i)}else if(t==39||ge&&t==70&&o=="c"){let i=t==39?Ar(n,n.state.selection.from)=="ltr"?1:-1:1;return Er(n,i,o)||wt(n,i)}else{if(t==38||ge&&t==80&&o=="c")return Nr(n,-1,o)||wt(n,-1);if(t==40||ge&&t==78&&o=="c")return Tp(n)||Nr(n,1,o)||wt(n,1);if(o==(ge?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function fi(n,e){n.someProp("transformCopied",b=>{e=b(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 b=o.firstChild;t.push(b.type.name,b.attrs!=b.type.defaultAttrs?b.attrs:null),o=b.content}let a=n.someProp("clipboardSerializer")||Et.fromSchema(n.state.schema),l=_s(),c=l.createElement("div");c.appendChild(a.serializeFragment(o,{document:l}));let p=c.firstChild,d,m=0;for(;p&&p.nodeType==1&&(d=ks[p.nodeName.toLowerCase()]);){for(let b=d.length-1;b>=0;b--){let S=l.createElement(d[b]);for(;c.firstChild;)S.appendChild(c.firstChild);c.appendChild(S),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",b=>b(e,n))||e.content.textBetween(0,e.content.size,`
7
7
 
8
- `);return{dom:c,text:g,slice:e}}function gs(n,e,t,o,i){let r=i.parent.type.spec.code,a,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(R.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:b}=n.state,S=Et.fromSchema(b);a=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(_=>{let w=a.appendChild(document.createElement("p"));_&&w.appendChild(S.serializeNode(b.text(_,g)))})}}else n.someProp("transformPastedHTML",m=>{t=m(t,n)}),a=Ep(t),un&&Ap(a);let p=a&&a.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=a.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;a=g}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Zt.fromSchema(n.state.schema)).parseSlice(a,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!vp.test(g.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Np(Br(l,+d[1],+d[2]),d[4]);else if(l=A.maxOpen(Mp(l.content,i),!0),l.openStart||l.openEnd){let m=0,g=0;for(let b=l.content.firstChild;m<l.openStart&&!b.type.spec.isolating;m++,b=b.firstChild);for(let b=l.content.lastChild;g<l.openEnd&&!b.type.spec.isolating;g++,b=b.lastChild);l=Br(l,m,g)}return n.someProp("transformPasted",m=>{l=m(l,n,c)}),l}const vp=/^(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 Mp(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,a=[];if(n.forEach(l=>{if(!a)return;let c=i.findWrapping(l.type),p;if(!c)return a=null;if(p=a.length&&r.length&&ys(c,r,l,a[a.length-1],0))a[a.length-1]=p;else{a.length&&(a[a.length-1]=bs(a[a.length-1],r.length));let d=xs(l,c);a.push(d),i=i.matchType(d.type),r=c}}),a)return R.from(a)}return n}function xs(n,e,t=0){for(let o=e.length-1;o>=t;o--)n=e[o].create(null,R.from(n));return n}function ys(n,e,t,o,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let r=ys(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(R.from(xs(t,n,i+1))))}}function bs(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,bs(n.lastChild,e-1)),o=n.contentMatchAt(n.childCount).fillBefore(R.empty,!0);return n.copy(t.append(o))}function ti(n,e,t,o,i,r){let a=e<0?n.firstChild:n.lastChild,l=a.content;return n.childCount>1&&(r=0),i<o-1&&(l=ti(l,e,t,o,i+1,r)),i>=t&&(l=e<0?a.contentMatchAt(0).fillBefore(l,r<=i).append(l):l.append(a.contentMatchAt(a.childCount).fillBefore(R.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,a.copy(l))}function Br(n,e,t){return e<n.openStart&&(n=new A(ti(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new A(ti(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Ss={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 ks(){return document.implementation.createHTMLDocument("title")}let zt=null;function Op(n){let e=window.trustedTypes;if(!e)return n;if(!zt){if(zt=e.defaultPolicy)try{return zt.createHTML(n)}catch{}zt=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return zt.createHTML(n)}function Ep(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=ks(),o=t.body,i=/<([a-z][^>\s]+)/i.exec(n),r;if((r=i&&Ss[i[1].toLowerCase()])&&(n=r.map(a=>"<"+a+">").join("")+n+r.map(a=>"</"+a+">").reverse().join("")),o.innerHTML=Op(n),r)for(let a=0;a<r.length;a++)o=o.querySelector(r[a])||o;for(let a=0;a<t.styleSheets.length;a++){let l=t.styleSheets[a];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 Ap(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 Np(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:a}=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=R.from(c.create(o[l+1],i)),r++,a++}return new A(i,r,a)}const le={},ce={},Dp={touchstart:!0,touchmove:!0};class Bp{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 Vp(n){for(let e in le){let t=le[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=o=>{Kp(n,o)&&!gi(n,o)&&(n.editable||!(o.type in ce))&&t(n,o)},Dp[e]?{passive:!0}:void 0)}ie&&n.dom.addEventListener("input",()=>null),ni(n)}function Ke(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Pp(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 ni(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=o=>gi(n,o))})}function gi(n,e){return n.someProp("handleDOMEvents",t=>{let o=t[e.type];return o?o(n,e)||e.defaultPrevented:!1})}function Kp(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 zp(n,e){!gi(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,!Is(n)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Pe&&te&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Mt&&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))||Cp(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(Is(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",a=>a(n,o.$from.pos,o.$to.pos,i,r))&&n.dispatch(r()),t.preventDefault()}};function dn(n){return{left:n.clientX,top:n.clientY}}function Fp(n,e){let t=e.x-n.clientX,o=e.y-n.clientY;return t*t+o*o<100}function xi(n,e,t,o,i){if(o==-1)return!1;let r=n.state.doc.resolve(o);for(let a=r.depth+1;a>0;a--)if(n.someProp(e,l=>a>r.depth?l(n,t,r.nodeAfter,r.before(a),i,!0):l(n,t,r.node(a),r.before(a),i,!1)))return!0;return!1}function mn(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 qp(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),o=t.nodeAfter;return o&&o.isAtom&&B.isSelectable(o)?(mn(n,new B(t)),!0):!1}function Up(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 a=r.depth+1;a>0;a--){let l=a>r.depth?r.nodeAfter:r.node(a);if(B.isSelectable(l)){o&&t.$from.depth>0&&a>=t.$from.depth&&r.before(t.$from.depth+1)==t.$from.pos?i=r.before(t.$from.depth):i=r.before(a);break}}return i!=null?(mn(n,B.create(n.state.doc,i)),!0):!1}function Gp(n,e,t,o,i){return xi(n,"handleClickOn",e,t,o)||n.someProp("handleClick",r=>r(n,e,o))||(i?Up(n,t):qp(n,t))}function Lp(n,e,t,o){return xi(n,"handleDoubleClickOn",e,t,o)||n.someProp("handleDoubleClick",i=>i(n,e,o))}function Wp(n,e,t,o){return xi(n,"handleTripleClickOn",e,t,o)||n.someProp("handleTripleClick",i=>i(n,e,o))||jp(n,t,o)}function jp(n,e,t){if(t.button!=0)return!1;let o=_s(n,e,!0),i=n.state.doc;return o?(mn(n,o),o instanceof U&&i.eq(n.state.doc)&&(n.input.mouseDown=new Hp(n,o)),!0):!1}function _s(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 a=r>i.depth?i.nodeAfter:i.node(r),l=i.before(r);if(a.inlineContent)return U.create(o,l+1,l+1+a.content.size);if(t&&B.isSelectable(a))return B.create(o,l)}return null}function yi(n){return Fn(n)}const ws=ge?"metaKey":"ctrlKey";le.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let o=yi(n),i=Date.now(),r="singleClick";i-n.input.lastClick.time<500&&Fp(t,n.input.lastClick)&&!t[ws]&&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 a=n.posAtCoords(dn(t));a&&(r=="singleClick"?n.input.mouseDown=new $p(n,a,t,!!o):(r=="doubleClick"?Lp:Wp)(n,a.pos,a.inside,t)?t.preventDefault():Ke(n,"pointer"))};class Ts{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 $p extends Ts{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[ws],this.allowDefault=o.shiftKey;let r,a;if(t.inside>-1)r=e.state.doc.nodeAt(t.inside),a=t.inside;else{let d=e.state.doc.resolve(t.pos);r=d.parent,a=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<=a&&p.to>a)&&(this.mightDrag={node:r,pos:a,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(dn(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ke(this.view,"pointer"):Gp(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)?(mn(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 Hp extends Ts{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(dn(e)),o=t&&_s(this.view,t.inside,!1);if(!o)return;let{doc:i}=this.view.state,r=this.startSelection,[a,l]=o.from<r.from?[r.to,o.from]:[r.from,o.to];mn(this.view,U.create(i,a,l))}}le.touchstart=n=>{n.input.lastTouch=Date.now(),yi(n),Ke(n,"pointer")};le.touchmove=n=>{n.input.lastTouch=Date.now(),Ke(n,"pointer")};le.contextmenu=n=>yi(n);function Is(n,e){return n.composing?!0:ie&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Jp=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&&Za&&Qp(n)))n.markCursor=n.state.storedMarks||t.marks(),Fn(n,!0),n.markCursor=null;else if(Fn(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 a=r<0?i.lastChild:i.childNodes[r-1];if(!a)break;if(a.nodeType==3){let l=n.domSelection();l&&l.collapse(a,a.nodeValue.length);break}else i=a,r=-1}}n.input.composing=!0}Rs(n,Jp)};function Qp(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++,Rs(n,20))};function Rs(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Fn(n),e))}function Cs(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Xp(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Uu(e.focusNode,e.focusOffset),o=Gu(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 a=t.pmViewDesc;if(!(!a||!a.isText(t.nodeValue)))return o}}return t||o}function Fn(n,e=!1){if(!(Pe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Cs(n),e||n.docView&&n.docView.dirty){let t=mi(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 Yp(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 on=ue&&Je<15||Mt&&$u<604;le.copy=ce.cut=(n,e)=>{let t=e,o=n.state.selection,i=t.type=="cut";if(o.empty)return;let r=on?null:t.clipboardData,a=o.content(),{dom:l,text:c}=fi(n,a);r?(t.preventDefault(),r.clearData(),r.setData("text/html",l.innerHTML),r.setData("text/plain",c)):Yp(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Zp(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function ed(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?rn(n,o.value,null,i,e):rn(n,o.textContent,o.innerHTML,i,e)},50)}function rn(n,e,t,o,i){let r=gs(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 a=Zp(r),l=a?n.state.tr.replaceSelectionWith(a,o):n.state.tr.replaceSelection(r);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function vs(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=on?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;o&&rn(n,vs(o),o.getData("text/html"),i,t)?t.preventDefault():ed(n,t)};class Ms{constructor(e,t,o){this.slice=e,this.move=t,this.node=o}}const td=ge?"altKey":"ctrlKey";function Os(n,e){let t;return n.someProp("dragCopies",o=>{t=t||o(e)}),t!=null?!t:!e[td]}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(dn(t)),a;if(!(r&&r.pos>=i.from&&r.pos<=(i instanceof B?i.to-1:i.to))){if(o&&o.mightDrag)a=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&&(a=B.create(n.state.doc,m.posBefore))}}let l=(a||n.state.selection).content(),{dom:c,text:p,slice:d}=fi(n,l);(!t.dataTransfer.files.length||!te||Ya>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(on?"Text":"text/html",c.innerHTML),t.dataTransfer.effectAllowed="copyMove",on||t.dataTransfer.setData("text/plain",p),n.dragging=new Ms(d,Os(n,t),a)};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{nd(n,e,n.dragging)}finally{n.dragging=null}};function nd(n,e,t){if(!e.dataTransfer)return;let o=n.posAtCoords(dn(e));if(!o)return;let i=n.state.doc.resolve(o.pos),r=t&&t.slice;r?n.someProp("transformPasted",b=>{r=b(r,n,!1)}):r=gs(n,vs(e.dataTransfer),on?null:e.dataTransfer.getData("text/html"),!1,i);let a=!!(t&&Os(n,e));if(n.someProp("handleDrop",b=>b(n,e,r||A.empty,a))){e.preventDefault();return}if(!r)return;e.preventDefault();let l=r?vu(n.state.doc,i.pos,r):i.pos;l==null&&(l=i.pos);let c=n.state.tr;if(a){let{node:b}=t;b?b.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 b=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((S,_,w,O)=>b=O),c.setSelection(hi(n,g,c.doc.resolve(b)))}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 an(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 qn{constructor(e,t){this.toDOM=e,this.spec=t||dt,this.side=this.spec.side||0}map(e,t,o,i){let{pos:r,deleted:a}=e.mapResult(t.from+i,this.side<0?-1:1);return a?null:new _e(r-o,r-o,this)}valid(){return!0}eq(e){return this==e||e instanceof qn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&an(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ye{constructor(e,t){this.attrs=e,this.spec=t||dt}map(e,t,o,i){let r=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-o,a=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-o;return r>=a?null:new _e(r,a,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Ye&&an(this.attrs,e.attrs)&&an(this.spec,e.spec)}static is(e){return e.type instanceof Ye}destroy(){}}class bi{constructor(e,t){this.attrs=e,this.spec=t||dt}map(e,t,o,i){let r=e.mapResult(t.from+i,1);if(r.deleted)return null;let a=e.mapResult(t.to+i,-1);return a.deleted||a.pos<=r.pos?null:new _e(r.pos-o,a.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 bi&&an(this.attrs,e.attrs)&&an(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 qn(t,o))}static inline(e,t,o,i){return new _e(e,t,new Ye(o,i))}static node(e,t,o,i){return new _e(e,t,new bi(o,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ye}get widget(){return this.type instanceof qn}}const It=[],dt={};class J{constructor(e,t){this.local=e.length?e:It,this.children=t.length?t:It}static create(e,t){return t.length?Un(t,e,0,dt):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 a=0;a<this.local.length;a++){let l=this.local[a];l.from<=t&&l.to>=e&&(!r||r(l.spec))&&o.push(l.copy(l.from+i,l.to+i))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let l=this.children[a]+1;this.children[a+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||dt)}mapInner(e,t,o,i,r){let a;for(let l=0;l<this.local.length;l++){let c=this.local[l].map(e,o,i);c&&c.type.valid(t,c)?(a||(a=[])).push(c):r.onRemove&&r.onRemove(this.local[l].spec)}return this.children.length?od(this.children,a||[],e,t,o,i,r):a?new J(a.sort(mt),It):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=As(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,Un(d,l,p+1,dt)),r+=3}});let a=Es(r?Ns(t):t,-o);for(let l=0;l<a.length;l++)a[l].type.valid(e,a[l])||a.splice(l--,1);return new J(a.length?this.local.concat(a).sort(mt):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 a,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,(a||(a=[])).push(m));if(!a)continue;o==this.children&&(o=this.children.slice());let p=o[r+2].removeInner(a,l+1);p!=oe?o[r+2]=p:(o.splice(r,3),r-=3)}if(i.length){for(let r=0,a;r<e.length;r++)if(a=e[r])for(let l=0;l<i.length;l++)i[l].eq(a,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,a=r+t.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<a&&c.to>r&&c.type instanceof Ye){let p=Math.max(r,c.from)-r,d=Math.min(a,c.to)-r;p<d&&(i||(i=[])).push(c.copy(p,d))}}if(i){let l=new J(i.sort(mt),It);return o?new je([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 It;if(e.inlineContent||!this.local.some(Ye.is))return this.local;let t=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof Ye||t.push(this.local[o]);return t}forEachSet(e){e(this)}}J.empty=new J([],[]);J.removeOverlap=Si;const oe=J.empty;class je{constructor(e){this.members=e}map(e,t){const o=this.members.map(i=>i.map(e,t,dt));return je.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 je?o=o.concat(r.members):o.push(r))}return je.from(o)}eq(e){if(!(e instanceof je)||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 a=0;a<r.length;a++)t.push(r[a])}}return t?Si(o?t:t.sort(mt)):It}static from(e){switch(e.length){case 0:return oe;case 1:return e[0];default:return new je(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 od(n,e,t,o,i,r,a){let l=n.slice();for(let p=0,d=r;p<t.maps.length;p++){let m=0;t.maps[p].forEach((g,b,S,_)=>{let w=_-S-(b-g);for(let O=0;O<l.length;O+=3){let L=l[O+1];if(L<0||g>L+d-m)continue;let F=l[O]+d-m;b>=F?l[O+1]=g<=F?-2:-1:g>=d&&w&&(l[O]+=w,l[O+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),b=g-i,{index:S,offset:_}=o.content.findIndex(m),w=o.maybeChild(S);if(w&&_==m&&_+w.nodeSize==b){let O=l[p+2].mapInner(t,w,d+1,n[p]+r+1,a);O!=oe?(l[p]=m,l[p+1]=b,l[p+2]=O):(l[p+1]=-2,c=!0)}else c=!0}if(c){let p=id(l,n,e,t,i,r,a),d=Un(p,o,0,a);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 b=d.children[m];for(;g<l.length&&l[g]<b;)g+=3;l.splice(g,0,d.children[m],d.children[m+1],d.children[m+2])}}return new J(e.sort(mt),l)}function Es(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 id(n,e,t,o,i,r,a){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):a.onRemove&&a.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 As(n,e,t){if(e.isLeaf)return null;let o=t+e.nodeSize,i=null;for(let r=0,a;r<n.length;r++)(a=n[r])&&a.from>t&&a.to<o&&((i||(i=[])).push(a),n[r]=null);return i}function Ns(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Un(n,e,t,o){let i=[],r=!1;e.forEach((l,c)=>{let p=As(n,l,c+t);if(p){r=!0;let d=Un(p,l,t+c+1,o);d!=oe&&i.push(c,c+l.nodeSize,d)}});let a=Es(r?Ns(n):n,-t).sort(mt);for(let l=0;l<a.length;l++)a[l].type.valid(e,a[l])||(o.onRemove&&o.onRemove(a[l].spec),a.splice(l--,1));return a.length||i.length?new J(a,i):oe}function mt(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),Vr(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),Vr(e,i,o.copy(r.from,o.to)));break}}}return e}function Vr(n,e,t){for(;e<n.length&&mt(t,n[e])>0;)e++;n.splice(e,0,t)}function Eo(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])),je.from(e)}const rd={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ad=ue&&Je<=11;class sd{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 ld{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new sd,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&&Je<=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()}),ad&&(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,rd)),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(Mr(this.view)){if(this.suppressingSelectionUpdates)return ze(this.view);if(ue&&Je<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&xt(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=vt(r))t.add(r);for(let r=e.anchorNode;r;r=vt(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)&&Mr(e)&&!this.ignoreSelectionChange(o),r=-1,a=-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),a=a<0?m.to:Math.max(m.to,a),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 b=g.parentNode;b&&b.nodeName=="LI"&&(!m||pd(e,m)!=b)&&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&&Qn(o)&&(p=mi(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,a),cd(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,dd(e,c)),this.handleDOMChange(r,a,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&&Je<=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 a=i&&i.parentNode==e.target?Z(i)+1:0,l=o.localPosFromDOM(e.target,a,-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 Pr=new WeakMap,Kr=!1;function cd(n){if(!Pr.has(n)&&(Pr.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=ye,Kr)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."),Kr=!0}}function zr(n,e){let t=e.startContainer,o=e.startOffset,i=e.endContainer,r=e.endOffset,a=n.domAtPos(n.state.selection.anchor);return xt(a.node,a.offset,i,r)&&([t,o,i,r]=[i,r,t,o]),{anchorNode:t,anchorOffset:o,focusNode:i,focusOffset:r}}function ud(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return zr(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?zr(n,t):null}function pd(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 dd(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 a=r.nextSibling;for(;a&&a.nodeName!="TD"&&a.nodeName!="TH";)a=a.nextSibling;if(a){let l=a;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 md(n,e,t,o){let{node:i,fromOffset:r,toOffset:a,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}],Qn(p)||d.push({node:p.focusNode,offset:p.focusOffset})),te&&n.input.lastKeyCode===8)for(let O=a;O>r;O--){let L=i.childNodes[O-1],F=L.pmViewDesc;if(L.nodeName=="BR"&&!F){a=O;break}if(!F||F.size)break}let g=n.state.doc,b=n.someProp("domParser")||Zt.fromSchema(n.state.schema),S=g.resolve(l),_=null,w=b.parse(i,{topNode:S.parent,topMatch:S.parent.contentMatchAt(S.index()),topOpen:!0,from:r,to:a,preserveWhitespace:S.parent.type.whitespace=="pre"?"full":!0,findPositions:d,ruleFromNode:hd(o),context:S});if(d&&d[0].pos!=null){let O=d[0].pos,L=d[1]&&d[1].pos;L==null&&(L=O),_={anchor:O+l,head:L+l}}return{doc:w,sel:_,from:l,to:c}}const hd=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},fd=/^(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 gd(n,e,t,o,i){let r=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let C=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,T=mi(n,C);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);C=="pointer"?D.setMeta("pointer",!0):C=="key"&&D.scrollIntoView(),r&&D.setMeta("composition",r),n.dispatch(D)}return}let a=n.state.doc.resolve(e),l=a.sharedDepth(t);e=a.before(l+1),t=n.state.doc.resolve(t).after(l+1);let c=n.state.selection,p=md(n,e,t,i),d=n.state.doc,m=d.slice(p.from,p.to),g,b;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(g=n.state.selection.to,b="end"):(g=n.state.selection.from,b="start"),n.input.lastKeyCode=null;let S=bd(m.content,p.doc.content,p.from,g,b);if(S&&n.input.domChangeCount++,(Mt&&n.input.lastIOSEnter>Date.now()-225||Pe)&&i.some(C=>C.nodeType==1&&!fd.test(C.nodeName))&&(!S||S.endA>=S.endB)&&n.someProp("handleKeyDown",C=>C(n,st(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!S)if(o&&c instanceof U&&!c.empty&&c.$head.sameParent(c.$anchor)&&!n.composing&&!(p.sel&&p.sel.anchor!=p.sel.head))S={start:c.from,endA:c.to,endB:c.to};else{if(p.sel){let C=Fr(n,n.state.doc,p.sel);if(C&&!C.eq(n.state.selection)){let T=n.state.tr.setSelection(C);r&&T.setMeta("composition",r),n.dispatch(T)}}return}n.state.selection.from<n.state.selection.to&&S.start==S.endB&&n.state.selection instanceof U&&(S.start>n.state.selection.from&&S.start<=n.state.selection.from+2&&n.state.selection.from>=p.from?S.start=n.state.selection.from:S.endA<n.state.selection.to&&S.endA>=n.state.selection.to-2&&n.state.selection.to<=p.to&&(S.endB+=n.state.selection.to-S.endA,S.endA=n.state.selection.to)),ue&&Je<=11&&S.endB==S.start+1&&S.endA==S.start&&S.start>p.from&&p.doc.textBetween(S.start-p.from-1,S.start-p.from+1)=="  "&&(S.start--,S.endA--,S.endB--);let _=p.doc.resolveNoCache(S.start-p.from),w=p.doc.resolveNoCache(S.endB-p.from),O=d.resolve(S.start),L=_.sameParent(w)&&_.parent.inlineContent&&O.end()>=S.endA;if((Mt&&n.input.lastIOSEnter>Date.now()-225&&(!L||i.some(C=>C.nodeName=="DIV"||C.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",C=>C(n,st(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>S.start&&yd(d,S.start,S.endA,_,w)&&n.someProp("handleKeyDown",C=>C(n,st(8,"Backspace")))){Pe&&te&&n.domObserver.suppressSelectionUpdates();return}te&&S.endB==S.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==S.endA&&(S.endB-=2,w=p.doc.resolveNoCache(S.endB-p.from),setTimeout(()=>{n.someProp("handleKeyDown",function(C){return C(n,st(13,"Enter"))})},20));let F=S.start,ne=S.endA,v=C=>{let T=C||n.state.tr.replace(F,ne,p.doc.slice(S.start-p.from,S.endB-p.from));if(p.sel){let D=Fr(n,T.doc,p.sel);D&&!(te&&n.composing&&D.empty&&(S.start!=S.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&&Je<=11&&_.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>ze(n),20));let C=v(n.state.tr.delete(F,ne)),T=d.resolve(S.start).marksAcross(d.resolve(S.endA));T&&C.ensureMarks(T),n.dispatch(C)}else if(S.endA==S.endB&&(I=xd(_.parent.content.cut(_.parentOffset,w.parentOffset),O.parent.content.cut(O.parentOffset,S.endA-O.start())))){let C=v(n.state.tr);I.type=="add"?C.addMark(F,ne,I.mark):C.removeMark(F,ne,I.mark),n.dispatch(C)}else if(_.parent.child(_.index()).isText&&_.index()==w.index()-(w.textOffset?0:1)){let C=_.parent.textBetween(_.parentOffset,w.parentOffset),T=()=>v(n.state.tr.insertText(C,F,ne));n.someProp("handleTextInput",D=>D(n,F,ne,C,T))||n.dispatch(T())}else n.dispatch(v());else n.dispatch(v())}function Fr(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:hi(n,e.resolve(t.anchor),e.resolve(t.head))}function xd(n,e){let t=n.firstChild.marks,o=e.firstChild.marks,i=t,r=o,a,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],a="add",c=d=>d.mark(l.addToSet(d.marks));else if(i.length==0&&r.length==1)l=r[0],a="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(R.from(p).eq(n))return{mark:l,type:a}}function yd(n,e,t,o,i){if(t-e<=i.pos-o.pos||Ao(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 a=n.resolve(Ao(r,!0,!0));return!a.parent.isTextblock||a.pos>t||Ao(a,!0,!1)<t?!1:o.parent.content.cut(o.parentOffset).eq(a.parent.content)}function Ao(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 bd(n,e,t,o,i){let r=n.findDiffStart(e,t),a=t+n.size,l=t+e.size;if(r==null)return null;let{a:c,b:p}=n.findDiffEnd(e,a,l);if(i=="end"){let d=Math.max(0,r-Math.min(c,p));o-=c+d-r}if(c<r&&a<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 Sd{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 Bp,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Wr),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=Gr(this),Ur(this),this.nodeViews=Lr(this),this.docView=wr(this.state.doc,qr(this),Eo(this),this.dom,this),this.domObserver=new ld(this,(o,i,r,a)=>gd(this,o,i,r,a)),this.domObserver.start(),Vp(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&&ni(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Wr),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,a=!1;e.storedMarks&&this.composing&&(Cs(this),a=!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 b=Lr(this);_d(b,this.nodeViews)&&(this.nodeViews=b,r=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&ni(this),this.editable=Gr(this),Ur(this);let c=Eo(this),p=qr(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))&&(a=!0);let g=d=="preserve"&&a&&this.dom.style.overflowAnchor==null&&Qu(this);if(a){this.domObserver.stop();let b=m&&(ue||te)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&kd(i.selection,e.selection);if(m){let _=te?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Xp(this)),(r||!this.docView.update(e.doc,p,c,this))&&(this.docView.updateOuterDeco(p),this.docView.destroy(),this.docView=wr(e.doc,p,c,this.dom,this)),_&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(b=!0)}let S=this.input.mouseDown;b||!(S&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Sp(this)&&S.delaySelUpdate())?ze(this,b):(ms(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&&Xu(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&&yr(this,t.getBoundingClientRect(),e)}else yr(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 Ms(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 a=0;a<this.directPlugins.length;a++){let l=this.directPlugins[a].props[e];if(l!=null&&(i=t?t(l):l))return i}let r=this.state.plugins;if(r)for(let a=0;a<r.length;a++){let l=r[a].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&&Yu(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 op(this,e)}coordsAtPos(e,t=1){return rs(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 lp(this,t||this.state,e)}pasteHTML(e,t){return rn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return rn(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return fi(this,e)}destroy(){this.docView&&(Pp(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Eo(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Fu())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return zp(this,e)}domSelectionRange(){let e=this.domSelection();return e?ie&&this.root.nodeType===11&&Wu(this.dom.ownerDocument)==this.dom&&ud(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Sd.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function qr(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 Ur(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 Gr(n){return!n.someProp("editable",e=>e(n.state)===!1)}function kd(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 Lr(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 _d(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 Wr(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 Ds=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function wd(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Td=(n,e,t)=>{let o=wd(n,t);if(!o)return!1;let i=Bs(o);if(!i){let a=o.blockRange(),l=a&&ci(a);return l==null?!1:(e&&e(n.tr.lift(a,l).scrollIntoView()),!0)}let r=i.nodeBefore;if(Ps(n,i,e,-1))return!0;if(o.parent.content.size==0&&(Ot(r,"end")||B.isSelectable(r)))for(let a=o.depth;;a--){let l=ui(n.doc,o.before(a),o.after(a),A.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=n.tr.step(l);c.setSelection(Ot(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(a==1||o.node(a-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 Ot(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 Id=(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=Bs(o)}let a=r&&r.nodeBefore;return!a||!B.isSelectable(a)?!1:(e&&e(n.tr.setSelection(B.create(n.doc,r.pos-a.nodeSize)).scrollIntoView()),!0)};function Bs(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 Rd(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Cd=(n,e,t)=>{let o=Rd(n,t);if(!o)return!1;let i=Vs(o);if(!i)return!1;let r=i.nodeAfter;if(Ps(n,i,e,1))return!0;if(o.parent.content.size==0&&(Ot(r,"start")||B.isSelectable(r))){let a=ui(n.doc,o.before(),o.after(),A.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=n.tr.step(a);l.setSelection(Ot(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},vd=(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=Vs(o)}let a=r&&r.nodeAfter;return!a||!B.isSelectable(a)?!1:(e&&e(n.tr.setSelection(B.create(n.doc,r.pos)).scrollIntoView()),!0)};function Vs(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 Md=(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 ki(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 Od=(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),a=ki(i.contentMatchAt(r));if(!a||!i.canReplaceWith(r,r,a))return!1;if(e){let l=t.after(),c=n.tr.replaceWith(l,l,a.createAndFill());c.setSelection(G.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},Ed=(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=ki(i.parent.contentMatchAt(i.indexAfter()));if(!r||!r.isTextblock)return!1;if(e){let a=(!o.parentOffset&&i.index()<i.parent.childCount?o:i).pos,l=n.tr.insert(a,r.createAndFill());l.setSelection(U.create(l.doc,a+1)),e(l.scrollIntoView())}return!0},Ad=(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(Nn(n.doc,r))return e&&e(n.tr.split(r).scrollIntoView()),!0}let o=t.blockRange(),i=o&&ci(o);return i==null?!1:(e&&e(n.tr.lift(o,i).scrollIntoView()),!0)};function Nd(n){return(e,t)=>{if(e.selection instanceof B&&e.selection.node.isBlock){let{$from:b}=e.selection;return!b.parentOffset||!Nn(e.doc,b.pos)?!1:(t&&t(e.tr.split(b.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,a=[],l,c,p=!1,d=!1;for(let b=i.depth;;b--)if(i.node(b).isBlock){p=i.end(b)==i.pos+(i.depth-b),d=i.start(b)==i.pos-(i.depth-b),c=ki(i.node(b-1).contentMatchAt(i.indexAfter(b-1))),a.unshift(p&&c?{type:c}:null),l=b;break}else{if(b==1)return!1;a.unshift(null)}let m=i.pos,g=Nn(o.doc,m,a.length,a);if(g||(a[0]=c?{type:c}:null,g=Nn(o.doc,m,a.length,a)),!g)return!1;if(o.split(m,a.length,a),!p&&d&&i.node(l).type!=c){let b=o.mapping.slice(r),S=b.map(i.before(l)),_=o.doc.resolve(S);c&&i.node(l-1).canReplaceWith(_.index(),_.index()+1,c)&&o.setNodeMarkup(b.map(i.before(l)),c)}return t&&t(o.scrollIntoView()),!0}}const Dd=Nd(),Bd=(n,e)=>(e&&e(n.tr.setSelection(new he(n.doc))),!0);function Vd(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||Ua(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Ps(n,e,t,o){let i=e.nodeBefore,r=e.nodeAfter,a,l,c=i.type.spec.isolating||r.type.spec.isolating;if(!c&&Vd(n,e,t))return!0;let p=!c&&e.parent.canReplace(e.index(),e.index()+1);if(p&&(a=(l=i.contentMatchAt(i.childCount)).findWrapping(r.type))&&l.matchType(a[0]||r.type).validEnd){if(t){let b=e.pos+r.nodeSize,S=R.empty;for(let O=a.length-1;O>=0;O--)S=R.from(a[O].create(null,S));S=R.from(i.copy(S));let _=n.tr.step(new me(e.pos-1,b,e.pos,b,new A(S,1,0),a.length,!0)),w=_.doc.resolve(b+2*a.length);w.nodeAfter&&w.nodeAfter.type==i.type&&Ua(_.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&&ci(m);if(g!=null&&g>=e.depth)return t&&t(n.tr.lift(m,g).scrollIntoView()),!0;if(p&&Ot(r,"start",!0)&&Ot(i,"end")){let b=i,S=[];for(;S.push(b),!b.isTextblock;)b=b.lastChild;let _=r,w=1;for(;!_.isTextblock;_=_.firstChild)w++;if(b.canReplace(b.childCount,b.childCount,_.content)){if(t){let O=R.empty;for(let F=S.length-1;F>=0;F--)O=R.from(S[F].copy(O));let L=n.tr.step(new me(e.pos-S.length,e.pos+r.nodeSize,e.pos+w,e.pos+r.nodeSize-w,new A(O,S.length,0),0,!0));t(L.scrollIntoView())}return!0}}return!1}function Ks(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 Pd=Ks(-1),Kd=Ks(1);function _i(...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 No=_i(Ds,Td,Id),jr=_i(Ds,Cd,vd);const Ve={Enter:_i(Md,Ed,Ad,Dd),"Mod-Enter":Od,Backspace:No,"Mod-Backspace":No,"Shift-Backspace":No,Delete:jr,"Mod-Delete":jr,"Mod-a":Bd},zs={"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":Pd,"Ctrl-e":Kd};for(let n in Ve)zs[n]=Ve[n];const zd=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,t_=zd?zs:Ve;var Gn=200,Q=function(){};Q.prototype.append=function(e){return e.length?(e=Q.from(e),!this.length&&e||e.length<Gn&&this.leafAppend(e)||this.length<Gn&&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 Fd(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,a){return i.push(e(r,a))},t,o),i};Q.from=function(e){return e instanceof Q?e:e&&e.length?new Fs(e):Q.empty};var Fs=(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,a,l){for(var c=r;c<a;c++)if(i(this.values[c],l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(i,r,a,l){for(var c=r-1;c>=a;c--)if(i(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Gn)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Gn)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 Fs([]);var Fd=(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,a){var l=this.left.length;if(i<l&&this.left.forEachInner(o,i,Math.min(r,l),a)===!1||r>l&&this.right.forEachInner(o,Math.max(i-l,0),Math.min(this.length,r)-l,a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,r,a){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(o,i-l,Math.max(r,l)-l,a+l)===!1||r<l&&this.left.forEachInvertedInner(o,Math.min(i,l),r,a)===!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 qd=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 a=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 Re(m.map));let b=m.step.map(i.slice(r)),S;b&&a.maybeStep(b).doc&&(S=a.mapping.maps[a.mapping.maps.length-1],p.push(new Re(S,void 0,void 0,p.length+d.length))),r--,S&&i.appendMap(S,r)}else a.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:a,selection:l}}addTransform(e,t,o,i){let r=[],a=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 Re(e.mapping.maps[d],m,t),b;(b=c&&c.merge(g))&&(g=b,d?r.pop():l=l.slice(0,l.length-1)),r.push(g),t&&(a++,t=void 0),i||(c=g)}let p=a-o.depth;return p>Gd&&(l=Ud(l,p),a-=p),new ke(l.append(r),a)}remapping(e,t){let o=new tn;return this.items.forEach((i,r)=>{let a=i.mirrorOffset!=null&&r-i.mirrorOffset>=e?o.maps.length-i.mirrorOffset:void 0;o.appendMap(i.map,a)},e,t),o}addMaps(e){return this.eventCount==0?this:new ke(this.items.append(e.map(t=>new Re(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let o=[],i=Math.max(0,this.items.length-t),r=e.mapping,a=e.steps.length,l=this.eventCount;this.items.forEach(g=>{g.selection&&l--},i);let c=t;this.items.forEach(g=>{let b=r.getMirror(--c);if(b==null)return;a=Math.min(a,b);let S=r.maps[b];if(g.step){let _=e.steps[b].invert(e.docs[b]),w=g.selection&&g.selection.map(r.slice(c+1,b));w&&l++,o.push(new Re(S,_,w))}else o.push(new Re(S))},i);let p=[];for(let g=t;g<a;g++)p.push(new Re(r.maps[g]));let d=this.items.slice(0,i).append(p).append(o),m=new ke(d,l);return m.emptyItemCount()>qd&&(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((a,l)=>{if(l>=e)i.push(a),a.selection&&r++;else if(a.step){let c=a.step.map(t.slice(o)),p=c&&c.getMap();if(o--,p&&t.appendMap(p,o),c){let d=a.selection&&a.selection.map(t.slice(o));d&&r++;let m=new Re(p.invert(),c,d),g,b=i.length-1;(g=i.length&&i[b].merge(m))?i[b]=g:i.push(m)}}else a.map&&o--},this.items.length,0),new ke(Q.from(i.reverse()),r)}}ke.empty=new ke(Q.empty,0);function Ud(n,e){let t;return n.forEach((o,i)=>{if(o.selection&&e--==0)return t=i,!1}),n.slice(t)}class Re{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 Re(t.getMap().invert(),t,this.selection)}}}class We{constructor(e,t,o,i,r){this.done=e,this.undone=t,this.prevRanges=o,this.prevTime=i,this.prevComposition=r}}const Gd=20;function Ld(n,e,t,o){let i=t.getMeta(ht),r;if(i)return i.historyState;t.getMeta(qs)&&(n=new We(n.done,n.undone,null,0,-1));let a=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(a&&a.getMeta(ht))return a.getMeta(ht).redo?new We(n.done.addTransform(t,void 0,o,Dn(e)),n.undone,$r(t.mapping.maps),n.prevTime,n.prevComposition):new We(n.done,n.undone.addTransform(t,void 0,o,Dn(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(a&&a.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),c=n.prevTime==0||!a&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-o.newGroupDelay||!Wd(t,n.prevRanges)),p=a?Do(n.prevRanges,t.mapping):$r(t.mapping.maps);return new We(n.done.addTransform(t,c?e.selection.getBookmark():void 0,o,Dn(e)),ke.empty,p,t.time,l??n.prevComposition)}else return(r=t.getMeta("rebased"))?new We(n.done.rebased(t,r),n.undone.rebased(t,r),Do(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new We(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Do(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Wd(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 $r(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((o,i,r,a)=>e.push(r,a));return e}function Do(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 jd(n,e,t){let o=Dn(e),i=ht.get(e).spec.config,r=(t?n.undone:n.done).popEvent(e,o);if(!r)return null;let a=r.selection.resolve(r.transform.doc),l=(t?n.done:n.undone).addTransform(r.transform,e.selection.getBookmark(),i,o),c=new We(t?l:r.remaining,t?r.remaining:l,null,0,-1);return r.transform.setSelection(a).setMeta(ht,{redo:t,historyState:c})}let Bo=!1,Hr=null;function Dn(n){let e=n.plugins;if(Hr!=e){Bo=!1,Hr=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Bo=!0;break}}return Bo}function n_(n){return n.setMeta(qs,!0)}const ht=new Qa("history"),qs=new Qa("closeHistory");function o_(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new Ha({key:ht,state:{init(){return new We(ke.empty,ke.empty,null,0,-1)},apply(e,t,o){return Ld(t,o,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let o=t.inputType,i=o=="historyUndo"?$d:o=="historyRedo"?Hd:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function Us(n,e){return(t,o)=>{let i=ht.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(o){let r=jd(i,t,n);r&&o(e?r.scrollIntoView():r)}return!0}}const $d=Us(!1,!0),Hd=Us(!0,!0);var Ze={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:"'"},Ln={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Jd=typeof navigator<"u"&&/Mac/.test(navigator.platform),Qd=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ee=0;ee<10;ee++)Ze[48+ee]=Ze[96+ee]=String(ee);for(var ee=1;ee<=24;ee++)Ze[ee+111]="F"+ee;for(var ee=65;ee<=90;ee++)Ze[ee]=String.fromCharCode(ee+32),Ln[ee]=String.fromCharCode(ee);for(var Vo in Ze)Ln.hasOwnProperty(Vo)||(Ln[Vo]=Ze[Vo]);function Xd(n){var e=Jd&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Qd&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Ln:Ze)[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 Yd=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Zd=typeof navigator<"u"&&/Win/.test(navigator.platform);function em(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let o,i,r,a;for(let l=0;l<e.length-1;l++){let c=e[l];if(/^(cmd|meta|m)$/i.test(c))a=!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))Yd?a=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return o&&(t="Alt-"+t),i&&(t="Ctrl-"+t),a&&(t="Meta-"+t),r&&(t="Shift-"+t),t}function tm(n){let e=Object.create(null);for(let t in n)e[em(t)]=n[t];return e}function Po(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 i_(n){return new Ha({props:{handleKeyDown:nm(n)}})}function nm(n){let e=tm(n);return function(t,o){let i=Xd(o),r,a=e[Po(i,o)];if(a&&a(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(o.shiftKey){let l=e[Po(i,o,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((o.altKey||o.metaKey||o.ctrlKey)&&!(Zd&&o.ctrlKey&&o.altKey)&&(r=Ze[o.keyCode])&&r!=i){let l=e[Po(r,o)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const r_=28,Gs=[{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"}];Gs.map(({column:n})=>n);function a_(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 Gs.map(({column:o,type:i})=>({column:o,type:i,value:t[o]}))}const om=s().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)"),im=s().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)"),rm=s().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)"),am=s().regex(/^nano-banana-[a-z0-9]+(?:-[a-z0-9]+)*$/,"Expected a listed model or a kie Nano Banana alias (e.g. nano-banana-3)"),sm=s().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)"),lm=s().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)"),cm=s().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)"),um=s().regex(/^bytedance\/seedance-\d+(?:\.\d+)*(?:-[a-z][a-z0-9]*)*$/,"Expected a listed model or a kie Seedance alias (e.g. bytedance/seedance-3)"),pm=s().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)"),dm=s().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)"),mm=s().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)"),hm=s().regex(/^pixverse-v\d+(?:\.\d+)*(?:-[a-z]+)?\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,"Expected a listed model or a kie PixVerse alias (e.g. pixverse-v7/text-to-video)"),fm=["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","kling-4.0/reference-to-video","kling-4.0/keyframe-to-video","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-5-draft","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","omnihuman-2-0","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","pixverse-v6-max/text-to-video","pixverse-v6-max/image-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"],gm=h(fm).or(om).or(im).or(rm).or(am).or(sm).or(lm).or(cm).or(um).or(pm).or(dm).or(mm).or(hm);h(["image","video","audio","transcription"]);const xm=["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"],ym=h(xm),bm=["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(bm),km=h(["Neutral","American (Gen)","American (Valley)","American (South)","British (RP)","British (Brixton)","Transatlantic","Australian"]),_m=h(["Vocal Smile","Newscaster","Whisper","Empathetic","Promo/Hype","Deadpan"]),wm=h(["Natural","Rapid Fire","The Drift","Staccato"]),Yn=s().refine(n=>/^Speaker \d+$/.test(n),{message:'Expected a speaker id in "Speaker N" format (e.g. "Speaker 1")'}),Jr={minimum:0,maximum:2},Tm=1e4,Im=h(["user","model"]),Rm=h(["low","high"]),Cm=u({mime_type:s().min(1),data:s().min(1)}),vm=u({mime_type:s().min(1),file_uri:s().min(1)}),Mm=u({text:s().optional(),inline_data:Cm.optional(),file_data:vm.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"}),Zn=u({role:Im,parts:k(Mm).min(1)}),Om=u({type:s().optional(),properties:z(s(),K()).optional(),required:k(s()).optional()}).passthrough(),Ls=u({name:s().min(1),description:s().optional(),parameters:Om.optional()}).passthrough(),Ws=u({}).strict();u({googleSearch:Ws}).strict();u({functionDeclarations:k(Ls).min(1)}).strict();const eo=u({googleSearch:Ws.optional(),functionDeclarations:k(Ls).min(1).optional()}).strict().refine(n=>n.googleSearch!==void 0||n.functionDeclarations!==void 0,{message:"tools entries must include googleSearch or functionDeclarations"}),Em=u({includeThoughts:x().optional(),thinkingLevel:Rm.optional()}).strict(),to=u({temperature:y().optional(),topP:y().optional(),topK:y().optional(),candidateCount:y().int().positive().optional(),maxOutputTokens:y().int().positive().optional(),stopSequences:k(s()).optional(),thinkingConfig:Em.optional()}).passthrough();u({stream:x().default(!0),contents:k(Zn).min(1),tools:k(eo).optional(),generationConfig:to.optional()}).passthrough();u({stream:x().default(!0),contents:k(Zn).min(1),tools:k(eo).optional(),generationConfig:to.optional()}).passthrough();u({stream:x().default(!0),contents:k(Zn).min(1),tools:k(eo).optional(),generationConfig:to.optional()}).passthrough();u({stream:x().default(!0),contents:k(Zn).min(1),tools:k(eo).optional(),generationConfig:to.optional()}).passthrough();const Am=h(["developer","system","user","assistant","tool"]);h(["text","image_url"]);const Nm=h(["low","high"]),Dm=h(["function"]),Bm=h(["googleSearch"]),Vm=u({type:f("text"),text:s()}).strict(),Pm=u({type:f("image_url"),image_url:u({url:s().url()}).strict()}).strict(),Km=Te("type",[Vm,Pm]),zm=u({role:Am,content:P([s().min(1),k(Km).min(1)])}).passthrough(),Fm=u({type:f("object"),properties:z(s(),K()).optional(),required:k(s()).optional()}).passthrough(),qm=u({name:Bm,description:s().optional(),parameters:Fm.optional()}).passthrough(),Um=u({type:Dm,function:qm}).strict();u({messages:k(zm).min(1),stream:x().default(!1),tools:k(Um).min(0).optional(),include_thoughts:x().default(!1),reasoning_effort:Nm.default("high")}).passthrough();const Gm=h(["developer","system","user","assistant","tool"]);h(["text","image_url"]);const Lm=h(["low","high"]),Wm=h(["function"]),jm=h(["web_search"]),$m=u({type:f("text"),text:s()}).strict(),Hm=u({type:f("image_url"),image_url:u({url:s().url()}).strict()}).strict(),Jm=Te("type",[$m,Hm]),Qm=u({role:Gm,content:P([s().min(1),k(Jm).min(1)])}).passthrough(),Xm=u({type:f("object"),properties:z(s(),K()).optional(),required:k(s()).optional()}).passthrough(),Ym=u({name:jm,description:s().optional(),parameters:Xm.optional()}).passthrough(),Zm=u({type:Wm,function:Ym}).strict();u({messages:k(Qm).min(1),tools:k(Zm).min(0).optional(),reasoning_effort:Lm.default("high")}).passthrough();const eh=h(["developer","system","user","assistant","tool"]);h(["text","image_url"]);const th=h(["low","high"]),nh=h(["function"]),oh=u({type:f("text"),text:s()}).strict(),ih=u({type:f("image_url"),image_url:u({url:s().url()}).strict()}).strict(),rh=Te("type",[oh,ih]),ah=u({role:eh,content:k(rh).min(1)}).passthrough(),sh=u({type:f("object"),properties:z(s(),K()).optional(),required:k(s()).optional()}).passthrough(),lh=u({name:s().min(1),description:s().optional(),parameters:sh.optional()}).passthrough(),ch=u({type:nh,function:lh}).strict(),uh=u({type:s().optional(),json_schema:z(s(),K()).optional(),properties:z(s(),K()).optional()}).passthrough();u({messages:k(ah).min(1),stream:x().default(!1),tools:k(ch).min(0).optional(),include_thoughts:x().optional(),reasoning_effort:th.optional(),response_format:uh.optional()}).passthrough();const ph=h(["developer","system","user","assistant","tool"]);h(["text","image_url"]);const dh=h(["low","high"]),mh=h(["function"]),hh=u({type:f("text"),text:s()}).strict(),fh=u({type:f("image_url"),image_url:u({url:s().url()}).strict()}).strict(),gh=Te("type",[hh,fh]),xh=u({role:ph,content:k(gh).min(1)}).passthrough(),yh=u({type:f("object"),properties:z(s(),K()).optional(),required:k(s()).optional()}).passthrough(),bh=u({name:s().min(1),description:s().optional(),parameters:yh.optional()}).passthrough(),Sh=u({type:mh,function:bh}).strict(),kh=u({type:s().optional(),json_schema:z(s(),K()).optional(),properties:z(s(),K()).optional()}).passthrough();u({messages:k(xh).min(1),stream:x().default(!1),tools:k(Sh).min(0).optional(),include_thoughts:x().optional(),reasoning_effort:dh.optional(),response_format:kh.optional()}).passthrough();const _h=h(["developer","system","user","assistant","tool"]);h(["text","image_url"]);const wh=h(["low","high"]),Th=h(["function"]),Ih=u({type:f("text"),text:s()}).strict(),Rh=u({type:f("image_url"),image_url:u({url:s().url()}).strict()}).strict(),Ch=Te("type",[Ih,Rh]),vh=u({role:_h,content:k(Ch).min(1)}).passthrough(),Mh=u({type:f("object"),properties:z(s(),K()).optional(),required:k(s()).optional()}).passthrough(),Oh=u({name:s().min(1),description:s().optional(),parameters:Mh.optional()}).passthrough(),Eh=u({type:Th,function:Oh}).strict(),Ah=u({type:s().optional(),json_schema:z(s(),K()).optional(),properties:z(s(),K()).optional()}).passthrough();u({messages:k(vh).min(1),stream:x().default(!1),tools:k(Eh).min(0).optional(),include_thoughts:x().optional(),reasoning_effort:wh.optional(),response_format:Ah.optional()}).passthrough();const Nh=h(["developer","system","user","assistant","tool"]);h(["text","image_url"]);const Dh=h(["low","high"]),Bh=h(["function"]),Vh=u({type:f("text"),text:s()}).strict(),Ph=u({type:f("image_url"),image_url:u({url:s().url()}).strict()}).strict(),Kh=Te("type",[Vh,Ph]),zh=u({role:Nh,content:k(Kh).min(1)}).passthrough(),Fh=u({type:f("object"),properties:z(s(),K()).optional(),required:k(s()).optional()}).passthrough(),qh=u({name:s().min(1),description:s().optional(),parameters:Fh.optional()}).passthrough(),Uh=u({type:Bh,function:qh}).strict(),Gh=u({type:s().optional(),json_schema:z(s(),K()).optional(),properties:z(s(),K()).optional()}).passthrough();u({messages:k(zh).min(1),stream:x().default(!1),tools:k(Uh).min(0).optional(),include_thoughts:x().optional(),reasoning_effort:Dh.optional(),response_format:Gh.optional()}).passthrough();const Lh=h(["developer","system","user","assistant","tool"]);h(["text","image_url"]);const Wh=h(["low","high"]),jh=h(["function"]),$h=u({type:f("text"),text:s()}).strict(),Hh=u({type:f("image_url"),image_url:u({url:s().url()}).strict()}).strict(),Jh=Te("type",[$h,Hh]),Qh=u({role:Lh,content:k(Jh).min(1)}).passthrough(),Xh=u({type:f("object"),properties:z(s(),K()).optional(),required:k(s()).optional()}).passthrough(),Yh=u({name:s().min(1),description:s().optional(),parameters:Xh.optional()}).passthrough(),Zh=u({type:jh,function:Yh}).strict(),ef=u({type:s().optional(),json_schema:z(s(),K()).optional(),properties:z(s(),K()).optional()}).passthrough();u({messages:k(Qh).min(1),stream:x().default(!1),tools:k(Zh).min(0).optional(),include_thoughts:x().optional(),reasoning_effort:Wh.optional(),response_format:ef.optional()}).passthrough();const tf=h(["developer","system","user","assistant","tool"]);h(["text","image_url"]);const nf=h(["low","high"]),of=h(["function"]),rf=u({type:f("text"),text:s()}).strict(),af=u({type:f("image_url"),image_url:u({url:s().url()}).strict()}).strict(),sf=Te("type",[rf,af]),lf=u({role:tf,content:k(sf).min(1)}).passthrough(),cf=u({type:f("object"),properties:z(s(),K()).optional(),required:k(s()).optional()}).passthrough(),uf=u({name:s().min(1),description:s().optional(),parameters:cf.optional()}).passthrough(),pf=u({type:of,function:uf}).strict(),df=u({type:s().optional(),json_schema:z(s(),K()).optional(),properties:z(s(),K()).optional()}).passthrough();u({messages:k(lf).min(1),stream:x().default(!1),tools:k(pf).min(0).optional(),include_thoughts:x().default(!1),reasoning_effort:nf.default("high"),response_format:df.optional()}).passthrough();const mf=h(["developer","system","user","assistant","tool"]);h(["text","image_url"]);const hf=h(["function"]),ff=h(["low","high"]),gf=u({type:f("text"),text:s()}).strict(),xf=u({type:f("image_url"),image_url:u({url:s().url()}).strict()}).strict(),yf=Te("type",[gf,xf]),bf=u({role:mf,content:k(yf).min(1)}).passthrough(),Sf=u({type:f("object"),properties:z(s(),K()).optional(),required:k(s()).optional()}).passthrough(),kf=u({name:s().min(1),description:s().optional(),parameters:Sf.optional()}).passthrough(),_f=u({type:hf,function:kf}).strict(),wf=u({type:s().optional(),json_schema:z(s(),K()).optional(),properties:z(s(),K()).optional()}).passthrough();u({messages:k(bf).min(1),stream:x().default(!1),tools:k(_f).min(0).optional(),include_thoughts:x().default(!1),reasoning_effort:ff.default("high"),response_format:wf.optional()}).passthrough();const Tf=h(["3","4","5","6","7","8","9","10","11","12","13","14","15"]),no=h(["16:9","9:16","1:1"]),If=h(["std","pro","4K"]),js=h(["720p","1080p"]),Rf=h(["1:1","9:16","16:9"]),Cf=s().regex(/^[1-9]\d*$/),vf=h(["3","4","5","6","7","8","9","10","11","12","13","14","15"]),Mf=h(["fun","normal","spicy"]),Of=h(["fun","normal","spicy"]);h(["fun","normal","spicy"]);const Ef=h(["2:3","3:2","1:1","16:9","9:16"]),Af=h(["2:3","3:2","1:1","16:9","9:16"]),$s=y().int().min(6).max(30),Hs=s().regex(/^(?:[6-9]|[12][0-9]|30)$/),Nf=P([$s,Hs]),Df=P([$s,Hs]),Bf=h(["6","10"]),Js=h(["480p","720p","1080p"]),Qs=h(["480p","720p"]),Vf=[".jpg",".jpeg",".png",".webp"];function Pf(n){try{const e=new URL(n).pathname.toLowerCase();return Vf.some(t=>e.endsWith(t))}catch{return!1}}const Kf=s().url().refine(Pf,{message:"image_urls entries must be JPEG, PNG, or WEBP URLs"}),zf=h(["auto","1:1","16:9","9:16","4:3","3:4","3:2","2:3"]),wi=h(["1K","2K","4K"]),Ti=h(["png","jpg"]),Xs=h(["medium","high"]),Ff=h(["1:1","3:4","4:3","9:16","16:9"]),Ys=h(["1K","2K"]),qf=h(["1:1","3:2","2:3","4:3","3:4","16:9","9:16","21:9"]),Uf=h(["png","jpeg"]),Zs=h(["square","square_hd","portrait_4_3","portrait_16_9","landscape_4_3","landscape_16_9"]),Ii=h(["none","regular","high"]),Gf=h(["1","2","3","4"]),oo=h(["720p","1080p"]),Ri=h(["16:9","9:16","1:1","4:3","3:4"]),Lf=h(["auto","origin"]),Wf=h(["1K","2K","4K"]),jf=h(["1:1","16:9","4:3","21:9","3:4","9:16","8:1","1:8"]),$f=y().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."),bt=h(["720p","1080p"]),el=h(["16:9","9:16","1:1","4:3","3:4"]),tl=h(["16:9","9:16","3:4","4:3","4:5","5:4","1:1","9:21","21:9"]),Hf=h(["auto","origin"]),Jf=3,Qf=15,At=y().int().min(Jf).max(Qf),Xf=h(["720","1080"]),Yf=h(["lite","basic"]),nl=h(["4","6","8","10"]),ol=h(["16:9","9:16"]),Zf=h(["720p","1080p","4k"]),eg=h(["360p","720p","1080p","4k"]),tg=h(["480p","720p"]),ng=h(["16:9","4:3","1:1","3:4","9:16","21:9","adaptive"]),og=h(["waiting","success","fail"]),Ci=s().min(1).max(7e3),vi=y().int().min(4).max(15),Mi=h(["768P","2K"]),il=h(["21:9","16:9","4:3","1:1","3:4","9:16"]),ig=h(["adaptive",...il.options]),rg=new Set(["http:","https:","oss:"]);function ag(n){try{return rg.has(new URL(n).protocol)}catch{return!1}}const Qt=s().url().refine(ag,{message:"Expected an HTTP, HTTPS, or OSS media address"}),Qr={video:{minimum:2e3,maximum:15e3,maximumTotal:15e3},audio:{minimum:2e3,maximum:15e3,maximumTotal:15e3}};function Xr(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 sg=u({name:s().min(1),description:s().min(1),element_input_urls:k(s()).optional(),element_input_video_urls:k(s()).optional()}),lg=u({prompt:s().min(1).max(500),duration:y().int().min(1).max(12)}),io=h(["720p","1080p","4k"]),Oi=y().int().min(3).max(15),Ei=h(["16:9","9:16","1:1","auto"]),yt=s().refine(n=>/^(https?|oss):\/\//.test(n),{message:"Expected an HTTP, HTTPS, or OSS media reference"}),cg=u({prompt:s().min(1).max(512),duration:y().int().min(1).max(15)}),Ai=k(cg).max(6),ro=u({name:s().min(1),description:s().min(1),element_input_urls:k(yt).min(1).max(4),element_input_audio_urls:k(yt).optional(),start_time:y().int().optional(),end_time:y().int().optional()}),ao=s().min(1).max(3072).refine(n=>n.trim().length>0,{message:"Prompt must contain a non-whitespace character"}),Ni=x().optional().describe("Enable intelligent shot planning; mutually exclusive with customize_multi_shots");function Di(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 ug=u({hex:s().min(1),ratio:s().min(1)}),tt=h(["5","10"]),Nt=y().min(0).max(1),pg=u({model:f("kling-2.6/text-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(1e3),sound:x(),aspect_ratio:no,duration:tt})}),dg=u({model:f("kling-2.6/image-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(1e3),image_urls:k(s().min(1)).min(1).max(1),sound:x(),duration:tt})}),mg=u({model:f("kling-2.6/motion-control"),callBackUrl:s().optional(),input:u({prompt:s().max(2500).optional(),input_urls:k(s().min(1)).min(1).max(1),video_urls:k(s().min(1)).min(1).max(1),character_orientation:h(["image","video"]),mode:h(["720p","1080p"])})}),rl=u({image_url:s().min(1),audio_url:s().min(1),prompt:s().max(5e3)}),hg=u({model:f("kling/ai-avatar-pro"),callBackUrl:s().optional(),input:rl}),fg=u({model:f("kling/ai-avatar-standard"),callBackUrl:s().optional(),input:rl}),gg=u({model:f("kling/v2-1-master-image-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),image_url:s().min(1),duration:tt.optional(),negative_prompt:s().max(500).optional(),cfg_scale:Nt.optional()})}),xg=u({model:f("kling/v2-1-master-text-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),duration:tt.optional(),aspect_ratio:no.optional(),negative_prompt:s().max(500).optional(),cfg_scale:Nt.optional()})}),yg=u({model:f("kling/v2-1-pro"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),image_url:s().min(1),duration:tt.optional(),negative_prompt:s().max(500).optional(),cfg_scale:Nt.optional(),tail_image_url:s().min(1).optional()})}),bg=u({model:f("kling/v2-1-standard"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),image_url:s().min(1),duration:tt.optional(),negative_prompt:s().max(500).optional(),cfg_scale:Nt.optional()})}),Sg=u({model:f("kling/v2-5-turbo-image-to-video-pro"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(2500),image_url:s().min(1),tail_image_url:s().min(1).optional(),duration:tt.optional(),negative_prompt:s().max(500).optional(),cfg_scale:Nt.optional()})}),kg=u({model:f("kling/v2-5-turbo-text-to-video-pro"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(2500),duration:tt.optional(),aspect_ratio:no.optional(),negative_prompt:s().max(2500).optional(),cfg_scale:Nt.optional()})}),_g=u({model:f("kling-3.0/video"),callBackUrl:s().optional(),input:u({prompt:s().optional(),image_urls:k(s()).optional(),sound:x().optional(),duration:Tf,aspect_ratio:no.optional(),mode:If,multi_shots:x(),multi_prompt:k(lg).optional(),kling_elements:k(sg).max(3).optional()})}),wg=u({model:f("kling/v3-turbo-image-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1),image_urls:k(s().min(1)).min(1).max(1),duration:Cf,resolution:js})}),Tg=u({model:f("kling/v3-turbo-text-to-video"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(2500),duration:vf.default("5"),aspect_ratio:Rf.default("16:9"),resolution:js.default("720p")})}),Ig=u({model:f("kling-3.0/motion-control"),callBackUrl:s().optional(),input:u({prompt:s().optional(),input_urls:k(s()).min(1).max(1),video_urls:k(s()).min(1),mode:h(["720p","1080p"]).optional(),character_orientation:h(["video","image"]).optional(),background_source:h(["input_video","input_image"]).optional()})}),Rg=u({prompt:ao,customize_multi_shots:x().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:Ni,multi_prompt:Ai.optional(),elements:k(ro).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:x().optional().describe("Generate audio; upstream default false"),resolution:io.default("720p"),aspect_ratio:h(["16:9","9:16","1:1"]).default("16:9"),duration:Oi.default(5)}),Cg=u({model:f("kling-3.0-omni/text-to-video"),callBackUrl:s().url().optional(),input:Rg}),vg=Cg.superRefine((n,e)=>{Di(n.input,e)}),Mg=u({prompt:ao,image_urls:k(yt).min(1).max(2).describe("One URL supplies the first frame; two URLs supply first and last frames"),duration:Oi.default(5),resolution:io.default("720p"),aspect_ratio:Ei.optional().describe("Output aspect ratio; upstream default auto, with fixed ratios available for custom multi-shot mode"),audio:x().optional(),customize_multi_shots:x().optional(),prefer_multi_shots:Ni,multi_prompt:Ai.optional(),elements:k(ro).max(3).optional().describe("One-time subject assets, up to 3 subjects")}),Og=u({model:f("kling-3.0-omni/image-to-video"),callBackUrl:s().url().optional(),input:Mg}),Eg=Og.superRefine((n,e)=>{Di(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"]})}),Ag=u({prompt:ao,image_urls:k(yt).min(1).max(7).optional(),video_urls:k(yt).min(1).max(1).optional(),duration:Oi.default(5),resolution:io.default("720p"),aspect_ratio:Ei.optional().describe("Fixed ratios apply without video or with video plus images; video-only input requires explicit auto"),audio:x().optional().describe("Video-backed requests require explicit false"),customize_multi_shots:x().optional(),prefer_multi_shots:Ni,multi_prompt:Ai.optional(),elements:k(ro).optional().describe("Subject assets share the reference quota; video-backed requests impose the upstream composition limits")}),Ng=u({model:f("kling-3.0-omni/reference-to-video"),callBackUrl:s().url().optional(),input:Ag}),Dg=Ng.superRefine((n,e)=>{const{input:t}=n,o=!!t.image_urls?.length,i=!!t.video_urls?.length;if(Di(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"]})}),Bg=u({prompt:ao,image_urls:k(yt).min(1).max(4).optional(),video_urls:k(yt).min(1).max(1),duration:s().optional().describe("String duration supported only by the video-with-images shape"),resolution:io.default("720p"),aspect_ratio:Ei.optional().describe("Video-only input uses auto; video with images uses 16:9, 9:16, or 1:1"),audio:x().optional(),elements:k(ro).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")}),Vg=u({model:f("kling-3.0-omni/transformation"),callBackUrl:s().url().optional(),input:Bg}),Pg=Vg.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"]})}),al=h(["720p","1080p"]),sl=y().int().min(3).max(30),ll=h(["auto","16:9","9:16","1:1","21:9"]),Fe=s().regex(/^https?:\/\/.+/),Kg=h(["character","animal","prop","costume","scene","effect","others"]),cl=s().min(1).max(8e3),ul=s().regex(/^[\u4e00-\u9fa5A-Za-z0-9_]{1,20}$/).describe("Mentioned in the prompt as @name: 1-20 Chinese characters, letters, digits or underscores, unique across elements and voices (case-insensitive). image_N, video_N, keyframe_N, object_N, audio_N, first_frame and last_frame are reserved"),zg=/^(?:(?:image|video|keyframe|object|audio)_\d+|first_frame|last_frame)$/i,Fg=u({name:ul,image_urls:k(Fe).min(2).max(4).optional().describe("Image subject: 2-4 image URLs, the first is the primary view; exclusive with video_url"),video_url:Fe.optional().describe("Video subject: one 3-8 s single-shot character video, shortest side at least 700 px; exclusive with image_urls"),tag:Kg.optional().describe("Subject category; inferred from the primary image when omitted. A video subject is always character"),description:s().max(100).optional(),voice_url:Fe.optional().describe("Reference audio bound to a character subject; not mentionable on its own and outside the voices quota")}),qg=u({name:ul,audio_url:Fe.describe("Reference audio URL; the task fails when no usable voice is detected")}),Ug=u({prompt:cl.describe("Video prompt (1-8000 characters). Mention materials as @image_1, @video_1 or @name; every mention must match a material in this request"),duration:sl.default(5),resolution:al.default("720p"),aspect_ratio:ll.optional().describe("Output aspect ratio; upstream uses auto when any material is provided and 16:9 otherwise"),image_urls:k(Fe).max(10).default([]).describe("Reference images, mentioned as @image_1, @image_2, ... in order; each side 300-65536 px, aspect ratio 0.40-2.5"),video_urls:k(Fe).max(5).default([]).describe("Reference videos of 2-30 s each, mentioned as @video_1, @video_2, ...; at most 5 together with video elements"),keep_original_sound:x().default(!1).describe("Keep the reference videos' audio; applies only with video_urls, otherwise native audio is generated"),elements:k(Fg).max(7).default([]).describe("Subjects for this task, at most 3 of them video subjects"),voices:k(qg).max(3).default([]).describe("Standalone voice references, mentioned as @name")}),Gg=u({model:f("kling-4.0/reference-to-video"),callBackUrl:s().url().optional(),input:Ug}),Lg=Gg.superRefine((n,e)=>{const{input:t}=n,o=(c,p)=>e.addIssue({code:"custom",message:c,path:["input",...p]});t.elements.forEach((c,p)=>{const d=c.video_url!==void 0;d===(c.image_urls!==void 0)&&o("An element takes either 2-4 image_urls or one video_url",["elements",p]),!(c.tag===void 0||c.tag==="character")&&(d?o("A video element is always a character subject",["elements",p,"tag"]):c.voice_url!==void 0&&o("voice_url binds only to a character subject",["elements",p,"voice_url"]))});const i=t.elements.filter(c=>c.video_url!==void 0).length;i>3&&o("At most 3 elements can be video subjects",["elements"]),t.video_urls.length+i>5&&o("video_urls and video elements together cannot exceed 5",["video_urls"]),t.image_urls.length+t.video_urls.length+t.elements.length+t.voices.length>15&&o("image_urls, video_urls, elements and voices together cannot exceed 15",["elements"]);const a=new Set,l=[...t.elements.map((c,p)=>({name:c.name,path:["elements",p,"name"]})),...t.voices.map((c,p)=>({name:c.name,path:["voices",p,"name"]}))];for(const{name:c,path:p}of l)zg.test(c)?o(`${c} is a reserved material name`,p):a.has(c.toLowerCase())&&o(`${c} repeats a name in elements or voices (case-insensitive)`,p),a.add(c.toLowerCase())}),Wg=u({prompt:cl.describe("Video prompt (1-8000 characters). Mention frames as @first_frame, @keyframe_1, ... and @last_frame; only frames in this request can be mentioned"),duration:sl.default(5).describe("Output seconds, 3-30 (default 5). Also caps first + keyframes + last: 3 s allows 4 frames, one more per second, 10 from 9 s"),resolution:al.default("720p"),aspect_ratio:ll.optional().describe("Used only without frames (text-to-video, default 16:9); with frames the output follows the first frame"),first_frame_url:Fe.optional().describe("First-frame image URL, mentioned as @first_frame"),keyframe_urls:k(Fe).max(8).default([]).describe("Middle-frame image URLs in chronological order, mentioned as @keyframe_1, @keyframe_2, ..."),last_frame_url:Fe.optional().describe("Last-frame image URL, mentioned as @last_frame")}),jg=u({model:f("kling-4.0/keyframe-to-video"),callBackUrl:s().url().optional(),input:Wg}),$g=jg.superRefine((n,e)=>{const{input:t}=n,o=(t.first_frame_url===void 0?0:1)+t.keyframe_urls.length+(t.last_frame_url===void 0?0:1),i=Math.min(t.duration+1,10);o>i&&e.addIssue({code:"custom",message:`duration ${t.duration}s allows at most ${i} frames (first + keyframes + last), got ${o}`,path:["input","keyframe_urls"]})});u({resultUrls:k(s().url()).min(1)});const Hg=u({model:f("grok-imagine/text-to-image"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),aspect_ratio:h(["2:3","3:2","1:1","16:9","9:16"]).default("16:9"),nsfw_checker:x().default(!1),enable_pro:x().optional()})}),Jg=u({model:f("qwen2/text-to-image"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(800),image_size:Ff.default("16:9"),seed:y().int().optional(),output_format:h(["jpeg","png"]).default("png"),nsfw_checker:x().default(!1)})}),Qg=u({model:f("qwen2/image-edit"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(800),image_url:s().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:y().multipleOf(1).optional(),nsfw_checker:x().default(!1)})}),pl=h(["1:1","4:3","3:4","3:2","2:3","16:9","9:16","21:9","9:21"]),Xg=h(["1K","2K"]),Yg=h(["opaque","transparent"]),Zg=h(["png","webp","jpeg"]),dl={resolution:Xg.default("1K"),background:Yg.default("opaque"),output_format:Zg.default("png"),enhance_prompt:x().default(!0),seed:y().int().optional(),nsfw_checker:x().default(!1)},e0=u({model:f("qwen2-1/text-to-image"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(5e3),aspect_ratio:pl.default("1:1"),...dl}).strict()}),t0=(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"]}))},n0=u({model:f("qwen2-1/image-to-image"),callBackUrl:s().url().optional(),input:u({image_urls:k(s().url()).min(1).max(10),prompt:s().min(1).max(5e3),mask_url:s().url().optional(),aspect_ratio:P([f("auto"),pl]).default("auto"),...dl}).strict()}).superRefine(t0),ml={prompt:s().max(5e3),image_size:qf.default("16:9"),output_format:Uf.default("png"),prompt_extend:x().default(!0),nsfw_checker:x().default(!1),negative_prompt:s().max(5e3).optional(),seed:y().int().min(0).max(2147483647).default(1)},hl=u({...ml,resolution:Ys.optional()}).strict(),fl=u({...ml,image_urls:k(s().url()).min(1).max(3),resolution:Ys.default("1K")}).strict(),o0=u({model:f("qwen3/text-to-image"),callBackUrl:s().url().optional(),input:hl}),i0=u({model:f("qwen3/image-to-image"),callBackUrl:s().url().optional(),input:fl}),r0=u({model:f("qwen3/pro-text-to-image"),callBackUrl:s().url().optional(),input:hl}),a0=u({model:f("qwen3/pro-image-to-image"),callBackUrl:s().url().optional(),input:fl}),s0=u({model:f("qwen/text-to-image"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(5e3),image_size:Zs.optional(),num_inference_steps:y().min(2).max(250).default(30),seed:y().int().optional(),guidance_scale:y().min(0).max(20).default(2.5),enable_safety_checker:x().optional(),output_format:h(["png","jpeg"]).default("png"),negative_prompt:s().max(500).optional(),acceleration:Ii.default("none"),nsfw_checker:x().default(!1)})}),l0=u({model:f("qwen/image-edit"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(2e3),image_url:s().min(1),acceleration:Ii.default("none"),image_size:Zs.default("landscape_4_3"),num_inference_steps:y().min(2).max(49).default(25),seed:y().int().optional(),guidance_scale:y().min(0).max(20).default(4),sync_mode:x().optional(),num_images:Gf.optional(),enable_safety_checker:x().optional(),output_format:h(["jpeg","png"]).default("png"),negative_prompt:s().max(500).optional(),nsfw_checker:x().default(!1)})}),c0=u({model:f("qwen/image-to-image"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(5e3),image_url:s().min(1),strength:y().min(0).max(1).default(.8),output_format:h(["png","jpeg"]).default("png"),acceleration:Ii.default("none"),negative_prompt:s().max(500).optional(),seed:y().int().optional(),num_inference_steps:y().min(2).max(250).default(30),guidance_scale:y().min(0).max(20).default(2.5),enable_safety_checker:x().optional(),nsfw_checker:x().default(!1)})}),u0=u({model:f("grok-imagine/image-to-image"),callBackUrl:s().optional(),input:u({prompt:s().max(39e4).optional(),image_urls:ua([s()]),nsfw_checker:x().default(!1)})}),p0=u({model:f("grok-imagine/text-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),aspect_ratio:Ef.optional(),mode:Mf.optional(),duration:Nf.optional(),resolution:Js.optional(),nsfw_checker:x().default(!1)})}),d0=u({model:f("grok-imagine/image-to-video"),callBackUrl:s().url().optional(),input:u({prompt:s().max(4096).optional(),image_urls:k(Kf).min(1).max(7,"grok-imagine/image-to-video accepts at most 7 image_urls").optional(),task_id:s().min(1).max(100).optional(),index:y().int().min(0).max(5).default(0),mode:Of.default("normal"),duration:Df.default(6),resolution:Js.default("480p"),aspect_ratio:Af.default("16:9"),nsfw_checker:x().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"]})}),m0=u({url:s().describe("Keyframe image URL"),timestamp_s:y().positive().describe("Seconds into the video, greater than 0 and less than duration; keyframes at least 1/3 s apart")}),h0=u({prompt:s().max(4096).optional(),image_urls:k(s()).min(1),aspect_ratio:zf.default("auto"),resolution:Qs.default("480p"),duration:y().int().min(1).max(15).default(8),first_frame_url:s().optional().describe("First-frame image URL; can be sent with image_urls"),last_frame_url:s().optional().describe("Last-frame image URL"),loop_url:s().optional().describe("One image URL used as both the first and the last frame; cannot be combined with a different first_frame_url or last_frame_url"),keyframes:k(m0).max(4).optional().describe("Up to 4 mid-video keyframes, each an image url pinned at timestamp_s seconds"),enable_audio:x().default(!0).describe("Generate an audio track (default true; false returns a video without one)"),nsfw_checker:x().default(!0)}),f0=u({model:f("grok-imagine-video-1-5-preview"),callBackUrl:s().optional(),input:h0}).superRefine((n,e)=>{const{duration:t,keyframes:o=[],loop_url:i}=n.input;o.forEach(({timestamp_s:a},l)=>{a>=t&&e.addIssue({code:"custom",message:`keyframe timestamp_s must be less than duration (${t}s)`,path:["input","keyframes",l,"timestamp_s"]})});const r=o.map(({timestamp_s:a})=>a).sort((a,l)=>a-l);r.some((a,l)=>l>0&&a-r[l-1]<1/3-1e-9)&&e.addIssue({code:"custom",message:"keyframes must be at least 1/3 second apart",path:["input","keyframes"]});for(const a of["first_frame_url","last_frame_url"]){const l=n.input[a];i!==void 0&&l!==void 0&&l!==i&&e.addIssue({code:"custom",message:`loop_url cannot be combined with a different ${a}`,path:["input",a]})}}),g0=u({model:f("grok-imagine/extend"),callBackUrl:s().optional(),resolution:Qs.optional(),input:u({task_id:s().min(1).max(100),prompt:s().min(1).max(5e3),extend_at:y().min(0),extend_times:Bf})}),x0=u({model:f("grok-imagine/upscale"),callBackUrl:s().optional(),input:u({task_id:s().min(1).max(100)})}),y0=u({model:f("grok-imagine-image-2-0/text-to-image"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1),aspect_ratio:h(["1:1","2:3","3:2","16:9","9:16"])}).strict()}),b0=u({model:f("grok-imagine-image-2-0/segment-map"),callBackUrl:s().url().optional(),input:u({task_id:s().min(1)}).strict()}),S0=u({model:f("grok-imagine-image-2-0/image-edit"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1),task_id:s().min(1),mask_indexs:k(y().int().min(0)).min(1).optional()}).strict()}),k0=u({model:f("grok-imagine-image-2-0/segment-edit"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1),task_id:s().min(1),mask_indexs:k(y().int().min(1)).min(1).optional()}).strict()}),_0=u({model:f("nano-banana-pro"),callBackUrl:s().optional(),input:u({prompt:s().min(1),image_input:k(s()).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:wi.default("2K"),output_format:Ti.optional()})}),w0=u({prompt:s().min(3).max(2e4),first_frame_url:s().optional(),last_frame_url:s().optional(),reference_image_urls:k(s()).max(9).optional(),reference_video_urls:k(s()).max(3).optional(),reference_audio_urls:k(s()).max(3).optional(),return_last_frame:x().optional(),generate_audio:x().optional(),resolution:h(["480p","720p"]).optional(),aspect_ratio:h(["1:1","4:3","3:4","16:9","9:16","21:9","adaptive"]).optional(),duration:y().int().min(4).max(15).default(5),web_search:x().optional(),nsfw_checker:x().default(!1)}),T0=u({model:f("bytedance/seedance-2-fast"),callBackUrl:s().optional(),input:w0}),I0=T0.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"]}),R0=u({prompt:s().min(3).max(2e4),first_frame_url:s().optional(),last_frame_url:s().optional(),reference_image_urls:k(s()).max(9).optional(),reference_video_urls:k(s()).max(3).optional(),reference_audio_urls:k(s()).max(3).optional(),return_last_frame:x().optional(),generate_audio:x().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:y().int().min(4).max(15).default(5),web_search:x().optional(),nsfw_checker:x().default(!1)}),C0=u({model:f("bytedance/seedance-2"),callBackUrl:s().optional(),input:R0}),v0=C0.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"]}),Ft=s().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"),M0=u({prompt:s().max(3e4).optional(),first_frame_url:Ft.optional(),last_frame_url:Ft.optional(),reference_image_urls:k(Ft).max(30).optional(),reference_video_urls:k(Ft).max(10).optional(),reference_audio_urls:k(Ft).max(10).optional(),return_last_frame:x().default(!1),generate_audio:x().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),y().int().min(4).max(30)]).default(5),output_format:h(["mp4","mov"]).default("mp4"),web_search:x().optional(),draft:x().default(!1),nsfw_checker:x().default(!1)}),O0=u({model:f("bytedance/seedance-2-5"),callBackUrl:s().url().optional(),input:M0}),E0=O0.superRefine((n,e)=>{const{input:t}=n;t.draft&&t.resolution!=="480p"&&e.addIssue({code:"custom",message:"Seedance 2.5 draft mode requires 480p resolution",path:["input","resolution"]});const 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 a of["reference_image_urls","reference_video_urls","reference_audio_urls"])(t[a]?.length??0)>0&&e.addIssue({code:"custom",message:`${a} cannot be combined with first_frame_url or last_frame_url`,path:["input",a]})}}),A0=u({draft_task_id:s().min(1),resolution:f("1080p"),output_format:h(["mp4","mov"]).optional(),return_last_frame:x().default(!1),nsfw_checker:x().default(!1)}),N0=u({model:f("bytedance/seedance-2-5-draft"),callBackUrl:s().url().optional(),input:A0}),D0=u({prompt:s().max(2e4).optional(),reference_image_urls:k(s()).max(9).default([]),reference_video_urls:k(s()).max(3).default([]),reference_audio_urls:k(s()).max(3).default([]),generate_audio:x().default(!0),resolution:tg.default("720p"),aspect_ratio:ng.default("16:9"),duration:y().int().min(4).max(15).default(5),web_search:x().default(!1),nsfw_checker:x().default(!0)}),B0=u({model:f("bytedance/seedance-2-mini"),callBackUrl:s().url().optional(),input:D0}),V0=h(["1:1","4:3","3:4","16:9","9:16","21:9"]),P0=h(["480p","720p","1080p"]),K0=u({prompt:s().min(3).max(2e4),input_urls:k(s()).max(2).optional(),aspect_ratio:V0,resolution:P0.default("720p"),duration:y().int().min(4).max(12),fixed_lens:x().default(!1),generate_audio:x().default(!1),nsfw_checker:x().default(!1)}),z0=u({model:f("bytedance/seedance-1.5-pro"),callBackUrl:s().optional(),input:K0}),F0=h(["square","square_hd","portrait_4_3","portrait_16_9","landscape_4_3","landscape_16_9"]),q0=u({prompt:s().min(3).max(5e3),image_size:F0.default("square_hd"),guidance_scale:y().min(1).max(10).default(2.5),seed:y().int().optional()}),U0=u({model:f("bytedance/seedream"),callBackUrl:s().optional(),input:q0}),gl=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"]),xl=h(["1K","2K","4K"]),G0=u({prompt:s().min(3).max(5e3),image_size:gl.default("square_hd"),image_resolution:xl.default("1K"),max_images:y().int().min(1).max(6).default(1),seed:y().int().optional(),nsfw_checker:x().default(!1)}),L0=u({model:f("bytedance/seedream-v4-text-to-image"),callBackUrl:s().optional(),input:G0}),W0=u({prompt:s().min(3).max(5e3),image_urls:k(s()).min(1).max(10),image_size:gl.default("square_hd"),image_resolution:xl.default("1K"),max_images:y().int().min(1).max(6).default(1),seed:y().int().optional(),nsfw_checker:x().default(!1)}),j0=u({model:f("bytedance/seedream-v4-edit"),callBackUrl:s().optional(),input:W0}),hn=h(["5","10"]),so=h(["480p","720p","1080p"]),$0=h(["720p","1080p"]),H0=h(["16:9","4:3","1:1","3:4","9:16","9:21"]),J0=h(["21:9","16:9","4:3","1:1","3:4","9:16"]),lo=y().int().min(-1).max(2147483647).optional(),Q0=u({prompt:s().min(3).max(1e4),image_url:s().min(1),resolution:so.default("720p"),duration:hn.default("5"),camera_fixed:x().optional(),seed:lo,enable_safety_checker:x().optional(),end_image_url:s().optional(),nsfw_checker:x().default(!1)}),X0=u({model:f("bytedance/v1-lite-image-to-video"),callBackUrl:s().optional(),input:Q0}),Y0=u({prompt:s().min(3).max(1e4),aspect_ratio:H0.default("16:9"),resolution:so.default("720p"),duration:hn.default("5"),camera_fixed:x().optional(),seed:lo,enable_safety_checker:x().optional(),nsfw_checker:x().default(!1)}),Z0=u({model:f("bytedance/v1-lite-text-to-video"),callBackUrl:s().optional(),input:Y0}),e1=u({prompt:s().min(3).max(1e4),image_url:s().min(1),resolution:$0.default("720p"),duration:hn.default("5"),nsfw_checker:x().default(!1)}),t1=u({model:f("bytedance/v1-pro-fast-image-to-video"),callBackUrl:s().optional(),input:e1}),n1=u({prompt:s().min(3).max(1e4),image_url:s().min(1),resolution:so.default("720p"),duration:hn.default("5"),camera_fixed:x().optional(),seed:lo,enable_safety_checker:x().optional(),nsfw_checker:x().default(!1)}),o1=u({model:f("bytedance/v1-pro-image-to-video"),callBackUrl:s().optional(),input:n1}),i1=u({prompt:s().min(3).max(1e4),aspect_ratio:J0.default("16:9"),resolution:so.default("720p"),duration:hn.default("5"),camera_fixed:x().optional(),seed:lo,enable_safety_checker:x().optional(),nsfw_checker:x().default(!1)}),r1=u({model:f("bytedance/v1-pro-text-to-video"),callBackUrl:s().optional(),input:i1}),a1=u({model:f("nano-banana-2"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(2e4),image_input:k(s().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:wi.default("1K"),output_format:Ti.default("jpg")})}),yl=h(["540p","720p","1080p","2k","4k"]),bl=y().int().min(3).max(16),oi=s().refine(n=>{try{return["http:","https:"].includes(new URL(n).protocol)}catch{return!1}},"Expected an HTTP(S) media URL"),s1=u({model:f("vidu-q4/image-to-video"),callBackUrl:s().url().optional(),input:u({image_url:oi.describe("JPG/JPEG/PNG/WEBP image, up to 50 MB; output inherits its aspect ratio"),prompt:s().max(2e4).optional(),duration:bl.default(5),resolution:yl.default("720p"),audio:x().default(!0)})}),l1=h(["16:9","9:16","1:1","4:3","3:4"]),c1=u({model:f("vidu-q4/reference-to-video"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(2e4),reference_image_urls:k(oi).min(1).max(15).describe("JPG/JPEG/PNG/WEBP reference images, referenced in prompt by order"),reference_audio_urls:k(oi).max(3).optional().describe("MP3 references, 3-12 seconds each, up to 50 MB"),aspect_ratio:l1.default("16:9"),duration:bl.default(5),resolution:yl.default("720p"),audio:x().default(!0)})}),u1=u({model:f("nano-banana-2-1"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(2e4),image_input:k(s().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:wi.default("1K"),output_format:Ti.default("jpg")})}),p1=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"]),d1=u({model:f("nano-banana-2-lite"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(2e4),image_urls:k(s()).max(10).optional(),aspect_ratio:p1.default("auto")})}),m1=u({model:f("gpt-image/1.5-image-to-image"),callBackUrl:s().optional(),input:u({input_urls:k(s()).min(1).max(4),prompt:s().min(1),aspect_ratio:h(["1:1","2:3","3:2"]).optional(),quality:Xs.optional()})}),h1=h(["1:1","2:3","3:2"]),f1=u({model:f("gpt-image/1.5-text-to-image"),callBackUrl:s().optional(),input:u({prompt:s().min(1),aspect_ratio:h1,quality:Xs})}),g1=h(["auto","1:1","5:4","9:16","21:9","16:9","4:3","3:2","4:5","3:4","2:3"]),x1=h(["1K","2K","4K"]),y1=u({model:f("gpt-image-2-image-to-image"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(2e4),input_urls:k(s()).min(1).max(16),aspect_ratio:g1.default("auto"),resolution:x1.default("1K"),nsfw_checker:x().default(!1)})}),b1=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"]),S1=h(["1K","2K","4K"]),k1=u({model:f("gpt-image-2-text-to-image"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(2e4),aspect_ratio:b1.default("auto"),resolution:S1.default("1K"),nsfw_checker:x().default(!1)})}),co=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"]),uo=h(["1K","2K","4K"]),po=h(["transparent","opaque","auto"]),_1=new Set(["27:16","16:27","9:8","8:9"]),mo=(n,e)=>{_1.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"]})},w1=u({model:f("gpt-image-2-5-flare-text-to-image"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(2e4),aspect_ratio:co.default("auto"),resolution:uo.default("1K"),background:po.optional()})}).superRefine(mo),T1=u({model:f("gpt-image-2-5-flare-image-to-image"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(2e4),input_urls:k(s()).min(1).max(16),aspect_ratio:co.default("auto"),resolution:uo.default("1K"),background:po.optional()})}).superRefine(mo),I1=u({model:f("gpt-image-2-5-sunburst-text-to-image"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(2e4),aspect_ratio:co.default("auto"),resolution:uo.default("1K"),background:po.optional()})}).superRefine(mo),R1=u({model:f("gpt-image-2-5-sunburst-image-to-image"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(2e4),input_urls:k(s()).min(1).max(16),aspect_ratio:co.default("auto"),resolution:uo.default("1K"),background:po.optional()})}).superRefine(mo),C1=u({model:f("seedream/5-lite-image-to-image"),callBackUrl:s().optional(),input:u({image_urls:k(s()).min(1).max(14),prompt:s().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:x().default(!1)})}),v1=u({model:f("seedream/5-lite-text-to-image"),callBackUrl:s().optional(),input:u({prompt:s().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:x().default(!1)})}),M1=u({model:f("seedream/5-pro-image-to-image"),callBackUrl:s().optional(),input:u({image_urls:k(s()).min(1).max(10),prompt:s().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:x().default(!1)})}),O1=u({model:f("seedream/5-pro-text-to-image"),callBackUrl:s().optional(),input:u({prompt:s().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:x().default(!1)})}),E1=u({model:f("seedream/5-flash-text-to-image"),callBackUrl:s().url().optional(),input:u({prompt:s().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:x().optional()})}),A1=u({model:f("seedream/5-flash-image-to-image"),callBackUrl:s().url().optional(),input:u({image_urls:k(s().url()).min(1).max(10),prompt:s().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:x().optional()})}),N1=u({model:f("seedream/5-pro-layer-decomposition"),callBackUrl:s().optional(),input:u({image_url:s().url(),prompt:s().max(5e3).optional(),size:h(["auto","1K","1.5K","2K"]).default("auto"),output_format:h(["png","jpeg"]).default("jpeg")})}),D1=u({model:f("seedream/5-flash-layer-decomposition"),callBackUrl:s().url().optional(),input:u({image_url:s().url(),prompt:s().min(3).max(5e3).optional(),size:h(["auto","1K","1.5K","2K"]).default("auto"),output_format:h(["png","jpeg"]).default("jpeg"),nsfw_checker:x().optional()})}),B1=u({model:f("seedream/4.5-text-to-image"),callBackUrl:s().optional(),input:u({prompt:s().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:x().default(!1)})}),V1=u({model:f("seedream/4.5-edit"),callBackUrl:s().optional(),input:u({prompt:s().min(3).max(3e3),image_urls:k(s()).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:x().default(!1)})}),P1=u({model:f("recraft/crisp-upscale"),callBackUrl:s().url().optional(),input:u({image:s().min(1)})}),K1=u({model:f("recraft/remove-background"),callBackUrl:s().url().optional(),input:u({image:s().min(1)})}),z1=u({model:f("happyhorse/text-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),resolution:bt.optional(),aspect_ratio:el.optional(),duration:At.optional(),seed:y().int().min(0).max(2147483647).optional()})}),F1=u({model:f("happyhorse/image-to-video"),callBackUrl:s().optional(),input:u({prompt:s().max(5e3).optional(),image_urls:k(s()).min(1).max(1),resolution:bt.optional(),duration:At.optional(),seed:y().int().min(0).max(2147483647).optional()})}),q1=u({model:f("happyhorse/reference-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),reference_image:k(s()).min(1).max(9),resolution:bt.optional(),aspect_ratio:el.optional(),duration:At.optional(),seed:y().int().min(0).max(2147483647).optional()})}),U1=u({model:f("happyhorse/video-edit"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),video_url:s().min(1),reference_image:k(s()).max(5).optional(),resolution:bt.optional(),audio_setting:Hf.optional(),seed:y().int().min(0).max(2147483647).optional()})}),G1=u({model:f("happyhorse-1-1/text-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),resolution:bt.default("1080p"),aspect_ratio:tl.default("16:9"),duration:At.default(5)})}),L1=u({model:f("happyhorse-1-1/image-to-video"),callBackUrl:s().optional(),input:u({prompt:s().max(5e3).default(""),image_urls:k(s().url()).min(1).max(1),resolution:bt.default("1080p"),duration:At.default(5)})}),W1=u({model:f("happyhorse-1-1/reference-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),reference_image:k(s().url()).min(1).max(9),resolution:bt.default("1080p"),aspect_ratio:tl.default("16:9"),duration:At.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 j1=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:s(),data:u({taskId:s()})}),u({code:j1,msg:s(),data:K().optional()})]);const $1=u({model:f("omnihuman-1-5"),callBackUrl:s().url().optional(),input:u({image_url:s().url(),mask_url:k(s().url()).max(5).optional(),audio_url:s().url(),prompt:s().max(1e3).optional(),output_resolution:Xf.default("1080"),pe_fast_mode:x().default(!1),seed:y().int().min(-1).default(-1)})}),H1=u({model:f("omnihuman-1-5/human-identification"),callBackUrl:s().url().optional(),input:u({image_url:s().url()})}),J1=u({model:f("omnihuman-1-5/subject-detection"),callBackUrl:s().url().optional(),input:u({image_url:s().url()})}),Q1=u({image_urls:k(s().url()).min(1).max(1).describe("Exactly one source image URL (jpeg, png, webp, bmp, tiff, gif, heic or heif; under 30 MB; aspect ratio 0.4-2.5; each side 300-6000 px)"),audio_url:s().url().describe("Driving audio URL for motion and lip sync (wav or mp3, 4-300 seconds, under 15 MB); the video length follows the audio"),prompt:s().max(300).optional().describe("Optional scene, motion and camera direction, up to 300 characters (Chinese, English, Japanese, Korean, Mexican Spanish or Indonesian)"),enable_watermark:x().default(!0).describe("Add a watermark to the output video (default true)")}),X1=u({model:f("omnihuman-2-0"),callBackUrl:s().url().optional(),input:Q1});u({resultUrls:k(s().url()).min(1)});const Y1=u({model:f("volcengine/video-to-video-lip-sync"),callBackUrl:s().optional(),input:u({mode:Yf,video_url:s().min(1),audio_url:s().min(1),separate_vocal:x().default(!1),open_scenedet:x().default(!1),align_audio:x().default(!0),align_audio_reverse:x().default(!1),templ_start_seconds:y().min(0).default(0)})}),Z1=u({url:s().url(),start:y().min(0),ends:y().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"]})}),ex=u({model:f("gemini-omni-video"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(2e4),image_urls:k(s().url()).max(7).optional(),audio_ids:k(s().min(1)).max(3).optional(),video_list:k(Z1).max(1).optional(),character_ids:k(s().min(1)).max(3).optional(),duration:nl,aspect_ratio:ol.optional(),seed:y().int().min(0).max(2147483647).optional(),resolution:Zf.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"]})}),tx=u({url:s().url(),start:y().min(0),ends:y().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"]})}),nx=u({model:f("google/gemini-omni-flash-1-1"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(2e4),image_urls:k(s().url()).max(7).optional(),first_frame_url:s().url().optional(),last_frame_url:s().url().optional(),audio_ids:k(s().min(1)).max(3).optional(),video_list:k(tx).max(1).optional(),character_ids:k(s().min(1)).max(7).optional(),duration:nl,aspect_ratio:ol.optional(),seed:y().int().min(0).max(2147483647).optional(),resolution:eg.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}},vn={values:[0,.5,1],default:.5},Sl=u({text:s().min(1),voice:s().min(1),stability:y().min(fe.stability.minimum).max(fe.stability.maximum).default(fe.stability.default),similarity_boost:y().min(fe.similarity_boost.minimum).max(fe.similarity_boost.maximum).default(fe.similarity_boost.default),style:y().min(fe.style.minimum).max(fe.style.maximum).default(fe.style.default),speed:y().min(fe.speed.minimum).max(fe.speed.maximum).default(fe.speed.default),timestamps:x().optional(),previous_text:s().optional(),next_text:s().optional(),language_code:s().optional()}),ox=u({model:f("elevenlabs/audio-isolation"),callBackUrl:s().optional(),input:u({audio_url:s().min(1)})}),ix=u({model:f("elevenlabs/text-to-dialogue-v3"),callBackUrl:s().optional(),input:u({dialogue:k(u({text:s().min(1),voice:s().min(1)})).min(1),stability:P([f(vn.values[0]),f(vn.values[1]),f(vn.values[2])]).default(vn.default)})}),rx=u({model:f("elevenlabs/text-to-speech-multilingual-v2"),callBackUrl:s().optional(),input:Sl}),ax=u({model:f("elevenlabs/text-to-speech-turbo-2-5"),callBackUrl:s().optional(),input:Sl}),sx=u({model:f("elevenlabs/sound-effect-v2"),callBackUrl:s().optional(),input:u({text:s(),loop:x().optional(),prompt_influence:y().optional(),output_format:s().optional()})}),lx=h(["480P","720P","1080P"]),cx=h(["adaptive","16:9","4:3","1:1","3:4","9:16"]),ux=P([f(-1),y().int().min(2).max(30)]),kl={prompt:s().max(2e4).optional(),first_frame_url:s().optional(),last_frame_url:s().optional(),reference_image_urls:k(s()).max(10).optional(),reference_video_urls:k(s()).max(5).optional(),reference_audio_urls:k(s()).max(5).optional(),reference_file_urls:k(s()).max(1).optional(),reference_link_urls:k(s()).max(1).optional(),resolution:lx.optional(),aspect_ratio:cx.optional(),duration:ux.optional(),audio:x().optional(),seed:y().int().min(0).max(2147483647).optional(),nsfw_checker:x().default(!1)},px=u({model:f("wan/3-0-video"),callBackUrl:s().optional(),input:u(kl)}).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"]}),dx=u({model:f("wan/3-0-video-prime"),callBackUrl:s().optional(),input:u(kl)}).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"]}),mx=u({model:f("wan/2-7-image-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),negative_prompt:s().max(500).optional(),first_frame_url:s().optional(),last_frame_url:s().optional(),first_clip_url:s().optional(),driving_audio_url:s().optional(),resolution:oo.optional(),duration:y().int().min(2).max(15).optional(),prompt_extend:x().optional(),watermark:x().optional(),seed:y().int().min(0).max(2147483647).optional(),nsfw_checker:x().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"]}),hx=u({model:f("wan/2-7-text-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),negative_prompt:s().max(500).optional(),audio_url:s().optional(),resolution:oo.optional(),ratio:Ri.optional(),duration:y().int().min(2).max(15).optional(),prompt_extend:x().optional(),watermark:x().optional(),seed:y().int().min(0).max(2147483647).optional(),nsfw_checker:x().default(!1)})}),fx=u({model:f("wan/2-7-r2v"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),negative_prompt:s().max(500).optional(),reference_image:k(s()).max(5).optional(),reference_video:k(s()).max(5).optional(),first_frame:s().optional(),reference_voice:s().optional(),resolution:oo.optional(),aspect_ratio:Ri.optional(),duration:y().int().min(2).max(10).optional(),prompt_extend:x().optional(),watermark:x().optional(),seed:y().int().min(0).max(2147483647).optional(),nsfw_checker:x().default(!1)})}),gx=u({model:f("wan/2-7-videoedit"),callBackUrl:s().optional(),input:u({prompt:s().max(5e3).optional(),negative_prompt:s().max(500).optional(),video_url:s().min(1),reference_image:s().optional(),resolution:oo.optional(),aspect_ratio:Ri.optional(),duration:$f.optional(),audio_setting:Lf.optional(),prompt_extend:x().optional(),watermark:x().optional(),seed:y().int().min(0).max(2147483647).optional(),nsfw_checker:x().default(!1)})}),xx={prompt:s().min(1).max(5e3),input_urls:k(s()).max(9).optional(),aspect_ratio:jf.default("16:9"),enable_sequential:x().optional(),n:y().int().min(1).max(12).optional(),resolution:Wf.optional(),thinking_mode:x().optional(),color_palette:k(ug).min(3).max(10).optional(),bbox_list:k(k(k(y().multipleOf(1)).length(4)).max(2)).optional(),watermark:x().optional(),seed:y().int().min(0).max(2147483647).optional(),nsfw_checker:x().default(!1)},_l=n=>n.input.aspect_ratio===void 0||n.input.resolution!==void 0,wl={message:"aspect_ratio requires resolution",path:["input","resolution"]},Tl=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)},Il={message:"resolution 4K is only supported for non-sequential text-to-image",path:["input","resolution"]},Rl=u(xx),yx=u({model:f("wan/2-7-image"),callBackUrl:s().optional(),input:Rl}),bx=u({model:f("wan/2-7-image-pro"),callBackUrl:s().optional(),input:Rl}),Sx=yx.refine(_l,wl).refine(Tl,Il),kx=bx.refine(_l,wl).refine(Tl,Il),Cl=h(["480p","720p"]),vl=h(["none","regular"]),_x=h(["16:9","9:16"]),Bi=h(["480p","580p","720p"]),Ml=h(["5","10"]),Ol=h(["720p","1080p"]),wx=h(["16:9","9:16","1:1"]),Vi=h(["5","10","15"]),El=h(["5","10"]),fn=h(["720p","1080p"]),Al=y().int().min(0).max(2147483647).optional(),Tx=y().int().min(40).max(120).refine(n=>n%4===0,{message:"must be a multiple of 4"}),Yr=n=>y().min(1).max(10).refine(e=>Number.isInteger(e*10),{message:"must be in increments of 0.1"}).default(n),Ix=u({model:f("wan/2-2-a14b-image-to-video-turbo"),callBackUrl:s().optional(),input:u({image_url:s().min(1),prompt:s().min(1).max(5e3),resolution:Cl.default("720p"),enable_prompt_expansion:x().optional(),seed:Al,acceleration:vl.default("none"),nsfw_checker:x().default(!1)})}),Rx=u({model:f("wan/2-2-a14b-speech-to-video-turbo"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),image_url:s().min(1),audio_url:s().min(1),num_frames:Tx.default(80),frames_per_second:y().int().min(4).max(60).default(16),resolution:Bi.default("480p"),negative_prompt:s().max(500).optional(),seed:y().int().optional(),num_inference_steps:y().int().min(2).max(40).default(27),guidance_scale:Yr(3.5),shift:Yr(5),nsfw_checker:x().default(!1)})}),Cx=u({model:f("wan/2-2-a14b-text-to-video-turbo"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),resolution:Cl.default("720p"),aspect_ratio:_x.default("16:9"),enable_prompt_expansion:x().optional(),seed:Al,acceleration:vl.default("none"),nsfw_checker:x().default(!1)})}),vx=u({model:f("wan/2-2-animate-move"),callBackUrl:s().optional(),input:u({video_url:s().min(1),image_url:s().min(1),resolution:Bi.default("480p"),nsfw_checker:x().default(!1)})}),Mx=u({model:f("wan/2-2-animate-replace"),callBackUrl:s().optional(),input:u({video_url:s().min(1),image_url:s().min(1),resolution:Bi.default("480p"),nsfw_checker:x().default(!1)})}),Ox=u({model:f("wan/2-5-image-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(800),image_url:s().min(1),duration:Ml,resolution:Ol.optional(),negative_prompt:s().max(500).optional(),enable_prompt_expansion:x().optional(),seed:y().int().optional(),nsfw_checker:x().default(!1)})}),Ex=u({model:f("wan/2-5-text-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(800),duration:Ml,aspect_ratio:wx.optional(),resolution:Ol.optional(),negative_prompt:s().max(500).optional(),enable_prompt_expansion:x().optional(),seed:y().int().optional(),nsfw_checker:x().default(!1)})}),Ax=u({model:f("wan/2-6-flash-image-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(2).max(1500),image_urls:k(s().min(1)).min(1).max(1),duration:Vi.default("5"),resolution:fn.default("1080p"),audio:x(),multi_shots:x().optional(),nsfw_checker:x().default(!1)})}),Nx=u({model:f("wan/2-6-flash-video-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(2).max(1500),video_urls:k(s().min(1)).min(1).max(3),duration:El.default("5"),resolution:fn.default("1080p"),audio:x().optional(),multi_shots:x().optional(),nsfw_checker:x().default(!1)})}),Dx=u({model:f("wan/2-6-image-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(2).max(5e3),image_urls:k(s().min(1)).min(1).max(1),duration:Vi.default("5"),resolution:fn.default("1080p"),multi_shots:x().default(!1),nsfw_checker:x().default(!1)})}),Bx=u({model:f("wan/2-6-text-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),duration:Vi.default("5"),resolution:fn.default("1080p"),multi_shots:x().default(!1),nsfw_checker:x().default(!1)})}),Vx=u({model:f("wan/2-6-video-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(2).max(5e3),video_urls:k(s().min(1)).min(1).max(3),duration:El.default("5"),resolution:fn.default("1080p"),multi_shots:x().default(!1),nsfw_checker:x().default(!1)})}),gn=s().min(3).max(5e3),Dt=h(["360p","540p","720p","1080p"]),Pi=h(["16:9","4:3","1:1","3:4","9:16","2:3","3:2","21:9"]),Bt=y().int().min(1).max(15),Vt=y().int().min(0).max(2147483647),Px=u({prompt:gn,aspect_ratio:Pi,quality:Dt,duration:Bt,generate_audio_switch:x().default(!1),generate_multi_clip_switch:x().default(!1),seed:Vt.optional()}),Kx=u({model:f("pixverse-v6/text-to-video"),callBackUrl:s().url().optional(),input:Px}),zx=u({prompt:gn,image_urls:k(s().url()).min(1).max(2),quality:Dt,duration:Bt.optional(),template_id:s().min(1).optional(),generate_audio_switch:x().default(!1),generate_multi_clip_switch:x().default(!1),seed:Vt.optional()}),Fx=u({model:f("pixverse-v6/image-to-video"),callBackUrl:s().url().optional(),input:zx}).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"]}),n.input.image_urls.length>1&&!o&&e.addIssue({code:"custom",message:"template_id cannot be empty when multiple image_urls are provided",path:["input","template_id"]})}),qx=u({prompt:gn,first_frame_image_url:s().url(),last_frame_image_url:s().url(),quality:Dt,duration:Bt,generate_audio_switch:x().default(!1),seed:Vt.optional()}),Ux=u({model:f("pixverse-v6/transition"),callBackUrl:s().url().optional(),input:qx}),Gx=u({prompt:gn,duration:Bt,quality:Dt,taskId:s().min(1).optional(),video_url:s().url().optional(),generate_audio_switch:x().optional(),seed:Vt.optional()}),Lx=u({model:f("pixverse-v6/extend"),callBackUrl:s().url().optional(),input:Gx}).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"]})}),Wx=u({image_url:s().url(),type:h(["subject","background"]).default("subject"),ref_name:s().min(1).max(30).optional()}),jx=u({prompt:gn,image_references:k(Wx).min(1).max(7),aspect_ratio:Pi,quality:Dt,duration:Bt,generate_audio_switch:x().default(!1),seed:Vt.optional()}),$x=u({model:f("pixverse-v6/reference-to-video"),callBackUrl:s().url().optional(),input:jx}).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))}}),Nl=s().min(1).max(5e3).describe("Generation prompt (1-5000 characters)"),Dl=Dt.describe("Output resolution: 360p, 540p, 720p or 1080p"),Bl=Bt.describe("Output length in seconds, 1-15"),Vl=x().default(!1).describe("Generate native audio synchronized with the video (default false)"),Pl=Vt.describe("Random seed, 0-2147483647; omit it for a random seed"),Hx=u({prompt:Nl,aspect_ratio:Pi.describe("Output aspect ratio"),quality:Dl,duration:Bl,generate_audio_switch:Vl,seed:Pl.optional()}),Jx=u({model:f("pixverse-v6-max/text-to-video"),callBackUrl:s().url().optional(),input:Hx}),Qx=u({prompt:Nl,image_urls:k(s().url()).min(1).max(1).describe("Exactly one first-frame image URL (HTTP, HTTPS or OSS; JPG, JPEG, PNG or WebP, each side at most 10,000 px, at most 20 MB). The output aspect ratio follows this image"),aspect_ratio:bc({error:"pixverse-v6-max/image-to-video takes its aspect ratio from the source image; do not send aspect_ratio"}).optional().describe("Not accepted: the output aspect ratio follows the source image"),quality:Dl,duration:Bl,generate_audio_switch:Vl,seed:Pl.optional()}),Xx=u({model:f("pixverse-v6-max/image-to-video"),callBackUrl:s().url().optional(),input:Qx});u({resultUrls:k(s().url()).min(1)});const Yx=u({prompt:Ci,aspect_ratio:il,duration:vi,resolution:Mi.optional()}).strict(),Zx=u({model:f("minimax-h3/text-to-video"),callBackUrl:s().url().optional(),input:Yx}),ey=u({prompt:Ci,first_frame_url:Qt.optional(),last_frame_url:Qt.optional(),duration:vi,resolution:Mi.optional()}).strict(),ty=u({model:f("minimax-h3/image-to-video"),callBackUrl:s().url().optional(),input:ey}).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"]})}),ny=u({prompt:Ci,reference_image_urls:k(Qt).max(9).optional(),reference_video_urls:k(Qt).max(3).optional().describe(`MP4/MOV reference videos. ${Xr(Qr.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(Qt).max(3).optional().describe(`WAV/MP3 reference audio; it cannot be the sole reference. ${Xr(Qr.audio)}, as documented upstream but not yet observed at runtime. URLs are not inspected locally, so check local media against MiniMaxH3ReferenceClipDurationMs.audio.`),aspect_ratio:ig.optional(),duration:vi,resolution:Mi.optional()}).strict(),oy=u({model:f("minimax-h3/reference-to-video"),callBackUrl:s().url().optional(),input:ny}).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"]})}),iy=u({speaker_id:Yn,voice_name:Sm,audio_profile:s().optional(),accent:km,style:_m.optional(),pace:wm.optional()}).strict(),ry=u({speaker_id:Yn,text:s().min(1).max(Tm)}).strict(),Kl=u({temperature:y().min(Jr.minimum).max(Jr.maximum).optional(),scene:s().optional(),sample_context:s().optional(),speakers:k(iy).min(1),dialogue_turns:k(ry).min(1)}).strict(),ay=u({model:f("google/gemini-2-5-pro-tts"),callBackUrl:s().url().optional(),input:Kl}),sy=u({model:f("google/gemini-3-1-flash-tts"),callBackUrl:s().url().optional(),input:Kl}),ly=["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"],cy=h(ly),uy=u({speaker_id:Yn,voice_name:cy.default("Fola")}).strict(),py=u({speaker_id:Yn,text:s().min(1).max(1e4),style:s().optional()}).strict(),zl=u({temperature:y().min(0).max(2).default(1),speakers:k(uy).min(1),filler_words:x().default(!1),dialogue_turns:k(py).min(1)}).strict(),dy=u({model:f("google/gemini-3-8-flash-tts"),callBackUrl:s().url().optional(),input:zl}),my=u({model:f("google/gemini-3-8-flash-lite-tts"),callBackUrl:s().url().optional(),input:zl}),Fl=h(["1:1","16:9","9:16","3:4","4:3","auto"]),ql=u({prompt:s().min(1).max(5e3),negative_prompt:s().max(5e3).optional(),aspect_ratio:Fl.optional(),seed:s().max(500).optional()}),hy=u({prompt:s().min(1).max(5e3),negative_prompt:s().max(5e3).optional(),aspect_ratio:Fl.optional(),seed:y().int().optional()}),fy=u({model:f("google/imagen4"),callBackUrl:s().optional(),input:ql}),gy=u({model:f("google/imagen4-fast"),callBackUrl:s().optional(),input:hy}),xy=u({model:f("google/imagen4-ultra"),callBackUrl:s().optional(),input:ql}),Wn=h(["1:1","9:16","16:9","3:4","4:3","3:2","2:3","5:4","4:5","21:9","auto"]),Ul=h(["png","jpeg"]),yy=u({model:f("google/nano-banana"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),output_format:Ul.optional(),aspect_ratio:Wn.optional(),image_size:Wn.optional(),nsfw_checker:x().optional()})}),by=u({model:f("google/nano-banana-edit"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),image_urls:k(s()).min(1).max(10),output_format:Ul.optional(),aspect_ratio:Wn.optional(),image_size:Wn.optional()})}),Gl=h(["1","2","4"]),Sy=u({model:f("topaz/image-upscale"),callBackUrl:s().optional(),input:u({image_url:s().min(1),upscale_factor:Gl})}),ky=u({model:f("topaz/video-upscale"),callBackUrl:s().optional(),input:u({video_url:s().min(1),upscale_factor:Gl.optional()})}),_y=h(["480p","720p"]),wy=u({model:f("infinitalk/from-audio"),callBackUrl:s().url().optional(),input:u({image_url:s().min(1),audio_url:s().min(1),prompt:s().min(1).max(5e3),resolution:_y.optional(),seed:y().int().min(1e4).max(1e6).optional()})}),Ty=h(["1:1","4:3","3:4","16:9","9:16"]),Iy=u({model:f("z-image"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(1e3),aspect_ratio:Ty,nsfw_checker:x().default(!1)})}),Pt=h(["TURBO","BALANCED","QUALITY"]),ho=h(["square","square_hd","portrait_4_3","portrait_16_9","landscape_4_3","landscape_16_9"]),fo=h(["1","2","3","4"]),Ll=h(["AUTO","GENERAL","REALISTIC","DESIGN"]),Ki=h(["AUTO","REALISTIC","FICTION"]),Ry=u({model:f("ideogram/v3-text-to-image"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(5e3),rendering_speed:Pt.optional(),style:Ll.optional(),expand_prompt:x().optional(),image_size:ho.optional(),seed:y().int().optional(),negative_prompt:s().max(5e3).optional()})}),Cy=u({model:f("ideogram/v3-edit"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(5e3),image_url:s().min(1),mask_url:s().min(1),rendering_speed:Pt.optional(),expand_prompt:x().optional(),seed:y().int().optional()})}),vy=u({model:f("ideogram/v3-remix"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(5e3),image_url:s().min(1),rendering_speed:Pt.optional(),style:Ll.optional(),expand_prompt:x().optional(),image_size:ho.optional(),num_images:fo.optional(),seed:y().int().optional(),strength:y().min(.01).max(1).optional(),negative_prompt:s().max(5e3).optional()})}),My=u({model:f("ideogram/character"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(5e3),reference_image_urls:k(s().min(1)).min(1),rendering_speed:Pt.optional(),style:Ki.optional(),expand_prompt:x().optional(),num_images:fo.optional(),image_size:ho.optional(),seed:y().int().optional(),negative_prompt:s().max(5e3).optional()})}),Oy=u({model:f("ideogram/character-edit"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(5e3),image_url:s().min(1),mask_url:s().min(1),reference_image_urls:k(s().min(1)).min(1),rendering_speed:Pt.optional(),style:Ki.optional(),expand_prompt:x().optional(),num_images:fo.optional(),seed:y().int().optional()})}),Ey=u({model:f("ideogram/character-remix"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(5e3),image_url:s().min(1),reference_image_urls:k(s().min(1)).min(1),rendering_speed:Pt.optional(),style:Ki.optional(),expand_prompt:x().optional(),image_size:ho.optional(),num_images:fo.optional(),seed:y().int().optional(),strength:y().min(.1).max(1).optional(),negative_prompt:s().max(500).optional(),image_urls:k(s().min(1)).optional(),reference_mask_urls:s().optional()})}),Ay=h(["1:1","4:3","3:4","16:9","9:16","3:2","2:3"]),Ny=h(["1:1","4:3","3:4","16:9","9:16","3:2","2:3","auto"]),Wl=h(["1K","2K"]),jl=u({prompt:s().min(3).max(5e3),aspect_ratio:Ay,resolution:Wl,nsfw_checker:x().default(!1)}),$l=u({input_urls:k(s()).min(1).max(8),prompt:s().min(3).max(5e3),aspect_ratio:Ny,resolution:Wl,nsfw_checker:x().default(!1)}),Dy=u({model:f("flux-2/pro-text-to-image"),callBackUrl:s().optional(),input:jl}),By=u({model:f("flux-2/flex-text-to-image"),callBackUrl:s().optional(),input:jl}),Vy=u({model:f("flux-2/pro-image-to-image"),callBackUrl:s().optional(),input:$l}),Py=u({model:f("flux-2/flex-image-to-image"),callBackUrl:s().optional(),input:$l}),Hl=h(["1:1","4:3","3:4","3:2","2:3","16:9","9:16","21:9","9:21"]),Ky=h(["1K","2K","4K"]),Jl={prompt:s().min(1).max(5e3),resolution:Ky.default("1K"),width:y().int().min(256).max(4096).optional(),height:y().int().min(256).max(4096).optional(),output_format:h(["png","jpeg","webp"]).default("png"),num_images:y().int().min(1).max(4).default(1),seed:y().int().min(0).max(2147483647).optional(),enhance_prompt:x().default(!0),nsfw_checker:x().default(!1)},Ql=(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"})},zy=u({model:f("flux-3/klein-text-to-image"),callBackUrl:s().optional(),input:u({...Jl,aspect_ratio:Hl.default("1:1")})}).superRefine(Ql),Fy=u({model:f("flux-3/klein-edit-image"),callBackUrl:s().optional(),input:u({...Jl,image_urls:k(s().regex(/^https?:\/\/.+/)).min(1).max(10),aspect_ratio:h([...Hl.options,"auto"]).default("auto")})}).superRefine(Ql),zi=h(["6","10"]),qy=h(["512P","768P"]),Uy=h(["768P","1080P"]);function Gy(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 Ly=u({model:f("hailuo/02-text-to-video-pro"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(1500),prompt_optimizer:x().optional(),nsfw_checker:x().default(!1)})}),Wy=u({model:f("hailuo/02-text-to-video-standard"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(1500),duration:zi.optional(),prompt_optimizer:x().optional(),nsfw_checker:x().default(!1)})}),jy=u({model:f("hailuo/02-image-to-video-pro"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(1500),image_url:s().min(1),end_image_url:s().min(1).optional(),prompt_optimizer:x().optional(),nsfw_checker:x().default(!1)})}),$y=u({model:f("hailuo/02-image-to-video-standard"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(1500),image_url:s().min(1),end_image_url:s().min(1).optional(),duration:zi.optional(),resolution:qy.optional(),prompt_optimizer:x().optional(),nsfw_checker:x().default(!1)})}),Xl=u({prompt:s().min(1).max(5e3),image_url:s().min(1),duration:zi.optional(),resolution:Uy.optional(),nsfw_checker:x().default(!1)}).superRefine(Gy),Hy=u({model:f("hailuo/2-3-image-to-video-pro"),callBackUrl:s().optional(),input:Xl}),Jy=u({model:f("hailuo/2-3-image-to-video-standard"),callBackUrl:s().optional(),input:Xl});u({resultUrls:k(s().url()).min(1),resultObject:z(s(),K()).optional()});u({resultUrls:k(s().url()).optional(),resultObject:z(s(),K()).optional()}).refine(n=>n.resultUrls!==void 0||n.resultObject!==void 0,{message:"resultJson must include resultUrls or resultObject"});const Qy=u({taskId:s().min(1),model:f("bytedance/seedance-2-mini"),state:og,param:s().min(1),resultJson:s().optional(),failCode:s().nullable(),failMsg:s().nullable(),costTime:y().int().nullable(),completeTime:y().int().nullable(),createTime:y().int()});u({code:y().int(),msg:s(),data:Qy.optional()});u({taskId:s().min(1)});const Xy=u({taskId:s().optional(),paramJson:s().optional(),completeTime:y().int().nullable().optional(),response:u({resultUrls:k(s()).optional()}).nullable().optional(),successFlag:y().int().optional(),status:h(["GENERATING","SUCCESS","CREATE_TASK_FAILED","GENERATE_FAILED"]).optional(),errorCode:y().int().nullable().optional(),errorMessage:s().nullable().optional(),createTime:y().int().nullable().optional(),progress:s().nullable().optional()});u({code:y().int(),msg:s(),data:Xy.nullable().optional()});u({code:y().int(),msg:s(),data:u({taskId:s().min(1)}).optional()});const Yy=Sc(Blob);u({file:Yy,filename:s().min(1),uploadPath:s().min(1),fileName:s().optional(),mimeType:s().optional()});u({fileUrl:s().min(1),uploadPath:s().min(1),fileName:s().optional()});u({base64Data:s().min(1),uploadPath:s().min(1),fileName:s().optional(),mimeType:s().optional()});u({url:s().min(1)});u({taskId:s().min(1),url:s().min(1)});u({audio_id:ym,name:s().min(1).max(210),voice_description:s().min(1).max(2e4).optional(),example_dialogue:s().min(1).max(120).optional()});u({descriptions:s().min(1),image_urls:k(s().url()).min(1).max(1),audio_ids:k(s().min(1)).optional(),character_name:s().min(1).optional()});const Zy=u({characterId:s().min(1),characterName:s().min(1),imageUrl:s().url()});u({code:y().optional(),msg:s(),data:Zy.optional()});u({apiKey:s().min(1),baseURL:s().url().optional(),uploadBaseURL:s().url().optional(),timeout:y().int().positive().optional(),fetch:Hi().optional(),paygate:Hi().optional()});const eb=u({model:gm,callBackUrl:s().optional(),input:z(s(),K())}),tb=s().regex(/^veo\d+(?:_[a-z0-9]+)*$/,"Expected a listed model or an underscored kie Veo alias (e.g. veo4_fast)"),nb=h(["720p","1080p","4k"]),ob=P([f(4),f(6),f(8)]);u({prompt:s().min(1),model:h(["veo3","veo3_fast","veo3_lite"]).or(tb).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(s()).optional(),seeds:y().optional(),watermark:s().optional(),enableTranslation:x().optional(),resolution:nb.optional(),duration:ob.optional(),callBackUrl:s().optional(),enableFallback:x().optional()});u({taskId:s().min(1),prompt:s().min(1),model:h(["fast","quality"]).optional(),seeds:y().optional(),watermark:s().optional(),callBackUrl:s().optional()});u({taskId:s().min(1),index:y().int().min(0).optional()});u({code:y(),msg:s().optional(),data:u({resultUrl:s().url()}).nullable().optional()});u({taskId:s().min(1),index:y().int().min(0).optional(),callBackUrl:s().optional()});u({code:y(),msg:s().optional(),data:u({taskId:s().optional(),resultUrls:k(s()).nullable().optional(),imageUrls:k(s()).nullable().optional()}).nullable().optional()});u({taskId:s().min(1)});const ib=P([f(0),f(1),f(2),f(3)]),rb=u({taskId:s().optional(),resultUrls:k(s()).optional(),originUrls:k(s()).optional(),fullResultUrls:k(s()).optional(),resolution:s().optional(),mediaIds:k(s()).optional()}).passthrough(),ab=u({taskId:s(),paramJson:s().optional(),completeTime:s().nullable().optional(),response:rb.nullable().optional(),successFlag:ib,errorCode:P([y().int(),s()]).nullable().optional(),errorMessage:s().nullable().optional(),createTime:s().optional(),fallbackFlag:x().optional()});u({code:y().int(),msg:s(),data:ab.nullable().optional()});const sb=h(["21:9","16:9","4:3","1:1","3:4","9:16"]),lb=s().regex(/^flux-kontext-[a-z0-9]+(?:-[a-z0-9]+)*$/,"Expected a listed model or a Flux Kontext alias (e.g. flux-kontext-ultra)"),cb=["flux-kontext-pro","flux-kontext-max"],ub=h(cb).or(lb);u({prompt:s().min(1),enableTranslation:x().optional(),uploadCn:x().optional(),inputImage:s().url().optional(),aspectRatio:sb.optional(),outputFormat:h(["jpeg","png"]).optional(),promptUpsampling:x().optional(),model:ub.optional(),callBackUrl:s().url().optional(),safetyTolerance:y().int().min(0).max(6).optional(),watermark:s().optional()});const pb=P([f(0),f(1),f(2),f(3)]);u({taskId:s().min(1)});const db=u({taskId:s(),paramJson:s().optional(),completeTime:s().nullable().optional(),response:u({originImageUrl:s().optional(),resultImageUrl:s().optional()}).nullable().optional(),successFlag:pb,errorCode:y().int().nullable().optional(),errorMessage:s().nullable().optional(),createTime:s().optional()});u({code:y().int(),msg:s(),data:db.nullable().optional()});const mb=h(["1:1","3:2","2:3"]),hb=h(["GPT_IMAGE_1","FLUX_MAX"]);u({prompt:s().min(1).optional(),filesUrl:k(s().url()).max(5).optional(),size:mb,maskUrl:s().url().optional(),callBackUrl:s().url().optional(),isEnhance:x().optional(),uploadCn:x().optional(),enableFallback:x().optional(),fallbackModel:hb.optional()}).refine(n=>n.prompt!==void 0||n.filesUrl!==void 0,{message:"At least one of `prompt` or `filesUrl` must be provided"});const Yl=h(["mj_txt2img","mj_img2img","mj_style_reference","mj_omni_reference","mj_video","mj_video_hd"]),fb=h(["relaxed","fast","turbo"]),gb=h(["7","6.1","6","5.2","5.1","niji6"]),xb=h(["1:2","9:16","2:3","3:4","5:6","6:5","4:3","3:2","1:1","16:9","2:1"]),yb=h(["high","low"]);u({prompt:s().min(1).max(2e3),taskType:Yl,speed:fb.optional(),fileUrl:s().url().optional(),fileUrls:k(s().url()).optional(),aspectRatio:xb.optional(),version:gb.optional(),variety:y().int().min(0).max(100).optional(),stylization:y().int().min(0).max(1e3).optional(),weirdness:y().int().min(0).max(3e3).optional(),ow:y().int().min(1).max(1e3).optional(),waterMark:s().optional(),enableTranslation:x().optional(),callBackUrl:s().url().optional(),videoBatchSize:P([f(1),f(2),f(4)]).optional(),motion:yb.optional()});const bb=P([f(0),f(1),f(2),f(3)]);u({taskId:s().min(1)});const Sb=u({resultUrls:k(u({resultUrl:s()}).passthrough()).optional()}).passthrough(),kb=u({taskId:s().optional(),taskType:Yl.optional(),paramJson:s().optional(),completeTime:s().nullable().optional(),resultInfoJson:Sb.nullable().optional(),successFlag:bb.optional(),createTime:s().nullable().optional(),errorCode:y().int().nullable().optional(),errorMessage:s().nullable().optional()}).passthrough();u({code:y().int(),msg:s(),data:kb.nullable().optional()});const Zl=h(["720p","1080p"]),_b=h(["16:9","4:3","1:1","3:4","9:16"]),wb=P([f(5),f(10)]);u({prompt:s().min(1).max(1800),duration:wb,quality:Zl,imageUrl:s().url().optional(),aspectRatio:_b.optional(),waterMark:s().optional(),callBackUrl:s().url().optional()});u({taskId:s().min(1),prompt:s().min(1),quality:Zl,waterMark:s().optional(),callBackUrl:s().url().optional()});const Tb=u({videoId:s().optional(),taskId:s().optional(),videoUrl:s().optional(),imageUrl:s().optional()}),Ib=u({prompt:s().optional(),imageUrl:s().optional(),expandPrompt:x().optional()}).passthrough(),Rb=u({taskId:s().optional(),parentTaskId:s().nullable().optional(),generateParam:Ib.nullable().optional(),state:s().optional(),generateTime:s().nullable().optional(),videoInfo:Tb.nullable().optional(),failCode:y().int().nullable().optional(),failMsg:s().nullable().optional(),expireFlag:y().int().nullable().optional()});u({code:y().int(),msg:s(),data:Rb.nullable().optional()});const nt=s().regex(/^V\d+(?:_\d+)*(?:PLUS|ALL)?$/,"Expected a listed model or a Suno version alias (e.g. V5_5PLUS)");u({prompt:s().min(1),model:h(["V3_5","V4","V4_5","V4_5PLUS","V4_5ALL","V5","V5_5"]).or(nt),instrumental:x(),customMode:x(),callBackUrl:s().min(1),style:s().optional(),negativeTags:s().optional(),title:s().optional(),vocalGender:h(["m","f"]).optional(),styleWeight:y().min(0).max(1).optional(),weirdnessConstraint:y().min(0).max(1).optional(),audioWeight:y().min(0).max(1).optional(),personaId:s().optional()});u({defaultParamFlag:x(),audioId:s().min(1),prompt:s().min(1),model:h(["V3_5","V4","V4_5","V4_5PLUS","V4_5ALL","V5","V5_5"]).or(nt),callBackUrl:s().min(1),style:s().optional(),title:s().optional(),continueAt:y().optional(),negativeTags:s().optional(),vocalGender:h(["m","f"]).optional(),styleWeight:y().min(0).max(1).optional(),weirdnessConstraint:y().min(0).max(1).optional(),audioWeight:y().min(0).max(1).optional(),personaId:s().optional()});u({taskId:s().min(1),audioId:s().min(1),callBackUrl:s().min(1)});u({taskId:s().min(1)}).passthrough();const Cb=h(["PENDING","SUCCESS","CREATE_TASK_FAILED","GENERATE_WAV_FAILED","CALLBACK_EXCEPTION"]),vb=u({taskId:s(),musicId:s(),callbackUrl:s(),musicIndex:y().int(),completeTime:s().nullable().optional(),response:u({audioWavUrl:s()}).passthrough().nullable().optional(),successFlag:Cb,createTime:s(),errorCode:y().int().nullable(),errorMessage:s().nullable()}).passthrough();u({code:y().int(),msg:s().optional(),data:vb.nullable().optional()}).passthrough();u({taskId:s().min(1),audioId:s().min(1),callBackUrl:s().min(1),type:h(["separate_vocal","split_stem"]).optional()});u({taskId:s().min(1)}).passthrough();const Mb=h(["PENDING","SUCCESS","CREATE_TASK_FAILED","GENERATE_AUDIO_FAILED","CALLBACK_EXCEPTION"]),Ob=u({duration:y().optional(),audio_url:s().optional(),stem_type_group_name:s().optional(),id:s().optional()}).passthrough(),Eb=u({id:s().nullable().optional(),originUrl:s().nullable().optional(),originData:k(Ob).optional(),instrumentalUrl:s().nullable().optional(),vocalUrl:s().nullable().optional(),backingVocalsUrl:s().nullable().optional(),drumsUrl:s().nullable().optional(),bassUrl:s().nullable().optional(),guitarUrl:s().nullable().optional(),pianoUrl:s().nullable().optional(),keyboardUrl:s().nullable().optional(),percussionUrl:s().nullable().optional(),stringsUrl:s().nullable().optional(),synthUrl:s().nullable().optional(),fxUrl:s().nullable().optional(),brassUrl:s().nullable().optional(),woodwindsUrl:s().nullable().optional()}).passthrough(),Ab=u({taskId:s(),musicId:s().optional(),callbackUrl:s().optional(),musicIndex:y().int().optional(),completeTime:P([s(),y()]).nullable().optional(),response:Eb.nullable().optional(),successFlag:Mb.optional(),createTime:P([s(),y()]).optional(),errorCode:y().nullable().optional(),errorMessage:s().nullable().optional()}).passthrough();u({code:y().int(),msg:s().optional(),data:Ab.nullable().optional()}).passthrough();u({taskId:s().min(1)}).passthrough();const ec=h(["wait_processing","processing_validate","processing_validate_fail","wait_validating","success","fail"]),Nb=u({taskId:s(),voiceId:s(),status:ec,errorCode:y().int().nullable(),errorMessage:s().nullable()}).passthrough();u({code:y().int(),msg:s().optional(),data:Nb.nullable().optional()}).passthrough();u({taskId:s().min(1)}).passthrough();const Db=u({taskId:s(),validateInfo:s(),status:ec,errorCode:y().int().nullable(),errorMessage:s().nullable()}).passthrough();u({code:y().int(),msg:s().optional(),data:Db.nullable().optional()}).passthrough();const Bb=h(["beginner","intermediate","advanced","professional"]);u({taskId:s().min(1),verifyUrl:s().min(1),voiceName:s().optional(),description:s().optional(),style:s().optional(),callBackUrl:s().optional(),singerSkillLevel:Bb.optional()}).passthrough();u({voiceUrl:s().min(1),vocalStartS:y().int(),vocalEndS:y().int(),language:s().optional(),callBackUrl:s().optional()}).passthrough();const Vb=u({taskId:s()}).passthrough();u({code:y().int(),msg:s().optional(),data:Vb.nullable().optional()}).passthrough();u({taskId:s().min(1),calBackUrl:s().min(1)}).passthrough();const Pb=u({taskId:s()}).passthrough();u({code:y().int(),msg:s().optional(),data:Pb.nullable().optional()}).passthrough();u({task_id:s().min(1)}).passthrough();const Kb=u({isAvailable:x()}).passthrough();u({code:y().int(),msg:s().optional(),data:Kb.nullable().optional()}).passthrough();u({taskId:s().min(1),audioId:s().min(1),name:s().min(1),description:s().min(1),vocalStart:y().min(0).optional(),vocalEnd:y().min(0).optional(),style:s().optional()}).passthrough();const zb=u({personaId:s().optional(),name:s().optional(),description:s().optional()}).passthrough();u({code:y().int(),msg:s().optional(),data:zb.nullable().optional()}).passthrough();u({taskId:s().min(1),audioId:s().min(1)}).passthrough();const Fb=u({word:s().optional(),success:x().optional(),startS:y().optional(),endS:y().optional(),palign:y().int().optional()}).passthrough(),qb=u({alignedWords:k(Fb).optional(),waveformData:k(y()).optional(),hootCer:y().optional(),isStreamed:x().optional()}).passthrough();u({code:y().int(),msg:s().optional(),data:qb.nullable().optional()}).passthrough();u({taskId:s().min(1),callBackUrl:s().min(1)}).passthrough();u({taskId:s().min(1)}).passthrough();const Ub=u({images:k(s()).optional()}).passthrough(),Gb=u({taskId:s(),parentTaskId:s().optional(),callbackUrl:s().optional(),completeTime:s().nullable().optional(),response:Ub.nullable().optional(),successFlag:y().int().optional(),createTime:s().optional(),errorCode:y().int().nullable().optional(),errorMessage:s().nullable().optional()}).passthrough();u({code:y().int(),msg:s().optional(),data:Gb.nullable().optional()}).passthrough();u({task_id:s().min(1)}).passthrough();u({code:y().int(),msg:s().optional(),data:k(u({}).passthrough()).nullable().optional()}).passthrough();u({task_id:s().min(1),call_back_url:s().optional()});u({taskId:s().min(1),audioId:s().min(1),callBackUrl:s().min(1),author:s().max(50).optional(),domainName:s().max(50).optional()});u({taskId:s().min(1)});const Lb=h(["PENDING","SUCCESS","CREATE_TASK_FAILED","GENERATE_MP4_FAILED"]),Wb=u({videoUrl:s().optional()}).passthrough(),jb=u({taskId:s(),musicId:s(),callbackUrl:s(),musicIndex:y().int(),completeTime:s().nullable().optional(),response:Wb.nullable().optional(),successFlag:Lb,createTime:s(),errorCode:y().int().nullable().optional(),errorMessage:s().nullable().optional()}).passthrough();u({code:y().int(),msg:s().optional(),data:jb.nullable().optional()});u({prompt:s().min(1).max(200),callBackUrl:s().min(1)});u({taskId:s().min(1)});const $b=h(["PENDING","SUCCESS","CREATE_TASK_FAILED","GENERATE_LYRICS_FAILED","CALLBACK_EXCEPTION","SENSITIVE_WORD_ERROR"]),Hb=u({text:s(),title:s(),status:s().optional(),errorMessage:s().optional()}).passthrough();u({code:y().int(),msg:s().optional(),data:u({taskId:s(),param:s().optional(),response:u({taskId:s().optional(),data:k(Hb).optional()}).passthrough().nullable().optional(),status:$b.optional(),errorCode:y().int().nullable().optional(),errorMessage:s().nullable().optional()}).passthrough().nullable().optional()});u({content:s().min(1)});u({uploadUrl:s().min(1),prompt:s().min(1),customMode:x(),instrumental:x(),model:h(["V3_5","V4","V4_5","V4_5PLUS","V4_5ALL","V5","V5_5"]).or(nt),callBackUrl:s().min(1),style:s().optional(),title:s().optional(),negativeTags:s().optional(),vocalGender:h(["m","f"]).optional(),styleWeight:y().min(0).max(1).optional(),weirdnessConstraint:y().min(0).max(1).optional(),audioWeight:y().min(0).max(1).optional(),personaId:s().optional()});u({uploadUrl:s().min(1),defaultParamFlag:x(),instrumental:x(),continueAt:y(),model:h(["V3_5","V4","V4_5","V4_5PLUS","V4_5ALL","V5","V5_5"]).or(nt),callBackUrl:s().min(1),prompt:s().optional(),style:s().optional(),title:s().optional(),negativeTags:s().optional(),vocalGender:h(["m","f"]).optional(),styleWeight:y().min(0).max(1).optional(),weirdnessConstraint:y().min(0).max(1).optional(),audioWeight:y().min(0).max(1).optional(),personaId:s().optional()});u({taskId:s().min(1),callBackUrl:s().min(1),audioId:s().optional()});u({taskId:s().min(1)});const Jb=P([f(0),f(1),f(2),f(3)]),Qb=u({pitch:y(),start:y(),end:y(),velocity:y()}).passthrough(),Xb=u({name:s(),notes:k(Qb)}).passthrough(),Yb=u({state:s().optional(),instruments:k(Xb).optional()}).passthrough();u({code:y().int(),msg:s().optional(),data:u({taskId:s(),successFlag:Jb,recordTaskId:y().int().optional(),audioId:s().optional(),callbackUrl:s().optional(),createTime:y().int().optional(),completeTime:y().int().nullable().optional(),errorCode:P([s(),y().int()]).nullable().optional(),errorMessage:s().nullable().optional(),midiData:Yb.nullable().optional()}).passthrough().nullable().optional()}).passthrough();u({uploadUrlList:ua([s().min(1),s().min(1)]),customMode:x(),model:h(["V4","V4_5","V4_5PLUS","V4_5ALL","V5","V5_5"]).or(nt),callBackUrl:s().min(1),prompt:s().optional(),style:s().optional(),title:s().optional(),instrumental:x().optional(),vocalGender:h(["m","f"]).optional(),styleWeight:y().min(0).max(1).optional(),weirdnessConstraint:y().min(0).max(1).optional(),audioWeight:y().min(0).max(1).optional()});u({taskId:s().min(1),audioId:s().min(1),prompt:s().min(1),tags:s().min(1),title:s().min(1),infillStartS:y().min(0),infillEndS:y().min(0),negativeTags:s().optional(),fullLyrics:s().optional(),callBackUrl:s().optional()});u({prompt:s().min(1),model:h(["V5","V5_5"]).or(nt),soundLoop:x().optional(),soundTempo:y().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:x().optional(),callBackUrl:s().optional()});u({uploadUrl:s().min(1),title:s().min(1),tags:s().min(1),callBackUrl:s().min(1),model:h(["V3_5","V4","V4_5","V4_5PLUS","V4_5ALL","V5","V5_5"]).or(nt),negativeTags:s().optional(),vocalGender:h(["m","f"]).optional(),styleWeight:y().min(0).max(1).optional(),weirdnessConstraint:y().min(0).max(1).optional(),audioWeight:y().min(0).max(1).optional()});u({uploadUrl:s().min(1),prompt:s().min(1),title:s().min(1),style:s().min(1),negativeTags:s().min(1),callBackUrl:s().min(1),model:h(["V3_5","V4","V4_5","V4_5PLUS","V4_5ALL","V5","V5_5"]).or(nt),vocalGender:h(["m","f"]).optional(),styleWeight:y().min(0).max(1).optional(),weirdnessConstraint:y().min(0).max(1).optional(),audioWeight:y().min(0).max(1).optional()});const Zb=u({type:h(["text","image_url"]),text:s().optional(),image_url:u({url:s()}).optional()}),eS=u({role:h(["user","assistant","system"]),content:P([s(),k(Zb)])});u({model:s(),messages:k(eS),temperature:y().min(0).max(2).optional(),max_tokens:y().int().positive().optional(),stream:x().optional(),response_format:u({type:h(["text","json_object","json_schema"]),json_schema:z(s(),K()).optional()}).optional()});const tS=s().regex(/^gpt-\d+(?:[-.]\d+)*(?:-[a-z0-9]+)*$/,"Expected a listed model or a versioned GPT alias (e.g. gpt-5-5-mini)"),nS=["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","gpt-6-1-sol"],oS=h(nS).or(tS),iS=h(["low","medium","high","xhigh"]),rS=h(["user","assistant","system","developer","tool"]),aS=u({type:f("input_text"),text:s().min(1)}),sS=u({type:f("input_image"),image_url:s().url()}),lS=u({type:f("input_file"),file_url:s().url()}),cS=Te("type",[aS,sS,lS]),xn=u({role:rS,content:k(cS).min(1)}),go=u({effort:iS.default("low").optional()}),uS=u({type:f("web_search")}),tc=u({type:f("function"),name:s().min(1),description:s().min(1),parameters:z(s(),K())}),pS=Te("type",[uS,tc]),xo=k(pS).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:oS,stream:x().default(!1).optional(),input:P([s().min(1),k(xn).min(1)]),reasoning:go.optional(),tools:xo.optional(),tool_choice:s().optional()});const dS=s().regex(/^grok-\d+(?:[-.]\d+)*(?:-[a-z0-9]+)*$/,"Expected a listed model or a versioned Grok alias (e.g. grok-4-5-fast)"),mS=["grok-4-5","grok-4-6","grok-4-7"],hS=h(mS).or(dS);u({model:hS,stream:x().default(!1).optional(),input:P([s().min(1),k(xn).min(1)]),reasoning:go.optional(),tools:xo.optional(),tool_choice:s().optional()});const fS=s().regex(/^grok-\d+(?:-\d+)*(?:-[a-z0-9]+)*$/,"Expected a listed model or a versioned Grok alias (e.g. grok-4-6)"),gS=["grok-4-7","grok-4-6","grok-4-5","grok-4-3"],xS=h(gS).or(fS);u({model:xS,stream:x().default(!1).optional(),input:P([s().min(1),k(xn).min(1)]),reasoning:go.optional(),tools:xo.optional(),tool_choice:s().optional()});const yS=s().regex(/^gpt-\d+(?:\.\d+)*-codex(?:-[a-z0-9]+)*$/,"Expected a listed model or a versioned GPT Codex alias (e.g. gpt-5.5-codex)"),bS=["gpt-5-codex","gpt-5.1-codex","gpt-5.2-codex","gpt-5.3-codex","gpt-5.4-codex"],SS=h(bS).or(yS);u({model:SS,stream:x().default(!1).optional(),input:P([s().min(1),k(xn).min(1)]),reasoning:go.optional(),tools:xo.optional(),tool_choice:s().optional()});const kS=s().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)"),_S=["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(_S).or(kS),TS=h(["none","minimal","low","medium","high","xhigh","max"]),IS=u({type:h(["enabled","disabled","auto"]).optional()}),RS=u({type:h(["text","json_object","json_schema"]),name:s().optional(),description:s().optional(),schema:z(s(),K()).optional(),strict:x().optional()}),CS=u({format:RS}),vS=P([s(),u({type:f("function"),name:s().min(1)})]);u({model:wS,stream:x().default(!1).optional(),input:P([s().min(1),k(xn).min(1)]),instructions:s().optional(),reasoning:u({effort:TS.optional()}).optional(),thinking:IS.optional(),tools:k(tc).optional(),tool_choice:vS.optional(),text:CS.optional()});const MS=u({type:s(),properties:z(s(),K()).optional(),required:k(s()).optional()}),OS=u({name:s(),description:s(),input_schema:MS}),ES=u({type:s(),text:s().optional()}).passthrough(),nc=u({role:h(["user","assistant"]),content:P([s(),k(ES)])}),oc=s().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-haiku-5-5","claude-opus-5"]).or(oc),messages:k(nc),tools:k(OS).optional(),thinkingFlag:x().optional(),stream:x().optional()});u({after_id:s().min(1).optional()});const AS=["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"],NS=h(AS).or(oc),DS=u({type:f("text"),text:s()}).passthrough(),BS=u({name:s().min(1),description:s().optional(),input_schema:u({type:s()}).passthrough()}).passthrough(),Zr=u({type:s()}).passthrough();u({model:NS,max_tokens:y().int().min(1),messages:k(nc).min(1),system:P([s(),k(DS)]).optional(),temperature:y().min(0).max(1).optional(),top_p:y().min(0).max(1).optional(),top_k:y().int().min(0).optional(),stop_sequences:k(s()).optional(),tools:k(BS).optional(),tool_choice:Zr.optional(),thinking:Zr.optional(),metadata:u({user_id:s().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 VS=["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"],PS=s().regex(/^[A-Z][A-Za-z0-9]*(?: [A-Za-z0-9]+)*$/),ea=h(VS).or(PS);u({taskType:P([ea,k(ea)]).optional(),provider:s().optional(),q:s().optional()});const KS=s().regex(/^[A-Za-z0-9][A-Za-z0-9._-]*(?:\/[A-Za-z0-9][A-Za-z0-9._-]*)?$/);u({model:KS});const zS=P([_g,Ig,wg,Tg,pg,dg,mg,hg,fg,gg,xg,yg,bg,Sg,kg,vg,Eg,Dg,Pg,Lg,$g,Hg,u0,p0,d0,f0,g0,x0,y0,b0,S0,k0,_0,a1,u1,s1,c1,d1,m1,f1,y1,k1,T1,w1,R1,I1,C1,v1,M1,O1,E1,A1,N1,D1,B1,V1,Jg,Qg,e0,n0,o0,i0,r0,a0,s0,l0,c0,I0,v0,E0,N0,B0,z0,U0,j0,L0,X0,Z0,t1,o1,r1,px,dx,mx,hx,fx,gx,Sx,kx,Ix,Rx,Cx,vx,Mx,Ox,Ex,Ax,Nx,Dx,Bx,Vx,z1,F1,q1,U1,G1,L1,W1,$1,H1,J1,X1,Y1,ex,nx,ox,ix,rx,ax,sx,P1,K1,Kx,Fx,Ux,Lx,$x,Jx,Xx,Zx,ty,oy,ay,sy,dy,my,fy,gy,xy,yy,by,Sy,ky,wy,Iy,zy,Fy,Dy,By,Vy,Py,Ly,Wy,jy,$y,Hy,Jy,Ry,Cy,vy,My,Oy,Ey]);eb.pipe(zS);function ic(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=ic(n[e]))&&(o&&(o+=" "),o+=t)}else for(t in n)n[t]&&(o&&(o+=" "),o+=t);return o}function s_(){for(var n,e,t=0,o="",i=arguments.length;t<i;t++)(n=arguments[t])&&(e=ic(n))&&(o&&(o+=" "),o+=e);return o}const FS=(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},qS=(n,e)=>({classGroupId:n,validator:e}),rc=(n=new Map,e=null,t)=>({nextPart:n,validators:e,classGroupId:t}),jn="-",ta=[],US="arbitrary..",GS=n=>{const e=WS(n),{conflictingClassGroups:t,conflictingClassGroupModifiers:o}=n;return{getClassGroupId:a=>{if(a.startsWith("[")&&a.endsWith("]"))return LS(a);const l=a.split(jn),c=l[0]===""&&l.length>1?1:0;return ac(l,c,e)},getConflictingClassGroupIds:(a,l)=>{if(l){const c=o[a],p=t[a];return c?p?FS(p,c):c:p||ta}return t[a]||ta}}},ac=(n,e,t)=>{if(n.length-e===0)return t.classGroupId;const i=n[e],r=t.nextPart.get(i);if(r){const p=ac(n,e+1,r);if(p)return p}const a=t.validators;if(a===null)return;const l=e===0?n.join(jn):n.slice(e).join(jn),c=a.length;for(let p=0;p<c;p++){const d=a[p];if(d.validator(l))return d.classGroupId}},LS=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?US+o:void 0})(),WS=n=>{const{theme:e,classGroups:t}=n;return jS(t,e)},jS=(n,e)=>{const t=rc();for(const o in n){const i=n[o];Fi(i,t,o,e)}return t},Fi=(n,e,t,o)=>{const i=n.length;for(let r=0;r<i;r++){const a=n[r];$S(a,e,t,o)}},$S=(n,e,t,o)=>{if(typeof n=="string"){HS(n,e,t);return}if(typeof n=="function"){JS(n,e,t,o);return}QS(n,e,t,o)},HS=(n,e,t)=>{const o=n===""?e:sc(e,n);o.classGroupId=t},JS=(n,e,t,o)=>{if(XS(n)){Fi(n(o),e,t,o);return}e.validators===null&&(e.validators=[]),e.validators.push(qS(t,n))},QS=(n,e,t,o)=>{const i=Object.entries(n),r=i.length;for(let a=0;a<r;a++){const[l,c]=i[a];Fi(c,sc(e,l),t,o)}},sc=(n,e)=>{let t=n;const o=e.split(jn),i=o.length;for(let r=0;r<i;r++){const a=o[r];let l=t.nextPart.get(a);l||(l=rc(),t.nextPart.set(a,l)),t=l}return t},XS=n=>"isThemeGetter"in n&&n.isThemeGetter===!0,YS=n=>{if(n<1)return{get:()=>{},set:()=>{}};let e=0,t=Object.create(null),o=Object.create(null);const i=(r,a)=>{t[r]=a,e++,e>n&&(e=0,o=t,t=Object.create(null))};return{get(r){let a=t[r];if(a!==void 0)return a;if((a=o[r])!==void 0)return i(r,a),a},set(r,a){r in t?t[r]=a:i(r,a)}}},ii="!",na=":",ZS=[],oa=(n,e,t,o,i)=>({modifiers:n,hasImportantModifier:e,baseClassName:t,maybePostfixModifierPosition:o,isExternal:i}),ek=n=>{const{prefix:e,experimentalParseClassName:t}=n;let o=i=>{const r=[];let a=0,l=0,c=0,p;const d=i.length;for(let _=0;_<d;_++){const w=i[_];if(a===0&&l===0){if(w===na){r.push(i.slice(c,_)),c=_+1;continue}if(w==="/"){p=_;continue}}w==="["?a++:w==="]"?a--:w==="("?l++:w===")"&&l--}const m=r.length===0?i:i.slice(c);let g=m,b=!1;m.endsWith(ii)?(g=m.slice(0,-1),b=!0):m.startsWith(ii)&&(g=m.slice(1),b=!0);const S=p&&p>c?p-c:void 0;return oa(r,b,g,S)};if(e){const i=e+na,r=o;o=a=>a.startsWith(i)?r(a.slice(i.length)):oa(ZS,!1,a,void 0,!0)}if(t){const i=o;o=r=>t({className:r,parseClassName:i})}return o},tk=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 a=t[r],l=a[0]==="[",c=e.has(a);l||c?(i.length>0&&(i.sort(),o.push(...i),i=[]),o.push(a)):i.push(a)}return i.length>0&&(i.sort(),o.push(...i)),o}},nk=n=>({cache:YS(n.cacheSize),parseClassName:ek(n),sortModifiers:tk(n),...GS(n)}),ok=/\s+/,ik=(n,e)=>{const{parseClassName:t,getClassGroupId:o,getConflictingClassGroupIds:i,sortModifiers:r}=e,a=[],l=n.trim().split(ok);let c="";for(let p=l.length-1;p>=0;p-=1){const d=l[p],{isExternal:m,modifiers:g,hasImportantModifier:b,baseClassName:S,maybePostfixModifierPosition:_}=t(d);if(m){c=d+(c.length>0?" "+c:c);continue}let w=!!_,O=o(w?S.substring(0,_):S);if(!O){if(!w){c=d+(c.length>0?" "+c:c);continue}if(O=o(S),!O){c=d+(c.length>0?" "+c:c);continue}w=!1}const L=g.length===0?"":g.length===1?g[0]:r(g).join(":"),F=b?L+ii:L,ne=F+O;if(a.indexOf(ne)>-1)continue;a.push(ne);const v=i(O,w);for(let I=0;I<v.length;++I){const C=v[I];a.push(F+C)}c=d+(c.length>0?" "+c:c)}return c},rk=(...n)=>{let e=0,t,o,i="";for(;e<n.length;)(t=n[e++])&&(o=lc(t))&&(i&&(i+=" "),i+=o);return i},lc=n=>{if(typeof n=="string")return n;let e,t="";for(let o=0;o<n.length;o++)n[o]&&(e=lc(n[o]))&&(t&&(t+=" "),t+=e);return t},ak=(n,...e)=>{let t,o,i,r;const a=c=>{const p=e.reduce((d,m)=>m(d),n());return t=nk(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=ik(c,t);return i(c,d),d};return r=a,(...c)=>r(rk(...c))},sk=[],j=n=>{const e=t=>t[n]||sk;return e.isThemeGetter=!0,e},cc=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,uc=/^\((?:(\w[\w-]*):)?(.+)\)$/i,lk=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,ck=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,uk=/\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$/,pk=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,dk=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,mk=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,qe=n=>lk.test(n),V=n=>!!n&&!Number.isNaN(Number(n)),Ue=n=>!!n&&Number.isInteger(Number(n)),Ko=n=>n.endsWith("%")&&V(n.slice(0,-1)),De=n=>ck.test(n),pc=()=>!0,hk=n=>uk.test(n)&&!pk.test(n),qi=()=>!1,fk=n=>dk.test(n),gk=n=>mk.test(n),xk=n=>!M(n)&&!E(n),yk=n=>ot(n,hc,qi),M=n=>cc.test(n),rt=n=>ot(n,fc,hk),ia=n=>ot(n,Rk,V),bk=n=>ot(n,xc,pc),Sk=n=>ot(n,gc,qi),ra=n=>ot(n,dc,qi),kk=n=>ot(n,mc,gk),Mn=n=>ot(n,yc,fk),E=n=>uc.test(n),qt=n=>St(n,fc),_k=n=>St(n,gc),aa=n=>St(n,dc),wk=n=>St(n,hc),Tk=n=>St(n,mc),On=n=>St(n,yc,!0),Ik=n=>St(n,xc,!0),ot=(n,e,t)=>{const o=cc.exec(n);return o?o[1]?e(o[1]):t(o[2]):!1},St=(n,e,t=!1)=>{const o=uc.exec(n);return o?o[1]?e(o[1]):t:!1},dc=n=>n==="position"||n==="percentage",mc=n=>n==="image"||n==="url",hc=n=>n==="length"||n==="size"||n==="bg-size",fc=n=>n==="length",Rk=n=>n==="number",gc=n=>n==="family-name",xc=n=>n==="number"||n==="weight",yc=n=>n==="shadow",Ck=()=>{const n=j("color"),e=j("font"),t=j("text"),o=j("font-weight"),i=j("tracking"),r=j("leading"),a=j("breakpoint"),l=j("container"),c=j("spacing"),p=j("radius"),d=j("shadow"),m=j("inset-shadow"),g=j("text-shadow"),b=j("drop-shadow"),S=j("blur"),_=j("perspective"),w=j("aspect"),O=j("ease"),L=j("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"],v=()=>[...ne(),E,M],I=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],T=()=>[E,M,c],D=()=>[qe,"full","auto",...T()],pe=()=>[Ue,"none","subgrid",E,M],yn=()=>["auto",{span:["full",Ue,E,M]},Ue,E,M],kt=()=>[Ue,"auto",E,M],bn=()=>["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"],Se=()=>["auto",...T()],it=()=>[qe,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],yo=()=>[qe,"screen","full","dvw","lvw","svw","min","max","fit",...T()],bo=()=>[qe,"screen","full","lh","dvh","lvh","svh","min","max","fit",...T()],N=()=>[n,E,M],Gi=()=>[...ne(),aa,ra,{position:[E,M]}],Li=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Wi=()=>["auto","cover","contain",wk,yk,{size:[E,M]}],So=()=>[Ko,qt,rt],ae=()=>["","none","full",p,E,M],se=()=>["",V,qt,rt],Sn=()=>["solid","dashed","dotted","double"],ji=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],$=()=>[V,Ko,aa,ra],$i=()=>["","none",S,E,M],kn=()=>["none",V,E,M],_n=()=>["none",V,E,M],ko=()=>[V,E,M],wn=()=>[qe,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[De],breakpoint:[De],color:[pc],container:[De],"drop-shadow":[De],ease:["in","out","in-out"],font:[xk],"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",qe,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:v()}],overflow:[{overflow:I()}],"overflow-x":[{"overflow-x":I()}],"overflow-y":[{"overflow-y":I()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],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:[Ue,"auto",E,M]}],basis:[{basis:[qe,"full","auto",l,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[V,qe,"auto","initial","none",M]}],grow:[{grow:["",V,E,M]}],shrink:[{shrink:["",V,E,M]}],order:[{order:[Ue,"first","last","none",E,M]}],"grid-cols":[{"grid-cols":pe()}],"col-start-end":[{col:yn()}],"col-start":[{"col-start":kt()}],"col-end":[{"col-end":kt()}],"grid-rows":[{"grid-rows":pe()}],"row-start-end":[{row:yn()}],"row-start":[{"row-start":kt()}],"row-end":[{"row-end":kt()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":bn()}],"auto-rows":[{"auto-rows":bn()}],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:Se()}],mx:[{mx:Se()}],my:[{my:Se()}],ms:[{ms:Se()}],me:[{me:Se()}],mbs:[{mbs:Se()}],mbe:[{mbe:Se()}],mt:[{mt:Se()}],mr:[{mr:Se()}],mb:[{mb:Se()}],ml:[{ml:Se()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:it()}],"inline-size":[{inline:["auto",...yo()]}],"min-inline-size":[{"min-inline":["auto",...yo()]}],"max-inline-size":[{"max-inline":["none",...yo()]}],"block-size":[{block:["auto",...bo()]}],"min-block-size":[{"min-block":["auto",...bo()]}],"max-block-size":[{"max-block":["none",...bo()]}],w:[{w:[l,"screen",...it()]}],"min-w":[{"min-w":[l,"screen","none",...it()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[a]},...it()]}],h:[{h:["screen","lh",...it()]}],"min-h":[{"min-h":["screen","lh","none",...it()]}],"max-h":[{"max-h":["screen","lh",...it()]}],"font-size":[{text:["base",t,qt,rt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[o,Ik,bk]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ko,M]}],"font-family":[{font:[_k,Sk,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,ia]}],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,rt]}],"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:Gi()}],"bg-repeat":[{bg:Li()}],"bg-size":[{bg:Wi()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ue,E,M],radial:["",E,M],conic:[Ue,E,M]},Tk,kk]}],"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:ae()}],"rounded-s":[{"rounded-s":ae()}],"rounded-e":[{"rounded-e":ae()}],"rounded-t":[{"rounded-t":ae()}],"rounded-r":[{"rounded-r":ae()}],"rounded-b":[{"rounded-b":ae()}],"rounded-l":[{"rounded-l":ae()}],"rounded-ss":[{"rounded-ss":ae()}],"rounded-se":[{"rounded-se":ae()}],"rounded-ee":[{"rounded-ee":ae()}],"rounded-es":[{"rounded-es":ae()}],"rounded-tl":[{"rounded-tl":ae()}],"rounded-tr":[{"rounded-tr":ae()}],"rounded-br":[{"rounded-br":ae()}],"rounded-bl":[{"rounded-bl":ae()}],"border-w":[{border:se()}],"border-w-x":[{"border-x":se()}],"border-w-y":[{"border-y":se()}],"border-w-s":[{"border-s":se()}],"border-w-e":[{"border-e":se()}],"border-w-bs":[{"border-bs":se()}],"border-w-be":[{"border-be":se()}],"border-w-t":[{"border-t":se()}],"border-w-r":[{"border-r":se()}],"border-w-b":[{"border-b":se()}],"border-w-l":[{"border-l":se()}],"divide-x":[{"divide-x":se()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":se()}],"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,qt,rt]}],"outline-color":[{outline:N()}],shadow:[{shadow:["","none",d,On,Mn]}],"shadow-color":[{shadow:N()}],"inset-shadow":[{"inset-shadow":["none",m,On,Mn]}],"inset-shadow-color":[{"inset-shadow":N()}],"ring-w":[{ring:se()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:N()}],"ring-offset-w":[{"ring-offset":[V,rt]}],"ring-offset-color":[{"ring-offset":N()}],"inset-ring-w":[{"inset-ring":se()}],"inset-ring-color":[{"inset-ring":N()}],"text-shadow":[{"text-shadow":["none",g,On,Mn]}],"text-shadow-color":[{"text-shadow":N()}],opacity:[{opacity:[V,E,M]}],"mix-blend":[{"mix-blend":[...ji(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ji()}],"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":$()}],"mask-image-linear-to-pos":[{"mask-linear-to":$()}],"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":$()}],"mask-image-t-to-pos":[{"mask-t-to":$()}],"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":$()}],"mask-image-r-to-pos":[{"mask-r-to":$()}],"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":$()}],"mask-image-b-to-pos":[{"mask-b-to":$()}],"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":$()}],"mask-image-l-to-pos":[{"mask-l-to":$()}],"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":$()}],"mask-image-x-to-pos":[{"mask-x-to":$()}],"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":$()}],"mask-image-y-to-pos":[{"mask-y-to":$()}],"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":$()}],"mask-image-radial-to-pos":[{"mask-radial-to":$()}],"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":$()}],"mask-image-conic-to-pos":[{"mask-conic-to":$()}],"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:Gi()}],"mask-repeat":[{mask:Li()}],"mask-size":[{mask:Wi()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",E,M]}],filter:[{filter:["","none",E,M]}],blur:[{blur:$i()}],brightness:[{brightness:[V,E,M]}],contrast:[{contrast:[V,E,M]}],"drop-shadow":[{"drop-shadow":["","none",b,On,Mn]}],"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":$i()}],"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",O,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":v()}],rotate:[{rotate:kn()}],"rotate-x":[{"rotate-x":kn()}],"rotate-y":[{"rotate-y":kn()}],"rotate-z":[{"rotate-z":kn()}],scale:[{scale:_n()}],"scale-x":[{"scale-x":_n()}],"scale-y":[{"scale-y":_n()}],"scale-z":[{"scale-z":_n()}],"scale-3d":["scale-3d"],skew:[{skew:ko()}],"skew-x":[{"skew-x":ko()}],"skew-y":[{"skew-y":ko()}],transform:[{transform:[E,M,"","none","gpu","cpu"]}],"transform-origin":[{origin:v()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:wn()}],"translate-x":[{"translate-x":wn()}],"translate-y":[{"translate-y":wn()}],"translate-z":[{"translate-z":wn()}],"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,qt,rt,ia]}],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"]}},l_=ak(Ck),c_="Project slugs must contain at least one letter (a-z) or number (0-9)";function u_(n){return n.normalize("NFKD").replace(new RegExp("\\p{M}+","gu"),"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}const vk="5.7.1",p_={version:vk};let Ui;Ui=globalThis.crypto;async function Mk(n){return(await Ui).getRandomValues(new Uint8Array(n))}async function Ok(n){const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",t=Math.pow(2,8)-Math.pow(2,8)%e.length;let o="";for(;o.length<n;){const i=await Mk(n-o.length);for(const r of i)r<t&&(o+=e[r%e.length])}return o}async function Ek(n){return await Ok(n)}async function Ak(n){const e=await(await Ui).subtle.digest("SHA-256",new TextEncoder().encode(n));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function d_(n){if(n||(n=43),n<43||n>128)throw`Expected a length between 43 and 128. Received ${n}.`;const e=await Ek(n),t=await Ak(e);return{code_verifier:e,code_challenge:t}}class zo 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 sa=10,Nk=13,at=32;function Fo(n){}function Dk(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=Fo,onError:t=Fo,onRetry:o=Fo,onComment:i,maxBufferSize:r}=n,a=[];let l=0,c=!0,p,d="",m=0,g,b=!1;function S(v){if(b)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,v.charCodeAt(0)===239&&v.charCodeAt(1)===187&&v.charCodeAt(2)===191&&(v=v.slice(3))),a.length===0){const T=w(v);T!==""&&(a.push(T),l=T.length),_();return}if(v.indexOf(`
8
+ `);return{dom:c,text:g,slice:e}}function xs(n,e,t,o,i){let r=i.parent.type.spec.code,a,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(R.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:b}=n.state,S=Et.fromSchema(b);a=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(_=>{let w=a.appendChild(document.createElement("p"));_&&w.appendChild(S.serializeNode(b.text(_,g)))})}}else n.someProp("transformPastedHTML",m=>{t=m(t,n)}),a=Op(t),un&&Ep(a);let p=a&&a.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=a.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;a=g}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Zt.fromSchema(n.state.schema)).parseSlice(a,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!Cp.test(g.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Ap(Vr(l,+d[1],+d[2]),d[4]);else if(l=A.maxOpen(vp(l.content,i),!0),l.openStart||l.openEnd){let m=0,g=0;for(let b=l.content.firstChild;m<l.openStart&&!b.type.spec.isolating;m++,b=b.firstChild);for(let b=l.content.lastChild;g<l.openEnd&&!b.type.spec.isolating;g++,b=b.lastChild);l=Vr(l,m,g)}return n.someProp("transformPasted",m=>{l=m(l,n,c)}),l}const Cp=/^(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 vp(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,a=[];if(n.forEach(l=>{if(!a)return;let c=i.findWrapping(l.type),p;if(!c)return a=null;if(p=a.length&&r.length&&bs(c,r,l,a[a.length-1],0))a[a.length-1]=p;else{a.length&&(a[a.length-1]=Ss(a[a.length-1],r.length));let d=ys(l,c);a.push(d),i=i.matchType(d.type),r=c}}),a)return R.from(a)}return n}function ys(n,e,t=0){for(let o=e.length-1;o>=t;o--)n=e[o].create(null,R.from(n));return n}function bs(n,e,t,o,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let r=bs(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(R.from(ys(t,n,i+1))))}}function Ss(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Ss(n.lastChild,e-1)),o=n.contentMatchAt(n.childCount).fillBefore(R.empty,!0);return n.copy(t.append(o))}function ti(n,e,t,o,i,r){let a=e<0?n.firstChild:n.lastChild,l=a.content;return n.childCount>1&&(r=0),i<o-1&&(l=ti(l,e,t,o,i+1,r)),i>=t&&(l=e<0?a.contentMatchAt(0).fillBefore(l,r<=i).append(l):l.append(a.contentMatchAt(a.childCount).fillBefore(R.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,a.copy(l))}function Vr(n,e,t){return e<n.openStart&&(n=new A(ti(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new A(ti(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const ks={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 _s(){return document.implementation.createHTMLDocument("title")}let zt=null;function Mp(n){let e=window.trustedTypes;if(!e)return n;if(!zt){if(zt=e.defaultPolicy)try{return zt.createHTML(n)}catch{}zt=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return zt.createHTML(n)}function Op(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=_s(),o=t.body,i=/<([a-z][^>\s]+)/i.exec(n),r;if((r=i&&ks[i[1].toLowerCase()])&&(n=r.map(a=>"<"+a+">").join("")+n+r.map(a=>"</"+a+">").reverse().join("")),o.innerHTML=Mp(n),r)for(let a=0;a<r.length;a++)o=o.querySelector(r[a])||o;for(let a=0;a<t.styleSheets.length;a++){let l=t.styleSheets[a];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 Ep(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 Ap(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:a}=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=R.from(c.create(o[l+1],i)),r++,a++}return new A(i,r,a)}const le={},ce={},Np={touchstart:!0,touchmove:!0};class Dp{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 Bp(n){for(let e in le){let t=le[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=o=>{Pp(n,o)&&!gi(n,o)&&(n.editable||!(o.type in ce))&&t(n,o)},Np[e]?{passive:!0}:void 0)}ie&&n.dom.addEventListener("input",()=>null),ni(n)}function Ke(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Vp(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 ni(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=o=>gi(n,o))})}function gi(n,e){return n.someProp("handleDOMEvents",t=>{let o=t[e.type];return o?o(n,e)||e.defaultPrevented:!1})}function Pp(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 Kp(n,e){!gi(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,!Rs(n)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Pe&&te&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Mt&&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))||Rp(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(Rs(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",a=>a(n,o.$from.pos,o.$to.pos,i,r))&&n.dispatch(r()),t.preventDefault()}};function dn(n){return{left:n.clientX,top:n.clientY}}function zp(n,e){let t=e.x-n.clientX,o=e.y-n.clientY;return t*t+o*o<100}function xi(n,e,t,o,i){if(o==-1)return!1;let r=n.state.doc.resolve(o);for(let a=r.depth+1;a>0;a--)if(n.someProp(e,l=>a>r.depth?l(n,t,r.nodeAfter,r.before(a),i,!0):l(n,t,r.node(a),r.before(a),i,!1)))return!0;return!1}function mn(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 Fp(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),o=t.nodeAfter;return o&&o.isAtom&&B.isSelectable(o)?(mn(n,new B(t)),!0):!1}function qp(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 a=r.depth+1;a>0;a--){let l=a>r.depth?r.nodeAfter:r.node(a);if(B.isSelectable(l)){o&&t.$from.depth>0&&a>=t.$from.depth&&r.before(t.$from.depth+1)==t.$from.pos?i=r.before(t.$from.depth):i=r.before(a);break}}return i!=null?(mn(n,B.create(n.state.doc,i)),!0):!1}function Up(n,e,t,o,i){return xi(n,"handleClickOn",e,t,o)||n.someProp("handleClick",r=>r(n,e,o))||(i?qp(n,t):Fp(n,t))}function Gp(n,e,t,o){return xi(n,"handleDoubleClickOn",e,t,o)||n.someProp("handleDoubleClick",i=>i(n,e,o))}function Lp(n,e,t,o){return xi(n,"handleTripleClickOn",e,t,o)||n.someProp("handleTripleClick",i=>i(n,e,o))||Wp(n,t,o)}function Wp(n,e,t){if(t.button!=0)return!1;let o=ws(n,e,!0),i=n.state.doc;return o?(mn(n,o),o instanceof U&&i.eq(n.state.doc)&&(n.input.mouseDown=new $p(n,o)),!0):!1}function ws(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 a=r>i.depth?i.nodeAfter:i.node(r),l=i.before(r);if(a.inlineContent)return U.create(o,l+1,l+1+a.content.size);if(t&&B.isSelectable(a))return B.create(o,l)}return null}function yi(n){return Fn(n)}const Ts=ge?"metaKey":"ctrlKey";le.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let o=yi(n),i=Date.now(),r="singleClick";i-n.input.lastClick.time<500&&zp(t,n.input.lastClick)&&!t[Ts]&&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 a=n.posAtCoords(dn(t));a&&(r=="singleClick"?n.input.mouseDown=new jp(n,a,t,!!o):(r=="doubleClick"?Gp:Lp)(n,a.pos,a.inside,t)?t.preventDefault():Ke(n,"pointer"))};class Is{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 jp extends Is{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[Ts],this.allowDefault=o.shiftKey;let r,a;if(t.inside>-1)r=e.state.doc.nodeAt(t.inside),a=t.inside;else{let d=e.state.doc.resolve(t.pos);r=d.parent,a=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<=a&&p.to>a)&&(this.mightDrag={node:r,pos:a,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(dn(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ke(this.view,"pointer"):Up(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)?(mn(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 $p extends Is{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(dn(e)),o=t&&ws(this.view,t.inside,!1);if(!o)return;let{doc:i}=this.view.state,r=this.startSelection,[a,l]=o.from<r.from?[r.to,o.from]:[r.from,o.to];mn(this.view,U.create(i,a,l))}}le.touchstart=n=>{n.input.lastTouch=Date.now(),yi(n),Ke(n,"pointer")};le.touchmove=n=>{n.input.lastTouch=Date.now(),Ke(n,"pointer")};le.contextmenu=n=>yi(n);function Rs(n,e){return n.composing?!0:ie&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Hp=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&&es&&Jp(n)))n.markCursor=n.state.storedMarks||t.marks(),Fn(n,!0),n.markCursor=null;else if(Fn(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 a=r<0?i.lastChild:i.childNodes[r-1];if(!a)break;if(a.nodeType==3){let l=n.domSelection();l&&l.collapse(a,a.nodeValue.length);break}else i=a,r=-1}}n.input.composing=!0}Cs(n,Hp)};function Jp(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++,Cs(n,20))};function Cs(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Fn(n),e))}function vs(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Qp(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=qu(e.focusNode,e.focusOffset),o=Uu(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 a=t.pmViewDesc;if(!(!a||!a.isText(t.nodeValue)))return o}}return t||o}function Fn(n,e=!1){if(!(Pe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),vs(n),e||n.docView&&n.docView.dirty){let t=mi(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 Xp(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 on=ue&&Je<15||Mt&&ju<604;le.copy=ce.cut=(n,e)=>{let t=e,o=n.state.selection,i=t.type=="cut";if(o.empty)return;let r=on?null:t.clipboardData,a=o.content(),{dom:l,text:c}=fi(n,a);r?(t.preventDefault(),r.clearData(),r.setData("text/html",l.innerHTML),r.setData("text/plain",c)):Xp(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Yp(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Zp(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?rn(n,o.value,null,i,e):rn(n,o.textContent,o.innerHTML,i,e)},50)}function rn(n,e,t,o,i){let r=xs(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 a=Yp(r),l=a?n.state.tr.replaceSelectionWith(a,o):n.state.tr.replaceSelection(r);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Ms(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=on?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;o&&rn(n,Ms(o),o.getData("text/html"),i,t)?t.preventDefault():Zp(n,t)};class Os{constructor(e,t,o){this.slice=e,this.move=t,this.node=o}}const ed=ge?"altKey":"ctrlKey";function Es(n,e){let t;return n.someProp("dragCopies",o=>{t=t||o(e)}),t!=null?!t:!e[ed]}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(dn(t)),a;if(!(r&&r.pos>=i.from&&r.pos<=(i instanceof B?i.to-1:i.to))){if(o&&o.mightDrag)a=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&&(a=B.create(n.state.doc,m.posBefore))}}let l=(a||n.state.selection).content(),{dom:c,text:p,slice:d}=fi(n,l);(!t.dataTransfer.files.length||!te||Za>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(on?"Text":"text/html",c.innerHTML),t.dataTransfer.effectAllowed="copyMove",on||t.dataTransfer.setData("text/plain",p),n.dragging=new Os(d,Es(n,t),a)};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{td(n,e,n.dragging)}finally{n.dragging=null}};function td(n,e,t){if(!e.dataTransfer)return;let o=n.posAtCoords(dn(e));if(!o)return;let i=n.state.doc.resolve(o.pos),r=t&&t.slice;r?n.someProp("transformPasted",b=>{r=b(r,n,!1)}):r=xs(n,Ms(e.dataTransfer),on?null:e.dataTransfer.getData("text/html"),!1,i);let a=!!(t&&Es(n,e));if(n.someProp("handleDrop",b=>b(n,e,r||A.empty,a))){e.preventDefault();return}if(!r)return;e.preventDefault();let l=r?Cu(n.state.doc,i.pos,r):i.pos;l==null&&(l=i.pos);let c=n.state.tr;if(a){let{node:b}=t;b?b.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 b=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((S,_,w,O)=>b=O),c.setSelection(hi(n,g,c.doc.resolve(b)))}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 an(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 qn{constructor(e,t){this.toDOM=e,this.spec=t||dt,this.side=this.spec.side||0}map(e,t,o,i){let{pos:r,deleted:a}=e.mapResult(t.from+i,this.side<0?-1:1);return a?null:new _e(r-o,r-o,this)}valid(){return!0}eq(e){return this==e||e instanceof qn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&an(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ye{constructor(e,t){this.attrs=e,this.spec=t||dt}map(e,t,o,i){let r=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-o,a=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-o;return r>=a?null:new _e(r,a,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Ye&&an(this.attrs,e.attrs)&&an(this.spec,e.spec)}static is(e){return e.type instanceof Ye}destroy(){}}class bi{constructor(e,t){this.attrs=e,this.spec=t||dt}map(e,t,o,i){let r=e.mapResult(t.from+i,1);if(r.deleted)return null;let a=e.mapResult(t.to+i,-1);return a.deleted||a.pos<=r.pos?null:new _e(r.pos-o,a.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 bi&&an(this.attrs,e.attrs)&&an(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 qn(t,o))}static inline(e,t,o,i){return new _e(e,t,new Ye(o,i))}static node(e,t,o,i){return new _e(e,t,new bi(o,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ye}get widget(){return this.type instanceof qn}}const It=[],dt={};class J{constructor(e,t){this.local=e.length?e:It,this.children=t.length?t:It}static create(e,t){return t.length?Un(t,e,0,dt):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 a=0;a<this.local.length;a++){let l=this.local[a];l.from<=t&&l.to>=e&&(!r||r(l.spec))&&o.push(l.copy(l.from+i,l.to+i))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let l=this.children[a]+1;this.children[a+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||dt)}mapInner(e,t,o,i,r){let a;for(let l=0;l<this.local.length;l++){let c=this.local[l].map(e,o,i);c&&c.type.valid(t,c)?(a||(a=[])).push(c):r.onRemove&&r.onRemove(this.local[l].spec)}return this.children.length?nd(this.children,a||[],e,t,o,i,r):a?new J(a.sort(mt),It):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=Ns(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,Un(d,l,p+1,dt)),r+=3}});let a=As(r?Ds(t):t,-o);for(let l=0;l<a.length;l++)a[l].type.valid(e,a[l])||a.splice(l--,1);return new J(a.length?this.local.concat(a).sort(mt):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 a,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,(a||(a=[])).push(m));if(!a)continue;o==this.children&&(o=this.children.slice());let p=o[r+2].removeInner(a,l+1);p!=oe?o[r+2]=p:(o.splice(r,3),r-=3)}if(i.length){for(let r=0,a;r<e.length;r++)if(a=e[r])for(let l=0;l<i.length;l++)i[l].eq(a,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,a=r+t.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<a&&c.to>r&&c.type instanceof Ye){let p=Math.max(r,c.from)-r,d=Math.min(a,c.to)-r;p<d&&(i||(i=[])).push(c.copy(p,d))}}if(i){let l=new J(i.sort(mt),It);return o?new je([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 It;if(e.inlineContent||!this.local.some(Ye.is))return this.local;let t=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof Ye||t.push(this.local[o]);return t}forEachSet(e){e(this)}}J.empty=new J([],[]);J.removeOverlap=Si;const oe=J.empty;class je{constructor(e){this.members=e}map(e,t){const o=this.members.map(i=>i.map(e,t,dt));return je.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 je?o=o.concat(r.members):o.push(r))}return je.from(o)}eq(e){if(!(e instanceof je)||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 a=0;a<r.length;a++)t.push(r[a])}}return t?Si(o?t:t.sort(mt)):It}static from(e){switch(e.length){case 0:return oe;case 1:return e[0];default:return new je(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 nd(n,e,t,o,i,r,a){let l=n.slice();for(let p=0,d=r;p<t.maps.length;p++){let m=0;t.maps[p].forEach((g,b,S,_)=>{let w=_-S-(b-g);for(let O=0;O<l.length;O+=3){let L=l[O+1];if(L<0||g>L+d-m)continue;let F=l[O]+d-m;b>=F?l[O+1]=g<=F?-2:-1:g>=d&&w&&(l[O]+=w,l[O+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),b=g-i,{index:S,offset:_}=o.content.findIndex(m),w=o.maybeChild(S);if(w&&_==m&&_+w.nodeSize==b){let O=l[p+2].mapInner(t,w,d+1,n[p]+r+1,a);O!=oe?(l[p]=m,l[p+1]=b,l[p+2]=O):(l[p+1]=-2,c=!0)}else c=!0}if(c){let p=od(l,n,e,t,i,r,a),d=Un(p,o,0,a);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 b=d.children[m];for(;g<l.length&&l[g]<b;)g+=3;l.splice(g,0,d.children[m],d.children[m+1],d.children[m+2])}}return new J(e.sort(mt),l)}function As(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 od(n,e,t,o,i,r,a){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):a.onRemove&&a.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 Ns(n,e,t){if(e.isLeaf)return null;let o=t+e.nodeSize,i=null;for(let r=0,a;r<n.length;r++)(a=n[r])&&a.from>t&&a.to<o&&((i||(i=[])).push(a),n[r]=null);return i}function Ds(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Un(n,e,t,o){let i=[],r=!1;e.forEach((l,c)=>{let p=Ns(n,l,c+t);if(p){r=!0;let d=Un(p,l,t+c+1,o);d!=oe&&i.push(c,c+l.nodeSize,d)}});let a=As(r?Ds(n):n,-t).sort(mt);for(let l=0;l<a.length;l++)a[l].type.valid(e,a[l])||(o.onRemove&&o.onRemove(a[l].spec),a.splice(l--,1));return a.length||i.length?new J(a,i):oe}function mt(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),Pr(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),Pr(e,i,o.copy(r.from,o.to)));break}}}return e}function Pr(n,e,t){for(;e<n.length&&mt(t,n[e])>0;)e++;n.splice(e,0,t)}function Eo(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])),je.from(e)}const id={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},rd=ue&&Je<=11;class ad{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 sd{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ad,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&&Je<=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()}),rd&&(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,id)),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(Or(this.view)){if(this.suppressingSelectionUpdates)return ze(this.view);if(ue&&Je<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&xt(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=vt(r))t.add(r);for(let r=e.anchorNode;r;r=vt(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)&&Or(e)&&!this.ignoreSelectionChange(o),r=-1,a=-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),a=a<0?m.to:Math.max(m.to,a),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 b=g.parentNode;b&&b.nodeName=="LI"&&(!m||ud(e,m)!=b)&&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&&Qn(o)&&(p=mi(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,a),ld(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,pd(e,c)),this.handleDOMChange(r,a,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&&Je<=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 a=i&&i.parentNode==e.target?Z(i)+1:0,l=o.localPosFromDOM(e.target,a,-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 Kr=new WeakMap,zr=!1;function ld(n){if(!Kr.has(n)&&(Kr.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=ye,zr)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."),zr=!0}}function Fr(n,e){let t=e.startContainer,o=e.startOffset,i=e.endContainer,r=e.endOffset,a=n.domAtPos(n.state.selection.anchor);return xt(a.node,a.offset,i,r)&&([t,o,i,r]=[i,r,t,o]),{anchorNode:t,anchorOffset:o,focusNode:i,focusOffset:r}}function cd(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return Fr(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?Fr(n,t):null}function ud(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 pd(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 a=r.nextSibling;for(;a&&a.nodeName!="TD"&&a.nodeName!="TH";)a=a.nextSibling;if(a){let l=a;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 dd(n,e,t,o){let{node:i,fromOffset:r,toOffset:a,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}],Qn(p)||d.push({node:p.focusNode,offset:p.focusOffset})),te&&n.input.lastKeyCode===8)for(let O=a;O>r;O--){let L=i.childNodes[O-1],F=L.pmViewDesc;if(L.nodeName=="BR"&&!F){a=O;break}if(!F||F.size)break}let g=n.state.doc,b=n.someProp("domParser")||Zt.fromSchema(n.state.schema),S=g.resolve(l),_=null,w=b.parse(i,{topNode:S.parent,topMatch:S.parent.contentMatchAt(S.index()),topOpen:!0,from:r,to:a,preserveWhitespace:S.parent.type.whitespace=="pre"?"full":!0,findPositions:d,ruleFromNode:md(o),context:S});if(d&&d[0].pos!=null){let O=d[0].pos,L=d[1]&&d[1].pos;L==null&&(L=O),_={anchor:O+l,head:L+l}}return{doc:w,sel:_,from:l,to:c}}const md=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},hd=/^(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 fd(n,e,t,o,i){let r=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let C=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,T=mi(n,C);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);C=="pointer"?D.setMeta("pointer",!0):C=="key"&&D.scrollIntoView(),r&&D.setMeta("composition",r),n.dispatch(D)}return}let a=n.state.doc.resolve(e),l=a.sharedDepth(t);e=a.before(l+1),t=n.state.doc.resolve(t).after(l+1);let c=n.state.selection,p=dd(n,e,t,i),d=n.state.doc,m=d.slice(p.from,p.to),g,b;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(g=n.state.selection.to,b="end"):(g=n.state.selection.from,b="start"),n.input.lastKeyCode=null;let S=yd(m.content,p.doc.content,p.from,g,b);if(S&&n.input.domChangeCount++,(Mt&&n.input.lastIOSEnter>Date.now()-225||Pe)&&i.some(C=>C.nodeType==1&&!hd.test(C.nodeName))&&(!S||S.endA>=S.endB)&&n.someProp("handleKeyDown",C=>C(n,st(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!S)if(o&&c instanceof U&&!c.empty&&c.$head.sameParent(c.$anchor)&&!n.composing&&!(p.sel&&p.sel.anchor!=p.sel.head))S={start:c.from,endA:c.to,endB:c.to};else{if(p.sel){let C=qr(n,n.state.doc,p.sel);if(C&&!C.eq(n.state.selection)){let T=n.state.tr.setSelection(C);r&&T.setMeta("composition",r),n.dispatch(T)}}return}n.state.selection.from<n.state.selection.to&&S.start==S.endB&&n.state.selection instanceof U&&(S.start>n.state.selection.from&&S.start<=n.state.selection.from+2&&n.state.selection.from>=p.from?S.start=n.state.selection.from:S.endA<n.state.selection.to&&S.endA>=n.state.selection.to-2&&n.state.selection.to<=p.to&&(S.endB+=n.state.selection.to-S.endA,S.endA=n.state.selection.to)),ue&&Je<=11&&S.endB==S.start+1&&S.endA==S.start&&S.start>p.from&&p.doc.textBetween(S.start-p.from-1,S.start-p.from+1)=="  "&&(S.start--,S.endA--,S.endB--);let _=p.doc.resolveNoCache(S.start-p.from),w=p.doc.resolveNoCache(S.endB-p.from),O=d.resolve(S.start),L=_.sameParent(w)&&_.parent.inlineContent&&O.end()>=S.endA;if((Mt&&n.input.lastIOSEnter>Date.now()-225&&(!L||i.some(C=>C.nodeName=="DIV"||C.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",C=>C(n,st(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>S.start&&xd(d,S.start,S.endA,_,w)&&n.someProp("handleKeyDown",C=>C(n,st(8,"Backspace")))){Pe&&te&&n.domObserver.suppressSelectionUpdates();return}te&&S.endB==S.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==S.endA&&(S.endB-=2,w=p.doc.resolveNoCache(S.endB-p.from),setTimeout(()=>{n.someProp("handleKeyDown",function(C){return C(n,st(13,"Enter"))})},20));let F=S.start,ne=S.endA,v=C=>{let T=C||n.state.tr.replace(F,ne,p.doc.slice(S.start-p.from,S.endB-p.from));if(p.sel){let D=qr(n,T.doc,p.sel);D&&!(te&&n.composing&&D.empty&&(S.start!=S.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&&Je<=11&&_.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>ze(n),20));let C=v(n.state.tr.delete(F,ne)),T=d.resolve(S.start).marksAcross(d.resolve(S.endA));T&&C.ensureMarks(T),n.dispatch(C)}else if(S.endA==S.endB&&(I=gd(_.parent.content.cut(_.parentOffset,w.parentOffset),O.parent.content.cut(O.parentOffset,S.endA-O.start())))){let C=v(n.state.tr);I.type=="add"?C.addMark(F,ne,I.mark):C.removeMark(F,ne,I.mark),n.dispatch(C)}else if(_.parent.child(_.index()).isText&&_.index()==w.index()-(w.textOffset?0:1)){let C=_.parent.textBetween(_.parentOffset,w.parentOffset),T=()=>v(n.state.tr.insertText(C,F,ne));n.someProp("handleTextInput",D=>D(n,F,ne,C,T))||n.dispatch(T())}else n.dispatch(v());else n.dispatch(v())}function qr(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:hi(n,e.resolve(t.anchor),e.resolve(t.head))}function gd(n,e){let t=n.firstChild.marks,o=e.firstChild.marks,i=t,r=o,a,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],a="add",c=d=>d.mark(l.addToSet(d.marks));else if(i.length==0&&r.length==1)l=r[0],a="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(R.from(p).eq(n))return{mark:l,type:a}}function xd(n,e,t,o,i){if(t-e<=i.pos-o.pos||Ao(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 a=n.resolve(Ao(r,!0,!0));return!a.parent.isTextblock||a.pos>t||Ao(a,!0,!1)<t?!1:o.parent.content.cut(o.parentOffset).eq(a.parent.content)}function Ao(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 yd(n,e,t,o,i){let r=n.findDiffStart(e,t),a=t+n.size,l=t+e.size;if(r==null)return null;let{a:c,b:p}=n.findDiffEnd(e,a,l);if(i=="end"){let d=Math.max(0,r-Math.min(c,p));o-=c+d-r}if(c<r&&a<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 bd{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 Dp,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(jr),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=Lr(this),Gr(this),this.nodeViews=Wr(this),this.docView=Tr(this.state.doc,Ur(this),Eo(this),this.dom,this),this.domObserver=new sd(this,(o,i,r,a)=>fd(this,o,i,r,a)),this.domObserver.start(),Bp(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&&ni(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(jr),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,a=!1;e.storedMarks&&this.composing&&(vs(this),a=!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 b=Wr(this);kd(b,this.nodeViews)&&(this.nodeViews=b,r=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&ni(this),this.editable=Lr(this),Gr(this);let c=Eo(this),p=Ur(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))&&(a=!0);let g=d=="preserve"&&a&&this.dom.style.overflowAnchor==null&&Ju(this);if(a){this.domObserver.stop();let b=m&&(ue||te)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Sd(i.selection,e.selection);if(m){let _=te?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Qp(this)),(r||!this.docView.update(e.doc,p,c,this))&&(this.docView.updateOuterDeco(p),this.docView.destroy(),this.docView=Tr(e.doc,p,c,this.dom,this)),_&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(b=!0)}let S=this.input.mouseDown;b||!(S&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&bp(this)&&S.delaySelUpdate())?ze(this,b):(hs(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&&Qu(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&&br(this,t.getBoundingClientRect(),e)}else br(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 Os(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 a=0;a<this.directPlugins.length;a++){let l=this.directPlugins[a].props[e];if(l!=null&&(i=t?t(l):l))return i}let r=this.state.plugins;if(r)for(let a=0;a<r.length;a++){let l=r[a].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&&Xu(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 np(this,e)}coordsAtPos(e,t=1){return as(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 sp(this,t||this.state,e)}pasteHTML(e,t){return rn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return rn(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return fi(this,e)}destroy(){this.docView&&(Vp(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Eo(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,zu())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Kp(this,e)}domSelectionRange(){let e=this.domSelection();return e?ie&&this.root.nodeType===11&&Lu(this.dom.ownerDocument)==this.dom&&cd(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}bd.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function Ur(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 Gr(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 Lr(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Sd(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 Wr(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 kd(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 jr(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 Bs=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function _d(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const wd=(n,e,t)=>{let o=_d(n,t);if(!o)return!1;let i=Vs(o);if(!i){let a=o.blockRange(),l=a&&ci(a);return l==null?!1:(e&&e(n.tr.lift(a,l).scrollIntoView()),!0)}let r=i.nodeBefore;if(Ks(n,i,e,-1))return!0;if(o.parent.content.size==0&&(Ot(r,"end")||B.isSelectable(r)))for(let a=o.depth;;a--){let l=ui(n.doc,o.before(a),o.after(a),A.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=n.tr.step(l);c.setSelection(Ot(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(a==1||o.node(a-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 Ot(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 Td=(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=Vs(o)}let a=r&&r.nodeBefore;return!a||!B.isSelectable(a)?!1:(e&&e(n.tr.setSelection(B.create(n.doc,r.pos-a.nodeSize)).scrollIntoView()),!0)};function Vs(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 Id(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Rd=(n,e,t)=>{let o=Id(n,t);if(!o)return!1;let i=Ps(o);if(!i)return!1;let r=i.nodeAfter;if(Ks(n,i,e,1))return!0;if(o.parent.content.size==0&&(Ot(r,"start")||B.isSelectable(r))){let a=ui(n.doc,o.before(),o.after(),A.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=n.tr.step(a);l.setSelection(Ot(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},Cd=(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=Ps(o)}let a=r&&r.nodeAfter;return!a||!B.isSelectable(a)?!1:(e&&e(n.tr.setSelection(B.create(n.doc,r.pos)).scrollIntoView()),!0)};function Ps(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 vd=(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 ki(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 Md=(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),a=ki(i.contentMatchAt(r));if(!a||!i.canReplaceWith(r,r,a))return!1;if(e){let l=t.after(),c=n.tr.replaceWith(l,l,a.createAndFill());c.setSelection(G.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},Od=(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=ki(i.parent.contentMatchAt(i.indexAfter()));if(!r||!r.isTextblock)return!1;if(e){let a=(!o.parentOffset&&i.index()<i.parent.childCount?o:i).pos,l=n.tr.insert(a,r.createAndFill());l.setSelection(U.create(l.doc,a+1)),e(l.scrollIntoView())}return!0},Ed=(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(Nn(n.doc,r))return e&&e(n.tr.split(r).scrollIntoView()),!0}let o=t.blockRange(),i=o&&ci(o);return i==null?!1:(e&&e(n.tr.lift(o,i).scrollIntoView()),!0)};function Ad(n){return(e,t)=>{if(e.selection instanceof B&&e.selection.node.isBlock){let{$from:b}=e.selection;return!b.parentOffset||!Nn(e.doc,b.pos)?!1:(t&&t(e.tr.split(b.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,a=[],l,c,p=!1,d=!1;for(let b=i.depth;;b--)if(i.node(b).isBlock){p=i.end(b)==i.pos+(i.depth-b),d=i.start(b)==i.pos-(i.depth-b),c=ki(i.node(b-1).contentMatchAt(i.indexAfter(b-1))),a.unshift(p&&c?{type:c}:null),l=b;break}else{if(b==1)return!1;a.unshift(null)}let m=i.pos,g=Nn(o.doc,m,a.length,a);if(g||(a[0]=c?{type:c}:null,g=Nn(o.doc,m,a.length,a)),!g)return!1;if(o.split(m,a.length,a),!p&&d&&i.node(l).type!=c){let b=o.mapping.slice(r),S=b.map(i.before(l)),_=o.doc.resolve(S);c&&i.node(l-1).canReplaceWith(_.index(),_.index()+1,c)&&o.setNodeMarkup(b.map(i.before(l)),c)}return t&&t(o.scrollIntoView()),!0}}const Nd=Ad(),Dd=(n,e)=>(e&&e(n.tr.setSelection(new he(n.doc))),!0);function Bd(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||Ga(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Ks(n,e,t,o){let i=e.nodeBefore,r=e.nodeAfter,a,l,c=i.type.spec.isolating||r.type.spec.isolating;if(!c&&Bd(n,e,t))return!0;let p=!c&&e.parent.canReplace(e.index(),e.index()+1);if(p&&(a=(l=i.contentMatchAt(i.childCount)).findWrapping(r.type))&&l.matchType(a[0]||r.type).validEnd){if(t){let b=e.pos+r.nodeSize,S=R.empty;for(let O=a.length-1;O>=0;O--)S=R.from(a[O].create(null,S));S=R.from(i.copy(S));let _=n.tr.step(new me(e.pos-1,b,e.pos,b,new A(S,1,0),a.length,!0)),w=_.doc.resolve(b+2*a.length);w.nodeAfter&&w.nodeAfter.type==i.type&&Ga(_.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&&ci(m);if(g!=null&&g>=e.depth)return t&&t(n.tr.lift(m,g).scrollIntoView()),!0;if(p&&Ot(r,"start",!0)&&Ot(i,"end")){let b=i,S=[];for(;S.push(b),!b.isTextblock;)b=b.lastChild;let _=r,w=1;for(;!_.isTextblock;_=_.firstChild)w++;if(b.canReplace(b.childCount,b.childCount,_.content)){if(t){let O=R.empty;for(let F=S.length-1;F>=0;F--)O=R.from(S[F].copy(O));let L=n.tr.step(new me(e.pos-S.length,e.pos+r.nodeSize,e.pos+w,e.pos+r.nodeSize-w,new A(O,S.length,0),0,!0));t(L.scrollIntoView())}return!0}}return!1}function zs(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 Vd=zs(-1),Pd=zs(1);function _i(...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 No=_i(Bs,wd,Td),$r=_i(Bs,Rd,Cd);const Ve={Enter:_i(vd,Od,Ed,Nd),"Mod-Enter":Md,Backspace:No,"Mod-Backspace":No,"Shift-Backspace":No,Delete:$r,"Mod-Delete":$r,"Mod-a":Dd},Fs={"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":Vd,"Ctrl-e":Pd};for(let n in Ve)Fs[n]=Ve[n];const Kd=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,t_=Kd?Fs:Ve;var Gn=200,Q=function(){};Q.prototype.append=function(e){return e.length?(e=Q.from(e),!this.length&&e||e.length<Gn&&this.leafAppend(e)||this.length<Gn&&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 zd(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,a){return i.push(e(r,a))},t,o),i};Q.from=function(e){return e instanceof Q?e:e&&e.length?new qs(e):Q.empty};var qs=(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,a,l){for(var c=r;c<a;c++)if(i(this.values[c],l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(i,r,a,l){for(var c=r-1;c>=a;c--)if(i(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Gn)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Gn)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 qs([]);var zd=(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,a){var l=this.left.length;if(i<l&&this.left.forEachInner(o,i,Math.min(r,l),a)===!1||r>l&&this.right.forEachInner(o,Math.max(i-l,0),Math.min(this.length,r)-l,a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,r,a){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(o,i-l,Math.max(r,l)-l,a+l)===!1||r<l&&this.left.forEachInvertedInner(o,Math.min(i,l),r,a)===!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 Fd=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 a=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 Re(m.map));let b=m.step.map(i.slice(r)),S;b&&a.maybeStep(b).doc&&(S=a.mapping.maps[a.mapping.maps.length-1],p.push(new Re(S,void 0,void 0,p.length+d.length))),r--,S&&i.appendMap(S,r)}else a.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:a,selection:l}}addTransform(e,t,o,i){let r=[],a=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 Re(e.mapping.maps[d],m,t),b;(b=c&&c.merge(g))&&(g=b,d?r.pop():l=l.slice(0,l.length-1)),r.push(g),t&&(a++,t=void 0),i||(c=g)}let p=a-o.depth;return p>Ud&&(l=qd(l,p),a-=p),new ke(l.append(r),a)}remapping(e,t){let o=new tn;return this.items.forEach((i,r)=>{let a=i.mirrorOffset!=null&&r-i.mirrorOffset>=e?o.maps.length-i.mirrorOffset:void 0;o.appendMap(i.map,a)},e,t),o}addMaps(e){return this.eventCount==0?this:new ke(this.items.append(e.map(t=>new Re(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let o=[],i=Math.max(0,this.items.length-t),r=e.mapping,a=e.steps.length,l=this.eventCount;this.items.forEach(g=>{g.selection&&l--},i);let c=t;this.items.forEach(g=>{let b=r.getMirror(--c);if(b==null)return;a=Math.min(a,b);let S=r.maps[b];if(g.step){let _=e.steps[b].invert(e.docs[b]),w=g.selection&&g.selection.map(r.slice(c+1,b));w&&l++,o.push(new Re(S,_,w))}else o.push(new Re(S))},i);let p=[];for(let g=t;g<a;g++)p.push(new Re(r.maps[g]));let d=this.items.slice(0,i).append(p).append(o),m=new ke(d,l);return m.emptyItemCount()>Fd&&(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((a,l)=>{if(l>=e)i.push(a),a.selection&&r++;else if(a.step){let c=a.step.map(t.slice(o)),p=c&&c.getMap();if(o--,p&&t.appendMap(p,o),c){let d=a.selection&&a.selection.map(t.slice(o));d&&r++;let m=new Re(p.invert(),c,d),g,b=i.length-1;(g=i.length&&i[b].merge(m))?i[b]=g:i.push(m)}}else a.map&&o--},this.items.length,0),new ke(Q.from(i.reverse()),r)}}ke.empty=new ke(Q.empty,0);function qd(n,e){let t;return n.forEach((o,i)=>{if(o.selection&&e--==0)return t=i,!1}),n.slice(t)}class Re{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 Re(t.getMap().invert(),t,this.selection)}}}class We{constructor(e,t,o,i,r){this.done=e,this.undone=t,this.prevRanges=o,this.prevTime=i,this.prevComposition=r}}const Ud=20;function Gd(n,e,t,o){let i=t.getMeta(ht),r;if(i)return i.historyState;t.getMeta(Us)&&(n=new We(n.done,n.undone,null,0,-1));let a=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(a&&a.getMeta(ht))return a.getMeta(ht).redo?new We(n.done.addTransform(t,void 0,o,Dn(e)),n.undone,Hr(t.mapping.maps),n.prevTime,n.prevComposition):new We(n.done,n.undone.addTransform(t,void 0,o,Dn(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(a&&a.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),c=n.prevTime==0||!a&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-o.newGroupDelay||!Ld(t,n.prevRanges)),p=a?Do(n.prevRanges,t.mapping):Hr(t.mapping.maps);return new We(n.done.addTransform(t,c?e.selection.getBookmark():void 0,o,Dn(e)),ke.empty,p,t.time,l??n.prevComposition)}else return(r=t.getMeta("rebased"))?new We(n.done.rebased(t,r),n.undone.rebased(t,r),Do(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new We(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Do(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Ld(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 Hr(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((o,i,r,a)=>e.push(r,a));return e}function Do(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 Wd(n,e,t){let o=Dn(e),i=ht.get(e).spec.config,r=(t?n.undone:n.done).popEvent(e,o);if(!r)return null;let a=r.selection.resolve(r.transform.doc),l=(t?n.done:n.undone).addTransform(r.transform,e.selection.getBookmark(),i,o),c=new We(t?l:r.remaining,t?r.remaining:l,null,0,-1);return r.transform.setSelection(a).setMeta(ht,{redo:t,historyState:c})}let Bo=!1,Jr=null;function Dn(n){let e=n.plugins;if(Jr!=e){Bo=!1,Jr=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Bo=!0;break}}return Bo}function n_(n){return n.setMeta(Us,!0)}const ht=new Xa("history"),Us=new Xa("closeHistory");function o_(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new Ja({key:ht,state:{init(){return new We(ke.empty,ke.empty,null,0,-1)},apply(e,t,o){return Gd(t,o,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let o=t.inputType,i=o=="historyUndo"?jd:o=="historyRedo"?$d:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function Gs(n,e){return(t,o)=>{let i=ht.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(o){let r=Wd(i,t,n);r&&o(e?r.scrollIntoView():r)}return!0}}const jd=Gs(!1,!0),$d=Gs(!0,!0);var Ze={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:"'"},Ln={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Hd=typeof navigator<"u"&&/Mac/.test(navigator.platform),Jd=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ee=0;ee<10;ee++)Ze[48+ee]=Ze[96+ee]=String(ee);for(var ee=1;ee<=24;ee++)Ze[ee+111]="F"+ee;for(var ee=65;ee<=90;ee++)Ze[ee]=String.fromCharCode(ee+32),Ln[ee]=String.fromCharCode(ee);for(var Vo in Ze)Ln.hasOwnProperty(Vo)||(Ln[Vo]=Ze[Vo]);function Qd(n){var e=Hd&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Jd&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Ln:Ze)[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 Xd=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Yd=typeof navigator<"u"&&/Win/.test(navigator.platform);function Zd(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let o,i,r,a;for(let l=0;l<e.length-1;l++){let c=e[l];if(/^(cmd|meta|m)$/i.test(c))a=!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))Xd?a=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return o&&(t="Alt-"+t),i&&(t="Ctrl-"+t),a&&(t="Meta-"+t),r&&(t="Shift-"+t),t}function em(n){let e=Object.create(null);for(let t in n)e[Zd(t)]=n[t];return e}function Po(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 i_(n){return new Ja({props:{handleKeyDown:tm(n)}})}function tm(n){let e=em(n);return function(t,o){let i=Qd(o),r,a=e[Po(i,o)];if(a&&a(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(o.shiftKey){let l=e[Po(i,o,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((o.altKey||o.metaKey||o.ctrlKey)&&!(Yd&&o.ctrlKey&&o.altKey)&&(r=Ze[o.keyCode])&&r!=i){let l=e[Po(r,o)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const r_=28,Ls=[{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"}];Ls.map(({column:n})=>n);function a_(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 Ls.map(({column:o,type:i})=>({column:o,type:i,value:t[o]}))}const nm=s().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)"),om=s().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)"),im=s().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)"),rm=s().regex(/^nano-banana-[a-z0-9]+(?:-[a-z0-9]+)*$/,"Expected a listed model or a kie Nano Banana alias (e.g. nano-banana-3)"),am=s().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)"),sm=s().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)"),lm=s().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)"),cm=s().regex(/^bytedance\/seedance-\d+(?:\.\d+)*(?:-[a-z][a-z0-9]*)*$/,"Expected a listed model or a kie Seedance alias (e.g. bytedance/seedance-3)"),um=s().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)"),pm=s().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)"),dm=s().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)"),mm=s().regex(/^pixverse-v\d+(?:\.\d+)*(?:-[a-z]+)?\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,"Expected a listed model or a kie PixVerse alias (e.g. pixverse-v7/text-to-video)"),hm=["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","kling-4.0/reference-to-video","kling-4.0/keyframe-to-video","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-5-draft","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","omnihuman-2-0","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","pixverse-v6-max/text-to-video","pixverse-v6-max/image-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"],fm=h(hm).or(nm).or(om).or(im).or(rm).or(am).or(sm).or(lm).or(cm).or(um).or(pm).or(dm).or(mm);h(["image","video","audio","transcription"]);const gm=["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"],xm=h(gm),ym=["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"],bm=h(ym),Sm=h(["Neutral","American (Gen)","American (Valley)","American (South)","British (RP)","British (Brixton)","Transatlantic","Australian"]),km=h(["Vocal Smile","Newscaster","Whisper","Empathetic","Promo/Hype","Deadpan"]),_m=h(["Natural","Rapid Fire","The Drift","Staccato"]),Yn=s().refine(n=>/^Speaker \d+$/.test(n),{message:'Expected a speaker id in "Speaker N" format (e.g. "Speaker 1")'}),Qr={minimum:0,maximum:2},wm=1e4,Tm=h(["user","model"]),Im=h(["low","high"]),Rm=u({mime_type:s().min(1),data:s().min(1)}),Cm=u({mime_type:s().min(1),file_uri:s().min(1)}),vm=u({text:s().optional(),inline_data:Rm.optional(),file_data:Cm.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"}),Zn=u({role:Tm,parts:k(vm).min(1)}),Mm=u({type:s().optional(),properties:z(s(),K()).optional(),required:k(s()).optional()}).passthrough(),Ws=u({name:s().min(1),description:s().optional(),parameters:Mm.optional()}).passthrough(),js=u({}).strict();u({googleSearch:js}).strict();u({functionDeclarations:k(Ws).min(1)}).strict();const eo=u({googleSearch:js.optional(),functionDeclarations:k(Ws).min(1).optional()}).strict().refine(n=>n.googleSearch!==void 0||n.functionDeclarations!==void 0,{message:"tools entries must include googleSearch or functionDeclarations"}),Om=u({includeThoughts:x().optional(),thinkingLevel:Im.optional()}).strict(),to=u({temperature:y().optional(),topP:y().optional(),topK:y().optional(),candidateCount:y().int().positive().optional(),maxOutputTokens:y().int().positive().optional(),stopSequences:k(s()).optional(),thinkingConfig:Om.optional()}).passthrough();u({stream:x().default(!0),contents:k(Zn).min(1),tools:k(eo).optional(),generationConfig:to.optional()}).passthrough();u({stream:x().default(!0),contents:k(Zn).min(1),tools:k(eo).optional(),generationConfig:to.optional()}).passthrough();u({stream:x().default(!0),contents:k(Zn).min(1),tools:k(eo).optional(),generationConfig:to.optional()}).passthrough();u({stream:x().default(!0),contents:k(Zn).min(1),tools:k(eo).optional(),generationConfig:to.optional()}).passthrough();const Em=h(["developer","system","user","assistant","tool"]);h(["text","image_url"]);const Am=h(["low","high"]),Nm=h(["function"]),Dm=h(["googleSearch"]),Bm=u({type:f("text"),text:s()}).strict(),Vm=u({type:f("image_url"),image_url:u({url:s().url()}).strict()}).strict(),Pm=Te("type",[Bm,Vm]),Km=u({role:Em,content:P([s().min(1),k(Pm).min(1)])}).passthrough(),zm=u({type:f("object"),properties:z(s(),K()).optional(),required:k(s()).optional()}).passthrough(),Fm=u({name:Dm,description:s().optional(),parameters:zm.optional()}).passthrough(),qm=u({type:Nm,function:Fm}).strict();u({messages:k(Km).min(1),stream:x().default(!1),tools:k(qm).min(0).optional(),include_thoughts:x().default(!1),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=h(["web_search"]),jm=u({type:f("text"),text:s()}).strict(),$m=u({type:f("image_url"),image_url:u({url:s().url()}).strict()}).strict(),Hm=Te("type",[jm,$m]),Jm=u({role:Um,content:P([s().min(1),k(Hm).min(1)])}).passthrough(),Qm=u({type:f("object"),properties:z(s(),K()).optional(),required:k(s()).optional()}).passthrough(),Xm=u({name:Wm,description:s().optional(),parameters:Qm.optional()}).passthrough(),Ym=u({type:Lm,function:Xm}).strict();u({messages:k(Jm).min(1),tools:k(Ym).min(0).optional(),reasoning_effort:Gm.default("high")}).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:s()}).strict(),oh=u({type:f("image_url"),image_url:u({url:s().url()}).strict()}).strict(),ih=Te("type",[nh,oh]),rh=u({role:Zm,content:k(ih).min(1)}).passthrough(),ah=u({type:f("object"),properties:z(s(),K()).optional(),required:k(s()).optional()}).passthrough(),sh=u({name:s().min(1),description:s().optional(),parameters:ah.optional()}).passthrough(),lh=u({type:th,function:sh}).strict(),ch=u({type:s().optional(),json_schema:z(s(),K()).optional(),properties:z(s(),K()).optional()}).passthrough();u({messages:k(rh).min(1),stream:x().default(!1),tools:k(lh).min(0).optional(),include_thoughts:x().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:s()}).strict(),hh=u({type:f("image_url"),image_url:u({url:s().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(s(),K()).optional(),required:k(s()).optional()}).passthrough(),yh=u({name:s().min(1),description:s().optional(),parameters:xh.optional()}).passthrough(),bh=u({type:dh,function:yh}).strict(),Sh=u({type:s().optional(),json_schema:z(s(),K()).optional(),properties:z(s(),K()).optional()}).passthrough();u({messages:k(gh).min(1),stream:x().default(!1),tools:k(bh).min(0).optional(),include_thoughts:x().optional(),reasoning_effort:ph.optional(),response_format:Sh.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:s()}).strict(),Ih=u({type:f("image_url"),image_url:u({url:s().url()}).strict()}).strict(),Rh=Te("type",[Th,Ih]),Ch=u({role:kh,content:k(Rh).min(1)}).passthrough(),vh=u({type:f("object"),properties:z(s(),K()).optional(),required:k(s()).optional()}).passthrough(),Mh=u({name:s().min(1),description:s().optional(),parameters:vh.optional()}).passthrough(),Oh=u({type:wh,function:Mh}).strict(),Eh=u({type:s().optional(),json_schema:z(s(),K()).optional(),properties:z(s(),K()).optional()}).passthrough();u({messages:k(Ch).min(1),stream:x().default(!1),tools:k(Oh).min(0).optional(),include_thoughts:x().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:s()}).strict(),Vh=u({type:f("image_url"),image_url:u({url:s().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(s(),K()).optional(),required:k(s()).optional()}).passthrough(),Fh=u({name:s().min(1),description:s().optional(),parameters:zh.optional()}).passthrough(),qh=u({type:Dh,function:Fh}).strict(),Uh=u({type:s().optional(),json_schema:z(s(),K()).optional(),properties:z(s(),K()).optional()}).passthrough();u({messages:k(Kh).min(1),stream:x().default(!1),tools:k(qh).min(0).optional(),include_thoughts:x().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"]),jh=u({type:f("text"),text:s()}).strict(),$h=u({type:f("image_url"),image_url:u({url:s().url()}).strict()}).strict(),Hh=Te("type",[jh,$h]),Jh=u({role:Gh,content:k(Hh).min(1)}).passthrough(),Qh=u({type:f("object"),properties:z(s(),K()).optional(),required:k(s()).optional()}).passthrough(),Xh=u({name:s().min(1),description:s().optional(),parameters:Qh.optional()}).passthrough(),Yh=u({type:Wh,function:Xh}).strict(),Zh=u({type:s().optional(),json_schema:z(s(),K()).optional(),properties:z(s(),K()).optional()}).passthrough();u({messages:k(Jh).min(1),stream:x().default(!1),tools:k(Yh).min(0).optional(),include_thoughts:x().optional(),reasoning_effort:Lh.optional(),response_format:Zh.optional()}).passthrough();const ef=h(["developer","system","user","assistant","tool"]);h(["text","image_url"]);const tf=h(["low","high"]),nf=h(["function"]),of=u({type:f("text"),text:s()}).strict(),rf=u({type:f("image_url"),image_url:u({url:s().url()}).strict()}).strict(),af=Te("type",[of,rf]),sf=u({role:ef,content:k(af).min(1)}).passthrough(),lf=u({type:f("object"),properties:z(s(),K()).optional(),required:k(s()).optional()}).passthrough(),cf=u({name:s().min(1),description:s().optional(),parameters:lf.optional()}).passthrough(),uf=u({type:nf,function:cf}).strict(),pf=u({type:s().optional(),json_schema:z(s(),K()).optional(),properties:z(s(),K()).optional()}).passthrough();u({messages:k(sf).min(1),stream:x().default(!1),tools:k(uf).min(0).optional(),include_thoughts:x().default(!1),reasoning_effort:tf.default("high"),response_format:pf.optional()}).passthrough();const df=h(["developer","system","user","assistant","tool"]);h(["text","image_url"]);const mf=h(["function"]),hf=h(["low","high"]),ff=u({type:f("text"),text:s()}).strict(),gf=u({type:f("image_url"),image_url:u({url:s().url()}).strict()}).strict(),xf=Te("type",[ff,gf]),yf=u({role:df,content:k(xf).min(1)}).passthrough(),bf=u({type:f("object"),properties:z(s(),K()).optional(),required:k(s()).optional()}).passthrough(),Sf=u({name:s().min(1),description:s().optional(),parameters:bf.optional()}).passthrough(),kf=u({type:mf,function:Sf}).strict(),_f=u({type:s().optional(),json_schema:z(s(),K()).optional(),properties:z(s(),K()).optional()}).passthrough();u({messages:k(yf).min(1),stream:x().default(!1),tools:k(kf).min(0).optional(),include_thoughts:x().default(!1),reasoning_effort:hf.default("high"),response_format:_f.optional()}).passthrough();const wf=h(["3","4","5","6","7","8","9","10","11","12","13","14","15"]),no=h(["16:9","9:16","1:1"]),Tf=h(["std","pro","4K"]),$s=h(["720p","1080p"]),If=h(["1:1","9:16","16:9"]),Rf=s().regex(/^[1-9]\d*$/),Cf=h(["3","4","5","6","7","8","9","10","11","12","13","14","15"]),vf=h(["fun","normal","spicy"]),Mf=h(["fun","normal","spicy"]);h(["fun","normal","spicy"]);const Of=h(["2:3","3:2","1:1","16:9","9:16"]),Ef=h(["2:3","3:2","1:1","16:9","9:16"]),Hs=y().int().min(6).max(30),Js=s().regex(/^(?:[6-9]|[12][0-9]|30)$/),Af=P([Hs,Js]),Nf=P([Hs,Js]),Df=h(["6","10"]),wi=h(["480p","720p","1080p"]),Bf=h(["480p","720p"]),Vf=[".jpg",".jpeg",".png",".webp"];function Pf(n){try{const e=new URL(n).pathname.toLowerCase();return Vf.some(t=>e.endsWith(t))}catch{return!1}}const Kf=s().url().refine(Pf,{message:"image_urls entries must be JPEG, PNG, or WEBP URLs"}),zf=h(["auto","1:1","16:9","9:16","4:3","3:4","3:2","2:3"]),Ti=h(["1K","2K","4K"]),Ii=h(["png","jpg"]),Qs=h(["medium","high"]),Ff=h(["1:1","3:4","4:3","9:16","16:9"]),Xs=h(["1K","2K"]),qf=h(["1:1","3:2","2:3","4:3","3:4","16:9","9:16","21:9"]),Uf=h(["png","jpeg"]),Ys=h(["square","square_hd","portrait_4_3","portrait_16_9","landscape_4_3","landscape_16_9"]),Ri=h(["none","regular","high"]),Gf=h(["1","2","3","4"]),oo=h(["720p","1080p"]),Ci=h(["16:9","9:16","1:1","4:3","3:4"]),Lf=h(["auto","origin"]),Wf=h(["1K","2K","4K"]),jf=h(["1:1","16:9","4:3","21:9","3:4","9:16","8:1","1:8"]),$f=y().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."),bt=h(["720p","1080p"]),Zs=h(["16:9","9:16","1:1","4:3","3:4"]),el=h(["16:9","9:16","3:4","4:3","4:5","5:4","1:1","9:21","21:9"]),Hf=h(["auto","origin"]),Jf=3,Qf=15,At=y().int().min(Jf).max(Qf),Xf=h(["720","1080"]),Yf=h(["lite","basic"]),tl=h(["4","6","8","10"]),nl=h(["16:9","9:16"]),Zf=h(["720p","1080p","4k"]),eg=h(["360p","720p","1080p","4k"]),tg=h(["480p","720p"]),ng=h(["16:9","4:3","1:1","3:4","9:16","21:9","adaptive"]),og=h(["waiting","success","fail"]),vi=s().min(1).max(7e3),Mi=y().int().min(4).max(15),Oi=h(["768P","2K"]),ol=h(["21:9","16:9","4:3","1:1","3:4","9:16"]),ig=h(["adaptive",...ol.options]),rg=new Set(["http:","https:","oss:"]);function ag(n){try{return rg.has(new URL(n).protocol)}catch{return!1}}const Qt=s().url().refine(ag,{message:"Expected an HTTP, HTTPS, or OSS media address"}),Xr={video:{minimum:2e3,maximum:15e3,maximumTotal:15e3},audio:{minimum:2e3,maximum:15e3,maximumTotal:15e3}};function Yr(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 sg=u({name:s().min(1),description:s().min(1),element_input_urls:k(s()).optional(),element_input_video_urls:k(s()).optional()}),lg=u({prompt:s().min(1).max(500),duration:y().int().min(1).max(12)}),io=h(["720p","1080p","4k"]),Ei=y().int().min(3).max(15),Ai=h(["16:9","9:16","1:1","auto"]),yt=s().refine(n=>/^(https?|oss):\/\//.test(n),{message:"Expected an HTTP, HTTPS, or OSS media reference"}),cg=u({prompt:s().min(1).max(512),duration:y().int().min(1).max(15)}),Ni=k(cg).max(6),ro=u({name:s().min(1),description:s().min(1),element_input_urls:k(yt).min(1).max(4),element_input_audio_urls:k(yt).optional(),start_time:y().int().optional(),end_time:y().int().optional()}),ao=s().min(1).max(3072).refine(n=>n.trim().length>0,{message:"Prompt must contain a non-whitespace character"}),Di=x().optional().describe("Enable intelligent shot planning; mutually exclusive with customize_multi_shots");function Bi(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 ug=u({hex:s().min(1),ratio:s().min(1)}),tt=h(["5","10"]),Nt=y().min(0).max(1),pg=u({model:f("kling-2.6/text-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(1e3),sound:x(),aspect_ratio:no,duration:tt})}),dg=u({model:f("kling-2.6/image-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(1e3),image_urls:k(s().min(1)).min(1).max(1),sound:x(),duration:tt})}),mg=u({model:f("kling-2.6/motion-control"),callBackUrl:s().optional(),input:u({prompt:s().max(2500).optional(),input_urls:k(s().min(1)).min(1).max(1),video_urls:k(s().min(1)).min(1).max(1),character_orientation:h(["image","video"]),mode:h(["720p","1080p"])})}),il=u({image_url:s().min(1),audio_url:s().min(1),prompt:s().max(5e3)}),hg=u({model:f("kling/ai-avatar-pro"),callBackUrl:s().optional(),input:il}),fg=u({model:f("kling/ai-avatar-standard"),callBackUrl:s().optional(),input:il}),gg=u({model:f("kling/v2-1-master-image-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),image_url:s().min(1),duration:tt.optional(),negative_prompt:s().max(500).optional(),cfg_scale:Nt.optional()})}),xg=u({model:f("kling/v2-1-master-text-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),duration:tt.optional(),aspect_ratio:no.optional(),negative_prompt:s().max(500).optional(),cfg_scale:Nt.optional()})}),yg=u({model:f("kling/v2-1-pro"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),image_url:s().min(1),duration:tt.optional(),negative_prompt:s().max(500).optional(),cfg_scale:Nt.optional(),tail_image_url:s().min(1).optional()})}),bg=u({model:f("kling/v2-1-standard"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),image_url:s().min(1),duration:tt.optional(),negative_prompt:s().max(500).optional(),cfg_scale:Nt.optional()})}),Sg=u({model:f("kling/v2-5-turbo-image-to-video-pro"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(2500),image_url:s().min(1),tail_image_url:s().min(1).optional(),duration:tt.optional(),negative_prompt:s().max(500).optional(),cfg_scale:Nt.optional()})}),kg=u({model:f("kling/v2-5-turbo-text-to-video-pro"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(2500),duration:tt.optional(),aspect_ratio:no.optional(),negative_prompt:s().max(2500).optional(),cfg_scale:Nt.optional()})}),_g=u({model:f("kling-3.0/video"),callBackUrl:s().optional(),input:u({prompt:s().optional(),image_urls:k(s()).optional(),sound:x().optional(),duration:wf,aspect_ratio:no.optional(),mode:Tf,multi_shots:x(),multi_prompt:k(lg).optional(),kling_elements:k(sg).max(3).optional()})}),wg=u({model:f("kling/v3-turbo-image-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1),image_urls:k(s().min(1)).min(1).max(1),duration:Rf,resolution:$s})}),Tg=u({model:f("kling/v3-turbo-text-to-video"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(2500),duration:Cf.default("5"),aspect_ratio:If.default("16:9"),resolution:$s.default("720p")})}),Ig=u({model:f("kling-3.0/motion-control"),callBackUrl:s().optional(),input:u({prompt:s().optional(),input_urls:k(s()).min(1).max(1),video_urls:k(s()).min(1),mode:h(["720p","1080p"]).optional(),character_orientation:h(["video","image"]).optional(),background_source:h(["input_video","input_image"]).optional()})}),Rg=u({prompt:ao,customize_multi_shots:x().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:Di,multi_prompt:Ni.optional(),elements:k(ro).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:x().optional().describe("Generate audio; upstream default false"),resolution:io.default("720p"),aspect_ratio:h(["16:9","9:16","1:1"]).default("16:9"),duration:Ei.default(5)}),Cg=u({model:f("kling-3.0-omni/text-to-video"),callBackUrl:s().url().optional(),input:Rg}),vg=Cg.superRefine((n,e)=>{Bi(n.input,e)}),Mg=u({prompt:ao,image_urls:k(yt).min(1).max(2).describe("One URL supplies the first frame; two URLs supply first and last frames"),duration:Ei.default(5),resolution:io.default("720p"),aspect_ratio:Ai.optional().describe("Output aspect ratio; upstream default auto, with fixed ratios available for custom multi-shot mode"),audio:x().optional(),customize_multi_shots:x().optional(),prefer_multi_shots:Di,multi_prompt:Ni.optional(),elements:k(ro).max(3).optional().describe("One-time subject assets, up to 3 subjects")}),Og=u({model:f("kling-3.0-omni/image-to-video"),callBackUrl:s().url().optional(),input:Mg}),Eg=Og.superRefine((n,e)=>{Bi(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"]})}),Ag=u({prompt:ao,image_urls:k(yt).min(1).max(7).optional(),video_urls:k(yt).min(1).max(1).optional(),duration:Ei.default(5),resolution:io.default("720p"),aspect_ratio:Ai.optional().describe("Fixed ratios apply without video or with video plus images; video-only input requires explicit auto"),audio:x().optional().describe("Video-backed requests require explicit false"),customize_multi_shots:x().optional(),prefer_multi_shots:Di,multi_prompt:Ni.optional(),elements:k(ro).optional().describe("Subject assets share the reference quota; video-backed requests impose the upstream composition limits")}),Ng=u({model:f("kling-3.0-omni/reference-to-video"),callBackUrl:s().url().optional(),input:Ag}),Dg=Ng.superRefine((n,e)=>{const{input:t}=n,o=!!t.image_urls?.length,i=!!t.video_urls?.length;if(Bi(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"]})}),Bg=u({prompt:ao,image_urls:k(yt).min(1).max(4).optional(),video_urls:k(yt).min(1).max(1),duration:s().optional().describe("String duration supported only by the video-with-images shape"),resolution:io.default("720p"),aspect_ratio:Ai.optional().describe("Video-only input uses auto; video with images uses 16:9, 9:16, or 1:1"),audio:x().optional(),elements:k(ro).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")}),Vg=u({model:f("kling-3.0-omni/transformation"),callBackUrl:s().url().optional(),input:Bg}),Pg=Vg.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"]})}),rl=h(["720p","1080p"]),al=y().int().min(3).max(30),sl=h(["auto","16:9","9:16","1:1","21:9"]),Fe=s().regex(/^https?:\/\/.+/),Kg=h(["character","animal","prop","costume","scene","effect","others"]),ll=s().min(1).max(8e3),cl=s().regex(/^[\u4e00-\u9fa5A-Za-z0-9_]{1,20}$/).describe("Mentioned in the prompt as @name: 1-20 Chinese characters, letters, digits or underscores, unique across elements and voices (case-insensitive). image_N, video_N, keyframe_N, object_N, audio_N, first_frame and last_frame are reserved"),zg=/^(?:(?:image|video|keyframe|object|audio)_\d+|first_frame|last_frame)$/i,Fg=u({name:cl,image_urls:k(Fe).min(2).max(4).optional().describe("Image subject: 2-4 image URLs, the first is the primary view; exclusive with video_url"),video_url:Fe.optional().describe("Video subject: one 3-8 s single-shot character video, shortest side at least 700 px; exclusive with image_urls"),tag:Kg.optional().describe("Subject category; inferred from the primary image when omitted. A video subject is always character"),description:s().max(100).optional(),voice_url:Fe.optional().describe("Reference audio bound to a character subject; not mentionable on its own and outside the voices quota")}),qg=u({name:cl,audio_url:Fe.describe("Reference audio URL; the task fails when no usable voice is detected")}),Ug=u({prompt:ll.describe("Video prompt (1-8000 characters). Mention materials as @image_1, @video_1 or @name; every mention must match a material in this request"),duration:al.default(5),resolution:rl.default("720p"),aspect_ratio:sl.optional().describe("Output aspect ratio; upstream uses auto when any material is provided and 16:9 otherwise"),image_urls:k(Fe).max(10).default([]).describe("Reference images, mentioned as @image_1, @image_2, ... in order; each side 300-65536 px, aspect ratio 0.40-2.5"),video_urls:k(Fe).max(5).default([]).describe("Reference videos of 2-30 s each, mentioned as @video_1, @video_2, ...; at most 5 together with video elements"),keep_original_sound:x().default(!1).describe("Keep the reference videos' audio; applies only with video_urls, otherwise native audio is generated"),elements:k(Fg).max(7).default([]).describe("Subjects for this task, at most 3 of them video subjects"),voices:k(qg).max(3).default([]).describe("Standalone voice references, mentioned as @name")}),Gg=u({model:f("kling-4.0/reference-to-video"),callBackUrl:s().url().optional(),input:Ug}),Lg=Gg.superRefine((n,e)=>{const{input:t}=n,o=(c,p)=>e.addIssue({code:"custom",message:c,path:["input",...p]});t.elements.forEach((c,p)=>{const d=c.video_url!==void 0;d===(c.image_urls!==void 0)&&o("An element takes either 2-4 image_urls or one video_url",["elements",p]),!(c.tag===void 0||c.tag==="character")&&(d?o("A video element is always a character subject",["elements",p,"tag"]):c.voice_url!==void 0&&o("voice_url binds only to a character subject",["elements",p,"voice_url"]))});const i=t.elements.filter(c=>c.video_url!==void 0).length;i>3&&o("At most 3 elements can be video subjects",["elements"]),t.video_urls.length+i>5&&o("video_urls and video elements together cannot exceed 5",["video_urls"]),t.image_urls.length+t.video_urls.length+t.elements.length+t.voices.length>15&&o("image_urls, video_urls, elements and voices together cannot exceed 15",["elements"]);const a=new Set,l=[...t.elements.map((c,p)=>({name:c.name,path:["elements",p,"name"]})),...t.voices.map((c,p)=>({name:c.name,path:["voices",p,"name"]}))];for(const{name:c,path:p}of l)zg.test(c)?o(`${c} is a reserved material name`,p):a.has(c.toLowerCase())&&o(`${c} repeats a name in elements or voices (case-insensitive)`,p),a.add(c.toLowerCase())}),Wg=u({prompt:ll.describe("Video prompt (1-8000 characters). Mention frames as @first_frame, @keyframe_1, ... and @last_frame; only frames in this request can be mentioned"),duration:al.default(5).describe("Output seconds, 3-30 (default 5). Also caps first + keyframes + last: 3 s allows 4 frames, one more per second, 10 from 9 s"),resolution:rl.default("720p"),aspect_ratio:sl.optional().describe("Used only without frames (text-to-video, default 16:9); with frames the output follows the first frame"),first_frame_url:Fe.optional().describe("First-frame image URL, mentioned as @first_frame"),keyframe_urls:k(Fe).max(8).default([]).describe("Middle-frame image URLs in chronological order, mentioned as @keyframe_1, @keyframe_2, ..."),last_frame_url:Fe.optional().describe("Last-frame image URL, mentioned as @last_frame")}),jg=u({model:f("kling-4.0/keyframe-to-video"),callBackUrl:s().url().optional(),input:Wg}),$g=jg.superRefine((n,e)=>{const{input:t}=n,o=(t.first_frame_url===void 0?0:1)+t.keyframe_urls.length+(t.last_frame_url===void 0?0:1),i=Math.min(t.duration+1,10);o>i&&e.addIssue({code:"custom",message:`duration ${t.duration}s allows at most ${i} frames (first + keyframes + last), got ${o}`,path:["input","keyframe_urls"]})});u({resultUrls:k(s().url()).min(1)});const Hg=u({model:f("grok-imagine/text-to-image"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),aspect_ratio:h(["2:3","3:2","1:1","16:9","9:16"]).default("16:9"),nsfw_checker:x().default(!1),enable_pro:x().optional()})}),Jg=u({model:f("qwen2/text-to-image"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(800),image_size:Ff.default("16:9"),seed:y().int().optional(),output_format:h(["jpeg","png"]).default("png"),nsfw_checker:x().default(!1)})}),Qg=u({model:f("qwen2/image-edit"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(800),image_url:s().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:y().multipleOf(1).optional(),nsfw_checker:x().default(!1)})}),ul=h(["1:1","4:3","3:4","3:2","2:3","16:9","9:16","21:9","9:21"]),Xg=h(["1K","2K"]),Yg=h(["opaque","transparent"]),Zg=h(["png","webp","jpeg"]),pl={resolution:Xg.default("1K"),background:Yg.default("opaque"),output_format:Zg.default("png"),enhance_prompt:x().default(!0),seed:y().int().optional(),nsfw_checker:x().default(!1)},e0=u({model:f("qwen2-1/text-to-image"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(5e3),aspect_ratio:ul.default("1:1"),...pl}).strict()}),t0=(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"]}))},n0=u({model:f("qwen2-1/image-to-image"),callBackUrl:s().url().optional(),input:u({image_urls:k(s().url()).min(1).max(10),prompt:s().min(1).max(5e3),mask_url:s().url().optional(),aspect_ratio:P([f("auto"),ul]).default("auto"),...pl}).strict()}).superRefine(t0),dl={prompt:s().max(5e3),image_size:qf.default("16:9"),output_format:Uf.default("png"),prompt_extend:x().default(!0),nsfw_checker:x().default(!1),negative_prompt:s().max(5e3).optional(),seed:y().int().min(0).max(2147483647).default(1)},ml=u({...dl,resolution:Xs.optional()}).strict(),hl=u({...dl,image_urls:k(s().url()).min(1).max(3),resolution:Xs.default("1K")}).strict(),o0=u({model:f("qwen3/text-to-image"),callBackUrl:s().url().optional(),input:ml}),i0=u({model:f("qwen3/image-to-image"),callBackUrl:s().url().optional(),input:hl}),r0=u({model:f("qwen3/pro-text-to-image"),callBackUrl:s().url().optional(),input:ml}),a0=u({model:f("qwen3/pro-image-to-image"),callBackUrl:s().url().optional(),input:hl}),s0=u({model:f("qwen/text-to-image"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(5e3),image_size:Ys.optional(),num_inference_steps:y().min(2).max(250).default(30),seed:y().int().optional(),guidance_scale:y().min(0).max(20).default(2.5),enable_safety_checker:x().optional(),output_format:h(["png","jpeg"]).default("png"),negative_prompt:s().max(500).optional(),acceleration:Ri.default("none"),nsfw_checker:x().default(!1)})}),l0=u({model:f("qwen/image-edit"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(2e3),image_url:s().min(1),acceleration:Ri.default("none"),image_size:Ys.default("landscape_4_3"),num_inference_steps:y().min(2).max(49).default(25),seed:y().int().optional(),guidance_scale:y().min(0).max(20).default(4),sync_mode:x().optional(),num_images:Gf.optional(),enable_safety_checker:x().optional(),output_format:h(["jpeg","png"]).default("png"),negative_prompt:s().max(500).optional(),nsfw_checker:x().default(!1)})}),c0=u({model:f("qwen/image-to-image"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(5e3),image_url:s().min(1),strength:y().min(0).max(1).default(.8),output_format:h(["png","jpeg"]).default("png"),acceleration:Ri.default("none"),negative_prompt:s().max(500).optional(),seed:y().int().optional(),num_inference_steps:y().min(2).max(250).default(30),guidance_scale:y().min(0).max(20).default(2.5),enable_safety_checker:x().optional(),nsfw_checker:x().default(!1)})}),u0=u({model:f("grok-imagine/image-to-image"),callBackUrl:s().optional(),input:u({prompt:s().max(39e4).optional(),image_urls:pa([s()]),nsfw_checker:x().default(!1)})}),p0=u({model:f("grok-imagine/text-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),aspect_ratio:Of.optional(),mode:vf.optional(),duration:Af.optional(),resolution:wi.optional(),nsfw_checker:x().default(!1)})}),d0=u({model:f("grok-imagine/image-to-video"),callBackUrl:s().url().optional(),input:u({prompt:s().max(4096).optional(),image_urls:k(Kf).min(1).max(7,"grok-imagine/image-to-video accepts at most 7 image_urls").optional(),task_id:s().min(1).max(100).optional(),index:y().int().min(0).max(5).default(0),mode:Mf.default("normal"),duration:Nf.default(6),resolution:wi.default("480p"),aspect_ratio:Ef.default("16:9"),nsfw_checker:x().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"]})}),m0=u({url:s().describe("Keyframe image URL"),timestamp_s:y().positive().describe("Seconds into the video, greater than 0 and less than duration; keyframes at least 1/3 s apart")}),h0=u({prompt:s().max(4096).optional(),image_urls:k(s()).min(1),aspect_ratio:zf.default("auto"),resolution:wi.default("480p"),duration:y().int().min(1).max(15).default(8),first_frame_url:s().optional().describe("First-frame image URL; can be sent with image_urls"),last_frame_url:s().optional().describe("Last-frame image URL"),loop_url:s().optional().describe("One image URL used as both the first and the last frame; cannot be combined with a different first_frame_url or last_frame_url"),keyframes:k(m0).max(4).optional().describe("Up to 4 mid-video keyframes, each an image url pinned at timestamp_s seconds"),enable_audio:x().default(!0).describe("Generate an audio track (default true; false returns a video without one)"),nsfw_checker:x().default(!1)}),f0=u({model:f("grok-imagine-video-1-5-preview"),callBackUrl:s().optional(),input:h0}).superRefine((n,e)=>{const{duration:t,keyframes:o=[],loop_url:i}=n.input;o.forEach(({timestamp_s:a},l)=>{a>=t&&e.addIssue({code:"custom",message:`keyframe timestamp_s must be less than duration (${t}s)`,path:["input","keyframes",l,"timestamp_s"]})});const r=o.map(({timestamp_s:a})=>a).sort((a,l)=>a-l);r.some((a,l)=>l>0&&a-r[l-1]<1/3-1e-9)&&e.addIssue({code:"custom",message:"keyframes must be at least 1/3 second apart",path:["input","keyframes"]});for(const a of["first_frame_url","last_frame_url"]){const l=n.input[a];i!==void 0&&l!==void 0&&l!==i&&e.addIssue({code:"custom",message:`loop_url cannot be combined with a different ${a}`,path:["input",a]})}n.input.resolution==="1080p"&&n.input.image_urls.length>1&&e.addIssue({code:"custom",message:"grok-imagine-video-1-5-preview accepts exactly 1 image_url at 1080p",path:["input","image_urls"]})}),g0=u({model:f("grok-imagine/extend"),callBackUrl:s().optional(),resolution:Bf.optional(),input:u({task_id:s().min(1).max(100),prompt:s().min(1).max(5e3),extend_at:y().min(0),extend_times:Df})}),x0=u({model:f("grok-imagine/upscale"),callBackUrl:s().optional(),input:u({task_id:s().min(1).max(100)})}),y0=u({model:f("grok-imagine-image-2-0/text-to-image"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1),aspect_ratio:h(["1:1","2:3","3:2","16:9","9:16"])}).strict()}),b0=u({model:f("grok-imagine-image-2-0/segment-map"),callBackUrl:s().url().optional(),input:u({task_id:s().min(1)}).strict()}),S0=u({model:f("grok-imagine-image-2-0/image-edit"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1),task_id:s().min(1),mask_indexs:k(y().int().min(0)).min(1).optional()}).strict()}),k0=u({model:f("grok-imagine-image-2-0/segment-edit"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1),task_id:s().min(1),mask_indexs:k(y().int().min(1)).min(1).optional()}).strict()}),_0=u({model:f("nano-banana-pro"),callBackUrl:s().optional(),input:u({prompt:s().min(1),image_input:k(s()).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:Ti.default("2K"),output_format:Ii.optional()})}),w0=u({prompt:s().min(3).max(2e4),first_frame_url:s().optional(),last_frame_url:s().optional(),reference_image_urls:k(s()).max(9).optional(),reference_video_urls:k(s()).max(3).optional(),reference_audio_urls:k(s()).max(3).optional(),return_last_frame:x().optional(),generate_audio:x().optional(),resolution:h(["480p","720p"]).optional(),aspect_ratio:h(["1:1","4:3","3:4","16:9","9:16","21:9","adaptive"]).optional(),duration:y().int().min(4).max(15).default(5),web_search:x().optional(),nsfw_checker:x().default(!1)}),T0=u({model:f("bytedance/seedance-2-fast"),callBackUrl:s().optional(),input:w0}),I0=T0.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"]}),R0=u({prompt:s().min(3).max(2e4),first_frame_url:s().optional(),last_frame_url:s().optional(),reference_image_urls:k(s()).max(9).optional(),reference_video_urls:k(s()).max(3).optional(),reference_audio_urls:k(s()).max(3).optional(),return_last_frame:x().optional(),generate_audio:x().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:y().int().min(4).max(15).default(5),web_search:x().optional(),nsfw_checker:x().default(!1)}),C0=u({model:f("bytedance/seedance-2"),callBackUrl:s().optional(),input:R0}),v0=C0.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"]}),Ft=s().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"),M0=u({prompt:s().max(3e4).optional(),first_frame_url:Ft.optional(),last_frame_url:Ft.optional(),reference_image_urls:k(Ft).max(30).optional(),reference_video_urls:k(Ft).max(10).optional(),reference_audio_urls:k(Ft).max(10).optional(),return_last_frame:x().default(!1),generate_audio:x().default(!1),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),y().int().min(4).max(30)]).default(5),output_format:h(["mp4","mov"]).default("mp4"),web_search:x().optional(),draft:x().default(!1),nsfw_checker:x().default(!1)}),O0=u({model:f("bytedance/seedance-2-5"),callBackUrl:s().url().optional(),input:M0}),E0=O0.superRefine((n,e)=>{const{input:t}=n;t.draft&&t.resolution!=="480p"&&e.addIssue({code:"custom",message:"Seedance 2.5 draft mode requires 480p resolution",path:["input","resolution"]});const 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 a of["reference_image_urls","reference_video_urls","reference_audio_urls"])(t[a]?.length??0)>0&&e.addIssue({code:"custom",message:`${a} cannot be combined with first_frame_url or last_frame_url`,path:["input",a]})}}),A0=u({draft_task_id:s().min(1),resolution:f("1080p"),output_format:h(["mp4","mov"]).optional(),return_last_frame:x().default(!1),nsfw_checker:x().default(!1)}),N0=u({model:f("bytedance/seedance-2-5-draft"),callBackUrl:s().url().optional(),input:A0}),D0=u({prompt:s().max(2e4).optional(),reference_image_urls:k(s()).max(9).default([]),reference_video_urls:k(s()).max(3).default([]),reference_audio_urls:k(s()).max(3).default([]),generate_audio:x().default(!0),resolution:tg.default("720p"),aspect_ratio:ng.default("16:9"),duration:y().int().min(4).max(15).default(5),web_search:x().default(!1),nsfw_checker:x().default(!0)}),B0=u({model:f("bytedance/seedance-2-mini"),callBackUrl:s().url().optional(),input:D0}),V0=h(["1:1","4:3","3:4","16:9","9:16","21:9"]),P0=h(["480p","720p","1080p"]),K0=u({prompt:s().min(3).max(2e4),input_urls:k(s()).max(2).optional(),aspect_ratio:V0,resolution:P0.default("720p"),duration:y().int().min(4).max(12),fixed_lens:x().default(!1),generate_audio:x().default(!1),nsfw_checker:x().default(!1)}),z0=u({model:f("bytedance/seedance-1.5-pro"),callBackUrl:s().optional(),input:K0}),F0=h(["square","square_hd","portrait_4_3","portrait_16_9","landscape_4_3","landscape_16_9"]),q0=u({prompt:s().min(3).max(5e3),image_size:F0.default("square_hd"),guidance_scale:y().min(1).max(10).default(2.5),seed:y().int().optional()}),U0=u({model:f("bytedance/seedream"),callBackUrl:s().optional(),input:q0}),fl=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"]),gl=h(["1K","2K","4K"]),G0=u({prompt:s().min(3).max(5e3),image_size:fl.default("square_hd"),image_resolution:gl.default("1K"),max_images:y().int().min(1).max(6).default(1),seed:y().int().optional(),nsfw_checker:x().default(!1)}),L0=u({model:f("bytedance/seedream-v4-text-to-image"),callBackUrl:s().optional(),input:G0}),W0=u({prompt:s().min(3).max(5e3),image_urls:k(s()).min(1).max(10),image_size:fl.default("square_hd"),image_resolution:gl.default("1K"),max_images:y().int().min(1).max(6).default(1),seed:y().int().optional(),nsfw_checker:x().default(!1)}),j0=u({model:f("bytedance/seedream-v4-edit"),callBackUrl:s().optional(),input:W0}),hn=h(["5","10"]),so=h(["480p","720p","1080p"]),$0=h(["720p","1080p"]),H0=h(["16:9","4:3","1:1","3:4","9:16","9:21"]),J0=h(["21:9","16:9","4:3","1:1","3:4","9:16"]),lo=y().int().min(-1).max(2147483647).optional(),Q0=u({prompt:s().min(3).max(1e4),image_url:s().min(1),resolution:so.default("720p"),duration:hn.default("5"),camera_fixed:x().optional(),seed:lo,enable_safety_checker:x().optional(),end_image_url:s().optional(),nsfw_checker:x().default(!1)}),X0=u({model:f("bytedance/v1-lite-image-to-video"),callBackUrl:s().optional(),input:Q0}),Y0=u({prompt:s().min(3).max(1e4),aspect_ratio:H0.default("16:9"),resolution:so.default("720p"),duration:hn.default("5"),camera_fixed:x().optional(),seed:lo,enable_safety_checker:x().optional(),nsfw_checker:x().default(!1)}),Z0=u({model:f("bytedance/v1-lite-text-to-video"),callBackUrl:s().optional(),input:Y0}),e1=u({prompt:s().min(3).max(1e4),image_url:s().min(1),resolution:$0.default("720p"),duration:hn.default("5"),nsfw_checker:x().default(!1)}),t1=u({model:f("bytedance/v1-pro-fast-image-to-video"),callBackUrl:s().optional(),input:e1}),n1=u({prompt:s().min(3).max(1e4),image_url:s().min(1),resolution:so.default("720p"),duration:hn.default("5"),camera_fixed:x().optional(),seed:lo,enable_safety_checker:x().optional(),nsfw_checker:x().default(!1)}),o1=u({model:f("bytedance/v1-pro-image-to-video"),callBackUrl:s().optional(),input:n1}),i1=u({prompt:s().min(3).max(1e4),aspect_ratio:J0.default("16:9"),resolution:so.default("720p"),duration:hn.default("5"),camera_fixed:x().optional(),seed:lo,enable_safety_checker:x().optional(),nsfw_checker:x().default(!1)}),r1=u({model:f("bytedance/v1-pro-text-to-video"),callBackUrl:s().optional(),input:i1}),a1=u({model:f("nano-banana-2"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(2e4),image_input:k(s().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:Ti.default("1K"),output_format:Ii.default("jpg")})}),xl=h(["540p","720p","1080p","2k","4k"]),yl=y().int().min(3).max(16),oi=s().refine(n=>{try{return["http:","https:"].includes(new URL(n).protocol)}catch{return!1}},"Expected an HTTP(S) media URL"),s1=u({model:f("vidu-q4/image-to-video"),callBackUrl:s().url().optional(),input:u({image_url:oi.describe("JPG/JPEG/PNG/WEBP image, up to 50 MB; output inherits its aspect ratio"),prompt:s().max(2e4).optional(),duration:yl.default(5),resolution:xl.default("720p"),audio:x().default(!0)})}),l1=h(["16:9","9:16","1:1","4:3","3:4"]),c1=u({model:f("vidu-q4/reference-to-video"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(2e4),reference_image_urls:k(oi).min(1).max(15).describe("JPG/JPEG/PNG/WEBP reference images, referenced in prompt by order"),reference_audio_urls:k(oi).max(3).optional().describe("MP3 references, 3-12 seconds each, up to 50 MB"),aspect_ratio:l1.default("16:9"),duration:yl.default(5),resolution:xl.default("720p"),audio:x().default(!0)})}),u1=u({model:f("nano-banana-2-1"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(2e4),image_input:k(s().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:Ti.default("1K"),output_format:Ii.default("jpg")})}),p1=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"]),d1=u({model:f("nano-banana-2-lite"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(2e4),image_urls:k(s()).max(10).optional(),aspect_ratio:p1.default("auto")})}),m1=u({model:f("gpt-image/1.5-image-to-image"),callBackUrl:s().optional(),input:u({input_urls:k(s()).min(1).max(4),prompt:s().min(1),aspect_ratio:h(["1:1","2:3","3:2"]).optional(),quality:Qs.optional()})}),h1=h(["1:1","2:3","3:2"]),f1=u({model:f("gpt-image/1.5-text-to-image"),callBackUrl:s().optional(),input:u({prompt:s().min(1),aspect_ratio:h1,quality:Qs})}),g1=h(["auto","1:1","5:4","9:16","21:9","16:9","4:3","3:2","4:5","3:4","2:3"]),x1=h(["1K","2K","4K"]),y1=u({model:f("gpt-image-2-image-to-image"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(2e4),input_urls:k(s()).min(1).max(16),aspect_ratio:g1.default("auto"),resolution:x1.default("1K"),nsfw_checker:x().default(!1)})}),b1=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"]),S1=h(["1K","2K","4K"]),k1=u({model:f("gpt-image-2-text-to-image"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(2e4),aspect_ratio:b1.default("auto"),resolution:S1.default("1K"),nsfw_checker:x().default(!1)})}),co=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"]),uo=h(["1K","2K","4K"]),po=h(["transparent","opaque","auto"]),_1=new Set(["27:16","16:27","9:8","8:9"]),mo=(n,e)=>{_1.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"]})},w1=u({model:f("gpt-image-2-5-flare-text-to-image"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(2e4),aspect_ratio:co.default("auto"),resolution:uo.default("1K"),background:po.optional()})}).superRefine(mo),T1=u({model:f("gpt-image-2-5-flare-image-to-image"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(2e4),input_urls:k(s()).min(1).max(16),aspect_ratio:co.default("auto"),resolution:uo.default("1K"),background:po.optional()})}).superRefine(mo),I1=u({model:f("gpt-image-2-5-sunburst-text-to-image"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(2e4),aspect_ratio:co.default("auto"),resolution:uo.default("1K"),background:po.optional()})}).superRefine(mo),R1=u({model:f("gpt-image-2-5-sunburst-image-to-image"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(2e4),input_urls:k(s()).min(1).max(16),aspect_ratio:co.default("auto"),resolution:uo.default("1K"),background:po.optional()})}).superRefine(mo),C1=u({model:f("seedream/5-lite-image-to-image"),callBackUrl:s().optional(),input:u({image_urls:k(s()).min(1).max(14),prompt:s().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:x().default(!1)})}),v1=u({model:f("seedream/5-lite-text-to-image"),callBackUrl:s().optional(),input:u({prompt:s().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:x().default(!1)})}),M1=u({model:f("seedream/5-pro-image-to-image"),callBackUrl:s().optional(),input:u({image_urls:k(s()).min(1).max(10),prompt:s().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:x().default(!1)})}),O1=u({model:f("seedream/5-pro-text-to-image"),callBackUrl:s().optional(),input:u({prompt:s().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:x().default(!1)})}),E1=u({model:f("seedream/5-flash-text-to-image"),callBackUrl:s().url().optional(),input:u({prompt:s().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:x().optional()})}),A1=u({model:f("seedream/5-flash-image-to-image"),callBackUrl:s().url().optional(),input:u({image_urls:k(s().url()).min(1).max(10),prompt:s().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:x().optional()})}),N1=u({model:f("seedream/5-pro-layer-decomposition"),callBackUrl:s().optional(),input:u({image_url:s().url(),prompt:s().max(5e3).optional(),size:h(["auto","1K","1.5K","2K"]).default("auto"),output_format:h(["png","jpeg"]).default("jpeg")})}),D1=u({model:f("seedream/5-flash-layer-decomposition"),callBackUrl:s().url().optional(),input:u({image_url:s().url(),prompt:s().min(3).max(5e3).optional(),size:h(["auto","1K","1.5K","2K"]).default("auto"),output_format:h(["png","jpeg"]).default("jpeg"),nsfw_checker:x().optional()})}),B1=u({model:f("seedream/4.5-text-to-image"),callBackUrl:s().optional(),input:u({prompt:s().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:x().default(!1)})}),V1=u({model:f("seedream/4.5-edit"),callBackUrl:s().optional(),input:u({prompt:s().min(3).max(3e3),image_urls:k(s()).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:x().default(!1)})}),P1=u({model:f("recraft/crisp-upscale"),callBackUrl:s().url().optional(),input:u({image:s().min(1)})}),K1=u({model:f("recraft/remove-background"),callBackUrl:s().url().optional(),input:u({image:s().min(1)})}),z1=u({model:f("happyhorse/text-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),resolution:bt.optional(),aspect_ratio:Zs.optional(),duration:At.optional(),seed:y().int().min(0).max(2147483647).optional()})}),F1=u({model:f("happyhorse/image-to-video"),callBackUrl:s().optional(),input:u({prompt:s().max(5e3).optional(),image_urls:k(s()).min(1).max(1),resolution:bt.optional(),duration:At.optional(),seed:y().int().min(0).max(2147483647).optional()})}),q1=u({model:f("happyhorse/reference-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),reference_image:k(s()).min(1).max(9),resolution:bt.optional(),aspect_ratio:Zs.optional(),duration:At.optional(),seed:y().int().min(0).max(2147483647).optional()})}),U1=u({model:f("happyhorse/video-edit"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),video_url:s().min(1),reference_image:k(s()).max(5).optional(),resolution:bt.optional(),audio_setting:Hf.optional(),seed:y().int().min(0).max(2147483647).optional()})}),G1=u({model:f("happyhorse-1-1/text-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),resolution:bt.default("1080p"),aspect_ratio:el.default("16:9"),duration:At.default(5)})}),L1=u({model:f("happyhorse-1-1/image-to-video"),callBackUrl:s().optional(),input:u({prompt:s().max(5e3).default(""),image_urls:k(s().url()).min(1).max(1),resolution:bt.default("1080p"),duration:At.default(5)})}),W1=u({model:f("happyhorse-1-1/reference-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),reference_image:k(s().url()).min(1).max(9),resolution:bt.default("1080p"),aspect_ratio:el.default("16:9"),duration:At.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 j1=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:s(),data:u({taskId:s()})}),u({code:j1,msg:s(),data:K().optional()})]);const $1=u({model:f("omnihuman-1-5"),callBackUrl:s().url().optional(),input:u({image_url:s().url(),mask_url:k(s().url()).max(5).optional(),audio_url:s().url(),prompt:s().max(1e3).optional(),output_resolution:Xf.default("1080"),pe_fast_mode:x().default(!1),seed:y().int().min(-1).default(-1)})}),H1=u({model:f("omnihuman-1-5/human-identification"),callBackUrl:s().url().optional(),input:u({image_url:s().url()})}),J1=u({model:f("omnihuman-1-5/subject-detection"),callBackUrl:s().url().optional(),input:u({image_url:s().url()})}),Q1=u({image_urls:k(s().url()).min(1).max(1).describe("Exactly one source image URL (jpeg, png, webp, bmp, tiff, gif, heic or heif; under 30 MB; aspect ratio 0.4-2.5; each side 300-6000 px)"),audio_url:s().url().describe("Driving audio URL for motion and lip sync (wav or mp3, 4-300 seconds, under 15 MB); the video length follows the audio"),prompt:s().max(300).optional().describe("Optional scene, motion and camera direction, up to 300 characters (Chinese, English, Japanese, Korean, Mexican Spanish or Indonesian)"),enable_watermark:x().default(!0).describe("Add a watermark to the output video (default true)")}),X1=u({model:f("omnihuman-2-0"),callBackUrl:s().url().optional(),input:Q1});u({resultUrls:k(s().url()).min(1)});const Y1=u({model:f("volcengine/video-to-video-lip-sync"),callBackUrl:s().optional(),input:u({mode:Yf,video_url:s().min(1),audio_url:s().min(1),separate_vocal:x().default(!1),open_scenedet:x().default(!1),align_audio:x().default(!0),align_audio_reverse:x().default(!1),templ_start_seconds:y().min(0).default(0)})}),Z1=u({url:s().url(),start:y().min(0),ends:y().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"]})}),ex=u({model:f("gemini-omni-video"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(2e4),image_urls:k(s().url()).max(7).optional(),audio_ids:k(s().min(1)).max(3).optional(),video_list:k(Z1).max(1).optional(),character_ids:k(s().min(1)).max(3).optional(),duration:tl,aspect_ratio:nl.optional(),seed:y().int().min(0).max(2147483647).optional(),resolution:Zf.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"]})}),tx=u({url:s().url(),start:y().min(0),ends:y().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"]})}),nx=u({model:f("google/gemini-omni-flash-1-1"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(2e4),image_urls:k(s().url()).max(7).optional(),first_frame_url:s().url().optional(),last_frame_url:s().url().optional(),audio_ids:k(s().min(1)).max(3).optional(),video_list:k(tx).max(1).optional(),character_ids:k(s().min(1)).max(7).optional(),duration:tl,aspect_ratio:nl.optional(),seed:y().int().min(0).max(2147483647).optional(),resolution:eg.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}},vn={values:[0,.5,1],default:.5},bl=u({text:s().min(1),voice:s().min(1),stability:y().min(fe.stability.minimum).max(fe.stability.maximum).default(fe.stability.default),similarity_boost:y().min(fe.similarity_boost.minimum).max(fe.similarity_boost.maximum).default(fe.similarity_boost.default),style:y().min(fe.style.minimum).max(fe.style.maximum).default(fe.style.default),speed:y().min(fe.speed.minimum).max(fe.speed.maximum).default(fe.speed.default),timestamps:x().optional(),previous_text:s().optional(),next_text:s().optional(),language_code:s().optional()}),ox=u({model:f("elevenlabs/audio-isolation"),callBackUrl:s().optional(),input:u({audio_url:s().min(1)})}),ix=u({model:f("elevenlabs/text-to-dialogue-v3"),callBackUrl:s().optional(),input:u({dialogue:k(u({text:s().min(1),voice:s().min(1)})).min(1),stability:P([f(vn.values[0]),f(vn.values[1]),f(vn.values[2])]).default(vn.default)})}),rx=u({model:f("elevenlabs/text-to-speech-multilingual-v2"),callBackUrl:s().optional(),input:bl}),ax=u({model:f("elevenlabs/text-to-speech-turbo-2-5"),callBackUrl:s().optional(),input:bl}),sx=u({model:f("elevenlabs/sound-effect-v2"),callBackUrl:s().optional(),input:u({text:s(),loop:x().optional(),prompt_influence:y().optional(),output_format:s().optional()})}),lx=h(["480P","720P","1080P"]),cx=h(["adaptive","16:9","4:3","1:1","3:4","9:16"]),ux=P([f(-1),y().int().min(2).max(30)]),Sl={prompt:s().max(2e4).optional(),first_frame_url:s().optional(),last_frame_url:s().optional(),reference_image_urls:k(s()).max(10).optional(),reference_video_urls:k(s()).max(5).optional(),reference_audio_urls:k(s()).max(5).optional(),reference_file_urls:k(s()).max(1).optional(),reference_link_urls:k(s()).max(1).optional(),resolution:lx.optional(),aspect_ratio:cx.optional(),duration:ux.optional(),audio:x().optional(),seed:y().int().min(0).max(2147483647).optional(),nsfw_checker:x().default(!1)},px=u({model:f("wan/3-0-video"),callBackUrl:s().optional(),input:u(Sl)}).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"]}),dx=u({model:f("wan/3-0-video-prime"),callBackUrl:s().optional(),input:u(Sl)}).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"]}),mx=u({model:f("wan/2-7-image-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),negative_prompt:s().max(500).optional(),first_frame_url:s().optional(),last_frame_url:s().optional(),first_clip_url:s().optional(),driving_audio_url:s().optional(),resolution:oo.optional(),duration:y().int().min(2).max(15).optional(),prompt_extend:x().optional(),watermark:x().optional(),seed:y().int().min(0).max(2147483647).optional(),nsfw_checker:x().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"]}),hx=u({model:f("wan/2-7-text-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),negative_prompt:s().max(500).optional(),audio_url:s().optional(),resolution:oo.optional(),ratio:Ci.optional(),duration:y().int().min(2).max(15).optional(),prompt_extend:x().optional(),watermark:x().optional(),seed:y().int().min(0).max(2147483647).optional(),nsfw_checker:x().default(!1)})}),fx=u({model:f("wan/2-7-r2v"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),negative_prompt:s().max(500).optional(),reference_image:k(s()).max(5).optional(),reference_video:k(s()).max(5).optional(),first_frame:s().optional(),reference_voice:s().optional(),resolution:oo.optional(),aspect_ratio:Ci.optional(),duration:y().int().min(2).max(10).optional(),prompt_extend:x().optional(),watermark:x().optional(),seed:y().int().min(0).max(2147483647).optional(),nsfw_checker:x().default(!1)})}),gx=u({model:f("wan/2-7-videoedit"),callBackUrl:s().optional(),input:u({prompt:s().max(5e3).optional(),negative_prompt:s().max(500).optional(),video_url:s().min(1),reference_image:s().optional(),resolution:oo.optional(),aspect_ratio:Ci.optional(),duration:$f.optional(),audio_setting:Lf.optional(),prompt_extend:x().optional(),watermark:x().optional(),seed:y().int().min(0).max(2147483647).optional(),nsfw_checker:x().default(!1)})}),xx={prompt:s().min(1).max(5e3),input_urls:k(s()).max(9).optional(),aspect_ratio:jf.default("16:9"),enable_sequential:x().optional(),n:y().int().min(1).max(12).optional(),resolution:Wf.optional(),thinking_mode:x().optional(),color_palette:k(ug).min(3).max(10).optional(),bbox_list:k(k(k(y().multipleOf(1)).length(4)).max(2)).optional(),watermark:x().optional(),seed:y().int().min(0).max(2147483647).optional(),nsfw_checker:x().default(!1)},kl=n=>n.input.aspect_ratio===void 0||n.input.resolution!==void 0,_l={message:"aspect_ratio requires resolution",path:["input","resolution"]},wl=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)},Tl={message:"resolution 4K is only supported for non-sequential text-to-image",path:["input","resolution"]},Il=u(xx),yx=u({model:f("wan/2-7-image"),callBackUrl:s().optional(),input:Il}),bx=u({model:f("wan/2-7-image-pro"),callBackUrl:s().optional(),input:Il}),Sx=yx.refine(kl,_l).refine(wl,Tl),kx=bx.refine(kl,_l).refine(wl,Tl),Rl=h(["480p","720p"]),Cl=h(["none","regular"]),_x=h(["16:9","9:16"]),Vi=h(["480p","580p","720p"]),vl=h(["5","10"]),Ml=h(["720p","1080p"]),wx=h(["16:9","9:16","1:1"]),Pi=h(["5","10","15"]),Ol=h(["5","10"]),fn=h(["720p","1080p"]),El=y().int().min(0).max(2147483647).optional(),Tx=y().int().min(40).max(120).refine(n=>n%4===0,{message:"must be a multiple of 4"}),Zr=n=>y().min(1).max(10).refine(e=>Number.isInteger(e*10),{message:"must be in increments of 0.1"}).default(n),Ix=u({model:f("wan/2-2-a14b-image-to-video-turbo"),callBackUrl:s().optional(),input:u({image_url:s().min(1),prompt:s().min(1).max(5e3),resolution:Rl.default("720p"),enable_prompt_expansion:x().optional(),seed:El,acceleration:Cl.default("none"),nsfw_checker:x().default(!1)})}),Rx=u({model:f("wan/2-2-a14b-speech-to-video-turbo"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),image_url:s().min(1),audio_url:s().min(1),num_frames:Tx.default(80),frames_per_second:y().int().min(4).max(60).default(16),resolution:Vi.default("480p"),negative_prompt:s().max(500).optional(),seed:y().int().optional(),num_inference_steps:y().int().min(2).max(40).default(27),guidance_scale:Zr(3.5),shift:Zr(5),nsfw_checker:x().default(!1)})}),Cx=u({model:f("wan/2-2-a14b-text-to-video-turbo"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),resolution:Rl.default("720p"),aspect_ratio:_x.default("16:9"),enable_prompt_expansion:x().optional(),seed:El,acceleration:Cl.default("none"),nsfw_checker:x().default(!1)})}),vx=u({model:f("wan/2-2-animate-move"),callBackUrl:s().optional(),input:u({video_url:s().min(1),image_url:s().min(1),resolution:Vi.default("480p"),nsfw_checker:x().default(!1)})}),Mx=u({model:f("wan/2-2-animate-replace"),callBackUrl:s().optional(),input:u({video_url:s().min(1),image_url:s().min(1),resolution:Vi.default("480p"),nsfw_checker:x().default(!1)})}),Ox=u({model:f("wan/2-5-image-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(800),image_url:s().min(1),duration:vl,resolution:Ml.optional(),negative_prompt:s().max(500).optional(),enable_prompt_expansion:x().optional(),seed:y().int().optional(),nsfw_checker:x().default(!1)})}),Ex=u({model:f("wan/2-5-text-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(800),duration:vl,aspect_ratio:wx.optional(),resolution:Ml.optional(),negative_prompt:s().max(500).optional(),enable_prompt_expansion:x().optional(),seed:y().int().optional(),nsfw_checker:x().default(!1)})}),Ax=u({model:f("wan/2-6-flash-image-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(2).max(1500),image_urls:k(s().min(1)).min(1).max(1),duration:Pi.default("5"),resolution:fn.default("1080p"),audio:x(),multi_shots:x().optional(),nsfw_checker:x().default(!1)})}),Nx=u({model:f("wan/2-6-flash-video-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(2).max(1500),video_urls:k(s().min(1)).min(1).max(3),duration:Ol.default("5"),resolution:fn.default("1080p"),audio:x().optional(),multi_shots:x().optional(),nsfw_checker:x().default(!1)})}),Dx=u({model:f("wan/2-6-image-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(2).max(5e3),image_urls:k(s().min(1)).min(1).max(1),duration:Pi.default("5"),resolution:fn.default("1080p"),multi_shots:x().default(!1),nsfw_checker:x().default(!1)})}),Bx=u({model:f("wan/2-6-text-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),duration:Pi.default("5"),resolution:fn.default("1080p"),multi_shots:x().default(!1),nsfw_checker:x().default(!1)})}),Vx=u({model:f("wan/2-6-video-to-video"),callBackUrl:s().optional(),input:u({prompt:s().min(2).max(5e3),video_urls:k(s().min(1)).min(1).max(3),duration:Ol.default("5"),resolution:fn.default("1080p"),multi_shots:x().default(!1),nsfw_checker:x().default(!1)})}),gn=s().min(3).max(5e3),Dt=h(["360p","540p","720p","1080p"]),Ki=h(["16:9","4:3","1:1","3:4","9:16","2:3","3:2","21:9"]),Bt=y().int().min(1).max(15),Vt=y().int().min(0).max(2147483647),Px=u({prompt:gn,aspect_ratio:Ki,quality:Dt,duration:Bt,generate_audio_switch:x().default(!1),generate_multi_clip_switch:x().default(!1),seed:Vt.optional()}),Kx=u({model:f("pixverse-v6/text-to-video"),callBackUrl:s().url().optional(),input:Px}),zx=u({prompt:gn,image_urls:k(s().url()).min(1).max(2),quality:Dt,duration:Bt.optional(),template_id:s().min(1).optional(),generate_audio_switch:x().default(!1),generate_multi_clip_switch:x().default(!1),seed:Vt.optional()}),Fx=u({model:f("pixverse-v6/image-to-video"),callBackUrl:s().url().optional(),input:zx}).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"]}),n.input.image_urls.length>1&&!o&&e.addIssue({code:"custom",message:"template_id cannot be empty when multiple image_urls are provided",path:["input","template_id"]})}),qx=u({prompt:gn,first_frame_image_url:s().url(),last_frame_image_url:s().url(),quality:Dt,duration:Bt,generate_audio_switch:x().default(!1),seed:Vt.optional()}),Ux=u({model:f("pixverse-v6/transition"),callBackUrl:s().url().optional(),input:qx}),Gx=u({prompt:gn,duration:Bt,quality:Dt,taskId:s().min(1).optional(),video_url:s().url().optional(),generate_audio_switch:x().optional(),seed:Vt.optional()}),Lx=u({model:f("pixverse-v6/extend"),callBackUrl:s().url().optional(),input:Gx}).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"]})}),Wx=u({image_url:s().url(),type:h(["subject","background"]).default("subject"),ref_name:s().min(1).max(30).optional()}),jx=u({prompt:gn,image_references:k(Wx).min(1).max(7),aspect_ratio:Ki,quality:Dt,duration:Bt,generate_audio_switch:x().default(!1),seed:Vt.optional()}),$x=u({model:f("pixverse-v6/reference-to-video"),callBackUrl:s().url().optional(),input:jx}).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))}}),Al=s().min(1).max(5e3).describe("Generation prompt (1-5000 characters)"),Nl=Dt.describe("Output resolution: 360p, 540p, 720p or 1080p"),Dl=Bt.describe("Output length in seconds, 1-15"),Bl=x().default(!1).describe("Generate native audio synchronized with the video (default false)"),Vl=Vt.describe("Random seed, 0-2147483647; omit it for a random seed"),Hx=u({prompt:Al,aspect_ratio:Ki.describe("Output aspect ratio"),quality:Nl,duration:Dl,generate_audio_switch:Bl,seed:Vl.optional()}),Jx=u({model:f("pixverse-v6-max/text-to-video"),callBackUrl:s().url().optional(),input:Hx}),Qx=u({prompt:Al,image_urls:k(s().url()).min(1).max(1).describe("Exactly one first-frame image URL (HTTP, HTTPS or OSS; JPG, JPEG, PNG or WebP, each side at most 10,000 px, at most 20 MB). The output aspect ratio follows this image"),aspect_ratio:yc({error:"pixverse-v6-max/image-to-video takes its aspect ratio from the source image; do not send aspect_ratio"}).optional().describe("Not accepted: the output aspect ratio follows the source image"),quality:Nl,duration:Dl,generate_audio_switch:Bl,seed:Vl.optional()}),Xx=u({model:f("pixverse-v6-max/image-to-video"),callBackUrl:s().url().optional(),input:Qx});u({resultUrls:k(s().url()).min(1)});const Yx=u({prompt:vi,aspect_ratio:ol,duration:Mi,resolution:Oi.optional()}).strict(),Zx=u({model:f("minimax-h3/text-to-video"),callBackUrl:s().url().optional(),input:Yx}),ey=u({prompt:vi,first_frame_url:Qt.optional(),last_frame_url:Qt.optional(),duration:Mi,resolution:Oi.optional()}).strict(),ty=u({model:f("minimax-h3/image-to-video"),callBackUrl:s().url().optional(),input:ey}).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"]})}),ny=u({prompt:vi,reference_image_urls:k(Qt).max(9).optional(),reference_video_urls:k(Qt).max(3).optional().describe(`MP4/MOV reference videos. ${Yr(Xr.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(Qt).max(3).optional().describe(`WAV/MP3 reference audio; it cannot be the sole reference. ${Yr(Xr.audio)}, as documented upstream but not yet observed at runtime. URLs are not inspected locally, so check local media against MiniMaxH3ReferenceClipDurationMs.audio.`),aspect_ratio:ig.optional(),duration:Mi,resolution:Oi.optional()}).strict(),oy=u({model:f("minimax-h3/reference-to-video"),callBackUrl:s().url().optional(),input:ny}).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"]})}),iy=u({speaker_id:Yn,voice_name:bm,audio_profile:s().optional(),accent:Sm,style:km.optional(),pace:_m.optional()}).strict(),ry=u({speaker_id:Yn,text:s().min(1).max(wm)}).strict(),Pl=u({temperature:y().min(Qr.minimum).max(Qr.maximum).optional(),scene:s().optional(),sample_context:s().optional(),speakers:k(iy).min(1),dialogue_turns:k(ry).min(1)}).strict(),ay=u({model:f("google/gemini-2-5-pro-tts"),callBackUrl:s().url().optional(),input:Pl}),sy=u({model:f("google/gemini-3-1-flash-tts"),callBackUrl:s().url().optional(),input:Pl}),ly=["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"],cy=h(ly),uy=u({speaker_id:Yn,voice_name:cy.default("Fola")}).strict(),py=u({speaker_id:Yn,text:s().min(1).max(1e4),style:s().optional()}).strict(),Kl=u({temperature:y().min(0).max(2).default(1),speakers:k(uy).min(1),filler_words:x().default(!1),dialogue_turns:k(py).min(1)}).strict(),dy=u({model:f("google/gemini-3-8-flash-tts"),callBackUrl:s().url().optional(),input:Kl}),my=u({model:f("google/gemini-3-8-flash-lite-tts"),callBackUrl:s().url().optional(),input:Kl}),zl=h(["1:1","16:9","9:16","3:4","4:3","auto"]),Fl=u({prompt:s().min(1).max(5e3),negative_prompt:s().max(5e3).optional(),aspect_ratio:zl.optional(),seed:s().max(500).optional()}),hy=u({prompt:s().min(1).max(5e3),negative_prompt:s().max(5e3).optional(),aspect_ratio:zl.optional(),seed:y().int().optional()}),fy=u({model:f("google/imagen4"),callBackUrl:s().optional(),input:Fl}),gy=u({model:f("google/imagen4-fast"),callBackUrl:s().optional(),input:hy}),xy=u({model:f("google/imagen4-ultra"),callBackUrl:s().optional(),input:Fl}),Wn=h(["1:1","9:16","16:9","3:4","4:3","3:2","2:3","5:4","4:5","21:9","auto"]),ql=h(["png","jpeg"]),yy=u({model:f("google/nano-banana"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),output_format:ql.optional(),aspect_ratio:Wn.optional(),image_size:Wn.optional(),nsfw_checker:x().optional()})}),by=u({model:f("google/nano-banana-edit"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(5e3),image_urls:k(s()).min(1).max(10),output_format:ql.optional(),aspect_ratio:Wn.optional(),image_size:Wn.optional()})}),Ul=h(["1","2","4"]),Sy=u({model:f("topaz/image-upscale"),callBackUrl:s().optional(),input:u({image_url:s().min(1),upscale_factor:Ul})}),ky=u({model:f("topaz/video-upscale"),callBackUrl:s().optional(),input:u({video_url:s().min(1),upscale_factor:Ul.optional()})}),_y=h(["480p","720p"]),wy=u({model:f("infinitalk/from-audio"),callBackUrl:s().url().optional(),input:u({image_url:s().min(1),audio_url:s().min(1),prompt:s().min(1).max(5e3),resolution:_y.optional(),seed:y().int().min(1e4).max(1e6).optional()})}),Ty=h(["1:1","4:3","3:4","16:9","9:16"]),Iy=u({model:f("z-image"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(1e3),aspect_ratio:Ty,nsfw_checker:x().default(!1)})}),Pt=h(["TURBO","BALANCED","QUALITY"]),ho=h(["square","square_hd","portrait_4_3","portrait_16_9","landscape_4_3","landscape_16_9"]),fo=h(["1","2","3","4"]),Gl=h(["AUTO","GENERAL","REALISTIC","DESIGN"]),zi=h(["AUTO","REALISTIC","FICTION"]),Ry=u({model:f("ideogram/v3-text-to-image"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(5e3),rendering_speed:Pt.optional(),style:Gl.optional(),expand_prompt:x().optional(),image_size:ho.optional(),seed:y().int().optional(),negative_prompt:s().max(5e3).optional()})}),Cy=u({model:f("ideogram/v3-edit"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(5e3),image_url:s().min(1),mask_url:s().min(1),rendering_speed:Pt.optional(),expand_prompt:x().optional(),seed:y().int().optional()})}),vy=u({model:f("ideogram/v3-remix"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(5e3),image_url:s().min(1),rendering_speed:Pt.optional(),style:Gl.optional(),expand_prompt:x().optional(),image_size:ho.optional(),num_images:fo.optional(),seed:y().int().optional(),strength:y().min(.01).max(1).optional(),negative_prompt:s().max(5e3).optional()})}),My=u({model:f("ideogram/character"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(5e3),reference_image_urls:k(s().min(1)).min(1),rendering_speed:Pt.optional(),style:zi.optional(),expand_prompt:x().optional(),num_images:fo.optional(),image_size:ho.optional(),seed:y().int().optional(),negative_prompt:s().max(5e3).optional()})}),Oy=u({model:f("ideogram/character-edit"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(5e3),image_url:s().min(1),mask_url:s().min(1),reference_image_urls:k(s().min(1)).min(1),rendering_speed:Pt.optional(),style:zi.optional(),expand_prompt:x().optional(),num_images:fo.optional(),seed:y().int().optional()})}),Ey=u({model:f("ideogram/character-remix"),callBackUrl:s().url().optional(),input:u({prompt:s().min(1).max(5e3),image_url:s().min(1),reference_image_urls:k(s().min(1)).min(1),rendering_speed:Pt.optional(),style:zi.optional(),expand_prompt:x().optional(),image_size:ho.optional(),num_images:fo.optional(),seed:y().int().optional(),strength:y().min(.1).max(1).optional(),negative_prompt:s().max(500).optional(),image_urls:k(s().min(1)).optional(),reference_mask_urls:s().optional()})}),Ay=h(["1:1","4:3","3:4","16:9","9:16","3:2","2:3"]),Ny=h(["1:1","4:3","3:4","16:9","9:16","3:2","2:3","auto"]),Ll=h(["1K","2K"]),Wl=u({prompt:s().min(3).max(5e3),aspect_ratio:Ay,resolution:Ll,nsfw_checker:x().default(!1)}),jl=u({input_urls:k(s()).min(1).max(8),prompt:s().min(3).max(5e3),aspect_ratio:Ny,resolution:Ll,nsfw_checker:x().default(!1)}),Dy=u({model:f("flux-2/pro-text-to-image"),callBackUrl:s().optional(),input:Wl}),By=u({model:f("flux-2/flex-text-to-image"),callBackUrl:s().optional(),input:Wl}),Vy=u({model:f("flux-2/pro-image-to-image"),callBackUrl:s().optional(),input:jl}),Py=u({model:f("flux-2/flex-image-to-image"),callBackUrl:s().optional(),input:jl}),$l=h(["1:1","4:3","3:4","3:2","2:3","16:9","9:16","21:9","9:21"]),Ky=h(["1K","2K","4K"]),Hl={prompt:s().min(1).max(5e3),resolution:Ky.default("1K"),width:y().int().min(256).max(4096).optional(),height:y().int().min(256).max(4096).optional(),output_format:h(["png","jpeg","webp"]).default("png"),num_images:y().int().min(1).max(4).default(1),seed:y().int().min(0).max(2147483647).optional(),enhance_prompt:x().default(!0),nsfw_checker:x().default(!1)},Jl=(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"})},zy=u({model:f("flux-3/klein-text-to-image"),callBackUrl:s().optional(),input:u({...Hl,aspect_ratio:$l.default("1:1")})}).superRefine(Jl),Fy=u({model:f("flux-3/klein-edit-image"),callBackUrl:s().optional(),input:u({...Hl,image_urls:k(s().regex(/^https?:\/\/.+/)).min(1).max(10),aspect_ratio:h([...$l.options,"auto"]).default("auto")})}).superRefine(Jl),Fi=h(["6","10"]),qy=h(["512P","768P"]),Uy=h(["768P","1080P"]);function Gy(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 Ly=u({model:f("hailuo/02-text-to-video-pro"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(1500),prompt_optimizer:x().optional(),nsfw_checker:x().default(!1)})}),Wy=u({model:f("hailuo/02-text-to-video-standard"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(1500),duration:Fi.optional(),prompt_optimizer:x().optional(),nsfw_checker:x().default(!1)})}),jy=u({model:f("hailuo/02-image-to-video-pro"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(1500),image_url:s().min(1),end_image_url:s().min(1).optional(),prompt_optimizer:x().optional(),nsfw_checker:x().default(!1)})}),$y=u({model:f("hailuo/02-image-to-video-standard"),callBackUrl:s().optional(),input:u({prompt:s().min(1).max(1500),image_url:s().min(1),end_image_url:s().min(1).optional(),duration:Fi.optional(),resolution:qy.optional(),prompt_optimizer:x().optional(),nsfw_checker:x().default(!1)})}),Ql=u({prompt:s().min(1).max(5e3),image_url:s().min(1),duration:Fi.optional(),resolution:Uy.optional(),nsfw_checker:x().default(!1)}).superRefine(Gy),Hy=u({model:f("hailuo/2-3-image-to-video-pro"),callBackUrl:s().optional(),input:Ql}),Jy=u({model:f("hailuo/2-3-image-to-video-standard"),callBackUrl:s().optional(),input:Ql});u({resultUrls:k(s().url()).min(1),resultObject:z(s(),K()).optional()});u({resultUrls:k(s().url()).optional(),resultObject:z(s(),K()).optional()}).refine(n=>n.resultUrls!==void 0||n.resultObject!==void 0,{message:"resultJson must include resultUrls or resultObject"});const Qy=u({taskId:s().min(1),model:f("bytedance/seedance-2-mini"),state:og,param:s().min(1),resultJson:s().optional(),failCode:s().nullable(),failMsg:s().nullable(),costTime:y().int().nullable(),completeTime:y().int().nullable(),createTime:y().int()});u({code:y().int(),msg:s(),data:Qy.optional()});u({taskId:s().min(1)});const Xy=u({taskId:s().optional(),paramJson:s().optional(),completeTime:y().int().nullable().optional(),response:u({resultUrls:k(s()).optional()}).nullable().optional(),successFlag:y().int().optional(),status:h(["GENERATING","SUCCESS","CREATE_TASK_FAILED","GENERATE_FAILED"]).optional(),errorCode:y().int().nullable().optional(),errorMessage:s().nullable().optional(),createTime:y().int().nullable().optional(),progress:s().nullable().optional()});u({code:y().int(),msg:s(),data:Xy.nullable().optional()});u({code:y().int(),msg:s(),data:u({taskId:s().min(1)}).optional()});const Yy=bc(Blob);u({file:Yy,filename:s().min(1),uploadPath:s().min(1),fileName:s().optional(),mimeType:s().optional()});u({fileUrl:s().min(1),uploadPath:s().min(1),fileName:s().optional()});u({base64Data:s().min(1),uploadPath:s().min(1),fileName:s().optional(),mimeType:s().optional()});u({url:s().min(1)});u({taskId:s().min(1),url:s().min(1)});u({audio_id:xm,name:s().min(1).max(210),voice_description:s().min(1).max(2e4).optional(),example_dialogue:s().min(1).max(120).optional()});u({descriptions:s().min(1),image_urls:k(s().url()).min(1).max(1),audio_ids:k(s().min(1)).optional(),character_name:s().min(1).optional()});const Zy=u({characterId:s().min(1),characterName:s().min(1),imageUrl:s().url()});u({code:y().optional(),msg:s(),data:Zy.optional()});u({apiKey:s().min(1),baseURL:s().url().optional(),uploadBaseURL:s().url().optional(),timeout:y().int().positive().optional(),fetch:Ji().optional(),paygate:Ji().optional()});const eb=u({model:fm,callBackUrl:s().optional(),input:z(s(),K())}),tb=s().regex(/^veo\d+(?:_[a-z0-9]+)*$/,"Expected a listed model or an underscored kie Veo alias (e.g. veo4_fast)"),nb=h(["720p","1080p","4k"]),ob=P([f(4),f(6),f(8)]);u({prompt:s().min(1),model:h(["veo3","veo3_fast","veo3_lite"]).or(tb).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(s()).optional(),seeds:y().optional(),watermark:s().optional(),enableTranslation:x().optional(),resolution:nb.optional(),duration:ob.optional(),callBackUrl:s().optional(),enableFallback:x().optional()});u({taskId:s().min(1),prompt:s().min(1),model:h(["fast","quality"]).optional(),seeds:y().optional(),watermark:s().optional(),callBackUrl:s().optional()});u({taskId:s().min(1),index:y().int().min(0).optional()});u({code:y(),msg:s().optional(),data:u({resultUrl:s().url()}).nullable().optional()});u({taskId:s().min(1),index:y().int().min(0).optional(),callBackUrl:s().optional()});u({code:y(),msg:s().optional(),data:u({taskId:s().optional(),resultUrls:k(s()).nullable().optional(),imageUrls:k(s()).nullable().optional()}).nullable().optional()});u({taskId:s().min(1)});const ib=P([f(0),f(1),f(2),f(3)]),rb=u({taskId:s().optional(),resultUrls:k(s()).optional(),originUrls:k(s()).optional(),fullResultUrls:k(s()).optional(),resolution:s().optional(),mediaIds:k(s()).optional()}).passthrough(),ab=u({taskId:s(),paramJson:s().optional(),completeTime:s().nullable().optional(),response:rb.nullable().optional(),successFlag:ib,errorCode:P([y().int(),s()]).nullable().optional(),errorMessage:s().nullable().optional(),createTime:s().optional(),fallbackFlag:x().optional()});u({code:y().int(),msg:s(),data:ab.nullable().optional()});const sb=h(["21:9","16:9","4:3","1:1","3:4","9:16"]),lb=s().regex(/^flux-kontext-[a-z0-9]+(?:-[a-z0-9]+)*$/,"Expected a listed model or a Flux Kontext alias (e.g. flux-kontext-ultra)"),cb=["flux-kontext-pro","flux-kontext-max"],ub=h(cb).or(lb);u({prompt:s().min(1),enableTranslation:x().optional(),uploadCn:x().optional(),inputImage:s().url().optional(),aspectRatio:sb.optional(),outputFormat:h(["jpeg","png"]).optional(),promptUpsampling:x().optional(),model:ub.optional(),callBackUrl:s().url().optional(),safetyTolerance:y().int().min(0).max(6).optional(),watermark:s().optional()});const pb=P([f(0),f(1),f(2),f(3)]);u({taskId:s().min(1)});const db=u({taskId:s(),paramJson:s().optional(),completeTime:s().nullable().optional(),response:u({originImageUrl:s().optional(),resultImageUrl:s().optional()}).nullable().optional(),successFlag:pb,errorCode:y().int().nullable().optional(),errorMessage:s().nullable().optional(),createTime:s().optional()});u({code:y().int(),msg:s(),data:db.nullable().optional()});const mb=h(["1:1","3:2","2:3"]),hb=h(["GPT_IMAGE_1","FLUX_MAX"]);u({prompt:s().min(1).optional(),filesUrl:k(s().url()).max(5).optional(),size:mb,maskUrl:s().url().optional(),callBackUrl:s().url().optional(),isEnhance:x().optional(),uploadCn:x().optional(),enableFallback:x().optional(),fallbackModel:hb.optional()}).refine(n=>n.prompt!==void 0||n.filesUrl!==void 0,{message:"At least one of `prompt` or `filesUrl` must be provided"});const Xl=h(["mj_txt2img","mj_img2img","mj_style_reference","mj_omni_reference","mj_video","mj_video_hd"]),fb=h(["relaxed","fast","turbo"]),gb=h(["7","6.1","6","5.2","5.1","niji6"]),xb=h(["1:2","9:16","2:3","3:4","5:6","6:5","4:3","3:2","1:1","16:9","2:1"]),yb=h(["high","low"]);u({prompt:s().min(1).max(2e3),taskType:Xl,speed:fb.optional(),fileUrl:s().url().optional(),fileUrls:k(s().url()).optional(),aspectRatio:xb.optional(),version:gb.optional(),variety:y().int().min(0).max(100).optional(),stylization:y().int().min(0).max(1e3).optional(),weirdness:y().int().min(0).max(3e3).optional(),ow:y().int().min(1).max(1e3).optional(),waterMark:s().optional(),enableTranslation:x().optional(),callBackUrl:s().url().optional(),videoBatchSize:P([f(1),f(2),f(4)]).optional(),motion:yb.optional()});const bb=P([f(0),f(1),f(2),f(3)]);u({taskId:s().min(1)});const Sb=u({resultUrls:k(u({resultUrl:s()}).passthrough()).optional()}).passthrough(),kb=u({taskId:s().optional(),taskType:Xl.optional(),paramJson:s().optional(),completeTime:s().nullable().optional(),resultInfoJson:Sb.nullable().optional(),successFlag:bb.optional(),createTime:s().nullable().optional(),errorCode:y().int().nullable().optional(),errorMessage:s().nullable().optional()}).passthrough();u({code:y().int(),msg:s(),data:kb.nullable().optional()});const Yl=h(["720p","1080p"]),_b=h(["16:9","4:3","1:1","3:4","9:16"]),wb=P([f(5),f(10)]);u({prompt:s().min(1).max(1800),duration:wb,quality:Yl,imageUrl:s().url().optional(),aspectRatio:_b.optional(),waterMark:s().optional(),callBackUrl:s().url().optional()});u({taskId:s().min(1),prompt:s().min(1),quality:Yl,waterMark:s().optional(),callBackUrl:s().url().optional()});const Tb=u({videoId:s().optional(),taskId:s().optional(),videoUrl:s().optional(),imageUrl:s().optional()}),Ib=u({prompt:s().optional(),imageUrl:s().optional(),expandPrompt:x().optional()}).passthrough(),Rb=u({taskId:s().optional(),parentTaskId:s().nullable().optional(),generateParam:Ib.nullable().optional(),state:s().optional(),generateTime:s().nullable().optional(),videoInfo:Tb.nullable().optional(),failCode:y().int().nullable().optional(),failMsg:s().nullable().optional(),expireFlag:y().int().nullable().optional()});u({code:y().int(),msg:s(),data:Rb.nullable().optional()});const nt=s().regex(/^V\d+(?:_\d+)*(?:PLUS|ALL)?$/,"Expected a listed model or a Suno version alias (e.g. V5_5PLUS)");u({prompt:s().min(1),model:h(["V3_5","V4","V4_5","V4_5PLUS","V4_5ALL","V5","V5_5"]).or(nt),instrumental:x(),customMode:x(),callBackUrl:s().min(1),style:s().optional(),negativeTags:s().optional(),title:s().optional(),vocalGender:h(["m","f"]).optional(),styleWeight:y().min(0).max(1).optional(),weirdnessConstraint:y().min(0).max(1).optional(),audioWeight:y().min(0).max(1).optional(),personaId:s().optional()});u({defaultParamFlag:x(),audioId:s().min(1),prompt:s().min(1),model:h(["V3_5","V4","V4_5","V4_5PLUS","V4_5ALL","V5","V5_5"]).or(nt),callBackUrl:s().min(1),style:s().optional(),title:s().optional(),continueAt:y().optional(),negativeTags:s().optional(),vocalGender:h(["m","f"]).optional(),styleWeight:y().min(0).max(1).optional(),weirdnessConstraint:y().min(0).max(1).optional(),audioWeight:y().min(0).max(1).optional(),personaId:s().optional()});u({taskId:s().min(1),audioId:s().min(1),callBackUrl:s().min(1)});u({taskId:s().min(1)}).passthrough();const Cb=h(["PENDING","SUCCESS","CREATE_TASK_FAILED","GENERATE_WAV_FAILED","CALLBACK_EXCEPTION"]),vb=u({taskId:s(),musicId:s(),callbackUrl:s(),musicIndex:y().int(),completeTime:s().nullable().optional(),response:u({audioWavUrl:s()}).passthrough().nullable().optional(),successFlag:Cb,createTime:s(),errorCode:y().int().nullable(),errorMessage:s().nullable()}).passthrough();u({code:y().int(),msg:s().optional(),data:vb.nullable().optional()}).passthrough();u({taskId:s().min(1),audioId:s().min(1),callBackUrl:s().min(1),type:h(["separate_vocal","split_stem"]).optional()});u({taskId:s().min(1)}).passthrough();const Mb=h(["PENDING","SUCCESS","CREATE_TASK_FAILED","GENERATE_AUDIO_FAILED","CALLBACK_EXCEPTION"]),Ob=u({duration:y().optional(),audio_url:s().optional(),stem_type_group_name:s().optional(),id:s().optional()}).passthrough(),Eb=u({id:s().nullable().optional(),originUrl:s().nullable().optional(),originData:k(Ob).optional(),instrumentalUrl:s().nullable().optional(),vocalUrl:s().nullable().optional(),backingVocalsUrl:s().nullable().optional(),drumsUrl:s().nullable().optional(),bassUrl:s().nullable().optional(),guitarUrl:s().nullable().optional(),pianoUrl:s().nullable().optional(),keyboardUrl:s().nullable().optional(),percussionUrl:s().nullable().optional(),stringsUrl:s().nullable().optional(),synthUrl:s().nullable().optional(),fxUrl:s().nullable().optional(),brassUrl:s().nullable().optional(),woodwindsUrl:s().nullable().optional()}).passthrough(),Ab=u({taskId:s(),musicId:s().optional(),callbackUrl:s().optional(),musicIndex:y().int().optional(),completeTime:P([s(),y()]).nullable().optional(),response:Eb.nullable().optional(),successFlag:Mb.optional(),createTime:P([s(),y()]).optional(),errorCode:y().nullable().optional(),errorMessage:s().nullable().optional()}).passthrough();u({code:y().int(),msg:s().optional(),data:Ab.nullable().optional()}).passthrough();u({taskId:s().min(1)}).passthrough();const Zl=h(["wait_processing","processing_validate","processing_validate_fail","wait_validating","success","fail"]),Nb=u({taskId:s(),voiceId:s(),status:Zl,errorCode:y().int().nullable(),errorMessage:s().nullable()}).passthrough();u({code:y().int(),msg:s().optional(),data:Nb.nullable().optional()}).passthrough();u({taskId:s().min(1)}).passthrough();const Db=u({taskId:s(),validateInfo:s(),status:Zl,errorCode:y().int().nullable(),errorMessage:s().nullable()}).passthrough();u({code:y().int(),msg:s().optional(),data:Db.nullable().optional()}).passthrough();const Bb=h(["beginner","intermediate","advanced","professional"]);u({taskId:s().min(1),verifyUrl:s().min(1),voiceName:s().optional(),description:s().optional(),style:s().optional(),callBackUrl:s().optional(),singerSkillLevel:Bb.optional()}).passthrough();u({voiceUrl:s().min(1),vocalStartS:y().int(),vocalEndS:y().int(),language:s().optional(),callBackUrl:s().optional()}).passthrough();const Vb=u({taskId:s()}).passthrough();u({code:y().int(),msg:s().optional(),data:Vb.nullable().optional()}).passthrough();u({taskId:s().min(1),calBackUrl:s().min(1)}).passthrough();const Pb=u({taskId:s()}).passthrough();u({code:y().int(),msg:s().optional(),data:Pb.nullable().optional()}).passthrough();u({task_id:s().min(1)}).passthrough();const Kb=u({isAvailable:x()}).passthrough();u({code:y().int(),msg:s().optional(),data:Kb.nullable().optional()}).passthrough();u({taskId:s().min(1),audioId:s().min(1),name:s().min(1),description:s().min(1),vocalStart:y().min(0).optional(),vocalEnd:y().min(0).optional(),style:s().optional()}).passthrough();const zb=u({personaId:s().optional(),name:s().optional(),description:s().optional()}).passthrough();u({code:y().int(),msg:s().optional(),data:zb.nullable().optional()}).passthrough();u({taskId:s().min(1),audioId:s().min(1)}).passthrough();const Fb=u({word:s().optional(),success:x().optional(),startS:y().optional(),endS:y().optional(),palign:y().int().optional()}).passthrough(),qb=u({alignedWords:k(Fb).optional(),waveformData:k(y()).optional(),hootCer:y().optional(),isStreamed:x().optional()}).passthrough();u({code:y().int(),msg:s().optional(),data:qb.nullable().optional()}).passthrough();u({taskId:s().min(1),callBackUrl:s().min(1)}).passthrough();u({taskId:s().min(1)}).passthrough();const Ub=u({images:k(s()).optional()}).passthrough(),Gb=u({taskId:s(),parentTaskId:s().optional(),callbackUrl:s().optional(),completeTime:s().nullable().optional(),response:Ub.nullable().optional(),successFlag:y().int().optional(),createTime:s().optional(),errorCode:y().int().nullable().optional(),errorMessage:s().nullable().optional()}).passthrough();u({code:y().int(),msg:s().optional(),data:Gb.nullable().optional()}).passthrough();u({task_id:s().min(1)}).passthrough();u({code:y().int(),msg:s().optional(),data:k(u({}).passthrough()).nullable().optional()}).passthrough();u({task_id:s().min(1),call_back_url:s().optional()});u({taskId:s().min(1),audioId:s().min(1),callBackUrl:s().min(1),author:s().max(50).optional(),domainName:s().max(50).optional()});u({taskId:s().min(1)});const Lb=h(["PENDING","SUCCESS","CREATE_TASK_FAILED","GENERATE_MP4_FAILED"]),Wb=u({videoUrl:s().optional()}).passthrough(),jb=u({taskId:s(),musicId:s(),callbackUrl:s(),musicIndex:y().int(),completeTime:s().nullable().optional(),response:Wb.nullable().optional(),successFlag:Lb,createTime:s(),errorCode:y().int().nullable().optional(),errorMessage:s().nullable().optional()}).passthrough();u({code:y().int(),msg:s().optional(),data:jb.nullable().optional()});u({prompt:s().min(1).max(200),callBackUrl:s().min(1)});u({taskId:s().min(1)});const $b=h(["PENDING","SUCCESS","CREATE_TASK_FAILED","GENERATE_LYRICS_FAILED","CALLBACK_EXCEPTION","SENSITIVE_WORD_ERROR"]),Hb=u({text:s(),title:s(),status:s().optional(),errorMessage:s().optional()}).passthrough();u({code:y().int(),msg:s().optional(),data:u({taskId:s(),param:s().optional(),response:u({taskId:s().optional(),data:k(Hb).optional()}).passthrough().nullable().optional(),status:$b.optional(),errorCode:y().int().nullable().optional(),errorMessage:s().nullable().optional()}).passthrough().nullable().optional()});u({content:s().min(1)});u({uploadUrl:s().min(1),prompt:s().min(1),customMode:x(),instrumental:x(),model:h(["V3_5","V4","V4_5","V4_5PLUS","V4_5ALL","V5","V5_5"]).or(nt),callBackUrl:s().min(1),style:s().optional(),title:s().optional(),negativeTags:s().optional(),vocalGender:h(["m","f"]).optional(),styleWeight:y().min(0).max(1).optional(),weirdnessConstraint:y().min(0).max(1).optional(),audioWeight:y().min(0).max(1).optional(),personaId:s().optional()});u({uploadUrl:s().min(1),defaultParamFlag:x(),instrumental:x(),continueAt:y(),model:h(["V3_5","V4","V4_5","V4_5PLUS","V4_5ALL","V5","V5_5"]).or(nt),callBackUrl:s().min(1),prompt:s().optional(),style:s().optional(),title:s().optional(),negativeTags:s().optional(),vocalGender:h(["m","f"]).optional(),styleWeight:y().min(0).max(1).optional(),weirdnessConstraint:y().min(0).max(1).optional(),audioWeight:y().min(0).max(1).optional(),personaId:s().optional()});u({taskId:s().min(1),callBackUrl:s().min(1),audioId:s().optional()});u({taskId:s().min(1)});const Jb=P([f(0),f(1),f(2),f(3)]),Qb=u({pitch:y(),start:y(),end:y(),velocity:y()}).passthrough(),Xb=u({name:s(),notes:k(Qb)}).passthrough(),Yb=u({state:s().optional(),instruments:k(Xb).optional()}).passthrough();u({code:y().int(),msg:s().optional(),data:u({taskId:s(),successFlag:Jb,recordTaskId:y().int().optional(),audioId:s().optional(),callbackUrl:s().optional(),createTime:y().int().optional(),completeTime:y().int().nullable().optional(),errorCode:P([s(),y().int()]).nullable().optional(),errorMessage:s().nullable().optional(),midiData:Yb.nullable().optional()}).passthrough().nullable().optional()}).passthrough();u({uploadUrlList:pa([s().min(1),s().min(1)]),customMode:x(),model:h(["V4","V4_5","V4_5PLUS","V4_5ALL","V5","V5_5"]).or(nt),callBackUrl:s().min(1),prompt:s().optional(),style:s().optional(),title:s().optional(),instrumental:x().optional(),vocalGender:h(["m","f"]).optional(),styleWeight:y().min(0).max(1).optional(),weirdnessConstraint:y().min(0).max(1).optional(),audioWeight:y().min(0).max(1).optional()});u({taskId:s().min(1),audioId:s().min(1),prompt:s().min(1),tags:s().min(1),title:s().min(1),infillStartS:y().min(0),infillEndS:y().min(0),negativeTags:s().optional(),fullLyrics:s().optional(),callBackUrl:s().optional()});u({prompt:s().min(1),model:h(["V5","V5_5"]).or(nt),soundLoop:x().optional(),soundTempo:y().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:x().optional(),callBackUrl:s().optional()});u({uploadUrl:s().min(1),title:s().min(1),tags:s().min(1),callBackUrl:s().min(1),model:h(["V3_5","V4","V4_5","V4_5PLUS","V4_5ALL","V5","V5_5"]).or(nt),negativeTags:s().optional(),vocalGender:h(["m","f"]).optional(),styleWeight:y().min(0).max(1).optional(),weirdnessConstraint:y().min(0).max(1).optional(),audioWeight:y().min(0).max(1).optional()});u({uploadUrl:s().min(1),prompt:s().min(1),title:s().min(1),style:s().min(1),negativeTags:s().min(1),callBackUrl:s().min(1),model:h(["V3_5","V4","V4_5","V4_5PLUS","V4_5ALL","V5","V5_5"]).or(nt),vocalGender:h(["m","f"]).optional(),styleWeight:y().min(0).max(1).optional(),weirdnessConstraint:y().min(0).max(1).optional(),audioWeight:y().min(0).max(1).optional()});const Zb=u({type:h(["text","image_url"]),text:s().optional(),image_url:u({url:s()}).optional()}),eS=u({role:h(["user","assistant","system"]),content:P([s(),k(Zb)])});u({model:s(),messages:k(eS),temperature:y().min(0).max(2).optional(),max_tokens:y().int().positive().optional(),stream:x().optional(),response_format:u({type:h(["text","json_object","json_schema"]),json_schema:z(s(),K()).optional()}).optional()});const tS=s().regex(/^gpt-\d+(?:[-.]\d+)*(?:-[a-z0-9]+)*$/,"Expected a listed model or a versioned GPT alias (e.g. gpt-5-5-mini)"),nS=["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","gpt-6-1-sol"],oS=h(nS).or(tS),iS=h(["low","medium","high","xhigh"]),rS=h(["user","assistant","system","developer","tool"]),aS=u({type:f("input_text"),text:s().min(1)}),sS=u({type:f("input_image"),image_url:s().url()}),lS=u({type:f("input_file"),file_url:s().url()}),cS=Te("type",[aS,sS,lS]),xn=u({role:rS,content:k(cS).min(1)}),go=u({effort:iS.default("low").optional()}),uS=u({type:f("web_search")}),ec=u({type:f("function"),name:s().min(1),description:s().min(1),parameters:z(s(),K())}),pS=Te("type",[uS,ec]),xo=k(pS).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:oS,stream:x().default(!1).optional(),input:P([s().min(1),k(xn).min(1)]),reasoning:go.optional(),tools:xo.optional(),tool_choice:s().optional()});const dS=s().regex(/^grok-\d+(?:[-.]\d+)*(?:-[a-z0-9]+)*$/,"Expected a listed model or a versioned Grok alias (e.g. grok-4-5-fast)"),mS=["grok-4-5","grok-4-6","grok-4-7"],hS=h(mS).or(dS);u({model:hS,stream:x().default(!1).optional(),input:P([s().min(1),k(xn).min(1)]),reasoning:go.optional(),tools:xo.optional(),tool_choice:s().optional()});const fS=s().regex(/^grok-\d+(?:-\d+)*(?:-[a-z0-9]+)*$/,"Expected a listed model or a versioned Grok alias (e.g. grok-4-6)"),gS=["grok-4-7","grok-4-6","grok-4-5","grok-4-3"],xS=h(gS).or(fS);u({model:xS,stream:x().default(!1).optional(),input:P([s().min(1),k(xn).min(1)]),reasoning:go.optional(),tools:xo.optional(),tool_choice:s().optional()});const yS=s().regex(/^gpt-\d+(?:\.\d+)*-codex(?:-[a-z0-9]+)*$/,"Expected a listed model or a versioned GPT Codex alias (e.g. gpt-5.5-codex)"),bS=["gpt-5-codex","gpt-5.1-codex","gpt-5.2-codex","gpt-5.3-codex","gpt-5.4-codex"],SS=h(bS).or(yS);u({model:SS,stream:x().default(!1).optional(),input:P([s().min(1),k(xn).min(1)]),reasoning:go.optional(),tools:xo.optional(),tool_choice:s().optional()});const kS=s().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)"),_S=["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(_S).or(kS),TS=h(["none","minimal","low","medium","high","xhigh","max"]),IS=u({type:h(["enabled","disabled","auto"]).optional()}),RS=u({type:h(["text","json_object","json_schema"]),name:s().optional(),description:s().optional(),schema:z(s(),K()).optional(),strict:x().optional()}),CS=u({format:RS}),vS=P([s(),u({type:f("function"),name:s().min(1)})]);u({model:wS,stream:x().default(!1).optional(),input:P([s().min(1),k(xn).min(1)]),instructions:s().optional(),reasoning:u({effort:TS.optional()}).optional(),thinking:IS.optional(),tools:k(ec).optional(),tool_choice:vS.optional(),text:CS.optional()});const MS=u({type:s(),properties:z(s(),K()).optional(),required:k(s()).optional()}),OS=u({name:s(),description:s(),input_schema:MS}),ES=u({type:s(),text:s().optional()}).passthrough(),tc=u({role:h(["user","assistant"]),content:P([s(),k(ES)])}),nc=s().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-haiku-5-5","claude-opus-5"]).or(nc),messages:k(tc),tools:k(OS).optional(),thinkingFlag:x().optional(),stream:x().optional()});u({after_id:s().min(1).optional()});const AS=["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"],NS=h(AS).or(nc),DS=u({type:f("text"),text:s()}).passthrough(),BS=u({name:s().min(1),description:s().optional(),input_schema:u({type:s()}).passthrough()}).passthrough(),ea=u({type:s()}).passthrough();u({model:NS,max_tokens:y().int().min(1),messages:k(tc).min(1),system:P([s(),k(DS)]).optional(),temperature:y().min(0).max(1).optional(),top_p:y().min(0).max(1).optional(),top_k:y().int().min(0).optional(),stop_sequences:k(s()).optional(),tools:k(BS).optional(),tool_choice:ea.optional(),thinking:ea.optional(),metadata:u({user_id:s().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 VS=["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"],PS=s().regex(/^[A-Z][A-Za-z0-9]*(?: [A-Za-z0-9]+)*$/),ta=h(VS).or(PS);u({taskType:P([ta,k(ta)]).optional(),provider:s().optional(),q:s().optional()});const KS=s().regex(/^[A-Za-z0-9][A-Za-z0-9._-]*(?:\/[A-Za-z0-9][A-Za-z0-9._-]*)?$/);u({model:KS});const zS=P([_g,Ig,wg,Tg,pg,dg,mg,hg,fg,gg,xg,yg,bg,Sg,kg,vg,Eg,Dg,Pg,Lg,$g,Hg,u0,p0,d0,f0,g0,x0,y0,b0,S0,k0,_0,a1,u1,s1,c1,d1,m1,f1,y1,k1,T1,w1,R1,I1,C1,v1,M1,O1,E1,A1,N1,D1,B1,V1,Jg,Qg,e0,n0,o0,i0,r0,a0,s0,l0,c0,I0,v0,E0,N0,B0,z0,U0,j0,L0,X0,Z0,t1,o1,r1,px,dx,mx,hx,fx,gx,Sx,kx,Ix,Rx,Cx,vx,Mx,Ox,Ex,Ax,Nx,Dx,Bx,Vx,z1,F1,q1,U1,G1,L1,W1,$1,H1,J1,X1,Y1,ex,nx,ox,ix,rx,ax,sx,P1,K1,Kx,Fx,Ux,Lx,$x,Jx,Xx,Zx,ty,oy,ay,sy,dy,my,fy,gy,xy,yy,by,Sy,ky,wy,Iy,zy,Fy,Dy,By,Vy,Py,Ly,Wy,jy,$y,Hy,Jy,Ry,Cy,vy,My,Oy,Ey]);eb.pipe(zS);function oc(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=oc(n[e]))&&(o&&(o+=" "),o+=t)}else for(t in n)n[t]&&(o&&(o+=" "),o+=t);return o}function s_(){for(var n,e,t=0,o="",i=arguments.length;t<i;t++)(n=arguments[t])&&(e=oc(n))&&(o&&(o+=" "),o+=e);return o}const FS=(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},qS=(n,e)=>({classGroupId:n,validator:e}),ic=(n=new Map,e=null,t)=>({nextPart:n,validators:e,classGroupId:t}),jn="-",na=[],US="arbitrary..",GS=n=>{const e=WS(n),{conflictingClassGroups:t,conflictingClassGroupModifiers:o}=n;return{getClassGroupId:a=>{if(a.startsWith("[")&&a.endsWith("]"))return LS(a);const l=a.split(jn),c=l[0]===""&&l.length>1?1:0;return rc(l,c,e)},getConflictingClassGroupIds:(a,l)=>{if(l){const c=o[a],p=t[a];return c?p?FS(p,c):c:p||na}return t[a]||na}}},rc=(n,e,t)=>{if(n.length-e===0)return t.classGroupId;const i=n[e],r=t.nextPart.get(i);if(r){const p=rc(n,e+1,r);if(p)return p}const a=t.validators;if(a===null)return;const l=e===0?n.join(jn):n.slice(e).join(jn),c=a.length;for(let p=0;p<c;p++){const d=a[p];if(d.validator(l))return d.classGroupId}},LS=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?US+o:void 0})(),WS=n=>{const{theme:e,classGroups:t}=n;return jS(t,e)},jS=(n,e)=>{const t=ic();for(const o in n){const i=n[o];qi(i,t,o,e)}return t},qi=(n,e,t,o)=>{const i=n.length;for(let r=0;r<i;r++){const a=n[r];$S(a,e,t,o)}},$S=(n,e,t,o)=>{if(typeof n=="string"){HS(n,e,t);return}if(typeof n=="function"){JS(n,e,t,o);return}QS(n,e,t,o)},HS=(n,e,t)=>{const o=n===""?e:ac(e,n);o.classGroupId=t},JS=(n,e,t,o)=>{if(XS(n)){qi(n(o),e,t,o);return}e.validators===null&&(e.validators=[]),e.validators.push(qS(t,n))},QS=(n,e,t,o)=>{const i=Object.entries(n),r=i.length;for(let a=0;a<r;a++){const[l,c]=i[a];qi(c,ac(e,l),t,o)}},ac=(n,e)=>{let t=n;const o=e.split(jn),i=o.length;for(let r=0;r<i;r++){const a=o[r];let l=t.nextPart.get(a);l||(l=ic(),t.nextPart.set(a,l)),t=l}return t},XS=n=>"isThemeGetter"in n&&n.isThemeGetter===!0,YS=n=>{if(n<1)return{get:()=>{},set:()=>{}};let e=0,t=Object.create(null),o=Object.create(null);const i=(r,a)=>{t[r]=a,e++,e>n&&(e=0,o=t,t=Object.create(null))};return{get(r){let a=t[r];if(a!==void 0)return a;if((a=o[r])!==void 0)return i(r,a),a},set(r,a){r in t?t[r]=a:i(r,a)}}},ii="!",oa=":",ZS=[],ia=(n,e,t,o,i)=>({modifiers:n,hasImportantModifier:e,baseClassName:t,maybePostfixModifierPosition:o,isExternal:i}),ek=n=>{const{prefix:e,experimentalParseClassName:t}=n;let o=i=>{const r=[];let a=0,l=0,c=0,p;const d=i.length;for(let _=0;_<d;_++){const w=i[_];if(a===0&&l===0){if(w===oa){r.push(i.slice(c,_)),c=_+1;continue}if(w==="/"){p=_;continue}}w==="["?a++:w==="]"?a--:w==="("?l++:w===")"&&l--}const m=r.length===0?i:i.slice(c);let g=m,b=!1;m.endsWith(ii)?(g=m.slice(0,-1),b=!0):m.startsWith(ii)&&(g=m.slice(1),b=!0);const S=p&&p>c?p-c:void 0;return ia(r,b,g,S)};if(e){const i=e+oa,r=o;o=a=>a.startsWith(i)?r(a.slice(i.length)):ia(ZS,!1,a,void 0,!0)}if(t){const i=o;o=r=>t({className:r,parseClassName:i})}return o},tk=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 a=t[r],l=a[0]==="[",c=e.has(a);l||c?(i.length>0&&(i.sort(),o.push(...i),i=[]),o.push(a)):i.push(a)}return i.length>0&&(i.sort(),o.push(...i)),o}},nk=n=>({cache:YS(n.cacheSize),parseClassName:ek(n),sortModifiers:tk(n),...GS(n)}),ok=/\s+/,ik=(n,e)=>{const{parseClassName:t,getClassGroupId:o,getConflictingClassGroupIds:i,sortModifiers:r}=e,a=[],l=n.trim().split(ok);let c="";for(let p=l.length-1;p>=0;p-=1){const d=l[p],{isExternal:m,modifiers:g,hasImportantModifier:b,baseClassName:S,maybePostfixModifierPosition:_}=t(d);if(m){c=d+(c.length>0?" "+c:c);continue}let w=!!_,O=o(w?S.substring(0,_):S);if(!O){if(!w){c=d+(c.length>0?" "+c:c);continue}if(O=o(S),!O){c=d+(c.length>0?" "+c:c);continue}w=!1}const L=g.length===0?"":g.length===1?g[0]:r(g).join(":"),F=b?L+ii:L,ne=F+O;if(a.indexOf(ne)>-1)continue;a.push(ne);const v=i(O,w);for(let I=0;I<v.length;++I){const C=v[I];a.push(F+C)}c=d+(c.length>0?" "+c:c)}return c},rk=(...n)=>{let e=0,t,o,i="";for(;e<n.length;)(t=n[e++])&&(o=sc(t))&&(i&&(i+=" "),i+=o);return i},sc=n=>{if(typeof n=="string")return n;let e,t="";for(let o=0;o<n.length;o++)n[o]&&(e=sc(n[o]))&&(t&&(t+=" "),t+=e);return t},ak=(n,...e)=>{let t,o,i,r;const a=c=>{const p=e.reduce((d,m)=>m(d),n());return t=nk(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=ik(c,t);return i(c,d),d};return r=a,(...c)=>r(rk(...c))},sk=[],j=n=>{const e=t=>t[n]||sk;return e.isThemeGetter=!0,e},lc=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,cc=/^\((?:(\w[\w-]*):)?(.+)\)$/i,lk=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,ck=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,uk=/\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$/,pk=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,dk=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,mk=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,qe=n=>lk.test(n),V=n=>!!n&&!Number.isNaN(Number(n)),Ue=n=>!!n&&Number.isInteger(Number(n)),Ko=n=>n.endsWith("%")&&V(n.slice(0,-1)),De=n=>ck.test(n),uc=()=>!0,hk=n=>uk.test(n)&&!pk.test(n),Ui=()=>!1,fk=n=>dk.test(n),gk=n=>mk.test(n),xk=n=>!M(n)&&!E(n),yk=n=>ot(n,mc,Ui),M=n=>lc.test(n),rt=n=>ot(n,hc,hk),ra=n=>ot(n,Rk,V),bk=n=>ot(n,gc,uc),Sk=n=>ot(n,fc,Ui),aa=n=>ot(n,pc,Ui),kk=n=>ot(n,dc,gk),Mn=n=>ot(n,xc,fk),E=n=>cc.test(n),qt=n=>St(n,hc),_k=n=>St(n,fc),sa=n=>St(n,pc),wk=n=>St(n,mc),Tk=n=>St(n,dc),On=n=>St(n,xc,!0),Ik=n=>St(n,gc,!0),ot=(n,e,t)=>{const o=lc.exec(n);return o?o[1]?e(o[1]):t(o[2]):!1},St=(n,e,t=!1)=>{const o=cc.exec(n);return o?o[1]?e(o[1]):t:!1},pc=n=>n==="position"||n==="percentage",dc=n=>n==="image"||n==="url",mc=n=>n==="length"||n==="size"||n==="bg-size",hc=n=>n==="length",Rk=n=>n==="number",fc=n=>n==="family-name",gc=n=>n==="number"||n==="weight",xc=n=>n==="shadow",Ck=()=>{const n=j("color"),e=j("font"),t=j("text"),o=j("font-weight"),i=j("tracking"),r=j("leading"),a=j("breakpoint"),l=j("container"),c=j("spacing"),p=j("radius"),d=j("shadow"),m=j("inset-shadow"),g=j("text-shadow"),b=j("drop-shadow"),S=j("blur"),_=j("perspective"),w=j("aspect"),O=j("ease"),L=j("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"],v=()=>[...ne(),E,M],I=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],T=()=>[E,M,c],D=()=>[qe,"full","auto",...T()],pe=()=>[Ue,"none","subgrid",E,M],yn=()=>["auto",{span:["full",Ue,E,M]},Ue,E,M],kt=()=>[Ue,"auto",E,M],bn=()=>["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"],Se=()=>["auto",...T()],it=()=>[qe,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],yo=()=>[qe,"screen","full","dvw","lvw","svw","min","max","fit",...T()],bo=()=>[qe,"screen","full","lh","dvh","lvh","svh","min","max","fit",...T()],N=()=>[n,E,M],Li=()=>[...ne(),sa,aa,{position:[E,M]}],Wi=()=>["no-repeat",{repeat:["","x","y","space","round"]}],ji=()=>["auto","cover","contain",wk,yk,{size:[E,M]}],So=()=>[Ko,qt,rt],ae=()=>["","none","full",p,E,M],se=()=>["",V,qt,rt],Sn=()=>["solid","dashed","dotted","double"],$i=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],$=()=>[V,Ko,sa,aa],Hi=()=>["","none",S,E,M],kn=()=>["none",V,E,M],_n=()=>["none",V,E,M],ko=()=>[V,E,M],wn=()=>[qe,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[De],breakpoint:[De],color:[uc],container:[De],"drop-shadow":[De],ease:["in","out","in-out"],font:[xk],"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",qe,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:v()}],overflow:[{overflow:I()}],"overflow-x":[{"overflow-x":I()}],"overflow-y":[{"overflow-y":I()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],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:[Ue,"auto",E,M]}],basis:[{basis:[qe,"full","auto",l,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[V,qe,"auto","initial","none",M]}],grow:[{grow:["",V,E,M]}],shrink:[{shrink:["",V,E,M]}],order:[{order:[Ue,"first","last","none",E,M]}],"grid-cols":[{"grid-cols":pe()}],"col-start-end":[{col:yn()}],"col-start":[{"col-start":kt()}],"col-end":[{"col-end":kt()}],"grid-rows":[{"grid-rows":pe()}],"row-start-end":[{row:yn()}],"row-start":[{"row-start":kt()}],"row-end":[{"row-end":kt()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":bn()}],"auto-rows":[{"auto-rows":bn()}],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:Se()}],mx:[{mx:Se()}],my:[{my:Se()}],ms:[{ms:Se()}],me:[{me:Se()}],mbs:[{mbs:Se()}],mbe:[{mbe:Se()}],mt:[{mt:Se()}],mr:[{mr:Se()}],mb:[{mb:Se()}],ml:[{ml:Se()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:it()}],"inline-size":[{inline:["auto",...yo()]}],"min-inline-size":[{"min-inline":["auto",...yo()]}],"max-inline-size":[{"max-inline":["none",...yo()]}],"block-size":[{block:["auto",...bo()]}],"min-block-size":[{"min-block":["auto",...bo()]}],"max-block-size":[{"max-block":["none",...bo()]}],w:[{w:[l,"screen",...it()]}],"min-w":[{"min-w":[l,"screen","none",...it()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[a]},...it()]}],h:[{h:["screen","lh",...it()]}],"min-h":[{"min-h":["screen","lh","none",...it()]}],"max-h":[{"max-h":["screen","lh",...it()]}],"font-size":[{text:["base",t,qt,rt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[o,Ik,bk]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ko,M]}],"font-family":[{font:[_k,Sk,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,ra]}],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,rt]}],"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:Li()}],"bg-repeat":[{bg:Wi()}],"bg-size":[{bg:ji()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ue,E,M],radial:["",E,M],conic:[Ue,E,M]},Tk,kk]}],"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:ae()}],"rounded-s":[{"rounded-s":ae()}],"rounded-e":[{"rounded-e":ae()}],"rounded-t":[{"rounded-t":ae()}],"rounded-r":[{"rounded-r":ae()}],"rounded-b":[{"rounded-b":ae()}],"rounded-l":[{"rounded-l":ae()}],"rounded-ss":[{"rounded-ss":ae()}],"rounded-se":[{"rounded-se":ae()}],"rounded-ee":[{"rounded-ee":ae()}],"rounded-es":[{"rounded-es":ae()}],"rounded-tl":[{"rounded-tl":ae()}],"rounded-tr":[{"rounded-tr":ae()}],"rounded-br":[{"rounded-br":ae()}],"rounded-bl":[{"rounded-bl":ae()}],"border-w":[{border:se()}],"border-w-x":[{"border-x":se()}],"border-w-y":[{"border-y":se()}],"border-w-s":[{"border-s":se()}],"border-w-e":[{"border-e":se()}],"border-w-bs":[{"border-bs":se()}],"border-w-be":[{"border-be":se()}],"border-w-t":[{"border-t":se()}],"border-w-r":[{"border-r":se()}],"border-w-b":[{"border-b":se()}],"border-w-l":[{"border-l":se()}],"divide-x":[{"divide-x":se()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":se()}],"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,qt,rt]}],"outline-color":[{outline:N()}],shadow:[{shadow:["","none",d,On,Mn]}],"shadow-color":[{shadow:N()}],"inset-shadow":[{"inset-shadow":["none",m,On,Mn]}],"inset-shadow-color":[{"inset-shadow":N()}],"ring-w":[{ring:se()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:N()}],"ring-offset-w":[{"ring-offset":[V,rt]}],"ring-offset-color":[{"ring-offset":N()}],"inset-ring-w":[{"inset-ring":se()}],"inset-ring-color":[{"inset-ring":N()}],"text-shadow":[{"text-shadow":["none",g,On,Mn]}],"text-shadow-color":[{"text-shadow":N()}],opacity:[{opacity:[V,E,M]}],"mix-blend":[{"mix-blend":[...$i(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":$i()}],"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":$()}],"mask-image-linear-to-pos":[{"mask-linear-to":$()}],"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":$()}],"mask-image-t-to-pos":[{"mask-t-to":$()}],"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":$()}],"mask-image-r-to-pos":[{"mask-r-to":$()}],"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":$()}],"mask-image-b-to-pos":[{"mask-b-to":$()}],"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":$()}],"mask-image-l-to-pos":[{"mask-l-to":$()}],"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":$()}],"mask-image-x-to-pos":[{"mask-x-to":$()}],"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":$()}],"mask-image-y-to-pos":[{"mask-y-to":$()}],"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":$()}],"mask-image-radial-to-pos":[{"mask-radial-to":$()}],"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":$()}],"mask-image-conic-to-pos":[{"mask-conic-to":$()}],"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:Li()}],"mask-repeat":[{mask:Wi()}],"mask-size":[{mask:ji()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",E,M]}],filter:[{filter:["","none",E,M]}],blur:[{blur:Hi()}],brightness:[{brightness:[V,E,M]}],contrast:[{contrast:[V,E,M]}],"drop-shadow":[{"drop-shadow":["","none",b,On,Mn]}],"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":Hi()}],"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",O,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":v()}],rotate:[{rotate:kn()}],"rotate-x":[{"rotate-x":kn()}],"rotate-y":[{"rotate-y":kn()}],"rotate-z":[{"rotate-z":kn()}],scale:[{scale:_n()}],"scale-x":[{"scale-x":_n()}],"scale-y":[{"scale-y":_n()}],"scale-z":[{"scale-z":_n()}],"scale-3d":["scale-3d"],skew:[{skew:ko()}],"skew-x":[{"skew-x":ko()}],"skew-y":[{"skew-y":ko()}],transform:[{transform:[E,M,"","none","gpu","cpu"]}],"transform-origin":[{origin:v()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:wn()}],"translate-x":[{"translate-x":wn()}],"translate-y":[{"translate-y":wn()}],"translate-z":[{"translate-z":wn()}],"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,qt,rt,ra]}],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"]}},l_=ak(Ck),c_="Project slugs must contain at least one letter (a-z) or number (0-9)";function u_(n){return n.normalize("NFKD").replace(new RegExp("\\p{M}+","gu"),"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}const vk="5.7.1",p_={version:vk};let Gi;Gi=globalThis.crypto;async function Mk(n){return(await Gi).getRandomValues(new Uint8Array(n))}async function Ok(n){const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",t=Math.pow(2,8)-Math.pow(2,8)%e.length;let o="";for(;o.length<n;){const i=await Mk(n-o.length);for(const r of i)r<t&&(o+=e[r%e.length])}return o}async function Ek(n){return await Ok(n)}async function Ak(n){const e=await(await Gi).subtle.digest("SHA-256",new TextEncoder().encode(n));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function d_(n){if(n||(n=43),n<43||n>128)throw`Expected a length between 43 and 128. Received ${n}.`;const e=await Ek(n),t=await Ak(e);return{code_verifier:e,code_challenge:t}}class zo 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 la=10,Nk=13,at=32;function Fo(n){}function Dk(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=Fo,onError:t=Fo,onRetry:o=Fo,onComment:i,maxBufferSize:r}=n,a=[];let l=0,c=!0,p,d="",m=0,g,b=!1;function S(v){if(b)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,v.charCodeAt(0)===239&&v.charCodeAt(1)===187&&v.charCodeAt(2)===191&&(v=v.slice(3))),a.length===0){const T=w(v);T!==""&&(a.push(T),l=T.length),_();return}if(v.indexOf(`
11
11
  `)===-1&&v.indexOf("\r")===-1){a.push(v),l+=v.length,_();return}a.push(v);const I=a.join("");a.length=0,l=0;const C=w(I);C!==""&&(a.push(C),l=C.length),_()}function _(){r!==void 0&&(l+d.length<=r||(b=!0,a.length=0,l=0,p=void 0,d="",m=0,g=void 0,t(new zo(`Buffered data exceeded max buffer size of ${r} characters`,{type:"max-buffer-size-exceeded"}))))}function w(v){let I=0;if(v.indexOf("\r")===-1){let C=v.indexOf(`
12
12
  `,I);for(;C!==-1;){if(I===C){m>0&&e({id:p,event:g,data:d}),p=void 0,d="",m=0,g=void 0,I=C+1,C=v.indexOf(`
13
- `,I);continue}const T=v.charCodeAt(I);if(la(v,I,T)){const D=v.charCodeAt(I+5)===at?I+6:I+5,pe=v.slice(D,C);if(m===0&&v.charCodeAt(C+1)===sa){e({id:p,event:g,data:pe}),p=void 0,d="",g=void 0,I=C+2,C=v.indexOf(`
13
+ `,I);continue}const T=v.charCodeAt(I);if(ca(v,I,T)){const D=v.charCodeAt(I+5)===at?I+6:I+5,pe=v.slice(D,C);if(m===0&&v.charCodeAt(C+1)===la){e({id:p,event:g,data:pe}),p=void 0,d="",g=void 0,I=C+2,C=v.indexOf(`
14
14
  `,I);continue}d=m===0?pe:`${d}
15
- ${pe}`,m++}else ca(v,I,T)?g=v.slice(v.charCodeAt(I+6)===at?I+7:I+6,C)||void 0:O(v,I,C);I=C+1,C=v.indexOf(`
15
+ ${pe}`,m++}else ua(v,I,T)?g=v.slice(v.charCodeAt(I+6)===at?I+7:I+6,C)||void 0:O(v,I,C);I=C+1,C=v.indexOf(`
16
16
  `,I)}return v.slice(I)}for(;I<v.length;){const C=v.indexOf("\r",I),T=v.indexOf(`
17
- `,I);let D=-1;if(C!==-1&&T!==-1?D=C<T?C:T:C!==-1?C===v.length-1?D=-1:D=C:T!==-1&&(D=T),D===-1)break;O(v,I,D),I=D+1,v.charCodeAt(I-1)===Nk&&v.charCodeAt(I)===sa&&I++}return v.slice(I)}function O(v,I,C){if(I===C){F();return}const T=v.charCodeAt(I);if(la(v,I,T)){const Ie=v.charCodeAt(I+5)===at?I+6:I+5,Ae=v.slice(Ie,C);d=m===0?Ae:`${d}
18
- ${Ae}`,m++;return}if(ca(v,I,T)){g=v.slice(v.charCodeAt(I+6)===at?I+7:I+6,C)||void 0;return}if(T===105&&v.charCodeAt(I+1)===100&&v.charCodeAt(I+2)===58){const Ie=v.slice(v.charCodeAt(I+3)===at?I+4:I+3,C);Ie.includes("\0")||(p=Ie);return}if(T===58){if(i){const Ie=v.slice(I,C);i(Ie.slice(v.charCodeAt(I+1)===at?2:1))}return}const D=v.slice(I,C),pe=D.indexOf(":");if(pe===-1){L(D,"",D);return}const yn=D.slice(0,pe),kt=D.charCodeAt(pe+1)===at?2:1,bn=D.slice(pe+kt);L(yn,bn,D)}function L(v,I,C){switch(v){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 zo(`Invalid \`retry\` value: "${I}"`,{type:"invalid-retry",value:I,line:C}));break;default:t(new zo(`Unknown field "${v.length>20?`${v.slice(0,20)}…`:v}"`,{type:"unknown-field",field:v,value:I,line:C}));break}}function F(){m>0&&e({id:p,event:g,data:d}),p=void 0,d="",m=0,g=void 0}function ne(v={}){if(v.consume&&a.length>0){const I=a.join("");O(I,0,I.length)}c=!0,p=void 0,d="",m=0,g=void 0,a.length=0,l=0,b=!1}return{feed:S,reset:ne}}function la(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 ca(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 m_ extends TransformStream{constructor({onError:e,onRetry:t,onComment:o,maxBufferSize:i}={}){let r;super({start(a){r=Dk({onEvent:l=>{a.enqueue(l)},onError(l){typeof e=="function"&&e(l),(e==="terminate"||l.type==="max-buffer-size-exceeded")&&a.error(l)},onRetry:t,onComment:o,maxBufferSize:i})},transform(a){r.feed(a)}})}}export{pa as A,vc as B,qk as C,ha as D,n_ as E,Wt as F,o_ as G,i_ as H,Sd as I,Hd as J,$d as K,t_ as L,Qr as M,Me as N,l_ as O,s_ as P,u_ as Q,c_ as R,e_ as S,Xk as T,p_ as U,r_ as V,m_ as W,d_ as X,Fk as Y,Vc as a,Lk as b,Mc as c,Oe as d,Kk as e,sn as f,U as g,Gk as h,Vk as i,Uk as j,Hk as k,jk as l,wc as m,Cc as n,Tc as o,Jk as p,$k as q,a_ as r,Pk as s,Yk as t,zk as u,Wk as v,Uc as w,Zk as x,Qk as y,Pc as z};
17
+ `,I);let D=-1;if(C!==-1&&T!==-1?D=C<T?C:T:C!==-1?C===v.length-1?D=-1:D=C:T!==-1&&(D=T),D===-1)break;O(v,I,D),I=D+1,v.charCodeAt(I-1)===Nk&&v.charCodeAt(I)===la&&I++}return v.slice(I)}function O(v,I,C){if(I===C){F();return}const T=v.charCodeAt(I);if(ca(v,I,T)){const Ie=v.charCodeAt(I+5)===at?I+6:I+5,Ae=v.slice(Ie,C);d=m===0?Ae:`${d}
18
+ ${Ae}`,m++;return}if(ua(v,I,T)){g=v.slice(v.charCodeAt(I+6)===at?I+7:I+6,C)||void 0;return}if(T===105&&v.charCodeAt(I+1)===100&&v.charCodeAt(I+2)===58){const Ie=v.slice(v.charCodeAt(I+3)===at?I+4:I+3,C);Ie.includes("\0")||(p=Ie);return}if(T===58){if(i){const Ie=v.slice(I,C);i(Ie.slice(v.charCodeAt(I+1)===at?2:1))}return}const D=v.slice(I,C),pe=D.indexOf(":");if(pe===-1){L(D,"",D);return}const yn=D.slice(0,pe),kt=D.charCodeAt(pe+1)===at?2:1,bn=D.slice(pe+kt);L(yn,bn,D)}function L(v,I,C){switch(v){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 zo(`Invalid \`retry\` value: "${I}"`,{type:"invalid-retry",value:I,line:C}));break;default:t(new zo(`Unknown field "${v.length>20?`${v.slice(0,20)}…`:v}"`,{type:"unknown-field",field:v,value:I,line:C}));break}}function F(){m>0&&e({id:p,event:g,data:d}),p=void 0,d="",m=0,g=void 0}function ne(v={}){if(v.consume&&a.length>0){const I=a.join("");O(I,0,I.length)}c=!0,p=void 0,d="",m=0,g=void 0,a.length=0,l=0,b=!1}return{feed:S,reset:ne}}function ca(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 ua(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 m_ extends TransformStream{constructor({onError:e,onRetry:t,onComment:o,maxBufferSize:i}={}){let r;super({start(a){r=Dk({onEvent:l=>{a.enqueue(l)},onError(l){typeof e=="function"&&e(l),(e==="terminate"||l.type==="max-buffer-size-exceeded")&&a.error(l)},onRetry:t,onComment:o,maxBufferSize:i})},transform(a){r.feed(a)}})}}export{da as A,Cc as B,qk as C,fa as D,n_ as E,Wt as F,o_ as G,i_ as H,bd as I,$d as J,jd as K,t_ as L,Xr as M,Me as N,l_ as O,s_ as P,u_ as Q,c_ as R,e_ as S,Xk as T,p_ as U,r_ as V,m_ as W,d_ as X,Fk as Y,Bc as a,Lk as b,vc as c,Oe as d,Kk as e,sn as f,U as g,Gk as h,Vk as i,Uk as j,Hk as k,jk as l,_c as m,Rc as n,wc as o,Jk as p,$k as q,a_ as r,Pk as s,Yk as t,zk as u,Wk as v,qc as w,Zk as x,Qk as y,Vc as z};