@ones-editor/editor 1.1.6-beta.2 → 1.1.6-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -639,7 +639,7 @@ __p += '`),zt&&(et+=`' +
|
|
|
639
639
|
function print() { __p += __j.call(arguments, '') }
|
|
640
640
|
`:`;
|
|
641
641
|
`)+et+`return __p
|
|
642
|
-
}`;var Nt=R6(function(){return Wt(w,At+"return "+et).apply(e,O)});if(Nt.source=et,fb(Nt))throw Nt;return Nt}function tlt(a){return ne(a).toLowerCase()}function elt(a){return ne(a).toUpperCase()}function nlt(a,u,g){if(a=ne(a),a&&(g||u===e))return vo(a);if(!a||!(u=lr(u)))return a;var A=sr(a),T=sr(u),w=Nl(A,T),O=ad(A,T)+1;return Ls(A,w,O).join("")}function rlt(a,u,g){if(a=ne(a),a&&(g||u===e))return a.slice(0,Pc(a)+1);if(!a||!(u=lr(u)))return a;var A=sr(a),T=ad(A,sr(u))+1;return Ls(A,0,T).join("")}function ilt(a,u,g){if(a=ne(a),a&&(g||u===e))return a.replace(Vf,"");if(!a||!(u=lr(u)))return a;var A=sr(a),T=Nl(A,sr(u));return Ls(A,T).join("")}function olt(a,u){var g=xt,A=Gt;if(Re(u)){var T="separator"in u?u.separator:T;g="length"in u?Ut(u.length):g,A="omission"in u?lr(u.omission):A}a=ne(a);var w=a.length;if(Bo(a)){var O=sr(a);w=O.length}if(g>=w)return a;var P=g-ys(A);if(P<1)return A;var V=O?Ls(O,0,P).join(""):a.slice(0,P);if(T===e)return V+A;if(O&&(P+=V.length-P),db(T)){if(a.slice(P).search(T)){var Y,Q=V;for(T.global||(T=$c(T.source,ne(Bc.exec(T))+"g")),T.lastIndex=0;Y=T.exec(Q);)var et=Y.index;V=V.slice(0,et===e?P:et)}}else if(a.indexOf(lr(T),P)!=P){var ht=V.lastIndexOf(T);ht>-1&&(V=V.slice(0,ht))}return V+A}function slt(a){return a=ne(a),a&&NA.test(a)?a.replace(Bm,Fc):a}var llt=jc(function(a,u,g){return a+(g?" ":"")+u.toUpperCase()}),gb=wL("toUpperCase");function k6(a,u,g){return a=ne(a),u=g?e:u,u===e?Uc(a)?zm(a):ir(a):a.match(u)||[]}var R6=Pt(function(a,u){try{return Rn(a,e,u)}catch(g){return fb(g)?g:new St(g)}}),alt=Oo(function(a,u){return Vn(u,function(g){g=Hi(g),Mo(a,g,cb(a[g],a))}),a});function clt(a){var u=a==null?0:a.length,g=Tt();return a=u?Ce(a,function(A){if(typeof A[1]!="function")throw new wn(s);return[g(A[0]),A[1]]}):[],Pt(function(A){for(var T=-1;++T<u;){var w=a[T];if(Rn(w[0],this,A))return Rn(w[1],this,A)}})}function ult(a){return Unt(yr(a,C))}function pb(a){return function(){return a}}function flt(a,u){return a==null||a!==a?u:a}var dlt=LL(),hlt=LL(!0);function Wn(a){return a}function Cb(a){return sL(typeof a=="function"?a:yr(a,C))}function mlt(a){return aL(yr(a,C))}function glt(a,u){return cL(a,yr(u,C))}var plt=Pt(function(a,u){return function(g){return Ed(g,a,u)}}),Clt=Pt(function(a,u){return function(g){return Ed(a,g,u)}});function Eb(a,u,g){var A=nn(u),T=ng(u,A);g==null&&!(Re(u)&&(T.length||!A.length))&&(g=u,u=a,a=this,T=ng(u,nn(u)));var w=!(Re(g)&&"chain"in g)||!!g.chain,O=Po(a);return Vn(T,function(P){var V=u[P];a[P]=V,O&&(a.prototype[P]=function(){var Y=this.__chain__;if(w||Y){var Q=a(this.__wrapped__),et=Q.__actions__=jn(this.__actions__);return et.push({func:V,args:arguments,thisArg:a}),Q.__chain__=Y,Q}return V.apply(a,Pi([this.value()],arguments))})}),a}function Elt(){return Je._===this&&(Je._=Wm),this}function Ab(){}function Alt(a){return a=Ut(a),Pt(function(u){return uL(u,a)})}var xlt=Yx(Ce),blt=Yx(Nm),vlt=Yx(od);function w6(a){return rb(a)?Dc(Hi(a)):Jnt(a)}function Blt(a){return function(u){return a==null?e:ea(a,u)}}var Tlt=DL(),ylt=DL(!0);function xb(){return[]}function bb(){return!1}function klt(){return{}}function Rlt(){return""}function wlt(){return!0}function Slt(a,u){if(a=Ut(a),a<1||a>pn)return[];var g=xr,A=_(a,xr);u=Tt(u),a-=xr;for(var T=Mc(A,u);++g<a;)u(g);return T}function Llt(a){return Mt(a)?Ce(a,Hi):ar(a)?[a]:jn(qL(ne(a)))}function Ilt(a){var u=++Gm;return ne(a)+u}var Dlt=ag(function(a,u){return a+u},0),_lt=Qx("ceil"),Mlt=ag(function(a,u){return a/u},1),Ult=Qx("floor");function Olt(a){return a&&a.length?eg(a,Wn,Ox):e}function Nlt(a,u){return a&&a.length?eg(a,Tt(u,2),Ox):e}function Plt(a){return Ic(a,Wn)}function Flt(a,u){return Ic(a,Tt(u,2))}function Klt(a){return a&&a.length?eg(a,Wn,Kx):e}function Vlt(a,u){return a&&a.length?eg(a,Tt(u,2),Kx):e}var $lt=ag(function(a,u){return a*u},1),Hlt=Qx("round"),jlt=ag(function(a,u){return a-u},0);function zlt(a){return a&&a.length?_c(a,Wn):0}function Glt(a,u){return a&&a.length?_c(a,Tt(u,2)):0}return k.after=mot,k.ary=o6,k.assign=est,k.assignIn=A6,k.assignInWith=bg,k.assignWith=nst,k.at=rst,k.before=s6,k.bind=cb,k.bindAll=alt,k.bindKey=l6,k.castArray=kot,k.chain=n6,k.chunk=Urt,k.compact=Ort,k.concat=Nrt,k.cond=clt,k.conforms=ult,k.constant=pb,k.countBy=zit,k.create=ist,k.curry=a6,k.curryRight=c6,k.debounce=u6,k.defaults=ost,k.defaultsDeep=sst,k.defer=got,k.delay=pot,k.difference=Prt,k.differenceBy=Frt,k.differenceWith=Krt,k.drop=Vrt,k.dropRight=$rt,k.dropRightWhile=Hrt,k.dropWhile=jrt,k.fill=zrt,k.filter=Wit,k.flatMap=Yit,k.flatMapDeep=Qit,k.flatMapDepth=Jit,k.flatten=JL,k.flattenDeep=Grt,k.flattenDepth=Wrt,k.flip=Cot,k.flow=dlt,k.flowRight=hlt,k.fromPairs=qrt,k.functions=hst,k.functionsIn=mst,k.groupBy=Zit,k.initial=Yrt,k.intersection=Qrt,k.intersectionBy=Jrt,k.intersectionWith=Zrt,k.invert=pst,k.invertBy=Cst,k.invokeMap=eot,k.iteratee=Cb,k.keyBy=not,k.keys=nn,k.keysIn=Gn,k.map=gg,k.mapKeys=Ast,k.mapValues=xst,k.matches=mlt,k.matchesProperty=glt,k.memoize=Cg,k.merge=bst,k.mergeWith=x6,k.method=plt,k.methodOf=Clt,k.mixin=Eb,k.negate=Eg,k.nthArg=Alt,k.omit=vst,k.omitBy=Bst,k.once=Eot,k.orderBy=rot,k.over=xlt,k.overArgs=Aot,k.overEvery=blt,k.overSome=vlt,k.partial=ub,k.partialRight=f6,k.partition=iot,k.pick=Tst,k.pickBy=b6,k.property=w6,k.propertyOf=Blt,k.pull=rit,k.pullAll=t6,k.pullAllBy=iit,k.pullAllWith=oit,k.pullAt=sit,k.range=Tlt,k.rangeRight=ylt,k.rearg=xot,k.reject=lot,k.remove=lit,k.rest=bot,k.reverse=lb,k.sampleSize=cot,k.set=kst,k.setWith=Rst,k.shuffle=uot,k.slice=ait,k.sortBy=hot,k.sortedUniq=git,k.sortedUniqBy=pit,k.split=Yst,k.spread=vot,k.tail=Cit,k.take=Eit,k.takeRight=Ait,k.takeRightWhile=xit,k.takeWhile=bit,k.tap=Oit,k.throttle=Bot,k.thru=mg,k.toArray=p6,k.toPairs=v6,k.toPairsIn=B6,k.toPath=Llt,k.toPlainObject=E6,k.transform=wst,k.unary=Tot,k.union=vit,k.unionBy=Bit,k.unionWith=Tit,k.uniq=yit,k.uniqBy=kit,k.uniqWith=Rit,k.unset=Sst,k.unzip=ab,k.unzipWith=e6,k.update=Lst,k.updateWith=Ist,k.values=Wc,k.valuesIn=Dst,k.without=wit,k.words=k6,k.wrap=yot,k.xor=Sit,k.xorBy=Lit,k.xorWith=Iit,k.zip=Dit,k.zipObject=_it,k.zipObjectDeep=Mit,k.zipWith=Uit,k.entries=v6,k.entriesIn=B6,k.extend=A6,k.extendWith=bg,Eb(k,k),k.add=Dlt,k.attempt=R6,k.camelCase=Ost,k.capitalize=T6,k.ceil=_lt,k.clamp=_st,k.clone=Rot,k.cloneDeep=Sot,k.cloneDeepWith=Lot,k.cloneWith=wot,k.conformsTo=Iot,k.deburr=y6,k.defaultTo=flt,k.divide=Mlt,k.endsWith=Nst,k.eq=oi,k.escape=Pst,k.escapeRegExp=Fst,k.every=Git,k.find=qit,k.findIndex=YL,k.findKey=lst,k.findLast=Xit,k.findLastIndex=QL,k.findLastKey=ast,k.floor=Ult,k.forEach=r6,k.forEachRight=i6,k.forIn=cst,k.forInRight=ust,k.forOwn=fst,k.forOwnRight=dst,k.get=hb,k.gt=Dot,k.gte=_ot,k.has=gst,k.hasIn=mb,k.head=ZL,k.identity=Wn,k.includes=tot,k.indexOf=Xrt,k.inRange=Mst,k.invoke=Est,k.isArguments=ia,k.isArray=Mt,k.isArrayBuffer=Mot,k.isArrayLike=zn,k.isArrayLikeObject=Ne,k.isBoolean=Uot,k.isBuffer=Is,k.isDate=Oot,k.isElement=Not,k.isEmpty=Pot,k.isEqual=Fot,k.isEqualWith=Kot,k.isError=fb,k.isFinite=Vot,k.isFunction=Po,k.isInteger=d6,k.isLength=Ag,k.isMap=h6,k.isMatch=$ot,k.isMatchWith=Hot,k.isNaN=jot,k.isNative=zot,k.isNil=Wot,k.isNull=Got,k.isNumber=m6,k.isObject=Re,k.isObjectLike=De,k.isPlainObject=Td,k.isRegExp=db,k.isSafeInteger=qot,k.isSet=g6,k.isString=xg,k.isSymbol=ar,k.isTypedArray=Gc,k.isUndefined=Xot,k.isWeakMap=Yot,k.isWeakSet=Qot,k.join=tit,k.kebabCase=Kst,k.last=Rr,k.lastIndexOf=eit,k.lowerCase=Vst,k.lowerFirst=$st,k.lt=Jot,k.lte=Zot,k.max=Olt,k.maxBy=Nlt,k.mean=Plt,k.meanBy=Flt,k.min=Klt,k.minBy=Vlt,k.stubArray=xb,k.stubFalse=bb,k.stubObject=klt,k.stubString=Rlt,k.stubTrue=wlt,k.multiply=$lt,k.nth=nit,k.noConflict=Elt,k.noop=Ab,k.now=pg,k.pad=Hst,k.padEnd=jst,k.padStart=zst,k.parseInt=Gst,k.random=Ust,k.reduce=oot,k.reduceRight=sot,k.repeat=Wst,k.replace=qst,k.result=yst,k.round=Hlt,k.runInContext=K,k.sample=aot,k.size=fot,k.snakeCase=Xst,k.some=dot,k.sortedIndex=cit,k.sortedIndexBy=uit,k.sortedIndexOf=fit,k.sortedLastIndex=dit,k.sortedLastIndexBy=hit,k.sortedLastIndexOf=mit,k.startCase=Qst,k.startsWith=Jst,k.subtract=jlt,k.sum=zlt,k.sumBy=Glt,k.template=Zst,k.times=Slt,k.toFinite=Fo,k.toInteger=Ut,k.toLength=C6,k.toLower=tlt,k.toNumber=wr,k.toSafeInteger=tst,k.toString=ne,k.toUpper=elt,k.trim=nlt,k.trimEnd=rlt,k.trimStart=ilt,k.truncate=olt,k.unescape=slt,k.uniqueId=Ilt,k.upperCase=llt,k.upperFirst=gb,k.each=r6,k.eachRight=i6,k.first=ZL,Eb(k,function(){var a={};return Vi(k,function(u,g){qt.call(k.prototype,g)||(a[g]=u)}),a}(),{chain:!1}),k.VERSION=r,Vn(["bind","bindKey","curry","curryRight","partial","partialRight"],function(a){k[a].placeholder=k}),Vn(["drop","take"],function(a,u){Vt.prototype[a]=function(g){g=g===e?1:S(Ut(g),0);var A=this.__filtered__&&!u?new Vt(this):this.clone();return A.__filtered__?A.__takeCount__=_(g,A.__takeCount__):A.__views__.push({size:_(g,xr),type:a+(A.__dir__<0?"Right":"")}),A},Vt.prototype[a+"Right"]=function(g){return this.reverse()[a](g).reverse()}}),Vn(["filter","map","takeWhile"],function(a,u){var g=u+1,A=g==be||g==_i;Vt.prototype[a]=function(T){var w=this.clone();return w.__iteratees__.push({iteratee:Tt(T,3),type:g}),w.__filtered__=w.__filtered__||A,w}}),Vn(["head","last"],function(a,u){var g="take"+(u?"Right":"");Vt.prototype[a]=function(){return this[g](1).value()[0]}}),Vn(["initial","tail"],function(a,u){var g="drop"+(u?"":"Right");Vt.prototype[a]=function(){return this.__filtered__?new Vt(this):this[g](1)}}),Vt.prototype.compact=function(){return this.filter(Wn)},Vt.prototype.find=function(a){return this.filter(a).head()},Vt.prototype.findLast=function(a){return this.reverse().find(a)},Vt.prototype.invokeMap=Pt(function(a,u){return typeof a=="function"?new Vt(this):this.map(function(g){return Ed(g,a,u)})}),Vt.prototype.reject=function(a){return this.filter(Eg(Tt(a)))},Vt.prototype.slice=function(a,u){a=Ut(a);var g=this;return g.__filtered__&&(a>0||u<0)?new Vt(g):(a<0?g=g.takeRight(-a):a&&(g=g.drop(a)),u!==e&&(u=Ut(u),g=u<0?g.dropRight(-u):g.take(u-a)),g)},Vt.prototype.takeRightWhile=function(a){return this.reverse().takeWhile(a).reverse()},Vt.prototype.toArray=function(){return this.take(xr)},Vi(Vt.prototype,function(a,u){var g=/^(?:filter|find|map|reject)|While$/.test(u),A=/^(?:head|last)$/.test(u),T=k[A?"take"+(u=="last"?"Right":""):u],w=A||/^find/.test(u);!T||(k.prototype[u]=function(){var O=this.__wrapped__,P=A?[1]:arguments,V=O instanceof Vt,Y=P[0],Q=V||Mt(O),et=function(jt){var zt=T.apply(k,Pi([jt],P));return A&&ht?zt[0]:zt};Q&&g&&typeof Y=="function"&&Y.length!=1&&(V=Q=!1);var ht=this.__chain__,At=!!this.__actions__.length,yt=w&&!ht,Nt=V&&!At;if(!w&&Q){O=Nt?O:new Vt(this);var kt=a.apply(O,P);return kt.__actions__.push({func:mg,args:[et],thisArg:e}),new Hn(kt,ht)}return yt&&Nt?a.apply(this,P):(kt=this.thru(et),yt?A?kt.value()[0]:kt.value():kt)})}),Vn(["pop","push","shift","sort","splice","unshift"],function(a){var u=Vl[a],g=/^(?:push|sort|unshift)$/.test(a)?"tap":"thru",A=/^(?:pop|shift)$/.test(a);k.prototype[a]=function(){var T=arguments;if(A&&!this.__chain__){var w=this.value();return u.apply(Mt(w)?w:[],T)}return this[g](function(O){return u.apply(Mt(O)?O:[],T)})}}),Vi(Vt.prototype,function(a,u){var g=k[u];if(g){var A=g.name+"";qt.call(an,A)||(an[A]=[]),an[A].push({name:u,func:g})}}),an[lg(e,M).name]=[{name:"wrapper",func:e}],Vt.prototype.clone=snt,Vt.prototype.reverse=lnt,Vt.prototype.value=ant,k.prototype.at=Nit,k.prototype.chain=Pit,k.prototype.commit=Fit,k.prototype.next=Kit,k.prototype.plant=$it,k.prototype.reverse=Hit,k.prototype.toJSON=k.prototype.valueOf=k.prototype.value=jit,k.prototype.first=k.prototype.head,ql&&(k.prototype[ql]=Vit),k},ko=Vc();xo?((xo.exports=ko)._=ko,Qf._=ko):Je._=ko}).call(_n)})(er,er.exports);function f$(n,t,e,r){a0(n,{className:"status-input",defaultValue:t,onChange:e,onKeyDown:r,maxLength:32})}const iE=["Blue","Grey","Yellow","Red","Green","Purple"];function d$(){const n=B("div",["status-color-palette"],null);for(const t of iE){const e=B("button",["status-box-button"],null);e.setAttribute("data-color",er.exports.lowerCase(t)),e.setAttribute("title",D.t(`status.color.${er.exports.lowerCase(t)}`)),n.appendChild(e)}return n}class h${constructor(){m(this,"root",d$());m(this,"changeColor",t=>{for(const r of Array.from(this.root.querySelectorAll(":scope > button")))r.classList.remove("selected");const e=this.root.querySelector(`button[data-color="${er.exports.lowerCase(t)}"]`);e==null||e.classList.add("selected")})}}function m$(n){localStorage.setItem(`statusBox.lastColor.${er.exports.lowerCase(n.color)}`,n.title)}function Gk(n){var t;return(t=localStorage.getItem(`statusBox.lastColor.${er.exports.lowerCase(n)}`))!=null?t:D.t(`status.colorDefaultTitle.${er.exports.lowerCase(n)}`)}function Wk(){var i;const n=iE[0],t=(i=Gk(n))!=null?i:D.t(`status.colorDefaultTitle.${er.exports.lowerCase(n)}`);return{insert:" ",attributes:{id:tt(),type:"status",box:!0,title:t,subtle:!1,created:Date.now(),color:n}}}const D0=I("StatusBoxEditor");class oE{constructor(t){m(this,"linkPopup",null);m(this,"boxElement");m(this,"statusPalette",new h$);m(this,"isEditing",!1);m(this,"editorStatus",t=>{if(!this.editor.isWritable())return;const e=this.editor.getBoxData(t);this.linkPopup=new $a(this.createPopupContent(e.title,e.color,e.subtle),{id:"status-box-popup"}),this.linkPopup.on("show",this.handleShow),this.linkPopup.on("close",this.handClose),this.linkPopup.manualShow(t,{theme:"light",placement:"bottom-start",offset:[5,5]}),this.boxElement=t});m(this,"handleShow",()=>{this.focus()});m(this,"handClose",()=>{var r;p(D0,this.boxElement,"boxElement not found");const t=this.editor.getBoxData(this.boxElement),e=Z(this.boxElement);if(p(D0,e,"block not found"),t.title)m$(t);else{const i=Go(e,this.boxElement);this.editor.deleteTextFromBlock(e,i.start,1)}this.editor.focus(),(r=this.linkPopup)==null||r.destroy(),this.linkPopup=null,this.boxElement=void 0,this.isEditing=!1});m(this,"handleKeyDown",t=>{var e;t.key==="Enter"&&((e=this.linkPopup)==null||e.close(null))});m(this,"onColorChange",t=>{var o,s;if(!(t.target instanceof HTMLElement)||t.target.closest("[data-color]")===null)return;const e=er.exports.capitalize(t.target.getAttribute("data-color"));p(D0,this.boxElement,"boxElement not found");const r=this.editor.getBoxData(this.boxElement);this.statusPalette.changeColor(e);const i={...r,color:e};if(!this.isEditing){const l=(s=(o=this.linkPopup)==null?void 0:o.popper)==null?void 0:s.querySelector("input"),c=Gk(e);l&&(l.value=c),i.title=c}this.editor.updateBoxData(i,{noFocus:!0}),this.focus()});m(this,"onTitleChange",t=>{const e=t.target.value;p(D0,this.boxElement,"boxElement not found");const i={...this.editor.getBoxData(this.boxElement),title:e.trim()};this.editor.updateBoxData(i,{noFocus:!0}),this.isEditing=!0});this.editor=t,this.statusPalette.root.addEventListener("click",this.onColorChange)}focus(){setTimeout(()=>{var t,e,r,i,o,s;(r=(e=(t=this.linkPopup)==null?void 0:t.popper)==null?void 0:e.querySelector("input"))==null||r.focus(),(s=(o=(i=this.linkPopup)==null?void 0:i.popper)==null?void 0:o.querySelector("input"))==null||s.select()},100)}createPopupContent(t,e,r){const i=B("div",["status-box-editor-popup"],null);return f$(i,t,this.onTitleChange,this.handleKeyDown),this.isEditing=!1,i.appendChild(this.statusPalette.root),this.statusPalette.changeColor(e),i}destroy(){var t;(t=this.linkPopup)==null||t.destroy()}}const Ict="";class qk{constructor(t){m(this,"onMouseOver",t=>{const e=t.target;if(e.hasAttribute("data-editor-overflow-tooltip"))if(this.check(e)){const r=e.getAttribute("data-editor-overflow-tooltip");e.setAttribute(`data-editor-tooltip-${this.editor.clientId}`,r)}else e.removeAttribute(`data-editor-tooltip-${this.editor.clientId}`)});this.editor=t,this.editor.rootContainer.addEventListener("mouseover",this.onMouseOver)}check(t){return t.scrollWidth>t.offsetWidth}destroy(){this.editor.rootContainer.removeEventListener("mouseover",this.onMouseOver)}static create(t,e){const r=B("a",t,null,this.replaceTitleSpace(e));return r.setAttribute("data-editor-overflow-tooltip",this.replaceTitleSpace(e)),r}static replaceTitleSpace(t){return t.replace(/\s/g,"\xA0")}}function g$(n,t,e,r){const i=r,{title:o,subtle:s,color:l}=i,c=s?["box-status-common",`box-status-${er.exports.lowerCase(l)}-subtle`]:["box-status-common",`box-status-${er.exports.lowerCase(l)}`];o||c.push("box-status-empty");const d=qk.create(c,o||D.t("status.empty"));e.appendChild(d),n.addCustom("status-box-overflow-tooltip",h=>new qk(h)),n.addCustom("status-box",h=>new oE(h))}function p$(n,t){return{abstract:D.t("status.command.name")}}function C$(n,t){n.getCustom("status-box").editorStatus(t)}function E$(n,t){const{title:e}=t;return e!=null?e:""}async function A$(n,t){var s;const{title:e,color:r}=t,i=iE.indexOf(r),o=[4,6,2,0,3,5];return[{insert:e!=null?e:"",attributes:{[`style-color-${(s=o[i])!=null?s:4}`]:!0}}]}const Xk={boxType:"status",updateBoxContent:g$,getBoxProperties:p$,handleClickBox:C$,convertTo:E$,toStandardText:A$},x$=I("status-box-command");class rc{static get commands(){return[{id:this.id,name:D.t("status.command.name"),icon:Cy,order:650,group:"common",subText:"/status"}]}static insertStatus(t,e,r){var c;const i=t.getBlockByIndex(e,r),o=Wk(),{start:s}=t.selection.range;p(x$,Or(s),"invalid block position"),t.insertBoxToBlock(i,s.offset,o.attributes);const l=t.getBoxById((c=o.attributes)==null?void 0:c.id);t.addCustom("status-box",d=>new oE(d)).editorStatus(l)}static insertEmptyBlockStatus(t,e,r){var l;let i=t.getBlockByIndex(e,r);(!i||!oe(t,i))&&(i=t.insertTextBlock([],e,r));const o=Wk();t.setBlockText(i,[o]);const s=t.getBoxById((l=o.attributes)==null?void 0:l.id);return t.addCustom("status-box",c=>new oE(c)).editorStatus(s),i}}m(rc,"id","insert-status");const b$={"en-US":{status:{empty:"\u8BBE\u7F6E\u72B6\u6001",command:{name:"\u72B6\u6001"},color:{red:"\u7EA2\u8272",yellow:"\u9EC4\u8272",green:"\u7EFF\u8272",blue:"\u84DD\u8272",purple:"\u7D2B\u8272",grey:"\u7070\u8272"},colorDefaultTitle:{red:"\u5DF2\u5EF6\u671F",yellow:"\u8FDB\u884C\u4E2D",green:"\u5DF2\u5B8C\u6210",blue:"\u672A\u5F00\u59CB",purple:"\u5DF2\u53D6\u6D88",grey:"\u6682\u505C"}}},"zh-CN":{status:{empty:"\u8BBE\u7F6E\u72B6\u6001",command:{name:"\u72B6\u6001"},color:{red:"\u7EA2\u8272",yellow:"\u9EC4\u8272",green:"\u7EFF\u8272",blue:"\u84DD\u8272",purple:"\u7D2B\u8272",grey:"\u7070\u8272"},colorDefaultTitle:{red:"\u5DF2\u5EF6\u671F",yellow:"\u8FDB\u884C\u4E2D",green:"\u5DF2\u5B8C\u6210",blue:"\u672A\u5F00\u59CB",purple:"\u5DF2\u53D6\u6D88",grey:"\u6682\u505C"}}},"ja-JP":{status:{empty:"\u8BBE\u7F6E\u72B6\u6001",command:{name:"\u72B6\u6001"},color:{red:"\u7EA2\u8272",yellow:"\u9EC4\u8272",green:"\u7EFF\u8272",blue:"\u84DD\u8272",purple:"\u7D2B\u8272",grey:"\u7070\u8272"},colorDefaultTitle:{red:"\u5DF2\u5EF6\u671F",yellow:"\u8FDB\u884C\u4E2D",green:"\u5DF2\u5B8C\u6210",blue:"\u672A\u5F00\u59CB",purple:"\u5DF2\u53D6\u6D88",grey:"\u6682\u505C"}}}};D.mergeLang(b$);const hl=I("inline-box-items");function v$(n,t,e){return n.undoManager.runInGroup(()=>{var s;let r=n.findBlockByIndex(t,e);(!r||!oe(n,r))&&(r=n.insertTextBlock([],t,e));const i=Hk();n.setBlockText(r,[i]);const o=(s=i.attributes)==null?void 0:s.id;return p(hl,o,"mathjax box id is empty"),setTimeout(()=>{const l=n.getBoxById(o);I0(n,l)},100),r})}function B$(n,t,e){let r=n.findBlockByIndex(t,e),i="bottom-start";return(!r||!oe(n,r))&&(i="top-start",r=n.insertTextBlock([],t,e)),Qu(n,{target:r,linkText:"",linkUrl:"",onFinished:(l,c)=>{n.undoManager.runInGroup(()=>{try{p(hl,r,"block not found"),oe(n,r)||(r=n.insertTextBlock([],t,e));const d=gr(l,{link:c}),h=gr(" ",null),C=[d,h];n.insertTextToBlock(r,0,C),n.selection.selectBlock(r,fn(C)),n.focus()}catch(d){hl.error(d)}})},onClose:()=>{n.focus()},placement:i}),r}function T$(n,t,e){return n.undoManager.runInGroup(()=>{var l;const r=n.getBlockByIndex(t,e),i=n.selection.range;p(hl,Or(i.start),"invalid block position");const o=Hk();n.insertBoxToBlock(r,i.start.offset,o.attributes);const s=(l=o.attributes)==null?void 0:l.id;return p(hl,s,"mathjax box id is empty"),setTimeout(()=>{const c=n.getBoxById(s);I0(n,c)},100),r})}function y$(n,t,e){const r=n.getBlockByIndex(t,e),i=n.selection.range;p(hl,Or(i.start),"invalid block position");const o=Yi(n,r,i);if(o.length===0)return;const s=o[0],l=Zi(n,r,"quick-menu-inline-link",s);Qu(n,{target:l,linkText:"",linkUrl:"",onFinished:(h,C)=>{n.undoManager.runInGroup(()=>{try{const E=n.getBlockText(r),x=no(E,i.start.offset,h,{link:C});n.setBlockText(r,x),n.selection.selectBlock(r,i.start.offset+h.length),n.focus()}catch(E){hl.error(E)}})},onClose:()=>{n.focus()},placement:"bottom-start"})}class Yk{getCommands(){return[{id:"insert-math",name:D.t("quickMenu.inlineBox.math"),icon:MT,order:900,group:"common",subText:Tn("insert-math")},{id:"insert-link",name:D.t("quickMenu.inlineBox.link"),icon:rC,order:400,group:"common",subText:Tn("insert-link")},...rc.commands]}async handleUpdateBlockCore(t,e){switch(e.item.id){case"insert-math":return T$(t,e.containerId,e.blockIndex);case"insert-link":return y$(t,e.containerId,e.blockIndex);case rc.id:return rc.insertStatus(t,e.containerId,e.blockIndex);default:return null}}async handleInsertEmptyBlockCore(t,e){switch(e.item.id){case"insert-math":return v$(t,e.containerId,e.blockIndex);case"insert-link":return B$(t,e.containerId,e.blockIndex);case rc.id:return rc.insertEmptyBlockStatus(t,e.containerId,e.blockIndex);default:return null}}async executeCommand(t,e,r){if(r.from==="quick-menu"){const i=t.getBlockById(r.blockId),o=t.getParentContainer(i),s=ft(o),l=t.getBlockIndex(i);t.undoManager.runInGroup(()=>this.handleUpdateBlockCore(t,{item:e,containerId:s,blockIndex:l}))}else r.from==="block-menu"&&t.undoManager.runInGroup(()=>this.handleInsertEmptyBlockCore(t,{item:e,containerId:r.containerId,blockIndex:r.blockIndex}));return null}}function k$(n,t={withPlainText:!1}){var o,s;const{withPlainText:e}=t,r=(s=(o=n.options.componentsOptions)==null?void 0:o.quickMenu)==null?void 0:s.commandProviders;if(!r)return[];const i=[];return[...r,new Ok(e),new Yk].forEach(l=>{const c=l.getCommands(n);i.push(...c.map(d=>({...d,itemType:"insert-block",commandProvider:l})))}),i}function R$(n,t={withPlainText:!1}){const e=[];return n.editorBlocks.forEach(r=>{if(!r.getOptions)return;const i=r.getOptions(n);!i.insertBlockCommandItems||(i.insertBlockCommandItems.forEach(o=>{Uk(o,i)}),e.push(...i.insertBlockCommandItems))}),e.push(...k$(n,t)),e}function sE(n,t={withPlainText:!1}){const e=R$(n,t),r=new Map;e.forEach(s=>{var d;const l=(d=s.group)!=null?d:"";let c=r.get(l);c?c.items.push(s):(c={group:l,order:s.groupOrder||Nk[l]||1e3,items:[s]},r.set(l,c))});const i=Array.from(r.values());i.sort((s,l)=>s.order-l.order),i.forEach(s=>{s.items.sort((l,c)=>{var d,h;return((d=l.order)!=null?d:0)-((h=c.order)!=null?h:0)})});const o=[];return i.forEach((s,l)=>{const c=`blockMenu.section.${s.group||"common"}`,d=D.t(c),h=d===c?s.group:d;o.push({id:`section-${l}`,name:h,type:"section",group:s.group,itemType:"insert-block"}),o.push(...s.items.map(C=>({...C})))}),o}function w$(n,t,e){const r=n.getFocusedBlock();if(!r)return;const i=n.getParentContainer(r),o=ft(i);let l=n.getBlockIndex(r);if(oe(n,r)||(l+=1),t.commandProvider){t.commandProvider.executeCommand(n,t,{from:"quick-menu",...e});return}!t.blockOptions||!t.blockOptions.handleInsertEmptyBlock||t.blockOptions.handleInsertEmptyBlock(n,{containerId:o,blockIndex:l,item:t})}const Qk=I("quick-menu"),S$={id:"quick-menu",trigger:["/"]},L$=5;class _0{constructor(t,e=S$){m(this,"suggest");m(this,"items");m(this,"maxHeading");m(this,"firstEmptyOffset",-1);m(this,"queryItems",async(t,e)=>{if(this.items.length===0?this.initMenuItems():this.refreshMenuItems(),e){const r=new Set,i=e.toLocaleLowerCase().replace(/^\s+|\s+$/g,""),o=this.items.filter(s=>{if(s.type==="section")return!0;if(s.name.toLocaleLowerCase().indexOf(i)!==-1||FP(s).toLocaleLowerCase().indexOf(i)!==-1)return r.add(s.group),!0;const l=`blockMenu.section.${s.group||"common"}`,c=D.t(l),d=c===l?s.group:c;return(d==null?void 0:d.toLocaleLowerCase().indexOf(i))!==-1?(r.add(s.group),!0):!1}).filter(s=>s.type==="section"?r.has(s.group):!0);return o.length?this.firstEmptyOffset=-1:this.handleEmptySearch(),o}return this.items});m(this,"onClose",()=>{this.firstEmptyOffset=-1});m(this,"onShow",(t,e,r,i)=>{const o=this.editor.getBlockByIndex(e,r);if(!dr(o)){const s=Z(it(o));if(s&&Dt(s)==="code")return!1}return!0});m(this,"onClickItem",(t,e)=>{const r=e;r.itemType==="insert-block"&&(p(Qk,r.blockOptions||r.commandProvider,"invalid quick item, no block options or command provider"),p(Qk,this.suggest.anchor,"invalid suggest, no anchor"),this.options.id==="empty-block-menu"&&this.editor.focus(),w$(this.editor,r,this.suggest.anchor))});this.editor=t,this.options=e,this.items=[],this.maxHeading=x0(),this.suggest=new mC(t,{id:e.id||"quick-menu",trigger:e.trigger,needSpaceBeforeTrigger:!0,autoDeleteTrigger:!0,highlight:!0,onClose:this.onClose,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems})}get menu(){return this.suggest.menu.menu}destroy(){this.suggest.destroy()}initMenuItems(){const t=sE(this.editor);this.items=t}refreshMenuItems(){let t=null,e=0;const r=x0();if(r!==this.maxHeading){const i=new Ok,s=i.getCommands().map(l=>({...l,itemType:"insert-block",commandProvider:i}));for(let l=0;l<this.items.length;l++)this.items[l].group==="basics"&&(t||(t=l),t&&e++);t&&e&&this.items.splice(t,e,...s),this.maxHeading=r}}handleEmptySearch(){const t=this.editor.selection.getFocusedPos();if(this.firstEmptyOffset===-1){if(t.isSimple()){const{offset:e}=t;this.firstEmptyOffset=e-1}}else if(t.isSimple()){const{offset:e}=t;e-this.firstEmptyOffset>L$&&(this.suggest.close(),this.firstEmptyOffset=-1)}}}class M0{constructor(t){m(this,"instance");m(this,"mousedown",!1);m(this,"currentInstance",null);m(this,"attributeName",[]);m(this,"attributeDesc","");m(this,"_lastClickButtonId","");m(this,"observer",null);m(this,"observerCallback",null);m(this,"createContent",t=>{let e="",r=0;for(;r<this.attributeName.length&&!e;)t.hasAttribute(this.attributeName[r])&&(e=t.getAttribute(this.attributeName[r])||""),r++;const i=t.getAttribute(this.attributeDesc);if(!i)return e;const o=B("div",[],null);return B("span",[],o,e),i&&B("span",["editor-tooltip-desc"],o,i),o});m(this,"handleDocumentMouseDown",()=>{this.mousedown=!0,this.editor.domEvents.addEventListener(document,"mouseup",this.handleDocumentMouseUp)});m(this,"handleDocumentMouseUp",()=>{this.mousedown=!1,this.editor.domEvents.removeEventListener(document,"mouseup",this.handleDocumentMouseUp)});m(this,"handleShown",t=>{this.currentInstance&&this.hide(),this.currentInstance=t,this.createObserver()});m(this,"handleHidden",()=>{this.destroyObserver(),this.currentInstance=null});m(this,"handleShow",t=>{var i;const e=t.reference;if(!e||!re(document.body,e)||window.isDragging||this.mousedown)return!1;const r=Number.parseInt((i=e.getAttribute("data-tooltip-hide-at"))!=null?i:"",10);if(r&&Date.now()-r<1e3)return!1;if(this._lastClickButtonId===e.getAttribute("data-button-id"))return this._lastClickButtonId="",!1;if(this.attributeName.every(o=>!e.hasAttribute(o)))return!1;if(t.reference){const o={};if(t.reference.hasAttribute("data-editor-tooltip-placement")&&(o.placement=t.reference.getAttribute("data-editor-tooltip-placement")||"top"),t.reference.hasAttribute("data-editor-tooltip-offset-x")||t.reference.hasAttribute("data-editor-tooltip-offset-y")){const l=t.reference.getAttribute("data-editor-tooltip-offset-x"),c=t.reference.getAttribute("data-editor-tooltip-offset-y");o.offset=[l?Number.parseInt(l,10):0,c?Number.parseInt(c,10):0]}t.reference.hasAttribute("data-editor-tooltip-maxwidth")&&(o.maxWidth=Number.parseInt(t.reference.getAttribute("data-editor-tooltip-maxwidth")||"350",10)),t.reference.hasAttribute("data-editor-tooltip-allow-markdown")&&(o.allowHTML=!0);const s=document.body;if(o.appendTo=this.fixContainerForFullscreen(s),Object.keys(o).length&&t.setProps(o),t.reference.hasAttribute(`data-editor-tooltip-${this.editor.clientId}-dynamic`)){const l=t.reference.getAttribute(`data-editor-tooltip-${this.editor.clientId}-dynamic`);t.setContent(l||"")}}return!0});this.editor=t;const e=t.clientId;this.attributeName=[`data-editor-tooltip-${e}`,`data-editor-tooltip-${e}-dynamic`,"data-editor-tooltip-common"],this.attributeDesc=`data-editor-tooltip-desc-${e}`,this.instance=vg.delegate(document.body,{theme:"editor-tooltip",maxWidth:400,delay:200,target:this.attributeName.map(r=>`[${r}]`).join(","),content:this.createContent,onShow:this.handleShow,onShown:this.handleShown,onHide:this.handleHidden,hideOnClick:!1}),t.domEvents.addEventListener(document,"mousedown",this.handleDocumentMouseDown)}set lastClickButtonId(t){this._lastClickButtonId=t,t&&setTimeout(()=>{this._lastClickButtonId===t&&(this._lastClickButtonId="")},500)}visible(){var t;return(t=this.currentInstance)==null?void 0:t.state.isVisible}hide(){var t;(t=this.currentInstance)!=null&&t.state.isVisible&&this.currentInstance.hide()}destroy(){this.destroyObserver(),this.instance.destroy(),this.editor.domEvents.removeEventListener(document,"mousedown",this.handleDocumentMouseDown),this.editor.domEvents.removeEventListener(document,"mouseup",this.handleDocumentMouseUp)}createObserver(){this.destroyObserver();const t=this.currentInstance;if(!t||!t.reference)return;this.observerCallback=Me.default(()=>{t.reference.closest("body")||(t.hide(),this.destroyObserver())},200),this.observer=new MutationObserver(this.observerCallback);const e=document.body,r={childList:!0,attributes:!1,subtree:!0};this.observer.observe(e,r)}destroyObserver(){this.observer&&(this.observer.disconnect(),this.observer=null),this.observerCallback&&(this.observerCallback.cancel(),this.observerCallback=null)}fixContainerForFullscreen(t){return t.closest("body")&&document.fullscreenElement&&!document.fullscreenElement.contains(t)?document.fullscreenElement:t}}const I$={"text/style-bold":"bold","text/style-italic":"italic","text/style-underline":"underline","text/style-strikethrough":"line-through","text/style-code":"code","text/style-sub":"subscript","text/style-super":"superscript",link:"link"};function D$(n,t){const e=new Set(Object.keys(I$)),r=t.filter(o=>e.has(o.id));return E0(r)}function tf(n,t){if(!n.isWritable()||Ti(n))return!1;const e=n.selection.range,r=n.editorCommandProviders.getCommands(e),o=D$(n,r).find(s=>s.id===`text/${t}`||s.id==="link");return o?(n.editorCommandProviders.executeCommand(e,o,{}),nc.get(n).update("selectionChange"),!0):!1}function _$(n,t){const e=n.selection.focusedBlock;if(!n.isWritable()||!nt(n,e))return!1;const r=n.getBlockData(e).heading,i={id:`heading-${t}`,source:"BlockTurnIntoCommandProvider",value:String(t)};return Number(r)===t&&(i.id="text",i.value=null),n.editorCommandProviders.executeCommand(n.selection.range,i,{}),!0}const lE={"CtrlOrCmd+B":n=>tf(n,"style-bold"),"CtrlOrCmd+I":n=>tf(n,"style-italic"),"CtrlOrCmd+U":n=>tf(n,"style-underline"),"CtrlOrCmd+D":n=>tf(n,"style-strikethrough"),"CtrlOrCmd+K":n=>tf(n,"link"),...(()=>{const n={};for(let t=1;t<=8;t++)n[`CtrlOrCmd+${t}`]=e=>_$(e,t);return n})()},M$={quickMenu:{basic:{heading:{title:"\u6807\u9898 {heading}",space:"{markdown}\u7A7A\u683C"},unordered:"\u65E0\u5E8F\u5217\u8868",ordered:"\u6709\u5E8F\u5217\u8868",checkbox:"\u5F85\u529E\u5217\u8868",quote:"\u5F15\u7528"},inlineBox:{math:"\u516C\u5F0F",link:"\u94FE\u63A5"}},link:{textLabel:"\u6587\u672C",urlLabel:"\u94FE\u63A5\u5730\u5740",textPlaceholder:"\u8BF7\u8F93\u5165\u6587\u672C",urlPlaceholder:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740",submitText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",edit:"\u7F16\u8F91",remove:"\u53D6\u6D88\u94FE\u63A5"},commands:{unordered:"\u65E0\u5E8F\u5217\u8868",ordered:"\u6709\u5E8F\u5217\u8868",check:"\u5F85\u529E\u5217\u8868",link:"\u94FE\u63A5",quote:"\u5F15\u7528",alignLeft:"\u5DE6\u5BF9\u9F50",alignRight:"\u53F3\u5BF9\u9F50",alignCenter:"\u5C45\u4E2D\u5BF9\u9F50",alignGroup:"\u5BF9\u9F50\u65B9\u5F0F",heading:"\u6807\u9898 {name}",headingGroup:"\u6807\u9898\u6837\u5F0F",text:"\u6B63\u6587"}},U$={quickMenu:{basic:{heading:{title:"Heading {heading}",space:"{markdown}space"},unordered:"Bulleted list",ordered:"Numbered list",checkbox:"To-do list",quote:"Quote"},inlineBox:{math:"Formula",link:"Link"}},link:{textLabel:"Text",urlLabel:"Link address",textPlaceholder:"Please enter text",urlPlaceholder:"Please enter link",submitText:"Confirm",cancelText:"Cancel",edit:"Edit",remove:"Remove link"},commands:{unordered:"Bulleted list",ordered:"Numberer list",check:"To-do list",link:"Link",quote:"Quote",alignLeft:"Align left",alignRight:"Align right",alignCenter:"Center text",alignGroup:"Alignment",heading:"Heading {name}",headingGroup:"Text style",text:"Text"}},O$={quickMenu:{basic:{heading:{title:"\u898B\u51FA\u3057{heading}",space:"{markdown}\u30B9\u30DA\u30FC\u30B9"},unordered:"\u7B87\u6761\u66F8\u304D\u30EA\u30B9\u30C8",ordered:"\u756A\u53F7\u4ED8\u304D\u30EA\u30B9\u30C8",checkbox:"\u30D0\u30C3\u30AF\u30ED\u30B0",quote:"\u5F15\u7528"},inlineBox:{math:"\u6570\u5F0F",link:"URL"}},link:{textLabel:"\u30C6\u30AD\u30B9\u30C8",urlLabel:"URL",textPlaceholder:"\u30C6\u30AD\u30B9\u30C8\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",urlPlaceholder:"URL \u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",submitText:"OK",cancelText:"\u30AD\u30E3\u30F3\u30BB\u30EB",edit:"\u7DE8\u96C6",remove:"\u30EA\u30F3\u30AF\u3092\u89E3\u9664"},commands:{unordered:"\u7B87\u6761\u66F8\u304D\u30EA\u30B9\u30C8",ordered:"\u756A\u53F7\u4ED8\u304D\u30EA\u30B9\u30C8",check:"\u30D0\u30C3\u30AF\u30ED\u30B0",link:"URL",quote:"\u5F15\u7528",alignLeft:"\u5DE6\u63C3\u3048",alignRight:"\u53F3\u63C3\u3048",alignCenter:"\u4E2D\u592E\u63C3\u3048",alignGroup:"\u5BF9\u9F50\u65B9\u5F0F",heading:"\u898B\u51FA\u3057{name}",headingGroup:"\u30BF\u30A4\u30C8\u30EB\u30B9\u30BF\u30A4\u30EB",text:"\u672C\u6587"}};D.mergeLang({"zh-CN":M$,"en-US":U$,"ja-JP":O$});const Oct="";function ml(n,...t){const e=Cr(...t);return e.classList.remove("editor-button"),e.classList.add("editor-text-button"),n.append(e),e}function Jk(n){const t=A0(n);t==null||t.hide();const e=n.findCustom("table-border-bar");e==null||e.closeToolbar()}function N$(n){return B("div",["insert-column-button","drop-marker"],n)}const P$=I("row-height");function Zk(n){const t=It.fromTable(n),e=n.rows;p(P$,e.length===t.rowCount,"row count mismatch");const r=Array(t.rowCount).fill(0);for(let i=0;i<e.length;){let o=1,l=e[i].getBoundingClientRect().height,c=i+1;for(;c<e.length;){const d=e[c];if(d.cells.length!==0)break;o++,c++,l+=d.getBoundingClientRect().height}for(let d=0;d<o;d++)r[i+d]=l/o;i=c}return r}const F$=I("table-border-bar-dom");function tR(n){var c;const t=Z(n.contentElement);p(F$,t,"no block");const r=ie(t).querySelector(".table-border-bar-container.left"),o=Ot(t).offsetLeft-Ga,s=((c=n.scrollOptions.paddingLeft)!=null?c:0)+o,l=Math.min(n.contentElement.offsetLeft-o,n.rootElement.scrollLeft-s);r&&(r.style.left=`${-l}px`)}const ls=I("table-border-bar-dom");function ic(n,t){p(ls,$e(t),"invalid table block");const e=Ve(t),r=Bi(n,t),i=ie(t),o=(C,E,x)=>{const v=B("div",["button-root",E],C),R=B("div",["button-container",E],v);v.setAttribute(`data-${E}-index`,`${x}`),R.setAttribute(`data-editor-tooltip-${n.clientId}`,E==="left"?D.t("table.insertRow"):D.t("table.insertCol")),B("span",["insert-indicator"],R),N$(R)},{selectedRows:s,selectedColumns:l}=pC(n,t),c=()=>{const C=r.querySelector(".table-border-bar-container.top");p(ls,C,"no top border bar container");const E=B("div",["table-border-bar-container","top"],null),x=B("div",["table-border-bar","top"],E),v=OF(e),L=It.fromTable(e).colCount;n.selection.range.isSimple()&&o(x,"top",0);for(let M=0;M<L;M++){const U=M===L-1?v[M]+2:v[M],F=B("span",["table-border-bar-cell","top"],x);l.has(M)&&F.classList.add("selected"),F.setAttribute("data-top-index",`${M}`),F.style.width=`${U}px`,n.selection.range.isSimple()&&o(x,"top",M+1)}eu(C,E)},d=()=>{const C=i.querySelector(".table-border-bar-container.left");p(ls,C,"no left border bar container");const E=B("div",["table-border-bar-container","left"],null),x=B("div",["table-border-bar","left"],E);B("span",["table-border-bar-cell","corner"],x);const v=Zk(e);n.selection.range.isSimple()&&o(x,"left",0),Array.from(e.rows).forEach((R,L,M)=>{const U=B("span",["table-border-bar-cell","left"],x);s.has(L)&&U.classList.add("selected"),U.setAttribute("data-left-index",`${L}`);const F=L===M.length-1?v[L]+2:v[L];U.style.height=`${F}px`,n.selection.range.isSimple()&&o(x,"left",L+1)}),eu(C,E)};c(),d();const h=n.findCustom(vi(t));h&&tR(h)}function eR(n,t){const e=t.target;if(!(e instanceof Element))return;const r=Z(e);p(ls,r&&$e(r),"invalid table block"),ic(n,r),n.selection.caret.update()}function U0(n,t){const e=t.target;if(!(e instanceof Element))return;const r=Z(e);p(ls,r&&$e(r),"invalid table block");const i=e.closest(".button-root");if(i){if(i.classList.contains("top")){const o=parseInt(i.getAttribute("data-top-index")||"0",10);sk(n,r,o),ic(n,r)}else if(i.classList.contains("left")){const o=parseInt(i.getAttribute("data-left-index")||"0",10);_C(n,r,o),ic(n,r)}}}function O0(n,t){var s;Jk(n),t.preventDefault(),t.stopPropagation();let e=null,r,i;const o=l=>{var c;if(l.target instanceof HTMLElement&&r&&e&&i!==void 0){const d=Z(l.target),h=l.target.closest(".table-border-bar");if(d===e&&h){const C=parseInt((c=l.target.getAttribute(`data-${r}-index`))!=null?c:"0",10),E=Math.min(i,C),x=Math.abs(i-C)+1;wt(l.target,"top")&&r==="top"?YF(n,d,E,x,{reverse:!0}):wt(l.target,"left")&&r==="left"&&QF(n,d,E,x,{reverse:!0})}}l.type==="mouseup"&&(e=null,i=void 0,r=void 0,document.body.removeEventListener("mousemove",o),document.body.removeEventListener("mouseup",o))};t.target instanceof HTMLElement&&wt(t.target,"table-border-bar-cell")&&(e=Z(t.target),wt(t.target,"top")?r="top":wt(t.target,"left")&&(r="left"),r&&e&&(i=parseInt((s=t.target.getAttribute(`data-${r}-index`))!=null?s:"0",10),document.body.addEventListener("mousemove",o),document.body.addEventListener("mouseup",o)))}function nR(n){const t=n.selection.range,e=$u(n,t);e&&ic(n,e)}function K$(n,t){p(ls,$e(t),"invalid table block");const e=Bi(n,t),r=ie(t),i=B("div",["table-border-bar-container","top"],e),o=B("div",["table-border-bar-container","left"],r);ic(n,t),n.domEvents.addEventListener(Ot(t),"scroll",eR),n.domEvents.addEventListener(i,"click",U0),n.domEvents.addEventListener(o,"click",U0),n.domEvents.addEventListener(i,"mousedown",O0),n.domEvents.addEventListener(o,"mousedown",O0),n.addListener("afterClearSelection",nR)}function rR(n,t){if(!n.isWritable())return;if(Bi(n,t).querySelector(".table-border-bar-container")){ic(n,t);return}K$(n,t)}function iR(n,t){p(ls,$e(t),"invalid table block");const e=Bi(n,t),r=ie(t),i=e.querySelectorAll(".table-border-bar-container"),o=r.querySelectorAll(".table-border-bar-container");i.forEach(s=>{n.domEvents.removeEventListener(s,"click",U0),n.domEvents.removeEventListener(s,"mousedown",O0),s.remove()}),o.forEach(s=>{n.domEvents.removeEventListener(s,"click",U0),n.domEvents.removeEventListener(s,"mousedown",O0),s.remove()}),n.domEvents.removeEventListener(Ot(t),"scroll",eR),n.addListener("afterClearSelection",nR)}function V$(n,t){p(ls,$e(t),"invalid table block");const r=Bi(n,t).querySelector(".table-border-bar-container.top");return r?r.getBoundingClientRect().height:0}class $${constructor(t,e){m(this,"toolbar");m(this,"handleSelectionChange",(t,e)=>{!t.isVisible||(e==="delete-columns"?(ns(this.editor,this.tableBlock,!0,!0),rs(this.editor,this.tableBlock,!0,!0)):e==="delete-rows"?(ns(this.editor,this.tableBlock,!0,!1),rs(this.editor,this.tableBlock,!0,!1)):(ns(this.editor,this.tableBlock,!1),rs(this.editor,this.tableBlock,!1)))});m(this,"handleClick",(t,e,r)=>{e.id==="delete-columns"?CC(this.editor.selection.range):e.id==="delete-rows"&&EC(this.editor.selection.range)});m(this,"handleToolbarClose",()=>{this.tableBlock&&$u(this.editor,this.editor.selection.range)===this.tableBlock&&(ns(this.editor,this.tableBlock,!1),rs(this.editor,this.tableBlock,!1))});this.editor=t,this.tableBlock=e;const r=t.options.componentsOptions.popover;this.toolbar=new Fu([],void 0,{id:"table-row-column-toolbar",overflowBoundary:r==null?void 0:r.overflowBoundary,refuseOverflow:!0,tooltipId:this.editor.clientId}),this.toolbar.addListener("selectionChange",this.handleSelectionChange),this.toolbar.addListener("click",this.handleClick),this.toolbar.addListener("close",this.handleToolbarClose)}close(){this.toolbar.close("cancelBar")}update(){var i,o,s;const{selectedColumns:t,selectedRows:e}=pC(this.editor,this.tableBlock);if(!this.editor.isWritable())return;if(t.size>0&&e.size>0){this.toolbar.close("cancelBar");return}if(t.size===0&&e.size===0){this.toolbar.close("cancelBar");return}const r=Yi(this.editor,this.tableBlock,this.editor.selection.range)[0];if(!r){this.toolbar.close("cancelBar");return}if(t.size>0){const l={id:"delete-columns",name:D.t("table.deleteSelectCol"),icon:bT};this.toolbar.updateItems([l]);const c=Zi(this.editor,this.tableBlock,"table-row-column-delete",r);this.toolbar.manualShow(c,{placement:"top",offset:[0,5]})}else{const l={id:"delete-rows",name:D.t("table.deleteSelectRow"),icon:xT};this.toolbar.updateItems([l]);const h=ie(this.tableBlock).querySelector(".table-border-bar-container.left").getBoundingClientRect(),C=new DOMRect(Math.max(h.left,r.left-Ga),r.top,Ga,r.height),E=Zi(this.editor,this.tableBlock,"table-row-column-delete",C);this.toolbar.manualShow(E,{placement:"left",offset:[0,5]});const x=this.editor.options.componentsOptions.popover;(i=this.toolbar.tippyInstance)==null||i.setProps({popperOptions:{modifiers:[{name:"flip",options:{boundary:x==null?void 0:x.overflowBoundary,fallbackPlacements:["left","right"]}}]}})}(s=(o=this.toolbar.tippyInstance)==null?void 0:o.popperInstance)==null||s.update()}destroy(){this.toolbar.destroy(),this.toolbar.removeAllListeners()}}const aE=I("table-border-bar");class H${constructor(t,e){m(this,"toolbar");m(this,"resizeObserver",null);m(this,"handleReadonlyChanged",t=>{t.isWritable()?this.update():iR(this.editor,this.tableBlock)});m(this,"handleBlockUpdated",()=>{var t;(t=this.resizeObserver)==null||t.disconnect(),setTimeout(()=>{var r;const e=this.editor.getBlockById(st(this.tableBlock));(r=this.resizeObserver)==null||r.observe(Ve(e))})});m(this,"handleScroll",()=>{var t;(t=this.toolbar)==null||t.update()});m(this,"handleTableResize",()=>{!this.editor.isWritable()||this.update()});this.editor=t,this.tableBlock=e,p(aE,this.tableBlock,"no table block"),aE.debug("create table border bar"),rR(this.editor,this.tableBlock),this.resizeObserver=new Ms(this.handleTableResize),this.resizeObserver.observe(Ve(this.tableBlock));const r=t.getComponentOptions("table");r!=null&&r.hideToolbar||(this.toolbar=new $$(this.editor,this.tableBlock)),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}close(){var t;(t=this.toolbar)==null||t.close()}destroy(){var t,e;aE.debug("destroy table border bar"),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=null,iR(this.editor,this.tableBlock),(e=this.toolbar)==null||e.destroy(),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged)}update(){var t;rR(this.editor,this.tableBlock),(t=this.toolbar)==null||t.update()}}const j$=I("table-border-bar");class z${constructor(t){m(this,"activeTableBar",null);m(this,"handleBlockDeleted",(t,e)=>{!this.activeTableBar||(e===this.activeTableBar.tableBlock||re(e,this.activeTableBar.tableBlock))&&(this.activeTableBar.destroy(),this.activeTableBar=null)});m(this,"handleSelectionChanged",t=>{setTimeout(()=>{var i;const e=t.selection.range,r=$u(t,e);((i=this.activeTableBar)==null?void 0:i.tableBlock)!==r&&this.activeTableBar&&this.hide(),r&&this.show(r)})});m(this,"handleScroll",()=>{var t;(t=this.activeTableBar)==null||t.handleScroll()});this.editor=t,this.editor.addListener("blockDeleted",this.handleBlockDeleted),this.editor.addListener("selectionChanged",this.handleSelectionChanged)}destroy(){this.editor.removeListener("blockDeleted",this.handleBlockDeleted),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}show(t){this.activeTableBar?(this.activeTableBar.tableBlock!==t&&this.hide(),this.activeTableBar.update()):this.activeTableBar=new H$(this.editor,t)}update(){var t;(t=this.activeTableBar)==null||t.handleBlockUpdated()}closeToolbar(){var t;(t=this.activeTableBar)==null||t.close()}hide(){!this.activeTableBar||(p(j$,this.activeTableBar,"no active table bar"),this.activeTableBar.destroy(),this.activeTableBar=null)}}function oR(n,t){const e=n.addCustom("table-border-bar",r=>new z$(r));t==="update"&&e.update()}const Pn=I("table-cell-menu"),G$="style-bg-color-";class W${constructor(t){m(this,"activeTableBlock",null);m(this,"targetButton",null);m(this,"manualMenu",null);m(this,"colorPaletteItem",null);m(this,"handlePrevent",(t,e)=>{e.stopPropagation()});m(this,"handleReadonlyChanged",t=>{t.isWritable()||this.hide()});m(this,"handleSelectionChanged",t=>{const e=t.selection.range,r=$u(t,e);if(this.hide(),this.activeTableBlock!==r&&(this.activeTableBlock=r),this.activeTableBlock){const i=It.fromBlock(this.activeTableBlock),o=e.isReverse()?e.start:e.end;let s=null;o instanceof Ur?t.getBlockById(o.blockId)===this.activeTableBlock?s=i.getCellByContainerId(o.childContainerId):s=this.getCellByChildBlockId(i,o.blockId):o.blockId!==this.activeTableBlock.id&&(s=this.getCellByChildBlockId(i,o.blockId)),s&&this.editor.isWritable()&&this.showCellMenuButton(s)}});m(this,"handleBeforePopupPalette",()=>{var e;const t=this.getSelectedBkgColorIndex();(e=this.colorPaletteItem)==null||e.palette.setColor("backgroundColor",t)});m(this,"createBkgColorItem",()=>{const t=B("div",["cell-background-color-item"],null);B("span",[],t,D.t("table.cellBackground"));const e=this.getSelectedBkgColorIndex();B("button",["item-button"],t).setAttribute("data-color-index",`${e}`);const i=B("span",["item-sub-indicator"],t);return i.innerHTML=Qp,t});m(this,"handleCommand",t=>{var i;p(Pn,this.activeTableBlock,"no target table block");const e=((i=t.states)==null?void 0:i.includes("checked"))||!1,r=t.value;switch(t.id){case"delete-select-row":EC(Vy(this.editor,this.activeTableBlock,!1));break;case"delete-select-col":CC(Vy(this.editor,this.activeTableBlock,!0));break;case"merge-cell":Py(this.editor.selection.range);break;case"split-cell":this.handleSplitCell();break;case"row-title":this.handleRowTitle(e);break;case"col-title":this.handleColTitle(e);break;case"stripe-style":this.handleStripeStyle(e);break;case"hide-border":sF(this.editor,this.activeTableBlock,r==="show-border");break;case"show-chart":cF(this.editor,this.activeTableBlock,r==="show-chart"),yC(this.editor,this.activeTableBlock,{updateNow:!0});break}});m(this,"handleToolbarClose",()=>{this.targetButton&&ot(this.targetButton,"active"),this.activeTableBlock&&$u(this.editor,this.editor.selection.range)===this.activeTableBlock&&(ns(this.editor,this.activeTableBlock,!1),rs(this.editor,this.activeTableBlock,!1)),this.editor.focus()});m(this,"handleSelectionChange",(t,e)=>{!t.isVisible||(p(Pn,this.activeTableBlock,"no target table block"),e==="cell-background-color"&&this.handleBeforePopupPalette(),e==="delete-select-row"?(ns(this.editor,this.activeTableBlock,!0,!1),rs(this.editor,this.activeTableBlock,!0,!1)):e==="delete-select-col"?(ns(this.editor,this.activeTableBlock,!0,!0),rs(this.editor,this.activeTableBlock,!0,!0)):(ns(this.editor,this.activeTableBlock,!1),rs(this.editor,this.activeTableBlock,!1)))});m(this,"handleClick",(t,e)=>{var r;p(Pn,this.activeTableBlock,"no target table block"),p(Pn,this.targetButton,"no target button"),Jk(this.editor),wt(this.targetButton,"active")?(ot(this.targetButton,"active"),(r=this.manualMenu)==null||r.close("clickItem")):(z(this.targetButton,"active"),this.manualMenu?this.manualMenu.updateItems(this.createCommandMenu()):(this.manualMenu=new ts(this.createCommandMenu(),void 0,{id:"table-cell-menu"}),this.manualMenu.on("click",(i,o)=>{var s;this.handleCommand(o),(s=this.manualMenu)==null||s.close("clickItem")}),this.manualMenu.on("selectionChange",this.handleSelectionChange),this.manualMenu.on("close",this.handleToolbarClose)),this.manualMenu.manualShow(this.targetButton,{placement:"right-start"})),e.stopPropagation()});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChanged),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}destroy(){var t,e;this.activeTableBlock=null,this.targetButton=null,this.editor.removeListener("selectionChanged",this.handleSelectionChanged),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged),(t=this.manualMenu)==null||t.destroy(),(e=this.colorPaletteItem)==null||e.destroy()}hide(){var t;(t=this.manualMenu)==null||t.close("cancelBar"),this.targetButton&&(ot(this.targetButton,"active"),this.targetButton.style.display="none")}getCellByChildBlockId(t,e){let r=this.editor.getBlockById(e);for(;r;){const i=r.closest("td");p(Pn,i,"no parent cell");const o=Z(i);if(p(Pn,o,"no parent block"),Ve(o)===t.table)return t.getCellByCellElement(i);r=o}return p(Pn,!1,"filed to get cell by child block id"),null}createTargetButton(t){this.targetButton?t.querySelector(`:scope > .${BC}`)||t.appendChild(this.targetButton):(this.targetButton=B("button",[BC],t),this.targetButton.innerHTML=qh,this.editor.domEvents.addEventListener(this.targetButton,"click",this.handleClick),this.editor.domEvents.addEventListener(this.targetButton,"mousedown",this.handlePrevent),this.editor.domEvents.addEventListener(this.targetButton,"dblclick",this.handlePrevent))}showCellMenuButton(t){this.createTargetButton(t.cell),p(Pn,this.targetButton,"no target button"),this.targetButton.style.display="inline-block"}handleSplitCell(){if(this.activeTableBlock){const t=It.fromBlock(this.activeTableBlock),e=this.editor.selection.range;if(e.isSimple()){const{col:r,row:i}=this.getCellByChildBlockId(t,e.start.blockId);xC(this.editor,this.activeTableBlock,{col:r,row:i})}else bC(this.editor.selection.range)}}getSelectedBkgColorIndex(){var s;p(Pn,this.activeTableBlock,"no target table block");const t=this.editor.selection.range,e=es(this.editor,this.activeTableBlock,t.focus),r=this.editor.getBlockData(this.activeTableBlock),i=e.childContainerId,o=r[`${i}_background`];return o?Number.parseInt((s=o.substring(G$.length))!=null?s:"0",10):-1}createCommandMenu(){p(Pn,this.activeTableBlock,"no target table block");const t=this.editor.getBlockData(this.activeTableBlock),e=Ny(this.editor,this.activeTableBlock,this.editor.selection.range);let r=this.editor.selection.range;if(r.isSimple()){const h=es(this.editor,this.activeTableBlock,r.start);r=qe(this.editor,{anchor:h,focus:h})}const i=Oy(this.editor,this.activeTableBlock,r),o=t.hasRowTitle,s=t.hasColTitle,l=t.isStripeStyle,c=t.noBorder,d=t.chart;return this.colorPaletteItem=new Sy("cell-background-color",{color:!1}),this.colorPaletteItem.palette.on("onClick",(h,C)=>{var E;switch(p(Pn,this.activeTableBlock,"no target table block"),h){case"clearColor":jy(this.editor,this.activeTableBlock,-1);break;case"backgroundColor":jy(this.editor,this.activeTableBlock,C);break}(E=this.manualMenu)==null||E.close("clickItem")}),[{id:"cell-background-color",name:D.t("table.cellBackground"),element:this.createBkgColorItem(),children:[this.colorPaletteItem]},{id:"separator",name:"",type:"separator"},{id:"merge-cell",name:D.t("table.mergeCell"),states:e?[]:["disabled"]},{id:"split-cell",name:D.t("table.splitCell"),states:i?[]:["disabled"]},{id:"separator",name:"",type:"separator"},{id:"delete-select-row",name:D.t("table.deleteSelectRow")},{id:"delete-select-col",name:D.t("table.deleteSelectCol")},{id:"separator",name:"",type:"separator"},{id:"table-config",name:D.t("table.tableConfigKey"),children:[{id:"row-title",name:D.t("table.tableConfig.rowTitle"),states:o?["checked"]:[]},{id:"col-title",name:D.t("table.tableConfig.colTitle"),states:s?["checked"]:[]},{id:"stripe-style",name:D.t("table.tableConfig.stripeStyle"),states:l?["checked"]:[]},{id:"hide-border",name:c?D.t("table.tableConfig.showBorder"):D.t("table.tableConfig.hideBorder"),value:c?"show-border":"hide-border"},{id:"show-chart",name:d?D.t("table.tableConfig.hideChart"):D.t("table.tableConfig.showChart"),value:d?"hide-chart":"show-chart"}]}]}handleRowTitle(t){p(Pn,this.activeTableBlock,"no target table block"),t?rF(this.editor,this.activeTableBlock):nF(this.editor,this.activeTableBlock)}handleColTitle(t){p(Pn,this.activeTableBlock,"no target table block"),t?eF(this.editor,this.activeTableBlock):tF(this.editor,this.activeTableBlock)}handleStripeStyle(t){p(Pn,this.activeTableBlock,"no target table block"),t?oF(this.editor,this.activeTableBlock):iF(this.editor,this.activeTableBlock)}}function sR(n){n.addCustom("table-cell-menu",t=>new W$(t))}const N0=I("table-container");function cE(n){const t=n.closest("td");return p(N0,t,"no parent cell for a table cell container"),t}function lR(n){const t=Ve(n);return Array.from(t.querySelectorAll(':scope > tbody > tr > td > [data-type="editor-container"].child'))}function uE(n,t,e,r){const i=It.fromBlock(n),o=i.getCellByContainerId(ft(t));if(e==="ArrowDown"){const s=i.getBottomCell(o);return s?s.container:null}if(e==="ArrowUp"){const s=i.getTopCell(o);return s?s.container:null}if(e==="ArrowLeft"){const s=i.getAllContainers(),l=s.indexOf(t);if(p(N0,l>=0,"not a valid child container"),l===0)return null;const c=s[l-1];return r!=null&&r.noWrap&&i.getCellByContainerId(ft(c)).row!==o.row?null:c}if(e==="ArrowRight"){const s=i.getAllContainers(),l=s.indexOf(t);if(p(N0,l>=0,"not a valid child container"),l===s.length-1)return null;const c=s[l+1];return r!=null&&r.noWrap&&i.getCellByContainerId(ft(c)).row!==o.row?null:c}p(N0,!1,`invalid navigation type: ${e}`)}const q$=12,X$=90,P0=23,aR=2;class Y${constructor(t){m(this,"scrollTableBlock",null);m(this,"autoScrollDir",null);m(this,"autoScrollTimer",null);m(this,"handleMouseDown",t=>{const e=document.elementFromPoint(t.clientX,t.clientY);if(e&&e instanceof HTMLElement){const r=Z(e);if(r&&re(this.editor.rootContainer,r)){const i=fo(r);i&&(this.scrollTableBlock=i,document.addEventListener("mousemove",this.handleAutoScroll))}}});m(this,"handleAutoScroll",s9.default(t=>{if(this.scrollTableBlock){const e=this.editor.getCustom(vi(this.scrollTableBlock)),r=e.rootElement,i=e.scrollOptions.parentContainer,o=r.getBoundingClientRect(),s=window.innerHeight-this.getBarFloatWindowBottom(e),l=i.getBoundingClientRect(),c=Math.min(l.bottom,s),d=Math.max(l.top,0);o.bottom>c&&t.clientY>=c?this.setAutoScroll("bottom"):o.top<d&&t.clientY<=d?this.setAutoScroll("top"):r.scrollLeft>0&&t.clientX<o.left?this.setAutoScroll("left"):r.scrollLeft<r.scrollWidth-r.offsetWidth&&t.clientX>o.right?this.setAutoScroll("right"):this.clearAutoScroll()}},15));m(this,"handleMouseUp",()=>{document.removeEventListener("mousemove",this.handleAutoScroll),setTimeout(()=>{this.scrollTableBlock=null})});m(this,"handleSelectionChanged",t=>{const e=t.selection.range;if(e.isCollapsed()&&e.isSimple()){const r=t.getBlockById(e.start.blockId),i=fo(r);if(i){const o=t.getCustom(vi(i)),s=o.rootElement.getBoundingClientRect(),l=_r(t,r,e.start);if(s.left>l.left){const c=e.start.offset===0?q$:aR;o.rootElement.scrollLeft-=s.left-l.left+c}else if(l.right>s.right){const c=e.start.offset===0?X$:aR;o.rootElement.scrollLeft+=l.right-s.right+c}}}else{const r=t.getBlockById(e.start.blockId),i=fo(r),o=t.getBlockById(e.end.blockId),s=fo(o);if(i&&i===s){const l=t.getCustom(vi(i)),c=l.rootElement.getBoundingClientRect();let d=null;if(e.isSimple())d=e.isReverse()?_r(t,r,e.start):_r(t,o,e.end);else{const h=cE(ui(t,e.start.childContainerId)),C=cE(ui(t,e.end.childContainerId));d=e.isReverse()?h.getBoundingClientRect():C.getBoundingClientRect()}c.left>d.left&&e.isReverse()?l.rootElement.scrollLeft-=c.left-d.left:c.right<d.right&&!e.isReverse()&&(l.rootElement.scrollLeft+=d.right-c.right)}}});m(this,"handleScroll",t=>{_y(t),this.editor.selection.caret.update()});m(this,"handleReset",t=>{_y(t),this.editor.selection.caret.update();const e=this.editor.findCustom("table-border-bar");e&&e.handleScroll(),tR(t)});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChanged),document.addEventListener("mousedown",this.handleMouseDown),document.addEventListener("mouseup",this.handleMouseUp)}getBarFloatWindowBottom(t){return t.scrollOptions.barFloatWindowBottom?typeof t.scrollOptions.barFloatWindowBottom=="number"?t.scrollOptions.barFloatWindowBottom:t.scrollOptions.barFloatWindowBottom():0}clearAutoScroll(){this.autoScrollTimer&&(clearInterval(this.autoScrollTimer),this.autoScrollTimer=null,this.autoScrollDir=null)}setAutoScroll(t){this.autoScrollDir&&this.autoScrollDir!==t&&this.clearAutoScroll(),this.autoScrollTimer||(this.autoScrollDir=t,this.autoScrollTimer=window.setInterval(()=>{if(this.scrollTableBlock){const e=this.editor.getCustom(vi(this.scrollTableBlock)),r=e.rootElement,i=e.scrollOptions.parentContainer,o=r.getBoundingClientRect(),s=i===document.documentElement?window.innerHeight:i.offsetHeight,l=window.innerHeight-this.getBarFloatWindowBottom(e),c=i.getBoundingClientRect(),d=Math.min(c.bottom,l),h=Math.max(c.top,0);this.autoScrollDir==="left"&&(r.scrollLeft-=P0,r.scrollLeft<=0&&this.clearAutoScroll()),this.autoScrollDir==="right"&&(r.scrollLeft+=P0,r.scrollLeft>=r.scrollWidth-r.offsetWidth&&this.clearAutoScroll()),this.autoScrollDir==="bottom"&&(i.scrollTop+=P0,(i.scrollTop>=i.scrollHeight-s||o.bottom<=d)&&this.clearAutoScroll()),this.autoScrollDir==="top"&&(i.scrollTop-=P0,(i.scrollTop<=0||o.top>=h)&&this.clearAutoScroll())}},100))}destroy(){document.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mouseup",this.handleMouseUp),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}}function cR(n){return n.addCustom("table-scroll-events",t=>new Y$(t))}const Q$=I("table-doc-change-handler");class J${constructor(t){this.editor=t,this.editor.addListener("docChanged",this.handleDocChanged)}handleDocChanged(t,e){if(!e){const{start:r,end:i}=t.selection.range;if(!t.findBlockById(r.blockId)||!t.findBlockById(i.blockId)){t.selection.selectBlock(t.getBlockByIndex("root",0),0);return}if(ga(r)){const o=t.getBlockById(r.blockId);if(!$e(o))return;if(p(Q$,ga(i),"invalid range"),!zd(t,r.childContainerId)||!zd(t,i.childContainerId)){t.selection.selectBlock(o,0);return}let s=null,l=null;const c=(d,h)=>{const C=h.getCellById(d.childContainerId),{colIndex:E=0,rowIndex:x=0}=d.custom;let v=-1,R=-1;return(C.col>E||C.col+C.colSpan-1<E)&&(v=C.col),(C.row>x||C.row+C.rowSpan-1<x)&&(R=C.row),v!==-1||R!==-1?Ae(o,d.childContainerId,{colIndex:v===-1?E:v,rowIndex:R===-1?x:R}):null};if(r.custom){const d=It.fromBlock(o);s=c(r,d),l=c(i,d)}(s!==null||l!==null)&&(t.selection.range.isReverse()?t.selection.setSelection(l!=null?l:i,s!=null?s:r):t.selection.setSelection(s!=null?s:r,l!=null?l:i))}}}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged)}}function uR(n){n.addCustom("table-doc-change-handler",t=>new J$(t))}const yi=I("create-content");function fR(n,t,e){var C;const r=new c0(e),i=e.rows,o=e.cols;p(yi,i>=1,`invalid rows: ${i}`),p(yi,o>=1,`invalid cols: ${o}`),p(yi,e.children,"no table children");const s=B("table",[],null),l=(C=e.colsWidth)!=null?C:new Array(e.cols).fill(0),c=B("colgroup",[],s);for(let E=0;E<r.colCount;E++){const x=B("col",[],c);l[E]&&(x.style.width=`${l[E]}px`)}const d=B("tbody",[],s);let h=0;for(let E=0;E<i;E++){const x=B("tr",[],d);for(let v=0;v<o;v++){const R=r.getCell({col:v,row:E});if(R.virtual)p(yi,R.colSpan>1||R.rowSpan>1,"virtual cell should have colSpan or rowSpan");else{const L=e.children[h],M=B("td",[],x);R.colSpan>1&&(M.colSpan=R.colSpan),R.rowSpan>1&&(M.rowSpan=R.rowSpan);const U=e[zu(L)];U&&z(M,U),v===0&&e.hasColTitle&&z(M,Fy.COL_TITLE_ITEM),n.createChildContainer(t,M,L),h+=1}}}return p(yi,h===e.children.length,"container count mismatch"),s.style.minWidth=`${l.reduce((E,x)=>x+E,0)}px`,e.noBorder&&z(s,"no-border"),e.chart&&z(s,"editor-table-chart"),e.isStripeStyle&&z(s,"stripe"),e.hasRowTitle&&z(s,"row-title"),e.hasColTitle&&z(s,"col-title"),s}function Z$(n,t,e,r,i){p(yi,i.type==="table","not table data"),p(yi,ft(e)===t[t.length-1].containerId,"invalid path");const o=i,s=js(r,"div");try{const l=B("div",[],null);l.setAttribute("data-type","table-content");const c=fR(n,t,o);c.classList.add("drag-preview-element"),l.appendChild(c);const d=n.getComponentOptions("table");ik(n),lk(n),oR(n,"create"),uR(n),d!=null&&d.hideCellMenu||sR(n),pT(n,kC);const h=n.addCustom(vi(r),()=>MF());h.init({parentElement:s,childElement:l,safeRightSpace:50,safeLeftSpace:40,parentContainer:Qt(e)?n.scrollContainer:e,locatingContainer:Qt(e)?(d==null?void 0:d.locatingContainer)||n.parent:e,paddingLeft:Ga+ju,paddingTop:Ga+ju,paddingBottom:ju/2,paddingRight:ju/2,barFloatWindowBottom:d==null?void 0:d.barFloatWindowBottom,allowScrollBarFixed:d==null?void 0:d.allowScrollBarFixed,isSetScale:d==null?void 0:d.isSetScale});const C=cR(n);h.on("scroll",C.handleReset),h.on("resize",C.handleReset),setTimeout(()=>{dF(n,r)})}catch{const c=`invalid table data: ${JSON.stringify(o)}`;yi.error(c);const d=B("div",["error"],s);d.innerText=c}return s}function tH(n,t,e){p(yi,e.type==="table","not table data");const r=e,i=Ot(t);try{const o=Ve(t),s=$o(t),l=fR(n,s,r);l.classList.add("drag-preview-element"),o.insertAdjacentElement("afterend",l),o.remove();const c=n.getComponentOptions("table");ik(n),lk(n),oR(n,"update"),uR(n),c!=null&&c.hideCellMenu||sR(n),kC(n,t)}catch{const s=`invalid table data: ${JSON.stringify(r)}`;yi.error(s);const l=B("div",["error"],i);l.innerText=s}}function eH(n,t){let e,r,i=!1;if([...t].every(E=>E==="|")?(r=t.length,e=Array(r).fill(""),i=!0):(e=Og(t,"|").split("|"),r=e.length),r<2)return null;const o=3,s=r,l=[];for(let E=0;E<3;E++)e.forEach(x=>{l.push(ro(n.doc,E===0?x:""))});const c=Array(s).fill(SC),d=l[i?0:s],h=n.doc.getContainerBlocks(d)[0].id;return{blockData:{id:tt(),type:"table",rows:o,cols:s,children:l,colsWidth:c},focusBlockId:h}}function nH(n,t){const e=t.rows,r=t.cols;if(e<1||r<1)return null;const i=[];for(let d=0;d<e;d++)for(let h=0;h<r;h++)i.push(ro(n.doc));const o=Array(r).fill(SC),s=i[0],l=n.doc.getContainerBlocks(s)[0].id;return{blockData:{id:tt(),type:"table",rows:e,cols:r,children:i,colsWidth:o},focusBlockId:l}}const fE=I("get-selected-containers");function dR(n,t,e,r){p(fE,e.blockId===r.blockId,"only allow select in single table block"),p(fE,st(t)===e.blockId,"only allow select in single table block");const i=It.fromBlock(t),o=i.getCellByContainerId(e.childContainerId),s=i.getCellByContainerId(r.childContainerId);if(e.custom===void 0||r.custom===void 0)return i.getCells(o,s).map(L=>i.getCellContainer(L));const{fromCol:l,toCol:c,fromRow:d,toRow:h}=Gr(t,e,r),C=new Set,E=[];return i.sub({row:d,col:l},{row:h,col:c}).forEach(v=>{v.forEach(R=>{const L=i.getCellByContainerId(R.containerId);L.col<l||L.row<d||L.col+L.colSpan-1>c||L.row+L.rowSpan-1>h||C.has(R.containerId)||(C.add(R.containerId),E.push(L.container))})}),E}function rH(n,t,e){p(fE,t.blockId===e.blockId,"only allow select in single table block");const r=n.getBlockById(t.blockId);return dR(n,r,t,e)}const hR=I("table-selection-to-doc");function iH(n,t){const{start:e,end:r,block:i}=t,o=Dt(i);p(hR,o==="table",`invalid block type: ${o}`);const s=n.getBlockData(i);if(e.isSimple()&&r.isSimple())return Xo(n.editorBlocks,n.doc.toJSON(),s);p(hR,!e.isSimple()&&!r.isSimple(),"invalid block pos type");const l=It.fromBlock(i),{fromCol:c,toCol:d,fromRow:h,toRow:C}=Gr(i,e,r),E={},x=[],v=n.doc.toJSON();let R={};l.sub({row:h,col:c},{row:C,col:d}).forEach((rt,lt)=>{rt.forEach((Et,vt)=>{const xt=Et.containerId;if(x.indexOf(xt)!==-1)return;x.push(xt);let Gt;if(Et.virtual){const be=l.getCellByContainerId(Et.containerId),Fn=c+vt;let _i=be.col+be.colSpan-1;_i>d&&(_i=d);const kn=_i-Fn+1;kn>1&&(E[`${xt}_colSpan`]=kn);const pn=h+lt;let Mi=be.row+be.rowSpan-1;Mi>C&&(Mi=C);const po=Mi-pn+1;po>1&&(E[`${xt}_rowSpan`]=po),Gt=Ci()}else{if(Gt=lp(n.editorBlocks,v,xt),Et.col+Et.colSpan>d+1){const be=d-Et.col+1;be>1&&(E[`${xt}_colSpan`]=be)}else Et.colSpan>1&&(E[`${xt}_colSpan`]=Et.colSpan);if(Et.row+Et.rowSpan>C+1){const be=C-Et.row+1;be>1&&(E[`${xt}_rowSpan`]=be)}else Et.rowSpan>1&&(E[`${xt}_rowSpan`]=Et.rowSpan)}const{root:Yt,...ln}=Gt.blocks;R={...R,...ln,[xt]:Yt}})});const M=Yu(Ve(i)).slice(c,d+1);return{blocks:{root:[{id:tt(),type:o,children:x,colsWidth:M,rows:C-h+1,cols:d-c+1,...E}],...R},meta:{},comments:{}}}const oH=I("ajust-selection-pos");function sH(n,t){if(t.top===0)return!0;for(let e=t.left;e<=t.right;e++)if(n[t.top-1][e]===n[t.top][e])return!1;return!0}function lH(n,t){if(t.left===0)return!0;for(let e=t.top;e<=t.bottom;e++)if(n[e][t.left-1]===n[e][t.left])return!1;return!0}function aH(n,t){if(t.bottom===n.length-1)return!0;for(let e=t.left;e<=t.right;e++)if(n[t.bottom][e]===n[t.bottom+1][e])return!1;return!0}function cH(n,t){if(t.right===n[0].length-1)return!0;for(let e=t.top;e<=t.bottom;e++)if(n[e][t.right]===n[e][t.right+1])return!1;return!0}function uH(n,t,e){const r=t.col,i=t.row,o=e.col,s=e.row,l={left:r,top:i,right:o,bottom:s};let c=!1;do{if(c=!1,!sH(n,l)){l.top--,c=!0;continue}if(!lH(n,l)){l.left--,c=!0;continue}if(!aH(n,l)){l.bottom++,c=!0;continue}if(!cH(n,l)){l.right++,c=!0;continue}}while(c);return l}function fH(n,t,e,r){if(e.custom!==void 0||r.custom!==void 0)return{anchor:e,focus:r};const i=It.fromBlock(t),o=i.map(F=>F.containerId),s=i.getCellByContainerId(e.childContainerId),l=i.getCellByContainerId(r.childContainerId),c=Math.min(s.row,l.row),d=Math.max(s.row,l.row),h=Math.min(s.col,l.col),C=Math.max(s.col,l.col),E=uH(o,{row:c,col:h},{row:d,col:C}),x=i.getCell({row:E.top,col:E.left}),v=i.getCell({row:E.bottom,col:E.right}),R=i.getCell({row:E.top,col:E.right}),L=i.getCell({row:E.bottom,col:E.left});let M,U;return s.row<=l.row?s.col<=l.col?(M=x,U=v):(M=R,U=L):s.col<l.col?(M=L,U=R):(M=v,U=x),oH.debug(`move ${M.col}, ${M.row}, -> ${U.col}, ${U.row}`),{anchor:Ae(t,M.containerId),focus:Ae(t,U.containerId)}}function mR(n,t,e){if(e.isSimple())return[Ve(t).getBoundingClientRect()];const r=Ve(t),i=r.getBoundingClientRect(),{fromCol:o,fromRow:s,toCol:l,toRow:c}=Gr(t,e.start,e.end),d=Yu(r),h=d.slice(0,o).reduce((R,L)=>R+L,0),C=h+d.slice(o,l+1).reduce((R,L)=>R+L,0),E=Zk(r);let x=E.slice(0,s).reduce((R,L)=>R+L,0);const v=x+E.slice(s,c+1).reduce((R,L)=>R+L,0);if(s===0){const R=V$(n,t);x-=R}return[new DOMRect(i.left+h,i.top+x,C-h,v-x)]}I("table-size");const dH=40;function F0(n){const t=n.querySelector("td");if(!t)return 0;const e=window.getComputedStyle(t),r=Number.parseInt(e.borderLeft,10),i=Number.parseInt(e.borderRight,10);return(r+i)/2}function hH(n,t,e){const r=l1(n,e.container);return r!==void 0?r+F0(t):dH*e.colSpan-F0(t)}function mH(n,t,e,r){let i=0;const o=e.colCount;for(let s=0;s<o;s++){const l=e.getCell({col:s,row:r});if(l.virtual)continue;let c=hH(n,t,l);const d=n3(l.container,{withPadding:!0});d&&d>c&&(c=d),i+=c+F0(t)}return i}function gH(n,t){const e=Ve(t),r=It.fromTable(e);let i=0;for(let s=0;s<r.rowCount;s++)i=Math.max(i,mH(n,e,r,s));const o=F0(e);return i+=o,i}const ho=I("table-creator");async function pH(n,t){return n.undoManager.runInGroup(()=>{var c,d;const e=t.item,r=(c=e.colCount)!=null?c:5,i=(d=e.rowCount)!=null?d:3,o=nH(n,{cols:r,rows:i});if(!o)return null;const{blockData:s,focusBlockId:l}=o;return n.insertBlock(t.containerId,t.blockIndex,s,ye(n,l,0))})}class CH{constructor(){m(this,"id","insert-table");m(this,"name","Create table");m(this,"element");m(this,"closeable",null);m(this,"colCount");m(this,"rowCount");m(this,"setCloseable",t=>{this.closeable=t});m(this,"destroy",()=>{this.closeable=null});m(this,"getTableCreatorCellId",(t,e)=>`table-creator-cell-${t}-${e}`);m(this,"handleTableCreatorClick",t=>{var E,x;t.preventDefault(),t.stopPropagation();const e=t.target;p(ho,e instanceof HTMLElement,"invalid event target");const r=e.closest(".table-creator");p(ho,r,"no table creator");const i=r.querySelectorAll(".active");if(i.length===0)return;const s=i[i.length-1].id;p(ho,s,"no cell id");const l="table-creator-cell-";if(!s.startsWith(l))return;const d=s.substring(l.length).split("-");p(ho,d.length===2,"invalid cell id");const h=Number.parseInt(d[0],10)+1,C=Number.parseInt(d[1],10)+1;ho.debug(`${h}, ${C}`),this.colCount=C,this.rowCount=h,(E=this.closeable)==null||E.click(this,this.element),(x=this.closeable)==null||x.close("clickItem"),this.handleTableCreatorLeave()});m(this,"handleTableCreatorLeave",()=>{for(let t=0;t<9;t++)for(let e=0;e<9;e++){const r=this.getTableCreatorCellId(t,e),i=document.getElementById(r);i&&ot(i,"active")}});m(this,"handleTableCreatorCellEnter",t=>{const e=t.target;p(ho,e instanceof HTMLElement,"invalid event target");const r=e.id,i="table-creator-cell-";p(ho,r.startsWith(i),"invalid cell id");const s=r.substring(i.length).split("-");p(ho,s.length===2,"invalid cell id");let l=Number.parseInt(s[0],10),c=Number.parseInt(s[1],10);l===0&&c===0&&(l=-1,c=-1);for(let d=0;d<9;d++)for(let h=0;h<9;h++){const C=this.getTableCreatorCellId(d,h),E=document.getElementById(C);p(ho,E,"no cell"),d<=l&&h<=c?z(E,"active"):ot(E,"active")}});this.element=this.createTableCreatorElement()}createTableCreatorElement(){const t=B("div",["table-creator"],null),e=(r,i,o)=>{const s=B("div",["table-creator-cell"],r);return s.id=this.getTableCreatorCellId(i,o),s};t.addEventListener("click",this.handleTableCreatorClick),t.addEventListener("mouseleave",this.handleTableCreatorLeave);for(let r=0;r<9;r++){const i=B("div",["table-creator-row"],t);for(let o=0;o<9;o++)e(i,r,o).addEventListener("mouseenter",this.handleTableCreatorCellEnter)}return t}}function EH(){return new CH}function AH(n){const t=/[\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g,e=n.match(t);return e?e.length:0}function gR(n){const t=AH(n);return n.length+t}function xH(n,t,e=[]){let r=0;if(!e||e.length===0)return r;for(let i=n;i<n+t;i+=1)r+=e[i]||0;return r}function bH(n,t){const e=gR(n),r=t-e;return r>0?n+" ".repeat(r):n}function vH(n,t,e,r,i){var l;const o=t,s=new c0(o);if(r==="markdown"||r==="text"){const c=M=>e.blocks[M].map((G,W)=>r==="markdown"?bh(n,G,e,[...i,{containerId:M,blockIndex:W}]):xh(n,G,e,[...i,{containerId:M,blockIndex:W}])),d=M=>c(M).join(" ").replace(/\n/g," ").trim(),h=new Map,C=new Map;for(let M=0;M<s.colCount;M++){let U=0;for(let F=0;F<s.rowCount;F++){const G=s.getCell({row:F,col:M});let W="";G.virtual||(W=d(G.containerId)),h.set(`${F},${M}`,W),U=Math.max(U,gR(W))}C.set(M,U)}const E=M=>{const U=h.get(`${M.row},${M.col}`)||"",F=C.get(M.col)||0;return bH(U,F)};if(r==="text"){const M=[];for(let U=0;U<s.colCount;U++){const F=E({row:0,col:U});M.push(F)}for(let U=1;U<s.rowCount;U++)for(let F=0;F<s.colCount;F++){const G=E({row:U,col:F});M.push(G)}return M.join(`
|
|
642
|
+
}`;var Nt=R6(function(){return Wt(w,At+"return "+et).apply(e,O)});if(Nt.source=et,fb(Nt))throw Nt;return Nt}function tlt(a){return ne(a).toLowerCase()}function elt(a){return ne(a).toUpperCase()}function nlt(a,u,g){if(a=ne(a),a&&(g||u===e))return vo(a);if(!a||!(u=lr(u)))return a;var A=sr(a),T=sr(u),w=Nl(A,T),O=ad(A,T)+1;return Ls(A,w,O).join("")}function rlt(a,u,g){if(a=ne(a),a&&(g||u===e))return a.slice(0,Pc(a)+1);if(!a||!(u=lr(u)))return a;var A=sr(a),T=ad(A,sr(u))+1;return Ls(A,0,T).join("")}function ilt(a,u,g){if(a=ne(a),a&&(g||u===e))return a.replace(Vf,"");if(!a||!(u=lr(u)))return a;var A=sr(a),T=Nl(A,sr(u));return Ls(A,T).join("")}function olt(a,u){var g=xt,A=Gt;if(Re(u)){var T="separator"in u?u.separator:T;g="length"in u?Ut(u.length):g,A="omission"in u?lr(u.omission):A}a=ne(a);var w=a.length;if(Bo(a)){var O=sr(a);w=O.length}if(g>=w)return a;var P=g-ys(A);if(P<1)return A;var V=O?Ls(O,0,P).join(""):a.slice(0,P);if(T===e)return V+A;if(O&&(P+=V.length-P),db(T)){if(a.slice(P).search(T)){var Y,Q=V;for(T.global||(T=$c(T.source,ne(Bc.exec(T))+"g")),T.lastIndex=0;Y=T.exec(Q);)var et=Y.index;V=V.slice(0,et===e?P:et)}}else if(a.indexOf(lr(T),P)!=P){var ht=V.lastIndexOf(T);ht>-1&&(V=V.slice(0,ht))}return V+A}function slt(a){return a=ne(a),a&&NA.test(a)?a.replace(Bm,Fc):a}var llt=jc(function(a,u,g){return a+(g?" ":"")+u.toUpperCase()}),gb=wL("toUpperCase");function k6(a,u,g){return a=ne(a),u=g?e:u,u===e?Uc(a)?zm(a):ir(a):a.match(u)||[]}var R6=Pt(function(a,u){try{return Rn(a,e,u)}catch(g){return fb(g)?g:new St(g)}}),alt=Oo(function(a,u){return Vn(u,function(g){g=Hi(g),Mo(a,g,cb(a[g],a))}),a});function clt(a){var u=a==null?0:a.length,g=Tt();return a=u?Ce(a,function(A){if(typeof A[1]!="function")throw new wn(s);return[g(A[0]),A[1]]}):[],Pt(function(A){for(var T=-1;++T<u;){var w=a[T];if(Rn(w[0],this,A))return Rn(w[1],this,A)}})}function ult(a){return Unt(yr(a,C))}function pb(a){return function(){return a}}function flt(a,u){return a==null||a!==a?u:a}var dlt=LL(),hlt=LL(!0);function Wn(a){return a}function Cb(a){return sL(typeof a=="function"?a:yr(a,C))}function mlt(a){return aL(yr(a,C))}function glt(a,u){return cL(a,yr(u,C))}var plt=Pt(function(a,u){return function(g){return Ed(g,a,u)}}),Clt=Pt(function(a,u){return function(g){return Ed(a,g,u)}});function Eb(a,u,g){var A=nn(u),T=ng(u,A);g==null&&!(Re(u)&&(T.length||!A.length))&&(g=u,u=a,a=this,T=ng(u,nn(u)));var w=!(Re(g)&&"chain"in g)||!!g.chain,O=Po(a);return Vn(T,function(P){var V=u[P];a[P]=V,O&&(a.prototype[P]=function(){var Y=this.__chain__;if(w||Y){var Q=a(this.__wrapped__),et=Q.__actions__=jn(this.__actions__);return et.push({func:V,args:arguments,thisArg:a}),Q.__chain__=Y,Q}return V.apply(a,Pi([this.value()],arguments))})}),a}function Elt(){return Je._===this&&(Je._=Wm),this}function Ab(){}function Alt(a){return a=Ut(a),Pt(function(u){return uL(u,a)})}var xlt=Yx(Ce),blt=Yx(Nm),vlt=Yx(od);function w6(a){return rb(a)?Dc(Hi(a)):Jnt(a)}function Blt(a){return function(u){return a==null?e:ea(a,u)}}var Tlt=DL(),ylt=DL(!0);function xb(){return[]}function bb(){return!1}function klt(){return{}}function Rlt(){return""}function wlt(){return!0}function Slt(a,u){if(a=Ut(a),a<1||a>pn)return[];var g=xr,A=_(a,xr);u=Tt(u),a-=xr;for(var T=Mc(A,u);++g<a;)u(g);return T}function Llt(a){return Mt(a)?Ce(a,Hi):ar(a)?[a]:jn(qL(ne(a)))}function Ilt(a){var u=++Gm;return ne(a)+u}var Dlt=ag(function(a,u){return a+u},0),_lt=Qx("ceil"),Mlt=ag(function(a,u){return a/u},1),Ult=Qx("floor");function Olt(a){return a&&a.length?eg(a,Wn,Ox):e}function Nlt(a,u){return a&&a.length?eg(a,Tt(u,2),Ox):e}function Plt(a){return Ic(a,Wn)}function Flt(a,u){return Ic(a,Tt(u,2))}function Klt(a){return a&&a.length?eg(a,Wn,Kx):e}function Vlt(a,u){return a&&a.length?eg(a,Tt(u,2),Kx):e}var $lt=ag(function(a,u){return a*u},1),Hlt=Qx("round"),jlt=ag(function(a,u){return a-u},0);function zlt(a){return a&&a.length?_c(a,Wn):0}function Glt(a,u){return a&&a.length?_c(a,Tt(u,2)):0}return k.after=mot,k.ary=o6,k.assign=est,k.assignIn=A6,k.assignInWith=bg,k.assignWith=nst,k.at=rst,k.before=s6,k.bind=cb,k.bindAll=alt,k.bindKey=l6,k.castArray=kot,k.chain=n6,k.chunk=Urt,k.compact=Ort,k.concat=Nrt,k.cond=clt,k.conforms=ult,k.constant=pb,k.countBy=zit,k.create=ist,k.curry=a6,k.curryRight=c6,k.debounce=u6,k.defaults=ost,k.defaultsDeep=sst,k.defer=got,k.delay=pot,k.difference=Prt,k.differenceBy=Frt,k.differenceWith=Krt,k.drop=Vrt,k.dropRight=$rt,k.dropRightWhile=Hrt,k.dropWhile=jrt,k.fill=zrt,k.filter=Wit,k.flatMap=Yit,k.flatMapDeep=Qit,k.flatMapDepth=Jit,k.flatten=JL,k.flattenDeep=Grt,k.flattenDepth=Wrt,k.flip=Cot,k.flow=dlt,k.flowRight=hlt,k.fromPairs=qrt,k.functions=hst,k.functionsIn=mst,k.groupBy=Zit,k.initial=Yrt,k.intersection=Qrt,k.intersectionBy=Jrt,k.intersectionWith=Zrt,k.invert=pst,k.invertBy=Cst,k.invokeMap=eot,k.iteratee=Cb,k.keyBy=not,k.keys=nn,k.keysIn=Gn,k.map=gg,k.mapKeys=Ast,k.mapValues=xst,k.matches=mlt,k.matchesProperty=glt,k.memoize=Cg,k.merge=bst,k.mergeWith=x6,k.method=plt,k.methodOf=Clt,k.mixin=Eb,k.negate=Eg,k.nthArg=Alt,k.omit=vst,k.omitBy=Bst,k.once=Eot,k.orderBy=rot,k.over=xlt,k.overArgs=Aot,k.overEvery=blt,k.overSome=vlt,k.partial=ub,k.partialRight=f6,k.partition=iot,k.pick=Tst,k.pickBy=b6,k.property=w6,k.propertyOf=Blt,k.pull=rit,k.pullAll=t6,k.pullAllBy=iit,k.pullAllWith=oit,k.pullAt=sit,k.range=Tlt,k.rangeRight=ylt,k.rearg=xot,k.reject=lot,k.remove=lit,k.rest=bot,k.reverse=lb,k.sampleSize=cot,k.set=kst,k.setWith=Rst,k.shuffle=uot,k.slice=ait,k.sortBy=hot,k.sortedUniq=git,k.sortedUniqBy=pit,k.split=Yst,k.spread=vot,k.tail=Cit,k.take=Eit,k.takeRight=Ait,k.takeRightWhile=xit,k.takeWhile=bit,k.tap=Oit,k.throttle=Bot,k.thru=mg,k.toArray=p6,k.toPairs=v6,k.toPairsIn=B6,k.toPath=Llt,k.toPlainObject=E6,k.transform=wst,k.unary=Tot,k.union=vit,k.unionBy=Bit,k.unionWith=Tit,k.uniq=yit,k.uniqBy=kit,k.uniqWith=Rit,k.unset=Sst,k.unzip=ab,k.unzipWith=e6,k.update=Lst,k.updateWith=Ist,k.values=Wc,k.valuesIn=Dst,k.without=wit,k.words=k6,k.wrap=yot,k.xor=Sit,k.xorBy=Lit,k.xorWith=Iit,k.zip=Dit,k.zipObject=_it,k.zipObjectDeep=Mit,k.zipWith=Uit,k.entries=v6,k.entriesIn=B6,k.extend=A6,k.extendWith=bg,Eb(k,k),k.add=Dlt,k.attempt=R6,k.camelCase=Ost,k.capitalize=T6,k.ceil=_lt,k.clamp=_st,k.clone=Rot,k.cloneDeep=Sot,k.cloneDeepWith=Lot,k.cloneWith=wot,k.conformsTo=Iot,k.deburr=y6,k.defaultTo=flt,k.divide=Mlt,k.endsWith=Nst,k.eq=oi,k.escape=Pst,k.escapeRegExp=Fst,k.every=Git,k.find=qit,k.findIndex=YL,k.findKey=lst,k.findLast=Xit,k.findLastIndex=QL,k.findLastKey=ast,k.floor=Ult,k.forEach=r6,k.forEachRight=i6,k.forIn=cst,k.forInRight=ust,k.forOwn=fst,k.forOwnRight=dst,k.get=hb,k.gt=Dot,k.gte=_ot,k.has=gst,k.hasIn=mb,k.head=ZL,k.identity=Wn,k.includes=tot,k.indexOf=Xrt,k.inRange=Mst,k.invoke=Est,k.isArguments=ia,k.isArray=Mt,k.isArrayBuffer=Mot,k.isArrayLike=zn,k.isArrayLikeObject=Ne,k.isBoolean=Uot,k.isBuffer=Is,k.isDate=Oot,k.isElement=Not,k.isEmpty=Pot,k.isEqual=Fot,k.isEqualWith=Kot,k.isError=fb,k.isFinite=Vot,k.isFunction=Po,k.isInteger=d6,k.isLength=Ag,k.isMap=h6,k.isMatch=$ot,k.isMatchWith=Hot,k.isNaN=jot,k.isNative=zot,k.isNil=Wot,k.isNull=Got,k.isNumber=m6,k.isObject=Re,k.isObjectLike=De,k.isPlainObject=Td,k.isRegExp=db,k.isSafeInteger=qot,k.isSet=g6,k.isString=xg,k.isSymbol=ar,k.isTypedArray=Gc,k.isUndefined=Xot,k.isWeakMap=Yot,k.isWeakSet=Qot,k.join=tit,k.kebabCase=Kst,k.last=Rr,k.lastIndexOf=eit,k.lowerCase=Vst,k.lowerFirst=$st,k.lt=Jot,k.lte=Zot,k.max=Olt,k.maxBy=Nlt,k.mean=Plt,k.meanBy=Flt,k.min=Klt,k.minBy=Vlt,k.stubArray=xb,k.stubFalse=bb,k.stubObject=klt,k.stubString=Rlt,k.stubTrue=wlt,k.multiply=$lt,k.nth=nit,k.noConflict=Elt,k.noop=Ab,k.now=pg,k.pad=Hst,k.padEnd=jst,k.padStart=zst,k.parseInt=Gst,k.random=Ust,k.reduce=oot,k.reduceRight=sot,k.repeat=Wst,k.replace=qst,k.result=yst,k.round=Hlt,k.runInContext=K,k.sample=aot,k.size=fot,k.snakeCase=Xst,k.some=dot,k.sortedIndex=cit,k.sortedIndexBy=uit,k.sortedIndexOf=fit,k.sortedLastIndex=dit,k.sortedLastIndexBy=hit,k.sortedLastIndexOf=mit,k.startCase=Qst,k.startsWith=Jst,k.subtract=jlt,k.sum=zlt,k.sumBy=Glt,k.template=Zst,k.times=Slt,k.toFinite=Fo,k.toInteger=Ut,k.toLength=C6,k.toLower=tlt,k.toNumber=wr,k.toSafeInteger=tst,k.toString=ne,k.toUpper=elt,k.trim=nlt,k.trimEnd=rlt,k.trimStart=ilt,k.truncate=olt,k.unescape=slt,k.uniqueId=Ilt,k.upperCase=llt,k.upperFirst=gb,k.each=r6,k.eachRight=i6,k.first=ZL,Eb(k,function(){var a={};return Vi(k,function(u,g){qt.call(k.prototype,g)||(a[g]=u)}),a}(),{chain:!1}),k.VERSION=r,Vn(["bind","bindKey","curry","curryRight","partial","partialRight"],function(a){k[a].placeholder=k}),Vn(["drop","take"],function(a,u){Vt.prototype[a]=function(g){g=g===e?1:S(Ut(g),0);var A=this.__filtered__&&!u?new Vt(this):this.clone();return A.__filtered__?A.__takeCount__=_(g,A.__takeCount__):A.__views__.push({size:_(g,xr),type:a+(A.__dir__<0?"Right":"")}),A},Vt.prototype[a+"Right"]=function(g){return this.reverse()[a](g).reverse()}}),Vn(["filter","map","takeWhile"],function(a,u){var g=u+1,A=g==be||g==_i;Vt.prototype[a]=function(T){var w=this.clone();return w.__iteratees__.push({iteratee:Tt(T,3),type:g}),w.__filtered__=w.__filtered__||A,w}}),Vn(["head","last"],function(a,u){var g="take"+(u?"Right":"");Vt.prototype[a]=function(){return this[g](1).value()[0]}}),Vn(["initial","tail"],function(a,u){var g="drop"+(u?"":"Right");Vt.prototype[a]=function(){return this.__filtered__?new Vt(this):this[g](1)}}),Vt.prototype.compact=function(){return this.filter(Wn)},Vt.prototype.find=function(a){return this.filter(a).head()},Vt.prototype.findLast=function(a){return this.reverse().find(a)},Vt.prototype.invokeMap=Pt(function(a,u){return typeof a=="function"?new Vt(this):this.map(function(g){return Ed(g,a,u)})}),Vt.prototype.reject=function(a){return this.filter(Eg(Tt(a)))},Vt.prototype.slice=function(a,u){a=Ut(a);var g=this;return g.__filtered__&&(a>0||u<0)?new Vt(g):(a<0?g=g.takeRight(-a):a&&(g=g.drop(a)),u!==e&&(u=Ut(u),g=u<0?g.dropRight(-u):g.take(u-a)),g)},Vt.prototype.takeRightWhile=function(a){return this.reverse().takeWhile(a).reverse()},Vt.prototype.toArray=function(){return this.take(xr)},Vi(Vt.prototype,function(a,u){var g=/^(?:filter|find|map|reject)|While$/.test(u),A=/^(?:head|last)$/.test(u),T=k[A?"take"+(u=="last"?"Right":""):u],w=A||/^find/.test(u);!T||(k.prototype[u]=function(){var O=this.__wrapped__,P=A?[1]:arguments,V=O instanceof Vt,Y=P[0],Q=V||Mt(O),et=function(jt){var zt=T.apply(k,Pi([jt],P));return A&&ht?zt[0]:zt};Q&&g&&typeof Y=="function"&&Y.length!=1&&(V=Q=!1);var ht=this.__chain__,At=!!this.__actions__.length,yt=w&&!ht,Nt=V&&!At;if(!w&&Q){O=Nt?O:new Vt(this);var kt=a.apply(O,P);return kt.__actions__.push({func:mg,args:[et],thisArg:e}),new Hn(kt,ht)}return yt&&Nt?a.apply(this,P):(kt=this.thru(et),yt?A?kt.value()[0]:kt.value():kt)})}),Vn(["pop","push","shift","sort","splice","unshift"],function(a){var u=Vl[a],g=/^(?:push|sort|unshift)$/.test(a)?"tap":"thru",A=/^(?:pop|shift)$/.test(a);k.prototype[a]=function(){var T=arguments;if(A&&!this.__chain__){var w=this.value();return u.apply(Mt(w)?w:[],T)}return this[g](function(O){return u.apply(Mt(O)?O:[],T)})}}),Vi(Vt.prototype,function(a,u){var g=k[u];if(g){var A=g.name+"";qt.call(an,A)||(an[A]=[]),an[A].push({name:u,func:g})}}),an[lg(e,M).name]=[{name:"wrapper",func:e}],Vt.prototype.clone=snt,Vt.prototype.reverse=lnt,Vt.prototype.value=ant,k.prototype.at=Nit,k.prototype.chain=Pit,k.prototype.commit=Fit,k.prototype.next=Kit,k.prototype.plant=$it,k.prototype.reverse=Hit,k.prototype.toJSON=k.prototype.valueOf=k.prototype.value=jit,k.prototype.first=k.prototype.head,ql&&(k.prototype[ql]=Vit),k},ko=Vc();xo?((xo.exports=ko)._=ko,Qf._=ko):Je._=ko}).call(_n)})(er,er.exports);function f$(n,t,e,r){a0(n,{className:"status-input",defaultValue:t,onChange:e,onKeyDown:r,maxLength:32})}const iE=["Blue","Grey","Yellow","Red","Green","Purple"];function d$(){const n=B("div",["status-color-palette"],null);for(const t of iE){const e=B("button",["status-box-button"],null);e.setAttribute("data-color",er.exports.lowerCase(t)),e.setAttribute("title",D.t(`status.color.${er.exports.lowerCase(t)}`)),n.appendChild(e)}return n}class h${constructor(){m(this,"root",d$());m(this,"changeColor",t=>{for(const r of Array.from(this.root.querySelectorAll(":scope > button")))r.classList.remove("selected");const e=this.root.querySelector(`button[data-color="${er.exports.lowerCase(t)}"]`);e==null||e.classList.add("selected")})}}function m$(n){localStorage.setItem(`statusBox.lastColor.${er.exports.lowerCase(n.color)}`,n.title)}function Gk(n){var t;return(t=localStorage.getItem(`statusBox.lastColor.${er.exports.lowerCase(n)}`))!=null?t:D.t(`status.colorDefaultTitle.${er.exports.lowerCase(n)}`)}function Wk(){var i;const n=iE[0],t=(i=Gk(n))!=null?i:D.t(`status.colorDefaultTitle.${er.exports.lowerCase(n)}`);return{insert:" ",attributes:{id:tt(),type:"status",box:!0,title:t,subtle:!1,created:Date.now(),color:n}}}const D0=I("StatusBoxEditor");class oE{constructor(t){m(this,"linkPopup",null);m(this,"boxElement");m(this,"statusPalette",new h$);m(this,"isEditing",!1);m(this,"editorStatus",t=>{if(!this.editor.isWritable())return;const e=this.editor.getBoxData(t);this.linkPopup=new $a(this.createPopupContent(e.title,e.color,e.subtle),{id:"status-box-popup"}),this.linkPopup.on("show",this.handleShow),this.linkPopup.on("close",this.handClose),this.linkPopup.manualShow(t,{theme:"light",placement:"bottom-start",offset:[5,5]}),this.boxElement=t});m(this,"handleShow",()=>{this.focus()});m(this,"handClose",()=>{var r;p(D0,this.boxElement,"boxElement not found");const t=this.editor.getBoxData(this.boxElement),e=Z(this.boxElement);if(p(D0,e,"block not found"),t.title)m$(t);else{const i=Go(e,this.boxElement);this.editor.deleteTextFromBlock(e,i.start,1)}this.editor.focus(),(r=this.linkPopup)==null||r.destroy(),this.linkPopup=null,this.boxElement=void 0,this.isEditing=!1});m(this,"handleKeyDown",t=>{var e;t.key==="Enter"&&((e=this.linkPopup)==null||e.close(null))});m(this,"onColorChange",t=>{var o,s;if(!(t.target instanceof HTMLElement)||t.target.closest("[data-color]")===null)return;const e=er.exports.capitalize(t.target.getAttribute("data-color"));p(D0,this.boxElement,"boxElement not found");const r=this.editor.getBoxData(this.boxElement);this.statusPalette.changeColor(e);const i={...r,color:e};if(!this.isEditing){const l=(s=(o=this.linkPopup)==null?void 0:o.popper)==null?void 0:s.querySelector("input"),c=Gk(e);l&&(l.value=c),i.title=c}this.editor.updateBoxData(i,{noFocus:!0}),this.focus()});m(this,"onTitleChange",t=>{const e=t.target.value;p(D0,this.boxElement,"boxElement not found");const i={...this.editor.getBoxData(this.boxElement),title:e.trim()};this.editor.updateBoxData(i,{noFocus:!0}),this.isEditing=!0});this.editor=t,this.statusPalette.root.addEventListener("click",this.onColorChange)}focus(){setTimeout(()=>{var t,e,r,i,o,s;(r=(e=(t=this.linkPopup)==null?void 0:t.popper)==null?void 0:e.querySelector("input"))==null||r.focus(),(s=(o=(i=this.linkPopup)==null?void 0:i.popper)==null?void 0:o.querySelector("input"))==null||s.select()},100)}createPopupContent(t,e,r){const i=B("div",["status-box-editor-popup"],null);return f$(i,t,this.onTitleChange,this.handleKeyDown),this.isEditing=!1,i.appendChild(this.statusPalette.root),this.statusPalette.changeColor(e),i}destroy(){var t;(t=this.linkPopup)==null||t.destroy()}}const Ict="";class qk{constructor(t){m(this,"onMouseOver",t=>{const e=t.target;if(e.hasAttribute("data-editor-overflow-tooltip"))if(this.check(e)){const r=e.getAttribute("data-editor-overflow-tooltip");e.setAttribute(`data-editor-tooltip-${this.editor.clientId}`,r)}else e.removeAttribute(`data-editor-tooltip-${this.editor.clientId}`)});this.editor=t,this.editor.rootContainer.addEventListener("mouseover",this.onMouseOver)}check(t){return t.scrollWidth>t.offsetWidth}destroy(){this.editor.rootContainer.removeEventListener("mouseover",this.onMouseOver)}static create(t,e){const r=B("a",t,null,this.replaceTitleSpace(e));return r.setAttribute("data-editor-overflow-tooltip",this.replaceTitleSpace(e)),r}static replaceTitleSpace(t){return t.replace(/\s/g,"\xA0")}}function g$(n,t,e,r){const i=r,{title:o,subtle:s,color:l}=i,c=s?["box-status-common",`box-status-${er.exports.lowerCase(l)}-subtle`]:["box-status-common",`box-status-${er.exports.lowerCase(l)}`];o||c.push("box-status-empty");const d=qk.create(c,o||D.t("status.empty"));e.appendChild(d),n.addCustom("status-box-overflow-tooltip",h=>new qk(h)),n.addCustom("status-box",h=>new oE(h))}function p$(n,t){return{abstract:D.t("status.command.name")}}function C$(n,t){n.getCustom("status-box").editorStatus(t)}function E$(n,t){const{title:e}=t;return e!=null?e:""}async function A$(n,t){var s;const{title:e,color:r}=t,i=iE.indexOf(r),o=[4,6,2,0,3,5];return[{insert:e!=null?e:"",attributes:{[`style-color-${(s=o[i])!=null?s:4}`]:!0}}]}const Xk={boxType:"status",updateBoxContent:g$,getBoxProperties:p$,handleClickBox:C$,convertTo:E$,toStandardText:A$},x$=I("status-box-command");class rc{static get commands(){return[{id:this.id,name:D.t("status.command.name"),icon:Cy,order:650,group:"common",subText:"/status"}]}static insertStatus(t,e,r){var c;const i=t.getBlockByIndex(e,r),o=Wk(),{start:s}=t.selection.range;p(x$,Or(s),"invalid block position"),t.insertBoxToBlock(i,s.offset,o.attributes);const l=t.getBoxById((c=o.attributes)==null?void 0:c.id);t.addCustom("status-box",d=>new oE(d)).editorStatus(l)}static insertEmptyBlockStatus(t,e,r){var l;let i=t.getBlockByIndex(e,r);(!i||!oe(t,i))&&(i=t.insertTextBlock([],e,r));const o=Wk();t.setBlockText(i,[o]);const s=t.getBoxById((l=o.attributes)==null?void 0:l.id);return t.addCustom("status-box",c=>new oE(c)).editorStatus(s),i}}m(rc,"id","insert-status");const b$={"en-US":{status:{empty:"Set status",command:{name:"Status"},color:{red:"Red",yellow:"Yellow",green:"Green",blue:"Blue",purple:"Purple",grey:"Gray"},colorDefaultTitle:{red:"Delayed",yellow:"In progress",green:"Done",blue:"Not started",purple:"To be confirmed",grey:"Paused"}}},"zh-CN":{status:{empty:"\u8BBE\u7F6E\u72B6\u6001",command:{name:"\u72B6\u6001"},color:{red:"\u7EA2\u8272",yellow:"\u9EC4\u8272",green:"\u7EFF\u8272",blue:"\u84DD\u8272",purple:"\u7D2B\u8272",grey:"\u7070\u8272"},colorDefaultTitle:{red:"\u5DF2\u5EF6\u671F",yellow:"\u8FDB\u884C\u4E2D",green:"\u5DF2\u5B8C\u6210",blue:"\u672A\u5F00\u59CB",purple:"\u5F85\u786E\u8BA4",grey:"\u5DF2\u6682\u505C"}}},"ja-JP":{status:{empty:"\u30B9\u30C6\u30FC\u30BF\u30B9\u3092\u8A2D\u5B9A",command:{name:"\u30B9\u30C6\u30FC\u30BF\u30B9"},color:{red:"\u8D64",yellow:"\u9EC4",green:"\u7EFF",blue:"\u9752",purple:"\u7D2B",grey:"\u7070"},colorDefaultTitle:{red:"\u9045\u5EF6",yellow:"\u9032\u884C\u4E2D",green:"\u5B8C\u4E86",blue:"\u672A\u7740\u624B",purple:"\u672A\u78BA\u8A8D",grey:"\u4E00\u6642\u505C\u6B62"}}}};D.mergeLang(b$);const hl=I("inline-box-items");function v$(n,t,e){return n.undoManager.runInGroup(()=>{var s;let r=n.findBlockByIndex(t,e);(!r||!oe(n,r))&&(r=n.insertTextBlock([],t,e));const i=Hk();n.setBlockText(r,[i]);const o=(s=i.attributes)==null?void 0:s.id;return p(hl,o,"mathjax box id is empty"),setTimeout(()=>{const l=n.getBoxById(o);I0(n,l)},100),r})}function B$(n,t,e){let r=n.findBlockByIndex(t,e),i="bottom-start";return(!r||!oe(n,r))&&(i="top-start",r=n.insertTextBlock([],t,e)),Qu(n,{target:r,linkText:"",linkUrl:"",onFinished:(l,c)=>{n.undoManager.runInGroup(()=>{try{p(hl,r,"block not found"),oe(n,r)||(r=n.insertTextBlock([],t,e));const d=gr(l,{link:c}),h=gr(" ",null),C=[d,h];n.insertTextToBlock(r,0,C),n.selection.selectBlock(r,fn(C)),n.focus()}catch(d){hl.error(d)}})},onClose:()=>{n.focus()},placement:i}),r}function T$(n,t,e){return n.undoManager.runInGroup(()=>{var l;const r=n.getBlockByIndex(t,e),i=n.selection.range;p(hl,Or(i.start),"invalid block position");const o=Hk();n.insertBoxToBlock(r,i.start.offset,o.attributes);const s=(l=o.attributes)==null?void 0:l.id;return p(hl,s,"mathjax box id is empty"),setTimeout(()=>{const c=n.getBoxById(s);I0(n,c)},100),r})}function y$(n,t,e){const r=n.getBlockByIndex(t,e),i=n.selection.range;p(hl,Or(i.start),"invalid block position");const o=Yi(n,r,i);if(o.length===0)return;const s=o[0],l=Zi(n,r,"quick-menu-inline-link",s);Qu(n,{target:l,linkText:"",linkUrl:"",onFinished:(h,C)=>{n.undoManager.runInGroup(()=>{try{const E=n.getBlockText(r),x=no(E,i.start.offset,h,{link:C});n.setBlockText(r,x),n.selection.selectBlock(r,i.start.offset+h.length),n.focus()}catch(E){hl.error(E)}})},onClose:()=>{n.focus()},placement:"bottom-start"})}class Yk{getCommands(){return[{id:"insert-math",name:D.t("quickMenu.inlineBox.math"),icon:MT,order:900,group:"common",subText:Tn("insert-math")},{id:"insert-link",name:D.t("quickMenu.inlineBox.link"),icon:rC,order:400,group:"common",subText:Tn("insert-link")},...rc.commands]}async handleUpdateBlockCore(t,e){switch(e.item.id){case"insert-math":return T$(t,e.containerId,e.blockIndex);case"insert-link":return y$(t,e.containerId,e.blockIndex);case rc.id:return rc.insertStatus(t,e.containerId,e.blockIndex);default:return null}}async handleInsertEmptyBlockCore(t,e){switch(e.item.id){case"insert-math":return v$(t,e.containerId,e.blockIndex);case"insert-link":return B$(t,e.containerId,e.blockIndex);case rc.id:return rc.insertEmptyBlockStatus(t,e.containerId,e.blockIndex);default:return null}}async executeCommand(t,e,r){if(r.from==="quick-menu"){const i=t.getBlockById(r.blockId),o=t.getParentContainer(i),s=ft(o),l=t.getBlockIndex(i);t.undoManager.runInGroup(()=>this.handleUpdateBlockCore(t,{item:e,containerId:s,blockIndex:l}))}else r.from==="block-menu"&&t.undoManager.runInGroup(()=>this.handleInsertEmptyBlockCore(t,{item:e,containerId:r.containerId,blockIndex:r.blockIndex}));return null}}function k$(n,t={withPlainText:!1}){var o,s;const{withPlainText:e}=t,r=(s=(o=n.options.componentsOptions)==null?void 0:o.quickMenu)==null?void 0:s.commandProviders;if(!r)return[];const i=[];return[...r,new Ok(e),new Yk].forEach(l=>{const c=l.getCommands(n);i.push(...c.map(d=>({...d,itemType:"insert-block",commandProvider:l})))}),i}function R$(n,t={withPlainText:!1}){const e=[];return n.editorBlocks.forEach(r=>{if(!r.getOptions)return;const i=r.getOptions(n);!i.insertBlockCommandItems||(i.insertBlockCommandItems.forEach(o=>{Uk(o,i)}),e.push(...i.insertBlockCommandItems))}),e.push(...k$(n,t)),e}function sE(n,t={withPlainText:!1}){const e=R$(n,t),r=new Map;e.forEach(s=>{var d;const l=(d=s.group)!=null?d:"";let c=r.get(l);c?c.items.push(s):(c={group:l,order:s.groupOrder||Nk[l]||1e3,items:[s]},r.set(l,c))});const i=Array.from(r.values());i.sort((s,l)=>s.order-l.order),i.forEach(s=>{s.items.sort((l,c)=>{var d,h;return((d=l.order)!=null?d:0)-((h=c.order)!=null?h:0)})});const o=[];return i.forEach((s,l)=>{const c=`blockMenu.section.${s.group||"common"}`,d=D.t(c),h=d===c?s.group:d;o.push({id:`section-${l}`,name:h,type:"section",group:s.group,itemType:"insert-block"}),o.push(...s.items.map(C=>({...C})))}),o}function w$(n,t,e){const r=n.getFocusedBlock();if(!r)return;const i=n.getParentContainer(r),o=ft(i);let l=n.getBlockIndex(r);if(oe(n,r)||(l+=1),t.commandProvider){t.commandProvider.executeCommand(n,t,{from:"quick-menu",...e});return}!t.blockOptions||!t.blockOptions.handleInsertEmptyBlock||t.blockOptions.handleInsertEmptyBlock(n,{containerId:o,blockIndex:l,item:t})}const Qk=I("quick-menu"),S$={id:"quick-menu",trigger:["/"]},L$=5;class _0{constructor(t,e=S$){m(this,"suggest");m(this,"items");m(this,"maxHeading");m(this,"firstEmptyOffset",-1);m(this,"queryItems",async(t,e)=>{if(this.items.length===0?this.initMenuItems():this.refreshMenuItems(),e){const r=new Set,i=e.toLocaleLowerCase().replace(/^\s+|\s+$/g,""),o=this.items.filter(s=>{if(s.type==="section")return!0;if(s.name.toLocaleLowerCase().indexOf(i)!==-1||FP(s).toLocaleLowerCase().indexOf(i)!==-1)return r.add(s.group),!0;const l=`blockMenu.section.${s.group||"common"}`,c=D.t(l),d=c===l?s.group:c;return(d==null?void 0:d.toLocaleLowerCase().indexOf(i))!==-1?(r.add(s.group),!0):!1}).filter(s=>s.type==="section"?r.has(s.group):!0);return o.length?this.firstEmptyOffset=-1:this.handleEmptySearch(),o}return this.items});m(this,"onClose",()=>{this.firstEmptyOffset=-1});m(this,"onShow",(t,e,r,i)=>{const o=this.editor.getBlockByIndex(e,r);if(!dr(o)){const s=Z(it(o));if(s&&Dt(s)==="code")return!1}return!0});m(this,"onClickItem",(t,e)=>{const r=e;r.itemType==="insert-block"&&(p(Qk,r.blockOptions||r.commandProvider,"invalid quick item, no block options or command provider"),p(Qk,this.suggest.anchor,"invalid suggest, no anchor"),this.options.id==="empty-block-menu"&&this.editor.focus(),w$(this.editor,r,this.suggest.anchor))});this.editor=t,this.options=e,this.items=[],this.maxHeading=x0(),this.suggest=new mC(t,{id:e.id||"quick-menu",trigger:e.trigger,needSpaceBeforeTrigger:!0,autoDeleteTrigger:!0,highlight:!0,onClose:this.onClose,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems})}get menu(){return this.suggest.menu.menu}destroy(){this.suggest.destroy()}initMenuItems(){const t=sE(this.editor);this.items=t}refreshMenuItems(){let t=null,e=0;const r=x0();if(r!==this.maxHeading){const i=new Ok,s=i.getCommands().map(l=>({...l,itemType:"insert-block",commandProvider:i}));for(let l=0;l<this.items.length;l++)this.items[l].group==="basics"&&(t||(t=l),t&&e++);t&&e&&this.items.splice(t,e,...s),this.maxHeading=r}}handleEmptySearch(){const t=this.editor.selection.getFocusedPos();if(this.firstEmptyOffset===-1){if(t.isSimple()){const{offset:e}=t;this.firstEmptyOffset=e-1}}else if(t.isSimple()){const{offset:e}=t;e-this.firstEmptyOffset>L$&&(this.suggest.close(),this.firstEmptyOffset=-1)}}}class M0{constructor(t){m(this,"instance");m(this,"mousedown",!1);m(this,"currentInstance",null);m(this,"attributeName",[]);m(this,"attributeDesc","");m(this,"_lastClickButtonId","");m(this,"observer",null);m(this,"observerCallback",null);m(this,"createContent",t=>{let e="",r=0;for(;r<this.attributeName.length&&!e;)t.hasAttribute(this.attributeName[r])&&(e=t.getAttribute(this.attributeName[r])||""),r++;const i=t.getAttribute(this.attributeDesc);if(!i)return e;const o=B("div",[],null);return B("span",[],o,e),i&&B("span",["editor-tooltip-desc"],o,i),o});m(this,"handleDocumentMouseDown",()=>{this.mousedown=!0,this.editor.domEvents.addEventListener(document,"mouseup",this.handleDocumentMouseUp)});m(this,"handleDocumentMouseUp",()=>{this.mousedown=!1,this.editor.domEvents.removeEventListener(document,"mouseup",this.handleDocumentMouseUp)});m(this,"handleShown",t=>{this.currentInstance&&this.hide(),this.currentInstance=t,this.createObserver()});m(this,"handleHidden",()=>{this.destroyObserver(),this.currentInstance=null});m(this,"handleShow",t=>{var i;const e=t.reference;if(!e||!re(document.body,e)||window.isDragging||this.mousedown)return!1;const r=Number.parseInt((i=e.getAttribute("data-tooltip-hide-at"))!=null?i:"",10);if(r&&Date.now()-r<1e3)return!1;if(this._lastClickButtonId===e.getAttribute("data-button-id"))return this._lastClickButtonId="",!1;if(this.attributeName.every(o=>!e.hasAttribute(o)))return!1;if(t.reference){const o={};if(t.reference.hasAttribute("data-editor-tooltip-placement")&&(o.placement=t.reference.getAttribute("data-editor-tooltip-placement")||"top"),t.reference.hasAttribute("data-editor-tooltip-offset-x")||t.reference.hasAttribute("data-editor-tooltip-offset-y")){const l=t.reference.getAttribute("data-editor-tooltip-offset-x"),c=t.reference.getAttribute("data-editor-tooltip-offset-y");o.offset=[l?Number.parseInt(l,10):0,c?Number.parseInt(c,10):0]}t.reference.hasAttribute("data-editor-tooltip-maxwidth")&&(o.maxWidth=Number.parseInt(t.reference.getAttribute("data-editor-tooltip-maxwidth")||"350",10)),t.reference.hasAttribute("data-editor-tooltip-allow-markdown")&&(o.allowHTML=!0);const s=document.body;if(o.appendTo=this.fixContainerForFullscreen(s),Object.keys(o).length&&t.setProps(o),t.reference.hasAttribute(`data-editor-tooltip-${this.editor.clientId}-dynamic`)){const l=t.reference.getAttribute(`data-editor-tooltip-${this.editor.clientId}-dynamic`);t.setContent(l||"")}}return!0});this.editor=t;const e=t.clientId;this.attributeName=[`data-editor-tooltip-${e}`,`data-editor-tooltip-${e}-dynamic`,"data-editor-tooltip-common"],this.attributeDesc=`data-editor-tooltip-desc-${e}`,this.instance=vg.delegate(document.body,{theme:"editor-tooltip",maxWidth:400,delay:200,target:this.attributeName.map(r=>`[${r}]`).join(","),content:this.createContent,onShow:this.handleShow,onShown:this.handleShown,onHide:this.handleHidden,hideOnClick:!1}),t.domEvents.addEventListener(document,"mousedown",this.handleDocumentMouseDown)}set lastClickButtonId(t){this._lastClickButtonId=t,t&&setTimeout(()=>{this._lastClickButtonId===t&&(this._lastClickButtonId="")},500)}visible(){var t;return(t=this.currentInstance)==null?void 0:t.state.isVisible}hide(){var t;(t=this.currentInstance)!=null&&t.state.isVisible&&this.currentInstance.hide()}destroy(){this.destroyObserver(),this.instance.destroy(),this.editor.domEvents.removeEventListener(document,"mousedown",this.handleDocumentMouseDown),this.editor.domEvents.removeEventListener(document,"mouseup",this.handleDocumentMouseUp)}createObserver(){this.destroyObserver();const t=this.currentInstance;if(!t||!t.reference)return;this.observerCallback=Me.default(()=>{t.reference.closest("body")||(t.hide(),this.destroyObserver())},200),this.observer=new MutationObserver(this.observerCallback);const e=document.body,r={childList:!0,attributes:!1,subtree:!0};this.observer.observe(e,r)}destroyObserver(){this.observer&&(this.observer.disconnect(),this.observer=null),this.observerCallback&&(this.observerCallback.cancel(),this.observerCallback=null)}fixContainerForFullscreen(t){return t.closest("body")&&document.fullscreenElement&&!document.fullscreenElement.contains(t)?document.fullscreenElement:t}}const I$={"text/style-bold":"bold","text/style-italic":"italic","text/style-underline":"underline","text/style-strikethrough":"line-through","text/style-code":"code","text/style-sub":"subscript","text/style-super":"superscript",link:"link"};function D$(n,t){const e=new Set(Object.keys(I$)),r=t.filter(o=>e.has(o.id));return E0(r)}function tf(n,t){if(!n.isWritable()||Ti(n))return!1;const e=n.selection.range,r=n.editorCommandProviders.getCommands(e),o=D$(n,r).find(s=>s.id===`text/${t}`||s.id==="link");return o?(n.editorCommandProviders.executeCommand(e,o,{}),nc.get(n).update("selectionChange"),!0):!1}function _$(n,t){const e=n.selection.focusedBlock;if(!n.isWritable()||!nt(n,e))return!1;const r=n.getBlockData(e).heading,i={id:`heading-${t}`,source:"BlockTurnIntoCommandProvider",value:String(t)};return Number(r)===t&&(i.id="text",i.value=null),n.editorCommandProviders.executeCommand(n.selection.range,i,{}),!0}const lE={"CtrlOrCmd+B":n=>tf(n,"style-bold"),"CtrlOrCmd+I":n=>tf(n,"style-italic"),"CtrlOrCmd+U":n=>tf(n,"style-underline"),"CtrlOrCmd+D":n=>tf(n,"style-strikethrough"),"CtrlOrCmd+K":n=>tf(n,"link"),...(()=>{const n={};for(let t=1;t<=8;t++)n[`CtrlOrCmd+${t}`]=e=>_$(e,t);return n})()},M$={quickMenu:{basic:{heading:{title:"\u6807\u9898 {heading}",space:"{markdown}\u7A7A\u683C"},unordered:"\u65E0\u5E8F\u5217\u8868",ordered:"\u6709\u5E8F\u5217\u8868",checkbox:"\u5F85\u529E\u5217\u8868",quote:"\u5F15\u7528"},inlineBox:{math:"\u516C\u5F0F",link:"\u94FE\u63A5"}},link:{textLabel:"\u6587\u672C",urlLabel:"\u94FE\u63A5\u5730\u5740",textPlaceholder:"\u8BF7\u8F93\u5165\u6587\u672C",urlPlaceholder:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740",submitText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",edit:"\u7F16\u8F91",remove:"\u53D6\u6D88\u94FE\u63A5"},commands:{unordered:"\u65E0\u5E8F\u5217\u8868",ordered:"\u6709\u5E8F\u5217\u8868",check:"\u5F85\u529E\u5217\u8868",link:"\u94FE\u63A5",quote:"\u5F15\u7528",alignLeft:"\u5DE6\u5BF9\u9F50",alignRight:"\u53F3\u5BF9\u9F50",alignCenter:"\u5C45\u4E2D\u5BF9\u9F50",alignGroup:"\u5BF9\u9F50\u65B9\u5F0F",heading:"\u6807\u9898 {name}",headingGroup:"\u6807\u9898\u6837\u5F0F",text:"\u6B63\u6587"}},U$={quickMenu:{basic:{heading:{title:"Heading {heading}",space:"{markdown}space"},unordered:"Bulleted list",ordered:"Numbered list",checkbox:"To-do list",quote:"Quote"},inlineBox:{math:"Formula",link:"Link"}},link:{textLabel:"Text",urlLabel:"Link address",textPlaceholder:"Please enter text",urlPlaceholder:"Please enter link",submitText:"Confirm",cancelText:"Cancel",edit:"Edit",remove:"Remove link"},commands:{unordered:"Bulleted list",ordered:"Numberer list",check:"To-do list",link:"Link",quote:"Quote",alignLeft:"Align left",alignRight:"Align right",alignCenter:"Center text",alignGroup:"Alignment",heading:"Heading {name}",headingGroup:"Text style",text:"Text"}},O$={quickMenu:{basic:{heading:{title:"\u898B\u51FA\u3057{heading}",space:"{markdown}\u30B9\u30DA\u30FC\u30B9"},unordered:"\u7B87\u6761\u66F8\u304D\u30EA\u30B9\u30C8",ordered:"\u756A\u53F7\u4ED8\u304D\u30EA\u30B9\u30C8",checkbox:"\u30D0\u30C3\u30AF\u30ED\u30B0",quote:"\u5F15\u7528"},inlineBox:{math:"\u6570\u5F0F",link:"URL"}},link:{textLabel:"\u30C6\u30AD\u30B9\u30C8",urlLabel:"URL",textPlaceholder:"\u30C6\u30AD\u30B9\u30C8\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",urlPlaceholder:"URL \u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",submitText:"OK",cancelText:"\u30AD\u30E3\u30F3\u30BB\u30EB",edit:"\u7DE8\u96C6",remove:"\u30EA\u30F3\u30AF\u3092\u89E3\u9664"},commands:{unordered:"\u7B87\u6761\u66F8\u304D\u30EA\u30B9\u30C8",ordered:"\u756A\u53F7\u4ED8\u304D\u30EA\u30B9\u30C8",check:"\u30D0\u30C3\u30AF\u30ED\u30B0",link:"URL",quote:"\u5F15\u7528",alignLeft:"\u5DE6\u63C3\u3048",alignRight:"\u53F3\u63C3\u3048",alignCenter:"\u4E2D\u592E\u63C3\u3048",alignGroup:"\u5BF9\u9F50\u65B9\u5F0F",heading:"\u898B\u51FA\u3057{name}",headingGroup:"\u30BF\u30A4\u30C8\u30EB\u30B9\u30BF\u30A4\u30EB",text:"\u672C\u6587"}};D.mergeLang({"zh-CN":M$,"en-US":U$,"ja-JP":O$});const Oct="";function ml(n,...t){const e=Cr(...t);return e.classList.remove("editor-button"),e.classList.add("editor-text-button"),n.append(e),e}function Jk(n){const t=A0(n);t==null||t.hide();const e=n.findCustom("table-border-bar");e==null||e.closeToolbar()}function N$(n){return B("div",["insert-column-button","drop-marker"],n)}const P$=I("row-height");function Zk(n){const t=It.fromTable(n),e=n.rows;p(P$,e.length===t.rowCount,"row count mismatch");const r=Array(t.rowCount).fill(0);for(let i=0;i<e.length;){let o=1,l=e[i].getBoundingClientRect().height,c=i+1;for(;c<e.length;){const d=e[c];if(d.cells.length!==0)break;o++,c++,l+=d.getBoundingClientRect().height}for(let d=0;d<o;d++)r[i+d]=l/o;i=c}return r}const F$=I("table-border-bar-dom");function tR(n){var c;const t=Z(n.contentElement);p(F$,t,"no block");const r=ie(t).querySelector(".table-border-bar-container.left"),o=Ot(t).offsetLeft-Ga,s=((c=n.scrollOptions.paddingLeft)!=null?c:0)+o,l=Math.min(n.contentElement.offsetLeft-o,n.rootElement.scrollLeft-s);r&&(r.style.left=`${-l}px`)}const ls=I("table-border-bar-dom");function ic(n,t){p(ls,$e(t),"invalid table block");const e=Ve(t),r=Bi(n,t),i=ie(t),o=(C,E,x)=>{const v=B("div",["button-root",E],C),R=B("div",["button-container",E],v);v.setAttribute(`data-${E}-index`,`${x}`),R.setAttribute(`data-editor-tooltip-${n.clientId}`,E==="left"?D.t("table.insertRow"):D.t("table.insertCol")),B("span",["insert-indicator"],R),N$(R)},{selectedRows:s,selectedColumns:l}=pC(n,t),c=()=>{const C=r.querySelector(".table-border-bar-container.top");p(ls,C,"no top border bar container");const E=B("div",["table-border-bar-container","top"],null),x=B("div",["table-border-bar","top"],E),v=OF(e),L=It.fromTable(e).colCount;n.selection.range.isSimple()&&o(x,"top",0);for(let M=0;M<L;M++){const U=M===L-1?v[M]+2:v[M],F=B("span",["table-border-bar-cell","top"],x);l.has(M)&&F.classList.add("selected"),F.setAttribute("data-top-index",`${M}`),F.style.width=`${U}px`,n.selection.range.isSimple()&&o(x,"top",M+1)}eu(C,E)},d=()=>{const C=i.querySelector(".table-border-bar-container.left");p(ls,C,"no left border bar container");const E=B("div",["table-border-bar-container","left"],null),x=B("div",["table-border-bar","left"],E);B("span",["table-border-bar-cell","corner"],x);const v=Zk(e);n.selection.range.isSimple()&&o(x,"left",0),Array.from(e.rows).forEach((R,L,M)=>{const U=B("span",["table-border-bar-cell","left"],x);s.has(L)&&U.classList.add("selected"),U.setAttribute("data-left-index",`${L}`);const F=L===M.length-1?v[L]+2:v[L];U.style.height=`${F}px`,n.selection.range.isSimple()&&o(x,"left",L+1)}),eu(C,E)};c(),d();const h=n.findCustom(vi(t));h&&tR(h)}function eR(n,t){const e=t.target;if(!(e instanceof Element))return;const r=Z(e);p(ls,r&&$e(r),"invalid table block"),ic(n,r),n.selection.caret.update()}function U0(n,t){const e=t.target;if(!(e instanceof Element))return;const r=Z(e);p(ls,r&&$e(r),"invalid table block");const i=e.closest(".button-root");if(i){if(i.classList.contains("top")){const o=parseInt(i.getAttribute("data-top-index")||"0",10);sk(n,r,o),ic(n,r)}else if(i.classList.contains("left")){const o=parseInt(i.getAttribute("data-left-index")||"0",10);_C(n,r,o),ic(n,r)}}}function O0(n,t){var s;Jk(n),t.preventDefault(),t.stopPropagation();let e=null,r,i;const o=l=>{var c;if(l.target instanceof HTMLElement&&r&&e&&i!==void 0){const d=Z(l.target),h=l.target.closest(".table-border-bar");if(d===e&&h){const C=parseInt((c=l.target.getAttribute(`data-${r}-index`))!=null?c:"0",10),E=Math.min(i,C),x=Math.abs(i-C)+1;wt(l.target,"top")&&r==="top"?YF(n,d,E,x,{reverse:!0}):wt(l.target,"left")&&r==="left"&&QF(n,d,E,x,{reverse:!0})}}l.type==="mouseup"&&(e=null,i=void 0,r=void 0,document.body.removeEventListener("mousemove",o),document.body.removeEventListener("mouseup",o))};t.target instanceof HTMLElement&&wt(t.target,"table-border-bar-cell")&&(e=Z(t.target),wt(t.target,"top")?r="top":wt(t.target,"left")&&(r="left"),r&&e&&(i=parseInt((s=t.target.getAttribute(`data-${r}-index`))!=null?s:"0",10),document.body.addEventListener("mousemove",o),document.body.addEventListener("mouseup",o)))}function nR(n){const t=n.selection.range,e=$u(n,t);e&&ic(n,e)}function K$(n,t){p(ls,$e(t),"invalid table block");const e=Bi(n,t),r=ie(t),i=B("div",["table-border-bar-container","top"],e),o=B("div",["table-border-bar-container","left"],r);ic(n,t),n.domEvents.addEventListener(Ot(t),"scroll",eR),n.domEvents.addEventListener(i,"click",U0),n.domEvents.addEventListener(o,"click",U0),n.domEvents.addEventListener(i,"mousedown",O0),n.domEvents.addEventListener(o,"mousedown",O0),n.addListener("afterClearSelection",nR)}function rR(n,t){if(!n.isWritable())return;if(Bi(n,t).querySelector(".table-border-bar-container")){ic(n,t);return}K$(n,t)}function iR(n,t){p(ls,$e(t),"invalid table block");const e=Bi(n,t),r=ie(t),i=e.querySelectorAll(".table-border-bar-container"),o=r.querySelectorAll(".table-border-bar-container");i.forEach(s=>{n.domEvents.removeEventListener(s,"click",U0),n.domEvents.removeEventListener(s,"mousedown",O0),s.remove()}),o.forEach(s=>{n.domEvents.removeEventListener(s,"click",U0),n.domEvents.removeEventListener(s,"mousedown",O0),s.remove()}),n.domEvents.removeEventListener(Ot(t),"scroll",eR),n.addListener("afterClearSelection",nR)}function V$(n,t){p(ls,$e(t),"invalid table block");const r=Bi(n,t).querySelector(".table-border-bar-container.top");return r?r.getBoundingClientRect().height:0}class $${constructor(t,e){m(this,"toolbar");m(this,"handleSelectionChange",(t,e)=>{!t.isVisible||(e==="delete-columns"?(ns(this.editor,this.tableBlock,!0,!0),rs(this.editor,this.tableBlock,!0,!0)):e==="delete-rows"?(ns(this.editor,this.tableBlock,!0,!1),rs(this.editor,this.tableBlock,!0,!1)):(ns(this.editor,this.tableBlock,!1),rs(this.editor,this.tableBlock,!1)))});m(this,"handleClick",(t,e,r)=>{e.id==="delete-columns"?CC(this.editor.selection.range):e.id==="delete-rows"&&EC(this.editor.selection.range)});m(this,"handleToolbarClose",()=>{this.tableBlock&&$u(this.editor,this.editor.selection.range)===this.tableBlock&&(ns(this.editor,this.tableBlock,!1),rs(this.editor,this.tableBlock,!1))});this.editor=t,this.tableBlock=e;const r=t.options.componentsOptions.popover;this.toolbar=new Fu([],void 0,{id:"table-row-column-toolbar",overflowBoundary:r==null?void 0:r.overflowBoundary,refuseOverflow:!0,tooltipId:this.editor.clientId}),this.toolbar.addListener("selectionChange",this.handleSelectionChange),this.toolbar.addListener("click",this.handleClick),this.toolbar.addListener("close",this.handleToolbarClose)}close(){this.toolbar.close("cancelBar")}update(){var i,o,s;const{selectedColumns:t,selectedRows:e}=pC(this.editor,this.tableBlock);if(!this.editor.isWritable())return;if(t.size>0&&e.size>0){this.toolbar.close("cancelBar");return}if(t.size===0&&e.size===0){this.toolbar.close("cancelBar");return}const r=Yi(this.editor,this.tableBlock,this.editor.selection.range)[0];if(!r){this.toolbar.close("cancelBar");return}if(t.size>0){const l={id:"delete-columns",name:D.t("table.deleteSelectCol"),icon:bT};this.toolbar.updateItems([l]);const c=Zi(this.editor,this.tableBlock,"table-row-column-delete",r);this.toolbar.manualShow(c,{placement:"top",offset:[0,5]})}else{const l={id:"delete-rows",name:D.t("table.deleteSelectRow"),icon:xT};this.toolbar.updateItems([l]);const h=ie(this.tableBlock).querySelector(".table-border-bar-container.left").getBoundingClientRect(),C=new DOMRect(Math.max(h.left,r.left-Ga),r.top,Ga,r.height),E=Zi(this.editor,this.tableBlock,"table-row-column-delete",C);this.toolbar.manualShow(E,{placement:"left",offset:[0,5]});const x=this.editor.options.componentsOptions.popover;(i=this.toolbar.tippyInstance)==null||i.setProps({popperOptions:{modifiers:[{name:"flip",options:{boundary:x==null?void 0:x.overflowBoundary,fallbackPlacements:["left","right"]}}]}})}(s=(o=this.toolbar.tippyInstance)==null?void 0:o.popperInstance)==null||s.update()}destroy(){this.toolbar.destroy(),this.toolbar.removeAllListeners()}}const aE=I("table-border-bar");class H${constructor(t,e){m(this,"toolbar");m(this,"resizeObserver",null);m(this,"handleReadonlyChanged",t=>{t.isWritable()?this.update():iR(this.editor,this.tableBlock)});m(this,"handleBlockUpdated",()=>{var t;(t=this.resizeObserver)==null||t.disconnect(),setTimeout(()=>{var r;const e=this.editor.getBlockById(st(this.tableBlock));(r=this.resizeObserver)==null||r.observe(Ve(e))})});m(this,"handleScroll",()=>{var t;(t=this.toolbar)==null||t.update()});m(this,"handleTableResize",()=>{!this.editor.isWritable()||this.update()});this.editor=t,this.tableBlock=e,p(aE,this.tableBlock,"no table block"),aE.debug("create table border bar"),rR(this.editor,this.tableBlock),this.resizeObserver=new Ms(this.handleTableResize),this.resizeObserver.observe(Ve(this.tableBlock));const r=t.getComponentOptions("table");r!=null&&r.hideToolbar||(this.toolbar=new $$(this.editor,this.tableBlock)),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}close(){var t;(t=this.toolbar)==null||t.close()}destroy(){var t,e;aE.debug("destroy table border bar"),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=null,iR(this.editor,this.tableBlock),(e=this.toolbar)==null||e.destroy(),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged)}update(){var t;rR(this.editor,this.tableBlock),(t=this.toolbar)==null||t.update()}}const j$=I("table-border-bar");class z${constructor(t){m(this,"activeTableBar",null);m(this,"handleBlockDeleted",(t,e)=>{!this.activeTableBar||(e===this.activeTableBar.tableBlock||re(e,this.activeTableBar.tableBlock))&&(this.activeTableBar.destroy(),this.activeTableBar=null)});m(this,"handleSelectionChanged",t=>{setTimeout(()=>{var i;const e=t.selection.range,r=$u(t,e);((i=this.activeTableBar)==null?void 0:i.tableBlock)!==r&&this.activeTableBar&&this.hide(),r&&this.show(r)})});m(this,"handleScroll",()=>{var t;(t=this.activeTableBar)==null||t.handleScroll()});this.editor=t,this.editor.addListener("blockDeleted",this.handleBlockDeleted),this.editor.addListener("selectionChanged",this.handleSelectionChanged)}destroy(){this.editor.removeListener("blockDeleted",this.handleBlockDeleted),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}show(t){this.activeTableBar?(this.activeTableBar.tableBlock!==t&&this.hide(),this.activeTableBar.update()):this.activeTableBar=new H$(this.editor,t)}update(){var t;(t=this.activeTableBar)==null||t.handleBlockUpdated()}closeToolbar(){var t;(t=this.activeTableBar)==null||t.close()}hide(){!this.activeTableBar||(p(j$,this.activeTableBar,"no active table bar"),this.activeTableBar.destroy(),this.activeTableBar=null)}}function oR(n,t){const e=n.addCustom("table-border-bar",r=>new z$(r));t==="update"&&e.update()}const Pn=I("table-cell-menu"),G$="style-bg-color-";class W${constructor(t){m(this,"activeTableBlock",null);m(this,"targetButton",null);m(this,"manualMenu",null);m(this,"colorPaletteItem",null);m(this,"handlePrevent",(t,e)=>{e.stopPropagation()});m(this,"handleReadonlyChanged",t=>{t.isWritable()||this.hide()});m(this,"handleSelectionChanged",t=>{const e=t.selection.range,r=$u(t,e);if(this.hide(),this.activeTableBlock!==r&&(this.activeTableBlock=r),this.activeTableBlock){const i=It.fromBlock(this.activeTableBlock),o=e.isReverse()?e.start:e.end;let s=null;o instanceof Ur?t.getBlockById(o.blockId)===this.activeTableBlock?s=i.getCellByContainerId(o.childContainerId):s=this.getCellByChildBlockId(i,o.blockId):o.blockId!==this.activeTableBlock.id&&(s=this.getCellByChildBlockId(i,o.blockId)),s&&this.editor.isWritable()&&this.showCellMenuButton(s)}});m(this,"handleBeforePopupPalette",()=>{var e;const t=this.getSelectedBkgColorIndex();(e=this.colorPaletteItem)==null||e.palette.setColor("backgroundColor",t)});m(this,"createBkgColorItem",()=>{const t=B("div",["cell-background-color-item"],null);B("span",[],t,D.t("table.cellBackground"));const e=this.getSelectedBkgColorIndex();B("button",["item-button"],t).setAttribute("data-color-index",`${e}`);const i=B("span",["item-sub-indicator"],t);return i.innerHTML=Qp,t});m(this,"handleCommand",t=>{var i;p(Pn,this.activeTableBlock,"no target table block");const e=((i=t.states)==null?void 0:i.includes("checked"))||!1,r=t.value;switch(t.id){case"delete-select-row":EC(Vy(this.editor,this.activeTableBlock,!1));break;case"delete-select-col":CC(Vy(this.editor,this.activeTableBlock,!0));break;case"merge-cell":Py(this.editor.selection.range);break;case"split-cell":this.handleSplitCell();break;case"row-title":this.handleRowTitle(e);break;case"col-title":this.handleColTitle(e);break;case"stripe-style":this.handleStripeStyle(e);break;case"hide-border":sF(this.editor,this.activeTableBlock,r==="show-border");break;case"show-chart":cF(this.editor,this.activeTableBlock,r==="show-chart"),yC(this.editor,this.activeTableBlock,{updateNow:!0});break}});m(this,"handleToolbarClose",()=>{this.targetButton&&ot(this.targetButton,"active"),this.activeTableBlock&&$u(this.editor,this.editor.selection.range)===this.activeTableBlock&&(ns(this.editor,this.activeTableBlock,!1),rs(this.editor,this.activeTableBlock,!1)),this.editor.focus()});m(this,"handleSelectionChange",(t,e)=>{!t.isVisible||(p(Pn,this.activeTableBlock,"no target table block"),e==="cell-background-color"&&this.handleBeforePopupPalette(),e==="delete-select-row"?(ns(this.editor,this.activeTableBlock,!0,!1),rs(this.editor,this.activeTableBlock,!0,!1)):e==="delete-select-col"?(ns(this.editor,this.activeTableBlock,!0,!0),rs(this.editor,this.activeTableBlock,!0,!0)):(ns(this.editor,this.activeTableBlock,!1),rs(this.editor,this.activeTableBlock,!1)))});m(this,"handleClick",(t,e)=>{var r;p(Pn,this.activeTableBlock,"no target table block"),p(Pn,this.targetButton,"no target button"),Jk(this.editor),wt(this.targetButton,"active")?(ot(this.targetButton,"active"),(r=this.manualMenu)==null||r.close("clickItem")):(z(this.targetButton,"active"),this.manualMenu?this.manualMenu.updateItems(this.createCommandMenu()):(this.manualMenu=new ts(this.createCommandMenu(),void 0,{id:"table-cell-menu"}),this.manualMenu.on("click",(i,o)=>{var s;this.handleCommand(o),(s=this.manualMenu)==null||s.close("clickItem")}),this.manualMenu.on("selectionChange",this.handleSelectionChange),this.manualMenu.on("close",this.handleToolbarClose)),this.manualMenu.manualShow(this.targetButton,{placement:"right-start"})),e.stopPropagation()});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChanged),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}destroy(){var t,e;this.activeTableBlock=null,this.targetButton=null,this.editor.removeListener("selectionChanged",this.handleSelectionChanged),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged),(t=this.manualMenu)==null||t.destroy(),(e=this.colorPaletteItem)==null||e.destroy()}hide(){var t;(t=this.manualMenu)==null||t.close("cancelBar"),this.targetButton&&(ot(this.targetButton,"active"),this.targetButton.style.display="none")}getCellByChildBlockId(t,e){let r=this.editor.getBlockById(e);for(;r;){const i=r.closest("td");p(Pn,i,"no parent cell");const o=Z(i);if(p(Pn,o,"no parent block"),Ve(o)===t.table)return t.getCellByCellElement(i);r=o}return p(Pn,!1,"filed to get cell by child block id"),null}createTargetButton(t){this.targetButton?t.querySelector(`:scope > .${BC}`)||t.appendChild(this.targetButton):(this.targetButton=B("button",[BC],t),this.targetButton.innerHTML=qh,this.editor.domEvents.addEventListener(this.targetButton,"click",this.handleClick),this.editor.domEvents.addEventListener(this.targetButton,"mousedown",this.handlePrevent),this.editor.domEvents.addEventListener(this.targetButton,"dblclick",this.handlePrevent))}showCellMenuButton(t){this.createTargetButton(t.cell),p(Pn,this.targetButton,"no target button"),this.targetButton.style.display="inline-block"}handleSplitCell(){if(this.activeTableBlock){const t=It.fromBlock(this.activeTableBlock),e=this.editor.selection.range;if(e.isSimple()){const{col:r,row:i}=this.getCellByChildBlockId(t,e.start.blockId);xC(this.editor,this.activeTableBlock,{col:r,row:i})}else bC(this.editor.selection.range)}}getSelectedBkgColorIndex(){var s;p(Pn,this.activeTableBlock,"no target table block");const t=this.editor.selection.range,e=es(this.editor,this.activeTableBlock,t.focus),r=this.editor.getBlockData(this.activeTableBlock),i=e.childContainerId,o=r[`${i}_background`];return o?Number.parseInt((s=o.substring(G$.length))!=null?s:"0",10):-1}createCommandMenu(){p(Pn,this.activeTableBlock,"no target table block");const t=this.editor.getBlockData(this.activeTableBlock),e=Ny(this.editor,this.activeTableBlock,this.editor.selection.range);let r=this.editor.selection.range;if(r.isSimple()){const h=es(this.editor,this.activeTableBlock,r.start);r=qe(this.editor,{anchor:h,focus:h})}const i=Oy(this.editor,this.activeTableBlock,r),o=t.hasRowTitle,s=t.hasColTitle,l=t.isStripeStyle,c=t.noBorder,d=t.chart;return this.colorPaletteItem=new Sy("cell-background-color",{color:!1}),this.colorPaletteItem.palette.on("onClick",(h,C)=>{var E;switch(p(Pn,this.activeTableBlock,"no target table block"),h){case"clearColor":jy(this.editor,this.activeTableBlock,-1);break;case"backgroundColor":jy(this.editor,this.activeTableBlock,C);break}(E=this.manualMenu)==null||E.close("clickItem")}),[{id:"cell-background-color",name:D.t("table.cellBackground"),element:this.createBkgColorItem(),children:[this.colorPaletteItem]},{id:"separator",name:"",type:"separator"},{id:"merge-cell",name:D.t("table.mergeCell"),states:e?[]:["disabled"]},{id:"split-cell",name:D.t("table.splitCell"),states:i?[]:["disabled"]},{id:"separator",name:"",type:"separator"},{id:"delete-select-row",name:D.t("table.deleteSelectRow")},{id:"delete-select-col",name:D.t("table.deleteSelectCol")},{id:"separator",name:"",type:"separator"},{id:"table-config",name:D.t("table.tableConfigKey"),children:[{id:"row-title",name:D.t("table.tableConfig.rowTitle"),states:o?["checked"]:[]},{id:"col-title",name:D.t("table.tableConfig.colTitle"),states:s?["checked"]:[]},{id:"stripe-style",name:D.t("table.tableConfig.stripeStyle"),states:l?["checked"]:[]},{id:"hide-border",name:c?D.t("table.tableConfig.showBorder"):D.t("table.tableConfig.hideBorder"),value:c?"show-border":"hide-border"},{id:"show-chart",name:d?D.t("table.tableConfig.hideChart"):D.t("table.tableConfig.showChart"),value:d?"hide-chart":"show-chart"}]}]}handleRowTitle(t){p(Pn,this.activeTableBlock,"no target table block"),t?rF(this.editor,this.activeTableBlock):nF(this.editor,this.activeTableBlock)}handleColTitle(t){p(Pn,this.activeTableBlock,"no target table block"),t?eF(this.editor,this.activeTableBlock):tF(this.editor,this.activeTableBlock)}handleStripeStyle(t){p(Pn,this.activeTableBlock,"no target table block"),t?oF(this.editor,this.activeTableBlock):iF(this.editor,this.activeTableBlock)}}function sR(n){n.addCustom("table-cell-menu",t=>new W$(t))}const N0=I("table-container");function cE(n){const t=n.closest("td");return p(N0,t,"no parent cell for a table cell container"),t}function lR(n){const t=Ve(n);return Array.from(t.querySelectorAll(':scope > tbody > tr > td > [data-type="editor-container"].child'))}function uE(n,t,e,r){const i=It.fromBlock(n),o=i.getCellByContainerId(ft(t));if(e==="ArrowDown"){const s=i.getBottomCell(o);return s?s.container:null}if(e==="ArrowUp"){const s=i.getTopCell(o);return s?s.container:null}if(e==="ArrowLeft"){const s=i.getAllContainers(),l=s.indexOf(t);if(p(N0,l>=0,"not a valid child container"),l===0)return null;const c=s[l-1];return r!=null&&r.noWrap&&i.getCellByContainerId(ft(c)).row!==o.row?null:c}if(e==="ArrowRight"){const s=i.getAllContainers(),l=s.indexOf(t);if(p(N0,l>=0,"not a valid child container"),l===s.length-1)return null;const c=s[l+1];return r!=null&&r.noWrap&&i.getCellByContainerId(ft(c)).row!==o.row?null:c}p(N0,!1,`invalid navigation type: ${e}`)}const q$=12,X$=90,P0=23,aR=2;class Y${constructor(t){m(this,"scrollTableBlock",null);m(this,"autoScrollDir",null);m(this,"autoScrollTimer",null);m(this,"handleMouseDown",t=>{const e=document.elementFromPoint(t.clientX,t.clientY);if(e&&e instanceof HTMLElement){const r=Z(e);if(r&&re(this.editor.rootContainer,r)){const i=fo(r);i&&(this.scrollTableBlock=i,document.addEventListener("mousemove",this.handleAutoScroll))}}});m(this,"handleAutoScroll",s9.default(t=>{if(this.scrollTableBlock){const e=this.editor.getCustom(vi(this.scrollTableBlock)),r=e.rootElement,i=e.scrollOptions.parentContainer,o=r.getBoundingClientRect(),s=window.innerHeight-this.getBarFloatWindowBottom(e),l=i.getBoundingClientRect(),c=Math.min(l.bottom,s),d=Math.max(l.top,0);o.bottom>c&&t.clientY>=c?this.setAutoScroll("bottom"):o.top<d&&t.clientY<=d?this.setAutoScroll("top"):r.scrollLeft>0&&t.clientX<o.left?this.setAutoScroll("left"):r.scrollLeft<r.scrollWidth-r.offsetWidth&&t.clientX>o.right?this.setAutoScroll("right"):this.clearAutoScroll()}},15));m(this,"handleMouseUp",()=>{document.removeEventListener("mousemove",this.handleAutoScroll),setTimeout(()=>{this.scrollTableBlock=null})});m(this,"handleSelectionChanged",t=>{const e=t.selection.range;if(e.isCollapsed()&&e.isSimple()){const r=t.getBlockById(e.start.blockId),i=fo(r);if(i){const o=t.getCustom(vi(i)),s=o.rootElement.getBoundingClientRect(),l=_r(t,r,e.start);if(s.left>l.left){const c=e.start.offset===0?q$:aR;o.rootElement.scrollLeft-=s.left-l.left+c}else if(l.right>s.right){const c=e.start.offset===0?X$:aR;o.rootElement.scrollLeft+=l.right-s.right+c}}}else{const r=t.getBlockById(e.start.blockId),i=fo(r),o=t.getBlockById(e.end.blockId),s=fo(o);if(i&&i===s){const l=t.getCustom(vi(i)),c=l.rootElement.getBoundingClientRect();let d=null;if(e.isSimple())d=e.isReverse()?_r(t,r,e.start):_r(t,o,e.end);else{const h=cE(ui(t,e.start.childContainerId)),C=cE(ui(t,e.end.childContainerId));d=e.isReverse()?h.getBoundingClientRect():C.getBoundingClientRect()}c.left>d.left&&e.isReverse()?l.rootElement.scrollLeft-=c.left-d.left:c.right<d.right&&!e.isReverse()&&(l.rootElement.scrollLeft+=d.right-c.right)}}});m(this,"handleScroll",t=>{_y(t),this.editor.selection.caret.update()});m(this,"handleReset",t=>{_y(t),this.editor.selection.caret.update();const e=this.editor.findCustom("table-border-bar");e&&e.handleScroll(),tR(t)});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChanged),document.addEventListener("mousedown",this.handleMouseDown),document.addEventListener("mouseup",this.handleMouseUp)}getBarFloatWindowBottom(t){return t.scrollOptions.barFloatWindowBottom?typeof t.scrollOptions.barFloatWindowBottom=="number"?t.scrollOptions.barFloatWindowBottom:t.scrollOptions.barFloatWindowBottom():0}clearAutoScroll(){this.autoScrollTimer&&(clearInterval(this.autoScrollTimer),this.autoScrollTimer=null,this.autoScrollDir=null)}setAutoScroll(t){this.autoScrollDir&&this.autoScrollDir!==t&&this.clearAutoScroll(),this.autoScrollTimer||(this.autoScrollDir=t,this.autoScrollTimer=window.setInterval(()=>{if(this.scrollTableBlock){const e=this.editor.getCustom(vi(this.scrollTableBlock)),r=e.rootElement,i=e.scrollOptions.parentContainer,o=r.getBoundingClientRect(),s=i===document.documentElement?window.innerHeight:i.offsetHeight,l=window.innerHeight-this.getBarFloatWindowBottom(e),c=i.getBoundingClientRect(),d=Math.min(c.bottom,l),h=Math.max(c.top,0);this.autoScrollDir==="left"&&(r.scrollLeft-=P0,r.scrollLeft<=0&&this.clearAutoScroll()),this.autoScrollDir==="right"&&(r.scrollLeft+=P0,r.scrollLeft>=r.scrollWidth-r.offsetWidth&&this.clearAutoScroll()),this.autoScrollDir==="bottom"&&(i.scrollTop+=P0,(i.scrollTop>=i.scrollHeight-s||o.bottom<=d)&&this.clearAutoScroll()),this.autoScrollDir==="top"&&(i.scrollTop-=P0,(i.scrollTop<=0||o.top>=h)&&this.clearAutoScroll())}},100))}destroy(){document.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mouseup",this.handleMouseUp),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}}function cR(n){return n.addCustom("table-scroll-events",t=>new Y$(t))}const Q$=I("table-doc-change-handler");class J${constructor(t){this.editor=t,this.editor.addListener("docChanged",this.handleDocChanged)}handleDocChanged(t,e){if(!e){const{start:r,end:i}=t.selection.range;if(!t.findBlockById(r.blockId)||!t.findBlockById(i.blockId)){t.selection.selectBlock(t.getBlockByIndex("root",0),0);return}if(ga(r)){const o=t.getBlockById(r.blockId);if(!$e(o))return;if(p(Q$,ga(i),"invalid range"),!zd(t,r.childContainerId)||!zd(t,i.childContainerId)){t.selection.selectBlock(o,0);return}let s=null,l=null;const c=(d,h)=>{const C=h.getCellById(d.childContainerId),{colIndex:E=0,rowIndex:x=0}=d.custom;let v=-1,R=-1;return(C.col>E||C.col+C.colSpan-1<E)&&(v=C.col),(C.row>x||C.row+C.rowSpan-1<x)&&(R=C.row),v!==-1||R!==-1?Ae(o,d.childContainerId,{colIndex:v===-1?E:v,rowIndex:R===-1?x:R}):null};if(r.custom){const d=It.fromBlock(o);s=c(r,d),l=c(i,d)}(s!==null||l!==null)&&(t.selection.range.isReverse()?t.selection.setSelection(l!=null?l:i,s!=null?s:r):t.selection.setSelection(s!=null?s:r,l!=null?l:i))}}}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged)}}function uR(n){n.addCustom("table-doc-change-handler",t=>new J$(t))}const yi=I("create-content");function fR(n,t,e){var C;const r=new c0(e),i=e.rows,o=e.cols;p(yi,i>=1,`invalid rows: ${i}`),p(yi,o>=1,`invalid cols: ${o}`),p(yi,e.children,"no table children");const s=B("table",[],null),l=(C=e.colsWidth)!=null?C:new Array(e.cols).fill(0),c=B("colgroup",[],s);for(let E=0;E<r.colCount;E++){const x=B("col",[],c);l[E]&&(x.style.width=`${l[E]}px`)}const d=B("tbody",[],s);let h=0;for(let E=0;E<i;E++){const x=B("tr",[],d);for(let v=0;v<o;v++){const R=r.getCell({col:v,row:E});if(R.virtual)p(yi,R.colSpan>1||R.rowSpan>1,"virtual cell should have colSpan or rowSpan");else{const L=e.children[h],M=B("td",[],x);R.colSpan>1&&(M.colSpan=R.colSpan),R.rowSpan>1&&(M.rowSpan=R.rowSpan);const U=e[zu(L)];U&&z(M,U),v===0&&e.hasColTitle&&z(M,Fy.COL_TITLE_ITEM),n.createChildContainer(t,M,L),h+=1}}}return p(yi,h===e.children.length,"container count mismatch"),s.style.minWidth=`${l.reduce((E,x)=>x+E,0)}px`,e.noBorder&&z(s,"no-border"),e.chart&&z(s,"editor-table-chart"),e.isStripeStyle&&z(s,"stripe"),e.hasRowTitle&&z(s,"row-title"),e.hasColTitle&&z(s,"col-title"),s}function Z$(n,t,e,r,i){p(yi,i.type==="table","not table data"),p(yi,ft(e)===t[t.length-1].containerId,"invalid path");const o=i,s=js(r,"div");try{const l=B("div",[],null);l.setAttribute("data-type","table-content");const c=fR(n,t,o);c.classList.add("drag-preview-element"),l.appendChild(c);const d=n.getComponentOptions("table");ik(n),lk(n),oR(n,"create"),uR(n),d!=null&&d.hideCellMenu||sR(n),pT(n,kC);const h=n.addCustom(vi(r),()=>MF());h.init({parentElement:s,childElement:l,safeRightSpace:50,safeLeftSpace:40,parentContainer:Qt(e)?n.scrollContainer:e,locatingContainer:Qt(e)?(d==null?void 0:d.locatingContainer)||n.parent:e,paddingLeft:Ga+ju,paddingTop:Ga+ju,paddingBottom:ju/2,paddingRight:ju/2,barFloatWindowBottom:d==null?void 0:d.barFloatWindowBottom,allowScrollBarFixed:d==null?void 0:d.allowScrollBarFixed,isSetScale:d==null?void 0:d.isSetScale});const C=cR(n);h.on("scroll",C.handleReset),h.on("resize",C.handleReset),setTimeout(()=>{dF(n,r)})}catch{const c=`invalid table data: ${JSON.stringify(o)}`;yi.error(c);const d=B("div",["error"],s);d.innerText=c}return s}function tH(n,t,e){p(yi,e.type==="table","not table data");const r=e,i=Ot(t);try{const o=Ve(t),s=$o(t),l=fR(n,s,r);l.classList.add("drag-preview-element"),o.insertAdjacentElement("afterend",l),o.remove();const c=n.getComponentOptions("table");ik(n),lk(n),oR(n,"update"),uR(n),c!=null&&c.hideCellMenu||sR(n),kC(n,t)}catch{const s=`invalid table data: ${JSON.stringify(r)}`;yi.error(s);const l=B("div",["error"],i);l.innerText=s}}function eH(n,t){let e,r,i=!1;if([...t].every(E=>E==="|")?(r=t.length,e=Array(r).fill(""),i=!0):(e=Og(t,"|").split("|"),r=e.length),r<2)return null;const o=3,s=r,l=[];for(let E=0;E<3;E++)e.forEach(x=>{l.push(ro(n.doc,E===0?x:""))});const c=Array(s).fill(SC),d=l[i?0:s],h=n.doc.getContainerBlocks(d)[0].id;return{blockData:{id:tt(),type:"table",rows:o,cols:s,children:l,colsWidth:c},focusBlockId:h}}function nH(n,t){const e=t.rows,r=t.cols;if(e<1||r<1)return null;const i=[];for(let d=0;d<e;d++)for(let h=0;h<r;h++)i.push(ro(n.doc));const o=Array(r).fill(SC),s=i[0],l=n.doc.getContainerBlocks(s)[0].id;return{blockData:{id:tt(),type:"table",rows:e,cols:r,children:i,colsWidth:o},focusBlockId:l}}const fE=I("get-selected-containers");function dR(n,t,e,r){p(fE,e.blockId===r.blockId,"only allow select in single table block"),p(fE,st(t)===e.blockId,"only allow select in single table block");const i=It.fromBlock(t),o=i.getCellByContainerId(e.childContainerId),s=i.getCellByContainerId(r.childContainerId);if(e.custom===void 0||r.custom===void 0)return i.getCells(o,s).map(L=>i.getCellContainer(L));const{fromCol:l,toCol:c,fromRow:d,toRow:h}=Gr(t,e,r),C=new Set,E=[];return i.sub({row:d,col:l},{row:h,col:c}).forEach(v=>{v.forEach(R=>{const L=i.getCellByContainerId(R.containerId);L.col<l||L.row<d||L.col+L.colSpan-1>c||L.row+L.rowSpan-1>h||C.has(R.containerId)||(C.add(R.containerId),E.push(L.container))})}),E}function rH(n,t,e){p(fE,t.blockId===e.blockId,"only allow select in single table block");const r=n.getBlockById(t.blockId);return dR(n,r,t,e)}const hR=I("table-selection-to-doc");function iH(n,t){const{start:e,end:r,block:i}=t,o=Dt(i);p(hR,o==="table",`invalid block type: ${o}`);const s=n.getBlockData(i);if(e.isSimple()&&r.isSimple())return Xo(n.editorBlocks,n.doc.toJSON(),s);p(hR,!e.isSimple()&&!r.isSimple(),"invalid block pos type");const l=It.fromBlock(i),{fromCol:c,toCol:d,fromRow:h,toRow:C}=Gr(i,e,r),E={},x=[],v=n.doc.toJSON();let R={};l.sub({row:h,col:c},{row:C,col:d}).forEach((rt,lt)=>{rt.forEach((Et,vt)=>{const xt=Et.containerId;if(x.indexOf(xt)!==-1)return;x.push(xt);let Gt;if(Et.virtual){const be=l.getCellByContainerId(Et.containerId),Fn=c+vt;let _i=be.col+be.colSpan-1;_i>d&&(_i=d);const kn=_i-Fn+1;kn>1&&(E[`${xt}_colSpan`]=kn);const pn=h+lt;let Mi=be.row+be.rowSpan-1;Mi>C&&(Mi=C);const po=Mi-pn+1;po>1&&(E[`${xt}_rowSpan`]=po),Gt=Ci()}else{if(Gt=lp(n.editorBlocks,v,xt),Et.col+Et.colSpan>d+1){const be=d-Et.col+1;be>1&&(E[`${xt}_colSpan`]=be)}else Et.colSpan>1&&(E[`${xt}_colSpan`]=Et.colSpan);if(Et.row+Et.rowSpan>C+1){const be=C-Et.row+1;be>1&&(E[`${xt}_rowSpan`]=be)}else Et.rowSpan>1&&(E[`${xt}_rowSpan`]=Et.rowSpan)}const{root:Yt,...ln}=Gt.blocks;R={...R,...ln,[xt]:Yt}})});const M=Yu(Ve(i)).slice(c,d+1);return{blocks:{root:[{id:tt(),type:o,children:x,colsWidth:M,rows:C-h+1,cols:d-c+1,...E}],...R},meta:{},comments:{}}}const oH=I("ajust-selection-pos");function sH(n,t){if(t.top===0)return!0;for(let e=t.left;e<=t.right;e++)if(n[t.top-1][e]===n[t.top][e])return!1;return!0}function lH(n,t){if(t.left===0)return!0;for(let e=t.top;e<=t.bottom;e++)if(n[e][t.left-1]===n[e][t.left])return!1;return!0}function aH(n,t){if(t.bottom===n.length-1)return!0;for(let e=t.left;e<=t.right;e++)if(n[t.bottom][e]===n[t.bottom+1][e])return!1;return!0}function cH(n,t){if(t.right===n[0].length-1)return!0;for(let e=t.top;e<=t.bottom;e++)if(n[e][t.right]===n[e][t.right+1])return!1;return!0}function uH(n,t,e){const r=t.col,i=t.row,o=e.col,s=e.row,l={left:r,top:i,right:o,bottom:s};let c=!1;do{if(c=!1,!sH(n,l)){l.top--,c=!0;continue}if(!lH(n,l)){l.left--,c=!0;continue}if(!aH(n,l)){l.bottom++,c=!0;continue}if(!cH(n,l)){l.right++,c=!0;continue}}while(c);return l}function fH(n,t,e,r){if(e.custom!==void 0||r.custom!==void 0)return{anchor:e,focus:r};const i=It.fromBlock(t),o=i.map(F=>F.containerId),s=i.getCellByContainerId(e.childContainerId),l=i.getCellByContainerId(r.childContainerId),c=Math.min(s.row,l.row),d=Math.max(s.row,l.row),h=Math.min(s.col,l.col),C=Math.max(s.col,l.col),E=uH(o,{row:c,col:h},{row:d,col:C}),x=i.getCell({row:E.top,col:E.left}),v=i.getCell({row:E.bottom,col:E.right}),R=i.getCell({row:E.top,col:E.right}),L=i.getCell({row:E.bottom,col:E.left});let M,U;return s.row<=l.row?s.col<=l.col?(M=x,U=v):(M=R,U=L):s.col<l.col?(M=L,U=R):(M=v,U=x),oH.debug(`move ${M.col}, ${M.row}, -> ${U.col}, ${U.row}`),{anchor:Ae(t,M.containerId),focus:Ae(t,U.containerId)}}function mR(n,t,e){if(e.isSimple())return[Ve(t).getBoundingClientRect()];const r=Ve(t),i=r.getBoundingClientRect(),{fromCol:o,fromRow:s,toCol:l,toRow:c}=Gr(t,e.start,e.end),d=Yu(r),h=d.slice(0,o).reduce((R,L)=>R+L,0),C=h+d.slice(o,l+1).reduce((R,L)=>R+L,0),E=Zk(r);let x=E.slice(0,s).reduce((R,L)=>R+L,0);const v=x+E.slice(s,c+1).reduce((R,L)=>R+L,0);if(s===0){const R=V$(n,t);x-=R}return[new DOMRect(i.left+h,i.top+x,C-h,v-x)]}I("table-size");const dH=40;function F0(n){const t=n.querySelector("td");if(!t)return 0;const e=window.getComputedStyle(t),r=Number.parseInt(e.borderLeft,10),i=Number.parseInt(e.borderRight,10);return(r+i)/2}function hH(n,t,e){const r=l1(n,e.container);return r!==void 0?r+F0(t):dH*e.colSpan-F0(t)}function mH(n,t,e,r){let i=0;const o=e.colCount;for(let s=0;s<o;s++){const l=e.getCell({col:s,row:r});if(l.virtual)continue;let c=hH(n,t,l);const d=n3(l.container,{withPadding:!0});d&&d>c&&(c=d),i+=c+F0(t)}return i}function gH(n,t){const e=Ve(t),r=It.fromTable(e);let i=0;for(let s=0;s<r.rowCount;s++)i=Math.max(i,mH(n,e,r,s));const o=F0(e);return i+=o,i}const ho=I("table-creator");async function pH(n,t){return n.undoManager.runInGroup(()=>{var c,d;const e=t.item,r=(c=e.colCount)!=null?c:5,i=(d=e.rowCount)!=null?d:3,o=nH(n,{cols:r,rows:i});if(!o)return null;const{blockData:s,focusBlockId:l}=o;return n.insertBlock(t.containerId,t.blockIndex,s,ye(n,l,0))})}class CH{constructor(){m(this,"id","insert-table");m(this,"name","Create table");m(this,"element");m(this,"closeable",null);m(this,"colCount");m(this,"rowCount");m(this,"setCloseable",t=>{this.closeable=t});m(this,"destroy",()=>{this.closeable=null});m(this,"getTableCreatorCellId",(t,e)=>`table-creator-cell-${t}-${e}`);m(this,"handleTableCreatorClick",t=>{var E,x;t.preventDefault(),t.stopPropagation();const e=t.target;p(ho,e instanceof HTMLElement,"invalid event target");const r=e.closest(".table-creator");p(ho,r,"no table creator");const i=r.querySelectorAll(".active");if(i.length===0)return;const s=i[i.length-1].id;p(ho,s,"no cell id");const l="table-creator-cell-";if(!s.startsWith(l))return;const d=s.substring(l.length).split("-");p(ho,d.length===2,"invalid cell id");const h=Number.parseInt(d[0],10)+1,C=Number.parseInt(d[1],10)+1;ho.debug(`${h}, ${C}`),this.colCount=C,this.rowCount=h,(E=this.closeable)==null||E.click(this,this.element),(x=this.closeable)==null||x.close("clickItem"),this.handleTableCreatorLeave()});m(this,"handleTableCreatorLeave",()=>{for(let t=0;t<9;t++)for(let e=0;e<9;e++){const r=this.getTableCreatorCellId(t,e),i=document.getElementById(r);i&&ot(i,"active")}});m(this,"handleTableCreatorCellEnter",t=>{const e=t.target;p(ho,e instanceof HTMLElement,"invalid event target");const r=e.id,i="table-creator-cell-";p(ho,r.startsWith(i),"invalid cell id");const s=r.substring(i.length).split("-");p(ho,s.length===2,"invalid cell id");let l=Number.parseInt(s[0],10),c=Number.parseInt(s[1],10);l===0&&c===0&&(l=-1,c=-1);for(let d=0;d<9;d++)for(let h=0;h<9;h++){const C=this.getTableCreatorCellId(d,h),E=document.getElementById(C);p(ho,E,"no cell"),d<=l&&h<=c?z(E,"active"):ot(E,"active")}});this.element=this.createTableCreatorElement()}createTableCreatorElement(){const t=B("div",["table-creator"],null),e=(r,i,o)=>{const s=B("div",["table-creator-cell"],r);return s.id=this.getTableCreatorCellId(i,o),s};t.addEventListener("click",this.handleTableCreatorClick),t.addEventListener("mouseleave",this.handleTableCreatorLeave);for(let r=0;r<9;r++){const i=B("div",["table-creator-row"],t);for(let o=0;o<9;o++)e(i,r,o).addEventListener("mouseenter",this.handleTableCreatorCellEnter)}return t}}function EH(){return new CH}function AH(n){const t=/[\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g,e=n.match(t);return e?e.length:0}function gR(n){const t=AH(n);return n.length+t}function xH(n,t,e=[]){let r=0;if(!e||e.length===0)return r;for(let i=n;i<n+t;i+=1)r+=e[i]||0;return r}function bH(n,t){const e=gR(n),r=t-e;return r>0?n+" ".repeat(r):n}function vH(n,t,e,r,i){var l;const o=t,s=new c0(o);if(r==="markdown"||r==="text"){const c=M=>e.blocks[M].map((G,W)=>r==="markdown"?bh(n,G,e,[...i,{containerId:M,blockIndex:W}]):xh(n,G,e,[...i,{containerId:M,blockIndex:W}])),d=M=>c(M).join(" ").replace(/\n/g," ").trim(),h=new Map,C=new Map;for(let M=0;M<s.colCount;M++){let U=0;for(let F=0;F<s.rowCount;F++){const G=s.getCell({row:F,col:M});let W="";G.virtual||(W=d(G.containerId)),h.set(`${F},${M}`,W),U=Math.max(U,gR(W))}C.set(M,U)}const E=M=>{const U=h.get(`${M.row},${M.col}`)||"",F=C.get(M.col)||0;return bH(U,F)};if(r==="text"){const M=[];for(let U=0;U<s.colCount;U++){const F=E({row:0,col:U});M.push(F)}for(let U=1;U<s.rowCount;U++)for(let F=0;F<s.colCount;F++){const G=E({row:U,col:F});M.push(G)}return M.join(`
|
|
643
643
|
`)}const x=[];let v="|",R="|";for(let M=0;M<s.colCount;M++){const U=E({row:0,col:M});v+=` ${U} |`;const F="-".repeat((C.get(M)||0)+2);R+=`${F}|`}x.push(v),x.push(R);for(let M=1;M<s.rowCount;M++){let U="|";for(let F=0;F<s.colCount;F++){const G=E({row:M,col:F});U+=` ${G} |`}x.push(U)}return`${x.join(`
|
|
644
644
|
`)}
|
|
645
645
|
`}if(r==="html"){const c=C=>e.blocks[C].map((v,R)=>Q1(n,v,e,[...i,{containerId:C,blockIndex:R}])).join(`
|