@univerjs/core 0.19.0 → 0.20.0
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 +3 -3
- package/lib/es/index.js +2 -2
- package/lib/index.js +2 -2
- package/lib/types/index.d.ts +1 -1
- package/lib/types/sheets/sheet-skeleton.d.ts +11 -54
- package/lib/umd/index.js +3 -3
- package/package.json +3 -3
package/lib/umd/index.js
CHANGED
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
`,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}({});function th(e){return`${e}`}let nh=[eh.TABLE_START,eh.TABLE_ROW_START,eh.TABLE_CELL_START,eh.TABLE_CELL_END,eh.TABLE_ROW_END,eh.TABLE_END],rh=e=>{let t=e.endsWith(`\r
|
|
5
5
|
`)?e.slice(0,-2):e;return nh.reduce((e,t)=>e.replaceAll(t,``),t)},ih=e=>e?rh(e).replaceAll(`\r`,``)===``:!0,ah=e=>{let t=e.replace(/\n/g,`\r`),n=[],r=[],i=0,a=``,o=(o,s=!0)=>{let c=t.slice(i,o);if(R.isLegalUrl(c)){let t=Ya(),l=`${c}`,u={startIndex:i,endIndex:i+l.length-1,rangeId:t,rangeType:Po.HYPERLINK,properties:{url:e}};r.push(u),a+=l,i=o+1,s&&(a+=`\r`,n.push({startIndex:o}))}else a+=t.slice(i,o+1),i=o+1,s&&n.push({startIndex:o})},s=0;for(let e=0;e<t.length;e++)t[e]===`\r`&&(o(e),s=e);return(s!==t.length-1||t.length===1)&&o(t.length,!1),{dataStream:a,paragraphs:n,customRanges:r}},oh={id:`default_doc`,documentStyle:{}};var sh=class extends Pa{getUnitId(){throw Error(`Method not implemented.`)}constructor(e){var t;super(),P(this,`type`,I.UNIVER_DOC),P(this,`_name$`,new n.BehaviorSubject(``)),P(this,`name$`,this._name$.asObservable()),P(this,`snapshot`,void 0),this.snapshot={...oh,...e},this._name$.next((t=this.snapshot.title)==null?`No Title`:t)}getRev(){var e;return(e=this.snapshot.rev)==null?1:e}incrementRev(){this.snapshot.rev=this.getRev()+1}setRev(e){this.snapshot.rev=e}setName(e){this.snapshot.title=e,this._name$.next(e)}get drawings(){return this.snapshot.drawings}get documentStyle(){return this.snapshot.documentStyle}get lists(){return this.snapshot.lists}get zoomRatio(){var e;return((e=this.snapshot.settings)==null?void 0:e.zoomRatio)||1}resetDrawing(e,t){this.snapshot.drawings=e,this.snapshot.drawingsOrder=t}getBody(){return this.snapshot.body}getSnapshot(){return this.snapshot}getBulletPresetList(){var e;let t=(e=this.snapshot.lists)==null?{}:e;return{...um,...t}}updateDocumentId(e){this.snapshot.id=e}updateDocumentRenderConfig(e){let{documentStyle:t}=this.snapshot;t.renderConfig==null?t.renderConfig=e:t.renderConfig={...t.renderConfig,...e}}getDocumentStyle(){return this.snapshot.documentStyle}updateDocumentStyle(e){this.snapshot.documentStyle==null?this.snapshot.documentStyle=e:this.snapshot.documentStyle={...this.snapshot.documentStyle,...e}}updateDocumentDataMargin(e){let{t,l:n,b:r,r:i}=e,{documentStyle:a}=this.snapshot;t!=null&&(a.marginTop=t),n!=null&&(a.marginLeft=n),r!=null&&(a.marginBottom=r),i!=null&&(a.marginRight=i)}updateDocumentDataPageSize(e,t){let{documentStyle:n}=this.snapshot;if(!n.pageSize){n.pageSize={width:e==null?1/0:e,height:t==null?1/0:t};return}e!==void 0&&(n.pageSize.width=e),t!==void 0&&(n.pageSize.height=t)}updateDrawing(e,t){let{drawings:n}=this,{width:r,height:i,left:a,top:o}=t,s=n==null?void 0:n[e];if(!s)return;let c=s.docTransform;c.size.width=r,c.size.height=i,c.positionH.posOffset=a,c.positionV.posOffset=o}setZoomRatio(e=1){this.snapshot.settings?this.snapshot.settings.zoomRatio=e:this.snapshot.settings={zoomRatio:e}}setDisabled(e){this.snapshot.disabled=e}getDisabled(){return this.snapshot.disabled}getTitle(){return this.snapshot.title}},ch=class e extends sh{constructor(e){var t,r;super(R.isEmptyObject(e)?ws():e),P(this,`_unitId`,void 0),P(this,`headerModelMap`,new Map),P(this,`footerModelMap`,new Map),P(this,`change$`,new n.BehaviorSubject(0)),this._unitId=(t=this.snapshot.id)==null?Ya(6):t,this._initializeHeaderFooterModel(),this._name$.next((r=this.snapshot.title)==null?``:r)}dispose(){super.dispose(),this.headerModelMap.forEach(e=>{e.dispose()}),this.footerModelMap.forEach(e=>{e.dispose()}),this._name$.complete()}getDrawings(){return this.snapshot.drawings}getDrawingsOrder(){return this.snapshot.drawingsOrder}getCustomRanges(){var e;return(e=this.snapshot.body)==null?void 0:e.customRanges}getCustomDecorations(){var e;return(e=this.snapshot.body)==null?void 0:e.customDecorations}getSettings(){return this.snapshot.settings}reset(e){if(e.id&&e.id!==this._unitId)throw Error(`Cannot reset a document model with a different unit id!`);this.snapshot={...oh,...e},this._initializeHeaderFooterModel(),this.change$.next(this.change$.value+1)}getSelfOrHeaderFooterModel(e){if(e!=null){if(this.headerModelMap.has(e))return this.headerModelMap.get(e);if(this.footerModelMap.has(e))return this.footerModelMap.get(e)}return this}getUnitId(){return this._unitId}apply(e){if(!Qm.isNoop(e))return this.snapshot=Qm.apply(this.snapshot,e),e!=null&&e.some(e=>Array.isArray(e)&&((e==null?void 0:e[0])===`headers`||(e==null?void 0:e[0])===`footers`))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.change$.next(this.change$.value+1),this.snapshot}sliceBody(e,t,n=Cm.copy){let r=this.getBody();if(r!=null)return km(r,e,t,!1,n)}_initializeHeaderFooterModel(){let{headers:t,footers:n}=this.getSnapshot();if(t)for(let n in t){let r=t[n];this.headerModelMap.set(n,new e(r)),this.headerModelMap.get(n).updateDocumentId(this.getUnitId())}if(n)for(let t in n){let r=n[t];this.footerModelMap.set(t,new e(r)),this.footerModelMap.get(t).updateDocumentId(this.getUnitId())}}updateDocumentId(e){super.updateDocumentId(e),this._unitId=e}getPlainText(){var e,t;return rh((e=(t=this.getBody())==null?void 0:t.dataStream)==null?``:e)}};function lh(e){let{ranges:t,id:n,type:r}=e,i=new Q,a=0;for(let e=0;e<t.length;e++){let{startOffset:o,endOffset:s}=t[e];o>0&&i.push({t:U.RETAIN,len:o-a}),i.push({t:U.RETAIN,body:{dataStream:``,customDecorations:[{id:n,type:r,startIndex:0,endIndex:s-o-1}]},len:s-o}),a=s}return i}function uh(e){var t;let{id:n,segmentId:r,documentDataModel:i}=e,a=i==null?void 0:i.getBody();if(!i||!a)return!1;let o=(t=i.getSelfOrHeaderFooterModel(r))==null||(t=t.getBody())==null||(t=t.customDecorations)==null?void 0:t.find(e=>e.id===n);if(!o)return!1;let s=new Q,{startIndex:c,endIndex:l}=o,u=l-c+1;return s.push({t:U.RETAIN,len:c}),s.push({t:U.RETAIN,len:u,body:{dataStream:``,customDecorations:[{startIndex:0,endIndex:u-1,id:n,type:Fo.DELETED}]}}),s}function dh(e,t,n,r){return e<=n&&t>=n||e>=n&&e<=r}function fh(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];e.collapsed?i.startIndex<e.startOffset&&e.startOffset<=i.endIndex&&n.push(i):dh(e.startOffset,e.endOffset-1,i.startIndex,i.endIndex)&&n.push(i)}return n}function ph(e){return{...R.deepClone(e),rangeId:Ya()}}function mh(e,t){let n=[],r=e[0];for(let i of t)i<e[0]||i>e[1]||(r<i&&n.push([r,i-1]),r=i+1);return r<=e[1]&&n.push([r,e[1]]),n}function hh(e,t,n,r){let i=[];for(let a=0,o=n.length;a<o;a++){let o=n[a];if((r===void 0||o.rangeType===r)&&Math.max(o.startIndex,e)<=Math.min(o.endIndex,t)&&i.push({...o}),o.startIndex>t)break}return i}function gh(e,t){var n,r,i,a,o;let s=hh(e.startOffset,e.collapsed?e.startOffset:e.endOffset-1,(n=t.customRanges)==null?[]:n),c=Math.min(e.startOffset,(r=(i=s[0])==null?void 0:i.startIndex)==null?1/0:r),l=Math.max(e.endOffset,((a=(o=s[s.length-1])==null?void 0:o.endIndex)==null?-1/0:a)+1);return{startOffset:c,endOffset:l,collapsed:c===l}}var _h=m(d(((e,t)=>{var n=-1,r=1,i=0;function a(e,t,n,r,a){if(e===t)return e?[[i,e]]:[];if(n!=null){var s=D(e,t,n);if(s)return s}var c=l(e,t),u=e.substring(0,c);e=e.substring(c),t=t.substring(c),c=d(e,t);var f=e.substring(e.length-c);e=e.substring(0,e.length-c),t=t.substring(0,t.length-c);var m=o(e,t);return u&&m.unshift([i,u]),f&&m.push([i,f]),b(m,a),r&&p(m),m}function o(e,t){var o;if(!e)return[[r,t]];if(!t)return[[n,e]];var c=e.length>t.length?e:t,l=e.length>t.length?t:e,u=c.indexOf(l);if(u!==-1)return o=[[r,c.substring(0,u)],[i,l],[r,c.substring(u+l.length)]],e.length>t.length&&(o[0][0]=o[2][0]=n),o;if(l.length===1)return[[n,e],[r,t]];var d=f(e,t);if(d){var p=d[0],m=d[1],h=d[2],g=d[3],_=d[4],v=a(p,h),y=a(m,g);return v.concat([[i,_]],y)}return s(e,t)}function s(e,t){for(var i=e.length,a=t.length,o=Math.ceil((i+a)/2),s=o,l=2*o,u=Array(l),d=Array(l),f=0;f<l;f++)u[f]=-1,d[f]=-1;u[s+1]=0,d[s+1]=0;for(var p=i-a,m=p%2!=0,h=0,g=0,_=0,v=0,y=0;y<o;y++){for(var b=-y+h;b<=y-g;b+=2){for(var x=s+b,S=b===-y||b!==y&&u[x-1]<u[x+1]?u[x+1]:u[x-1]+1,C=S-b;S<i&&C<a&&e.charAt(S)===t.charAt(C);)S++,C++;if(u[x]=S,S>i)g+=2;else if(C>a)h+=2;else if(m){var w=s+p-b;if(w>=0&&w<l&&d[w]!==-1){var T=i-d[w];if(S>=T)return c(e,t,S,C)}}}for(var E=-y+_;E<=y-v;E+=2){for(var w=s+E,T=E===-y||E!==y&&d[w-1]<d[w+1]?d[w+1]:d[w-1]+1,D=T-E;T<i&&D<a&&e.charAt(i-T-1)===t.charAt(a-D-1);)T++,D++;if(d[w]=T,T>i)v+=2;else if(D>a)_+=2;else if(!m){var x=s+p-E;if(x>=0&&x<l&&u[x]!==-1){var S=u[x],C=s+S-x;if(T=i-T,S>=T)return c(e,t,S,C)}}}}return[[n,e],[r,t]]}function c(e,t,n,r){var i=e.substring(0,n),o=t.substring(0,r),s=e.substring(n),c=t.substring(r),l=a(i,o),u=a(s,c);return l.concat(u)}function l(e,t){if(!e||!t||e.charAt(0)!==t.charAt(0))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(a,i)==t.substring(a,i)?(n=i,a=n):r=i,i=Math.floor((r-n)/2+n);return x(e.charCodeAt(i-1))&&i--,i}function u(e,t){var n=e.length,r=t.length;if(n==0||r==0)return 0;n>r?e=e.substring(n-r):n<r&&(t=t.substring(0,n));var i=Math.min(n,r);if(e==t)return i;for(var a=0,o=1;;){var s=e.substring(i-o),c=t.indexOf(s);if(c==-1)return a;o+=c,(c==0||e.substring(i-o)==t.substring(0,o))&&(a=o,o++)}}function d(e,t){if(!e||!t||e.slice(-1)!==t.slice(-1))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(e.length-i,e.length-a)==t.substring(t.length-i,t.length-a)?(n=i,a=n):r=i,i=Math.floor((r-n)/2+n);return S(e.charCodeAt(e.length-i))&&i--,i}function f(e,t){var n=e.length>t.length?e:t,r=e.length>t.length?t:e;if(n.length<4||r.length*2<n.length)return null;function i(e,t,n){for(var r=e.substring(n,n+Math.floor(e.length/4)),i=-1,a=``,o,s,c,u;(i=t.indexOf(r,i+1))!==-1;){var f=l(e.substring(n),t.substring(i)),p=d(e.substring(0,n),t.substring(0,i));a.length<p+f&&(a=t.substring(i-p,i)+t.substring(i,i+f),o=e.substring(0,n-p),s=e.substring(n+f),c=t.substring(0,i-p),u=t.substring(i+f))}return a.length*2>=e.length?[o,s,c,u,a]:null}var a=i(n,r,Math.ceil(n.length/4)),o=i(n,r,Math.ceil(n.length/2)),s;if(!a&&!o)return null;s=o?a&&a[4].length>o[4].length?a:o:a;var c,u,f,p;e.length>t.length?(c=s[0],u=s[1],f=s[2],p=s[3]):(f=s[0],p=s[1],c=s[2],u=s[3]);var m=s[4];return[c,u,f,p,m]}function p(e){for(var t=!1,a=[],o=0,s=null,c=0,l=0,d=0,f=0,p=0;c<e.length;)e[c][0]==i?(a[o++]=c,l=f,d=p,f=0,p=0,s=e[c][1]):(e[c][0]==r?f+=e[c][1].length:p+=e[c][1].length,s&&s.length<=Math.max(l,d)&&s.length<=Math.max(f,p)&&(e.splice(a[o-1],0,[n,s]),e[a[o-1]+1][0]=r,o--,o--,c=o>0?a[o-1]:-1,l=0,d=0,f=0,p=0,s=null,t=!0)),c++;for(t&&b(e),y(e),c=1;c<e.length;){if(e[c-1][0]==n&&e[c][0]==r){var m=e[c-1][1],h=e[c][1],g=u(m,h),_=u(h,m);g>=_?(g>=m.length/2||g>=h.length/2)&&(e.splice(c,0,[i,h.substring(0,g)]),e[c-1][1]=m.substring(0,m.length-g),e[c+1][1]=h.substring(g),c++):(_>=m.length/2||_>=h.length/2)&&(e.splice(c,0,[i,m.substring(0,_)]),e[c-1][0]=r,e[c-1][1]=h.substring(0,h.length-_),e[c+1][0]=n,e[c+1][1]=m.substring(_),c++),c++}c++}}var m=/[^a-zA-Z0-9]/,h=/\s/,g=/[\r\n]/,_=/\n\r?\n$/,v=/^\r?\n\r?\n/;function y(e){function t(e,t){if(!e||!t)return 6;var n=e.charAt(e.length-1),r=t.charAt(0),i=n.match(m),a=r.match(m),o=i&&n.match(h),s=a&&r.match(h),c=o&&n.match(g),l=s&&r.match(g),u=c&&e.match(_),d=l&&t.match(v);return u||d?5:c||l?4:i&&!o&&s?3:o||s?2:i||a?1:0}for(var n=1;n<e.length-1;){if(e[n-1][0]==i&&e[n+1][0]==i){var r=e[n-1][1],a=e[n][1],o=e[n+1][1],s=d(r,a);if(s){var c=a.substring(a.length-s);r=r.substring(0,r.length-s),a=c+a.substring(0,a.length-s),o=c+o}for(var l=r,u=a,f=o,p=t(r,a)+t(a,o);a.charAt(0)===o.charAt(0);){r+=a.charAt(0),a=a.substring(1)+o.charAt(0),o=o.substring(1);var y=t(r,a)+t(a,o);y>=p&&(p=y,l=r,u=a,f=o)}e[n-1][1]!=l&&(l?e[n-1][1]=l:(e.splice(n-1,1),n--),e[n][1]=u,f?e[n+1][1]=f:(e.splice(n+1,1),n--))}n++}}function b(e,t){e.push([i,``]);for(var a=0,o=0,s=0,c=``,u=``,f;a<e.length;){if(a<e.length-1&&!e[a][1]){e.splice(a,1);continue}switch(e[a][0]){case r:s++,u+=e[a][1],a++;break;case n:o++,c+=e[a][1],a++;break;case i:var p=a-s-o-1;if(t){if(p>=0&&w(e[p][1])){var m=e[p][1].slice(-1);if(e[p][1]=e[p][1].slice(0,-1),c=m+c,u=m+u,!e[p][1]){e.splice(p,1),a--;var h=p-1;e[h]&&e[h][0]===r&&(s++,u=e[h][1]+u,h--),e[h]&&e[h][0]===n&&(o++,c=e[h][1]+c,h--),p=h}}if(C(e[a][1])){var m=e[a][1].charAt(0);e[a][1]=e[a][1].slice(1),c+=m,u+=m}}if(a<e.length-1&&!e[a][1]){e.splice(a,1);break}if(c.length>0||u.length>0){c.length>0&&u.length>0&&(f=l(u,c),f!==0&&(p>=0?e[p][1]+=u.substring(0,f):(e.splice(0,0,[i,u.substring(0,f)]),a++),u=u.substring(f),c=c.substring(f)),f=d(u,c),f!==0&&(e[a][1]=u.substring(u.length-f)+e[a][1],u=u.substring(0,u.length-f),c=c.substring(0,c.length-f)));var g=s+o;c.length===0&&u.length===0?(e.splice(a-g,g),a-=g):c.length===0?(e.splice(a-g,g,[r,u]),a=a-g+1):u.length===0?(e.splice(a-g,g,[n,c]),a=a-g+1):(e.splice(a-g,g,[n,c],[r,u]),a=a-g+2)}a!==0&&e[a-1][0]===i?(e[a-1][1]+=e[a][1],e.splice(a,1)):a++,s=0,o=0,c=``,u=``;break}}e[e.length-1][1]===``&&e.pop();var _=!1;for(a=1;a<e.length-1;)e[a-1][0]===i&&e[a+1][0]===i&&(e[a][1].substring(e[a][1].length-e[a-1][1].length)===e[a-1][1]?(e[a][1]=e[a-1][1]+e[a][1].substring(0,e[a][1].length-e[a-1][1].length),e[a+1][1]=e[a-1][1]+e[a+1][1],e.splice(a-1,1),_=!0):e[a][1].substring(0,e[a+1][1].length)==e[a+1][1]&&(e[a-1][1]+=e[a+1][1],e[a][1]=e[a][1].substring(e[a+1][1].length)+e[a+1][1],e.splice(a+1,1),_=!0)),a++;_&&b(e,t)}function x(e){return e>=55296&&e<=56319}function S(e){return e>=56320&&e<=57343}function C(e){return S(e.charCodeAt(0))}function w(e){return x(e.charCodeAt(e.length-1))}function T(e){for(var t=[],n=0;n<e.length;n++)e[n][1].length>0&&t.push(e[n]);return t}function E(e,t,a,o){return w(e)||C(o)?null:T([[i,e],[n,t],[r,a],[i,o]])}function D(e,t,n){var r=typeof n==`number`?{index:n,length:0}:n.oldRange,i=typeof n==`number`?null:n.newRange,a=e.length,o=t.length;if(r.length===0&&(i===null||i.length===0)){var s=r.index,c=e.slice(0,s),l=e.slice(s),u=i?i.index:null;editBefore:{var d=s+o-a;if(u!==null&&u!==d||d<0||d>o)break editBefore;var f=t.slice(0,d),p=t.slice(d);if(p!==l)break editBefore;var m=Math.min(s,d),h=c.slice(0,m),g=f.slice(0,m);if(h!==g)break editBefore;var _=c.slice(m),v=f.slice(m);return E(h,_,v,l)}editAfter:{if(u!==null&&u!==s)break editAfter;var y=s,f=t.slice(0,y),p=t.slice(y);if(f!==c)break editAfter;var b=Math.min(a-y,o-y),x=l.slice(l.length-b),S=p.slice(p.length-b);if(x!==S)break editAfter;var _=l.slice(0,l.length-b),v=p.slice(0,p.length-b);return E(c,_,v,x)}}if(r.length>0&&i&&i.length===0)replaceRange:{var h=e.slice(0,r.index),x=e.slice(r.index+r.length),m=h.length,b=x.length;if(o<m+b)break replaceRange;var g=t.slice(0,m),S=t.slice(o-b);if(h!==g||x!==S)break replaceRange;var _=e.slice(m,a-b),v=t.slice(m,o-b);return E(h,_,v,x)}return null}function O(e,t,n,r){return a(e,t,n,r,!0)}O.INSERT=r,O.DELETE=n,O.EQUAL=i,t.exports=O}))());function vh(e){var t,n;let{rangeId:r,segmentId:i,documentDataModel:a,insert:o}=e,s=(t=a.getSelfOrHeaderFooterModel(i).getBody())==null||(t=t.customRanges)==null?void 0:t.find(e=>e.rangeId===r);if(!s)return!1;let{startIndex:c,endIndex:l}=s,u=new Q,d=l-c+1;u.push({t:U.RETAIN,len:c}),u.push({t:U.RETAIN,len:d,body:{dataStream:``,customRanges:[]}}),o&&u.push({t:U.INSERT,body:o,len:o.dataStream.length});let f=l+1+((n=o==null?void 0:o.dataStream.length)==null?0:n);return u.selections=[{startOffset:f,endOffset:f,collapsed:!0}],u}function yh(e){let{ranges:t,rangeId:n,rangeType:r,wholeEntity:i,properties:a,body:o}=e,s=0,c=new Q,l=!1;return t.forEach(e=>{var t,u,d;let f=gh(e,o);if(!f||!o)return!1;let{startOffset:p,endOffset:m}=f,h=(t=o.customRanges)==null?[]:t,g=(e,t,o)=>{var l,u,d,f;let p=hh(e,t,h,r),m=Math.min((l=(u=p[0])==null?void 0:u.startIndex)==null?1/0:l,e),g=Math.max((d=(f=p[p.length-1])==null?void 0:f.endIndex)==null?-1/0:d,t),_={rangeId:o?`${n}$${o}`:n,rangeType:r,startIndex:0,endIndex:g-m,wholeEntity:i,properties:{...a}};c.push({t:U.RETAIN,len:m-s}),c.push({t:U.RETAIN,len:g-m+1,body:{dataStream:``,customRanges:[_]},coverType:H.COVER}),s=g+1},_=((u=o.paragraphs)==null?[]:u).filter(e=>e.startIndex<m&&e.startIndex>p),v=((d=o.customBlocks)==null?[]:d).filter(e=>e.startIndex<m&&e.startIndex>p);mh([p,m-1],[..._.map(e=>e.startIndex),...v.map(e=>e.startIndex)]).forEach(([e,t],n)=>g(e,t,n)),l=!0,c.selections=[{startOffset:f.endOffset,endOffset:f.endOffset,collapsed:!0}]}),l?c:!1}function bh(e,t,n=0,r=null,i=!0){e.sort((e,t)=>e.startOffset-t.startOffset);let a=[],{paragraphs:o=[]}=t,s=o==null?void 0:o.find(t=>t.startIndex>=e[0].startOffset&&t.startIndex<e[0].endOffset),c=n;if(e.forEach(e=>{let{startOffset:t,endOffset:n}=e;t>c&&(a.push({t:U.RETAIN,len:t-c}),c=t),c<n&&(a.push({t:U.DELETE,len:n-c}),c=n)}),r&&a.push({t:U.INSERT,body:r,len:r.dataStream.length}),s&&i){let t=o.find(t=>t.startIndex-n>=e[e.length-1].endOffset-1);t&&(t.startIndex>c&&(a.push({t:U.RETAIN,len:t.startIndex-c}),c=t.startIndex),a.push({t:U.RETAIN,len:1,body:{dataStream:``,paragraphs:[{...t,startIndex:0,bullet:s==null?void 0:s.bullet}]},coverType:H.REPLACE}))}return a}function xh(e,t,n=0){let r=[],i=n;return e.forEach(e=>{let{startOffset:n,endOffset:a}=e;n>i&&(r.push({t:U.RETAIN,len:n-i}),i=n),a>i&&(r.push({t:U.RETAIN,len:a-i,body:{...R.deepClone(t),dataStream:``}}),i=a)}),r}let Sh=e=>{var t;let{selection:n,body:r,doc:i}=e,a=n.segmentId,o=(t=i.getSelfOrHeaderFooterModel(a))==null?void 0:t.getBody();if(!o)return!1;let s=n.collapsed?null:km(o,n.startOffset,n.endOffset),c=(0,_h.default)(s?s.dataStream:``,r.dataStream),l=0,u=c.map(([e,t])=>{switch(e){case 0:{let e={t:U.RETAIN,body:{...km(r,l,l+t.length,!1),dataStream:``},len:t.length};return l+=t.length,e}case 1:{let e={t:U.INSERT,body:km(r,l,l+t.length),len:t.length};return l+=t.length,e}default:return{t:U.DELETE,len:t.length}}}),d=new Q;return d.push({t:U.RETAIN,len:n.startOffset}),d.push(...u),d};function Ch(e,t){return!!((e==null?void 0:e.length)===(t==null?void 0:t.length)&&e!=null&&e.every((e,n)=>JSON.stringify(e)===JSON.stringify(t==null?void 0:t[n])))}let wh=e=>{var t;let{selection:n,body:r,doc:i,themeService:a}=e,o=n.segmentId,s=(t=i.getSelfOrHeaderFooterModel(o))==null?void 0:t.getBody();if(!s)return!1;let c=n.collapsed?null:km(s,n.startOffset,n.endOffset),l=(0,_h.default)(c?c.dataStream:``,r.dataStream),u=0,d=l.map(([e,t])=>{switch(e){case 0:{let e=wm(r,u,u+t.length,!1),n=wm(c,u,u+t.length,!1),i={t:U.RETAIN,body:Ch(e,n)?void 0:{textRuns:e==null?void 0:e.map(e=>{var t,n,r,i;return{...e,ts:{...e.ts,cl:!((t=e.ts)==null||(t=t.cl)==null||(t=t.rgb)==null)&&t.includes(`.`)?{rgb:a.getColorFromTheme((n=(r=e.ts)==null||(r=r.cl)==null?void 0:r.rgb)==null?``:n)}:(i=e.ts)==null?void 0:i.cl}}}),dataStream:``},len:t.length};return u+=t.length,i}case 1:{let e={t:U.INSERT,body:km(r,u,u+t.length),len:t.length};return u+=t.length,e}default:return{t:U.DELETE,len:t.length}}});if(d.every(e=>e.t===U.RETAIN&&!e.body))return!1;let f=new Q;return f.push({t:U.RETAIN,len:n.startOffset}),f.push(...d),f};function Th(e,t){let n=[],{customBlocks:r=[]}=e;for(let e of t){let{startOffset:t,endOffset:i}=e;if(!(t==null||i==null))for(let e of r){let{startIndex:r}=e;r>=t&&r<i&&n.push(e.blockId)}}return n}function Eh(e,t=``){if(!t)return[`body`];let{headers:n,footers:r}=e.getSnapshot();if(n==null&&r==null)throw 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 Error(`Segment id not found in headers or footers`)}let Dh=e=>{var t,n;let{selection:r,documentDataModel:i,drawings:a}=e,{collapsed:o,startOffset:s,segmentId:c}=r,l=new Q,u=Qm.getInstance(),d=[],f=i.getSelfOrHeaderFooterModel(c).getBody();if(!f)return!1;let p=(t=(n=i.getSnapshot().drawingsOrder)==null?void 0:n.length)==null?0:t,m=0;if(o)s>0&&l.push({t:U.RETAIN,len:s});else{var h,g;let e=bh([r],f,0,null,!1);l.push(...e);let t=Th(f,[r]),n=(h=i.getDrawings())==null?{}:h,a=(g=i.getDrawingsOrder())==null?[]:g,o=t.sort((e,t)=>a.indexOf(e)>a.indexOf(t)?-1:a.indexOf(e)<a.indexOf(t)?1:0);if(o.length>0)for(let e of o){let t=n[e],r=a.indexOf(e);if(t==null||r<0)continue;let i=u.removeOp([`drawings`,e],t),o=u.removeOp([`drawingsOrder`,r],e);d.push(i),d.push(o),m++}}l.push({t:U.INSERT,body:{dataStream:`\b`.repeat(a.length),customBlocks:a.map((e,t)=>({startIndex:t,blockId:e.drawingId}))},len:a.length});let _=Eh(i,c),v=u.editOp(l.serialize(),_);d.push(v);for(let e of a){let{drawingId:t}=e,n=u.insertOp([`drawings`,t],e),r=u.insertOp([`drawingsOrder`,p-m],t);d.push(n),d.push(r)}return d.reduce((e,t)=>Qm.compose(e,t),null)};function Oh(e,t){if(t===void 0)return{startOffset:e,endOffset:e,collapsed:!0};if(t<e)throw Error(`Cannot make a doc selection when endOffset ${t} is less than startOffset ${e}.`);return{startOffset:e,endOffset:t,collapsed:e===t}}function kh(e){let{startOffset:t,endOffset:n,collapsed:r}=e;return{startOffset:Math.min(t,n),endOffset:Math.max(t,n),collapsed:r}}function Ah(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function jh(e,t,n,r){let{startOffset:i,endOffset:a}=e,o=r==null?Ph(t,n):r,s=[],c=-1;for(let e=0;e<o.length;e++){let t=o[e],{startIndex:n}=t;(i>c&&i<=n||a>c&&a<=n||n>=i&&n<=a)&&s.push(t),c=n}return s}function Mh(e,t,n){let r=[],i=Ph(t,n);for(let a of e){let e=jh(a,t,n,i);r.push(...e)}return r}let Nh=[eh.PARAGRAPH,eh.TABLE_START,eh.TABLE_END,eh.TABLE_ROW_START,eh.TABLE_CELL_START,eh.TABLE_CELL_END];function Ph(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r],{startIndex:a}=i,o=a-1;for(;!Nh.includes(t[o])&&o>=0;)o--;n.push({...i,paragraphStart:o+1,paragraphEnd:i.startIndex})}return n}let Fh=e=>{var t,n;let{paragraphs:r,segmentId:i,document:a}=e,o=e.listType,s=(t=(n=a.getSelfOrHeaderFooterModel(i).getBody())==null?void 0:n.paragraphs)==null?[]:t,c=r.every(e=>{var t;return((t=e.bullet)==null?void 0:t.listType.indexOf(o))===0}),l=Ya(6);if(r.length===1){let e=s.indexOf(r[0]),t=s[e-1],n=s[e+1];t&&t.bullet&&t.bullet.listType.indexOf(o)===0?(l=t.bullet.listId,o!==Z.CHECK_LIST&&(o=t.bullet.listType)):n&&n.bullet&&n.bullet.listType.indexOf(o)===0&&(l=n.bullet.listId,o!==Z.CHECK_LIST&&(o=n.bullet.listType))}let u=new Ui;u.reset();let d=new Q;for(let e of r){var f;let{startIndex:t,paragraphStyle:n={},bullet:r}=e;d.push({t:U.RETAIN,len:t-u.cursor}),d.push({t:U.RETAIN,len:1,body:{dataStream:``,paragraphs:[c?{paragraphStyle:n,startIndex:0}:{startIndex:0,paragraphStyle:{...n},bullet:{nestingLevel:(f=r==null?void 0:r.nestingLevel)==null?0:f,textStyle:{fs:20},listType:o,listId:l}}]},coverType:H.REPLACE}),u.moveCursorTo(t+1)}return d},Ih=e=>{var t;let{paragraphIndex:n,segmentId:r,document:i}=e,a=(t=i.getSelfOrHeaderFooterModel(r).getBody())==null?void 0:t.paragraphs;if(a==null)return!1;let o=a.find(e=>e.startIndex===n);if(!(o!=null&&o.bullet)||o.bullet.listType.indexOf(Z.CHECK_LIST)===-1)return!1;let s=new Ui;s.reset();let c=new Q,{startIndex:l,paragraphStyle:u={}}=o,d=o.bullet.listType===Z.CHECK_LIST?Z.CHECK_LIST_CHECKED:Z.CHECK_LIST;return c.push({t:U.RETAIN,len:l-s.cursor}),c.push({t:U.RETAIN,len:1,body:{dataStream:``,paragraphs:[{...o,paragraphStyle:u,startIndex:0,bullet:{...o.bullet,listType:d}}]},coverType:H.REPLACE}),s.moveCursorTo(l+1),c},Lh=e=>{var t;let{paragraphs:n,listType:r,segmentId:i,document:a}=e;if(((t=a.getSelfOrHeaderFooterModel(i).getBody())==null?void 0:t.paragraphs)==null)return!1;let o=Ya(6),s=new Ui;s.reset();let c=new Q;for(let e of n){var l;let{startIndex:t,paragraphStyle:n={},bullet:i}=e;c.push({t:U.RETAIN,len:t-s.cursor}),c.push({t:U.RETAIN,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphStyle:n,bullet:{nestingLevel:(l=i==null?void 0:i.nestingLevel)==null?0:l,textStyle:(i==null?void 0:i.listType)===r?i.textStyle:{fs:20},listType:r,listId:o}}]},coverType:H.REPLACE}),s.moveCursorTo(t+1)}return c};function Rh(e,t){return t.some(t=>e.startIndex>t.startIndex&&e.startIndex<t.endIndex)}let zh=e=>{var t,n,r;let{paragraphs:i,document:a,type:o}=e,s=new Ui;s.reset();let c=new Q,l=(t=a.getSnapshot().lists)==null?{}:t,u=(n=(r=a.getBody())==null?void 0:r.tables)==null?[]:n,d={...um,...l};for(let e of i){let{startIndex:t,paragraphStyle:n={},bullet:r}=e,i=Rh(e,u);if(c.push({t:U.RETAIN,len:t-s.cursor}),r){let e=d[r.listType].nestingLevel.length-1;i&&(e=Math.min(e,2)),c.push({t:U.RETAIN,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphStyle:{...n},bullet:{...r,nestingLevel:Math.max(Math.min(r.nestingLevel+o,e),0)}}]},coverType:H.REPLACE})}else c.push({t:U.RETAIN,len:1});s.moveCursorTo(t+1)}return c},Bh=e=>{var t,n,r,i;let{textRanges:a,segmentId:o,document:s,style:c,paragraphTextRun:l,cursor:u,deleteLen:d,textX:f}=e,p=s.getSelfOrHeaderFooterModel(o),m=Mh(a,(t=(n=p.getBody())==null?void 0:n.paragraphs)==null?[]:t,(r=(i=p.getBody())==null?void 0:i.dataStream)==null?``:r),h=new Ui;u&&h.moveCursorTo(u);let g=f==null?new Q:f;m.sort((e,t)=>e.startIndex-t.startIndex);let _=Math.max(0,m[0].paragraphStart-1);_>h.cursor&&(g.push({t:U.RETAIN,len:_-h.cursor}),h.moveCursorTo(_)),d&&g.push({t:U.DELETE,len:d});for(let e of m){let{startIndex:t,paragraphStyle:n={}}=e,r=t-h.cursor;g.push({t:U.RETAIN,len:r,...l?{body:{dataStream:``,textRuns:[{ts:l,st:0,ed:r}]},coverType:H.REPLACE}:null}),g.push({t:U.RETAIN,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphStyle:{...n,...c}}]},coverType:H.REPLACE}),h.moveCursorTo(t+1)}return g};var Vh=class{};P(Vh,`customRange`,{add:yh,delete:vh,copyCustomRange:ph,getCustomRangesInterestsWithSelection:fh,isIntersecting:dh}),P(Vh,`customDecoration`,{add:lh,delete:uh}),P(Vh,`selection`,{replace:Sh,makeSelection:Oh,normalizeSelection:kh,delete:bh,replaceTextRuns:wh,retain:xh}),P(Vh,`range`,{isIntersects:Ah,getParagraphsInRange:jh,getParagraphsInRanges:Mh}),P(Vh,`transform`,{getPlainText:rh,fromPlainText:ah,isEmptyDocument:ih}),P(Vh,`paragraph`,{bullet:{set:Lh,switch:Fh,toggleChecklist:Ih,changeNestLevel:zh},style:{set:Bh},util:{transform:Ph,getParagraphsInRange:jh,getParagraphsInRanges:Mh}}),P(Vh,`drawing`,{add:Dh});function Hh(e,t,n,r){if(t===``)return e;let i=new ch({id:`mock-id`,body:e,documentStyle:{}}),a=t.length,o;for(;(o=(r?i.getBody().dataStream:i.getBody().dataStream.toLowerCase()).indexOf(t))>=0;){let e=new Q,t=Qm.getInstance();if(o>0&&e.retain(o),n.length>0){var s;let t=i.sliceBody(o,o+a),r={dataStream:n};Array.isArray(t==null?void 0:t.textRuns)&&t.textRuns.length&&(r.textRuns=[{...t.textRuns[0],st:0,ed:n.length}]),!(t==null||(s=t.customRanges)==null)&&s.length&&(r.customRanges=[{...t.customRanges[0],startIndex:0,endIndex:n.length-1}]),e.insert(n.length,r)}e.delete(a),i.apply(t.editOp(e.serialize()))}let c=i.getBody();return i.dispose(),c}function Uh(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 Wh(e){var t;return e.body=Uh((t=e.body)==null?{dataStream:``}:t),e.drawingsOrder||(e.drawingsOrder=[]),e.drawings||(e.drawings={}),e.documentStyle||(e.documentStyle={}),e}var Gh=class e{static create(t={}){return new e(t)}constructor(e={}){P(this,`_style`,void 0),this._style=e}get fontFamily(){return this._style.ff}get fontSize(){return this._style.fs}get italic(){return this._style.it===B.TRUE}get bold(){return this._style.bl===B.TRUE}get underline(){return this._style.ul&&qh.create(this._style.ul)}get bottomBorderLine(){return this._style.bbl&&qh.create(this._style.bbl)}get strikethrough(){return this._style.st&&qh.create(this._style.st)}get overline(){return this._style.ol&&qh.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 Kh.create(R.deepClone(this._style))}getValue(){return{...this._style}}},Kh=class e extends Gh{static create(t={}){return new e(t)}constructor(e={}){super(e)}setFontFamily(e){return this._style.ff=e,this}setFontSize(e){return this._style.fs=e,this}setItalic(e){return this._style.it=e?1:0,this}setBold(e){return this._style.bl=e?1:0,this}setUnderline(e){return this._style.ul=e.build(),this}setBottomBorderLine(e){return this._style.bbl=e.build(),this}setStrikethrough(e){return this._style.st=e.build(),this}setOverline(e){return this._style.ol=e.build(),this}setBackground(e){return this._style.bg=e,this}setBorder(e){return this._style.bd=e,this}setColor(e){return this._style.cl=e,this}setVerticalAlign(e){return this._style.va=e,this}copy(){return e.create(R.deepClone(this._style))}build(){return this.getValue()}},qh=class e{static create(t={s:1}){return new e(t)}constructor(e={s:1}){P(this,`_decoration`,void 0),this._decoration=e}get show(){return this._decoration.s===B.TRUE}get followFontColor(){return this._decoration.c===B.TRUE}get color(){return this._decoration.cl}get type(){return this._decoration.t}setShow(e){return this._decoration.s=e?1:0,this}setFollowFontColor(e){return this._decoration.c=e?1:0,this}setColor(e){return this._decoration.cl=e,this}setLineType(e){return this._decoration.t=e,this}copy(){return e.create(R.deepClone(this._decoration))}build(){return{...this._decoration}}},Jh=class e{static create(t={}){return new e(t)}constructor(e={}){P(this,`_style`,void 0),this._style=e}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===B.TRUE}get keepNext(){return this._style.keepNext===B.TRUE}get wordWrap(){return this._style.wordWrap===B.TRUE}get widowControl(){return this._style.widowControl===B.TRUE}get shading(){return this._style.shading}get suppressHyphenation(){return this._style.suppressHyphenation===B.TRUE}copy(){return Yh.create(R.deepClone(this._style))}getValue(){return this._style}},Yh=class e extends Jh{static create(t={}){return new e(t)}constructor(e={}){super(e)}setIndentFirstLine(e){return this._style.indentFirstLine=e,this}setHanging(e){return this._style.hanging=e,this}setIndentStart(e){return this._style.indentStart=e,this}setTabStops(e){return this._style.tabStops=e,this}setIndentEnd(e){return this._style.indentEnd=e,this}setTextStyle(e){return this._style.textStyle=e,this}setHeadingId(e){return this._style.headingId=e,this}setNamedStyleType(e){return this._style.namedStyleType=e,this}setHorizontalAlign(e){return this._style.horizontalAlign=e,this}setLineSpacing(e){return this._style.lineSpacing=e,this}setDirection(e){return this._style.direction=e,this}setSpacingRule(e){return this._style.spacingRule=e,this}setSnapToGrid(e){return this._style.snapToGrid=e?1:0,this}setSpaceAbove(e){return this._style.spaceAbove=e,this}setSpaceBelow(e){return this._style.spaceBelow=e,this}setBorderBetween(e){return this._style.borderBetween=e,this}setBorderTop(e){return this._style.borderTop=e,this}setBorderBottom(e){return this._style.borderBottom=e,this}setBorderLeft(e){return this._style.borderLeft=e,this}setBorderRight(e){return this._style.borderRight=e,this}setKeepLines(e){return this._style.keepLines=e?1:0,this}setKeepNext(e){return this._style.keepNext=e?1:0,this}setWordWrap(e){return this._style.wordWrap=e?1:0,this}setWidowControl(e){return this._style.widowControl=e?1:0,this}setShading(e){return this._style.shading=e,this}setSuppressHyphenation(e){return this._style.suppressHyphenation=e?1:0,this}copy(){return e.create(R.deepClone(this._style))}build(){return this.getValue()}},Xh=class e{static create(t){return new e(t)}static createByBody(t){return new e({body:t,id:`d`,documentStyle:{}})}constructor(e){if(P(this,`_data`,void 0),!e.body)throw Error(`Invalid document data, body is required`);this._data=Wh(e)}copy(){return Zh.create(R.deepClone(this._data))}slice(e,t){let{body:n,...r}=this._data;return Zh.create({...R.deepClone(r),body:km(n,e,t)})}toPlainText(){var e,t;return Vh.transform.getPlainText((e=(t=this._data.body)==null?void 0:t.dataStream)==null?``:e).replaceAll(`\r`,`
|
|
6
6
|
`)}getParagraphStyle(){var e;return Jh.create((e=this._data.body)==null||(e=e.paragraphs)==null?void 0:e[0].paragraphStyle)}getParagraphBullet(){var e;return(e=this._data.body)==null||(e=e.paragraphs)==null?void 0:e[0].bullet}getParagraphs(){var e,t;let n=(e=(t=this._data.body)==null?void 0:t.paragraphs)==null?[]:e,r=0;return n.map(e=>{let t=this.slice(r,e.startIndex);return r=e.startIndex,t})}getTextRuns(){var e,t;return((e=(t=this._data.body)==null?void 0:t.textRuns)==null?[]:e).map(e=>({...e,ts:e.ts?Gh.create(e.ts):null}))}getLinks(){var e,t;return(e=(t=this._data.body)==null||(t=t.customRanges)==null?void 0:t.filter(e=>e.rangeType===Po.HYPERLINK))==null?[]:e}getData(){return this._data}},Zh=class e extends Xh{static newEmptyData(){return Wh({id:`d`,documentStyle:{},drawings:{},drawingsOrder:[],body:{dataStream:`\r
|
|
7
|
-
`,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(t){return new e(t==null?e.newEmptyData():t)}constructor(e){super(e),P(this,`_doc`,void 0),this._doc=new ch(e)}insertText(e,t,n){var r,i;let a=((r=(i=this._data.body)==null?void 0:i.dataStream.length)==null?2:r)-2,o,s;if(typeof e==`string`?o=e:(a=Math.min(e,a),o=t),s=typeof t==`object`?t instanceof Kh?t.build():t:n instanceof Kh?n.build():n,!o)return this;let c={dataStream:o,textRuns:s?[{ts:s,st:a,ed:a+o.length}]:[]},l=Vh.selection.replace({doc:this._doc,selection:{startOffset:a,endOffset:a,collapsed:!0},body:c});if(!l)throw Error(`Insert text failed, please check.`);return Q.apply(this._doc.getBody(),l.serialize()),this}insertRichText(e,t){var n,r;let i=((n=(r=this._data.body)==null?void 0:r.dataStream.length)==null?2:n)-2,a;typeof e==`object`?a=e instanceof Xh?e.getData():e:(i=Math.min(e,i),a=t instanceof Xh?t.getData():t);let o=Vh.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:a.body});if(!o)throw Error(`Insert text failed, please check.`);return Q.apply(this._doc.getBody(),o.serialize()),this}delete(e,t){if(t!==void 0){if(!t)return this;let n=Vh.selection.delete([{startOffset:e,endOffset:e+t,collapsed:!0}],this._data.body);Q.apply(this._doc.getBody(),n)}return this}setStyle(e,t,n){let r={dataStream:``,textRuns:[{ts:n instanceof Kh?n.build():n,st:0,ed:t-e}]},i=Vh.selection.retain([{startOffset:e,endOffset:t,collapsed:!0}],r);return Q.apply(this._doc.getBody(),i),this}setLink(e,t,n){let r=Vh.customRange.add({rangeType:Po.HYPERLINK,rangeId:Ya(),properties:{url:n},ranges:[{startOffset:e,endOffset:t,collapsed:!1}],body:this._data.body});if(!r)throw Error(`Insert text failed, please check.`);return Q.apply(this._doc.getBody(),r.serialize()),this}cancelLink(e,t){if(typeof e==`string`){let t=Vh.customRange.delete({rangeId:e,documentDataModel:this._doc});if(!t)throw Error(`Insert text failed, please check.`);Q.apply(this._doc.getBody(),t.serialize())}else this.slice(e,t).getLinks().forEach(e=>{let t=Vh.customRange.delete({rangeId:e.rangeId,documentDataModel:this._doc});if(!t)throw Error(`Insert text failed, please check.`);Q.apply(this._doc.getBody(),t.serialize())});return this}updateLink(e,t){var n;let r=(n=this._data.body)==null||(n=n.customRanges)==null?void 0:n.find(t=>t.rangeId===e);if(!r)throw Error(`Link not found`);return r.properties.url=t,this}insertParagraph(e,t){let n,r;if(typeof e==`object`){var i,a;n={dataStream:`\r`,paragraphs:[{startIndex:0,paragraphStyle:e.build()}]},r=((i=(a=this._data.body)==null?void 0:a.dataStream.length)==null?2:i)-2}else r=e,n={dataStream:`\r`,paragraphs:[{startIndex:0,paragraphStyle:t==null?void 0:t.build()}]};return this.insertRichText(r,Xh.create({body:n,id:`d`,documentStyle:{}})),this}insertLink(t,n,r){let i=``,a=``;typeof t==`string`?(i=t,a=n):(i=n,a=r);let o=e.createByBody({dataStream:i,customRanges:[{rangeType:Po.HYPERLINK,rangeId:Ya(),properties:{url:a},startIndex:0,endIndex:i.length-1}]});return typeof t==`number`?this.insertRichText(t,o):this.insertRichText(o)}},Qh=class{constructor(){P(this,`skipNextObservers`,!1),P(this,`lastReturnValue`,void 0),P(this,`isStopPropagation`,!1)}stopPropagation(){this.isStopPropagation=!0}},$h=class extends n.Subject{constructor(...e){super(...e),P(this,`_sortedObservers`,[])}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(e){let t;t=typeof e==`function`?{next:([t,n])=>e(t,n)}:e;let n=super.subscribe(t);return this._sortedObservers.push(t),this._sortedObservers.sort((e,t)=>{var n,r;return((n=e.priority)==null?0:n)-((r=t.priority)==null?0:r)}),n.add(()=>this._sortedObservers=this._sortedObservers.filter(e=>e!==t)),n}clearObservers(){this._sortedObservers.forEach(e=>{var t;return(t=e.complete)==null?void 0:t.call(e)}),this._sortedObservers.length=0}emitEvent(e){if(!this.closed){let n=new Qh;n.lastReturnValue=e;for(let r of this._sortedObservers){var t;if(n.lastReturnValue=(t=r.next)==null?void 0:t.call(r,[e,n]),n.skipNextObservers)return{handled:!0,lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}throw Error(`[EventSubject]: cannot emit event on a closed subject.`)}};function eg(e){return new n.Observable(t=>{let n=e.subscribeEvent(e=>{t.next(e)});return()=>n.unsubscribe()})}let tg=(0,t.createIdentifier)(`core.resource-manager.service`),ng={[L.Editor]:`Editor`,[L.Owner]:`Owner`,[L.Reader]:`Reader`,[L.UNRECOGNIZED]:`UNRECOGNIZED`},rg=e=>e?{userID:`${ng[e]}_${Ya(8)}`,name:ng[e],avatar:``}:{userID:``,name:``,avatar:``,anonymous:!0,canBindAnonymous:!1},ig=(e,t)=>e.startsWith(ng[t]);var ag=class extends ra{constructor(...e){super(...e),P(this,`_model`,new Map),P(this,`_userChange$`,new n.Subject),P(this,`userChange$`,this._userChange$.asObservable()),P(this,`_currentUser$`,new n.BehaviorSubject(rg())),P(this,`currentUser$`,this._currentUser$.asObservable())}dispose(){super.dispose(),this._model.clear(),this._userChange$.complete(),this._currentUser$.complete()}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(e){this.addUser(e),this._currentUser$.next(e)}addUser(e){this._model.set(e.userID,e),this._userChange$.next({type:`add`,user:e})}getUser(e,t){let n=this._model.get(e);if(n)return n;t&&t()}delete(e){let t=this.getUser(e);this._model.delete(e),t&&this._userChange$.next({type:`delete`,user:t})}clear(){this._model.clear(),this._userChange$.next({type:`clear`})}list(){return Array.from(this._model.values())}};let og=class{constructor(e,t){this._resourceManagerService=e,this._userManagerService=t,P(this,`_permissionMap`,new Map([])),P(this,`_permissionOverrides`,new Map),this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){let e=this._userManagerService.getCurrentUser();e&&e.userID||this._userManagerService.setCurrentUser(rg(L.Owner))}_getRole(e){let t=this._userManagerService.getCurrentUser();return t?ig(t.userID,e):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:e=>{let t=[...this._permissionMap.keys()].reduce((e,t)=>(e[t]=this._permissionMap.get(t),e),{});return JSON.stringify(t)},parseJson:e=>JSON.parse(e),pluginName:`SHEET_AuthzIoMockService_PLUGIN`,businesses:[I.UNIVER_SHEET,I.UNIVER_DOC,I.UNIVER_SLIDE],onLoad:(e,t)=>{for(let e in t)this._permissionMap.set(e,t[e])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(e){let t=Ya(8),{objectType:n,selectRangeObject:r,worksheetObject:i}=e,a=r||i,o={objectType:n,unitID:(a==null?void 0:a.unitID)||``,name:(a==null?void 0:a.name)||``,strategies:[{action:6,role:L.Owner},{action:16,role:L.Owner},{action:17,role:L.Owner},{action:18,role:L.Owner},{action:19,role:L.Owner},{action:33,role:L.Owner},{action:34,role:L.Owner},{action:35,role:L.Owner},{action:36,role:L.Owner},{action:37,role:L.Owner},{action:38,role:L.Owner},{action:39,role:L.Owner},{action:40,role:L.Owner}],selectRangeObject:r};return this._permissionMap.set(t,o),t}async allowed(e){let{objectID:t,actions:n}=e,r=this._permissionMap.get(t);return r?n.map(e=>{let n=`${t}:${e}`;if(this._permissionOverrides.has(n))return{action:e,allowed:this._permissionOverrides.get(n)};let i=r.strategies.find(t=>t.action===e);return i?{action:e,allowed:this._getRole(i.role)}:{action:e,allowed:this._getRole(L.Owner)||this._getRole(L.Editor)}}):n.map(e=>({action:e,allowed:this._getRole(L.Owner)||this._getRole(L.Editor)}))}async batchAllowed(e){let t=await Promise.all(e.map(e=>this.allowed(e)));return e.map((e,n)=>({unitID:e.unitID,objectID:e.objectID,actions:t[n]}))}async list(e){let t=[],n=[{action:6,role:L.Owner},{action:16,role:L.Owner},{action:17,role:L.Owner},{action:18,role:L.Owner},{action:19,role:L.Owner},{action:33,role:L.Owner},{action:34,role:L.Owner},{action:35,role:L.Owner},{action:36,role:L.Owner},{action:37,role:L.Owner},{action:38,role:L.Owner},{action:39,role:L.Owner},{action:40,role:L.Owner}];return e.objectIDs.forEach(r=>{let i=this._permissionMap.get(r),a=(i==null?void 0:i.strategies)||n,o={objectID:r,unitID:e.unitID,objectType:(i==null?void 0:i.objectType)||3,name:(i==null?void 0:i.name)||``,shareOn:!1,shareRole:L.Owner,shareScope:-1,scope:{read:pa.AllCollaborator,edit:pa.AllCollaborator},creator:rg(L.Owner),strategies:a.map(e=>({action:e.action,role:e.role})),actions:e.actions.map(e=>{let t=`${r}:${e}`;if(this._permissionOverrides.has(t))return{action:e,allowed:this._permissionOverrides.get(t)};let n=a.find(t=>t.action===e);return n?{action:e,allowed:this._getRole(n.role)}:{action:e,allowed:this._getRole(L.Owner)||this._getRole(L.Editor)}})};t.push(o)}),t}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(e){let{objectID:t,strategies:n}=e,r=this._permissionMap.get(t);r&&n&&(r.strategies=n.map(e=>({action:e.action,role:e.role})),this._permissionMap.set(t,r),n.forEach(e=>{e.role===L.Reader?this.setPermissionOverride(t,e.action,!1):(e.role===L.Owner||e.role===L.Editor)&&this.clearPermissionOverride(t,e.action)}))}setPermissionOverride(e,t,n){let r=`${e}:${t}`;this._permissionOverrides.set(r,n)}clearPermissionOverride(e,t){let n=`${e}:${t}`;this._permissionOverrides.delete(n)}clearAllOverrides(e){let t=[];this._permissionOverrides.forEach((n,r)=>{r.startsWith(`${e}:`)&&t.push(r)}),t.forEach(e=>this._permissionOverrides.delete(e))}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(e){}};og=Us([W(0,tg),W(1,(0,t.Inject)(ag))],og);let sg=(0,t.createIdentifier)(`IAuthzIoIoService`),cg=(0,t.createIdentifier)(`univer.confirm-service`);var lg=class{constructor(){P(this,`confirmOptions$`,new n.Subject)}dispose(){this.confirmOptions$.complete()}open(e){throw Error(`This is not implemented in the test service!`)}confirm(e){return Promise.resolve(!0)}close(e){throw Error(`This is not implemented in the test service!`)}};let ug=`FOCUSING_UNIT`,dg=`FOCUSING_SHEET`,fg=`FOCUSING_DOC`,pg=`FOCUSING_SLIDE`,mg=`EDITOR_ACTIVATED`,hg=`FOCUSING_FX_BAR_EDITOR`;var gg=class extends ra{constructor(...e){super(...e),P(this,`_error$`,new n.Subject),P(this,`error$`,this._error$.asObservable())}dispose(){this._error$.complete()}emit(e){this._error$.next({errorKey:e})}};let _g=function(e){return e.URL=`URL`,e.UUID=`UUID`,e.BASE64=`BASE64`,e}({}),vg=function(e){return e.SUCCUSS=`0`,e.ERROR_EXCEED_SIZE=`1`,e.ERROR_IMAGE_TYPE=`2`,e.ERROR_UPLOAD_COUNT_LIMIT=`3`,e.ERROR_IMAGE=`4`,e}({}),yg=(0,t.createIdentifier)(`core.image-io.service`),bg=(0,t.createIdentifier)(`core.url-image.service`);var xg=`@univerjs/core`,Sg=`0.19.0`;function Cg(e=``,t=uo.ZH_CN,n=``){return{id:e,sheetOrder:[],name:n,appVersion:Sg,locale:t,styles:{},sheets:{},resources:[]}}var wg=class{constructor(e={}){P(this,`_styles`,void 0),P(this,`_cacheMap`,new Mf(1e5)),this._styles=e,this._generateCacheMap()}each(e){return Object.entries(this._styles).forEach(e),this}search(e,t){return this._cacheMap.has(t)?this._cacheMap.get(t):this._getExistingStyleId(e)||`-1`}get(e){return typeof e==`string`?(e=String(e),this._styles[e]):e}add(e,t){let n=Ya(6);return this._styles[n]=e,this._cacheMap.set(t,n),n}setValue(e){if(e==null)return;let t=JSON.stringify(e),n=this.search(e,t);return n===`-1`?this.add(e,t):n}addCustomStyle(e,t){t!=null&&(this._styles[e]=t,this._cacheMap.set(JSON.stringify(t),e))}remove(e){let t=this._styles[e];t&&(delete this._styles[e],this._cacheMap.delete(JSON.stringify(t)))}toJSON(){return this._styles}getStyleByCell(e){let t;t=e&&R.isObject(e.s)?e.s:(e==null?void 0:e.s)&&this.get(e.s);let n=e==null?void 0:e.interceptorStyle;return n?{...t,...n}:t}_generateCacheMap(){let{_styles:e,_cacheMap:t}=this;for(let n in e){let r=JSON.stringify(e[n]);t.set(r,n)}}_getExistingStyleId(e){let{_styles:t}=this;for(let n in t)if(R.diffValue(t[n],e))return n;return null}};let Tg=(e,t)=>t.length===e.length&&!e.some(e=>t.some(t=>!Tp.equals(t,e))),Eg=(e,t)=>t.length===e.length&&e.every((e,n)=>{let r=t[n];return r.unitId===e.unitId&&r.sheetId===e.sheetId&&Tp.equals(e.range,r.range)}),Dg={t:0,b:2,l:2,r:2},Og=e=>({sbr:.6,sbo:e,spr:.6,spo:e});function kg(e,t,n={}){let r=e.length,{textRotation:i,paddingData:a,horizontalAlign:o=So.UNSPECIFIED,verticalAlign:s=Co.UNSPECIFIED,wrapStrategy:c=wo.UNSPECIFIED,cellValueType:l}=n,{t:u,r:d,b:f,l:p}=a||Dg,{vertexAngle:m,centerAngle:h}=Lg(i);return new ch({id:`d`,body:{dataStream:`${e}\r
|
|
8
|
-
`,textRuns:[{ts:t,st:0,ed:r}],paragraphs:[{startIndex:r,paragraphStyle:{horizontalAlign:o}}],sectionBreaks:[{startIndex:r+1}]},documentStyle:{pageSize:{width:1/0,height:1/0},marginTop:u,marginBottom:f,marginRight:d,marginLeft:p,renderConfig:{horizontalAlign:o,verticalAlign:s,centerAngle:h,vertexAngle:m,wrapStrategy:c,cellValueType:l}},drawings:{},drawingsOrder:[]})}function Ag(e){if(!e)return{};let{tr:t,td:n,ht:r,vt:i,tb:a,pd:o}=e;return{textRotation:t,textDirection:n,horizontalAlign:r,verticalAlign:i,wrapStrategy:a,paddingData:o}}function jg(e){if(!e)return{};let{ff:t,fs:n,it:r,bl:i,ul:a,st:o,ol:s,cl:c}=e,l={};return t&&(l.ff=t),n&&(l.fs=n),r&&(l.it=r),i&&(l.bl=i),a&&(l.ul=a),o&&(l.st=o),s&&(l.ol=s),c&&(l.cl=c),l}function Mg(e,t,n){var r;let i=e.getBody();if((r=i.customRanges)!=null&&r.some(e=>e.rangeType===Po.HYPERLINK))return;let a=Vh.customRange.add({ranges:[{startOffset:0,endOffset:i.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:Po.HYPERLINK,body:i,properties:{url:t,refId:n}});a&&Q.apply(i,a.serialize())}function Ng(e){return e!=null}function Pg(){return{p:null,s:null,v:null,t:null,f:null,si:null,ref:null,xf:null}}function Fg(e){let t=Vf.ff,n=Vf.fs;if(!e){let e=`${n}pt ${t}`;return{fontCache:e,fontString:e,fontSize:n,originFontSize:n,fontFamily:t}}let r=ts.ITALIC;(e.it===0||e.it===void 0)&&(r=ts.NORMAL);let i=ts.BOLD;(e.bl===0||e.bl===void 0)&&(i=ts.NORMAL);let a=n;e.fs&&(a=Math.ceil(e.fs));let o=t;if(e.ff){let n=e.ff;n=n.replace(/"/g,``).replace(/'/g,``),n.indexOf(` `)>-1&&(n=`"${n}"`),n==null&&(n=t),o=n}let{va:s}=e,c=a;if(s===Do.SUBSCRIPT||s===Do.SUPERSCRIPT){let{sbr:e,spr:t}=Ig(o,c);c*=s===Do.SUBSCRIPT?e:t}let l=`${r} ${i} ${c}pt ${o}`;return{fontCache:l,fontString:`${l}, "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif `,fontSize:c,originFontSize:a,fontFamily:o}}function Ig(e,t){return Og(t)}function Lg(e){let{a:t=0,v:n=B.FALSE}=e||{a:0,v:B.FALSE},r=0,i=t;return n===B.TRUE&&(r=90,i=90),{centerAngle:r,vertexAngle:i}}function Rg(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e)){let t=e.length,n=Array(t);for(let r=0;r<t;r++)n[r]=Rg(e[r]);return n}let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r];t[i]=Rg(e[i])}return t}function zg(e){if(e==null)return e;let t={};return e.p!==void 0&&(t.p=e.p===null?null:Rg(e.p)),e.s!==void 0&&(e.s===null||typeof e.s==`string`?t.s=e.s:t.s=Rg(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:Rg(e.custom)),t}function Bg(e){if(e==null)return e;let t={};return e.p!==void 0&&(t.p=e.p===null?null:Rg(e.p)),e.s!==void 0&&(e.s===null||typeof e.s==`string`?t.s=e.s:t.s=Rg(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:Rg(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 Vg(e){let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r],a=Number(i),o=e[a];if(o===void 0)continue;let s={},c=Object.keys(o);for(let e=0,t=c.length;e<t;e++){let t=c[e],n=Number(t),r=o[n];r!=null&&(s[n]=zg(r))}t[a]=s}return t}function Hg(e){let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r],a=Number(i),o=e[a];if(o===void 0)continue;let s={};`h`in o&&o.h!==void 0&&(s.h=o.h),`ia`in o&&o.ia!==void 0&&(s.ia=o.ia),`ah`in o&&o.ah!==void 0&&(s.ah=o.ah),`hd`in o&&o.hd!==void 0&&(s.hd=o.hd),`w`in o&&o.w!==void 0&&(s.w=o.w),`s`in o&&o.s!==void 0&&(o.s===null||typeof o.s==`string`?s.s=o.s:s.s=Rg(o.s)),`custom`in o&&o.custom!==void 0&&(s.custom=o.custom===null?null:Rg(o.custom)),t[a]=s}return t}function Ug(e){let t=e.length,n=Array(t);for(let r=0;r<t;r++){let t=e[r];n[r]={startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn,rangeType:t.rangeType,startAbsoluteRefType:t.startAbsoluteRefType,endAbsoluteRefType:t.endAbsoluteRefType}}return n}function Wg(e){let 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:Ug(e.mergeData),cellData:Vg(e.cellData),rowData:Hg(e.rowData),columnData:Hg(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=Rg(e.defaultStyle)),e.custom!==void 0&&(t.custom=e.custom===null?null:Rg(e.custom)),t}var Gg=class{constructor(e,t){this._config=e,P(this,`_columnData`,{}),this._columnData=t}getColumnData(){return this._columnData}getColVisible(e){let{_columnData:t}=this,n=t[e];return n?n.hd!==B.TRUE:!0}getColumnStyle(e){var t;return(t=this._columnData[e])==null?void 0:t.s}setColumnStyle(e,t){let n=this.getColumnOrCreate(e);n.s=t}getHiddenCols(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getColVisible(a);r&&e?(r=!1,n.push({rangeType:G.COLUMN,startColumn:i,endColumn:a-1,startRow:0,endRow:0})):!r&&!e&&(r=!0,i=a)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:t,rangeType:G.COLUMN}),n}getVisibleCols(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getColVisible(a);r&&!e?(r=!1,n.push({rangeType:G.COLUMN,startColumn:i,endColumn:a-1,startRow:0,endRow:0})):!r&&e&&(r=!0,i=a)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:t,rangeType:G.COLUMN}),n}getColumnDatas(e,t){let n={},r=0;for(let i=e;i<e+t;i++){let e=this.getColumn(i);n[r]=e==null?{w:this._config.defaultColumnWidth,hd:B.FALSE}:e,r++}return n}getSize(){return vd(this._columnData)}getColumnWidth(e){var t,n;return(t=(n=this._columnData[e])==null?void 0:n.w)==null?this._config.defaultColumnWidth:t}setColumnWidth(e,t){let n=this._columnData[e];t===this._config.defaultColumnWidth?n&&(delete n.w,Object.keys(n).length===0&&delete this._columnData[e]):this._columnData[e]=n?{...n,w:t}:{w:t}}getColumn(e){return this._columnData[e]}insertColumnsWithData(e,t,n){let r=t-e+1,i=Object.keys(this._columnData);for(let t=i.length-1;t>=0;t--){let n=Number(i[t]);n>=e&&(this._columnData[n+r]=this._columnData[n],delete this._columnData[n])}for(let r=e;r<=t;r++){let t=n==null?void 0:n[r-e];t!=null&&Object.keys(t).length>0&&(this._columnData[r]={...t})}}removeColumn(e){delete this._columnData[e]}getColumnOrCreate(e){let{_columnData:t}=this,n=t[e];if(n)return n;let r={};return this._columnData[e]=r,r}setCustomMetadata(e,t){let n=this.getColumn(e);n&&(n.custom=t)}getCustomMetadata(e){var t;return(t=this.getColumn(e))==null?void 0:t.custom}},Kg=class{constructor(e,t,n){this._config=e,this._viewModel=t,P(this,`_rowData`,void 0),this._rowData=n}getRowData(){return this._rowData}getRowStyle(e){var t;return(t=this._rowData[e])==null?void 0:t.s}setRowStyle(e,t){let n=this.getRowOrCreate(e);n.s=t}getRowDatas(e,t){let n={},r=0;for(let i=e;i<e+t;i++){let e=this.getRow(i);n[r]=e==null?{h:this._config.defaultRowHeight,hd:B.FALSE}:e,r++}return n}getRowHeight(e,t=1){let{_rowData:n}=this,r=this._config,i=0;for(let a=0;a<t;a++){let{ia:t,ah:o,h:s=r.defaultRowHeight}=n[a+e]||{hd:B.FALSE,h:r.defaultRowHeight};i+=(t==null||t===B.TRUE)&&typeof o==`number`?o:s}return i}setRowHeight(e,t){let n=this._rowData[e];if(t===this._config.defaultRowHeight)n&&(delete n.h,Object.keys(n).length===0&&delete this._rowData[e]);else{let r=Math.min(t,2e3);this._rowData[e]=n?{...n,h:r}:{h:r}}}getRow(e){return this._rowData[e]}insertRowsWithData(e,t,n){let r=t-e+1,i=Object.keys(this._rowData);for(let t=i.length-1;t>=0;t--){let n=Number(i[t]);n>=e&&(this._rowData[n+r]=this._rowData[n],delete this._rowData[n])}for(let r=e;r<=t;r++){let t=n==null?void 0:n[r-e];t!=null&&Object.keys(t).length>0&&(this._rowData[r]={...t})}}removeRow(e){delete this._rowData[e]}getRowOrCreate(e){let{_rowData:t}=this,n=t[e];if(n)return n;let r={};return t[e]=r,r}getHiddenRows(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getRowRawVisible(a);r&&e?(r=!1,n.push({startRow:i,endRow:a-1,startColumn:0,endColumn:0,rangeType:G.ROW})):!r&&!e&&(r=!0,i=a)}return r&&n.push({startRow:i,endRow:t,startColumn:0,endColumn:0,rangeType:G.ROW}),n}getVisibleRows(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getRowRawVisible(a);r&&!e?(r=!1,n.push({startRow:i,endRow:a-1,startColumn:0,endColumn:0,rangeType:G.ROW})):!r&&e&&(r=!0,i=a)}return r&&n.push({startRow:i,endRow:t,startColumn:0,endColumn:0,rangeType:G.ROW}),n}getRowRawVisible(e){let t=this.getRow(e);return t?t.hd!==B.TRUE:!0}getSize(){return vd(this._rowData)}setCustomMetadata(e,t){let n=this.getRow(e);n&&(n.custom=t)}getCustomMetadata(e){var t;return(t=this.getRow(e))==null?void 0:t.custom}};let qg=1e3;function Jg(e){let t={name:`Sheet1`,id:`sheet-01`,tabColor:``,hidden:B.FALSE,rowCount:qg,columnCount:20,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:88,defaultRowHeight:24,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:B.TRUE,rowHeader:{width:46,hidden:B.FALSE},columnHeader:{height:20,hidden:B.FALSE},rightToLeft:B.FALSE};return Object.keys(t).forEach(n=>{let r=n;e[r]===void 0&&(e[r]=t[r])}),e}var Yg=class extends ra{constructor(e){super(),P(this,`_cellCache`,new Map),P(this,`_rowCache`,new Map),P(this,`_columnCache`,new Map),P(this,`_hasRow`,!1),P(this,`_hasColumn`,!1),P(this,`_hasAll`,!1),P(this,`_allIndex`,-1),P(this,`_mergeData`,void 0),P(this,`_rangeMap`,new Mf(5e4)),this._init(e.concat())}_init(e){this._mergeData=e,this._createCache(e)}_clearCache(){this._cellCache.clear(),this._rowCache.clear(),this._columnCache.clear(),this._hasAll=!1,this._allIndex=-1,this._rangeMap.clear(),this._hasColumn=!1,this._hasRow=!1}_createCache(e){let t=0;for(let n of e){let{rangeType:e}=n;e===G.ROW?this._createRowCache(n,t):e===G.COLUMN?this._createColumnCache(n,t):e===G.ALL?this._createCellAllCache(t):this._createCellCache(n,t),t++}}rebuild(e){this._clearCache(),this._init(e.concat())}_createRowCache(e,t){let{startRow:n,endRow:r}=e;for(let e=n;e<=r;e++)this._rowCache.set(e,t),this._hasRow=!0}_createColumnCache(e,t){let{startColumn:n,endColumn:r}=e;for(let e=n;e<=r;e++)this._columnCache.set(e,t),this._hasColumn=!0}_createCellAllCache(e){this._hasAll=!0,this._allIndex=e}_createCellCache(e,t){for(let n=e.startRow;n<=e.endRow;n++){let r=this._cellCache.get(n);r==null&&(r=new Map,this._cellCache.set(n,r));for(let n=e.startColumn;n<=e.endColumn;n++)r.set(n,t)}}add(e){this._mergeData.push(e),this._clearCache(),this._createCache(this._mergeData)}remove(e,t){let n=this._getMergeDataIndex(e,t);n!==-1&&(this._mergeData.splice(n,1),this._clearCache(),this._createCache(this._mergeData))}getMergedCell(e,t){let n=this._getMergeDataIndex(e,t);return n===-1?null:this._mergeData[n]}getMergeDataIndex(e,t){return this._getMergeDataIndex(e,t)}isRowContainsMergedCell(e){return this._hasAll||!R.isEmptyObject(this._columnCache)?!0:this._mergeData.some(t=>t.startRow<=e&&e<=t.endRow)}isColumnContainsMergedCell(e){return this._hasAll||!R.isEmptyObject(this._rowCache)?!0:this._mergeData.some(t=>t.startColumn<=e&&e<=t.endColumn)}getMergedCellRange(e,t,n,r){let i=[],a=`${e}-${t}-${n}-${r}`;if(this._rangeMap.has(a))return this._getRangeFromCache(a);let o=0,s=[];for(let a of this._mergeData||[])Tp.intersects(a,{startRow:e,endRow:n,startColumn:t,endColumn:r})&&(i.push({...a}),s.push(o)),o++;return this._rangeMap.set(a,s),i}_getRangeFromCache(e){let t=this._rangeMap.get(e)||[],n=[];for(let e of t)n.push({...this._mergeData[e]});return n}_getMergeDataIndex(e,t){var n;if(this._hasAll)return this._allIndex;if(this._hasRow){let t=this._rowCache.get(e);if(t!==void 0)return t}if(this._hasColumn){let e=this._columnCache.get(t);if(e!==void 0)return e}let r=(n=this._cellCache.get(e))==null?void 0:n.get(t);return r===void 0?-1:r}getMergeDataSnapshot(){return this._mergeData}dispose(){this._clearCache(),this._mergeData=[]}},Xg=class extends ra{constructor(e){super(),this.getRawCell=e,P(this,`_cellContentInterceptor`,null),P(this,`_rowFilteredInterceptor`,null)}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(e,t,n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,he.Value|he.Style,n,r):this.getRawCell(e,t)}getCellValueOnly(e,t){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,he.Value):this.getRawCell(e,t)}getCellStyleOnly(e,t){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,he.Style):this.getRawCell(e,t)}getRowFiltered(e){var t,n;return(t=(n=this._rowFilteredInterceptor)==null?void 0:n.getRowFiltered(e))==null?!1:t}registerCellContentInterceptor(e){if(this._cellContentInterceptor)throw Error(`[SheetViewModel]: Interceptor already registered.`);return this._cellContentInterceptor=e,ta(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(e){if(this._rowFilteredInterceptor)throw Error(`[SheetViewModel]: Interceptor already registered.`);return this._rowFilteredInterceptor=e,ta(()=>this._rowFilteredInterceptor=null)}};let Zg={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};var Qg=class e{constructor(e,t,n){var r;this.unitId=e,this._styles=n,P(this,`_sheetId`,void 0),P(this,`_snapshot`,void 0),P(this,`_cellData`,void 0),P(this,`_rowManager`,void 0),P(this,`_columnManager`,void 0),P(this,`_viewModel`,void 0),P(this,`_spanModel`,void 0),P(this,`_isRowStylePrecedeColumnStyle`,!0),P(this,`_getCellHeight`,void 0),this._snapshot=Jg(t);let{columnData:i,rowData:a,cellData:o}=this._snapshot;this._sheetId=(r=this._snapshot.id)==null?Ya(6):r,this._cellData=new Dd(o),this._viewModel=new Xg((e,t)=>this.getCellRaw(e,t)),this._rowManager=new Kg(this._snapshot,this._viewModel,a),this._columnManager=new Gg(this._snapshot,i),this._spanModel=new Yg(this._snapshot.mergeData)}__interceptViewModel(e){e(this._viewModel)}__registerGetCellHeight(e){return this._getCellHeight=e,ta(()=>{this._getCellHeight=null})}getSnapshot(){return this._snapshot}getCellHeight(e,t){return this._getCellHeight?this._getCellHeight(e,t):this._snapshot.defaultRowHeight}setMergeData(e){this._snapshot.mergeData=e,this.getSpanModel().rebuild(e)}getSpanModel(){return this._spanModel}setIsRowStylePrecedeColumnStyle(e){this._isRowStylePrecedeColumnStyle=e}getStyleDataByHash(e){return{...this._styles.get(e)}}setStyleData(e){return this._styles.setValue(e)}getColumnStyle(e,t=!1){return t?this._columnManager.getColumnStyle(e):this._styles.get(this._columnManager.getColumnStyle(e))}setColumnStyle(e,t){this._columnManager.setColumnStyle(e,t)}getRowStyle(e,t=!1){return t?this._rowManager.getRowStyle(e):this._styles.get(this._rowManager.getRowStyle(e))}setRowStyle(e,t){this._rowManager.setRowStyle(e,t)}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){let e=this._snapshot.defaultStyle;return this._styles.get(e)}setDefaultCellStyle(e){this._snapshot.defaultStyle=e}getCellStyle(e,t){let n=this.getCell(e,t);if(n){let e=n.s;return typeof e==`string`?this._styles.get(e):e}return null}getComposedCellStyle(e,t,n){let r=this.getDefaultCellStyleInternal(),i=this.getRowStyle(e),a=this.getColumnStyle(t),o=this.getCell(e,t),s=this._styles.getStyleByCell(o);return(n==null?this._isRowStylePrecedeColumnStyle:n)?Xa(r,a,i,o==null?void 0:o.themeStyle,s):Xa(r,i,a,o==null?void 0:o.themeStyle,s)}getComposedCellStyleByCellData(e,t,n,r){let i=this.getDefaultCellStyleInternal(),a=this.getRowStyle(e),o=this.getColumnStyle(t),s=this._styles.getStyleByCell(n);return(r==null?this._isRowStylePrecedeColumnStyle:r)?Xa(i,o,a,n==null?void 0:n.themeStyle,s):Xa(i,a,o,n==null?void 0:n.themeStyle,s)}getComposedCellStyleWithoutSelf(e,t,n,r){let i=n===void 0?this.getComposedCellStyle(e,t,r):this.getComposedCellStyleByCellData(e,t,n,r),a=this.getCellRaw(e,t);if(!a||!a.s)return i;let o=typeof a.s==`string`?this._styles.get(a.s):a.s;if(!o)return i;for(let e in o)e in i&&delete i[e];return i}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){let e=this.getCellMatrix(),t=this.getMergeData(),n=-1,r=-1,i=-1,a=-1,o=!1,s=!1;return e.forEach((t,c)=>{Object.keys(c).forEach(c=>{let l=+c,u=e.getValue(t,l),d=u!=null&&u.s?this._styles.get(u.s):null,f=(d==null?void 0:d.bd)&&(d.bd.b||d.bd.l||d.bd.r||d.bd.t||d.bd.bc_tr||d.bd.bl_tr||d.bd.ml_tr||d.bd.tl_bc||d.bd.tl_br||d.bd.tl_mr);(u&&(u.v!==null&&u.v!==void 0&&u.v!==``||u.p)||d!=null&&d.bg||f)&&(o?n=Math.min(n,t):(n=t,o=!0),r=Math.max(r,t),s?i=Math.min(i,l):(s=!0,i=l),a=Math.max(a,l))})}),t.forEach(e=>{o?n=Math.min(n,e.startRow):(n=e.startRow,o=!0),r=Math.max(r,e.endRow),s?i=Math.min(i,e.startColumn):(i=e.startColumn,o=!0),a=Math.max(a,e.endColumn)}),!o||!s?null:{startColumn:i,startRow:n,endColumn:a,endRow:r}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){let{_snapshot:t}=this,n=Wg(t);return new e(this.unitId,n,this._styles)}getMergeData(){return this._spanModel.getMergeDataSnapshot()}getMergedCell(e,t){return this._spanModel.getMergedCell(e,t)}getMergedCellRange(e,t,n,r){return this._spanModel.getMergedCellRange(e,t,n,r)}isRowContainsMergedCell(e){return this._spanModel.isRowContainsMergedCell(e)}isColumnContainsMergedCell(e){return this._spanModel.isColumnContainsMergedCell(e)}getCellInfoInMergeData(e,t){let n=this.getMergedCell(e,t),r=!1,i=!1,a=e,o=t,s=e,c=t;if(n){let{startRow:l,endRow:u,startColumn:d,endColumn:f}=n;e===l&&t===d?(a=u,o=f,s=l,c=d,i=!0):e>=l&&e<=u&&t>=d&&t<=f&&(a=u,o=f,s=l,c=d,r=!0)}return{actualRow:e,actualColumn:t,isMergedMainCell:i,isMerged:r,endRow:a,endColumn:o,startRow:s,startColumn:c}}getCell(e,t){return e<0||t<0?null:this._viewModel.getCell(e,t)}getCellValueOnly(e,t){return e<0||t<0?null:this._viewModel.getCellValueOnly(e,t)}getCellStyleOnly(e,t){return e<0||t<0?null:this._viewModel.getCellStyleOnly(e,t)}getCellRaw(e,t){return this.getCellMatrix().getValue(e,t)}getCellWithFilteredInterceptors(e,t,n,r){return this._viewModel.getCell(e,t,n,r)}getRowFiltered(e){return this._viewModel.getRowFiltered(e)}getRangeFilterRows(e){let t=[];for(let n=e.startRow;n<=e.endRow;n++)this.getRowFiltered(n)&&t.push(n);return t}getMatrixWithMergedCells(e,t,n,r,i=Rc.Raw){let a=this.getCellMatrix(),o=this._spanModel.getMergedCellRange(e,t,n,r),s=new Dd;return jp(e,n,t,r).forEach((e,t)=>{let n;if(i===Rc.Raw)n=this.getCellRaw(e,t);else if(i===Rc.Intercepted)n=this.getCell(e,t);else if(i===Rc.Both){let i=this.getCellRaw(e,t);if(i){var r;n={...i};let a=(r=this.getCell(e,t))==null?void 0:r.v;Ng(a)&&n&&(n.displayV=String(a))}}n&&s.setValue(e,t,n)}),o.forEach(e=>{let{startColumn:t,startRow:n,endColumn:r,endRow:i}=e;jp(n,i,t,r).forEach((e,o)=>{e===n&&o===t&&s.setValue(e,o,{...a.getValue(e,o),rowSpan:i-n+1,colSpan:r-t+1}),(e!==n||o!==t)&&s.realDeleteValue(e,o)})}),s}getRange(e,t,n,r){return typeof e==`object`?new Yf(this,e,{getStyles:()=>this._styles}):new Yf(this,{startRow:e,startColumn:t,endColumn:r||t,endRow:n||e},{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(){let{_snapshot:e}=this,{columnCount:t}=e;return t}getMaxRows(){let{_snapshot:e}=this,{rowCount:t}=e;return t}getRowCount(){return this._snapshot.rowCount}setRowCount(e){this._snapshot.rowCount=e}getColumnCount(){return this._snapshot.columnCount}setColumnCount(e){this._snapshot.columnCount=e}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){let{_snapshot:e}=this,{showGridlines:t}=e;return t===0}getGridlinesColor(){return this.getConfig().gridlinesColor}getTabColor(){let{_snapshot:e}=this,{tabColor:t}=e;return t}getColumnWidth(e){return this.getColumnManager().getColumnWidth(e)}getRowHeight(e){return this._viewModel.getRowFiltered(e)?0:this.getRowManager().getRowHeight(e)}isRowFiltered(e){return this._viewModel.getRowFiltered(e)}getRowVisible(e){return!this.isRowFiltered(e)&&this.getRowRawVisible(e)}getRowRawVisible(e){return this.getRowManager().getRowRawVisible(e)}getHiddenRows(e,t){let n=this.getMaxColumns()-1,r=this._rowManager.getHiddenRows(e,t);return r.forEach(e=>e.endColumn=n),r}getColVisible(e){return this._columnManager.getColVisible(e)}getHiddenCols(e,t){let n=this.getMaxRows()-1,r=this._columnManager.getHiddenCols(e,t);return r.forEach(e=>e.endRow=n),r}getVisibleRows(){let e=this.getRowCount();return this._rowManager.getVisibleRows(0,e-1)}getVisibleCols(){let e=this.getColumnCount();return this._columnManager.getVisibleCols(0,e-1)}isRightToLeft(){let{_snapshot:e}=this,{rightToLeft:t}=e;return t}getLastRowWithContent(){return this._cellData.getRealRowRange().endRow}getLastColumnWithContent(){return this.getDataRealRange().endColumn}getDataRealRange(){return this._cellData.getRealRange()}getDataRangeScope(){return this._cellData.getStartEndScope()}cellHasValue(e){return e&&(e.v!==void 0||e.f!==void 0||e.p!==void 0)}iterateByRow(e,t=!0){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e,o=this;return{[Symbol.iterator]:()=>{let e=n,s=r;return{next(){for(;;){if(s>a&&(e+=1,s=r),e>i)return{done:!0,value:void 0};let n=o.getCell(e,s),c=!n,l=o.getMergedCell(e,s);if(l){if(e!==l.startRow||s!==l.startColumn){s=l.endColumn+1;continue}if(c&&t){s=l.endColumn+1;continue}let r={row:e,col:s,value:n};return r.colSpan=l.endColumn-l.startColumn+1,r.rowSpan=l.endRow-l.startRow+1,s=l.endColumn+1,{done:!1,value:r}}if(c&&t)s+=1;else{let t={row:e,col:s,value:n};return s+=1,{done:!1,value:t}}}}}}}}iterateByColumn(e,t=!0,n=!0){let{startRow:r,startColumn:i,endRow:a,endColumn:o}=e,s=this;return{[Symbol.iterator]:()=>{let e=r,c=i;return{next(){for(;;){if(e>a&&(c+=1,e=r),c>o)return{done:!0,value:void 0};let i=s.getMergedCell(e,c);if(i){let r=e!==i.startRow,a=r||c!==i.startColumn;if(n&&a||!n&&r){e=i.endRow+1;continue}let o=s.getCell(i.startRow,i.startColumn);if(!o&&t){e=i.endRow+1;continue}let l={row:e,col:i.startColumn,value:o};return l.colSpan=i.endColumn-i.startColumn+1,l.rowSpan=i.endRow-i.startRow+1,e=i.endRow+1,{done:!1,value:l}}let l=s.getCell(e,c);if(!l&&t)e+=1;else{let t={row:e,col:c,value:l};return e+=1,{done:!1,value:t}}}}}}}}getCellDocumentModel(e,t,n=Zg){var r;if(!e)return;let{isDeepClone:i,displayRawFormula:a,ignoreTextRotation:o}={...Zg,...n},s,c=`document`,l=Ag(t),u=o?Vf.tr:l.textRotation||Vf.tr,d=l.horizontalAlign||Vf.ht,f=l.verticalAlign||Vf.vt,p=l.wrapStrategy||Vf.tb,m=l.paddingData||Dg;if(e.f&&a)s=kg(e.f.toString(),{},{verticalAlign:f}),d=Vf.ht;else if(e.p){let{centerAngle:t,vertexAngle:n}=Lg(u);s=this._updateConfigAndGetDocumentModel(i?R.deepClone(e.p):e.p,d,m,{horizontalAlign:d,verticalAlign:f,centerAngle:t,vertexAngle:n,wrapStrategy:p,zeroWidthParagraphBreak:1})}else if(e.v!=null){let n=jg(t);c=Fg(n).fontCache;let r=$g(e);e.t===Oo.FORCE_STRING&&a&&(r=`'${r}`),s=kg(r,n,{...l,textRotation:u,cellValueType:e.t})}return s&&e.linkUrl&&e.linkId&&Mg(s,e.linkUrl,e.linkId),{documentModel:s,fontString:c,textRotation:u,wrapStrategy:p,verticalAlign:f,horizontalAlign:d,paddingData:m,fill:t==null||(r=t.bg)==null?void 0:r.rgb}}_updateConfigAndGetDocumentModel(e,t,n,r){var i,a,o,s,c;if(!r||!((i=e.body)!=null&&i.dataStream))return;e.documentStyle||(e.documentStyle={}),e.documentStyle.marginTop=(a=n.t)==null?0:a,e.documentStyle.marginBottom=(o=n.b)==null?2:o,e.documentStyle.marginLeft=(s=n.l)==null?2:s,e.documentStyle.marginRight=(c=n.r)==null?2:c,e.documentStyle.pageSize={width:1/0,height:1/0},e.documentStyle.renderConfig={...e.documentStyle.renderConfig,...r};let l=e.body.paragraphs||[];for(let e of l)e.paragraphStyle||(e.paragraphStyle={}),e.paragraphStyle.horizontalAlign=t;return new ch(e)}getBlankCellDocumentModel(e,t,n){let r=this.getComposedCellStyleByCellData(t,n,e),i=jg(r),a=this.getCellDocumentModel(e,r,{ignoreTextRotation:!0});if(a!=null)return a.documentModel==null&&(a.documentModel=kg(``,i)),a;let o=`document`,s=Vf.tr,c=Vf.ht,l=Vf.vt,u=Vf.tb,d=Dg;return o=Fg({}).fontCache,{documentModel:kg(``,i),fontString:o,textRotation:s,wrapStrategy:u,verticalAlign:l,horizontalAlign:c,paddingData:d}}getCellDocumentModelWithFormula(e,t,n){let r=this.getComposedCellStyleByCellData(t,n,e);return this.getCellDocumentModel(e,r,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(e){this._snapshot.custom=e}};function $g(e){var t;if(!e)return``;let n=(t=e.p)==null||(t=t.body)==null?void 0:t.dataStream;if(n)return Vh.transform.getPlainText(n);let r=e.v;return typeof r==`string`?e.t===Oo.BOOLEAN?r.toUpperCase():r.replace(/[\r\n]/g,``):typeof r==`number`?e.t===Oo.BOOLEAN?r?`TRUE`:`FALSE`:r.toString():typeof r==`boolean`?r?`TRUE`:`FALSE`:``}function e_(e){if(e===null)return``;if(e!=null&&e.p){let t=e==null?void 0:e.p.body;if(t==null)return``;let n=t.dataStream;return Vh.transform.getPlainText(n)}return e==null?void 0:e.v}function t_(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}let n_=class extends Pa{get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}static isIRangeType(e){return typeof e==`string`||`startRow`in e||`row`in e}constructor(e={},t){super(),this._logService=t,P(this,`type`,I.UNIVER_SHEET),P(this,`_sheetCreated$`,new n.Subject),P(this,`sheetCreated$`,this._sheetCreated$.asObservable()),P(this,`_sheetDisposed$`,new n.Subject),P(this,`sheetDisposed$`,this._sheetDisposed$.asObservable()),P(this,`_activeSheet$`,new n.BehaviorSubject(null)),P(this,`activeSheet$`,this._activeSheet$.asObservable()),P(this,`_worksheets`,void 0),P(this,`_styles`,void 0),P(this,`_snapshot`,void 0),P(this,`_unitId`,void 0),P(this,`_count`,void 0),P(this,`_name$`,void 0),P(this,`name$`,void 0);let r=Cg();R.isEmptyObject(e)?this._snapshot=r:this._snapshot=R.commonExtend(r,e);let{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=Ya(6)),this._unitId=this._snapshot.id,this._styles=new wg(i),this._count=1,this._worksheets=new Map,this._name$=new n.BehaviorSubject(e.name||``),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete(),Array.from(this._worksheets.keys()).forEach(e=>{this._removeSheet(e)})}save(){return R.deepClone(this._snapshot)}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(e){this._name$.next(e),this._snapshot.name=e}getUnitId(){return this._unitId}getRev(){var e;return(e=this._snapshot.rev)==null?1:e}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(e){this._snapshot.rev=e}addWorksheet(e,t,n){let{sheets:r,sheetOrder:i}=this._snapshot;if(r[e])return!1;r[e]=n,i.splice(t,0,e),this.ensureSheetOrderUnique();let a=new Qg(this._unitId,n,this._styles);return this._worksheets.set(e,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}ensureSheetOrderUnique(){let e=new Set,t=[];for(let n of this._snapshot.sheetOrder)e.has(n)||(e.add(n),t.push(n));this._snapshot.sheetOrder=t,e.clear()}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}addStyles(e){Object.entries(e).forEach(([e,t])=>{this._styles.addCustomStyle(e,t)})}removeStyles(e){e.forEach(e=>{this._styles.remove(e)})}getConfig(){return this._snapshot}getIndexBySheetId(e){let{sheetOrder:t}=this._snapshot;return t.findIndex(t=>t===e)}getActiveSheet(e){if(!this._activeSheet&&e===void 0)throw Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){let e=this._activeSheet;if(e)return e;let t=this._snapshot.sheetOrder;for(let e=0,n=t.length;e<n;e++){let n=this._worksheets.get(t[e]);if(n&&n.isSheetHidden()!==B.TRUE)return this.setActiveSheet(n),n}let n=this._worksheets.get(t[0]);return this.setActiveSheet(n),n}setActiveSheet(e){this._activeSheet$.next(e)}_removeSheet(e){let t=this._worksheets.get(e);return t?(this._worksheets.delete(e),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(e),1),this.ensureSheetOrderUnique(),this._sheetDisposed$.next(t),!0):!1}removeSheet(e){let t=this._removeSheet(e);return t&&delete this._snapshot.sheets[e],t}getActiveSheetIndex(){let{sheetOrder:e}=this._snapshot;return e.findIndex(e=>this._worksheets.get(e)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){let{sheetOrder:e}=this._snapshot;return e.map(e=>this._worksheets.get(e))}getSheetsName(){let{sheetOrder:e}=this._snapshot,t=[];return e.forEach(e=>{let n=this._worksheets.get(e);n&&t.push(n.getName())}),t}getSheetIndex(e){let{sheetOrder:t}=this._snapshot;return t.findIndex(t=>e.getSheetId()===t)}getSheetBySheetName(e){let{sheetOrder:t}=this._snapshot,n=t.find(t=>this._worksheets.get(t).getName()===e);return this._worksheets.get(n)}getSheetBySheetId(e){return this._worksheets.get(e)}getSheetByIndex(e){let{sheetOrder:t}=this._snapshot;return this._worksheets.get(t[e])}getHiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden===B.TRUE).map(e=>e.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden!==B.TRUE).map(e=>e.getConfig().id)}load(e){this._snapshot=e}checkSheetName(e){return this.getSheetsName().some(t=>t.toLowerCase()===e.toLowerCase())}uniqueSheetName(e=`Sheet1`){let t=e;for(;this.checkSheetName(t);)t=e+this._count,this._count++;return t}generateNewSheetName(e){let t=e+this._count;for(;this.checkSheetName(t);)t=e+this._count,this._count++;return t}_parseWorksheetSnapshots(){let{_snapshot:e,_worksheets:t}=this,{sheets:n,sheetOrder:r}=e;if(R.isEmptyObject(n)){let e=Ya();n[e]={id:e}}for(let e in n){let i=n[e],{name:a}=i;i.name=this.uniqueSheetName(a),i.name!==a&&this._logService.debug(`[Workbook]`,`The worksheet name ${a} is duplicated, we changed it to ${i.name}. Please fix the problem in your snapshot.`);let o=new Qg(this._unitId,i,this._styles);t.set(e,o),r.includes(e)||r.push(e)}this.ensureSheetOrderUnique(),this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(e){this._snapshot.custom=e}};n_=Us([W(1,Bs)],n_);var r_=class extends Pa{get _activePage(){let e=this._activePage$.getValue();if(!e){var t,n;let e=(t=this.getPageOrder())==null?void 0:t[0];return e?(n=this.getPages())==null?void 0:n[e]:null}return e}constructor(e){var t;super(),P(this,`type`,I.UNIVER_SLIDE),P(this,`_activePage$`,new n.BehaviorSubject(null)),P(this,`activePage$`,this._activePage$.asObservable()),P(this,`_name$`,void 0),P(this,`name$`,void 0),P(this,`_snapshot`,void 0),P(this,`_unitId`,void 0),this._snapshot={...Hf,...e},this._unitId=(t=this._snapshot.id)==null?Ya(6):t,this._name$=new n.BehaviorSubject(this._snapshot.title),this.name$=this._name$.asObservable()}setName(e){var t;this._snapshot.title=e,this._name$.next(e),this._unitId=(t=this._snapshot.id)==null?Ya(6):t}getRev(){return 0}incrementRev(){}setRev(e){}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var e;return(e=this._snapshot.body)==null?void 0:e.pages}getPageOrder(){var e;return(e=this._snapshot.body)==null?void 0:e.pageOrder}getPage(e){let t=this.getPages();return t==null?void 0:t[e]}getElementsByPage(e){var t;return(t=this.getPage(e))==null?void 0:t.pageElements}getElement(e,t){var n;return(n=this.getElementsByPage(e))==null?void 0:n[t]}getPageSize(){return this._snapshot.pageSize}getBlankPage(){let e=Ya(6);return{id:e,pageType:ps.SLIDE,zIndex:10,title:e,description:``,pageBackgroundFill:{rgb:`rgb(255,255,255)`},pageElements:{}}}setActivePage(e){this._activePage$.next(e)}getActivePage(){return this._activePage}updatePage(e,t){this._snapshot.body&&(this._snapshot.body.pages[e]=t)}appendPage(e){var t;if(!this._snapshot.body)return;this._snapshot.body.pages[e.id]=e;let n=this._activePage,r=this._snapshot.body.pageOrder.indexOf((t=n==null?void 0:n.id)==null?``:t);this._snapshot.body.pageOrder.splice(r+1,0,e.id)}};let i_=(0,t.createIdentifier)(`univer.current`),a_=class extends ra{constructor(e,t,r){super(),this._injector=e,this._contextService=t,this._logService=r,P(this,`_unitsByType`,new Map),P(this,`_createHandler`,void 0),P(this,`_ctorByType`,new Map),P(this,`_currentUnits`,new Map),P(this,`_currentUnits$`,new n.BehaviorSubject(this._currentUnits)),P(this,`currentUnits$`,this._currentUnits$.asObservable()),P(this,`_unitAdded$`,new n.Subject),P(this,`unitAdded$`,this._unitAdded$.asObservable()),P(this,`_unitDisposed$`,new n.Subject),P(this,`unitDisposed$`,this._unitDisposed$.asObservable()),P(this,`_focused$`,new n.BehaviorSubject(null)),P(this,`focused$`,this._focused$.asObservable())}dispose(){super.dispose(),this._focused$.complete(),this._currentUnits$.complete(),this._unitAdded$.complete(),this._currentUnits.forEach(e=>e==null?void 0:e.dispose()),this._currentUnits.clear(),this._unitsByType.clear()}__setCreateHandler(e){this._createHandler=e}createUnit(e,t,n){return this._createHandler(e,t,this._ctorByType.get(e),n)}registerCtorForType(e,t){return this._ctorByType.set(e,t),{dispose:()=>{this._ctorByType.delete(e)}}}getCurrentTypeOfUnit$(e){return this.currentUnits$.pipe((0,n.map)(t=>{var n;return(n=t.get(e))==null?null:n}),(0,n.distinctUntilChanged)())}getCurrentUnitForType(e){return this._currentUnits.get(e)}getCurrentUnitOfType(e){return this.getCurrentUnitForType(e)}setCurrentUnitForType(e){let t=this._getUnitById(e);if(!t)throw Error(`[UniverInstanceService]: no document with unitId ${e}!`);this._currentUnits.set(t[1],t[0]),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(e){return this._unitAdded$.pipe((0,n.filter)(t=>t.type===e))}__addUnit(e,t){var n;this._logService.debug(`[UniverInstanceService]: Adding unit with id ${e.getUnitId()}`);let r=e.type;this._unitsByType.has(r)||this._unitsByType.set(r,[]);let i=this._unitsByType.get(r),a=e.getUnitId();if(i.findIndex(e=>e.getUnitId()===a)!==-1)throw Error(`[UniverInstanceService]: cannot create a unit with the same unit id: ${a}.`);i.push(e),this._unitAdded$.next(e),((n=t==null?void 0:t.makeCurrent)==null||n)&&this.setCurrentUnitForType(e.getUnitId())}getTypeOfUnitDisposed$(e){return this.unitDisposed$.pipe((0,n.filter)(t=>t.type===e))}getUnit(e,t){var n;let r=(n=this._getUnitById(e))==null?void 0:n[0];return t&&(r==null?void 0:r.type)!==t?null:r}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(I.UNIVER_DOC)}getUniverDocInstance(e){return this.getUnit(e,I.UNIVER_DOC)}getUniverSheetInstance(e){return this.getUnit(e,I.UNIVER_SHEET)}getAllUnitsForType(e){var t;return(t=this._unitsByType.get(e))==null?[]:t}changeDoc(e,t){let n=this.getAllUnitsForType(I.UNIVER_DOC),r=n.find(t=>t.getUnitId()===e);if(r!=null){let e=n.indexOf(r);n.splice(e,1)}this.__addUnit(t)}get focused(){var e;let t=this._focused$.getValue();return t?(e=this._getUnitById(t))==null?void 0:e[0]:null}focusUnit(e){this._focused$.next(e),this.focused instanceof n_?(this._contextService.setContextValue(ug,!0),this._contextService.setContextValue(fg,!1),this._contextService.setContextValue(dg,!0),this._contextService.setContextValue(pg,!1),this.setCurrentUnitForType(e)):this.focused instanceof ch?(this._contextService.setContextValue(ug,!0),this._contextService.setContextValue(fg,!0),this._contextService.setContextValue(dg,!1),this._contextService.setContextValue(pg,!1),this.setCurrentUnitForType(e)):this.focused instanceof r_?(this._contextService.setContextValue(ug,!0),this._contextService.setContextValue(fg,!1),this._contextService.setContextValue(dg,!1),this._contextService.setContextValue(pg,!0),this.setCurrentUnitForType(e)):(this._contextService.setContextValue(ug,!1),this._contextService.setContextValue(fg,!1),this._contextService.setContextValue(dg,!1),this._contextService.setContextValue(pg,!1))}getFocusedUnit(){return this.focused}getUnitType(e){let t=this._getUnitById(e);return t?t[1]:I.UNRECOGNIZED}disposeUnit(e){this._logService.debug(`[UniverInstanceService]: Disposing unit with id ${e}`);let t=this._getUnitById(e);if(!t)return this._logService.debug(`[UniverInstanceService]: No unit found with id ${e}`),!1;let[n,r]=t,i=this._unitsByType.get(r),a=i.indexOf(n);return i.splice(a,1),this._tryResetCurrentOnRemoval(e,r),this._tryResetFocusOnRemoval(e),this._unitDisposed$.next(n),n.dispose(),!0}_tryResetCurrentOnRemoval(e,t){let n=this.getCurrentUnitForType(t);(n==null?void 0:n.getUnitId())===e&&(this._currentUnits.set(t,null),this._currentUnits$.next(this._currentUnits))}_tryResetFocusOnRemoval(e){var t;((t=this.focused)==null?void 0:t.getUnitId())===e&&this._focused$.next(null)}_getUnitById(e){for(let[t,n]of this._unitsByType){let r=n.find(t=>t.getUnitId()===e);if(r)return[r,t]}}};a_=Us([W(0,(0,t.Inject)(t.Injector)),W(1,Ls),W(2,(0,t.Inject)(Bs))],a_);let $=function(e){return e[e.Starting=0]=`Starting`,e[e.Ready=1]=`Ready`,e[e.Rendered=2]=`Rendered`,e[e.Steady=3]=`Steady`,e}({}),o_={[$.Starting]:`Starting`,[$.Ready]:`Ready`,[$.Rendered]:`Rendered`,[$.Steady]:`Steady`};var s_=class extends Error{constructor(e){super(`[LifecycleService]: lifecycle stage "${o_[e]}" will never be reached!`),this.name=`LifecycleUnreachableError`}};let c_=class extends ra{constructor(e){super(),this._logService=e,P(this,`_lifecycle$`,new n.BehaviorSubject($.Starting)),P(this,`lifecycle$`,this._lifecycle$.asObservable()),P(this,`_lock`,!1),this._reportProgress($.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(e){if(this._lock)throw Error(`[LifecycleService]: cannot set new stage when related logic is all handled!`);if(e<this.stage)throw Error(`[LifecycleService]: lifecycle stage cannot go backward!`);e!==this.stage&&(this._lock=!0,this._reportProgress(e),this._lifecycle$.next(e),this._lock=!1)}dispose(){this._lifecycle$.complete(),super.dispose()}onStage(e){return(0,n.firstValueFrom)(this.lifecycle$.pipe((0,n.filter)(t=>t>=e),ec(t=>t===e),(0,n.map)(()=>void 0))).catch(t=>t.name===`EmptyError`?Promise.reject(new s_(e)):Promise.reject(t))}subscribeWithPrevious(){return(0,n.merge)(l_(this.stage),this._lifecycle$.pipe((0,n.skip)(1))).pipe(ec(e=>e===$.Steady))}_reportProgress(e){this._logService.debug(`[LifecycleService]`,`lifecycle progressed to "${o_[e]}".`)}};c_=Us([W(0,Bs)],c_);function l_(e){switch(e){case $.Starting:return(0,n.of)($.Starting);case $.Ready:return(0,n.of)($.Starting,$.Ready);case $.Rendered:return(0,n.of)($.Starting,$.Ready,$.Rendered);default:return(0,n.of)($.Starting,$.Ready,$.Rendered,$.Steady)}}let u_=(0,t.createIdentifier)(`ILocalStorageService`);var d_=class extends ra{get _currentLocale(){return this._currentLocale$.value}constructor(){super(),P(this,`_currentLocale$`,new n.BehaviorSubject(uo.ZH_CN)),P(this,`currentLocale$`,this._currentLocale$.asObservable()),P(this,`_locales`,null),P(this,`localeChanged$`,new n.Subject),P(this,`t`,(e,...t)=>{if(!this._locales)throw Error(`[LocaleService]: Locale not initialized`);let n=e.split(`.`),r=this.resolveKeyPath(this._locales[this._currentLocale],n);if(typeof r==`string`){let e=r;return t.forEach((t,n)=>{e=e.replace(`{${n}}`,t)}),e}else return e}),this.disposeWithMe(ta(()=>{this._locales=null,this._currentLocale$.complete(),this.localeChanged$.complete()}))}load(e){var t;this._locales=Bi((t=this._locales)==null?{}:t,e)}setLocale(e){this._currentLocale$.next(e),this.localeChanged$.next()}getLocales(){var e;return(e=this._locales)==null?void 0:e[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(e,t){let n=t.shift();if(n&&e&&n in e){let r=e[n];return t.length>0&&(typeof r==`object`||Array.isArray(r))?this.resolveKeyPath(r,t):r}return null}};let f_=class{constructor(e){this._userManagerService=e}async list(e){return{list:[{type:fo.PERSON,mentions:[{objectType:fo.PERSON,objectId:this._userManagerService.getCurrentUser().userID,label:this._userManagerService.getCurrentUser().name,metadata:{icon:this._userManagerService.getCurrentUser().avatar}}],metadata:{},title:`PEOPLE`}],page:e.page,size:e.size,total:1}}};f_=Us([W(0,(0,t.Inject)(ag))],f_);let p_=(0,t.createIdentifier)(`univer.service.mention-io`),m_=function(e){return e.INIT=`init`,e.FETCHING=`fetching`,e.DONE=`done`,e}({}),h_=(0,t.createIdentifier)(`univer.permission-service`);var g_=class extends ra{constructor(...e){super(...e),P(this,`_permissionPointMap`,new Map),P(this,`_permissionPointUpdate$`,new n.Subject),P(this,`permissionPointUpdate$`,this._permissionPointUpdate$.asObservable()),P(this,`_showComponents`,!0)}setShowComponents(e){this._showComponents=e}getShowComponents(){return this._showComponents}deletePermissionPoint(e){let t=this._permissionPointMap.get(e);t&&(t.complete(),this._permissionPointMap.delete(e))}addPermissionPoint(e){let t=e instanceof n.BehaviorSubject,r=t?e.getValue():e;return r.id?this._permissionPointMap.get(r.id)?(console.warn(`${r.id} PermissionPoint already exists`),!1):(this._permissionPointMap.set(r.id,t?e:new n.BehaviorSubject(r)),this._permissionPointUpdate$.next(r),!0):!1}updatePermissionPoint(e,t){let n=this._permissionPointMap.get(e);if(!n)return;let r=n.getValue();r.value=t,r.status=m_.DONE,n.next(r),this._permissionPointUpdate$.next(r)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(e){let t=this._permissionPointMap.get(e);if(t)return t.getValue()}getPermissionPoint$(e){let t=this._permissionPointMap.get(e);if(t)return t}composePermission$(e){return(0,n.combineLatest)(e.map(e=>{var t;let n=(t=this._permissionPointMap)==null?void 0:t.get(e);if(!n)throw Error(`[PermissionService]: ${e} permissionPoint does not exist!`);return n.asObservable()})).pipe((0,r.map)(e=>e))}composePermission(e){return e.map(e=>{var t;let n=(t=this._permissionPointMap)==null?void 0:t.get(e);if(!n)throw Error(`[PermissionService]: ${e} permissionPoint does not exist!`);return n.getValue()})}getAllPermissionPoint(){let e=new Map;return this._permissionPointMap.forEach((t,n)=>{e.set(n,t)}),e}};function __(e,t){if(!t)return e;let n=[];for(let r of e){let e=t.find(([e])=>e===r[0]);if(e){if(e[1]===null)continue;n.push([r[0],e[1]])}else n.push(r)}return n}let v_=Symbol(`DependentOn`);var y_=class extends ra{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}};P(y_,`pluginName`,void 0),P(y_,`packageName`,xg),P(y_,`version`,Sg),P(y_,`type`,I.UNIVER_UNKNOWN);var b_=class{constructor(){P(this,`_plugins`,[])}addPlugin(e){this._plugins.push(e)}removePlugins(){let e=this._plugins.slice();return this._plugins.length=0,e}forEachPlugin(e){this._plugins.forEach(e)}};function x_(...e){return function(t){t[v_]=e}}let S_=class{constructor(e,t,n){this._injector=e,this._lifecycleService=t,this._logService=n,P(this,`_pluginRegistry`,new Map),P(this,`_pluginStore`,new b_),P(this,`_seenPlugins`,new Set),P(this,`_loadedPlugins`,new Set),P(this,`_loadedPluginTypes`,new Set([I.UNIVER_UNKNOWN])),P(this,`_flushTimerByType`,new Map)}dispose(){this._pluginStore.removePlugins().forEach(e=>e.dispose()),this._flushTimerByType.forEach(e=>clearTimeout(e))}registerPlugin(e,t){this._assertPluginValid(e);let n={plugin:e,options:t};this._pluginRegistry.set(e.pluginName,n),this._logService.debug(`[PluginService]`,`Plugin "${e.pluginName}" registered.`);let{type:r}=e;this._loadedPluginTypes.has(r)&&(r===I.UNIVER_UNKNOWN?this._loadFromPlugins([n]):this._flushType(r))}startPluginsForType(e){this._loadedPluginTypes.has(e)||this._loadPluginsForType(e)}_loadPluginsForType(e){let t=Array.from(this._pluginRegistry.keys()),n=[];t.forEach(t=>{let r=this._pluginRegistry.get(t);r.plugin.type===e&&n.push(r)}),this._loadFromPlugins(n),this._loadedPluginTypes.add(e)}_assertPluginValid(e){let{type:t,pluginName:n,packageName:r,version:i}=e;if(t===I.UNRECOGNIZED)throw Error(`[PluginService]: invalid plugin type for ${e.name}. Please assign a "type" to your plugin.`);if(!n)throw Error(`[PluginService]: no plugin name for ${e.name}. Please assign a "pluginName" to your plugin.`);if(i&&i!==y_.version)throw Error(`[PluginService]: package "${r==null?`UNKNOWN`:r}" version mismatch. Plugin version is "${i}" but @univerjs/core version is "${y_.version}". Please make sure all @univerjs packages use the same version.`);if(this._seenPlugins.has(n))throw Error(`[PluginService]: duplicated plugin name for "${n}". Maybe a plugin that dependents on "${n} has already registered it. In that case please register "${n}" before the that plugin.`);this._seenPlugins.add(e.pluginName)}_flushType(e){this._flushTimerByType.get(e)===void 0&&this._flushTimerByType.set(e,setTimeout(()=>{this._loadPluginsForType(e),this._flushTimerByType.delete(e)},4))}_loadFromPlugins(e){let t=[],n=new Set,r=e=>{let{plugin:i}=e,{pluginName:a}=i;if(this._loadedPlugins.has(a)||n.has(a))return;n.add(a),this._pluginRegistry.delete(a);let o=i[v_];o&&o.forEach(e=>{let t=this._pluginRegistry.get(e.pluginName);if(t)r(t);else if(!this._seenPlugins.has(e.pluginName)&&!n.has(e.pluginName)){if(i.type===I.UNIVER_UNKNOWN&&e.type!==I.UNIVER_UNKNOWN)throw Error(`[PluginService]: cannot register a plugin with Univer type that depends on a plugin with other type. The dependent is ${i.pluginName} and the dependency is ${e.pluginName}.`);i.type!==e.type&&e.type!==I.UNIVER_UNKNOWN&&this._logService.debug(`[PluginService]`,`Plugin "${a}" depends on "${e.pluginName}" which has different type.`),this._logService.debug(`[PluginService]`,`Plugin "${a}" depends on "${e.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(e),r({plugin:e,options:void 0})}}),t.push(e)};e.forEach(e=>r(e));let i=t.map(e=>this._initPlugin(e.plugin,e.options));this._pluginsRunLifecycle(i)}_pluginsRunLifecycle(e){let t=this._lifecycleService.stage;if(l_(t).subscribe(t=>this._runStage(e,t)),t!==$.Steady){let t=this._lifecycleService.lifecycle$.pipe((0,n.skip)(1)).subscribe(n=>{this._runStage(e,n),n===$.Steady&&t.unsubscribe()})}}_runStage(e,t){e.forEach(e=>{switch(t){case $.Starting:e.onStarting();break;case $.Ready:e.onReady();break;case $.Rendered:e.onRendered();break;case $.Steady:e.onSteady();break}})}_initPlugin(e,t){let n=this._injector.createInstance(e,t);return this._pluginStore.addPlugin(n),this._loadedPlugins.add(e.pluginName),this._logService.debug(`[PluginService]`,`Plugin "${n.getPluginName()}" loaded.`),n}};S_=Us([W(0,(0,t.Inject)(t.Injector)),W(1,(0,t.Inject)(c_)),W(2,Bs)],S_);let C_=(0,t.createIdentifier)(`resource-loader-service`),w_=class extends ra{constructor(e){super(),this._logService=e,P(this,`_resourceMap`,new Map),P(this,`_register$`,new n.Subject),P(this,`register$`,this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(e,t){return t?this.getResourcesByType(e,t):this.getAllResourceHooks().map(t=>{let n=t.toJson(e);return{name:t.pluginName,data:n}})}getResourcesByType(e,t){return this.getAllResourceHooks().filter(e=>e.businesses.includes(t)).map(t=>{let n=t.toJson(e);return{name:t.pluginName,data:n}})}registerPluginResource(e){let t=e.pluginName;if(this._resourceMap.has(t))throw Error(`the pluginName is registered {${t}}`);return this._resourceMap.set(t,e),this._register$.next(e),ta(()=>this._resourceMap.delete(t))}disposePluginResource(e){this._resourceMap.delete(e)}loadResources(e,t){this.getAllResourceHooks().forEach(n=>{var r;let i=t==null||(r=t.find(e=>e.name===n.pluginName))==null?void 0:r.data;if(i)try{let t=n.parseJson(i);n.onLoad(e,t)}catch(e){this._logService.error(`[ResourceManagerService]`,`loadResources error`,e)}})}unloadResources(e,t){this.getAllResourceHooks().filter(e=>e.businesses.includes(t)).forEach(t=>{t.onUnLoad(e)})}dispose(){this._register$.complete(),this._resourceMap.clear()}};w_=Us([W(0,Bs)],w_);var T_=class extends ra{get darkMode(){return this._darkMode$.getValue()}constructor(){super(),P(this,`_darkMode$`,new n.BehaviorSubject(!1)),P(this,`darkMode$`,this._darkMode$.asObservable()),P(this,`_validColorCache`,new Map),P(this,`_currentTheme`,i.defaultTheme),P(this,`_currentTheme$`,new n.BehaviorSubject(this._currentTheme)),P(this,`currentTheme$`,this._currentTheme$.asObservable()),this.disposeWithMe(ta(()=>{this._currentTheme=i.defaultTheme,this._currentTheme$.complete(),this._darkMode$.complete()}))}isValidThemeColor(e){if(this._validColorCache.has(e))return this._validColorCache.get(e);let t=!1,n=e.split(`.`);if(n.length===1)t=e in i.defaultTheme;else if(n.length===2){let[e,r]=n;t=e in i.defaultTheme&&r in this._currentTheme[e]}return this._validColorCache.set(e,t),t}getCurrentTheme(){return this._currentTheme}setTheme(e){this._currentTheme=e,this._currentTheme$.next(e)}setDarkMode(e){this._darkMode$.next(e)}getColorFromTheme(e){return ti(this._currentTheme,e)}},E_=function(e){return e[e.WAITING=0]=`WAITING`,e[e.CREATED=1]=`CREATED`,e}(E_||{});let D_=(0,t.createIdentifier)(`univer.undo-redo.service`);var O_=class{dispose(){}async dispatchToHandlers(){return!1}};let k_=`univer.command.redo`,A_=`univer.command.undo`,j_=new class extends O_{constructor(...e){super(...e),P(this,`type`,Gs.COMMAND),P(this,`id`,A_)}handler(e){let t=e.get(D_),n=t.pitchTopUndoElement();if(!n)return!1;let r=e.get(Ks);return Zs(n.undoMutations,r)?(t.popUndoToRedo(),!0):!1}},M_=new class extends O_{constructor(...e){super(...e),P(this,`type`,Gs.COMMAND),P(this,`id`,k_)}handler(e){let t=e.get(D_),n=t.pitchTopRedoElement();if(!n)return!1;let r=e.get(Ks);return Zs(n.redoMutations,r)?(t.popRedoToUndo(),!0):!1}},N_=class extends ra{constructor(e,t,r){super(),this._univerInstanceService=e,this._commandService=t,this._contextService=r,P(this,`undoRedoStatus$`,void 0),P(this,`_undoRedoStatus$`,new n.BehaviorSubject({undos:0,redos:0})),P(this,`_undoStacks`,new Map),P(this,`_redoStacks`,new Map),P(this,`_batchingStatus`,new Map),this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(j_)),this.disposeWithMe(this._commandService.registerCommand(M_)),this.disposeWithMe(ta(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(ta(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(e){let{unitID:t}=e,n=this._getRedoStack(t,!0),r=this._getUndoStack(t,!0);if(n.length=0,this._batchingStatus.has(e.unitID)){let t=this._batchingStatus.get(e.unitID),n=this._pitchUndoElement(e.unitID);t===E_.WAITING||!n?(i(e),this._batchingStatus.set(e.unitID,E_.CREATED)):this._tryBatchingElements(n,e)}else i(e);function i(e){r.push(e),r.length>20&&r.splice(0,1)}this._updateStatus()}clearUndoRedo(e){let t=this._getRedoStack(e);t&&(t.length=0);let n=this._getUndoStack(e);n&&(n.length=0),this._updateStatus()}pitchTopUndoElement(){let e=this._getFocusedUnitId();return this._pitchUndoElement(e)}pitchTopRedoElement(){let e=this._getFocusedUnitId();return this._pitchRedoElement(e)}_pitchUndoElement(e){let t=this._getUndoStack(e);return t!=null&&t.length?t[t.length-1]:null}_pitchRedoElement(e){let t=this._getRedoStack(e);return t!=null&&t.length?t[t.length-1]:null}popUndoToRedo(){let e=this._getUndoStackForFocused().pop();e&&(e.redoMutations.length>0&&this._getRedoStackForFocused().push(e),this._updateStatus())}popRedoToUndo(){let e=this._getRedoStackForFocused().pop();e&&(this._getUndoStackForFocused().push(e),this._updateStatus())}rollback(e,t){let n=t||this._getFocusedUnitId(),r=this._getUndoStack(n),i=r==null?void 0:r[(r==null?void 0:r.length)-1];i&&i.id===e&&(r.pop(),Zs(i.undoMutations,this._commandService))}__tempBatchingUndoRedo(e){if(this._batchingStatus.has(e))throw Error(`[LocalUndoRedoService]: cannot batching undo redo twice at the same time!`);return this._batchingStatus.set(e,E_.WAITING),ta(()=>this._batchingStatus.delete(e))}_updateStatus(){var e,t;let n=this._getFocusedUnitId(),r=n&&((e=this._undoStacks.get(n))==null?void 0:e.length)||0,i=n&&((t=this._redoStacks.get(n))==null?void 0:t.length)||0;this._undoRedoStatus$.next({undos:r,redos:i})}_getUndoStack(e,t=!1){let n=this._undoStacks.get(e);return!n&&t&&(n=[],this._undoStacks.set(e,n)),n||null}_getRedoStack(e,t=!1){let n=this._redoStacks.get(e);return!n&&t&&(n=[],this._redoStacks.set(e,n)),n||null}_getUndoStackForFocused(){let e=this._getFocusedUnitId();if(!e)throw Error(`No focused univer instance!`);return this._getUndoStack(e,!0)}_getRedoStackForFocused(){let e=this._getFocusedUnitId();if(!e)throw Error(`No focused univer instance!`);return this._getRedoStack(e,!0)}_tryBatchingElements(e,t){e.redoMutations.push(...t.redoMutations),e.undoMutations.push(...t.undoMutations)}_getFocusedUnitId(){let e=``,t=this._contextService.getContextValue(dg),n=this._contextService.getContextValue(hg),r=this._contextService.getContextValue(mg);if(t)if(n)e=N;else if(r)e=M;else{var i,a;e=(i=(a=this._univerInstanceService.getFocusedUnit())==null?void 0:a.getUnitId())==null?``:i}else{var o,s;e=(o=(s=this._univerInstanceService.getFocusedUnit())==null?void 0:s.getUnitId())==null?``:o}return e}};N_=Us([W(0,i_),W(1,Ks),W(2,Ls)],N_);var P_=class{constructor(e,t=1e3){this._injector=e,P(this,`_imageCacheMap`,void 0),this._imageCacheMap=new Mf(t)}_getImageCacheKey(e,t){return`${e}-${t}`}getImage(e,t,n,r){let i=this._getImageCacheKey(e,t);return this._imageCacheMap.get(i)||((async()=>{let a=new Image,o=this._injector.has(yg)?this._injector.get(yg):null,s=this._injector.has(bg)?this._injector.get(bg):null;if(e===_g.UUID)try{a.src=await(o==null?void 0:o.getImage(t))||``}catch(e){console.error(e)}else if(e===_g.URL)try{a.src=await(s==null?void 0:s.getImage(t))||t}catch{a.src=t}else a.src=t;a.onload=()=>{a.removeAttribute(`data-error`),n==null||n()},a.onerror=()=>{a.setAttribute(`data-error`,`true`),r==null||r()},this._imageCacheMap.set(i,a)})(),null)}};function F_(e){return!(e.length===0||e.length>31||e.startsWith(`'`)||e.endsWith(`'`)||/[:\\\/\?\*\[\]]/.test(e))}function I_(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))}let L_=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];var R_=class e{static from(t){if(!(t instanceof ArrayBuffer))throw Error(`Data must be an instance of ArrayBuffer.`);let[n,r]=new Uint8Array(t,0,2);if(n!==219)throw Error(`Data does not appear to be in a KDBush format.`);let i=r>>4;if(i!==1)throw Error(`Got v${i} data when expected v1.`);let a=L_[r&15];if(!a)throw Error(`Unrecognized array type.`);let[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new e(s,o,a,t)}constructor(e,t=64,n=Float64Array,r){if(isNaN(e)||e<0)throw Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=n,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;let i=L_.indexOf(this.ArrayType),a=e*2*this.ArrayType.BYTES_PER_ELEMENT,o=e*this.IndexArrayType.BYTES_PER_ELEMENT,s=(8-o%8)%8;if(i<0)throw Error(`Unexpected typed array class: ${n}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+o+s,e*2),this._pos=e*2,this._finished=!0):(this.data=new ArrayBuffer(8+a+o+s),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+o+s,e*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){let n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=e,this.coords[this._pos++]=t,n}finish(){let e=this._pos>>1;if(e!==this.numItems)throw Error(`Added ${e} items when expected ${this.numItems}.`);return z_(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,n,r){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:i,coords:a,nodeSize:o}=this,s=[0,i.length-1,0],c=[];for(;s.length;){let l=s.pop()||0,u=s.pop()||0,d=s.pop()||0;if(u-d<=o){for(let o=d;o<=u;o++){let s=a[2*o],l=a[2*o+1];s>=e&&s<=n&&l>=t&&l<=r&&c.push(i[o])}continue}let f=d+u>>1,p=a[2*f],m=a[2*f+1];p>=e&&p<=n&&m>=t&&m<=r&&c.push(i[f]),(l===0?e<=p:t<=m)&&(s.push(d),s.push(f-1),s.push(1-l)),(l===0?n>=p:r>=m)&&(s.push(f+1),s.push(u),s.push(1-l))}return c}within(e,t,n){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:r,coords:i,nodeSize:a}=this,o=[0,r.length-1,0],s=[],c=n*n;for(;o.length;){let l=o.pop()||0,u=o.pop()||0,d=o.pop()||0;if(u-d<=a){for(let n=d;n<=u;n++)U_(i[2*n],i[2*n+1],e,t)<=c&&s.push(r[n]);continue}let f=d+u>>1,p=i[2*f],m=i[2*f+1];U_(p,m,e,t)<=c&&s.push(r[f]),(l===0?e-n<=p:t-n<=m)&&(o.push(d),o.push(f-1),o.push(1-l)),(l===0?e+n>=p:t+n>=m)&&(o.push(f+1),o.push(u),o.push(1-l))}return s}};function z_(e,t,n,r,i,a){if(i-r<=n)return;let o=r+i>>1;B_(e,t,o,r,i,a),z_(e,t,n,r,o-1,1-a),z_(e,t,n,o+1,i,1-a)}function B_(e,t,n,r,i,a){for(;i>r;){if(i-r>600){let o=i-r+1,s=n-r+1,c=Math.log(o),l=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*l*(o-l)/o)*(s-o/2<0?-1:1);B_(e,t,n,Math.max(r,Math.floor(n-s*l/o+u)),Math.min(i,Math.floor(n+(o-s)*l/o+u)),a)}let o=t[2*n+a],s=r,c=i;for(V_(e,t,r,n),t[2*i+a]>o&&V_(e,t,r,i);s<c;){for(V_(e,t,s,c),s++,c--;t[2*s+a]<o;)s++;for(;t[2*c+a]>o;)c--}t[2*r+a]===o?V_(e,t,r,c):(c++,V_(e,t,c,i)),c<=n&&(r=c+1),n<=c&&(i=c-1)}}function V_(e,t,n,r){H_(e,n,r),H_(t,2*n,2*r),H_(t,2*n+1,2*r+1)}function H_(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function U_(e,t,n,r){let i=e-n,a=t-r;return i*i+a*a}var W_=class{constructor(e=!1){this._enableOneCellCache=e,P(this,`_tree`,new Map),P(this,`_oneCellCache`,new Map),P(this,`_kdTree`,new Map)}dispose(){this.clear()}getTree(e,t){return this._tree.has(e)||this._tree.set(e,new Map),this._tree.get(e).has(t)||this._tree.get(e).set(t,new $f),this._tree.get(e).get(t)}_getOneCellCache(e,t,n,r){return this._oneCellCache.has(e)||this._oneCellCache.set(e,new Map),this._oneCellCache.get(e).has(t)||this._oneCellCache.get(e).set(t,new Map),this._oneCellCache.get(e).get(t).has(n)||this._oneCellCache.get(e).get(t).set(n,new Map),this._oneCellCache.get(e).get(t).get(n).has(r)||this._oneCellCache.get(e).get(t).get(n).set(r,new Set),this._oneCellCache.get(e).get(t).get(n).get(r)}_removeOneCellCache(e,t,n,r,i){let a=this._oneCellCache.get(e);if(!a)return;let o=a.get(t);if(!o)return;let s=o.get(n);if(!s)return;let c=s.get(r);c&&c.delete(i)}_removeCellCacheByRange(e){let{unitId:t,sheetId:n,range:r,id:i}=e,a=this._oneCellCache.get(t);if(!a)return;let o=a.get(n);if(!o)return;let{startRow:s,startColumn:c,endRow:l,endColumn:u}=r;for(let e=s;e<=l;e++){let t=o.get(e);if(t)for(let e=c;e<=u;e++){let n=t.get(e);n&&n.delete(i)}}}_insertOneCellCache(e,t,n,r,i){this._getOneCellCache(e,t,n,r).add(i)}_getRdTreeItems(e){let t=[];for(let[n,r]of e)for(let[e,i]of r)t.push({x:e,y:n,ids:i});return t}_searchByOneCellCache(e){var t;let{unitId:n,sheetId:r,range:i}=e,{startRow:a,startColumn:o,endRow:s,endColumn:c}=i,l=(t=this._kdTree.get(n))==null?void 0:t.get(r);if(!l)return[];let{tree:u,items:d}=l,f=u.range(o,a,c,s),p=[];for(let e of f){let t=d[e];p.push(...Array.from(t.ids))}return p}openKdTree(){for(let[t,n]of this._oneCellCache){this._kdTree.has(t)||this._kdTree.set(t,new Map);for(let[r,i]of n){var e;let n=this._getRdTreeItems(i),a=new R_(n.length);(e=this._kdTree.get(t))==null||e.set(r,{tree:a,items:n});for(let e of n)a.add(e.x,e.y);a.finish()}}}closeKdTree(){for(let[t,n]of this._oneCellCache)for(let[r,i]of n){var e;(e=this._kdTree.get(t))==null||e.set(r,void 0)}}insert(e){let{unitId:t,sheetId:n,range:r,id:i}=e;if(!t||t.length===0)return;let{startRow:a,endRow:o,startColumn:s,endColumn:c}=r;if(this._enableOneCellCache&&a===o&&s===c){this._insertOneCellCache(t,n,a,s,i);return}let l=this.getTree(t,n);Number.isNaN(a)&&(a=0),Number.isNaN(s)&&(s=0),Number.isNaN(o)&&(o=1/0),Number.isNaN(c)&&(c=1/0),l.insert({minX:s,minY:a,maxX:c,maxY:o,id:i})}bulkInsert(e){for(let t of e)this.insert(t)}*searchGenerator(e){var t;let{unitId:n,sheetId:r,range:i}=e;if(this._enableOneCellCache){let t=this._searchByOneCellCache(e);for(let e of t)yield e}let a=(t=this._tree.get(n))==null?void 0:t.get(r);if(!a)return;let o=a.search({minX:i.startColumn,minY:i.startRow,maxX:i.endColumn,maxY:i.endRow});for(let e of o)yield e.id}bulkSearch(e,t){let n=new Set;for(let r of e)for(let e of this.searchGenerator(r))(t==null?void 0:t.has(e))!==!0&&n.add(e);return n}removeById(e,t){if(t){var n,r;(n=this._tree.get(e))==null||n.delete(t),(r=this._oneCellCache.get(e))==null||r.delete(t)}else this._tree.delete(e),this._oneCellCache.delete(e)}_removeRTreeItem(e){let{unitId:t,sheetId:n,range:r,id:i}=e,a=this.getTree(t,n),o=a.search({minX:r.startColumn,minY:r.startRow,maxX:r.endColumn,maxY:r.endRow});for(let e=0;e<o.length;e++)o[e].id===i&&a.remove(o[e])}remove(e){let{unitId:t,sheetId:n,range:r,id:i}=e,{startRow:a,startColumn:o,endRow:s,endColumn:c}=r;this._enableOneCellCache?a===s&&o===c?this._removeOneCellCache(t,n,r.startRow,r.startColumn,i):(this._removeCellCacheByRange(e),this._removeRTreeItem(e)):this._removeRTreeItem(e)}bulkRemove(e){for(let t of e)this.remove(t)}clear(){this._tree.clear(),this._oneCellCache.clear()}toJSON(){let e={};return this._tree.forEach((t,n)=>{e[n]={},t.forEach((t,r)=>{e[n][r]=t.toJSON()})}),e}fromJSON(e){this._tree.clear();for(let t in e){this._tree.set(t,new Map);for(let n in e[t]){let r=new $f;r.fromJSON(e[t][n]),this._tree.get(t).set(n,r)}}}};function G_(e){return new Promise(t=>setTimeout(t,e))}function K_(e=1){return new Promise(t=>{let n=0,r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}let q_=class extends ra{constructor(e){super(),this._localeService=e,P(this,`_fontLocale`,void 0),P(this,`_dirty`,!0),this._localeInitial()}get dirty(){return this._dirty}getFontLocale(){return this._fontLocale}makeDirty(e){this._dirty=e}dispose(){super.dispose(),this._fontLocale=null}_localeInitial(){}};q_=Us([W(0,(0,t.Inject)(d_))],q_);let J_=class extends q_{constructor(e,t,n,r,i,a){super(n),this.worksheet=e,this._styles=t,this._contextService=r,this._configService=i,this._injector=a,P(this,`_worksheetData`,void 0),P(this,`_renderRawFormula`,!1),P(this,`_cellData`,void 0),P(this,`_imageCacheMap`,void 0),P(this,`_skipAutoHeightForMergedCells`,!0),P(this,`_rowTotalHeight`,0),P(this,`_columnTotalWidth`,0),P(this,`_rowHeaderWidth`,0),P(this,`_columnHeaderHeight`,0),P(this,`_rowHeightAccumulation`,[]),P(this,`_columnWidthAccumulation`,[]),P(this,`_marginTop`,0),P(this,`_marginLeft`,0),P(this,`_scaleX`,void 0),P(this,`_scaleY`,void 0),P(this,`_scrollX`,void 0),P(this,`_scrollY`,void 0),this._worksheetData=this.worksheet.getConfig(),this._cellData=this.worksheet.getCellMatrix(),this._imageCacheMap=new P_(this._injector),this.initConfig()}initConfig(){var e,t;this._skipAutoHeightForMergedCells=!((e=this._configService.getConfig(ne))!=null&&e),this.worksheet.setIsRowStylePrecedeColumnStyle((t=this._configService.getConfig(`isRowStylePrecedeColumnStyle`))==null?!1:t)}resetCache(){}getWorksheetConfig(){return this._worksheetData}getLocation(){return[this.worksheet.getUnitId(),this.worksheet.getSheetId()]}set columnHeaderHeight(e){this._columnHeaderHeight=e,this._worksheetData.columnHeader.height=e}set rowHeaderWidth(e){this._rowHeaderWidth=e,this._worksheetData.rowHeader.width=e}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(e){this._marginLeft=e}setMarginTop(e){this._marginTop=e}setScale(e,t){this._updateLayout(),this._scaleX=e,this._scaleY=t||e,this._updateLayout()}setScroll(e,t){R.isDefine(e)&&(this._scrollX=e),R.isDefine(t)&&(this._scrollY=t)}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(e,t,n){let r=0,i=[],a=t;for(let t=0;t<e;t++){let e=n;if(this.worksheet.getRowFiltered(t))e=0;else if(a[t]!=null){let r=a[t];if(!r)continue;let{h:i=n,ah:o,ia:s}=r;e=(s==null||s===B.TRUE)&&typeof o==`number`&&o>0?o:i,r.hd===B.TRUE&&(e=0)}r+=e,i.push(r)}return{rowTotalHeight:r,rowHeightAccumulation:i}}_generateColumnMatrixCache(e,t,n){let r=0,i=[],a=t;for(let t=0;t<e;t++){let e=n;if(a[t]!=null){let n=a[t];if(!n)continue;n.w!=null&&(e=n.w),n.hd===B.TRUE&&(e=0)}r+=e,i.push(r)}return{columnTotalWidth:r,columnWidthAccumulation:i}}intersectMergeRange(e,t){return!!this.worksheet.getMergedCell(e,t)}_getOverflowBound(e,t,n,r,i=So.LEFT){let a=0;if(t>n){let o=this._columnWidthAccumulation.length-1;for(let s=t;s>=n;s--){let n=s;if(!Md(this.worksheet.getCell(e,n))&&n!==t||this.intersectMergeRange(e,n))return n===t?n:n+1>o?o:n+1;let{startX:c,endX:l}=Z_(e,n,this.rowHeightAccumulation,this.columnWidthAccumulation);if(i===So.CENTER&&n===t?a+=(l-c)/2:a+=l-c,r<a)return n}return t}for(let o=t;o<=n;o++){let n=o;if(!Md(this.worksheet.getCell(e,n))&&n!==t||this.intersectMergeRange(e,n))return n===t?n:n-1<0?0:n-1;let{startX:s,endX:c}=Z_(e,n,this.rowHeightAccumulation,this.columnWidthAccumulation);if(i===So.CENTER&&n===t?a+=(c-s)/2:a+=c-s,r<a)return n}return n}_updateLayout(){if(!this.dirty)return;let{rowData:e,columnData:t,defaultRowHeight:n,defaultColumnWidth:r,rowCount:i,columnCount:a,rowHeader:o,columnHeader:s}=this._worksheetData,{rowTotalHeight:c,rowHeightAccumulation:l}=this._generateRowMatrixCache(i,e,n),{columnTotalWidth:u,columnWidthAccumulation:d}=this._generateColumnMatrixCache(a,t,r);this._rowHeaderWidth=o.hidden===B.TRUE?0:this._dynamicallyUpdateRowHeaderWidth(o),this._columnHeaderHeight=s.hidden===B.TRUE?0:s.height,this._rowTotalHeight=c,this._rowHeightAccumulation=l,this._columnTotalWidth=u,this._columnWidthAccumulation=d,this.makeDirty(!1)}calculate(){return this.resetCache(),this._updateLayout(),this}resetRangeCache(e){}_dynamicallyUpdateRowHeaderWidth(e){let t=`${this.worksheet.getRowCount()}`.length*8;return Math.max(e.width,t)}_hasUnMergedCellInRow(e,t,n){if(!this.worksheet.getMergeData())return!1;for(let r=t;r<=n;r++){let{isMerged:t,isMergedMainCell:n}=this.worksheet.getCellInfoInMergeData(e,r);if(!t&&!n)return!0}return!1}expandRangeByMerge(e,t){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e,o=this._worksheetData.mergeData;if(!o)return{startRow:n,startColumn:r,endRow:i,endColumn:a};let s=!0,c=new Dd,l=0,u=null;for(;s;){s=!1;for(let e=0;e<o.length;e++){let{startRow:t,startColumn:d,endRow:f,endColumn:p}=o[e];if(c.getValue(t,d))continue;let m={startColumn:r,startRow:n,endColumn:a,endRow:i},h={startColumn:d,startRow:t,endColumn:p,endRow:f};xp(m,h)&&(n=Math.min(n,t),r=Math.min(r,d),i=Math.max(i,f),a=Math.max(a,p),c.setValue(t,d,!0),s=!0,l++,u=h)}}return t&&l===1&&Tp.contains(u,e)?{startRow:u.startRow,startColumn:u.startColumn,endRow:u.startRow,endColumn:u.startColumn}:{startRow:n,startColumn:r,endRow:i,endColumn:a}}getColumnCount(){return this._columnWidthAccumulation.length}getRowCount(){return this._rowHeightAccumulation.length}_getCellMergeInfo(e,t){return this.worksheet.getCellInfoInMergeData(e,t)}getNoMergeCellPositionByIndex(e,t,n=!0){return this.getNoMergeCellWithCoordByIndex(e,t,n)}getNoMergeCellWithCoordByIndex(e,t,n=!0){let{rowHeightAccumulation:r,columnWidthAccumulation:i,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:o}=this,{startY:s,endY:c,startX:l,endX:u}=Z_(e,t,r,i);return n&&(s+=o,c+=o,l+=a,u+=a),{startY:s,endY:c,startX:l,endX:u}}getNoMergeCellPositionByIndexWithNoHeader(e,t){let{rowHeightAccumulation:n,columnWidthAccumulation:r}=this,{startY:i,endY:a,startX:o,endX:s}=Z_(e,t,n,r);return{startY:i,endY:a,startX:o,endX:s}}getRowIndexByOffsetY(e,t,n,r){let{rowHeightAccumulation:i}=this;e=$_(e,t,n,this.columnHeaderHeightAndMarginTop);let a=cc(i,e,r==null?void 0:r.firstMatch);if(r!=null&&r.closeFirst){var o;Math.abs(i[a]-e)<Math.abs(e-((o=i[a-1])==null?0:o))&&(a+=1)}return a}getColumnIndexByOffsetX(e,t,n,r){let i=Q_(e,t,n,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this,o=cc(a,i,r==null?void 0:r.firstMatch);if(r!=null&&r.closeFirst){var s;Math.abs(a[o]-i)<Math.abs(i-((s=a[o-1])==null?0:s))&&(o+=1)}return o}getCellIndexByOffset(e,t,n,r,i,a){return{row:this.getRowIndexByOffsetY(t,r,i,a),column:this.getColumnIndexByOffsetX(e,n,i,a)}}getCellByOffset(e,t,n,r,i){var a;let o=(a=this)==null?void 0:a.getCellIndexByOffset(e,t,n,r,i,{firstMatch:!0});return o?this.worksheet.getCellInfoInMergeData(o.row,o.column):null}getCellWithCoordByIndex(e,t,n=!0){var r;let{rowHeightAccumulation:i,columnWidthAccumulation:a,rowHeaderWidthAndMarginLeft:o,columnHeaderHeightAndMarginTop:s}=this,c=Z_(e,t,i,a,(r=this.worksheet)==null?void 0:r.getCellInfoInMergeData(e,t)),{isMerged:l,isMergedMainCell:u}=c,{startY:d,endY:f,startX:p,endX:m,mergeInfo:h}=c,g=o,_=s;return n===!1&&(g=0,_=0),d+=_,f+=_,p+=g,m+=g,h.startY+=_,h.endY+=_,h.startX+=g,h.endX+=g,{actualRow:e,actualColumn:t,startX:p,startY:d,endX:m,endY:f,isMerged:l,isMergedMainCell:u,mergeInfo:h}}getCellWithCoordByOffset(e,t,n,r,i,a){let{row:o,column:s}=this.getCellIndexByOffset(e,t,n,r,i,a);return this.getCellWithCoordByIndex(o,s)}getOffsetByColumn(e){let{columnWidthAccumulation:t,rowHeaderWidthAndMarginLeft:n}=this,r=t.length-1,i=t[e];return i==null?e<0?n:t[r]+n:i+n}getOffsetByRow(e){let{rowHeightAccumulation:t,columnHeaderHeightAndMarginTop:n}=this,r=t.length-1,i=t[e];return i==null?e<0?n:t[r]+n:i+n}getOffsetRelativeToRowCol(e,t){let n=cc(this.columnWidthAccumulation,e),r=0;r=n===0?e:e-this._columnWidthAccumulation[n-1];let i=cc(this.rowHeightAccumulation,t),a=0;return a=i===0?t:t-this._rowHeightAccumulation[i-1],{row:i,column:n,columnOffset:r,rowOffset:a}}_updateConfigAndGetDocumentModel(e,t,n,r){var i,a,o,s,c;if(!r||!((i=e.body)!=null&&i.dataStream))return;e.documentStyle||(e.documentStyle={}),e.documentStyle.marginTop=(a=n.t)==null?0:a,e.documentStyle.marginBottom=(o=n.b)==null?2:o,e.documentStyle.marginLeft=(s=n.l)==null?2:s,e.documentStyle.marginRight=(c=n.r)==null?2:c,e.documentStyle.pageSize={width:1/0,height:1/0},e.documentStyle.renderConfig={...e.documentStyle.renderConfig,...r};let l=e.body.paragraphs||[];for(let e of l)e.paragraphStyle||(e.paragraphStyle={}),e.paragraphStyle.horizontalAlign=t;return new ch(e)}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}};J_=Us([W(2,(0,t.Inject)(d_)),W(3,Ls),W(4,Fs),W(5,(0,t.Inject)(t.Injector))],J_);function Y_(e,t,n,r){let i=e-1,a=t-1,o=n[i]||0,s=n[e];s==null&&(s=n[n.length-1]);let c=r[a]||0,l=r[t];return l==null&&(l=r[r.length-1]),{startY:o,endY:s,startX:c,endX:l}}function X_(e,t,n,r){return Y_(e,t,n,r)}function Z_(e,t,n,r,i){e=R.clamp(e,0,n.length-1),t=R.clamp(t,0,r.length-1);let{startY:a,endY:o,startX:s,endX:c}=Y_(e,t,n,r);if(!i)return{startY:a,endY:o,startX:s,endX:c,isMerged:!1,isMergedMainCell:!1,actualRow:e,actualColumn:t,mergeInfo:{startY:a,endY:o,startX:s,endX:c,startRow:e,startColumn:t,endRow:e,endColumn:t}};let{isMerged:l,isMergedMainCell:u,startRow:d,startColumn:f,endRow:p,endColumn:m}=i,h={startRow:d,startColumn:f,endRow:p,endColumn:m,startY:a,endY:o,startX:s,endX:c},g=n.length-1,_=r.length-1;if(l&&d!==-1&&f!==-1){let e=n[d-1]||0,t=n[p]||n[g],i=r[f-1]||0,a=r[m]||r[_];h={...h,startY:e,endY:t,startX:i,endX:a}}else if(!l&&p!==-1&&m!==-1){let e=n[p]||n[g],t=r[m]||r[_];h={...h,startY:a,endY:e,startX:s,endX:t}}return{isMerged:l,isMergedMainCell:u,actualRow:e,actualColumn:t,startY:a,endY:o,startX:s,endX:c,mergeInfo:h}}function Q_(e,t,n,r){let{x:i}=n;return e/t+i-r}function $_(e,t,n,r){let{y:i}=n;return e=e/t+i-r,e}let ev=[`script`,`style`,`meta`,`comment`,`link`],tv=function(e){return e[e.INFO=0]=`INFO`,e[e.STOP=1]=`STOP`,e[e.WARNING=2]=`WARNING`,e}({}),nv=function(e){return 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}({}),rv=function(e){return 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}({}),iv=function(e){return e[e.TEXT=0]=`TEXT`,e[e.ARROW=1]=`ARROW`,e[e.CUSTOM=2]=`CUSTOM`,e}({}),av=function(e){return e.VALID=`valid`,e.INVALID=`invalid`,e.VALIDATING=`validating`,e}({}),ov=function(e){return 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}({}),sv=class extends ra{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){let e=e=>{e.businesses.forEach(t=>{switch(t){case I.UNRECOGNIZED:case I.UNIVER_UNKNOWN:case I.UNIVER_SLIDE:case I.UNIVER_DOC:this._univerInstanceService.getAllUnitsForType(I.UNIVER_DOC).forEach(t=>{let n=(t.getSnapshot().resources||[]).find(t=>t.name===e.pluginName);if(n)try{let r=e.parseJson(n.data);e.onLoad(t.getUnitId(),r)}catch{console.error(`Load Document{${t.getUnitId()}} Resources{${e.pluginName}} Data Error.`)}});break;case I.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(I.UNIVER_SHEET).forEach(t=>{let n=(t.getSnapshot().resources||[]).find(t=>t.name===e.pluginName);if(n)try{let r=e.parseJson(n.data);e.onLoad(t.getUnitId(),r)}catch{console.error(`Load Workbook{${t.getUnitId()}} Resources{${e.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(t=>e(t)),this.disposeWithMe(this._resourceManagerService.register$.subscribe(t=>e(t))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(I.UNIVER_SHEET).subscribe(e=>{this._resourceManagerService.loadResources(e.getUnitId(),e.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(I.UNIVER_DOC).subscribe(e=>{ie(e.getUnitId())||this._resourceManagerService.loadResources(e.getUnitId(),e.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(I.UNIVER_SHEET).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),I.UNIVER_SHEET)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(I.UNIVER_DOC).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),I.UNIVER_DOC)}))}saveUnit(e){let t=this._univerInstanceService.getUnit(e);if(!t)return null;let n=this._resourceManagerService.getResources(e,t.type),r=R.deepClone(t.getSnapshot());return r.resources=n,r}};sv=Us([W(0,(0,t.Inject)(tg)),W(1,(0,t.Inject)(i_))],sv);var cv=class{get _univerInstanceService(){return this._injector.get(i_)}get _pluginService(){return this._injector.get(S_)}constructor(e={},t){P(this,`_startedTypes`,new Set),P(this,`_injector`,void 0),P(this,`_disposingCallbacks`,new na);let n=this._injector=lv(t,e==null?void 0:e.override),{theme:r,darkMode:i,locale:a,locales:o,logLevel:s,logCommandExecution:c}=e;r&&this._injector.get(T_).setTheme(r),i&&this._injector.get(T_).setDarkMode(i),o&&this._injector.get(d_).load(o),a&&this._injector.get(d_).setLocale(a),s&&this._injector.get(Bs).setLogLevel(s),c!==void 0&&this._injector.get(Fs).setConfig(Ws,c),this._init(n)}__getInjector(){return this._injector}onDispose(e){let t=this._disposingCallbacks.add(ta(e));return ta(()=>t.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(e){this._injector.get(d_).setLocale(e)}createUnit(e,t){return this._univerInstanceService.createUnit(e,t)}createUniverSheet(e){return this._injector.get(Bs).warn(`[Univer]`,`Univer.createUniverSheet is deprecated, use createUnit instead`),this._univerInstanceService.createUnit(I.UNIVER_SHEET,e)}createUniverDoc(e){return this._injector.get(Bs).warn(`[Univer]`,`Univer.createUniverDoc is deprecated, use createUnit instead`),this._univerInstanceService.createUnit(I.UNIVER_DOC,e)}createUniverSlide(e){return this._injector.get(Bs).warn(`[Univer]`,`Univer.createUniverSlide is deprecated, use createUnit instead`),this._univerInstanceService.createUnit(I.UNIVER_SLIDE,e)}_init(e){this._univerInstanceService.registerCtorForType(I.UNIVER_SHEET,n_),this._univerInstanceService.registerCtorForType(I.UNIVER_DOC,ch),this._univerInstanceService.registerCtorForType(I.UNIVER_SLIDE,r_);let t=e.get(i_);t.__setCreateHandler((n,r,i,a)=>{if(!this._startedTypes.has(n)){this._pluginService.startPluginsForType(n),this._startedTypes.add(n);let o=e.createInstance(i,r);return t.__addUnit(o,a),this._tryProgressToReady(),o}let o=e.createInstance(i,r);return t.__addUnit(o,a),o})}_tryProgressToReady(){this._injector.get(c_).stage<$.Ready&&(this._injector.get(c_).stage=$.Ready)}registerPlugin(e,t){this._pluginService.registerPlugin(e,t)}registerPlugins(e){e.forEach(e=>{let[t,n]=e;this._pluginService.registerPlugin(t,n)})}};function lv(e,n){let r=__([[gg],[d_],[T_],[c_],[S_],[ag],[i_,{useClass:a_}],[h_,{useClass:g_}],[Bs,{useClass:Vs,lazy:!0}],[Ks,{useClass:Ys}],[D_,{useClass:N_,lazy:!0}],[Fs,{useClass:Is}],[Ls,{useClass:Rs}],[tg,{useClass:w_,lazy:!0}],[C_,{useClass:sv,lazy:!0}],[sg,{useClass:og}],[p_,{useClass:f_,lazy:!0}]],n),i=e?e.createChild(r):new t.Injector(r);return se(i,[[ag],[C_]]),i}y(),e.ABCToNumber=Mp,e.AUTO_HEIGHT_FOR_MERGED_CELLS=ne,e.AbsoluteRefType=K,e.ActionIterator=Rm,e.AlignTypeH=as,e.AlignTypeV=os,e.ArrangeTypeEnum=ds,e.ArrowsAndMarkersShapes=ho,e.AsyncInterceptorManager=xe,e.AsyncLock=O.default,Object.defineProperty(e,`AuthzIoLocalService`,{enumerable:!0,get:function(){return og}}),e.AutoFillSeries=$a,e.BORDER_KEYS=bs,e.BORDER_STYLE_KEYS=ys,e.BaselineOffset=Do,e.BasicShapes=mo,e.BlockType=Io,e.BooleanNumber=B,e.BorderStyleTypes=z,e.BorderType=eo,e.BuildTextUtils=Vh,e.BulletAlignment=No,e.COLORS=dc,e.COLOR_STYLE_KEYS=vs,e.COMMAND_LOG_EXECUTION_CONFIG_KEY=Ws,e.CanceledError=ue,e.CellModeEnum=Rc,e.CellValueType=Oo,e.ColorKit=fc,e.ColorType=to,e.ColumnSeparatorType=Bo,Object.defineProperty(e,`CommandService`,{enumerable:!0,get:function(){return Ys}}),e.CommandType=Gs,e.CommonHideTypes=no,e.ConfigService=Is,e.ContextService=Rs,e.CopyPasteType=ro,e.CustomCommandExecutionError=le,e.CustomDecorationType=Fo,e.CustomRangeType=Po,e.DEFAULT_CELL=Bf,e.DEFAULT_DOC=oh,e.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=`__default_document_sub_component_id20231101__`,e.DEFAULT_EMPTY_DOCUMENT_VALUE=`\r
|
|
9
|
-
`,e.DEFAULT_NUMBER_FORMAT=`General`,e.DEFAULT_RANGE=Rf,e.DEFAULT_RANGE_ARRAY=Lf,e.DEFAULT_SELECTION=zf,e.DEFAULT_SLIDE=Hf,e.DEFAULT_STYLES=Vf,e.DEFAULT_TEXT_FORMAT=`@@@`,e.DEFAULT_TEXT_FORMAT_EXCEL=`@`,e.DEFAULT_WORKSHEET_COLUMN_COUNT=20,e.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=`DEFAULT_WORKSHEET_COLUMN_COUNT`,e.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=20,e.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=`DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT`,e.DEFAULT_WORKSHEET_COLUMN_WIDTH=88,e.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=`DEFAULT_WORKSHEET_COLUMN_WIDTH`,e.DEFAULT_WORKSHEET_ROW_COUNT=qg,e.DEFAULT_WORKSHEET_ROW_COUNT_KEY=`DEFAULT_WORKSHEET_ROW_COUNT`,e.DEFAULT_WORKSHEET_ROW_HEIGHT=24,e.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=`DEFAULT_WORKSHEET_ROW_HEIGHT`,e.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=46,e.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=`DEFAULT_WORKSHEET_ROW_TITLE_WIDTH`,e.DOCS_COMMENT_EDITOR_UNIT_ID_KEY=te,e.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=N,e.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=M,e.DOCS_ZEN_EDITOR_UNIT_ID_KEY=ee,e.DOC_DRAWING_PRINTING_COMPONENT_KEY=`univer-docs-drawing-printing`,e.DOC_RANGE_TYPE=Ic,e.DashStyleType=qo,e.DataStreamTreeNodeType=$m,e.DataStreamTreeTokenType=eh,e.DataValidationErrorStyle=tv,e.DataValidationImeMode=nv,e.DataValidationOperator=rv,e.DataValidationRenderMode=iv,e.DataValidationStatus=av,e.DataValidationType=ov,e.DeleteDirection=io,e.DependentOn=x_,e.DesktopLogService=Vs,e.DeveloperMetadataVisibility=ao,e.Dimension=oo,e.Direction=so,e.Disposable=ra,e.DisposableCollection=na,e.DocStyleType=jo,e.DocumentDataModel=ch,e.DocumentFlavor=Lo,e.DrawingTypeEnum=fs,e.EDITOR_ACTIVATED=mg,e.EXTENSION_NAMES=Kf,e.ErrorService=gg,e.EventState=Qh,e.EventSubject=$h,e.FOCUSING_COMMENT_EDITOR=`FOCUSING_COMMENT_EDITOR`,e.FOCUSING_COMMON_DRAWINGS=`FOCUSING_COMMON_DRAWINGS`,e.FOCUSING_DOC=fg,e.FOCUSING_EDITOR_BUT_HIDDEN=`FOCUSING_EDITOR_BUT_HIDDEN`,e.FOCUSING_EDITOR_INPUT_FORMULA=`FOCUSING_EDITOR_INPUT_FORMULA`,e.FOCUSING_EDITOR_STANDALONE=`FOCUSING_EDITOR_INPUT_FORMULA`,e.FOCUSING_FX_BAR_EDITOR=hg,e.FOCUSING_PANEL_EDITOR=`FOCUSING_PANEL_EDITOR`,e.FOCUSING_SHAPE_TEXT_EDITOR=`FOCUSING_SHAPE_TEXT_EDITOR`,e.FOCUSING_SHEET=dg,e.FOCUSING_SLIDE=pg,e.FOCUSING_UNIT=ug,e.FOCUSING_UNIVER_EDITOR=`FOCUSING_UNIVER_EDITOR`,e.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=`FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE`,e.FORMULA_EDITOR_ACTIVATED=`FORMULA_EDITOR_ACTIVATED`,e.FollowNumberWithType=Mo,e.FontItalic=To,e.FontStyleType=ts,e.FontWeight=Eo,e.GridType=Ro,e.HorizontalAlign=So,e.IAuthzIoService=sg,e.ICommandService=Ks,e.IConfigService=Fs,e.IConfirmService=cg,e.IContextService=Ls,e.IImageIoService=yg,e.ILocalStorageService=u_,e.ILogService=Bs,e.IMentionIOService=p_,e.IPermissionService=h_,e.IResourceLoaderService=C_,e.IResourceManagerService=tg,e.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE=`isRowStylePrecedeColumnStyle`,e.IURLImageService=bg,e.IUndoRedoService=D_,e.IUniverInstanceService=i_,e.ImageCacheMap=P_,e.ImageSourceType=_g,e.ImageUploadStatusType=vg,Object.defineProperty(e,`Inject`,{enumerable:!0,get:function(){return t.Inject}}),Object.defineProperty(e,`InjectSelf`,{enumerable:!0,get:function(){return t.InjectSelf}}),Object.defineProperty(e,`Injector`,{enumerable:!0,get:function(){return t.Injector}}),e.InterceptorEffectEnum=he,e.InterceptorManager=ve,e.InterpolationPointType=lo,Object.defineProperty(e,`JSON1`,{enumerable:!0,get:function(){return Ps}}),e.JSONX=Qm,e.LRUHelper=Nf,e.LRUMap=Mf,Object.defineProperty(e,`LifecycleService`,{enumerable:!0,get:function(){return c_}}),e.LifecycleStages=$,e.LifecycleUnreachableError=s_,e.ListGlyphType=V,Object.defineProperty(e,`LocalUndoRedoService`,{enumerable:!0,get:function(){return N_}}),e.LocaleService=d_,e.LocaleType=uo,e.LogLevel=zs,Object.defineProperty(e,`LookUp`,{enumerable:!0,get:function(){return t.LookUp}}),e.MAX_COLUMN_COUNT=If,e.MAX_ROW_COUNT=Ff,e.MOVE_BUFFER_VALUE=2,Object.defineProperty(e,`Many`,{enumerable:!0,get:function(){return t.Many}}),e.MemoryCursor=Ui,Object.defineProperty(e,`MentionIOLocalService`,{enumerable:!0,get:function(){return f_}}),e.MentionType=fo,e.NAMED_STYLE_MAP=Wf,e.NAMED_STYLE_SPACE_MAP=Gf,e.NamedStyleType=Go,e.NilCommand=Js,e.NumberUnitType=is,e.ObjectMatrix=Dd,e.ObjectRelativeFromH=ns,e.ObjectRelativeFromV=rs,Object.defineProperty(e,`Optional`,{enumerable:!0,get:function(){return t.Optional}}),e.OtherShapes=go,e.PADDING_KEYS=Ss,e.PAGE_SIZE=qf,e.PAPER_TYPES=us,e.PRESET_LIST_TYPE=um,e.PRINT_CHART_COMPONENT_KEY=`univer-sheets-chart-print-chart`,e.PageElementType=ms,e.PageOrientType=cs,e.PageType=ps,e.PaperType=ls,e.ParagraphElementType=Ho,e.ParagraphStyleBuilder=Yh,e.ParagraphStyleValue=Jh,e.PermissionService=g_,e.PermissionStatus=m_,e.Plugin=y_,Object.defineProperty(e,`PluginService`,{enumerable:!0,get:function(){return S_}}),e.PositionedObjectLayoutType=Wo,e.PresetListType=Z,e.ProtectionType=po,Object.defineProperty(e,`Quantity`,{enumerable:!0,get:function(){return t.Quantity}}),e.QuickListType=am,e.QuickListTypeMap=pm,e.RANGE_DIRECTION=Fc,e.RANGE_TYPE=G,e.RBush=$f,e.RCDisposable=aa,e.RGBA_PAREN=`rgba(`,e.RGB_PAREN=`rgb(`,e.ROTATE_BUFFER_VALUE=1,e.RTree=W_,e.Range=Yf,e.Rectangle=Tp,Object.defineProperty(e,`RediError`,{enumerable:!0,get:function(){return t.RediError}}),e.RedoCommand=M_,e.RedoCommandId=k_,e.RefAlias=Ap,e.Registry=Ji,e.RegistryAsMap=Yi,e.RelativeDate=vo,e.RelativeSlideLink=hs,Object.defineProperty(e,`ResourceManagerService`,{enumerable:!0,get:function(){return w_}}),e.RichTextBuilder=Zh,e.RichTextValue=Xh,e.RxDisposable=ia,e.SHEET_EDITOR_UNITS=Uf,e.STYLE_KEYS=Cs,e.SectionType=zo,Object.defineProperty(e,`Self`,{enumerable:!0,get:function(){return t.Self}}),Object.defineProperty(e,`SheetSkeleton`,{enumerable:!0,get:function(){return J_}}),e.SheetTypes=yo,e.SheetViewModel=Xg,Object.defineProperty(e,`Skeleton`,{enumerable:!0,get:function(){return q_}}),Object.defineProperty(e,`SkipSelf`,{enumerable:!0,get:function(){return t.SkipSelf}}),e.SliceBodyType=Cm,e.SlideDataModel=r_,e.SpacingRule=Ko,e.SpecialShapes=_o,e.Styles=wg,e.TEXT_DECORATION_KEYS=_s,e.TEXT_ROTATION_KEYS=xs,e.THEME_COLORS=zc,e.TabStopAlignment=Jo,e.TableAlignmentType=Xo,e.TableLayoutType=Zo,e.TableRowHeightRule=$o,e.TableSizeType=Yo,e.TableTextWrapType=Qo,e.TestConfirmService=lg,e.TextDecoration=xo,e.TextDecorationBuilder=qh,e.TextDirection=bo,e.TextDirectionType=Vo,e.TextStyleBuilder=Kh,e.TextStyleValue=Gh,e.TextX=Q,e.TextXActionType=U,e.ThemeColorType=ko,e.ThemeColors=Ao,e.ThemeService=T_,e.Tools=R,e.UndoCommand=j_,e.UndoCommandId=A_,e.UnitModel=Pa,e.Univer=cv,Object.defineProperty(e,`UniverInstanceService`,{enumerable:!0,get:function(){return a_}}),e.UniverInstanceType=I,e.UpdateDocsAttributeType=H,e.UserManagerService=ag,e.VerticalAlign=Co,e.VerticalAlignmentType=es,Object.defineProperty(e,`WithNew`,{enumerable:!0,get:function(){return t.WithNew}}),Object.defineProperty(e,`Workbook`,{enumerable:!0,get:function(){return n_}}),e.Worksheet=Qg,e.WrapStrategy=wo,e.WrapTextType=Uo,e.addLinkToDocumentModel=Mg,e.afterInitApply=ic,e.afterTime=nc,e.awaitTime=G_,e.binSearchFirstGreaterThanTarget=sc,e.binarySearchArray=oc,e.bufferDebounceTime=tc,e.cellToRange=Vd,e.characterSpacingControlType=ss,e.checkForSubstrings=Kd,e.checkIfMove=uc,e.checkParagraphHasBullet=pf,e.checkParagraphHasIndent=mf,e.checkParagraphHasIndentByStyle=hf,e.cloneCellData=zg,e.cloneCellDataMatrix=Vg,e.cloneCellDataWithSpanAndDisplay=Bg,e.cloneValue=Rg,e.cloneWorksheetData=Wg,e.codeToBlob=lc,e.columnLabelToNumber=Pf,e.composeBody=Im,e.composeInterceptors=_e,e.composeStyles=Xa,e.concatMatrixArray=Sd,e.convertCellToRange=Od,e.convertObservableToBehaviorSubject=rc,e.covertCellValue=Hd,e.covertCellValues=Ud,e.createAsyncInterceptorKey=ye,e.createDefaultUser=rg,e.createDocumentModelWithStyle=kg,Object.defineProperty(e,`createIdentifier`,{enumerable:!0,get:function(){return t.createIdentifier}}),e.createInterceptorKey=ge,e.createInternalEditorID=re,e.createREGEXFromWildChar=Qa,e.createRowColIter=jp,e.customNameCharacterCheck=I_,e.dayjs=nf.default,e.debounce=Mi,e.dedupe=x,e.dedupeBy=S,e.deepCompare=Wd,e.delayAnimationFrame=K_,e.deleteContent=_f,e.extractPureTextFromCell=$g,Object.defineProperty(e,`forwardRef`,{enumerable:!0,get:function(){return t.forwardRef}}),e.fromCallback=$s,e.fromEventSubject=eg,e.generateIntervalsByPoints=bf,e.generateRandomId=Ya,e.get=ti,e.getArrayLength=vd,e.getBodySlice=km,e.getBorderStyleType=Rd,e.getCellCoordByIndexSimple=Y_,e.getCellInfoInMergeData=Lc,e.getCellPositionByIndexSimple=X_,e.getCellValueType=jc,e.getCellWithCoordByIndexCore=Z_,e.getColorStyle=Nd,e.getCustomBlockSlice=Om,e.getCustomDecorationSlice=Mm,e.getCustomRangeSlice=jm,e.getDocsUpdateBody=zd,e.getEmptyCell=Pg,e.getIntersectRange=xp,e.getNumfmtParseValueFilter=gd,e.getOriginCellValue=e_,e.getParagraphsSlice=Em,e.getPlainText=rh,e.getReverseDirection=co,e.getSectionBreakSlice=Dm,e.getTableSlice=Tm,e.getTextRunSlice=wm,e.getTransformOffsetX=Q_,e.getTransformOffsetY=$_,e.getWorksheetUID=t_,e.groupBy=T,e.handleStyleToString=Id,e.hashAlgorithm=yf,e.horizontalLineSegmentsSubtraction=ff,e.insertMatrixArray=bd,e.insertTextToContent=gf,e.invertColorByHSL=Ne,e.invertColorByMatrix=Ie,Object.defineProperty(e,`isAsyncDependencyItem`,{enumerable:!0,get:function(){return t.isAsyncDependencyItem}}),Object.defineProperty(e,`isAsyncHook`,{enumerable:!0,get:function(){return t.isAsyncHook}}),e.isBlackColor=Oc,e.isBooleanString=A,e.isCellCoverable=Md,e.isCellV=Nc,Object.defineProperty(e,`isClassDependencyItem`,{enumerable:!0,get:function(){return t.isClassDependencyItem}}),e.isCommentEditorID=ae,Object.defineProperty(e,`isCtor`,{enumerable:!0,get:function(){return t.isCtor}}),e.isDefaultFormat=dd,Object.defineProperty(e,`isDisposable`,{enumerable:!0,get:function(){return t.isDisposable}}),e.isEmptyCell=jd,Object.defineProperty(e,`isFactoryDependencyItem`,{enumerable:!0,get:function(){return t.isFactoryDependencyItem}}),e.isFormulaId=Fd,e.isFormulaString=Pd,e.isICellData=Ac,e.isInternalEditorID=ie,e.isNodeEnv=Za,e.isNotNullOrUndefined=Ng,e.isNullCell=Mc,e.isNumeric=Gi,e.isPatternEqualWithoutDecimal=fd,e.isRangesEqual=Tg,e.isRealNum=vf,e.isSafeNumeric=Ki,e.isSameStyleTextRun=Gd,e.isTextFormat=ud,e.isUnitRangesEqual=Eg,e.isValidRange=Bd,Object.defineProperty(e,`isValueDependencyItem`,{enumerable:!0,get:function(){return t.isValueDependencyItem}}),e.isWhiteColor=kc,e.makeArray=E,e.makeCellRangeToRangeData=Ad,e.makeCellToSelection=kd,e.makeCustomRangeStream=th,e.mapObjectMatrix=_d,e.merge=Bi,e.mergeIntervals=xf,e.mergeLocales=Sf,e.mergeOverrideWithDependencies=__,e.mergeSets=$i,e.mergeWith=zi,e.mergeWorksheetSnapshotWithDefault=Jg,e.mixinClass=Wi,e.moveMatrixArray=wd,e.moveRangeByOffset=mp,e.nameCharacterCheck=F_,e.normalizeBody=Am,e.normalizeTextRuns=zp,e.numberToABC=Np,e.numberToListABC=Fp,Object.defineProperty(e,`numfmt`,{enumerable:!0,get:function(){return Qu}}),e.queryObjectMatrix=kp,e.registerDependencies=oe,e.remove=b,e.repeatStringNumTimes=Pp,e.replaceInDocumentBody=Hh,e.requestImmediateMacroTask=Xi,e.resolveWithBasePath=Va,e.rotate=w,e.searchArray=cc,e.searchInOrderedArray=ac,e.selectionToArray=Pc,e.sequence=Qi,e.sequenceAsync=Zi,e.sequenceExecute=Zs,e.sequenceExecuteAsync=Qs,e.set=Hi,Object.defineProperty(e,`setDependencies`,{enumerable:!0,get:function(){return t.setDependencies}}),e.shallowEqual=ce,e.skipParseTagNames=ev,e.sliceMatrixArray=Cd,e.sortRules=Ip,e.sortRulesByDesc=Lp,e.sortRulesFactory=Rp,e.spliceArray=xd,e.splitIntoGrid=gp,e.takeAfter=ec,Object.defineProperty(e,`textDiff`,{enumerable:!0,get:function(){return _h.default}}),e.throttle=de,e.toDisposable=ta,e.touchDependencies=se,e.updateAttributeByDelete=zm,e.updateAttributeByInsert=Bm,e.willLoseNumericPrecision=qi});
|
|
7
|
+
`,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(t){return new e(t==null?e.newEmptyData():t)}constructor(e){super(e),P(this,`_doc`,void 0),this._doc=new ch(e)}insertText(e,t,n){var r,i;let a=((r=(i=this._data.body)==null?void 0:i.dataStream.length)==null?2:r)-2,o,s;if(typeof e==`string`?o=e:(a=Math.min(e,a),o=t),s=typeof t==`object`?t instanceof Kh?t.build():t:n instanceof Kh?n.build():n,!o)return this;let c={dataStream:o,textRuns:s?[{ts:s,st:a,ed:a+o.length}]:[]},l=Vh.selection.replace({doc:this._doc,selection:{startOffset:a,endOffset:a,collapsed:!0},body:c});if(!l)throw Error(`Insert text failed, please check.`);return Q.apply(this._doc.getBody(),l.serialize()),this}insertRichText(e,t){var n,r;let i=((n=(r=this._data.body)==null?void 0:r.dataStream.length)==null?2:n)-2,a;typeof e==`object`?a=e instanceof Xh?e.getData():e:(i=Math.min(e,i),a=t instanceof Xh?t.getData():t);let o=Vh.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:a.body});if(!o)throw Error(`Insert text failed, please check.`);return Q.apply(this._doc.getBody(),o.serialize()),this}delete(e,t){if(t!==void 0){if(!t)return this;let n=Vh.selection.delete([{startOffset:e,endOffset:e+t,collapsed:!0}],this._data.body);Q.apply(this._doc.getBody(),n)}return this}setStyle(e,t,n){let r={dataStream:``,textRuns:[{ts:n instanceof Kh?n.build():n,st:0,ed:t-e}]},i=Vh.selection.retain([{startOffset:e,endOffset:t,collapsed:!0}],r);return Q.apply(this._doc.getBody(),i),this}setLink(e,t,n){let r=Vh.customRange.add({rangeType:Po.HYPERLINK,rangeId:Ya(),properties:{url:n},ranges:[{startOffset:e,endOffset:t,collapsed:!1}],body:this._data.body});if(!r)throw Error(`Insert text failed, please check.`);return Q.apply(this._doc.getBody(),r.serialize()),this}cancelLink(e,t){if(typeof e==`string`){let t=Vh.customRange.delete({rangeId:e,documentDataModel:this._doc});if(!t)throw Error(`Insert text failed, please check.`);Q.apply(this._doc.getBody(),t.serialize())}else this.slice(e,t).getLinks().forEach(e=>{let t=Vh.customRange.delete({rangeId:e.rangeId,documentDataModel:this._doc});if(!t)throw Error(`Insert text failed, please check.`);Q.apply(this._doc.getBody(),t.serialize())});return this}updateLink(e,t){var n;let r=(n=this._data.body)==null||(n=n.customRanges)==null?void 0:n.find(t=>t.rangeId===e);if(!r)throw Error(`Link not found`);return r.properties.url=t,this}insertParagraph(e,t){let n,r;if(typeof e==`object`){var i,a;n={dataStream:`\r`,paragraphs:[{startIndex:0,paragraphStyle:e.build()}]},r=((i=(a=this._data.body)==null?void 0:a.dataStream.length)==null?2:i)-2}else r=e,n={dataStream:`\r`,paragraphs:[{startIndex:0,paragraphStyle:t==null?void 0:t.build()}]};return this.insertRichText(r,Xh.create({body:n,id:`d`,documentStyle:{}})),this}insertLink(t,n,r){let i=``,a=``;typeof t==`string`?(i=t,a=n):(i=n,a=r);let o=e.createByBody({dataStream:i,customRanges:[{rangeType:Po.HYPERLINK,rangeId:Ya(),properties:{url:a},startIndex:0,endIndex:i.length-1}]});return typeof t==`number`?this.insertRichText(t,o):this.insertRichText(o)}},Qh=class{constructor(){P(this,`skipNextObservers`,!1),P(this,`lastReturnValue`,void 0),P(this,`isStopPropagation`,!1)}stopPropagation(){this.isStopPropagation=!0}},$h=class extends n.Subject{constructor(...e){super(...e),P(this,`_sortedObservers`,[])}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(e){let t;t=typeof e==`function`?{next:([t,n])=>e(t,n)}:e;let n=super.subscribe(t);return this._sortedObservers.push(t),this._sortedObservers.sort((e,t)=>{var n,r;return((n=e.priority)==null?0:n)-((r=t.priority)==null?0:r)}),n.add(()=>this._sortedObservers=this._sortedObservers.filter(e=>e!==t)),n}clearObservers(){this._sortedObservers.forEach(e=>{var t;return(t=e.complete)==null?void 0:t.call(e)}),this._sortedObservers.length=0}emitEvent(e){if(!this.closed){let n=new Qh;n.lastReturnValue=e;for(let r of this._sortedObservers){var t;if(n.lastReturnValue=(t=r.next)==null?void 0:t.call(r,[e,n]),n.skipNextObservers)return{handled:!0,lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}throw Error(`[EventSubject]: cannot emit event on a closed subject.`)}};function eg(e){return new n.Observable(t=>{let n=e.subscribeEvent(e=>{t.next(e)});return()=>n.unsubscribe()})}let tg=(0,t.createIdentifier)(`core.resource-manager.service`),ng={[L.Editor]:`Editor`,[L.Owner]:`Owner`,[L.Reader]:`Reader`,[L.UNRECOGNIZED]:`UNRECOGNIZED`},rg=e=>e?{userID:`${ng[e]}_${Ya(8)}`,name:ng[e],avatar:``}:{userID:``,name:``,avatar:``,anonymous:!0,canBindAnonymous:!1},ig=(e,t)=>e.startsWith(ng[t]);var ag=class extends ra{constructor(...e){super(...e),P(this,`_model`,new Map),P(this,`_userChange$`,new n.Subject),P(this,`userChange$`,this._userChange$.asObservable()),P(this,`_currentUser$`,new n.BehaviorSubject(rg())),P(this,`currentUser$`,this._currentUser$.asObservable())}dispose(){super.dispose(),this._model.clear(),this._userChange$.complete(),this._currentUser$.complete()}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(e){this.addUser(e),this._currentUser$.next(e)}addUser(e){this._model.set(e.userID,e),this._userChange$.next({type:`add`,user:e})}getUser(e,t){let n=this._model.get(e);if(n)return n;t&&t()}delete(e){let t=this.getUser(e);this._model.delete(e),t&&this._userChange$.next({type:`delete`,user:t})}clear(){this._model.clear(),this._userChange$.next({type:`clear`})}list(){return Array.from(this._model.values())}};let og=class{constructor(e,t){this._resourceManagerService=e,this._userManagerService=t,P(this,`_permissionMap`,new Map([])),P(this,`_permissionOverrides`,new Map),this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){let e=this._userManagerService.getCurrentUser();e&&e.userID||this._userManagerService.setCurrentUser(rg(L.Owner))}_getRole(e){let t=this._userManagerService.getCurrentUser();return t?ig(t.userID,e):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:e=>{let t=[...this._permissionMap.keys()].reduce((e,t)=>(e[t]=this._permissionMap.get(t),e),{});return JSON.stringify(t)},parseJson:e=>JSON.parse(e),pluginName:`SHEET_AuthzIoMockService_PLUGIN`,businesses:[I.UNIVER_SHEET,I.UNIVER_DOC,I.UNIVER_SLIDE],onLoad:(e,t)=>{for(let e in t)this._permissionMap.set(e,t[e])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(e){let t=Ya(8),{objectType:n,selectRangeObject:r,worksheetObject:i}=e,a=r||i,o={objectType:n,unitID:(a==null?void 0:a.unitID)||``,name:(a==null?void 0:a.name)||``,strategies:[{action:6,role:L.Owner},{action:16,role:L.Owner},{action:17,role:L.Owner},{action:18,role:L.Owner},{action:19,role:L.Owner},{action:33,role:L.Owner},{action:34,role:L.Owner},{action:35,role:L.Owner},{action:36,role:L.Owner},{action:37,role:L.Owner},{action:38,role:L.Owner},{action:39,role:L.Owner},{action:40,role:L.Owner}],selectRangeObject:r};return this._permissionMap.set(t,o),t}async allowed(e){let{objectID:t,actions:n}=e,r=this._permissionMap.get(t);return r?n.map(e=>{let n=`${t}:${e}`;if(this._permissionOverrides.has(n))return{action:e,allowed:this._permissionOverrides.get(n)};let i=r.strategies.find(t=>t.action===e);return i?{action:e,allowed:this._getRole(i.role)}:{action:e,allowed:this._getRole(L.Owner)||this._getRole(L.Editor)}}):n.map(e=>({action:e,allowed:this._getRole(L.Owner)||this._getRole(L.Editor)}))}async batchAllowed(e){let t=await Promise.all(e.map(e=>this.allowed(e)));return e.map((e,n)=>({unitID:e.unitID,objectID:e.objectID,actions:t[n]}))}async list(e){let t=[],n=[{action:6,role:L.Owner},{action:16,role:L.Owner},{action:17,role:L.Owner},{action:18,role:L.Owner},{action:19,role:L.Owner},{action:33,role:L.Owner},{action:34,role:L.Owner},{action:35,role:L.Owner},{action:36,role:L.Owner},{action:37,role:L.Owner},{action:38,role:L.Owner},{action:39,role:L.Owner},{action:40,role:L.Owner}];return e.objectIDs.forEach(r=>{let i=this._permissionMap.get(r),a=(i==null?void 0:i.strategies)||n,o={objectID:r,unitID:e.unitID,objectType:(i==null?void 0:i.objectType)||3,name:(i==null?void 0:i.name)||``,shareOn:!1,shareRole:L.Owner,shareScope:-1,scope:{read:pa.AllCollaborator,edit:pa.AllCollaborator},creator:rg(L.Owner),strategies:a.map(e=>({action:e.action,role:e.role})),actions:e.actions.map(e=>{let t=`${r}:${e}`;if(this._permissionOverrides.has(t))return{action:e,allowed:this._permissionOverrides.get(t)};let n=a.find(t=>t.action===e);return n?{action:e,allowed:this._getRole(n.role)}:{action:e,allowed:this._getRole(L.Owner)||this._getRole(L.Editor)}})};t.push(o)}),t}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(e){let{objectID:t,strategies:n}=e,r=this._permissionMap.get(t);r&&n&&(r.strategies=n.map(e=>({action:e.action,role:e.role})),this._permissionMap.set(t,r),n.forEach(e=>{e.role===L.Reader?this.setPermissionOverride(t,e.action,!1):(e.role===L.Owner||e.role===L.Editor)&&this.clearPermissionOverride(t,e.action)}))}setPermissionOverride(e,t,n){let r=`${e}:${t}`;this._permissionOverrides.set(r,n)}clearPermissionOverride(e,t){let n=`${e}:${t}`;this._permissionOverrides.delete(n)}clearAllOverrides(e){let t=[];this._permissionOverrides.forEach((n,r)=>{r.startsWith(`${e}:`)&&t.push(r)}),t.forEach(e=>this._permissionOverrides.delete(e))}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(e){}};og=Us([W(0,tg),W(1,(0,t.Inject)(ag))],og);let sg=(0,t.createIdentifier)(`IAuthzIoIoService`),cg=(0,t.createIdentifier)(`univer.confirm-service`);var lg=class{constructor(){P(this,`confirmOptions$`,new n.Subject)}dispose(){this.confirmOptions$.complete()}open(e){throw Error(`This is not implemented in the test service!`)}confirm(e){return Promise.resolve(!0)}close(e){throw Error(`This is not implemented in the test service!`)}};let ug=`FOCUSING_UNIT`,dg=`FOCUSING_SHEET`,fg=`FOCUSING_DOC`,pg=`FOCUSING_SLIDE`,mg=`EDITOR_ACTIVATED`,hg=`FOCUSING_FX_BAR_EDITOR`;var gg=class extends ra{constructor(...e){super(...e),P(this,`_error$`,new n.Subject),P(this,`error$`,this._error$.asObservable())}dispose(){this._error$.complete()}emit(e){this._error$.next({errorKey:e})}};let _g=function(e){return e.URL=`URL`,e.UUID=`UUID`,e.BASE64=`BASE64`,e}({}),vg=function(e){return e.SUCCUSS=`0`,e.ERROR_EXCEED_SIZE=`1`,e.ERROR_IMAGE_TYPE=`2`,e.ERROR_UPLOAD_COUNT_LIMIT=`3`,e.ERROR_IMAGE=`4`,e}({}),yg=(0,t.createIdentifier)(`core.image-io.service`),bg=(0,t.createIdentifier)(`core.url-image.service`);var xg=`@univerjs/core`,Sg=`0.20.0`;function Cg(e=``,t=uo.ZH_CN,n=``){return{id:e,sheetOrder:[],name:n,appVersion:Sg,locale:t,styles:{},sheets:{},resources:[]}}var wg=class{constructor(e={}){P(this,`_styles`,void 0),P(this,`_cacheMap`,new Mf(1e5)),this._styles=e,this._generateCacheMap()}each(e){return Object.entries(this._styles).forEach(e),this}search(e,t){return this._cacheMap.has(t)?this._cacheMap.get(t):this._getExistingStyleId(e)||`-1`}get(e){return typeof e==`string`?(e=String(e),this._styles[e]):e}add(e,t){let n=Ya(6);return this._styles[n]=e,this._cacheMap.set(t,n),n}setValue(e){if(e==null)return;let t=JSON.stringify(e),n=this.search(e,t);return n===`-1`?this.add(e,t):n}addCustomStyle(e,t){t!=null&&(this._styles[e]=t,this._cacheMap.set(JSON.stringify(t),e))}remove(e){let t=this._styles[e];t&&(delete this._styles[e],this._cacheMap.delete(JSON.stringify(t)))}toJSON(){return this._styles}getStyleByCell(e){let t;t=e&&R.isObject(e.s)?e.s:(e==null?void 0:e.s)&&this.get(e.s);let n=e==null?void 0:e.interceptorStyle;return n?{...t,...n}:t}_generateCacheMap(){let{_styles:e,_cacheMap:t}=this;for(let n in e){let r=JSON.stringify(e[n]);t.set(r,n)}}_getExistingStyleId(e){let{_styles:t}=this;for(let n in t)if(R.diffValue(t[n],e))return n;return null}};let Tg=(e,t)=>t.length===e.length&&!e.some(e=>t.some(t=>!Tp.equals(t,e))),Eg=(e,t)=>t.length===e.length&&e.every((e,n)=>{let r=t[n];return r.unitId===e.unitId&&r.sheetId===e.sheetId&&Tp.equals(e.range,r.range)}),Dg={t:0,b:2,l:2,r:2},Og=e=>({sbr:.6,sbo:e,spr:.6,spo:e});function kg(e,t,n={}){let r=e.length,{textRotation:i,paddingData:a,horizontalAlign:o=So.UNSPECIFIED,verticalAlign:s=Co.UNSPECIFIED,wrapStrategy:c=wo.UNSPECIFIED,cellValueType:l}=n,{t:u,r:d,b:f,l:p}=a||Dg,{vertexAngle:m,centerAngle:h}=Lg(i);return new ch({id:`d`,body:{dataStream:`${e}\r
|
|
8
|
+
`,textRuns:[{ts:t,st:0,ed:r}],paragraphs:[{startIndex:r,paragraphStyle:{horizontalAlign:o}}],sectionBreaks:[{startIndex:r+1}]},documentStyle:{pageSize:{width:1/0,height:1/0},marginTop:u,marginBottom:f,marginRight:d,marginLeft:p,renderConfig:{horizontalAlign:o,verticalAlign:s,centerAngle:h,vertexAngle:m,wrapStrategy:c,cellValueType:l}},drawings:{},drawingsOrder:[]})}function Ag(e){if(!e)return{};let{tr:t,td:n,ht:r,vt:i,tb:a,pd:o}=e;return{textRotation:t,textDirection:n,horizontalAlign:r,verticalAlign:i,wrapStrategy:a,paddingData:o}}function jg(e){if(!e)return{};let{ff:t,fs:n,it:r,bl:i,ul:a,st:o,ol:s,cl:c}=e,l={};return t&&(l.ff=t),n&&(l.fs=n),r&&(l.it=r),i&&(l.bl=i),a&&(l.ul=a),o&&(l.st=o),s&&(l.ol=s),c&&(l.cl=c),l}function Mg(e,t,n){var r;let i=e.getBody();if((r=i.customRanges)!=null&&r.some(e=>e.rangeType===Po.HYPERLINK))return;let a=Vh.customRange.add({ranges:[{startOffset:0,endOffset:i.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:Po.HYPERLINK,body:i,properties:{url:t,refId:n}});a&&Q.apply(i,a.serialize())}function Ng(e){return e!=null}function Pg(){return{p:null,s:null,v:null,t:null,f:null,si:null,ref:null,xf:null}}function Fg(e){let t=Vf.ff,n=Vf.fs;if(!e){let e=`${n}pt ${t}`;return{fontCache:e,fontString:e,fontSize:n,originFontSize:n,fontFamily:t}}let r=ts.ITALIC;(e.it===0||e.it===void 0)&&(r=ts.NORMAL);let i=ts.BOLD;(e.bl===0||e.bl===void 0)&&(i=ts.NORMAL);let a=n;e.fs&&(a=Math.ceil(e.fs));let o=t;if(e.ff){let n=e.ff;n=n.replace(/"/g,``).replace(/'/g,``),n.indexOf(` `)>-1&&(n=`"${n}"`),n==null&&(n=t),o=n}let{va:s}=e,c=a;if(s===Do.SUBSCRIPT||s===Do.SUPERSCRIPT){let{sbr:e,spr:t}=Ig(o,c);c*=s===Do.SUBSCRIPT?e:t}let l=`${r} ${i} ${c}pt ${o}`;return{fontCache:l,fontString:`${l}, "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif `,fontSize:c,originFontSize:a,fontFamily:o}}function Ig(e,t){return Og(t)}function Lg(e){let{a:t=0,v:n=B.FALSE}=e||{a:0,v:B.FALSE},r=0,i=t;return n===B.TRUE&&(r=90,i=90),{centerAngle:r,vertexAngle:i}}function Rg(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e)){let t=e.length,n=Array(t);for(let r=0;r<t;r++)n[r]=Rg(e[r]);return n}let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r];t[i]=Rg(e[i])}return t}function zg(e){if(e==null)return e;let t={};return e.p!==void 0&&(t.p=e.p===null?null:Rg(e.p)),e.s!==void 0&&(e.s===null||typeof e.s==`string`?t.s=e.s:t.s=Rg(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:Rg(e.custom)),t}function Bg(e){if(e==null)return e;let t={};return e.p!==void 0&&(t.p=e.p===null?null:Rg(e.p)),e.s!==void 0&&(e.s===null||typeof e.s==`string`?t.s=e.s:t.s=Rg(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:Rg(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 Vg(e){let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r],a=Number(i),o=e[a];if(o===void 0)continue;let s={},c=Object.keys(o);for(let e=0,t=c.length;e<t;e++){let t=c[e],n=Number(t),r=o[n];r!=null&&(s[n]=zg(r))}t[a]=s}return t}function Hg(e){let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r],a=Number(i),o=e[a];if(o===void 0)continue;let s={};`h`in o&&o.h!==void 0&&(s.h=o.h),`ia`in o&&o.ia!==void 0&&(s.ia=o.ia),`ah`in o&&o.ah!==void 0&&(s.ah=o.ah),`hd`in o&&o.hd!==void 0&&(s.hd=o.hd),`w`in o&&o.w!==void 0&&(s.w=o.w),`s`in o&&o.s!==void 0&&(o.s===null||typeof o.s==`string`?s.s=o.s:s.s=Rg(o.s)),`custom`in o&&o.custom!==void 0&&(s.custom=o.custom===null?null:Rg(o.custom)),t[a]=s}return t}function Ug(e){let t=e.length,n=Array(t);for(let r=0;r<t;r++){let t=e[r];n[r]={startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn,rangeType:t.rangeType,startAbsoluteRefType:t.startAbsoluteRefType,endAbsoluteRefType:t.endAbsoluteRefType}}return n}function Wg(e){let 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:Ug(e.mergeData),cellData:Vg(e.cellData),rowData:Hg(e.rowData),columnData:Hg(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=Rg(e.defaultStyle)),e.custom!==void 0&&(t.custom=e.custom===null?null:Rg(e.custom)),t}var Gg=class{constructor(e,t){this._config=e,P(this,`_columnData`,{}),this._columnData=t}getColumnData(){return this._columnData}getColVisible(e){let{_columnData:t}=this,n=t[e];return n?n.hd!==B.TRUE:!0}getColumnStyle(e){var t;return(t=this._columnData[e])==null?void 0:t.s}setColumnStyle(e,t){let n=this.getColumnOrCreate(e);n.s=t}getHiddenCols(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getColVisible(a);r&&e?(r=!1,n.push({rangeType:G.COLUMN,startColumn:i,endColumn:a-1,startRow:0,endRow:0})):!r&&!e&&(r=!0,i=a)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:t,rangeType:G.COLUMN}),n}getVisibleCols(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getColVisible(a);r&&!e?(r=!1,n.push({rangeType:G.COLUMN,startColumn:i,endColumn:a-1,startRow:0,endRow:0})):!r&&e&&(r=!0,i=a)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:t,rangeType:G.COLUMN}),n}getColumnDatas(e,t){let n={},r=0;for(let i=e;i<e+t;i++){let e=this.getColumn(i);n[r]=e==null?{w:this._config.defaultColumnWidth,hd:B.FALSE}:e,r++}return n}getSize(){return vd(this._columnData)}getColumnWidth(e){var t,n;return(t=(n=this._columnData[e])==null?void 0:n.w)==null?this._config.defaultColumnWidth:t}setColumnWidth(e,t){let n=this._columnData[e];t===this._config.defaultColumnWidth?n&&(delete n.w,Object.keys(n).length===0&&delete this._columnData[e]):this._columnData[e]=n?{...n,w:t}:{w:t}}getColumn(e){return this._columnData[e]}insertColumnsWithData(e,t,n){let r=t-e+1,i=Object.keys(this._columnData);for(let t=i.length-1;t>=0;t--){let n=Number(i[t]);n>=e&&(this._columnData[n+r]=this._columnData[n],delete this._columnData[n])}for(let r=e;r<=t;r++){let t=n==null?void 0:n[r-e];t!=null&&Object.keys(t).length>0&&(this._columnData[r]={...t})}}removeColumn(e){delete this._columnData[e]}getColumnOrCreate(e){let{_columnData:t}=this,n=t[e];if(n)return n;let r={};return this._columnData[e]=r,r}setCustomMetadata(e,t){let n=this.getColumn(e);n&&(n.custom=t)}getCustomMetadata(e){var t;return(t=this.getColumn(e))==null?void 0:t.custom}},Kg=class{constructor(e,t,n){this._config=e,this._viewModel=t,P(this,`_rowData`,void 0),this._rowData=n}getRowData(){return this._rowData}getRowStyle(e){var t;return(t=this._rowData[e])==null?void 0:t.s}setRowStyle(e,t){let n=this.getRowOrCreate(e);n.s=t}getRowDatas(e,t){let n={},r=0;for(let i=e;i<e+t;i++){let e=this.getRow(i);n[r]=e==null?{h:this._config.defaultRowHeight,hd:B.FALSE}:e,r++}return n}getRowHeight(e,t=1){let{_rowData:n}=this,r=this._config,i=0;for(let a=0;a<t;a++){let{ia:t,ah:o,h:s=r.defaultRowHeight}=n[a+e]||{hd:B.FALSE,h:r.defaultRowHeight};i+=(t==null||t===B.TRUE)&&typeof o==`number`?o:s}return i}setRowHeight(e,t){let n=this._rowData[e];if(t===this._config.defaultRowHeight)n&&(delete n.h,Object.keys(n).length===0&&delete this._rowData[e]);else{let r=Math.min(t,2e3);this._rowData[e]=n?{...n,h:r}:{h:r}}}getRow(e){return this._rowData[e]}insertRowsWithData(e,t,n){let r=t-e+1,i=Object.keys(this._rowData);for(let t=i.length-1;t>=0;t--){let n=Number(i[t]);n>=e&&(this._rowData[n+r]=this._rowData[n],delete this._rowData[n])}for(let r=e;r<=t;r++){let t=n==null?void 0:n[r-e];t!=null&&Object.keys(t).length>0&&(this._rowData[r]={...t})}}removeRow(e){delete this._rowData[e]}getRowOrCreate(e){let{_rowData:t}=this,n=t[e];if(n)return n;let r={};return t[e]=r,r}getHiddenRows(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getRowRawVisible(a);r&&e?(r=!1,n.push({startRow:i,endRow:a-1,startColumn:0,endColumn:0,rangeType:G.ROW})):!r&&!e&&(r=!0,i=a)}return r&&n.push({startRow:i,endRow:t,startColumn:0,endColumn:0,rangeType:G.ROW}),n}getVisibleRows(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getRowRawVisible(a);r&&!e?(r=!1,n.push({startRow:i,endRow:a-1,startColumn:0,endColumn:0,rangeType:G.ROW})):!r&&e&&(r=!0,i=a)}return r&&n.push({startRow:i,endRow:t,startColumn:0,endColumn:0,rangeType:G.ROW}),n}getRowRawVisible(e){let t=this.getRow(e);return t?t.hd!==B.TRUE:!0}getSize(){return vd(this._rowData)}setCustomMetadata(e,t){let n=this.getRow(e);n&&(n.custom=t)}getCustomMetadata(e){var t;return(t=this.getRow(e))==null?void 0:t.custom}};let qg=1e3;function Jg(e){let t={name:`Sheet1`,id:`sheet-01`,tabColor:``,hidden:B.FALSE,rowCount:qg,columnCount:20,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:88,defaultRowHeight:24,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:B.TRUE,rowHeader:{width:46,hidden:B.FALSE},columnHeader:{height:20,hidden:B.FALSE},rightToLeft:B.FALSE};return Object.keys(t).forEach(n=>{let r=n;e[r]===void 0&&(e[r]=t[r])}),e}var Yg=class extends ra{constructor(e){super(),P(this,`_cellCache`,new Map),P(this,`_rowCache`,new Map),P(this,`_columnCache`,new Map),P(this,`_hasRow`,!1),P(this,`_hasColumn`,!1),P(this,`_hasAll`,!1),P(this,`_allIndex`,-1),P(this,`_mergeData`,void 0),P(this,`_rangeMap`,new Mf(5e4)),this._init(e.concat())}_init(e){this._mergeData=e,this._createCache(e)}_clearCache(){this._cellCache.clear(),this._rowCache.clear(),this._columnCache.clear(),this._hasAll=!1,this._allIndex=-1,this._rangeMap.clear(),this._hasColumn=!1,this._hasRow=!1}_createCache(e){let t=0;for(let n of e){let{rangeType:e}=n;e===G.ROW?this._createRowCache(n,t):e===G.COLUMN?this._createColumnCache(n,t):e===G.ALL?this._createCellAllCache(t):this._createCellCache(n,t),t++}}rebuild(e){this._clearCache(),this._init(e.concat())}_createRowCache(e,t){let{startRow:n,endRow:r}=e;for(let e=n;e<=r;e++)this._rowCache.set(e,t),this._hasRow=!0}_createColumnCache(e,t){let{startColumn:n,endColumn:r}=e;for(let e=n;e<=r;e++)this._columnCache.set(e,t),this._hasColumn=!0}_createCellAllCache(e){this._hasAll=!0,this._allIndex=e}_createCellCache(e,t){for(let n=e.startRow;n<=e.endRow;n++){let r=this._cellCache.get(n);r==null&&(r=new Map,this._cellCache.set(n,r));for(let n=e.startColumn;n<=e.endColumn;n++)r.set(n,t)}}add(e){this._mergeData.push(e),this._clearCache(),this._createCache(this._mergeData)}remove(e,t){let n=this._getMergeDataIndex(e,t);n!==-1&&(this._mergeData.splice(n,1),this._clearCache(),this._createCache(this._mergeData))}getMergedCell(e,t){let n=this._getMergeDataIndex(e,t);return n===-1?null:this._mergeData[n]}getMergeDataIndex(e,t){return this._getMergeDataIndex(e,t)}isRowContainsMergedCell(e){return this._hasAll||!R.isEmptyObject(this._columnCache)?!0:this._mergeData.some(t=>t.startRow<=e&&e<=t.endRow)}isColumnContainsMergedCell(e){return this._hasAll||!R.isEmptyObject(this._rowCache)?!0:this._mergeData.some(t=>t.startColumn<=e&&e<=t.endColumn)}getMergedCellRange(e,t,n,r){let i=[],a=`${e}-${t}-${n}-${r}`;if(this._rangeMap.has(a))return this._getRangeFromCache(a);let o=0,s=[];for(let a of this._mergeData||[])Tp.intersects(a,{startRow:e,endRow:n,startColumn:t,endColumn:r})&&(i.push({...a}),s.push(o)),o++;return this._rangeMap.set(a,s),i}_getRangeFromCache(e){let t=this._rangeMap.get(e)||[],n=[];for(let e of t)n.push({...this._mergeData[e]});return n}_getMergeDataIndex(e,t){var n;if(this._hasAll)return this._allIndex;if(this._hasRow){let t=this._rowCache.get(e);if(t!==void 0)return t}if(this._hasColumn){let e=this._columnCache.get(t);if(e!==void 0)return e}let r=(n=this._cellCache.get(e))==null?void 0:n.get(t);return r===void 0?-1:r}getMergeDataSnapshot(){return this._mergeData}dispose(){this._clearCache(),this._mergeData=[]}},Xg=class extends ra{constructor(e){super(),this.getRawCell=e,P(this,`_cellContentInterceptor`,null),P(this,`_rowFilteredInterceptor`,null)}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(e,t,n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,he.Value|he.Style,n,r):this.getRawCell(e,t)}getCellValueOnly(e,t){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,he.Value):this.getRawCell(e,t)}getCellStyleOnly(e,t){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,he.Style):this.getRawCell(e,t)}getRowFiltered(e){var t,n;return(t=(n=this._rowFilteredInterceptor)==null?void 0:n.getRowFiltered(e))==null?!1:t}registerCellContentInterceptor(e){if(this._cellContentInterceptor)throw Error(`[SheetViewModel]: Interceptor already registered.`);return this._cellContentInterceptor=e,ta(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(e){if(this._rowFilteredInterceptor)throw Error(`[SheetViewModel]: Interceptor already registered.`);return this._rowFilteredInterceptor=e,ta(()=>this._rowFilteredInterceptor=null)}};let Zg={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};var Qg=class e{constructor(e,t,n){var r;this.unitId=e,this._styles=n,P(this,`_sheetId`,void 0),P(this,`_snapshot`,void 0),P(this,`_cellData`,void 0),P(this,`_rowManager`,void 0),P(this,`_columnManager`,void 0),P(this,`_viewModel`,void 0),P(this,`_spanModel`,void 0),P(this,`_isRowStylePrecedeColumnStyle`,!0),P(this,`_getCellHeight`,void 0),this._snapshot=Jg(t);let{columnData:i,rowData:a,cellData:o}=this._snapshot;this._sheetId=(r=this._snapshot.id)==null?Ya(6):r,this._cellData=new Dd(o),this._viewModel=new Xg((e,t)=>this.getCellRaw(e,t)),this._rowManager=new Kg(this._snapshot,this._viewModel,a),this._columnManager=new Gg(this._snapshot,i),this._spanModel=new Yg(this._snapshot.mergeData)}__interceptViewModel(e){e(this._viewModel)}__registerGetCellHeight(e){return this._getCellHeight=e,ta(()=>{this._getCellHeight=null})}getSnapshot(){return this._snapshot}getCellHeight(e,t){return this._getCellHeight?this._getCellHeight(e,t):this._snapshot.defaultRowHeight}setMergeData(e){this._snapshot.mergeData=e,this.getSpanModel().rebuild(e)}getSpanModel(){return this._spanModel}setIsRowStylePrecedeColumnStyle(e){this._isRowStylePrecedeColumnStyle=e}getStyleDataByHash(e){return{...this._styles.get(e)}}setStyleData(e){return this._styles.setValue(e)}getColumnStyle(e,t=!1){return t?this._columnManager.getColumnStyle(e):this._styles.get(this._columnManager.getColumnStyle(e))}setColumnStyle(e,t){this._columnManager.setColumnStyle(e,t)}getRowStyle(e,t=!1){return t?this._rowManager.getRowStyle(e):this._styles.get(this._rowManager.getRowStyle(e))}setRowStyle(e,t){this._rowManager.setRowStyle(e,t)}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){let e=this._snapshot.defaultStyle;return this._styles.get(e)}setDefaultCellStyle(e){this._snapshot.defaultStyle=e}getCellStyle(e,t){let n=this.getCell(e,t);if(n){let e=n.s;return typeof e==`string`?this._styles.get(e):e}return null}getComposedCellStyle(e,t,n){let r=this.getDefaultCellStyleInternal(),i=this.getRowStyle(e),a=this.getColumnStyle(t),o=this.getCell(e,t),s=this._styles.getStyleByCell(o);return(n==null?this._isRowStylePrecedeColumnStyle:n)?Xa(r,a,i,o==null?void 0:o.themeStyle,s):Xa(r,i,a,o==null?void 0:o.themeStyle,s)}getComposedCellStyleByCellData(e,t,n,r){let i=this.getDefaultCellStyleInternal(),a=this.getRowStyle(e),o=this.getColumnStyle(t),s=this._styles.getStyleByCell(n);return(r==null?this._isRowStylePrecedeColumnStyle:r)?Xa(i,o,a,n==null?void 0:n.themeStyle,s):Xa(i,a,o,n==null?void 0:n.themeStyle,s)}getComposedCellStyleWithoutSelf(e,t,n,r){let i=n===void 0?this.getComposedCellStyle(e,t,r):this.getComposedCellStyleByCellData(e,t,n,r),a=this.getCellRaw(e,t);if(!a||!a.s)return i;let o=typeof a.s==`string`?this._styles.get(a.s):a.s;if(!o)return i;for(let e in o)e in i&&delete i[e];return i}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){let e=this.getCellMatrix(),t=this.getMergeData(),n=-1,r=-1,i=-1,a=-1,o=!1,s=!1;return e.forEach((t,c)=>{Object.keys(c).forEach(c=>{let l=+c,u=e.getValue(t,l),d=u!=null&&u.s?this._styles.get(u.s):null,f=(d==null?void 0:d.bd)&&(d.bd.b||d.bd.l||d.bd.r||d.bd.t||d.bd.bc_tr||d.bd.bl_tr||d.bd.ml_tr||d.bd.tl_bc||d.bd.tl_br||d.bd.tl_mr);(u&&(u.v!==null&&u.v!==void 0&&u.v!==``||u.p)||d!=null&&d.bg||f)&&(o?n=Math.min(n,t):(n=t,o=!0),r=Math.max(r,t),s?i=Math.min(i,l):(s=!0,i=l),a=Math.max(a,l))})}),t.forEach(e=>{o?n=Math.min(n,e.startRow):(n=e.startRow,o=!0),r=Math.max(r,e.endRow),s?i=Math.min(i,e.startColumn):(i=e.startColumn,o=!0),a=Math.max(a,e.endColumn)}),!o||!s?null:{startColumn:i,startRow:n,endColumn:a,endRow:r}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){let{_snapshot:t}=this,n=Wg(t);return new e(this.unitId,n,this._styles)}getMergeData(){return this._spanModel.getMergeDataSnapshot()}getMergedCell(e,t){return this._spanModel.getMergedCell(e,t)}getMergedCellRange(e,t,n,r){return this._spanModel.getMergedCellRange(e,t,n,r)}isRowContainsMergedCell(e){return this._spanModel.isRowContainsMergedCell(e)}isColumnContainsMergedCell(e){return this._spanModel.isColumnContainsMergedCell(e)}getCellInfoInMergeData(e,t){let n=this.getMergedCell(e,t),r=!1,i=!1,a=e,o=t,s=e,c=t;if(n){let{startRow:l,endRow:u,startColumn:d,endColumn:f}=n;e===l&&t===d?(a=u,o=f,s=l,c=d,i=!0):e>=l&&e<=u&&t>=d&&t<=f&&(a=u,o=f,s=l,c=d,r=!0)}return{actualRow:e,actualColumn:t,isMergedMainCell:i,isMerged:r,endRow:a,endColumn:o,startRow:s,startColumn:c}}getCell(e,t){return e<0||t<0?null:this._viewModel.getCell(e,t)}getCellValueOnly(e,t){return e<0||t<0?null:this._viewModel.getCellValueOnly(e,t)}getCellStyleOnly(e,t){return e<0||t<0?null:this._viewModel.getCellStyleOnly(e,t)}getCellRaw(e,t){return this.getCellMatrix().getValue(e,t)}getCellWithFilteredInterceptors(e,t,n,r){return this._viewModel.getCell(e,t,n,r)}getRowFiltered(e){return this._viewModel.getRowFiltered(e)}getRangeFilterRows(e){let t=[];for(let n=e.startRow;n<=e.endRow;n++)this.getRowFiltered(n)&&t.push(n);return t}getMatrixWithMergedCells(e,t,n,r,i=Rc.Raw){let a=this.getCellMatrix(),o=this._spanModel.getMergedCellRange(e,t,n,r),s=new Dd;return jp(e,n,t,r).forEach((e,t)=>{let n;if(i===Rc.Raw)n=this.getCellRaw(e,t);else if(i===Rc.Intercepted)n=this.getCell(e,t);else if(i===Rc.Both){let i=this.getCellRaw(e,t);if(i){var r;n={...i};let a=(r=this.getCell(e,t))==null?void 0:r.v;Ng(a)&&n&&(n.displayV=String(a))}}n&&s.setValue(e,t,n)}),o.forEach(e=>{let{startColumn:t,startRow:n,endColumn:r,endRow:i}=e;jp(n,i,t,r).forEach((e,o)=>{e===n&&o===t&&s.setValue(e,o,{...a.getValue(e,o),rowSpan:i-n+1,colSpan:r-t+1}),(e!==n||o!==t)&&s.realDeleteValue(e,o)})}),s}getRange(e,t,n,r){return typeof e==`object`?new Yf(this,e,{getStyles:()=>this._styles}):new Yf(this,{startRow:e,startColumn:t,endColumn:r||t,endRow:n||e},{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(){let{_snapshot:e}=this,{columnCount:t}=e;return t}getMaxRows(){let{_snapshot:e}=this,{rowCount:t}=e;return t}getRowCount(){return this._snapshot.rowCount}setRowCount(e){this._snapshot.rowCount=e}getColumnCount(){return this._snapshot.columnCount}setColumnCount(e){this._snapshot.columnCount=e}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){let{_snapshot:e}=this,{showGridlines:t}=e;return t===0}getGridlinesColor(){return this.getConfig().gridlinesColor}getTabColor(){let{_snapshot:e}=this,{tabColor:t}=e;return t}getColumnWidth(e){return this.getColumnManager().getColumnWidth(e)}getRowHeight(e){return this._viewModel.getRowFiltered(e)?0:this.getRowManager().getRowHeight(e)}isRowFiltered(e){return this._viewModel.getRowFiltered(e)}getRowVisible(e){return!this.isRowFiltered(e)&&this.getRowRawVisible(e)}getRowRawVisible(e){return this.getRowManager().getRowRawVisible(e)}getHiddenRows(e,t){let n=this.getMaxColumns()-1,r=this._rowManager.getHiddenRows(e,t);return r.forEach(e=>e.endColumn=n),r}getColVisible(e){return this._columnManager.getColVisible(e)}getHiddenCols(e,t){let n=this.getMaxRows()-1,r=this._columnManager.getHiddenCols(e,t);return r.forEach(e=>e.endRow=n),r}getVisibleRows(){let e=this.getRowCount();return this._rowManager.getVisibleRows(0,e-1)}getVisibleCols(){let e=this.getColumnCount();return this._columnManager.getVisibleCols(0,e-1)}isRightToLeft(){let{_snapshot:e}=this,{rightToLeft:t}=e;return t}getLastRowWithContent(){return this._cellData.getRealRowRange().endRow}getLastColumnWithContent(){return this.getDataRealRange().endColumn}getDataRealRange(){return this._cellData.getRealRange()}getDataRangeScope(){return this._cellData.getStartEndScope()}cellHasValue(e){return e&&(e.v!==void 0||e.f!==void 0||e.p!==void 0)}iterateByRow(e,t=!0){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e,o=this;return{[Symbol.iterator]:()=>{let e=n,s=r;return{next(){for(;;){if(s>a&&(e+=1,s=r),e>i)return{done:!0,value:void 0};let n=o.getCell(e,s),c=!n,l=o.getMergedCell(e,s);if(l){if(e!==l.startRow||s!==l.startColumn){s=l.endColumn+1;continue}if(c&&t){s=l.endColumn+1;continue}let r={row:e,col:s,value:n};return r.colSpan=l.endColumn-l.startColumn+1,r.rowSpan=l.endRow-l.startRow+1,s=l.endColumn+1,{done:!1,value:r}}if(c&&t)s+=1;else{let t={row:e,col:s,value:n};return s+=1,{done:!1,value:t}}}}}}}}iterateByColumn(e,t=!0,n=!0){let{startRow:r,startColumn:i,endRow:a,endColumn:o}=e,s=this;return{[Symbol.iterator]:()=>{let e=r,c=i;return{next(){for(;;){if(e>a&&(c+=1,e=r),c>o)return{done:!0,value:void 0};let i=s.getMergedCell(e,c);if(i){let r=e!==i.startRow,a=r||c!==i.startColumn;if(n&&a||!n&&r){e=i.endRow+1;continue}let o=s.getCell(i.startRow,i.startColumn);if(!o&&t){e=i.endRow+1;continue}let l={row:e,col:i.startColumn,value:o};return l.colSpan=i.endColumn-i.startColumn+1,l.rowSpan=i.endRow-i.startRow+1,e=i.endRow+1,{done:!1,value:l}}let l=s.getCell(e,c);if(!l&&t)e+=1;else{let t={row:e,col:c,value:l};return e+=1,{done:!1,value:t}}}}}}}}getCellDocumentModel(e,t,n=Zg){var r;if(!e)return;let{isDeepClone:i,displayRawFormula:a,ignoreTextRotation:o}={...Zg,...n},s,c=`document`,l=Ag(t),u=o?Vf.tr:l.textRotation||Vf.tr,d=l.horizontalAlign||Vf.ht,f=l.verticalAlign||Vf.vt,p=l.wrapStrategy||Vf.tb,m=l.paddingData||Dg;if(e.f&&a)s=kg(e.f.toString(),{},{verticalAlign:f}),d=Vf.ht;else if(e.p){let{centerAngle:t,vertexAngle:n}=Lg(u);s=this._updateConfigAndGetDocumentModel(i?R.deepClone(e.p):e.p,d,m,{horizontalAlign:d,verticalAlign:f,centerAngle:t,vertexAngle:n,wrapStrategy:p,zeroWidthParagraphBreak:1})}else if(e.v!=null){let n=jg(t);c=Fg(n).fontCache;let r=$g(e);e.t===Oo.FORCE_STRING&&a&&(r=`'${r}`),s=kg(r,n,{...l,textRotation:u,cellValueType:e.t})}return s&&e.linkUrl&&e.linkId&&Mg(s,e.linkUrl,e.linkId),{documentModel:s,fontString:c,textRotation:u,wrapStrategy:p,verticalAlign:f,horizontalAlign:d,paddingData:m,fill:t==null||(r=t.bg)==null?void 0:r.rgb}}_updateConfigAndGetDocumentModel(e,t,n,r){var i,a,o,s,c;if(!r||!((i=e.body)!=null&&i.dataStream))return;e.documentStyle||(e.documentStyle={}),e.documentStyle.marginTop=(a=n.t)==null?0:a,e.documentStyle.marginBottom=(o=n.b)==null?2:o,e.documentStyle.marginLeft=(s=n.l)==null?2:s,e.documentStyle.marginRight=(c=n.r)==null?2:c,e.documentStyle.pageSize={width:1/0,height:1/0},e.documentStyle.renderConfig={...e.documentStyle.renderConfig,...r};let l=e.body.paragraphs||[];for(let e of l)e.paragraphStyle||(e.paragraphStyle={}),e.paragraphStyle.horizontalAlign=t;return new ch(e)}getBlankCellDocumentModel(e,t,n){let r=this.getComposedCellStyleByCellData(t,n,e),i=jg(r),a=this.getCellDocumentModel(e,r,{ignoreTextRotation:!0});if(a!=null)return a.documentModel==null&&(a.documentModel=kg(``,i)),a;let o=`document`,s=Vf.tr,c=Vf.ht,l=Vf.vt,u=Vf.tb,d=Dg;return o=Fg({}).fontCache,{documentModel:kg(``,i),fontString:o,textRotation:s,wrapStrategy:u,verticalAlign:l,horizontalAlign:c,paddingData:d}}getCellDocumentModelWithFormula(e,t,n){let r=this.getComposedCellStyleByCellData(t,n,e);return this.getCellDocumentModel(e,r,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(e){this._snapshot.custom=e}};function $g(e){var t;if(!e)return``;let n=(t=e.p)==null||(t=t.body)==null?void 0:t.dataStream;if(n)return Vh.transform.getPlainText(n);let r=e.v;return typeof r==`string`?e.t===Oo.BOOLEAN?r.toUpperCase():r.replace(/[\r\n]/g,``):typeof r==`number`?e.t===Oo.BOOLEAN?r?`TRUE`:`FALSE`:r.toString():typeof r==`boolean`?r?`TRUE`:`FALSE`:``}function e_(e){if(e===null)return``;if(e!=null&&e.p){let t=e==null?void 0:e.p.body;if(t==null)return``;let n=t.dataStream;return Vh.transform.getPlainText(n)}return e==null?void 0:e.v}function t_(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}let n_=class extends Pa{get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}static isIRangeType(e){return typeof e==`string`||`startRow`in e||`row`in e}constructor(e={},t){super(),this._logService=t,P(this,`type`,I.UNIVER_SHEET),P(this,`_sheetCreated$`,new n.Subject),P(this,`sheetCreated$`,this._sheetCreated$.asObservable()),P(this,`_sheetDisposed$`,new n.Subject),P(this,`sheetDisposed$`,this._sheetDisposed$.asObservable()),P(this,`_activeSheet$`,new n.BehaviorSubject(null)),P(this,`activeSheet$`,this._activeSheet$.asObservable()),P(this,`_worksheets`,void 0),P(this,`_styles`,void 0),P(this,`_snapshot`,void 0),P(this,`_unitId`,void 0),P(this,`_count`,void 0),P(this,`_name$`,void 0),P(this,`name$`,void 0);let r=Cg();R.isEmptyObject(e)?this._snapshot=r:this._snapshot=R.commonExtend(r,e);let{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=Ya(6)),this._unitId=this._snapshot.id,this._styles=new wg(i),this._count=1,this._worksheets=new Map,this._name$=new n.BehaviorSubject(e.name||``),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete(),Array.from(this._worksheets.keys()).forEach(e=>{this._removeSheet(e)})}save(){return R.deepClone(this._snapshot)}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(e){this._name$.next(e),this._snapshot.name=e}getUnitId(){return this._unitId}getRev(){var e;return(e=this._snapshot.rev)==null?1:e}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(e){this._snapshot.rev=e}addWorksheet(e,t,n){let{sheets:r,sheetOrder:i}=this._snapshot;if(r[e])return!1;r[e]=n,i.splice(t,0,e),this.ensureSheetOrderUnique();let a=new Qg(this._unitId,n,this._styles);return this._worksheets.set(e,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}ensureSheetOrderUnique(){let e=new Set,t=[];for(let n of this._snapshot.sheetOrder)e.has(n)||(e.add(n),t.push(n));this._snapshot.sheetOrder=t,e.clear()}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}addStyles(e){Object.entries(e).forEach(([e,t])=>{this._styles.addCustomStyle(e,t)})}removeStyles(e){e.forEach(e=>{this._styles.remove(e)})}getConfig(){return this._snapshot}getIndexBySheetId(e){let{sheetOrder:t}=this._snapshot;return t.findIndex(t=>t===e)}getActiveSheet(e){if(!this._activeSheet&&e===void 0)throw Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){let e=this._activeSheet;if(e)return e;let t=this._snapshot.sheetOrder;for(let e=0,n=t.length;e<n;e++){let n=this._worksheets.get(t[e]);if(n&&n.isSheetHidden()!==B.TRUE)return this.setActiveSheet(n),n}let n=this._worksheets.get(t[0]);return this.setActiveSheet(n),n}setActiveSheet(e){this._activeSheet$.next(e)}_removeSheet(e){let t=this._worksheets.get(e);return t?(this._worksheets.delete(e),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(e),1),this.ensureSheetOrderUnique(),this._sheetDisposed$.next(t),!0):!1}removeSheet(e){let t=this._removeSheet(e);return t&&delete this._snapshot.sheets[e],t}getActiveSheetIndex(){let{sheetOrder:e}=this._snapshot;return e.findIndex(e=>this._worksheets.get(e)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){let{sheetOrder:e}=this._snapshot;return e.map(e=>this._worksheets.get(e))}getSheetsName(){let{sheetOrder:e}=this._snapshot,t=[];return e.forEach(e=>{let n=this._worksheets.get(e);n&&t.push(n.getName())}),t}getSheetIndex(e){let{sheetOrder:t}=this._snapshot;return t.findIndex(t=>e.getSheetId()===t)}getSheetBySheetName(e){let{sheetOrder:t}=this._snapshot,n=t.find(t=>this._worksheets.get(t).getName()===e);return this._worksheets.get(n)}getSheetBySheetId(e){return this._worksheets.get(e)}getSheetByIndex(e){let{sheetOrder:t}=this._snapshot;return this._worksheets.get(t[e])}getHiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden===B.TRUE).map(e=>e.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden!==B.TRUE).map(e=>e.getConfig().id)}load(e){this._snapshot=e}checkSheetName(e){return this.getSheetsName().some(t=>t.toLowerCase()===e.toLowerCase())}uniqueSheetName(e=`Sheet1`){let t=e;for(;this.checkSheetName(t);)t=e+this._count,this._count++;return t}generateNewSheetName(e){let t=e+this._count;for(;this.checkSheetName(t);)t=e+this._count,this._count++;return t}_parseWorksheetSnapshots(){let{_snapshot:e,_worksheets:t}=this,{sheets:n,sheetOrder:r}=e;if(R.isEmptyObject(n)){let e=Ya();n[e]={id:e}}for(let e in n){let i=n[e],{name:a}=i;i.name=this.uniqueSheetName(a),i.name!==a&&this._logService.debug(`[Workbook]`,`The worksheet name ${a} is duplicated, we changed it to ${i.name}. Please fix the problem in your snapshot.`);let o=new Qg(this._unitId,i,this._styles);t.set(e,o),r.includes(e)||r.push(e)}this.ensureSheetOrderUnique(),this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(e){this._snapshot.custom=e}};n_=Us([W(1,Bs)],n_);var r_=class extends Pa{get _activePage(){let e=this._activePage$.getValue();if(!e){var t,n;let e=(t=this.getPageOrder())==null?void 0:t[0];return e?(n=this.getPages())==null?void 0:n[e]:null}return e}constructor(e){var t;super(),P(this,`type`,I.UNIVER_SLIDE),P(this,`_activePage$`,new n.BehaviorSubject(null)),P(this,`activePage$`,this._activePage$.asObservable()),P(this,`_name$`,void 0),P(this,`name$`,void 0),P(this,`_snapshot`,void 0),P(this,`_unitId`,void 0),this._snapshot={...Hf,...e},this._unitId=(t=this._snapshot.id)==null?Ya(6):t,this._name$=new n.BehaviorSubject(this._snapshot.title),this.name$=this._name$.asObservable()}setName(e){var t;this._snapshot.title=e,this._name$.next(e),this._unitId=(t=this._snapshot.id)==null?Ya(6):t}getRev(){return 0}incrementRev(){}setRev(e){}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var e;return(e=this._snapshot.body)==null?void 0:e.pages}getPageOrder(){var e;return(e=this._snapshot.body)==null?void 0:e.pageOrder}getPage(e){let t=this.getPages();return t==null?void 0:t[e]}getElementsByPage(e){var t;return(t=this.getPage(e))==null?void 0:t.pageElements}getElement(e,t){var n;return(n=this.getElementsByPage(e))==null?void 0:n[t]}getPageSize(){return this._snapshot.pageSize}getBlankPage(){let e=Ya(6);return{id:e,pageType:ps.SLIDE,zIndex:10,title:e,description:``,pageBackgroundFill:{rgb:`rgb(255,255,255)`},pageElements:{}}}setActivePage(e){this._activePage$.next(e)}getActivePage(){return this._activePage}updatePage(e,t){this._snapshot.body&&(this._snapshot.body.pages[e]=t)}appendPage(e){var t;if(!this._snapshot.body)return;this._snapshot.body.pages[e.id]=e;let n=this._activePage,r=this._snapshot.body.pageOrder.indexOf((t=n==null?void 0:n.id)==null?``:t);this._snapshot.body.pageOrder.splice(r+1,0,e.id)}};let i_=(0,t.createIdentifier)(`univer.current`),a_=class extends ra{constructor(e,t,r){super(),this._injector=e,this._contextService=t,this._logService=r,P(this,`_unitsByType`,new Map),P(this,`_createHandler`,void 0),P(this,`_ctorByType`,new Map),P(this,`_currentUnits`,new Map),P(this,`_currentUnits$`,new n.BehaviorSubject(this._currentUnits)),P(this,`currentUnits$`,this._currentUnits$.asObservable()),P(this,`_unitAdded$`,new n.Subject),P(this,`unitAdded$`,this._unitAdded$.asObservable()),P(this,`_unitDisposed$`,new n.Subject),P(this,`unitDisposed$`,this._unitDisposed$.asObservable()),P(this,`_focused$`,new n.BehaviorSubject(null)),P(this,`focused$`,this._focused$.asObservable())}dispose(){super.dispose(),this._focused$.complete(),this._currentUnits$.complete(),this._unitAdded$.complete(),this._currentUnits.forEach(e=>e==null?void 0:e.dispose()),this._currentUnits.clear(),this._unitsByType.clear()}__setCreateHandler(e){this._createHandler=e}createUnit(e,t,n){return this._createHandler(e,t,this._ctorByType.get(e),n)}registerCtorForType(e,t){return this._ctorByType.set(e,t),{dispose:()=>{this._ctorByType.delete(e)}}}getCurrentTypeOfUnit$(e){return this.currentUnits$.pipe((0,n.map)(t=>{var n;return(n=t.get(e))==null?null:n}),(0,n.distinctUntilChanged)())}getCurrentUnitForType(e){return this._currentUnits.get(e)}getCurrentUnitOfType(e){return this.getCurrentUnitForType(e)}setCurrentUnitForType(e){let t=this._getUnitById(e);if(!t)throw Error(`[UniverInstanceService]: no document with unitId ${e}!`);this._currentUnits.set(t[1],t[0]),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(e){return this._unitAdded$.pipe((0,n.filter)(t=>t.type===e))}__addUnit(e,t){var n;this._logService.debug(`[UniverInstanceService]: Adding unit with id ${e.getUnitId()}`);let r=e.type;this._unitsByType.has(r)||this._unitsByType.set(r,[]);let i=this._unitsByType.get(r),a=e.getUnitId();if(i.findIndex(e=>e.getUnitId()===a)!==-1)throw Error(`[UniverInstanceService]: cannot create a unit with the same unit id: ${a}.`);i.push(e),this._unitAdded$.next(e),((n=t==null?void 0:t.makeCurrent)==null||n)&&this.setCurrentUnitForType(e.getUnitId())}getTypeOfUnitDisposed$(e){return this.unitDisposed$.pipe((0,n.filter)(t=>t.type===e))}getUnit(e,t){var n;let r=(n=this._getUnitById(e))==null?void 0:n[0];return t&&(r==null?void 0:r.type)!==t?null:r}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(I.UNIVER_DOC)}getUniverDocInstance(e){return this.getUnit(e,I.UNIVER_DOC)}getUniverSheetInstance(e){return this.getUnit(e,I.UNIVER_SHEET)}getAllUnitsForType(e){var t;return(t=this._unitsByType.get(e))==null?[]:t}changeDoc(e,t){let n=this.getAllUnitsForType(I.UNIVER_DOC),r=n.find(t=>t.getUnitId()===e);if(r!=null){let e=n.indexOf(r);n.splice(e,1)}this.__addUnit(t)}get focused(){var e;let t=this._focused$.getValue();return t?(e=this._getUnitById(t))==null?void 0:e[0]:null}focusUnit(e){this._focused$.next(e),this.focused instanceof n_?(this._contextService.setContextValue(ug,!0),this._contextService.setContextValue(fg,!1),this._contextService.setContextValue(dg,!0),this._contextService.setContextValue(pg,!1),this.setCurrentUnitForType(e)):this.focused instanceof ch?(this._contextService.setContextValue(ug,!0),this._contextService.setContextValue(fg,!0),this._contextService.setContextValue(dg,!1),this._contextService.setContextValue(pg,!1),this.setCurrentUnitForType(e)):this.focused instanceof r_?(this._contextService.setContextValue(ug,!0),this._contextService.setContextValue(fg,!1),this._contextService.setContextValue(dg,!1),this._contextService.setContextValue(pg,!0),this.setCurrentUnitForType(e)):(this._contextService.setContextValue(ug,!1),this._contextService.setContextValue(fg,!1),this._contextService.setContextValue(dg,!1),this._contextService.setContextValue(pg,!1))}getFocusedUnit(){return this.focused}getUnitType(e){let t=this._getUnitById(e);return t?t[1]:I.UNRECOGNIZED}disposeUnit(e){this._logService.debug(`[UniverInstanceService]: Disposing unit with id ${e}`);let t=this._getUnitById(e);if(!t)return this._logService.debug(`[UniverInstanceService]: No unit found with id ${e}`),!1;let[n,r]=t,i=this._unitsByType.get(r),a=i.indexOf(n);return i.splice(a,1),this._tryResetCurrentOnRemoval(e,r),this._tryResetFocusOnRemoval(e),this._unitDisposed$.next(n),n.dispose(),!0}_tryResetCurrentOnRemoval(e,t){let n=this.getCurrentUnitForType(t);(n==null?void 0:n.getUnitId())===e&&(this._currentUnits.set(t,null),this._currentUnits$.next(this._currentUnits))}_tryResetFocusOnRemoval(e){var t;((t=this.focused)==null?void 0:t.getUnitId())===e&&this._focused$.next(null)}_getUnitById(e){for(let[t,n]of this._unitsByType){let r=n.find(t=>t.getUnitId()===e);if(r)return[r,t]}}};a_=Us([W(0,(0,t.Inject)(t.Injector)),W(1,Ls),W(2,(0,t.Inject)(Bs))],a_);let $=function(e){return e[e.Starting=0]=`Starting`,e[e.Ready=1]=`Ready`,e[e.Rendered=2]=`Rendered`,e[e.Steady=3]=`Steady`,e}({}),o_={[$.Starting]:`Starting`,[$.Ready]:`Ready`,[$.Rendered]:`Rendered`,[$.Steady]:`Steady`};var s_=class extends Error{constructor(e){super(`[LifecycleService]: lifecycle stage "${o_[e]}" will never be reached!`),this.name=`LifecycleUnreachableError`}};let c_=class extends ra{constructor(e){super(),this._logService=e,P(this,`_lifecycle$`,new n.BehaviorSubject($.Starting)),P(this,`lifecycle$`,this._lifecycle$.asObservable()),P(this,`_lock`,!1),this._reportProgress($.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(e){if(this._lock)throw Error(`[LifecycleService]: cannot set new stage when related logic is all handled!`);if(e<this.stage)throw Error(`[LifecycleService]: lifecycle stage cannot go backward!`);e!==this.stage&&(this._lock=!0,this._reportProgress(e),this._lifecycle$.next(e),this._lock=!1)}dispose(){this._lifecycle$.complete(),super.dispose()}onStage(e){return(0,n.firstValueFrom)(this.lifecycle$.pipe((0,n.filter)(t=>t>=e),ec(t=>t===e),(0,n.map)(()=>void 0))).catch(t=>t.name===`EmptyError`?Promise.reject(new s_(e)):Promise.reject(t))}subscribeWithPrevious(){return(0,n.merge)(l_(this.stage),this._lifecycle$.pipe((0,n.skip)(1))).pipe(ec(e=>e===$.Steady))}_reportProgress(e){this._logService.debug(`[LifecycleService]`,`lifecycle progressed to "${o_[e]}".`)}};c_=Us([W(0,Bs)],c_);function l_(e){switch(e){case $.Starting:return(0,n.of)($.Starting);case $.Ready:return(0,n.of)($.Starting,$.Ready);case $.Rendered:return(0,n.of)($.Starting,$.Ready,$.Rendered);default:return(0,n.of)($.Starting,$.Ready,$.Rendered,$.Steady)}}let u_=(0,t.createIdentifier)(`ILocalStorageService`);var d_=class extends ra{get _currentLocale(){return this._currentLocale$.value}constructor(){super(),P(this,`_currentLocale$`,new n.BehaviorSubject(uo.ZH_CN)),P(this,`currentLocale$`,this._currentLocale$.asObservable()),P(this,`_locales`,null),P(this,`localeChanged$`,new n.Subject),P(this,`t`,(e,...t)=>{if(!this._locales)throw Error(`[LocaleService]: Locale not initialized`);let n=e.split(`.`),r=this.resolveKeyPath(this._locales[this._currentLocale],n);if(typeof r==`string`){let e=r;return t.forEach((t,n)=>{e=e.replace(`{${n}}`,t)}),e}else return e}),this.disposeWithMe(ta(()=>{this._locales=null,this._currentLocale$.complete(),this.localeChanged$.complete()}))}load(e){var t;this._locales=Bi((t=this._locales)==null?{}:t,e)}setLocale(e){this._currentLocale$.next(e),this.localeChanged$.next()}getLocales(){var e;return(e=this._locales)==null?void 0:e[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(e,t){let n=t.shift();if(n&&e&&n in e){let r=e[n];return t.length>0&&(typeof r==`object`||Array.isArray(r))?this.resolveKeyPath(r,t):r}return null}};let f_=class{constructor(e){this._userManagerService=e}async list(e){return{list:[{type:fo.PERSON,mentions:[{objectType:fo.PERSON,objectId:this._userManagerService.getCurrentUser().userID,label:this._userManagerService.getCurrentUser().name,metadata:{icon:this._userManagerService.getCurrentUser().avatar}}],metadata:{},title:`PEOPLE`}],page:e.page,size:e.size,total:1}}};f_=Us([W(0,(0,t.Inject)(ag))],f_);let p_=(0,t.createIdentifier)(`univer.service.mention-io`),m_=function(e){return e.INIT=`init`,e.FETCHING=`fetching`,e.DONE=`done`,e}({}),h_=(0,t.createIdentifier)(`univer.permission-service`);var g_=class extends ra{constructor(...e){super(...e),P(this,`_permissionPointMap`,new Map),P(this,`_permissionPointUpdate$`,new n.Subject),P(this,`permissionPointUpdate$`,this._permissionPointUpdate$.asObservable()),P(this,`_showComponents`,!0)}setShowComponents(e){this._showComponents=e}getShowComponents(){return this._showComponents}deletePermissionPoint(e){let t=this._permissionPointMap.get(e);t&&(t.complete(),this._permissionPointMap.delete(e))}addPermissionPoint(e){let t=e instanceof n.BehaviorSubject,r=t?e.getValue():e;return r.id?this._permissionPointMap.get(r.id)?(console.warn(`${r.id} PermissionPoint already exists`),!1):(this._permissionPointMap.set(r.id,t?e:new n.BehaviorSubject(r)),this._permissionPointUpdate$.next(r),!0):!1}updatePermissionPoint(e,t){let n=this._permissionPointMap.get(e);if(!n)return;let r=n.getValue();r.value=t,r.status=m_.DONE,n.next(r),this._permissionPointUpdate$.next(r)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(e){let t=this._permissionPointMap.get(e);if(t)return t.getValue()}getPermissionPoint$(e){let t=this._permissionPointMap.get(e);if(t)return t}composePermission$(e){return(0,n.combineLatest)(e.map(e=>{var t;let n=(t=this._permissionPointMap)==null?void 0:t.get(e);if(!n)throw Error(`[PermissionService]: ${e} permissionPoint does not exist!`);return n.asObservable()})).pipe((0,r.map)(e=>e))}composePermission(e){return e.map(e=>{var t;let n=(t=this._permissionPointMap)==null?void 0:t.get(e);if(!n)throw Error(`[PermissionService]: ${e} permissionPoint does not exist!`);return n.getValue()})}getAllPermissionPoint(){let e=new Map;return this._permissionPointMap.forEach((t,n)=>{e.set(n,t)}),e}};function __(e,t){if(!t)return e;let n=[];for(let r of e){let e=t.find(([e])=>e===r[0]);if(e){if(e[1]===null)continue;n.push([r[0],e[1]])}else n.push(r)}return n}let v_=Symbol(`DependentOn`);var y_=class extends ra{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}};P(y_,`pluginName`,void 0),P(y_,`packageName`,xg),P(y_,`version`,Sg),P(y_,`type`,I.UNIVER_UNKNOWN);var b_=class{constructor(){P(this,`_plugins`,[])}addPlugin(e){this._plugins.push(e)}removePlugins(){let e=this._plugins.slice();return this._plugins.length=0,e}forEachPlugin(e){this._plugins.forEach(e)}};function x_(...e){return function(t){t[v_]=e}}let S_=class{constructor(e,t,n){this._injector=e,this._lifecycleService=t,this._logService=n,P(this,`_pluginRegistry`,new Map),P(this,`_pluginStore`,new b_),P(this,`_seenPlugins`,new Set),P(this,`_loadedPlugins`,new Set),P(this,`_loadedPluginTypes`,new Set([I.UNIVER_UNKNOWN])),P(this,`_flushTimerByType`,new Map)}dispose(){this._pluginStore.removePlugins().forEach(e=>e.dispose()),this._flushTimerByType.forEach(e=>clearTimeout(e))}registerPlugin(e,t){this._assertPluginValid(e);let n={plugin:e,options:t};this._pluginRegistry.set(e.pluginName,n),this._logService.debug(`[PluginService]`,`Plugin "${e.pluginName}" registered.`);let{type:r}=e;this._loadedPluginTypes.has(r)&&(r===I.UNIVER_UNKNOWN?this._loadFromPlugins([n]):this._flushType(r))}startPluginsForType(e){this._loadedPluginTypes.has(e)||this._loadPluginsForType(e)}_loadPluginsForType(e){let t=Array.from(this._pluginRegistry.keys()),n=[];t.forEach(t=>{let r=this._pluginRegistry.get(t);r.plugin.type===e&&n.push(r)}),this._loadFromPlugins(n),this._loadedPluginTypes.add(e)}_assertPluginValid(e){let{type:t,pluginName:n,packageName:r,version:i}=e;if(t===I.UNRECOGNIZED)throw Error(`[PluginService]: invalid plugin type for ${e.name}. Please assign a "type" to your plugin.`);if(!n)throw Error(`[PluginService]: no plugin name for ${e.name}. Please assign a "pluginName" to your plugin.`);if(i&&i!==y_.version)throw Error(`[PluginService]: package "${r==null?`UNKNOWN`:r}" version mismatch. Plugin version is "${i}" but @univerjs/core version is "${y_.version}". Please make sure all @univerjs packages use the same version.`);if(this._seenPlugins.has(n))throw Error(`[PluginService]: duplicated plugin name for "${n}". Maybe a plugin that dependents on "${n} has already registered it. In that case please register "${n}" before the that plugin.`);this._seenPlugins.add(e.pluginName)}_flushType(e){this._flushTimerByType.get(e)===void 0&&this._flushTimerByType.set(e,setTimeout(()=>{this._loadPluginsForType(e),this._flushTimerByType.delete(e)},4))}_loadFromPlugins(e){let t=[],n=new Set,r=e=>{let{plugin:i}=e,{pluginName:a}=i;if(this._loadedPlugins.has(a)||n.has(a))return;n.add(a),this._pluginRegistry.delete(a);let o=i[v_];o&&o.forEach(e=>{let t=this._pluginRegistry.get(e.pluginName);if(t)r(t);else if(!this._seenPlugins.has(e.pluginName)&&!n.has(e.pluginName)){if(i.type===I.UNIVER_UNKNOWN&&e.type!==I.UNIVER_UNKNOWN)throw Error(`[PluginService]: cannot register a plugin with Univer type that depends on a plugin with other type. The dependent is ${i.pluginName} and the dependency is ${e.pluginName}.`);i.type!==e.type&&e.type!==I.UNIVER_UNKNOWN&&this._logService.debug(`[PluginService]`,`Plugin "${a}" depends on "${e.pluginName}" which has different type.`),this._logService.debug(`[PluginService]`,`Plugin "${a}" depends on "${e.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(e),r({plugin:e,options:void 0})}}),t.push(e)};e.forEach(e=>r(e));let i=t.map(e=>this._initPlugin(e.plugin,e.options));this._pluginsRunLifecycle(i)}_pluginsRunLifecycle(e){let t=this._lifecycleService.stage;if(l_(t).subscribe(t=>this._runStage(e,t)),t!==$.Steady){let t=this._lifecycleService.lifecycle$.pipe((0,n.skip)(1)).subscribe(n=>{this._runStage(e,n),n===$.Steady&&t.unsubscribe()})}}_runStage(e,t){e.forEach(e=>{switch(t){case $.Starting:e.onStarting();break;case $.Ready:e.onReady();break;case $.Rendered:e.onRendered();break;case $.Steady:e.onSteady();break}})}_initPlugin(e,t){let n=this._injector.createInstance(e,t);return this._pluginStore.addPlugin(n),this._loadedPlugins.add(e.pluginName),this._logService.debug(`[PluginService]`,`Plugin "${n.getPluginName()}" loaded.`),n}};S_=Us([W(0,(0,t.Inject)(t.Injector)),W(1,(0,t.Inject)(c_)),W(2,Bs)],S_);let C_=(0,t.createIdentifier)(`resource-loader-service`),w_=class extends ra{constructor(e){super(),this._logService=e,P(this,`_resourceMap`,new Map),P(this,`_register$`,new n.Subject),P(this,`register$`,this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(e,t){return t?this.getResourcesByType(e,t):this.getAllResourceHooks().map(t=>{let n=t.toJson(e);return{name:t.pluginName,data:n}})}getResourcesByType(e,t){return this.getAllResourceHooks().filter(e=>e.businesses.includes(t)).map(t=>{let n=t.toJson(e);return{name:t.pluginName,data:n}})}registerPluginResource(e){let t=e.pluginName;if(this._resourceMap.has(t))throw Error(`the pluginName is registered {${t}}`);return this._resourceMap.set(t,e),this._register$.next(e),ta(()=>this._resourceMap.delete(t))}disposePluginResource(e){this._resourceMap.delete(e)}loadResources(e,t){this.getAllResourceHooks().forEach(n=>{var r;let i=t==null||(r=t.find(e=>e.name===n.pluginName))==null?void 0:r.data;if(i)try{let t=n.parseJson(i);n.onLoad(e,t)}catch(e){this._logService.error(`[ResourceManagerService]`,`loadResources error`,e)}})}unloadResources(e,t){this.getAllResourceHooks().filter(e=>e.businesses.includes(t)).forEach(t=>{t.onUnLoad(e)})}dispose(){this._register$.complete(),this._resourceMap.clear()}};w_=Us([W(0,Bs)],w_);var T_=class extends ra{get darkMode(){return this._darkMode$.getValue()}constructor(){super(),P(this,`_darkMode$`,new n.BehaviorSubject(!1)),P(this,`darkMode$`,this._darkMode$.asObservable()),P(this,`_validColorCache`,new Map),P(this,`_currentTheme`,i.defaultTheme),P(this,`_currentTheme$`,new n.BehaviorSubject(this._currentTheme)),P(this,`currentTheme$`,this._currentTheme$.asObservable()),this.disposeWithMe(ta(()=>{this._currentTheme=i.defaultTheme,this._currentTheme$.complete(),this._darkMode$.complete()}))}isValidThemeColor(e){if(this._validColorCache.has(e))return this._validColorCache.get(e);let t=!1,n=e.split(`.`);if(n.length===1)t=e in i.defaultTheme;else if(n.length===2){let[e,r]=n;t=e in i.defaultTheme&&r in this._currentTheme[e]}return this._validColorCache.set(e,t),t}getCurrentTheme(){return this._currentTheme}setTheme(e){this._currentTheme=e,this._currentTheme$.next(e)}setDarkMode(e){this._darkMode$.next(e)}getColorFromTheme(e){return ti(this._currentTheme,e)}},E_=function(e){return e[e.WAITING=0]=`WAITING`,e[e.CREATED=1]=`CREATED`,e}(E_||{});let D_=(0,t.createIdentifier)(`univer.undo-redo.service`);var O_=class{dispose(){}async dispatchToHandlers(){return!1}};let k_=`univer.command.redo`,A_=`univer.command.undo`,j_=new class extends O_{constructor(...e){super(...e),P(this,`type`,Gs.COMMAND),P(this,`id`,A_)}handler(e){let t=e.get(D_),n=t.pitchTopUndoElement();if(!n)return!1;let r=e.get(Ks);return Zs(n.undoMutations,r)?(t.popUndoToRedo(),!0):!1}},M_=new class extends O_{constructor(...e){super(...e),P(this,`type`,Gs.COMMAND),P(this,`id`,k_)}handler(e){let t=e.get(D_),n=t.pitchTopRedoElement();if(!n)return!1;let r=e.get(Ks);return Zs(n.redoMutations,r)?(t.popRedoToUndo(),!0):!1}},N_=class extends ra{constructor(e,t,r){super(),this._univerInstanceService=e,this._commandService=t,this._contextService=r,P(this,`undoRedoStatus$`,void 0),P(this,`_undoRedoStatus$`,new n.BehaviorSubject({undos:0,redos:0})),P(this,`_undoStacks`,new Map),P(this,`_redoStacks`,new Map),P(this,`_batchingStatus`,new Map),this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(j_)),this.disposeWithMe(this._commandService.registerCommand(M_)),this.disposeWithMe(ta(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(ta(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(e){let{unitID:t}=e,n=this._getRedoStack(t,!0),r=this._getUndoStack(t,!0);if(n.length=0,this._batchingStatus.has(e.unitID)){let t=this._batchingStatus.get(e.unitID),n=this._pitchUndoElement(e.unitID);t===E_.WAITING||!n?(i(e),this._batchingStatus.set(e.unitID,E_.CREATED)):this._tryBatchingElements(n,e)}else i(e);function i(e){r.push(e),r.length>20&&r.splice(0,1)}this._updateStatus()}clearUndoRedo(e){let t=this._getRedoStack(e);t&&(t.length=0);let n=this._getUndoStack(e);n&&(n.length=0),this._updateStatus()}pitchTopUndoElement(){let e=this._getFocusedUnitId();return this._pitchUndoElement(e)}pitchTopRedoElement(){let e=this._getFocusedUnitId();return this._pitchRedoElement(e)}_pitchUndoElement(e){let t=this._getUndoStack(e);return t!=null&&t.length?t[t.length-1]:null}_pitchRedoElement(e){let t=this._getRedoStack(e);return t!=null&&t.length?t[t.length-1]:null}popUndoToRedo(){let e=this._getUndoStackForFocused().pop();e&&(e.redoMutations.length>0&&this._getRedoStackForFocused().push(e),this._updateStatus())}popRedoToUndo(){let e=this._getRedoStackForFocused().pop();e&&(this._getUndoStackForFocused().push(e),this._updateStatus())}rollback(e,t){let n=t||this._getFocusedUnitId(),r=this._getUndoStack(n),i=r==null?void 0:r[(r==null?void 0:r.length)-1];i&&i.id===e&&(r.pop(),Zs(i.undoMutations,this._commandService))}__tempBatchingUndoRedo(e){if(this._batchingStatus.has(e))throw Error(`[LocalUndoRedoService]: cannot batching undo redo twice at the same time!`);return this._batchingStatus.set(e,E_.WAITING),ta(()=>this._batchingStatus.delete(e))}_updateStatus(){var e,t;let n=this._getFocusedUnitId(),r=n&&((e=this._undoStacks.get(n))==null?void 0:e.length)||0,i=n&&((t=this._redoStacks.get(n))==null?void 0:t.length)||0;this._undoRedoStatus$.next({undos:r,redos:i})}_getUndoStack(e,t=!1){let n=this._undoStacks.get(e);return!n&&t&&(n=[],this._undoStacks.set(e,n)),n||null}_getRedoStack(e,t=!1){let n=this._redoStacks.get(e);return!n&&t&&(n=[],this._redoStacks.set(e,n)),n||null}_getUndoStackForFocused(){let e=this._getFocusedUnitId();if(!e)throw Error(`No focused univer instance!`);return this._getUndoStack(e,!0)}_getRedoStackForFocused(){let e=this._getFocusedUnitId();if(!e)throw Error(`No focused univer instance!`);return this._getRedoStack(e,!0)}_tryBatchingElements(e,t){e.redoMutations.push(...t.redoMutations),e.undoMutations.push(...t.undoMutations)}_getFocusedUnitId(){let e=``,t=this._contextService.getContextValue(dg),n=this._contextService.getContextValue(hg),r=this._contextService.getContextValue(mg);if(t)if(n)e=N;else if(r)e=M;else{var i,a;e=(i=(a=this._univerInstanceService.getFocusedUnit())==null?void 0:a.getUnitId())==null?``:i}else{var o,s;e=(o=(s=this._univerInstanceService.getFocusedUnit())==null?void 0:s.getUnitId())==null?``:o}return e}};N_=Us([W(0,i_),W(1,Ks),W(2,Ls)],N_);var P_=class{constructor(e,t=1e3){this._injector=e,P(this,`_imageCacheMap`,void 0),this._imageCacheMap=new Mf(t)}_getImageCacheKey(e,t){return`${e}-${t}`}getImage(e,t,n,r){let i=this._getImageCacheKey(e,t);return this._imageCacheMap.get(i)||((async()=>{let a=new Image,o=this._injector.has(yg)?this._injector.get(yg):null,s=this._injector.has(bg)?this._injector.get(bg):null;if(e===_g.UUID)try{a.src=await(o==null?void 0:o.getImage(t))||``}catch(e){console.error(e)}else if(e===_g.URL)try{a.src=await(s==null?void 0:s.getImage(t))||t}catch{a.src=t}else a.src=t;a.onload=()=>{a.removeAttribute(`data-error`),n==null||n()},a.onerror=()=>{a.setAttribute(`data-error`,`true`),r==null||r()},this._imageCacheMap.set(i,a)})(),null)}};function F_(e){return!(e.length===0||e.length>31||e.startsWith(`'`)||e.endsWith(`'`)||/[:\\\/\?\*\[\]]/.test(e))}function I_(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))}let L_=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];var R_=class e{static from(t){if(!(t instanceof ArrayBuffer))throw Error(`Data must be an instance of ArrayBuffer.`);let[n,r]=new Uint8Array(t,0,2);if(n!==219)throw Error(`Data does not appear to be in a KDBush format.`);let i=r>>4;if(i!==1)throw Error(`Got v${i} data when expected v1.`);let a=L_[r&15];if(!a)throw Error(`Unrecognized array type.`);let[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new e(s,o,a,t)}constructor(e,t=64,n=Float64Array,r){if(isNaN(e)||e<0)throw Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=n,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;let i=L_.indexOf(this.ArrayType),a=e*2*this.ArrayType.BYTES_PER_ELEMENT,o=e*this.IndexArrayType.BYTES_PER_ELEMENT,s=(8-o%8)%8;if(i<0)throw Error(`Unexpected typed array class: ${n}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+o+s,e*2),this._pos=e*2,this._finished=!0):(this.data=new ArrayBuffer(8+a+o+s),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+o+s,e*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){let n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=e,this.coords[this._pos++]=t,n}finish(){let e=this._pos>>1;if(e!==this.numItems)throw Error(`Added ${e} items when expected ${this.numItems}.`);return z_(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,n,r){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:i,coords:a,nodeSize:o}=this,s=[0,i.length-1,0],c=[];for(;s.length;){let l=s.pop()||0,u=s.pop()||0,d=s.pop()||0;if(u-d<=o){for(let o=d;o<=u;o++){let s=a[2*o],l=a[2*o+1];s>=e&&s<=n&&l>=t&&l<=r&&c.push(i[o])}continue}let f=d+u>>1,p=a[2*f],m=a[2*f+1];p>=e&&p<=n&&m>=t&&m<=r&&c.push(i[f]),(l===0?e<=p:t<=m)&&(s.push(d),s.push(f-1),s.push(1-l)),(l===0?n>=p:r>=m)&&(s.push(f+1),s.push(u),s.push(1-l))}return c}within(e,t,n){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:r,coords:i,nodeSize:a}=this,o=[0,r.length-1,0],s=[],c=n*n;for(;o.length;){let l=o.pop()||0,u=o.pop()||0,d=o.pop()||0;if(u-d<=a){for(let n=d;n<=u;n++)U_(i[2*n],i[2*n+1],e,t)<=c&&s.push(r[n]);continue}let f=d+u>>1,p=i[2*f],m=i[2*f+1];U_(p,m,e,t)<=c&&s.push(r[f]),(l===0?e-n<=p:t-n<=m)&&(o.push(d),o.push(f-1),o.push(1-l)),(l===0?e+n>=p:t+n>=m)&&(o.push(f+1),o.push(u),o.push(1-l))}return s}};function z_(e,t,n,r,i,a){if(i-r<=n)return;let o=r+i>>1;B_(e,t,o,r,i,a),z_(e,t,n,r,o-1,1-a),z_(e,t,n,o+1,i,1-a)}function B_(e,t,n,r,i,a){for(;i>r;){if(i-r>600){let o=i-r+1,s=n-r+1,c=Math.log(o),l=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*l*(o-l)/o)*(s-o/2<0?-1:1);B_(e,t,n,Math.max(r,Math.floor(n-s*l/o+u)),Math.min(i,Math.floor(n+(o-s)*l/o+u)),a)}let o=t[2*n+a],s=r,c=i;for(V_(e,t,r,n),t[2*i+a]>o&&V_(e,t,r,i);s<c;){for(V_(e,t,s,c),s++,c--;t[2*s+a]<o;)s++;for(;t[2*c+a]>o;)c--}t[2*r+a]===o?V_(e,t,r,c):(c++,V_(e,t,c,i)),c<=n&&(r=c+1),n<=c&&(i=c-1)}}function V_(e,t,n,r){H_(e,n,r),H_(t,2*n,2*r),H_(t,2*n+1,2*r+1)}function H_(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function U_(e,t,n,r){let i=e-n,a=t-r;return i*i+a*a}var W_=class{constructor(e=!1){this._enableOneCellCache=e,P(this,`_tree`,new Map),P(this,`_oneCellCache`,new Map),P(this,`_kdTree`,new Map)}dispose(){this.clear()}getTree(e,t){return this._tree.has(e)||this._tree.set(e,new Map),this._tree.get(e).has(t)||this._tree.get(e).set(t,new $f),this._tree.get(e).get(t)}_getOneCellCache(e,t,n,r){return this._oneCellCache.has(e)||this._oneCellCache.set(e,new Map),this._oneCellCache.get(e).has(t)||this._oneCellCache.get(e).set(t,new Map),this._oneCellCache.get(e).get(t).has(n)||this._oneCellCache.get(e).get(t).set(n,new Map),this._oneCellCache.get(e).get(t).get(n).has(r)||this._oneCellCache.get(e).get(t).get(n).set(r,new Set),this._oneCellCache.get(e).get(t).get(n).get(r)}_removeOneCellCache(e,t,n,r,i){let a=this._oneCellCache.get(e);if(!a)return;let o=a.get(t);if(!o)return;let s=o.get(n);if(!s)return;let c=s.get(r);c&&c.delete(i)}_removeCellCacheByRange(e){let{unitId:t,sheetId:n,range:r,id:i}=e,a=this._oneCellCache.get(t);if(!a)return;let o=a.get(n);if(!o)return;let{startRow:s,startColumn:c,endRow:l,endColumn:u}=r;for(let e=s;e<=l;e++){let t=o.get(e);if(t)for(let e=c;e<=u;e++){let n=t.get(e);n&&n.delete(i)}}}_insertOneCellCache(e,t,n,r,i){this._getOneCellCache(e,t,n,r).add(i)}_getRdTreeItems(e){let t=[];for(let[n,r]of e)for(let[e,i]of r)t.push({x:e,y:n,ids:i});return t}_searchByOneCellCache(e){var t;let{unitId:n,sheetId:r,range:i}=e,{startRow:a,startColumn:o,endRow:s,endColumn:c}=i,l=(t=this._kdTree.get(n))==null?void 0:t.get(r);if(!l)return[];let{tree:u,items:d}=l,f=u.range(o,a,c,s),p=[];for(let e of f){let t=d[e];p.push(...Array.from(t.ids))}return p}openKdTree(){for(let[t,n]of this._oneCellCache){this._kdTree.has(t)||this._kdTree.set(t,new Map);for(let[r,i]of n){var e;let n=this._getRdTreeItems(i),a=new R_(n.length);(e=this._kdTree.get(t))==null||e.set(r,{tree:a,items:n});for(let e of n)a.add(e.x,e.y);a.finish()}}}closeKdTree(){for(let[t,n]of this._oneCellCache)for(let[r,i]of n){var e;(e=this._kdTree.get(t))==null||e.set(r,void 0)}}insert(e){let{unitId:t,sheetId:n,range:r,id:i}=e;if(!t||t.length===0)return;let{startRow:a,endRow:o,startColumn:s,endColumn:c}=r;if(this._enableOneCellCache&&a===o&&s===c){this._insertOneCellCache(t,n,a,s,i);return}let l=this.getTree(t,n);Number.isNaN(a)&&(a=0),Number.isNaN(s)&&(s=0),Number.isNaN(o)&&(o=1/0),Number.isNaN(c)&&(c=1/0),l.insert({minX:s,minY:a,maxX:c,maxY:o,id:i})}bulkInsert(e){for(let t of e)this.insert(t)}*searchGenerator(e){var t;let{unitId:n,sheetId:r,range:i}=e;if(this._enableOneCellCache){let t=this._searchByOneCellCache(e);for(let e of t)yield e}let a=(t=this._tree.get(n))==null?void 0:t.get(r);if(!a)return;let o=a.search({minX:i.startColumn,minY:i.startRow,maxX:i.endColumn,maxY:i.endRow});for(let e of o)yield e.id}bulkSearch(e,t){let n=new Set;for(let r of e)for(let e of this.searchGenerator(r))(t==null?void 0:t.has(e))!==!0&&n.add(e);return n}removeById(e,t){if(t){var n,r;(n=this._tree.get(e))==null||n.delete(t),(r=this._oneCellCache.get(e))==null||r.delete(t)}else this._tree.delete(e),this._oneCellCache.delete(e)}_removeRTreeItem(e){let{unitId:t,sheetId:n,range:r,id:i}=e,a=this.getTree(t,n),o=a.search({minX:r.startColumn,minY:r.startRow,maxX:r.endColumn,maxY:r.endRow});for(let e=0;e<o.length;e++)o[e].id===i&&a.remove(o[e])}remove(e){let{unitId:t,sheetId:n,range:r,id:i}=e,{startRow:a,startColumn:o,endRow:s,endColumn:c}=r;this._enableOneCellCache?a===s&&o===c?this._removeOneCellCache(t,n,r.startRow,r.startColumn,i):(this._removeCellCacheByRange(e),this._removeRTreeItem(e)):this._removeRTreeItem(e)}bulkRemove(e){for(let t of e)this.remove(t)}clear(){this._tree.clear(),this._oneCellCache.clear()}toJSON(){let e={};return this._tree.forEach((t,n)=>{e[n]={},t.forEach((t,r)=>{e[n][r]=t.toJSON()})}),e}fromJSON(e){this._tree.clear();for(let t in e){this._tree.set(t,new Map);for(let n in e[t]){let r=new $f;r.fromJSON(e[t][n]),this._tree.get(t).set(n,r)}}}};function G_(e){return new Promise(t=>setTimeout(t,e))}function K_(e=1){return new Promise(t=>{let n=0,r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}let q_=class extends ra{constructor(e){super(),this._localeService=e,P(this,`_fontLocale`,void 0),P(this,`_dirty`,!0),this._localeInitial()}get dirty(){return this._dirty}getFontLocale(){return this._fontLocale}makeDirty(e){this._dirty=e}dispose(){super.dispose(),this._fontLocale=null}_localeInitial(){}};q_=Us([W(0,(0,t.Inject)(d_))],q_);let J_=class extends q_{constructor(e,t,n,r,i,a){super(n),this.worksheet=e,this._styles=t,this._contextService=r,this._configService=i,this._injector=a,P(this,`_worksheetData`,void 0),P(this,`_renderRawFormula`,!1),P(this,`_cellData`,void 0),P(this,`_imageCacheMap`,void 0),P(this,`_skipAutoHeightForMergedCells`,!0),P(this,`_rowTotalHeight`,0),P(this,`_columnTotalWidth`,0),P(this,`_rowHeaderWidth`,0),P(this,`_columnHeaderHeight`,0),P(this,`_rowHeightAccumulation`,[]),P(this,`_columnWidthAccumulation`,[]),P(this,`_marginTop`,0),P(this,`_marginLeft`,0),P(this,`_scaleX`,1),P(this,`_scaleY`,1),P(this,`_scrollX`,0),P(this,`_scrollY`,0),this._worksheetData=this.worksheet.getConfig(),this._cellData=this.worksheet.getCellMatrix(),this._imageCacheMap=new P_(this._injector),this.initConfig()}initConfig(){var e,t;this._skipAutoHeightForMergedCells=!((e=this._configService.getConfig(ne))!=null&&e),this.worksheet.setIsRowStylePrecedeColumnStyle((t=this._configService.getConfig(`isRowStylePrecedeColumnStyle`))==null?!1:t)}resetCache(){}getWorksheetConfig(){return this._worksheetData}getLocation(){return[this.worksheet.getUnitId(),this.worksheet.getSheetId()]}set columnHeaderHeight(e){this._columnHeaderHeight=e,this._worksheetData.columnHeader.height=e}set rowHeaderWidth(e){this._rowHeaderWidth=e,this._worksheetData.rowHeader.width=e}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(e){this._marginLeft=e}setMarginTop(e){this._marginTop=e}setScale(e,t){this._updateLayout(),this._scaleX=e,this._scaleY=t||e,this._updateLayout()}setScroll(e,t){R.isDefine(e)&&(this._scrollX=e),R.isDefine(t)&&(this._scrollY=t)}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(e,t,n){let r=0,i=[],a=t;for(let t=0;t<e;t++){let e=n;if(this.worksheet.getRowFiltered(t))e=0;else if(a[t]!=null){let r=a[t];if(!r)continue;let{h:i=n,ah:o,ia:s}=r;e=(s==null||s===B.TRUE)&&typeof o==`number`&&o>0?o:i,r.hd===B.TRUE&&(e=0)}r+=e,i.push(r)}return{rowTotalHeight:r,rowHeightAccumulation:i}}_generateColumnMatrixCache(e,t,n){let r=0,i=[],a=t;for(let t=0;t<e;t++){let e=n;if(a[t]!=null){let n=a[t];if(!n)continue;n.w!=null&&(e=n.w),n.hd===B.TRUE&&(e=0)}r+=e,i.push(r)}return{columnTotalWidth:r,columnWidthAccumulation:i}}intersectMergeRange(e,t){return!!this.worksheet.getMergedCell(e,t)}_getOverflowBound(e,t,n,r,i=So.LEFT){let a=0;if(t>n){let o=this._columnWidthAccumulation.length-1;for(let s=t;s>=n;s--){let n=s;if(!Md(this.worksheet.getCell(e,n))&&n!==t||this.intersectMergeRange(e,n))return n===t?n:n+1>o?o:n+1;let{startX:c,endX:l}=X_(e,n,this.rowHeightAccumulation,this.columnWidthAccumulation);if(i===So.CENTER&&n===t?a+=(l-c)/2:a+=l-c,r<a)return n}return t}for(let o=t;o<=n;o++){let n=o;if(!Md(this.worksheet.getCell(e,n))&&n!==t||this.intersectMergeRange(e,n))return n===t?n:n-1<0?0:n-1;let{startX:s,endX:c}=X_(e,n,this.rowHeightAccumulation,this.columnWidthAccumulation);if(i===So.CENTER&&n===t?a+=(c-s)/2:a+=c-s,r<a)return n}return n}_updateLayout(){if(!this.dirty)return;let{rowData:e,columnData:t,defaultRowHeight:n,defaultColumnWidth:r,rowCount:i,columnCount:a,rowHeader:o,columnHeader:s}=this._worksheetData,{rowTotalHeight:c,rowHeightAccumulation:l}=this._generateRowMatrixCache(i,e,n),{columnTotalWidth:u,columnWidthAccumulation:d}=this._generateColumnMatrixCache(a,t,r);this._rowHeaderWidth=o.hidden===B.TRUE?0:this._dynamicallyUpdateRowHeaderWidth(o),this._columnHeaderHeight=s.hidden===B.TRUE?0:s.height,this._rowTotalHeight=c,this._rowHeightAccumulation=l,this._columnTotalWidth=u,this._columnWidthAccumulation=d,this.makeDirty(!1)}calculate(){return this.resetCache(),this._updateLayout(),this}resetRangeCache(e){}_dynamicallyUpdateRowHeaderWidth(e){let t=`${this.worksheet.getRowCount()}`.length*8;return Math.max(e.width,t)}_hasUnMergedCellInRow(e,t,n){if(!this.worksheet.getMergeData())return!1;for(let r=t;r<=n;r++){let{isMerged:t,isMergedMainCell:n}=this.worksheet.getCellInfoInMergeData(e,r);if(!t&&!n)return!0}return!1}expandRangeByMerge(e,t){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e,o=this._worksheetData.mergeData;if(!o)return{startRow:n,startColumn:r,endRow:i,endColumn:a};let s=!0,c=new Dd,l=0,u=null;for(;s;){s=!1;for(let e=0;e<o.length;e++){let{startRow:t,startColumn:d,endRow:f,endColumn:p}=o[e];if(c.getValue(t,d))continue;let m={startColumn:r,startRow:n,endColumn:a,endRow:i},h={startColumn:d,startRow:t,endColumn:p,endRow:f};xp(m,h)&&(n=Math.min(n,t),r=Math.min(r,d),i=Math.max(i,f),a=Math.max(a,p),c.setValue(t,d,!0),s=!0,l++,u=h)}}return t&&l===1&&Tp.contains(u,e)?{startRow:u.startRow,startColumn:u.startColumn,endRow:u.startRow,endColumn:u.startColumn}:{startRow:n,startColumn:r,endRow:i,endColumn:a}}getColumnCount(){return this._columnWidthAccumulation.length}getRowCount(){return this._rowHeightAccumulation.length}_getCellMergeInfo(e,t){return this.worksheet.getCellInfoInMergeData(e,t)}getNoMergeCellWithCoordByIndex(e,t,n=!0){let{rowHeightAccumulation:r,columnWidthAccumulation:i,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:o}=this,{startY:s,endY:c,startX:l,endX:u}=X_(e,t,r,i);return n&&(s+=o,c+=o,l+=a,u+=a),{startY:s,endY:c,startX:l,endX:u}}getRowIndexByOffsetY(e,t,n,r){let{rowHeightAccumulation:i}=this;e=Q_(e,t,n,this.columnHeaderHeightAndMarginTop);let a=cc(i,e,r==null?void 0:r.firstMatch);if(r!=null&&r.closeFirst){var o;Math.abs(i[a]-e)<Math.abs(e-((o=i[a-1])==null?0:o))&&(a+=1)}return a}getColumnIndexByOffsetX(e,t,n,r){let i=Z_(e,t,n,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this,o=cc(a,i,r==null?void 0:r.firstMatch);if(r!=null&&r.closeFirst){var s;Math.abs(a[o]-i)<Math.abs(i-((s=a[o-1])==null?0:s))&&(o+=1)}return o}getCellIndexByOffset(e,t,n,r,i,a){return{row:this.getRowIndexByOffsetY(t,r,i,a),column:this.getColumnIndexByOffsetX(e,n,i,a)}}getCellByOffset(e,t,n,r,i){var a;let o=(a=this)==null?void 0:a.getCellIndexByOffset(e,t,n,r,i,{firstMatch:!0});return o?this.worksheet.getCellInfoInMergeData(o.row,o.column):null}getCellWithCoordByIndex(e,t,n=!0){var r;let{rowHeightAccumulation:i,columnWidthAccumulation:a,rowHeaderWidthAndMarginLeft:o,columnHeaderHeightAndMarginTop:s}=this,c=X_(e,t,i,a,(r=this.worksheet)==null?void 0:r.getCellInfoInMergeData(e,t)),{isMerged:l,isMergedMainCell:u}=c,{startY:d,endY:f,startX:p,endX:m,mergeInfo:h}=c,g=o,_=s;return n===!1&&(g=0,_=0),d+=_,f+=_,p+=g,m+=g,h.startY+=_,h.endY+=_,h.startX+=g,h.endX+=g,{actualRow:e,actualColumn:t,startX:p,startY:d,endX:m,endY:f,isMerged:l,isMergedMainCell:u,mergeInfo:h}}getCellWithCoordByOffset(e,t,n,r,i,a){let{row:o,column:s}=this.getCellIndexByOffset(e,t,n,r,i,a);return this.getCellWithCoordByIndex(o,s)}getOffsetByColumn(e){let{columnWidthAccumulation:t,rowHeaderWidthAndMarginLeft:n}=this,r=t.length-1,i=t[e];return i==null?e<0?n:t[r]+n:i+n}getOffsetByRow(e){let{rowHeightAccumulation:t,columnHeaderHeightAndMarginTop:n}=this,r=t.length-1,i=t[e];return i==null?e<0?n:t[r]+n:i+n}getOffsetRelativeToRowCol(e,t){let n=cc(this.columnWidthAccumulation,e),r=0;r=n===0?e:e-this._columnWidthAccumulation[n-1];let i=cc(this.rowHeightAccumulation,t),a=0;return a=i===0?t:t-this._rowHeightAccumulation[i-1],{row:i,column:n,columnOffset:r,rowOffset:a}}getCellIndexAndOffsetByPosition(e,t){let{actualRow:n,actualColumn:r,startX:i,startY:a}=this.getCellWithCoordByOffset(e,t,this._scaleX,this._scaleY,{x:this._scrollX,y:this._scrollY});return{row:n,rowOffset:t-a,column:r,columnOffset:e-i}}_updateConfigAndGetDocumentModel(e,t,n,r){var i,a,o,s,c;if(!r||!((i=e.body)!=null&&i.dataStream))return;e.documentStyle||(e.documentStyle={}),e.documentStyle.marginTop=(a=n.t)==null?0:a,e.documentStyle.marginBottom=(o=n.b)==null?2:o,e.documentStyle.marginLeft=(s=n.l)==null?2:s,e.documentStyle.marginRight=(c=n.r)==null?2:c,e.documentStyle.pageSize={width:1/0,height:1/0},e.documentStyle.renderConfig={...e.documentStyle.renderConfig,...r};let l=e.body.paragraphs||[];for(let e of l)e.paragraphStyle||(e.paragraphStyle={}),e.paragraphStyle.horizontalAlign=t;return new ch(e)}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}};J_=Us([W(2,(0,t.Inject)(d_)),W(3,Ls),W(4,Fs),W(5,(0,t.Inject)(t.Injector))],J_);function Y_(e,t,n,r){let i=e-1,a=t-1,o=n[i]||0,s=n[e];s==null&&(s=n[n.length-1]);let c=r[a]||0,l=r[t];return l==null&&(l=r[r.length-1]),{startY:o,endY:s,startX:c,endX:l}}function X_(e,t,n,r,i){e=R.clamp(e,0,n.length-1),t=R.clamp(t,0,r.length-1);let{startY:a,endY:o,startX:s,endX:c}=Y_(e,t,n,r);if(!i)return{startY:a,endY:o,startX:s,endX:c,isMerged:!1,isMergedMainCell:!1,actualRow:e,actualColumn:t,mergeInfo:{startY:a,endY:o,startX:s,endX:c,startRow:e,startColumn:t,endRow:e,endColumn:t}};let{isMerged:l,isMergedMainCell:u,startRow:d,startColumn:f,endRow:p,endColumn:m}=i,h={startRow:d,startColumn:f,endRow:p,endColumn:m,startY:a,endY:o,startX:s,endX:c},g=n.length-1,_=r.length-1;if(l&&d!==-1&&f!==-1){let e=n[d-1]||0,t=n[p]||n[g],i=r[f-1]||0,a=r[m]||r[_];h={...h,startY:e,endY:t,startX:i,endX:a}}else if(!l&&p!==-1&&m!==-1){let e=n[p]||n[g],t=r[m]||r[_];h={...h,startY:a,endY:e,startX:s,endX:t}}return{isMerged:l,isMergedMainCell:u,actualRow:e,actualColumn:t,startY:a,endY:o,startX:s,endX:c,mergeInfo:h}}function Z_(e,t,n,r){let{x:i}=n;return e/t+i-r}function Q_(e,t,n,r){let{y:i}=n;return e=e/t+i-r,e}let $_=[`script`,`style`,`meta`,`comment`,`link`],ev=function(e){return e[e.INFO=0]=`INFO`,e[e.STOP=1]=`STOP`,e[e.WARNING=2]=`WARNING`,e}({}),tv=function(e){return 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}({}),nv=function(e){return 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}({}),rv=function(e){return e[e.TEXT=0]=`TEXT`,e[e.ARROW=1]=`ARROW`,e[e.CUSTOM=2]=`CUSTOM`,e}({}),iv=function(e){return e.VALID=`valid`,e.INVALID=`invalid`,e.VALIDATING=`validating`,e}({}),av=function(e){return 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}({}),ov=class extends ra{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){let e=e=>{e.businesses.forEach(t=>{switch(t){case I.UNRECOGNIZED:case I.UNIVER_UNKNOWN:case I.UNIVER_SLIDE:case I.UNIVER_DOC:this._univerInstanceService.getAllUnitsForType(I.UNIVER_DOC).forEach(t=>{let n=(t.getSnapshot().resources||[]).find(t=>t.name===e.pluginName);if(n)try{let r=e.parseJson(n.data);e.onLoad(t.getUnitId(),r)}catch{console.error(`Load Document{${t.getUnitId()}} Resources{${e.pluginName}} Data Error.`)}});break;case I.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(I.UNIVER_SHEET).forEach(t=>{let n=(t.getSnapshot().resources||[]).find(t=>t.name===e.pluginName);if(n)try{let r=e.parseJson(n.data);e.onLoad(t.getUnitId(),r)}catch{console.error(`Load Workbook{${t.getUnitId()}} Resources{${e.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(t=>e(t)),this.disposeWithMe(this._resourceManagerService.register$.subscribe(t=>e(t))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(I.UNIVER_SHEET).subscribe(e=>{this._resourceManagerService.loadResources(e.getUnitId(),e.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(I.UNIVER_DOC).subscribe(e=>{ie(e.getUnitId())||this._resourceManagerService.loadResources(e.getUnitId(),e.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(I.UNIVER_SHEET).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),I.UNIVER_SHEET)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(I.UNIVER_DOC).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),I.UNIVER_DOC)}))}saveUnit(e){let t=this._univerInstanceService.getUnit(e);if(!t)return null;let n=this._resourceManagerService.getResources(e,t.type),r=R.deepClone(t.getSnapshot());return r.resources=n,r}};ov=Us([W(0,(0,t.Inject)(tg)),W(1,(0,t.Inject)(i_))],ov);var sv=class{get _univerInstanceService(){return this._injector.get(i_)}get _pluginService(){return this._injector.get(S_)}constructor(e={},t){P(this,`_startedTypes`,new Set),P(this,`_injector`,void 0),P(this,`_disposingCallbacks`,new na);let n=this._injector=cv(t,e==null?void 0:e.override),{theme:r,darkMode:i,locale:a,locales:o,logLevel:s,logCommandExecution:c}=e;r&&this._injector.get(T_).setTheme(r),i&&this._injector.get(T_).setDarkMode(i),o&&this._injector.get(d_).load(o),a&&this._injector.get(d_).setLocale(a),s&&this._injector.get(Bs).setLogLevel(s),c!==void 0&&this._injector.get(Fs).setConfig(Ws,c),this._init(n)}__getInjector(){return this._injector}onDispose(e){let t=this._disposingCallbacks.add(ta(e));return ta(()=>t.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(e){this._injector.get(d_).setLocale(e)}createUnit(e,t){return this._univerInstanceService.createUnit(e,t)}createUniverSheet(e){return this._injector.get(Bs).warn(`[Univer]`,`Univer.createUniverSheet is deprecated, use createUnit instead`),this._univerInstanceService.createUnit(I.UNIVER_SHEET,e)}createUniverDoc(e){return this._injector.get(Bs).warn(`[Univer]`,`Univer.createUniverDoc is deprecated, use createUnit instead`),this._univerInstanceService.createUnit(I.UNIVER_DOC,e)}createUniverSlide(e){return this._injector.get(Bs).warn(`[Univer]`,`Univer.createUniverSlide is deprecated, use createUnit instead`),this._univerInstanceService.createUnit(I.UNIVER_SLIDE,e)}_init(e){this._univerInstanceService.registerCtorForType(I.UNIVER_SHEET,n_),this._univerInstanceService.registerCtorForType(I.UNIVER_DOC,ch),this._univerInstanceService.registerCtorForType(I.UNIVER_SLIDE,r_);let t=e.get(i_);t.__setCreateHandler((n,r,i,a)=>{if(!this._startedTypes.has(n)){this._pluginService.startPluginsForType(n),this._startedTypes.add(n);let o=e.createInstance(i,r);return t.__addUnit(o,a),this._tryProgressToReady(),o}let o=e.createInstance(i,r);return t.__addUnit(o,a),o})}_tryProgressToReady(){this._injector.get(c_).stage<$.Ready&&(this._injector.get(c_).stage=$.Ready)}registerPlugin(e,t){this._pluginService.registerPlugin(e,t)}registerPlugins(e){e.forEach(e=>{let[t,n]=e;this._pluginService.registerPlugin(t,n)})}};function cv(e,n){let r=__([[gg],[d_],[T_],[c_],[S_],[ag],[i_,{useClass:a_}],[h_,{useClass:g_}],[Bs,{useClass:Vs,lazy:!0}],[Ks,{useClass:Ys}],[D_,{useClass:N_,lazy:!0}],[Fs,{useClass:Is}],[Ls,{useClass:Rs}],[tg,{useClass:w_,lazy:!0}],[C_,{useClass:ov,lazy:!0}],[sg,{useClass:og}],[p_,{useClass:f_,lazy:!0}]],n),i=e?e.createChild(r):new t.Injector(r);return se(i,[[ag],[C_]]),i}y(),e.ABCToNumber=Mp,e.AUTO_HEIGHT_FOR_MERGED_CELLS=ne,e.AbsoluteRefType=K,e.ActionIterator=Rm,e.AlignTypeH=as,e.AlignTypeV=os,e.ArrangeTypeEnum=ds,e.ArrowsAndMarkersShapes=ho,e.AsyncInterceptorManager=xe,e.AsyncLock=O.default,Object.defineProperty(e,`AuthzIoLocalService`,{enumerable:!0,get:function(){return og}}),e.AutoFillSeries=$a,e.BORDER_KEYS=bs,e.BORDER_STYLE_KEYS=ys,e.BaselineOffset=Do,e.BasicShapes=mo,e.BlockType=Io,e.BooleanNumber=B,e.BorderStyleTypes=z,e.BorderType=eo,e.BuildTextUtils=Vh,e.BulletAlignment=No,e.COLORS=dc,e.COLOR_STYLE_KEYS=vs,e.COMMAND_LOG_EXECUTION_CONFIG_KEY=Ws,e.CanceledError=ue,e.CellModeEnum=Rc,e.CellValueType=Oo,e.ColorKit=fc,e.ColorType=to,e.ColumnSeparatorType=Bo,Object.defineProperty(e,`CommandService`,{enumerable:!0,get:function(){return Ys}}),e.CommandType=Gs,e.CommonHideTypes=no,e.ConfigService=Is,e.ContextService=Rs,e.CopyPasteType=ro,e.CustomCommandExecutionError=le,e.CustomDecorationType=Fo,e.CustomRangeType=Po,e.DEFAULT_CELL=Bf,e.DEFAULT_DOC=oh,e.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=`__default_document_sub_component_id20231101__`,e.DEFAULT_EMPTY_DOCUMENT_VALUE=`\r
|
|
9
|
+
`,e.DEFAULT_NUMBER_FORMAT=`General`,e.DEFAULT_RANGE=Rf,e.DEFAULT_RANGE_ARRAY=Lf,e.DEFAULT_SELECTION=zf,e.DEFAULT_SLIDE=Hf,e.DEFAULT_STYLES=Vf,e.DEFAULT_TEXT_FORMAT=`@@@`,e.DEFAULT_TEXT_FORMAT_EXCEL=`@`,e.DEFAULT_WORKSHEET_COLUMN_COUNT=20,e.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=`DEFAULT_WORKSHEET_COLUMN_COUNT`,e.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=20,e.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=`DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT`,e.DEFAULT_WORKSHEET_COLUMN_WIDTH=88,e.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=`DEFAULT_WORKSHEET_COLUMN_WIDTH`,e.DEFAULT_WORKSHEET_ROW_COUNT=qg,e.DEFAULT_WORKSHEET_ROW_COUNT_KEY=`DEFAULT_WORKSHEET_ROW_COUNT`,e.DEFAULT_WORKSHEET_ROW_HEIGHT=24,e.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=`DEFAULT_WORKSHEET_ROW_HEIGHT`,e.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=46,e.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=`DEFAULT_WORKSHEET_ROW_TITLE_WIDTH`,e.DOCS_COMMENT_EDITOR_UNIT_ID_KEY=te,e.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=N,e.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=M,e.DOCS_ZEN_EDITOR_UNIT_ID_KEY=ee,e.DOC_DRAWING_PRINTING_COMPONENT_KEY=`univer-docs-drawing-printing`,e.DOC_RANGE_TYPE=Ic,e.DashStyleType=qo,e.DataStreamTreeNodeType=$m,e.DataStreamTreeTokenType=eh,e.DataValidationErrorStyle=ev,e.DataValidationImeMode=tv,e.DataValidationOperator=nv,e.DataValidationRenderMode=rv,e.DataValidationStatus=iv,e.DataValidationType=av,e.DeleteDirection=io,e.DependentOn=x_,e.DesktopLogService=Vs,e.DeveloperMetadataVisibility=ao,e.Dimension=oo,e.Direction=so,e.Disposable=ra,e.DisposableCollection=na,e.DocStyleType=jo,e.DocumentDataModel=ch,e.DocumentFlavor=Lo,e.DrawingTypeEnum=fs,e.EDITOR_ACTIVATED=mg,e.EXTENSION_NAMES=Kf,e.ErrorService=gg,e.EventState=Qh,e.EventSubject=$h,e.FOCUSING_COMMENT_EDITOR=`FOCUSING_COMMENT_EDITOR`,e.FOCUSING_COMMON_DRAWINGS=`FOCUSING_COMMON_DRAWINGS`,e.FOCUSING_DOC=fg,e.FOCUSING_EDITOR_BUT_HIDDEN=`FOCUSING_EDITOR_BUT_HIDDEN`,e.FOCUSING_EDITOR_INPUT_FORMULA=`FOCUSING_EDITOR_INPUT_FORMULA`,e.FOCUSING_EDITOR_STANDALONE=`FOCUSING_EDITOR_INPUT_FORMULA`,e.FOCUSING_FX_BAR_EDITOR=hg,e.FOCUSING_PANEL_EDITOR=`FOCUSING_PANEL_EDITOR`,e.FOCUSING_SHAPE_TEXT_EDITOR=`FOCUSING_SHAPE_TEXT_EDITOR`,e.FOCUSING_SHEET=dg,e.FOCUSING_SLIDE=pg,e.FOCUSING_UNIT=ug,e.FOCUSING_UNIVER_EDITOR=`FOCUSING_UNIVER_EDITOR`,e.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=`FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE`,e.FORMULA_EDITOR_ACTIVATED=`FORMULA_EDITOR_ACTIVATED`,e.FollowNumberWithType=Mo,e.FontItalic=To,e.FontStyleType=ts,e.FontWeight=Eo,e.GridType=Ro,e.HorizontalAlign=So,e.IAuthzIoService=sg,e.ICommandService=Ks,e.IConfigService=Fs,e.IConfirmService=cg,e.IContextService=Ls,e.IImageIoService=yg,e.ILocalStorageService=u_,e.ILogService=Bs,e.IMentionIOService=p_,e.IPermissionService=h_,e.IResourceLoaderService=C_,e.IResourceManagerService=tg,e.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE=`isRowStylePrecedeColumnStyle`,e.IURLImageService=bg,e.IUndoRedoService=D_,e.IUniverInstanceService=i_,e.ImageCacheMap=P_,e.ImageSourceType=_g,e.ImageUploadStatusType=vg,Object.defineProperty(e,`Inject`,{enumerable:!0,get:function(){return t.Inject}}),Object.defineProperty(e,`InjectSelf`,{enumerable:!0,get:function(){return t.InjectSelf}}),Object.defineProperty(e,`Injector`,{enumerable:!0,get:function(){return t.Injector}}),e.InterceptorEffectEnum=he,e.InterceptorManager=ve,e.InterpolationPointType=lo,Object.defineProperty(e,`JSON1`,{enumerable:!0,get:function(){return Ps}}),e.JSONX=Qm,e.LRUHelper=Nf,e.LRUMap=Mf,Object.defineProperty(e,`LifecycleService`,{enumerable:!0,get:function(){return c_}}),e.LifecycleStages=$,e.LifecycleUnreachableError=s_,e.ListGlyphType=V,Object.defineProperty(e,`LocalUndoRedoService`,{enumerable:!0,get:function(){return N_}}),e.LocaleService=d_,e.LocaleType=uo,e.LogLevel=zs,Object.defineProperty(e,`LookUp`,{enumerable:!0,get:function(){return t.LookUp}}),e.MAX_COLUMN_COUNT=If,e.MAX_ROW_COUNT=Ff,e.MOVE_BUFFER_VALUE=2,Object.defineProperty(e,`Many`,{enumerable:!0,get:function(){return t.Many}}),e.MemoryCursor=Ui,Object.defineProperty(e,`MentionIOLocalService`,{enumerable:!0,get:function(){return f_}}),e.MentionType=fo,e.NAMED_STYLE_MAP=Wf,e.NAMED_STYLE_SPACE_MAP=Gf,e.NamedStyleType=Go,e.NilCommand=Js,e.NumberUnitType=is,e.ObjectMatrix=Dd,e.ObjectRelativeFromH=ns,e.ObjectRelativeFromV=rs,Object.defineProperty(e,`Optional`,{enumerable:!0,get:function(){return t.Optional}}),e.OtherShapes=go,e.PADDING_KEYS=Ss,e.PAGE_SIZE=qf,e.PAPER_TYPES=us,e.PRESET_LIST_TYPE=um,e.PRINT_CHART_COMPONENT_KEY=`univer-sheets-chart-print-chart`,e.PageElementType=ms,e.PageOrientType=cs,e.PageType=ps,e.PaperType=ls,e.ParagraphElementType=Ho,e.ParagraphStyleBuilder=Yh,e.ParagraphStyleValue=Jh,e.PermissionService=g_,e.PermissionStatus=m_,e.Plugin=y_,Object.defineProperty(e,`PluginService`,{enumerable:!0,get:function(){return S_}}),e.PositionedObjectLayoutType=Wo,e.PresetListType=Z,e.ProtectionType=po,Object.defineProperty(e,`Quantity`,{enumerable:!0,get:function(){return t.Quantity}}),e.QuickListType=am,e.QuickListTypeMap=pm,e.RANGE_DIRECTION=Fc,e.RANGE_TYPE=G,e.RBush=$f,e.RCDisposable=aa,e.RGBA_PAREN=`rgba(`,e.RGB_PAREN=`rgb(`,e.ROTATE_BUFFER_VALUE=1,e.RTree=W_,e.Range=Yf,e.Rectangle=Tp,Object.defineProperty(e,`RediError`,{enumerable:!0,get:function(){return t.RediError}}),e.RedoCommand=M_,e.RedoCommandId=k_,e.RefAlias=Ap,e.Registry=Ji,e.RegistryAsMap=Yi,e.RelativeDate=vo,e.RelativeSlideLink=hs,Object.defineProperty(e,`ResourceManagerService`,{enumerable:!0,get:function(){return w_}}),e.RichTextBuilder=Zh,e.RichTextValue=Xh,e.RxDisposable=ia,e.SHEET_EDITOR_UNITS=Uf,e.STYLE_KEYS=Cs,e.SectionType=zo,Object.defineProperty(e,`Self`,{enumerable:!0,get:function(){return t.Self}}),Object.defineProperty(e,`SheetSkeleton`,{enumerable:!0,get:function(){return J_}}),e.SheetTypes=yo,e.SheetViewModel=Xg,Object.defineProperty(e,`Skeleton`,{enumerable:!0,get:function(){return q_}}),Object.defineProperty(e,`SkipSelf`,{enumerable:!0,get:function(){return t.SkipSelf}}),e.SliceBodyType=Cm,e.SlideDataModel=r_,e.SpacingRule=Ko,e.SpecialShapes=_o,e.Styles=wg,e.TEXT_DECORATION_KEYS=_s,e.TEXT_ROTATION_KEYS=xs,e.THEME_COLORS=zc,e.TabStopAlignment=Jo,e.TableAlignmentType=Xo,e.TableLayoutType=Zo,e.TableRowHeightRule=$o,e.TableSizeType=Yo,e.TableTextWrapType=Qo,e.TestConfirmService=lg,e.TextDecoration=xo,e.TextDecorationBuilder=qh,e.TextDirection=bo,e.TextDirectionType=Vo,e.TextStyleBuilder=Kh,e.TextStyleValue=Gh,e.TextX=Q,e.TextXActionType=U,e.ThemeColorType=ko,e.ThemeColors=Ao,e.ThemeService=T_,e.Tools=R,e.UndoCommand=j_,e.UndoCommandId=A_,e.UnitModel=Pa,e.Univer=sv,Object.defineProperty(e,`UniverInstanceService`,{enumerable:!0,get:function(){return a_}}),e.UniverInstanceType=I,e.UpdateDocsAttributeType=H,e.UserManagerService=ag,e.VerticalAlign=Co,e.VerticalAlignmentType=es,Object.defineProperty(e,`WithNew`,{enumerable:!0,get:function(){return t.WithNew}}),Object.defineProperty(e,`Workbook`,{enumerable:!0,get:function(){return n_}}),e.Worksheet=Qg,e.WrapStrategy=wo,e.WrapTextType=Uo,e.addLinkToDocumentModel=Mg,e.afterInitApply=ic,e.afterTime=nc,e.awaitTime=G_,e.binSearchFirstGreaterThanTarget=sc,e.binarySearchArray=oc,e.bufferDebounceTime=tc,e.cellToRange=Vd,e.characterSpacingControlType=ss,e.checkForSubstrings=Kd,e.checkIfMove=uc,e.checkParagraphHasBullet=pf,e.checkParagraphHasIndent=mf,e.checkParagraphHasIndentByStyle=hf,e.cloneCellData=zg,e.cloneCellDataMatrix=Vg,e.cloneCellDataWithSpanAndDisplay=Bg,e.cloneValue=Rg,e.cloneWorksheetData=Wg,e.codeToBlob=lc,e.columnLabelToNumber=Pf,e.composeBody=Im,e.composeInterceptors=_e,e.composeStyles=Xa,e.concatMatrixArray=Sd,e.convertCellToRange=Od,e.convertObservableToBehaviorSubject=rc,e.covertCellValue=Hd,e.covertCellValues=Ud,e.createAsyncInterceptorKey=ye,e.createDefaultUser=rg,e.createDocumentModelWithStyle=kg,Object.defineProperty(e,`createIdentifier`,{enumerable:!0,get:function(){return t.createIdentifier}}),e.createInterceptorKey=ge,e.createInternalEditorID=re,e.createREGEXFromWildChar=Qa,e.createRowColIter=jp,e.customNameCharacterCheck=I_,e.dayjs=nf.default,e.debounce=Mi,e.dedupe=x,e.dedupeBy=S,e.deepCompare=Wd,e.delayAnimationFrame=K_,e.deleteContent=_f,e.extractPureTextFromCell=$g,Object.defineProperty(e,`forwardRef`,{enumerable:!0,get:function(){return t.forwardRef}}),e.fromCallback=$s,e.fromEventSubject=eg,e.generateIntervalsByPoints=bf,e.generateRandomId=Ya,e.get=ti,e.getArrayLength=vd,e.getBodySlice=km,e.getBorderStyleType=Rd,e.getCellCoordByIndexSimple=Y_,e.getCellInfoInMergeData=Lc,e.getCellValueType=jc,e.getCellWithCoordByIndexCore=X_,e.getColorStyle=Nd,e.getCustomBlockSlice=Om,e.getCustomDecorationSlice=Mm,e.getCustomRangeSlice=jm,e.getDocsUpdateBody=zd,e.getEmptyCell=Pg,e.getIntersectRange=xp,e.getNumfmtParseValueFilter=gd,e.getOriginCellValue=e_,e.getParagraphsSlice=Em,e.getPlainText=rh,e.getReverseDirection=co,e.getSectionBreakSlice=Dm,e.getTableSlice=Tm,e.getTextRunSlice=wm,e.getTransformOffsetX=Z_,e.getTransformOffsetY=Q_,e.getWorksheetUID=t_,e.groupBy=T,e.handleStyleToString=Id,e.hashAlgorithm=yf,e.horizontalLineSegmentsSubtraction=ff,e.insertMatrixArray=bd,e.insertTextToContent=gf,e.invertColorByHSL=Ne,e.invertColorByMatrix=Ie,Object.defineProperty(e,`isAsyncDependencyItem`,{enumerable:!0,get:function(){return t.isAsyncDependencyItem}}),Object.defineProperty(e,`isAsyncHook`,{enumerable:!0,get:function(){return t.isAsyncHook}}),e.isBlackColor=Oc,e.isBooleanString=A,e.isCellCoverable=Md,e.isCellV=Nc,Object.defineProperty(e,`isClassDependencyItem`,{enumerable:!0,get:function(){return t.isClassDependencyItem}}),e.isCommentEditorID=ae,Object.defineProperty(e,`isCtor`,{enumerable:!0,get:function(){return t.isCtor}}),e.isDefaultFormat=dd,Object.defineProperty(e,`isDisposable`,{enumerable:!0,get:function(){return t.isDisposable}}),e.isEmptyCell=jd,Object.defineProperty(e,`isFactoryDependencyItem`,{enumerable:!0,get:function(){return t.isFactoryDependencyItem}}),e.isFormulaId=Fd,e.isFormulaString=Pd,e.isICellData=Ac,e.isInternalEditorID=ie,e.isNodeEnv=Za,e.isNotNullOrUndefined=Ng,e.isNullCell=Mc,e.isNumeric=Gi,e.isPatternEqualWithoutDecimal=fd,e.isRangesEqual=Tg,e.isRealNum=vf,e.isSafeNumeric=Ki,e.isSameStyleTextRun=Gd,e.isTextFormat=ud,e.isUnitRangesEqual=Eg,e.isValidRange=Bd,Object.defineProperty(e,`isValueDependencyItem`,{enumerable:!0,get:function(){return t.isValueDependencyItem}}),e.isWhiteColor=kc,e.makeArray=E,e.makeCellRangeToRangeData=Ad,e.makeCellToSelection=kd,e.makeCustomRangeStream=th,e.mapObjectMatrix=_d,e.merge=Bi,e.mergeIntervals=xf,e.mergeLocales=Sf,e.mergeOverrideWithDependencies=__,e.mergeSets=$i,e.mergeWith=zi,e.mergeWorksheetSnapshotWithDefault=Jg,e.mixinClass=Wi,e.moveMatrixArray=wd,e.moveRangeByOffset=mp,e.nameCharacterCheck=F_,e.normalizeBody=Am,e.normalizeTextRuns=zp,e.numberToABC=Np,e.numberToListABC=Fp,Object.defineProperty(e,`numfmt`,{enumerable:!0,get:function(){return Qu}}),e.queryObjectMatrix=kp,e.registerDependencies=oe,e.remove=b,e.repeatStringNumTimes=Pp,e.replaceInDocumentBody=Hh,e.requestImmediateMacroTask=Xi,e.resolveWithBasePath=Va,e.rotate=w,e.searchArray=cc,e.searchInOrderedArray=ac,e.selectionToArray=Pc,e.sequence=Qi,e.sequenceAsync=Zi,e.sequenceExecute=Zs,e.sequenceExecuteAsync=Qs,e.set=Hi,Object.defineProperty(e,`setDependencies`,{enumerable:!0,get:function(){return t.setDependencies}}),e.shallowEqual=ce,e.skipParseTagNames=$_,e.sliceMatrixArray=Cd,e.sortRules=Ip,e.sortRulesByDesc=Lp,e.sortRulesFactory=Rp,e.spliceArray=xd,e.splitIntoGrid=gp,e.takeAfter=ec,Object.defineProperty(e,`textDiff`,{enumerable:!0,get:function(){return _h.default}}),e.throttle=de,e.toDisposable=ta,e.touchDependencies=se,e.updateAttributeByDelete=zm,e.updateAttributeByInsert=Bm,e.willLoseNumericPrecision=qi});
|