@univerjs/core 0.15.1 → 0.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +3 -3
package/lib/umd/index.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
`,e.TABLE_START="",e.TABLE_ROW_START="\x1B",e.TABLE_CELL_START="",e.TABLE_CELL_END="",e.TABLE_ROW_END="",e.TABLE_END="",e.CUSTOM_RANGE_START="",e.CUSTOM_RANGE_END="",e.COLUMN_BREAK="\v",e.PAGE_BREAK="\f",e.DOCS_END="\0",e.TAB=" ",e.CUSTOM_BLOCK="\b",e.LETTER="",e.SPACE=" ",e))(ut||{});function TC(e){return`${e}`}const NC=[ut.TABLE_START,ut.TABLE_ROW_START,ut.TABLE_CELL_START,ut.TABLE_CELL_END,ut.TABLE_ROW_END,ut.TABLE_END],Zs=e=>{const t=e.endsWith(`\r
|
|
6
6
|
`)?e.slice(0,-2):e;return NC.reduce((n,r)=>n.replaceAll(r,""),t)},MC=e=>e?Zs(e).replaceAll("\r","")==="":!0,DC=e=>{const t=e.replace(/\n/g,"\r"),n=[],r=[];let s=0,i="";const o=(l,c=!0)=>{const u=t.slice(s,l);if(Z.isLegalUrl(u)){const h=nt(),d=`${u}`,m={startIndex:s,endIndex:s+d.length-1,rangeId:h,rangeType:en.HYPERLINK,properties:{url:e}};r.push(m),i+=d,s=l+1,c&&(i+="\r",n.push({startIndex:l}))}else i+=t.slice(s,l+1),s=l+1,c&&n.push({startIndex:l})};let a=0;for(let l=0;l<t.length;l++)t[l]==="\r"&&(o(l),a=l);return(a!==t.length-1||t.length===1)&&o(t.length,!1),{dataStream:i,paragraphs:n,customRanges:r}},qo={id:"default_doc",documentStyle:{}};class LC extends as{constructor(n){var r;super();E(this,"type",ve.UNIVER_DOC);E(this,"_name$",new se.BehaviorSubject(""));E(this,"name$",this._name$.asObservable());E(this,"snapshot");this.snapshot={...qo,...n},this._name$.next((r=this.snapshot.title)!=null?r:"No Title")}getUnitId(){throw new Error("Method not implemented.")}getRev(){var n;return(n=this.snapshot.rev)!=null?n:1}incrementRev(){this.snapshot.rev=this.getRev()+1}setRev(n){this.snapshot.rev=n}setName(n){this.snapshot.title=n,this._name$.next(n)}get drawings(){return this.snapshot.drawings}get documentStyle(){return this.snapshot.documentStyle}get lists(){return this.snapshot.lists}get zoomRatio(){var n;return((n=this.snapshot.settings)==null?void 0:n.zoomRatio)||1}resetDrawing(n,r){this.snapshot.drawings=n,this.snapshot.drawingsOrder=r}getBody(){return this.snapshot.body}getSnapshot(){return this.snapshot}getBulletPresetList(){var s;const n=(s=this.snapshot.lists)!=null?s:{};return{...kr,...n}}updateDocumentId(n){this.snapshot.id=n}updateDocumentRenderConfig(n){const{documentStyle:r}=this.snapshot;r.renderConfig==null?r.renderConfig=n:r.renderConfig={...r.renderConfig,...n}}getDocumentStyle(){return this.snapshot.documentStyle}updateDocumentStyle(n){this.snapshot.documentStyle==null?this.snapshot.documentStyle=n:this.snapshot.documentStyle={...this.snapshot.documentStyle,...n}}updateDocumentDataMargin(n){const{t:r,l:s,b:i,r:o}=n,{documentStyle:a}=this.snapshot;r!=null&&(a.marginTop=r),s!=null&&(a.marginLeft=s),i!=null&&(a.marginBottom=i),o!=null&&(a.marginRight=o)}updateDocumentDataPageSize(n,r){const{documentStyle:s}=this.snapshot;if(!s.pageSize){s.pageSize={width:n!=null?n:Number.POSITIVE_INFINITY,height:r!=null?r:Number.POSITIVE_INFINITY};return}n!==void 0&&(s.pageSize.width=n),r!==void 0&&(s.pageSize.height=r)}updateDrawing(n,r){const{drawings:s}=this,{width:i,height:o,left:a,top:l}=r,c=s==null?void 0:s[n];if(!c)return;const u=c.docTransform;u.size.width=i,u.size.height=o,u.positionH.posOffset=a,u.positionV.posOffset=l}setZoomRatio(n=1){this.snapshot.settings?this.snapshot.settings.zoomRatio=n:this.snapshot.settings={zoomRatio:n}}setDisabled(n){this.snapshot.disabled=n}getDisabled(){return this.snapshot.disabled}getTitle(){return this.snapshot.title}}class Tt extends LC{constructor(n){var s,i;super(Z.isEmptyObject(n)?U_():n);E(this,"_unitId");E(this,"headerModelMap",new Map);E(this,"footerModelMap",new Map);E(this,"change$",new se.BehaviorSubject(0));const r=6;this._unitId=(s=this.snapshot.id)!=null?s:nt(r),this._initializeHeaderFooterModel(),this._name$.next((i=this.snapshot.title)!=null?i:"")}dispose(){super.dispose(),this.headerModelMap.forEach(n=>{n.dispose()}),this.footerModelMap.forEach(n=>{n.dispose()}),this._name$.complete()}getDrawings(){return this.snapshot.drawings}getDrawingsOrder(){return this.snapshot.drawingsOrder}getCustomRanges(){var n;return(n=this.snapshot.body)==null?void 0:n.customRanges}getCustomDecorations(){var n;return(n=this.snapshot.body)==null?void 0:n.customDecorations}getSettings(){return this.snapshot.settings}reset(n){if(n.id&&n.id!==this._unitId)throw new Error("Cannot reset a document model with a different unit id!");this.snapshot={...qo,...n},this._initializeHeaderFooterModel(),this.change$.next(this.change$.value+1)}getSelfOrHeaderFooterModel(n){if(n!=null){if(this.headerModelMap.has(n))return this.headerModelMap.get(n);if(this.footerModelMap.has(n))return this.footerModelMap.get(n)}return this}getUnitId(){return this._unitId}apply(n){if(!Vt.isNoop(n))return this.snapshot=Vt.apply(this.snapshot,n),n!=null&&n.some(r=>Array.isArray(r)&&((r==null?void 0:r[0])==="headers"||(r==null?void 0:r[0])==="footers"))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.change$.next(this.change$.value+1),this.snapshot}sliceBody(n,r,s=Ko.copy){const i=this.getBody();if(i!=null)return At(i,n,r,!1,s)}_initializeHeaderFooterModel(){const{headers:n,footers:r}=this.getSnapshot();if(n)for(const s in n){const i=n[s];this.headerModelMap.set(s,new Tt(i)),this.headerModelMap.get(s).updateDocumentId(this.getUnitId())}if(r)for(const s in r){const i=r[s];this.footerModelMap.set(s,new Tt(i)),this.footerModelMap.get(s).updateDocumentId(this.getUnitId())}}updateDocumentId(n){super.updateDocumentId(n),this._unitId=n}getPlainText(){var n,r;return Zs((r=(n=this.getBody())==null?void 0:n.dataStream)!=null?r:"")}}function UC(e){const{ranges:t,id:n,type:r}=e,s=new De;let i=0;for(let o=0;o<t.length;o++){const a=t[o],{startOffset:l,endOffset:c}=a;l>0&&s.push({t:J.RETAIN,len:l-i}),s.push({t:J.RETAIN,body:{dataStream:"",customDecorations:[{id:n,type:r,startIndex:0,endIndex:c-l-1}]},len:c-l}),i=c}return s}function PC(e){var u,h,d;const{id:t,segmentId:n,documentDataModel:r}=e,s=r==null?void 0:r.getBody();if(!r||!s)return!1;const i=(d=(h=(u=r.getSelfOrHeaderFooterModel(n))==null?void 0:u.getBody())==null?void 0:h.customDecorations)==null?void 0:d.find(m=>m.id===t);if(!i)return!1;const o=new De,{startIndex:a,endIndex:l}=i,c=l-a+1;return o.push({t:J.RETAIN,len:a}),o.push({t:J.RETAIN,len:c,body:{dataStream:"",customDecorations:[{startIndex:0,endIndex:c-1,id:t,type:_n.DELETED}]}}),o}function Oh(e,t,n,r){return e<=n&&t>=n||e>=n&&e<=r}function kC(e,t){const n=[];for(let r=0,s=t.length;r<s;r++){const i=t[r];e.collapsed?i.startIndex<e.startOffset&&e.startOffset<=i.endIndex&&n.push(i):Oh(e.startOffset,e.endOffset-1,i.startIndex,i.endIndex)&&n.push(i)}return n}function FC(e){return{...Z.deepClone(e),rangeId:nt()}}function xC(e,t){const n=[];let r=e[0];for(const s of t)s<e[0]||s>e[1]||(r<s&&n.push([r,s-1]),r=s+1);return r<=e[1]&&n.push([r,e[1]]),n}function wh(e,t,n,r){const s=[];for(let i=0,o=n.length;i<o;i++){const a=n[i];if((r===void 0||a.rangeType===r)&&Math.max(a.startIndex,e)<=Math.min(a.endIndex,t)&&s.push({...a}),a.startIndex>t)break}return s}function HC(e,t){var i,o,a,l,c;const n=wh(e.startOffset,e.collapsed?e.startOffset:e.endOffset-1,(i=t.customRanges)!=null?i:[]),r=Math.min(e.startOffset,(a=(o=n[0])==null?void 0:o.startIndex)!=null?a:1/0),s=Math.max(e.endOffset,((c=(l=n[n.length-1])==null?void 0:l.endIndex)!=null?c:-1/0)+1);return{startOffset:r,endOffset:s,collapsed:r===s}}var Jo,vh;function BC(){if(vh)return Jo;vh=1;var e=-1,t=1,n=0;function r(g,P,w,M,A){if(g===P)return g?[[n,g]]:[];if(w!=null){var v=B(g,P,w);if(v)return v}var N=a(g,P),D=g.substring(0,N);g=g.substring(N),P=P.substring(N),N=c(g,P);var L=g.substring(g.length-N);g=g.substring(0,g.length-N),P=P.substring(0,P.length-N);var F=s(g,P);return D&&F.unshift([n,D]),L&&F.push([n,L]),H(F,A),M&&h(F),F}function s(g,P){var w;if(!g)return[[t,P]];if(!P)return[[e,g]];var M=g.length>P.length?g:P,A=g.length>P.length?P:g,v=M.indexOf(A);if(v!==-1)return w=[[t,M.substring(0,v)],[n,A],[t,M.substring(v+A.length)]],g.length>P.length&&(w[0][0]=w[2][0]=e),w;if(A.length===1)return[[e,g],[t,P]];var N=u(g,P);if(N){var D=N[0],L=N[1],F=N[2],Q=N[3],G=N[4],le=r(D,F),ue=r(L,Q);return le.concat([[n,G]],ue)}return i(g,P)}function i(g,P){for(var w=g.length,M=P.length,A=Math.ceil((w+M)/2),v=A,N=2*A,D=new Array(N),L=new Array(N),F=0;F<N;F++)D[F]=-1,L[F]=-1;D[v+1]=0,L[v+1]=0;for(var Q=w-M,G=Q%2!==0,le=0,ue=0,S=0,U=0,V=0;V<A;V++){for(var z=-V+le;z<=V-ue;z+=2){var j=v+z,W;z===-V||z!==V&&D[j-1]<D[j+1]?W=D[j+1]:W=D[j-1]+1;for(var ee=W-z;W<w&&ee<M&&g.charAt(W)===P.charAt(ee);)W++,ee++;if(D[j]=W,W>w)ue+=2;else if(ee>M)le+=2;else if(G){var te=v+Q-z;if(te>=0&&te<N&&L[te]!==-1){var k=w-L[te];if(W>=k)return o(g,P,W,ee)}}}for(var K=-V+S;K<=V-U;K+=2){var te=v+K,k;K===-V||K!==V&&L[te-1]<L[te+1]?k=L[te+1]:k=L[te-1]+1;for(var q=k-K;k<w&&q<M&&g.charAt(w-k-1)===P.charAt(M-q-1);)k++,q++;if(L[te]=k,k>w)U+=2;else if(q>M)S+=2;else if(!G){var j=v+Q-K;if(j>=0&&j<N&&D[j]!==-1){var W=D[j],ee=v+W-j;if(k=w-k,W>=k)return o(g,P,W,ee)}}}}return[[e,g],[t,P]]}function o(g,P,w,M){var A=g.substring(0,w),v=P.substring(0,M),N=g.substring(w),D=P.substring(M),L=r(A,v),F=r(N,D);return L.concat(F)}function a(g,P){if(!g||!P||g.charAt(0)!==P.charAt(0))return 0;for(var w=0,M=Math.min(g.length,P.length),A=M,v=0;w<A;)g.substring(v,A)==P.substring(v,A)?(w=A,v=w):M=A,A=Math.floor((M-w)/2+w);return x(g.charCodeAt(A-1))&&A--,A}function l(g,P){var w=g.length,M=P.length;if(w==0||M==0)return 0;w>M?g=g.substring(w-M):w<M&&(P=P.substring(0,w));var A=Math.min(w,M);if(g==P)return A;for(var v=0,N=1;;){var D=g.substring(A-N),L=P.indexOf(D);if(L==-1)return v;N+=L,(L==0||g.substring(A-N)==P.substring(0,N))&&(v=N,N++)}}function c(g,P){if(!g||!P||g.slice(-1)!==P.slice(-1))return 0;for(var w=0,M=Math.min(g.length,P.length),A=M,v=0;w<A;)g.substring(g.length-A,g.length-v)==P.substring(P.length-A,P.length-v)?(w=A,v=w):M=A,A=Math.floor((M-w)/2+w);return Y(g.charCodeAt(g.length-A))&&A--,A}function u(g,P){var w=g.length>P.length?g:P,M=g.length>P.length?P:g;if(w.length<4||M.length*2<w.length)return null;function A(ue,S,U){for(var V=ue.substring(U,U+Math.floor(ue.length/4)),z=-1,j="",W,ee,te,k;(z=S.indexOf(V,z+1))!==-1;){var K=a(ue.substring(U),S.substring(z)),q=c(ue.substring(0,U),S.substring(0,z));j.length<q+K&&(j=S.substring(z-q,z)+S.substring(z,z+K),W=ue.substring(0,U-q),ee=ue.substring(U+K),te=S.substring(0,z-q),k=S.substring(z+K))}return j.length*2>=ue.length?[W,ee,te,k,j]:null}var v=A(w,M,Math.ceil(w.length/4)),N=A(w,M,Math.ceil(w.length/2)),D;if(!v&&!N)return null;N?v?D=v[4].length>N[4].length?v:N:D=N:D=v;var L,F,Q,G;g.length>P.length?(L=D[0],F=D[1],Q=D[2],G=D[3]):(Q=D[0],G=D[1],L=D[2],F=D[3]);var le=D[4];return[L,F,Q,G,le]}function h(g){for(var P=!1,w=[],M=0,A=null,v=0,N=0,D=0,L=0,F=0;v<g.length;)g[v][0]==n?(w[M++]=v,N=L,D=F,L=0,F=0,A=g[v][1]):(g[v][0]==t?L+=g[v][1].length:F+=g[v][1].length,A&&A.length<=Math.max(N,D)&&A.length<=Math.max(L,F)&&(g.splice(w[M-1],0,[e,A]),g[w[M-1]+1][0]=t,M--,M--,v=M>0?w[M-1]:-1,N=0,D=0,L=0,F=0,A=null,P=!0)),v++;for(P&&H(g),y(g),v=1;v<g.length;){if(g[v-1][0]==e&&g[v][0]==t){var Q=g[v-1][1],G=g[v][1],le=l(Q,G),ue=l(G,Q);le>=ue?(le>=Q.length/2||le>=G.length/2)&&(g.splice(v,0,[n,G.substring(0,le)]),g[v-1][1]=Q.substring(0,Q.length-le),g[v+1][1]=G.substring(le),v++):(ue>=Q.length/2||ue>=G.length/2)&&(g.splice(v,0,[n,Q.substring(0,ue)]),g[v-1][0]=t,g[v-1][1]=G.substring(0,G.length-ue),g[v+1][0]=e,g[v+1][1]=Q.substring(ue),v++),v++}v++}}var d=/[^a-zA-Z0-9]/,m=/\s/,_=/[\r\n]/,p=/\n\r?\n$/,I=/^\r?\n\r?\n/;function y(g){function P(ue,S){if(!ue||!S)return 6;var U=ue.charAt(ue.length-1),V=S.charAt(0),z=U.match(d),j=V.match(d),W=z&&U.match(m),ee=j&&V.match(m),te=W&&U.match(_),k=ee&&V.match(_),K=te&&ue.match(p),q=k&&S.match(I);return K||q?5:te||k?4:z&&!W&&ee?3:W||ee?2:z||j?1:0}for(var w=1;w<g.length-1;){if(g[w-1][0]==n&&g[w+1][0]==n){var M=g[w-1][1],A=g[w][1],v=g[w+1][1],N=c(M,A);if(N){var D=A.substring(A.length-N);M=M.substring(0,M.length-N),A=D+A.substring(0,A.length-N),v=D+v}for(var L=M,F=A,Q=v,G=P(M,A)+P(A,v);A.charAt(0)===v.charAt(0);){M+=A.charAt(0),A=A.substring(1)+v.charAt(0),v=v.substring(1);var le=P(M,A)+P(A,v);le>=G&&(G=le,L=M,F=A,Q=v)}g[w-1][1]!=L&&(L?g[w-1][1]=L:(g.splice(w-1,1),w--),g[w][1]=F,Q?g[w+1][1]=Q:(g.splice(w+1,1),w--))}w++}}function H(g,P){g.push([n,""]);for(var w=0,M=0,A=0,v="",N="",D;w<g.length;){if(w<g.length-1&&!g[w][1]){g.splice(w,1);continue}switch(g[w][0]){case t:A++,N+=g[w][1],w++;break;case e:M++,v+=g[w][1],w++;break;case n:var L=w-A-M-1;if(P){if(L>=0&&R(g[L][1])){var F=g[L][1].slice(-1);if(g[L][1]=g[L][1].slice(0,-1),v=F+v,N=F+N,!g[L][1]){g.splice(L,1),w--;var Q=L-1;g[Q]&&g[Q][0]===t&&(A++,N=g[Q][1]+N,Q--),g[Q]&&g[Q][0]===e&&(M++,v=g[Q][1]+v,Q--),L=Q}}if(O(g[w][1])){var F=g[w][1].charAt(0);g[w][1]=g[w][1].slice(1),v+=F,N+=F}}if(w<g.length-1&&!g[w][1]){g.splice(w,1);break}if(v.length>0||N.length>0){v.length>0&&N.length>0&&(D=a(N,v),D!==0&&(L>=0?g[L][1]+=N.substring(0,D):(g.splice(0,0,[n,N.substring(0,D)]),w++),N=N.substring(D),v=v.substring(D)),D=c(N,v),D!==0&&(g[w][1]=N.substring(N.length-D)+g[w][1],N=N.substring(0,N.length-D),v=v.substring(0,v.length-D)));var G=A+M;v.length===0&&N.length===0?(g.splice(w-G,G),w=w-G):v.length===0?(g.splice(w-G,G,[t,N]),w=w-G+1):N.length===0?(g.splice(w-G,G,[e,v]),w=w-G+1):(g.splice(w-G,G,[e,v],[t,N]),w=w-G+2)}w!==0&&g[w-1][0]===n?(g[w-1][1]+=g[w][1],g.splice(w,1)):w++,A=0,M=0,v="",N="";break}}g[g.length-1][1]===""&&g.pop();var le=!1;for(w=1;w<g.length-1;)g[w-1][0]===n&&g[w+1][0]===n&&(g[w][1].substring(g[w][1].length-g[w-1][1].length)===g[w-1][1]?(g[w][1]=g[w-1][1]+g[w][1].substring(0,g[w][1].length-g[w-1][1].length),g[w+1][1]=g[w-1][1]+g[w+1][1],g.splice(w-1,1),le=!0):g[w][1].substring(0,g[w+1][1].length)==g[w+1][1]&&(g[w-1][1]+=g[w+1][1],g[w][1]=g[w][1].substring(g[w+1][1].length)+g[w+1][1],g.splice(w+1,1),le=!0)),w++;le&&H(g,P)}function x(g){return g>=55296&&g<=56319}function Y(g){return g>=56320&&g<=57343}function O(g){return Y(g.charCodeAt(0))}function R(g){return x(g.charCodeAt(g.length-1))}function b(g){for(var P=[],w=0;w<g.length;w++)g[w][1].length>0&&P.push(g[w]);return P}function T(g,P,w,M){return R(g)||O(M)?null:b([[n,g],[e,P],[t,w],[n,M]])}function B(g,P,w){var M=typeof w=="number"?{index:w,length:0}:w.oldRange,A=typeof w=="number"?null:w.newRange,v=g.length,N=P.length;if(M.length===0&&(A===null||A.length===0)){var D=M.index,L=g.slice(0,D),F=g.slice(D),Q=A?A.index:null;e:{var G=D+N-v;if(Q!==null&&Q!==G||G<0||G>N)break e;var le=P.slice(0,G),ue=P.slice(G);if(ue!==F)break e;var S=Math.min(D,G),U=L.slice(0,S),V=le.slice(0,S);if(U!==V)break e;var z=L.slice(S),j=le.slice(S);return T(U,z,j,F)}e:{if(Q!==null&&Q!==D)break e;var W=D,le=P.slice(0,W),ue=P.slice(W);if(le!==L)break e;var ee=Math.min(v-W,N-W),te=F.slice(F.length-ee),k=ue.slice(ue.length-ee);if(te!==k)break e;var z=F.slice(0,F.length-ee),j=ue.slice(0,ue.length-ee);return T(L,z,j,te)}}if(M.length>0&&A&&A.length===0)e:{var U=g.slice(0,M.index),te=g.slice(M.index+M.length),S=U.length,ee=te.length;if(N<S+ee)break e;var V=P.slice(0,S),k=P.slice(N-ee);if(U!==V||te!==k)break e;var z=g.slice(S,v-ee),j=P.slice(S,N-ee);return T(U,z,j,te)}return null}function $(g,P,w,M){return r(g,P,w,M,!0)}return $.INSERT=t,$.DELETE=e,$.EQUAL=n,Jo=$,Jo}var $C=BC();const Zo=pt($C);function jC(e){var h,d,m;const{rangeId:t,segmentId:n,documentDataModel:r,insert:s}=e,i=(d=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.customRanges)==null?void 0:d.find(_=>_.rangeId===t);if(!i)return!1;const{startIndex:o,endIndex:a}=i,l=new De,c=a-o+1;l.push({t:J.RETAIN,len:o}),l.push({t:J.RETAIN,len:c,body:{dataStream:"",customRanges:[]}}),s&&l.push({t:J.INSERT,body:s,len:s.dataStream.length});const u=a+1+((m=s==null?void 0:s.dataStream.length)!=null?m:0);return l.selections=[{startOffset:u,endOffset:u,collapsed:!0}],l}function WC(e){const{ranges:t,rangeId:n,rangeType:r,wholeEntity:s,properties:i,body:o}=e;let a=0;const l=new De;let c=!1;return t.forEach(u=>{var x,Y,O;const h=HC(u,o);if(!h||!o)return!1;const{startOffset:d,endOffset:m}=h,_=(x=o.customRanges)!=null?x:[],p=(R,b,T)=>{var w,M,A,v;const B=wh(R,b,_,r),$=Math.min((M=(w=B[0])==null?void 0:w.startIndex)!=null?M:1/0,R),g=Math.max((v=(A=B[B.length-1])==null?void 0:A.endIndex)!=null?v:-1/0,b),P={rangeId:T?`${n}$${T}`:n,rangeType:r,startIndex:0,endIndex:g-$,wholeEntity:s,properties:{...i}};l.push({t:J.RETAIN,len:$-a}),l.push({t:J.RETAIN,len:g-$+1,body:{dataStream:"",customRanges:[P]},coverType:Re.COVER}),a=g+1},I=((Y=o.paragraphs)!=null?Y:[]).filter(R=>R.startIndex<m&&R.startIndex>d),y=((O=o.customBlocks)!=null?O:[]).filter(R=>R.startIndex<m&&R.startIndex>d);xC([d,m-1],[...I.map(R=>R.startIndex),...y.map(R=>R.startIndex)]).forEach(([R,b],T)=>p(R,b,T)),c=!0,l.selections=[{startOffset:h.endOffset,endOffset:h.endOffset,collapsed:!0}]}),c?l:!1}function bh(e,t,n=0,r=null,s=!0){e.sort((c,u)=>c.startOffset-u.startOffset);const i=[],{paragraphs:o=[]}=t,a=o==null?void 0:o.find(c=>c.startIndex>=e[0].startOffset&&c.startIndex<e[0].endOffset);let l=n;if(e.forEach(c=>{const{startOffset:u,endOffset:h}=c;u>l&&(i.push({t:J.RETAIN,len:u-l}),l=u),l<h&&(i.push({t:J.DELETE,len:h-l}),l=h)}),r&&i.push({t:J.INSERT,body:r,len:r.dataStream.length}),a&&s){const c=o.find(u=>u.startIndex-n>=e[e.length-1].endOffset-1);c&&(c.startIndex>l&&(i.push({t:J.RETAIN,len:c.startIndex-l}),l=c.startIndex),i.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...c,startIndex:0,bullet:a==null?void 0:a.bullet}]},coverType:Re.REPLACE}))}return i}function YC(e,t,n=0){const r=[];let s=n;return e.forEach(i=>{const{startOffset:o,endOffset:a}=i;o>s&&(r.push({t:J.RETAIN,len:o-s}),s=o),a>s&&(r.push({t:J.RETAIN,len:a-s,body:{...Z.deepClone(t),dataStream:""}}),s=a)}),r}const VC=e=>{var h;const{selection:t,body:n,doc:r}=e,s=t.segmentId,i=(h=r.getSelfOrHeaderFooterModel(s))==null?void 0:h.getBody();if(!i)return!1;const o=t.collapsed?null:At(i,t.startOffset,t.endOffset),a=Zo(o?o.dataStream:"",n.dataStream);let l=0;const c=a.map(([d,m])=>{switch(d){case 0:{const _={t:J.RETAIN,body:{...At(n,l,l+m.length,!1),dataStream:""},len:m.length};return l+=m.length,_}case 1:{const _={t:J.INSERT,body:At(n,l,l+m.length),len:m.length};return l+=m.length,_}default:return{t:J.DELETE,len:m.length}}}),u=new De;return u.push({t:J.RETAIN,len:t.startOffset}),u.push(...c),u};function zC(e,t){return!!((e==null?void 0:e.length)===(t==null?void 0:t.length)&&(e!=null&&e.every((n,r)=>JSON.stringify(n)===JSON.stringify(t==null?void 0:t[r]))))}const GC=e=>{var d;const{selection:t,body:n,doc:r,themeService:s}=e,i=t.segmentId,o=(d=r.getSelfOrHeaderFooterModel(i))==null?void 0:d.getBody();if(!o)return!1;const a=t.collapsed?null:At(o,t.startOffset,t.endOffset),l=Zo(a?a.dataStream:"",n.dataStream);let c=0;const u=l.map(([m,_])=>{switch(m){case 0:{const p=Js(n,c,c+_.length,!1),I=Js(a,c,c+_.length,!1),y={t:J.RETAIN,body:zC(p,I)?void 0:{textRuns:p==null?void 0:p.map(H=>{var x,Y,O,R,b,T,B;return{...H,ts:{...H.ts,cl:(O=(Y=(x=H.ts)==null?void 0:x.cl)==null?void 0:Y.rgb)!=null&&O.includes(".")?{rgb:s.getColorFromTheme((T=(b=(R=H.ts)==null?void 0:R.cl)==null?void 0:b.rgb)!=null?T:"")}:(B=H.ts)==null?void 0:B.cl}}}),dataStream:""},len:_.length};return c+=_.length,y}case 1:{const p={t:J.INSERT,body:At(n,c,c+_.length),len:_.length};return c+=_.length,p}default:return{t:J.DELETE,len:_.length}}});if(u.every(m=>m.t===J.RETAIN&&!m.body))return!1;const h=new De;return h.push({t:J.RETAIN,len:t.startOffset}),h.push(...u),h};function KC(e,t){const n=[],{customBlocks:r=[]}=e;for(const s of t){const{startOffset:i,endOffset:o}=s;if(!(i==null||o==null))for(const a of r){const{startIndex:l}=a;l>=i&&l<o&&n.push(a.blockId)}}return n}function XC(e,t=""){if(!t)return["body"];const{headers:n,footers:r}=e.getSnapshot();if(n==null&&r==null)throw new Error("Document data model must have headers or footers when update by segment id");if((n==null?void 0:n[t])!=null)return["headers",t,"body"];if((r==null?void 0:r[t])!=null)return["footers",t,"body"];throw new Error("Segment id not found in headers or footers")}const qC=e=>{var p,I,y,H;const{selection:t,documentDataModel:n,drawings:r}=e,{collapsed:s,startOffset:i,segmentId:o}=t,a=new De,l=Vt.getInstance(),c=[],u=n.getSelfOrHeaderFooterModel(o).getBody();if(!u)return!1;const h=(I=(p=n.getSnapshot().drawingsOrder)==null?void 0:p.length)!=null?I:0;let d=0;if(s)i>0&&a.push({t:J.RETAIN,len:i});else{const x=bh([t],u,0,null,!1);a.push(...x);const Y=KC(u,[t]),O=(y=n.getDrawings())!=null?y:{},R=(H=n.getDrawingsOrder())!=null?H:[],b=Y.sort((T,B)=>R.indexOf(T)>R.indexOf(B)?-1:R.indexOf(T)<R.indexOf(B)?1:0);if(b.length>0)for(const T of b){const B=O[T],$=R.indexOf(T);if(B==null||$<0)continue;const g=l.removeOp(["drawings",T],B),P=l.removeOp(["drawingsOrder",$],T);c.push(g),c.push(P),d++}}a.push({t:J.INSERT,body:{dataStream:"\b".repeat(r.length),customBlocks:r.map((x,Y)=>({startIndex:Y,blockId:x.drawingId}))},len:r.length});const m=XC(n,o),_=l.editOp(a.serialize(),m);c.push(_);for(const x of r){const{drawingId:Y}=x,O=l.insertOp(["drawings",Y],x),R=l.insertOp(["drawingsOrder",h-d],Y);c.push(O),c.push(R)}return c.reduce((x,Y)=>Vt.compose(x,Y),null)};function JC(e,t){if(typeof t>"u")return{startOffset:e,endOffset:e,collapsed:!0};if(t<e)throw new Error(`Cannot make a doc selection when endOffset ${t} is less than startOffset ${e}.`);return{startOffset:e,endOffset:t,collapsed:e===t}}function ZC(e){const{startOffset:t,endOffset:n,collapsed:r}=e,s=Math.min(t,n),i=Math.max(t,n);return{startOffset:s,endOffset:i,collapsed:r}}function QC(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function Qo(e,t,n,r){const{startOffset:s,endOffset:i}=e,o=r!=null?r:ta(t,n),a=[];let l=-1;for(let c=0;c<o.length;c++){const u=o[c],{startIndex:h}=u;(s>l&&s<=h||i>l&&i<=h||h>=s&&h<=i)&&a.push(u),l=h}return a}function ea(e,t,n){const r=[],s=ta(t,n);for(const i of e){const o=Qo(i,t,n,s);r.push(...o)}return r}const eR=[ut.PARAGRAPH,ut.TABLE_START,ut.TABLE_END,ut.TABLE_ROW_START,ut.TABLE_CELL_START,ut.TABLE_CELL_END];function ta(e,t){const n=[];for(let r=0;r<e.length;r++){const s=e[r],{startIndex:i}=s;let o=i-1;for(;!eR.includes(t[o])&&o>=0;)o--;n.push({...s,paragraphStart:o+1,paragraphEnd:s.startIndex})}return n}const tR=e=>{var h,d,m;const{paragraphs:t,segmentId:n,document:r}=e;let s=e.listType;const i=(d=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.paragraphs)!=null?d:[],o=t.every(_=>{var p;return((p=_.bullet)==null?void 0:p.listType.indexOf(s))===0});let l=nt(6);if(t.length===1){const _=i.indexOf(t[0]),p=i[_-1],I=i[_+1];p&&p.bullet&&p.bullet.listType.indexOf(s)===0?(l=p.bullet.listId,s!==xt.CHECK_LIST&&(s=p.bullet.listType)):I&&I.bullet&&I.bullet.listType.indexOf(s)===0&&(l=I.bullet.listId,s!==xt.CHECK_LIST&&(s=I.bullet.listType))}const c=new fn;c.reset();const u=new De;for(const _ of t){const{startIndex:p,paragraphStyle:I={},bullet:y}=_;u.push({t:J.RETAIN,len:p-c.cursor}),u.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[o?{paragraphStyle:I,startIndex:0}:{startIndex:0,paragraphStyle:{...I},bullet:{nestingLevel:(m=y==null?void 0:y.nestingLevel)!=null?m:0,textStyle:{fs:20},listType:s,listId:l}}]},coverType:Re.REPLACE}),c.moveCursorTo(p+1)}return u},nR=e=>{var h;const{paragraphIndex:t,segmentId:n,document:r}=e,s=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.paragraphs;if(s==null)return!1;const i=s.find(d=>d.startIndex===t);if(!(i!=null&&i.bullet)||i.bullet.listType.indexOf(xt.CHECK_LIST)===-1)return!1;const o=new fn;o.reset();const a=new De,{startIndex:l,paragraphStyle:c={}}=i,u=i.bullet.listType===xt.CHECK_LIST?xt.CHECK_LIST_CHECKED:xt.CHECK_LIST;return a.push({t:J.RETAIN,len:l-o.cursor}),a.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...i,paragraphStyle:c,startIndex:0,bullet:{...i.bullet,listType:u}}]},coverType:Re.REPLACE}),o.moveCursorTo(l+1),a},rR=e=>{var u,h;const{paragraphs:t,listType:n,segmentId:r,document:s}=e;if(((u=s.getSelfOrHeaderFooterModel(r).getBody())==null?void 0:u.paragraphs)==null)return!1;const a=nt(6),l=new fn;l.reset();const c=new De;for(const d of t){const{startIndex:m,paragraphStyle:_={},bullet:p}=d;c.push({t:J.RETAIN,len:m-l.cursor}),c.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:_,bullet:{nestingLevel:(h=p==null?void 0:p.nestingLevel)!=null?h:0,textStyle:(p==null?void 0:p.listType)===n?p.textStyle:{fs:20},listType:n,listId:a}}]},coverType:Re.REPLACE}),l.moveCursorTo(m+1)}return c};function sR(e,t){return t.some(n=>e.startIndex>n.startIndex&&e.startIndex<n.endIndex)}const iR=e=>{var c,u,h;const{paragraphs:t,document:n,type:r}=e,s=new fn;s.reset();const i=new De,o=(c=n.getSnapshot().lists)!=null?c:{},a=(h=(u=n.getBody())==null?void 0:u.tables)!=null?h:[],l={...kr,...o};for(const d of t){const{startIndex:m,paragraphStyle:_={},bullet:p}=d,I=sR(d,a);if(i.push({t:J.RETAIN,len:m-s.cursor}),p){const y=p.listType;let H=l[y].nestingLevel.length-1;I&&(H=Math.min(H,2)),i.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:{..._},bullet:{...p,nestingLevel:Math.max(Math.min(p.nestingLevel+r,H),0)}}]},coverType:Re.REPLACE})}else i.push({t:J.RETAIN,len:1});s.moveCursorTo(m+1)}return i},oR=e=>{var I,y,H,x;const{textRanges:t,segmentId:n,document:r,style:s,paragraphTextRun:i,cursor:o,deleteLen:a,textX:l}=e,c=r.getSelfOrHeaderFooterModel(n),u=(y=(I=c.getBody())==null?void 0:I.paragraphs)!=null?y:[],h=(x=(H=c.getBody())==null?void 0:H.dataStream)!=null?x:"",d=ea(t,u,h),m=new fn;o&&m.moveCursorTo(o);const _=l!=null?l:new De;d.sort((Y,O)=>Y.startIndex-O.startIndex);const p=Math.max(0,d[0].paragraphStart-1);p>m.cursor&&(_.push({t:J.RETAIN,len:p-m.cursor}),m.moveCursorTo(p)),a&&_.push({t:J.DELETE,len:a});for(const Y of d){const{startIndex:O,paragraphStyle:R={}}=Y,b=O-m.cursor;_.push({t:J.RETAIN,len:b,...i?{body:{dataStream:"",textRuns:[{ts:i,st:0,ed:b}]},coverType:Re.REPLACE}:null}),_.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:{...R,...s}}]},coverType:Re.REPLACE}),m.moveCursorTo(O+1)}return _};class Qe{}E(Qe,"customRange",{add:WC,delete:jC,copyCustomRange:FC,getCustomRangesInterestsWithSelection:kC,isIntersecting:Oh}),E(Qe,"customDecoration",{add:UC,delete:PC}),E(Qe,"selection",{replace:VC,makeSelection:JC,normalizeSelection:ZC,delete:bh,replaceTextRuns:GC,retain:YC}),E(Qe,"range",{isIntersects:QC,getParagraphsInRange:Qo,getParagraphsInRanges:ea}),E(Qe,"transform",{getPlainText:Zs,fromPlainText:DC,isEmptyDocument:MC}),E(Qe,"paragraph",{bullet:{set:rR,switch:tR,toggleChecklist:nR,changeNestLevel:iR},style:{set:oR},util:{transform:ta,getParagraphsInRange:Qo,getParagraphsInRanges:ea}}),E(Qe,"drawing",{add:qC});function aR(e,t,n,r){var c;if(t==="")return e;const s={id:"mock-id",body:e,documentStyle:{}},i=new Tt(s),o=t.length;let a;for(;(a=(r?i.getBody().dataStream:i.getBody().dataStream.toLowerCase()).indexOf(t))>=0;){const u=new De,h=Vt.getInstance();if(a>0&&u.retain(a),n.length>0){const d=i.sliceBody(a,a+o),m={dataStream:n};if(Array.isArray(d==null?void 0:d.textRuns)&&d.textRuns.length&&(m.textRuns=[{...d.textRuns[0],st:0,ed:n.length}]),(c=d==null?void 0:d.customRanges)!=null&&c.length){const _=d.customRanges[0];m.customRanges=[{..._,startIndex:0,endIndex:n.length-1}]}u.insert(n.length,m)}u.delete(o),i.apply(h.editOp(u.serialize()))}const l=i.getBody();return i.dispose(),l}function lR(e){if(e.customRanges||(e.customRanges=[]),!e.paragraphs){e.paragraphs=[];for(let t=0;t<e.dataStream.length;t++)e.dataStream[t]==="\r"&&e.paragraphs.push({startIndex:t})}return e.customBlocks||(e.customBlocks=[]),e.textRuns||(e.textRuns=[]),e.customDecorations||(e.customDecorations=[]),e.sectionBreaks||(e.sectionBreaks=[]),e.tables||(e.tables=[]),e}function yh(e){var t;return e.body=lR((t=e.body)!=null?t:{dataStream:""}),e.drawingsOrder||(e.drawingsOrder=[]),e.drawings||(e.drawings={}),e.documentStyle||(e.documentStyle={}),e}class Fr{constructor(t={}){E(this,"_style");this._style=t}static create(t={}){return new Fr(t)}get fontFamily(){return this._style.ff}get fontSize(){return this._style.fs}get italic(){return this._style.it===ae.TRUE}get bold(){return this._style.bl===ae.TRUE}get underline(){return this._style.ul&&on.create(this._style.ul)}get bottomBorderLine(){return this._style.bbl&&on.create(this._style.bbl)}get strikethrough(){return this._style.st&&on.create(this._style.st)}get overline(){return this._style.ol&&on.create(this._style.ol)}get background(){return this._style.bg}get border(){return this._style.bd}get color(){return this._style.cl}get verticalAlign(){return this._style.va}get numberFormat(){return this._style.n}copy(){return sn.create(Z.deepClone(this._style))}getValue(){return{...this._style}}}class sn extends Fr{static create(t={}){return new sn(t)}constructor(t={}){super(t)}setFontFamily(t){return this._style.ff=t,this}setFontSize(t){return this._style.fs=t,this}setItalic(t){return this._style.it=t?1:0,this}setBold(t){return this._style.bl=t?1:0,this}setUnderline(t){return this._style.ul=t.build(),this}setBottomBorderLine(t){return this._style.bbl=t.build(),this}setStrikethrough(t){return this._style.st=t.build(),this}setOverline(t){return this._style.ol=t.build(),this}setBackground(t){return this._style.bg=t,this}setBorder(t){return this._style.bd=t,this}setColor(t){return this._style.cl=t,this}setVerticalAlign(t){return this._style.va=t,this}copy(){return sn.create(Z.deepClone(this._style))}build(){return this.getValue()}}class on{constructor(t={s:1}){E(this,"_decoration");this._decoration=t}static create(t={s:1}){return new on(t)}get show(){return this._decoration.s===ae.TRUE}get followFontColor(){return this._decoration.c===ae.TRUE}get color(){return this._decoration.cl}get type(){return this._decoration.t}setShow(t){return this._decoration.s=t?1:0,this}setFollowFontColor(t){return this._decoration.c=t?1:0,this}setColor(t){return this._decoration.cl=t,this}setLineType(t){return this._decoration.t=t,this}copy(){return on.create(Z.deepClone(this._decoration))}build(){return{...this._decoration}}}class xr{constructor(t={}){E(this,"_style");this._style=t}static create(t={}){return new xr(t)}get indentFirstLine(){return this._style.indentFirstLine}get hanging(){return this._style.hanging}get indentStart(){return this._style.indentStart}get tabStops(){return this._style.tabStops}get indentEnd(){return this._style.indentEnd}get textStyle(){return this._style.textStyle}get headingId(){return this._style.headingId}get namedStyleType(){return this._style.namedStyleType}get horizontalAlign(){return this._style.horizontalAlign}get lineSpacing(){return this._style.lineSpacing}get direction(){return this._style.direction}get spacingRule(){return this._style.spacingRule}get snapToGrid(){return this._style.snapToGrid}get spaceAbove(){return this._style.spaceAbove}get spaceBelow(){return this._style.spaceBelow}get borderBetween(){return this._style.borderBetween}get borderTop(){return this._style.borderTop}get borderBottom(){return this._style.borderBottom}get borderLeft(){return this._style.borderLeft}get borderRight(){return this._style.borderRight}get keepLines(){return this._style.keepLines===ae.TRUE}get keepNext(){return this._style.keepNext===ae.TRUE}get wordWrap(){return this._style.wordWrap===ae.TRUE}get widowControl(){return this._style.widowControl===ae.TRUE}get shading(){return this._style.shading}get suppressHyphenation(){return this._style.suppressHyphenation===ae.TRUE}copy(){return Hr.create(Z.deepClone(this._style))}getValue(){return this._style}}class Hr extends xr{static create(t={}){return new Hr(t)}constructor(t={}){super(t)}setIndentFirstLine(t){return this._style.indentFirstLine=t,this}setHanging(t){return this._style.hanging=t,this}setIndentStart(t){return this._style.indentStart=t,this}setTabStops(t){return this._style.tabStops=t,this}setIndentEnd(t){return this._style.indentEnd=t,this}setTextStyle(t){return this._style.textStyle=t,this}setHeadingId(t){return this._style.headingId=t,this}setNamedStyleType(t){return this._style.namedStyleType=t,this}setHorizontalAlign(t){return this._style.horizontalAlign=t,this}setLineSpacing(t){return this._style.lineSpacing=t,this}setDirection(t){return this._style.direction=t,this}setSpacingRule(t){return this._style.spacingRule=t,this}setSnapToGrid(t){return this._style.snapToGrid=t?1:0,this}setSpaceAbove(t){return this._style.spaceAbove=t,this}setSpaceBelow(t){return this._style.spaceBelow=t,this}setBorderBetween(t){return this._style.borderBetween=t,this}setBorderTop(t){return this._style.borderTop=t,this}setBorderBottom(t){return this._style.borderBottom=t,this}setBorderLeft(t){return this._style.borderLeft=t,this}setBorderRight(t){return this._style.borderRight=t,this}setKeepLines(t){return this._style.keepLines=t?1:0,this}setKeepNext(t){return this._style.keepNext=t?1:0,this}setWordWrap(t){return this._style.wordWrap=t?1:0,this}setWidowControl(t){return this._style.widowControl=t?1:0,this}setShading(t){return this._style.shading=t,this}setSuppressHyphenation(t){return this._style.suppressHyphenation=t?1:0,this}copy(){return Hr.create(Z.deepClone(this._style))}build(){return this.getValue()}}class an{constructor(t){E(this,"_data");if(!t.body)throw new Error("Invalid document data, body is required");this._data=yh(t)}static create(t){return new an(t)}static createByBody(t){return new an({body:t,id:"d",documentStyle:{}})}copy(){return Sn.create(Z.deepClone(this._data))}slice(t,n){const{body:r,...s}=this._data;return Sn.create({...Z.deepClone(s),body:At(r,t,n)})}toPlainText(){var t,n;return Qe.transform.getPlainText((n=(t=this._data.body)==null?void 0:t.dataStream)!=null?n:"").replaceAll("\r",`
|
|
7
7
|
`)}getParagraphStyle(){var t,n;return xr.create((n=(t=this._data.body)==null?void 0:t.paragraphs)==null?void 0:n[0].paragraphStyle)}getParagraphBullet(){var t,n;return(n=(t=this._data.body)==null?void 0:t.paragraphs)==null?void 0:n[0].bullet}getParagraphs(){var r,s;const t=(s=(r=this._data.body)==null?void 0:r.paragraphs)!=null?s:[];let n=0;return t.map(i=>{const o=this.slice(n,i.startIndex);return n=i.startIndex,o})}getTextRuns(){var t,n;return((n=(t=this._data.body)==null?void 0:t.textRuns)!=null?n:[]).map(r=>({...r,ts:r.ts?Fr.create(r.ts):null}))}getLinks(){var t,n,r;return(r=(n=(t=this._data.body)==null?void 0:t.customRanges)==null?void 0:n.filter(s=>s.rangeType===en.HYPERLINK))!=null?r:[]}getData(){return this._data}}class Sn extends an{constructor(n){super(n);E(this,"_doc");this._doc=new Tt(n)}static newEmptyData(){return yh({id:"d",documentStyle:{},drawings:{},drawingsOrder:[],body:{dataStream:`\r
|
|
8
|
-
`,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(n){return new Sn(n!=null?n:Sn.newEmptyData())}insertText(n,r,s){var u,h;let i=((h=(u=this._data.body)==null?void 0:u.dataStream.length)!=null?h:2)-2,o,a;if(typeof n=="string"?o=n:(i=Math.min(n,i),o=r),typeof r=="object"?a=r instanceof sn?r.build():r:a=s instanceof sn?s.build():s,!o)return this;const l={dataStream:o,textRuns:a?[{ts:a,st:i,ed:i+o.length}]:[]},c=Qe.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:l});if(!c)throw new Error("Insert text failed, please check.");return De.apply(this._doc.getBody(),c.serialize()),this}insertRichText(n,r){var a,l;let s=((l=(a=this._data.body)==null?void 0:a.dataStream.length)!=null?l:2)-2,i;typeof n=="object"?i=n instanceof an?n.getData():n:(s=Math.min(n,s),i=r instanceof an?r.getData():r);const o=Qe.selection.replace({doc:this._doc,selection:{startOffset:s,endOffset:s,collapsed:!0},body:i.body});if(!o)throw new Error("Insert text failed, please check.");return De.apply(this._doc.getBody(),o.serialize()),this}delete(n,r){if(r!==void 0){if(!r)return this;const s=Qe.selection.delete([{startOffset:n,endOffset:n+r,collapsed:!0}],this._data.body);De.apply(this._doc.getBody(),s)}return this}setStyle(n,r,s){const i={dataStream:"",textRuns:[{ts:s instanceof sn?s.build():s,st:0,ed:r-n}]},o=Qe.selection.retain([{startOffset:n,endOffset:r,collapsed:!0}],i);return De.apply(this._doc.getBody(),o),this}setLink(n,r,s){const i=Qe.customRange.add({rangeType:en.HYPERLINK,rangeId:nt(),properties:{url:s},ranges:[{startOffset:n,endOffset:r,collapsed:!1}],body:this._data.body});if(!i)throw new Error("Insert text failed, please check.");return De.apply(this._doc.getBody(),i.serialize()),this}cancelLink(n,r){if(typeof n=="string"){const s=Qe.customRange.delete({rangeId:n,documentDataModel:this._doc});if(!s)throw new Error("Insert text failed, please check.");De.apply(this._doc.getBody(),s.serialize())}else this.slice(n,r).getLinks().forEach(i=>{const o=Qe.customRange.delete({rangeId:i.rangeId,documentDataModel:this._doc});if(!o)throw new Error("Insert text failed, please check.");De.apply(this._doc.getBody(),o.serialize())});return this}updateLink(n,r){var i,o;const s=(o=(i=this._data.body)==null?void 0:i.customRanges)==null?void 0:o.find(a=>a.rangeId===n);if(!s)throw new Error("Link not found");return s.properties.url=r,this}insertParagraph(n,r){var o,a;let s,i;return typeof n=="object"?(s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:n.build()}]},i=((a=(o=this._data.body)==null?void 0:o.dataStream.length)!=null?a:2)-2):(i=n,s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:r==null?void 0:r.build()}]}),this.insertRichText(i,an.create({body:s,id:"d",documentStyle:{}})),this}insertLink(n,r,s){let i="",o="";typeof n=="string"?(i=n,o=r):(i=r,o=s);const a=Sn.createByBody({dataStream:i,customRanges:[{rangeType:en.HYPERLINK,rangeId:nt(),properties:{url:o},startIndex:0,endIndex:i.length-1}]});return typeof n=="number"?this.insertRichText(n,a):this.insertRichText(a)}}const cR="__default_document_sub_component_id20231101__";class Ah{constructor(){E(this,"skipNextObservers",!1);E(this,"lastReturnValue");E(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class uR extends se.Subject{constructor(){super(...arguments);E(this,"_sortedObservers",[])}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(n){let r;typeof n=="function"?r={next:([i,o])=>n(i,o)}:r=n;const s=super.subscribe(r);return this._sortedObservers.push(r),this._sortedObservers.sort((i,o)=>{var a,l;return((a=i.priority)!=null?a:0)-((l=o.priority)!=null?l:0)}),s.add(()=>this._sortedObservers=this._sortedObservers.filter(i=>i!==r)),s}clearObservers(){this._sortedObservers.forEach(n=>{var r;return(r=n.complete)==null?void 0:r.call(n)}),this._sortedObservers.length=0}emitEvent(n){var r;if(!this.closed){const s=new Ah;s.lastReturnValue=n;for(const i of this._sortedObservers){const o=(r=i.next)==null?void 0:r.call(i,[n,s]);if(s.lastReturnValue=o,s.skipNextObservers)return{handled:!0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}throw new Error("[EventSubject]: cannot emit event on a closed subject.")}}function hR(e){return new se.Observable(t=>{const n=e.subscribeEvent(r=>{t.next(r)});return()=>n.unsubscribe()})}const Qs=Ce.createIdentifier("core.resource-manager.service"),na={[Se.Editor]:"Editor",[Se.Owner]:"Owner",[Se.Reader]:"Reader",[Se.UNRECOGNIZED]:"UNRECOGNIZED"},ei=e=>e?{userID:`${na[e]}_${nt(8)}`,name:na[e],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},dR=(e,t)=>e.startsWith(na[t]);class Br extends Ke{constructor(){super(...arguments);E(this,"_model",new Map);E(this,"_userChange$",new se.Subject);E(this,"userChange$",this._userChange$.asObservable());E(this,"_currentUser$",new se.BehaviorSubject(ei()));E(this,"currentUser$",this._currentUser$.asObservable())}dispose(){super.dispose(),this._model.clear(),this._userChange$.complete(),this._currentUser$.complete()}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(n){this.addUser(n),this._currentUser$.next(n)}addUser(n){this._model.set(n.userID,n),this._userChange$.next({type:"add",user:n})}getUser(n,r){const s=this._model.get(n);if(s)return s;r&&r()}delete(n){const r=this.getUser(n);this._model.delete(n),r&&this._userChange$.next({type:"delete",user:r})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}list(){return Array.from(this._model.values())}}var fR=Object.getOwnPropertyDescriptor,mR=(e,t,n,r)=>{for(var s=r>1?void 0:r?fR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Th=(e,t)=>(n,r)=>t(n,r,e);f.AuthzIoLocalService=class{constructor(t,n){E(this,"_permissionMap",new Map([]));E(this,"_permissionOverrides",new Map);this._resourceManagerService=t,this._userManagerService=n,this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){const t=this._userManagerService.getCurrentUser();t&&t.userID||this._userManagerService.setCurrentUser(ei(Se.Owner))}_getRole(t){const n=this._userManagerService.getCurrentUser();return n?dR(n.userID,t):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:t=>{const n=[...this._permissionMap.keys()].reduce((r,s)=>{const i=this._permissionMap.get(s);return r[s]=i,r},{});return JSON.stringify(n)},parseJson:t=>JSON.parse(t),pluginName:"SHEET_AuthzIoMockService_PLUGIN",businesses:[ve.UNIVER_SHEET,ve.UNIVER_DOC,ve.UNIVER_SLIDE],onLoad:(t,n)=>{for(const r in n)this._permissionMap.set(r,n[r])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(t){const n=nt(8),{objectType:r,selectRangeObject:s,worksheetObject:i}=t,o=s||i,a={objectType:r,unitID:(o==null?void 0:o.unitID)||"",name:(o==null?void 0:o.name)||"",strategies:[{action:6,role:Se.Owner},{action:16,role:Se.Owner},{action:17,role:Se.Owner},{action:18,role:Se.Owner},{action:19,role:Se.Owner},{action:33,role:Se.Owner},{action:34,role:Se.Owner},{action:35,role:Se.Owner},{action:36,role:Se.Owner},{action:37,role:Se.Owner},{action:38,role:Se.Owner},{action:39,role:Se.Owner},{action:40,role:Se.Owner}],selectRangeObject:s};return this._permissionMap.set(n,a),n}async allowed(t){const{objectID:n,actions:r}=t,s=this._permissionMap.get(n);return s?r.map(o=>{const a=`${n}:${o}`;if(this._permissionOverrides.has(a))return{action:o,allowed:this._permissionOverrides.get(a)};const l=s.strategies.find(c=>c.action===o);return l?{action:o,allowed:this._getRole(l.role)}:{action:o,allowed:this._getRole(Se.Owner)||this._getRole(Se.Editor)}}):r.map(a=>({action:a,allowed:this._getRole(Se.Owner)||this._getRole(Se.Editor)}))}async batchAllowed(t){const n=await Promise.all(t.map(s=>this.allowed(s)));return t.map((s,i)=>({unitID:s.unitID,objectID:s.objectID,actions:n[i]}))}async list(t){const n=[],r=[{action:6,role:Se.Owner},{action:16,role:Se.Owner},{action:17,role:Se.Owner},{action:18,role:Se.Owner},{action:19,role:Se.Owner},{action:33,role:Se.Owner},{action:34,role:Se.Owner},{action:35,role:Se.Owner},{action:36,role:Se.Owner},{action:37,role:Se.Owner},{action:38,role:Se.Owner},{action:39,role:Se.Owner},{action:40,role:Se.Owner}];return t.objectIDs.forEach(s=>{const i=this._permissionMap.get(s),o=(i==null?void 0:i.strategies)||r,a={objectID:s,unitID:t.unitID,objectType:(i==null?void 0:i.objectType)||3,name:(i==null?void 0:i.name)||"",shareOn:!1,shareRole:Se.Owner,shareScope:-1,scope:{read:yi.AllCollaborator,edit:yi.AllCollaborator},creator:ei(Se.Owner),strategies:o.map(l=>({action:l.action,role:l.role})),actions:t.actions.map(l=>{const c=`${s}:${l}`;if(this._permissionOverrides.has(c))return{action:l,allowed:this._permissionOverrides.get(c)};const u=o.find(h=>h.action===l);if(!u){const h=this._getRole(Se.Owner)||this._getRole(Se.Editor);return{action:l,allowed:h}}return{action:l,allowed:this._getRole(u.role)}})};n.push(a)}),n}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(t){const{objectID:n,strategies:r}=t,s=this._permissionMap.get(n);s&&r&&(s.strategies=r.map(i=>({action:i.action,role:i.role})),this._permissionMap.set(n,s),r.forEach(i=>{i.role===Se.Reader?this.setPermissionOverride(n,i.action,!1):(i.role===Se.Owner||i.role===Se.Editor)&&this.clearPermissionOverride(n,i.action)}))}setPermissionOverride(t,n,r){const s=`${t}:${n}`;this._permissionOverrides.set(s,r)}clearPermissionOverride(t,n){const r=`${t}:${n}`;this._permissionOverrides.delete(r)}clearAllOverrides(t){const n=[];this._permissionOverrides.forEach((r,s)=>{s.startsWith(`${t}:`)&&n.push(s)}),n.forEach(r=>this._permissionOverrides.delete(r))}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(t){}},f.AuthzIoLocalService=mR([Th(0,Qs),Th(1,Ce.Inject(Br))],f.AuthzIoLocalService);const Nh=Ce.createIdentifier("IAuthzIoIoService"),gR=Ce.createIdentifier("univer.confirm-service");class _R{constructor(){E(this,"confirmOptions$",new se.Subject)}dispose(){this.confirmOptions$.complete()}open(t){throw new Error("This is not implemented in the test service!")}confirm(t){return Promise.resolve(!0)}close(t){throw new Error("This is not implemented in the test service!")}}const $r="FOCUSING_UNIT",qn="FOCUSING_SHEET",jr="FOCUSING_DOC",Wr="FOCUSING_SLIDE",pR="FOCUSING_EDITOR_BUT_HIDDEN",Mh="EDITOR_ACTIVATED",ER="FOCUSING_EDITOR_INPUT_FORMULA",Dh="FOCUSING_FX_BAR_EDITOR",CR="FOCUSING_UNIVER_EDITOR",RR="FOCUSING_EDITOR_INPUT_FORMULA",IR="FOCUSING_COMMENT_EDITOR",SR="FOCUSING_PANEL_EDITOR",OR="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",wR="FOCUSING_COMMON_DRAWINGS",vR="FORMULA_EDITOR_ACTIVATED";class Lh extends Ke{constructor(){super(...arguments);E(this,"_error$",new se.Subject);E(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(n){this._error$.next({errorKey:n})}}var ti=(e=>(e.URL="URL",e.UUID="UUID",e.BASE64="BASE64",e))(ti||{}),Uh=(e=>(e.SUCCUSS="0",e.ERROR_EXCEED_SIZE="1",e.ERROR_IMAGE_TYPE="2",e.ERROR_UPLOAD_COUNT_LIMIT="3",e.ERROR_IMAGE="4",e))(Uh||{});const ra=Ce.createIdentifier("core.image-io.service"),sa=Ce.createIdentifier("core.url-image.service"),bR={version:"0.15.1"};function yR(e="",t=cr.ZH_CN,n=""){return{id:e,sheetOrder:[],name:n,appVersion:bR.version,locale:t,styles:{},sheets:{},resources:[]}}class Ph{constructor(t={}){E(this,"_styles");E(this,"_cacheMap",new Tr(1e5));this._styles=t,this._generateCacheMap()}each(t){return Object.entries(this._styles).forEach(t),this}search(t,n){if(this._cacheMap.has(n))return this._cacheMap.get(n);const r=this._getExistingStyleId(t);return r||"-1"}get(t){return typeof t!="string"?t:(t=String(t),this._styles[t])}add(t,n){const r=nt(6);return this._styles[r]=t,this._cacheMap.set(n,r),r}setValue(t){if(t==null)return;const n=JSON.stringify(t),r=this.search(t,n);return r!=="-1"?r:this.add(t,n)}addCustomStyle(t,n){n!=null&&(this._styles[t]=n,this._cacheMap.set(JSON.stringify(n),t))}remove(t){const n=this._styles[t];n&&(delete this._styles[t],this._cacheMap.delete(JSON.stringify(n)))}toJSON(){return this._styles}getStyleByCell(t){let n;t&&Z.isObject(t.s)?n=t.s:n=(t==null?void 0:t.s)&&this.get(t.s);const r=t==null?void 0:t.interceptorStyle;return r?{...n,...r}:n}_generateCacheMap(){const{_styles:t,_cacheMap:n}=this;for(const r in t){const s=JSON.stringify(t[r]);n.set(s,r)}}_getExistingStyleId(t){const{_styles:n}=this;for(const r in n)if(Z.diffValue(n[r],t))return r;return null}}const AR=(e,t)=>t.length===e.length&&!e.some(n=>t.some(r=>!Yt.equals(r,n))),TR=(e,t)=>t.length===e.length&&e.every((n,r)=>{const s=t[r];return s.unitId===n.unitId&&s.sheetId===n.sheetId&&Yt.equals(n.range,s.range)}),ia={t:0,b:2,l:2,r:2},NR=e=>({sbr:.6,sbo:e,spr:.6,spo:e}),kh=90;function Yr(e,t,n={}){const r=e.length,{textRotation:s,paddingData:i,horizontalAlign:o=bt.UNSPECIFIED,verticalAlign:a=mn.UNSPECIFIED,wrapStrategy:l=gn.UNSPECIFIED,cellValueType:c}=n,{t:u,r:h,b:d,l:m}=i||ia,{vertexAngle:_,centerAngle:p}=$h(s),I={id:"d",body:{dataStream:`${e}${wa}`,textRuns:[{ts:t,st:0,ed:r}],paragraphs:[{startIndex:r,paragraphStyle:{horizontalAlign:o}}],sectionBreaks:[{startIndex:r+1}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},marginTop:u,marginBottom:d,marginRight:h,marginLeft:m,renderConfig:{horizontalAlign:o,verticalAlign:a,centerAngle:p,vertexAngle:_,wrapStrategy:l,cellValueType:c}},drawings:{},drawingsOrder:[]};return new Tt(I)}function MR(e){if(!e)return{};const{tr:t,td:n,ht:r,vt:s,tb:i,pd:o}=e;return{textRotation:t,textDirection:n,horizontalAlign:r,verticalAlign:s,wrapStrategy:i,paddingData:o}}function Fh(e){if(!e)return{};const{ff:t,fs:n,it:r,bl:s,ul:i,st:o,ol:a,cl:l,bg:c}=e,u={};return t&&(u.ff=t),n&&(u.fs=n),r&&(u.it=r),s&&(u.bl=s),i&&(u.ul=i),o&&(u.st=o),a&&(u.ol=a),l&&(u.cl=l),c&&(u.bg=c),u}function xh(e,t,n){var i;const r=e.getBody();if((i=r.customRanges)!=null&&i.some(o=>o.rangeType===en.HYPERLINK))return;const s=Qe.customRange.add({ranges:[{startOffset:0,endOffset:r.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:en.HYPERLINK,body:r,properties:{url:t,refId:n}});s&&De.apply(r,s.serialize())}function Hh(e){return e!=null}function DR(){return{p:null,s:null,v:null,t:null,f:null,si:null,ref:null,xf:null}}const LR='"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif';function Bh(e){const t=it.ff,n=it.fs;if(!e){const h=`${n}pt ${t}`;return{fontCache:h,fontString:h,fontSize:n,originFontSize:n,fontFamily:t}}let r=Ln.ITALIC;(e.it===0||e.it===void 0)&&(r=Ln.NORMAL);let s=Ln.BOLD;(e.bl===0||e.bl===void 0)&&(s=Ln.NORMAL);let i=n;e.fs&&(i=Math.ceil(e.fs));let o=t;if(e.ff){let h=e.ff;h=h.replace(/"/g,"").replace(/'/g,""),h.indexOf(" ")>-1&&(h=`"${h}"`),h==null&&(h=t),o=h}const{va:a}=e;let l=i;if(a===jt.SUBSCRIPT||a===jt.SUPERSCRIPT){const h=UR(o,l),{sbr:d,spr:m}=h;l*=a===jt.SUBSCRIPT?d:m}const c=`${r} ${s} ${l}pt ${o}`,u=`${c}, ${LR} `;return{fontCache:c,fontString:u,fontSize:l,originFontSize:i,fontFamily:o}}function UR(e,t){return NR(t)}function $h(e){const{a:t=0,v:n=ae.FALSE}=e||{a:0,v:ae.FALSE};let r=0,s=t;return n===ae.TRUE&&(r=kh,s=kh),{centerAngle:r,vertexAngle:s}}function gt(e){if(e==null||typeof e!=="object")return e;if(Array.isArray(e)){const s=e.length,i=new Array(s);for(let o=0;o<s;o++)i[o]=gt(e[o]);return i}const n={},r=Object.keys(e);for(let s=0,i=r.length;s<i;s++){const o=r[s];n[o]=gt(e[o])}return n}function jh(e){if(e==null)return e;const t={};return e.p!==void 0&&(t.p=e.p===null?null:gt(e.p)),e.s!==void 0&&(e.s===null||typeof e.s=="string"?t.s=e.s:t.s=gt(e.s)),e.v!==void 0&&(t.v=e.v),e.t!==void 0&&(t.t=e.t),e.f!==void 0&&(t.f=e.f),e.ref!==void 0&&(t.ref=e.ref),e.xf!==void 0&&(t.xf=e.xf),e.si!==void 0&&(t.si=e.si),e.custom!==void 0&&(t.custom=e.custom===null?null:gt(e.custom)),t}function PR(e){if(e==null)return e;const t={};return e.p!==void 0&&(t.p=e.p===null?null:gt(e.p)),e.s!==void 0&&(e.s===null||typeof e.s=="string"?t.s=e.s:t.s=gt(e.s)),e.v!==void 0&&(t.v=e.v),e.t!==void 0&&(t.t=e.t),e.f!==void 0&&(t.f=e.f),e.ref!==void 0&&(t.ref=e.ref),e.xf!==void 0&&(t.xf=e.xf),e.si!==void 0&&(t.si=e.si),e.custom!==void 0&&(t.custom=e.custom===null?null:gt(e.custom)),e.rowSpan!==void 0&&(t.rowSpan=e.rowSpan),e.colSpan!==void 0&&(t.colSpan=e.colSpan),e.displayV!==void 0&&(t.displayV=e.displayV),t}function Wh(e){const t={},n=Object.keys(e);for(let r=0,s=n.length;r<s;r++){const i=n[r],o=Number(i),a=e[o];if(a===void 0)continue;const l={},c=Object.keys(a);for(let u=0,h=c.length;u<h;u++){const d=c[u],m=Number(d),_=a[m];_!=null&&(l[m]=jh(_))}t[o]=l}return t}function Yh(e){const t={},n=Object.keys(e);for(let r=0,s=n.length;r<s;r++){const i=n[r],o=Number(i),a=e[o];if(a===void 0)continue;const l={};"h"in a&&a.h!==void 0&&(l.h=a.h),"ia"in a&&a.ia!==void 0&&(l.ia=a.ia),"ah"in a&&a.ah!==void 0&&(l.ah=a.ah),"hd"in a&&a.hd!==void 0&&(l.hd=a.hd),"w"in a&&a.w!==void 0&&(l.w=a.w),"s"in a&&a.s!==void 0&&(a.s===null||typeof a.s=="string"?l.s=a.s:l.s=gt(a.s)),"custom"in a&&a.custom!==void 0&&(l.custom=a.custom===null?null:gt(a.custom)),t[o]=l}return t}function kR(e){const t=e.length,n=new Array(t);for(let r=0;r<t;r++){const s=e[r];n[r]={startRow:s.startRow,startColumn:s.startColumn,endRow:s.endRow,endColumn:s.endColumn,rangeType:s.rangeType,startAbsoluteRefType:s.startAbsoluteRefType,endAbsoluteRefType:s.endAbsoluteRefType}}return n}function Vh(e){const t={id:e.id,name:e.name,tabColor:e.tabColor,hidden:e.hidden,rowCount:e.rowCount,columnCount:e.columnCount,zoomRatio:e.zoomRatio,scrollTop:e.scrollTop,scrollLeft:e.scrollLeft,defaultColumnWidth:e.defaultColumnWidth,defaultRowHeight:e.defaultRowHeight,showGridlines:e.showGridlines,rightToLeft:e.rightToLeft,freeze:{xSplit:e.freeze.xSplit,ySplit:e.freeze.ySplit,startRow:e.freeze.startRow,startColumn:e.freeze.startColumn},rowHeader:{width:e.rowHeader.width,hidden:e.rowHeader.hidden},columnHeader:{height:e.columnHeader.height,hidden:e.columnHeader.hidden},mergeData:kR(e.mergeData),cellData:Wh(e.cellData),rowData:Yh(e.rowData),columnData:Yh(e.columnData)};return e.gridlinesColor!==void 0&&(t.gridlinesColor=e.gridlinesColor),e.defaultStyle!==void 0&&(e.defaultStyle===null||typeof e.defaultStyle=="string"?t.defaultStyle=e.defaultStyle:t.defaultStyle=gt(e.defaultStyle)),e.custom!==void 0&&(t.custom=e.custom===null?null:gt(e.custom)),t}class FR{constructor(t,n){E(this,"_columnData",{});this._config=t,this._columnData=n}getColumnData(){return this._columnData}getColVisible(t){const{_columnData:n}=this,r=n[t];return r?r.hd!==ae.TRUE:!0}getColumnStyle(t){var n;return(n=this._columnData[t])==null?void 0:n.s}setColumnStyle(t,n){const r=this.getColumnOrCreate(t);r.s=n}getHiddenCols(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getColVisible(o);s&&a?(s=!1,r.push({rangeType:pe.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:pe.COLUMN}),r}getVisibleCols(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getColVisible(o);s&&!a?(s=!1,r.push({rangeType:pe.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:pe.COLUMN}),r}getColumnDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getColumn(i);r[s]=o!=null?o:{w:this._config.defaultColumnWidth,hd:ae.FALSE},s++}return r}getSize(){return rn(this._columnData)}getColumnWidth(t){var n,r;return(r=(n=this._columnData[t])==null?void 0:n.w)!=null?r:this._config.defaultColumnWidth}setColumnWidth(t,n){const r=this._columnData[t];n===this._config.defaultColumnWidth?r&&(delete r.w,Object.keys(r).length===0&&delete this._columnData[t]):this._columnData[t]=r?{...r,w:n}:{w:n}}getColumn(t){return this._columnData[t]}removeColumn(t){delete this._columnData[t]}getColumnOrCreate(t){const{_columnData:n}=this,r=n[t];if(r)return r;const s={};return this._columnData[t]=s,s}setCustomMetadata(t,n){const r=this.getColumn(t);r&&(r.custom=n)}getCustomMetadata(t){var n;return(n=this.getColumn(t))==null?void 0:n.custom}}const xR=2e3;class HR{constructor(t,n,r){E(this,"_rowData");this._config=t,this._viewModel=n,this._rowData=r}getRowData(){return this._rowData}getRowStyle(t){var n;return(n=this._rowData[t])==null?void 0:n.s}setRowStyle(t,n){const r=this.getRowOrCreate(t);r.s=n}getRowDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getRow(i);r[s]=o!=null?o:{h:this._config.defaultRowHeight,hd:ae.FALSE},s++}return r}getRowHeight(t,n=1){const{_rowData:r}=this,s=this._config;let i=0;for(let o=0;o<n;o++){const a=r[o+t]||{hd:ae.FALSE,h:s.defaultRowHeight},{ia:l,ah:c,h:u=s.defaultRowHeight}=a;i+=(l==null||l===ae.TRUE)&&typeof c=="number"?c:u}return i}setRowHeight(t,n){const r=this._rowData[t];if(n===this._config.defaultRowHeight)r&&(delete r.h,Object.keys(r).length===0&&delete this._rowData[t]);else{const s=Math.min(n,xR);this._rowData[t]=r?{...r,h:s}:{h:s}}}getRow(t){return this._rowData[t]}removeRow(t){delete this._rowData[t]}getRowOrCreate(t){const{_rowData:n}=this,r=n[t];if(r)return r;const s={};return n[t]=s,s}getHiddenRows(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getRowRawVisible(o);s&&a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:pe.ROW})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:pe.ROW}),r}getVisibleRows(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getRowRawVisible(o);s&&!a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:pe.ROW})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:pe.ROW}),r}getRowRawVisible(t){const n=this.getRow(t);return n?n.hd!==ae.TRUE:!0}getSize(){return rn(this._rowData)}setCustomMetadata(t,n){const r=this.getRow(t);r&&(r.custom=n)}getCustomMetadata(t){var n;return(n=this.getRow(t))==null?void 0:n.custom}}const BR="DEFAULT_WORKSHEET_ROW_COUNT",zh=1e3,$R="DEFAULT_WORKSHEET_COLUMN_COUNT",Gh=20,jR="DEFAULT_WORKSHEET_ROW_HEIGHT",Kh=24,WR="DEFAULT_WORKSHEET_COLUMN_WIDTH",Xh=88,YR="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",qh=46,VR="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Jh=20;function Zh(e){const t={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:ae.FALSE,rowCount:zh,columnCount:Gh,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:Xh,defaultRowHeight:Kh,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:ae.TRUE,rowHeader:{width:qh,hidden:ae.FALSE},columnHeader:{height:Jh,hidden:ae.FALSE},rightToLeft:ae.FALSE};return Object.keys(t).forEach(n=>{const r=n;typeof e[r]>"u"&&(e[r]=t[r])}),e}class zR extends Ke{constructor(n){super();E(this,"_cellCache",new Map);E(this,"_rowCache",new Map);E(this,"_columnCache",new Map);E(this,"_hasRow",!1);E(this,"_hasColumn",!1);E(this,"_hasAll",!1);E(this,"_allIndex",-1);E(this,"_mergeData");E(this,"_rangeMap",new Tr(5e4));E(this,"_skeletonCache",new Tr(5e4));this._init(n.concat())}_init(n){this._mergeData=n,this._createCache(n)}_clearCache(){this._cellCache.clear(),this._rowCache.clear(),this._columnCache.clear(),this._hasAll=!1,this._allIndex=-1,this._rangeMap.clear(),this._skeletonCache.clear(),this._hasColumn=!1,this._hasRow=!1}_createCache(n){let r=0;for(const s of n){const{rangeType:i}=s;i===pe.ROW?this._createRowCache(s,r):i===pe.COLUMN?this._createColumnCache(s,r):i===pe.ALL?this._createCellAllCache(r):this._createCellCache(s,r),r++}}rebuild(n){this._clearCache(),this._init(n.concat())}_createRowCache(n,r){const{startRow:s,endRow:i}=n;for(let o=s;o<=i;o++)this._rowCache.set(o,r),this._hasRow=!0}_createColumnCache(n,r){const{startColumn:s,endColumn:i}=n;for(let o=s;o<=i;o++)this._columnCache.set(o,r),this._hasColumn=!0}_createCellAllCache(n){this._hasAll=!0,this._allIndex=n}_createCellCache(n,r){for(let s=n.startRow;s<=n.endRow;s++){let i=this._cellCache.get(s);i==null&&(i=new Map,this._cellCache.set(s,i));for(let o=n.startColumn;o<=n.endColumn;o++)i.set(o,r)}}add(n){this._mergeData.push(n),this._clearCache(),this._createCache(this._mergeData)}remove(n,r){const s=this._getMergeDataIndex(n,r);s!==-1&&(this._mergeData.splice(s,1),this._clearCache(),this._createCache(this._mergeData))}getMergedCell(n,r){const s=this._getMergeDataIndex(n,r);return s!==-1?this._mergeData[s]:null}getMergeDataIndex(n,r){return this._getMergeDataIndex(n,r)}isRowContainsMergedCell(n){return this._hasAll||!Z.isEmptyObject(this._columnCache)?!0:this._mergeData.some(r=>r.startRow<=n&&n<=r.endRow)}isColumnContainsMergedCell(n){return this._hasAll||!Z.isEmptyObject(this._rowCache)?!0:this._mergeData.some(r=>r.startColumn<=n&&n<=r.endColumn)}getMergedCellRange(n,r,s,i){const o=[],a=`${n}-${r}-${s}-${i}`;if(this._rangeMap.has(a))return this._getRangeFromCache(a);let l=0;const c=[];for(const u of this._mergeData||[])Yt.intersects(u,{startRow:n,endRow:s,startColumn:r,endColumn:i})&&(o.push({...u}),c.push(l)),l++;return this._rangeMap.set(a,c),o}getMergedCellRangeForSkeleton(n,r,s,i){const o=[],a=this._mergeData,l=`${n}-${r}-${s}-${i}`;if(this._skeletonCache.has(l))return this._getSkeletonRangeFromCache(l);const c=[];for(let u=0;u<a.length;u++){const{startRow:h,endRow:d,startColumn:m,endColumn:_}=a[u];for(let p=n;p<=s;p++){let I=!1;for(let y=r;y<=i;y++)if(p>=h&&p<=d&&y>=m&&y<=_){o.push({startRow:h,endRow:d,startColumn:m,endColumn:_}),c.push(u),I=!0;break}if(I)break}}return this._skeletonCache.set(l,c),o}_getRangeFromCache(n){const r=this._rangeMap.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getSkeletonRangeFromCache(n){const r=this._skeletonCache.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getMergeDataIndex(n,r){var i;if(this._hasAll)return this._allIndex;if(this._hasRow){const o=this._rowCache.get(n);if(o!==void 0)return o}if(this._hasColumn){const o=this._columnCache.get(r);if(o!==void 0)return o}const s=(i=this._cellCache.get(n))==null?void 0:i.get(r);return s!==void 0?s:-1}getMergeDataSnapshot(){return this._mergeData}dispose(){this._clearCache(),this._mergeData=[]}}class Qh extends Ke{constructor(n){super();E(this,"_cellContentInterceptor",null);E(this,"_rowFilteredInterceptor",null);this.getRawCell=n}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(n,r,s,i){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,An.Value|An.Style,s,i):this.getRawCell(n,r)}getCellValueOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,An.Value):this.getRawCell(n,r)}getCellStyleOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,An.Style):this.getRawCell(n,r)}getRowFiltered(n){var r,s;return(s=(r=this._rowFilteredInterceptor)==null?void 0:r.getRowFiltered(n))!=null?s:!1}registerCellContentInterceptor(n){if(this._cellContentInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptor=n,Ye(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(n){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=n,Ye(()=>this._rowFilteredInterceptor=null)}}const ed={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};class Vr{constructor(t,n,r){E(this,"_sheetId");E(this,"_snapshot");E(this,"_cellData");E(this,"_rowManager");E(this,"_columnManager");E(this,"_viewModel");E(this,"_spanModel");E(this,"_isRowStylePrecedeColumnStyle",!0);E(this,"_getCellHeight");var a;this.unitId=t,this._styles=r,this._snapshot=Zh(n);const{columnData:s,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:nt(6),this._cellData=new ct(o),this._viewModel=new Qh((l,c)=>this.getCellRaw(l,c)),this._rowManager=new HR(this._snapshot,this._viewModel,i),this._columnManager=new FR(this._snapshot,s),this._spanModel=new zR(this._snapshot.mergeData)}__interceptViewModel(t){t(this._viewModel)}__registerGetCellHeight(t){return this._getCellHeight=t,Ye(()=>{this._getCellHeight=null})}getSnapshot(){return this._snapshot}getCellHeight(t,n){return this._getCellHeight?this._getCellHeight(t,n):this._snapshot.defaultRowHeight}setMergeData(t){this._snapshot.mergeData=t,this.getSpanModel().rebuild(t)}getSpanModel(){return this._spanModel}setIsRowStylePrecedeColumnStyle(t){this._isRowStylePrecedeColumnStyle=t}getStyleDataByHash(t){return{...this._styles.get(t)}}setStyleData(t){return this._styles.setValue(t)}getColumnStyle(t,n=!1){return n?this._columnManager.getColumnStyle(t):this._styles.get(this._columnManager.getColumnStyle(t))}setColumnStyle(t,n){this._columnManager.setColumnStyle(t,n)}getRowStyle(t,n=!1){return n?this._rowManager.getRowStyle(t):this._styles.get(this._rowManager.getRowStyle(t))}setRowStyle(t,n){this._rowManager.setRowStyle(t,n)}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){const t=this._snapshot.defaultStyle;return this._styles.get(t)}setDefaultCellStyle(t){this._snapshot.defaultStyle=t}getCellStyle(t,n){const r=this.getCell(t,n);if(r){const s=r.s;return typeof s=="string"?this._styles.get(s):s}return null}getComposedCellStyle(t,n,r){const s=this.getDefaultCellStyleInternal(),i=this.getRowStyle(t),o=this.getColumnStyle(n),a=this.getCell(t,n),l=this._styles.getStyleByCell(a);return(r!=null?r:this._isRowStylePrecedeColumnStyle)?lr(s,o,i,a==null?void 0:a.themeStyle,l):lr(s,i,o,a==null?void 0:a.themeStyle,l)}getComposedCellStyleByCellData(t,n,r,s){const i=this.getDefaultCellStyleInternal(),o=this.getRowStyle(t),a=this.getColumnStyle(n),l=this._styles.getStyleByCell(r);return(s!=null?s:this._isRowStylePrecedeColumnStyle)?lr(i,a,o,r==null?void 0:r.themeStyle,l):lr(i,o,a,r==null?void 0:r.themeStyle,l)}getComposedCellStyleWithoutSelf(t,n,r,s){const i=r===void 0?this.getComposedCellStyle(t,n,s):this.getComposedCellStyleByCellData(t,n,r,s),o=this.getCellRaw(t,n);if(!o||!o.s)return i;const a=typeof o.s=="string"?this._styles.get(o.s):o.s;if(!a)return i;for(const l in a)l in i&&delete i[l];return i}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const t=this.getCellMatrix(),n=this.getMergeData();let r=-1,s=-1,i=-1,o=-1,a=!1,l=!1;return t.forEach((c,u)=>{Object.keys(u).forEach(h=>{const d=+h,m=t.getValue(c,d),_=m!=null&&m.s?this._styles.get(m.s):null,p=(_==null?void 0:_.bd)&&(_.bd.b||_.bd.l||_.bd.r||_.bd.t||_.bd.bc_tr||_.bd.bl_tr||_.bd.ml_tr||_.bd.tl_bc||_.bd.tl_br||_.bd.tl_mr);(m&&(m.v!==null&&m.v!==void 0&&m.v!==""||m.p)||_!=null&&_.bg||p)&&(a?r=Math.min(r,c):(r=c,a=!0),s=Math.max(s,c),l?i=Math.min(i,d):(l=!0,i=d),o=Math.max(o,d))})}),n.forEach(c=>{a?r=Math.min(r,c.startRow):(r=c.startRow,a=!0),s=Math.max(s,c.endRow),l?i=Math.min(i,c.startColumn):(i=c.startColumn,a=!0),o=Math.max(o,c.endColumn)}),!a||!l?null:{startColumn:i,startRow:r,endColumn:o,endRow:s}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:t}=this,n=Vh(t);return new Vr(this.unitId,n,this._styles)}getMergeData(){return this._spanModel.getMergeDataSnapshot()}getMergedCell(t,n){return this._spanModel.getMergedCell(t,n)}getMergedCellRange(t,n,r,s){return this._spanModel.getMergedCellRange(t,n,r,s)}isRowContainsMergedCell(t){return this._spanModel.isRowContainsMergedCell(t)}isColumnContainsMergedCell(t){return this._spanModel.isColumnContainsMergedCell(t)}getCellInfoInMergeData(t,n){const r=this.getMergedCell(t,n);let s=!1,i=!1,o=t,a=n,l=t,c=n;if(r){const{startRow:u,endRow:h,startColumn:d,endColumn:m}=r;t===u&&n===d?(o=h,a=m,l=u,c=d,i=!0):t>=u&&t<=h&&n>=d&&n<=m&&(o=h,a=m,l=u,c=d,s=!0)}return{actualRow:t,actualColumn:n,isMergedMainCell:i,isMerged:s,endRow:o,endColumn:a,startRow:l,startColumn:c}}getCell(t,n){return t<0||n<0?null:this._viewModel.getCell(t,n)}getCellValueOnly(t,n){return t<0||n<0?null:this._viewModel.getCellValueOnly(t,n)}getCellStyleOnly(t,n){return t<0||n<0?null:this._viewModel.getCellStyleOnly(t,n)}getCellRaw(t,n){return this.getCellMatrix().getValue(t,n)}getCellWithFilteredInterceptors(t,n,r,s){return this._viewModel.getCell(t,n,r,s)}getRowFiltered(t){return this._viewModel.getRowFiltered(t)}getRangeFilterRows(t){const n=[];for(let r=t.startRow;r<=t.endRow;r++)this.getRowFiltered(r)&&n.push(r);return n}getMatrixWithMergedCells(t,n,r,s,i=Pn.Raw){const o=this.getCellMatrix(),a=this._spanModel.getMergedCellRange(t,n,r,s),l=new ct;return Yo(t,r,n,s).forEach((c,u)=>{var d;let h;if(i===Pn.Raw)h=this.getCellRaw(c,u);else if(i===Pn.Intercepted)h=this.getCell(c,u);else if(i===Pn.Both){const m=this.getCellRaw(c,u);if(m){h={...m};const _=(d=this.getCell(c,u))==null?void 0:d.v;Hh(_)&&h&&(h.displayV=String(_))}}h&&l.setValue(c,u,h)}),a.forEach(c=>{const{startColumn:u,startRow:h,endColumn:d,endRow:m}=c;Yo(h,m,u,d).forEach((_,p)=>{_===h&&p===u&&l.setValue(_,p,{...o.getValue(_,p),rowSpan:m-h+1,colSpan:d-u+1}),(_!==h||p!==u)&&l.realDeleteValue(_,p)})}),l}getRange(t,n,r,s){return typeof t=="object"?new Yn(this,t,{getStyles:()=>this._styles}):new Yn(this,{startRow:t,startColumn:n,endColumn:s||n,endRow:r||t},{getStyles:()=>this._styles})}getScrollLeftTopFromSnapshot(){return{scrollLeft:this._snapshot.scrollLeft,scrollTop:this._snapshot.scrollTop}}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){const{_snapshot:t}=this,{columnCount:n}=t;return n}getMaxRows(){const{_snapshot:t}=this,{rowCount:n}=t;return n}getRowCount(){return this._snapshot.rowCount}setRowCount(t){this._snapshot.rowCount=t}getColumnCount(){return this._snapshot.columnCount}setColumnCount(t){this._snapshot.columnCount=t}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:t}=this,{showGridlines:n}=t;return n===0}getGridlinesColor(){return this.getConfig().gridlinesColor}getTabColor(){const{_snapshot:t}=this,{tabColor:n}=t;return n}getColumnWidth(t){return this.getColumnManager().getColumnWidth(t)}getRowHeight(t){return this._viewModel.getRowFiltered(t)?0:this.getRowManager().getRowHeight(t)}isRowFiltered(t){return this._viewModel.getRowFiltered(t)}getRowVisible(t){return!this.isRowFiltered(t)&&this.getRowRawVisible(t)}getRowRawVisible(t){return this.getRowManager().getRowRawVisible(t)}getHiddenRows(t,n){const r=this.getMaxColumns()-1,s=this._rowManager.getHiddenRows(t,n);return s.forEach(i=>i.endColumn=r),s}getColVisible(t){return this._columnManager.getColVisible(t)}getHiddenCols(t,n){const r=this.getMaxRows()-1,s=this._columnManager.getHiddenCols(t,n);return s.forEach(i=>i.endRow=r),s}getVisibleRows(){const t=this.getRowCount();return this._rowManager.getVisibleRows(0,t-1)}getVisibleCols(){const t=this.getColumnCount();return this._columnManager.getVisibleCols(0,t-1)}isRightToLeft(){const{_snapshot:t}=this,{rightToLeft:n}=t;return n}getLastRowWithContent(){return this._cellData.getRealRowRange().endRow}getLastColumnWithContent(){return this.getDataRealRange().endColumn}getDataRealRange(){return this._cellData.getRealRange()}getDataRangeScope(){return this._cellData.getStartEndScope()}cellHasValue(t){return t&&(t.v!==void 0||t.f!==void 0||t.p!==void 0)}iterateByRow(t,n=!0){const{startRow:r,startColumn:s,endRow:i,endColumn:o}=t,a=this;return{[Symbol.iterator]:()=>{let l=r,c=s;return{next(){for(;;){if(c>o&&(l+=1,c=s),l>i)return{done:!0,value:void 0};const u=a.getCell(l,c),h=!u,d=a.getMergedCell(l,c);if(d){if(l!==d.startRow||c!==d.startColumn){c=d.endColumn+1;continue}if(h&&n){c=d.endColumn+1;continue}const _={row:l,col:c,value:u};return _.colSpan=d.endColumn-d.startColumn+1,_.rowSpan=d.endRow-d.startRow+1,c=d.endColumn+1,{done:!1,value:_}}if(h&&n)c+=1;else{const m={row:l,col:c,value:u};return c+=1,{done:!1,value:m}}}}}}}}iterateByColumn(t,n=!0,r=!0){const{startRow:s,startColumn:i,endRow:o,endColumn:a}=t,l=this;return{[Symbol.iterator]:()=>{let c=s,u=i;return{next(){for(;;){if(c>o&&(u+=1,c=s),u>a)return{done:!0,value:void 0};const h=l.getMergedCell(c,u);if(h){const _=c!==h.startRow,p=_||u!==h.startColumn;if(r&&p||!r&&_){c=h.endRow+1;continue}const I=l.getCell(h.startRow,h.startColumn);if(!I&&n){c=h.endRow+1;continue}const H={row:c,col:h.startColumn,value:I};return H.colSpan=h.endColumn-h.startColumn+1,H.rowSpan=h.endRow-h.startRow+1,c=h.endRow+1,{done:!1,value:H}}const d=l.getCell(c,u);if(!d&&n)c+=1;else{const _={row:c,col:u,value:d};return c+=1,{done:!1,value:_}}}}}}}}getCellDocumentModel(t,n,r=ed){var p;if(!t)return;const{isDeepClone:s,displayRawFormula:i,ignoreTextRotation:o}={...ed,...r};let a,l="document";const c=MR(n),u=o?it.tr:c.textRotation||it.tr;let h=c.horizontalAlign||it.ht;const d=c.verticalAlign||it.vt,m=c.wrapStrategy||it.tb,_=c.paddingData||ia;if(t.f&&i)a=Yr(t.f.toString(),{},{verticalAlign:d}),h=it.ht;else if(t.p){const{centerAngle:I,vertexAngle:y}=$h(u);a=this._updateConfigAndGetDocumentModel(s?Z.deepClone(t.p):t.p,h,_,{horizontalAlign:h,verticalAlign:d,centerAngle:I,vertexAngle:y,wrapStrategy:m,zeroWidthParagraphBreak:1})}else if(t.v!=null){const I=Fh(n);l=Bh(I).fontCache;let y=td(t);t.t===Qt.FORCE_STRING&&i&&(y=`'${y}`),a=Yr(y,I,{...c,textRotation:u,cellValueType:t.t})}return a&&t.linkUrl&&t.linkId&&xh(a,t.linkUrl,t.linkId),{documentModel:a,fontString:l,textRotation:u,wrapStrategy:m,verticalAlign:d,horizontalAlign:h,paddingData:_,fill:(p=n==null?void 0:n.bg)==null?void 0:p.rgb}}_updateConfigAndGetDocumentModel(t,n,r,s){var o,a,l,c,u;if(!s||!((o=t.body)!=null&&o.dataStream))return;t.documentStyle||(t.documentStyle={}),t.documentStyle.marginTop=(a=r.t)!=null?a:0,t.documentStyle.marginBottom=(l=r.b)!=null?l:2,t.documentStyle.marginLeft=(c=r.l)!=null?c:2,t.documentStyle.marginRight=(u=r.r)!=null?u:2,t.documentStyle.pageSize={width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},t.documentStyle.renderConfig={...t.documentStyle.renderConfig,...s};const i=t.body.paragraphs||[];for(const h of i)h.paragraphStyle||(h.paragraphStyle={}),h.paragraphStyle.horizontalAlign=n;return new Tt(t)}getBlankCellDocumentModel(t,n,r){const s=this.getComposedCellStyleByCellData(n,r,t),i=Fh(s),o=this.getCellDocumentModel(t,s,{ignoreTextRotation:!0});if(o!=null)return o.documentModel==null&&(o.documentModel=Yr("",i)),o;const a="";let l="document";const c=it.tr,u=it.ht,h=it.vt,d=it.tb,m=ia;return l=Bh({}).fontCache,{documentModel:Yr(a,i),fontString:l,textRotation:c,wrapStrategy:d,verticalAlign:h,horizontalAlign:u,paddingData:m}}getCellDocumentModelWithFormula(t,n,r){const s=this.getComposedCellStyleByCellData(n,r,t);return this.getCellDocumentModel(t,s,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(t){this._snapshot.custom=t}}function td(e){var r,s;if(!e)return"";const t=(s=(r=e.p)==null?void 0:r.body)==null?void 0:s.dataStream;if(t)return Qe.transform.getPlainText(t);const n=e.v;return typeof n=="string"?e.t===Qt.BOOLEAN?n.toUpperCase():n.replace(/[\r\n]/g,""):typeof n=="number"?e.t===Qt.BOOLEAN?n?"TRUE":"FALSE":n.toString():typeof n=="boolean"?n?"TRUE":"FALSE":""}function GR(e){if(e===null)return"";if(e!=null&&e.p){const t=e==null?void 0:e.p.body;if(t==null)return"";const n=t.dataStream;return Qe.transform.getPlainText(n)}return e==null?void 0:e.v}var KR=Object.getOwnPropertyDescriptor,XR=(e,t,n,r)=>{for(var s=r>1?void 0:r?KR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},qR=(e,t)=>(n,r)=>t(n,r,e);function JR(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}f.Workbook=class extends as{constructor(n={},r){super();E(this,"type",ve.UNIVER_SHEET);E(this,"_sheetCreated$",new se.Subject);E(this,"sheetCreated$",this._sheetCreated$.asObservable());E(this,"_sheetDisposed$",new se.Subject);E(this,"sheetDisposed$",this._sheetDisposed$.asObservable());E(this,"_activeSheet$",new se.BehaviorSubject(null));E(this,"activeSheet$",this._activeSheet$.asObservable());E(this,"_worksheets");E(this,"_styles");E(this,"_snapshot");E(this,"_unitId");E(this,"_count");E(this,"_name$");E(this,"name$");this._logService=r;const s=yR();Z.isEmptyObject(n)?this._snapshot=s:this._snapshot=Z.commonExtend(s,n);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=nt(6)),this._unitId=this._snapshot.id,this._styles=new Ph(i),this._count=1,this._worksheets=new Map,this._name$=new se.BehaviorSubject(n.name||""),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}static isIRangeType(n){return typeof n=="string"||"startRow"in n||"row"in n}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete(),Array.from(this._worksheets.keys()).forEach(r=>{this._removeSheet(r)})}save(){return Z.deepClone(this._snapshot)}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(n){this._name$.next(n),this._snapshot.name=n}getUnitId(){return this._unitId}getRev(){var n;return(n=this._snapshot.rev)!=null?n:1}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(n){this._snapshot.rev=n}addWorksheet(n,r,s){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[n])return!1;i[n]=s,o.splice(r,0,n),this.ensureSheetOrderUnique();const a=new Vr(this._unitId,s,this._styles);return this._worksheets.set(n,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}ensureSheetOrderUnique(){const n=new Set,r=[];for(const s of this._snapshot.sheetOrder)n.has(s)||(n.add(s),r.push(s));this._snapshot.sheetOrder=r,n.clear()}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}addStyles(n){Object.entries(n).forEach(([r,s])=>{this._styles.addCustomStyle(r,s)})}removeStyles(n){n.forEach(r=>{this._styles.remove(r)})}getConfig(){return this._snapshot}getIndexBySheetId(n){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>s===n)}getActiveSheet(n){if(!this._activeSheet&&typeof n>"u")throw new Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){const n=this._activeSheet;if(n)return n;const r=this._snapshot.sheetOrder;for(let i=0,o=r.length;i<o;i++){const a=this._worksheets.get(r[i]);if(a&&a.isSheetHidden()!==ae.TRUE)return this.setActiveSheet(a),a}const s=this._worksheets.get(r[0]);return this.setActiveSheet(s),s}setActiveSheet(n){this._activeSheet$.next(n)}_removeSheet(n){const r=this._worksheets.get(n);return r?(this._worksheets.delete(n),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(n),1),this.ensureSheetOrderUnique(),this._sheetDisposed$.next(r),!0):!1}removeSheet(n){const r=this._removeSheet(n);return r&&delete this._snapshot.sheets[n],r}getActiveSheetIndex(){const{sheetOrder:n}=this._snapshot;return n.findIndex(r=>this._worksheets.get(r)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:n}=this._snapshot;return n.map(r=>this._worksheets.get(r))}getSheetsName(){const{sheetOrder:n}=this._snapshot,r=[];return n.forEach(s=>{const i=this._worksheets.get(s);i&&r.push(i.getName())}),r}getSheetIndex(n){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>n.getSheetId()===s)}getSheetBySheetName(n){const{sheetOrder:r}=this._snapshot,s=r.find(i=>this._worksheets.get(i).getName()===n);return this._worksheets.get(s)}getSheetBySheetId(n){return this._worksheets.get(n)}getSheetByIndex(n){const{sheetOrder:r}=this._snapshot;return this._worksheets.get(r[n])}getHiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden===ae.TRUE).map(n=>n.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden!==ae.TRUE).map(n=>n.getConfig().id)}load(n){this._snapshot=n}checkSheetName(n){return this.getSheetsName().some(s=>s.toLowerCase()===n.toLowerCase())}uniqueSheetName(n="Sheet1"){let r=n;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}generateNewSheetName(n){let r=n+this._count;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}_parseWorksheetSnapshots(){const{_snapshot:n,_worksheets:r}=this,{sheets:s,sheetOrder:i}=n;if(Z.isEmptyObject(s)){const o=nt();s[o]={id:o}}for(const o in s){const a=s[o],{name:l}=a;a.name=this.uniqueSheetName(l),a.name!==l&&this._logService.debug("[Workbook]",`The worksheet name ${l} is duplicated, we changed it to ${a.name}. Please fix the problem in your snapshot.`);const c=new Vr(this._unitId,a,this._styles);r.set(o,c),i.includes(o)||i.push(o)}this.ensureSheetOrderUnique(),this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(n){this._snapshot.custom=n}},f.Workbook=XR([qR(1,dt)],f.Workbook);class oa extends as{constructor(n){var r;super();E(this,"type",ve.UNIVER_SLIDE);E(this,"_activePage$",new se.BehaviorSubject(null));E(this,"activePage$",this._activePage$.asObservable());E(this,"_name$");E(this,"name$");E(this,"_snapshot");E(this,"_unitId");this._snapshot={...$u,...n},this._unitId=(r=this._snapshot.id)!=null?r:nt(6),this._name$=new se.BehaviorSubject(this._snapshot.title),this.name$=this._name$.asObservable()}get _activePage(){var r,s;const n=this._activePage$.getValue();if(!n){const i=(r=this.getPageOrder())==null?void 0:r[0];return i?(s=this.getPages())==null?void 0:s[i]:null}return n}setName(n){var r;this._snapshot.title=n,this._name$.next(n),this._unitId=(r=this._snapshot.id)!=null?r:nt(6)}getRev(){return 0}incrementRev(){}setRev(n){}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var n;return(n=this._snapshot.body)==null?void 0:n.pages}getPageOrder(){var n;return(n=this._snapshot.body)==null?void 0:n.pageOrder}getPage(n){const r=this.getPages();return r==null?void 0:r[n]}getElementsByPage(n){var r;return(r=this.getPage(n))==null?void 0:r.pageElements}getElement(n,r){var s;return(s=this.getElementsByPage(n))==null?void 0:s[r]}getPageSize(){return this._snapshot.pageSize}getBlankPage(){const n=nt(6);return{id:n,pageType:Ni.SLIDE,zIndex:10,title:n,description:"",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}setActivePage(n){this._activePage$.next(n)}getActivePage(){return this._activePage}updatePage(n,r){this._snapshot.body&&(this._snapshot.body.pages[n]=r)}appendPage(n){var i;if(!this._snapshot.body)return;this._snapshot.body.pages[n.id]=n;const r=this._activePage,s=this._snapshot.body.pageOrder.indexOf((i=r==null?void 0:r.id)!=null?i:"");this._snapshot.body.pageOrder.splice(s+1,0,n.id)}}var ZR=Object.getOwnPropertyDescriptor,QR=(e,t,n,r)=>{for(var s=r>1?void 0:r?ZR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},aa=(e,t)=>(n,r)=>t(n,r,e);const Jn=Ce.createIdentifier("univer.current");f.UniverInstanceService=class extends Ke{constructor(n,r,s){super();E(this,"_unitsByType",new Map);E(this,"_createHandler");E(this,"_ctorByType",new Map);E(this,"_currentUnits",new Map);E(this,"_currentUnits$",new se.BehaviorSubject(this._currentUnits));E(this,"currentUnits$",this._currentUnits$.asObservable());E(this,"_unitAdded$",new se.Subject);E(this,"unitAdded$",this._unitAdded$.asObservable());E(this,"_unitDisposed$",new se.Subject);E(this,"unitDisposed$",this._unitDisposed$.asObservable());E(this,"_focused$",new se.BehaviorSubject(null));E(this,"focused$",this._focused$.asObservable());this._injector=n,this._contextService=r,this._logService=s}dispose(){super.dispose(),this._focused$.complete(),this._currentUnits$.complete(),this._unitAdded$.complete(),this._currentUnits.forEach(n=>n==null?void 0:n.dispose()),this._currentUnits.clear(),this._unitsByType.clear()}__setCreateHandler(n){this._createHandler=n}createUnit(n,r,s){return this._createHandler(n,r,this._ctorByType.get(n),s)}registerCtorForType(n,r){return this._ctorByType.set(n,r),{dispose:()=>{this._ctorByType.delete(n)}}}getCurrentTypeOfUnit$(n){return this.currentUnits$.pipe(se.map(r=>{var s;return(s=r.get(n))!=null?s:null}),se.distinctUntilChanged())}getCurrentUnitForType(n){return this._currentUnits.get(n)}getCurrentUnitOfType(n){return this.getCurrentUnitForType(n)}setCurrentUnitForType(n){const r=this._getUnitById(n);if(!r)throw new Error(`[UniverInstanceService]: no document with unitId ${n}!`);this._currentUnits.set(r[1],r[0]),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(n){return this._unitAdded$.pipe(se.filter(r=>r.type===n))}__addUnit(n,r){var a;this._logService.debug(`[UniverInstanceService]: Adding unit with id ${n.getUnitId()}`);const s=n.type;this._unitsByType.has(s)||this._unitsByType.set(s,[]);const i=this._unitsByType.get(s),o=n.getUnitId();if(i.findIndex(l=>l.getUnitId()===o)!==-1)throw new Error(`[UniverInstanceService]: cannot create a unit with the same unit id: ${o}.`);i.push(n),this._unitAdded$.next(n),((a=r==null?void 0:r.makeCurrent)==null||a)&&this.setCurrentUnitForType(n.getUnitId())}getTypeOfUnitDisposed$(n){return this.unitDisposed$.pipe(se.filter(r=>r.type===n))}getUnit(n,r){var i;const s=(i=this._getUnitById(n))==null?void 0:i[0];return r&&(s==null?void 0:s.type)!==r?null:s}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(ve.UNIVER_DOC)}getUniverDocInstance(n){return this.getUnit(n,ve.UNIVER_DOC)}getUniverSheetInstance(n){return this.getUnit(n,ve.UNIVER_SHEET)}getAllUnitsForType(n){var r;return(r=this._unitsByType.get(n))!=null?r:[]}changeDoc(n,r){const s=this.getAllUnitsForType(ve.UNIVER_DOC),i=s.find(o=>o.getUnitId()===n);if(i!=null){const o=s.indexOf(i);s.splice(o,1)}this.__addUnit(r)}get focused(){var r;const n=this._focused$.getValue();return n?(r=this._getUnitById(n))==null?void 0:r[0]:null}focusUnit(n){this._focused$.next(n),this.focused instanceof f.Workbook?(this._contextService.setContextValue($r,!0),this._contextService.setContextValue(jr,!1),this._contextService.setContextValue(qn,!0),this._contextService.setContextValue(Wr,!1),this.setCurrentUnitForType(n)):this.focused instanceof Tt?(this._contextService.setContextValue($r,!0),this._contextService.setContextValue(jr,!0),this._contextService.setContextValue(qn,!1),this._contextService.setContextValue(Wr,!1),this.setCurrentUnitForType(n)):this.focused instanceof oa?(this._contextService.setContextValue($r,!0),this._contextService.setContextValue(jr,!1),this._contextService.setContextValue(qn,!1),this._contextService.setContextValue(Wr,!0),this.setCurrentUnitForType(n)):(this._contextService.setContextValue($r,!1),this._contextService.setContextValue(jr,!1),this._contextService.setContextValue(qn,!1),this._contextService.setContextValue(Wr,!1))}getFocusedUnit(){return this.focused}getUnitType(n){const r=this._getUnitById(n);return r?r[1]:ve.UNRECOGNIZED}disposeUnit(n){this._logService.debug(`[UniverInstanceService]: Disposing unit with id ${n}`);const r=this._getUnitById(n);if(!r)return this._logService.debug(`[UniverInstanceService]: No unit found with id ${n}`),!1;const[s,i]=r,o=this._unitsByType.get(i),a=o.indexOf(s);return o.splice(a,1),this._tryResetCurrentOnRemoval(n,i),this._tryResetFocusOnRemoval(n),this._unitDisposed$.next(s),s.dispose(),!0}_tryResetCurrentOnRemoval(n,r){const s=this.getCurrentUnitForType(r);(s==null?void 0:s.getUnitId())===n&&(this._currentUnits.set(r,null),this._currentUnits$.next(this._currentUnits))}_tryResetFocusOnRemoval(n){var r;((r=this.focused)==null?void 0:r.getUnitId())===n&&this._focused$.next(null)}_getUnitById(n){for(const[r,s]of this._unitsByType){const i=s.find(o=>o.getUnitId()===n);if(i)return[i,r]}}},f.UniverInstanceService=QR([aa(0,Ce.Inject(Ce.Injector)),aa(1,Un),aa(2,Ce.Inject(dt))],f.UniverInstanceService);var Fe=(e=>(e[e.Starting=0]="Starting",e[e.Ready=1]="Ready",e[e.Rendered=2]="Rendered",e[e.Steady=3]="Steady",e))(Fe||{});const nd={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"};var eI=Object.getOwnPropertyDescriptor,tI=(e,t,n,r)=>{for(var s=r>1?void 0:r?eI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},nI=(e,t)=>(n,r)=>t(n,r,e);class rd extends Error{constructor(t){super(`[LifecycleService]: lifecycle stage "${nd[t]}" will never be reached!`),this.name="LifecycleUnreachableError"}}f.LifecycleService=class extends Ke{constructor(n){super();E(this,"_lifecycle$",new se.BehaviorSubject(Fe.Starting));E(this,"lifecycle$",this._lifecycle$.asObservable());E(this,"_lock",!1);this._logService=n,this._reportProgress(Fe.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(n){if(this._lock)throw new Error("[LifecycleService]: cannot set new stage when related logic is all handled!");if(n<this.stage)throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");n!==this.stage&&(this._lock=!0,this._reportProgress(n),this._lifecycle$.next(n),this._lock=!1)}dispose(){this._lifecycle$.complete(),super.dispose()}onStage(n){return se.firstValueFrom(this.lifecycle$.pipe(se.filter(r=>r>=n),Fi(r=>r===n),se.map(()=>{}))).catch(r=>r.name==="EmptyError"?Promise.reject(new rd(n)):Promise.reject(r))}subscribeWithPrevious(){return se.merge(sd(this.stage),this._lifecycle$.pipe(se.skip(1))).pipe(Fi(n=>n===Fe.Steady))}_reportProgress(n){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${nd[n]}".`)}},f.LifecycleService=tI([nI(0,dt)],f.LifecycleService);function sd(e){switch(e){case Fe.Starting:return se.of(Fe.Starting);case Fe.Ready:return se.of(Fe.Starting,Fe.Ready);case Fe.Rendered:return se.of(Fe.Starting,Fe.Ready,Fe.Rendered);default:return se.of(Fe.Starting,Fe.Ready,Fe.Rendered,Fe.Steady)}}const rI=Ce.createIdentifier("ILocalStorageService");class On extends Ke{constructor(){super();E(this,"_currentLocale$",new se.BehaviorSubject(cr.ZH_CN));E(this,"currentLocale$",this._currentLocale$.asObservable());E(this,"_locales",null);E(this,"localeChanged$",new se.Subject);E(this,"t",(n,...r)=>{if(!this._locales)throw new Error("[LocaleService]: Locale not initialized");const s=n.split("."),i=this.resolveKeyPath(this._locales[this._currentLocale],s);if(typeof i=="string"){let o=i;return r.forEach((a,l)=>{o=o.replace(`{${l}}`,a)}),o}else return n});this.disposeWithMe(Ye(()=>{this._locales=null,this._currentLocale$.complete(),this.localeChanged$.complete()}))}get _currentLocale(){return this._currentLocale$.value}load(n){var r;this._locales=is((r=this._locales)!=null?r:{},n)}setLocale(n){this._currentLocale$.next(n),this.localeChanged$.next()}getLocales(){var n;return(n=this._locales)==null?void 0:n[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(n,r){const s=r.shift();if(s&&n&&s in n){const i=n[s];return r.length>0&&(typeof i=="object"||Array.isArray(i))?this.resolveKeyPath(i,r):i}return null}}var sI=Object.getOwnPropertyDescriptor,iI=(e,t,n,r)=>{for(var s=r>1?void 0:r?sI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},oI=(e,t)=>(n,r)=>t(n,r,e);f.MentionIOLocalService=class{constructor(t){this._userManagerService=t}async list(t){return{list:[{type:ls.PERSON,mentions:[{objectType:ls.PERSON,objectId:this._userManagerService.getCurrentUser().userID,label:this._userManagerService.getCurrentUser().name,metadata:{icon:this._userManagerService.getCurrentUser().avatar}}],metadata:{},title:"PEOPLE"}],page:t.page,size:t.size,total:1}}},f.MentionIOLocalService=iI([oI(0,Ce.Inject(Br))],f.MentionIOLocalService);const id=Ce.createIdentifier("univer.service.mention-io");var la=(e=>(e.INIT="init",e.FETCHING="fetching",e.DONE="done",e))(la||{});const od=Ce.createIdentifier("univer.permission-service");class ad extends Ke{constructor(){super(...arguments);E(this,"_permissionPointMap",new Map);E(this,"_permissionPointUpdate$",new se.Subject);E(this,"permissionPointUpdate$",this._permissionPointUpdate$.asObservable());E(this,"_showComponents",!0)}setShowComponents(n){this._showComponents=n}getShowComponents(){return this._showComponents}deletePermissionPoint(n){const r=this._permissionPointMap.get(n);r&&(r.complete(),this._permissionPointMap.delete(n))}addPermissionPoint(n){const r=n instanceof se.BehaviorSubject,s=r?n.getValue():n;return s.id?this._permissionPointMap.get(s.id)?(console.warn(`${s.id} PermissionPoint already exists`),!1):(this._permissionPointMap.set(s.id,r?n:new se.BehaviorSubject(s)),this._permissionPointUpdate$.next(s),!0):!1}updatePermissionPoint(n,r){const s=this._permissionPointMap.get(n);if(!s)return;const i=s.getValue();i.value=r,i.status=la.DONE,s.next(i),this._permissionPointUpdate$.next(i)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(n){const r=this._permissionPointMap.get(n);if(r)return r.getValue()}getPermissionPoint$(n){const r=this._permissionPointMap.get(n);if(r)return r}composePermission$(n){const r=n.map(s=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(s);if(!i)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return i.asObservable()});return se.combineLatest(r).pipe(qr.map(s=>s))}composePermission(n){return n.map(s=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(s);if(!i)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return i.getValue()})}getAllPermissionPoint(){const n=new Map;return this._permissionPointMap.forEach((r,s)=>{n.set(s,r)}),n}}function ld(e,t){if(!t)return e;const n=[];for(const r of e){const s=t.find(([i])=>i===r[0]);if(s){if(s[1]===null)continue;n.push([r[0],s[1]])}else n.push(r)}return n}var aI=Object.getOwnPropertyDescriptor,lI=(e,t,n,r)=>{for(var s=r>1?void 0:r?aI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},ca=(e,t)=>(n,r)=>t(n,r,e);const cI=4,cd=Symbol("DependentOn");class ua extends Ke{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}E(ua,"pluginName"),E(ua,"type",ve.UNIVER_UNKNOWN);class uI{constructor(){E(this,"_plugins",[])}addPlugin(t){this._plugins.push(t)}removePlugins(){const t=this._plugins.slice();return this._plugins.length=0,t}forEachPlugin(t){this._plugins.forEach(t)}}function hI(...e){return function(t){t[cd]=e}}f.PluginService=class{constructor(t,n,r){E(this,"_pluginRegistry",new Map);E(this,"_pluginStore",new uI);E(this,"_seenPlugins",new Set);E(this,"_loadedPlugins",new Set);E(this,"_loadedPluginTypes",new Set([ve.UNIVER_UNKNOWN]));E(this,"_flushTimerByType",new Map);this._injector=t,this._lifecycleService=n,this._logService=r}dispose(){this._pluginStore.removePlugins().forEach(t=>t.dispose()),this._flushTimerByType.forEach(t=>clearTimeout(t))}registerPlugin(t,n){this._assertPluginValid(t);const r={plugin:t,options:n};this._pluginRegistry.set(t.pluginName,r),this._logService.debug("[PluginService]",`Plugin "${t.pluginName}" registered.`);const{type:s}=t;this._loadedPluginTypes.has(s)&&(s===ve.UNIVER_UNKNOWN?this._loadFromPlugins([r]):this._flushType(s))}startPluginsForType(t){this._loadedPluginTypes.has(t)||this._loadPluginsForType(t)}_loadPluginsForType(t){const n=Array.from(this._pluginRegistry.keys()),r=[];n.forEach(s=>{const i=this._pluginRegistry.get(s);i.plugin.type===t&&r.push(i)}),this._loadFromPlugins(r),this._loadedPluginTypes.add(t)}_assertPluginValid(t){const{type:n,pluginName:r}=t;if(n===ve.UNRECOGNIZED)throw new Error(`[PluginService]: invalid plugin type for ${t.name}. Please assign a "type" to your plugin.`);if(!r)throw new Error(`[PluginService]: no plugin name for ${t.name}. Please assign a "pluginName" to your plugin.`);if(this._seenPlugins.has(r))throw new Error(`[PluginService]: duplicated plugin name for "${r}". Maybe a plugin that dependents on "${r} has already registered it. In that case please register "${r}" before the that plugin.`);this._seenPlugins.add(t.pluginName)}_flushType(t){this._flushTimerByType.get(t)===void 0&&this._flushTimerByType.set(t,setTimeout(()=>{this._loadPluginsForType(t),this._flushTimerByType.delete(t)},cI))}_loadFromPlugins(t){const n=[],r=new Set,s=o=>{const{plugin:a}=o,{pluginName:l}=a;if(this._loadedPlugins.has(l)||r.has(l))return;r.add(l),this._pluginRegistry.delete(l);const c=a[cd];c&&c.forEach(u=>{const h=this._pluginRegistry.get(u.pluginName);if(h)s(h);else if(!this._seenPlugins.has(u.pluginName)&&!r.has(u.pluginName)){if(a.type===ve.UNIVER_UNKNOWN&&u.type!==ve.UNIVER_UNKNOWN)throw new Error(`[PluginService]: cannot register a plugin with Univer type that depends on a plugin with other type. The dependent is ${a.pluginName} and the dependency is ${u.pluginName}.`);a.type!==u.type&&u.type!==ve.UNIVER_UNKNOWN&&this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${u.pluginName}" which has different type.`),this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${u.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(u),s({plugin:u,options:void 0})}}),n.push(o)};t.forEach(o=>s(o));const i=n.map(o=>this._initPlugin(o.plugin,o.options));this._pluginsRunLifecycle(i)}_pluginsRunLifecycle(t){const n=this._lifecycleService.stage;if(sd(n).subscribe(r=>this._runStage(t,r)),n!==Fe.Steady){const r=this._lifecycleService.lifecycle$.pipe(se.skip(1)).subscribe(s=>{this._runStage(t,s),s===Fe.Steady&&r.unsubscribe()})}}_runStage(t,n){t.forEach(r=>{switch(n){case Fe.Starting:r.onStarting();break;case Fe.Ready:r.onReady();break;case Fe.Rendered:r.onRendered();break;case Fe.Steady:r.onSteady();break}})}_initPlugin(t,n){const r=this._injector.createInstance(t,n);return this._pluginStore.addPlugin(r),this._loadedPlugins.add(t.pluginName),this._logService.debug("[PluginService]",`Plugin "${r.getPluginName()}" loaded.`),r}},f.PluginService=lI([ca(0,Ce.Inject(Ce.Injector)),ca(1,Ce.Inject(f.LifecycleService)),ca(2,dt)],f.PluginService);const ha=Ce.createIdentifier("resource-loader-service");var dI=Object.getOwnPropertyDescriptor,fI=(e,t,n,r)=>{for(var s=r>1?void 0:r?dI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},mI=(e,t)=>(n,r)=>t(n,r,e);f.ResourceManagerService=class extends Ke{constructor(n){super();E(this,"_resourceMap",new Map);E(this,"_register$",new se.Subject);E(this,"register$",this._register$.asObservable());this._logService=n}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(n,r){return r?this.getResourcesByType(n,r):this.getAllResourceHooks().map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}getResourcesByType(n,r){return this.getAllResourceHooks().filter(o=>o.businesses.includes(r)).map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}registerPluginResource(n){const r=n.pluginName;if(this._resourceMap.has(r))throw new Error(`the pluginName is registered {${r}}`);return this._resourceMap.set(r,n),this._register$.next(n),Ye(()=>this._resourceMap.delete(r))}disposePluginResource(n){this._resourceMap.delete(n)}loadResources(n,r){this.getAllResourceHooks().forEach(s=>{var o;const i=(o=r==null?void 0:r.find(a=>a.name===s.pluginName))==null?void 0:o.data;if(i)try{const a=s.parseJson(i);s.onLoad(n,a)}catch(a){this._logService.error("[ResourceManagerService]","loadResources error",a)}})}unloadResources(n,r){this.getAllResourceHooks().filter(s=>s.businesses.includes(r)).forEach(s=>{s.onUnLoad(n)})}dispose(){this._register$.complete(),this._resourceMap.clear()}},f.ResourceManagerService=fI([mI(0,dt)],f.ResourceManagerService);class ni extends Ke{constructor(){super();E(this,"_darkMode$",new se.BehaviorSubject(!1));E(this,"darkMode$",this._darkMode$.asObservable());E(this,"_validColorCache",new Map);E(this,"_currentTheme",Jr.defaultTheme);E(this,"_currentTheme$",new se.BehaviorSubject(this._currentTheme));E(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(Ye(()=>{this._currentTheme=Jr.defaultTheme,this._currentTheme$.complete(),this._darkMode$.complete()}))}get darkMode(){return this._darkMode$.getValue()}isValidThemeColor(n){if(this._validColorCache.has(n))return this._validColorCache.get(n);let r=!1;const s=n.split(".");if(s.length===1)r=n in Jr.defaultTheme;else if(s.length===2){const[i,o]=s;r=i in Jr.defaultTheme&&o in this._currentTheme[i]}return this._validColorCache.set(n,r),r}getCurrentTheme(){return this._currentTheme}setTheme(n){this._currentTheme=n,this._currentTheme$.next(n)}setDarkMode(n){this._darkMode$.next(n)}getColorFromTheme(n){return ul(this._currentTheme,n)}}var gI=Object.getOwnPropertyDescriptor,_I=(e,t,n,r)=>{for(var s=r>1?void 0:r?gI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},da=(e,t)=>(n,r)=>t(n,r,e);const ri=Ce.createIdentifier("univer.undo-redo.service"),pI=20;class ud{dispose(){}async dispatchToHandlers(){return!1}}const hd="univer.command.redo",dd="univer.command.undo",fd=new class extends ud{constructor(){super(...arguments);E(this,"type",mr.COMMAND);E(this,"id",dd)}handler(t){const n=t.get(ri),r=n.pitchTopUndoElement();if(!r)return!1;const s=t.get(gr);return _s(r.undoMutations,s)?(n.popUndoToRedo(),!0):!1}},md=new class extends ud{constructor(){super(...arguments);E(this,"type",mr.COMMAND);E(this,"id",hd)}handler(t){const n=t.get(ri),r=n.pitchTopRedoElement();if(!r)return!1;const s=t.get(gr);return _s(r.redoMutations,s)?(n.popRedoToUndo(),!0):!1}};f.LocalUndoRedoService=class extends Ke{constructor(n,r,s){super();E(this,"undoRedoStatus$");E(this,"_undoRedoStatus$",new se.BehaviorSubject({undos:0,redos:0}));E(this,"_undoStacks",new Map);E(this,"_redoStacks",new Map);E(this,"_batchingStatus",new Map);this._univerInstanceService=n,this._commandService=r,this._contextService=s,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(fd)),this.disposeWithMe(this._commandService.registerCommand(md)),this.disposeWithMe(Ye(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(Ye(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(n){const{unitID:r}=n,s=this._getRedoStack(r,!0),i=this._getUndoStack(r,!0);if(s.length=0,this._batchingStatus.has(n.unitID)){const a=this._batchingStatus.get(n.unitID),l=this._pitchUndoElement(n.unitID);a===0||!l?(o(n),this._batchingStatus.set(n.unitID,1)):this._tryBatchingElements(l,n)}else o(n);function o(a){i.push(a),i.length>pI&&i.splice(0,1)}this._updateStatus()}clearUndoRedo(n){const r=this._getRedoStack(n);r&&(r.length=0);const s=this._getUndoStack(n);s&&(s.length=0),this._updateStatus()}pitchTopUndoElement(){const n=this._getFocusedUnitId();return this._pitchUndoElement(n)}pitchTopRedoElement(){const n=this._getFocusedUnitId();return this._pitchRedoElement(n)}_pitchUndoElement(n){const r=this._getUndoStack(n);return r!=null&&r.length?r[r.length-1]:null}_pitchRedoElement(n){const r=this._getRedoStack(n);return r!=null&&r.length?r[r.length-1]:null}popUndoToRedo(){const r=this._getUndoStackForFocused().pop();r&&(r.redoMutations.length>0&&this._getRedoStackForFocused().push(r),this._updateStatus())}popRedoToUndo(){const r=this._getRedoStackForFocused().pop();r&&(this._getUndoStackForFocused().push(r),this._updateStatus())}rollback(n,r){const s=r||this._getFocusedUnitId(),i=this._getUndoStack(s),o=i==null?void 0:i[(i==null?void 0:i.length)-1];o&&o.id===n&&(i.pop(),_s(o.undoMutations,this._commandService))}__tempBatchingUndoRedo(n){if(this._batchingStatus.has(n))throw new Error("[LocalUndoRedoService]: cannot batching undo redo twice at the same time!");return this._batchingStatus.set(n,0),Ye(()=>this._batchingStatus.delete(n))}_updateStatus(){var i,o;const n=this._getFocusedUnitId(),r=n&&((i=this._undoStacks.get(n))==null?void 0:i.length)||0,s=n&&((o=this._redoStacks.get(n))==null?void 0:o.length)||0;this._undoRedoStatus$.next({undos:r,redos:s})}_getUndoStack(n,r=!1){let s=this._undoStacks.get(n);return!s&&r&&(s=[],this._undoStacks.set(n,s)),s||null}_getRedoStack(n,r=!1){let s=this._redoStacks.get(n);return!s&&r&&(s=[],this._redoStacks.set(n,s)),s||null}_getUndoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getUndoStack(n,!0)}_getRedoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getRedoStack(n,!0)}_tryBatchingElements(n,r){n.redoMutations.push(...r.redoMutations),n.undoMutations.push(...r.undoMutations)}_getFocusedUnitId(){var o,a,l,c;let n="";const r=this._contextService.getContextValue(qn),s=this._contextService.getContextValue(Dh),i=this._contextService.getContextValue(Mh);return r?s?n=ci:i?n=li:n=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":n=(c=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?c:"",n}},f.LocalUndoRedoService=_I([da(0,Jn),da(1,gr),da(2,Un)],f.LocalUndoRedoService);class gd{constructor(t,n=1e3){E(this,"_imageCacheMap");this._injector=t,this._imageCacheMap=new Tr(n)}_getImageCacheKey(t,n){return`${t}-${n}`}getImage(t,n,r,s){const i=this._getImageCacheKey(t,n),o=this._imageCacheMap.get(i);return o||((async()=>{const a=new Image,l=this._injector.has(ra)?this._injector.get(ra):null,c=this._injector.has(sa)?this._injector.get(sa):null;if(t===ti.UUID)try{a.src=await(l==null?void 0:l.getImage(n))||""}catch(u){console.error(u)}else if(t===ti.URL)try{const u=await(c==null?void 0:c.getImage(n));a.src=u||n}catch{a.src=n}else a.src=n;a.onload=()=>{a.removeAttribute("data-error"),r==null||r()},a.onerror=()=>{a.setAttribute("data-error","true"),s==null||s()},this._imageCacheMap.set(i,a)})(),null)}}function EI(e){return!(e.length===0||e.length>31||e.startsWith("'")||e.endsWith("'")||/[:\\\/\?\*\[\]]/.test(e))}function CI(e,t){return!(!e||e.length===0||e.length>255||t.has(e)||/[ :\\\/\?\*\[\]]/.test(e)||!/^[\p{L}_]/u.test(e)||/^\$?[A-Za-z]{1,3}\$?[0-9]+$/.test(e)||/^[rR]\d+[cC]\d+$/.test(e)||/^\d+$/.test(e))}const _d=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],fa=1,zr=8;class ma{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[n,r]=new Uint8Array(t,0,2);if(n!==219)throw new Error("Data does not appear to be in a KDBush format.");const s=r>>4;if(s!==fa)throw new Error(`Got v${s} data when expected v${fa}.`);const i=_d[r&15];if(!i)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new ma(a,o,i,t)}constructor(t,n=64,r=Float64Array,s){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+n,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=_d.indexOf(this.ArrayType),o=t*2*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);s&&s instanceof ArrayBuffer?(this.data=s,this.ids=new this.IndexArrayType(this.data,zr,t),this.coords=new this.ArrayType(this.data,zr+a+l,t*2),this._pos=t*2,this._finished=!0):(this.data=new ArrayBuffer(zr+o+a+l),this.ids=new this.IndexArrayType(this.data,zr,t),this.coords=new this.ArrayType(this.data,zr+a+l,t*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(fa<<4)+i]),new Uint16Array(this.data,2,1)[0]=n,new Uint32Array(this.data,4,1)[0]=t)}add(t,n){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=n,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ga(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,n,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:o,nodeSize:a}=this,l=[0,i.length-1,0],c=[];for(;l.length;){const u=l.pop()||0,h=l.pop()||0,d=l.pop()||0;if(h-d<=a){for(let I=d;I<=h;I++){const y=o[2*I],H=o[2*I+1];y>=t&&y<=r&&H>=n&&H<=s&&c.push(i[I])}continue}const m=d+h>>1,_=o[2*m],p=o[2*m+1];_>=t&&_<=r&&p>=n&&p<=s&&c.push(i[m]),(u===0?t<=_:n<=p)&&(l.push(d),l.push(m-1),l.push(1-u)),(u===0?r>=_:s>=p)&&(l.push(m+1),l.push(h),l.push(1-u))}return c}within(t,n,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:i,nodeSize:o}=this,a=[0,s.length-1,0],l=[],c=r*r;for(;a.length;){const u=a.pop()||0,h=a.pop()||0,d=a.pop()||0;if(h-d<=o){for(let I=d;I<=h;I++)Ed(i[2*I],i[2*I+1],t,n)<=c&&l.push(s[I]);continue}const m=d+h>>1,_=i[2*m],p=i[2*m+1];Ed(_,p,t,n)<=c&&l.push(s[m]),(u===0?t-r<=_:n-r<=p)&&(a.push(d),a.push(m-1),a.push(1-u)),(u===0?t+r>=_:n+r>=p)&&(a.push(m+1),a.push(h),a.push(1-u))}return l}}function ga(e,t,n,r,s,i){if(s-r<=n)return;const o=r+s>>1;pd(e,t,o,r,s,i),ga(e,t,n,r,o-1,1-i),ga(e,t,n,o+1,s,1-i)}function pd(e,t,n,r,s,i){for(;s>r;){if(s-r>600){const c=s-r+1,u=n-r+1,h=Math.log(c),d=.5*Math.exp(2*h/3),m=.5*Math.sqrt(h*d*(c-d)/c)*(u-c/2<0?-1:1),_=Math.max(r,Math.floor(n-u*d/c+m)),p=Math.min(s,Math.floor(n+(c-u)*d/c+m));pd(e,t,n,_,p,i)}const o=t[2*n+i];let a=r,l=s;for(Gr(e,t,r,n),t[2*s+i]>o&&Gr(e,t,r,s);a<l;){for(Gr(e,t,a,l),a++,l--;t[2*a+i]<o;)a++;for(;t[2*l+i]>o;)l--}t[2*r+i]===o?Gr(e,t,r,l):(l++,Gr(e,t,l,s)),l<=n&&(r=l+1),n<=l&&(s=l-1)}}function Gr(e,t,n,r){_a(e,n,r),_a(t,2*n,2*r),_a(t,2*n+1,2*r+1)}function _a(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function Ed(e,t,n,r){const s=e-n,i=t-r;return s*s+i*i}class RI{constructor(t=!1){E(this,"_tree",new Map);E(this,"_oneCellCache",new Map);E(this,"_kdTree",new Map);this._enableOneCellCache=t}dispose(){this.clear()}getTree(t,n){return this._tree.has(t)||this._tree.set(t,new Map),this._tree.get(t).has(n)||this._tree.get(t).set(n,new Vs),this._tree.get(t).get(n)}_getOneCellCache(t,n,r,s){return this._oneCellCache.has(t)||this._oneCellCache.set(t,new Map),this._oneCellCache.get(t).has(n)||this._oneCellCache.get(t).set(n,new Map),this._oneCellCache.get(t).get(n).has(r)||this._oneCellCache.get(t).get(n).set(r,new Map),this._oneCellCache.get(t).get(n).get(r).has(s)||this._oneCellCache.get(t).get(n).get(r).set(s,new Set),this._oneCellCache.get(t).get(n).get(r).get(s)}_removeOneCellCache(t,n,r,s,i){const o=this._oneCellCache.get(t);if(!o)return;const a=o.get(n);if(!a)return;const l=a.get(r);if(!l)return;const c=l.get(s);c&&c.delete(i)}_removeCellCacheByRange(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this._oneCellCache.get(n);if(!o)return;const a=o.get(r);if(!a)return;const{startRow:l,startColumn:c,endRow:u,endColumn:h}=s;for(let d=l;d<=u;d++){const m=a.get(d);if(m)for(let _=c;_<=h;_++){const p=m.get(_);p&&p.delete(i)}}}_insertOneCellCache(t,n,r,s,i){this._getOneCellCache(t,n,r,s).add(i)}_getRdTreeItems(t){const n=[];for(const[r,s]of t)for(const[i,o]of s)n.push({x:i,y:r,ids:o});return n}_searchByOneCellCache(t){var _;const{unitId:n,sheetId:r,range:s}=t,{startRow:i,startColumn:o,endRow:a,endColumn:l}=s,c=(_=this._kdTree.get(n))==null?void 0:_.get(r);if(!c)return[];const{tree:u,items:h}=c,d=u.range(o,i,l,a),m=[];for(const p of d){const I=h[p];m.push(...Array.from(I.ids))}return m}openKdTree(){var t;for(const[n,r]of this._oneCellCache){this._kdTree.has(n)||this._kdTree.set(n,new Map);for(const[s,i]of r){const o=this._getRdTreeItems(i),a=new ma(o.length);(t=this._kdTree.get(n))==null||t.set(s,{tree:a,items:o});for(const l of o)a.add(l.x,l.y);a.finish()}}}closeKdTree(){var t;for(const[n,r]of this._oneCellCache)for(const[s,i]of r)(t=this._kdTree.get(n))==null||t.set(s,void 0)}insert(t){const{unitId:n,sheetId:r,range:s,id:i}=t;if(!n||n.length===0)return;let{startRow:o,endRow:a,startColumn:l,endColumn:c}=s;if(this._enableOneCellCache&&o===a&&l===c){this._insertOneCellCache(n,r,o,l,i);return}const u=this.getTree(n,r);Number.isNaN(o)&&(o=0),Number.isNaN(l)&&(l=0),Number.isNaN(a)&&(a=Number.POSITIVE_INFINITY),Number.isNaN(c)&&(c=Number.POSITIVE_INFINITY),u.insert({minX:l,minY:o,maxX:c,maxY:a,id:i})}bulkInsert(t){for(const n of t)this.insert(n)}*searchGenerator(t){var a;const{unitId:n,sheetId:r,range:s}=t;if(this._enableOneCellCache){const l=this._searchByOneCellCache(t);for(const c of l)yield c}const i=(a=this._tree.get(n))==null?void 0:a.get(r);if(!i)return;const o=i.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(const l of o)yield l.id}bulkSearch(t,n){const r=new Set;for(const s of t)for(const i of this.searchGenerator(s))(n==null?void 0:n.has(i))!==!0&&r.add(i);return r}removeById(t,n){var r,s;n?((r=this._tree.get(t))==null||r.delete(n),(s=this._oneCellCache.get(t))==null||s.delete(n)):(this._tree.delete(t),this._oneCellCache.delete(t))}_removeRTreeItem(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this.getTree(n,r),a=o.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(let l=0;l<a.length;l++)a[l].id===i&&o.remove(a[l])}remove(t){const{unitId:n,sheetId:r,range:s,id:i}=t,{startRow:o,startColumn:a,endRow:l,endColumn:c}=s;this._enableOneCellCache?o===l&&a===c?this._removeOneCellCache(n,r,s.startRow,s.startColumn,i):(this._removeCellCacheByRange(t),this._removeRTreeItem(t)):this._removeRTreeItem(t)}bulkRemove(t){for(const n of t)this.remove(n)}clear(){this._tree.clear(),this._oneCellCache.clear()}toJSON(){const t={};return this._tree.forEach((n,r)=>{t[r]={},n.forEach((s,i)=>{t[r][i]=s.toJSON()})}),t}fromJSON(t){this._tree.clear();for(const n in t){this._tree.set(n,new Map);for(const r in t[n]){const s=new Vs;s.fromJSON(t[n][r]),this._tree.get(n).set(r,s)}}}}function II(e){return new Promise(t=>setTimeout(t,e))}function SI(e=1){return new Promise(t=>{let n=0;const r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}var OI=Object.getOwnPropertyDescriptor,wI=(e,t,n,r)=>{for(var s=r>1?void 0:r?OI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},vI=(e,t)=>(n,r)=>t(n,r,e);f.Skeleton=class extends Ke{constructor(n){super();E(this,"_fontLocale");E(this,"_dirty",!0);this._localeService=n,this._localeInitial()}get dirty(){return this._dirty}getFontLocale(){return this._fontLocale}makeDirty(n){this._dirty=n}dispose(){super.dispose(),this._fontLocale=null}_localeInitial(){}},f.Skeleton=wI([vI(0,Ce.Inject(On))],f.Skeleton);var bI=Object.getOwnPropertyDescriptor,yI=(e,t,n,r)=>{for(var s=r>1?void 0:r?bI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},si=(e,t)=>(n,r)=>t(n,r,e);f.SheetSkeleton=class extends f.Skeleton{constructor(n,r,s,i,o,a){super(s);E(this,"_worksheetData");E(this,"_renderRawFormula",!1);E(this,"_cellData");E(this,"_imageCacheMap");E(this,"_skipAutoHeightForMergedCells",!0);E(this,"_rowTotalHeight",0);E(this,"_columnTotalWidth",0);E(this,"_rowHeaderWidth",0);E(this,"_columnHeaderHeight",0);E(this,"_rowHeightAccumulation",[]);E(this,"_columnWidthAccumulation",[]);E(this,"_marginTop",0);E(this,"_marginLeft",0);E(this,"_scaleX");E(this,"_scaleY");E(this,"_scrollX");E(this,"_scrollY");this.worksheet=n,this._styles=r,this._contextService=i,this._configService=o,this._injector=a,this._worksheetData=this.worksheet.getConfig(),this._cellData=this.worksheet.getCellMatrix(),this._imageCacheMap=new gd(this._injector),this.initConfig()}initConfig(){var n,r;this._skipAutoHeightForMergedCells=!((n=this._configService.getConfig(ba))!=null&&n),this.worksheet.setIsRowStylePrecedeColumnStyle((r=this._configService.getConfig(va))!=null?r:!1)}resetCache(){}getWorksheetConfig(){return this._worksheetData}getLocation(){return[this.worksheet.getUnitId(),this.worksheet.getSheetId()]}set columnHeaderHeight(n){this._columnHeaderHeight=n,this._worksheetData.columnHeader.height=n}set rowHeaderWidth(n){this._rowHeaderWidth=n,this._worksheetData.rowHeader.width=n}get rowHeightAccumulation(){return this._rowHeightAccumulation}get rowTotalHeight(){return this._rowTotalHeight}get columnWidthAccumulation(){return this._columnWidthAccumulation}get columnTotalWidth(){return this._columnTotalWidth}get rowHeaderWidth(){return this._rowHeaderWidth}get columnHeaderHeight(){return this._columnHeaderHeight}setMarginLeft(n){this._marginLeft=n}setMarginTop(n){this._marginTop=n}setScale(n,r){this._updateLayout(),this._scaleX=n,this._scaleY=r||n,this._updateLayout()}setScroll(n,r){Z.isDefine(n)&&(this._scrollX=n),Z.isDefine(r)&&(this._scrollY=r)}get scrollX(){return this._scrollX}get scrollY(){return this._scrollY}get scaleX(){return this._scaleX}get scaleY(){return this._scaleY}get rowHeaderWidthAndMarginLeft(){return this.rowHeaderWidth+this._marginLeft}get columnHeaderHeightAndMarginTop(){return this.columnHeaderHeight+this._marginTop}get imageCacheMap(){return this._imageCacheMap}_generateRowMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let c=s;if(this.worksheet.getRowFiltered(l))c=0;else if(a[l]!=null){const u=a[l];if(!u)continue;const{h=s,ah:d,ia:m}=u;(m==null||m===ae.TRUE)&&typeof d=="number"?c=d:c=h,u.hd===ae.TRUE&&(c=0)}i+=c,o.push(i)}return{rowTotalHeight:i,rowHeightAccumulation:o}}_generateColumnMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let c=s;if(a[l]!=null){const u=a[l];if(!u)continue;u.w!=null&&(c=u.w),u.hd===ae.TRUE&&(c=0)}i+=c,o.push(i)}return{columnTotalWidth:i,columnWidthAccumulation:o}}intersectMergeRange(n,r){return!!this.worksheet.getMergedCell(n,r)}_getOverflowBound(n,r,s,i,o=bt.LEFT){let a=0;if(r>s){const l=this._columnWidthAccumulation.length-1;for(let c=r;c>=s;c--){const u=c,h=this.worksheet.getCell(n,u);if(!xo(h)&&u!==r||this.intersectMergeRange(n,u))return u===r?u:u+1>l?l:u+1;const{startX:d,endX:m}=Zn(n,u,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===bt.CENTER&&u===r?a+=(m-d)/2:a+=m-d,i<a)return u}return r}for(let l=r;l<=s;l++){const c=l,u=this.worksheet.getCell(n,c);if(!xo(u)&&c!==r||this.intersectMergeRange(n,c))return c===r?c:c-1<0?0:c-1;const{startX:h,endX:d}=Zn(n,c,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===bt.CENTER&&c===r?a+=(d-h)/2:a+=d-h,i<a)return c}return s}_updateLayout(){if(!this.dirty)return;const{rowData:n,columnData:r,defaultRowHeight:s,defaultColumnWidth:i,rowCount:o,columnCount:a,rowHeader:l,columnHeader:c}=this._worksheetData,{rowTotalHeight:u,rowHeightAccumulation:h}=this._generateRowMatrixCache(o,n,s),{columnTotalWidth:d,columnWidthAccumulation:m}=this._generateColumnMatrixCache(a,r,i);this._rowHeaderWidth=l.hidden!==ae.TRUE?this._dynamicallyUpdateRowHeaderWidth(l):0,this._columnHeaderHeight=c.hidden!==ae.TRUE?c.height:0,this._rowTotalHeight=u,this._rowHeightAccumulation=h,this._columnTotalWidth=d,this._columnWidthAccumulation=m,this.makeDirty(!1)}calculate(){return this.resetCache(),this._updateLayout(),this}resetRangeCache(n){}_dynamicallyUpdateRowHeaderWidth(n){const s=`${this.worksheet.getRowCount()}`.length*8;return Math.max(n.width,s)}_hasUnMergedCellInRow(n,r,s){if(!this.worksheet.getMergeData())return!1;for(let o=r;o<=s;o++){const{isMerged:a,isMergedMainCell:l}=this.worksheet.getCellInfoInMergeData(n,o);if(!a&&!l)return!0}return!1}expandRangeByMerge(n,r){let{startRow:s,startColumn:i,endRow:o,endColumn:a}=n;const l=this._worksheetData.mergeData;if(!l)return{startRow:s,startColumn:i,endRow:o,endColumn:a};let c=!0;const u=new ct;let h=0,d=null;for(;c;){c=!1;for(let m=0;m<l.length;m++){const{startRow:_,startColumn:p,endRow:I,endColumn:y}=l[m];if(u.getValue(_,p))continue;const H={startColumn:i,startRow:s,endColumn:a,endRow:o},x={startColumn:p,startRow:_,endColumn:y,endRow:I};zu(H,x)&&(s=Math.min(s,_),i=Math.min(i,p),o=Math.max(o,I),a=Math.max(a,y),u.setValue(_,p,!0),c=!0,h++,d=x)}}return r&&h===1&&Yt.contains(d,n)?{startRow:d.startRow,startColumn:d.startColumn,endRow:d.startRow,endColumn:d.startColumn}:{startRow:s,startColumn:i,endRow:o,endColumn:a}}getColumnCount(){return this._columnWidthAccumulation.length}getRowCount(){return this._rowHeightAccumulation.length}_getCellMergeInfo(n,r){return this.worksheet.getCellInfoInMergeData(n,r)}getNoMergeCellPositionByIndex(n,r,s=!0){return this.getNoMergeCellWithCoordByIndex(n,r,s)}getNoMergeCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this;let{startY:c,endY:u,startX:h,endX:d}=Zn(n,r,i,o);return s&&(c+=l,u+=l,h+=a,d+=a),{startY:c,endY:u,startX:h,endX:d}}getNoMergeCellPositionByIndexWithNoHeader(n,r){const{rowHeightAccumulation:s,columnWidthAccumulation:i}=this,{startY:o,endY:a,startX:l,endX:c}=Zn(n,r,s,i);return{startY:o,endY:a,startX:l,endX:c}}getRowIndexByOffsetY(n,r,s,i){var l;const{rowHeightAccumulation:o}=this;n=Rd(n,r,s,this.columnHeaderHeightAndMarginTop);let a=_r(o,n,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(o[a]-n)<Math.abs(n-((l=o[a-1])!=null?l:0))&&(a=a+1),a}getColumnIndexByOffsetX(n,r,s,i){var c;const o=Cd(n,r,s,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this;let l=_r(a,o,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(a[l]-o)<Math.abs(o-((c=a[l-1])!=null?c:0))&&(l=l+1),l}getCellIndexByOffset(n,r,s,i,o,a){const l=this.getRowIndexByOffsetY(r,i,o,a),c=this.getColumnIndexByOffsetX(n,s,o,a);return{row:l,column:c}}getCellByOffset(n,r,s,i,o){const a=this==null?void 0:this.getCellIndexByOffset(n,r,s,i,o,{firstMatch:!0});return a?this.worksheet.getCellInfoInMergeData(a.row,a.column):null}getCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this,c=Zn(n,r,i,o,this.worksheet.getCellInfoInMergeData(n,r)),{isMerged:u,isMergedMainCell:h}=c;let{startY:d,endY:m,startX:_,endX:p,mergeInfo:I}=c,y=a,H=l;return s===!1&&(y=0,H=0),d+=H,m+=H,_+=y,p+=y,I.startY+=H,I.endY+=H,I.startX+=y,I.endX+=y,{actualRow:n,actualColumn:r,startX:_,startY:d,endX:p,endY:m,isMerged:u,isMergedMainCell:h,mergeInfo:I}}getCellWithCoordByOffset(n,r,s,i,o,a){const{row:l,column:c}=this.getCellIndexByOffset(n,r,s,i,o,a);return this.getCellWithCoordByIndex(l,c)}getOffsetByColumn(n){const{columnWidthAccumulation:r,rowHeaderWidthAndMarginLeft:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetByRow(n){const{rowHeightAccumulation:r,columnHeaderHeightAndMarginTop:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetRelativeToRowCol(n,r){const s=_r(this.columnWidthAccumulation,n);let i=0;s===0?i=n:i=n-this._columnWidthAccumulation[s-1];const o=_r(this.rowHeightAccumulation,r);let a=0;return o===0?a=r:a=r-this._rowHeightAccumulation[o-1],{row:o,column:s,columnOffset:i,rowOffset:a}}_updateConfigAndGetDocumentModel(n,r,s,i){var a,l,c,u,h;if(!i||!((a=n.body)!=null&&a.dataStream))return;n.documentStyle||(n.documentStyle={}),n.documentStyle.marginTop=(l=s.t)!=null?l:0,n.documentStyle.marginBottom=(c=s.b)!=null?c:2,n.documentStyle.marginLeft=(u=s.l)!=null?u:2,n.documentStyle.marginRight=(h=s.r)!=null?h:2,n.documentStyle.pageSize={width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},n.documentStyle.renderConfig={...n.documentStyle.renderConfig,...i};const o=n.body.paragraphs||[];for(const d of o)d.paragraphStyle||(d.paragraphStyle={}),d.paragraphStyle.horizontalAlign=r;return new Tt(n)}dispose(){super.dispose(),this._rowHeightAccumulation=[],this._columnWidthAccumulation=[],this._rowTotalHeight=0,this._columnTotalWidth=0,this._rowHeaderWidth=0,this._columnHeaderHeight=0,this._worksheetData=null,this._cellData=null,this._styles=null,this.worksheet=null}},f.SheetSkeleton=yI([si(2,Ce.Inject(On)),si(3,Un),si(4,fr),si(5,Ce.Inject(Ce.Injector))],f.SheetSkeleton);function pa(e,t,n,r){const s=e-1,i=t-1,o=n[s]||0;let a=n[e];a==null&&(a=n[n.length-1]);const l=r[i]||0;let c=r[t];return c==null&&(c=r[r.length-1]),{startY:o,endY:a,startX:l,endX:c}}function AI(e,t,n,r){return pa(e,t,n,r)}function Zn(e,t,n,r,s){e=Z.clamp(e,0,n.length-1),t=Z.clamp(t,0,r.length-1);let{startY:i,endY:o,startX:a,endX:l}=pa(e,t,n,r);if(!s)return{startY:i,endY:o,startX:a,endX:l,isMerged:!1,isMergedMainCell:!1,actualRow:e,actualColumn:t,mergeInfo:{startY:i,endY:o,startX:a,endX:l,startRow:e,startColumn:t,endRow:e,endColumn:t}};const{isMerged:c,isMergedMainCell:u,startRow:h,startColumn:d,endRow:m,endColumn:_}=s;let p={startRow:h,startColumn:d,endRow:m,endColumn:_,startY:i,endY:o,startX:a,endX:l};const I=n.length-1,y=r.length-1;if(c&&h!==-1&&d!==-1){const H=n[h-1]||0,x=n[m]||n[I],Y=r[d-1]||0,O=r[_]||r[y];p={...p,startY:H,endY:x,startX:Y,endX:O}}else if(!c&&m!==-1&&_!==-1){const H=n[m]||n[I],x=r[_]||r[y];p={...p,startY:i,endY:H,startX:a,endX:x}}return{isMerged:c,isMergedMainCell:u,actualRow:e,actualColumn:t,startY:i,endY:o,startX:a,endX:l,mergeInfo:p}}function Cd(e,t,n,r){const{x:s}=n;return e/t+s-r}function Rd(e,t,n,r){const{y:s}=n;return e=e/t+s-r,e}const TI=["script","style","meta","comment","link"];var Id=(e=>(e[e.INFO=0]="INFO",e[e.STOP=1]="STOP",e[e.WARNING=2]="WARNING",e))(Id||{}),Sd=(e=>(e[e.DISABLED=0]="DISABLED",e[e.FULL_ALPHA=1]="FULL_ALPHA",e[e.FULL_HANGUL=2]="FULL_HANGUL",e[e.FULL_KATAKANA=3]="FULL_KATAKANA",e[e.HALF_ALPHA=4]="HALF_ALPHA",e[e.HALF_HANGUL=5]="HALF_HANGUL",e[e.HALF_KATAKANA=6]="HALF_KATAKANA",e[e.HIRAGANA=7]="HIRAGANA",e[e.NO_CONTROL=8]="NO_CONTROL",e[e.OFF=9]="OFF",e[e.ON=10]="ON",e))(Sd||{}),Od=(e=>(e.BETWEEN="between",e.EQUAL="equal",e.GREATER_THAN="greaterThan",e.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",e.LESS_THAN="lessThan",e.LESS_THAN_OR_EQUAL="lessThanOrEqual",e.NOT_BETWEEN="notBetween",e.NOT_EQUAL="notEqual",e))(Od||{}),wd=(e=>(e[e.TEXT=0]="TEXT",e[e.ARROW=1]="ARROW",e[e.CUSTOM=2]="CUSTOM",e))(wd||{}),vd=(e=>(e.VALID="valid",e.INVALID="invalid",e.VALIDATING="validating",e))(vd||{}),bd=(e=>(e.CUSTOM="custom",e.LIST="list",e.LIST_MULTIPLE="listMultiple",e.NONE="none",e.TEXT_LENGTH="textLength",e.DATE="date",e.TIME="time",e.WHOLE="whole",e.DECIMAL="decimal",e.CHECKBOX="checkbox",e.ANY="any",e))(bd||{}),NI=Object.getOwnPropertyDescriptor,MI=(e,t,n,r)=>{for(var s=r>1?void 0:r?NI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},yd=(e,t)=>(n,r)=>t(n,r,e);let Ea=class extends Ke{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){const e=n=>{n.businesses.forEach(r=>{switch(r){case ve.UNRECOGNIZED:case ve.UNIVER_UNKNOWN:case ve.UNIVER_SLIDE:case ve.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType(ve.UNIVER_DOC).forEach(s=>{const o=(s.getSnapshot().resources||[]).find(a=>a.name===n.pluginName);if(o)try{const a=n.parseJson(o.data);n.onLoad(s.getUnitId(),a)}catch{console.error(`Load Document{${s.getUnitId()}} Resources{${n.pluginName}} Data Error.`)}});break}case ve.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(ve.UNIVER_SHEET).forEach(s=>{const o=(s.getSnapshot().resources||[]).find(a=>a.name===n.pluginName);if(o)try{const a=n.parseJson(o.data);n.onLoad(s.getUnitId(),a)}catch{console.error(`Load Workbook{${s.getUnitId()}} Resources{${n.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(n=>e(n)),this.disposeWithMe(this._resourceManagerService.register$.subscribe(n=>e(n))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(ve.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(ve.UNIVER_DOC).subscribe(n=>{const r=n.getUnitId();ya(r)||this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(ve.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId(),ve.UNIVER_SHEET)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(ve.UNIVER_DOC).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId(),ve.UNIVER_DOC)}))}saveUnit(e){const t=this._univerInstanceService.getUnit(e);if(!t)return null;const n=this._resourceManagerService.getResources(e,t.type),r=Z.deepClone(t.getSnapshot());return r.resources=n,r}};Ea=MI([yd(0,Ce.Inject(Qs)),yd(1,Ce.Inject(Jn))],Ea);class DI{constructor(t={},n){E(this,"_startedTypes",new Set);E(this,"_injector");E(this,"_disposingCallbacks",new os);const r=this._injector=LI(n,t==null?void 0:t.override),{theme:s,darkMode:i,locale:o,locales:a,logLevel:l,logCommandExecution:c}=t;s&&this._injector.get(ni).setTheme(s),i&&this._injector.get(ni).setDarkMode(i),a&&this._injector.get(On).load(a),o&&this._injector.get(On).setLocale(o),l&&this._injector.get(dt).setLogLevel(l),c!==void 0&&this._injector.get(fr).setConfig(gs,c),this._init(r)}get _univerInstanceService(){return this._injector.get(Jn)}get _pluginService(){return this._injector.get(f.PluginService)}__getInjector(){return this._injector}onDispose(t){const n=this._disposingCallbacks.add(Ye(t));return Ye(()=>n.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(t){this._injector.get(On).setLocale(t)}createUnit(t,n){return this._univerInstanceService.createUnit(t,n)}createUniverSheet(t){return this._injector.get(dt).warn("[Univer]","Univer.createUniverSheet is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(ve.UNIVER_SHEET,t)}createUniverDoc(t){return this._injector.get(dt).warn("[Univer]","Univer.createUniverDoc is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(ve.UNIVER_DOC,t)}createUniverSlide(t){return this._injector.get(dt).warn("[Univer]","Univer.createUniverSlide is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(ve.UNIVER_SLIDE,t)}_init(t){this._univerInstanceService.registerCtorForType(ve.UNIVER_SHEET,f.Workbook),this._univerInstanceService.registerCtorForType(ve.UNIVER_DOC,Tt),this._univerInstanceService.registerCtorForType(ve.UNIVER_SLIDE,oa);const n=t.get(Jn);n.__setCreateHandler((r,s,i,o)=>{if(!this._startedTypes.has(r)){this._pluginService.startPluginsForType(r),this._startedTypes.add(r);const l=t.createInstance(i,s);return n.__addUnit(l,o),this._tryProgressToReady(),l}const a=t.createInstance(i,s);return n.__addUnit(a,o),a})}_tryProgressToReady(){this._injector.get(f.LifecycleService).stage<Fe.Ready&&(this._injector.get(f.LifecycleService).stage=Fe.Ready)}registerPlugin(t,n){this._pluginService.registerPlugin(t,n)}registerPlugins(t){t.forEach(n=>{const[r,s]=n;this._pluginService.registerPlugin(r,s)})}}function LI(e,t){const n=ld([[Lh],[On],[ni],[f.LifecycleService],[f.PluginService],[Br],[Jn,{useClass:f.UniverInstanceService}],[od,{useClass:ad}],[dt,{useClass:Mc,lazy:!0}],[gr,{useClass:f.CommandService}],[ri,{useClass:f.LocalUndoRedoService,lazy:!0}],[fr,{useClass:Ac}],[Un,{useClass:Tc}],[Qs,{useClass:f.ResourceManagerService,lazy:!0}],[ha,{useClass:Ea,lazy:!0}],[Nh,{useClass:f.AuthzIoLocalService}],[id,{useClass:f.MentionIOLocalService,lazy:!0}]],t),r=e?e.createChild(n):new Ce.Injector(n);return Aa(r,[[Br],[ha]]),r}Pd(),f.ABCToNumber=X0,f.AUTO_HEIGHT_FOR_MERGED_CELLS=ba,f.AbsoluteRefType=Me,f.ActionIterator=Xn,f.AlignTypeH=lc,f.AlignTypeV=cc,f.ArrangeTypeEnum=dc,f.ArrowsAndMarkersShapes=Ul,f.AsyncInterceptorManager=rf,f.AsyncLock=Vd,f.AutoFillSeries=Ol,f.BaselineOffset=jt,f.BasicShapes=Ll,f.BlockType=jl,f.BooleanNumber=ae,f.BorderStyleTypes=Pe,f.BorderType=wl,f.BuildTextUtils=Qe,f.BulletAlignment=hr,f.COLORS=Hi,f.COMMAND_LOG_EXECUTION_CONFIG_KEY=gs,f.CanceledError=Jd,f.CellModeEnum=Pn,f.CellValueType=Qt,f.Color=Cn,f.ColorBuilder=Es,f.ColorKit=It,f.ColorType=Rt,f.ColumnSeparatorType=Vl,f.CommandType=mr,f.CommonHideTypes=vl,f.ConfigService=Ac,f.ContextService=Tc,f.CopyPasteType=bl,f.CustomCommandExecutionError=Zr,f.CustomDecorationType=_n,f.CustomRangeType=en,f.DEFAULT_CELL=v0,f.DEFAULT_DOC=qo,f.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=cR,f.DEFAULT_EMPTY_DOCUMENT_VALUE=wa,f.DEFAULT_NUMBER_FORMAT=Po,f.DEFAULT_RANGE=O0,f.DEFAULT_RANGE_ARRAY=S0,f.DEFAULT_SELECTION=w0,f.DEFAULT_SLIDE=$u,f.DEFAULT_STYLES=it,f.DEFAULT_TEXT_FORMAT=Iu,f.DEFAULT_TEXT_FORMAT_EXCEL=Su,f.DEFAULT_WORKSHEET_COLUMN_COUNT=Gh,f.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=$R,f.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Jh,f.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=VR,f.DEFAULT_WORKSHEET_COLUMN_WIDTH=Xh,f.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=WR,f.DEFAULT_WORKSHEET_ROW_COUNT=zh,f.DEFAULT_WORKSHEET_ROW_COUNT_KEY=BR,f.DEFAULT_WORKSHEET_ROW_HEIGHT=Kh,f.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=jR,f.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=qh,f.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=YR,f.DOCS_COMMENT_EDITOR_UNIT_ID_KEY=Oa,f.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=ci,f.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=li,f.DOCS_ZEN_EDITOR_UNIT_ID_KEY=Sa,f.DOC_DRAWING_PRINTING_COMPONENT_KEY=N0,f.DOC_RANGE_TYPE=Wc,f.DashStyleType=Jl,f.DataStreamTreeNodeType=Sh,f.DataStreamTreeTokenType=ut,f.DataValidationErrorStyle=Id,f.DataValidationImeMode=Sd,f.DataValidationOperator=Od,f.DataValidationRenderMode=wd,f.DataValidationStatus=vd,f.DataValidationType=bd,f.DeleteDirection=yl,f.DependentOn=hI,f.DesktopLogService=Mc,f.DeveloperMetadataVisibility=Al,f.Dimension=Tl,f.Direction=Nl,f.Disposable=Ke,f.DisposableCollection=os,f.DocStyleType=Bl,f.DocumentDataModel=Tt,f.DocumentFlavor=Ti,f.DrawingTypeEnum=fc,f.EDITOR_ACTIVATED=Mh,f.EXTENSION_NAMES=ju,f.ErrorService=Lh,f.EventState=Ah,f.EventSubject=uR,f.FOCUSING_COMMENT_EDITOR=IR,f.FOCUSING_COMMON_DRAWINGS=wR,f.FOCUSING_DOC=jr,f.FOCUSING_EDITOR_BUT_HIDDEN=pR,f.FOCUSING_EDITOR_INPUT_FORMULA=ER,f.FOCUSING_EDITOR_STANDALONE=RR,f.FOCUSING_FX_BAR_EDITOR=Dh,f.FOCUSING_PANEL_EDITOR=SR,f.FOCUSING_SHEET=qn,f.FOCUSING_SLIDE=Wr,f.FOCUSING_UNIT=$r,f.FOCUSING_UNIVER_EDITOR=CR,f.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=OR,f.FORMULA_EDITOR_ACTIVATED=vR,f.FollowNumberWithType=$l,f.FontItalic=cs,f.FontStyleType=Ln,f.FontWeight=us,f.GridType=Wl,f.HLSColor=xc,f.HorizontalAlign=bt,f.IAuthzIoService=Nh,f.ICommandService=gr,f.IConfigService=fr,f.IConfirmService=gR,f.IContextService=Un,f.IImageIoService=ra,f.ILocalStorageService=rI,f.ILogService=dt,f.IMentionIOService=id,f.IPermissionService=od,f.IResourceLoaderService=ha,f.IResourceManagerService=Qs,f.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE=va,f.IURLImageService=sa,f.IUndoRedoService=ri,f.IUniverInstanceService=Jn,f.ImageCacheMap=gd,f.ImageSourceType=ti,f.ImageUploadStatusType=Uh,f.InterceptorEffectEnum=An,f.InterceptorManager=ef,f.InterpolationPointType=Ml,f.JSON1=$_,f.JSONX=Vt,f.LRUHelper=Nr,f.LRUMap=Tr,f.LifecycleStages=Fe,f.LifecycleUnreachableError=rd,f.ListGlyphType=fe,f.LocaleService=On,f.LocaleType=cr,f.LogLevel=Nc,f.MOVE_BUFFER_VALUE=pr,f.MemoryCursor=fn,f.MentionType=ls,f.NAMED_STYLE_MAP=y0,f.NAMED_STYLE_SPACE_MAP=A0,f.NamedStyleType=Je,f.NilCommand=Dc,f.NumberUnitType=ac,f.ObjectMatrix=ct,f.ObjectRelativeFromH=ic,f.ObjectRelativeFromV=oc,f.OtherShapes=Pl,f.PAGE_SIZE=M0,f.PAPER_TYPES=L_,f.PRESET_LIST_TYPE=kr,f.PRINT_CHART_COMPONENT_KEY=T0,f.PageElementType=mc,f.PageOrientType=hc,f.PageType=Ni,f.PaperType=ht,f.ParagraphElementType=Gl,f.ParagraphStyleBuilder=Hr,f.ParagraphStyleValue=xr,f.PermissionService=ad,f.PermissionStatus=la,f.Plugin=ua,f.PositionedObjectLayoutType=Xl,f.PresetListType=xt,f.ProtectionType=Dl,f.QuickListType=uh,f.QuickListTypeMap=oC,f.RANGE_DIRECTION=jc,f.RANGE_TYPE=pe,f.RBush=Vs,f.RCDisposable=E_,f.RGBA_PAREN=rp,f.RGB_PAREN=np,f.ROTATE_BUFFER_VALUE=kc,f.RTree=RI,f.Range=Yn,f.Rectangle=Yt,f.RedoCommand=md,f.RedoCommandId=hd,f.RefAlias=K0,f.Registry=vi,f.RegistryAsMap=bi,f.RelativeDate=Fl,f.RelativeSlideLink=gc,f.RgbColor=Cs,f.RichTextBuilder=Sn,f.RichTextValue=an,f.RxDisposable=p_,f.SHEET_EDITOR_UNITS=b0,f.SectionType=Yl,f.SheetTypes=xl,f.SheetViewModel=Qh,f.SliceBodyType=Ko,f.SlideDataModel=oa,f.SpacingRule=ql,f.SpecialShapes=kl,f.Styles=Ph,f.THEME_COLORS=Fc,f.TabStopAlignment=Zl,f.TableAlignmentType=ec,f.TableLayoutType=tc,f.TableRowHeightRule=rc,f.TableSizeType=Ql,f.TableTextWrapType=nc,f.TestConfirmService=_R,f.TextDecoration=Hl,f.TextDecorationBuilder=on,f.TextDirection=ur,f.TextDirectionType=zl,f.TextStyleBuilder=sn,f.TextStyleValue=Fr,f.TextX=De,f.TextXActionType=J,f.ThemeColor=Rs,f.ThemeColorType=at,f.ThemeColors=hs,f.ThemeService=ni,f.Tools=Z,f.UndoCommand=fd,f.UndoCommandId=dd,f.UnitModel=as,f.Univer=DI,f.UniverInstanceType=ve,f.UpdateDocsAttributeType=Re,f.UserManagerService=Br,f.VerticalAlign=mn,f.VerticalAlignmentType=sc,f.Worksheet=Vr,f.WrapStrategy=gn,f.WrapTextType=Kl,f.addLinkToDocumentModel=xh,f.afterInitApply=J_,f.afterTime=X_,f.awaitTime=II,f.binSearchFirstGreaterThanTarget=Pc,f.binarySearchArray=Z_,f.bufferDebounceTime=K_,f.cellToRange=NE,f.characterSpacingControlType=uc,f.checkForSubstrings=DE,f.checkIfMove=ep,f.checkParagraphHasBullet=m0,f.checkParagraphHasIndent=g0,f.checkParagraphHasIndentByStyle=Fu,f.cloneCellData=jh,f.cloneCellDataMatrix=Wh,f.cloneCellDataWithSpanAndDisplay=PR,f.cloneValue=gt,f.cloneWorksheetData=Vh,f.codeToBlob=Q_,f.composeBody=Xo,f.composeInterceptors=Na,f.composeStyles=lr,f.concatMatrixArray=CE,f.convertBodyToHtml=tp,f.convertCellToRange=wu,f.convertObservableToBehaviorSubject=q_,f.covertCellValue=Ho,f.covertCellValues=ME,f.covertTextRunToHtml=xi,f.createAsyncInterceptorKey=tf,f.createDefaultUser=ei,f.createDocumentModelWithStyle=Yr,f.createInterceptorKey=Qd,f.createInternalEditorID=Kd,f.createREGEXFromWildChar=M_,f.createRowColIter=Yo,f.customNameCharacterCheck=CI,f.dayjs=Wt,f.debounce=s_,f.dedupe=kd,f.dedupeBy=Fd,f.deepCompare=Bo,f.delayAnimationFrame=SI,f.deleteContent=Hu,f.extractPureTextFromCell=td,f.fromCallback=Lc,f.fromEventSubject=hR,f.generateRandomId=nt,f.get=ul,f.getArrayLength=rn,f.getBodySlice=At,f.getBodySliceHtml=ps,f.getBorderStyleType=yE,f.getCellCoordByIndexSimple=pa,f.getCellInfoInMergeData=Rp,f.getCellPositionByIndexSimple=AI,f.getCellValueType=pp,f.getCellWithCoordByIndexCore=Zn,f.getColorStyle=Ft,f.getCustomBlockSlice=gh,f.getCustomDecorationSlice=ph,f.getCustomRangeSlice=_h,f.getDocsUpdateBody=AE,f.getEmptyCell=DR,f.getIntersectRange=zu,f.getNumfmtParseValueFilter=Ou,f.getOriginCellValue=GR,f.getParagraphsSlice=mh,f.getPlainText=Zs,f.getReverseDirection=D_,f.getSectionBreakSlice=gC,f.getTableSlice=fh,f.getTextRunSlice=Js,f.getTransformOffsetX=Cd,f.getTransformOffsetY=Rd,f.getWorksheetUID=JR,f.groupBy=Bd,f.handleStyleToString=bE,f.hashAlgorithm=p0,f.horizontalLineSegmentsSubtraction=Ws,f.insertMatrixArray=EE,f.insertTextToContent=xu,f.invertColorByHSL=uf,f.invertColorByMatrix=df,f.isBlackColor=gp,f.isBooleanString=Gd,f.isCellCoverable=xo,f.isCellV=$c,f.isCommentEditorID=Xd,f.isDefaultFormat=fE,f.isEmptyCell=vu,f.isFormulaId=vE,f.isFormulaString=bu,f.isICellData=Bc,f.isInternalEditorID=ya,f.isNodeEnv=N_,f.isNotNullOrUndefined=Hh,f.isNullCell=Ep,f.isNumeric=pl,f.isPatternEqualWithoutDecimal=mE,f.isRangesEqual=AR,f.isRealNum=_0,f.isSafeNumeric=d_,f.isSameStyleTextRun=yu,f.isTextFormat=dE,f.isUnitRangesEqual=TR,f.isValidRange=TE,f.isWhiteColor=_p,f.makeArray=$d,f.makeCellRangeToRangeData=wE,f.makeCellToSelection=OE,f.makeCustomRangeStream=TC,f.mapObjectMatrix=pE,f.merge=is,f.mergeLocales=E0,f.mergeOverrideWithDependencies=ld,f.mergeSets=g_,f.mergeWith=l_,f.mergeWorksheetSnapshotWithDefault=Zh,f.mixinClass=h_,f.moveMatrixArray=Fo,f.moveRangeByOffset=x0,f.nameCharacterCheck=EI,f.normalizeBody=_C,f.normalizeTextRuns=Pr,f.numberToABC=J0,f.numberToListABC=Z0,f.numfmt=hE,f.queryObjectMatrix=G0,f.registerDependencies=qd,f.remove=rr,f.repeatStringNumTimes=qu,f.replaceInDocumentBody=aR,f.requestImmediateMacroTask=m_,f.resolveWithBasePath=S_,f.rotate=Hd,f.searchArray=_r,f.searchInOrderedArray=Uc,f.selectionToArray=Cp,f.sequence=Cl,f.sequenceAsync=El,f.sequenceExecute=_s,f.sequenceExecuteAsync=G_,f.set=u_,f.shallowEqual=Ta,f.skipParseTagNames=TI,f.sliceMatrixArray=RE,f.sortRules=Q0,f.sortRulesByDesc=eC,f.sortRulesFactory=Ur,f.spliceArray=ko,f.splitIntoGrid=Wo,f.takeAfter=Fi,f.textDiff=Zo,f.throttle=Zd,f.toDisposable=Ye,f.touchDependencies=Aa,f.updateAttributeByDelete=Eh,f.updateAttributeByInsert=Ch,f.willLoseNumericPrecision=f_,Object.keys(Ce).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(f,e)&&Object.defineProperty(f,e,{enumerable:!0,get:()=>Ce[e]})}),Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}));
|
|
8
|
+
`,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(n){return new Sn(n!=null?n:Sn.newEmptyData())}insertText(n,r,s){var u,h;let i=((h=(u=this._data.body)==null?void 0:u.dataStream.length)!=null?h:2)-2,o,a;if(typeof n=="string"?o=n:(i=Math.min(n,i),o=r),typeof r=="object"?a=r instanceof sn?r.build():r:a=s instanceof sn?s.build():s,!o)return this;const l={dataStream:o,textRuns:a?[{ts:a,st:i,ed:i+o.length}]:[]},c=Qe.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:l});if(!c)throw new Error("Insert text failed, please check.");return De.apply(this._doc.getBody(),c.serialize()),this}insertRichText(n,r){var a,l;let s=((l=(a=this._data.body)==null?void 0:a.dataStream.length)!=null?l:2)-2,i;typeof n=="object"?i=n instanceof an?n.getData():n:(s=Math.min(n,s),i=r instanceof an?r.getData():r);const o=Qe.selection.replace({doc:this._doc,selection:{startOffset:s,endOffset:s,collapsed:!0},body:i.body});if(!o)throw new Error("Insert text failed, please check.");return De.apply(this._doc.getBody(),o.serialize()),this}delete(n,r){if(r!==void 0){if(!r)return this;const s=Qe.selection.delete([{startOffset:n,endOffset:n+r,collapsed:!0}],this._data.body);De.apply(this._doc.getBody(),s)}return this}setStyle(n,r,s){const i={dataStream:"",textRuns:[{ts:s instanceof sn?s.build():s,st:0,ed:r-n}]},o=Qe.selection.retain([{startOffset:n,endOffset:r,collapsed:!0}],i);return De.apply(this._doc.getBody(),o),this}setLink(n,r,s){const i=Qe.customRange.add({rangeType:en.HYPERLINK,rangeId:nt(),properties:{url:s},ranges:[{startOffset:n,endOffset:r,collapsed:!1}],body:this._data.body});if(!i)throw new Error("Insert text failed, please check.");return De.apply(this._doc.getBody(),i.serialize()),this}cancelLink(n,r){if(typeof n=="string"){const s=Qe.customRange.delete({rangeId:n,documentDataModel:this._doc});if(!s)throw new Error("Insert text failed, please check.");De.apply(this._doc.getBody(),s.serialize())}else this.slice(n,r).getLinks().forEach(i=>{const o=Qe.customRange.delete({rangeId:i.rangeId,documentDataModel:this._doc});if(!o)throw new Error("Insert text failed, please check.");De.apply(this._doc.getBody(),o.serialize())});return this}updateLink(n,r){var i,o;const s=(o=(i=this._data.body)==null?void 0:i.customRanges)==null?void 0:o.find(a=>a.rangeId===n);if(!s)throw new Error("Link not found");return s.properties.url=r,this}insertParagraph(n,r){var o,a;let s,i;return typeof n=="object"?(s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:n.build()}]},i=((a=(o=this._data.body)==null?void 0:o.dataStream.length)!=null?a:2)-2):(i=n,s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:r==null?void 0:r.build()}]}),this.insertRichText(i,an.create({body:s,id:"d",documentStyle:{}})),this}insertLink(n,r,s){let i="",o="";typeof n=="string"?(i=n,o=r):(i=r,o=s);const a=Sn.createByBody({dataStream:i,customRanges:[{rangeType:en.HYPERLINK,rangeId:nt(),properties:{url:o},startIndex:0,endIndex:i.length-1}]});return typeof n=="number"?this.insertRichText(n,a):this.insertRichText(a)}}const cR="__default_document_sub_component_id20231101__";class Ah{constructor(){E(this,"skipNextObservers",!1);E(this,"lastReturnValue");E(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class uR extends se.Subject{constructor(){super(...arguments);E(this,"_sortedObservers",[])}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(n){let r;typeof n=="function"?r={next:([i,o])=>n(i,o)}:r=n;const s=super.subscribe(r);return this._sortedObservers.push(r),this._sortedObservers.sort((i,o)=>{var a,l;return((a=i.priority)!=null?a:0)-((l=o.priority)!=null?l:0)}),s.add(()=>this._sortedObservers=this._sortedObservers.filter(i=>i!==r)),s}clearObservers(){this._sortedObservers.forEach(n=>{var r;return(r=n.complete)==null?void 0:r.call(n)}),this._sortedObservers.length=0}emitEvent(n){var r;if(!this.closed){const s=new Ah;s.lastReturnValue=n;for(const i of this._sortedObservers){const o=(r=i.next)==null?void 0:r.call(i,[n,s]);if(s.lastReturnValue=o,s.skipNextObservers)return{handled:!0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}throw new Error("[EventSubject]: cannot emit event on a closed subject.")}}function hR(e){return new se.Observable(t=>{const n=e.subscribeEvent(r=>{t.next(r)});return()=>n.unsubscribe()})}const Qs=Ce.createIdentifier("core.resource-manager.service"),na={[Se.Editor]:"Editor",[Se.Owner]:"Owner",[Se.Reader]:"Reader",[Se.UNRECOGNIZED]:"UNRECOGNIZED"},ei=e=>e?{userID:`${na[e]}_${nt(8)}`,name:na[e],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},dR=(e,t)=>e.startsWith(na[t]);class Br extends Ke{constructor(){super(...arguments);E(this,"_model",new Map);E(this,"_userChange$",new se.Subject);E(this,"userChange$",this._userChange$.asObservable());E(this,"_currentUser$",new se.BehaviorSubject(ei()));E(this,"currentUser$",this._currentUser$.asObservable())}dispose(){super.dispose(),this._model.clear(),this._userChange$.complete(),this._currentUser$.complete()}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(n){this.addUser(n),this._currentUser$.next(n)}addUser(n){this._model.set(n.userID,n),this._userChange$.next({type:"add",user:n})}getUser(n,r){const s=this._model.get(n);if(s)return s;r&&r()}delete(n){const r=this.getUser(n);this._model.delete(n),r&&this._userChange$.next({type:"delete",user:r})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}list(){return Array.from(this._model.values())}}var fR=Object.getOwnPropertyDescriptor,mR=(e,t,n,r)=>{for(var s=r>1?void 0:r?fR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Th=(e,t)=>(n,r)=>t(n,r,e);f.AuthzIoLocalService=class{constructor(t,n){E(this,"_permissionMap",new Map([]));E(this,"_permissionOverrides",new Map);this._resourceManagerService=t,this._userManagerService=n,this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){const t=this._userManagerService.getCurrentUser();t&&t.userID||this._userManagerService.setCurrentUser(ei(Se.Owner))}_getRole(t){const n=this._userManagerService.getCurrentUser();return n?dR(n.userID,t):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:t=>{const n=[...this._permissionMap.keys()].reduce((r,s)=>{const i=this._permissionMap.get(s);return r[s]=i,r},{});return JSON.stringify(n)},parseJson:t=>JSON.parse(t),pluginName:"SHEET_AuthzIoMockService_PLUGIN",businesses:[ve.UNIVER_SHEET,ve.UNIVER_DOC,ve.UNIVER_SLIDE],onLoad:(t,n)=>{for(const r in n)this._permissionMap.set(r,n[r])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(t){const n=nt(8),{objectType:r,selectRangeObject:s,worksheetObject:i}=t,o=s||i,a={objectType:r,unitID:(o==null?void 0:o.unitID)||"",name:(o==null?void 0:o.name)||"",strategies:[{action:6,role:Se.Owner},{action:16,role:Se.Owner},{action:17,role:Se.Owner},{action:18,role:Se.Owner},{action:19,role:Se.Owner},{action:33,role:Se.Owner},{action:34,role:Se.Owner},{action:35,role:Se.Owner},{action:36,role:Se.Owner},{action:37,role:Se.Owner},{action:38,role:Se.Owner},{action:39,role:Se.Owner},{action:40,role:Se.Owner}],selectRangeObject:s};return this._permissionMap.set(n,a),n}async allowed(t){const{objectID:n,actions:r}=t,s=this._permissionMap.get(n);return s?r.map(o=>{const a=`${n}:${o}`;if(this._permissionOverrides.has(a))return{action:o,allowed:this._permissionOverrides.get(a)};const l=s.strategies.find(c=>c.action===o);return l?{action:o,allowed:this._getRole(l.role)}:{action:o,allowed:this._getRole(Se.Owner)||this._getRole(Se.Editor)}}):r.map(a=>({action:a,allowed:this._getRole(Se.Owner)||this._getRole(Se.Editor)}))}async batchAllowed(t){const n=await Promise.all(t.map(s=>this.allowed(s)));return t.map((s,i)=>({unitID:s.unitID,objectID:s.objectID,actions:n[i]}))}async list(t){const n=[],r=[{action:6,role:Se.Owner},{action:16,role:Se.Owner},{action:17,role:Se.Owner},{action:18,role:Se.Owner},{action:19,role:Se.Owner},{action:33,role:Se.Owner},{action:34,role:Se.Owner},{action:35,role:Se.Owner},{action:36,role:Se.Owner},{action:37,role:Se.Owner},{action:38,role:Se.Owner},{action:39,role:Se.Owner},{action:40,role:Se.Owner}];return t.objectIDs.forEach(s=>{const i=this._permissionMap.get(s),o=(i==null?void 0:i.strategies)||r,a={objectID:s,unitID:t.unitID,objectType:(i==null?void 0:i.objectType)||3,name:(i==null?void 0:i.name)||"",shareOn:!1,shareRole:Se.Owner,shareScope:-1,scope:{read:yi.AllCollaborator,edit:yi.AllCollaborator},creator:ei(Se.Owner),strategies:o.map(l=>({action:l.action,role:l.role})),actions:t.actions.map(l=>{const c=`${s}:${l}`;if(this._permissionOverrides.has(c))return{action:l,allowed:this._permissionOverrides.get(c)};const u=o.find(h=>h.action===l);if(!u){const h=this._getRole(Se.Owner)||this._getRole(Se.Editor);return{action:l,allowed:h}}return{action:l,allowed:this._getRole(u.role)}})};n.push(a)}),n}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(t){const{objectID:n,strategies:r}=t,s=this._permissionMap.get(n);s&&r&&(s.strategies=r.map(i=>({action:i.action,role:i.role})),this._permissionMap.set(n,s),r.forEach(i=>{i.role===Se.Reader?this.setPermissionOverride(n,i.action,!1):(i.role===Se.Owner||i.role===Se.Editor)&&this.clearPermissionOverride(n,i.action)}))}setPermissionOverride(t,n,r){const s=`${t}:${n}`;this._permissionOverrides.set(s,r)}clearPermissionOverride(t,n){const r=`${t}:${n}`;this._permissionOverrides.delete(r)}clearAllOverrides(t){const n=[];this._permissionOverrides.forEach((r,s)=>{s.startsWith(`${t}:`)&&n.push(s)}),n.forEach(r=>this._permissionOverrides.delete(r))}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(t){}},f.AuthzIoLocalService=mR([Th(0,Qs),Th(1,Ce.Inject(Br))],f.AuthzIoLocalService);const Nh=Ce.createIdentifier("IAuthzIoIoService"),gR=Ce.createIdentifier("univer.confirm-service");class _R{constructor(){E(this,"confirmOptions$",new se.Subject)}dispose(){this.confirmOptions$.complete()}open(t){throw new Error("This is not implemented in the test service!")}confirm(t){return Promise.resolve(!0)}close(t){throw new Error("This is not implemented in the test service!")}}const $r="FOCUSING_UNIT",qn="FOCUSING_SHEET",jr="FOCUSING_DOC",Wr="FOCUSING_SLIDE",pR="FOCUSING_EDITOR_BUT_HIDDEN",Mh="EDITOR_ACTIVATED",ER="FOCUSING_EDITOR_INPUT_FORMULA",Dh="FOCUSING_FX_BAR_EDITOR",CR="FOCUSING_UNIVER_EDITOR",RR="FOCUSING_EDITOR_INPUT_FORMULA",IR="FOCUSING_COMMENT_EDITOR",SR="FOCUSING_PANEL_EDITOR",OR="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",wR="FOCUSING_COMMON_DRAWINGS",vR="FORMULA_EDITOR_ACTIVATED";class Lh extends Ke{constructor(){super(...arguments);E(this,"_error$",new se.Subject);E(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(n){this._error$.next({errorKey:n})}}var ti=(e=>(e.URL="URL",e.UUID="UUID",e.BASE64="BASE64",e))(ti||{}),Uh=(e=>(e.SUCCUSS="0",e.ERROR_EXCEED_SIZE="1",e.ERROR_IMAGE_TYPE="2",e.ERROR_UPLOAD_COUNT_LIMIT="3",e.ERROR_IMAGE="4",e))(Uh||{});const ra=Ce.createIdentifier("core.image-io.service"),sa=Ce.createIdentifier("core.url-image.service"),bR={version:"0.15.2"};function yR(e="",t=cr.ZH_CN,n=""){return{id:e,sheetOrder:[],name:n,appVersion:bR.version,locale:t,styles:{},sheets:{},resources:[]}}class Ph{constructor(t={}){E(this,"_styles");E(this,"_cacheMap",new Tr(1e5));this._styles=t,this._generateCacheMap()}each(t){return Object.entries(this._styles).forEach(t),this}search(t,n){if(this._cacheMap.has(n))return this._cacheMap.get(n);const r=this._getExistingStyleId(t);return r||"-1"}get(t){return typeof t!="string"?t:(t=String(t),this._styles[t])}add(t,n){const r=nt(6);return this._styles[r]=t,this._cacheMap.set(n,r),r}setValue(t){if(t==null)return;const n=JSON.stringify(t),r=this.search(t,n);return r!=="-1"?r:this.add(t,n)}addCustomStyle(t,n){n!=null&&(this._styles[t]=n,this._cacheMap.set(JSON.stringify(n),t))}remove(t){const n=this._styles[t];n&&(delete this._styles[t],this._cacheMap.delete(JSON.stringify(n)))}toJSON(){return this._styles}getStyleByCell(t){let n;t&&Z.isObject(t.s)?n=t.s:n=(t==null?void 0:t.s)&&this.get(t.s);const r=t==null?void 0:t.interceptorStyle;return r?{...n,...r}:n}_generateCacheMap(){const{_styles:t,_cacheMap:n}=this;for(const r in t){const s=JSON.stringify(t[r]);n.set(s,r)}}_getExistingStyleId(t){const{_styles:n}=this;for(const r in n)if(Z.diffValue(n[r],t))return r;return null}}const AR=(e,t)=>t.length===e.length&&!e.some(n=>t.some(r=>!Yt.equals(r,n))),TR=(e,t)=>t.length===e.length&&e.every((n,r)=>{const s=t[r];return s.unitId===n.unitId&&s.sheetId===n.sheetId&&Yt.equals(n.range,s.range)}),ia={t:0,b:2,l:2,r:2},NR=e=>({sbr:.6,sbo:e,spr:.6,spo:e}),kh=90;function Yr(e,t,n={}){const r=e.length,{textRotation:s,paddingData:i,horizontalAlign:o=bt.UNSPECIFIED,verticalAlign:a=mn.UNSPECIFIED,wrapStrategy:l=gn.UNSPECIFIED,cellValueType:c}=n,{t:u,r:h,b:d,l:m}=i||ia,{vertexAngle:_,centerAngle:p}=$h(s),I={id:"d",body:{dataStream:`${e}${wa}`,textRuns:[{ts:t,st:0,ed:r}],paragraphs:[{startIndex:r,paragraphStyle:{horizontalAlign:o}}],sectionBreaks:[{startIndex:r+1}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},marginTop:u,marginBottom:d,marginRight:h,marginLeft:m,renderConfig:{horizontalAlign:o,verticalAlign:a,centerAngle:p,vertexAngle:_,wrapStrategy:l,cellValueType:c}},drawings:{},drawingsOrder:[]};return new Tt(I)}function MR(e){if(!e)return{};const{tr:t,td:n,ht:r,vt:s,tb:i,pd:o}=e;return{textRotation:t,textDirection:n,horizontalAlign:r,verticalAlign:s,wrapStrategy:i,paddingData:o}}function Fh(e){if(!e)return{};const{ff:t,fs:n,it:r,bl:s,ul:i,st:o,ol:a,cl:l,bg:c}=e,u={};return t&&(u.ff=t),n&&(u.fs=n),r&&(u.it=r),s&&(u.bl=s),i&&(u.ul=i),o&&(u.st=o),a&&(u.ol=a),l&&(u.cl=l),c&&(u.bg=c),u}function xh(e,t,n){var i;const r=e.getBody();if((i=r.customRanges)!=null&&i.some(o=>o.rangeType===en.HYPERLINK))return;const s=Qe.customRange.add({ranges:[{startOffset:0,endOffset:r.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:en.HYPERLINK,body:r,properties:{url:t,refId:n}});s&&De.apply(r,s.serialize())}function Hh(e){return e!=null}function DR(){return{p:null,s:null,v:null,t:null,f:null,si:null,ref:null,xf:null}}const LR='"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif';function Bh(e){const t=it.ff,n=it.fs;if(!e){const h=`${n}pt ${t}`;return{fontCache:h,fontString:h,fontSize:n,originFontSize:n,fontFamily:t}}let r=Ln.ITALIC;(e.it===0||e.it===void 0)&&(r=Ln.NORMAL);let s=Ln.BOLD;(e.bl===0||e.bl===void 0)&&(s=Ln.NORMAL);let i=n;e.fs&&(i=Math.ceil(e.fs));let o=t;if(e.ff){let h=e.ff;h=h.replace(/"/g,"").replace(/'/g,""),h.indexOf(" ")>-1&&(h=`"${h}"`),h==null&&(h=t),o=h}const{va:a}=e;let l=i;if(a===jt.SUBSCRIPT||a===jt.SUPERSCRIPT){const h=UR(o,l),{sbr:d,spr:m}=h;l*=a===jt.SUBSCRIPT?d:m}const c=`${r} ${s} ${l}pt ${o}`,u=`${c}, ${LR} `;return{fontCache:c,fontString:u,fontSize:l,originFontSize:i,fontFamily:o}}function UR(e,t){return NR(t)}function $h(e){const{a:t=0,v:n=ae.FALSE}=e||{a:0,v:ae.FALSE};let r=0,s=t;return n===ae.TRUE&&(r=kh,s=kh),{centerAngle:r,vertexAngle:s}}function gt(e){if(e==null||typeof e!=="object")return e;if(Array.isArray(e)){const s=e.length,i=new Array(s);for(let o=0;o<s;o++)i[o]=gt(e[o]);return i}const n={},r=Object.keys(e);for(let s=0,i=r.length;s<i;s++){const o=r[s];n[o]=gt(e[o])}return n}function jh(e){if(e==null)return e;const t={};return e.p!==void 0&&(t.p=e.p===null?null:gt(e.p)),e.s!==void 0&&(e.s===null||typeof e.s=="string"?t.s=e.s:t.s=gt(e.s)),e.v!==void 0&&(t.v=e.v),e.t!==void 0&&(t.t=e.t),e.f!==void 0&&(t.f=e.f),e.ref!==void 0&&(t.ref=e.ref),e.xf!==void 0&&(t.xf=e.xf),e.si!==void 0&&(t.si=e.si),e.custom!==void 0&&(t.custom=e.custom===null?null:gt(e.custom)),t}function PR(e){if(e==null)return e;const t={};return e.p!==void 0&&(t.p=e.p===null?null:gt(e.p)),e.s!==void 0&&(e.s===null||typeof e.s=="string"?t.s=e.s:t.s=gt(e.s)),e.v!==void 0&&(t.v=e.v),e.t!==void 0&&(t.t=e.t),e.f!==void 0&&(t.f=e.f),e.ref!==void 0&&(t.ref=e.ref),e.xf!==void 0&&(t.xf=e.xf),e.si!==void 0&&(t.si=e.si),e.custom!==void 0&&(t.custom=e.custom===null?null:gt(e.custom)),e.rowSpan!==void 0&&(t.rowSpan=e.rowSpan),e.colSpan!==void 0&&(t.colSpan=e.colSpan),e.displayV!==void 0&&(t.displayV=e.displayV),t}function Wh(e){const t={},n=Object.keys(e);for(let r=0,s=n.length;r<s;r++){const i=n[r],o=Number(i),a=e[o];if(a===void 0)continue;const l={},c=Object.keys(a);for(let u=0,h=c.length;u<h;u++){const d=c[u],m=Number(d),_=a[m];_!=null&&(l[m]=jh(_))}t[o]=l}return t}function Yh(e){const t={},n=Object.keys(e);for(let r=0,s=n.length;r<s;r++){const i=n[r],o=Number(i),a=e[o];if(a===void 0)continue;const l={};"h"in a&&a.h!==void 0&&(l.h=a.h),"ia"in a&&a.ia!==void 0&&(l.ia=a.ia),"ah"in a&&a.ah!==void 0&&(l.ah=a.ah),"hd"in a&&a.hd!==void 0&&(l.hd=a.hd),"w"in a&&a.w!==void 0&&(l.w=a.w),"s"in a&&a.s!==void 0&&(a.s===null||typeof a.s=="string"?l.s=a.s:l.s=gt(a.s)),"custom"in a&&a.custom!==void 0&&(l.custom=a.custom===null?null:gt(a.custom)),t[o]=l}return t}function kR(e){const t=e.length,n=new Array(t);for(let r=0;r<t;r++){const s=e[r];n[r]={startRow:s.startRow,startColumn:s.startColumn,endRow:s.endRow,endColumn:s.endColumn,rangeType:s.rangeType,startAbsoluteRefType:s.startAbsoluteRefType,endAbsoluteRefType:s.endAbsoluteRefType}}return n}function Vh(e){const t={id:e.id,name:e.name,tabColor:e.tabColor,hidden:e.hidden,rowCount:e.rowCount,columnCount:e.columnCount,zoomRatio:e.zoomRatio,scrollTop:e.scrollTop,scrollLeft:e.scrollLeft,defaultColumnWidth:e.defaultColumnWidth,defaultRowHeight:e.defaultRowHeight,showGridlines:e.showGridlines,rightToLeft:e.rightToLeft,freeze:{xSplit:e.freeze.xSplit,ySplit:e.freeze.ySplit,startRow:e.freeze.startRow,startColumn:e.freeze.startColumn},rowHeader:{width:e.rowHeader.width,hidden:e.rowHeader.hidden},columnHeader:{height:e.columnHeader.height,hidden:e.columnHeader.hidden},mergeData:kR(e.mergeData),cellData:Wh(e.cellData),rowData:Yh(e.rowData),columnData:Yh(e.columnData)};return e.gridlinesColor!==void 0&&(t.gridlinesColor=e.gridlinesColor),e.defaultStyle!==void 0&&(e.defaultStyle===null||typeof e.defaultStyle=="string"?t.defaultStyle=e.defaultStyle:t.defaultStyle=gt(e.defaultStyle)),e.custom!==void 0&&(t.custom=e.custom===null?null:gt(e.custom)),t}class FR{constructor(t,n){E(this,"_columnData",{});this._config=t,this._columnData=n}getColumnData(){return this._columnData}getColVisible(t){const{_columnData:n}=this,r=n[t];return r?r.hd!==ae.TRUE:!0}getColumnStyle(t){var n;return(n=this._columnData[t])==null?void 0:n.s}setColumnStyle(t,n){const r=this.getColumnOrCreate(t);r.s=n}getHiddenCols(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getColVisible(o);s&&a?(s=!1,r.push({rangeType:pe.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:pe.COLUMN}),r}getVisibleCols(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getColVisible(o);s&&!a?(s=!1,r.push({rangeType:pe.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:pe.COLUMN}),r}getColumnDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getColumn(i);r[s]=o!=null?o:{w:this._config.defaultColumnWidth,hd:ae.FALSE},s++}return r}getSize(){return rn(this._columnData)}getColumnWidth(t){var n,r;return(r=(n=this._columnData[t])==null?void 0:n.w)!=null?r:this._config.defaultColumnWidth}setColumnWidth(t,n){const r=this._columnData[t];n===this._config.defaultColumnWidth?r&&(delete r.w,Object.keys(r).length===0&&delete this._columnData[t]):this._columnData[t]=r?{...r,w:n}:{w:n}}getColumn(t){return this._columnData[t]}removeColumn(t){delete this._columnData[t]}getColumnOrCreate(t){const{_columnData:n}=this,r=n[t];if(r)return r;const s={};return this._columnData[t]=s,s}setCustomMetadata(t,n){const r=this.getColumn(t);r&&(r.custom=n)}getCustomMetadata(t){var n;return(n=this.getColumn(t))==null?void 0:n.custom}}const xR=2e3;class HR{constructor(t,n,r){E(this,"_rowData");this._config=t,this._viewModel=n,this._rowData=r}getRowData(){return this._rowData}getRowStyle(t){var n;return(n=this._rowData[t])==null?void 0:n.s}setRowStyle(t,n){const r=this.getRowOrCreate(t);r.s=n}getRowDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getRow(i);r[s]=o!=null?o:{h:this._config.defaultRowHeight,hd:ae.FALSE},s++}return r}getRowHeight(t,n=1){const{_rowData:r}=this,s=this._config;let i=0;for(let o=0;o<n;o++){const a=r[o+t]||{hd:ae.FALSE,h:s.defaultRowHeight},{ia:l,ah:c,h:u=s.defaultRowHeight}=a;i+=(l==null||l===ae.TRUE)&&typeof c=="number"?c:u}return i}setRowHeight(t,n){const r=this._rowData[t];if(n===this._config.defaultRowHeight)r&&(delete r.h,Object.keys(r).length===0&&delete this._rowData[t]);else{const s=Math.min(n,xR);this._rowData[t]=r?{...r,h:s}:{h:s}}}getRow(t){return this._rowData[t]}removeRow(t){delete this._rowData[t]}getRowOrCreate(t){const{_rowData:n}=this,r=n[t];if(r)return r;const s={};return n[t]=s,s}getHiddenRows(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getRowRawVisible(o);s&&a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:pe.ROW})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:pe.ROW}),r}getVisibleRows(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getRowRawVisible(o);s&&!a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:pe.ROW})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:pe.ROW}),r}getRowRawVisible(t){const n=this.getRow(t);return n?n.hd!==ae.TRUE:!0}getSize(){return rn(this._rowData)}setCustomMetadata(t,n){const r=this.getRow(t);r&&(r.custom=n)}getCustomMetadata(t){var n;return(n=this.getRow(t))==null?void 0:n.custom}}const BR="DEFAULT_WORKSHEET_ROW_COUNT",zh=1e3,$R="DEFAULT_WORKSHEET_COLUMN_COUNT",Gh=20,jR="DEFAULT_WORKSHEET_ROW_HEIGHT",Kh=24,WR="DEFAULT_WORKSHEET_COLUMN_WIDTH",Xh=88,YR="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",qh=46,VR="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Jh=20;function Zh(e){const t={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:ae.FALSE,rowCount:zh,columnCount:Gh,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:Xh,defaultRowHeight:Kh,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:ae.TRUE,rowHeader:{width:qh,hidden:ae.FALSE},columnHeader:{height:Jh,hidden:ae.FALSE},rightToLeft:ae.FALSE};return Object.keys(t).forEach(n=>{const r=n;typeof e[r]>"u"&&(e[r]=t[r])}),e}class zR extends Ke{constructor(n){super();E(this,"_cellCache",new Map);E(this,"_rowCache",new Map);E(this,"_columnCache",new Map);E(this,"_hasRow",!1);E(this,"_hasColumn",!1);E(this,"_hasAll",!1);E(this,"_allIndex",-1);E(this,"_mergeData");E(this,"_rangeMap",new Tr(5e4));E(this,"_skeletonCache",new Tr(5e4));this._init(n.concat())}_init(n){this._mergeData=n,this._createCache(n)}_clearCache(){this._cellCache.clear(),this._rowCache.clear(),this._columnCache.clear(),this._hasAll=!1,this._allIndex=-1,this._rangeMap.clear(),this._skeletonCache.clear(),this._hasColumn=!1,this._hasRow=!1}_createCache(n){let r=0;for(const s of n){const{rangeType:i}=s;i===pe.ROW?this._createRowCache(s,r):i===pe.COLUMN?this._createColumnCache(s,r):i===pe.ALL?this._createCellAllCache(r):this._createCellCache(s,r),r++}}rebuild(n){this._clearCache(),this._init(n.concat())}_createRowCache(n,r){const{startRow:s,endRow:i}=n;for(let o=s;o<=i;o++)this._rowCache.set(o,r),this._hasRow=!0}_createColumnCache(n,r){const{startColumn:s,endColumn:i}=n;for(let o=s;o<=i;o++)this._columnCache.set(o,r),this._hasColumn=!0}_createCellAllCache(n){this._hasAll=!0,this._allIndex=n}_createCellCache(n,r){for(let s=n.startRow;s<=n.endRow;s++){let i=this._cellCache.get(s);i==null&&(i=new Map,this._cellCache.set(s,i));for(let o=n.startColumn;o<=n.endColumn;o++)i.set(o,r)}}add(n){this._mergeData.push(n),this._clearCache(),this._createCache(this._mergeData)}remove(n,r){const s=this._getMergeDataIndex(n,r);s!==-1&&(this._mergeData.splice(s,1),this._clearCache(),this._createCache(this._mergeData))}getMergedCell(n,r){const s=this._getMergeDataIndex(n,r);return s!==-1?this._mergeData[s]:null}getMergeDataIndex(n,r){return this._getMergeDataIndex(n,r)}isRowContainsMergedCell(n){return this._hasAll||!Z.isEmptyObject(this._columnCache)?!0:this._mergeData.some(r=>r.startRow<=n&&n<=r.endRow)}isColumnContainsMergedCell(n){return this._hasAll||!Z.isEmptyObject(this._rowCache)?!0:this._mergeData.some(r=>r.startColumn<=n&&n<=r.endColumn)}getMergedCellRange(n,r,s,i){const o=[],a=`${n}-${r}-${s}-${i}`;if(this._rangeMap.has(a))return this._getRangeFromCache(a);let l=0;const c=[];for(const u of this._mergeData||[])Yt.intersects(u,{startRow:n,endRow:s,startColumn:r,endColumn:i})&&(o.push({...u}),c.push(l)),l++;return this._rangeMap.set(a,c),o}getMergedCellRangeForSkeleton(n,r,s,i){const o=[],a=this._mergeData,l=`${n}-${r}-${s}-${i}`;if(this._skeletonCache.has(l))return this._getSkeletonRangeFromCache(l);const c=[];for(let u=0;u<a.length;u++){const{startRow:h,endRow:d,startColumn:m,endColumn:_}=a[u];for(let p=n;p<=s;p++){let I=!1;for(let y=r;y<=i;y++)if(p>=h&&p<=d&&y>=m&&y<=_){o.push({startRow:h,endRow:d,startColumn:m,endColumn:_}),c.push(u),I=!0;break}if(I)break}}return this._skeletonCache.set(l,c),o}_getRangeFromCache(n){const r=this._rangeMap.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getSkeletonRangeFromCache(n){const r=this._skeletonCache.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getMergeDataIndex(n,r){var i;if(this._hasAll)return this._allIndex;if(this._hasRow){const o=this._rowCache.get(n);if(o!==void 0)return o}if(this._hasColumn){const o=this._columnCache.get(r);if(o!==void 0)return o}const s=(i=this._cellCache.get(n))==null?void 0:i.get(r);return s!==void 0?s:-1}getMergeDataSnapshot(){return this._mergeData}dispose(){this._clearCache(),this._mergeData=[]}}class Qh extends Ke{constructor(n){super();E(this,"_cellContentInterceptor",null);E(this,"_rowFilteredInterceptor",null);this.getRawCell=n}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(n,r,s,i){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,An.Value|An.Style,s,i):this.getRawCell(n,r)}getCellValueOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,An.Value):this.getRawCell(n,r)}getCellStyleOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,An.Style):this.getRawCell(n,r)}getRowFiltered(n){var r,s;return(s=(r=this._rowFilteredInterceptor)==null?void 0:r.getRowFiltered(n))!=null?s:!1}registerCellContentInterceptor(n){if(this._cellContentInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptor=n,Ye(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(n){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=n,Ye(()=>this._rowFilteredInterceptor=null)}}const ed={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};class Vr{constructor(t,n,r){E(this,"_sheetId");E(this,"_snapshot");E(this,"_cellData");E(this,"_rowManager");E(this,"_columnManager");E(this,"_viewModel");E(this,"_spanModel");E(this,"_isRowStylePrecedeColumnStyle",!0);E(this,"_getCellHeight");var a;this.unitId=t,this._styles=r,this._snapshot=Zh(n);const{columnData:s,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:nt(6),this._cellData=new ct(o),this._viewModel=new Qh((l,c)=>this.getCellRaw(l,c)),this._rowManager=new HR(this._snapshot,this._viewModel,i),this._columnManager=new FR(this._snapshot,s),this._spanModel=new zR(this._snapshot.mergeData)}__interceptViewModel(t){t(this._viewModel)}__registerGetCellHeight(t){return this._getCellHeight=t,Ye(()=>{this._getCellHeight=null})}getSnapshot(){return this._snapshot}getCellHeight(t,n){return this._getCellHeight?this._getCellHeight(t,n):this._snapshot.defaultRowHeight}setMergeData(t){this._snapshot.mergeData=t,this.getSpanModel().rebuild(t)}getSpanModel(){return this._spanModel}setIsRowStylePrecedeColumnStyle(t){this._isRowStylePrecedeColumnStyle=t}getStyleDataByHash(t){return{...this._styles.get(t)}}setStyleData(t){return this._styles.setValue(t)}getColumnStyle(t,n=!1){return n?this._columnManager.getColumnStyle(t):this._styles.get(this._columnManager.getColumnStyle(t))}setColumnStyle(t,n){this._columnManager.setColumnStyle(t,n)}getRowStyle(t,n=!1){return n?this._rowManager.getRowStyle(t):this._styles.get(this._rowManager.getRowStyle(t))}setRowStyle(t,n){this._rowManager.setRowStyle(t,n)}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){const t=this._snapshot.defaultStyle;return this._styles.get(t)}setDefaultCellStyle(t){this._snapshot.defaultStyle=t}getCellStyle(t,n){const r=this.getCell(t,n);if(r){const s=r.s;return typeof s=="string"?this._styles.get(s):s}return null}getComposedCellStyle(t,n,r){const s=this.getDefaultCellStyleInternal(),i=this.getRowStyle(t),o=this.getColumnStyle(n),a=this.getCell(t,n),l=this._styles.getStyleByCell(a);return(r!=null?r:this._isRowStylePrecedeColumnStyle)?lr(s,o,i,a==null?void 0:a.themeStyle,l):lr(s,i,o,a==null?void 0:a.themeStyle,l)}getComposedCellStyleByCellData(t,n,r,s){const i=this.getDefaultCellStyleInternal(),o=this.getRowStyle(t),a=this.getColumnStyle(n),l=this._styles.getStyleByCell(r);return(s!=null?s:this._isRowStylePrecedeColumnStyle)?lr(i,a,o,r==null?void 0:r.themeStyle,l):lr(i,o,a,r==null?void 0:r.themeStyle,l)}getComposedCellStyleWithoutSelf(t,n,r,s){const i=r===void 0?this.getComposedCellStyle(t,n,s):this.getComposedCellStyleByCellData(t,n,r,s),o=this.getCellRaw(t,n);if(!o||!o.s)return i;const a=typeof o.s=="string"?this._styles.get(o.s):o.s;if(!a)return i;for(const l in a)l in i&&delete i[l];return i}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const t=this.getCellMatrix(),n=this.getMergeData();let r=-1,s=-1,i=-1,o=-1,a=!1,l=!1;return t.forEach((c,u)=>{Object.keys(u).forEach(h=>{const d=+h,m=t.getValue(c,d),_=m!=null&&m.s?this._styles.get(m.s):null,p=(_==null?void 0:_.bd)&&(_.bd.b||_.bd.l||_.bd.r||_.bd.t||_.bd.bc_tr||_.bd.bl_tr||_.bd.ml_tr||_.bd.tl_bc||_.bd.tl_br||_.bd.tl_mr);(m&&(m.v!==null&&m.v!==void 0&&m.v!==""||m.p)||_!=null&&_.bg||p)&&(a?r=Math.min(r,c):(r=c,a=!0),s=Math.max(s,c),l?i=Math.min(i,d):(l=!0,i=d),o=Math.max(o,d))})}),n.forEach(c=>{a?r=Math.min(r,c.startRow):(r=c.startRow,a=!0),s=Math.max(s,c.endRow),l?i=Math.min(i,c.startColumn):(i=c.startColumn,a=!0),o=Math.max(o,c.endColumn)}),!a||!l?null:{startColumn:i,startRow:r,endColumn:o,endRow:s}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:t}=this,n=Vh(t);return new Vr(this.unitId,n,this._styles)}getMergeData(){return this._spanModel.getMergeDataSnapshot()}getMergedCell(t,n){return this._spanModel.getMergedCell(t,n)}getMergedCellRange(t,n,r,s){return this._spanModel.getMergedCellRange(t,n,r,s)}isRowContainsMergedCell(t){return this._spanModel.isRowContainsMergedCell(t)}isColumnContainsMergedCell(t){return this._spanModel.isColumnContainsMergedCell(t)}getCellInfoInMergeData(t,n){const r=this.getMergedCell(t,n);let s=!1,i=!1,o=t,a=n,l=t,c=n;if(r){const{startRow:u,endRow:h,startColumn:d,endColumn:m}=r;t===u&&n===d?(o=h,a=m,l=u,c=d,i=!0):t>=u&&t<=h&&n>=d&&n<=m&&(o=h,a=m,l=u,c=d,s=!0)}return{actualRow:t,actualColumn:n,isMergedMainCell:i,isMerged:s,endRow:o,endColumn:a,startRow:l,startColumn:c}}getCell(t,n){return t<0||n<0?null:this._viewModel.getCell(t,n)}getCellValueOnly(t,n){return t<0||n<0?null:this._viewModel.getCellValueOnly(t,n)}getCellStyleOnly(t,n){return t<0||n<0?null:this._viewModel.getCellStyleOnly(t,n)}getCellRaw(t,n){return this.getCellMatrix().getValue(t,n)}getCellWithFilteredInterceptors(t,n,r,s){return this._viewModel.getCell(t,n,r,s)}getRowFiltered(t){return this._viewModel.getRowFiltered(t)}getRangeFilterRows(t){const n=[];for(let r=t.startRow;r<=t.endRow;r++)this.getRowFiltered(r)&&n.push(r);return n}getMatrixWithMergedCells(t,n,r,s,i=Pn.Raw){const o=this.getCellMatrix(),a=this._spanModel.getMergedCellRange(t,n,r,s),l=new ct;return Yo(t,r,n,s).forEach((c,u)=>{var d;let h;if(i===Pn.Raw)h=this.getCellRaw(c,u);else if(i===Pn.Intercepted)h=this.getCell(c,u);else if(i===Pn.Both){const m=this.getCellRaw(c,u);if(m){h={...m};const _=(d=this.getCell(c,u))==null?void 0:d.v;Hh(_)&&h&&(h.displayV=String(_))}}h&&l.setValue(c,u,h)}),a.forEach(c=>{const{startColumn:u,startRow:h,endColumn:d,endRow:m}=c;Yo(h,m,u,d).forEach((_,p)=>{_===h&&p===u&&l.setValue(_,p,{...o.getValue(_,p),rowSpan:m-h+1,colSpan:d-u+1}),(_!==h||p!==u)&&l.realDeleteValue(_,p)})}),l}getRange(t,n,r,s){return typeof t=="object"?new Yn(this,t,{getStyles:()=>this._styles}):new Yn(this,{startRow:t,startColumn:n,endColumn:s||n,endRow:r||t},{getStyles:()=>this._styles})}getScrollLeftTopFromSnapshot(){return{scrollLeft:this._snapshot.scrollLeft,scrollTop:this._snapshot.scrollTop}}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){const{_snapshot:t}=this,{columnCount:n}=t;return n}getMaxRows(){const{_snapshot:t}=this,{rowCount:n}=t;return n}getRowCount(){return this._snapshot.rowCount}setRowCount(t){this._snapshot.rowCount=t}getColumnCount(){return this._snapshot.columnCount}setColumnCount(t){this._snapshot.columnCount=t}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:t}=this,{showGridlines:n}=t;return n===0}getGridlinesColor(){return this.getConfig().gridlinesColor}getTabColor(){const{_snapshot:t}=this,{tabColor:n}=t;return n}getColumnWidth(t){return this.getColumnManager().getColumnWidth(t)}getRowHeight(t){return this._viewModel.getRowFiltered(t)?0:this.getRowManager().getRowHeight(t)}isRowFiltered(t){return this._viewModel.getRowFiltered(t)}getRowVisible(t){return!this.isRowFiltered(t)&&this.getRowRawVisible(t)}getRowRawVisible(t){return this.getRowManager().getRowRawVisible(t)}getHiddenRows(t,n){const r=this.getMaxColumns()-1,s=this._rowManager.getHiddenRows(t,n);return s.forEach(i=>i.endColumn=r),s}getColVisible(t){return this._columnManager.getColVisible(t)}getHiddenCols(t,n){const r=this.getMaxRows()-1,s=this._columnManager.getHiddenCols(t,n);return s.forEach(i=>i.endRow=r),s}getVisibleRows(){const t=this.getRowCount();return this._rowManager.getVisibleRows(0,t-1)}getVisibleCols(){const t=this.getColumnCount();return this._columnManager.getVisibleCols(0,t-1)}isRightToLeft(){const{_snapshot:t}=this,{rightToLeft:n}=t;return n}getLastRowWithContent(){return this._cellData.getRealRowRange().endRow}getLastColumnWithContent(){return this.getDataRealRange().endColumn}getDataRealRange(){return this._cellData.getRealRange()}getDataRangeScope(){return this._cellData.getStartEndScope()}cellHasValue(t){return t&&(t.v!==void 0||t.f!==void 0||t.p!==void 0)}iterateByRow(t,n=!0){const{startRow:r,startColumn:s,endRow:i,endColumn:o}=t,a=this;return{[Symbol.iterator]:()=>{let l=r,c=s;return{next(){for(;;){if(c>o&&(l+=1,c=s),l>i)return{done:!0,value:void 0};const u=a.getCell(l,c),h=!u,d=a.getMergedCell(l,c);if(d){if(l!==d.startRow||c!==d.startColumn){c=d.endColumn+1;continue}if(h&&n){c=d.endColumn+1;continue}const _={row:l,col:c,value:u};return _.colSpan=d.endColumn-d.startColumn+1,_.rowSpan=d.endRow-d.startRow+1,c=d.endColumn+1,{done:!1,value:_}}if(h&&n)c+=1;else{const m={row:l,col:c,value:u};return c+=1,{done:!1,value:m}}}}}}}}iterateByColumn(t,n=!0,r=!0){const{startRow:s,startColumn:i,endRow:o,endColumn:a}=t,l=this;return{[Symbol.iterator]:()=>{let c=s,u=i;return{next(){for(;;){if(c>o&&(u+=1,c=s),u>a)return{done:!0,value:void 0};const h=l.getMergedCell(c,u);if(h){const _=c!==h.startRow,p=_||u!==h.startColumn;if(r&&p||!r&&_){c=h.endRow+1;continue}const I=l.getCell(h.startRow,h.startColumn);if(!I&&n){c=h.endRow+1;continue}const H={row:c,col:h.startColumn,value:I};return H.colSpan=h.endColumn-h.startColumn+1,H.rowSpan=h.endRow-h.startRow+1,c=h.endRow+1,{done:!1,value:H}}const d=l.getCell(c,u);if(!d&&n)c+=1;else{const _={row:c,col:u,value:d};return c+=1,{done:!1,value:_}}}}}}}}getCellDocumentModel(t,n,r=ed){var p;if(!t)return;const{isDeepClone:s,displayRawFormula:i,ignoreTextRotation:o}={...ed,...r};let a,l="document";const c=MR(n),u=o?it.tr:c.textRotation||it.tr;let h=c.horizontalAlign||it.ht;const d=c.verticalAlign||it.vt,m=c.wrapStrategy||it.tb,_=c.paddingData||ia;if(t.f&&i)a=Yr(t.f.toString(),{},{verticalAlign:d}),h=it.ht;else if(t.p){const{centerAngle:I,vertexAngle:y}=$h(u);a=this._updateConfigAndGetDocumentModel(s?Z.deepClone(t.p):t.p,h,_,{horizontalAlign:h,verticalAlign:d,centerAngle:I,vertexAngle:y,wrapStrategy:m,zeroWidthParagraphBreak:1})}else if(t.v!=null){const I=Fh(n);l=Bh(I).fontCache;let y=td(t);t.t===Qt.FORCE_STRING&&i&&(y=`'${y}`),a=Yr(y,I,{...c,textRotation:u,cellValueType:t.t})}return a&&t.linkUrl&&t.linkId&&xh(a,t.linkUrl,t.linkId),{documentModel:a,fontString:l,textRotation:u,wrapStrategy:m,verticalAlign:d,horizontalAlign:h,paddingData:_,fill:(p=n==null?void 0:n.bg)==null?void 0:p.rgb}}_updateConfigAndGetDocumentModel(t,n,r,s){var o,a,l,c,u;if(!s||!((o=t.body)!=null&&o.dataStream))return;t.documentStyle||(t.documentStyle={}),t.documentStyle.marginTop=(a=r.t)!=null?a:0,t.documentStyle.marginBottom=(l=r.b)!=null?l:2,t.documentStyle.marginLeft=(c=r.l)!=null?c:2,t.documentStyle.marginRight=(u=r.r)!=null?u:2,t.documentStyle.pageSize={width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},t.documentStyle.renderConfig={...t.documentStyle.renderConfig,...s};const i=t.body.paragraphs||[];for(const h of i)h.paragraphStyle||(h.paragraphStyle={}),h.paragraphStyle.horizontalAlign=n;return new Tt(t)}getBlankCellDocumentModel(t,n,r){const s=this.getComposedCellStyleByCellData(n,r,t),i=Fh(s),o=this.getCellDocumentModel(t,s,{ignoreTextRotation:!0});if(o!=null)return o.documentModel==null&&(o.documentModel=Yr("",i)),o;const a="";let l="document";const c=it.tr,u=it.ht,h=it.vt,d=it.tb,m=ia;return l=Bh({}).fontCache,{documentModel:Yr(a,i),fontString:l,textRotation:c,wrapStrategy:d,verticalAlign:h,horizontalAlign:u,paddingData:m}}getCellDocumentModelWithFormula(t,n,r){const s=this.getComposedCellStyleByCellData(n,r,t);return this.getCellDocumentModel(t,s,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(t){this._snapshot.custom=t}}function td(e){var r,s;if(!e)return"";const t=(s=(r=e.p)==null?void 0:r.body)==null?void 0:s.dataStream;if(t)return Qe.transform.getPlainText(t);const n=e.v;return typeof n=="string"?e.t===Qt.BOOLEAN?n.toUpperCase():n.replace(/[\r\n]/g,""):typeof n=="number"?e.t===Qt.BOOLEAN?n?"TRUE":"FALSE":n.toString():typeof n=="boolean"?n?"TRUE":"FALSE":""}function GR(e){if(e===null)return"";if(e!=null&&e.p){const t=e==null?void 0:e.p.body;if(t==null)return"";const n=t.dataStream;return Qe.transform.getPlainText(n)}return e==null?void 0:e.v}var KR=Object.getOwnPropertyDescriptor,XR=(e,t,n,r)=>{for(var s=r>1?void 0:r?KR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},qR=(e,t)=>(n,r)=>t(n,r,e);function JR(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}f.Workbook=class extends as{constructor(n={},r){super();E(this,"type",ve.UNIVER_SHEET);E(this,"_sheetCreated$",new se.Subject);E(this,"sheetCreated$",this._sheetCreated$.asObservable());E(this,"_sheetDisposed$",new se.Subject);E(this,"sheetDisposed$",this._sheetDisposed$.asObservable());E(this,"_activeSheet$",new se.BehaviorSubject(null));E(this,"activeSheet$",this._activeSheet$.asObservable());E(this,"_worksheets");E(this,"_styles");E(this,"_snapshot");E(this,"_unitId");E(this,"_count");E(this,"_name$");E(this,"name$");this._logService=r;const s=yR();Z.isEmptyObject(n)?this._snapshot=s:this._snapshot=Z.commonExtend(s,n);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=nt(6)),this._unitId=this._snapshot.id,this._styles=new Ph(i),this._count=1,this._worksheets=new Map,this._name$=new se.BehaviorSubject(n.name||""),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}static isIRangeType(n){return typeof n=="string"||"startRow"in n||"row"in n}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete(),Array.from(this._worksheets.keys()).forEach(r=>{this._removeSheet(r)})}save(){return Z.deepClone(this._snapshot)}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(n){this._name$.next(n),this._snapshot.name=n}getUnitId(){return this._unitId}getRev(){var n;return(n=this._snapshot.rev)!=null?n:1}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(n){this._snapshot.rev=n}addWorksheet(n,r,s){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[n])return!1;i[n]=s,o.splice(r,0,n),this.ensureSheetOrderUnique();const a=new Vr(this._unitId,s,this._styles);return this._worksheets.set(n,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}ensureSheetOrderUnique(){const n=new Set,r=[];for(const s of this._snapshot.sheetOrder)n.has(s)||(n.add(s),r.push(s));this._snapshot.sheetOrder=r,n.clear()}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}addStyles(n){Object.entries(n).forEach(([r,s])=>{this._styles.addCustomStyle(r,s)})}removeStyles(n){n.forEach(r=>{this._styles.remove(r)})}getConfig(){return this._snapshot}getIndexBySheetId(n){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>s===n)}getActiveSheet(n){if(!this._activeSheet&&typeof n>"u")throw new Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){const n=this._activeSheet;if(n)return n;const r=this._snapshot.sheetOrder;for(let i=0,o=r.length;i<o;i++){const a=this._worksheets.get(r[i]);if(a&&a.isSheetHidden()!==ae.TRUE)return this.setActiveSheet(a),a}const s=this._worksheets.get(r[0]);return this.setActiveSheet(s),s}setActiveSheet(n){this._activeSheet$.next(n)}_removeSheet(n){const r=this._worksheets.get(n);return r?(this._worksheets.delete(n),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(n),1),this.ensureSheetOrderUnique(),this._sheetDisposed$.next(r),!0):!1}removeSheet(n){const r=this._removeSheet(n);return r&&delete this._snapshot.sheets[n],r}getActiveSheetIndex(){const{sheetOrder:n}=this._snapshot;return n.findIndex(r=>this._worksheets.get(r)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:n}=this._snapshot;return n.map(r=>this._worksheets.get(r))}getSheetsName(){const{sheetOrder:n}=this._snapshot,r=[];return n.forEach(s=>{const i=this._worksheets.get(s);i&&r.push(i.getName())}),r}getSheetIndex(n){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>n.getSheetId()===s)}getSheetBySheetName(n){const{sheetOrder:r}=this._snapshot,s=r.find(i=>this._worksheets.get(i).getName()===n);return this._worksheets.get(s)}getSheetBySheetId(n){return this._worksheets.get(n)}getSheetByIndex(n){const{sheetOrder:r}=this._snapshot;return this._worksheets.get(r[n])}getHiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden===ae.TRUE).map(n=>n.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden!==ae.TRUE).map(n=>n.getConfig().id)}load(n){this._snapshot=n}checkSheetName(n){return this.getSheetsName().some(s=>s.toLowerCase()===n.toLowerCase())}uniqueSheetName(n="Sheet1"){let r=n;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}generateNewSheetName(n){let r=n+this._count;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}_parseWorksheetSnapshots(){const{_snapshot:n,_worksheets:r}=this,{sheets:s,sheetOrder:i}=n;if(Z.isEmptyObject(s)){const o=nt();s[o]={id:o}}for(const o in s){const a=s[o],{name:l}=a;a.name=this.uniqueSheetName(l),a.name!==l&&this._logService.debug("[Workbook]",`The worksheet name ${l} is duplicated, we changed it to ${a.name}. Please fix the problem in your snapshot.`);const c=new Vr(this._unitId,a,this._styles);r.set(o,c),i.includes(o)||i.push(o)}this.ensureSheetOrderUnique(),this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(n){this._snapshot.custom=n}},f.Workbook=XR([qR(1,dt)],f.Workbook);class oa extends as{constructor(n){var r;super();E(this,"type",ve.UNIVER_SLIDE);E(this,"_activePage$",new se.BehaviorSubject(null));E(this,"activePage$",this._activePage$.asObservable());E(this,"_name$");E(this,"name$");E(this,"_snapshot");E(this,"_unitId");this._snapshot={...$u,...n},this._unitId=(r=this._snapshot.id)!=null?r:nt(6),this._name$=new se.BehaviorSubject(this._snapshot.title),this.name$=this._name$.asObservable()}get _activePage(){var r,s;const n=this._activePage$.getValue();if(!n){const i=(r=this.getPageOrder())==null?void 0:r[0];return i?(s=this.getPages())==null?void 0:s[i]:null}return n}setName(n){var r;this._snapshot.title=n,this._name$.next(n),this._unitId=(r=this._snapshot.id)!=null?r:nt(6)}getRev(){return 0}incrementRev(){}setRev(n){}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var n;return(n=this._snapshot.body)==null?void 0:n.pages}getPageOrder(){var n;return(n=this._snapshot.body)==null?void 0:n.pageOrder}getPage(n){const r=this.getPages();return r==null?void 0:r[n]}getElementsByPage(n){var r;return(r=this.getPage(n))==null?void 0:r.pageElements}getElement(n,r){var s;return(s=this.getElementsByPage(n))==null?void 0:s[r]}getPageSize(){return this._snapshot.pageSize}getBlankPage(){const n=nt(6);return{id:n,pageType:Ni.SLIDE,zIndex:10,title:n,description:"",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}setActivePage(n){this._activePage$.next(n)}getActivePage(){return this._activePage}updatePage(n,r){this._snapshot.body&&(this._snapshot.body.pages[n]=r)}appendPage(n){var i;if(!this._snapshot.body)return;this._snapshot.body.pages[n.id]=n;const r=this._activePage,s=this._snapshot.body.pageOrder.indexOf((i=r==null?void 0:r.id)!=null?i:"");this._snapshot.body.pageOrder.splice(s+1,0,n.id)}}var ZR=Object.getOwnPropertyDescriptor,QR=(e,t,n,r)=>{for(var s=r>1?void 0:r?ZR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},aa=(e,t)=>(n,r)=>t(n,r,e);const Jn=Ce.createIdentifier("univer.current");f.UniverInstanceService=class extends Ke{constructor(n,r,s){super();E(this,"_unitsByType",new Map);E(this,"_createHandler");E(this,"_ctorByType",new Map);E(this,"_currentUnits",new Map);E(this,"_currentUnits$",new se.BehaviorSubject(this._currentUnits));E(this,"currentUnits$",this._currentUnits$.asObservable());E(this,"_unitAdded$",new se.Subject);E(this,"unitAdded$",this._unitAdded$.asObservable());E(this,"_unitDisposed$",new se.Subject);E(this,"unitDisposed$",this._unitDisposed$.asObservable());E(this,"_focused$",new se.BehaviorSubject(null));E(this,"focused$",this._focused$.asObservable());this._injector=n,this._contextService=r,this._logService=s}dispose(){super.dispose(),this._focused$.complete(),this._currentUnits$.complete(),this._unitAdded$.complete(),this._currentUnits.forEach(n=>n==null?void 0:n.dispose()),this._currentUnits.clear(),this._unitsByType.clear()}__setCreateHandler(n){this._createHandler=n}createUnit(n,r,s){return this._createHandler(n,r,this._ctorByType.get(n),s)}registerCtorForType(n,r){return this._ctorByType.set(n,r),{dispose:()=>{this._ctorByType.delete(n)}}}getCurrentTypeOfUnit$(n){return this.currentUnits$.pipe(se.map(r=>{var s;return(s=r.get(n))!=null?s:null}),se.distinctUntilChanged())}getCurrentUnitForType(n){return this._currentUnits.get(n)}getCurrentUnitOfType(n){return this.getCurrentUnitForType(n)}setCurrentUnitForType(n){const r=this._getUnitById(n);if(!r)throw new Error(`[UniverInstanceService]: no document with unitId ${n}!`);this._currentUnits.set(r[1],r[0]),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(n){return this._unitAdded$.pipe(se.filter(r=>r.type===n))}__addUnit(n,r){var a;this._logService.debug(`[UniverInstanceService]: Adding unit with id ${n.getUnitId()}`);const s=n.type;this._unitsByType.has(s)||this._unitsByType.set(s,[]);const i=this._unitsByType.get(s),o=n.getUnitId();if(i.findIndex(l=>l.getUnitId()===o)!==-1)throw new Error(`[UniverInstanceService]: cannot create a unit with the same unit id: ${o}.`);i.push(n),this._unitAdded$.next(n),((a=r==null?void 0:r.makeCurrent)==null||a)&&this.setCurrentUnitForType(n.getUnitId())}getTypeOfUnitDisposed$(n){return this.unitDisposed$.pipe(se.filter(r=>r.type===n))}getUnit(n,r){var i;const s=(i=this._getUnitById(n))==null?void 0:i[0];return r&&(s==null?void 0:s.type)!==r?null:s}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(ve.UNIVER_DOC)}getUniverDocInstance(n){return this.getUnit(n,ve.UNIVER_DOC)}getUniverSheetInstance(n){return this.getUnit(n,ve.UNIVER_SHEET)}getAllUnitsForType(n){var r;return(r=this._unitsByType.get(n))!=null?r:[]}changeDoc(n,r){const s=this.getAllUnitsForType(ve.UNIVER_DOC),i=s.find(o=>o.getUnitId()===n);if(i!=null){const o=s.indexOf(i);s.splice(o,1)}this.__addUnit(r)}get focused(){var r;const n=this._focused$.getValue();return n?(r=this._getUnitById(n))==null?void 0:r[0]:null}focusUnit(n){this._focused$.next(n),this.focused instanceof f.Workbook?(this._contextService.setContextValue($r,!0),this._contextService.setContextValue(jr,!1),this._contextService.setContextValue(qn,!0),this._contextService.setContextValue(Wr,!1),this.setCurrentUnitForType(n)):this.focused instanceof Tt?(this._contextService.setContextValue($r,!0),this._contextService.setContextValue(jr,!0),this._contextService.setContextValue(qn,!1),this._contextService.setContextValue(Wr,!1),this.setCurrentUnitForType(n)):this.focused instanceof oa?(this._contextService.setContextValue($r,!0),this._contextService.setContextValue(jr,!1),this._contextService.setContextValue(qn,!1),this._contextService.setContextValue(Wr,!0),this.setCurrentUnitForType(n)):(this._contextService.setContextValue($r,!1),this._contextService.setContextValue(jr,!1),this._contextService.setContextValue(qn,!1),this._contextService.setContextValue(Wr,!1))}getFocusedUnit(){return this.focused}getUnitType(n){const r=this._getUnitById(n);return r?r[1]:ve.UNRECOGNIZED}disposeUnit(n){this._logService.debug(`[UniverInstanceService]: Disposing unit with id ${n}`);const r=this._getUnitById(n);if(!r)return this._logService.debug(`[UniverInstanceService]: No unit found with id ${n}`),!1;const[s,i]=r,o=this._unitsByType.get(i),a=o.indexOf(s);return o.splice(a,1),this._tryResetCurrentOnRemoval(n,i),this._tryResetFocusOnRemoval(n),this._unitDisposed$.next(s),s.dispose(),!0}_tryResetCurrentOnRemoval(n,r){const s=this.getCurrentUnitForType(r);(s==null?void 0:s.getUnitId())===n&&(this._currentUnits.set(r,null),this._currentUnits$.next(this._currentUnits))}_tryResetFocusOnRemoval(n){var r;((r=this.focused)==null?void 0:r.getUnitId())===n&&this._focused$.next(null)}_getUnitById(n){for(const[r,s]of this._unitsByType){const i=s.find(o=>o.getUnitId()===n);if(i)return[i,r]}}},f.UniverInstanceService=QR([aa(0,Ce.Inject(Ce.Injector)),aa(1,Un),aa(2,Ce.Inject(dt))],f.UniverInstanceService);var Fe=(e=>(e[e.Starting=0]="Starting",e[e.Ready=1]="Ready",e[e.Rendered=2]="Rendered",e[e.Steady=3]="Steady",e))(Fe||{});const nd={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"};var eI=Object.getOwnPropertyDescriptor,tI=(e,t,n,r)=>{for(var s=r>1?void 0:r?eI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},nI=(e,t)=>(n,r)=>t(n,r,e);class rd extends Error{constructor(t){super(`[LifecycleService]: lifecycle stage "${nd[t]}" will never be reached!`),this.name="LifecycleUnreachableError"}}f.LifecycleService=class extends Ke{constructor(n){super();E(this,"_lifecycle$",new se.BehaviorSubject(Fe.Starting));E(this,"lifecycle$",this._lifecycle$.asObservable());E(this,"_lock",!1);this._logService=n,this._reportProgress(Fe.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(n){if(this._lock)throw new Error("[LifecycleService]: cannot set new stage when related logic is all handled!");if(n<this.stage)throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");n!==this.stage&&(this._lock=!0,this._reportProgress(n),this._lifecycle$.next(n),this._lock=!1)}dispose(){this._lifecycle$.complete(),super.dispose()}onStage(n){return se.firstValueFrom(this.lifecycle$.pipe(se.filter(r=>r>=n),Fi(r=>r===n),se.map(()=>{}))).catch(r=>r.name==="EmptyError"?Promise.reject(new rd(n)):Promise.reject(r))}subscribeWithPrevious(){return se.merge(sd(this.stage),this._lifecycle$.pipe(se.skip(1))).pipe(Fi(n=>n===Fe.Steady))}_reportProgress(n){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${nd[n]}".`)}},f.LifecycleService=tI([nI(0,dt)],f.LifecycleService);function sd(e){switch(e){case Fe.Starting:return se.of(Fe.Starting);case Fe.Ready:return se.of(Fe.Starting,Fe.Ready);case Fe.Rendered:return se.of(Fe.Starting,Fe.Ready,Fe.Rendered);default:return se.of(Fe.Starting,Fe.Ready,Fe.Rendered,Fe.Steady)}}const rI=Ce.createIdentifier("ILocalStorageService");class On extends Ke{constructor(){super();E(this,"_currentLocale$",new se.BehaviorSubject(cr.ZH_CN));E(this,"currentLocale$",this._currentLocale$.asObservable());E(this,"_locales",null);E(this,"localeChanged$",new se.Subject);E(this,"t",(n,...r)=>{if(!this._locales)throw new Error("[LocaleService]: Locale not initialized");const s=n.split("."),i=this.resolveKeyPath(this._locales[this._currentLocale],s);if(typeof i=="string"){let o=i;return r.forEach((a,l)=>{o=o.replace(`{${l}}`,a)}),o}else return n});this.disposeWithMe(Ye(()=>{this._locales=null,this._currentLocale$.complete(),this.localeChanged$.complete()}))}get _currentLocale(){return this._currentLocale$.value}load(n){var r;this._locales=is((r=this._locales)!=null?r:{},n)}setLocale(n){this._currentLocale$.next(n),this.localeChanged$.next()}getLocales(){var n;return(n=this._locales)==null?void 0:n[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(n,r){const s=r.shift();if(s&&n&&s in n){const i=n[s];return r.length>0&&(typeof i=="object"||Array.isArray(i))?this.resolveKeyPath(i,r):i}return null}}var sI=Object.getOwnPropertyDescriptor,iI=(e,t,n,r)=>{for(var s=r>1?void 0:r?sI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},oI=(e,t)=>(n,r)=>t(n,r,e);f.MentionIOLocalService=class{constructor(t){this._userManagerService=t}async list(t){return{list:[{type:ls.PERSON,mentions:[{objectType:ls.PERSON,objectId:this._userManagerService.getCurrentUser().userID,label:this._userManagerService.getCurrentUser().name,metadata:{icon:this._userManagerService.getCurrentUser().avatar}}],metadata:{},title:"PEOPLE"}],page:t.page,size:t.size,total:1}}},f.MentionIOLocalService=iI([oI(0,Ce.Inject(Br))],f.MentionIOLocalService);const id=Ce.createIdentifier("univer.service.mention-io");var la=(e=>(e.INIT="init",e.FETCHING="fetching",e.DONE="done",e))(la||{});const od=Ce.createIdentifier("univer.permission-service");class ad extends Ke{constructor(){super(...arguments);E(this,"_permissionPointMap",new Map);E(this,"_permissionPointUpdate$",new se.Subject);E(this,"permissionPointUpdate$",this._permissionPointUpdate$.asObservable());E(this,"_showComponents",!0)}setShowComponents(n){this._showComponents=n}getShowComponents(){return this._showComponents}deletePermissionPoint(n){const r=this._permissionPointMap.get(n);r&&(r.complete(),this._permissionPointMap.delete(n))}addPermissionPoint(n){const r=n instanceof se.BehaviorSubject,s=r?n.getValue():n;return s.id?this._permissionPointMap.get(s.id)?(console.warn(`${s.id} PermissionPoint already exists`),!1):(this._permissionPointMap.set(s.id,r?n:new se.BehaviorSubject(s)),this._permissionPointUpdate$.next(s),!0):!1}updatePermissionPoint(n,r){const s=this._permissionPointMap.get(n);if(!s)return;const i=s.getValue();i.value=r,i.status=la.DONE,s.next(i),this._permissionPointUpdate$.next(i)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(n){const r=this._permissionPointMap.get(n);if(r)return r.getValue()}getPermissionPoint$(n){const r=this._permissionPointMap.get(n);if(r)return r}composePermission$(n){const r=n.map(s=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(s);if(!i)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return i.asObservable()});return se.combineLatest(r).pipe(qr.map(s=>s))}composePermission(n){return n.map(s=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(s);if(!i)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return i.getValue()})}getAllPermissionPoint(){const n=new Map;return this._permissionPointMap.forEach((r,s)=>{n.set(s,r)}),n}}function ld(e,t){if(!t)return e;const n=[];for(const r of e){const s=t.find(([i])=>i===r[0]);if(s){if(s[1]===null)continue;n.push([r[0],s[1]])}else n.push(r)}return n}var aI=Object.getOwnPropertyDescriptor,lI=(e,t,n,r)=>{for(var s=r>1?void 0:r?aI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},ca=(e,t)=>(n,r)=>t(n,r,e);const cI=4,cd=Symbol("DependentOn");class ua extends Ke{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}E(ua,"pluginName"),E(ua,"type",ve.UNIVER_UNKNOWN);class uI{constructor(){E(this,"_plugins",[])}addPlugin(t){this._plugins.push(t)}removePlugins(){const t=this._plugins.slice();return this._plugins.length=0,t}forEachPlugin(t){this._plugins.forEach(t)}}function hI(...e){return function(t){t[cd]=e}}f.PluginService=class{constructor(t,n,r){E(this,"_pluginRegistry",new Map);E(this,"_pluginStore",new uI);E(this,"_seenPlugins",new Set);E(this,"_loadedPlugins",new Set);E(this,"_loadedPluginTypes",new Set([ve.UNIVER_UNKNOWN]));E(this,"_flushTimerByType",new Map);this._injector=t,this._lifecycleService=n,this._logService=r}dispose(){this._pluginStore.removePlugins().forEach(t=>t.dispose()),this._flushTimerByType.forEach(t=>clearTimeout(t))}registerPlugin(t,n){this._assertPluginValid(t);const r={plugin:t,options:n};this._pluginRegistry.set(t.pluginName,r),this._logService.debug("[PluginService]",`Plugin "${t.pluginName}" registered.`);const{type:s}=t;this._loadedPluginTypes.has(s)&&(s===ve.UNIVER_UNKNOWN?this._loadFromPlugins([r]):this._flushType(s))}startPluginsForType(t){this._loadedPluginTypes.has(t)||this._loadPluginsForType(t)}_loadPluginsForType(t){const n=Array.from(this._pluginRegistry.keys()),r=[];n.forEach(s=>{const i=this._pluginRegistry.get(s);i.plugin.type===t&&r.push(i)}),this._loadFromPlugins(r),this._loadedPluginTypes.add(t)}_assertPluginValid(t){const{type:n,pluginName:r}=t;if(n===ve.UNRECOGNIZED)throw new Error(`[PluginService]: invalid plugin type for ${t.name}. Please assign a "type" to your plugin.`);if(!r)throw new Error(`[PluginService]: no plugin name for ${t.name}. Please assign a "pluginName" to your plugin.`);if(this._seenPlugins.has(r))throw new Error(`[PluginService]: duplicated plugin name for "${r}". Maybe a plugin that dependents on "${r} has already registered it. In that case please register "${r}" before the that plugin.`);this._seenPlugins.add(t.pluginName)}_flushType(t){this._flushTimerByType.get(t)===void 0&&this._flushTimerByType.set(t,setTimeout(()=>{this._loadPluginsForType(t),this._flushTimerByType.delete(t)},cI))}_loadFromPlugins(t){const n=[],r=new Set,s=o=>{const{plugin:a}=o,{pluginName:l}=a;if(this._loadedPlugins.has(l)||r.has(l))return;r.add(l),this._pluginRegistry.delete(l);const c=a[cd];c&&c.forEach(u=>{const h=this._pluginRegistry.get(u.pluginName);if(h)s(h);else if(!this._seenPlugins.has(u.pluginName)&&!r.has(u.pluginName)){if(a.type===ve.UNIVER_UNKNOWN&&u.type!==ve.UNIVER_UNKNOWN)throw new Error(`[PluginService]: cannot register a plugin with Univer type that depends on a plugin with other type. The dependent is ${a.pluginName} and the dependency is ${u.pluginName}.`);a.type!==u.type&&u.type!==ve.UNIVER_UNKNOWN&&this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${u.pluginName}" which has different type.`),this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${u.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(u),s({plugin:u,options:void 0})}}),n.push(o)};t.forEach(o=>s(o));const i=n.map(o=>this._initPlugin(o.plugin,o.options));this._pluginsRunLifecycle(i)}_pluginsRunLifecycle(t){const n=this._lifecycleService.stage;if(sd(n).subscribe(r=>this._runStage(t,r)),n!==Fe.Steady){const r=this._lifecycleService.lifecycle$.pipe(se.skip(1)).subscribe(s=>{this._runStage(t,s),s===Fe.Steady&&r.unsubscribe()})}}_runStage(t,n){t.forEach(r=>{switch(n){case Fe.Starting:r.onStarting();break;case Fe.Ready:r.onReady();break;case Fe.Rendered:r.onRendered();break;case Fe.Steady:r.onSteady();break}})}_initPlugin(t,n){const r=this._injector.createInstance(t,n);return this._pluginStore.addPlugin(r),this._loadedPlugins.add(t.pluginName),this._logService.debug("[PluginService]",`Plugin "${r.getPluginName()}" loaded.`),r}},f.PluginService=lI([ca(0,Ce.Inject(Ce.Injector)),ca(1,Ce.Inject(f.LifecycleService)),ca(2,dt)],f.PluginService);const ha=Ce.createIdentifier("resource-loader-service");var dI=Object.getOwnPropertyDescriptor,fI=(e,t,n,r)=>{for(var s=r>1?void 0:r?dI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},mI=(e,t)=>(n,r)=>t(n,r,e);f.ResourceManagerService=class extends Ke{constructor(n){super();E(this,"_resourceMap",new Map);E(this,"_register$",new se.Subject);E(this,"register$",this._register$.asObservable());this._logService=n}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(n,r){return r?this.getResourcesByType(n,r):this.getAllResourceHooks().map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}getResourcesByType(n,r){return this.getAllResourceHooks().filter(o=>o.businesses.includes(r)).map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}registerPluginResource(n){const r=n.pluginName;if(this._resourceMap.has(r))throw new Error(`the pluginName is registered {${r}}`);return this._resourceMap.set(r,n),this._register$.next(n),Ye(()=>this._resourceMap.delete(r))}disposePluginResource(n){this._resourceMap.delete(n)}loadResources(n,r){this.getAllResourceHooks().forEach(s=>{var o;const i=(o=r==null?void 0:r.find(a=>a.name===s.pluginName))==null?void 0:o.data;if(i)try{const a=s.parseJson(i);s.onLoad(n,a)}catch(a){this._logService.error("[ResourceManagerService]","loadResources error",a)}})}unloadResources(n,r){this.getAllResourceHooks().filter(s=>s.businesses.includes(r)).forEach(s=>{s.onUnLoad(n)})}dispose(){this._register$.complete(),this._resourceMap.clear()}},f.ResourceManagerService=fI([mI(0,dt)],f.ResourceManagerService);class ni extends Ke{constructor(){super();E(this,"_darkMode$",new se.BehaviorSubject(!1));E(this,"darkMode$",this._darkMode$.asObservable());E(this,"_validColorCache",new Map);E(this,"_currentTheme",Jr.defaultTheme);E(this,"_currentTheme$",new se.BehaviorSubject(this._currentTheme));E(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(Ye(()=>{this._currentTheme=Jr.defaultTheme,this._currentTheme$.complete(),this._darkMode$.complete()}))}get darkMode(){return this._darkMode$.getValue()}isValidThemeColor(n){if(this._validColorCache.has(n))return this._validColorCache.get(n);let r=!1;const s=n.split(".");if(s.length===1)r=n in Jr.defaultTheme;else if(s.length===2){const[i,o]=s;r=i in Jr.defaultTheme&&o in this._currentTheme[i]}return this._validColorCache.set(n,r),r}getCurrentTheme(){return this._currentTheme}setTheme(n){this._currentTheme=n,this._currentTheme$.next(n)}setDarkMode(n){this._darkMode$.next(n)}getColorFromTheme(n){return ul(this._currentTheme,n)}}var gI=Object.getOwnPropertyDescriptor,_I=(e,t,n,r)=>{for(var s=r>1?void 0:r?gI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},da=(e,t)=>(n,r)=>t(n,r,e);const ri=Ce.createIdentifier("univer.undo-redo.service"),pI=20;class ud{dispose(){}async dispatchToHandlers(){return!1}}const hd="univer.command.redo",dd="univer.command.undo",fd=new class extends ud{constructor(){super(...arguments);E(this,"type",mr.COMMAND);E(this,"id",dd)}handler(t){const n=t.get(ri),r=n.pitchTopUndoElement();if(!r)return!1;const s=t.get(gr);return _s(r.undoMutations,s)?(n.popUndoToRedo(),!0):!1}},md=new class extends ud{constructor(){super(...arguments);E(this,"type",mr.COMMAND);E(this,"id",hd)}handler(t){const n=t.get(ri),r=n.pitchTopRedoElement();if(!r)return!1;const s=t.get(gr);return _s(r.redoMutations,s)?(n.popRedoToUndo(),!0):!1}};f.LocalUndoRedoService=class extends Ke{constructor(n,r,s){super();E(this,"undoRedoStatus$");E(this,"_undoRedoStatus$",new se.BehaviorSubject({undos:0,redos:0}));E(this,"_undoStacks",new Map);E(this,"_redoStacks",new Map);E(this,"_batchingStatus",new Map);this._univerInstanceService=n,this._commandService=r,this._contextService=s,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(fd)),this.disposeWithMe(this._commandService.registerCommand(md)),this.disposeWithMe(Ye(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(Ye(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(n){const{unitID:r}=n,s=this._getRedoStack(r,!0),i=this._getUndoStack(r,!0);if(s.length=0,this._batchingStatus.has(n.unitID)){const a=this._batchingStatus.get(n.unitID),l=this._pitchUndoElement(n.unitID);a===0||!l?(o(n),this._batchingStatus.set(n.unitID,1)):this._tryBatchingElements(l,n)}else o(n);function o(a){i.push(a),i.length>pI&&i.splice(0,1)}this._updateStatus()}clearUndoRedo(n){const r=this._getRedoStack(n);r&&(r.length=0);const s=this._getUndoStack(n);s&&(s.length=0),this._updateStatus()}pitchTopUndoElement(){const n=this._getFocusedUnitId();return this._pitchUndoElement(n)}pitchTopRedoElement(){const n=this._getFocusedUnitId();return this._pitchRedoElement(n)}_pitchUndoElement(n){const r=this._getUndoStack(n);return r!=null&&r.length?r[r.length-1]:null}_pitchRedoElement(n){const r=this._getRedoStack(n);return r!=null&&r.length?r[r.length-1]:null}popUndoToRedo(){const r=this._getUndoStackForFocused().pop();r&&(r.redoMutations.length>0&&this._getRedoStackForFocused().push(r),this._updateStatus())}popRedoToUndo(){const r=this._getRedoStackForFocused().pop();r&&(this._getUndoStackForFocused().push(r),this._updateStatus())}rollback(n,r){const s=r||this._getFocusedUnitId(),i=this._getUndoStack(s),o=i==null?void 0:i[(i==null?void 0:i.length)-1];o&&o.id===n&&(i.pop(),_s(o.undoMutations,this._commandService))}__tempBatchingUndoRedo(n){if(this._batchingStatus.has(n))throw new Error("[LocalUndoRedoService]: cannot batching undo redo twice at the same time!");return this._batchingStatus.set(n,0),Ye(()=>this._batchingStatus.delete(n))}_updateStatus(){var i,o;const n=this._getFocusedUnitId(),r=n&&((i=this._undoStacks.get(n))==null?void 0:i.length)||0,s=n&&((o=this._redoStacks.get(n))==null?void 0:o.length)||0;this._undoRedoStatus$.next({undos:r,redos:s})}_getUndoStack(n,r=!1){let s=this._undoStacks.get(n);return!s&&r&&(s=[],this._undoStacks.set(n,s)),s||null}_getRedoStack(n,r=!1){let s=this._redoStacks.get(n);return!s&&r&&(s=[],this._redoStacks.set(n,s)),s||null}_getUndoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getUndoStack(n,!0)}_getRedoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getRedoStack(n,!0)}_tryBatchingElements(n,r){n.redoMutations.push(...r.redoMutations),n.undoMutations.push(...r.undoMutations)}_getFocusedUnitId(){var o,a,l,c;let n="";const r=this._contextService.getContextValue(qn),s=this._contextService.getContextValue(Dh),i=this._contextService.getContextValue(Mh);return r?s?n=ci:i?n=li:n=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":n=(c=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?c:"",n}},f.LocalUndoRedoService=_I([da(0,Jn),da(1,gr),da(2,Un)],f.LocalUndoRedoService);class gd{constructor(t,n=1e3){E(this,"_imageCacheMap");this._injector=t,this._imageCacheMap=new Tr(n)}_getImageCacheKey(t,n){return`${t}-${n}`}getImage(t,n,r,s){const i=this._getImageCacheKey(t,n),o=this._imageCacheMap.get(i);return o||((async()=>{const a=new Image,l=this._injector.has(ra)?this._injector.get(ra):null,c=this._injector.has(sa)?this._injector.get(sa):null;if(t===ti.UUID)try{a.src=await(l==null?void 0:l.getImage(n))||""}catch(u){console.error(u)}else if(t===ti.URL)try{const u=await(c==null?void 0:c.getImage(n));a.src=u||n}catch{a.src=n}else a.src=n;a.onload=()=>{a.removeAttribute("data-error"),r==null||r()},a.onerror=()=>{a.setAttribute("data-error","true"),s==null||s()},this._imageCacheMap.set(i,a)})(),null)}}function EI(e){return!(e.length===0||e.length>31||e.startsWith("'")||e.endsWith("'")||/[:\\\/\?\*\[\]]/.test(e))}function CI(e,t){return!(!e||e.length===0||e.length>255||t.has(e)||/[ :\\\/\?\*\[\]]/.test(e)||!/^[\p{L}_]/u.test(e)||/^\$?[A-Za-z]{1,3}\$?[0-9]+$/.test(e)||/^[rR]\d+[cC]\d+$/.test(e)||/^\d+$/.test(e))}const _d=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],fa=1,zr=8;class ma{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[n,r]=new Uint8Array(t,0,2);if(n!==219)throw new Error("Data does not appear to be in a KDBush format.");const s=r>>4;if(s!==fa)throw new Error(`Got v${s} data when expected v${fa}.`);const i=_d[r&15];if(!i)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new ma(a,o,i,t)}constructor(t,n=64,r=Float64Array,s){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+n,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=_d.indexOf(this.ArrayType),o=t*2*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);s&&s instanceof ArrayBuffer?(this.data=s,this.ids=new this.IndexArrayType(this.data,zr,t),this.coords=new this.ArrayType(this.data,zr+a+l,t*2),this._pos=t*2,this._finished=!0):(this.data=new ArrayBuffer(zr+o+a+l),this.ids=new this.IndexArrayType(this.data,zr,t),this.coords=new this.ArrayType(this.data,zr+a+l,t*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(fa<<4)+i]),new Uint16Array(this.data,2,1)[0]=n,new Uint32Array(this.data,4,1)[0]=t)}add(t,n){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=n,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ga(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,n,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:o,nodeSize:a}=this,l=[0,i.length-1,0],c=[];for(;l.length;){const u=l.pop()||0,h=l.pop()||0,d=l.pop()||0;if(h-d<=a){for(let I=d;I<=h;I++){const y=o[2*I],H=o[2*I+1];y>=t&&y<=r&&H>=n&&H<=s&&c.push(i[I])}continue}const m=d+h>>1,_=o[2*m],p=o[2*m+1];_>=t&&_<=r&&p>=n&&p<=s&&c.push(i[m]),(u===0?t<=_:n<=p)&&(l.push(d),l.push(m-1),l.push(1-u)),(u===0?r>=_:s>=p)&&(l.push(m+1),l.push(h),l.push(1-u))}return c}within(t,n,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:i,nodeSize:o}=this,a=[0,s.length-1,0],l=[],c=r*r;for(;a.length;){const u=a.pop()||0,h=a.pop()||0,d=a.pop()||0;if(h-d<=o){for(let I=d;I<=h;I++)Ed(i[2*I],i[2*I+1],t,n)<=c&&l.push(s[I]);continue}const m=d+h>>1,_=i[2*m],p=i[2*m+1];Ed(_,p,t,n)<=c&&l.push(s[m]),(u===0?t-r<=_:n-r<=p)&&(a.push(d),a.push(m-1),a.push(1-u)),(u===0?t+r>=_:n+r>=p)&&(a.push(m+1),a.push(h),a.push(1-u))}return l}}function ga(e,t,n,r,s,i){if(s-r<=n)return;const o=r+s>>1;pd(e,t,o,r,s,i),ga(e,t,n,r,o-1,1-i),ga(e,t,n,o+1,s,1-i)}function pd(e,t,n,r,s,i){for(;s>r;){if(s-r>600){const c=s-r+1,u=n-r+1,h=Math.log(c),d=.5*Math.exp(2*h/3),m=.5*Math.sqrt(h*d*(c-d)/c)*(u-c/2<0?-1:1),_=Math.max(r,Math.floor(n-u*d/c+m)),p=Math.min(s,Math.floor(n+(c-u)*d/c+m));pd(e,t,n,_,p,i)}const o=t[2*n+i];let a=r,l=s;for(Gr(e,t,r,n),t[2*s+i]>o&&Gr(e,t,r,s);a<l;){for(Gr(e,t,a,l),a++,l--;t[2*a+i]<o;)a++;for(;t[2*l+i]>o;)l--}t[2*r+i]===o?Gr(e,t,r,l):(l++,Gr(e,t,l,s)),l<=n&&(r=l+1),n<=l&&(s=l-1)}}function Gr(e,t,n,r){_a(e,n,r),_a(t,2*n,2*r),_a(t,2*n+1,2*r+1)}function _a(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function Ed(e,t,n,r){const s=e-n,i=t-r;return s*s+i*i}class RI{constructor(t=!1){E(this,"_tree",new Map);E(this,"_oneCellCache",new Map);E(this,"_kdTree",new Map);this._enableOneCellCache=t}dispose(){this.clear()}getTree(t,n){return this._tree.has(t)||this._tree.set(t,new Map),this._tree.get(t).has(n)||this._tree.get(t).set(n,new Vs),this._tree.get(t).get(n)}_getOneCellCache(t,n,r,s){return this._oneCellCache.has(t)||this._oneCellCache.set(t,new Map),this._oneCellCache.get(t).has(n)||this._oneCellCache.get(t).set(n,new Map),this._oneCellCache.get(t).get(n).has(r)||this._oneCellCache.get(t).get(n).set(r,new Map),this._oneCellCache.get(t).get(n).get(r).has(s)||this._oneCellCache.get(t).get(n).get(r).set(s,new Set),this._oneCellCache.get(t).get(n).get(r).get(s)}_removeOneCellCache(t,n,r,s,i){const o=this._oneCellCache.get(t);if(!o)return;const a=o.get(n);if(!a)return;const l=a.get(r);if(!l)return;const c=l.get(s);c&&c.delete(i)}_removeCellCacheByRange(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this._oneCellCache.get(n);if(!o)return;const a=o.get(r);if(!a)return;const{startRow:l,startColumn:c,endRow:u,endColumn:h}=s;for(let d=l;d<=u;d++){const m=a.get(d);if(m)for(let _=c;_<=h;_++){const p=m.get(_);p&&p.delete(i)}}}_insertOneCellCache(t,n,r,s,i){this._getOneCellCache(t,n,r,s).add(i)}_getRdTreeItems(t){const n=[];for(const[r,s]of t)for(const[i,o]of s)n.push({x:i,y:r,ids:o});return n}_searchByOneCellCache(t){var _;const{unitId:n,sheetId:r,range:s}=t,{startRow:i,startColumn:o,endRow:a,endColumn:l}=s,c=(_=this._kdTree.get(n))==null?void 0:_.get(r);if(!c)return[];const{tree:u,items:h}=c,d=u.range(o,i,l,a),m=[];for(const p of d){const I=h[p];m.push(...Array.from(I.ids))}return m}openKdTree(){var t;for(const[n,r]of this._oneCellCache){this._kdTree.has(n)||this._kdTree.set(n,new Map);for(const[s,i]of r){const o=this._getRdTreeItems(i),a=new ma(o.length);(t=this._kdTree.get(n))==null||t.set(s,{tree:a,items:o});for(const l of o)a.add(l.x,l.y);a.finish()}}}closeKdTree(){var t;for(const[n,r]of this._oneCellCache)for(const[s,i]of r)(t=this._kdTree.get(n))==null||t.set(s,void 0)}insert(t){const{unitId:n,sheetId:r,range:s,id:i}=t;if(!n||n.length===0)return;let{startRow:o,endRow:a,startColumn:l,endColumn:c}=s;if(this._enableOneCellCache&&o===a&&l===c){this._insertOneCellCache(n,r,o,l,i);return}const u=this.getTree(n,r);Number.isNaN(o)&&(o=0),Number.isNaN(l)&&(l=0),Number.isNaN(a)&&(a=Number.POSITIVE_INFINITY),Number.isNaN(c)&&(c=Number.POSITIVE_INFINITY),u.insert({minX:l,minY:o,maxX:c,maxY:a,id:i})}bulkInsert(t){for(const n of t)this.insert(n)}*searchGenerator(t){var a;const{unitId:n,sheetId:r,range:s}=t;if(this._enableOneCellCache){const l=this._searchByOneCellCache(t);for(const c of l)yield c}const i=(a=this._tree.get(n))==null?void 0:a.get(r);if(!i)return;const o=i.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(const l of o)yield l.id}bulkSearch(t,n){const r=new Set;for(const s of t)for(const i of this.searchGenerator(s))(n==null?void 0:n.has(i))!==!0&&r.add(i);return r}removeById(t,n){var r,s;n?((r=this._tree.get(t))==null||r.delete(n),(s=this._oneCellCache.get(t))==null||s.delete(n)):(this._tree.delete(t),this._oneCellCache.delete(t))}_removeRTreeItem(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this.getTree(n,r),a=o.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(let l=0;l<a.length;l++)a[l].id===i&&o.remove(a[l])}remove(t){const{unitId:n,sheetId:r,range:s,id:i}=t,{startRow:o,startColumn:a,endRow:l,endColumn:c}=s;this._enableOneCellCache?o===l&&a===c?this._removeOneCellCache(n,r,s.startRow,s.startColumn,i):(this._removeCellCacheByRange(t),this._removeRTreeItem(t)):this._removeRTreeItem(t)}bulkRemove(t){for(const n of t)this.remove(n)}clear(){this._tree.clear(),this._oneCellCache.clear()}toJSON(){const t={};return this._tree.forEach((n,r)=>{t[r]={},n.forEach((s,i)=>{t[r][i]=s.toJSON()})}),t}fromJSON(t){this._tree.clear();for(const n in t){this._tree.set(n,new Map);for(const r in t[n]){const s=new Vs;s.fromJSON(t[n][r]),this._tree.get(n).set(r,s)}}}}function II(e){return new Promise(t=>setTimeout(t,e))}function SI(e=1){return new Promise(t=>{let n=0;const r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}var OI=Object.getOwnPropertyDescriptor,wI=(e,t,n,r)=>{for(var s=r>1?void 0:r?OI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},vI=(e,t)=>(n,r)=>t(n,r,e);f.Skeleton=class extends Ke{constructor(n){super();E(this,"_fontLocale");E(this,"_dirty",!0);this._localeService=n,this._localeInitial()}get dirty(){return this._dirty}getFontLocale(){return this._fontLocale}makeDirty(n){this._dirty=n}dispose(){super.dispose(),this._fontLocale=null}_localeInitial(){}},f.Skeleton=wI([vI(0,Ce.Inject(On))],f.Skeleton);var bI=Object.getOwnPropertyDescriptor,yI=(e,t,n,r)=>{for(var s=r>1?void 0:r?bI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},si=(e,t)=>(n,r)=>t(n,r,e);f.SheetSkeleton=class extends f.Skeleton{constructor(n,r,s,i,o,a){super(s);E(this,"_worksheetData");E(this,"_renderRawFormula",!1);E(this,"_cellData");E(this,"_imageCacheMap");E(this,"_skipAutoHeightForMergedCells",!0);E(this,"_rowTotalHeight",0);E(this,"_columnTotalWidth",0);E(this,"_rowHeaderWidth",0);E(this,"_columnHeaderHeight",0);E(this,"_rowHeightAccumulation",[]);E(this,"_columnWidthAccumulation",[]);E(this,"_marginTop",0);E(this,"_marginLeft",0);E(this,"_scaleX");E(this,"_scaleY");E(this,"_scrollX");E(this,"_scrollY");this.worksheet=n,this._styles=r,this._contextService=i,this._configService=o,this._injector=a,this._worksheetData=this.worksheet.getConfig(),this._cellData=this.worksheet.getCellMatrix(),this._imageCacheMap=new gd(this._injector),this.initConfig()}initConfig(){var n,r;this._skipAutoHeightForMergedCells=!((n=this._configService.getConfig(ba))!=null&&n),this.worksheet.setIsRowStylePrecedeColumnStyle((r=this._configService.getConfig(va))!=null?r:!1)}resetCache(){}getWorksheetConfig(){return this._worksheetData}getLocation(){return[this.worksheet.getUnitId(),this.worksheet.getSheetId()]}set columnHeaderHeight(n){this._columnHeaderHeight=n,this._worksheetData.columnHeader.height=n}set rowHeaderWidth(n){this._rowHeaderWidth=n,this._worksheetData.rowHeader.width=n}get rowHeightAccumulation(){return this._rowHeightAccumulation}get rowTotalHeight(){return this._rowTotalHeight}get columnWidthAccumulation(){return this._columnWidthAccumulation}get columnTotalWidth(){return this._columnTotalWidth}get rowHeaderWidth(){return this._rowHeaderWidth}get columnHeaderHeight(){return this._columnHeaderHeight}setMarginLeft(n){this._marginLeft=n}setMarginTop(n){this._marginTop=n}setScale(n,r){this._updateLayout(),this._scaleX=n,this._scaleY=r||n,this._updateLayout()}setScroll(n,r){Z.isDefine(n)&&(this._scrollX=n),Z.isDefine(r)&&(this._scrollY=r)}get scrollX(){return this._scrollX}get scrollY(){return this._scrollY}get scaleX(){return this._scaleX}get scaleY(){return this._scaleY}get rowHeaderWidthAndMarginLeft(){return this.rowHeaderWidth+this._marginLeft}get columnHeaderHeightAndMarginTop(){return this.columnHeaderHeight+this._marginTop}get imageCacheMap(){return this._imageCacheMap}_generateRowMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let c=s;if(this.worksheet.getRowFiltered(l))c=0;else if(a[l]!=null){const u=a[l];if(!u)continue;const{h=s,ah:d,ia:m}=u;(m==null||m===ae.TRUE)&&typeof d=="number"?c=d:c=h,u.hd===ae.TRUE&&(c=0)}i+=c,o.push(i)}return{rowTotalHeight:i,rowHeightAccumulation:o}}_generateColumnMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let c=s;if(a[l]!=null){const u=a[l];if(!u)continue;u.w!=null&&(c=u.w),u.hd===ae.TRUE&&(c=0)}i+=c,o.push(i)}return{columnTotalWidth:i,columnWidthAccumulation:o}}intersectMergeRange(n,r){return!!this.worksheet.getMergedCell(n,r)}_getOverflowBound(n,r,s,i,o=bt.LEFT){let a=0;if(r>s){const l=this._columnWidthAccumulation.length-1;for(let c=r;c>=s;c--){const u=c,h=this.worksheet.getCell(n,u);if(!xo(h)&&u!==r||this.intersectMergeRange(n,u))return u===r?u:u+1>l?l:u+1;const{startX:d,endX:m}=Zn(n,u,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===bt.CENTER&&u===r?a+=(m-d)/2:a+=m-d,i<a)return u}return r}for(let l=r;l<=s;l++){const c=l,u=this.worksheet.getCell(n,c);if(!xo(u)&&c!==r||this.intersectMergeRange(n,c))return c===r?c:c-1<0?0:c-1;const{startX:h,endX:d}=Zn(n,c,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===bt.CENTER&&c===r?a+=(d-h)/2:a+=d-h,i<a)return c}return s}_updateLayout(){if(!this.dirty)return;const{rowData:n,columnData:r,defaultRowHeight:s,defaultColumnWidth:i,rowCount:o,columnCount:a,rowHeader:l,columnHeader:c}=this._worksheetData,{rowTotalHeight:u,rowHeightAccumulation:h}=this._generateRowMatrixCache(o,n,s),{columnTotalWidth:d,columnWidthAccumulation:m}=this._generateColumnMatrixCache(a,r,i);this._rowHeaderWidth=l.hidden!==ae.TRUE?this._dynamicallyUpdateRowHeaderWidth(l):0,this._columnHeaderHeight=c.hidden!==ae.TRUE?c.height:0,this._rowTotalHeight=u,this._rowHeightAccumulation=h,this._columnTotalWidth=d,this._columnWidthAccumulation=m,this.makeDirty(!1)}calculate(){return this.resetCache(),this._updateLayout(),this}resetRangeCache(n){}_dynamicallyUpdateRowHeaderWidth(n){const s=`${this.worksheet.getRowCount()}`.length*8;return Math.max(n.width,s)}_hasUnMergedCellInRow(n,r,s){if(!this.worksheet.getMergeData())return!1;for(let o=r;o<=s;o++){const{isMerged:a,isMergedMainCell:l}=this.worksheet.getCellInfoInMergeData(n,o);if(!a&&!l)return!0}return!1}expandRangeByMerge(n,r){let{startRow:s,startColumn:i,endRow:o,endColumn:a}=n;const l=this._worksheetData.mergeData;if(!l)return{startRow:s,startColumn:i,endRow:o,endColumn:a};let c=!0;const u=new ct;let h=0,d=null;for(;c;){c=!1;for(let m=0;m<l.length;m++){const{startRow:_,startColumn:p,endRow:I,endColumn:y}=l[m];if(u.getValue(_,p))continue;const H={startColumn:i,startRow:s,endColumn:a,endRow:o},x={startColumn:p,startRow:_,endColumn:y,endRow:I};zu(H,x)&&(s=Math.min(s,_),i=Math.min(i,p),o=Math.max(o,I),a=Math.max(a,y),u.setValue(_,p,!0),c=!0,h++,d=x)}}return r&&h===1&&Yt.contains(d,n)?{startRow:d.startRow,startColumn:d.startColumn,endRow:d.startRow,endColumn:d.startColumn}:{startRow:s,startColumn:i,endRow:o,endColumn:a}}getColumnCount(){return this._columnWidthAccumulation.length}getRowCount(){return this._rowHeightAccumulation.length}_getCellMergeInfo(n,r){return this.worksheet.getCellInfoInMergeData(n,r)}getNoMergeCellPositionByIndex(n,r,s=!0){return this.getNoMergeCellWithCoordByIndex(n,r,s)}getNoMergeCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this;let{startY:c,endY:u,startX:h,endX:d}=Zn(n,r,i,o);return s&&(c+=l,u+=l,h+=a,d+=a),{startY:c,endY:u,startX:h,endX:d}}getNoMergeCellPositionByIndexWithNoHeader(n,r){const{rowHeightAccumulation:s,columnWidthAccumulation:i}=this,{startY:o,endY:a,startX:l,endX:c}=Zn(n,r,s,i);return{startY:o,endY:a,startX:l,endX:c}}getRowIndexByOffsetY(n,r,s,i){var l;const{rowHeightAccumulation:o}=this;n=Rd(n,r,s,this.columnHeaderHeightAndMarginTop);let a=_r(o,n,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(o[a]-n)<Math.abs(n-((l=o[a-1])!=null?l:0))&&(a=a+1),a}getColumnIndexByOffsetX(n,r,s,i){var c;const o=Cd(n,r,s,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this;let l=_r(a,o,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(a[l]-o)<Math.abs(o-((c=a[l-1])!=null?c:0))&&(l=l+1),l}getCellIndexByOffset(n,r,s,i,o,a){const l=this.getRowIndexByOffsetY(r,i,o,a),c=this.getColumnIndexByOffsetX(n,s,o,a);return{row:l,column:c}}getCellByOffset(n,r,s,i,o){const a=this==null?void 0:this.getCellIndexByOffset(n,r,s,i,o,{firstMatch:!0});return a?this.worksheet.getCellInfoInMergeData(a.row,a.column):null}getCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this,c=Zn(n,r,i,o,this.worksheet.getCellInfoInMergeData(n,r)),{isMerged:u,isMergedMainCell:h}=c;let{startY:d,endY:m,startX:_,endX:p,mergeInfo:I}=c,y=a,H=l;return s===!1&&(y=0,H=0),d+=H,m+=H,_+=y,p+=y,I.startY+=H,I.endY+=H,I.startX+=y,I.endX+=y,{actualRow:n,actualColumn:r,startX:_,startY:d,endX:p,endY:m,isMerged:u,isMergedMainCell:h,mergeInfo:I}}getCellWithCoordByOffset(n,r,s,i,o,a){const{row:l,column:c}=this.getCellIndexByOffset(n,r,s,i,o,a);return this.getCellWithCoordByIndex(l,c)}getOffsetByColumn(n){const{columnWidthAccumulation:r,rowHeaderWidthAndMarginLeft:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetByRow(n){const{rowHeightAccumulation:r,columnHeaderHeightAndMarginTop:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetRelativeToRowCol(n,r){const s=_r(this.columnWidthAccumulation,n);let i=0;s===0?i=n:i=n-this._columnWidthAccumulation[s-1];const o=_r(this.rowHeightAccumulation,r);let a=0;return o===0?a=r:a=r-this._rowHeightAccumulation[o-1],{row:o,column:s,columnOffset:i,rowOffset:a}}_updateConfigAndGetDocumentModel(n,r,s,i){var a,l,c,u,h;if(!i||!((a=n.body)!=null&&a.dataStream))return;n.documentStyle||(n.documentStyle={}),n.documentStyle.marginTop=(l=s.t)!=null?l:0,n.documentStyle.marginBottom=(c=s.b)!=null?c:2,n.documentStyle.marginLeft=(u=s.l)!=null?u:2,n.documentStyle.marginRight=(h=s.r)!=null?h:2,n.documentStyle.pageSize={width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},n.documentStyle.renderConfig={...n.documentStyle.renderConfig,...i};const o=n.body.paragraphs||[];for(const d of o)d.paragraphStyle||(d.paragraphStyle={}),d.paragraphStyle.horizontalAlign=r;return new Tt(n)}dispose(){super.dispose(),this._rowHeightAccumulation=[],this._columnWidthAccumulation=[],this._rowTotalHeight=0,this._columnTotalWidth=0,this._rowHeaderWidth=0,this._columnHeaderHeight=0,this._worksheetData=null,this._cellData=null,this._styles=null,this.worksheet=null}},f.SheetSkeleton=yI([si(2,Ce.Inject(On)),si(3,Un),si(4,fr),si(5,Ce.Inject(Ce.Injector))],f.SheetSkeleton);function pa(e,t,n,r){const s=e-1,i=t-1,o=n[s]||0;let a=n[e];a==null&&(a=n[n.length-1]);const l=r[i]||0;let c=r[t];return c==null&&(c=r[r.length-1]),{startY:o,endY:a,startX:l,endX:c}}function AI(e,t,n,r){return pa(e,t,n,r)}function Zn(e,t,n,r,s){e=Z.clamp(e,0,n.length-1),t=Z.clamp(t,0,r.length-1);let{startY:i,endY:o,startX:a,endX:l}=pa(e,t,n,r);if(!s)return{startY:i,endY:o,startX:a,endX:l,isMerged:!1,isMergedMainCell:!1,actualRow:e,actualColumn:t,mergeInfo:{startY:i,endY:o,startX:a,endX:l,startRow:e,startColumn:t,endRow:e,endColumn:t}};const{isMerged:c,isMergedMainCell:u,startRow:h,startColumn:d,endRow:m,endColumn:_}=s;let p={startRow:h,startColumn:d,endRow:m,endColumn:_,startY:i,endY:o,startX:a,endX:l};const I=n.length-1,y=r.length-1;if(c&&h!==-1&&d!==-1){const H=n[h-1]||0,x=n[m]||n[I],Y=r[d-1]||0,O=r[_]||r[y];p={...p,startY:H,endY:x,startX:Y,endX:O}}else if(!c&&m!==-1&&_!==-1){const H=n[m]||n[I],x=r[_]||r[y];p={...p,startY:i,endY:H,startX:a,endX:x}}return{isMerged:c,isMergedMainCell:u,actualRow:e,actualColumn:t,startY:i,endY:o,startX:a,endX:l,mergeInfo:p}}function Cd(e,t,n,r){const{x:s}=n;return e/t+s-r}function Rd(e,t,n,r){const{y:s}=n;return e=e/t+s-r,e}const TI=["script","style","meta","comment","link"];var Id=(e=>(e[e.INFO=0]="INFO",e[e.STOP=1]="STOP",e[e.WARNING=2]="WARNING",e))(Id||{}),Sd=(e=>(e[e.DISABLED=0]="DISABLED",e[e.FULL_ALPHA=1]="FULL_ALPHA",e[e.FULL_HANGUL=2]="FULL_HANGUL",e[e.FULL_KATAKANA=3]="FULL_KATAKANA",e[e.HALF_ALPHA=4]="HALF_ALPHA",e[e.HALF_HANGUL=5]="HALF_HANGUL",e[e.HALF_KATAKANA=6]="HALF_KATAKANA",e[e.HIRAGANA=7]="HIRAGANA",e[e.NO_CONTROL=8]="NO_CONTROL",e[e.OFF=9]="OFF",e[e.ON=10]="ON",e))(Sd||{}),Od=(e=>(e.BETWEEN="between",e.EQUAL="equal",e.GREATER_THAN="greaterThan",e.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",e.LESS_THAN="lessThan",e.LESS_THAN_OR_EQUAL="lessThanOrEqual",e.NOT_BETWEEN="notBetween",e.NOT_EQUAL="notEqual",e))(Od||{}),wd=(e=>(e[e.TEXT=0]="TEXT",e[e.ARROW=1]="ARROW",e[e.CUSTOM=2]="CUSTOM",e))(wd||{}),vd=(e=>(e.VALID="valid",e.INVALID="invalid",e.VALIDATING="validating",e))(vd||{}),bd=(e=>(e.CUSTOM="custom",e.LIST="list",e.LIST_MULTIPLE="listMultiple",e.NONE="none",e.TEXT_LENGTH="textLength",e.DATE="date",e.TIME="time",e.WHOLE="whole",e.DECIMAL="decimal",e.CHECKBOX="checkbox",e.ANY="any",e))(bd||{}),NI=Object.getOwnPropertyDescriptor,MI=(e,t,n,r)=>{for(var s=r>1?void 0:r?NI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},yd=(e,t)=>(n,r)=>t(n,r,e);let Ea=class extends Ke{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){const e=n=>{n.businesses.forEach(r=>{switch(r){case ve.UNRECOGNIZED:case ve.UNIVER_UNKNOWN:case ve.UNIVER_SLIDE:case ve.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType(ve.UNIVER_DOC).forEach(s=>{const o=(s.getSnapshot().resources||[]).find(a=>a.name===n.pluginName);if(o)try{const a=n.parseJson(o.data);n.onLoad(s.getUnitId(),a)}catch{console.error(`Load Document{${s.getUnitId()}} Resources{${n.pluginName}} Data Error.`)}});break}case ve.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(ve.UNIVER_SHEET).forEach(s=>{const o=(s.getSnapshot().resources||[]).find(a=>a.name===n.pluginName);if(o)try{const a=n.parseJson(o.data);n.onLoad(s.getUnitId(),a)}catch{console.error(`Load Workbook{${s.getUnitId()}} Resources{${n.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(n=>e(n)),this.disposeWithMe(this._resourceManagerService.register$.subscribe(n=>e(n))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(ve.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(ve.UNIVER_DOC).subscribe(n=>{const r=n.getUnitId();ya(r)||this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(ve.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId(),ve.UNIVER_SHEET)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(ve.UNIVER_DOC).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId(),ve.UNIVER_DOC)}))}saveUnit(e){const t=this._univerInstanceService.getUnit(e);if(!t)return null;const n=this._resourceManagerService.getResources(e,t.type),r=Z.deepClone(t.getSnapshot());return r.resources=n,r}};Ea=MI([yd(0,Ce.Inject(Qs)),yd(1,Ce.Inject(Jn))],Ea);class DI{constructor(t={},n){E(this,"_startedTypes",new Set);E(this,"_injector");E(this,"_disposingCallbacks",new os);const r=this._injector=LI(n,t==null?void 0:t.override),{theme:s,darkMode:i,locale:o,locales:a,logLevel:l,logCommandExecution:c}=t;s&&this._injector.get(ni).setTheme(s),i&&this._injector.get(ni).setDarkMode(i),a&&this._injector.get(On).load(a),o&&this._injector.get(On).setLocale(o),l&&this._injector.get(dt).setLogLevel(l),c!==void 0&&this._injector.get(fr).setConfig(gs,c),this._init(r)}get _univerInstanceService(){return this._injector.get(Jn)}get _pluginService(){return this._injector.get(f.PluginService)}__getInjector(){return this._injector}onDispose(t){const n=this._disposingCallbacks.add(Ye(t));return Ye(()=>n.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(t){this._injector.get(On).setLocale(t)}createUnit(t,n){return this._univerInstanceService.createUnit(t,n)}createUniverSheet(t){return this._injector.get(dt).warn("[Univer]","Univer.createUniverSheet is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(ve.UNIVER_SHEET,t)}createUniverDoc(t){return this._injector.get(dt).warn("[Univer]","Univer.createUniverDoc is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(ve.UNIVER_DOC,t)}createUniverSlide(t){return this._injector.get(dt).warn("[Univer]","Univer.createUniverSlide is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(ve.UNIVER_SLIDE,t)}_init(t){this._univerInstanceService.registerCtorForType(ve.UNIVER_SHEET,f.Workbook),this._univerInstanceService.registerCtorForType(ve.UNIVER_DOC,Tt),this._univerInstanceService.registerCtorForType(ve.UNIVER_SLIDE,oa);const n=t.get(Jn);n.__setCreateHandler((r,s,i,o)=>{if(!this._startedTypes.has(r)){this._pluginService.startPluginsForType(r),this._startedTypes.add(r);const l=t.createInstance(i,s);return n.__addUnit(l,o),this._tryProgressToReady(),l}const a=t.createInstance(i,s);return n.__addUnit(a,o),a})}_tryProgressToReady(){this._injector.get(f.LifecycleService).stage<Fe.Ready&&(this._injector.get(f.LifecycleService).stage=Fe.Ready)}registerPlugin(t,n){this._pluginService.registerPlugin(t,n)}registerPlugins(t){t.forEach(n=>{const[r,s]=n;this._pluginService.registerPlugin(r,s)})}}function LI(e,t){const n=ld([[Lh],[On],[ni],[f.LifecycleService],[f.PluginService],[Br],[Jn,{useClass:f.UniverInstanceService}],[od,{useClass:ad}],[dt,{useClass:Mc,lazy:!0}],[gr,{useClass:f.CommandService}],[ri,{useClass:f.LocalUndoRedoService,lazy:!0}],[fr,{useClass:Ac}],[Un,{useClass:Tc}],[Qs,{useClass:f.ResourceManagerService,lazy:!0}],[ha,{useClass:Ea,lazy:!0}],[Nh,{useClass:f.AuthzIoLocalService}],[id,{useClass:f.MentionIOLocalService,lazy:!0}]],t),r=e?e.createChild(n):new Ce.Injector(n);return Aa(r,[[Br],[ha]]),r}Pd(),f.ABCToNumber=X0,f.AUTO_HEIGHT_FOR_MERGED_CELLS=ba,f.AbsoluteRefType=Me,f.ActionIterator=Xn,f.AlignTypeH=lc,f.AlignTypeV=cc,f.ArrangeTypeEnum=dc,f.ArrowsAndMarkersShapes=Ul,f.AsyncInterceptorManager=rf,f.AsyncLock=Vd,f.AutoFillSeries=Ol,f.BaselineOffset=jt,f.BasicShapes=Ll,f.BlockType=jl,f.BooleanNumber=ae,f.BorderStyleTypes=Pe,f.BorderType=wl,f.BuildTextUtils=Qe,f.BulletAlignment=hr,f.COLORS=Hi,f.COMMAND_LOG_EXECUTION_CONFIG_KEY=gs,f.CanceledError=Jd,f.CellModeEnum=Pn,f.CellValueType=Qt,f.Color=Cn,f.ColorBuilder=Es,f.ColorKit=It,f.ColorType=Rt,f.ColumnSeparatorType=Vl,f.CommandType=mr,f.CommonHideTypes=vl,f.ConfigService=Ac,f.ContextService=Tc,f.CopyPasteType=bl,f.CustomCommandExecutionError=Zr,f.CustomDecorationType=_n,f.CustomRangeType=en,f.DEFAULT_CELL=v0,f.DEFAULT_DOC=qo,f.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=cR,f.DEFAULT_EMPTY_DOCUMENT_VALUE=wa,f.DEFAULT_NUMBER_FORMAT=Po,f.DEFAULT_RANGE=O0,f.DEFAULT_RANGE_ARRAY=S0,f.DEFAULT_SELECTION=w0,f.DEFAULT_SLIDE=$u,f.DEFAULT_STYLES=it,f.DEFAULT_TEXT_FORMAT=Iu,f.DEFAULT_TEXT_FORMAT_EXCEL=Su,f.DEFAULT_WORKSHEET_COLUMN_COUNT=Gh,f.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=$R,f.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Jh,f.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=VR,f.DEFAULT_WORKSHEET_COLUMN_WIDTH=Xh,f.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=WR,f.DEFAULT_WORKSHEET_ROW_COUNT=zh,f.DEFAULT_WORKSHEET_ROW_COUNT_KEY=BR,f.DEFAULT_WORKSHEET_ROW_HEIGHT=Kh,f.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=jR,f.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=qh,f.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=YR,f.DOCS_COMMENT_EDITOR_UNIT_ID_KEY=Oa,f.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=ci,f.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=li,f.DOCS_ZEN_EDITOR_UNIT_ID_KEY=Sa,f.DOC_DRAWING_PRINTING_COMPONENT_KEY=N0,f.DOC_RANGE_TYPE=Wc,f.DashStyleType=Jl,f.DataStreamTreeNodeType=Sh,f.DataStreamTreeTokenType=ut,f.DataValidationErrorStyle=Id,f.DataValidationImeMode=Sd,f.DataValidationOperator=Od,f.DataValidationRenderMode=wd,f.DataValidationStatus=vd,f.DataValidationType=bd,f.DeleteDirection=yl,f.DependentOn=hI,f.DesktopLogService=Mc,f.DeveloperMetadataVisibility=Al,f.Dimension=Tl,f.Direction=Nl,f.Disposable=Ke,f.DisposableCollection=os,f.DocStyleType=Bl,f.DocumentDataModel=Tt,f.DocumentFlavor=Ti,f.DrawingTypeEnum=fc,f.EDITOR_ACTIVATED=Mh,f.EXTENSION_NAMES=ju,f.ErrorService=Lh,f.EventState=Ah,f.EventSubject=uR,f.FOCUSING_COMMENT_EDITOR=IR,f.FOCUSING_COMMON_DRAWINGS=wR,f.FOCUSING_DOC=jr,f.FOCUSING_EDITOR_BUT_HIDDEN=pR,f.FOCUSING_EDITOR_INPUT_FORMULA=ER,f.FOCUSING_EDITOR_STANDALONE=RR,f.FOCUSING_FX_BAR_EDITOR=Dh,f.FOCUSING_PANEL_EDITOR=SR,f.FOCUSING_SHEET=qn,f.FOCUSING_SLIDE=Wr,f.FOCUSING_UNIT=$r,f.FOCUSING_UNIVER_EDITOR=CR,f.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=OR,f.FORMULA_EDITOR_ACTIVATED=vR,f.FollowNumberWithType=$l,f.FontItalic=cs,f.FontStyleType=Ln,f.FontWeight=us,f.GridType=Wl,f.HLSColor=xc,f.HorizontalAlign=bt,f.IAuthzIoService=Nh,f.ICommandService=gr,f.IConfigService=fr,f.IConfirmService=gR,f.IContextService=Un,f.IImageIoService=ra,f.ILocalStorageService=rI,f.ILogService=dt,f.IMentionIOService=id,f.IPermissionService=od,f.IResourceLoaderService=ha,f.IResourceManagerService=Qs,f.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE=va,f.IURLImageService=sa,f.IUndoRedoService=ri,f.IUniverInstanceService=Jn,f.ImageCacheMap=gd,f.ImageSourceType=ti,f.ImageUploadStatusType=Uh,f.InterceptorEffectEnum=An,f.InterceptorManager=ef,f.InterpolationPointType=Ml,f.JSON1=$_,f.JSONX=Vt,f.LRUHelper=Nr,f.LRUMap=Tr,f.LifecycleStages=Fe,f.LifecycleUnreachableError=rd,f.ListGlyphType=fe,f.LocaleService=On,f.LocaleType=cr,f.LogLevel=Nc,f.MOVE_BUFFER_VALUE=pr,f.MemoryCursor=fn,f.MentionType=ls,f.NAMED_STYLE_MAP=y0,f.NAMED_STYLE_SPACE_MAP=A0,f.NamedStyleType=Je,f.NilCommand=Dc,f.NumberUnitType=ac,f.ObjectMatrix=ct,f.ObjectRelativeFromH=ic,f.ObjectRelativeFromV=oc,f.OtherShapes=Pl,f.PAGE_SIZE=M0,f.PAPER_TYPES=L_,f.PRESET_LIST_TYPE=kr,f.PRINT_CHART_COMPONENT_KEY=T0,f.PageElementType=mc,f.PageOrientType=hc,f.PageType=Ni,f.PaperType=ht,f.ParagraphElementType=Gl,f.ParagraphStyleBuilder=Hr,f.ParagraphStyleValue=xr,f.PermissionService=ad,f.PermissionStatus=la,f.Plugin=ua,f.PositionedObjectLayoutType=Xl,f.PresetListType=xt,f.ProtectionType=Dl,f.QuickListType=uh,f.QuickListTypeMap=oC,f.RANGE_DIRECTION=jc,f.RANGE_TYPE=pe,f.RBush=Vs,f.RCDisposable=E_,f.RGBA_PAREN=rp,f.RGB_PAREN=np,f.ROTATE_BUFFER_VALUE=kc,f.RTree=RI,f.Range=Yn,f.Rectangle=Yt,f.RedoCommand=md,f.RedoCommandId=hd,f.RefAlias=K0,f.Registry=vi,f.RegistryAsMap=bi,f.RelativeDate=Fl,f.RelativeSlideLink=gc,f.RgbColor=Cs,f.RichTextBuilder=Sn,f.RichTextValue=an,f.RxDisposable=p_,f.SHEET_EDITOR_UNITS=b0,f.SectionType=Yl,f.SheetTypes=xl,f.SheetViewModel=Qh,f.SliceBodyType=Ko,f.SlideDataModel=oa,f.SpacingRule=ql,f.SpecialShapes=kl,f.Styles=Ph,f.THEME_COLORS=Fc,f.TabStopAlignment=Zl,f.TableAlignmentType=ec,f.TableLayoutType=tc,f.TableRowHeightRule=rc,f.TableSizeType=Ql,f.TableTextWrapType=nc,f.TestConfirmService=_R,f.TextDecoration=Hl,f.TextDecorationBuilder=on,f.TextDirection=ur,f.TextDirectionType=zl,f.TextStyleBuilder=sn,f.TextStyleValue=Fr,f.TextX=De,f.TextXActionType=J,f.ThemeColor=Rs,f.ThemeColorType=at,f.ThemeColors=hs,f.ThemeService=ni,f.Tools=Z,f.UndoCommand=fd,f.UndoCommandId=dd,f.UnitModel=as,f.Univer=DI,f.UniverInstanceType=ve,f.UpdateDocsAttributeType=Re,f.UserManagerService=Br,f.VerticalAlign=mn,f.VerticalAlignmentType=sc,f.Worksheet=Vr,f.WrapStrategy=gn,f.WrapTextType=Kl,f.addLinkToDocumentModel=xh,f.afterInitApply=J_,f.afterTime=X_,f.awaitTime=II,f.binSearchFirstGreaterThanTarget=Pc,f.binarySearchArray=Z_,f.bufferDebounceTime=K_,f.cellToRange=NE,f.characterSpacingControlType=uc,f.checkForSubstrings=DE,f.checkIfMove=ep,f.checkParagraphHasBullet=m0,f.checkParagraphHasIndent=g0,f.checkParagraphHasIndentByStyle=Fu,f.cloneCellData=jh,f.cloneCellDataMatrix=Wh,f.cloneCellDataWithSpanAndDisplay=PR,f.cloneValue=gt,f.cloneWorksheetData=Vh,f.codeToBlob=Q_,f.composeBody=Xo,f.composeInterceptors=Na,f.composeStyles=lr,f.concatMatrixArray=CE,f.convertBodyToHtml=tp,f.convertCellToRange=wu,f.convertObservableToBehaviorSubject=q_,f.covertCellValue=Ho,f.covertCellValues=ME,f.covertTextRunToHtml=xi,f.createAsyncInterceptorKey=tf,f.createDefaultUser=ei,f.createDocumentModelWithStyle=Yr,f.createInterceptorKey=Qd,f.createInternalEditorID=Kd,f.createREGEXFromWildChar=M_,f.createRowColIter=Yo,f.customNameCharacterCheck=CI,f.dayjs=Wt,f.debounce=s_,f.dedupe=kd,f.dedupeBy=Fd,f.deepCompare=Bo,f.delayAnimationFrame=SI,f.deleteContent=Hu,f.extractPureTextFromCell=td,f.fromCallback=Lc,f.fromEventSubject=hR,f.generateRandomId=nt,f.get=ul,f.getArrayLength=rn,f.getBodySlice=At,f.getBodySliceHtml=ps,f.getBorderStyleType=yE,f.getCellCoordByIndexSimple=pa,f.getCellInfoInMergeData=Rp,f.getCellPositionByIndexSimple=AI,f.getCellValueType=pp,f.getCellWithCoordByIndexCore=Zn,f.getColorStyle=Ft,f.getCustomBlockSlice=gh,f.getCustomDecorationSlice=ph,f.getCustomRangeSlice=_h,f.getDocsUpdateBody=AE,f.getEmptyCell=DR,f.getIntersectRange=zu,f.getNumfmtParseValueFilter=Ou,f.getOriginCellValue=GR,f.getParagraphsSlice=mh,f.getPlainText=Zs,f.getReverseDirection=D_,f.getSectionBreakSlice=gC,f.getTableSlice=fh,f.getTextRunSlice=Js,f.getTransformOffsetX=Cd,f.getTransformOffsetY=Rd,f.getWorksheetUID=JR,f.groupBy=Bd,f.handleStyleToString=bE,f.hashAlgorithm=p0,f.horizontalLineSegmentsSubtraction=Ws,f.insertMatrixArray=EE,f.insertTextToContent=xu,f.invertColorByHSL=uf,f.invertColorByMatrix=df,f.isBlackColor=gp,f.isBooleanString=Gd,f.isCellCoverable=xo,f.isCellV=$c,f.isCommentEditorID=Xd,f.isDefaultFormat=fE,f.isEmptyCell=vu,f.isFormulaId=vE,f.isFormulaString=bu,f.isICellData=Bc,f.isInternalEditorID=ya,f.isNodeEnv=N_,f.isNotNullOrUndefined=Hh,f.isNullCell=Ep,f.isNumeric=pl,f.isPatternEqualWithoutDecimal=mE,f.isRangesEqual=AR,f.isRealNum=_0,f.isSafeNumeric=d_,f.isSameStyleTextRun=yu,f.isTextFormat=dE,f.isUnitRangesEqual=TR,f.isValidRange=TE,f.isWhiteColor=_p,f.makeArray=$d,f.makeCellRangeToRangeData=wE,f.makeCellToSelection=OE,f.makeCustomRangeStream=TC,f.mapObjectMatrix=pE,f.merge=is,f.mergeLocales=E0,f.mergeOverrideWithDependencies=ld,f.mergeSets=g_,f.mergeWith=l_,f.mergeWorksheetSnapshotWithDefault=Zh,f.mixinClass=h_,f.moveMatrixArray=Fo,f.moveRangeByOffset=x0,f.nameCharacterCheck=EI,f.normalizeBody=_C,f.normalizeTextRuns=Pr,f.numberToABC=J0,f.numberToListABC=Z0,f.numfmt=hE,f.queryObjectMatrix=G0,f.registerDependencies=qd,f.remove=rr,f.repeatStringNumTimes=qu,f.replaceInDocumentBody=aR,f.requestImmediateMacroTask=m_,f.resolveWithBasePath=S_,f.rotate=Hd,f.searchArray=_r,f.searchInOrderedArray=Uc,f.selectionToArray=Cp,f.sequence=Cl,f.sequenceAsync=El,f.sequenceExecute=_s,f.sequenceExecuteAsync=G_,f.set=u_,f.shallowEqual=Ta,f.skipParseTagNames=TI,f.sliceMatrixArray=RE,f.sortRules=Q0,f.sortRulesByDesc=eC,f.sortRulesFactory=Ur,f.spliceArray=ko,f.splitIntoGrid=Wo,f.takeAfter=Fi,f.textDiff=Zo,f.throttle=Zd,f.toDisposable=Ye,f.touchDependencies=Aa,f.updateAttributeByDelete=Eh,f.updateAttributeByInsert=Ch,f.willLoseNumericPrecision=f_,Object.keys(Ce).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(f,e)&&Object.defineProperty(f,e,{enumerable:!0,get:()=>Ce[e]})}),Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}));
|