vdc-editor 0.1.193 → 0.1.194

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,4 +1,4 @@
1
- import { A as i, r as t, q as o, s as r, E as d, p, t as u, p as E, B as l, v as n, F as S, y as m, u as w, w as x, z as f, x as g } from "./index-DTJg9eJF.mjs";
1
+ import { A as i, r as t, q as o, s as r, E as d, p, t as u, p as E, B as l, v as n, F as S, y as m, u as w, w as x, z as f, x as g } from "./index-Beeb7hr-.mjs";
2
2
  import "@vueuse/core";
3
3
  export {
4
4
  i as ArticleCompareEditor,
@@ -277,7 +277,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),ne=R,te=q),Z===void 0&
277
277
  ${n?"!bg-ed-blue":t.storage.superText.enable?"!bg-blue-700":"!bg-blue-500"}
278
278
  `,tooltip:"수퍼 보기"}}]}},addAttributes(){return{[ot.ID]:{default:null},[ot.TEXT]:{default:""},[ot.POSITION]:{default:"0"},[ot.ELEMENT_ID]:{default:""}}},addCommands(){return{toggleSuperText:t=>({editor:e})=>t?e.storage.superText.toggleSuperViewMobileCallBack():e.storage.superText.enable=!e.storage.superText.enable,toggleSuperInputMoblie:()=>({editor:t})=>t.storage.superText.isShowSuperInputMoblie=!t.storage.superText.isShowSuperInputMoblie}},parseHTML(){return[{tag:"button.super-text"}]},renderHTML({HTMLAttributes:t}){return["button",bt(t,{class:"super-text"})]},addNodeView(){return Hs(LK)},addProseMirrorPlugins(){return[new tt({appendTransaction(t,e,n){let r=n.tr,o=!1;return n.doc.descendants((s,a)=>{if(s.type.name==="superText"){const l=s.attrs[ot.POSITION],u=String(a);l!==u&&(r=r.setNodeMarkup(a,void 0,{...s.attrs,[ot.POSITION]:u}),o=!0)}}),o?r:null}}),new tt({filterTransaction(t,e){return t.steps.some(r=>{if(r.toJSON&&r.toJSON().stepType==="replace"){const o=r.toJSON();return o.slice&&o.slice.content&&o.slice.content.some(s=>s.type===cc)}return!1})&&t.setMeta(xE.UPDATE,!0),!0}}),PK,DK]}}),VK=["innerHTML"],FK=["book-mark-node-id","page-id","page-number","book-mark-content","node-id","line-id"],$K=i.defineComponent({__name:"ConfigPlan",props:zs,setup(t){const e=t,n=i.ref(!1),r=i.ref(null),{selection:o,doc:s}=e.editor.state,a=i.inject("isMobile"),l=i.ref(!1),u=at.useEventBus(ir.RENDER_SUPER_TEXT),c=i.computed(()=>{var _,T;const x=s.resolve(o.from),S=x==null?void 0:x.node(-1),C=(_=S==null?void 0:S.attrs)==null?void 0:_.id,E=(T=S==null?void 0:S.attrs)==null?void 0:T.pageNumber;return{pageId:C,pageNumber:E}}),f=i.computed(()=>{const x=e.getPos(),S=e.editor.state.doc.resolve(x);for(let C=S.depth;C>0;C--){const E=S.node(C);if(E.type.name==="paragraph")return E}return null}),p=i.computed(()=>{var x;return((x=f.value)==null?void 0:x.attrs.id)||""});function m(x){e.updateAttributes({"data-text":x}),n.value=!1}function g(x){const S=e.node.attrs[ot.TEXT],C=e.node.attrs[ot.ID],_={lineId:x.target.querySelector(`[node-id="${C}"]`).getAttribute("line-id"),text:S};u.emit({action:"hover",payload:_})}function b(x){const S=e.node.attrs[ot.ID],E={lineId:x.target.querySelector(`[node-id="${S}"]`).getAttribute("line-id"),text:""};u.emit({action:"hover",payload:E})}function y(){const{getPos:x,node:S,editor:C}=e,E=x(),_=E+1;C.commands.deleteRange({from:E,to:_})}function w(){n.value=!0,a&&(l.value=!0)}return(x,S)=>{const C=_n,E=kp,_=Sp,T=Ep,A=Cp,L=uc;return i.openBlock(),i.createBlock(i.unref($s),{as:"span",class:i.normalizeClass(["w-fit text-inherit super-text align-middle",{"!leading-[9px] [&_*]:!leading-[9px]":i.unref(a)}]),"data-drag-handle":"",draggable:"true",contenteditable:"false"},{default:i.withCtx(()=>[i.createVNode(A,null,{default:i.withCtx(()=>[i.createVNode(E,{as:"template",class:"relative"},{default:i.withCtx(()=>[i.createVNode(C,{variant:"ghost",class:"!p-0 !m-0 !h-fit font-normal !text-ed-blue",onClick:w,onMouseenter:g,onMouseleave:b},{default:i.withCtx(()=>[i.createVNode(i.unref(jt),{name:"plan",class:i.normalizeClass({"w-[18px] h-auto pr-1":i.unref(a)})},null,8,["class"]),S[3]||(S[3]=i.createTextVNode(" [")),i.createElementVNode("span",{class:"[&_*]:inline",innerHTML:e.node.attrs[i.unref(ot).TEXT]},null,8,VK),S[4]||(S[4]=i.createTextVNode("] ")),i.createElementVNode("div",{ref_key:"bookMarkRef",ref:r,"book-mark-node-id":e.node.attrs[i.unref(ot).ID],"page-id":c.value.pageId,"page-number":c.value.pageNumber,"book-mark-content":e.node.attrs[i.unref(ot).TEXT],"node-id":e.node.attrs[i.unref(ot).ID],"line-id":p.value},null,8,FK)]),_:1})]),_:1}),i.createVNode(T,null,{default:i.withCtx(()=>[i.createVNode(_,{onSelect:S[0]||(S[0]=D=>n.value=!0)},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(x.$t("editor.configPlan.edit")),1)]),_:1}),i.createVNode(_,{onSelect:y},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(x.$t("editor.configPlan.delete")),1)]),_:1})]),_:1})]),_:1}),i.unref(a)?(i.openBlock(),i.createBlock(Ip,{key:1,title:x.$t("editor.configPlan"),open:n.value,"is-view-mode":l.value,editor:e.editor,"super-text-init":e.node.attrs[i.unref(ot).TEXT],"super-text-id":e.node.attrs[i.unref(ot).ID],onClose:S[2]||(S[2]=D=>n.value=!1),onSave:m,onDelete:y},null,8,["title","open","is-view-mode","editor","super-text-init","super-text-id"])):(i.openBlock(),i.createBlock(L,{key:0,open:n.value,editor:e.editor,"super-text-init":e.node.attrs[i.unref(ot).TEXT],"super-text-element-id":e.node.attrs[i.unref(ot).ELEMENT_ID],onClose:S[1]||(S[1]=D=>n.value=!1),onSave:m},null,8,["open","editor","super-text-init","super-text-element-id"]))]),_:1},8,["class"])}}}),EE=Bt.create({name:"configPlan",inline:!0,group:"inline",atom:!0,draggable:!0,addStorage(){return{isShowConfigPlanInput:!1}},addOptions(){return{specialCharModal:null,button:({editor:t,t:e,isMobile:n})=>[...n?[{component:Ge,componentProps:{action:()=>{t.commands.toggleConfigPlanInput()},isActive:()=>{},icon:"plan",title:e("editor.insertConfigPlan"),tooltip:e("editor.insertConfigPlan"),customClass:"whitespace-nowrap !bg-ed-blue !text-white !font-normal rounded-[3px] h-[26px] gap-x-1 ml-auto",customClassTooltip:"ml-auto"}}]:[]]}},addAttributes(){return{"data-id":{default:null},"data-text":{default:""},"data-position":{default:"0"}}},addCommands(){return{toggleConfigPlanInput:()=>({editor:t})=>t.storage.configPlan.isShowConfigPlanInput=!t.storage.configPlan.isShowConfigPlanInput}},parseHTML(){return[{tag:"button.config-plan"}]},renderHTML({HTMLAttributes:t}){return["button",bt(t,{class:"config-plan"})]},addNodeView(){return Hs($K)},addProseMirrorPlugins(){return[new tt({appendTransaction(t,e,n){let r=n.tr,o=!1;return n.doc.descendants((s,a)=>{if(s.type.name==="configPlan"){const l=s.attrs["data-position"],u=String(a);l!==u&&(r=r.setNodeMarkup(a,void 0,{...s.attrs,"data-position":u}),o=!0)}}),o?r:null}})]}});var bb,vb;if(typeof WeakMap<"u"){let t=new WeakMap;bb=e=>t.get(e),vb=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;bb=r=>{for(let o=0;o<t.length;o+=2)if(t[o]==r)return t[o+1]},vb=(r,o)=>(n==10&&(n=0),t[n++]=r,t[n++]=o)}var rn=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,o=e/this.width|0;let s=r+1,a=o+1;for(let l=1;s<this.width&&this.map[e+l]==n;l++)s++;for(let l=1;a<this.height&&this.map[e+this.width*l]==n;l++)a++;return{left:r,top:o,right:s,bottom:a}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:o,top:s,bottom:a}=this.findCell(t);return e=="horiz"?(n<0?r==0:o==this.width)?null:this.map[s*this.width+(n<0?r-1:o)]:(n<0?s==0:a==this.height)?null:this.map[r+this.width*(n<0?s-1:a)]}rectBetween(t,e){const{left:n,right:r,top:o,bottom:s}=this.findCell(t),{left:a,right:l,top:u,bottom:c}=this.findCell(e);return{left:Math.min(n,a),top:Math.min(o,u),right:Math.max(r,l),bottom:Math.max(s,c)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let o=t.left;o<t.right;o++){const s=r*this.width+o,a=this.map[s];n[a]||(n[a]=!0,!(o==t.left&&o&&this.map[s-1]==a||r==t.top&&r&&this.map[s-this.width]==a)&&e.push(a))}return e}positionAt(t,e,n){for(let r=0,o=0;;r++){const s=o+n.child(r).nodeSize;if(r==t){let a=e+t*this.width;const l=(t+1)*this.width;for(;a<l&&this.map[a]<o;)a++;return a==l?s-1:this.map[a]}o=s}}static get(t){return bb(t)||vb(t,zK(t))}};function zK(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=HK(t),n=t.childCount,r=[];let o=0,s=null;const a=[];for(let c=0,f=e*n;c<f;c++)r[c]=0;for(let c=0,f=0;c<n;c++){const p=t.child(c);f++;for(let b=0;;b++){for(;o<r.length&&r[o]!=0;)o++;if(b==p.childCount)break;const y=p.child(b),{colspan:w,rowspan:x,colwidth:S}=y.attrs;for(let C=0;C<x;C++){if(C+c>=n){(s||(s=[])).push({type:"overlong_rowspan",pos:f,n:x-C});break}const E=o+C*e;for(let _=0;_<w;_++){r[E+_]==0?r[E+_]=f:(s||(s=[])).push({type:"collision",row:c,pos:f,n:w-_});const T=S&&S[_];if(T){const A=(E+_)%e*2,L=a[A];L==null||L!=T&&a[A+1]==1?(a[A]=T,a[A+1]=1):L==T&&a[A+1]++}}}o+=w,f+=y.nodeSize}const m=(c+1)*e;let g=0;for(;o<m;)r[o++]==0&&g++;g&&(s||(s=[])).push({type:"missing",row:c,n:g}),f++}(e===0||n===0)&&(s||(s=[])).push({type:"zero_sized"});const l=new rn(e,n,r,s);let u=!1;for(let c=0;!u&&c<a.length;c+=2)a[c]!=null&&a[c+1]<n&&(u=!0);return u&&UK(l,a,t),l}function HK(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const o=t.child(r);let s=0;if(n)for(let a=0;a<r;a++){const l=t.child(a);for(let u=0;u<l.childCount;u++){const c=l.child(u);a+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let a=0;a<o.childCount;a++){const l=o.child(a);s+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function UK(t,e,n){t.problems||(t.problems=[]);const r={};for(let o=0;o<t.map.length;o++){const s=t.map[o];if(r[s])continue;r[s]=!0;const a=n.nodeAt(s);if(!a)throw new RangeError(`No cell with offset ${s} found`);let l=null;const u=a.attrs;for(let c=0;c<u.colspan;c++){const f=(o+c)%t.width,p=e[f*2];p!=null&&(!u.colwidth||u.colwidth[c]!=p)&&((l||(l=WK(u)))[c]=p)}l&&t.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function WK(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Fn(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],o=r.spec.tableRole;o&&(e[o]=r)}}return e}var fs=new St("selectingCells");function Sl(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function jK(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function uo(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function Rp(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=Sl(e.$head)||qK(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function qK(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function yb(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function KK(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function wb(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function SE(t,e,n){const r=t.node(-1),o=rn.get(r),s=t.start(-1),a=o.nextCell(t.pos-s,e,n);return a==null?null:t.node(0).resolve(s+a)}function la(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function kE(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<n;o++)r.colwidth.splice(e,0,0)}return r}function GK(t,e,n){const r=Fn(e.type.schema).header_cell;for(let o=0;o<t.height;o++)if(e.nodeAt(t.map[n+o*t.width]).type!=r)return!1;return!0}var Ft=class _i extends ze{constructor(e,n=e){const r=e.node(-1),o=rn.get(r),s=e.start(-1),a=o.rectBetween(e.pos-s,n.pos-s),l=e.node(0),u=o.cellsInRect(a).filter(f=>f!=n.pos-s);u.unshift(n.pos-s);const c=u.map(f=>{const p=r.nodeAt(f);if(!p)throw RangeError(`No cell with offset ${f} found`);const m=s+f+1;return new fy(l.resolve(m),l.resolve(m+p.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),o=e.resolve(n.map(this.$headCell.pos));if(yb(r)&&yb(o)&&wb(r,o)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?_i.rowSelection(r,o):s&&this.isColSelection()?_i.colSelection(r,o):new _i(r,o)}return Ie.between(r,o)}content(){const e=this.$anchorCell.node(-1),n=rn.get(e),r=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},a=[];for(let u=o.top;u<o.bottom;u++){const c=[];for(let f=u*n.width+o.left,p=o.left;p<o.right;p++,f++){const m=n.map[f];if(s[m])continue;s[m]=!0;const g=n.findCell(m);let b=e.nodeAt(m);if(!b)throw RangeError(`No cell with offset ${m} found`);const y=o.left-g.left,w=g.right-o.right;if(y>0||w>0){let x=b.attrs;if(y>0&&(x=la(x,0,y)),w>0&&(x=la(x,x.colspan-w,w)),g.left<o.left){if(b=b.type.createAndFill(x),!b)throw RangeError(`Could not create cell with attrs ${JSON.stringify(x)}`)}else b=b.type.create(x,b.content)}if(g.top<o.top||g.bottom>o.bottom){const x={...b.attrs,rowspan:Math.min(g.bottom,o.bottom)-Math.max(g.top,o.top)};g.top<o.top?b=b.type.createAndFill(x):b=b.type.create(x,b.content)}c.push(b)}a.push(e.child(u).copy(de.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:a;return new Ee(de.from(l),1,1)}replace(e,n=Ee.empty){const r=e.steps.length,o=this.ranges;for(let a=0;a<o.length;a++){const{$from:l,$to:u}=o[a],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(u.pos),a?Ee.empty:n)}const s=ze.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,n){this.replace(e,new Ee(de.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=rn.get(n),o=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let a=0;a<s.length;a++)e(n.nodeAt(s[a]),o+s[a])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),o=rn.get(r),s=e.start(-1),a=o.findCell(e.pos-s),l=o.findCell(n.pos-s),u=e.node(0);return a.top<=l.top?(a.top>0&&(e=u.resolve(s+o.map[a.left])),l.bottom<o.height&&(n=u.resolve(s+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(n=u.resolve(s+o.map[l.left])),a.bottom<o.height&&(e=u.resolve(s+o.map[o.width*(o.height-1)+a.right-1]))),new _i(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=rn.get(e),r=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-r),s=n.colCount(this.$headCell.pos-r);if(Math.min(o,s)>0)return!1;const a=o+this.$anchorCell.nodeAfter.attrs.colspan,l=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,l)==n.width}eq(e){return e instanceof _i&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),o=rn.get(r),s=e.start(-1),a=o.findCell(e.pos-s),l=o.findCell(n.pos-s),u=e.node(0);return a.left<=l.left?(a.left>0&&(e=u.resolve(s+o.map[a.top*o.width])),l.right<o.width&&(n=u.resolve(s+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(n=u.resolve(s+o.map[l.top*o.width])),a.right<o.width&&(e=u.resolve(s+o.map[o.width*(a.top+1)-1]))),new _i(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new _i(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new _i(e.resolve(n),e.resolve(r))}getBookmark(){return new XK(this.$anchorCell.pos,this.$headCell.pos)}};Ft.prototype.visible=!1,ze.jsonID("cell",Ft);var XK=class M_{constructor(e,n){this.anchor=e,this.head=n}map(e){return new M_(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&wb(n,r)?new Ft(n,r):ze.near(r,1)}};function YK(t){if(!(t.selection instanceof Ft))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(Wt.node(r,r+n.nodeSize,{class:"selectedCell"}))}),mt.create(t.doc,e)}function JK({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,o=t.depth;for(;o>=0&&!(t.after(o+1)<t.end(o));o--,n++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return n==r&&/row|table/.test(t.node(o).type.spec.tableRole)}function ZK({$from:t,$to:e}){let n,r;for(let o=t.depth;o>0;o--){const s=t.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){n=s;break}}for(let o=e.depth;o>0;o--){const s=e.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return n!==r&&e.parentOffset===0}function QK(t,e,n){const r=(e||t).selection,o=(e||t).doc;let s,a;if(r instanceof Fe&&(a=r.node.type.spec.tableRole)){if(a=="cell"||a=="header_cell")s=Ft.create(o,r.from);else if(a=="row"){const l=o.resolve(r.from+1);s=Ft.rowSelection(l,l)}else if(!n){const l=rn.get(r.node),u=r.from+1,c=u+l.map[l.width*l.height-1];s=Ft.create(o,u+1,c)}}else r instanceof Ie&&JK(r)?s=Ie.create(o,r.from):r instanceof Ie&&ZK(r)&&(s=Ie.create(o,r.$from.start(),r.$from.end()));return s&&(e||(e=t.tr)).setSelection(s),e}var NK=new St("fix-tables");function _E(t,e,n,r){const o=t.childCount,s=e.childCount;e:for(let a=0,l=0;a<s;a++){const u=e.child(a);for(let c=l,f=Math.min(o,a+3);c<f;c++)if(t.child(c)==u){l=c+1,n+=u.nodeSize;continue e}r(u,n),l<o&&t.child(l).sameMarkup(u)?_E(t.child(l),u,n+1,r):u.nodesBetween(0,u.content.size,r,n+1),n+=u.nodeSize}}function TE(t,e){let n;const r=(o,s)=>{o.type.spec.tableRole=="table"&&(n=eG(t,o,s,n))};return e?e.doc!=t.doc&&_E(e.doc,t.doc,0,r):t.doc.descendants(r),n}function eG(t,e,n,r){const o=rn.get(e);if(!o.problems)return r;r||(r=t.tr);const s=[];for(let u=0;u<o.height;u++)s.push(0);for(let u=0;u<o.problems.length;u++){const c=o.problems[u];if(c.type=="collision"){const f=e.nodeAt(c.pos);if(!f)continue;const p=f.attrs;for(let m=0;m<p.rowspan;m++)s[c.row+m]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,la(p,p.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const f=e.nodeAt(c.pos);if(!f)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...f.attrs,rowspan:f.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const f=e.nodeAt(c.pos);if(!f)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...f.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const f=r.mapping.map(n);r.delete(f,f+e.nodeSize)}}let a,l;for(let u=0;u<s.length;u++)s[u]&&(a==null&&(a=u),l=u);for(let u=0,c=n+1;u<o.height;u++){const f=e.child(u),p=c+f.nodeSize,m=s[u];if(m>0){let g="cell";f.firstChild&&(g=f.firstChild.type.spec.tableRole);const b=[];for(let w=0;w<m;w++){const x=Fn(t.schema)[g].createAndFill();x&&b.push(x)}const y=(u==0||a==u-1)&&l==u?c+1:p-1;r.insert(r.mapping.map(y),b)}c=p}return r.setMeta(NK,{fixTables:!0})}function Fo(t){const e=t.selection,n=Rp(t),r=n.node(-1),o=n.start(-1),s=rn.get(r);return{...e instanceof Ft?s.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):s.findCell(n.pos-o),tableStart:o,map:s,table:r}}function AE(t,{map:e,tableStart:n,table:r},o){let s=o>0?-1:0;GK(e,r,o+s)&&(s=o==0||o==e.width?null:0);for(let a=0;a<e.height;a++){const l=a*e.width+o;if(o>0&&o<e.width&&e.map[l-1]==e.map[l]){const u=e.map[l],c=r.nodeAt(u);t.setNodeMarkup(t.mapping.map(n+u),null,kE(c.attrs,o-e.colCount(u))),a+=c.attrs.rowspan-1}else{const u=s==null?Fn(r.type.schema).cell:r.nodeAt(e.map[l+s]).type,c=e.positionAt(a,o,r);t.insert(t.mapping.map(n+c),u.createAndFill())}}return t}function tG(t,e){if(!uo(t))return!1;if(e){const n=Fo(t);e(AE(t.tr,n,n.left))}return!0}function nG(t,e){if(!uo(t))return!1;if(e){const n=Fo(t);e(AE(t.tr,n,n.right))}return!0}function rG(t,{map:e,table:n,tableStart:r},o){const s=t.mapping.maps.length;for(let a=0;a<e.height;){const l=a*e.width+o,u=e.map[l],c=n.nodeAt(u),f=c.attrs;if(o>0&&e.map[l-1]==u||o<e.width-1&&e.map[l+1]==u)t.setNodeMarkup(t.mapping.slice(s).map(r+u),null,la(f,o-e.colCount(u)));else{const p=t.mapping.slice(s).map(r+u);t.delete(p,p+c.nodeSize)}a+=f.rowspan}}function oG(t,e){if(!uo(t))return!1;if(e){const n=Fo(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let o=n.right-1;rG(r,n,o),o!=n.left;o--){const s=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!s)throw RangeError("No table found");n.table=s,n.map=rn.get(s)}e(r)}return!0}function iG(t,e,n){var r;const o=Fn(e.type.schema).header_cell;for(let s=0;s<t.width;s++)if(((r=e.nodeAt(t.map[s+n*t.width]))==null?void 0:r.type)!=o)return!1;return!0}function OE(t,{map:e,tableStart:n,table:r},o){var s;let a=n;for(let c=0;c<o;c++)a+=r.child(c).nodeSize;const l=[];let u=o>0?-1:0;iG(e,r,o+u)&&(u=o==0||o==e.height?null:0);for(let c=0,f=e.width*o;c<e.width;c++,f++)if(o>0&&o<e.height&&e.map[f]==e.map[f-e.width]){const p=e.map[f],m=r.nodeAt(p).attrs;t.setNodeMarkup(n+p,null,{...m,rowspan:m.rowspan+1}),c+=m.colspan-1}else{const p=u==null?Fn(r.type.schema).cell:(s=r.nodeAt(e.map[f+u*e.width]))==null?void 0:s.type,m=p==null?void 0:p.createAndFill();m&&l.push(m)}return t.insert(a,Fn(r.type.schema).row.create(null,l)),t}function sG(t,e){if(!uo(t))return!1;if(e){const n=Fo(t);e(OE(t.tr,n,n.top))}return!0}function aG(t,e){if(!uo(t))return!1;if(e){const n=Fo(t);e(OE(t.tr,n,n.bottom))}return!0}function lG(t,{map:e,table:n,tableStart:r},o){let s=0;for(let c=0;c<o;c++)s+=n.child(c).nodeSize;const a=s+n.child(o).nodeSize,l=t.mapping.maps.length;t.delete(s+r,a+r);const u=new Set;for(let c=0,f=o*e.width;c<e.width;c++,f++){const p=e.map[f];if(!u.has(p)){if(u.add(p),o>0&&p==e.map[f-e.width]){const m=n.nodeAt(p).attrs;t.setNodeMarkup(t.mapping.slice(l).map(p+r),null,{...m,rowspan:m.rowspan-1}),c+=m.colspan-1}else if(o<e.height&&p==e.map[f+e.width]){const m=n.nodeAt(p),g=m.attrs,b=m.type.create({...g,rowspan:m.attrs.rowspan-1},m.content),y=e.positionAt(o+1,c,n);t.insert(t.mapping.slice(l).map(r+y),b),c+=g.colspan-1}}}}function uG(t,e){if(!uo(t))return!1;if(e){const n=Fo(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let o=n.bottom-1;lG(r,n,o),o!=n.top;o--){const s=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!s)throw RangeError("No table found");n.table=s,n.map=rn.get(n.table)}e(r)}return!0}function ME(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function cG({width:t,height:e,map:n},r){let o=r.top*t+r.left,s=o,a=(r.bottom-1)*t+r.left,l=o+(r.right-r.left-1);for(let u=r.top;u<r.bottom;u++){if(r.left>0&&n[s]==n[s-1]||r.right<t&&n[l]==n[l+1])return!0;s+=t,l+=t}for(let u=r.left;u<r.right;u++){if(r.top>0&&n[o]==n[o-t]||r.bottom<e&&n[a]==n[a+t])return!0;o++,a++}return!1}function BE(t,e){const n=t.selection;if(!(n instanceof Ft)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Fo(t),{map:o}=r;if(cG(o,r))return!1;if(e){const s=t.tr,a={};let l=de.empty,u,c;for(let f=r.top;f<r.bottom;f++)for(let p=r.left;p<r.right;p++){const m=o.map[f*o.width+p],g=r.table.nodeAt(m);if(!(a[m]||!g))if(a[m]=!0,u==null)u=m,c=g;else{ME(g)||(l=l.append(g.content));const b=s.mapping.map(m+r.tableStart);s.delete(b,b+g.nodeSize)}}if(u==null||c==null)return!0;if(s.setNodeMarkup(u+r.tableStart,null,{...kE(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size){const f=u+1+c.content.size,p=ME(c)?u+1:f;s.replaceWith(p+r.tableStart,f+r.tableStart,l)}s.setSelection(new Ft(s.doc.resolve(u+r.tableStart))),e(s)}return!0}function IE(t,e){const n=Fn(t.schema);return dG(({node:r})=>n[r.type.spec.tableRole])(t,e)}function dG(t){return(e,n)=>{var r;const o=e.selection;let s,a;if(o instanceof Ft){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;s=o.$anchorCell.nodeAfter,a=o.$anchorCell.pos}else{if(s=jK(o.$from),!s)return!1;a=(r=Sl(o.$from))==null?void 0:r.pos}if(s==null||a==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(n){let l=s.attrs;const u=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const f=Fo(e),p=e.tr;for(let g=0;g<f.right-f.left;g++)u.push(c?{...l,colwidth:c&&c[g]?[c[g]]:null}:l);let m;for(let g=f.top;g<f.bottom;g++){let b=f.map.positionAt(g,f.left,f.table);g==f.top&&(b+=s.nodeSize);for(let y=f.left,w=0;y<f.right;y++,w++)y==f.left&&g==f.top||p.insert(m=p.mapping.map(b+f.tableStart,1),t({node:s,row:g,col:y}).createAndFill(u[w]))}p.setNodeMarkup(a,t({node:s,row:f.top,col:f.left}),u[0]),o instanceof Ft&&p.setSelection(new Ft(p.doc.resolve(o.$anchorCell.pos),m?p.doc.resolve(m):void 0)),n(p)}return!0}}function fG(t,e){return function(n,r){if(!uo(n))return!1;const o=Rp(n);if(o.nodeAfter.attrs[t]===e)return!1;if(r){const s=n.tr;n.selection instanceof Ft?n.selection.forEachCell((a,l)=>{a.attrs[t]!==e&&s.setNodeMarkup(l,null,{...a.attrs,[t]:e})}):s.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[t]:e}),r(s)}return!0}}function pG(t){return function(e,n){if(!uo(e))return!1;if(n){const r=Fn(e.schema),o=Fo(e),s=e.tr,a=o.map.cellsInRect(t=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:t=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=a.map(u=>o.table.nodeAt(u));for(let u=0;u<a.length;u++)l[u].type==r.header_cell&&s.setNodeMarkup(o.tableStart+a[u],r.cell,l[u].attrs);if(s.steps.length==0)for(let u=0;u<a.length;u++)s.setNodeMarkup(o.tableStart+a[u],r.header_cell,l[u].attrs);n(s)}return!0}}function RE(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let o=0;o<r.length;o++){const s=e.table.nodeAt(r[o]);if(s&&s.type!==n.header_cell)return!1}return!0}function dc(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?pG(t):function(n,r){if(!uo(n))return!1;if(r){const o=Fn(n.schema),s=Fo(n),a=n.tr,l=RE("row",s,o),u=RE("column",s,o),f=(t==="column"?l:t==="row"?u:!1)?1:0,p=t=="column"?{left:0,top:f,right:1,bottom:s.map.height}:t=="row"?{left:f,top:0,right:s.map.width,bottom:1}:s,m=t=="column"?u?o.cell:o.header_cell:t=="row"?l?o.cell:o.header_cell:o.cell;s.map.cellsInRect(p).forEach(g=>{const b=g+s.tableStart,y=a.doc.nodeAt(b);y&&a.setNodeMarkup(b,m,y.attrs)}),r(a)}return!0}}dc("row",{useDeprecatedLogic:!0}),dc("column",{useDeprecatedLogic:!0});var hG=dc("cell",{useDeprecatedLogic:!0});function mG(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,o=t.before();r>=0;r--){const s=t.node(-1).child(r),a=s.lastChild;if(a)return o-1-a.nodeSize;o-=s.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),o=t.after();r<n.childCount;r++){const s=n.child(r);if(s.childCount)return o+1;o+=s.nodeSize}}return null}function LE(t){return function(e,n){if(!uo(e))return!1;const r=mG(Rp(e),t);if(r==null)return!1;if(n){const o=e.doc.resolve(r);n(e.tr.setSelection(Ie.between(o,KK(o))).scrollIntoView())}return!0}}function gG(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Lp(t,e){const n=t.selection;if(!(n instanceof Ft))return!1;if(e){const r=t.tr,o=Fn(t.schema).cell.createAndFill().content;n.forEachCell((s,a)=>{s.content.eq(o)||r.replace(r.mapping.map(a+1),r.mapping.map(a+s.nodeSize-1),new Ee(o,0,0))}),r.docChanged&&e(r)}return!0}function bG(t){if(!t.size)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const o=e.child(0),s=o.type.spec.tableRole,a=o.type.schema,l=[];if(s=="row")for(let u=0;u<e.childCount;u++){let c=e.child(u).content;const f=u?0:Math.max(0,n-1),p=u<e.childCount-1?0:Math.max(0,r-1);(f||p)&&(c=xb(Fn(a).row,new Ee(c,f,p)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(n||r?xb(Fn(a).row,new Ee(e,n,r)).content:e);else return null;return vG(a,l)}function vG(t,e){const n=[];for(let o=0;o<e.length;o++){const s=e[o];for(let a=s.childCount-1;a>=0;a--){const{rowspan:l,colspan:u}=s.child(a).attrs;for(let c=o;c<o+l;c++)n[c]=(n[c]||0)+u}}let r=0;for(let o=0;o<n.length;o++)r=Math.max(r,n[o]);for(let o=0;o<n.length;o++)if(o>=e.length&&e.push(de.empty),n[o]<r){const s=Fn(t).cell.createAndFill(),a=[];for(let l=n[o];l<r;l++)a.push(s);e[o]=e[o].append(de.from(a))}return{height:e.length,width:r,rows:e}}function xb(t,e){const n=t.createAndFill();return new um(n).replace(0,n.content.size,e).doc}function yG({width:t,height:e,rows:n},r,o){if(t!=r){const s=[],a=[];for(let l=0;l<n.length;l++){const u=n[l],c=[];for(let f=s[l]||0,p=0;f<r;p++){let m=u.child(p%u.childCount);f+m.attrs.colspan>r&&(m=m.type.createChecked(la(m.attrs,m.attrs.colspan,f+m.attrs.colspan-r),m.content)),c.push(m),f+=m.attrs.colspan;for(let g=1;g<m.attrs.rowspan;g++)s[l+g]=(s[l+g]||0)+m.attrs.colspan}a.push(de.from(c))}n=a,t=r}if(e!=o){const s=[];for(let a=0,l=0;a<o;a++,l++){const u=[],c=n[l%e];for(let f=0;f<c.childCount;f++){let p=c.child(f);a+p.attrs.rowspan>o&&(p=p.type.create({...p.attrs,rowspan:Math.max(1,o-p.attrs.rowspan)},p.content)),u.push(p)}s.push(de.from(u))}n=s,e=o}return{width:t,height:e,rows:n}}function wG(t,e,n,r,o,s,a){const l=t.doc.type.schema,u=Fn(l);let c,f;if(o>e.width)for(let p=0,m=0;p<e.height;p++){const g=n.child(p);m+=g.nodeSize;const b=[];let y;g.lastChild==null||g.lastChild.type==u.cell?y=c||(c=u.cell.createAndFill()):y=f||(f=u.header_cell.createAndFill());for(let w=e.width;w<o;w++)b.push(y);t.insert(t.mapping.slice(a).map(m-1+r),b)}if(s>e.height){const p=[];for(let b=0,y=(e.height-1)*e.width;b<Math.max(e.width,o);b++){const w=b>=e.width?!1:n.nodeAt(e.map[y+b]).type==u.header_cell;p.push(w?f||(f=u.header_cell.createAndFill()):c||(c=u.cell.createAndFill()))}const m=u.row.create(null,de.from(p)),g=[];for(let b=e.height;b<s;b++)g.push(m);t.insert(t.mapping.slice(a).map(r+n.nodeSize-2),g)}return!!(c||f)}function PE(t,e,n,r,o,s,a,l){if(a==0||a==e.height)return!1;let u=!1;for(let c=o;c<s;c++){const f=a*e.width+c,p=e.map[f];if(e.map[f-e.width]==p){u=!0;const m=n.nodeAt(p),{top:g,left:b}=e.findCell(p);t.setNodeMarkup(t.mapping.slice(l).map(p+r),null,{...m.attrs,rowspan:a-g}),t.insert(t.mapping.slice(l).map(e.positionAt(a,b,n)),m.type.createAndFill({...m.attrs,rowspan:g+m.attrs.rowspan-a})),c+=m.attrs.colspan-1}}return u}function DE(t,e,n,r,o,s,a,l){if(a==0||a==e.width)return!1;let u=!1;for(let c=o;c<s;c++){const f=c*e.width+a,p=e.map[f];if(e.map[f-1]==p){u=!0;const m=n.nodeAt(p),g=e.colCount(p),b=t.mapping.slice(l).map(p+r);t.setNodeMarkup(b,null,la(m.attrs,a-g,m.attrs.colspan-(a-g))),t.insert(b+m.nodeSize,m.type.createAndFill(la(m.attrs,0,a-g))),c+=m.attrs.rowspan-1}}return u}function VE(t,e,n,r,o){let s=n?t.doc.nodeAt(n-1):t.doc;if(!s)throw new Error("No table found");let a=rn.get(s);const{top:l,left:u}=r,c=u+o.width,f=l+o.height,p=t.tr;let m=0;function g(){if(s=n?p.doc.nodeAt(n-1):p.doc,!s)throw new Error("No table found");a=rn.get(s),m=p.mapping.maps.length}wG(p,a,s,n,c,f,m)&&g(),PE(p,a,s,n,u,c,l,m)&&g(),PE(p,a,s,n,u,c,f,m)&&g(),DE(p,a,s,n,l,f,u,m)&&g(),DE(p,a,s,n,l,f,c,m)&&g();for(let b=l;b<f;b++){const y=a.positionAt(b,u,s),w=a.positionAt(b,c,s);p.replace(p.mapping.slice(m).map(y+n),p.mapping.slice(m).map(w+n),new Ee(o.rows[b-l],0,0))}g(),p.setSelection(new Ft(p.doc.resolve(n+a.positionAt(l,u,s)),p.doc.resolve(n+a.positionAt(f-1,c-1,s)))),e(p)}var xG=zm({ArrowLeft:Dp("horiz",-1),ArrowRight:Dp("horiz",1),ArrowUp:Dp("vert",-1),ArrowDown:Dp("vert",1),"Shift-ArrowLeft":Vp("horiz",-1),"Shift-ArrowRight":Vp("horiz",1),"Shift-ArrowUp":Vp("vert",-1),"Shift-ArrowDown":Vp("vert",1),Backspace:Lp,"Mod-Backspace":Lp,Delete:Lp,"Mod-Delete":Lp});function Pp(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Dp(t,e){return(n,r,o)=>{if(!o)return!1;const s=n.selection;if(s instanceof Ft)return Pp(n,r,ze.near(s.$headCell,e));if(t!="horiz"&&!s.empty)return!1;const a=FE(o,t,e);if(a==null)return!1;if(t=="horiz")return Pp(n,r,ze.near(n.doc.resolve(s.head+e),e));{const l=n.doc.resolve(a),u=SE(l,t,e);let c;return u?c=ze.near(u,1):e<0?c=ze.near(n.doc.resolve(l.before(-1)),-1):c=ze.near(n.doc.resolve(l.after(-1)),1),Pp(n,r,c)}}}function Vp(t,e){return(n,r,o)=>{if(!o)return!1;const s=n.selection;let a;if(s instanceof Ft)a=s;else{const u=FE(o,t,e);if(u==null)return!1;a=new Ft(n.doc.resolve(u))}const l=SE(a.$headCell,t,e);return l?Pp(n,r,new Ft(a.$anchorCell,l)):!1}}function CG(t,e){const n=t.state.doc,r=Sl(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new Ft(r))),!0):!1}function EG(t,e,n){if(!uo(t.state))return!1;let r=bG(n);const o=t.state.selection;if(o instanceof Ft){r||(r={width:1,height:1,rows:[de.from(xb(Fn(t.state.schema).cell,n))]});const s=o.$anchorCell.node(-1),a=o.$anchorCell.start(-1),l=rn.get(s).rectBetween(o.$anchorCell.pos-a,o.$headCell.pos-a);return r=yG(r,l.right-l.left,l.bottom-l.top),VE(t.state,t.dispatch,a,l,r),!0}else if(r){const s=Rp(t.state),a=s.start(-1);return VE(t.state,t.dispatch,a,rn.get(s.node(-1)).findCell(s.pos-a),r),!0}else return!1}function SG(t,e){var n;if(e.ctrlKey||e.metaKey)return;const r=$E(t,e.target);let o;if(e.shiftKey&&t.state.selection instanceof Ft)s(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=Sl(t.state.selection.$anchor))!=null&&((n=Cb(t,e))==null?void 0:n.pos)!=o.pos)s(o,e),e.preventDefault();else if(!r)return;function s(u,c){let f=Cb(t,c);const p=fs.getState(t.state)==null;if(!f||!wb(u,f))if(p)f=u;else return;const m=new Ft(u,f);if(p||!t.state.selection.eq(m)){const g=t.state.tr.setSelection(m);p&&g.setMeta(fs,u.pos),t.dispatch(g)}}function a(){t.root.removeEventListener("mouseup",a),t.root.removeEventListener("dragstart",a),t.root.removeEventListener("mousemove",l),fs.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(fs,-1))}function l(u){const c=u,f=fs.getState(t.state);let p;if(f!=null)p=t.state.doc.resolve(f);else if($E(t,c.target)!=r&&(p=Cb(t,e),!p))return a();p&&s(p,c)}t.root.addEventListener("mouseup",a),t.root.addEventListener("dragstart",a),t.root.addEventListener("mousemove",l)}function FE(t,e,n){if(!(t.state.selection instanceof Ie))return null;const{$head:r}=t.state.selection;for(let o=r.depth-1;o>=0;o--){const s=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const l=r.before(o),u=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(u)?l:null}}return null}function $E(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Cb(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?Sl(t.state.doc.resolve(n.pos)):null}var kG=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Eb(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Eb(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Eb(t,e,n,r,o,s){var a;let l=0,u=!0,c=e.firstChild;const f=t.firstChild;if(f){for(let p=0,m=0;p<f.childCount;p++){const{colspan:g,colwidth:b}=f.child(p).attrs;for(let y=0;y<g;y++,m++){const w=o==m?s:b&&b[y],x=w?w+"px":"";if(l+=w||r,w||(u=!1),c)c.style.width!=x&&(c.style.width=x),c=c.nextSibling;else{const S=document.createElement("col");S.style.width=x,e.appendChild(S)}}}for(;c;){const p=c.nextSibling;(a=c.parentNode)==null||a.removeChild(c),c=p}u?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}var yr=new St("tableColumnResizing");function _G({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=kG,lastColumnResizable:o=!0}={}){const s=new tt({key:yr,state:{init(a,l){var u,c;const f=(c=(u=s.spec)==null?void 0:u.props)==null?void 0:c.nodeViews,p=Fn(l.schema).table.name;return r&&f&&(f[p]=(m,g)=>new r(m,n,g)),new TG(-1,!1)},apply(a,l){return l.apply(a)}},props:{attributes:a=>{const l=yr.getState(a);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(a,l)=>{AG(a,l,t,o)},mouseleave:a=>{OG(a)},mousedown:(a,l)=>{MG(a,l,e,n)}},decorations:a=>{const l=yr.getState(a);if(l&&l.activeHandle>-1)return PG(a,l.activeHandle)},nodeViews:{}}});return s}var TG=class Gh{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(yr);if(r&&r.setHandle!=null)return new Gh(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Gh(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let o=e.mapping.map(n.activeHandle,-1);return yb(e.doc.resolve(o))||(o=-1),new Gh(o,n.dragging)}return n}};function AG(t,e,n,r){if(!t.editable)return;const o=yr.getState(t.state);if(o&&!o.dragging){const s=IG(e.target);let a=-1;if(s){const{left:l,right:u}=s.getBoundingClientRect();e.clientX-l<=n?a=zE(t,e,"left",n):u-e.clientX<=n&&(a=zE(t,e,"right",n))}if(a!=o.activeHandle){if(!r&&a!==-1){const l=t.state.doc.resolve(a),u=l.node(-1),c=rn.get(u),f=l.start(-1);if(c.colCount(l.pos-f)+l.nodeAfter.attrs.colspan-1==c.width-1)return}UE(t,a)}}}function OG(t){if(!t.editable)return;const e=yr.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&UE(t,-1)}function MG(t,e,n,r){var o;if(!t.editable)return!1;const s=(o=t.dom.ownerDocument.defaultView)!=null?o:window,a=yr.getState(t.state);if(!a||a.activeHandle==-1||a.dragging)return!1;const l=t.state.doc.nodeAt(a.activeHandle),u=BG(t,a.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(yr,{setDragging:{startX:e.clientX,startWidth:u}}));function c(p){s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",f);const m=yr.getState(t.state);m!=null&&m.dragging&&(RG(t,m.activeHandle,HE(m.dragging,p,n)),t.dispatch(t.state.tr.setMeta(yr,{setDragging:null})))}function f(p){if(!p.which)return c(p);const m=yr.getState(t.state);if(m&&m.dragging){const g=HE(m.dragging,p,n);WE(t,m.activeHandle,g,r)}}return WE(t,a.activeHandle,u,r),s.addEventListener("mouseup",c),s.addEventListener("mousemove",f),e.preventDefault(),!0}function BG(t,e,{colspan:n,colwidth:r}){const o=r&&r[r.length-1];if(o)return o;const s=t.domAtPos(e);let l=s.node.childNodes[s.offset].offsetWidth,u=n;if(r)for(let c=0;c<n;c++)r[c]&&(l-=r[c],u--);return l/u}function IG(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function zE(t,e,n,r){const o=n=="right"?-r:r,s=t.posAtCoords({left:e.clientX+o,top:e.clientY});if(!s)return-1;const{pos:a}=s,l=Sl(t.state.doc.resolve(a));if(!l)return-1;if(n=="right")return l.pos;const u=rn.get(l.node(-1)),c=l.start(-1),f=u.map.indexOf(l.pos-c);return f%u.width==0?-1:c+u.map[f-1]}function HE(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function UE(t,e){t.dispatch(t.state.tr.setMeta(yr,{setHandle:e}))}function RG(t,e,n){const r=t.state.doc.resolve(e),o=r.node(-1),s=rn.get(o),a=r.start(-1),l=s.colCount(r.pos-a)+r.nodeAfter.attrs.colspan-1,u=t.state.tr;for(let c=0;c<s.height;c++){const f=c*s.width+l;if(c&&s.map[f]==s.map[f-s.width])continue;const p=s.map[f],m=o.nodeAt(p).attrs,g=m.colspan==1?0:l-s.colCount(p);if(m.colwidth&&m.colwidth[g]==n)continue;const b=m.colwidth?m.colwidth.slice():LG(m.colspan);b[g]=n,u.setNodeMarkup(a+p,null,{...m,colwidth:b})}u.docChanged&&t.dispatch(u)}function WE(t,e,n,r){const o=t.state.doc.resolve(e),s=o.node(-1),a=o.start(-1),l=rn.get(s).colCount(o.pos-a)+o.nodeAfter.attrs.colspan-1;let u=t.domAtPos(o.start(-1)).node;for(;u&&u.nodeName!="TABLE";)u=u.parentNode;u&&Eb(s,u.firstChild,u,r,l,n)}function LG(t){return Array(t).fill(0)}function PG(t,e){var n;const r=[],o=t.doc.resolve(e),s=o.node(-1);if(!s)return mt.empty;const a=rn.get(s),l=o.start(-1),u=a.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1;for(let c=0;c<a.height;c++){const f=u+c*a.width;if((u==a.width-1||a.map[f]!=a.map[f+1])&&(c==0||a.map[f]!=a.map[f-a.width])){const p=a.map[f],m=l+p+s.nodeAt(p).nodeSize-1,g=document.createElement("div");g.className="column-resize-handle",(n=yr.getState(t))!=null&&n.dragging&&r.push(Wt.node(l+p,l+p+s.nodeAt(p).nodeSize,{class:"column-resize-dragging"})),r.push(Wt.widget(m,g))}}return mt.create(t.doc,r)}function DG({allowTableNodeSelection:t=!1}={}){return new tt({key:fs,state:{init(){return null},apply(e,n){const r=e.getMeta(fs);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:o,pos:s}=e.mapping.mapResult(n);return o?null:s}},props:{decorations:YK,handleDOMEvents:{mousedown:SG},createSelectionBetween(e){return fs.getState(e.state)!=null?e.state.selection:null},handleTripleClick:CG,handleKeyDown:xG,handlePaste:EG},appendTransaction(e,n,r){return QK(r,TE(r,n),t)}})}const VG=(t,e,n)=>{if(!t.doc)return t;const r=t.doc.nodeAt(e);if(!r||n===r.attrs.backgroundColor)return t;const o={...r.attrs,backgroundColor:n};return t.setNodeMarkup(e,r.type,o,r.marks)},FG=(t,e,n)=>{const{doc:r,selection:o}=t;return!r||!o||!(o instanceof Ft)||o.forEachCell((s,a)=>{t=VG(t,a,n)}),t},jE=(t,e)=>({tr:n,state:r,dispatch:o})=>{const{selection:s}=r;return n=n.setSelection(s),n=FG(n,e,t),n.docChanged?(o==null||o(n),!0):!1},$G=Ne.create({name:"tableCellBackground",addOptions(){return{types:["tableCell"],HTMLAttributes:{}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{parseHTML:t=>t.style.backgroundColor||"",renderHTML:t=>!t.backgroundColor||t.backgroundColor===""?{}:{style:`background-color: ${t.backgroundColor}`}}}}]},addCommands(){return{setTableCellBackground:t=>jE(t,this.options),unsetTableCellBackground:()=>jE("",this.options)}}}),zG=Bt.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",bt(this.options.HTMLAttributes,t),0]}}),HG=Bt.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",bt(this.options.HTMLAttributes,t),0]}}),UG=Bt.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",bt(this.options.HTMLAttributes,t),0]}});function Sb(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function qE(t,e,n,r,o,s){var a;let l=0,u=!0,c=e.firstChild;const f=t.firstChild;if(f!==null)for(let p=0,m=0;p<f.childCount;p+=1){const{colspan:g,colwidth:b}=f.child(p).attrs;for(let y=0;y<g;y+=1,m+=1){const w=o===m?s:b&&b[y],x=w?`${w}px`:"";if(l+=w||r,w||(u=!1),c){if(c.style.width!==x){const[S,C]=Sb(r,w);c.style.setProperty(S,C)}c=c.nextSibling}else{const S=document.createElement("col"),[C,E]=Sb(r,w);S.style.setProperty(C,E),e.appendChild(S)}}}for(;c;){const p=c.nextSibling;(a=c.parentNode)===null||a===void 0||a.removeChild(c),c=p}u?(n.style.width=`${l}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${l}px`)}class WG{constructor(e,n){this.node=e,this.cellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),qE(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,qE(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function jG(t,e,n,r){let o=0,s=!0;const a=[],l=t.firstChild;if(!l)return{};for(let p=0,m=0;p<l.childCount;p+=1){const{colspan:g,colwidth:b}=l.child(p).attrs;for(let y=0;y<g;y+=1,m+=1){const w=n===m?r:b&&b[y];o+=w||e,w||(s=!1);const[x,S]=Sb(e,w);a.push(["col",{style:`${x}: ${S}`}])}}const u=s?`${o}px`:"",c=s?"":`${o}px`;return{colgroup:["colgroup",{},...a],tableWidth:u,tableMinWidth:c}}function KE(t,e){return t.createAndFill()}function qG(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function KG(t,e,n,r,o){const s=qG(t),a=[],l=[];for(let c=0;c<n;c+=1){const f=KE(s.cell);if(f&&l.push(f),r){const p=KE(s.header_cell);p&&a.push(p)}}const u=[];for(let c=0;c<e;c+=1)u.push(s.row.createChecked(null,r&&c===0?a:l));return s.table.createChecked(null,u)}function GG(t){return t instanceof Ft}const Fp=({editor:t})=>{const{selection:e}=t.state;if(!GG(e))return!1;let n=0;const r=lw(e.ranges[0].$from,s=>s.type.name==="table");return r==null||r.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},XG=Bt.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:WG,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:o}=jG(t,this.options.cellMinWidth);return["table",bt(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${o}`}),n,["tbody",0]]},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:s})=>{const a=KG(s.schema,t,e,n);if(o){const l=r.selection.from+1;r.replaceSelectionWith(a).scrollIntoView().setSelection(Ie.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>tG(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>nG(t,e),deleteColumn:()=>({state:t,dispatch:e})=>oG(t,e),addRowBefore:()=>({state:t,dispatch:e})=>sG(t,e),addRowAfter:()=>({state:t,dispatch:e})=>aG(t,e),deleteRow:()=>({state:t,dispatch:e})=>uG(t,e),deleteTable:()=>({state:t,dispatch:e})=>gG(t,e),mergeCells:()=>({state:t,dispatch:e})=>BE(t,e),splitCell:()=>({state:t,dispatch:e})=>IE(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>dc("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>dc("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>hG(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>BE(t,e)?!0:IE(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>fG(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>LE(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>LE(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&TE(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=Ft.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Fp,"Mod-Backspace":Fp,Delete:Fp,"Mod-Delete":Fp}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[_G({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],DG({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:ct(Re(t,"tableRole",e))}}}),YG=["disabled"],JG={"content-class":"table-grid-size-editor","content-style":"padding:0"},ZG={class:"flex flex-col flex-wrap gap-1 justify-between"},QG=["onMouseover","onMousedown"],NG={class:"text-center text-sm text-zinc-600 mt-2"},eX=i.defineComponent({__name:"CreateTablePopover",props:{disabled:{type:Boolean,default:!1}},emits:["create-table"],setup(t,{emit:e}){const n=e,r=i.ref(!1),o=i.ref(!0),s=i.reactive({rows:df()?Id:Bd,cols:df()?Id:Bd}),a=i.reactive({rows:Rd,cols:Rd});function l(f,p){f===s.rows&&(s.rows=Math.min(f+1,Id)),p===s.cols&&(s.cols=Math.min(p+1,Id)),a.rows=f,a.cols=p}function u(f,p){n("create-table",{rows:f,cols:p,withHeaderRow:i.unref(o)}),c()}function c(){r.value=!1,o.value=!1,s.rows=Bd,s.cols=Bd,a.rows=Rd,a.cols=Rd}return(f,p)=>(i.openBlock(),i.createBlock(i.unref(ul),null,{default:i.withCtx(()=>[i.createVNode(i.unref(fl),{"as-child":""},{default:i.withCtx(()=>[i.createElementVNode("button",{disabled:t.disabled,class:"m-0 p-0"},[i.renderSlot(f.$slots,"trigger")],8,YG)]),_:3}),i.createVNode(i.unref(cl),{class:"w-full",align:"start",side:"bottom"},{default:i.withCtx(()=>[i.createElementVNode("div",JG,[i.createElementVNode("div",ZG,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(s.rows,m=>(i.openBlock(),i.createElementBlock("div",{key:"r"+m,class:"flex gap-1"},[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(s.cols,g=>(i.openBlock(),i.createElementBlock("div",{key:"c"+g,class:i.normalizeClass([[g<=a.cols&&m<=a.rows&&"bg-ed-foreground border-ed-border","cursor-pointer"],"pa-1"]),onMouseover:b=>l(m,g),onMousedown:b=>u(m,g)},p[0]||(p[0]=[i.createElementVNode("div",{class:"w-4 h-4 p-1 border box-border"},null,-1)]),42,QG))),128))]))),128))]),i.createElementVNode("div",NG,i.toDisplayString(a.rows)+" x "+i.toDisplayString(a.cols),1)])]),_:1})]),_:3}))}}),tX={style:{display:"flex"}},nX=i.defineComponent({__name:"TableActionButton",props:{editor:{},icon:{default:void 0},tooltip:{default:void 0},disabled:{type:Boolean,default:!1},color:{default:void 0},action:{type:Function,default:void 0},isActive:{type:Function,default:void 0}},setup(t){const e=t;function n(r){e.editor.isActive("table")||e.editor.chain().focus().insertTable({...r,withHeaderRow:!1}).run()}return(r,o)=>(i.openBlock(),i.createBlock(eX,{disabled:r.editor.isActive("table"),onCreateTable:n},{trigger:i.withCtx(()=>[i.createElementVNode("div",tX,[i.createVNode(Ge,{icon:r.icon,tooltip:r.tooltip,disabled:r.disabled,color:r.color,action:r.action,"is-active":r.isActive},null,8,["icon","tooltip","disabled","color","action","is-active"])])]),_:1},8,["disabled"]))}}),kb=XG.extend({addStorage(){return{isTableMenuOpen:!1}},addCommands(){var t;return{...(t=this.parent)==null?void 0:t.call(this),toggleTableEditor:e=>({editor:n})=>n.storage.table?(n.storage.table.isTableEditorOpen=e,!0):!1}},addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),resizable:!0,lastColumnResizable:!0,allowTableNodeSelection:!1,button:({editor:e,t:n})=>({component:nX,componentProps:{icon:"Table",tooltip:n("editor.table.tooltip"),action:()=>{var o;const r=((o=e.storage.table)==null?void 0:o.isTableEditorOpen)??!1;e.commands.toggleTableEditor(!r)}}})}},addExtensions(){return[HG.configure(this.options.tableRow),zG.configure(this.options.tableHeader),UG.configure(this.options.tableCell),$G.configure(this.options.tableCellBackground)]}}),rX={class:"flex items-center gap-2 px-2"},oX=i.defineComponent({__name:"TextDropdown",props:{editor:{},disabled:{type:Boolean,default:!1},color:{default:void 0},maxHeight:{default:void 0},icon:{default:void 0},tooltip:{default:""}},setup(t){const e=t,{t:n}=At(),r=i.computed(()=>[{name:"paragraph",label:n("editor.paragraph.tooltip"),iconName:"Paragraph",isActive:()=>e.editor.isActive("paragraph")&&!e.editor.isActive("orderedList")&&!e.editor.isActive("bulletList")&&!e.editor.isActive("taskList"),action:()=>e.editor.chain().focus().clearNodes().run()},{name:"heading1",label:n("editor.heading.h1.tooltip"),isActive:()=>e.editor.isActive("heading",{level:1}),iconName:"Heading1",action:()=>e.editor.chain().focus().clearNodes().toggleHeading({level:1}).run()},{name:"heading2",label:n("editor.heading.h2.tooltip"),isActive:()=>e.editor.isActive("heading",{level:2}),iconName:"Heading2",action:()=>e.editor.chain().focus().clearNodes().toggleHeading({level:2}).run()},{name:"heading3",label:n("editor.heading.h3.tooltip"),isActive:()=>e.editor.isActive("heading",{level:3}),iconName:"Heading3",action:()=>e.editor.chain().focus().clearNodes().toggleHeading({level:3}).run()},{name:"bulletList",label:n("editor.bulletlist.tooltip"),isActive:()=>e.editor.isActive("bulletList"),iconName:"List",action:()=>e.editor.chain().focus().clearNodes().toggleBulletList().run()},{name:"numberedList",label:n("editor.orderedlist.tooltip"),isActive:()=>e.editor.isActive("orderedList"),iconName:"ListOrdered",action:()=>e.editor.chain().focus().clearNodes().toggleOrderedList().run()},{name:"taskList",label:n("editor.tasklist.tooltip"),isActive:()=>e.editor.isActive("taskList"),iconName:"ListTodo",action:()=>e.editor.chain().focus().clearNodes().toggleTaskList().run()},{name:"blockquote",label:n("editor.blockquote.tooltip"),isActive:()=>e.editor.isActive("blockquote"),iconName:"TextQuote",action:()=>e.editor.chain().focus().clearNodes().toggleBlockquote().run()},{name:"codeBlock",label:n("editor.codeblock.tooltip"),isActive:()=>e.editor.isActive("codeBlock"),iconName:"Code2",action:()=>e.editor.chain().focus().clearNodes().toggleCodeBlock().run()}]),o=i.computed(()=>r.value.filter(s=>s.isActive()).pop()??{label:n("editor.modify")});return(s,a)=>{var l;return i.openBlock(),i.createBlock(na,{title:(l=o.value)==null?void 0:l.label,"side-offset":5},{default:i.withCtx(()=>[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(r.value,(u,c)=>{var f;return i.openBlock(),i.createBlock(i.unref(yl),{key:c,class:"cursor-pointer",checked:((f=u.isActive)==null?void 0:f.call(u))||!1,onClick:u.action},{default:i.withCtx(()=>[i.createElementVNode("div",rX,[i.createVNode(i.unref(jt),{name:u.iconName,class:"h3 w-3"},null,8,["name"]),i.createElementVNode("span",null,i.toDisplayString(u.label),1)])]),_:2},1032,["checked","onClick"])}),128))]),_:1},8,["title"])}}}),iX=Ne.create({name:"text-bubble",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),toolbar:!1,button:()=>({component:oX,componentProps:{}})}}}),sX=[{label:"복합 표현 - 요일과 시간대",examples:["다음 월요일 저녁","이번 토요일 오전"],pattern:"(이번|다음)?\\s?(월|화|수|목|금|토|일)요일(\\s?(오전|오후|저녁|밤|새벽))?"},{label:"시각 표현",examples:["오전 10시","오후 3시 30분","정오","자정","새벽 2시"],pattern:"((오전|오후|새벽|밤|저녁)\\s?\\d{1,2}(시(\\s?\\d{1,2}분)?)?|정오|자정)"},{label:"시간 표현 - 이른/늦은",examples:["이른 아침","늦은 밤"],pattern:"(이른\\s아침|늦은\\s밤)"},{label:"연도+월",examples:["2019년 6월","2025년12월","2024년 01월"],pattern:"\\d{4}년\\s?\\d{1,2}월"},{label:"오늘/내일/어제",examples:["오늘","내일","모레","어제","그제","그끄제"],pattern:"(오늘|내일|모레|어제|그제|그끄제)"},{label:"상대적 주 단위",examples:["이번 주","다음 주","지난 주"],pattern:"(이번|다음|지난)\\s?주"},{label:"상대적 월 단위",examples:["이번 달","다음 달","지난 달"],pattern:"(이번|다음|지난)\\s?달"},{label:"상대적 연도",examples:["올해","내년","작년","재작년","내후년"],pattern:"(올해|내년|작년|재작년|내후년)"},{label:"복합 표현 - 날짜와 시간대",examples:["1월 1일 오전","12월25일 저녁","다음 주 금요일 오전"],pattern:"(내년|올해|작년)?\\s?\\d{1,2}\\s?월\\s?\\d{1,2}\\s?일(\\s?(오전|오후|저녁|밤|새벽))?"},{label:"정확한 날짜",examples:["1월1일","1월 1일","12월 25일","01월 01일"],pattern:"\\d{1,2}\\s?월\\s?\\d{1,2}\\s?일"},{label:"요일",examples:["월요일","화요일","이번 금요일","다음 화요일"],pattern:"(이번|다음)?\\s?(월|화|수|목|금|토|일)요일"},{label:"시간대",examples:["오전","오후","저녁","밤","새벽"],pattern:"(오전|오후|저녁|밤|새벽)"},{label:"짧은 시간 표현",examples:["방금","조금 전","금방","곧","잠시 후"],pattern:"(방금|조금\\s전|금방|곧|잠시\\s후)"},{label:"연도",examples:["2015년","2024년","1998년"],pattern:"\\d{4}년"}],aX=t=>{const e=[...t||[],...sX.map(n=>n.pattern)].join("|");return new RegExp(e,"gu")},lX=Ne.create({name:"time-highlighter",addOptions(){return{additionalTimeWords:[]}},addStorage(){return{cachedRegex:null,cachedAdditionalWords:null}},addProseMirrorPlugins(){return[new tt({props:{decorations:t=>{const e=[];return(this.storage.cachedAdditionalWords!==this.options.additionalTimeWords||!this.storage.cachedRegex)&&(this.storage.cachedAdditionalWords=this.options.additionalTimeWords,this.storage.cachedRegex=aX(this.options.additionalTimeWords)),t.doc.descendants((n,r)=>{if(!n.isText)return;let o;const s=this.storage.cachedRegex;for(;o=s.exec(n.text||"");){const a=r+o.index,l=a+o[0].length;e.push(Wt.inline(a,l,{class:"time-highlight"}))}}),mt.create(t.doc,e)}}})]}}),uX=Ne.create({name:"invalidCharFocus",addOptions(){return{invalidChars:["{","}"]}},addCommands(){return{focusInvalidChar:()=>({state:t,dispatch:e,view:n})=>{let r=null;if(t.doc.descendants((s,a)=>{if(!s.isText)return!0;const l=s.text??"";for(let u=0;u<l.length;u++)if(this.options.invalidChars.includes(l[u])){const c=a+u+1;(r==null||c<r)&&(r=c)}return!0}),r==null)return!1;const o=t.tr.setSelection(Ie.create(t.doc,r));return e&&e(o.scrollIntoView()),n&&n.focus(),!0}}}});function _b(t){const e=JSON.stringify(t),n=window.ReactNativeWebView;if(n){n.postMessage(e);return}console.warn("[clipboardBridge] no bridge found")}function cX(){return new Promise(t=>{const e=window.receiveDriverData;window.receiveDriverData=n=>{var o;e&&e(n);let r;try{r=typeof n=="string"?JSON.parse(n):n}catch{return}(r==null?void 0:r.type)==="CLIPBOARD_STATE"&&t(!!((o=r.data)!=null&&o.hasClipboard))},_b({type:"REQUEST_CLIPBOARD_STATE"})})}function dX(){return new Promise(t=>{const e=window.receiveDriverData;window.receiveDriverData=n=>{var o;e&&e(n);let r;try{r=typeof n=="string"?JSON.parse(n):n}catch{return}(r==null?void 0:r.type)==="PASTE_RESULT"&&t(((o=r.data)==null?void 0:o.text)??null)},_b({type:"PASTE"})})}function fX(t,e){_b({type:"COPY",data:{html:t,text:e}})}async function pX(t,e){try{const n=new ClipboardItem({"text/html":new Blob([t],{type:"text/html"}),"text/plain":new Blob([e],{type:"text/plain"})});await navigator.clipboard.write([n])}catch(n){console.error("navigator clipboard write failed:",n)}}async function hX(){try{if("read"in navigator.clipboard){const t=await navigator.clipboard.read();for(const e of t){if(e.types.includes("text/html"))return await(await e.getType("text/html")).text();if(e.types.includes("text/plain"))return await(await e.getType("text/plain")).text()}}}catch(t){console.warn("navigator clipboard read failed:",t)}}const mX=Ne.create({name:"clipboard",addCommands(){return{copyContent:()=>({editor:t,state:e})=>{const{from:n,to:r}=e.selection;return n===r?!1:((async()=>{try{const o=e.doc.slice(n,r),a=bo.fromSchema(t.schema).serializeFragment(o.content),l=document.createElement("div");l.appendChild(a);const u=l.innerHTML,c=e.doc.textBetween(n,r,`
279
279
  `);t.storage.deviceEnv.isMobile?fX(u,c):await pX(u,c)}catch(o){console.warn("[clipboard] copy failed",o)}})(),!0)},cutContent:()=>({editor:t})=>((async()=>{try{await t.commands.copyContent(),t.chain().focus().deleteSelection().run()}catch(e){console.warn("[clipboard] cut failed",e)}})(),!0),pasteContent:()=>({editor:t})=>((async()=>{try{t.chain().focus().run();const e=t.storage.deviceEnv.isMobile?await dX():await hX();if(!e)return;const n=new DataTransfer;n.setData("text/html",e),n.setData("text/plain",e);const r=new ClipboardEvent("paste",{bubbles:!0,cancelable:!0});Object.defineProperty(r,"clipboardData",{value:n}),t.view.dom.dispatchEvent(r)}catch(e){console.warn("Clipboard paste failed:",e)}})(),!0)}},onCreate(){const t=this.editor;t.hasClipboard=async()=>{try{return!!(t.storage.deviceEnv.isMobile?await cX():await navigator.clipboard.readText())}catch(e){return console.warn("[clipboard] check failed",e),!1}}}}),gX=Ne.create({name:"deviceEnv",addOptions(){return{initial:!1}},addStorage(){return{isMobile:this.options.initial}},addCommands(){return{setIsMobile:t=>({editor:e})=>{var n;return e.storage.deviceEnv.isMobile=t,(n=e.storage.spellchecker)==null||n.spellchecker.setIsMobile(t),!0}}}}),$p=i.defineComponent({__name:"TabsContent",props:{value:{},forceMount:{type:Boolean},asChild:{type:Boolean},as:{},class:{}},setup(t){const e=t,n=i.computed(()=>{const{class:r,...o}=e;return o});return(r,o)=>(i.openBlock(),i.createBlock(i.unref(rD),i.mergeProps({class:i.unref(Ae)("mt-2 ring-offset-ed-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ed-ring focus-visible:ring-offset-2",e.class)},n.value),{default:i.withCtx(()=>[i.renderSlot(r.$slots,"default")]),_:3},16,["class"]))}}),bX={class:"flex items-center w-full p-3 my-3 hover:bg-ed-accent border border-ed-border text-ed-muted-foreground cursor-pointer rounded-sm transition-all"},vX={key:0,class:"flex justify-center items-center gap-3 text-s"},yX={key:1,class:"flex justify-between items-center w-full"},wX={class:"flex justify-center items-center gap-3"},xX={class:"text-sm"},CX={class:"flex items-center gap-2"},EX=i.defineComponent({__name:"VideoUploader",props:{...zs},setup(t){const e=t,n=i.ref(""),r=i.ref(!1),o=i.ref(),{t:s}=At();function a(f){var y;r.value=!0;const p=f.target,m=Array.from((p==null?void 0:p.files)||[]),g=(y=e.editor.extensionManager.extensions.find(w=>w.name==="videoUpload"))==null?void 0:y.options;if(!e.editor||e.editor.isDestroyed||m.length===0||typeof(g==null?void 0:g.upload)!="function")return;const b=m[0];g.upload(b).then(w=>{e.editor.chain().setVideo({src:w}).deleteRange({from:e.getPos(),to:e.getPos()}).insertContentAt(e.getPos()+1,{type:"paragraph"}).focus().run(),r.value=!1})}function l(){e.editor.chain().setVideo({src:n.value,width:640}).deleteRange({from:e.getPos(),to:e.getPos()}).insertContentAt(e.getPos()+1,{type:"paragraph"}).focus().run()}function u(){e.deleteNode()}function c(){var f;(f=o.value)==null||f.click()}return(f,p)=>(i.openBlock(),i.createBlock(i.unref($s),{as:"div","data-drag-handle":""},{default:i.withCtx(()=>[i.createVNode(i.unref(ul),{"default-open":""},{default:i.withCtx(()=>[i.createVNode(i.unref(fl),{"as-child":""},{default:i.withCtx(()=>[i.createElementVNode("div",bX,[r.value?(i.openBlock(),i.createElementBlock("div",vX,[i.createVNode(i.unref(jt),{class:"animate-spin w-6 h-6",name:"LoaderCircle"}),i.createElementVNode("span",null,i.toDisplayString(i.unref(s)("editor.video.dialog.uploading"))+"...",1)])):(i.openBlock(),i.createElementBlock("div",yX,[i.createElementVNode("div",wX,[i.createVNode(i.unref(jt),{name:"Video",class:"w-6 h-6"}),i.createElementVNode("span",xX,i.toDisplayString(i.unref(s)("editor.video.dialog.title")),1)]),i.createVNode(i.unref(jt),{name:"Trash2",class:"hover:text-ed-foreground",onClick:i.withModifiers(u,["stop"])})]))])]),_:1}),i.createVNode(i.unref(cl),{"trap-focus":"",class:"w-full","on-open-auto-focus":m=>m.preventDefault()},{default:i.withCtx(()=>[i.createVNode(i.unref($g),{"default-value":"upload",class:"w-[300px] sm:w-[400px]","activation-mode":"manual"},{default:i.withCtx(()=>[i.createVNode(i.unref(zg),{class:"grid w-full grid-cols-2"},{default:i.withCtx(()=>[i.createVNode(i.unref(Fu),{value:"upload"},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(i.unref(s)("editor.video.dialog.tab.upload")),1)]),_:1}),i.createVNode(i.unref(Fu),{value:"link",disabled:r.value},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(i.unref(s)("editor.video.dialog.link")),1)]),_:1},8,["disabled"])]),_:1}),i.createVNode(i.unref($p),{value:"upload"},{default:i.withCtx(()=>[i.createVNode(i.unref(_n),{class:"w-full mt-1",size:"sm",disabled:r.value,onClick:c},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(i.unref(s)("editor.video.dialog.tab.upload")),1)]),_:1},8,["disabled"]),i.createElementVNode("input",{ref_key:"fileInput",ref:o,type:"file",accept:"video/*",hidden:"",onChange:a},null,544)]),_:1}),i.createVNode(i.unref($p),{value:"link"},{default:i.withCtx(()=>[i.createElementVNode("div",CX,[i.createVNode(i.unref(dl),{modelValue:n.value,"onUpdate:modelValue":p[0]||(p[0]=m=>n.value=m),type:"url",autofocus:"",required:"",placeholder:i.unref(s)("editor.video.dialog.placeholder")},null,8,["modelValue","placeholder"]),i.createVNode(i.unref(_n),{onClick:l},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(i.unref(s)("editor.video.dialog.button.apply")),1)]),_:1})])]),_:1})]),_:1})]),_:1},8,["on-open-auto-focus"])]),_:1})]),_:1}))}}),GE=Bt.create({name:"videoUpload",isolating:!0,defining:!0,group:"block",draggable:!0,selectable:!0,inline:!1,parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML(){return["div",{"data-type":this.name}]},addCommands(){return{setVideoUpload:()=>({commands:t})=>t.insertContent(`<div data-type="${this.name}"></div>`)}},addNodeView(){return Hs(EX)},addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),upload:()=>Promise.reject("link video not found"),button:({editor:e,t:n})=>{var r,o;return{component:Ge,componentProps:{action:()=>e.commands.setVideoUpload(),isActive:()=>e.isActive("video")||!1,disabled:!((o=(r=e.can()).setVideo)!=null&&o.call(r,{})),icon:"Video",tooltip:n("editor.video.tooltip")}}}}}});function SX(t){return t=t.replace("https://youtu.be/","https://www.youtube.com/watch?v=").replace("watch?v=","embed/"),t=t.replace("https://vimeo.com/","https://player.vimeo.com/video/"),/^https?:\/\/www.bilibili.com\/video\/.*/i.test(t)&&(t=t.replace(/\?.*$/i,"").replace("https://www.bilibili.com/video/","https://player.bilibili.com/player.html?bvid=")),t.includes("drive.google.com")&&(t=t.replace("/view","/preview")),t}function kX(t){return t?t.includes("youtube.com/embed")||t.includes("player.vimeo.com")||t.includes("player.bilibili.com")||t.includes("drive.google.com"):!1}const XE=Bt.create({name:"video",group:"block",atom:!0,draggable:!0,addOptions(){return{divider:!1,spacer:!1,allowFullscreen:!0,upload:void 0,width:Ld["size-medium"],controls:!0,autoplay:!1,HTMLAttributes:{class:"iframe-wrapper",style:"display: flex;justify-content: center;"}}},addAttributes(){return{src:{default:null,renderHTML:({src:t})=>({src:t?SX(t):null})},width:{default:this.options.width,renderHTML:({width:t})=>({width:an(t)})},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen},controls:{default:this.options.controls}}},parseHTML(){return[{tag:"video"},{tag:"iframe"}]},renderHTML({HTMLAttributes:t}){const{src:e,width:n,controls:r,allowfullscreen:o}=t??{},s=`max-width: ${an(n)};`;return kX(e)?["iframe",{src:e,style:s,...o&&{allowfullscreen:o}}]:["video",{src:e?e.replace(/\\/g,"/"):"",style:s,...r&&{controls:r}}]},addCommands(){return{setVideo:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t}),updateVideo:t=>({commands:e})=>e.updateAttributes(this.name,t)}}}),kl=new St("upload-image"),_X=()=>new tt({key:kl,state:{init(){return mt.empty},apply(t,e){e=e.map(t.mapping,t.doc);const n=t.getMeta(kl);return n!=null&&n.add?n.add.forEach(({id:r,pos:o,src:s})=>{const a=TX(s),l=Wt.widget(o,a,{id:r});e=e.add(t.doc,[l])}):n!=null&&n.remove&&n.remove.forEach(r=>{e=e.remove(e.find(void 0,void 0,o=>o.id===r))}),e}},props:{decorations(t){return this.getState(t)}}});function TX(t){const e=document.createElement("div"),n=document.createElement("img");return n.setAttribute("class","opacity-50"),n.src=t,n.onload=()=>{e.setAttribute("class","img-placeholder")},e.appendChild(n),e}function AX(t,e){var o;const r=kl.getState(t).find(void 0,void 0,s=>s.id===e);return r.length?(o=r[0])==null?void 0:o.from:null}const YE=({validateFn:t,onUpload:e})=>(n,r,o,s)=>{n.forEach(a=>{if(t&&!t(a))return;s||(s=ai(6));const l=r.state.tr;l.selection.empty||l.deleteSelection();let u=null;r.state.doc.descendants((p,m)=>{p.type.name===ds&&p.attrs.id===s&&(u=m)});const c=URL.createObjectURL(a);l.setMeta(kl,{add:[{id:s,pos:o,src:c}]}),r.dispatch(l);const f=AX(r.state,s)||u;e(a).then(p=>{var w;const{schema:m}=r.state;if(f===null)throw new Error("Not found placeholderPos");const g=typeof p=="object"?c:p,b=(w=m.nodes.image)==null?void 0:w.create({src:g});if(!b)return;const y=r.state.tr.replaceWith(f,f,b).setMeta(kl,{remove:[s]});r.dispatch(y)},()=>{const p=r.state.tr.delete(o,o).setMeta(kl,{remove:[s]});r.dispatch(p)})})},OX=(t,e,n)=>{var o;const r=Array.from(((o=e.clipboardData)==null?void 0:o.files)||[]);if(r.length){e.preventDefault();const s=t.state.selection.from;return n(r,t,s+1),!0}return!1},MX=(t,e,n,r)=>{var s;const o=Array.from(((s=e.dataTransfer)==null?void 0:s.files)||[]);if(!n&&o.length){e.preventDefault();const a=t.posAtCoords({left:e.clientX,top:e.clientY});if(a)return r(o,t,a.pos+1),!0}return!1},BX={class:"flex items-center w-full p-3 my-3 transition-all border rounded-sm cursor-pointer hover:bg-ed-accent border-ed-border text-ed-muted-foreground"},IX={class:"flex items-center justify-between w-full"},RX={class:"flex items-center justify-center gap-3"},LX={class:"text-sm"},PX={class:"flex items-center gap-2"},DX=i.defineComponent({__name:"ImageUploader",props:{...zs},setup(t){const e=t,n=i.ref(""),r=i.ref(),{t:o}=At(),s=i.inject("isEditable",i.ref(!0));function a(f){var y,w;const p=(y=f==null?void 0:f.target)==null?void 0:y.files;if(!e.editor||e.editor.isDestroyed||p.length===0)return;const m=p[0],g=(w=e.editor.extensionManager.extensions.find(x=>x.name==="imageUpload"))==null?void 0:w.options;YE({validateFn:x=>!0,onUpload:g.upload})([m],e.editor.view,e.getPos(),e.node.attrs.id)}function l(){e.editor.chain().setImage({src:n.value}).deleteRange({from:e.getPos(),to:e.getPos()}).focus().run()}function u(){s.value&&e.deleteNode()}function c(){var f;(f=r.value)==null||f.click()}return(f,p)=>(i.openBlock(),i.createBlock(i.unref($s),{id:f.node.attrs.id,class:"p-0 m-0","data-drag-handle":""},{default:i.withCtx(()=>[i.createVNode(i.unref(ul),{"default-open":""},{default:i.withCtx(()=>[i.createVNode(i.unref(fl),{"as-child":""},{default:i.withCtx(()=>[i.createElementVNode("div",BX,[i.createElementVNode("div",IX,[i.createElementVNode("div",RX,[i.createVNode(i.unref(jt),{name:"ImageUp",class:"w-6 h-6"}),i.createElementVNode("span",LX,i.toDisplayString(i.unref(o)("editor.image.dialog.title")),1)]),i.createVNode(i.unref(jt),{name:"Trash2",class:"hover:text-ed-foreground",onClick:i.withModifiers(u,["stop"])})])])]),_:1}),i.unref(s)?(i.openBlock(),i.createBlock(i.unref(cl),{key:0,"trap-focus":"",class:"w-full","on-open-auto-focus":m=>m.preventDefault()},{default:i.withCtx(()=>[i.createVNode(i.unref($g),{"default-value":"upload",class:"w-[300px] sm:w-[400px]","activation-mode":"manual"},{default:i.withCtx(()=>[i.createVNode(i.unref(zg),{class:"grid w-full grid-cols-2"},{default:i.withCtx(()=>[i.createVNode(i.unref(Fu),{value:"upload"},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(i.unref(o)("editor.image.dialog.tab.upload")),1)]),_:1}),i.createVNode(i.unref(Fu),{value:"link"},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(i.unref(o)("editor.image.dialog.tab.url")),1)]),_:1})]),_:1}),i.createVNode(i.unref($p),{value:"upload"},{default:i.withCtx(()=>[i.createVNode(i.unref(_n),{class:"w-full mt-1",size:"sm",onClick:c},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(i.unref(o)("editor.image.dialog.tab.upload")),1)]),_:1}),i.createElementVNode("input",{ref_key:"fileInput",ref:r,type:"file",accept:"image/*",multiple:"",hidden:"",onChange:a},null,544)]),_:1}),i.createVNode(i.unref($p),{value:"link"},{default:i.withCtx(()=>[i.createElementVNode("div",PX,[i.createVNode(i.unref(dl),{modelValue:n.value,"onUpdate:modelValue":p[0]||(p[0]=m=>n.value=m),type:"url",autofocus:"",required:"",placeholder:i.unref(o)("editor.image.dialog.placeholder")},null,8,["modelValue","placeholder"]),i.createVNode(i.unref(_n),{onClick:l},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(i.unref(o)("editor.image.dialog.button.apply")),1)]),_:1})])]),_:1})]),_:1})]),_:1},8,["on-open-auto-focus"])):i.createCommentVNode("",!0)]),_:1})]),_:1},8,["id"]))}}),VX=1,FX=1e6,pi={ADD_TOAST:"ADD_TOAST",UPDATE_TOAST:"UPDATE_TOAST",DISMISS_TOAST:"DISMISS_TOAST",REMOVE_TOAST:"REMOVE_TOAST"};let Tb=0;function $X(){return Tb=(Tb+1)%Number.MAX_VALUE,Tb.toString()}const Ab=new Map;function JE(t){if(Ab.has(t))return;const e=setTimeout(()=>{Ab.delete(t),fc({type:pi.REMOVE_TOAST,toastId:t})},FX);Ab.set(t,e)}const co=i.ref({toasts:[]});function fc(t){switch(t.type){case pi.ADD_TOAST:co.value.toasts=[t.toast,...co.value.toasts].slice(0,VX);break;case pi.UPDATE_TOAST:co.value.toasts=co.value.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e);break;case pi.DISMISS_TOAST:{const{toastId:e}=t;e?JE(e):co.value.toasts.forEach(n=>{JE(n.id)}),co.value.toasts=co.value.toasts.map(n=>n.id===e||e===void 0?{...n,open:!1}:n);break}case pi.REMOVE_TOAST:t.toastId===void 0?co.value.toasts=[]:co.value.toasts=co.value.toasts.filter(e=>e.id!==t.toastId);break}}function Ob(){return{toasts:i.computed(()=>co.value.toasts),toast:zX,dismiss:t=>fc({type:pi.DISMISS_TOAST,toastId:t})}}function zX(t){const e=$X(),n=o=>fc({type:pi.UPDATE_TOAST,toast:{...o,id:e}}),r=()=>fc({type:pi.DISMISS_TOAST,toastId:e});return fc({type:pi.ADD_TOAST,toast:{...t,id:e,open:!0,onOpenChange:o=>{o||r()}}}),{id:e,dismiss:r,update:n}}const HX={acceptMimes:["image/jpeg","image/gif","image/png","image/jpg"],maxSize:1024*1024*5},UX=t=>`${(t/1024/1024).toFixed(2)}MB`,ZE=Bt.create({name:"imageUpload",isolating:!0,defining:!0,group:"block",draggable:!1,selectable:!0,inline:!1,onCreate(){if(typeof this.options.upload!="function")throw new Error("Image upload function should be a function")},parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML(){return["div",{"data-type":this.name}]},addAttributes(){return{id:{default:ai(6),parseHTML:t=>t.getAttribute("id"),renderHTML:t=>t.id?{id:t.id}:{}}}},addCommands(){return{setImageUpload:()=>({commands:t})=>t.insertContent(`<div data-type="${this.name}"></div>`)}},addNodeView(){return Hs(DX)},addOptions(){var t;return{...HX,...(t=this.parent)==null?void 0:t.call(this),upload:()=>Promise.reject("Image Upload Function"),button:({editor:e,extension:n,t:r})=>{var o,s;return{component:Ge,componentProps:{action:()=>e.commands.setImageUpload(),disabled:!((s=(o=e.can()).setImage)!=null&&s.call(o,{})),icon:"ImageUp",tooltip:r("editor.image.tooltip")}}}}},addProseMirrorPlugins(){const{toast:t}=Ob(),{t:e}=At(),r=YE({validateFn:o=>this.options.acceptMimes.includes(o.type)?o.size>this.options.maxSize?(t({description:`${e("editor.imageUpload.fileSizeTooBig")} ${UX(this.options.maxSize)}.`,duration:2e3}),!1):!0:(t({description:e("editor.imageUpload.fileTypeNotSupported"),duration:2e3}),!1),onUpload:this.options.upload});return[new tt({props:{handlePaste:(o,s)=>!s.clipboardData||Array.from(s.clipboardData.items||[]).some(l=>l.type==="text/html")?!1:OX(o,s,r),handleDrop:(o,s,a,l)=>(!(s instanceof DragEvent)||!s.dataTransfer||MX(o,s,l,r),!1)}}),_X()]}}),QE=Ne.create({name:"base-kit",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),timeHighlighter:{additionalTimeWords:[]},bubble:{list:LB,defaultBubbleList:mj,button:({editor:e,extension:n,t:r})=>{var l;const{list:o={},defaultBubbleList:s}=((l=n.options)==null?void 0:l.bubble)??{},a=(s==null?void 0:s(e))??[];return gj(o,a,{editor:e,extension:n,t:r})}}}},addExtensions(){var n,r,o,s,a;const{t}=At(),e=[];this.options.placeholder!==!1&&e.push(fj.configure({placeholder:({node:l,pos:u})=>{var f;const c=(f=l==null?void 0:l.type)==null?void 0:f.name;return c==="heading"?`${t(`editor.heading.h${l.attrs.level}.tooltip`)}`:c==="table"||c==="codeBlock"?"":u===0?t("editor.content"):""},...this.options.placeholder})),this.options.focus!==!1&&e.push(nj.configure({className:"focus",...this.options.focus})),this.options.document!==!1&&(this.options.page?(e.push(F8.configure().extend({content:"page+"})),e.push(iK.configure({types:((r=(n=this.options.page)==null?void 0:n.nodesComputedOption)==null?void 0:r.types)??[],slots:i.useSlots()}))):e.push(F8.configure())),this.options.dropcursor!==!1&&e.push(tj.configure({...this.options.dropcursor,width:2,class:"ProseMirror-dropcursor border-black"})),this.options.characterCount!==!1&&e.push(QW.configure(this.options.characterCount)),this.options.paragraph!==!1&&e.push(P8.configure(this.options.paragraph)),this.options.hardBreak!==!1&&e.push(L8.configure(this.options.hardBreak)),this.options.listItem!==!1&&e.push(dj.configure(this.options.listItem)),this.options.textStyle!==!1&&e.push(FU.configure(this.options.textStyle)),this.options.imageUpload!==!1&&e.push(ZE.configure(this.options.imageUpload)),this.options.video!==!1&&e.push(XE.configure(this.options.video)),this.options.videoUpload!==!1&&e.push(GE.configure(this.options.videoUpload)),this.options.history!==!1&&e.push(H1.configure(this.options.history)),this.options.fontSize!==!1&&e.push(n8.configure(this.options.fontSize)),this.options.fontFamily!==!1&&e.push(hE.configure(this.options.fontFamily)),this.options.mode!==De.EDITOR&&e.push(fK),this.options.superText!==!1&&this.options.mode!==De.PLAIN_TEXT&&(typeof this.options.superText=="boolean"?e.push(CE.configure()):e.push(CE.configure({specialCharModal:(o=this.options.superText)==null?void 0:o.specialCharModal,toggleSuperViewMobileCallBack:(s=this.options.superText)==null?void 0:s.toggleSuperViewMobileCallBack}))),this.options.mode===De.EDITOR&&(this.options.image!==!1&&e.push(mb.configure()),e.push(e8.configure({spacer:!0}),SC,EC,kC,F1,kb)),this.options.mode!==De.EDITOR&&this.options.configPlan!==!1&&this.options.mode!==De.PLAIN_TEXT&&(typeof this.options.configPlan=="boolean"?e.push(EE.configure()):e.push(EE.configure({specialCharModal:(a=this.options.configPlan)==null?void 0:a.specialCharModal}))),this.options.mode!==De.EDITOR&&this.options.mode!==De.PLAIN_TEXT&&e.push(hK),(this.options.mode===De.STRAIGHT||this.options.mode===De.REPORT||this.options.mode===De.EDITOR)&&this.options.timeHighlighter&&e.push(lX.configure(this.options.timeHighlighter)),this.options.invalidCharFocus!==!1&&e.push(uX.configure(this.options.invalidCharFocus)),e.push(pj,D8.configure(),iX.configure(),cj.configure(),_C,r8.configure({spacer:!0}),t8.configure({types:["heading","paragraph"],spacer:!0}),bE,gb,pb,h1,mX,gX,o8.configure({multicolor:!0}));for(const l in this.options.excludes)Object.prototype.hasOwnProperty.call(this.options.excludes,l)&&this.options.excludes[l]&&it.remove(e,({name:c})=>c===l);return e},addStorage(){return{mode:this.options.mode}}}),NE=Kn.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",bt(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),eS=Kn.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",bt(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),WX=Ne.create({name:"subAndSuperScript",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button:({editor:e,extension:n,t:r})=>{const o=n.options.subscript,s=n.options.superscript,a={component:Ge,componentProps:{action:()=>e.commands.toggleSubscript(),isActive:()=>e.isActive("subscript")||!1,disabled:!e.can().toggleSubscript(),icon:"Subscript",tooltip:r("editor.subscript.tooltip")}},l={component:Ge,componentProps:{action:()=>e.commands.toggleSuperscript(),isActive:()=>e.isActive("superscript")||!1,disabled:!e.can().toggleSuperscript(),icon:"Superscript",tooltip:r("editor.superscript.tooltip")}},u=[];return o!==!1&&u.push(a),s!==!1&&u.push(l),u}}},addExtensions(){const t=[];return this.options.subscript!==!1&&t.push(NE.configure(this.options.subscript)),this.options.superscript!==!1&&t.push(eS.configure(this.options.superscript)),t}}),jX={class:"ml-1"},qX=i.defineComponent({__name:"ActionMoreButton",props:{editor:{},disabled:{type:Boolean,default:!1},color:{default:void 0},maxHeight:{default:void 0},icon:{default:void 0},tooltip:{default:""},items:{default:()=>[]}},setup(t){const e=t,n=i.computed(()=>{const r=e.items.find(s=>s.isActive());return r&&!r.default?{...r,icon:r.icon?r.icon:e.icon}:{title:e.tooltip,icon:e.icon,isActive:()=>!1}});return(r,o)=>(i.openBlock(),i.createBlock(na,{icon:r.icon,tooltip:r.tooltip,disabled:r.disabled},{default:i.withCtx(()=>[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(e.items,(s,a)=>(i.openBlock(),i.createBlock(i.unref(yl),{key:a,checked:n.value.title===s.title,disabled:s.disabled,class:"flex gap-3 items-center",onClick:s.action},{default:i.withCtx(()=>[s.icon?(i.openBlock(),i.createBlock(i.unref(jt),{key:0,name:s.icon},null,8,["name"])):i.createCommentVNode("",!0),i.createElementVNode("span",jX,i.toDisplayString(s.title),1),s.shortcutKeys?(i.openBlock(),i.createBlock(i.unref(NC),{key:1,class:"ml-auto"},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(i.unref($6)(s.shortcutKeys)),1)]),_:2},1024)):i.createCommentVNode("",!0)]),_:2},1032,["checked","disabled","onClick"]))),128))]),_:1},8,["icon","tooltip","disabled"]))}}),KX=Ne.create({name:"moreMark",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button({editor:e,extension:n,t:r}){const o=n.options.subscript,s=n.options.superscript,a={action:()=>e.commands.toggleSubscript(),isActive:()=>e.isActive("subscript")||!1,disabled:!e.can().toggleSubscript(),icon:"Subscript",title:r("editor.subscript.tooltip"),shortcutKeys:["mod","."]},l={action:()=>e.commands.toggleSuperscript(),isActive:()=>e.isActive("superscript")||!1,disabled:!e.can().toggleSuperscript(),icon:"Superscript",title:r("editor.superscript.tooltip"),shortcutKeys:["mod",","]},u=A0(e,"code"),c=[];if(o!==!1&&c.push(a),s!==!1&&c.push(l),u){const f={action:()=>e.commands.toggleCode(),isActive:()=>e.isActive("code")||!1,disabled:!e.can().toggleCode(),icon:"Code",title:r("editor.code.tooltip"),shortcutKeys:["mod","E"]};u&&c.push(f)}return{component:qX,componentProps:{icon:"Type",tooltip:r("editor.moremark"),disabled:!e.isEditable||c.every(f=>f.disabled),items:c}}}}},addExtensions(){const t=[];return this.options.subscript!==!1&&t.push(NE.configure(this.options.subscript)),this.options.superscript!==!1&&t.push(eS.configure(this.options.superscript)),t}});var ua=(t=>(t[t.max=7]="max",t[t.min=0]="min",t[t.more=1]="more",t[t.less=-1]="less",t))(ua||{});function GX(t,e,n){return t<e?e:t>n?n:t}function XX(t,e,n,r){const{doc:o,selection:s}=t;if(!o||!s||!(s instanceof Ie||s instanceof In))return t;const{from:a,to:l}=s;return o.nodesBetween(a,l,(u,c)=>{const f=u.type;return n.includes(f.name)?(t=YX(t,c,e),!1):!r0(u.type.name,r.extensionManager.extensions)}),t}function YX(t,e,n){if(!t.doc)return t;const r=t.doc.nodeAt(e);if(!r)return t;const a=GX((r.attrs.indent||0)+n,0,7);if(a===r.attrs.indent)return t;const l={...r.attrs,indent:a};return t.setNodeMarkup(e,r.type,l,r.marks)}function tS({delta:t,types:e}){return({state:n,dispatch:r,editor:o})=>{const{selection:s}=n;let{tr:a}=n;return a=a.setSelection(s),a=XX(a,t,e,o),a.docChanged?(r&&r(a),!0):!1}}const JX=Ne.create({name:"indent",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),types:["paragraph","heading","blockquote"],minIndent:ua.min,maxIndent:ua.max,button({editor:e,t:n}){var s,a;const{selection:r}=e.state,o=r.$anchor.parent;return[{component:Ge,componentProps:{action:()=>{e.commands.indent()},disabled:((s=o==null?void 0:o.attrs)==null?void 0:s.indent)>=ua.max||!e.can().indent(),shortcutKeys:["Tab"],icon:"IndentIncrease",tooltip:n("editor.indent.tooltip")}},{component:Ge,componentProps:{action:()=>{e.commands.outdent()},shortcutKeys:["Shift","Tab"],disabled:((a=o==null?void 0:o.attrs)==null?void 0:a.indent)<=ua.min||!e.can().outdent(),icon:"IndentDecrease",tooltip:n("editor.outdent.tooltip")}}]}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{indent:{default:0,parseHTML:t=>{const e=t.getAttribute("data-indent");return(e?parseInt(e,10):0)||0},renderHTML:t=>t.indent?{"data-indent":t.indent}:{}}}}]},addCommands(){return{indent:()=>tS({delta:ua.more,types:this.options.types}),outdent:()=>tS({delta:ua.less,types:this.options.types})}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.indent(),"Shift-Tab":()=>this.editor.commands.outdent()}}});function ZX(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:s,startOfLine:a,$position:l}=t,u=r&&!o,c=jO(n),f=new RegExp(`\\s${c}$`),p=a?"^":"",m=o?"":c,g=u?new RegExp(`${p}${c}.*?(?=\\s${m}|$)`,"gm"):new RegExp(`${p}(?:^)?${c}[^\\s${m}]*`,"gm"),b=((e=l.nodeBefore)===null||e===void 0?void 0:e.isText)&&l.nodeBefore.text;if(!b)return null;const y=l.pos-b.length,w=Array.from(b.matchAll(g)).pop();if(!w||w.input===void 0||w.index===void 0)return null;const x=w.input.slice(Math.max(0,w.index-1),w.index),S=new RegExp(`^[${s==null?void 0:s.join("")}\0]?$`).test(x);if(s!==null&&!S)return null;const C=y+w.index;let E=C+w[0].length;return u&&f.test(b.slice(E-1,E+1))&&(w[0]+=" ",E+=1),C<l.pos&&E>=l.pos?{range:{from:C,to:E},query:w[0].slice(n.length),text:w[0]}:null}const QX=new St("suggestion");function NX({pluginKey:t=QX,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:o=!1,allowedPrefixes:s=[" "],startOfLine:a=!1,decorationTag:l="span",decorationClass:u="suggestion",command:c=()=>null,items:f=()=>[],render:p=()=>({}),allow:m=()=>!0,findSuggestionMatch:g=ZX}){let b;const y=p==null?void 0:p(),w=new tt({key:t,view(){return{update:async(x,S)=>{var C,E,_,T,A,L,D;const M=(C=this.key)===null||C===void 0?void 0:C.getState(S),$=(E=this.key)===null||E===void 0?void 0:E.getState(x.state),j=M.active&&$.active&&M.range.from!==$.range.from,X=!M.active&&$.active,se=M.active&&!$.active,W=!X&&!se&&M.query!==$.query,z=X||j&&W,R=W||j,q=se||j&&W;if(!z&&!R&&!q)return;const Z=q&&!z?M:$,te=x.dom.querySelector(`[data-decoration-id="${Z.decorationId}"]`);b={editor:e,range:Z.range,query:Z.query,text:Z.text,items:[],command:ne=>c({editor:e,range:Z.range,props:ne}),decorationNode:te,clientRect:te?()=>{var ne;const{decorationId:ye}=(ne=this.key)===null||ne===void 0?void 0:ne.getState(e.state),Ce=x.dom.querySelector(`[data-decoration-id="${ye}"]`);return(Ce==null?void 0:Ce.getBoundingClientRect())||null}:null},z&&((_=y==null?void 0:y.onBeforeStart)===null||_===void 0||_.call(y,b)),R&&((T=y==null?void 0:y.onBeforeUpdate)===null||T===void 0||T.call(y,b)),(R||z)&&(b.items=await f({editor:e,query:Z.query})),q&&((A=y==null?void 0:y.onExit)===null||A===void 0||A.call(y,b)),R&&((L=y==null?void 0:y.onUpdate)===null||L===void 0||L.call(y,b)),z&&((D=y==null?void 0:y.onStart)===null||D===void 0||D.call(y,b))},destroy:()=>{var x;b&&((x=y==null?void 0:y.onExit)===null||x===void 0||x.call(y,b))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(x,S,C,E){const{isEditable:_}=e,{composing:T}=e.view,{selection:A}=x,{empty:L,from:D}=A,M={...S};if(M.composing=T,_&&(L||e.view.composing)){(D<S.range.from||D>S.range.to)&&!T&&!S.composing&&(M.active=!1);const $=g({char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:s,startOfLine:a,$position:A.$from}),j=`id_${Math.floor(Math.random()*4294967295)}`;$&&m({editor:e,state:E,range:$.range,isActive:S.active})?(M.active=!0,M.decorationId=S.decorationId?S.decorationId:j,M.range=$.range,M.query=$.query,M.text=$.text):M.active=!1}else M.active=!1;return M.active||(M.decorationId=null,M.range={from:0,to:0},M.query=null,M.text=null),M}},props:{handleKeyDown(x,S){var C;const{active:E,range:_}=w.getState(x.state);return E&&((C=y==null?void 0:y.onKeyDown)===null||C===void 0?void 0:C.call(y,{view:x,event:S,range:_}))||!1},decorations(x){const{active:S,range:C,decorationId:E}=w.getState(x);return S?mt.create(x.doc,[Wt.inline(C.from,C.to,{nodeName:l,class:u,"data-decoration-id":E})]):null}}});return w}const eY=[{label:"优酷",value:"youku",icon:"Youku"},{label:"哔哩哔哩",value:"bilibili",icon:"BiliBili"},{label:"腾讯视频",value:"qqvideo",icon:"QQVideo"}],tY=[{label:"高德地图",value:"amap",icon:"Gaode"},{label:"百度地图",value:"baidu_map",icon:"Baidu"}],nY=[{label:"墨刀",value:"modao",icon:"Modao"},{label:"蓝湖",value:"lanhu",icon:"Lanhu"},{label:"Figma",value:"figma",icon:"Figma"},{label:"Canva",value:"canva",icon:"Canva"},{label:"ProcessOn",value:"processon",icon:"Processon"}],rY=[{label:"CodePen",value:"codepen",icon:"Codepen"}],oY=[{label:"金数据",value:"jinshuju",icon:"Jinshuju"}],iY=[],sY=[...eY,...tY,...nY,...rY,...oY,...iY];function aY(t){const{t:e}=At(),n=[{name:"format",title:e("editor.slash.format"),commands:[{name:"paragraph",label:e("editor.paragraph.tooltip"),aliases:["paragraph","zw"],iconName:"Paragraph",action:({editor:o,range:s})=>{o.chain().focus().deleteRange(s).setHeading({level:1}).run()}},{name:"heading1",label:e("editor.heading.h1.tooltip"),aliases:["h1","bt","bt1"],iconName:"Heading1",action:({editor:o,range:s})=>{o.chain().focus().deleteRange(s).setHeading({level:1}).run()}},{name:"heading2",label:e("editor.heading.h2.tooltip"),aliases:["h2","bt","bt2"],iconName:"Heading2",action:({editor:o,range:s})=>{o.chain().focus().deleteRange(s).setNode("heading",{level:2}).run()}},{name:"heading3",label:e("editor.heading.h3.tooltip"),aliases:["h3","bt","bt3","heading3"],iconName:"Heading3",action:({editor:o,range:s})=>{o.chain().focus().deleteRange(s).setNode("heading",{level:3}).run()}},{name:"bulletList",label:e("editor.bulletlist.tooltip"),aliases:["ul","yxlb","bulletList"],iconName:"List",action:({editor:o,range:s})=>{o.chain().focus().deleteRange(s).toggleBulletList().run()}},{name:"numberedList",label:e("editor.orderedlist.tooltip"),aliases:["ol","yxlb"],iconName:"ListOrdered",action:({editor:o,range:s})=>{o.chain().focus().deleteRange(s).toggleOrderedList().run()}},{name:"codeBlock",label:e("editor.codeblock.tooltip"),iconName:"Code2",aliases:["codeBlock"],description:"Code block with syntax highlighting",shouldBeHidden:o=>o.isActive("columns"),action:({editor:o,range:s})=>{o.chain().focus().deleteRange(s).setCodeBlock().run()}},{name:"blockquote",label:e("editor.blockquote.tooltip"),description:"插入引入格式",aliases:["yr"],iconName:"TextQuote",action:({editor:o,range:s})=>{o.chain().focus().deleteRange(s).setBlockquote().run()}},{name:"horizontalrule",label:e("editor.horizontalrule.tooltip"),aliases:["fgx","horizontalRule"],iconName:"Minus",action:({editor:o,range:s})=>{o.chain().focus().deleteRange(s).setHorizontalRule().run()}},{name:"link",label:e("editor.link.tooltip"),aliases:["link","lianjie","lj"],iconName:"Link",action:({editor:o,range:s})=>{o.chain().deleteRange(s).extendMarkRange("link").insertContent({type:"text",text:"link",marks:[{type:"link",attrs:{href:"",target:"_blank"}}]}).setLink({href:""}).focus().run()}}]},{name:"insert",title:e("editor.slash.insert"),commands:[{name:"image",label:e("editor.image.tooltip"),iconName:"ImageUp",description:"Insert a image",aliases:["image","tp","tupian"],shouldBeHidden:o=>o.isActive("columns"),action:({editor:o,range:s})=>{o.chain().focus().deleteRange(s).setImageUpload().run()}},{name:"table",label:e("editor.table.tooltip"),iconName:"Table",description:"Insert a table",aliases:["table","bg","biaoge","biao"],shouldBeHidden:o=>o.isActive("columns"),action:({editor:o,range:s})=>{o.chain().focus().deleteRange(s).insertTable({rows:3,cols:3,withHeaderRow:!1}).run()}},{name:"video",label:e("editor.video.tooltip"),iconName:"Video",description:"Insert a video",aliases:["video","sp","shipin"],shouldBeHidden:o=>o.isActive("columns"),action:({editor:o,range:s})=>{o.chain().focus().deleteRange(s).setVideoUpload().run()}},{name:"taskList",label:e("editor.tasklist.tooltip"),iconName:"ListTodo",description:"Task list with todo items",aliases:["todo"],action:({editor:o,range:s})=>{o.chain().focus().deleteRange(s).toggleTaskList().run()}},{name:"columns",label:e("editor.columns.tooltip"),iconName:"Columns2",description:"Add two column content",aliases:["columns","cols","2cols"],shouldBeHidden:o=>o.isActive("columns"),action:({editor:o,range:s})=>{o.chain().deleteRange(s).setColumns().focus(o.state.selection.head-1).run()}}]}];if(A0(t,"iframes")){const o=sY;n.push({name:"others",title:e("editor.slash.embed"),commands:o.map(s=>({name:s.value,label:s.label,iconName:s.icon,aliases:[s.value,s.label],shouldBeHidden:a=>a.isActive("columns"),action:({editor:a,range:l})=>{a.chain().deleteRange(l).focus().setIframe({src:"",service:s.value}).run()}}))})}return n}const lY={key:0,class:"grid grid-cols-1 gap-0.5 min-w-48"},uY={className:"text-neutral-500 text-[0.65rem] col-[1/-1] mx-2 mt-2 font-semibold tracking-wider select-none uppercase first:mt-0.5"},cY=["onClick"],dY=["src"],fY={key:1,class:"p-3"},pY={class:"text-xs text-gray-800 dark:text-gray-100"},hY=i.defineComponent({__name:"CommandsList",props:{editor:{},items:{default:void 0},command:{type:Function,default:void 0}},setup(t,{expose:e}){const n=i.ref(0),r=i.ref(0),o=i.ref(null),{t:s}=At(),a=i.ref([]),l=t;e({onKeyDown:u}),i.watch([()=>n.value,()=>r.value],async()=>{if(!o.value)return;await i.nextTick();const y=r.value*1e3+n.value,w=a.value[y];w&&w.scrollIntoView({behavior:"smooth",block:"nearest"})});function u({event:y}){return y.key==="ArrowUp"?(c(),!0):y.key==="ArrowDown"?(f(),!0):y.key==="Enter"?(p(),!0):!1}function c(){var x;if(!l.items.length)return!1;let y=n.value-1,w=r.value;y<0&&(w=r.value-1,y=((x=l.items[w])==null?void 0:x.commands.length)-1||0),w<0&&(w=l.items.length-1,y=l.items[w].commands.length-1),n.value=y,r.value=w}function f(){if(!l.items.length)return!1;const y=l.items[r.value].commands;let w=n.value+1,x=r.value;y.length-1<w&&(w=0,x=r.value+1),l.items.length-1<x&&(x=0),n.value=w,r.value=x}function p(){if(!l.items.length||r.value===-1||n.value===-1)return!1;m(r.value,n.value)}function m(y,w){const x=l.items[y].commands[w];l.command(x)}function g(y,w){m(y,w)}function b(y,w,x){a.value[y*1e3+w]=x}return(y,w)=>{var x;return i.openBlock(),i.createElementBlock("div",{ref_key:"scrollContainer",ref:o,class:"bg-white rounded-lg dark:bg-black shadow-sm border border-neutral-200 dark:border-neutral-800 text-black max-h-[min(80vh,24rem)] overflow-auto flex-wrap mb-8 p-1"},[(x=y.items)!=null&&x.length?(i.openBlock(),i.createElementBlock("div",lY,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(y.items,(S,C)=>(i.openBlock(),i.createElementBlock(i.Fragment,{key:S.title},[i.createElementVNode("div",uY,i.toDisplayString(S.title),1),(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(S.commands,(E,_)=>(i.openBlock(),i.createElementBlock("button",{ref_for:!0,ref:T=>b(C,_,T),key:_,class:i.normalizeClass(["flex items-center gap-3 px-2 py-1.5 text-sm text-neutral-800 dark:text-neutral-200 text-left w-full rounded-sm outline-none transition-colors",[r.value===C&&n.value===_?"bg-ed-accent text-neutral-800 dark:bg-neutral-900 dark:text-neutral-200":"hover:bg-ed-accent hover:text-neutral-800 dark:hover:bg-neutral-900 dark:hover:text-neutral-200"]]),onClick:T=>g(C,_)},[E.iconUrl?(i.openBlock(),i.createElementBlock("img",{key:0,class:"w-6 h-6",src:E.iconUrl},null,8,dY)):i.createCommentVNode("",!0),E.iconName?(i.openBlock(),i.createBlock(i.unref(jt),{key:1,name:E.iconName,class:"mr-1 text-lg"},null,8,["name"])):i.createCommentVNode("",!0),i.createTextVNode(" "+i.toDisplayString(E.label),1)],10,cY))),128))],64))),128))])):(i.openBlock(),i.createElementBlock("div",fY,[i.createElementVNode("span",pY,i.toDisplayString(i.unref(s)("editor.slash.empty")),1)]))],512)}}}),ca="slashCommand";let Rt;const mY=Ne.create({name:ca,priority:200,onCreate(){Rt=Fs("body",{interactive:!0,trigger:"manual",placement:"bottom-start",theme:"slash-command",maxWidth:"16rem",offset:[16,8],popperOptions:{strategy:"fixed",modifiers:[{name:"flip",enabled:!1}]}})},addProseMirrorPlugins(){return[NX({editor:this.editor,char:"/",allowSpaces:!0,startOfLine:!0,pluginKey:new St(ca),allow:({state:t,range:e})=>{var c,f,p;const n=t.doc.resolve(e.from),r=n.depth===1,o=n.parent.type.name==="paragraph",s=((c=n.parent.textContent)==null?void 0:c.charAt(0))==="/",a=this.editor.isActive("column"),l=(p=n.parent.textContent)==null?void 0:p.substring((f=n.parent.textContent)==null?void 0:f.indexOf("/")),u=!(l!=null&&l.endsWith(" "));return(r&&o&&s||a&&o&&s)&&u},command:({editor:t,range:e,props:n})=>{const{view:r}=t;n.action({editor:t,range:e}),r.focus()},items:({query:t})=>aY(this.editor).map(s=>({...s,commands:s.commands.filter(a=>{const l=a.label.toLowerCase().trim(),u=t.toLowerCase().trim();if(a.aliases){const c=a.aliases.map(m=>m.toLowerCase().trim()),f=l.match(u),p=c.some(m=>m.match(u));return f||p}return l.match(u)}).filter(a=>a.shouldBeHidden?!a.shouldBeHidden(this.editor):!0)})).filter(s=>s.commands.length>0).map(s=>({...s,commands:s.commands.map(a=>({...a,isEnabled:!0}))})),render:()=>{let t,e=null;return{onStart:n=>{var s;t=new s4(hY,{props:n,editor:n.editor});const{view:r}=n.editor,o=()=>{if(!n.clientRect)return n.editor.storage[ca].rect;const a=n.clientRect();if(!a)return n.editor.storage[ca].rect;let l=a.y;if(t.element instanceof HTMLElement&&a.top+t.element.offsetHeight+40>window.innerHeight){const u=a.top+t.element.offsetHeight-window.innerHeight+40;l=a.y-u}return new DOMRect(a.x,l,a.width,a.height)};e=()=>{Rt==null||Rt[0].setProps({getReferenceClientRect:o})},(s=r.dom.parentElement)==null||s.addEventListener("scroll",e),t.element&&(Rt==null||Rt[0].setProps({getReferenceClientRect:o,appendTo:()=>document.body,content:t.element})),Rt==null||Rt[0].show()},onUpdate(n){var a;t.updateProps(n);const{view:r}=n.editor,o=()=>{if(!n.clientRect)return n.editor.storage[ca].rect;const l=n.clientRect();return l?new DOMRect(l.x,l.y,l.width,l.height):n.editor.storage[ca].rect},s=()=>{Rt==null||Rt[0].setProps({getReferenceClientRect:o})};(a=r.dom.parentElement)==null||a.addEventListener("scroll",s),n.editor.storage[ca].rect=n.clientRect?o():{width:0,height:0,left:0,top:0,right:0,bottom:0},Rt==null||Rt[0].setProps({getReferenceClientRect:o})},onKeyDown(n){var r;return n.event.key==="Escape"?(Rt==null||Rt[0].hide(),!0):(Rt!=null&&Rt[0].state.isShown||Rt==null||Rt[0].show(),(r=t.ref)==null?void 0:r.onKeyDown(n))},onExit(n){var r;if(Rt==null||Rt[0].hide(),e){const{view:o}=n.editor;(r=o.dom.parentElement)==null||r.removeEventListener("scroll",e)}t.destroy()}}}})]},addStorage(){return{rect:{width:0,height:0,left:0,top:0,right:0,bottom:0}}}}),gY=i.defineComponent({__name:"AIButton",props:{editor:{},icon:{default:void 0},title:{default:void 0},tooltip:{default:void 0},disabled:{type:Boolean,default:!1},shortcutKeys:{default:void 0},customClass:{default:""},loading:{type:Boolean,default:!1},tooltipOptions:{default:void 0},color:{default:void 0},action:{type:Function,default:void 0},isActive:{type:Function,default:void 0}},setup(t){const e=t,n=vn(),{toast:r}=Ob();function o(){var a,l,u;const s=(l=(a=e.editor.extensionManager.extensions.find(c=>c.name==="AI"))==null?void 0:a.options)==null?void 0:l.completions;if(typeof s!="function"){r({title:"AI completions method is not set or is not a valid function",variant:"destructive"});return}if(s.constructor.name!=="AsyncFunction"){r({title:"AI completions method must be an asynchronous function",variant:"destructive"});return}n.state.AIMenu=!0,(u=e.editor)==null||u.commands.focus()}return(s,a)=>(i.openBlock(),i.createBlock(Ge,{action:o,title:"AI",disabled:s.disabled,icon:s.icon,tooltip:s.tooltip},null,8,["disabled","icon","tooltip"]))}}),bY=Bt.create({name:"AI",group:"block",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),toolbar:!1,button:({editor:e,t:n})=>({component:gY,componentProps:{icon:"Sparkles",tooltip:n("editor.AI.ask")}})}}});function vY(t,e){const n=atob(t.split(",")[1]),r=new Array(n.length);for(let s=0;s<n.length;s++)r[s]=n.charCodeAt(s);const o=new Uint8Array(r);return new Blob([o],{type:e})}function yY(t,e){return new File([t],e,{type:t.type})}const wY=Ne.create({name:"importWord",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),upload:void 0,convert:void 0,limit:1024*1024*10,button:({editor:e,extension:n,t:r})=>({component:Ge,componentProps:{action:()=>{var o;return(o=e.commands)==null?void 0:o.toggleImportWord()},disabled:!e.can().setHorizontalRule(),icon:"Word",tooltip:r("editor.importWord.tooltip")}})}},addCommands(){return{toggleImportWord:()=>({chain:t,editor:e})=>{const{toast:n}=Ob(),{t:r}=At();async function o(u){var g;const f=new DOMParser().parseFromString(u,"text/html"),p=f.querySelectorAll("img");if(!p.length)return f.body.innerHTML;if(A0(e,"image")){const b=(g=e.extensionManager.extensions.find(y=>y.name==="importWord"))==null?void 0:g.options;if(b&&typeof b.upload=="function"){const y=[];for(const x of p){const S=x.getAttribute("src"),C=vY(S,"image/jpeg"),E=yY(C,"image.jpeg");y.push(E)}const w=await b.upload(y);for(let x=0;x<p.length;x++){const S=p[x];S.setAttribute("src",w[x].src);const C=S.parentElement;(C==null?void 0:C.tagName)==="P"&&(C.insertAdjacentElement("beforebegin",S),!C.hasChildNodes()&&C.textContent===""&&C.remove())}return f.body.innerHTML}else return console.warn("Image Upload method found, skip image conversion"),f.body.innerHTML}else return console.error("Image extension not found, unable to convert image"),f.body.innerHTML}async function s(u){const c=await o(u);e.chain().setContent(c.toString(),!0).run(),n({title:r("editor.importWord.success")})}const{open:a,onChange:l}=at.useFileDialog({accept:".docx",reset:!0,multiple:!1});return a(),l(async u=>{const[c]=Array.from(u??[]);if(c){if(c.size>this.options.limit){n({title:r("editor.importWord.fileTooLarge"),variant:"destructive"});return}if(this.options.convert){const f=await this.options.convert(c);s(f)}else{const f=new FormData,p=JSON.stringify({collaboration_features:{comments:!0,user_id:"e3",track_changes:!0},formatting:{resets:"none",defaults:"inline",styles:"inline",comments:"basic"}});f.append("config",p),f.append("file",c),fetch("https://docx-converter.cke-cs.com/v2/convert/docx-html",{method:"POST",body:f}).then(m=>m.json()).then(async m=>{s(m.html)}).catch(m=>{n({title:r("editor.importWord.error"),variant:"destructive"}),console.error("Error:",m)})}}}),!1}}}}),Mb=vn(),xY=Ne.create({name:"preview",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button:({t:e})=>({component:Ge,componentProps:{icon:"Eye",action:()=>{Mb.togglePreview()},tooltip:e("editor.preview.tooltip"),isActive:()=>Mb.state.showPreview}})}},addCommands(){return{togglePreview:()=>()=>(Mb.togglePreview(),!0)}}}),nS=vn(),CY=(t,e,n)=>RegExp(e?t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):t,n?"gu":"gui");function EY(t,e,n,r){const o=[],s=[];let a=[],l=0;if(!e)return{decorationsToReturn:mt.empty,results:[]};t==null||t.descendants((u,c)=>{u.isText?a[l]?a[l]={text:a[l].text+u.text,pos:a[l].pos}:a[l]={text:`${u.text}`,pos:c}:l+=1}),a=a.filter(Boolean);for(const u of a){const{text:c,pos:f}=u,p=Array.from(c.matchAll(e)).filter(([m])=>m.trim());for(const m of p){if(m[0]==="")break;m.index!==void 0&&s.push({from:f+m.index,to:f+m.index+m[0].length})}}for(let u=0;u<s.length;u+=1){const c=s[u],f=u===r?`${n} ${n}-current`:n,p=Wt.inline(c.from,c.to,{class:f});o.push(p)}return{decorationsToReturn:mt.create(t,o),results:s}}const SY=(t,e,{state:n,dispatch:r})=>{if(!e[0])return;const{from:s,to:a}=e[0];r&&r(n.tr.insertText(t,s,a))},kY=(t,e,n,r)=>{const o=e+1;if(!r[o])return null;const{from:s,to:a}=r[e],l=a-s-t.length+n,{from:u,to:c}=r[o];return r[o]={to:c-l,from:u-l},[l,r]},_Y=(t,e,{tr:n,dispatch:r})=>{let o=0,s=e.slice();if(s.length){for(let a=0;a<s.length;a+=1){const{from:l,to:u}=s[a];n.insertText(t,l,u);const c=kY(t,a,o,s);c&&(o=c[0],s=c[1])}r&&r(n)}},TY=new St("findAndReplacePlugin"),AY=Ne.create({name:"findAndReplace",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),searchResultClass:"vdc-editor-search-result",disableRegex:!0,button:({editor:e,extension:n,t:r})=>({component:Ge,componentProps:{icon:"DocSearch",tooltip:r("editor.findAndReplace.tooltip"),action:()=>{nS.toggleFindAndReplace()},isActive:()=>nS.state.findAndReplace}})}},addStorage(){return{searchTerm:"",replaceTerm:"",results:[],lastSearchTerm:"",caseSensitive:!1,lastCaseSensitive:!1,resultIndex:0,lastResultIndex:0}},addCommands(){return{setSearchTerm:t=>({editor:e})=>(e.storage.findAndReplace.searchTerm=t,!1),setReplaceTerm:t=>({editor:e})=>(e.storage.findAndReplace.replaceTerm=t,!1),setCaseSensitive:t=>({editor:e})=>(e.storage.findAndReplace.caseSensitive=t,!1),resetIndex:()=>({editor:t})=>(t.storage.findAndReplace.resultIndex=0,!1),nextSearchResult:()=>({editor:t})=>{const{results:e,resultIndex:n}=t.storage.findAndReplace,r=n+1;return e[r]?t.storage.findAndReplace.resultIndex=r:t.storage.findAndReplace.resultIndex=0,!1},previousSearchResult:()=>({editor:t})=>{const{results:e,resultIndex:n}=t.storage.findAndReplace,r=n-1;return e[r]?t.storage.findAndReplace.resultIndex=r:t.storage.findAndReplace.resultIndex=e.length-1,!1},replace:()=>({editor:t,state:e,dispatch:n})=>{const{replaceTerm:r,results:o}=t.storage.findAndReplace;return SY(r,o,{state:e,dispatch:n}),!1},replaceAll:()=>({editor:t,tr:e,dispatch:n})=>{const{replaceTerm:r,results:o}=t.storage.findAndReplace;return _Y(r,o,{tr:e,dispatch:n}),!1}}},addProseMirrorPlugins(){const t=this.editor,{searchResultClass:e,disableRegex:n}=this.options,r=a=>t.storage.findAndReplace.lastSearchTerm=a,o=a=>t.storage.findAndReplace.lastCaseSensitive=a,s=a=>t.storage.findAndReplace.lastResultIndex=a;return[new tt({key:TY,state:{init:()=>mt.empty,apply({doc:a,docChanged:l},u){const{searchTerm:c,lastSearchTerm:f,caseSensitive:p,lastCaseSensitive:m,resultIndex:g,lastResultIndex:b}=t.storage.findAndReplace;if(!l&&f===c&&m===p&&b===g)return u;if(r(c),o(p),s(g),!c)return t.storage.findAndReplace.results=[],mt.empty;const{decorationsToReturn:y,results:w}=EY(a,CY(c,n,p),e,g);return t.storage.findAndReplace.results=w,y}},props:{decorations(a){return this.getState(a)}}})]}}),{togglePrinter:OY,state:MY}=vn(),BY=Ne.create({name:"printer",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button:({t:e})=>({component:Ge,componentProps:{tooltip:e("editor.printer.tooltip"),action:()=>OY(),icon:"Printer",shortcutKeys:["mod","P"],isActive:()=>MY.printer}})}}}),Bb="spell-check";class IY{constructor(e,n,r,o=1e3){Gt(this,"debouncedGetMatchAndSetDecorations",it.debounce(this.getMatchAndSetDecorations.bind(this),300));Gt(this,"debouncedGetMatchAndSetDecorationsList",it.debounce(this.getMatchAndSetDecorationsList.bind(this),300));Gt(this,"debouncedClickEventsListener",it.debounce(this.clickEventsListener.bind(this),0));Gt(this,"debouncedAcceptSuggestionEventsListener",it.debounce(this.acceptSuggestionListener.bind(this),0));Gt(this,"debouncedProofreadChangedNodes",it.debounce(this.proofreadChangedNodes.bind(this),300));Gt(this,"proofreader");Gt(this,"uiStrings");Gt(this,"showSuggestionsEvent");Gt(this,"decorationSet");Gt(this,"editorView");Gt(this,"isInitialProofreadingDone",!1);Gt(this,"lastOriginalFrom",0);Gt(this,"lastClickedDecoration",null);Gt(this,"suggestionBox");Gt(this,"isEnableSuggestion");Gt(this,"isMobile");Gt(this,"limit",1e3);Gt(this,"_debouncedProofreadDoc",it.debounce((e,n)=>{this.proofreadDoc(e),n&&n()},500));Gt(this,"_debouncedHandleEnterKey",it.debounce((e,n,r)=>{this.handleEnterKey(e,n),r&&r()},500));this.proofreader=e,this.uiStrings=n,this.showSuggestionsEvent=r,this.decorationSet=mt.empty,this.limit=o,this.suggestionBox=document.createElement("div"),this.suggestionBox.id="suggestions-box",this.suggestionBox.tabIndex=0,this.isEnableSuggestion=!0,this.isMobile=!1,this.hideSuggestionBox()}get completeProofreadingDone(){return this.isInitialProofreadingDone}getProofreader(){return this.proofreader}toggleIsEnabledSpellCheck(){this.proofreader.toggleIsEnabled()}setEnabledProofreadText(e){this.proofreader.setEnabled(e)}getIsEnabledSpellCheck(){return this.proofreader.getIsEnabled()}setDecorationSet(e){this.decorationSet=e}getDecorationSet(){return this.decorationSet}setEditorView(e){this.editorView=e}getEditorView(){return this.editorView}getSuggestionBox(){return this.suggestionBox}hideSuggestionBox(){this.suggestionBox.textContent="",this.suggestionBox.style.display="none"}setIsEnableSuggestion(e){if(this.isEnableSuggestion=e,this.isEnableSuggestion){this.addEventListenersToDecorations();return}this.hideSuggestionBox(),this.removeEventListenersFromDecorations()}setIsMobile(e){this.isMobile=e}getChangedNodesFromTransaction(e,n=!1,r=!1){const o=[],s=new Set;let a=!1;return e.steps.forEach(l=>{var p,m,g;const u=l;if(u.from===void 0||u.to===void 0||n&&u.structure)return;((m=(p=u.slice)==null?void 0:p.content[0])==null?void 0:m.type.name)===cc&&(a=!0);const c=u.from-(r?1:0);let f=Math.max(u.to,u.from+(((g=u.slice)==null?void 0:g.size)||0))-(r?1:0);f>e.doc.content.size&&(f=e.doc.content.size),e.doc.nodesBetween(c,f,(b,y)=>{b&&(b.isText&&!s.has(y)&&(o.push({node:b,pos:y}),s.add(y)),b.type.name===cc&&(a=!0))})}),{changedNodes:o,isChangedSuperText:a}}debouncedProofreadDoc(e,n){this._debouncedProofreadDoc(e,n)}isSuperTextAlone(e,n){let r=!1;return e.descendants((o,s,a)=>o===n?(a&&a.type.name==="paragraph"&&a.childCount===1&&a.firstChild===n&&(r=!0),!1):!0),r}proofreadDoc(e){let n=[],r=0;e==null||e.descendants((u,c)=>{if(u.isText){const f={text:u.text??"",from:c,to:c+u.nodeSize};return n[r]&&(f.text=n[r].text+f.text,f.from=n[r].from),n[r]=f,r+=1,!1}return u.type.name!==cc}),n=n.filter(Boolean);let o="",s=1;for(const{text:u,from:c,to:f}of n){const p=c-s;p>0&&(o+=Array(p+1).join(`
280
- `)),s=f,o+=u}const a=p4(o,this.limit),l=this.getMatchAndSetDecorationsList(a.map(u=>({text:u.text,originalFrom:u.offset+1})));this.editorView&&this.dispatch(this.editorView.state.tr.setMeta($n.LOADING_TRANSACTION,!0)),l.then(()=>{this.editorView&&this.dispatch(this.editorView.state.tr.setMeta($n.LOADING_TRANSACTION,!1))}),this.isInitialProofreadingDone=!0}async proofreadChangedNodes(e){const n=this.isMobile?1:2,o=e.reduce((s,a)=>{if(s.length===0)return s.push({changedNode:a,time:1}),s;const l=s[s.length-1];return a.pos===l.changedNode.pos+l.changedNode.node.nodeSize+n*l.time?(l.changedNode.node.text+=a.node.text,l.time+=1):s.push({changedNode:a,time:1}),s},[]).map(({changedNode:s})=>{var c;const a=((c=s.node)==null?void 0:c.textContent)||"",l=s.pos;return p4(a,this.limit).map(f=>({text:f.text,originalFrom:l+f.offset}))});this.debouncedGetMatchAndSetDecorationsList(o.flat())}async getMatchAndSetDecorationsList(e){const n=e.map(r=>this.getMatchAndSetDecorations(r.text,r.originalFrom));await Promise.all(n)}async getMatchAndSetDecorations(e,n){const r=await this.proofreader.proofreadText(this.proofreader.normalizeTextForLanguage(e)),o=[];for(const l of r){const u=l.startIndex+n,c=u+l.length,f=await this.proofreader.getSuggestions(l.wrongWord),p={length:l.length,wrongWord:l.wrongWord,suggestions:f};o.push(Wt.inline(u,c,{class:"spell-error",nodeName:"span",[Bb]:JSON.stringify(p)}))}const s=this.decorationSet.find(n,n+e.length);let a=this.decorationSet.remove(s);this.editorView&&(a=a.add(this.editorView.state.doc,o)),this.setDecorationSet(a),this.editorView&&this.dispatch(this.editorView.state.tr.setMeta($n.SPELLCHECKER_TRANSACTION,!0)),this.addEventListenersToDecorations()}removeEventListenersFromDecorations(){var r;const e=(r=this.editorView)==null?void 0:r.domAtPos(this.lastOriginalFrom).node,n=(e==null?void 0:e.querySelectorAll("span.spell-error"))||[];n.length&&n.forEach(o=>{o.removeEventListener("click",this.debouncedClickEventsListener)})}addEventListenersToDecorations(){var e;if(this.isEnableSuggestion)try{const n=(e=this.editorView)==null?void 0:e.domAtPos(this.lastOriginalFrom).node,r=(n==null?void 0:n.querySelectorAll("span.spell-error"))||[];if(!r.length)return;r.forEach(o=>{o.addEventListener("click",this.debouncedClickEventsListener)})}catch{}}addEventListenersToSuggestionBox(){const e=this.suggestionBox.querySelectorAll("li");e.length&&e.forEach(n=>{n.addEventListener("mousedown",this.debouncedAcceptSuggestionEventsListener)})}dispatch(e){this.editorView&&this.editorView.dispatch(e)}findChangedTextNodes(e,n,r,o){if(!e.isBlock)return!1;if(!e.isTextblock)return e.descendants((u,c)=>{this.findChangedTextNodes(u,c,r,o)}),!1;const[s,a]=[n,n+e.nodeSize];if(!(s<=r&&o<=a))return;const l={node:e,pos:n};this.onNodeChanged(l.node.textContent,l.pos+1)}onNodeChanged(e,n){n!==this.lastOriginalFrom?this.getMatchAndSetDecorations(e,n):this.debouncedGetMatchAndSetDecorations(e,n),this.lastOriginalFrom=n}async clickEventsListener(e){var c,f;if(!e.target)return;let n=e.target;for(;n&&!n.classList.contains("spell-error");)n=n.parentElement;if(!n||!n.classList.contains("spell-error"))return;this.lastClickedDecoration=n;const r=(c=n.getAttribute(Bb))==null?void 0:c.trim();if(!r){console.error("No match string provided",{spellCheckerAttributes:r});return}const{length:o,wrongWord:s,suggestions:a}=JSON.parse(r),l=((f=this.editorView)==null?void 0:f.posAtDOM(n,0))??0,u=l+o;if(this.editorView){this.addSuggestionsList(a,l,u),this.suggestionBox.style.display="";const p=BK(n);if(!p)return;const m=n.getBoundingClientRect(),g=p.getBoundingClientRect(),b=window.getComputedStyle(p).padding,y=m.left-g.left+3-parseInt(b),w=m.top-g.top+30-parseInt(b);this.suggestionBox.style.left=y+"px",this.suggestionBox.style.top=w+"px",this.showSuggestionsEvent&&this.showSuggestionsEvent(this.proofreader.normalizeTextForLanguage(s))}return this.addEventListenersToSuggestionBox(),!1}acceptSuggestionListener(e){var s;if(!e||!e.target)return;e.preventDefault(),e.stopPropagation();const n=e.target;let r=0,o=0;if(this.lastClickedDecoration&&this.editorView){const a=(s=this.lastClickedDecoration.getAttribute(Bb))==null?void 0:s.trim();if(a){const{length:l}=JSON.parse(a);r=this.editorView.posAtDOM(this.lastClickedDecoration,0),o=r+l}}this.editorView&&r>=0&&o>r&&(this.dispatch(this.editorView.state.tr.setMeta($n.ACCEPT_SUGGESTION,!0)),this.dispatch(this.editorView.state.tr.insertText(n.textContent||"",r,o))),this.hideSuggestionBox(),this.lastClickedDecoration&&(this.lastClickedDecoration.removeEventListener("click",this.debouncedClickEventsListener),this.lastClickedDecoration=null)}addSuggestionsList(e,n,r){if(this.suggestionBox.textContent="",e.length>0){const o=document.createElement("ul");o.className="suggestion-list",e.forEach(s=>{const a=document.createElement("li");a.innerText=s,a.dataset.from=n+"",a.dataset.to=r+"",o.appendChild(a)}),this.suggestionBox.appendChild(o)}if(e.length===0){const o=document.createElement("b"),s=this.uiStrings&&this.uiStrings.noSuggestions?this.uiStrings.noSuggestions:"No suggestions found";o.textContent=s,this.suggestionBox.appendChild(o)}}isUndoRedo(e,n){return e.getMeta(R8.ADD_TO_HISTORY_TRANSACTION)===!1||e.getMeta($n.APPENDED)===!0||n.isUndoRedoOperation}handleUndoRedo(e,n){var s;const r=(s=e.getMeta(R8.HISTORY_TRANSACTION))==null?void 0:s.redo;if(n.isUndoRedoOperation=!1,r)return this.debouncedProofreadDoc(e.doc),this.getDecorationSet();const{changedNodes:o}=this.getChangedNodesFromTransaction(e,!0);return o.length===0?this.getDecorationSet():o.length===1?(this.debouncedProofreadChangedNodes(o),this.getDecorationSet()):(this.debouncedProofreadDoc(e.doc),this.getDecorationSet())}isTextContentChangedOrDeleted(e){let n=!1;return{isTextContentChanged:e.steps.some(o=>{var a,l;const s=(a=o.toJSON)==null?void 0:a.call(o);return(s==null?void 0:s.stepType)==="replace"&&((l=s==null?void 0:s.slice)!=null&&l.content)?s.slice.content.some(u=>u.type==="paragraph"&&u.content&&u.content.length>0):(s==null?void 0:s.stepType)==="replace"&&(!s.slice||!s.slice.content||s.slice.content.length===0)?(n=!0,s.from!==s.to):!1}),isDeleteAction:n}}handleEnterKey(e,n){if(n)return this.debouncedProofreadDoc(e.doc),this.getDecorationSet();const r=e.getMeta($n.APPENDED_TRANSACTION);if(!r)return this.getDecorationSet();const s=r.steps[0].to,a=r.before.nodeAt(s-1);if(!(a!=null&&a.isText))return this.getDecorationSet();let l=0;return r.before.descendants((c,f)=>{c.textContent===(a==null?void 0:a.textContent)&&(l=f)}),l+((a==null?void 0:a.nodeSize)||0)===s?this.getDecorationSet():(this.debouncedProofreadDoc(e.doc),this.getDecorationSet())}handleEnterKeyDebounced(e,n,r){this._debouncedHandleEnterKey(e,n,r)}}const rS=vn(),$n={SPELLCHECKER_TRANSACTION:"spellcheckerTransaction",IS_ACTIVE_SPELLCHECK:"isActiveSpellCheck",LOADING_TRANSACTION:"loading",PREVENT_UPDATE:"preventUpdate",APPENDED:"appended",APPENDED_TRANSACTION:"appendedTransaction",ACCEPT_SUGGESTION:"acceptSuggestion",SKIP_SPELLCHECK:"skipSpellcheck",UI_EVENT:"uiEvent"},RY={DROP:"drop"},oS=Ne.create({name:"spellchecker",addOptions(){return{proofreader:void 0,uiStrings:{noSuggestions:""},button:({editor:t,t:e,isMobile:n})=>({component:Ge,componentProps:{action:()=>t.commands.handleActiveSpellCheck(),isActive:()=>{var r,o,s,a;return((a=(s=(o=(r=t==null?void 0:t.extensionStorage)==null?void 0:r.spellchecker)==null?void 0:o.spellchecker)==null?void 0:s.proofreader)==null?void 0:a.enabled)||!1},icon:"SpellCheck",tooltip:"맞춤법 검사",title:n?e("editor.menubar.menu.spelling"):""}})}},addStorage(){return{didPaste:!1,spellchecker:void 0,isUndoRedoOperation:!1,pendingSpellCheck:!1,enterKeyPressed:!1}},addCommands(){return{checkSpelling:()=>({tr:t})=>(this.storage.spellchecker.proofreadDoc(t.doc),!0),selectAll:()=>({state:t,dispatch:e})=>(t9(t,e),!0),copy:()=>()=>(document.execCommand("copy"),!0),handleActiveSpellCheck:(t=!0)=>({editor:e})=>{const n=e.extensionStorage.spellchecker.spellchecker;return n.toggleIsEnabledSpellCheck(),e.view.dispatch(e.state.tr.setMeta($n.IS_ACTIVE_SPELLCHECK,n.getIsEnabledSpellCheck())),t&&rS.setSpellCheck(n.getIsEnabledSpellCheck()),!0},setIsEnableSuggestion:t=>()=>(this.storage.spellchecker.setIsEnableSuggestion(t),!0)}},addProseMirrorPlugins(){return[new tt({key:new St("skipMarkPlugin"),view:e=>{const n=e.dispatch;return e.dispatch=r=>(r.steps.some(s=>s instanceof jo||s instanceof Zr)&&r.setMeta($n.SKIP_SPELLCHECK,!0),n.call(e,r)),{}}}),new tt({key:new St("spellcheckerPlugin"),props:{decorations(e){return this.getState(e)},handlePaste:()=>{this.storage.didPaste=!0},handleClick:()=>{this.storage.spellchecker.hideSuggestionBox()},handleKeyDown:(e,n)=>((n.ctrlKey||n.metaKey)&&(n.key==="z"||n.key==="y")&&(this.storage.isUndoRedoOperation=!0,this.storage.pendingSpellCheck=!0),this.storage.enterKeyPressed&&(this.storage.pendingSpellCheck=!0),n.key==="Enter"&&(this.storage.enterKeyPressed=!0),!1)},state:{init:(e,n)=>{var o,s;const r=new IY(this.options.proofreader,this.options.uiStrings,this.options.onShowSuggestionsEvent,(o=this.options.proofreader)==null?void 0:o.limit);return this.storage.spellchecker=r,r.setDecorationSet(mt.create(n.doc,[])),rS.setSpellCheck(r.getIsEnabledSpellCheck()),(s=this.options.proofreader)!=null&&s.enabled&&r.proofreadDoc(n.doc),r.getDecorationSet()},apply:(e,n)=>{var s;if(e.getMeta($n.SKIP_SPELLCHECK))return n;const r=this.storage.spellchecker,o=e.getMeta($n.IS_ACTIVE_SPELLCHECK);if(o!==void 0)return o?r.proofreadDoc(e.doc):r.setDecorationSet(mt.empty),r.getDecorationSet();if(e.getMeta($n.SPELLCHECKER_TRANSACTION))return r.getDecorationSet();if(e.docChanged&&e.doc.nodeSize){const l=r.getDecorationSet().map(e.mapping,e.doc);if(r.setDecorationSet(l),e.getMeta($n.UI_EVENT)===RY.DROP)return r.debouncedProofreadDoc(e.doc),r.getDecorationSet();if(r.isUndoRedo(e,this.storage))return r.handleUndoRedo(e,this.storage);const{isTextContentChanged:u,isDeleteAction:c}=r.isTextContentChangedOrDeleted(e);if(c){const{changedNodes:g}=r.getChangedNodesFromTransaction(e,!1,!0);return g.length>0&&r.debouncedProofreadChangedNodes([g[0]]),r.getDecorationSet()}if(this.storage.enterKeyPressed)return r.handleEnterKeyDebounced(e,this.storage.pendingSpellCheck,()=>{this.storage.enterKeyPressed=!1,this.storage.pendingSpellCheck=!1}),r.getDecorationSet();if(this.storage.pendingSpellCheck||u)return r.debouncedProofreadDoc(e.doc,()=>{this.storage.pendingSpellCheck=!1}),r.getDecorationSet();if(e.getMeta(xE.UPDATE)||e.updated===0&&((s=e.steps[0])==null?void 0:s.structure)===!0)return r.getDecorationSet();if(e.getMeta($n.PREVENT_UPDATE)===!0&&e.before.textContent.length===0)return r.debouncedProofreadDoc(e.doc),r.getDecorationSet();this.storage.didPaste&&(this.storage.didPaste=!1);const{changedNodes:p,isChangedSuperText:m}=r.getChangedNodesFromTransaction(e);if(m)return r.debouncedProofreadDoc(e.doc),r.getDecorationSet();p.length>0&&r.debouncedProofreadChangedNodes(p)}return r.getDecorationSet()}},view:()=>({update:e=>{var r,o;const n=this.storage.spellchecker;n.setEditorView(e),(o=(r=e==null?void 0:e.dom)==null?void 0:r.parentNode)==null||o.appendChild(n.getSuggestionBox())}})})]}});function iS(t,e){return function(){return t.apply(e,arguments)}}const{toString:LY}=Object.prototype,{getPrototypeOf:Ib}=Object,zp=(t=>e=>{const n=LY.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),fo=t=>(t=t.toLowerCase(),e=>zp(e)===t),Hp=t=>e=>typeof e===t,{isArray:_l}=Array,pc=Hp("undefined");function PY(t){return t!==null&&!pc(t)&&t.constructor!==null&&!pc(t.constructor)&&wr(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const sS=fo("ArrayBuffer");function DY(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&sS(t.buffer),e}const VY=Hp("string"),wr=Hp("function"),aS=Hp("number"),Up=t=>t!==null&&typeof t=="object",FY=t=>t===!0||t===!1,Wp=t=>{if(zp(t)!=="object")return!1;const e=Ib(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},$Y=fo("Date"),zY=fo("File"),HY=fo("Blob"),UY=fo("FileList"),WY=t=>Up(t)&&wr(t.pipe),jY=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||wr(t.append)&&((e=zp(t))==="formdata"||e==="object"&&wr(t.toString)&&t.toString()==="[object FormData]"))},qY=fo("URLSearchParams"),[KY,GY,XY,YY]=["ReadableStream","Request","Response","Headers"].map(fo),JY=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function hc(t,e,{allOwnKeys:n=!1}={}){if(t===null||typeof t>"u")return;let r,o;if(typeof t!="object"&&(t=[t]),_l(t))for(r=0,o=t.length;r<o;r++)e.call(null,t[r],r,t);else{const s=n?Object.getOwnPropertyNames(t):Object.keys(t),a=s.length;let l;for(r=0;r<a;r++)l=s[r],e.call(null,t[l],l,t)}}function lS(t,e){e=e.toLowerCase();const n=Object.keys(t);let r=n.length,o;for(;r-- >0;)if(o=n[r],e===o.toLowerCase())return o;return null}const da=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,uS=t=>!pc(t)&&t!==da;function Rb(){const{caseless:t}=uS(this)&&this||{},e={},n=(r,o)=>{const s=t&&lS(e,o)||o;Wp(e[s])&&Wp(r)?e[s]=Rb(e[s],r):Wp(r)?e[s]=Rb({},r):_l(r)?e[s]=r.slice():e[s]=r};for(let r=0,o=arguments.length;r<o;r++)arguments[r]&&hc(arguments[r],n);return e}const ZY=(t,e,n,{allOwnKeys:r}={})=>(hc(e,(o,s)=>{n&&wr(o)?t[s]=iS(o,n):t[s]=o},{allOwnKeys:r}),t),QY=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),NY=(t,e,n,r)=>{t.prototype=Object.create(e.prototype,r),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),n&&Object.assign(t.prototype,n)},eJ=(t,e,n,r)=>{let o,s,a;const l={};if(e=e||{},t==null)return e;do{for(o=Object.getOwnPropertyNames(t),s=o.length;s-- >0;)a=o[s],(!r||r(a,t,e))&&!l[a]&&(e[a]=t[a],l[a]=!0);t=n!==!1&&Ib(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},tJ=(t,e,n)=>{t=String(t),(n===void 0||n>t.length)&&(n=t.length),n-=e.length;const r=t.indexOf(e,n);return r!==-1&&r===n},nJ=t=>{if(!t)return null;if(_l(t))return t;let e=t.length;if(!aS(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},rJ=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&Ib(Uint8Array)),oJ=(t,e)=>{const r=(t&&t[Symbol.iterator]).call(t);let o;for(;(o=r.next())&&!o.done;){const s=o.value;e.call(t,s[0],s[1])}},iJ=(t,e)=>{let n;const r=[];for(;(n=t.exec(e))!==null;)r.push(n);return r},sJ=fo("HTMLFormElement"),aJ=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),cS=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),lJ=fo("RegExp"),dS=(t,e)=>{const n=Object.getOwnPropertyDescriptors(t),r={};hc(n,(o,s)=>{let a;(a=e(o,s,t))!==!1&&(r[s]=a||o)}),Object.defineProperties(t,r)},uJ=t=>{dS(t,(e,n)=>{if(wr(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=t[n];if(wr(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},cJ=(t,e)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return _l(t)?r(t):r(String(t).split(e)),n},dJ=()=>{},fJ=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function pJ(t){return!!(t&&wr(t.append)&&t[Symbol.toStringTag]==="FormData"&&t[Symbol.iterator])}const hJ=t=>{const e=new Array(10),n=(r,o)=>{if(Up(r)){if(e.indexOf(r)>=0)return;if(!("toJSON"in r)){e[o]=r;const s=_l(r)?[]:{};return hc(r,(a,l)=>{const u=n(a,o+1);!pc(u)&&(s[l]=u)}),e[o]=void 0,s}}return r};return n(t,0)},mJ=fo("AsyncFunction"),gJ=t=>t&&(Up(t)||wr(t))&&wr(t.then)&&wr(t.catch),fS=((t,e)=>t?setImmediate:e?((n,r)=>(da.addEventListener("message",({source:o,data:s})=>{o===da&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),da.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",wr(da.postMessage)),bJ=typeof queueMicrotask<"u"?queueMicrotask.bind(da):typeof process<"u"&&process.nextTick||fS,re={isArray:_l,isArrayBuffer:sS,isBuffer:PY,isFormData:jY,isArrayBufferView:DY,isString:VY,isNumber:aS,isBoolean:FY,isObject:Up,isPlainObject:Wp,isReadableStream:KY,isRequest:GY,isResponse:XY,isHeaders:YY,isUndefined:pc,isDate:$Y,isFile:zY,isBlob:HY,isRegExp:lJ,isFunction:wr,isStream:WY,isURLSearchParams:qY,isTypedArray:rJ,isFileList:UY,forEach:hc,merge:Rb,extend:ZY,trim:JY,stripBOM:QY,inherits:NY,toFlatObject:eJ,kindOf:zp,kindOfTest:fo,endsWith:tJ,toArray:nJ,forEachEntry:oJ,matchAll:iJ,isHTMLForm:sJ,hasOwnProperty:cS,hasOwnProp:cS,reduceDescriptors:dS,freezeMethods:uJ,toObjectSet:cJ,toCamelCase:aJ,noop:dJ,toFiniteNumber:fJ,findKey:lS,global:da,isContextDefined:uS,isSpecCompliantForm:pJ,toJSONObject:hJ,isAsyncFn:mJ,isThenable:gJ,setImmediate:fS,asap:bJ};function st(t,e,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}re.inherits(st,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:re.toJSONObject(this.config),code:this.code,status:this.status}}});const pS=st.prototype,hS={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{hS[t]={value:t}}),Object.defineProperties(st,hS),Object.defineProperty(pS,"isAxiosError",{value:!0}),st.from=(t,e,n,r,o,s)=>{const a=Object.create(pS);return re.toFlatObject(t,a,function(u){return u!==Error.prototype},l=>l!=="isAxiosError"),st.call(a,t.message,e,n,r,o),a.cause=t,a.name=t.name,s&&Object.assign(a,s),a};const vJ=null;function Lb(t){return re.isPlainObject(t)||re.isArray(t)}function mS(t){return re.endsWith(t,"[]")?t.slice(0,-2):t}function gS(t,e,n){return t?t.concat(e).map(function(o,s){return o=mS(o),!n&&s?"["+o+"]":o}).join(n?".":""):e}function yJ(t){return re.isArray(t)&&!t.some(Lb)}const wJ=re.toFlatObject(re,{},null,function(e){return/^is[A-Z]/.test(e)});function jp(t,e,n){if(!re.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,n=re.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,w){return!re.isUndefined(w[y])});const r=n.metaTokens,o=n.visitor||f,s=n.dots,a=n.indexes,u=(n.Blob||typeof Blob<"u"&&Blob)&&re.isSpecCompliantForm(e);if(!re.isFunction(o))throw new TypeError("visitor must be a function");function c(b){if(b===null)return"";if(re.isDate(b))return b.toISOString();if(!u&&re.isBlob(b))throw new st("Blob is not supported. Use a Buffer instead.");return re.isArrayBuffer(b)||re.isTypedArray(b)?u&&typeof Blob=="function"?new Blob([b]):Buffer.from(b):b}function f(b,y,w){let x=b;if(b&&!w&&typeof b=="object"){if(re.endsWith(y,"{}"))y=r?y:y.slice(0,-2),b=JSON.stringify(b);else if(re.isArray(b)&&yJ(b)||(re.isFileList(b)||re.endsWith(y,"[]"))&&(x=re.toArray(b)))return y=mS(y),x.forEach(function(C,E){!(re.isUndefined(C)||C===null)&&e.append(a===!0?gS([y],E,s):a===null?y:y+"[]",c(C))}),!1}return Lb(b)?!0:(e.append(gS(w,y,s),c(b)),!1)}const p=[],m=Object.assign(wJ,{defaultVisitor:f,convertValue:c,isVisitable:Lb});function g(b,y){if(!re.isUndefined(b)){if(p.indexOf(b)!==-1)throw Error("Circular reference detected in "+y.join("."));p.push(b),re.forEach(b,function(x,S){(!(re.isUndefined(x)||x===null)&&o.call(e,x,re.isString(S)?S.trim():S,y,m))===!0&&g(x,y?y.concat(S):[S])}),p.pop()}}if(!re.isObject(t))throw new TypeError("data must be an object");return g(t),e}function bS(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function Pb(t,e){this._pairs=[],t&&jp(t,this,e)}const vS=Pb.prototype;vS.append=function(e,n){this._pairs.push([e,n])},vS.toString=function(e){const n=e?function(r){return e.call(this,r,bS)}:bS;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function xJ(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function yS(t,e,n){if(!e)return t;const r=n&&n.encode||xJ;re.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(e,n):s=re.isURLSearchParams(e)?e.toString():new Pb(e,n).toString(r),s){const a=t.indexOf("#");a!==-1&&(t=t.slice(0,a)),t+=(t.indexOf("?")===-1?"?":"&")+s}return t}class wS{constructor(){this.handlers=[]}use(e,n,r){return this.handlers.push({fulfilled:e,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){re.forEach(this.handlers,function(r){r!==null&&e(r)})}}const xS={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},CJ={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Pb,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Db=typeof window<"u"&&typeof document<"u",Vb=typeof navigator=="object"&&navigator||void 0,EJ=Db&&(!Vb||["ReactNative","NativeScript","NS"].indexOf(Vb.product)<0),SJ=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",kJ=Db&&window.location.href||"http://localhost",zn={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Db,hasStandardBrowserEnv:EJ,hasStandardBrowserWebWorkerEnv:SJ,navigator:Vb,origin:kJ},Symbol.toStringTag,{value:"Module"})),...CJ};function _J(t,e){return jp(t,new zn.classes.URLSearchParams,Object.assign({visitor:function(n,r,o,s){return zn.isNode&&re.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)}},e))}function TJ(t){return re.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function AJ(t){const e={},n=Object.keys(t);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],e[s]=t[s];return e}function CS(t){function e(n,r,o,s){let a=n[s++];if(a==="__proto__")return!0;const l=Number.isFinite(+a),u=s>=n.length;return a=!a&&re.isArray(o)?o.length:a,u?(re.hasOwnProp(o,a)?o[a]=[o[a],r]:o[a]=r,!l):((!o[a]||!re.isObject(o[a]))&&(o[a]=[]),e(n,r,o[a],s)&&re.isArray(o[a])&&(o[a]=AJ(o[a])),!l)}if(re.isFormData(t)&&re.isFunction(t.entries)){const n={};return re.forEachEntry(t,(r,o)=>{e(TJ(r),o,n,0)}),n}return null}function OJ(t,e,n){if(re.isString(t))try{return(e||JSON.parse)(t),re.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(t)}const mc={transitional:xS,adapter:["xhr","http","fetch"],transformRequest:[function(e,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=re.isObject(e);if(s&&re.isHTMLForm(e)&&(e=new FormData(e)),re.isFormData(e))return o?JSON.stringify(CS(e)):e;if(re.isArrayBuffer(e)||re.isBuffer(e)||re.isStream(e)||re.isFile(e)||re.isBlob(e)||re.isReadableStream(e))return e;if(re.isArrayBufferView(e))return e.buffer;if(re.isURLSearchParams(e))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let l;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return _J(e,this.formSerializer).toString();if((l=re.isFileList(e))||r.indexOf("multipart/form-data")>-1){const u=this.env&&this.env.FormData;return jp(l?{"files[]":e}:e,u&&new u,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),OJ(e)):e}],transformResponse:[function(e){const n=this.transitional||mc.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(re.isResponse(e)||re.isReadableStream(e))return e;if(e&&re.isString(e)&&(r&&!this.responseType||o)){const a=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(e)}catch(l){if(a)throw l.name==="SyntaxError"?st.from(l,st.ERR_BAD_RESPONSE,this,null,this.response):l}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:zn.classes.FormData,Blob:zn.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};re.forEach(["delete","get","head","post","put","patch"],t=>{mc.headers[t]={}});const MJ=re.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),BJ=t=>{const e={};let n,r,o;return t&&t.split(`
280
+ `)),s=f,o+=u}const a=p4(o,this.limit),l=this.getMatchAndSetDecorationsList(a.map(u=>({text:u.text,originalFrom:u.offset+1})));this.editorView&&this.dispatch(this.editorView.state.tr.setMeta($n.LOADING_TRANSACTION,!0)),l.then(()=>{this.editorView&&this.dispatch(this.editorView.state.tr.setMeta($n.LOADING_TRANSACTION,!1))}),this.isInitialProofreadingDone=!0}async proofreadChangedNodes(e){const n=this.isMobile?1:2,o=e.reduce((s,a)=>{if(s.length===0)return s.push({changedNode:a,time:1}),s;const l=s[s.length-1];return a.pos===l.changedNode.pos+l.changedNode.node.nodeSize+n*(l.time-1)?(l.changedNode.node.text+=a.node.text,l.time+=1):s.push({changedNode:a,time:1}),s},[]).map(({changedNode:s})=>{var c;const a=((c=s.node)==null?void 0:c.textContent)||"",l=s.pos;return p4(a,this.limit).map(f=>({text:f.text,originalFrom:l+f.offset}))});this.debouncedGetMatchAndSetDecorationsList(o.flat())}async getMatchAndSetDecorationsList(e){const n=e.map(r=>this.getMatchAndSetDecorations(r.text,r.originalFrom));await Promise.all(n)}async getMatchAndSetDecorations(e,n){const r=await this.proofreader.proofreadText(this.proofreader.normalizeTextForLanguage(e)),o=[];for(const l of r){const u=l.startIndex+n,c=u+l.length,f=await this.proofreader.getSuggestions(l.wrongWord),p={length:l.length,wrongWord:l.wrongWord,suggestions:f};o.push(Wt.inline(u,c,{class:"spell-error",nodeName:"span",[Bb]:JSON.stringify(p)}))}const s=this.decorationSet.find(n,n+e.length);let a=this.decorationSet.remove(s);this.editorView&&(a=a.add(this.editorView.state.doc,o)),this.setDecorationSet(a),this.editorView&&this.dispatch(this.editorView.state.tr.setMeta($n.SPELLCHECKER_TRANSACTION,!0)),this.addEventListenersToDecorations()}removeEventListenersFromDecorations(){var r;const e=(r=this.editorView)==null?void 0:r.domAtPos(this.lastOriginalFrom).node,n=(e==null?void 0:e.querySelectorAll("span.spell-error"))||[];n.length&&n.forEach(o=>{o.removeEventListener("click",this.debouncedClickEventsListener)})}addEventListenersToDecorations(){var e;if(this.isEnableSuggestion)try{const n=(e=this.editorView)==null?void 0:e.domAtPos(this.lastOriginalFrom).node,r=(n==null?void 0:n.querySelectorAll("span.spell-error"))||[];if(!r.length)return;r.forEach(o=>{o.addEventListener("click",this.debouncedClickEventsListener)})}catch{}}addEventListenersToSuggestionBox(){const e=this.suggestionBox.querySelectorAll("li");e.length&&e.forEach(n=>{n.addEventListener("mousedown",this.debouncedAcceptSuggestionEventsListener)})}dispatch(e){this.editorView&&this.editorView.dispatch(e)}findChangedTextNodes(e,n,r,o){if(!e.isBlock)return!1;if(!e.isTextblock)return e.descendants((u,c)=>{this.findChangedTextNodes(u,c,r,o)}),!1;const[s,a]=[n,n+e.nodeSize];if(!(s<=r&&o<=a))return;const l={node:e,pos:n};this.onNodeChanged(l.node.textContent,l.pos+1)}onNodeChanged(e,n){n!==this.lastOriginalFrom?this.getMatchAndSetDecorations(e,n):this.debouncedGetMatchAndSetDecorations(e,n),this.lastOriginalFrom=n}async clickEventsListener(e){var c,f;if(!e.target)return;let n=e.target;for(;n&&!n.classList.contains("spell-error");)n=n.parentElement;if(!n||!n.classList.contains("spell-error"))return;this.lastClickedDecoration=n;const r=(c=n.getAttribute(Bb))==null?void 0:c.trim();if(!r){console.error("No match string provided",{spellCheckerAttributes:r});return}const{length:o,wrongWord:s,suggestions:a}=JSON.parse(r),l=((f=this.editorView)==null?void 0:f.posAtDOM(n,0))??0,u=l+o;if(this.editorView){this.addSuggestionsList(a,l,u),this.suggestionBox.style.display="";const p=BK(n);if(!p)return;const m=n.getBoundingClientRect(),g=p.getBoundingClientRect(),b=window.getComputedStyle(p).padding,y=m.left-g.left+3-parseInt(b),w=m.top-g.top+30-parseInt(b);this.suggestionBox.style.left=y+"px",this.suggestionBox.style.top=w+"px",this.showSuggestionsEvent&&this.showSuggestionsEvent(this.proofreader.normalizeTextForLanguage(s))}return this.addEventListenersToSuggestionBox(),!1}acceptSuggestionListener(e){var s;if(!e||!e.target)return;e.preventDefault(),e.stopPropagation();const n=e.target;let r=0,o=0;if(this.lastClickedDecoration&&this.editorView){const a=(s=this.lastClickedDecoration.getAttribute(Bb))==null?void 0:s.trim();if(a){const{length:l}=JSON.parse(a);r=this.editorView.posAtDOM(this.lastClickedDecoration,0),o=r+l}}this.editorView&&r>=0&&o>r&&(this.dispatch(this.editorView.state.tr.setMeta($n.ACCEPT_SUGGESTION,!0)),this.dispatch(this.editorView.state.tr.insertText(n.textContent||"",r,o))),this.hideSuggestionBox(),this.lastClickedDecoration&&(this.lastClickedDecoration.removeEventListener("click",this.debouncedClickEventsListener),this.lastClickedDecoration=null)}addSuggestionsList(e,n,r){if(this.suggestionBox.textContent="",e.length>0){const o=document.createElement("ul");o.className="suggestion-list",e.forEach(s=>{const a=document.createElement("li");a.innerText=s,a.dataset.from=n+"",a.dataset.to=r+"",o.appendChild(a)}),this.suggestionBox.appendChild(o)}if(e.length===0){const o=document.createElement("b"),s=this.uiStrings&&this.uiStrings.noSuggestions?this.uiStrings.noSuggestions:"No suggestions found";o.textContent=s,this.suggestionBox.appendChild(o)}}isUndoRedo(e,n){return e.getMeta(R8.ADD_TO_HISTORY_TRANSACTION)===!1||e.getMeta($n.APPENDED)===!0||n.isUndoRedoOperation}handleUndoRedo(e,n){var s;const r=(s=e.getMeta(R8.HISTORY_TRANSACTION))==null?void 0:s.redo;if(n.isUndoRedoOperation=!1,r)return this.debouncedProofreadDoc(e.doc),this.getDecorationSet();const{changedNodes:o}=this.getChangedNodesFromTransaction(e,!0);return o.length===0?this.getDecorationSet():o.length===1?(this.debouncedProofreadChangedNodes(o),this.getDecorationSet()):(this.debouncedProofreadDoc(e.doc),this.getDecorationSet())}isTextContentChangedOrDeleted(e){let n=!1;return{isTextContentChanged:e.steps.some(o=>{var a,l;const s=(a=o.toJSON)==null?void 0:a.call(o);return(s==null?void 0:s.stepType)==="replace"&&((l=s==null?void 0:s.slice)!=null&&l.content)?s.slice.content.some(u=>u.type==="paragraph"&&u.content&&u.content.length>0):(s==null?void 0:s.stepType)==="replace"&&(!s.slice||!s.slice.content||s.slice.content.length===0)?(n=!0,s.from!==s.to):!1}),isDeleteAction:n}}handleEnterKey(e,n){if(n)return this.debouncedProofreadDoc(e.doc),this.getDecorationSet();const r=e.getMeta($n.APPENDED_TRANSACTION);if(!r)return this.getDecorationSet();const s=r.steps[0].to,a=r.before.nodeAt(s-1);if(!(a!=null&&a.isText))return this.getDecorationSet();let l=0;return r.before.descendants((c,f)=>{c.textContent===(a==null?void 0:a.textContent)&&(l=f)}),l+((a==null?void 0:a.nodeSize)||0)===s?this.getDecorationSet():(this.debouncedProofreadDoc(e.doc),this.getDecorationSet())}handleEnterKeyDebounced(e,n,r){this._debouncedHandleEnterKey(e,n,r)}}const rS=vn(),$n={SPELLCHECKER_TRANSACTION:"spellcheckerTransaction",IS_ACTIVE_SPELLCHECK:"isActiveSpellCheck",LOADING_TRANSACTION:"loading",PREVENT_UPDATE:"preventUpdate",APPENDED:"appended",APPENDED_TRANSACTION:"appendedTransaction",ACCEPT_SUGGESTION:"acceptSuggestion",SKIP_SPELLCHECK:"skipSpellcheck",UI_EVENT:"uiEvent"},RY={DROP:"drop"},oS=Ne.create({name:"spellchecker",addOptions(){return{proofreader:void 0,uiStrings:{noSuggestions:""},button:({editor:t,t:e,isMobile:n})=>({component:Ge,componentProps:{action:()=>t.commands.handleActiveSpellCheck(),isActive:()=>{var r,o,s,a;return((a=(s=(o=(r=t==null?void 0:t.extensionStorage)==null?void 0:r.spellchecker)==null?void 0:o.spellchecker)==null?void 0:s.proofreader)==null?void 0:a.enabled)||!1},icon:"SpellCheck",tooltip:"맞춤법 검사",title:n?e("editor.menubar.menu.spelling"):""}})}},addStorage(){return{didPaste:!1,spellchecker:void 0,isUndoRedoOperation:!1,pendingSpellCheck:!1,enterKeyPressed:!1}},addCommands(){return{checkSpelling:()=>({tr:t})=>(this.storage.spellchecker.proofreadDoc(t.doc),!0),selectAll:()=>({state:t,dispatch:e})=>(t9(t,e),!0),copy:()=>()=>(document.execCommand("copy"),!0),handleActiveSpellCheck:(t=!0)=>({editor:e})=>{const n=e.extensionStorage.spellchecker.spellchecker;return n.toggleIsEnabledSpellCheck(),e.view.dispatch(e.state.tr.setMeta($n.IS_ACTIVE_SPELLCHECK,n.getIsEnabledSpellCheck())),t&&rS.setSpellCheck(n.getIsEnabledSpellCheck()),!0},setIsEnableSuggestion:t=>()=>(this.storage.spellchecker.setIsEnableSuggestion(t),!0)}},addProseMirrorPlugins(){return[new tt({key:new St("skipMarkPlugin"),view:e=>{const n=e.dispatch;return e.dispatch=r=>(r.steps.some(s=>s instanceof jo||s instanceof Zr)&&r.setMeta($n.SKIP_SPELLCHECK,!0),n.call(e,r)),{}}}),new tt({key:new St("spellcheckerPlugin"),props:{decorations(e){return this.getState(e)},handlePaste:()=>{this.storage.didPaste=!0},handleClick:()=>{this.storage.spellchecker.hideSuggestionBox()},handleKeyDown:(e,n)=>((n.ctrlKey||n.metaKey)&&(n.key==="z"||n.key==="y")&&(this.storage.isUndoRedoOperation=!0,this.storage.pendingSpellCheck=!0),this.storage.enterKeyPressed&&(this.storage.pendingSpellCheck=!0),n.key==="Enter"&&(this.storage.enterKeyPressed=!0),!1)},state:{init:(e,n)=>{var o,s;const r=new IY(this.options.proofreader,this.options.uiStrings,this.options.onShowSuggestionsEvent,(o=this.options.proofreader)==null?void 0:o.limit);return this.storage.spellchecker=r,r.setDecorationSet(mt.create(n.doc,[])),rS.setSpellCheck(r.getIsEnabledSpellCheck()),(s=this.options.proofreader)!=null&&s.enabled&&r.proofreadDoc(n.doc),r.getDecorationSet()},apply:(e,n)=>{var s;if(e.getMeta($n.SKIP_SPELLCHECK))return n;const r=this.storage.spellchecker,o=e.getMeta($n.IS_ACTIVE_SPELLCHECK);if(o!==void 0)return o?r.proofreadDoc(e.doc):r.setDecorationSet(mt.empty),r.getDecorationSet();if(e.getMeta($n.SPELLCHECKER_TRANSACTION))return r.getDecorationSet();if(e.docChanged&&e.doc.nodeSize){const l=r.getDecorationSet().map(e.mapping,e.doc);if(r.setDecorationSet(l),e.getMeta($n.UI_EVENT)===RY.DROP)return r.debouncedProofreadDoc(e.doc),r.getDecorationSet();if(r.isUndoRedo(e,this.storage))return r.handleUndoRedo(e,this.storage);const{isTextContentChanged:u,isDeleteAction:c}=r.isTextContentChangedOrDeleted(e);if(c){const{changedNodes:g}=r.getChangedNodesFromTransaction(e,!1,!0);return g.length>0&&r.debouncedProofreadChangedNodes([g[0]]),r.getDecorationSet()}if(this.storage.enterKeyPressed)return r.handleEnterKeyDebounced(e,this.storage.pendingSpellCheck,()=>{this.storage.enterKeyPressed=!1,this.storage.pendingSpellCheck=!1}),r.getDecorationSet();if(this.storage.pendingSpellCheck||u)return r.debouncedProofreadDoc(e.doc,()=>{this.storage.pendingSpellCheck=!1}),r.getDecorationSet();if(e.getMeta(xE.UPDATE)||e.updated===0&&((s=e.steps[0])==null?void 0:s.structure)===!0)return r.getDecorationSet();if(e.getMeta($n.PREVENT_UPDATE)===!0&&e.before.textContent.length===0)return r.debouncedProofreadDoc(e.doc),r.getDecorationSet();this.storage.didPaste&&(this.storage.didPaste=!1);const{changedNodes:p,isChangedSuperText:m}=r.getChangedNodesFromTransaction(e);if(m)return r.debouncedProofreadDoc(e.doc),r.getDecorationSet();p.length>0&&r.debouncedProofreadChangedNodes(p)}return r.getDecorationSet()}},view:()=>({update:e=>{var r,o;const n=this.storage.spellchecker;n.setEditorView(e),(o=(r=e==null?void 0:e.dom)==null?void 0:r.parentNode)==null||o.appendChild(n.getSuggestionBox())}})})]}});function iS(t,e){return function(){return t.apply(e,arguments)}}const{toString:LY}=Object.prototype,{getPrototypeOf:Ib}=Object,zp=(t=>e=>{const n=LY.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),fo=t=>(t=t.toLowerCase(),e=>zp(e)===t),Hp=t=>e=>typeof e===t,{isArray:_l}=Array,pc=Hp("undefined");function PY(t){return t!==null&&!pc(t)&&t.constructor!==null&&!pc(t.constructor)&&wr(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const sS=fo("ArrayBuffer");function DY(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&sS(t.buffer),e}const VY=Hp("string"),wr=Hp("function"),aS=Hp("number"),Up=t=>t!==null&&typeof t=="object",FY=t=>t===!0||t===!1,Wp=t=>{if(zp(t)!=="object")return!1;const e=Ib(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},$Y=fo("Date"),zY=fo("File"),HY=fo("Blob"),UY=fo("FileList"),WY=t=>Up(t)&&wr(t.pipe),jY=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||wr(t.append)&&((e=zp(t))==="formdata"||e==="object"&&wr(t.toString)&&t.toString()==="[object FormData]"))},qY=fo("URLSearchParams"),[KY,GY,XY,YY]=["ReadableStream","Request","Response","Headers"].map(fo),JY=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function hc(t,e,{allOwnKeys:n=!1}={}){if(t===null||typeof t>"u")return;let r,o;if(typeof t!="object"&&(t=[t]),_l(t))for(r=0,o=t.length;r<o;r++)e.call(null,t[r],r,t);else{const s=n?Object.getOwnPropertyNames(t):Object.keys(t),a=s.length;let l;for(r=0;r<a;r++)l=s[r],e.call(null,t[l],l,t)}}function lS(t,e){e=e.toLowerCase();const n=Object.keys(t);let r=n.length,o;for(;r-- >0;)if(o=n[r],e===o.toLowerCase())return o;return null}const da=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,uS=t=>!pc(t)&&t!==da;function Rb(){const{caseless:t}=uS(this)&&this||{},e={},n=(r,o)=>{const s=t&&lS(e,o)||o;Wp(e[s])&&Wp(r)?e[s]=Rb(e[s],r):Wp(r)?e[s]=Rb({},r):_l(r)?e[s]=r.slice():e[s]=r};for(let r=0,o=arguments.length;r<o;r++)arguments[r]&&hc(arguments[r],n);return e}const ZY=(t,e,n,{allOwnKeys:r}={})=>(hc(e,(o,s)=>{n&&wr(o)?t[s]=iS(o,n):t[s]=o},{allOwnKeys:r}),t),QY=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),NY=(t,e,n,r)=>{t.prototype=Object.create(e.prototype,r),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),n&&Object.assign(t.prototype,n)},eJ=(t,e,n,r)=>{let o,s,a;const l={};if(e=e||{},t==null)return e;do{for(o=Object.getOwnPropertyNames(t),s=o.length;s-- >0;)a=o[s],(!r||r(a,t,e))&&!l[a]&&(e[a]=t[a],l[a]=!0);t=n!==!1&&Ib(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},tJ=(t,e,n)=>{t=String(t),(n===void 0||n>t.length)&&(n=t.length),n-=e.length;const r=t.indexOf(e,n);return r!==-1&&r===n},nJ=t=>{if(!t)return null;if(_l(t))return t;let e=t.length;if(!aS(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},rJ=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&Ib(Uint8Array)),oJ=(t,e)=>{const r=(t&&t[Symbol.iterator]).call(t);let o;for(;(o=r.next())&&!o.done;){const s=o.value;e.call(t,s[0],s[1])}},iJ=(t,e)=>{let n;const r=[];for(;(n=t.exec(e))!==null;)r.push(n);return r},sJ=fo("HTMLFormElement"),aJ=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),cS=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),lJ=fo("RegExp"),dS=(t,e)=>{const n=Object.getOwnPropertyDescriptors(t),r={};hc(n,(o,s)=>{let a;(a=e(o,s,t))!==!1&&(r[s]=a||o)}),Object.defineProperties(t,r)},uJ=t=>{dS(t,(e,n)=>{if(wr(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=t[n];if(wr(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},cJ=(t,e)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return _l(t)?r(t):r(String(t).split(e)),n},dJ=()=>{},fJ=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function pJ(t){return!!(t&&wr(t.append)&&t[Symbol.toStringTag]==="FormData"&&t[Symbol.iterator])}const hJ=t=>{const e=new Array(10),n=(r,o)=>{if(Up(r)){if(e.indexOf(r)>=0)return;if(!("toJSON"in r)){e[o]=r;const s=_l(r)?[]:{};return hc(r,(a,l)=>{const u=n(a,o+1);!pc(u)&&(s[l]=u)}),e[o]=void 0,s}}return r};return n(t,0)},mJ=fo("AsyncFunction"),gJ=t=>t&&(Up(t)||wr(t))&&wr(t.then)&&wr(t.catch),fS=((t,e)=>t?setImmediate:e?((n,r)=>(da.addEventListener("message",({source:o,data:s})=>{o===da&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),da.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",wr(da.postMessage)),bJ=typeof queueMicrotask<"u"?queueMicrotask.bind(da):typeof process<"u"&&process.nextTick||fS,re={isArray:_l,isArrayBuffer:sS,isBuffer:PY,isFormData:jY,isArrayBufferView:DY,isString:VY,isNumber:aS,isBoolean:FY,isObject:Up,isPlainObject:Wp,isReadableStream:KY,isRequest:GY,isResponse:XY,isHeaders:YY,isUndefined:pc,isDate:$Y,isFile:zY,isBlob:HY,isRegExp:lJ,isFunction:wr,isStream:WY,isURLSearchParams:qY,isTypedArray:rJ,isFileList:UY,forEach:hc,merge:Rb,extend:ZY,trim:JY,stripBOM:QY,inherits:NY,toFlatObject:eJ,kindOf:zp,kindOfTest:fo,endsWith:tJ,toArray:nJ,forEachEntry:oJ,matchAll:iJ,isHTMLForm:sJ,hasOwnProperty:cS,hasOwnProp:cS,reduceDescriptors:dS,freezeMethods:uJ,toObjectSet:cJ,toCamelCase:aJ,noop:dJ,toFiniteNumber:fJ,findKey:lS,global:da,isContextDefined:uS,isSpecCompliantForm:pJ,toJSONObject:hJ,isAsyncFn:mJ,isThenable:gJ,setImmediate:fS,asap:bJ};function st(t,e,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}re.inherits(st,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:re.toJSONObject(this.config),code:this.code,status:this.status}}});const pS=st.prototype,hS={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{hS[t]={value:t}}),Object.defineProperties(st,hS),Object.defineProperty(pS,"isAxiosError",{value:!0}),st.from=(t,e,n,r,o,s)=>{const a=Object.create(pS);return re.toFlatObject(t,a,function(u){return u!==Error.prototype},l=>l!=="isAxiosError"),st.call(a,t.message,e,n,r,o),a.cause=t,a.name=t.name,s&&Object.assign(a,s),a};const vJ=null;function Lb(t){return re.isPlainObject(t)||re.isArray(t)}function mS(t){return re.endsWith(t,"[]")?t.slice(0,-2):t}function gS(t,e,n){return t?t.concat(e).map(function(o,s){return o=mS(o),!n&&s?"["+o+"]":o}).join(n?".":""):e}function yJ(t){return re.isArray(t)&&!t.some(Lb)}const wJ=re.toFlatObject(re,{},null,function(e){return/^is[A-Z]/.test(e)});function jp(t,e,n){if(!re.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,n=re.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,w){return!re.isUndefined(w[y])});const r=n.metaTokens,o=n.visitor||f,s=n.dots,a=n.indexes,u=(n.Blob||typeof Blob<"u"&&Blob)&&re.isSpecCompliantForm(e);if(!re.isFunction(o))throw new TypeError("visitor must be a function");function c(b){if(b===null)return"";if(re.isDate(b))return b.toISOString();if(!u&&re.isBlob(b))throw new st("Blob is not supported. Use a Buffer instead.");return re.isArrayBuffer(b)||re.isTypedArray(b)?u&&typeof Blob=="function"?new Blob([b]):Buffer.from(b):b}function f(b,y,w){let x=b;if(b&&!w&&typeof b=="object"){if(re.endsWith(y,"{}"))y=r?y:y.slice(0,-2),b=JSON.stringify(b);else if(re.isArray(b)&&yJ(b)||(re.isFileList(b)||re.endsWith(y,"[]"))&&(x=re.toArray(b)))return y=mS(y),x.forEach(function(C,E){!(re.isUndefined(C)||C===null)&&e.append(a===!0?gS([y],E,s):a===null?y:y+"[]",c(C))}),!1}return Lb(b)?!0:(e.append(gS(w,y,s),c(b)),!1)}const p=[],m=Object.assign(wJ,{defaultVisitor:f,convertValue:c,isVisitable:Lb});function g(b,y){if(!re.isUndefined(b)){if(p.indexOf(b)!==-1)throw Error("Circular reference detected in "+y.join("."));p.push(b),re.forEach(b,function(x,S){(!(re.isUndefined(x)||x===null)&&o.call(e,x,re.isString(S)?S.trim():S,y,m))===!0&&g(x,y?y.concat(S):[S])}),p.pop()}}if(!re.isObject(t))throw new TypeError("data must be an object");return g(t),e}function bS(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function Pb(t,e){this._pairs=[],t&&jp(t,this,e)}const vS=Pb.prototype;vS.append=function(e,n){this._pairs.push([e,n])},vS.toString=function(e){const n=e?function(r){return e.call(this,r,bS)}:bS;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function xJ(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function yS(t,e,n){if(!e)return t;const r=n&&n.encode||xJ;re.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(e,n):s=re.isURLSearchParams(e)?e.toString():new Pb(e,n).toString(r),s){const a=t.indexOf("#");a!==-1&&(t=t.slice(0,a)),t+=(t.indexOf("?")===-1?"?":"&")+s}return t}class wS{constructor(){this.handlers=[]}use(e,n,r){return this.handlers.push({fulfilled:e,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){re.forEach(this.handlers,function(r){r!==null&&e(r)})}}const xS={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},CJ={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Pb,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Db=typeof window<"u"&&typeof document<"u",Vb=typeof navigator=="object"&&navigator||void 0,EJ=Db&&(!Vb||["ReactNative","NativeScript","NS"].indexOf(Vb.product)<0),SJ=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",kJ=Db&&window.location.href||"http://localhost",zn={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Db,hasStandardBrowserEnv:EJ,hasStandardBrowserWebWorkerEnv:SJ,navigator:Vb,origin:kJ},Symbol.toStringTag,{value:"Module"})),...CJ};function _J(t,e){return jp(t,new zn.classes.URLSearchParams,Object.assign({visitor:function(n,r,o,s){return zn.isNode&&re.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)}},e))}function TJ(t){return re.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function AJ(t){const e={},n=Object.keys(t);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],e[s]=t[s];return e}function CS(t){function e(n,r,o,s){let a=n[s++];if(a==="__proto__")return!0;const l=Number.isFinite(+a),u=s>=n.length;return a=!a&&re.isArray(o)?o.length:a,u?(re.hasOwnProp(o,a)?o[a]=[o[a],r]:o[a]=r,!l):((!o[a]||!re.isObject(o[a]))&&(o[a]=[]),e(n,r,o[a],s)&&re.isArray(o[a])&&(o[a]=AJ(o[a])),!l)}if(re.isFormData(t)&&re.isFunction(t.entries)){const n={};return re.forEachEntry(t,(r,o)=>{e(TJ(r),o,n,0)}),n}return null}function OJ(t,e,n){if(re.isString(t))try{return(e||JSON.parse)(t),re.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(t)}const mc={transitional:xS,adapter:["xhr","http","fetch"],transformRequest:[function(e,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=re.isObject(e);if(s&&re.isHTMLForm(e)&&(e=new FormData(e)),re.isFormData(e))return o?JSON.stringify(CS(e)):e;if(re.isArrayBuffer(e)||re.isBuffer(e)||re.isStream(e)||re.isFile(e)||re.isBlob(e)||re.isReadableStream(e))return e;if(re.isArrayBufferView(e))return e.buffer;if(re.isURLSearchParams(e))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let l;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return _J(e,this.formSerializer).toString();if((l=re.isFileList(e))||r.indexOf("multipart/form-data")>-1){const u=this.env&&this.env.FormData;return jp(l?{"files[]":e}:e,u&&new u,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),OJ(e)):e}],transformResponse:[function(e){const n=this.transitional||mc.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(re.isResponse(e)||re.isReadableStream(e))return e;if(e&&re.isString(e)&&(r&&!this.responseType||o)){const a=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(e)}catch(l){if(a)throw l.name==="SyntaxError"?st.from(l,st.ERR_BAD_RESPONSE,this,null,this.response):l}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:zn.classes.FormData,Blob:zn.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};re.forEach(["delete","get","head","post","put","patch"],t=>{mc.headers[t]={}});const MJ=re.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),BJ=t=>{const e={};let n,r,o;return t&&t.split(`
281
281
  `).forEach(function(a){o=a.indexOf(":"),n=a.substring(0,o).trim().toLowerCase(),r=a.substring(o+1).trim(),!(!n||e[n]&&MJ[n])&&(n==="set-cookie"?e[n]?e[n].push(r):e[n]=[r]:e[n]=e[n]?e[n]+", "+r:r)}),e},ES=Symbol("internals");function gc(t){return t&&String(t).trim().toLowerCase()}function qp(t){return t===!1||t==null?t:re.isArray(t)?t.map(qp):String(t)}function IJ(t){const e=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(t);)e[r[1]]=r[2];return e}const RJ=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function Fb(t,e,n,r,o){if(re.isFunction(r))return r.call(this,e,n);if(o&&(e=n),!!re.isString(e)){if(re.isString(r))return e.indexOf(r)!==-1;if(re.isRegExp(r))return r.test(e)}}function LJ(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,n,r)=>n.toUpperCase()+r)}function PJ(t,e){const n=re.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+n,{value:function(o,s,a){return this[r].call(this,e,o,s,a)},configurable:!0})})}let sr=class{constructor(e){e&&this.set(e)}set(e,n,r){const o=this;function s(l,u,c){const f=gc(u);if(!f)throw new Error("header name must be a non-empty string");const p=re.findKey(o,f);(!p||o[p]===void 0||c===!0||c===void 0&&o[p]!==!1)&&(o[p||u]=qp(l))}const a=(l,u)=>re.forEach(l,(c,f)=>s(c,f,u));if(re.isPlainObject(e)||e instanceof this.constructor)a(e,n);else if(re.isString(e)&&(e=e.trim())&&!RJ(e))a(BJ(e),n);else if(re.isHeaders(e))for(const[l,u]of e.entries())s(u,l,r);else e!=null&&s(n,e,r);return this}get(e,n){if(e=gc(e),e){const r=re.findKey(this,e);if(r){const o=this[r];if(!n)return o;if(n===!0)return IJ(o);if(re.isFunction(n))return n.call(this,o,r);if(re.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,n){if(e=gc(e),e){const r=re.findKey(this,e);return!!(r&&this[r]!==void 0&&(!n||Fb(this,this[r],r,n)))}return!1}delete(e,n){const r=this;let o=!1;function s(a){if(a=gc(a),a){const l=re.findKey(r,a);l&&(!n||Fb(r,r[l],l,n))&&(delete r[l],o=!0)}}return re.isArray(e)?e.forEach(s):s(e),o}clear(e){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const s=n[r];(!e||Fb(this,this[s],s,e,!0))&&(delete this[s],o=!0)}return o}normalize(e){const n=this,r={};return re.forEach(this,(o,s)=>{const a=re.findKey(r,s);if(a){n[a]=qp(o),delete n[s];return}const l=e?LJ(s):String(s).trim();l!==s&&delete n[s],n[l]=qp(o),r[l]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const n=Object.create(null);return re.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=e&&re.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,n])=>e+": "+n).join(`
282
282
  `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...n){const r=new this(e);return n.forEach(o=>r.set(o)),r}static accessor(e){const r=(this[ES]=this[ES]={accessors:{}}).accessors,o=this.prototype;function s(a){const l=gc(a);r[l]||(PJ(o,a),r[l]=!0)}return re.isArray(e)?e.forEach(s):s(e),this}};sr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),re.reduceDescriptors(sr.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(r){this[n]=r}}}),re.freezeMethods(sr);function $b(t,e){const n=this||mc,r=e||n,o=sr.from(r.headers);let s=r.data;return re.forEach(t,function(l){s=l.call(n,s,o.normalize(),e?e.status:void 0)}),o.normalize(),s}function SS(t){return!!(t&&t.__CANCEL__)}function Tl(t,e,n){st.call(this,t??"canceled",st.ERR_CANCELED,e,n),this.name="CanceledError"}re.inherits(Tl,st,{__CANCEL__:!0});function kS(t,e,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?t(n):e(new st("Request failed with status code "+n.status,[st.ERR_BAD_REQUEST,st.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function DJ(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function VJ(t,e){t=t||10;const n=new Array(t),r=new Array(t);let o=0,s=0,a;return e=e!==void 0?e:1e3,function(u){const c=Date.now(),f=r[s];a||(a=c),n[o]=u,r[o]=c;let p=s,m=0;for(;p!==o;)m+=n[p++],p=p%t;if(o=(o+1)%t,o===s&&(s=(s+1)%t),c-a<e)return;const g=f&&c-f;return g?Math.round(m*1e3/g):void 0}}function FJ(t,e){let n=0,r=1e3/e,o,s;const a=(c,f=Date.now())=>{n=f,o=null,s&&(clearTimeout(s),s=null),t.apply(null,c)};return[(...c)=>{const f=Date.now(),p=f-n;p>=r?a(c,f):(o=c,s||(s=setTimeout(()=>{s=null,a(o)},r-p)))},()=>o&&a(o)]}const Kp=(t,e,n=3)=>{let r=0;const o=VJ(50,250);return FJ(s=>{const a=s.loaded,l=s.lengthComputable?s.total:void 0,u=a-r,c=o(u),f=a<=l;r=a;const p={loaded:a,total:l,progress:l?a/l:void 0,bytes:u,rate:c||void 0,estimated:c&&l&&f?(l-a)/c:void 0,event:s,lengthComputable:l!=null,[e?"download":"upload"]:!0};t(p)},n)},_S=(t,e)=>{const n=t!=null;return[r=>e[0]({lengthComputable:n,total:t,loaded:r}),e[1]]},TS=t=>(...e)=>re.asap(()=>t(...e)),$J=zn.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,zn.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(zn.origin),zn.navigator&&/(msie|trident)/i.test(zn.navigator.userAgent)):()=>!0,zJ=zn.hasStandardBrowserEnv?{write(t,e,n,r,o,s){const a=[t+"="+encodeURIComponent(e)];re.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),re.isString(r)&&a.push("path="+r),re.isString(o)&&a.push("domain="+o),s===!0&&a.push("secure"),document.cookie=a.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function HJ(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function UJ(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function AS(t,e,n){let r=!HJ(e);return t&&(r||n==!1)?UJ(t,e):e}const OS=t=>t instanceof sr?{...t}:t;function fa(t,e){e=e||{};const n={};function r(c,f,p,m){return re.isPlainObject(c)&&re.isPlainObject(f)?re.merge.call({caseless:m},c,f):re.isPlainObject(f)?re.merge({},f):re.isArray(f)?f.slice():f}function o(c,f,p,m){if(re.isUndefined(f)){if(!re.isUndefined(c))return r(void 0,c,p,m)}else return r(c,f,p,m)}function s(c,f){if(!re.isUndefined(f))return r(void 0,f)}function a(c,f){if(re.isUndefined(f)){if(!re.isUndefined(c))return r(void 0,c)}else return r(void 0,f)}function l(c,f,p){if(p in e)return r(c,f);if(p in t)return r(void 0,c)}const u={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:l,headers:(c,f,p)=>o(OS(c),OS(f),p,!0)};return re.forEach(Object.keys(Object.assign({},t,e)),function(f){const p=u[f]||o,m=p(t[f],e[f],f);re.isUndefined(m)&&p!==l||(n[f]=m)}),n}const MS=t=>{const e=fa({},t);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:a,auth:l}=e;e.headers=a=sr.from(a),e.url=yS(AS(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),l&&a.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let u;if(re.isFormData(n)){if(zn.hasStandardBrowserEnv||zn.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if((u=a.getContentType())!==!1){const[c,...f]=u?u.split(";").map(p=>p.trim()).filter(Boolean):[];a.setContentType([c||"multipart/form-data",...f].join("; "))}}if(zn.hasStandardBrowserEnv&&(r&&re.isFunction(r)&&(r=r(e)),r||r!==!1&&$J(e.url))){const c=o&&s&&zJ.read(s);c&&a.set(o,c)}return e},WJ=typeof XMLHttpRequest<"u"&&function(t){return new Promise(function(n,r){const o=MS(t);let s=o.data;const a=sr.from(o.headers).normalize();let{responseType:l,onUploadProgress:u,onDownloadProgress:c}=o,f,p,m,g,b;function y(){g&&g(),b&&b(),o.cancelToken&&o.cancelToken.unsubscribe(f),o.signal&&o.signal.removeEventListener("abort",f)}let w=new XMLHttpRequest;w.open(o.method.toUpperCase(),o.url,!0),w.timeout=o.timeout;function x(){if(!w)return;const C=sr.from("getAllResponseHeaders"in w&&w.getAllResponseHeaders()),_={data:!l||l==="text"||l==="json"?w.responseText:w.response,status:w.status,statusText:w.statusText,headers:C,config:t,request:w};kS(function(A){n(A),y()},function(A){r(A),y()},_),w=null}"onloadend"in w?w.onloadend=x:w.onreadystatechange=function(){!w||w.readyState!==4||w.status===0&&!(w.responseURL&&w.responseURL.indexOf("file:")===0)||setTimeout(x)},w.onabort=function(){w&&(r(new st("Request aborted",st.ECONNABORTED,t,w)),w=null)},w.onerror=function(){r(new st("Network Error",st.ERR_NETWORK,t,w)),w=null},w.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const _=o.transitional||xS;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new st(E,_.clarifyTimeoutError?st.ETIMEDOUT:st.ECONNABORTED,t,w)),w=null},s===void 0&&a.setContentType(null),"setRequestHeader"in w&&re.forEach(a.toJSON(),function(E,_){w.setRequestHeader(_,E)}),re.isUndefined(o.withCredentials)||(w.withCredentials=!!o.withCredentials),l&&l!=="json"&&(w.responseType=o.responseType),c&&([m,b]=Kp(c,!0),w.addEventListener("progress",m)),u&&w.upload&&([p,g]=Kp(u),w.upload.addEventListener("progress",p),w.upload.addEventListener("loadend",g)),(o.cancelToken||o.signal)&&(f=C=>{w&&(r(!C||C.type?new Tl(null,t,w):C),w.abort(),w=null)},o.cancelToken&&o.cancelToken.subscribe(f),o.signal&&(o.signal.aborted?f():o.signal.addEventListener("abort",f)));const S=DJ(o.url);if(S&&zn.protocols.indexOf(S)===-1){r(new st("Unsupported protocol "+S+":",st.ERR_BAD_REQUEST,t));return}w.send(s||null)})},jJ=(t,e)=>{const{length:n}=t=t?t.filter(Boolean):[];if(e||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,l();const f=c instanceof Error?c:this.reason;r.abort(f instanceof st?f:new Tl(f instanceof Error?f.message:f))}};let a=e&&setTimeout(()=>{a=null,s(new st(`timeout ${e} of ms exceeded`,st.ETIMEDOUT))},e);const l=()=>{t&&(a&&clearTimeout(a),a=null,t.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),t=null)};t.forEach(c=>c.addEventListener("abort",s));const{signal:u}=r;return u.unsubscribe=()=>re.asap(l),u}},qJ=function*(t,e){let n=t.byteLength;if(n<e){yield t;return}let r=0,o;for(;r<n;)o=r+e,yield t.slice(r,o),r=o},KJ=async function*(t,e){for await(const n of GJ(t))yield*qJ(n,e)},GJ=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:n,value:r}=await e.read();if(n)break;yield r}}finally{await e.cancel()}},BS=(t,e,n,r)=>{const o=KJ(t,e);let s=0,a,l=u=>{a||(a=!0,r&&r(u))};return new ReadableStream({async pull(u){try{const{done:c,value:f}=await o.next();if(c){l(),u.close();return}let p=f.byteLength;if(n){let m=s+=p;n(m)}u.enqueue(new Uint8Array(f))}catch(c){throw l(c),c}},cancel(u){return l(u),o.return()}},{highWaterMark:2})},Gp=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",IS=Gp&&typeof ReadableStream=="function",XJ=Gp&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),RS=(t,...e)=>{try{return!!t(...e)}catch{return!1}},YJ=IS&&RS(()=>{let t=!1;const e=new Request(zn.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e}),LS=64*1024,zb=IS&&RS(()=>re.isReadableStream(new Response("").body)),Xp={stream:zb&&(t=>t.body)};Gp&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!Xp[e]&&(Xp[e]=re.isFunction(t[e])?n=>n[e]():(n,r)=>{throw new st(`Response type '${e}' is not supported`,st.ERR_NOT_SUPPORT,r)})})})(new Response);const JJ=async t=>{if(t==null)return 0;if(re.isBlob(t))return t.size;if(re.isSpecCompliantForm(t))return(await new Request(zn.origin,{method:"POST",body:t}).arrayBuffer()).byteLength;if(re.isArrayBufferView(t)||re.isArrayBuffer(t))return t.byteLength;if(re.isURLSearchParams(t)&&(t=t+""),re.isString(t))return(await XJ(t)).byteLength},ZJ=async(t,e)=>{const n=re.toFiniteNumber(t.getContentLength());return n??JJ(e)},Hb={http:vJ,xhr:WJ,fetch:Gp&&(async t=>{let{url:e,method:n,data:r,signal:o,cancelToken:s,timeout:a,onDownloadProgress:l,onUploadProgress:u,responseType:c,headers:f,withCredentials:p="same-origin",fetchOptions:m}=MS(t);c=c?(c+"").toLowerCase():"text";let g=jJ([o,s&&s.toAbortSignal()],a),b;const y=g&&g.unsubscribe&&(()=>{g.unsubscribe()});let w;try{if(u&&YJ&&n!=="get"&&n!=="head"&&(w=await ZJ(f,r))!==0){let _=new Request(e,{method:"POST",body:r,duplex:"half"}),T;if(re.isFormData(r)&&(T=_.headers.get("content-type"))&&f.setContentType(T),_.body){const[A,L]=_S(w,Kp(TS(u)));r=BS(_.body,LS,A,L)}}re.isString(p)||(p=p?"include":"omit");const x="credentials"in Request.prototype;b=new Request(e,{...m,signal:g,method:n.toUpperCase(),headers:f.normalize().toJSON(),body:r,duplex:"half",credentials:x?p:void 0});let S=await fetch(b);const C=zb&&(c==="stream"||c==="response");if(zb&&(l||C&&y)){const _={};["status","statusText","headers"].forEach(D=>{_[D]=S[D]});const T=re.toFiniteNumber(S.headers.get("content-length")),[A,L]=l&&_S(T,Kp(TS(l),!0))||[];S=new Response(BS(S.body,LS,A,()=>{L&&L(),y&&y()}),_)}c=c||"text";let E=await Xp[re.findKey(Xp,c)||"text"](S,t);return!C&&y&&y(),await new Promise((_,T)=>{kS(_,T,{data:E,headers:sr.from(S.headers),status:S.status,statusText:S.statusText,config:t,request:b})})}catch(x){throw y&&y(),x&&x.name==="TypeError"&&/fetch/i.test(x.message)?Object.assign(new st("Network Error",st.ERR_NETWORK,t,b),{cause:x.cause||x}):st.from(x,x&&x.code,t,b)}})};re.forEach(Hb,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const PS=t=>`- ${t}`,QJ=t=>re.isFunction(t)||t===null||t===!1,DS={getAdapter:t=>{t=re.isArray(t)?t:[t];const{length:e}=t;let n,r;const o={};for(let s=0;s<e;s++){n=t[s];let a;if(r=n,!QJ(n)&&(r=Hb[(a=String(n)).toLowerCase()],r===void 0))throw new st(`Unknown adapter '${a}'`);if(r)break;o[a||"#"+s]=r}if(!r){const s=Object.entries(o).map(([l,u])=>`adapter ${l} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=e?s.length>1?`since :
283
283
  `+s.map(PS).join(`