@univerjs/core 0.9.3 → 0.9.4
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 +2 -2
- package/lib/es/index.js +6 -6
- package/lib/index.js +6 -6
- package/lib/umd/index.js +2 -2
- package/package.json +3 -3
package/lib/cjs/index.js
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
`)===r?ie.TRUE:ie.FALSE}const br=class br{constructor(t,n,r){p(this,"_range");p(this,"_worksheet");this._deps=r,this._range=n,this._worksheet=t}static foreach(t,n){const{startRow:r,startColumn:s,endRow:i,endColumn:o}=t;for(let a=r;a<=i;a++)for(let l=s;l<=o;l++)n(a,l)}getRangeData(){return this._range}getValue(){return this.getValues()[0][0]}getValues(){const{startRow:t,endRow:n,startColumn:r,endColumn:s}=this._range,i=[];for(let o=t;o<=n;o++){const a=[];for(let l=r;l<=s;l++)a.push(this.getMatrix().getValue(o,l)||null);i.push(a)}return i}getMatrix(){const{startRow:t,endRow:n,startColumn:r,endColumn:s}=this._range,i=this._worksheet.getCellMatrix(),o=new dt;for(let a=t;a<=n;a++)for(let l=r;l<=s;l++)o.setValue(a,l,i.getValue(a,l)||null);return o}getMatrixObject(){const{startRow:t,endRow:n,startColumn:r,endColumn:s}=this._range,i=this._worksheet.getCellMatrix(),o=new dt;for(let a=t;a<=n;a++)for(let l=r;l<=s;l++)o.setValue(a-t,l-r,i.getValue(a,l)||{});return o}getA1Notation(){const{startRow:t,endRow:n,startColumn:r,endColumn:s}=this._range;let i,o;return r<s?(i=q.numToWord(r+1)+(t+1),o=q.numToWord(s+1)+(n+1)):(i=q.numToWord(s+1)+(n+1),o=q.numToWord(r+1)+(t+1)),i===o?`${i}`:`${i}:${o}`}getBackground(){return this.getBackgrounds()[0][0]}getBackgrounds(){const t=this._deps.getStyles();return this.getValues().map(n=>n.map(r=>{var i;const s=t.getStyleByCell(r);return((i=s==null?void 0:s.bg)==null?void 0:i.rgb)||st.bg.rgb}))}getCell(t,n){const{startRow:r,startColumn:s}=this._range,i={startRow:r+t,endRow:r+t,startColumn:s+n,endColumn:s+n};return new br(this._worksheet,i,this._deps)}getColumn(){return this._range.startColumn}getObjectValue(t={}){return this.getObjectValues(t)[0][0]}getObjectValues(t={}){var a;const{startRow:n,endRow:r,startColumn:s,endColumn:i}=this._range,o=this._worksheet.getCellMatrix().getFragment(n,r,s,i).getData();if(t.isIncludeStyle){const l=this._deps.getStyles();for(let c=0;c<=r-n;c++)for(let u=0;u<=i-s;u++){if(o==null||((a=o==null?void 0:o[c])==null?void 0:a[u])==null)continue;const h=o[c][u].s;h&&(o[c][u].s=l.get(h))}}return o}getFontColor(){return this.getFontColors()[0][0]}getFontColors(){const t=this._deps.getStyles();return this.getValues().map(n=>n.map(r=>{var i;const s=t.getStyleByCell(r);return((i=s==null?void 0:s.cl)==null?void 0:i.rgb)||st.cl.rgb}))}getFontFamilies(){return this._getStyles("ff")}getFontFamily(){return this.getFontFamilies()[0][0]}getUnderlines(){return this._getStyles("ul")}getUnderline(){var n,r;const{p:t}=(n=this.getValue())!=null?n:{};return t&&Array.isArray((r=t.body)==null?void 0:r.textRuns)&&t.body.textRuns.length>0?Qr("ul",t.body)===ie.TRUE?{s:ie.TRUE}:{s:ie.FALSE}:this.getUnderlines()[0][0]}getOverlines(){return this._getStyles("ol")}getOverline(){return this.getOverlines()[0][0]}getStrikeThrough(){var n,r;const{p:t}=(n=this.getValue())!=null?n:{};return t&&Array.isArray((r=t.body)==null?void 0:r.textRuns)&&t.body.textRuns.length>0?Qr("st",t.body)===ie.TRUE?{s:ie.TRUE}:{s:ie.FALSE}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles("st")}getFontSize(){var n,r;const t=((n=this.getValue())==null?void 0:n.p)||{};return t&&Array.isArray((r=t.body)==null?void 0:r.textRuns)&&t.body.textRuns.length>0?t.body.textRuns.some(s=>{var i;return((i=s==null?void 0:s.ts)==null?void 0:i.fs)!=null})?Math.max(...t.body.textRuns.map(s=>{var i;return((i=s==null?void 0:s.ts)==null?void 0:i.fs)||0})):this.getFontSizes()[0][0]:this.getFontSizes()[0][0]}getFontSizes(){return this._getStyles("fs")}getBorder(){return this.getBorders()[0][0]}getBorders(){return this._getStyles("bd")}getFontStyle(){var n,r;const{p:t}=(n=this.getValue())!=null?n:{};return t&&Array.isArray((r=t.body)==null?void 0:r.textRuns)&&t.body.textRuns.length>0?Qr("it",t.body)===ie.TRUE?ws.ITALIC:ws.NORMAL:this._getFontStyles()[0][0]}_getFontStyles(){return this._getStyles("it")}getFontWeight(){var n,r;const{p:t}=(n=this.getValue())!=null?n:{};return t&&Array.isArray((r=t.body)==null?void 0:r.textRuns)&&t.body.textRuns.length>0?Qr("bl",t.body)===ie.TRUE?bs.BOLD:bs.NORMAL:this._getFontWeights()[0][0]}_getFontWeights(){return this._getStyles("bl")}getGridId(){return this._worksheet.getSheetId()}getHeight(){const{_range:t,_worksheet:n}=this,{startRow:r,endRow:s}=t;let i=0;for(let o=0;o<=s-r;o++){const a=n.getRowHeight(o);i+=a}return i}getHorizontalAlignment(){return this.getHorizontalAlignments()[0][0]}getHorizontalAlignments(){return this._getStyles("ht")}getLastColumn(){return this._range.endColumn}getLastRow(){return this._range.endRow}getNumColumns(){const{startColumn:t,endColumn:n}=this._range;return n-t+1}getNumRows(){const{startRow:t,endRow:n}=this._range;return n-t+1}getRichTextValue(){return this.getRichTextValues()[0][0]}getRichTextValues(){return this.getValues().map(t=>t.map(n=>(n==null?void 0:n.p)||""))}getRowIndex(){return this._range.startRow}getSheet(){return this._worksheet}getTextDirection(){return this.getTextDirections()[0][0]}getTextDirections(){return this._getStyles("td")}getTextRotation(){return this.getTextRotations()[0][0]}getTextRotations(){return this._getStyles("tr")}getTextStyle(){return this.getTextStyles()[0][0]}getTextStyles(){const t=this._deps.getStyles();return this.getValues().map(n=>n.map(r=>t.getStyleByCell(r)))}getVerticalAlignment(){return this.getVerticalAlignments()[0][0]}getVerticalAlignments(){return this._getStyles("vt")}getWidth(){const{_range:t,_worksheet:n}=this,{startColumn:r,endColumn:s}=t;let i=0;for(let o=0;o<=s-r;o++)i+=n.getColumnWidth(o);return i}getWrap(){return this.getWrapStrategy()===Rn.WRAP?ie.TRUE:ie.FALSE}getWrapStrategies(){return this._getStyles("tb")}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(t){br.foreach(this._range,t)}_getStyles(t){const n=this._deps.getStyles();return this.getValues().map(r=>r.map(s=>{const i=n&&n.getStyleByCell(s);return i&&i[t]||st[t]}))}};p(br,"transformRange",(t,n)=>{const r=n.getMaxColumns()-1,s=n.getMaxRows()-1;return t.rangeType===_e.ALL?{startColumn:0,startRow:0,endColumn:r,endRow:s}:t.rangeType===_e.COLUMN?{startRow:0,endRow:s,startColumn:t.startColumn,endColumn:t.endColumn}:t.rangeType===_e.ROW?{startColumn:0,endColumn:r,startRow:t.startRow,endRow:t.endRow}:{startColumn:t.startColumn,endColumn:Math.min(t.endColumn,r),startRow:t.startRow,endRow:Math.min(t.endRow,s)}});let Vn=br;function Du(e,t,n=0,r=e.length-1,s=g_){for(;r>n;){if(r-n>600){const l=r-n+1,c=t-n+1,u=Math.log(l),h=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*h*(l-h)/l)*(c-l/2<0?-1:1),f=Math.max(n,Math.floor(t-c*h/l+d)),g=Math.min(r,Math.floor(t+(l-c)*h/l+d));Du(e,t,f,g,s)}const i=e[t];let o=n,a=r;for(nr(e,n,t),s(e[r],i)>0&&nr(e,n,r);o<a;){for(nr(e,o,a),o++,a--;s(e[o],i)<0;)o++;for(;s(e[a],i)>0;)a--}s(e[n],i)===0?nr(e,n,a):(a++,nr(e,a,r)),a<=t&&(n=a+1),t<=a&&(r=a-1)}}function nr(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function g_(e,t){return e<t?-1:e>t?1:0}class Ms{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let n=this.data;const r=[];if(!ts(t,n))return r;const s=this.toBBox,i=[];for(;n;){for(let o=0;o<n.children.length;o++){const a=n.children[o],l=n.leaf?s(a):a;ts(t,l)&&(n.leaf?r.push(a):mi(t,l)?this._all(a,r):i.push(a))}n=i.pop()}return r}collides(t){let n=this.data;if(!ts(t,n))return!1;const r=[];for(;n;){for(let s=0;s<n.children.length;s++){const i=n.children[s],o=n.leaf?this.toBBox(i):i;if(ts(t,o)){if(n.leaf||mi(t,o))return!0;r.push(i)}}n=r.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let r=0;r<t.length;r++)this.insert(t[r]);return this}let n=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=n;else if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){const r=this.data;this.data=n,n=r}this._insert(n,this.data.height-n.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Dn([]),this}remove(t,n){if(!t)return this;let r=this.data;const s=this.toBBox(t),i=[],o=[];let a,l,c;for(;r||i.length;){if(r||(r=i.pop(),l=i[i.length-1],a=o.pop(),c=!0),r.leaf){const u=__(t,r.children,n);if(u!==-1)return r.children.splice(u,1),i.push(r),this._condense(i),this}!c&&!r.leaf&&mi(r,s)?(i.push(r),o.push(a),a=0,l=r,r=r.children[0]):l?(a++,r=l.children[a],c=!1):r=null}return this}toBBox(t){return t}compareMinX(t,n){return t.minX-n.minX}compareMinY(t,n){return t.minY-n.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,n){const r=[];for(;t;)t.leaf?n.push(...t.children):r.push(...t.children),t=r.pop();return n}_build(t,n,r,s){const i=r-n+1;let o=this._maxEntries,a;if(i<=o)return a=Dn(t.slice(n,r+1)),Tn(a,this.toBBox),a;s||(s=Math.ceil(Math.log(i)/Math.log(o)),o=Math.ceil(i/Math.pow(o,s-1))),a=Dn([]),a.leaf=!1,a.height=s;const l=Math.ceil(i/o),c=l*Math.ceil(Math.sqrt(o));ka(t,n,r,c,this.compareMinX);for(let u=n;u<=r;u+=c){const h=Math.min(u+c-1,r);ka(t,u,h,l,this.compareMinY);for(let d=u;d<=h;d+=l){const f=Math.min(d+l-1,h);a.children.push(this._build(t,d,f,s-1))}}return Tn(a,this.toBBox),a}_chooseSubtree(t,n,r,s){for(;s.push(n),!(n.leaf||s.length-1===r);){let i=1/0,o=1/0,a;for(let l=0;l<n.children.length;l++){const c=n.children[l],u=fi(c),h=C_(t,c)-u;h<o?(o=h,i=u<i?u:i,a=c):h===o&&u<i&&(i=u,a=c)}n=a||n.children[0]}return n}_insert(t,n,r){const s=r?t:this.toBBox(t),i=[],o=this._chooseSubtree(s,this.data,n,i);for(o.children.push(t),Er(o,s);n>=0&&i[n].children.length>this._maxEntries;)this._split(i,n),n--;this._adjustParentBBoxes(s,i,n)}_split(t,n){const r=t[n],s=r.children.length,i=this._minEntries;this._chooseSplitAxis(r,i,s);const o=this._chooseSplitIndex(r,i,s),a=Dn(r.children.splice(o,r.children.length-o));a.height=r.height,a.leaf=r.leaf,Tn(r,this.toBBox),Tn(a,this.toBBox),n?t[n-1].children.push(a):this._splitRoot(r,a)}_splitRoot(t,n){this.data=Dn([t,n]),this.data.height=t.height+1,this.data.leaf=!1,Tn(this.data,this.toBBox)}_chooseSplitIndex(t,n,r){let s,i=1/0,o=1/0;for(let a=n;a<=r-n;a++){const l=pr(t,0,a,this.toBBox),c=pr(t,a,r,this.toBBox),u=R_(l,c),h=fi(l)+fi(c);u<i?(i=u,s=a,o=h<o?h:o):u===i&&h<o&&(o=h,s=a)}return s||r-n}_chooseSplitAxis(t,n,r){const s=t.leaf?this.compareMinX:p_,i=t.leaf?this.compareMinY:E_,o=this._allDistMargin(t,n,r,s),a=this._allDistMargin(t,n,r,i);o<a&&t.children.sort(s)}_allDistMargin(t,n,r,s){t.children.sort(s);const i=this.toBBox,o=pr(t,0,n,i),a=pr(t,r-n,r,i);let l=es(o)+es(a);for(let c=n;c<r-n;c++){const u=t.children[c];Er(o,t.leaf?i(u):u),l+=es(o)}for(let c=r-n-1;c>=n;c--){const u=t.children[c];Er(a,t.leaf?i(u):u),l+=es(a)}return l}_adjustParentBBoxes(t,n,r){for(let s=r;s>=0;s--)Er(n[s],t)}_condense(t){for(let n=t.length-1,r;n>=0;n--)t[n].children.length===0?n>0?(r=t[n-1].children,r.splice(r.indexOf(t[n]),1)):this.clear():Tn(t[n],this.toBBox)}}function __(e,t,n){if(!n)return t.indexOf(e);for(let r=0;r<t.length;r++)if(n(e,t[r]))return r;return-1}function Tn(e,t){pr(e,0,e.children.length,t,e)}function pr(e,t,n,r,s){s||(s=Dn(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let i=t;i<n;i++){const o=e.children[i];Er(s,e.leaf?r(o):o)}return s}function Er(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function p_(e,t){return e.minX-t.minX}function E_(e,t){return e.minY-t.minY}function fi(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function es(e){return e.maxX-e.minX+(e.maxY-e.minY)}function C_(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function R_(e,t){const n=Math.max(e.minX,t.minX),r=Math.max(e.minY,t.minY),s=Math.min(e.maxX,t.maxX),i=Math.min(e.maxY,t.maxY);return Math.max(0,s-n)*Math.max(0,i-r)}function mi(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function ts(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function Dn(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function ka(e,t,n,r,s){const i=[t,n];for(;i.length;){if(n=i.pop(),t=i.pop(),n-t<=r)continue;const o=t+Math.ceil((n-t)/r/2)*r;Du(e,o,t,n,s),i.push(t,o,o,n)}}function I_(e,t,n,r=!1){if(t===0&&n===0)return e;let s={...e};const i=s.startAbsoluteRefType||Ne.NONE,o=s.endAbsoluteRefType||Ne.NONE,a=s.rangeType||_e.NORMAL;if(!r&&i===Ne.ALL&&o===Ne.ALL)return s;const l=Fa(s.startRow,n,s.startColumn,t,a),c=Fa(s.endRow,n,s.endColumn,t,a);return r||i===Ne.NONE&&o===Ne.NONE?s={...s,startRow:l.row,startColumn:l.column,endRow:c.row,endColumn:c.column}:(i===Ne.NONE?s={...s,startRow:l.row,startColumn:l.column}:i===Ne.COLUMN?s={...s,startRow:l.row}:i===Ne.ROW&&(s={...s,startColumn:l.column}),o===Ne.NONE?s={...s,endRow:c.row,endColumn:c.column}:o===Ne.COLUMN?s={...s,endRow:c.row}:o===Ne.ROW&&(s={...s,endColumn:c.column}),s)}function Fa(e,t,n,r,s){return s===_e.NORMAL?{row:e+t,column:n+r}:s===_e.ROW?{row:e+t,column:n}:s===_e.COLUMN?{row:e,column:n+r}:{row:e,column:n}}function Go(e){const t=new Set,n=new Set;for(const o of e)t.add(o.startColumn),t.add(o.endColumn+1),n.add(o.startRow),n.add(o.endRow+1);const r=Array.from(t).sort((o,a)=>o-a),s=Array.from(n).sort((o,a)=>o-a);e.sort((o,a)=>o.startRow-a.startRow||o.startColumn-a.startColumn);const i=[];for(let o=0;o<s.length-1;o++)for(let a=0;a<r.length-1;a++){const l=r[a],c=r[a+1]-1,u=s[o],h=s[o+1]-1;for(const d of e){if(d.startRow>h)break;if(d.startRow<=u&&d.endRow>=h&&d.startColumn<=l&&d.endColumn>=c){i.push({startColumn:l,endColumn:c,startRow:u,endRow:h});break}}}return i}function S_(e){e.sort((r,s)=>r.startRow-s.startRow||r.startColumn-s.startColumn);const t={};for(const r of e)t[r.startRow]||(t[r.startRow]=[]),t[r.startRow].push(r);const n=[];for(const r in t){const s=t[+r];s.sort((o,a)=>o.startColumn-a.startColumn);let i=s[0];for(let o=1;o<s.length;o++){const a=s[o];a.startColumn<=i.endColumn+1&&a.startRow===i.startRow&&a.endRow===i.endRow?i.endColumn=Math.max(i.endColumn,a.endColumn):(n.push(i),i=a)}n.push(i)}return n}function O_(e){e.sort((r,s)=>r.startColumn-s.startColumn||r.startRow-s.startRow);const t={};for(const r of e)t[r.startColumn]||(t[r.startColumn]=[]),t[r.startColumn].push(r);const n=[];for(const r in t){const s=t[+r];s.sort((o,a)=>o.startRow-a.startRow);let i=s[0];for(let o=1;o<s.length;o++){const a=s[o];a.startRow<=i.endRow+1&&a.startColumn===i.startColumn&&a.endColumn===i.endColumn?i.endRow=Math.max(i.endRow,a.endRow):(n.push(i),i=a)}n.push(i)}return n}function v_(e){const t=Go(e),n=S_(t);return O_(n)}function w_(e,t){const n=[];return e.forEach(r=>{n.push(...on.subtract(r,t))}),on.mergeRanges(n)}function xu(e,t){const n=Ba(e.startRow,e.endRow,t.startRow,t.endRow),r=Ba(e.startColumn,e.endColumn,t.startColumn,t.endColumn);if(!n||!r)return null;const[s,i]=n,[o,a]=r,l=b_(e.rangeType,t.rangeType,s,i,o,a);return{startRow:s,endRow:i,startColumn:o,endColumn:a,rangeType:l}}function Ba(e,t,n,r){const s=isNaN(e)?-1/0:e,i=isNaN(t)?1/0:t,o=isNaN(n)?-1/0:n,a=isNaN(r)?1/0:r,l=Math.max(s,o),c=Math.min(i,a);if(l<=c){const u=l===-1/0?Number.NaN:l,h=c===1/0?Number.NaN:c;return[u,h]}else return null}function b_(e,t,n,r,s,i){const o=e!==void 0?e:$a(n,r,s,i),a=t!==void 0?t:$a(n,r,s,i);return o===_e.ALL||a===_e.ALL?o===a?o:o===_e.ALL?a:o:o===a?o:(o===_e.NORMAL||a===_e.NORMAL,_e.NORMAL)}function $a(e,t,n,r){const s=!isNaN(e)&&!isNaN(t),i=!isNaN(n)&&!isNaN(r);return s&&i?_e.NORMAL:s?_e.ROW:i?_e.COLUMN:_e.ALL}const Wt=class Wt{static clone(t){return t.rangeType!==void 0?{startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn,rangeType:t.rangeType}:{startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn}}static equals(t,n){return t==null||n==null?!1:t.endRow===n.endRow&&t.endColumn===n.endColumn&&t.startRow===n.startRow&&t.startColumn===n.startColumn&&(t.rangeType===n.rangeType||t.rangeType===void 0&&n.rangeType===_e.NORMAL||n.rangeType===void 0&&t.rangeType===_e.NORMAL)}static simpleRangesIntersect(t,n){const{startRow:r,endRow:s,startColumn:i,endColumn:o}=t,{startRow:a,endRow:l,startColumn:c,endColumn:u}=n,h=r<=l&&s>=a,d=i<=u&&o>=c;return h&&d}static intersects(t,n){if(t.rangeType===_e.ROW&&n.rangeType===_e.COLUMN||t.rangeType===_e.COLUMN&&n.rangeType===_e.ROW)return!0;if(t.rangeType===_e.ROW&&n.rangeType===_e.ROW)return t.startRow<=n.endRow&&t.endRow>=n.startRow;if(t.rangeType===_e.COLUMN&&n.rangeType===_e.COLUMN)return t.startColumn<=n.endColumn&&t.endColumn>=n.startColumn;const r=Math.floor(Number.MAX_SAFE_INTEGER/10),s=Number.isNaN(t.startRow)?0:t.startRow,i=Number.isNaN(t.endRow)?r:t.endRow,o=Number.isNaN(t.startColumn)?0:t.startColumn,a=Number.isNaN(t.endColumn)?r:t.endColumn,l=Number.isNaN(n.startRow)?0:n.startRow,c=Number.isNaN(n.endRow)?r:n.endRow,u=Number.isNaN(n.startColumn)?0:n.startColumn,h=Number.isNaN(n.endColumn)?r:n.endColumn,d=Math.abs(o+a-u-h),f=Math.abs(o-a)+Math.abs(u-h),g=Math.abs(s+i-l-c),_=Math.abs(s-i)+Math.abs(l-c);return d<=f&&g<=_}static doAnyRangesIntersect(t,n){const r=new Ms;return r.load(t.map(s=>({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow}))),n.some(s=>r.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow}).length>0)}static getIntersects(t,n){const r=t.startRow,s=t.endRow,i=t.startColumn,o=t.endColumn,a=n.startRow,l=n.endRow,c=n.startColumn,u=n.endColumn;let h,d,f,g;if(a<=s)a>=r?d=a:d=r;else return null;if(l>=r)l>=s?g=s:g=l;else return null;if(c<=o)c>i?h=c:h=i;else return null;if(u>=i)u>=o?f=o:f=u;else return null;return{startRow:d,endRow:g,startColumn:h,endColumn:f,rangeType:_e.NORMAL}}static contains(t,n){return t.startRow<=n.startRow&&t.endRow>=n.endRow&&t.startColumn<=n.startColumn&&t.endColumn>=n.endColumn}static realContain(t,n){return Wt.contains(t,n)&&(t.startRow<n.startRow||t.endRow>n.endRow||t.startColumn<n.startColumn||t.endColumn>n.endColumn)}static union(...t){return t.reduce((n,r)=>({startRow:Math.min(n.startRow,r.startRow),startColumn:Math.min(n.startColumn,r.startColumn),endRow:Math.max(n.endRow,r.endRow),endColumn:Math.max(n.endColumn,r.endColumn),rangeType:_e.NORMAL}),t[0])}static realUnion(...t){const n=t.some(i=>i.rangeType===_e.COLUMN),r=t.some(i=>i.rangeType===_e.ROW),s=Wt.union(...t);return{startColumn:r?Number.NaN:s.startColumn,endColumn:r?Number.NaN:s.endColumn,startRow:n?Number.NaN:s.startRow,endRow:n?Number.NaN:s.endRow,rangeType:r?_e.ROW:n?_e.COLUMN:_e.NORMAL}}static subtract(t,n){if(n.startRow>t.endRow||n.endRow<t.startRow||n.startColumn>t.endColumn||n.endColumn<t.startColumn)return[t];const r=[];n.startRow>=t.startRow&&r.push({startRow:t.startRow,startColumn:t.startColumn,endRow:n.startRow-1,endColumn:t.endColumn}),n.endRow<=t.endRow&&r.push({startRow:n.endRow+1,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn});const s=Math.max(t.startRow,n.startRow),i=Math.min(t.endRow,n.endRow);return n.startColumn>=t.startColumn&&r.push({startRow:s,startColumn:t.startColumn,endRow:i,endColumn:n.startColumn-1}),n.endColumn<=t.endColumn&&r.push({startRow:s,startColumn:n.endColumn+1,endRow:i,endColumn:t.endColumn}),r.filter(a=>a.startRow<=a.endRow&&a.startColumn<=a.endColumn)}static mergeRanges(t){return v_(t)}static splitIntoGrid(t){return Go(t)}static subtractMulti(t,n){if(!n.length)return t;let r=t;return n.forEach(s=>{r=w_(r,s)}),r}static hasIntersectionBetweenTwoRect(t,n){return!(t.left>n.right||t.right<n.left||t.top>n.bottom||t.bottom<n.top)}static getIntersectionBetweenTwoRect(t,n){const r=Math.max(t.left,n.left),s=Math.min(t.right,n.right),i=Math.max(t.top,n.top),o=Math.min(t.bottom,n.bottom);return s<=r||o<=i?null:{left:r,right:s,top:i,bottom:o,width:s-r,height:o-i}}static sort(t){return t.sort((n,r)=>n.startRow-r.startRow||n.startColumn-r.startColumn)}};p(Wt,"getRelativeRange",(t,n)=>({startRow:t.startRow-n.startRow,endRow:t.endRow-t.startRow,startColumn:t.startColumn-n.startColumn,endColumn:t.endColumn-t.startColumn})),p(Wt,"getPositionRange",(t,n,r)=>({...r||{},startRow:r&&[Ne.ROW,Ne.ALL].includes(r.startAbsoluteRefType||0)?r.startRow:t.startRow+n.startRow,endRow:r&&[Ne.ROW,Ne.ALL].includes(r.endAbsoluteRefType||0)?r.endRow:t.endRow+t.startRow+n.startRow,startColumn:r&&[Ne.COLUMN,Ne.ALL].includes(r.startAbsoluteRefType||0)?r.startColumn:t.startColumn+n.startColumn,endColumn:r&&[Ne.COLUMN,Ne.ALL].includes(r.endAbsoluteRefType||0)?r.endColumn:t.endColumn+t.startColumn+n.startColumn})),p(Wt,"moveHorizontal",(t,n=0,r=0)=>({...t,startColumn:t.startColumn+n,endColumn:t.endColumn+n+r})),p(Wt,"moveVertical",(t,n=0,r=0)=>({...t,startRow:t.startRow+n,endRow:t.endRow+n+r})),p(Wt,"moveOffset",(t,n,r)=>{const s={...t};switch(t.startAbsoluteRefType){case Ne.ROW:s.startColumn+=n;break;case Ne.COLUMN:s.startRow+=r;break;case Ne.ALL:break;case Ne.NONE:default:s.startRow+=r,s.startColumn+=n;break}switch(t.endAbsoluteRefType){case Ne.ROW:s.endColumn+=n;break;case Ne.COLUMN:s.endRow+=r;break;case Ne.ALL:break;case Ne.NONE:default:s.endRow+=r,s.endColumn+=n;break}return s});let on=Wt;function A_(e,t){if(e.length===0||e[0].length===0)return null;const n=new Array(e[0].length).fill(0);let r=0,s=null;for(let i=0;i<e.length;i++){for(let a=0;a<e[0].length;a++)n[a]=t(e[i][a])?n[a]+1:0;const o=T_(n);o.area>r&&(r=o.area,s={startColumn:o.start,startRow:i-o.height+1,endColumn:o.end,endRow:i})}return s}function T_(e){const t=[];let n=0,r={area:0,height:0,start:0,end:0},s=0;for(;s<e.length;)if(t.length===0||e[s]>=e[t[t.length-1]])t.push(s++);else{const i=e[t.pop()],o=t.length===0?s:s-t[t.length-1]-1;i*o>n&&(n=i*o,r={area:n,height:i,start:t.length===0?0:t[t.length-1]+1,end:s-1})}for(;t.length>0;){const i=e[t.pop()],o=t.length===0?s:s-t[t.length-1]-1;i*o>n&&(n=i*o,r={area:n,height:i,start:t.length===0?0:t[t.length-1]+1,end:s-1})}return r}function y_(e,t){Vn.foreach(t,(n,r)=>{e[n][r]=void 0})}function N_(e,t){const n=e.toFullArray(),r=[];for(;;){const s=A_(n,t);if(!s)break;r.push(s),y_(n,s)}return r}class M_{constructor(t,n){p(this,"_values",[]);p(this,"_keys",[]);p(this,"_keyMaps",new Map);this._values=t,this._keys=n,t.forEach(r=>{this._initKeyMap(r)})}_initKeyMap(t){this._keys.forEach(n=>{const r=t[n],s=this._keyMaps.get(n)||new Map;s.set(r,t),this._keyMaps.set(n,s)})}getValue(t,n){const r=n||this._keys;for(let s=0;s<r.length;s++){const i=this._keyMaps.get(r[s]);if(i!=null&&i.has(t))return i.get(t)}return null}hasValue(t){for(let n=0;n<this._keys.length;n++){const r=this._keyMaps.get(this._keys[n]);if(r!=null&&r.has(t))return!0}return!1}addValue(t){this._values.push(t),this._initKeyMap(t)}setValue(t,n,r){const s=this.getValue(t);s&&Object.keys(s).includes(n)&&(s[n]=r)}deleteValue(t,n){const r=this.getValue(t,n);if(r){this._keys.forEach(i=>{const o=this._keyMaps.get(i),a=r[i];o==null||o.delete(a)});const s=this._values.findIndex(i=>i===r);this._values.splice(s,1)}}getValues(){return this._values}getKeyMap(t){var n;return[...((n=this._keyMaps.get(t))==null?void 0:n.keys())||[]]}clear(){this._values=[],this._keys=[],this._keyMaps.clear()}}function $i(e,t,n,r){return{forEach(s){for(let i=e;i<=t;i++)for(let o=n;o<=r;o++)s(i,o)}}}function L_(e){if(e==null||e.length===0)return Number.NaN;const t=e.toLowerCase().split(""),n=t.length,r=o=>o.charCodeAt(0)-96;let s=0,i=0;for(let o=0;o<n;o++)i=r(t[o]),s+=i*26**(n-o-1);return s===0?Number.NaN:s-1}const Ls=65,Uu=90,D_=97;function x_(e){const t=Uu-Ls+1;let n="";for(;e>=0;)n=String.fromCharCode(e%t+Ls)+n,e=Math.floor(e/t)-1;return n}function Pu(e,t){let n="";for(;t>0;)n+=e,t--;return n}function U_(e,t=!1){const n=Uu-Ls+1;let r=D_;t&&(r=Ls);const s=String.fromCharCode(e%n+r),i=Math.floor(e/n)+1;return Pu(s,i)}function P_(e,t){return e.zIndex>t.zIndex?1:e.zIndex===t.zIndex?0:-1}function k_(e,t){return e.zIndex>t.zIndex?-1:e.zIndex===t.zIndex?0:1}function Hr(e="index",t=1){return(n,r)=>n[e]>r[e]?t:n[e]===r[e]?0:-t}var ve=(e=>(e[e.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",e[e.UNIVER_DOC=1]="UNIVER_DOC",e[e.UNIVER_SHEET=2]="UNIVER_SHEET",e[e.UNIVER_SLIDE=3]="UNIVER_SLIDE",e[e.UNIVER_PROJECT=4]="UNIVER_PROJECT",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(ve||{}),Ut=(e=>(e[e.Reader=0]="Reader",e[e.Editor=1]="Editor",e[e.Owner=2]="Owner",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(Ut||{}),Hi=(e=>(e[e.SomeCollaborator=0]="SomeCollaborator",e[e.AllCollaborator=1]="AllCollaborator",e[e.OneSelf=2]="OneSelf",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(Hi||{});class Gs extends Ke{}function F_(e=tt(6),t=Br.EN_US,n=""){return{id:e,locale:t,title:n,tableSource:{},drawings:{},drawingsOrder:[],headers:{},footers:{},body:{dataStream:`\r
|
|
4
4
|
`,textRuns:[],customBlocks:[],tables:[],paragraphs:[{startIndex:0,paragraphStyle:{spaceAbove:{v:5},lineSpacing:1,spaceBelow:{v:0}}}],sectionBreaks:[{startIndex:1}]},documentStyle:{pageSize:{width:793.3333333333334,height:1122.6666666666667},documentFlavor:Wo.TRADITIONAL,marginTop:50,marginBottom:50,marginRight:50,marginLeft:50,renderConfig:{zeroWidthParagraphBreak:ie.FALSE,vertexAngle:0,centerAngle:0,background:{rgb:"#ccc"}},autoHyphenation:ie.TRUE,doNotHyphenateCaps:ie.FALSE,consecutiveHyphenLimit:2,defaultHeaderId:"",defaultFooterId:"",evenPageHeaderId:"",evenPageFooterId:"",firstPageHeaderId:"",firstPageFooterId:"",evenAndOddHeaders:ie.FALSE,useFirstPageHeaderFooter:ie.FALSE,marginHeader:30,marginFooter:30},settings:{}}}var mn={},rr={},ns={},Ha;function B_(){if(Ha)return ns;Ha=1,Object.defineProperty(ns,"__esModule",{value:!0});function e(r,s){if(Array.isArray(s))return!1;for(let i in r)if(!n(r[i],s[i]))return!1;for(let i in s)if(r[i]===void 0)return!1;return!0}function t(r,s){if(!Array.isArray(s)||r.length!==s.length)return!1;for(let i=0;i<r.length;i++)if(!n(r[i],s[i]))return!1;return!0}function n(r,s){return r===s?!0:r===null||s===null||typeof r!="object"||typeof s!="object"?!1:Array.isArray(r)?t(r,s):e(r,s)}return ns.default=n,ns}var rs={},ja;function $_(){if(ja)return rs;ja=1,Object.defineProperty(rs,"__esModule",{value:!0});function e(t){if(t===null)return null;if(Array.isArray(t))return t.map(e);if(typeof t=="object"){const n={};for(let r in t)n[r]=e(t[r]);return n}else return t}return rs.default=e,rs}var gi={},Wa;function ku(){return Wa||(Wa=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.eachChildOf=e.advancer=e.readCursor=e.writeCursor=e.WriteCursor=e.ReadCursor=e.isValidPathItem=void 0;function t(u,h){if(!u)throw new Error(h)}const n=u=>u!=null&&typeof u=="object"&&!Array.isArray(u),r=(u,h)=>typeof u==typeof h?u>h:typeof u=="string"&&typeof h=="number";function s(u,h){for(let d in u){const f=d;h.write(f,u[f])}}e.isValidPathItem=u=>typeof u=="number"||typeof u=="string"&&u!=="__proto__";class i{constructor(h=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=h}ascend(){t(this.parents.length===this.indexes.length/2),this.idx===0?this.parents.length?(this.lcIdx=this.indexes.pop(),this.container=this.parents.pop(),this.idx=this.indexes.pop()):(this.lcIdx=0,this.idx=-1):(t(this.idx>0),this.idx--,n(this.container[this.idx])&&this.idx--)}getPath(){const h=[];let d=this.container,f=this.parents.length-1,g=this.idx;for(;g>=0;)h.unshift(d[g]),g===0?(g=this.indexes[f*2],d=this.parents[f--]):g-=n(d[g-1])?2:1;return h}}class o extends i{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return t(this.container!=null,"Invalid call to getKey before cursor descended"),this.container[this.idx]}getComponent(){let h;return this.container&&this.container.length>this.idx+1&&n(h=this.container[this.idx+1])?h:null}descendFirst(){let h=this.idx+1;if(!this.container||h>=this.container.length||n(this.container[h])&&h+1>=this.container.length)return!1;n(this.container[h])&&h++;const d=this.container[h];return Array.isArray(d)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(h),this.idx=0,this.container=d):this.idx=h,!0}nextSibling(){if(t(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;const h=this.indexes[this.indexes.length-1]+1,d=this.parents[this.parents.length-1];return h>=d.length?!1:(t(!isNaN(h)),this.indexes[this.indexes.length-1]=h,this.container=d[h],!0)}_init(h,d,f,g){this.container=h,this.idx=d,this.parents=f.slice(),this.indexes=g.slice()}clone(){const h=new o;return h._init(this.container,this.idx,this.parents,this.indexes),h}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(h,d){const f=this.getComponent();f&&d(f,h);for(const g of this)h&&h.descend(g),this.traverse(h,d),h&&h.ascend()}eachPick(h,d){this.traverse(h,(f,g)=>{f.p!=null&&d(f.p,g)})}eachDrop(h,d){this.traverse(h,(f,g)=>{f.d!=null&&d(f.d,g)})}}e.ReadCursor=o;class a extends i{constructor(h=null){super(h),this.pendingDescent=[],this._op=h}flushDescent(){t(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let h=0;h<this.pendingDescent.length;h++){const d=this.pendingDescent[h];let f=this.idx+1;if(f<this.container.length&&n(this.container[f])&&f++,t(f===this.container.length||!n(this.container[f])),f===this.container.length)this.container.push(d),this.idx=f;else if(this.container[f]===d)this.idx=f;else{if(!Array.isArray(this.container[f])){const g=this.container.splice(f,this.container.length-f);this.container.push(g),this.lcIdx>-1&&(this.lcIdx=f)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(t(r(d,this.container[this.lcIdx][0])),f=this.lcIdx+1,this.lcIdx=-1);f<this.container.length&&r(d,this.container[f][0]);)f++;if(this.indexes.push(f),this.idx=0,f<this.container.length&&this.container[f][0]===d)this.container=this.container[f];else{const g=[d];this.container.splice(f,0,g),this.container=g}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();const h=this.idx+1;if(h<this.container.length&&n(this.container[h]))return this.container[h];{const d={};return this.container.splice(h,0,d),d}}write(h,d){const f=this.getComponent();t(f[h]==null||f[h]===d,"Internal consistency error: Overwritten component. File a bug"),f[h]=d}get(){return this._op}descend(h){if(!e.isValidPathItem(h))throw Error("Invalid JSON key");this.pendingDescent.push(h)}descendPath(h){return this.pendingDescent.push(...h),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(h,d=s){if(h===null)return;if(t(Array.isArray(h)),h===this._op)throw Error("Cannot merge into my own tree");const f=this.lcIdx,g=this.parents.length;let _=0;for(let R=0;R<h.length;R++){const b=h[R];typeof b=="string"||typeof b=="number"?(_++,this.descend(b)):Array.isArray(b)?this.mergeTree(b,d):typeof b=="object"&&d(b,this)}for(;_--;)this.ascend();this.lcIdx=this.parents.length===g?f:-1}at(h,d){this.descendPath(h),d(this);for(let f=0;f<h.length;f++)this.ascend();return this}writeAtPath(h,d,f){return this.at(h,()=>this.write(d,f)),this.reset(),this}writeMove(h,d,f=0){return this.writeAtPath(h,"p",f).writeAtPath(d,"d",f)}getPath(){const h=super.getPath();return h.push(...this.pendingDescent),h}}e.WriteCursor=a,e.writeCursor=()=>new a,e.readCursor=u=>new o(u);function l(u,h,d){let f,g;g=f=u?u.descendFirst():!1;function _(R){let b;for(;g;){const F=b=u.getKey();if(R!=null){let k=!1;if(h&&typeof F=="number"&&(b=h(F,u.getComponent()),b<0&&(b=~b,k=!0)),r(b,R))return null;if(b===R&&!k)return u}d&&typeof b=="number"&&d(b,u.getComponent()),g=u.nextSibling()}return null}return _.end=()=>{f&&u.ascend()},_}e.advancer=l;function c(u,h,d){let f,g,_,R;for(f=g=u&&u.descendFirst(),_=R=h&&h.descendFirst();f||_;){let b=f?u.getKey():null,F=_?h.getKey():null;b!==null&&F!==null&&(r(F,b)?F=null:b!==F&&(b=null)),d(b==null?F:b,b!=null?u:null,F!=null?h:null),b!=null&&f&&(f=u.nextSibling()),F!=null&&_&&(_=h.nextSibling())}g&&u.ascend(),R&&h.ascend()}e.eachChildOf=c}(gi)),gi}var _i={},Ya;function Fu(){return Ya||(Ya=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ConflictType=void 0,function(t){t[t.RM_UNEXPECTED_CONTENT=1]="RM_UNEXPECTED_CONTENT",t[t.DROP_COLLISION=2]="DROP_COLLISION",t[t.BLACKHOLE=3]="BLACKHOLE"}(e.ConflictType||(e.ConflictType={}))}(_i)),_i}var bt={},gn={},Ga;function Vo(){return Ga||(Ga=1,Object.defineProperty(gn,"__esModule",{value:!0}),gn.uniToStrPos=gn.strPosToUni=void 0,gn.strPosToUni=(e,t=e.length)=>{let n=0,r=0;for(;r<t;r++){const s=e.charCodeAt(r);s>=55296&&s<=57343&&(n++,r++)}if(r!==t)throw Error("Invalid offset - splits unicode bytes");return r-n},gn.uniToStrPos=(e,t)=>{let n=0;for(;t>0;t--){const r=e.charCodeAt(n);n+=r>=55296&&r<=57343?2:1}return n}),gn}var pi={},Va;function ji(){return Va||(Va=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.uniSlice=e.dlen=e.eachOp=void 0;const t=Vo(),n=S=>{if(!Array.isArray(S))throw Error("Op must be an array of components");let C=null;for(let w=0;w<S.length;w++){const T=S[w];switch(typeof T){case"object":if(typeof T.d!="number"&&typeof T.d!="string")throw Error("Delete must be number or string");if(e.dlen(T.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(T.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(T>0))throw Error("Skip components must be >0");if(typeof C=="number")throw Error("Adjacent skip components should be combined");break}C=T}if(typeof C=="number")throw Error("Op has a trailing skip")};function r(S,C){let w=0,T=0;for(let B=0;B<S.length;B++){const $=S[B];switch(C($,w,T),typeof $){case"object":w+=e.dlen($.d);break;case"string":T+=t.strPosToUni($);break;case"number":w+=$,T+=$;break}}}e.eachOp=r;function s(S,C){const w=[],T=a(w);return r(S,(B,$,m)=>{T(C(B,$,m))}),h(w)}const i=S=>S,o=S=>s(S,i);e.dlen=S=>typeof S=="number"?S:t.strPosToUni(S);const a=S=>C=>{if(!(!C||C.d===0||C.d===""))if(S.length===0)S.push(C);else if(typeof C==typeof S[S.length-1])if(typeof C=="object"){const w=S[S.length-1];w.d=typeof w.d=="string"&&typeof C.d=="string"?w.d+C.d:e.dlen(w.d)+e.dlen(C.d)}else S[S.length-1]+=C;else S.push(C)},l=S=>typeof S=="number"?S:typeof S=="string"?t.strPosToUni(S):typeof S.d=="number"?S.d:t.strPosToUni(S.d);e.uniSlice=(S,C,w)=>{const T=t.uniToStrPos(S,C),B=w==null?1/0:t.uniToStrPos(S,w);return S.slice(T,B)};const c=(S,C,w)=>typeof S=="number"?w==null?S-C:Math.min(S,w)-C:e.uniSlice(S,C,w),u=S=>{let C=0,w=0;return{take:($,m)=>{if(C===S.length)return $===-1?null:$;const x=S[C];let O;if(typeof x=="number")return $===-1||x-w<=$?(O=x-w,++C,w=0,O):(w+=$,$);if(typeof x=="string"){if($===-1||m==="i"||t.strPosToUni(x.slice(w))<=$)return O=x.slice(w),++C,w=0,O;{const N=w+t.uniToStrPos(x.slice(w),$);return O=x.slice(w,N),w=N,O}}else{if($===-1||m==="d"||e.dlen(x.d)-w<=$)return O={d:c(x.d,w)},++C,w=0,O;{let N=c(x.d,w,w+$);return w+=$,{d:N}}}},peek:()=>S[C]}},h=S=>(S.length>0&&typeof S[S.length-1]=="number"&&S.pop(),S);function d(S,C,w){if(w!=="left"&&w!=="right")throw Error("side ("+w+") must be 'left' or 'right'");n(S),n(C);const T=[],B=a(T),{take:$,peek:m}=u(S);for(let O=0;O<C.length;O++){const N=C[O];let A,v;switch(typeof N){case"number":for(A=N;A>0;)v=$(A,"i"),B(v),typeof v!="string"&&(A-=l(v));break;case"string":w==="left"&&typeof m()=="string"&&B($(-1)),B(t.strPosToUni(N));break;case"object":for(A=e.dlen(N.d);A>0;)switch(v=$(A,"i"),typeof v){case"number":A-=v;break;case"string":B(v);break;case"object":A-=e.dlen(v.d)}break}}let x;for(;x=$(-1);)B(x);return h(T)}function f(S,C){n(S),n(C);const w=[],T=a(w),{take:B}=u(S);for(let m=0;m<C.length;m++){const x=C[m];let O,N;switch(typeof x){case"number":for(O=x;O>0;)N=B(O,"d"),T(N),typeof N!="object"&&(O-=l(N));break;case"string":T(x);break;case"object":O=e.dlen(x.d);let A=0;for(;A<O;)switch(N=B(O-A,"d"),typeof N){case"number":T({d:c(x.d,A,A+N)}),A+=N;break;case"string":A+=t.strPosToUni(N);break;case"object":T(N)}break}}let $;for(;$=B(-1);)T($);return h(w)}const g=(S,C)=>{let w=0;for(let T=0;T<C.length&&S>w;T++){const B=C[T];switch(typeof B){case"number":{w+=B;break}case"string":const $=t.strPosToUni(B);w+=$,S+=$;break;case"object":S-=Math.min(e.dlen(B.d),S-w);break}}return S},_=(S,C)=>typeof S=="number"?g(S,C):S.map(w=>g(w,C));function R(S,C,w){return s(S,(T,B)=>typeof T=="object"&&typeof T.d=="number"?{d:w.slice(C,B,B+T.d)}:T)}function b(S){return s(S,C=>{switch(typeof C){case"object":if(typeof C.d=="number")throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");return C.d;case"string":return{d:C};case"number":return C}})}function F(S){return s(S,C=>typeof C=="object"&&typeof C.d=="string"?{d:t.strPosToUni(C.d)}:C)}function k(S){let C=!0;return r(S,w=>{typeof w=="object"&&typeof w.d=="number"&&(C=!1)}),C}function W(S){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:h,normalize:o,checkOp:n,create(C=""){if(typeof C!="string")throw Error("Initial data must be a string");return S.create(C)},apply(C,w){n(w);const T=S.builder(C);for(let B=0;B<w.length;B++){const $=w[B];switch(typeof $){case"number":T.skip($);break;case"string":T.append($);break;case"object":T.del(e.dlen($.d));break}}return T.build()},transform:d,compose:f,transformPosition:g,transformSelection:_,isInvertible:k,makeInvertible(C,w){return R(C,w,S)},stripInvertible:F,invert:b,invertWithDoc(C,w){return b(R(C,w,S))},isNoop:C=>C.length===0}}e.default=W}(pi)),pi}var ss={},za;function H_(){if(za)return ss;za=1,Object.defineProperty(ss,"__esModule",{value:!0});const e=ji(),t=Vo();function n(r,s){return{get:r,getLength(){return r().length},insert(i,o,a){const l=t.strPosToUni(r(),i);return s([l,o],a)},remove(i,o,a){const l=t.strPosToUni(r(),i);return s([l,{d:o}],a)},_onOp(i){e.eachOp(i,(o,a,l)=>{switch(typeof o){case"string":this.onInsert&&this.onInsert(l,o);break;case"object":const c=e.dlen(o.d);this.onRemove&&this.onRemove(l,c)}})},onInsert:null,onRemove:null}}return ss.default=n,n.provides={text:!0},ss}var Ka;function j_(){return Ka||(Ka=1,function(e){var t=bt&&bt.__createBinding||(Object.create?function(d,f,g,_){_===void 0&&(_=g),Object.defineProperty(d,_,{enumerable:!0,get:function(){return f[g]}})}:function(d,f,g,_){_===void 0&&(_=g),d[_]=f[g]}),n=bt&&bt.__setModuleDefault||(Object.create?function(d,f){Object.defineProperty(d,"default",{enumerable:!0,value:f})}:function(d,f){d.default=f}),r=bt&&bt.__importStar||function(d){if(d&&d.__esModule)return d;var f={};if(d!=null)for(var g in d)Object.hasOwnProperty.call(d,g)&&t(f,d,g);return n(f,d),f},s=bt&&bt.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(e,"__esModule",{value:!0}),e.type=e.remove=e.insert=void 0;const i=Vo(),o=r(ji()),a=s(H_()),l={create(d){return d},toString(d){return d},builder(d){if(typeof d!="string")throw Error("Invalid document snapshot: "+d);const f=[];return{skip(g){let _=i.uniToStrPos(d,g);if(_>d.length)throw Error("The op is too long for this document");f.push(d.slice(0,_)),d=d.slice(_)},append(g){f.push(g)},del(g){d=d.slice(i.uniToStrPos(d,g))},build(){return f.join("")+d}}},slice:o.uniSlice},c=o.default(l),u=Object.assign(Object.assign({},c),{api:a.default});e.type=u,e.insert=(d,f)=>f.length===0?[]:d===0?[f]:[d,f],e.remove=(d,f)=>o.dlen(f)===0?[]:d===0?[{d:f}]:[d,{d:f}];var h=ji();Object.defineProperty(e,"makeType",{enumerable:!0,get:function(){return h.default}})}(bt)),bt}var Xa;function W_(){return Xa||(Xa=1,function(e){var t=rr&&rr.__importDefault||function(I){return I&&I.__esModule?I:{default:I}};Object.defineProperty(e,"__esModule",{value:!0}),e.editOp=e.replaceOp=e.insertOp=e.moveOp=e.removeOp=e.type=void 0;const n=t(B_()),r=t($_()),s=ku(),i=Fu();function o(I,D){if(!I)throw new Error(D)}e.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:s.readCursor,writeCursor:s.writeCursor,create:I=>I,isNoop:I=>I==null,setDebug(I){},registerSubtype:b,checkValidOp:B,normalize:$,apply:m,transformPosition:x,compose:O,tryTransform:L,transform:J,makeInvertible:v,invert:N,invertWithDoc:y,RM_UNEXPECTED_CONTENT:i.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:i.ConflictType.DROP_COLLISION,BLACKHOLE:i.ConflictType.BLACKHOLE,transformNoConflict:(I,D,Y)=>le(()=>!0,I,D,Y),typeAllowingConflictsPred:I=>Object.assign(Object.assign({},e.type),{transform:(D,Y,G)=>le(I,D,Y,G)})};const a=I=>I?I.getComponent():null;function l(I){return I&&typeof I=="object"&&!Array.isArray(I)}const c=I=>Array.isArray(I)?I.slice():I!==null&&typeof I=="object"?Object.assign({},I):I,u=I=>I&&(I.p!=null||I.r!==void 0),h=I=>I&&(I.d!=null||I.i!==void 0);function d(I,D){return o(I!=null),typeof D=="number"?(o(Array.isArray(I),"Invalid key - child is not an array"),(I=I.slice()).splice(D,1)):(o(l(I),"Invalid key - child is not an object"),delete(I=Object.assign({},I))[D]),I}function f(I,D,Y){return typeof D=="number"?(o(I!=null,"Container is missing for key"),o(Array.isArray(I),"Cannot use numerical key for object container"),o(I.length>=D,"Cannot insert into out of bounds index"),I.splice(D,0,Y)):(o(l(I),"Cannot insert into missing item"),o(I[D]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),I[D]=Y),Y}e.removeOp=(I,D=!0)=>s.writeCursor().writeAtPath(I,"r",D).get(),e.moveOp=(I,D)=>s.writeCursor().writeMove(I,D).get(),e.insertOp=(I,D)=>s.writeCursor().writeAtPath(I,"i",D).get(),e.replaceOp=(I,D,Y)=>s.writeCursor().at(I,G=>{G.write("r",D),G.write("i",Y)}).get(),e.editOp=(I,D,Y,G=!1)=>s.writeCursor().at(I,H=>C(H,D,Y,G)).get();const g=(I,D)=>I!=null&&(typeof D=="number"?Array.isArray(I):typeof I=="object"),_=(I,D)=>g(I,D)?I[D]:void 0,R={};function b(I){let D=I.type?I.type:I;D.name&&(R[D.name]=D),D.uri&&(R[D.uri]=D)}const F=I=>{const D=R[I];if(D)return D;throw Error("Missing type: "+I)};b(j_());const k=(I,D)=>I+D;b({name:"number",apply:k,compose:k,invert:I=>-I,transform:I=>I});const W=I=>I==null?null:I.et?F(I.et):I.es?R["text-unicode"]:I.ena!=null?R.number:null,S=I=>I.es?I.es:I.ena!=null?I.ena:I.e,C=(I,D,Y,G=!1)=>{const[H,j]=typeof D=="string"?[F(D),D]:[D,D.name];!G&&H.isNoop&&H.isNoop(Y)||(j==="number"?I.write("ena",Y):j==="text-unicode"?I.write("es",Y):(I.write("et",j),I.write("e",Y)))};function w(I){o(typeof I=="number"),o(I>=0),o(I===(0|I))}function T(I){typeof I=="number"?w(I):o(typeof I=="string")}function B(I){if(I===null)return;const D=new Set,Y=new Set,G=j=>{let Q=!0,ee=!1;for(let U in j){const z=j[U];if(Q=!1,o(U==="p"||U==="r"||U==="d"||U==="i"||U==="e"||U==="es"||U==="ena"||U==="et","Invalid component item '"+U+"'"),U==="p")w(z),o(!D.has(z)),D.add(z),o(j.r===void 0);else if(U==="d")w(z),o(!Y.has(z)),Y.add(z),o(j.i===void 0);else if(U==="e"||U==="es"||U==="ena"){o(!ee),ee=!0;const X=W(j);o(X,"Missing type in edit"),X.checkValidOp&&X.checkValidOp(S(j))}}o(!Q)},H=(j,Q,ee)=>{if(!Array.isArray(j))throw Error("Op must be null or a list");if(j.length===0)throw Error("Empty descent");Q||T(j[0]);let U=1,z=0,X=0;for(let ne=0;ne<j.length;ne++){const me=j[ne];if(o(me!=null),Array.isArray(me)){const pe=H(me,!1);if(z){const K=typeof X,he=typeof pe;K===he?o(X<pe,"descent keys are not in order"):o(K==="number"&&he==="string")}X=pe,z++,U=3}else typeof me=="object"?(o(U===1,`Prev not scalar - instead ${U}`),G(me),U=2):(o(U!==3),T(me),o(s.isValidPathItem(me),"Invalid path key"),U=1)}return o(z!==1,"Operation makes multiple descents. Remove some []"),o(U===2||U===3),j[0]};H(I,!0),o(D.size===Y.size,"Mismatched picks and drops in op");for(let j=0;j<D.size;j++)o(D.has(j)),o(Y.has(j))}function $(I){let D=0,Y=[];const G=s.writeCursor();return G.mergeTree(I,(H,j)=>{const Q=W(H);if(Q){const U=S(H);C(j,Q,Q.normalize?Q.normalize(U):U)}for(const U of["r","p","i","d"])if(H[U]!==void 0){const z=U==="p"||U==="d"?(ee=H[U],Y[ee]==null&&(Y[ee]=D++),Y[ee]):H[U];j.write(U,z)}var ee}),G.get()}function m(I,D){if(B(D),D===null)return I;const Y=[];return function G(H,j){let Q=H,ee=0,U={root:H},z=0,X=U,ne="root";function me(){for(;z<ee;z++){let pe=j[z];typeof pe!="object"&&(o(g(X,ne)),X=X[ne]=c(X[ne]),ne=pe)}}for(;ee<j.length;ee++){const pe=j[ee];if(Array.isArray(pe)){const K=G(Q,pe);K!==Q&&K!==void 0&&(me(),Q=X[ne]=K)}else if(typeof pe=="object"){pe.d!=null?(me(),Q=f(X,ne,Y[pe.d])):pe.i!==void 0&&(me(),Q=f(X,ne,pe.i));const K=W(pe);if(K)me(),Q=X[ne]=K.apply(Q,S(pe));else if(pe.e!==void 0)throw Error("Subtype "+pe.et+" undefined")}else Q=_(Q,pe)}return U.root}(I=function G(H,j){const Q=[];let ee=0;for(;ee<j.length;ee++){const ne=j[ee];if(Array.isArray(ne))break;typeof ne!="object"&&(Q.push(H),H=_(H,ne))}for(let ne=j.length-1;ne>=ee;ne--)H=G(H,j[ne]);for(--ee;ee>=0;ee--){const ne=j[ee];if(typeof ne!="object"){const me=Q.pop();H=H===_(me,ne)?me:H===void 0?d(me,ne):(z=ne,X=H,(U=c(U=me))[z]=X,U)}else u(ne)&&(o(H!==void 0,"Cannot pick up or remove undefined"),ne.p!=null&&(Y[ne.p]=H),H=void 0)}var U,z,X;return H}(I,D),D)}function x(I,D){I=I.slice(),B(D);const Y=s.readCursor(D);let G,H,j=!1;const Q=[];for(let U=0;;U++){const z=I[U],X=Y.getComponent();if(X&&(X.r!==void 0?j=!0:X.p!=null&&(j=!1,G=X.p,H=U)),U>=I.length)break;let ne=0;const me=s.advancer(Y,void 0,(K,he)=>{u(he)&&ne++});Q.unshift(me);const pe=me(z);if(typeof z=="number"&&(I[U]-=ne),!pe)break}if(Q.forEach(U=>U.end()),j)return null;const ee=()=>{let U=0;if(G!=null){const z=Y.getPath();U=z.length,I=z.concat(I.slice(H))}for(;U<I.length;U++){const z=I[U],X=a(Y),ne=W(X);if(ne){const K=S(X);ne.transformPosition&&(I[U]=ne.transformPosition(I[U],K));break}let me=0;const pe=s.advancer(Y,(K,he)=>h(he)?~(K-me):K-me,(K,he)=>{h(he)&&me++})(z);if(typeof z=="number"&&(I[U]+=me),!pe)break}};return G!=null?Y.eachDrop(null,U=>{U===G&&ee()}):ee(),I}function O(I,D){if(B(I),B(D),I==null)return D;if(D==null)return I;let Y=0;const G=s.readCursor(I),H=s.readCursor(D),j=s.writeCursor(),Q=[],ee=[],U=[],z=[],X=[],ne=[],me=new Set;G.traverse(null,K=>{K.p!=null&&(U[K.p]=G.clone())}),H.traverse(null,K=>{K.d!=null&&(z[K.d]=H.clone())});const pe=s.writeCursor();return function K(he,xe,ye,Ie,Be,Bt,nt,qe){o(xe||ye);const $e=a(xe),ft=a(ye),St=!!ft&&ft.r!==void 0,cn=!!$e&&$e.i!==void 0,mt=$e?$e.d:null,lt=ft?ft.p:null,$t=(Bt||St)&<==null;if(lt!=null)Ie=z[lt],nt=ee[lt]=new s.WriteCursor;else if(ft&&ft.r!==void 0)Ie=null;else{const se=a(Ie);se&&se.d!=null&&(Ie=null)}const be=a(Ie);if(mt!=null)if(he=U[mt],qe=Q[mt]=new s.WriteCursor,$t)Bt&&!St&&qe.write("r",!0);else{const se=X[mt]=Y++;nt.write("d",se)}else if($e&&$e.i!==void 0)he=null;else{const se=a(he);se&&se.p!=null&&(he=null)}let ae;cn?(o(Be===void 0),ae=$e.i):ae=Be;const Ce=(lt==null?!cn||Bt||St:ae===void 0)?null:nt.getComponent();if(lt!=null){if(!(Be!==void 0||cn)){const se=mt!=null?X[mt]:Y++;ne[lt]=se,qe.write("p",se)}}else St&&(cn||Be!==void 0||(ft.r,qe.write("r",ft.r)));const ue=$t?null:W($e),re=W(be);if((ue||re)&&(ue&&ue.name,re&&re.name),ue&&re){o(ue===re);const se=S($e),Re=S(be),ze=ue.compose(se,Re);C(nt,ue,ze),me.add(be)}else ue?C(nt,ue,S($e)):re&&(C(nt,re,S(be)),me.add(be));const de=typeof ae=="object"&&ae!=null;let we=!1,Oe=0,Te=0,Ve=0,Ye=0,He=0;const et=s.advancer(Ie,(se,Re)=>h(Re)?Ye-se-1:se-Ye,(se,Re)=>{h(Re)&&Ye++}),Se=s.advancer(he,(se,Re)=>u(Re)?Oe-se-1:se-Oe,(se,Re)=>{u(Re)&&Oe++});if(s.eachChildOf(xe,ye,(se,Re,ze)=>{let rt,Ht,un=se,Ot=se,er=se;if(typeof se=="number"){let Ze=se+Ve;Ht=et(Ze),Ot=Ze+Ye;let je=se+Te;rt=Se(je),h(a(Ht))&&(rt=null),un=je+Oe,er=se+He,o(un>=0,"p1PickKey is negative"),o(Ot>=0,"p2DropKey is negative");const vt=h(a(Re)),jt=u(a(ze));(vt||jt&&!$t)&&He--,vt&&Te--,jt&&Ve--}else rt=Se(se),Ht=et(se);qe.descend(un),nt.descend(Ot);const wn=de&&!h(a(Re))?ae[er]:void 0,Mt=K(rt,Re,ze,Ht,wn,$t,nt,qe);var Lt,ge,ke;de&&!$t?wn!==Mt&&(we||(ae=Array.isArray(ae)?ae.slice():Object.assign({},ae),we=!0),Lt=ae,ke=Mt,typeof(ge=er)=="number"?(o(Array.isArray(Lt)),o(ge<Lt.length)):(o(!Array.isArray(Lt)),o(Lt[ge]!==void 0)),ke===void 0?typeof ge=="number"?Lt.splice(ge,1):delete Lt[ge]:Lt[ge]=ke):o(Mt===void 0),nt.ascend(),qe.ascend()}),Se.end(),et.end(),Ce!=null)Ce.i=ae;else if(!Bt&&!St&<==null)return ae}(G,G.clone(),H,H.clone(),void 0,!1,j,pe),j.reset(),j.mergeTree(pe.get()),j.reset(),j.get(),Q.map(K=>K.get()),ee.map(K=>K.get()),G.traverse(j,(K,he)=>{const xe=K.p;if(xe!=null){const ye=X[xe];ye!=null&&he.write("p",ye);const Ie=Q[xe];Ie&&Ie.get(),Ie&&he.mergeTree(Ie.get())}else K.r!==void 0&&he.write("r",K.r)}),j.reset(),j.get(),H.traverse(j,(K,he)=>{const xe=K.d;if(xe!=null){const Ie=ne[xe];Ie!=null&&he.write("d",Ie);const Be=ee[xe];Be&&he.mergeTree(Be.get())}else K.i!==void 0&&he.write("i",K.i);const ye=W(K);ye&&!me.has(K)&&C(he,ye,S(K))}),j.get()}function N(I){if(I==null)return null;const D=new s.ReadCursor(I),Y=new s.WriteCursor;let G;const H=[],j=[];return function Q(ee,U,z){const X=ee.getComponent();let ne,me=!1;if(X){X.p!=null&&(U.write("d",X.p),H[X.p]=ee.clone()),X.r!==void 0&&U.write("i",X.r),X.d!=null&&(U.write("p",X.d),z=void 0),X.i!==void 0&&(z=ne=X.i);const K=W(X);K&&(z===void 0?(G||(G=new Set),G.add(X)):(S(X),z=K.apply(z,S(X)),me=!0))}let pe=0;for(const K of ee){U.descend(K);const he=typeof K=="number"?K-pe:K,xe=_(z,he);h(ee.getComponent())&&pe++;const ye=Q(ee,U,xe);if(z!==void 0&&ye!==void 0){if(me||(me=!0,z=c(z)),!g(z,he))throw Error("Cannot modify child - invalid operation");z[he]=ye}U.ascend()}if(ne===void 0)return me?z:void 0;U.write("r",z)}(D,Y,void 0),G&&(Y.reset(),function Q(ee,U,z){const X=U.getComponent();if(X){const K=X.d;if(K!=null&&(ee=H[K],z=j[K]=s.writeCursor()),G.has(X)){const he=W(X);if(!he.invert)throw Error(`Cannot invert subtype ${he.name}`);C(z,he,he.invert(S(X)))}}let ne=0,me=0;const pe=s.advancer(ee,(K,he)=>u(he)?ne-K-1:K-ne,(K,he)=>{u(he)&&ne++});for(const K of U)if(typeof K=="number"){const he=K-me,xe=pe(he),ye=he+ne;z.descend(ye),Q(xe,U,z),h(U.getComponent())&&me++,z.ascend()}else z.descend(K),Q(pe(K),U,z),z.ascend();pe.end()}(D.clone(),D,Y),j.length&&(Y.reset(),D.traverse(Y,(Q,ee)=>{const U=Q.p;if(U!=null){const z=j[U];z&&z.get(),z&&ee.mergeTree(z.get())}}))),Y.get()}const A=(I,D)=>I.some(Y=>typeof Y=="object"&&(Array.isArray(Y)?A(Y,D):D(Y)));function v(I,D){if(I==null||!A(I,U=>{var z;return U.r!==void 0||((z=W(U))===null||z===void 0?void 0:z.makeInvertible)!=null}))return I;const Y=new s.ReadCursor(I),G=new s.WriteCursor;let H=!1;const j=[],Q=[],ee=(U,z,X)=>{const ne=U.getComponent();let me=!1;if(ne){ne.d!=null&&z.write("d",ne.d),ne.i!==void 0&&z.write("i",ne.i);const K=ne.p;if(K!=null&&(j[K]=U.clone(),o(X!==void 0,"Operation picks up at an invalid key"),Q[K]=X,z.write("p",ne.p)),ne.r!==void 0&&X===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const he=W(ne);he&&(he.makeInvertible?H=!0:C(z,he,S(ne),!0))}let pe=0;for(const K of U){z.descend(K);const he=typeof K=="number"?K-pe:K,xe=_(X,he),ye=ee(U,z,xe);xe!==ye&&(me||(me=!0,X=c(X)),ye===void 0?(X=d(X,he),typeof K=="number"&&pe++):X[he]=ye),z.ascend()}return ne&&(ne.r!==void 0?(z.write("r",r.default(X)),X=void 0):ne.p!=null&&(X=void 0)),X};return ee(Y,G,D),G.get(),H&&(G.reset(),function U(z,X,ne,me,pe){const K=X.getComponent();if(K){K.i!==void 0?(me=K.i,pe=!0):K.d!=null&&(me=Q[K.d],z=j[K.d],pe=!1,K.d);let Ie=W(K);if(Ie&&Ie.makeInvertible){const Be=S(K);C(ne,Ie,Ie.makeInvertible(Be,me),!0)}}let he=0,xe=0;const ye=s.advancer(z,(Ie,Be)=>u(Be)?he-Ie-1:Ie-he,(Ie,Be)=>{u(Be)&&he++});for(const Ie of X)if(typeof Ie=="number"){const Be=Ie-xe,Bt=ye(Be),nt=Be+he,qe=_(me,pe?Be:nt);ne.descend(Ie),U(Bt,X,ne,qe,pe),h(X.getComponent())&&xe++,ne.ascend()}else{const Be=_(me,Ie);ne.descend(Ie),U(ye(Ie),X,ne,Be,pe),ne.ascend()}ye.end()}(Y.clone(),Y,G,D,!1)),G.get()}function y(I,D){return N(v(I,D))}const M=I=>{if(I==null)return null;const D=I.slice();for(let Y=0;Y<I.length;Y++){const G=D[Y];Array.isArray(G)&&(D[Y]=M(G))}return D};function L(I,D,Y){o(Y==="left"||Y==="right","Direction must be left or right");const G=Y==="left"?0:1;if(D==null)return{ok:!0,result:I};B(I),B(D);let H=null;const j=[],Q=[],ee=[],U=[],z=[],X=[],ne=[],me=[],pe=[],K=[],he=[],xe=[],ye=[],Ie=[],Be=[];let Bt=0;const nt=s.readCursor(I),qe=s.readCursor(D),$e=s.writeCursor();if(function be(ae,Ce=null,ue){const re=a(Ce);re&&(re.r!==void 0?ue=Ce.clone():re.p!=null&&(ue=null,X[re.p]=ae.clone()));const de=ae.getComponent();let we;de&&(we=de.p)!=null&&(z[we]=Ce?Ce.clone():null,ee[we]=ae.clone(),ue&&(K[we]=!0,pe[we]=ue),re&&re.p!=null&&(Ie[we]=re.p));const Oe=s.advancer(Ce);for(const Te of ae)be(ae,Oe(Te),ue);Oe.end()}(qe,nt,null),function be(ae,Ce,ue,re,de){const we=ue.getComponent();let Oe,Te=!1;we&&((Oe=we.d)!=null?(U[Oe]=ue.clone(),re!=null&&(Be[re]==null&&(Be[re]=[]),Be[re].push(Oe)),K[Oe],ae=z[Oe]||null,Ce=ee[Oe]||null,K[Oe]?(de&&(he[Oe]=!0),de=pe[Oe]||null):!de||G!==1&&Ie[Oe]!=null||H==null&&(H={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(de.getPath()),op2:e.moveOp(Ce.getPath(),ue.getPath())}),Te=!0):we.i!==void 0&&(ae=Ce=null,Te=!0,de&&H==null&&(H={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(de.getPath()),op2:e.insertOp(ue.getPath(),we.i)})));const Ve=a(ae);Ve&&(Ve.r!==void 0?de=ae.clone():Ve.p!=null&&(Ve.p,re=Ve.p,de=null));const Ye=W(we);Ye&&de&&H==null&&(H={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(de.getPath()),op2:e.editOp(ue.getPath(),Ye,S(we),!0)});let He=0,et=0;const Se=s.advancer(Ce,(Re,ze)=>u(ze)?He-Re-1:Re-He,(Re,ze)=>{u(ze)&&He++}),se=s.advancer(ae);for(const Re of ue)if(typeof Re=="number"){const ze=Re-et,rt=Se(ze);et+=+be(se(ze+He),rt,ue,re,de)}else{const ze=Se(Re);be(se(Re),ze,ue,re,de)}return Se.end(),se.end(),Te}(nt,qe,qe.clone(),null,null),U.map(be=>be&&be.get()),H)return{ok:!1,conflict:H};he.map(be=>!!be);const ft=[];let St=null;(function be(ae,Ce,ue,re,de){let we=!1;const Oe=a(Ce);if(u(Oe)){const Se=Oe.p;Se!=null?(ue=U[Se],re=xe[Se]=s.writeCursor(),we=!0,de=null):(ue=null,de=Ce.clone())}else h(a(ue))&&(ue=null);const Te=ae.getComponent();if(Te){const Se=Te.p;Se!=null?(de&&(me[Se]=de),ft[Se]=de||G===1&&we?null:re.getComponent(),j[Se]=ae.clone(),ue&&(ne[Se]=ue.clone())):Te.r!==void 0&&(de||re.write("r",!0),(de||we)&&(St==null&&(St=new Set),St.add(Te)))}let Ve=0,Ye=0;const He=s.advancer(Ce,void 0,(Se,se)=>{u(se)&&Ve++}),et=s.advancer(ue,(Se,se)=>h(se)?~(Se-Ye):Se-Ye,(Se,se)=>{h(se)&&Ye++});if(ae)for(const Se of ae)if(typeof Se=="string"){const se=He(Se),Re=et(Se);re.descend(Se),be(ae,se,Re,re,de),re.ascend()}else{const se=He(Se),Re=Se-Ve,ze=u(a(se))?null:et(Re),rt=Re+Ye;o(rt>=0),re.descend(rt),be(ae,se,ze,re,de),re.ascend()}He.end(),et.end()})(nt,qe,qe.clone(),$e,null),$e.reset();let cn=[];if(function be(ae,Ce,ue,re,de,we){o(Ce);const Oe=Ce.getComponent();let Te=a(re),Ve=!1;const Ye=(ge,ke,Ze)=>ge?e.moveOp(ge.getPath(),ke.getPath()):e.insertOp(ke.getPath(),Ze.i);if(h(Oe)){const ge=Oe.d;ge!=null&&(Q[ge]=Ce.clone());const ke=ge!=null?ft[ge]:null;let Ze=!1;if(Oe.i!==void 0||ge!=null&&ke){let je;Te&&(Te.i!==void 0||(je=Te.d)!=null&&!K[je])&&(Ze=je!=null?ge!=null&&ge===Ie[je]:n.default(Te.i,Oe.i),Ze||je!=null&&G!==1&&Ie[je]!=null||H==null&&(H={type:i.ConflictType.DROP_COLLISION,op1:Ye(ge!=null?j[ge]:null,Ce,Oe),op2:Ye(je!=null?ee[je]:null,re,Te)})),Ze||(we?H==null&&(H={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:Ye(ge!=null?j[ge]:null,Ce,Oe),op2:e.removeOp(we.getPath())}):(ge!=null?(cn[Bt]=ge,de.write("d",ke.p=Bt++)):de.write("i",r.default(Oe.i)),Ve=!0))}else if(ge!=null&&!ke){const je=me[ge];je&&(we=je.clone())}ge!=null?(ae=j[ge],ue=X[ge],re=ne[ge]):Oe.i!==void 0&&(ae=ue=null,Ze||(re=null))}else u(a(ae))&&(ae=ue=re=null);const He=a(ae),et=a(ue);if(u(et)){const ge=et.p;et.r!==void 0&&(!He||He.r===void 0)||K[ge]?(re=null,we=ue.clone()):ge!=null&&(re=U[ge],G!==1&&Ie[ge]!=null||((de=ye[ge])||(de=ye[ge]=s.writeCursor()),de.reset(),we=null))}else!h(Oe)&&h(Te)&&(re=null);Te=re!=null?re.getComponent():null;const Se=W(Oe);if(Se){const ge=S(Oe);if(we)H==null&&(H={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.editOp(Ce.getPath(),Se,ge,!0),op2:e.removeOp(we.getPath())});else{const ke=W(Te);let Ze;if(ke){if(Se!==ke)throw Error("Transforming incompatible types");const je=S(Te);Ze=Se.transform(ge,je,Y)}else Ze=r.default(ge);C(de,Se,Ze)}}let se=0,Re=0,ze=0,rt=0,Ht=0,un=0,Ot=ae!=null&&ae.descendFirst(),er=Ot;const wn=s.advancer(ue,void 0,(ge,ke)=>{u(ke)&&ze++});let Mt=re!=null&&re.descendFirst(),Lt=Mt;for(const ge of Ce)if(typeof ge=="number"){let ke;const Ze=h(Ce.getComponent()),je=ge-Re;{let Kt;for(;Ot&&typeof(Kt=ae.getKey())=="number";){Kt+=se;const wt=ae.getComponent(),bn=u(wt);if(Kt>je||Kt===je&&(!bn||G===0&&Ze))break;if(bn){se--;const hn=wt.p;Ie.includes(hn),wt.d,a(ye[wt.d]),u(a(ye[wt.d])),(wt.r===void 0||St&&St.has(wt))&&(hn==null||!ft[hn]||G!==1&&Ie.includes(hn))||Ht--}Ot=ae.nextSibling()}ke=Ot&&Kt===je?ae:null}const vt=je-se;let jt=wn(vt);const Qs=vt-ze;let zr=null;{let Kt,wt;for(;Mt&&typeof(Kt=re.getKey())=="number";){wt=Kt-rt;const bn=re.getComponent(),hn=h(bn);if(wt>Qs)break;if(wt===Qs){if(!hn){zr=re;break}{if(G===0&&Ze){zr=re;break}const Xt=jt&&u(jt.getComponent());if(G===0&&Xt)break}}if(hn){const Xt=bn.d;K[Xt],Ie[Xt],bn.i===void 0&&(K[Xt]||Ie[Xt]!=null&&G!==1)?(K[Xt]||Ie[Xt]!=null&&G===0)&&(rt++,un--):rt++}Mt=re.nextSibling()}}const da=Qs+rt+Ht+un;o(da>=0,"trying to descend to a negative index"),de.descend(da),Ze&&(ke=jt=zr=null,Re++),be(ke,Ce,jt,zr,de,we)&&un++,de.ascend()}else{let ke;for(;Ot&&(ke=ae.getKey(),typeof ke!="string"||!(ke>ge||ke===ge));)Ot=ae.nextSibling();const Ze=Ot&&ke===ge?ae:null,je=wn(ge);let vt;for(;Mt&&(vt=re.getKey(),typeof vt!="string"||!(vt>ge||vt===ge));)Mt=re.nextSibling();const jt=Mt&&vt===ge?re:null;de.descend(ge),be(Ze,Ce,je,jt,de,we),de.ascend()}return wn.end(),er&&ae.ascend(),Lt&&re.ascend(),Ve}(nt,nt.clone(),qe,qe.clone(),$e,null),H)return{ok:!1,conflict:H};$e.reset();const mt=(be,ae,Ce)=>be.traverse(ae,(ue,re)=>{ue.d!=null&&Ce(ue.d,be,re)});(K.length||xe.length)&&(mt(qe,$e,(be,ae,Ce)=>{K[be]&&!he[be]&&Ce.write("r",!0),xe[be]&&Ce.mergeTree(xe[be].get())}),$e.reset());const lt=[],$t=[];if((ye.length||K.length)&&!H){const be=s.readCursor(M($e.get()));if(mt(be,null,(ae,Ce)=>{lt[ae]=Ce.clone()}),ye.forEach(ae=>{ae&&mt(s.readCursor(ae.get()),null,(Ce,ue)=>{lt[Ce]=ue.clone()})}),function ae(Ce,ue,re,de,we,Oe){const Te=a(ue);if(Te&&u(Te))if(Te.p!=null){const se=Te.p;lt[se].getPath(),re=lt[se],de=$t[se]=s.writeCursor()}else Te.r!==void 0&&(re=null);else h(a(re))&&(re=null);const Ve=Ce.getComponent();if(Ve){let se;if((se=Ve.d)!=null){const Re=ye[se];Re&&(Re.get(),de.mergeTree(Re.get()),re=s.readCursor(Re.get()))}}let Ye=0,He=0;const et=s.advancer(ue,void 0,(se,Re)=>{u(Re)&&Ye--}),Se=s.advancer(re,(se,Re)=>h(Re)?-(se-He)-1:se-He,(se,Re)=>{h(Re)&&He++});for(const se of Ce)if(typeof se=="number"){const Re=et(se),ze=se+Ye,rt=Se(ze),Ht=ze+He;de.descend(Ht),ae(Ce,Re,rt,de),de.ascend()}else de.descend(se),ae(Ce,et(se),Se(se),de),de.ascend();et.end(),Se.end()}(qe,be,be.clone(),$e),$e.reset(),H)return{ok:!1,conflict:H};if($e.get(),$t.length){const ae=$t.map(ue=>ue?ue.get():null),Ce=s.readCursor(M($e.get()));if(mt(Ce,$e,(ue,re,de)=>{const we=ae[ue];we&&(de.mergeTree(we),ae[ue]=null)}),ae.find(ue=>ue)){const ue=s.writeCursor(),re=s.writeCursor();let de=0,we=0;ae.forEach(Oe=>{Oe!=null&&mt(s.readCursor(Oe),null,Te=>{const Ve=cn[Te];ue.writeMove(j[Ve].getPath(),Q[Ve].getPath(),de++);const Ye=Be[Ve];Ye&&Ye.forEach(He=>{K[He]||G!==1&&Ie[He]!=null||re.writeMove(ee[He].getPath(),U[He].getPath(),we++)})})}),H={type:i.ConflictType.BLACKHOLE,op1:ue.get(),op2:re.get()}}}}return H?{ok:!1,conflict:H}:{ok:!0,result:$e.get()}}const P=I=>{const D=new Error("Transform detected write conflict");throw D.conflict=I,D.type=D.name="writeConflict",D};function J(I,D,Y){const G=L(I,D,Y);if(G.ok)return G.result;P(G.conflict)}const V=I=>{const D=s.writeCursor();return s.readCursor(I).traverse(D,(Y,G)=>{(h(Y)||W(Y))&&G.write("r",!0)}),D.get()},oe=(I,D)=>{const{type:Y,op1:G,op2:H}=I;switch(Y){case i.ConflictType.DROP_COLLISION:return D==="left"?[null,V(H)]:[V(G),null];case i.ConflictType.RM_UNEXPECTED_CONTENT:let j=!1;return s.readCursor(G).traverse(null,Q=>{Q.r!==void 0&&(j=!0)}),j?[null,V(H)]:[V(G),null];case i.ConflictType.BLACKHOLE:return[V(G),V(H)];default:throw Error("Unrecognised conflict: "+Y)}};function le(I,D,Y,G){let H=null;for(;;){const j=L(D,Y,G);if(j.ok)return O(H,j.result);{const{conflict:Q}=j;I(Q)||P(Q);const[ee,U]=oe(Q,G);D=O($(D),ee),Y=O($(Y),U),H=O(H,U)}}}}(rr)),rr}var qa;function Y_(){return qa||(qa=1,function(e){var t=mn&&mn.__createBinding||(Object.create?function(i,o,a,l){l===void 0&&(l=a),Object.defineProperty(i,l,{enumerable:!0,get:function(){return o[a]}})}:function(i,o,a,l){l===void 0&&(l=a),i[l]=o[a]}),n=mn&&mn.__exportStar||function(i,o){for(var a in i)a!=="default"&&!o.hasOwnProperty(a)&&t(o,i,a)};Object.defineProperty(e,"__esModule",{value:!0}),n(W_(),e);var r=ku();Object.defineProperty(e,"ReadCursor",{enumerable:!0,get:function(){return r.ReadCursor}}),Object.defineProperty(e,"WriteCursor",{enumerable:!0,get:function(){return r.WriteCursor}});var s=Fu();Object.defineProperty(e,"ConflictType",{enumerable:!0,get:function(){return s.ConflictType}})}(mn)),mn}var ot=Y_();const G_=It(ot),V_=Od({__proto__:null,default:G_},[ot]);var Z=(e=>(e.RETAIN="r",e.INSERT="i",e.DELETE="d",e))(Z||{});function jr(e,t=!1){const n=[];for(const r of e){const{st:s,ed:i,ts:o}=r;if(r.sId===void 0&&delete r.sId,s===i||!t&&q.isEmptyObject(o)&&r.sId==null)continue;if(n.length===0){n.push(r);continue}const a=n.pop();bc(r,a)&&q.hasIntersectionBetweenTwoRanges(a.st,a.ed,r.st,r.ed)?n.push({...r,st:a.st,ed:i}):n.push(a,r)}return n}function Bu(e,t,n,r){var c;const{textRuns:s}=e;if(s==null)return;const i=[],o=s.length;let a=!1;const l=(c=t.textRuns)!=null?c:[];if(l.length)for(const u of l)u.st+=r,u.ed+=r;for(let u=0;u<o;u++){const h=s[u],{st:d,ed:f}=h;if(f<=r)i.push(h);else if(r>d&&r<f){a=!0;const g={...h,ed:r};i.push(g),l.length&&i.push(...l);const _={...h,st:r+n,ed:f+n};i.push(_)}else h.st+=n,h.ed+=n,a||(a=!0,i.push(...l)),i.push(h)}a||(a=!0,i.push(...l)),e.textRuns=jr(i)}function $u(e,t,n,r){const{paragraphs:s}=e;if(s==null)return;const{paragraphs:i}=t,o=[];for(let l=0,c=s.length;l<c;l++){const u=s[l],{startIndex:h}=u;h>=r&&(u.startIndex+=n),o.push(u.startIndex)}let a=-1;if(i){for(let l=0,c=i.length;l<c;l++){const u=i[l];u.startIndex+=r;const h=u.startIndex;a=o.indexOf(h)}a!==-1&&s.splice(a,1),s.push(...i),s.sort(Hr("startIndex"))}}function Hu(e,t,n,r){const{sectionBreaks:s}=e;if(s==null)return;for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:c}=l;c>=r&&(l.startIndex+=n)}const i=t.sectionBreaks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=r}s.push(...i),s.sort(Hr("startIndex"))}}function ju(e,t,n,r){const{customBlocks:s=[]}=e;for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:c}=l;c>=r&&(l.startIndex+=n)}const i=t.customBlocks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=r}s.push(...i),s.sort(Hr("startIndex"))}s.length&&!e.customBlocks&&(e.customBlocks=s)}function Wu(e,t,n,r){const{tables:s}=e;if(s==null)return;for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:c,endIndex:u}=l;c>r?(l.startIndex+=n,l.endIndex+=n):u>r&&(l.endIndex+=n)}const i=t.tables;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=r,l.endIndex+=r}s.push(...i),s.sort(Hr("startIndex"))}}const Yu="$",Za=e=>e.split(Yu)[0];function zo(e){if(e.length<=1)return e;e.sort((s,i)=>s.startIndex-i.startIndex);const t=[];let n={...e[0]};n.rangeId=Za(n.rangeId);for(let s=1;s<e.length;s++){const i=e[s];i.rangeId=Za(i.rangeId),i.rangeId===n.rangeId&&Ul(n.properties,i.properties)&&n.endIndex+1>=i.startIndex?n.endIndex=i.endIndex:(t.push(n),n={...i})}t.push(n);const r=Object.create(null);for(let s=0,i=t.length;s<i;s++){const o=t[s],a=o.rangeId;r[a]?(o.rangeId=`${a}${Yu}${r[a]}`,r[a]=r[a]+1):r[a]=1}return t}function Wi(e,t){const n=e.findIndex(s=>s.startIndex<t&&s.endIndex>=t),r=e[n];r&&e.splice(n,1,{rangeId:r.rangeId,rangeType:r.rangeType,startIndex:r.startIndex,endIndex:t-1,properties:{...r.properties}},{rangeId:r.rangeId,rangeType:r.rangeType,startIndex:t,endIndex:r.endIndex,properties:{...r.properties}})}function Gu(e){if(e.length<=1)return e;e.sort((r,s)=>r.startIndex-s.startIndex);const t=[];let n={...e[0]};for(let r=1;r<e.length;r++){const s=e[r];s.id===n.id&&n.endIndex+1>=s.startIndex?n.endIndex=s.endIndex:(t.push(n),n={...s})}return t.push(n),t}function Yi(e,t){e.filter(r=>r.startIndex<t&&r.endIndex>=t).forEach(r=>{const s=e.indexOf(r);e.splice(s,1,{id:r.id,type:r.type,startIndex:r.startIndex,endIndex:t-1},{id:r.id,type:r.type,startIndex:t,endIndex:r.endIndex})})}function z_(e,t,n,r){e.customRanges||(e.customRanges=[]);const{customRanges:s}=e;Wi(s,r);for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:c}=l;c>=r&&(l.startIndex+=n,l.endIndex+=n)}const i=[];if(t.customRanges){for(let o=0,a=t.customRanges.length;o<a;o++){const l=t.customRanges[o];l.startIndex+=r,l.endIndex+=r,i.push(l)}s.push(...i)}e.customRanges=zo(s)}function K_(e,t,n,r){e.customDecorations||(e.customDecorations=[]);const{customDecorations:s}=e;Yi(s,r);for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:c}=l;c>=r&&(l.startIndex+=n,l.endIndex+=n)}const i=[];if(t.customDecorations){for(let o=0,a=t.customDecorations.length;o<a;o++){const l=t.customDecorations[o];l.startIndex+=r,l.endIndex+=r,i.push(l)}s.push(...i)}e.customDecorations=Gu(s)}function Vu(e,t,n){const{textRuns:r}=e,s=n,i=n+t,o=[];if(r){const a=[];for(let l=0,c=r.length;l<c;l++){const u=r[l],{st:h,ed:d}=u;if(s<=h&&i>=d){o.push({...u,st:h-s,ed:d-s});continue}else h<=s&&d>=i?(o.push({...u,st:s-s,ed:i-s}),u.ed-=t):s>=h&&s<d?(o.push({...u,st:s-s,ed:d-s}),u.ed=s):i>h&&i<=d?(o.push({...u,st:h-s,ed:i-s}),u.st=i-t,u.ed-=t):h>=i&&(u.st-=t,u.ed-=t);a.push(u)}e.textRuns=a}return o.length===0&&o.push({st:0,ed:t,ts:{}}),o}function zu(e,t,n){const{paragraphs:r}=e,s=n,i=n+t,o=[];if(r){const a=[];for(let l=0,c=r.length;l<c;l++){const u=r[l],{startIndex:h}=u;if(h>=s&&h<i){o.push({...u,startIndex:h-n});continue}else h>=i&&(u.startIndex-=t);a.push(u)}e.paragraphs=a}return o}function Ku(e,t,n){const{sectionBreaks:r}=e,s=n,i=n+t-1,o=[];if(r){const a=[];for(let l=0,c=r.length;l<c;l++){const u=r[l],{startIndex:h}=u;if(h>=s&&h<=i){o.push({...u,startIndex:h-n});continue}else h>i&&(u.startIndex-=t);a.push(u)}e.sectionBreaks=a}return o}function Xu(e,t,n){const{customBlocks:r=[]}=e,s=n,i=n+t-1,o=[];if(r){const a=[];for(let l=0,c=r.length;l<c;l++){const u=r[l],{startIndex:h}=u;if(h>=s&&h<=i){o.push({...u,startIndex:h-n});continue}else h>i&&(u.startIndex-=t);a.push(u)}e.customBlocks=a}return r.length&&!e.customBlocks&&(e.customBlocks=r),o}function qu(e,t,n){const{tables:r}=e,s=n,i=n+t-1,o=[];if(r){const a=[];for(let l=0,c=r.length;l<c;l++){const u=r[l],{startIndex:h,endIndex:d}=u;if(s<=h&&i>=d){o.push({...u,startIndex:h-n,endIndex:d-n});continue}else if(h<=s&&d>=i){const f=Hs(h,d,s,i);if(f.length===0||(u.startIndex=f[0],u.endIndex=f[1],u.startIndex===u.endIndex))continue}else i<h&&(u.startIndex-=t,u.endIndex-=t);a.push(u)}e.tables=a}return o}function X_(e,t,n){const{customRanges:r}=e,s=n,i=n+t-1,o=[];if(r){const a=[];for(let l=0,c=r.length;l<c;l++){const u=r[l],{startIndex:h,endIndex:d}=u;if(h>=s&&d<=i){o.push(u);continue}else if(Math.max(s,h)<=Math.min(i,d)){const f=Hs(h,d,s,i);if(f.length===0)continue;u.startIndex=f[0],u.endIndex=f[1]}else i<h&&(u.startIndex-=t,u.endIndex-=t);a.push(u)}e.customRanges=zo(a)}return o}function q_(e,t,n,r=!0){const{customDecorations:s}=e,i=n,o=n+t-1,a=[];if(s){const l=[];for(let c=0,u=s.length;c<u;c++){const h=s[c],{startIndex:d,endIndex:f}=h;if(d>=i&&f<=o){a.push(h);continue}else if(Math.max(i,d)<=Math.min(o,f)){const g=Hs(d,f,i,o);if(g.length===0)continue;h.startIndex=g[0],h.endIndex=g[1]}else o<d&&r&&(h.startIndex-=t,h.endIndex-=t);l.push(h)}e.customDecorations=l}return a}var Zu=(e=>(e.ORDER_LIST_QUICK_1="1.",e.ORDER_LIST_QUICK_2="a)",e.ORDER_LIST_QUICK_3="a.",e.ORDER_LIST_QUICK_4="i.",e.ORDER_LIST_QUICK_5="A.",e.ORDER_LIST_QUICK_6="I.",e.ORDER_LIST_QUICK_7="01.",e.BULLET_LIST="*",e))(Zu||{}),kt=(e=>(e.BULLET_LIST="BULLET_LIST",e.BULLET_LIST_1="BULLET_LIST_1",e.BULLET_LIST_2="BULLET_LIST_2",e.BULLET_LIST_3="BULLET_LIST_3",e.BULLET_LIST_4="BULLET_LIST_4",e.BULLET_LIST_5="BULLET_LIST_5",e.ORDER_LIST="ORDER_LIST",e.ORDER_LIST_1="ORDER_LIST_1",e.ORDER_LIST_2="ORDER_LIST_2",e.ORDER_LIST_3="ORDER_LIST_3",e.ORDER_LIST_4="ORDER_LIST_4",e.ORDER_LIST_5="ORDER_LIST_5",e.ORDER_LIST_QUICK_2="ORDER_LIST_QUICK_2",e.ORDER_LIST_QUICK_3="ORDER_LIST_QUICK_3",e.ORDER_LIST_QUICK_4="ORDER_LIST_QUICK_4",e.ORDER_LIST_QUICK_5="ORDER_LIST_QUICK_5",e.ORDER_LIST_QUICK_6="ORDER_LIST_QUICK_6",e.CHECK_LIST="CHECK_LIST",e.CHECK_LIST_CHECKED="CHECK_LIST_CHECKED",e))(kt||{});const is={"a)":{glyphFormat:"%1)",glyphType:fe.DECIMAL},"1.":{glyphType:fe.DECIMAL},"a.":{glyphFormat:"%1.",glyphType:fe.LOWER_LETTER},"A.":{glyphType:fe.UPPER_LETTER},"i.":{glyphFormat:"%1.",glyphType:fe.LOWER_ROMAN},"I.":{glyphFormat:"%1.",glyphType:fe.UPPER_LETTER}},yn=e=>[...e,...e,...e].map((t,n)=>({glyphFormat:` %${n+1}`,glyphSymbol:t,bulletAlignment:$r.START,textStyle:{fs:12},startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*n}}})),Nn=e=>e.map((t,n)=>({...t,bulletAlignment:$r.START,textStyle:{fs:12},startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*n}}})),Ja=(e,t)=>new Array(9).fill(0).map((n,r)=>({glyphFormat:` %${r+1}`,glyphSymbol:e,bulletAlignment:$r.START,textStyle:{fs:16},startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*r},textStyle:t}})),Wr={BULLET_LIST:{listType:"BULLET_LIST",nestingLevel:yn(["●","○","■"])},BULLET_LIST_1:{listType:"BULLET_LIST",nestingLevel:yn(["❖","➢","■"])},BULLET_LIST_2:{listType:"BULLET_LIST",nestingLevel:yn(["✔","●","◆"])},BULLET_LIST_3:{listType:"BULLET_LIST",nestingLevel:yn(["■","◆","○"])},BULLET_LIST_4:{listType:"BULLET_LIST",nestingLevel:yn(["✧","○","■"])},BULLET_LIST_5:{listType:"BULLET_LIST",nestingLevel:yn(["➢","○","◆"])},ORDER_LIST:{listType:"ORDER_LIST",nestingLevel:Nn([{glyphFormat:"%1.",glyphType:fe.DECIMAL},{glyphFormat:"%2.",glyphType:fe.LOWER_LETTER},{glyphFormat:"%3.",glyphType:fe.LOWER_ROMAN},{glyphFormat:"%4.",glyphType:fe.DECIMAL},{glyphFormat:"%5.",glyphType:fe.LOWER_LETTER},{glyphFormat:"%6.",glyphType:fe.LOWER_ROMAN},{glyphFormat:"%7.",glyphType:fe.DECIMAL},{glyphFormat:"%8.",glyphType:fe.LOWER_LETTER},{glyphFormat:"%9.",glyphType:fe.LOWER_ROMAN}])},ORDER_LIST_1:{listType:"ORDER_LIST",nestingLevel:Nn([{glyphFormat:"%1)",glyphType:fe.DECIMAL},{glyphFormat:"%2)",glyphType:fe.LOWER_LETTER},{glyphFormat:"%3)",glyphType:fe.LOWER_ROMAN},{glyphFormat:"%4)",glyphType:fe.DECIMAL},{glyphFormat:"%5)",glyphType:fe.LOWER_LETTER},{glyphFormat:"%6)",glyphType:fe.LOWER_ROMAN},{glyphFormat:"%7)",glyphType:fe.DECIMAL},{glyphFormat:"%8)",glyphType:fe.LOWER_LETTER},{glyphFormat:"%9)",glyphType:fe.LOWER_ROMAN}])},ORDER_LIST_2:{listType:"ORDER_LIST",nestingLevel:Nn(["%1.","%1.%2.","%1.%2.%3.","%1.%2.%3.%4.","%1.%2.%3.%4.%5.","%1.%2.%3.%4.%5.%6.","%1.%2.%3.%4.%5.%6.%7."].map(e=>({glyphFormat:e,glyphType:fe.DECIMAL})))},ORDER_LIST_3:{listType:"ORDER_LIST",nestingLevel:Nn([{glyphFormat:"%1.",glyphType:fe.UPPER_LETTER},{glyphFormat:"%2.",glyphType:fe.LOWER_LETTER},{glyphFormat:"%3.",glyphType:fe.LOWER_ROMAN},{glyphFormat:"%4.",glyphType:fe.UPPER_LETTER},{glyphFormat:"%5.",glyphType:fe.LOWER_LETTER},{glyphFormat:"%6.",glyphType:fe.LOWER_ROMAN},{glyphFormat:"%7.",glyphType:fe.UPPER_LETTER},{glyphFormat:"%8.",glyphType:fe.LOWER_LETTER},{glyphFormat:"%9.",glyphType:fe.LOWER_ROMAN}])},ORDER_LIST_4:{listType:"ORDER_LIST",nestingLevel:Nn([{glyphFormat:"%1.",glyphType:fe.UPPER_LETTER},{glyphFormat:"%2.",glyphType:fe.DECIMAL},{glyphFormat:"%3.",glyphType:fe.LOWER_ROMAN},{glyphFormat:"%4.",glyphType:fe.UPPER_LETTER},{glyphFormat:"%5.",glyphType:fe.DECIMAL},{glyphFormat:"%6.",glyphType:fe.LOWER_ROMAN},{glyphFormat:"%7.",glyphType:fe.UPPER_LETTER},{glyphFormat:"%8.",glyphType:fe.DECIMAL},{glyphFormat:"%9.",glyphType:fe.LOWER_ROMAN}])},ORDER_LIST_5:{listType:"ORDER_LIST",nestingLevel:Nn([{glyphFormat:"%1.",glyphType:fe.DECIMAL_ZERO},{glyphFormat:"%2.",glyphType:fe.LOWER_LETTER},{glyphFormat:"%3.",glyphType:fe.LOWER_ROMAN},{glyphFormat:"%4.",glyphType:fe.DECIMAL_ZERO},{glyphFormat:"%5.",glyphType:fe.LOWER_LETTER},{glyphFormat:"%6.",glyphType:fe.LOWER_ROMAN},{glyphFormat:"%7.",glyphType:fe.DECIMAL_ZERO},{glyphFormat:"%8.",glyphType:fe.LOWER_LETTER},{glyphFormat:"%9.",glyphType:fe.LOWER_ROMAN}])},CHECK_LIST:{listType:"CHECK_LIST",nestingLevel:Ja("☐")},CHECK_LIST_CHECKED:{listType:"CHECK_LIST_CHECKED",nestingLevel:Ja("☑",{st:{s:ie.TRUE}})}},os=e=>{const{glyphFormat:t,glyphType:n}=e,r=q.deepClone(Wr.ORDER_LIST);return r.nestingLevel[0].glyphFormat=t,r.nestingLevel[0].glyphType=n,r},Z_={ORDER_LIST_QUICK_2:os(is["a)"]),ORDER_LIST_QUICK_3:os(is["a."]),ORDER_LIST_QUICK_4:os(is["i."]),ORDER_LIST_QUICK_6:os(is["I."])};Object.assign(Wr,Z_);const J_={"1.":"ORDER_LIST","a)":"ORDER_LIST_QUICK_2","a.":"ORDER_LIST_QUICK_3","i.":"ORDER_LIST_QUICK_4","A.":"ORDER_LIST_3","I.":"ORDER_LIST_QUICK_6","01.":"ORDER_LIST_5","*":"BULLET_LIST"};function Q_(e,t,n,r,s){const i=ep(e,t,n,r,s),o=tp(e,t,n,r,s),a=np(e,t,n,r,s),l=rp(e,t,n,r,s),c=sp(e,t,n,r,s),u=ip(e,t,n,r),h=op(e,t,n,r,s);return{dataStream:"",textRuns:i,paragraphs:o,sectionBreaks:a,customBlocks:l,tables:c,customRanges:u,customDecorations:h}}function ep(e,t,n,r,s){const{textRuns:i}=e,{textRuns:o}=t;if(i==null||o==null)return;const a=Vu(e,n,r);if(s!==Ee.REPLACE){const l=Ju(o,a,s);t.textRuns=l}return Bu(e,t,n,r),a}function Ju(e,t,n){if(t.length===0)return e;e=q.deepClone(e),t=q.deepClone(t);const r=[],s=e.length,i=t.length;let o=0,a=0,l=null;function c(){return l?(r.push(l),l=null,!0):!1}for(;o<s&&a<i;){const{st:f,ed:g,ts:_}=e[o],{st:R,ed:b,ts:F,sId:k}=t[a];let W;if(n===Ee.COVER?W={...F,..._}:W={..._},g<R)c()||r.push(e[o]),o++;else if(b<f)c()||r.push(t[a]),a++;else{const S={st:Math.min(f,R),ed:Math.max(f,R),ts:f<R?{..._}:{...F},sId:f<R?void 0:k};S.ed>S.st&&r.push(S),r.push({st:Math.max(f,R),ed:Math.min(g,b),ts:W,sId:k}),g<b?(o++,t[a].st=g,t[a].st===t[a].ed&&a++):(a++,e[o].st=b,e[o].st===e[o].ed&&o++);const C={st:Math.min(g,b),ed:Math.max(g,b),ts:g<b?{...F}:{..._},sId:g<b?k:void 0};l=C.ed>C.st?C:null}}c();const u=r[r.length-1],h=e[s-1],d=t[i-1];return u&&u.ed!==Math.max(h.ed,d.ed)&&(h.ed>d.ed?r.push(h):r.push(d)),jr(r)}function tp(e,t,n,r,s){const{paragraphs:i}=e,{paragraphs:o}=t;if(i==null||o==null)return;const a=zu(e,n,r);if(s!==Ee.REPLACE){const l=[];for(const c of o){const{startIndex:u,paragraphStyle:h,bullet:d}=c;let f=[];for(const g of a){const{startIndex:_,paragraphStyle:R,bullet:b}=g;let F,k;if(s===Ee.COVER?(F={...R,...h},k={listId:"",listType:kt.BULLET_LIST,nestingLevel:0,textStyle:{},...b,...d}):(F={...h,...R},k={listId:"",listType:kt.BULLET_LIST,nestingLevel:0,textStyle:{},...d,...b}),u===_){f.push({startIndex:u,paragraphStyle:F,bullet:k});break}}l.push(...f),f=[]}t.paragraphs=l}return $u(e,t,n,r),a}function np(e,t,n,r,s){const{sectionBreaks:i}=e,{sectionBreaks:o}=t;if(i==null||o==null)return;const a=Ku(e,n,r);if(s!==Ee.REPLACE){const l=[];for(const c of o){const{startIndex:u}=c;let h=[];for(const d of a){const{startIndex:f}=d;if(u===f){s===Ee.COVER?h.push({...d,...c}):h.push({...c,...d});break}}l.push(...h),h=[]}t.sectionBreaks=l}return Hu(e,t,n,r),a}function rp(e,t,n,r,s){const{customBlocks:i=[]}=e,{customBlocks:o}=t;if(i==null||o==null)return;const a=Xu(e,n,r);if(s!==Ee.REPLACE){const l=[];for(const c of o){const{startIndex:u}=c;let h=[];for(const d of a){const{startIndex:f}=d;if(u===f){s===Ee.COVER?h.push({...d,...c}):h.push({...c,...d});break}}l.push(...h),h=[]}t.customBlocks=l}return ju(e,t,n,r),i.length&&!e.customBlocks&&(e.customBlocks=i),a}function sp(e,t,n,r,s){const{tables:i}=e,{tables:o}=t;if(i==null||o==null)return;const a=qu(e,n,r);if(s!==Ee.REPLACE){const l=[];for(const c of o){const{startIndex:u,endIndex:h}=c;let d=[];for(const f of a){const{startIndex:g,endIndex:_}=f;if(g>=u&&_<=h){s===Ee.COVER?d.push({...f,...c}):d.push({...c,...f});break}}l.push(...d),d=[]}t.tables=l}return Wu(e,t,n,r),a}function ip(e,t,n,r,s){e.customRanges||(e.customRanges=[]),Wi(e.customRanges,r),Wi(e.customRanges,r+n);const i=r,o=r+n-1,{customRanges:a}=t,l=[],c=new Map;e.customRanges.forEach(h=>{const{startIndex:d,endIndex:f}=h;d>=i&&f<=o?c.set(h.rangeId,h):l.push(h)});const u=[];return a?(a.forEach(h=>{const{startIndex:d,endIndex:f}=h;l.push({...h,startIndex:d+r,endIndex:f+r})}),e.customRanges=zo(l),u):[]}function op(e,t,n,r,s){e.customDecorations||(e.customDecorations=[]),Yi(e.customDecorations,r),Yi(e.customDecorations,r+n);const i=[],{customDecorations:o}=e,{customDecorations:a=[]}=t;if(s===Ee.REPLACE){for(let l=0;l<o.length;l++){const c=o[l],{startIndex:u,endIndex:h}=c;u>=r&&h<=r+n-1&&i.push(c)}a.forEach(l=>{const{startIndex:c,endIndex:u}=l;o.push({...l,startIndex:c+r,endIndex:u+r})})}else for(const l of a){const{id:c}=l;if(l.type===pn.DELETED){const u=o.filter(h=>h.id===c);u.length&&i.push(...u)}else o.push({...l,startIndex:l.startIndex+r,endIndex:l.endIndex+r})}for(const l of i){const{id:c}=l,u=o.findIndex(h=>h.id===c);u!==-1&&o.splice(u,1)}return e.customDecorations=Gu(o),i}var Ko=(e=>(e[e.copy=0]="copy",e[e.cut=1]="cut",e))(Ko||{});function Ds(e,t,n,r=!0){const{textRuns:s}=e;if(s){const i=[];for(const o of s){const a=q.deepClone(o),{st:l,ed:c}=a;q.hasIntersectionBetweenTwoRanges(l,c,t,n)&&(t>=l&&t<=c?i.push({...a,st:t,ed:Math.min(n,c)}):n>=l&&n<=c?i.push({...a,st:Math.max(t,l),ed:n}):i.push(a))}return jr(i.map(o=>{const{st:a,ed:l}=o;return{...o,st:a-t,ed:l-t}}))}else if(r)return[{st:0,ed:n-t,ts:{}}]}function Qu(e,t,n){const{tables:r=[]}=e,s=[];for(const i of r){const o=q.deepClone(i),{startIndex:a,endIndex:l}=o;a>=t&&l<=n&&s.push({...o,startIndex:a-t,endIndex:l-t})}return s}function eh(e,t,n){const{paragraphs:r=[]}=e,s=[];for(const i of r){const{startIndex:o}=i;if(o>=t&&o<n){const a=q.deepClone(i);s.push(a)}}if(s.length)return s.map(i=>({...i,startIndex:i.startIndex-t}))}function ap(e,t,n){const{sectionBreaks:r=[]}=e,s=[];for(const i of r){const{startIndex:o}=i;o>=t&&o<=n&&s.push(q.deepClone(i))}if(s.length)return s.map(i=>({...i,startIndex:i.startIndex-t}))}function th(e,t,n){const{customBlocks:r=[]}=e,s=[];for(const i of r){const{startIndex:o}=i;o>=t&&o<n&&s.push(q.deepClone(i))}if(s.length)return s.map(i=>({...i,startIndex:i.startIndex-t}))}function yt(e,t,n,r=!0,s=1){const{dataStream:i}=e,o={dataStream:i.slice(t,n)};o.textRuns=Ds(e,t,n,r);const a=Qu(e,t,n);if(a.length&&(o.tables=a),o.paragraphs=eh(e,t,n),s===1){const c=rh(e,t,n);c?o.customDecorations=c:r&&(o.customDecorations=[])}const{customRanges:l}=nh(e,t,n);return l?o.customRanges=l:r&&(o.customRanges=[]),o.customBlocks=th(e,t,n),o}function lp(e){const{dataStream:t,textRuns:n,paragraphs:r,customRanges:s,customDecorations:i,tables:o}=e;let a=0,l=0;s==null||s.forEach(u=>{u.startIndex<0&&(a=Math.max(a,-u.startIndex)),u.endIndex>t.length-1&&(l=Math.max(l,u.endIndex-t.length+1))});const c=`${t}`;return n&&(n[0]&&(n[0].st=n[0].st-a),n[n.length-1]&&(n[n.length-1].ed=n[n.length-1].ed+l)),n==null||n.forEach(u=>{u.st+=a,u.ed+=a}),r==null||r.forEach(u=>{u.startIndex+=a}),s==null||s.forEach(u=>{u.startIndex+=a,u.endIndex+=a}),i==null||i.forEach(u=>{u.startIndex+=a,u.endIndex+=l}),o==null||o.forEach(u=>{u.startIndex+=a,u.endIndex+=l}),{...e,dataStream:c,textRuns:n,paragraphs:r,customRanges:s,customDecorations:i,tables:o}}function nh(e,t,n){if(e.customRanges==null)return{};const{customRanges:r}=e;return{customRanges:r.filter(a=>Math.max(a.startIndex,t)<=Math.min(a.endIndex,n-1)).map(a=>({...a,startIndex:Math.max(a.startIndex,t),endIndex:Math.min(a.endIndex,n-1)})).map(a=>({...a,startIndex:a.startIndex-t,endIndex:a.endIndex-t})),leftOffset:0,rightOffset:0}}function rh(e,t,n){if(e.customDecorations==null)return;const{customDecorations:r=[]}=e,s=[];return r.forEach(i=>{if(Math.max(i.startIndex,t)<=Math.min(i.endIndex,n-1)){const o=q.deepClone(i);s.push({...o,startIndex:Math.max(o.startIndex-t,0),endIndex:Math.min(o.endIndex,n-1)-t})}}),s}function cp(e,t,n){return e==null||t==null?e!=null?e:t:Ju(e,t,n)}function up(e,t,n){if(e==null||t==null)return e!=null?e:t;if(t.length===0||e.length===0)return e;if(t.length>1||e.length>1)throw new Error("Cannot cover multiple customRanges");return n===Ee.REPLACE?[{...e[0]}]:[{...t[0],...e[0]}]}function hp(e,t,n){return t.length===0||e.length===0||n===Ee.REPLACE?e:[...e,...t.filter(r=>!e.some(s=>r.id===s.id))]}function Gi(e,t,n=Ee.COVER){if(t.dataStream!=="")throw new Error("Cannot compose other body with non-empty dataStream");const r={dataStream:e.dataStream},{textRuns:s,paragraphs:i=[],customRanges:o,customDecorations:a=[]}=e,{textRuns:l,paragraphs:c=[],customRanges:u,customDecorations:h=[]}=t;r.textRuns=cp(l,s,n),r.customRanges=up(u,o,n);const d=hp(h,a,n);d.length&&(r.customDecorations=d);const f=[];let g=0,_=0;for(;g<i.length&&_<c.length;){const R=i[g],b=c[_],{startIndex:F}=R,{startIndex:k}=b;F===k?(f.push(q.deepMerge(R,b)),g++,_++):F<k?(f.push(q.deepClone(R)),g++):(f.push(q.deepClone(b)),_++)}return g<i.length&&f.push(...i.slice(g)),_<c.length&&f.push(...c.slice(_)),f.length&&(r.paragraphs=f),r}function dp(e){const{body:t}=e;if(t==null)return!0;const{textRuns:n,paragraphs:r,customRanges:s,customBlocks:i,customDecorations:o,tables:a}=t;return n==null&&r==null&&s==null&&i==null&&o==null&&a==null}class xn{constructor(t){p(this,"_index",0);p(this,"_offset",0);this._actions=t}hasNext(){return this.peekLength()<Number.POSITIVE_INFINITY}next(t){t||(t=Number.POSITIVE_INFINITY);const n=this._actions[this._index];if(n){const r=this._offset,s=n.len;return t>=s-r?(t=s-r,this._index+=1,this._offset=0):this._offset+=t,n.t===Z.DELETE||n.t===Z.RETAIN&&n.body==null?q.deepClone({...n,len:t}):q.deepClone({...n,len:t,body:yt(n.body,r,r+t,!1)})}else return{t:Z.RETAIN,len:Number.POSITIVE_INFINITY}}peek(){return this._actions[this._index]}peekLength(){return this._actions[this._index]?this._actions[this._index].len-this._offset:Number.POSITIVE_INFINITY}peekType(){const t=this._actions[this._index];return t?t.t:Z.RETAIN}rest(){if(this.hasNext()){if(this._offset===0)return this._actions.slice(this._index);{const t=this._offset,n=this._index,r=this.next(),s=this._actions.slice(this._index);return this._offset=t,this._index=n,[r].concat(s)}}else return[]}}function sh(e,t,n){const{dataStream:r}=e,s=n,i=n+t,o=Vu(e,t,n),a=zu(e,t,n),l=Ku(e,t,n),c=Xu(e,t,n),u=qu(e,t,n),h=X_(e,t,n),d=q_(e,t,n);let f="";return r&&(e.dataStream=yc(r,s,i),f=r.slice(s,i)),{dataStream:f,textRuns:o,paragraphs:a,sectionBreaks:l,customBlocks:c,tables:u,customRanges:h,customDecorations:d}}function ih(e,t,n,r){e.dataStream=Tc(e.dataStream,r,t.dataStream),Bu(e,t,n,r),$u(e,t,n,r),Hu(e,t,n,r),ju(e,t,n,r),Wu(e,t,n,r),z_(e,t,n,r),K_(e,t,n,r)}function fp(e,t,n,r,s=Ee.COVER){return Q_(e,t,n,r,s)}function mp(e,t,n){return t<=0?{dataStream:""}:sh(e,t,n)}function gp(e,t,n,r){n!==0&&ih(e,t,n,r)}function _p(e,t){const n=new On;return n.reset(),t.forEach(r=>{const s=q.deepClone(r);switch(s.t){case Z.RETAIN:{const{coverType:i,body:o,len:a}=s;o!=null&&fp(e,o,a,n.cursor,i),n.moveCursor(a);break}case Z.INSERT:{const{body:i,len:o}=s;gp(e,i,o,n.cursor),n.moveCursor(o);break}case Z.DELETE:{const{len:i}=s;mp(e,i,n.cursor);break}default:throw new Error(`Unknown action type for action: ${s}.`)}}),e}function pp(e,t,n,r,s){if(e==null||t==null)return t;if(e.length===0||t.length===0)return[];t=q.deepClone(t),e=q.deepClone(e);const i=[],o=t.length,a=e.length;let l=0,c=0,u=null;function h(){return u?(i.push(u),u=null,!0):!1}for(;l<o&&c<a;){const{st:_,ed:R,ts:b}=t[l],{st:F,ed:k,ts:W,sId:S}=e[c];let C={};if(s===0)C={...b},n===Ee.COVER&&r===Ee.REPLACE&&W&&(C=Object.assign({},W,C));else if(C={...b},n===Ee.REPLACE){if(r===Ee.REPLACE)C={...W};else if(b&&W){const w=Object.keys(b);for(const T of w)W[T]&&delete C[T]}}else if(r===Ee.REPLACE){if(W){const w=Object.keys(W);for(const T of w)W[T]!==void 0&&(C[T]=W[T])}}else if(W){const w=Object.keys(W);for(const T of w)C[T]!==void 0&&delete C[T]}if(R<F)h()||i.push(t[l]),l++;else if(k<_)h()||i.push(e[c]),c++;else{const w={st:Math.min(_,F),ed:Math.max(_,F),ts:_<F?{...b}:{...W}};w.ed>w.st&&i.push(),i.push({st:Math.max(_,F),ed:Math.min(R,k),ts:C,sId:S}),R<k?(l++,e[c].st=R,e[c].st===e[c].ed&&c++):(c++,t[l].st=k,t[l].st===t[l].ed&&l++);const T={st:Math.min(R,k),ed:Math.max(R,k),ts:R<k?{...W}:{...b},sId:R<k?S:void 0};u=T.ed>T.st?T:null}}h();const d=i[i.length-1],f=t[o-1],g=e[a-1];return d.ed!==Math.max(f.ed,g.ed)&&(f.ed>g.ed?i.push(f):i.push(g)),jr(i,!0)}function Ep(e,t,n,r,s){if(e==null||t==null)return t;if(e.length===0||t.length===0)return[];if(e.length>1||t.length>1)throw new Error("CustomRanges is only supported transform for length one now.");const i=e[0],o=t[0];if(n===Ee.REPLACE)return s===1?[q.deepClone(i)]:[q.deepClone(o)];if(r===Ee.REPLACE){const a=q.deepClone(o);return s===1&&Object.assign(a,q.deepClone(i)),[a]}else{const a=q.deepClone(o);return s===1&&Object.assign(a,q.deepClone(i)),[a]}}function Qa(e,t,n,r,s){const i={startIndex:t.startIndex};if(t.paragraphStyle&&(i.paragraphStyle=q.deepClone(t.paragraphStyle),e.paragraphStyle)){if(n===Ee.REPLACE)if(r===Ee.REPLACE)s===1&&(i.paragraphStyle={...e.paragraphStyle});else if(s===1){const o=Object.keys(e.paragraphStyle);for(const a of o)e.paragraphStyle[a]!==void 0&&(i.paragraphStyle[a]=e.paragraphStyle[a])}else{const o=Object.keys(e.paragraphStyle);for(const a of o)i.paragraphStyle[a]===void 0&&(i.paragraphStyle[a]=e.paragraphStyle[a])}else if(r===Ee.REPLACE)if(s===1){const o=Object.keys(e.paragraphStyle);for(const a of o)e.paragraphStyle[a]!==void 0&&(i.paragraphStyle[a]=e.paragraphStyle[a])}else{const o=Object.keys(e.paragraphStyle);for(const a of o)i.paragraphStyle[a]===void 0&&(i.paragraphStyle[a]=e.paragraphStyle[a])}else if(s===1){const o=Object.keys(e.paragraphStyle);for(const a of o)i.paragraphStyle[a]&&delete i.paragraphStyle[a]}}return n===Ee.REPLACE&&r===Ee.REPLACE?i.bullet=s===1?q.deepClone(e.bullet):q.deepClone(t.bullet):e.bullet===void 0?i.bullet=q.deepClone(t.bullet):n===Ee.REPLACE||r===Ee.REPLACE?i.bullet=s===0&&t.bullet?q.deepClone(t.bullet):q.deepClone(e.bullet):s===0&&t.bullet!==void 0&&(i.bullet=q.deepClone(t.bullet)),i}function Cp(e,t){if(e==null||t==null)return t;if(e.length===0||t.length===0)return q.deepClone(t);const n=[];for(const r of t){const{id:s,type:i}=r;let o=!1;for(const a of e)if(a.id===s){(a.type===pn.DELETED||i===pn.DELETED)&&(o=!0,n.push({...r,type:pn.DELETED}));break}o||n.push(r)}return n}function Rp(e,t,n=!1){const{body:r,coverType:s=Ee.COVER}=e,{body:i,coverType:o=Ee.COVER}=t;if(r==null||r.dataStream!==""||i==null||i.dataStream!=="")throw new Error("Data stream is not supported in retain transform.");const a={dataStream:""},l=o,{textRuns:c,paragraphs:u=[],customRanges:h,customDecorations:d}=r,{textRuns:f,paragraphs:g=[],customRanges:_,customDecorations:R}=i,b=pp(c,f,s,o,n?1:0);b&&(a.textRuns=b);const F=Ep(h,_,s,o,n?1:0);F&&(a.customRanges=F);const k=Cp(d,R);k&&(a.customDecorations=k);const W=[];let S=0,C=0;for(;S<u.length&&C<g.length;){const w=u[S],T=g[C],{startIndex:B}=w,{startIndex:$}=T;if(B===$){let m={startIndex:B};n?m=Qa(w,T,s,o,1):m=Qa(w,T,s,o,0),W.push(m),S++,C++}else B<$?S++:(W.push(q.deepClone(T)),C++)}return C<g.length&&W.push(...g.slice(C)),W.length&&(a.paragraphs=W),{coverType:l,body:a}}function el(e){return Object.keys(e).length===1}const jn=class jn{constructor(){p(this,"_actions",[])}static apply(t,n){return _p(t,n)}static compose(t,n){const r=new xn(t),s=new xn(n),i=new jn;for(;r.hasNext()||s.hasNext();)if(s.peekType()===Z.INSERT)i.push(s.next());else if(r.peekType()===Z.DELETE)i.push(r.next());else{const o=Math.min(r.peekLength(),s.peekLength()),a=r.next(o),l=s.next(o);if(a.t===Z.INSERT&&l.t===Z.RETAIN)l.body==null?i.push(a):i.push({...a,body:Gi(a.body,l.body,l.coverType)});else if(a.t===Z.RETAIN&&l.t===Z.RETAIN)if(a.body==null&&l.body==null)i.push(a.len!==Number.POSITIVE_INFINITY?a:l);else if(a.body&&l.body){const c=a.coverType===Ee.REPLACE||l.coverType===Ee.REPLACE?Ee.REPLACE:Ee.COVER;i.push({...a,t:Z.RETAIN,coverType:c,body:Gi(a.body,l.body,l.coverType)})}else i.push(a.body?a:l);else a.t===Z.RETAIN&&l.t===Z.DELETE?i.push(l):a.t===Z.INSERT&&(l.t,Z.DELETE)}return i.trimEndUselessRetainAction(),i.serialize()}static transform(t,n,r="right"){return this._transform(n,t,r==="left"?"right":"left")}static _transform(t,n,r="right"){const s=new xn(t),i=new xn(n),o=new jn;for(;s.hasNext()||i.hasNext();)if(s.peekType()===Z.INSERT&&(r==="left"||i.peekType()!==Z.INSERT)){const a=s.next();o.retain(a.len)}else if(i.peekType()===Z.INSERT)o.push(i.next());else{const a=Math.min(s.peekLength(),i.peekLength()),l=s.next(a),c=i.next(a);if(l.t===Z.DELETE)continue;if(c.t===Z.DELETE){o.push(c);continue}if(l.body==null||c.body==null)o.push(c);else{const{coverType:u,body:h}=Rp(l,c,r==="left");o.push({...c,t:Z.RETAIN,coverType:u,body:h})}}return o.trimEndUselessRetainAction(),o.serialize()}static transformPosition(t,n,r=!1){const s=new xn(t);let i=0;for(;s.hasNext()&&i<=n;){const o=s.peekLength(),a=s.peekType();if(s.next(),a===Z.DELETE){n-=Math.min(o,n-i);continue}else a===Z.INSERT&&(i<n||!r)&&(n+=o);i+=o}return n}static isNoop(t){return t.length===0}static invert(t){const n=[];for(const r of t)if(r.t===Z.INSERT)n.push({t:Z.DELETE,len:r.len,body:r.body});else if(r.t===Z.DELETE){if(r.body==null)throw new Error("Can not invert DELETE action without body property, makeInvertible must be called first.");n.push({t:Z.INSERT,body:r.body,len:r.len})}else if(r.body!=null){if(r.oldBody==null)throw new Error("Can not invert RETAIN action without oldBody property, makeInvertible must be called first.");n.push({t:Z.RETAIN,body:r.oldBody,oldBody:r.body,len:r.len,coverType:Ee.REPLACE})}else n.push(r);return n}static makeInvertible(t,n){const r=[];let s=0;for(const i of t){if(i.t===Z.DELETE&&(i.body==null||i.body&&i.body.dataStream.length!==i.len)){const o=yt(n,s,s+i.len,!1);i.len=o.dataStream.length,i.body=o}if(i.t===Z.RETAIN&&i.body!=null){const o=yt(n,s,s+i.len,!0);i.oldBody={...o,dataStream:""},i.len=o.dataStream.length}r.push(i),i.t!==Z.INSERT&&(s+=i.len)}return r}insert(t,n){const r={t:Z.INSERT,body:n,len:t};return this.push(r),this}retain(t,n,r){const s={t:Z.RETAIN,len:t};return n!=null&&(s.body=n),r!=null&&(s.coverType=r),this.push(s),this}delete(t){const n={t:Z.DELETE,len:t};return this.push(n),this}empty(){return this._actions=[],this}serialize(){return this._actions}push(...t){if(t.length>1){for(const i of t)this.push(i);return this}let n=this._actions.length,r=this._actions[n-1];const s=q.deepClone(t[0]);if(s.t===Z.RETAIN&&s.len===0&&s.body==null)return this;if(typeof r=="object"){if(r.t===Z.DELETE&&s.t===Z.DELETE)return r.len+=s.len,this;if(r.t===Z.DELETE&&s.t===Z.INSERT&&(n-=1,r=this._actions[n-1],r==null))return this._actions.unshift(s),this;if(r.t===Z.RETAIN&&s.t===Z.RETAIN&&r.body==null&&s.body==null)return r.len+=s.len,this;if(r.t===Z.INSERT&&el(r.body)&&s.t===Z.INSERT&&el(s.body))return r.len+=s.len,r.body.dataStream+=s.body.dataStream,this}return n===this._actions.length?this._actions.push(s):this._actions.splice(n,0,s),this}trimEndUselessRetainAction(){let t=this._actions[this._actions.length-1];for(;t&&t.t===Z.RETAIN&&dp(t);)this._actions.pop(),t=this._actions[this._actions.length-1];return this}};p(jn,"id","text-x"),p(jn,"uri","https://github.com/dream-num/univer#text-x");let Me=jn;Object.defineProperty(Me,"name",{value:"text-x"});const Wn=class Wn{static registerSubtype(t){var n;t==null||this._subTypes.has(t.name)&&((n=this._subTypes.get(t.name))==null?void 0:n.id)!==Me.id||(this._subTypes.set(t.name,t),ot.type.registerSubtype(t))}static apply(t,n){if(!ot.type.isNoop(n))return ot.type.apply(t,n)}static compose(t,n){return ot.type.compose(t,n)}static transform(t,n,r){return ot.type.transform(t,n,r)}static transformPosition(t,n,r="right"){return t&&t.length===2&&t[0]==="body"&&t[1].et===Me.name?Me.transformPosition(t[1].e,n,r==="left"):n}static invertWithDoc(t,n){return ot.type.invertWithDoc(t,n)}static isNoop(t){return ot.type.isNoop(t)}static getInstance(){return this._instance==null&&(this._instance=new Wn),this._instance}removeOp(t,n){return ot.removeOp(t,n)}moveOp(t,n){return ot.moveOp(t,n)}insertOp(t,n){return ot.insertOp(t,n)}replaceOp(t,n,r){return ot.replaceOp(t,n,r)}editOp(t,n=["body"]){return ot.editOp(n,Me.name,t)}};p(Wn,"uri","https://github.com/dream-num/univer#json-x"),p(Wn,"_subTypes",new Map),p(Wn,"_instance",null);let Gt=Wn;Gt.registerSubtype(Me);var oh=(e=>(e.PARAGRAPH="PARAGRAPH",e.SECTION_BREAK="SECTION_BREAK",e.TABLE="TABLE",e.TABLE_ROW="TABLE_ROW",e.TABLE_CELL="TABLE_CELL",e.CUSTOM_BLOCK="CUSTOM_BLOCK",e))(oh||{}),at=(e=>(e.PARAGRAPH="\r",e.SECTION_BREAK=`
|
|
5
5
|
`,e.TABLE_START="",e.TABLE_ROW_START="\x1B",e.TABLE_CELL_START="",e.TABLE_CELL_END="",e.TABLE_ROW_END="",e.TABLE_END="",e.CUSTOM_RANGE_START="",e.CUSTOM_RANGE_END="",e.COLUMN_BREAK="\v",e.PAGE_BREAK="\f",e.DOCS_END="\0",e.TAB=" ",e.CUSTOM_BLOCK="\b",e.LETTER="",e.SPACE=" ",e))(at||{});function Ip(e){return`${e}`}const Sp=[at.TABLE_START,at.TABLE_ROW_START,at.TABLE_CELL_START,at.TABLE_CELL_END,at.TABLE_ROW_END,at.TABLE_END],Vs=e=>{const t=e.endsWith(`\r
|
|
6
|
-
`)?e.slice(0,-2):e;return Sp.reduce((n,r)=>n.replaceAll(r,""),t)},Op=e=>e?Vs(e).replaceAll("\r","")==="":!0,vp=e=>{const t=e.replace(/\n/g,"\r"),n=[],r=[];let s=0,i="";const o=(l,c=!0)=>{const u=t.slice(s,l);if(q.isLegalUrl(u)){const h=tt(),d=`${u}`,f={startIndex:s,endIndex:s+d.length-1,rangeId:h,rangeType:sn.HYPERLINK,properties:{url:e}};r.push(f),i+=d,s=l+1,c&&(i+="\r",n.push({startIndex:l}))}else i+=t.slice(s,l+1),s=l+1,c&&n.push({startIndex:l})};let a=0;for(let l=0;l<t.length;l++)t[l]==="\r"&&(o(l),a=l);return(a!==t.length-1||t.length===1)&&o(t.length,!1),{dataStream:i,paragraphs:n,customRanges:r}},Xo={id:"default_doc",documentStyle:{}};class wp extends Gs{constructor(n){var r;super();p(this,"type",ve.UNIVER_DOC);p(this,"_name$",new ce.BehaviorSubject(""));p(this,"name$",this._name$.asObservable());p(this,"snapshot");this.snapshot={...Xo,...n},this._name$.next((r=this.snapshot.title)!=null?r:"No Title")}getUnitId(){throw new Error("Method not implemented.")}getRev(){var n;return(n=this.snapshot.rev)!=null?n:1}incrementRev(){this.snapshot.rev=this.getRev()+1}setRev(n){this.snapshot.rev=n}setName(n){this.snapshot.title=n,this._name$.next(n)}get drawings(){return this.snapshot.drawings}get documentStyle(){return this.snapshot.documentStyle}get lists(){return this.snapshot.lists}get zoomRatio(){var n;return((n=this.snapshot.settings)==null?void 0:n.zoomRatio)||1}resetDrawing(n,r){this.snapshot.drawings=n,this.snapshot.drawingsOrder=r}getBody(){return this.snapshot.body}getSnapshot(){return this.snapshot}getBulletPresetList(){var s;const n=(s=this.snapshot.lists)!=null?s:{};return{...Wr,...n}}updateDocumentId(n){this.snapshot.id=n}updateDocumentRenderConfig(n){const{documentStyle:r}=this.snapshot;r.renderConfig==null?r.renderConfig=n:r.renderConfig={...r.renderConfig,...n}}getDocumentStyle(){return this.snapshot.documentStyle}updateDocumentStyle(n){this.snapshot.documentStyle==null?this.snapshot.documentStyle=n:this.snapshot.documentStyle={...this.snapshot.documentStyle,...n}}updateDocumentDataMargin(n){const{t:r,l:s,b:i,r:o}=n,{documentStyle:a}=this.snapshot;r!=null&&(a.marginTop=r),s!=null&&(a.marginLeft=s),i!=null&&(a.marginBottom=i),o!=null&&(a.marginRight=o)}updateDocumentDataPageSize(n,r){const{documentStyle:s}=this.snapshot;if(!s.pageSize){n=n!=null?n:Number.POSITIVE_INFINITY,r=r!=null?r:Number.POSITIVE_INFINITY,s.pageSize={width:n,height:r};return}n!==void 0&&(s.pageSize.width=n),r!==void 0&&(s.pageSize.height=r)}updateDrawing(n,r){const{drawings:s}=this,{width:i,height:o,left:a,top:l}=r,c=s==null?void 0:s[n];if(!c)return;const u=c.docTransform;u.size.width=i,u.size.height=o,u.positionH.posOffset=a,u.positionV.posOffset=l}setZoomRatio(n=1){this.snapshot.settings==null?this.snapshot.settings={zoomRatio:n}:this.snapshot.settings.zoomRatio=1}setDisabled(n){this.snapshot.disabled=n}getDisabled(){return this.snapshot.disabled}getTitle(){return this.snapshot.title}}class Nt extends wp{constructor(n){var s,i;super(q.isEmptyObject(n)?F_():n);p(this,"_unitId");p(this,"headerModelMap",new Map);p(this,"footerModelMap",new Map);p(this,"change$",new ce.BehaviorSubject(0));const r=6;this._unitId=(s=this.snapshot.id)!=null?s:tt(r),this._initializeHeaderFooterModel(),this._name$.next((i=this.snapshot.title)!=null?i:"")}dispose(){super.dispose(),this.headerModelMap.forEach(n=>{n.dispose()}),this.footerModelMap.forEach(n=>{n.dispose()}),this._name$.complete()}getDrawings(){return this.snapshot.drawings}getDrawingsOrder(){return this.snapshot.drawingsOrder}getCustomRanges(){var n;return(n=this.snapshot.body)==null?void 0:n.customRanges}getCustomDecorations(){var n;return(n=this.snapshot.body)==null?void 0:n.customDecorations}getSettings(){return this.snapshot.settings}reset(n){if(n.id&&n.id!==this._unitId)throw new Error("Cannot reset a document model with a different unit id!");this.snapshot={...Xo,...n},this._initializeHeaderFooterModel(),this.change$.next(this.change$.value+1)}getSelfOrHeaderFooterModel(n){if(n!=null){if(this.headerModelMap.has(n))return this.headerModelMap.get(n);if(this.footerModelMap.has(n))return this.footerModelMap.get(n)}return this}getUnitId(){return this._unitId}apply(n){if(!Gt.isNoop(n))return this.snapshot=Gt.apply(this.snapshot,n),n!=null&&n.some(r=>Array.isArray(r)&&((r==null?void 0:r[0])==="headers"||(r==null?void 0:r[0])==="footers"))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.change$.next(this.change$.value+1),this.snapshot}sliceBody(n,r,s=Ko.copy){const i=this.getBody();if(i!=null)return yt(i,n,r,!1,s)}_initializeHeaderFooterModel(){const{headers:n,footers:r}=this.getSnapshot();if(n)for(const s in n){const i=n[s];this.headerModelMap.set(s,new Nt(i)),this.headerModelMap.get(s).updateDocumentId(this.getUnitId())}if(r)for(const s in r){const i=r[s];this.footerModelMap.set(s,new Nt(i)),this.footerModelMap.get(s).updateDocumentId(this.getUnitId())}}updateDocumentId(n){super.updateDocumentId(n),this._unitId=n}getPlainText(){var n,r;return Vs((r=(n=this.getBody())==null?void 0:n.dataStream)!=null?r:"")}}function bp(e){const{ranges:t,id:n,type:r}=e,s=new Me;let i=0;for(let o=0;o<t.length;o++){const a=t[o],{startOffset:l,endOffset:c}=a;l>0&&s.push({t:Z.RETAIN,len:l-i}),s.push({t:Z.RETAIN,body:{dataStream:"",customDecorations:[{id:n,type:r,startIndex:0,endIndex:c-l-1}]},len:c-l}),i=c}return s}function Ap(e){var u,h,d;const{id:t,segmentId:n,documentDataModel:r}=e,s=r==null?void 0:r.getBody();if(!r||!s)return!1;const i=(d=(h=(u=r.getSelfOrHeaderFooterModel(n))==null?void 0:u.getBody())==null?void 0:h.customDecorations)==null?void 0:d.find(f=>f.id===t);if(!i)return!1;const o=new Me,{startIndex:a,endIndex:l}=i,c=l-a+1;return o.push({t:Z.RETAIN,len:a}),o.push({t:Z.RETAIN,len:c,body:{dataStream:"",customDecorations:[{startIndex:0,endIndex:c-1,id:t,type:pn.DELETED}]}}),o}function ah(e,t,n,r){return e<=n&&t>=n||e>=n&&e<=r}function Tp(e,t){const n=[];for(let r=0,s=t.length;r<s;r++){const i=t[r];e.collapsed?i.startIndex<e.startOffset&&e.startOffset<=i.endIndex&&n.push(i):ah(e.startOffset,e.endOffset-1,i.startIndex,i.endIndex)&&n.push(i)}return n}function yp(e){return{...q.deepClone(e),rangeId:tt()}}function Np(e,t){const n=[];let r=e[0];for(const s of t)s<e[0]||s>e[1]||(r<s&&n.push([r,s-1]),r=s+1);return r<=e[1]&&n.push([r,e[1]]),n}function lh(e,t,n,r){const s=[];for(let i=0,o=n.length;i<o;i++){const a=n[i];if((r===void 0||a.rangeType===r)&&Math.max(a.startIndex,e)<=Math.min(a.endIndex,t)&&s.push({...a}),a.startIndex>t)break}return s}function Mp(e,t){var i,o,a,l,c;const n=lh(e.startOffset,e.collapsed?e.startOffset:e.endOffset-1,(i=t.customRanges)!=null?i:[]),r=Math.min(e.startOffset,(a=(o=n[0])==null?void 0:o.startIndex)!=null?a:1/0),s=Math.max(e.endOffset,((c=(l=n[n.length-1])==null?void 0:l.endIndex)!=null?c:-1/0)+1);return{startOffset:r,endOffset:s,collapsed:r===s}}var Ei,tl;function Lp(){if(tl)return Ei;tl=1;var e=-1,t=1,n=0;function r(m,x,O,N,A){if(m===x)return m?[[n,m]]:[];if(O!=null){var v=B(m,x,O);if(v)return v}var y=a(m,x),M=m.substring(0,y);m=m.substring(y),x=x.substring(y),y=c(m,x);var L=m.substring(m.length-y);m=m.substring(0,m.length-y),x=x.substring(0,x.length-y);var P=s(m,x);return M&&P.unshift([n,M]),L&&P.push([n,L]),F(P,A),N&&h(P),P}function s(m,x){var O;if(!m)return[[t,x]];if(!x)return[[e,m]];var N=m.length>x.length?m:x,A=m.length>x.length?x:m,v=N.indexOf(A);if(v!==-1)return O=[[t,N.substring(0,v)],[n,A],[t,N.substring(v+A.length)]],m.length>x.length&&(O[0][0]=O[2][0]=e),O;if(A.length===1)return[[e,m],[t,x]];var y=u(m,x);if(y){var M=y[0],L=y[1],P=y[2],J=y[3],V=y[4],oe=r(M,P),le=r(L,J);return oe.concat([[n,V]],le)}return i(m,x)}function i(m,x){for(var O=m.length,N=x.length,A=Math.ceil((O+N)/2),v=A,y=2*A,M=new Array(y),L=new Array(y),P=0;P<y;P++)M[P]=-1,L[P]=-1;M[v+1]=0,L[v+1]=0;for(var J=O-N,V=J%2!==0,oe=0,le=0,I=0,D=0,Y=0;Y<A;Y++){for(var G=-Y+oe;G<=Y-le;G+=2){var H=v+G,j;G===-Y||G!==Y&&M[H-1]<M[H+1]?j=M[H+1]:j=M[H-1]+1;for(var Q=j-G;j<O&&Q<N&&m.charAt(j)===x.charAt(Q);)j++,Q++;if(M[H]=j,j>O)le+=2;else if(Q>N)oe+=2;else if(V){var ee=v+J-G;if(ee>=0&&ee<y&&L[ee]!==-1){var U=O-L[ee];if(j>=U)return o(m,x,j,Q)}}}for(var z=-Y+I;z<=Y-D;z+=2){var ee=v+z,U;z===-Y||z!==Y&&L[ee-1]<L[ee+1]?U=L[ee+1]:U=L[ee-1]+1;for(var X=U-z;U<O&&X<N&&m.charAt(O-U-1)===x.charAt(N-X-1);)U++,X++;if(L[ee]=U,U>O)D+=2;else if(X>N)I+=2;else if(!V){var H=v+J-z;if(H>=0&&H<y&&M[H]!==-1){var j=M[H],Q=v+j-H;if(U=O-U,j>=U)return o(m,x,j,Q)}}}}return[[e,m],[t,x]]}function o(m,x,O,N){var A=m.substring(0,O),v=x.substring(0,N),y=m.substring(O),M=x.substring(N),L=r(A,v),P=r(y,M);return L.concat(P)}function a(m,x){if(!m||!x||m.charAt(0)!==x.charAt(0))return 0;for(var O=0,N=Math.min(m.length,x.length),A=N,v=0;O<A;)m.substring(v,A)==x.substring(v,A)?(O=A,v=O):N=A,A=Math.floor((N-O)/2+O);return k(m.charCodeAt(A-1))&&A--,A}function l(m,x){var O=m.length,N=x.length;if(O==0||N==0)return 0;O>N?m=m.substring(O-N):O<N&&(x=x.substring(0,O));var A=Math.min(O,N);if(m==x)return A;for(var v=0,y=1;;){var M=m.substring(A-y),L=x.indexOf(M);if(L==-1)return v;y+=L,(L==0||m.substring(A-y)==x.substring(0,y))&&(v=y,y++)}}function c(m,x){if(!m||!x||m.slice(-1)!==x.slice(-1))return 0;for(var O=0,N=Math.min(m.length,x.length),A=N,v=0;O<A;)m.substring(m.length-A,m.length-v)==x.substring(x.length-A,x.length-v)?(O=A,v=O):N=A,A=Math.floor((N-O)/2+O);return W(m.charCodeAt(m.length-A))&&A--,A}function u(m,x){var O=m.length>x.length?m:x,N=m.length>x.length?x:m;if(O.length<4||N.length*2<O.length)return null;function A(le,I,D){for(var Y=le.substring(D,D+Math.floor(le.length/4)),G=-1,H="",j,Q,ee,U;(G=I.indexOf(Y,G+1))!==-1;){var z=a(le.substring(D),I.substring(G)),X=c(le.substring(0,D),I.substring(0,G));H.length<X+z&&(H=I.substring(G-X,G)+I.substring(G,G+z),j=le.substring(0,D-X),Q=le.substring(D+z),ee=I.substring(0,G-X),U=I.substring(G+z))}return H.length*2>=le.length?[j,Q,ee,U,H]:null}var v=A(O,N,Math.ceil(O.length/4)),y=A(O,N,Math.ceil(O.length/2)),M;if(!v&&!y)return null;y?v?M=v[4].length>y[4].length?v:y:M=y:M=v;var L,P,J,V;m.length>x.length?(L=M[0],P=M[1],J=M[2],V=M[3]):(J=M[0],V=M[1],L=M[2],P=M[3]);var oe=M[4];return[L,P,J,V,oe]}function h(m){for(var x=!1,O=[],N=0,A=null,v=0,y=0,M=0,L=0,P=0;v<m.length;)m[v][0]==n?(O[N++]=v,y=L,M=P,L=0,P=0,A=m[v][1]):(m[v][0]==t?L+=m[v][1].length:P+=m[v][1].length,A&&A.length<=Math.max(y,M)&&A.length<=Math.max(L,P)&&(m.splice(O[N-1],0,[e,A]),m[O[N-1]+1][0]=t,N--,N--,v=N>0?O[N-1]:-1,y=0,M=0,L=0,P=0,A=null,x=!0)),v++;for(x&&F(m),b(m),v=1;v<m.length;){if(m[v-1][0]==e&&m[v][0]==t){var J=m[v-1][1],V=m[v][1],oe=l(J,V),le=l(V,J);oe>=le?(oe>=J.length/2||oe>=V.length/2)&&(m.splice(v,0,[n,V.substring(0,oe)]),m[v-1][1]=J.substring(0,J.length-oe),m[v+1][1]=V.substring(oe),v++):(le>=J.length/2||le>=V.length/2)&&(m.splice(v,0,[n,J.substring(0,le)]),m[v-1][0]=t,m[v-1][1]=V.substring(0,V.length-le),m[v+1][0]=e,m[v+1][1]=J.substring(le),v++),v++}v++}}var d=/[^a-zA-Z0-9]/,f=/\s/,g=/[\r\n]/,_=/\n\r?\n$/,R=/^\r?\n\r?\n/;function b(m){function x(le,I){if(!le||!I)return 6;var D=le.charAt(le.length-1),Y=I.charAt(0),G=D.match(d),H=Y.match(d),j=G&&D.match(f),Q=H&&Y.match(f),ee=j&&D.match(g),U=Q&&Y.match(g),z=ee&&le.match(_),X=U&&I.match(R);return z||X?5:ee||U?4:G&&!j&&Q?3:j||Q?2:G||H?1:0}for(var O=1;O<m.length-1;){if(m[O-1][0]==n&&m[O+1][0]==n){var N=m[O-1][1],A=m[O][1],v=m[O+1][1],y=c(N,A);if(y){var M=A.substring(A.length-y);N=N.substring(0,N.length-y),A=M+A.substring(0,A.length-y),v=M+v}for(var L=N,P=A,J=v,V=x(N,A)+x(A,v);A.charAt(0)===v.charAt(0);){N+=A.charAt(0),A=A.substring(1)+v.charAt(0),v=v.substring(1);var oe=x(N,A)+x(A,v);oe>=V&&(V=oe,L=N,P=A,J=v)}m[O-1][1]!=L&&(L?m[O-1][1]=L:(m.splice(O-1,1),O--),m[O][1]=P,J?m[O+1][1]=J:(m.splice(O+1,1),O--))}O++}}function F(m,x){m.push([n,""]);for(var O=0,N=0,A=0,v="",y="",M;O<m.length;){if(O<m.length-1&&!m[O][1]){m.splice(O,1);continue}switch(m[O][0]){case t:A++,y+=m[O][1],O++;break;case e:N++,v+=m[O][1],O++;break;case n:var L=O-A-N-1;if(x){if(L>=0&&C(m[L][1])){var P=m[L][1].slice(-1);if(m[L][1]=m[L][1].slice(0,-1),v=P+v,y=P+y,!m[L][1]){m.splice(L,1),O--;var J=L-1;m[J]&&m[J][0]===t&&(A++,y=m[J][1]+y,J--),m[J]&&m[J][0]===e&&(N++,v=m[J][1]+v,J--),L=J}}if(S(m[O][1])){var P=m[O][1].charAt(0);m[O][1]=m[O][1].slice(1),v+=P,y+=P}}if(O<m.length-1&&!m[O][1]){m.splice(O,1);break}if(v.length>0||y.length>0){v.length>0&&y.length>0&&(M=a(y,v),M!==0&&(L>=0?m[L][1]+=y.substring(0,M):(m.splice(0,0,[n,y.substring(0,M)]),O++),y=y.substring(M),v=v.substring(M)),M=c(y,v),M!==0&&(m[O][1]=y.substring(y.length-M)+m[O][1],y=y.substring(0,y.length-M),v=v.substring(0,v.length-M)));var V=A+N;v.length===0&&y.length===0?(m.splice(O-V,V),O=O-V):v.length===0?(m.splice(O-V,V,[t,y]),O=O-V+1):y.length===0?(m.splice(O-V,V,[e,v]),O=O-V+1):(m.splice(O-V,V,[e,v],[t,y]),O=O-V+2)}O!==0&&m[O-1][0]===n?(m[O-1][1]+=m[O][1],m.splice(O,1)):O++,A=0,N=0,v="",y="";break}}m[m.length-1][1]===""&&m.pop();var oe=!1;for(O=1;O<m.length-1;)m[O-1][0]===n&&m[O+1][0]===n&&(m[O][1].substring(m[O][1].length-m[O-1][1].length)===m[O-1][1]?(m[O][1]=m[O-1][1]+m[O][1].substring(0,m[O][1].length-m[O-1][1].length),m[O+1][1]=m[O-1][1]+m[O+1][1],m.splice(O-1,1),oe=!0):m[O][1].substring(0,m[O+1][1].length)==m[O+1][1]&&(m[O-1][1]+=m[O+1][1],m[O][1]=m[O][1].substring(m[O+1][1].length)+m[O+1][1],m.splice(O+1,1),oe=!0)),O++;oe&&F(m,x)}function k(m){return m>=55296&&m<=56319}function W(m){return m>=56320&&m<=57343}function S(m){return W(m.charCodeAt(0))}function C(m){return k(m.charCodeAt(m.length-1))}function w(m){for(var x=[],O=0;O<m.length;O++)m[O][1].length>0&&x.push(m[O]);return x}function T(m,x,O,N){return C(m)||S(N)?null:w([[n,m],[e,x],[t,O],[n,N]])}function B(m,x,O){var N=typeof O=="number"?{index:O,length:0}:O.oldRange,A=typeof O=="number"?null:O.newRange,v=m.length,y=x.length;if(N.length===0&&(A===null||A.length===0)){var M=N.index,L=m.slice(0,M),P=m.slice(M),J=A?A.index:null;e:{var V=M+y-v;if(J!==null&&J!==V||V<0||V>y)break e;var oe=x.slice(0,V),le=x.slice(V);if(le!==P)break e;var I=Math.min(M,V),D=L.slice(0,I),Y=oe.slice(0,I);if(D!==Y)break e;var G=L.slice(I),H=oe.slice(I);return T(D,G,H,P)}e:{if(J!==null&&J!==M)break e;var j=M,oe=x.slice(0,j),le=x.slice(j);if(oe!==L)break e;var Q=Math.min(v-j,y-j),ee=P.slice(P.length-Q),U=le.slice(le.length-Q);if(ee!==U)break e;var G=P.slice(0,P.length-Q),H=le.slice(0,le.length-Q);return T(L,G,H,ee)}}if(N.length>0&&A&&A.length===0)e:{var D=m.slice(0,N.index),ee=m.slice(N.index+N.length),I=D.length,Q=ee.length;if(y<I+Q)break e;var Y=x.slice(0,I),U=x.slice(y-Q);if(D!==Y||ee!==U)break e;var G=m.slice(I,v-Q),H=x.slice(I,y-Q);return T(D,G,H,ee)}return null}function $(m,x,O,N){return r(m,x,O,N,!0)}return $.INSERT=t,$.DELETE=e,$.EQUAL=n,Ei=$,Ei}var Dp=Lp();const qo=It(Dp);function xp(e){var h,d,f;const{rangeId:t,segmentId:n,documentDataModel:r,insert:s}=e,i=(d=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.customRanges)==null?void 0:d.find(g=>g.rangeId===t);if(!i)return!1;const{startIndex:o,endIndex:a}=i,l=new Me,c=a-o+1;l.push({t:Z.RETAIN,len:o}),l.push({t:Z.RETAIN,len:c,body:{dataStream:"",customRanges:[]}}),s&&l.push({t:Z.INSERT,body:s,len:s.dataStream.length});const u=a+1+((f=s==null?void 0:s.dataStream.length)!=null?f:0);return l.selections=[{startOffset:u,endOffset:u,collapsed:!0}],l}function Up(e){const{ranges:t,rangeId:n,rangeType:r,wholeEntity:s,properties:i,body:o}=e;let a=0;const l=new Me;let c=!1;return t.forEach(u=>{var k,W,S;const h=Mp(u,o);if(!h||!o)return!1;const{startOffset:d,endOffset:f}=h,g=(k=o.customRanges)!=null?k:[],_=(C,w,T)=>{var O,N,A,v;const B=lh(C,w,g,r),$=Math.min((N=(O=B[0])==null?void 0:O.startIndex)!=null?N:1/0,C),m=Math.max((v=(A=B[B.length-1])==null?void 0:A.endIndex)!=null?v:-1/0,w),x={rangeId:T?`${n}$${T}`:n,rangeType:r,startIndex:0,endIndex:m-$,wholeEntity:s,properties:{...i}};l.push({t:Z.RETAIN,len:$-a}),l.push({t:Z.RETAIN,len:m-$+1,body:{dataStream:"",customRanges:[x]},coverType:Ee.COVER}),a=m+1},R=((W=o.paragraphs)!=null?W:[]).filter(C=>C.startIndex<f&&C.startIndex>d),b=((S=o.customBlocks)!=null?S:[]).filter(C=>C.startIndex<f&&C.startIndex>d);Np([d,f-1],[...R.map(C=>C.startIndex),...b.map(C=>C.startIndex)]).forEach(([C,w],T)=>_(C,w,T)),c=!0,l.selections=[{startOffset:h.endOffset,endOffset:h.endOffset,collapsed:!0}]}),c?l:!1}function ch(e,t,n=0,r=null,s=!0){e.sort((c,u)=>c.startOffset-u.startOffset);const i=[],{paragraphs:o=[]}=t,a=o==null?void 0:o.find(c=>c.startIndex>=e[0].startOffset&&c.startIndex<e[0].endOffset);let l=n;if(e.forEach(c=>{const{startOffset:u,endOffset:h}=c;u>l&&(i.push({t:Z.RETAIN,len:u-l}),l=u),l<h&&(i.push({t:Z.DELETE,len:h-l}),l=h)}),r&&i.push({t:Z.INSERT,body:r,len:r.dataStream.length}),a&&s){const c=o.find(u=>u.startIndex-n>=e[e.length-1].endOffset-1);c&&(c.startIndex>l&&(i.push({t:Z.RETAIN,len:c.startIndex-l}),l=c.startIndex),i.push({t:Z.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...c,startIndex:0,bullet:a==null?void 0:a.bullet}]},coverType:Ee.REPLACE}))}return i}function Pp(e,t,n=0){const r=[];let s=n;return e.forEach(i=>{const{startOffset:o,endOffset:a}=i;o>s&&(r.push({t:Z.RETAIN,len:o-s}),s=o),a>s&&(r.push({t:Z.RETAIN,len:a-s,body:{...q.deepClone(t),dataStream:""}}),s=a)}),r}const kp=e=>{var h;const{selection:t,body:n,doc:r}=e,s=t.segmentId,i=(h=r.getSelfOrHeaderFooterModel(s))==null?void 0:h.getBody();if(!i)return!1;const o=t.collapsed?null:yt(i,t.startOffset,t.endOffset),a=qo(o?o.dataStream:"",n.dataStream);let l=0;const c=a.map(([d,f])=>{switch(d){case 0:{const g={t:Z.RETAIN,body:{...yt(n,l,l+f.length,!1),dataStream:""},len:f.length};return l+=f.length,g}case 1:{const g={t:Z.INSERT,body:yt(n,l,l+f.length),len:f.length};return l+=f.length,g}default:return{t:Z.DELETE,len:f.length}}}),u=new Me;return u.push({t:Z.RETAIN,len:t.startOffset}),u.push(...c),u};function Fp(e,t){return!!((e==null?void 0:e.length)===(t==null?void 0:t.length)&&(e!=null&&e.every((n,r)=>JSON.stringify(n)===JSON.stringify(t==null?void 0:t[r]))))}const Bp=e=>{var d;const{selection:t,body:n,doc:r,themeService:s}=e,i=t.segmentId,o=(d=r.getSelfOrHeaderFooterModel(i))==null?void 0:d.getBody();if(!o)return!1;const a=t.collapsed?null:yt(o,t.startOffset,t.endOffset),l=qo(a?a.dataStream:"",n.dataStream);let c=0;const u=l.map(([f,g])=>{switch(f){case 0:{const _=Ds(n,c,c+g.length,!1),R=Ds(a,c,c+g.length,!1),b={t:Z.RETAIN,body:Fp(_,R)?void 0:{textRuns:_==null?void 0:_.map(F=>{var k,W,S,C,w,T,B;return{...F,ts:{...F.ts,cl:(S=(W=(k=F.ts)==null?void 0:k.cl)==null?void 0:W.rgb)!=null&&S.includes(".")?{rgb:s.getColorFromTheme((T=(w=(C=F.ts)==null?void 0:C.cl)==null?void 0:w.rgb)!=null?T:"")}:(B=F.ts)==null?void 0:B.cl}}}),dataStream:""},len:g.length};return c+=g.length,b}case 1:{const _={t:Z.INSERT,body:yt(n,c,c+g.length),len:g.length};return c+=g.length,_}default:return{t:Z.DELETE,len:g.length}}});if(u.every(f=>f.t===Z.RETAIN&&!f.body))return!1;const h=new Me;return h.push({t:Z.RETAIN,len:t.startOffset}),h.push(...u),h};function $p(e,t){const n=[],{customBlocks:r=[]}=e;for(const s of t){const{startOffset:i,endOffset:o}=s;if(!(i==null||o==null))for(const a of r){const{startIndex:l}=a;l>=i&&l<o&&n.push(a.blockId)}}return n}function Hp(e,t=""){if(!t)return["body"];const{headers:n,footers:r}=e.getSnapshot();if(n==null&&r==null)throw new Error("Document data model must have headers or footers when update by segment id");if((n==null?void 0:n[t])!=null)return["headers",t,"body"];if((r==null?void 0:r[t])!=null)return["footers",t,"body"];throw new Error("Segment id not found in headers or footers")}const jp=e=>{var _,R,b,F;const{selection:t,documentDataModel:n,drawings:r}=e,{collapsed:s,startOffset:i,segmentId:o}=t,a=new Me,l=Gt.getInstance(),c=[],u=n.getSelfOrHeaderFooterModel(o).getBody();if(!u)return!1;const h=(R=(_=n.getSnapshot().drawingsOrder)==null?void 0:_.length)!=null?R:0;let d=0;if(s)i>0&&a.push({t:Z.RETAIN,len:i});else{const k=ch([t],u,0,null,!1);a.push(...k);const W=$p(u,[t]),S=(b=n.getDrawings())!=null?b:{},C=(F=n.getDrawingsOrder())!=null?F:[],w=W.sort((T,B)=>C.indexOf(T)>C.indexOf(B)?-1:C.indexOf(T)<C.indexOf(B)?1:0);if(w.length>0)for(const T of w){const B=S[T],$=C.indexOf(T);if(B==null||$<0)continue;const m=l.removeOp(["drawings",T],B),x=l.removeOp(["drawingsOrder",$],T);c.push(m),c.push(x),d++}}a.push({t:Z.INSERT,body:{dataStream:"\b".repeat(r.length),customBlocks:r.map((k,W)=>({startIndex:W,blockId:k.drawingId}))},len:r.length});const f=Hp(n,o),g=l.editOp(a.serialize(),f);c.push(g);for(const k of r){const{drawingId:W}=k,S=l.insertOp(["drawings",W],k),C=l.insertOp(["drawingsOrder",h-d],W);c.push(S),c.push(C)}return c.reduce((k,W)=>Gt.compose(k,W),null)};function Wp(e,t){if(typeof t>"u")return{startOffset:e,endOffset:e,collapsed:!0};if(t<e)throw new Error(`Cannot make a doc selection when endOffset ${t} is less than startOffset ${e}.`);return{startOffset:e,endOffset:t,collapsed:e===t}}function Yp(e){const{startOffset:t,endOffset:n,collapsed:r}=e,s=Math.min(t,n),i=Math.max(t,n);return{startOffset:s,endOffset:i,collapsed:r}}function Gp(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function Vi(e,t,n,r){const{startOffset:s,endOffset:i}=e,o=r!=null?r:Zo(t,n),a=[];let l=-1;for(let c=0;c<o.length;c++){const u=o[c],{startIndex:h}=u;(s>l&&s<=h||i>l&&i<=h||h>=s&&h<=i)&&a.push(u),l=h}return a}function zi(e,t,n){const r=[],s=Zo(t,n);for(const i of e){const o=Vi(i,t,n,s);r.push(...o)}return r}const Vp=[at.PARAGRAPH,at.TABLE_START,at.TABLE_END,at.TABLE_ROW_START,at.TABLE_CELL_START,at.TABLE_CELL_END];function Zo(e,t){const n=[];for(let r=0;r<e.length;r++){const s=e[r],{startIndex:i}=s;let o=i-1;for(;!Vp.includes(t[o])&&o>=0;)o--;n.push({...s,paragraphStart:o+1,paragraphEnd:s.startIndex})}return n}const zp=e=>{var h,d,f;const{paragraphs:t,segmentId:n,document:r}=e;let s=e.listType;const i=(d=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.paragraphs)!=null?d:[],o=t.every(g=>{var _;return((_=g.bullet)==null?void 0:_.listType.indexOf(s))===0});let l=tt(6);if(t.length===1){const g=i.indexOf(t[0]),_=i[g-1],R=i[g+1];_&&_.bullet&&_.bullet.listType.indexOf(s)===0?(l=_.bullet.listId,s!==kt.CHECK_LIST&&(s=_.bullet.listType)):R&&R.bullet&&R.bullet.listType.indexOf(s)===0&&(l=R.bullet.listId,s!==kt.CHECK_LIST&&(s=R.bullet.listType))}const c=new On;c.reset();const u=new Me;for(const g of t){const{startIndex:_,paragraphStyle:R={},bullet:b}=g;u.push({t:Z.RETAIN,len:_-c.cursor}),u.push({t:Z.RETAIN,len:1,body:{dataStream:"",paragraphs:[o?{paragraphStyle:R,startIndex:0}:{startIndex:0,paragraphStyle:{...R},bullet:{nestingLevel:(f=b==null?void 0:b.nestingLevel)!=null?f:0,textStyle:{fs:20},listType:s,listId:l}}]},coverType:Ee.REPLACE}),c.moveCursorTo(_+1)}return u},Kp=e=>{var h;const{paragraphIndex:t,segmentId:n,document:r}=e,s=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.paragraphs;if(s==null)return!1;const i=s.find(d=>d.startIndex===t);if(!(i!=null&&i.bullet)||i.bullet.listType.indexOf(kt.CHECK_LIST)===-1)return!1;const o=new On;o.reset();const a=new Me,{startIndex:l,paragraphStyle:c={}}=i,u=i.bullet.listType===kt.CHECK_LIST?kt.CHECK_LIST_CHECKED:kt.CHECK_LIST;return a.push({t:Z.RETAIN,len:l-o.cursor}),a.push({t:Z.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...i,paragraphStyle:c,startIndex:0,bullet:{...i.bullet,listType:u}}]},coverType:Ee.REPLACE}),o.moveCursorTo(l+1),a},Xp=e=>{var u,h;const{paragraphs:t,listType:n,segmentId:r,document:s}=e;if(((u=s.getSelfOrHeaderFooterModel(r).getBody())==null?void 0:u.paragraphs)==null)return!1;const a=tt(6),l=new On;l.reset();const c=new Me;for(const d of t){const{startIndex:f,paragraphStyle:g={},bullet:_}=d;c.push({t:Z.RETAIN,len:f-l.cursor}),c.push({t:Z.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:g,bullet:{nestingLevel:(h=_==null?void 0:_.nestingLevel)!=null?h:0,textStyle:(_==null?void 0:_.listType)===n?_.textStyle:{fs:20},listType:n,listId:a}}]},coverType:Ee.REPLACE}),l.moveCursorTo(f+1)}return c};function qp(e,t){return t.some(n=>e.startIndex>n.startIndex&&e.startIndex<n.endIndex)}const Zp=e=>{var c,u,h;const{paragraphs:t,document:n,type:r}=e,s=new On;s.reset();const i=new Me,o=(c=n.getSnapshot().lists)!=null?c:{},a=(h=(u=n.getBody())==null?void 0:u.tables)!=null?h:[],l={...Wr,...o};for(const d of t){const{startIndex:f,paragraphStyle:g={},bullet:_}=d,R=qp(d,a);if(i.push({t:Z.RETAIN,len:f-s.cursor}),_){const b=_.listType;let F=l[b].nestingLevel.length-1;R&&(F=Math.min(F,2)),i.push({t:Z.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:{...g},bullet:{..._,nestingLevel:Math.max(Math.min(_.nestingLevel+r,F),0)}}]},coverType:Ee.REPLACE})}else i.push({t:Z.RETAIN,len:1});s.moveCursorTo(f+1)}return i},Jp=e=>{var R,b,F,k;const{textRanges:t,segmentId:n,document:r,style:s,paragraphTextRun:i,cursor:o,deleteLen:a,textX:l}=e,c=r.getSelfOrHeaderFooterModel(n),u=(b=(R=c.getBody())==null?void 0:R.paragraphs)!=null?b:[],h=(k=(F=c.getBody())==null?void 0:F.dataStream)!=null?k:"",d=zi(t,u,h),f=new On;o&&f.moveCursorTo(o);const g=l!=null?l:new Me;d.sort((W,S)=>W.startIndex-S.startIndex);const _=Math.max(0,d[0].paragraphStart-1);_>f.cursor&&(g.push({t:Z.RETAIN,len:_-f.cursor}),f.moveCursorTo(_)),a&&g.push({t:Z.DELETE,len:a});for(const W of d){const{startIndex:S,paragraphStyle:C={}}=W,w=S-f.cursor;g.push({t:Z.RETAIN,len:w,...i?{body:{dataStream:"",textRuns:[{ts:i,st:0,ed:w}]},coverType:Ee.REPLACE}:null}),g.push({t:Z.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:{...C,...s}}]},coverType:Ee.REPLACE}),f.moveCursorTo(S+1)}return g};class Qe{}p(Qe,"customRange",{add:Up,delete:xp,copyCustomRange:yp,getCustomRangesInterestsWithSelection:Tp,isIntersecting:ah}),p(Qe,"customDecoration",{add:bp,delete:Ap}),p(Qe,"selection",{replace:kp,makeSelection:Wp,normalizeSelection:Yp,delete:ch,replaceTextRuns:Bp,retain:Pp}),p(Qe,"range",{isIntersects:Gp,getParagraphsInRange:Vi,getParagraphsInRanges:zi}),p(Qe,"transform",{getPlainText:Vs,fromPlainText:vp,isEmptyDocument:Op}),p(Qe,"paragraph",{bullet:{set:Xp,switch:zp,toggleChecklist:Kp,changeNestLevel:Zp},style:{set:Jp},util:{transform:Zo,getParagraphsInRange:Vi,getParagraphsInRanges:zi}}),p(Qe,"drawing",{add:jp});function Qp(e,t,n,r){var c;if(t==="")return e;const s={id:"mock-id",body:e,documentStyle:{}},i=new Nt(s),o=t.length;let a;for(;(a=(r?i.getBody().dataStream:i.getBody().dataStream.toLowerCase()).indexOf(t))>=0;){const u=new Me,h=Gt.getInstance();if(a>0&&u.retain(a),n.length>0){const d=i.sliceBody(a,a+o),f={dataStream:n};if(Array.isArray(d==null?void 0:d.textRuns)&&d.textRuns.length&&(f.textRuns=[{...d.textRuns[0],st:0,ed:n.length}]),(c=d==null?void 0:d.customRanges)!=null&&c.length){const g=d.customRanges[0];f.customRanges=[{...g,startIndex:0,endIndex:n.length-1}]}u.insert(n.length,f)}u.delete(o),i.apply(h.editOp(u.serialize()))}const l=i.getBody();return i.dispose(),l}function eE(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 uh(e){var t;return e.body=eE((t=e.body)!=null?t:{dataStream:""}),e.drawingsOrder||(e.drawingsOrder=[]),e.drawings||(e.drawings={}),e.documentStyle||(e.documentStyle={}),e}class Yr{constructor(t={}){p(this,"_style");this._style=t}static create(t={}){return new Yr(t)}get fontFamily(){return this._style.ff}get fontSize(){return this._style.fs}get italic(){return this._style.it===ie.TRUE}get bold(){return this._style.bl===ie.TRUE}get underline(){return this._style.ul&&Jt.create(this._style.ul)}get bottomBorderLine(){return this._style.bbl&&Jt.create(this._style.bbl)}get strikethrough(){return this._style.st&&Jt.create(this._style.st)}get overline(){return this._style.ol&&Jt.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 nn.create(q.deepClone(this._style))}getValue(){return{...this._style}}}class nn extends Yr{static create(t={}){return new nn(t)}constructor(t={}){super(t)}setFontFamily(t){return this._style.ff=t,this}setFontSize(t){return this._style.fs=t,this}setItalic(t){return this._style.it=t?1:0,this}setBold(t){return this._style.bl=t?1:0,this}setUnderline(t){return this._style.ul=t.build(),this}setBottomBorderLine(t){return this._style.bbl=t.build(),this}setStrikethrough(t){return this._style.st=t.build(),this}setOverline(t){return this._style.ol=t.build(),this}setBackground(t){return this._style.bg=t,this}setBorder(t){return this._style.bd=t,this}setColor(t){return this._style.cl=t,this}setVerticalAlign(t){return this._style.va=t,this}copy(){return nn.create(q.deepClone(this._style))}build(){return this.getValue()}}class Jt{constructor(t={s:1}){p(this,"_decoration");this._decoration=t}static create(t={s:1}){return new Jt(t)}get show(){return this._decoration.s===ie.TRUE}get followFontColor(){return this._decoration.c===ie.TRUE}get color(){return this._decoration.cl}get type(){return this._decoration.t}setShow(t){return this._decoration.s=t?1:0,this}setFollowFontColor(t){return this._decoration.c=t?1:0,this}setColor(t){return this._decoration.cl=t,this}setLineType(t){return this._decoration.t=t,this}copy(){return Jt.create(q.deepClone(this._decoration))}build(){return{...this._decoration}}}class Gr{constructor(t={}){p(this,"_style");this._style=t}static create(t={}){return new Gr(t)}get indentFirstLine(){return this._style.indentFirstLine}get hanging(){return this._style.hanging}get indentStart(){return this._style.indentStart}get tabStops(){return this._style.tabStops}get indentEnd(){return this._style.indentEnd}get textStyle(){return this._style.textStyle}get headingId(){return this._style.headingId}get namedStyleType(){return this._style.namedStyleType}get horizontalAlign(){return this._style.horizontalAlign}get lineSpacing(){return this._style.lineSpacing}get direction(){return this._style.direction}get spacingRule(){return this._style.spacingRule}get snapToGrid(){return this._style.snapToGrid}get spaceAbove(){return this._style.spaceAbove}get spaceBelow(){return this._style.spaceBelow}get borderBetween(){return this._style.borderBetween}get borderTop(){return this._style.borderTop}get borderBottom(){return this._style.borderBottom}get borderLeft(){return this._style.borderLeft}get borderRight(){return this._style.borderRight}get keepLines(){return this._style.keepLines===ie.TRUE}get keepNext(){return this._style.keepNext===ie.TRUE}get wordWrap(){return this._style.wordWrap===ie.TRUE}get widowControl(){return this._style.widowControl===ie.TRUE}get shading(){return this._style.shading}get suppressHyphenation(){return this._style.suppressHyphenation===ie.TRUE}copy(){return Mr.create(q.deepClone(this._style))}getValue(){return this._style}}class Mr extends Gr{static create(t={}){return new Mr(t)}constructor(t={}){super(t)}setIndentFirstLine(t){return this._style.indentFirstLine=t,this}setHanging(t){return this._style.hanging=t,this}setIndentStart(t){return this._style.indentStart=t,this}setTabStops(t){return this._style.tabStops=t,this}setIndentEnd(t){return this._style.indentEnd=t,this}setTextStyle(t){return this._style.textStyle=t,this}setHeadingId(t){return this._style.headingId=t,this}setNamedStyleType(t){return this._style.namedStyleType=t,this}setHorizontalAlign(t){return this._style.horizontalAlign=t,this}setLineSpacing(t){return this._style.lineSpacing=t,this}setDirection(t){return this._style.direction=t,this}setSpacingRule(t){return this._style.spacingRule=t,this}setSnapToGrid(t){return this._style.snapToGrid=t?1:0,this}setSpaceAbove(t){return this._style.spaceAbove=t,this}setSpaceBelow(t){return this._style.spaceBelow=t,this}setBorderBetween(t){return this._style.borderBetween=t,this}setBorderTop(t){return this._style.borderTop=t,this}setBorderBottom(t){return this._style.borderBottom=t,this}setBorderLeft(t){return this._style.borderLeft=t,this}setBorderRight(t){return this._style.borderRight=t,this}setKeepLines(t){return this._style.keepLines=t?1:0,this}setKeepNext(t){return this._style.keepNext=t?1:0,this}setWordWrap(t){return this._style.wordWrap=t?1:0,this}setWidowControl(t){return this._style.widowControl=t?1:0,this}setShading(t){return this._style.shading=t,this}setSuppressHyphenation(t){return this._style.suppressHyphenation=t?1:0,this}copy(){return Mr.create(q.deepClone(this._style))}build(){return this.getValue()}}class Qt{constructor(t){p(this,"_data");if(!t.body)throw new Error("Invalid document data, body is required");this._data=uh(t)}static create(t){return new Qt(t)}static createByBody(t){return new Qt({body:t,id:"d",documentStyle:{}})}copy(){return En.create(q.deepClone(this._data))}slice(t,n){const{body:r,...s}=this._data;return En.create({...q.deepClone(s),body:yt(r,t,n)})}toPlainText(){var t,n;return Qe.transform.getPlainText((n=(t=this._data.body)==null?void 0:t.dataStream)!=null?n:"").replaceAll("\r",`
|
|
6
|
+
`)?e.slice(0,-2):e;return Sp.reduce((n,r)=>n.replaceAll(r,""),t)},Op=e=>e?Vs(e).replaceAll("\r","")==="":!0,vp=e=>{const t=e.replace(/\n/g,"\r"),n=[],r=[];let s=0,i="";const o=(l,c=!0)=>{const u=t.slice(s,l);if(q.isLegalUrl(u)){const h=tt(),d=`${u}`,f={startIndex:s,endIndex:s+d.length-1,rangeId:h,rangeType:sn.HYPERLINK,properties:{url:e}};r.push(f),i+=d,s=l+1,c&&(i+="\r",n.push({startIndex:l}))}else i+=t.slice(s,l+1),s=l+1,c&&n.push({startIndex:l})};let a=0;for(let l=0;l<t.length;l++)t[l]==="\r"&&(o(l),a=l);return(a!==t.length-1||t.length===1)&&o(t.length,!1),{dataStream:i,paragraphs:n,customRanges:r}},Xo={id:"default_doc",documentStyle:{}};class wp extends Gs{constructor(n){var r;super();p(this,"type",ve.UNIVER_DOC);p(this,"_name$",new ce.BehaviorSubject(""));p(this,"name$",this._name$.asObservable());p(this,"snapshot");this.snapshot={...Xo,...n},this._name$.next((r=this.snapshot.title)!=null?r:"No Title")}getUnitId(){throw new Error("Method not implemented.")}getRev(){var n;return(n=this.snapshot.rev)!=null?n:1}incrementRev(){this.snapshot.rev=this.getRev()+1}setRev(n){this.snapshot.rev=n}setName(n){this.snapshot.title=n,this._name$.next(n)}get drawings(){return this.snapshot.drawings}get documentStyle(){return this.snapshot.documentStyle}get lists(){return this.snapshot.lists}get zoomRatio(){var n;return((n=this.snapshot.settings)==null?void 0:n.zoomRatio)||1}resetDrawing(n,r){this.snapshot.drawings=n,this.snapshot.drawingsOrder=r}getBody(){return this.snapshot.body}getSnapshot(){return this.snapshot}getBulletPresetList(){var s;const n=(s=this.snapshot.lists)!=null?s:{};return{...Wr,...n}}updateDocumentId(n){this.snapshot.id=n}updateDocumentRenderConfig(n){const{documentStyle:r}=this.snapshot;r.renderConfig==null?r.renderConfig=n:r.renderConfig={...r.renderConfig,...n}}getDocumentStyle(){return this.snapshot.documentStyle}updateDocumentStyle(n){this.snapshot.documentStyle==null?this.snapshot.documentStyle=n:this.snapshot.documentStyle={...this.snapshot.documentStyle,...n}}updateDocumentDataMargin(n){const{t:r,l:s,b:i,r:o}=n,{documentStyle:a}=this.snapshot;r!=null&&(a.marginTop=r),s!=null&&(a.marginLeft=s),i!=null&&(a.marginBottom=i),o!=null&&(a.marginRight=o)}updateDocumentDataPageSize(n,r){const{documentStyle:s}=this.snapshot;if(!s.pageSize){s.pageSize={width:n!=null?n:Number.POSITIVE_INFINITY,height:r!=null?r:Number.POSITIVE_INFINITY};return}n!==void 0&&(s.pageSize.width=n),r!==void 0&&(s.pageSize.height=r)}updateDrawing(n,r){const{drawings:s}=this,{width:i,height:o,left:a,top:l}=r,c=s==null?void 0:s[n];if(!c)return;const u=c.docTransform;u.size.width=i,u.size.height=o,u.positionH.posOffset=a,u.positionV.posOffset=l}setZoomRatio(n=1){this.snapshot.settings?this.snapshot.settings.zoomRatio=n:this.snapshot.settings={zoomRatio:n}}setDisabled(n){this.snapshot.disabled=n}getDisabled(){return this.snapshot.disabled}getTitle(){return this.snapshot.title}}class Nt extends wp{constructor(n){var s,i;super(q.isEmptyObject(n)?F_():n);p(this,"_unitId");p(this,"headerModelMap",new Map);p(this,"footerModelMap",new Map);p(this,"change$",new ce.BehaviorSubject(0));const r=6;this._unitId=(s=this.snapshot.id)!=null?s:tt(r),this._initializeHeaderFooterModel(),this._name$.next((i=this.snapshot.title)!=null?i:"")}dispose(){super.dispose(),this.headerModelMap.forEach(n=>{n.dispose()}),this.footerModelMap.forEach(n=>{n.dispose()}),this._name$.complete()}getDrawings(){return this.snapshot.drawings}getDrawingsOrder(){return this.snapshot.drawingsOrder}getCustomRanges(){var n;return(n=this.snapshot.body)==null?void 0:n.customRanges}getCustomDecorations(){var n;return(n=this.snapshot.body)==null?void 0:n.customDecorations}getSettings(){return this.snapshot.settings}reset(n){if(n.id&&n.id!==this._unitId)throw new Error("Cannot reset a document model with a different unit id!");this.snapshot={...Xo,...n},this._initializeHeaderFooterModel(),this.change$.next(this.change$.value+1)}getSelfOrHeaderFooterModel(n){if(n!=null){if(this.headerModelMap.has(n))return this.headerModelMap.get(n);if(this.footerModelMap.has(n))return this.footerModelMap.get(n)}return this}getUnitId(){return this._unitId}apply(n){if(!Gt.isNoop(n))return this.snapshot=Gt.apply(this.snapshot,n),n!=null&&n.some(r=>Array.isArray(r)&&((r==null?void 0:r[0])==="headers"||(r==null?void 0:r[0])==="footers"))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.change$.next(this.change$.value+1),this.snapshot}sliceBody(n,r,s=Ko.copy){const i=this.getBody();if(i!=null)return yt(i,n,r,!1,s)}_initializeHeaderFooterModel(){const{headers:n,footers:r}=this.getSnapshot();if(n)for(const s in n){const i=n[s];this.headerModelMap.set(s,new Nt(i)),this.headerModelMap.get(s).updateDocumentId(this.getUnitId())}if(r)for(const s in r){const i=r[s];this.footerModelMap.set(s,new Nt(i)),this.footerModelMap.get(s).updateDocumentId(this.getUnitId())}}updateDocumentId(n){super.updateDocumentId(n),this._unitId=n}getPlainText(){var n,r;return Vs((r=(n=this.getBody())==null?void 0:n.dataStream)!=null?r:"")}}function bp(e){const{ranges:t,id:n,type:r}=e,s=new Me;let i=0;for(let o=0;o<t.length;o++){const a=t[o],{startOffset:l,endOffset:c}=a;l>0&&s.push({t:Z.RETAIN,len:l-i}),s.push({t:Z.RETAIN,body:{dataStream:"",customDecorations:[{id:n,type:r,startIndex:0,endIndex:c-l-1}]},len:c-l}),i=c}return s}function Ap(e){var u,h,d;const{id:t,segmentId:n,documentDataModel:r}=e,s=r==null?void 0:r.getBody();if(!r||!s)return!1;const i=(d=(h=(u=r.getSelfOrHeaderFooterModel(n))==null?void 0:u.getBody())==null?void 0:h.customDecorations)==null?void 0:d.find(f=>f.id===t);if(!i)return!1;const o=new Me,{startIndex:a,endIndex:l}=i,c=l-a+1;return o.push({t:Z.RETAIN,len:a}),o.push({t:Z.RETAIN,len:c,body:{dataStream:"",customDecorations:[{startIndex:0,endIndex:c-1,id:t,type:pn.DELETED}]}}),o}function ah(e,t,n,r){return e<=n&&t>=n||e>=n&&e<=r}function Tp(e,t){const n=[];for(let r=0,s=t.length;r<s;r++){const i=t[r];e.collapsed?i.startIndex<e.startOffset&&e.startOffset<=i.endIndex&&n.push(i):ah(e.startOffset,e.endOffset-1,i.startIndex,i.endIndex)&&n.push(i)}return n}function yp(e){return{...q.deepClone(e),rangeId:tt()}}function Np(e,t){const n=[];let r=e[0];for(const s of t)s<e[0]||s>e[1]||(r<s&&n.push([r,s-1]),r=s+1);return r<=e[1]&&n.push([r,e[1]]),n}function lh(e,t,n,r){const s=[];for(let i=0,o=n.length;i<o;i++){const a=n[i];if((r===void 0||a.rangeType===r)&&Math.max(a.startIndex,e)<=Math.min(a.endIndex,t)&&s.push({...a}),a.startIndex>t)break}return s}function Mp(e,t){var i,o,a,l,c;const n=lh(e.startOffset,e.collapsed?e.startOffset:e.endOffset-1,(i=t.customRanges)!=null?i:[]),r=Math.min(e.startOffset,(a=(o=n[0])==null?void 0:o.startIndex)!=null?a:1/0),s=Math.max(e.endOffset,((c=(l=n[n.length-1])==null?void 0:l.endIndex)!=null?c:-1/0)+1);return{startOffset:r,endOffset:s,collapsed:r===s}}var Ei,tl;function Lp(){if(tl)return Ei;tl=1;var e=-1,t=1,n=0;function r(m,x,O,N,A){if(m===x)return m?[[n,m]]:[];if(O!=null){var v=B(m,x,O);if(v)return v}var y=a(m,x),M=m.substring(0,y);m=m.substring(y),x=x.substring(y),y=c(m,x);var L=m.substring(m.length-y);m=m.substring(0,m.length-y),x=x.substring(0,x.length-y);var P=s(m,x);return M&&P.unshift([n,M]),L&&P.push([n,L]),F(P,A),N&&h(P),P}function s(m,x){var O;if(!m)return[[t,x]];if(!x)return[[e,m]];var N=m.length>x.length?m:x,A=m.length>x.length?x:m,v=N.indexOf(A);if(v!==-1)return O=[[t,N.substring(0,v)],[n,A],[t,N.substring(v+A.length)]],m.length>x.length&&(O[0][0]=O[2][0]=e),O;if(A.length===1)return[[e,m],[t,x]];var y=u(m,x);if(y){var M=y[0],L=y[1],P=y[2],J=y[3],V=y[4],oe=r(M,P),le=r(L,J);return oe.concat([[n,V]],le)}return i(m,x)}function i(m,x){for(var O=m.length,N=x.length,A=Math.ceil((O+N)/2),v=A,y=2*A,M=new Array(y),L=new Array(y),P=0;P<y;P++)M[P]=-1,L[P]=-1;M[v+1]=0,L[v+1]=0;for(var J=O-N,V=J%2!==0,oe=0,le=0,I=0,D=0,Y=0;Y<A;Y++){for(var G=-Y+oe;G<=Y-le;G+=2){var H=v+G,j;G===-Y||G!==Y&&M[H-1]<M[H+1]?j=M[H+1]:j=M[H-1]+1;for(var Q=j-G;j<O&&Q<N&&m.charAt(j)===x.charAt(Q);)j++,Q++;if(M[H]=j,j>O)le+=2;else if(Q>N)oe+=2;else if(V){var ee=v+J-G;if(ee>=0&&ee<y&&L[ee]!==-1){var U=O-L[ee];if(j>=U)return o(m,x,j,Q)}}}for(var z=-Y+I;z<=Y-D;z+=2){var ee=v+z,U;z===-Y||z!==Y&&L[ee-1]<L[ee+1]?U=L[ee+1]:U=L[ee-1]+1;for(var X=U-z;U<O&&X<N&&m.charAt(O-U-1)===x.charAt(N-X-1);)U++,X++;if(L[ee]=U,U>O)D+=2;else if(X>N)I+=2;else if(!V){var H=v+J-z;if(H>=0&&H<y&&M[H]!==-1){var j=M[H],Q=v+j-H;if(U=O-U,j>=U)return o(m,x,j,Q)}}}}return[[e,m],[t,x]]}function o(m,x,O,N){var A=m.substring(0,O),v=x.substring(0,N),y=m.substring(O),M=x.substring(N),L=r(A,v),P=r(y,M);return L.concat(P)}function a(m,x){if(!m||!x||m.charAt(0)!==x.charAt(0))return 0;for(var O=0,N=Math.min(m.length,x.length),A=N,v=0;O<A;)m.substring(v,A)==x.substring(v,A)?(O=A,v=O):N=A,A=Math.floor((N-O)/2+O);return k(m.charCodeAt(A-1))&&A--,A}function l(m,x){var O=m.length,N=x.length;if(O==0||N==0)return 0;O>N?m=m.substring(O-N):O<N&&(x=x.substring(0,O));var A=Math.min(O,N);if(m==x)return A;for(var v=0,y=1;;){var M=m.substring(A-y),L=x.indexOf(M);if(L==-1)return v;y+=L,(L==0||m.substring(A-y)==x.substring(0,y))&&(v=y,y++)}}function c(m,x){if(!m||!x||m.slice(-1)!==x.slice(-1))return 0;for(var O=0,N=Math.min(m.length,x.length),A=N,v=0;O<A;)m.substring(m.length-A,m.length-v)==x.substring(x.length-A,x.length-v)?(O=A,v=O):N=A,A=Math.floor((N-O)/2+O);return W(m.charCodeAt(m.length-A))&&A--,A}function u(m,x){var O=m.length>x.length?m:x,N=m.length>x.length?x:m;if(O.length<4||N.length*2<O.length)return null;function A(le,I,D){for(var Y=le.substring(D,D+Math.floor(le.length/4)),G=-1,H="",j,Q,ee,U;(G=I.indexOf(Y,G+1))!==-1;){var z=a(le.substring(D),I.substring(G)),X=c(le.substring(0,D),I.substring(0,G));H.length<X+z&&(H=I.substring(G-X,G)+I.substring(G,G+z),j=le.substring(0,D-X),Q=le.substring(D+z),ee=I.substring(0,G-X),U=I.substring(G+z))}return H.length*2>=le.length?[j,Q,ee,U,H]:null}var v=A(O,N,Math.ceil(O.length/4)),y=A(O,N,Math.ceil(O.length/2)),M;if(!v&&!y)return null;y?v?M=v[4].length>y[4].length?v:y:M=y:M=v;var L,P,J,V;m.length>x.length?(L=M[0],P=M[1],J=M[2],V=M[3]):(J=M[0],V=M[1],L=M[2],P=M[3]);var oe=M[4];return[L,P,J,V,oe]}function h(m){for(var x=!1,O=[],N=0,A=null,v=0,y=0,M=0,L=0,P=0;v<m.length;)m[v][0]==n?(O[N++]=v,y=L,M=P,L=0,P=0,A=m[v][1]):(m[v][0]==t?L+=m[v][1].length:P+=m[v][1].length,A&&A.length<=Math.max(y,M)&&A.length<=Math.max(L,P)&&(m.splice(O[N-1],0,[e,A]),m[O[N-1]+1][0]=t,N--,N--,v=N>0?O[N-1]:-1,y=0,M=0,L=0,P=0,A=null,x=!0)),v++;for(x&&F(m),b(m),v=1;v<m.length;){if(m[v-1][0]==e&&m[v][0]==t){var J=m[v-1][1],V=m[v][1],oe=l(J,V),le=l(V,J);oe>=le?(oe>=J.length/2||oe>=V.length/2)&&(m.splice(v,0,[n,V.substring(0,oe)]),m[v-1][1]=J.substring(0,J.length-oe),m[v+1][1]=V.substring(oe),v++):(le>=J.length/2||le>=V.length/2)&&(m.splice(v,0,[n,J.substring(0,le)]),m[v-1][0]=t,m[v-1][1]=V.substring(0,V.length-le),m[v+1][0]=e,m[v+1][1]=J.substring(le),v++),v++}v++}}var d=/[^a-zA-Z0-9]/,f=/\s/,g=/[\r\n]/,_=/\n\r?\n$/,R=/^\r?\n\r?\n/;function b(m){function x(le,I){if(!le||!I)return 6;var D=le.charAt(le.length-1),Y=I.charAt(0),G=D.match(d),H=Y.match(d),j=G&&D.match(f),Q=H&&Y.match(f),ee=j&&D.match(g),U=Q&&Y.match(g),z=ee&&le.match(_),X=U&&I.match(R);return z||X?5:ee||U?4:G&&!j&&Q?3:j||Q?2:G||H?1:0}for(var O=1;O<m.length-1;){if(m[O-1][0]==n&&m[O+1][0]==n){var N=m[O-1][1],A=m[O][1],v=m[O+1][1],y=c(N,A);if(y){var M=A.substring(A.length-y);N=N.substring(0,N.length-y),A=M+A.substring(0,A.length-y),v=M+v}for(var L=N,P=A,J=v,V=x(N,A)+x(A,v);A.charAt(0)===v.charAt(0);){N+=A.charAt(0),A=A.substring(1)+v.charAt(0),v=v.substring(1);var oe=x(N,A)+x(A,v);oe>=V&&(V=oe,L=N,P=A,J=v)}m[O-1][1]!=L&&(L?m[O-1][1]=L:(m.splice(O-1,1),O--),m[O][1]=P,J?m[O+1][1]=J:(m.splice(O+1,1),O--))}O++}}function F(m,x){m.push([n,""]);for(var O=0,N=0,A=0,v="",y="",M;O<m.length;){if(O<m.length-1&&!m[O][1]){m.splice(O,1);continue}switch(m[O][0]){case t:A++,y+=m[O][1],O++;break;case e:N++,v+=m[O][1],O++;break;case n:var L=O-A-N-1;if(x){if(L>=0&&C(m[L][1])){var P=m[L][1].slice(-1);if(m[L][1]=m[L][1].slice(0,-1),v=P+v,y=P+y,!m[L][1]){m.splice(L,1),O--;var J=L-1;m[J]&&m[J][0]===t&&(A++,y=m[J][1]+y,J--),m[J]&&m[J][0]===e&&(N++,v=m[J][1]+v,J--),L=J}}if(S(m[O][1])){var P=m[O][1].charAt(0);m[O][1]=m[O][1].slice(1),v+=P,y+=P}}if(O<m.length-1&&!m[O][1]){m.splice(O,1);break}if(v.length>0||y.length>0){v.length>0&&y.length>0&&(M=a(y,v),M!==0&&(L>=0?m[L][1]+=y.substring(0,M):(m.splice(0,0,[n,y.substring(0,M)]),O++),y=y.substring(M),v=v.substring(M)),M=c(y,v),M!==0&&(m[O][1]=y.substring(y.length-M)+m[O][1],y=y.substring(0,y.length-M),v=v.substring(0,v.length-M)));var V=A+N;v.length===0&&y.length===0?(m.splice(O-V,V),O=O-V):v.length===0?(m.splice(O-V,V,[t,y]),O=O-V+1):y.length===0?(m.splice(O-V,V,[e,v]),O=O-V+1):(m.splice(O-V,V,[e,v],[t,y]),O=O-V+2)}O!==0&&m[O-1][0]===n?(m[O-1][1]+=m[O][1],m.splice(O,1)):O++,A=0,N=0,v="",y="";break}}m[m.length-1][1]===""&&m.pop();var oe=!1;for(O=1;O<m.length-1;)m[O-1][0]===n&&m[O+1][0]===n&&(m[O][1].substring(m[O][1].length-m[O-1][1].length)===m[O-1][1]?(m[O][1]=m[O-1][1]+m[O][1].substring(0,m[O][1].length-m[O-1][1].length),m[O+1][1]=m[O-1][1]+m[O+1][1],m.splice(O-1,1),oe=!0):m[O][1].substring(0,m[O+1][1].length)==m[O+1][1]&&(m[O-1][1]+=m[O+1][1],m[O][1]=m[O][1].substring(m[O+1][1].length)+m[O+1][1],m.splice(O+1,1),oe=!0)),O++;oe&&F(m,x)}function k(m){return m>=55296&&m<=56319}function W(m){return m>=56320&&m<=57343}function S(m){return W(m.charCodeAt(0))}function C(m){return k(m.charCodeAt(m.length-1))}function w(m){for(var x=[],O=0;O<m.length;O++)m[O][1].length>0&&x.push(m[O]);return x}function T(m,x,O,N){return C(m)||S(N)?null:w([[n,m],[e,x],[t,O],[n,N]])}function B(m,x,O){var N=typeof O=="number"?{index:O,length:0}:O.oldRange,A=typeof O=="number"?null:O.newRange,v=m.length,y=x.length;if(N.length===0&&(A===null||A.length===0)){var M=N.index,L=m.slice(0,M),P=m.slice(M),J=A?A.index:null;e:{var V=M+y-v;if(J!==null&&J!==V||V<0||V>y)break e;var oe=x.slice(0,V),le=x.slice(V);if(le!==P)break e;var I=Math.min(M,V),D=L.slice(0,I),Y=oe.slice(0,I);if(D!==Y)break e;var G=L.slice(I),H=oe.slice(I);return T(D,G,H,P)}e:{if(J!==null&&J!==M)break e;var j=M,oe=x.slice(0,j),le=x.slice(j);if(oe!==L)break e;var Q=Math.min(v-j,y-j),ee=P.slice(P.length-Q),U=le.slice(le.length-Q);if(ee!==U)break e;var G=P.slice(0,P.length-Q),H=le.slice(0,le.length-Q);return T(L,G,H,ee)}}if(N.length>0&&A&&A.length===0)e:{var D=m.slice(0,N.index),ee=m.slice(N.index+N.length),I=D.length,Q=ee.length;if(y<I+Q)break e;var Y=x.slice(0,I),U=x.slice(y-Q);if(D!==Y||ee!==U)break e;var G=m.slice(I,v-Q),H=x.slice(I,y-Q);return T(D,G,H,ee)}return null}function $(m,x,O,N){return r(m,x,O,N,!0)}return $.INSERT=t,$.DELETE=e,$.EQUAL=n,Ei=$,Ei}var Dp=Lp();const qo=It(Dp);function xp(e){var h,d,f;const{rangeId:t,segmentId:n,documentDataModel:r,insert:s}=e,i=(d=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.customRanges)==null?void 0:d.find(g=>g.rangeId===t);if(!i)return!1;const{startIndex:o,endIndex:a}=i,l=new Me,c=a-o+1;l.push({t:Z.RETAIN,len:o}),l.push({t:Z.RETAIN,len:c,body:{dataStream:"",customRanges:[]}}),s&&l.push({t:Z.INSERT,body:s,len:s.dataStream.length});const u=a+1+((f=s==null?void 0:s.dataStream.length)!=null?f:0);return l.selections=[{startOffset:u,endOffset:u,collapsed:!0}],l}function Up(e){const{ranges:t,rangeId:n,rangeType:r,wholeEntity:s,properties:i,body:o}=e;let a=0;const l=new Me;let c=!1;return t.forEach(u=>{var k,W,S;const h=Mp(u,o);if(!h||!o)return!1;const{startOffset:d,endOffset:f}=h,g=(k=o.customRanges)!=null?k:[],_=(C,w,T)=>{var O,N,A,v;const B=lh(C,w,g,r),$=Math.min((N=(O=B[0])==null?void 0:O.startIndex)!=null?N:1/0,C),m=Math.max((v=(A=B[B.length-1])==null?void 0:A.endIndex)!=null?v:-1/0,w),x={rangeId:T?`${n}$${T}`:n,rangeType:r,startIndex:0,endIndex:m-$,wholeEntity:s,properties:{...i}};l.push({t:Z.RETAIN,len:$-a}),l.push({t:Z.RETAIN,len:m-$+1,body:{dataStream:"",customRanges:[x]},coverType:Ee.COVER}),a=m+1},R=((W=o.paragraphs)!=null?W:[]).filter(C=>C.startIndex<f&&C.startIndex>d),b=((S=o.customBlocks)!=null?S:[]).filter(C=>C.startIndex<f&&C.startIndex>d);Np([d,f-1],[...R.map(C=>C.startIndex),...b.map(C=>C.startIndex)]).forEach(([C,w],T)=>_(C,w,T)),c=!0,l.selections=[{startOffset:h.endOffset,endOffset:h.endOffset,collapsed:!0}]}),c?l:!1}function ch(e,t,n=0,r=null,s=!0){e.sort((c,u)=>c.startOffset-u.startOffset);const i=[],{paragraphs:o=[]}=t,a=o==null?void 0:o.find(c=>c.startIndex>=e[0].startOffset&&c.startIndex<e[0].endOffset);let l=n;if(e.forEach(c=>{const{startOffset:u,endOffset:h}=c;u>l&&(i.push({t:Z.RETAIN,len:u-l}),l=u),l<h&&(i.push({t:Z.DELETE,len:h-l}),l=h)}),r&&i.push({t:Z.INSERT,body:r,len:r.dataStream.length}),a&&s){const c=o.find(u=>u.startIndex-n>=e[e.length-1].endOffset-1);c&&(c.startIndex>l&&(i.push({t:Z.RETAIN,len:c.startIndex-l}),l=c.startIndex),i.push({t:Z.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...c,startIndex:0,bullet:a==null?void 0:a.bullet}]},coverType:Ee.REPLACE}))}return i}function Pp(e,t,n=0){const r=[];let s=n;return e.forEach(i=>{const{startOffset:o,endOffset:a}=i;o>s&&(r.push({t:Z.RETAIN,len:o-s}),s=o),a>s&&(r.push({t:Z.RETAIN,len:a-s,body:{...q.deepClone(t),dataStream:""}}),s=a)}),r}const kp=e=>{var h;const{selection:t,body:n,doc:r}=e,s=t.segmentId,i=(h=r.getSelfOrHeaderFooterModel(s))==null?void 0:h.getBody();if(!i)return!1;const o=t.collapsed?null:yt(i,t.startOffset,t.endOffset),a=qo(o?o.dataStream:"",n.dataStream);let l=0;const c=a.map(([d,f])=>{switch(d){case 0:{const g={t:Z.RETAIN,body:{...yt(n,l,l+f.length,!1),dataStream:""},len:f.length};return l+=f.length,g}case 1:{const g={t:Z.INSERT,body:yt(n,l,l+f.length),len:f.length};return l+=f.length,g}default:return{t:Z.DELETE,len:f.length}}}),u=new Me;return u.push({t:Z.RETAIN,len:t.startOffset}),u.push(...c),u};function Fp(e,t){return!!((e==null?void 0:e.length)===(t==null?void 0:t.length)&&(e!=null&&e.every((n,r)=>JSON.stringify(n)===JSON.stringify(t==null?void 0:t[r]))))}const Bp=e=>{var d;const{selection:t,body:n,doc:r,themeService:s}=e,i=t.segmentId,o=(d=r.getSelfOrHeaderFooterModel(i))==null?void 0:d.getBody();if(!o)return!1;const a=t.collapsed?null:yt(o,t.startOffset,t.endOffset),l=qo(a?a.dataStream:"",n.dataStream);let c=0;const u=l.map(([f,g])=>{switch(f){case 0:{const _=Ds(n,c,c+g.length,!1),R=Ds(a,c,c+g.length,!1),b={t:Z.RETAIN,body:Fp(_,R)?void 0:{textRuns:_==null?void 0:_.map(F=>{var k,W,S,C,w,T,B;return{...F,ts:{...F.ts,cl:(S=(W=(k=F.ts)==null?void 0:k.cl)==null?void 0:W.rgb)!=null&&S.includes(".")?{rgb:s.getColorFromTheme((T=(w=(C=F.ts)==null?void 0:C.cl)==null?void 0:w.rgb)!=null?T:"")}:(B=F.ts)==null?void 0:B.cl}}}),dataStream:""},len:g.length};return c+=g.length,b}case 1:{const _={t:Z.INSERT,body:yt(n,c,c+g.length),len:g.length};return c+=g.length,_}default:return{t:Z.DELETE,len:g.length}}});if(u.every(f=>f.t===Z.RETAIN&&!f.body))return!1;const h=new Me;return h.push({t:Z.RETAIN,len:t.startOffset}),h.push(...u),h};function $p(e,t){const n=[],{customBlocks:r=[]}=e;for(const s of t){const{startOffset:i,endOffset:o}=s;if(!(i==null||o==null))for(const a of r){const{startIndex:l}=a;l>=i&&l<o&&n.push(a.blockId)}}return n}function Hp(e,t=""){if(!t)return["body"];const{headers:n,footers:r}=e.getSnapshot();if(n==null&&r==null)throw new Error("Document data model must have headers or footers when update by segment id");if((n==null?void 0:n[t])!=null)return["headers",t,"body"];if((r==null?void 0:r[t])!=null)return["footers",t,"body"];throw new Error("Segment id not found in headers or footers")}const jp=e=>{var _,R,b,F;const{selection:t,documentDataModel:n,drawings:r}=e,{collapsed:s,startOffset:i,segmentId:o}=t,a=new Me,l=Gt.getInstance(),c=[],u=n.getSelfOrHeaderFooterModel(o).getBody();if(!u)return!1;const h=(R=(_=n.getSnapshot().drawingsOrder)==null?void 0:_.length)!=null?R:0;let d=0;if(s)i>0&&a.push({t:Z.RETAIN,len:i});else{const k=ch([t],u,0,null,!1);a.push(...k);const W=$p(u,[t]),S=(b=n.getDrawings())!=null?b:{},C=(F=n.getDrawingsOrder())!=null?F:[],w=W.sort((T,B)=>C.indexOf(T)>C.indexOf(B)?-1:C.indexOf(T)<C.indexOf(B)?1:0);if(w.length>0)for(const T of w){const B=S[T],$=C.indexOf(T);if(B==null||$<0)continue;const m=l.removeOp(["drawings",T],B),x=l.removeOp(["drawingsOrder",$],T);c.push(m),c.push(x),d++}}a.push({t:Z.INSERT,body:{dataStream:"\b".repeat(r.length),customBlocks:r.map((k,W)=>({startIndex:W,blockId:k.drawingId}))},len:r.length});const f=Hp(n,o),g=l.editOp(a.serialize(),f);c.push(g);for(const k of r){const{drawingId:W}=k,S=l.insertOp(["drawings",W],k),C=l.insertOp(["drawingsOrder",h-d],W);c.push(S),c.push(C)}return c.reduce((k,W)=>Gt.compose(k,W),null)};function Wp(e,t){if(typeof t>"u")return{startOffset:e,endOffset:e,collapsed:!0};if(t<e)throw new Error(`Cannot make a doc selection when endOffset ${t} is less than startOffset ${e}.`);return{startOffset:e,endOffset:t,collapsed:e===t}}function Yp(e){const{startOffset:t,endOffset:n,collapsed:r}=e,s=Math.min(t,n),i=Math.max(t,n);return{startOffset:s,endOffset:i,collapsed:r}}function Gp(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function Vi(e,t,n,r){const{startOffset:s,endOffset:i}=e,o=r!=null?r:Zo(t,n),a=[];let l=-1;for(let c=0;c<o.length;c++){const u=o[c],{startIndex:h}=u;(s>l&&s<=h||i>l&&i<=h||h>=s&&h<=i)&&a.push(u),l=h}return a}function zi(e,t,n){const r=[],s=Zo(t,n);for(const i of e){const o=Vi(i,t,n,s);r.push(...o)}return r}const Vp=[at.PARAGRAPH,at.TABLE_START,at.TABLE_END,at.TABLE_ROW_START,at.TABLE_CELL_START,at.TABLE_CELL_END];function Zo(e,t){const n=[];for(let r=0;r<e.length;r++){const s=e[r],{startIndex:i}=s;let o=i-1;for(;!Vp.includes(t[o])&&o>=0;)o--;n.push({...s,paragraphStart:o+1,paragraphEnd:s.startIndex})}return n}const zp=e=>{var h,d,f;const{paragraphs:t,segmentId:n,document:r}=e;let s=e.listType;const i=(d=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.paragraphs)!=null?d:[],o=t.every(g=>{var _;return((_=g.bullet)==null?void 0:_.listType.indexOf(s))===0});let l=tt(6);if(t.length===1){const g=i.indexOf(t[0]),_=i[g-1],R=i[g+1];_&&_.bullet&&_.bullet.listType.indexOf(s)===0?(l=_.bullet.listId,s!==kt.CHECK_LIST&&(s=_.bullet.listType)):R&&R.bullet&&R.bullet.listType.indexOf(s)===0&&(l=R.bullet.listId,s!==kt.CHECK_LIST&&(s=R.bullet.listType))}const c=new On;c.reset();const u=new Me;for(const g of t){const{startIndex:_,paragraphStyle:R={},bullet:b}=g;u.push({t:Z.RETAIN,len:_-c.cursor}),u.push({t:Z.RETAIN,len:1,body:{dataStream:"",paragraphs:[o?{paragraphStyle:R,startIndex:0}:{startIndex:0,paragraphStyle:{...R},bullet:{nestingLevel:(f=b==null?void 0:b.nestingLevel)!=null?f:0,textStyle:{fs:20},listType:s,listId:l}}]},coverType:Ee.REPLACE}),c.moveCursorTo(_+1)}return u},Kp=e=>{var h;const{paragraphIndex:t,segmentId:n,document:r}=e,s=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.paragraphs;if(s==null)return!1;const i=s.find(d=>d.startIndex===t);if(!(i!=null&&i.bullet)||i.bullet.listType.indexOf(kt.CHECK_LIST)===-1)return!1;const o=new On;o.reset();const a=new Me,{startIndex:l,paragraphStyle:c={}}=i,u=i.bullet.listType===kt.CHECK_LIST?kt.CHECK_LIST_CHECKED:kt.CHECK_LIST;return a.push({t:Z.RETAIN,len:l-o.cursor}),a.push({t:Z.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...i,paragraphStyle:c,startIndex:0,bullet:{...i.bullet,listType:u}}]},coverType:Ee.REPLACE}),o.moveCursorTo(l+1),a},Xp=e=>{var u,h;const{paragraphs:t,listType:n,segmentId:r,document:s}=e;if(((u=s.getSelfOrHeaderFooterModel(r).getBody())==null?void 0:u.paragraphs)==null)return!1;const a=tt(6),l=new On;l.reset();const c=new Me;for(const d of t){const{startIndex:f,paragraphStyle:g={},bullet:_}=d;c.push({t:Z.RETAIN,len:f-l.cursor}),c.push({t:Z.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:g,bullet:{nestingLevel:(h=_==null?void 0:_.nestingLevel)!=null?h:0,textStyle:(_==null?void 0:_.listType)===n?_.textStyle:{fs:20},listType:n,listId:a}}]},coverType:Ee.REPLACE}),l.moveCursorTo(f+1)}return c};function qp(e,t){return t.some(n=>e.startIndex>n.startIndex&&e.startIndex<n.endIndex)}const Zp=e=>{var c,u,h;const{paragraphs:t,document:n,type:r}=e,s=new On;s.reset();const i=new Me,o=(c=n.getSnapshot().lists)!=null?c:{},a=(h=(u=n.getBody())==null?void 0:u.tables)!=null?h:[],l={...Wr,...o};for(const d of t){const{startIndex:f,paragraphStyle:g={},bullet:_}=d,R=qp(d,a);if(i.push({t:Z.RETAIN,len:f-s.cursor}),_){const b=_.listType;let F=l[b].nestingLevel.length-1;R&&(F=Math.min(F,2)),i.push({t:Z.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:{...g},bullet:{..._,nestingLevel:Math.max(Math.min(_.nestingLevel+r,F),0)}}]},coverType:Ee.REPLACE})}else i.push({t:Z.RETAIN,len:1});s.moveCursorTo(f+1)}return i},Jp=e=>{var R,b,F,k;const{textRanges:t,segmentId:n,document:r,style:s,paragraphTextRun:i,cursor:o,deleteLen:a,textX:l}=e,c=r.getSelfOrHeaderFooterModel(n),u=(b=(R=c.getBody())==null?void 0:R.paragraphs)!=null?b:[],h=(k=(F=c.getBody())==null?void 0:F.dataStream)!=null?k:"",d=zi(t,u,h),f=new On;o&&f.moveCursorTo(o);const g=l!=null?l:new Me;d.sort((W,S)=>W.startIndex-S.startIndex);const _=Math.max(0,d[0].paragraphStart-1);_>f.cursor&&(g.push({t:Z.RETAIN,len:_-f.cursor}),f.moveCursorTo(_)),a&&g.push({t:Z.DELETE,len:a});for(const W of d){const{startIndex:S,paragraphStyle:C={}}=W,w=S-f.cursor;g.push({t:Z.RETAIN,len:w,...i?{body:{dataStream:"",textRuns:[{ts:i,st:0,ed:w}]},coverType:Ee.REPLACE}:null}),g.push({t:Z.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:{...C,...s}}]},coverType:Ee.REPLACE}),f.moveCursorTo(S+1)}return g};class Qe{}p(Qe,"customRange",{add:Up,delete:xp,copyCustomRange:yp,getCustomRangesInterestsWithSelection:Tp,isIntersecting:ah}),p(Qe,"customDecoration",{add:bp,delete:Ap}),p(Qe,"selection",{replace:kp,makeSelection:Wp,normalizeSelection:Yp,delete:ch,replaceTextRuns:Bp,retain:Pp}),p(Qe,"range",{isIntersects:Gp,getParagraphsInRange:Vi,getParagraphsInRanges:zi}),p(Qe,"transform",{getPlainText:Vs,fromPlainText:vp,isEmptyDocument:Op}),p(Qe,"paragraph",{bullet:{set:Xp,switch:zp,toggleChecklist:Kp,changeNestLevel:Zp},style:{set:Jp},util:{transform:Zo,getParagraphsInRange:Vi,getParagraphsInRanges:zi}}),p(Qe,"drawing",{add:jp});function Qp(e,t,n,r){var c;if(t==="")return e;const s={id:"mock-id",body:e,documentStyle:{}},i=new Nt(s),o=t.length;let a;for(;(a=(r?i.getBody().dataStream:i.getBody().dataStream.toLowerCase()).indexOf(t))>=0;){const u=new Me,h=Gt.getInstance();if(a>0&&u.retain(a),n.length>0){const d=i.sliceBody(a,a+o),f={dataStream:n};if(Array.isArray(d==null?void 0:d.textRuns)&&d.textRuns.length&&(f.textRuns=[{...d.textRuns[0],st:0,ed:n.length}]),(c=d==null?void 0:d.customRanges)!=null&&c.length){const g=d.customRanges[0];f.customRanges=[{...g,startIndex:0,endIndex:n.length-1}]}u.insert(n.length,f)}u.delete(o),i.apply(h.editOp(u.serialize()))}const l=i.getBody();return i.dispose(),l}function eE(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 uh(e){var t;return e.body=eE((t=e.body)!=null?t:{dataStream:""}),e.drawingsOrder||(e.drawingsOrder=[]),e.drawings||(e.drawings={}),e.documentStyle||(e.documentStyle={}),e}class Yr{constructor(t={}){p(this,"_style");this._style=t}static create(t={}){return new Yr(t)}get fontFamily(){return this._style.ff}get fontSize(){return this._style.fs}get italic(){return this._style.it===ie.TRUE}get bold(){return this._style.bl===ie.TRUE}get underline(){return this._style.ul&&Jt.create(this._style.ul)}get bottomBorderLine(){return this._style.bbl&&Jt.create(this._style.bbl)}get strikethrough(){return this._style.st&&Jt.create(this._style.st)}get overline(){return this._style.ol&&Jt.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 nn.create(q.deepClone(this._style))}getValue(){return{...this._style}}}class nn extends Yr{static create(t={}){return new nn(t)}constructor(t={}){super(t)}setFontFamily(t){return this._style.ff=t,this}setFontSize(t){return this._style.fs=t,this}setItalic(t){return this._style.it=t?1:0,this}setBold(t){return this._style.bl=t?1:0,this}setUnderline(t){return this._style.ul=t.build(),this}setBottomBorderLine(t){return this._style.bbl=t.build(),this}setStrikethrough(t){return this._style.st=t.build(),this}setOverline(t){return this._style.ol=t.build(),this}setBackground(t){return this._style.bg=t,this}setBorder(t){return this._style.bd=t,this}setColor(t){return this._style.cl=t,this}setVerticalAlign(t){return this._style.va=t,this}copy(){return nn.create(q.deepClone(this._style))}build(){return this.getValue()}}class Jt{constructor(t={s:1}){p(this,"_decoration");this._decoration=t}static create(t={s:1}){return new Jt(t)}get show(){return this._decoration.s===ie.TRUE}get followFontColor(){return this._decoration.c===ie.TRUE}get color(){return this._decoration.cl}get type(){return this._decoration.t}setShow(t){return this._decoration.s=t?1:0,this}setFollowFontColor(t){return this._decoration.c=t?1:0,this}setColor(t){return this._decoration.cl=t,this}setLineType(t){return this._decoration.t=t,this}copy(){return Jt.create(q.deepClone(this._decoration))}build(){return{...this._decoration}}}class Gr{constructor(t={}){p(this,"_style");this._style=t}static create(t={}){return new Gr(t)}get indentFirstLine(){return this._style.indentFirstLine}get hanging(){return this._style.hanging}get indentStart(){return this._style.indentStart}get tabStops(){return this._style.tabStops}get indentEnd(){return this._style.indentEnd}get textStyle(){return this._style.textStyle}get headingId(){return this._style.headingId}get namedStyleType(){return this._style.namedStyleType}get horizontalAlign(){return this._style.horizontalAlign}get lineSpacing(){return this._style.lineSpacing}get direction(){return this._style.direction}get spacingRule(){return this._style.spacingRule}get snapToGrid(){return this._style.snapToGrid}get spaceAbove(){return this._style.spaceAbove}get spaceBelow(){return this._style.spaceBelow}get borderBetween(){return this._style.borderBetween}get borderTop(){return this._style.borderTop}get borderBottom(){return this._style.borderBottom}get borderLeft(){return this._style.borderLeft}get borderRight(){return this._style.borderRight}get keepLines(){return this._style.keepLines===ie.TRUE}get keepNext(){return this._style.keepNext===ie.TRUE}get wordWrap(){return this._style.wordWrap===ie.TRUE}get widowControl(){return this._style.widowControl===ie.TRUE}get shading(){return this._style.shading}get suppressHyphenation(){return this._style.suppressHyphenation===ie.TRUE}copy(){return Mr.create(q.deepClone(this._style))}getValue(){return this._style}}class Mr extends Gr{static create(t={}){return new Mr(t)}constructor(t={}){super(t)}setIndentFirstLine(t){return this._style.indentFirstLine=t,this}setHanging(t){return this._style.hanging=t,this}setIndentStart(t){return this._style.indentStart=t,this}setTabStops(t){return this._style.tabStops=t,this}setIndentEnd(t){return this._style.indentEnd=t,this}setTextStyle(t){return this._style.textStyle=t,this}setHeadingId(t){return this._style.headingId=t,this}setNamedStyleType(t){return this._style.namedStyleType=t,this}setHorizontalAlign(t){return this._style.horizontalAlign=t,this}setLineSpacing(t){return this._style.lineSpacing=t,this}setDirection(t){return this._style.direction=t,this}setSpacingRule(t){return this._style.spacingRule=t,this}setSnapToGrid(t){return this._style.snapToGrid=t?1:0,this}setSpaceAbove(t){return this._style.spaceAbove=t,this}setSpaceBelow(t){return this._style.spaceBelow=t,this}setBorderBetween(t){return this._style.borderBetween=t,this}setBorderTop(t){return this._style.borderTop=t,this}setBorderBottom(t){return this._style.borderBottom=t,this}setBorderLeft(t){return this._style.borderLeft=t,this}setBorderRight(t){return this._style.borderRight=t,this}setKeepLines(t){return this._style.keepLines=t?1:0,this}setKeepNext(t){return this._style.keepNext=t?1:0,this}setWordWrap(t){return this._style.wordWrap=t?1:0,this}setWidowControl(t){return this._style.widowControl=t?1:0,this}setShading(t){return this._style.shading=t,this}setSuppressHyphenation(t){return this._style.suppressHyphenation=t?1:0,this}copy(){return Mr.create(q.deepClone(this._style))}build(){return this.getValue()}}class Qt{constructor(t){p(this,"_data");if(!t.body)throw new Error("Invalid document data, body is required");this._data=uh(t)}static create(t){return new Qt(t)}static createByBody(t){return new Qt({body:t,id:"d",documentStyle:{}})}copy(){return En.create(q.deepClone(this._data))}slice(t,n){const{body:r,...s}=this._data;return En.create({...q.deepClone(s),body:yt(r,t,n)})}toPlainText(){var t,n;return Qe.transform.getPlainText((n=(t=this._data.body)==null?void 0:t.dataStream)!=null?n:"").replaceAll("\r",`
|
|
7
7
|
`)}getParagraphStyle(){var t,n;return Gr.create((n=(t=this._data.body)==null?void 0:t.paragraphs)==null?void 0:n[0].paragraphStyle)}getParagraphBullet(){var t,n;return(n=(t=this._data.body)==null?void 0:t.paragraphs)==null?void 0:n[0].bullet}getParagraphs(){var r,s;const t=(s=(r=this._data.body)==null?void 0:r.paragraphs)!=null?s:[];let n=0;return t.map(i=>{const o=this.slice(n,i.startIndex);return n=i.startIndex,o})}getTextRuns(){var t,n;return((n=(t=this._data.body)==null?void 0:t.textRuns)!=null?n:[]).map(r=>({...r,ts:r.ts?Yr.create(r.ts):null}))}getLinks(){var t,n,r;return(r=(n=(t=this._data.body)==null?void 0:t.customRanges)==null?void 0:n.filter(s=>s.rangeType===sn.HYPERLINK))!=null?r:[]}getData(){return this._data}}class En extends Qt{constructor(n){super(n);p(this,"_doc");this._doc=new Nt(n)}static newEmptyData(){return uh({id:"d",documentStyle:{},drawings:{},drawingsOrder:[],body:{dataStream:`\r
|
|
8
|
-
`,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(n){return new En(n!=null?n:En.newEmptyData())}insertText(n,r,s){var u,h;let i=((h=(u=this._data.body)==null?void 0:u.dataStream.length)!=null?h:2)-2,o,a;if(typeof n=="string"?o=n:(i=Math.min(n,i),o=r),typeof r=="object"?a=r instanceof nn?r.build():r:a=s instanceof nn?s.build():s,!o)return this;const l={dataStream:o,textRuns:a?[{ts:a,st:i,ed:i+o.length}]:[]},c=Qe.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:l});if(!c)throw new Error("Insert text failed, please check.");return Me.apply(this._doc.getBody(),c.serialize()),this}insertRichText(n,r){var a,l;let s=((l=(a=this._data.body)==null?void 0:a.dataStream.length)!=null?l:2)-2,i;typeof n=="object"?i=n instanceof Qt?n.getData():n:(s=Math.min(n,s),i=r instanceof Qt?r.getData():r);const o=Qe.selection.replace({doc:this._doc,selection:{startOffset:s,endOffset:s,collapsed:!0},body:i.body});if(!o)throw new Error("Insert text failed, please check.");return Me.apply(this._doc.getBody(),o.serialize()),this}delete(n,r){if(r!==void 0){if(!r)return this;const s=Qe.selection.delete([{startOffset:n,endOffset:n+r,collapsed:!0}],this._data.body);Me.apply(this._doc.getBody(),s)}return this}setStyle(n,r,s){const i={dataStream:"",textRuns:[{ts:s instanceof nn?s.build():s,st:0,ed:r-n}]},o=Qe.selection.retain([{startOffset:n,endOffset:r,collapsed:!0}],i);return Me.apply(this._doc.getBody(),o),this}setLink(n,r,s){const i=Qe.customRange.add({rangeType:sn.HYPERLINK,rangeId:tt(),properties:{url:s},ranges:[{startOffset:n,endOffset:r,collapsed:!1}],body:this._data.body});if(!i)throw new Error("Insert text failed, please check.");return Me.apply(this._doc.getBody(),i.serialize()),this}cancelLink(n,r){if(typeof n=="string"){const s=Qe.customRange.delete({rangeId:n,documentDataModel:this._doc});if(!s)throw new Error("Insert text failed, please check.");Me.apply(this._doc.getBody(),s.serialize())}else this.slice(n,r).getLinks().forEach(i=>{const o=Qe.customRange.delete({rangeId:i.rangeId,documentDataModel:this._doc});if(!o)throw new Error("Insert text failed, please check.");Me.apply(this._doc.getBody(),o.serialize())});return this}updateLink(n,r){var i,o;const s=(o=(i=this._data.body)==null?void 0:i.customRanges)==null?void 0:o.find(a=>a.rangeId===n);if(!s)throw new Error("Link not found");return s.properties.url=r,this}insertParagraph(n,r){var o,a;let s,i;return typeof n=="object"?(s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:n.build()}]},i=((a=(o=this._data.body)==null?void 0:o.dataStream.length)!=null?a:2)-2):(i=n,s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:r==null?void 0:r.build()}]}),this.insertRichText(i,Qt.create({body:s,id:"d",documentStyle:{}})),this}insertLink(n,r,s){let i="",o="";typeof n=="string"?(i=n,o=r):(i=r,o=s);const a=En.createByBody({dataStream:i,customRanges:[{rangeType:sn.HYPERLINK,rangeId:tt(),properties:{url:o},startIndex:0,endIndex:i.length-1}]});return typeof n=="number"?this.insertRichText(n,a):this.insertRichText(a)}}const tE="__default_document_sub_component_id20231101__";class hh{constructor(){p(this,"skipNextObservers",!1);p(this,"lastReturnValue");p(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class nE extends ce.Subject{constructor(){super(...arguments);p(this,"_sortedObservers",[])}subscribe(){throw new Error("[EventSubject]: please use `subscribeEvent` instead of `subscribe` method for `EventSubject`.")}next(){throw new Error("[EventSubject]: please use `emitEvent` instead of `next` method for `EventSubject`.")}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(n){let r;typeof n=="function"?r={next:([i,o])=>n(i,o)}:r=n;const s=super.subscribe(r);return this._sortedObservers.push(r),this._sortedObservers.sort((i,o)=>{var a,l;return((a=i.priority)!=null?a:0)-((l=o.priority)!=null?l:0)}),s.add(()=>this._sortedObservers=this._sortedObservers.filter(i=>i!==r)),s}clearObservers(){this._sortedObservers.forEach(n=>{var r;return(r=n.complete)==null?void 0:r.call(n)}),this._sortedObservers.length=0}emitEvent(n){var r;if(!this.closed){const s=new hh;s.lastReturnValue=n;for(const i of this._sortedObservers){const o=(r=i.next)==null?void 0:r.call(i,[n,s]);if(s.lastReturnValue=o,s.skipNextObservers)return{handled:!0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}throw new Error("[EventSubject]: cannot emit event on a closed subject.")}}function rE(e){return new ce.Observable(t=>{const n=e.subscribeEvent(r=>{t.next(r)});return()=>n.unsubscribe()})}const zs=Ae.createIdentifier("core.resource-manager.service"),Ki={[Ut.Editor]:"Editor",[Ut.Owner]:"Owner",[Ut.Reader]:"Reader",[Ut.UNRECOGNIZED]:"UNRECOGNIZED"},xs=e=>e?{userID:`${Ki[e]}_${tt(8)}`,name:Ki[e],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},sE=(e,t)=>e.startsWith(Ki[t]);class Lr extends Ke{constructor(){super(...arguments);p(this,"_model",new Map);p(this,"_userChange$",new ce.Subject);p(this,"userChange$",this._userChange$.asObservable());p(this,"_currentUser$",new ce.BehaviorSubject(xs()));p(this,"currentUser$",this._currentUser$.asObservable())}dispose(){super.dispose(),this._model.clear(),this._userChange$.complete(),this._currentUser$.complete()}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(n){this.addUser(n),this._currentUser$.next(n)}addUser(n){this._model.set(n.userID,n),this._userChange$.next({type:"add",user:n})}getUser(n,r){const s=this._model.get(n);if(s)return s;r&&r()}delete(n){const r=this.getUser(n);this._model.delete(n),r&&this._userChange$.next({type:"delete",user:r})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}list(){return Array.from(this._model.values())}}var iE=Object.getOwnPropertyDescriptor,oE=(e,t,n,r)=>{for(var s=r>1?void 0:r?iE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},nl=(e,t)=>(n,r)=>t(n,r,e);exports.AuthzIoLocalService=class{constructor(t,n){p(this,"_permissionMap",new Map([]));this._resourceManagerService=t,this._userManagerService=n,this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){const t=this._userManagerService.getCurrentUser();t&&t.userID||this._userManagerService.setCurrentUser(xs(Ut.Owner))}_getRole(t){const n=this._userManagerService.getCurrentUser();return n?sE(n.userID,t):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:t=>{const n=[...this._permissionMap.keys()].reduce((r,s)=>{const i=this._permissionMap.get(s);return r[s]=i,r},{});return JSON.stringify(n)},parseJson:t=>JSON.parse(t),pluginName:"SHEET_AuthzIoMockService_PLUGIN",businesses:[ve.UNIVER_SHEET,ve.UNIVER_DOC,ve.UNIVER_SLIDE],onLoad:(t,n)=>{for(const r in n)this._permissionMap.set(r,n[r])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(t){return tt(8)}async allowed(t){return Promise.resolve([])}async batchAllowed(t){return Promise.resolve([])}async list(t){const n=[];return t.objectIDs.forEach(r=>{const s=this._permissionMap.get(r);if(s){const i={objectID:r,unitID:t.unitID,objectType:s.objectType,name:s.name,shareOn:!1,shareRole:Ut.Owner,shareScope:-1,scope:{read:Hi.AllCollaborator,edit:Hi.AllCollaborator},creator:xs(Ut.Owner),strategies:[{action:6,role:1},{action:16,role:1},{action:17,role:1},{action:18,role:1},{action:19,role:1},{action:33,role:1},{action:34,role:1},{action:35,role:1},{action:36,role:1},{action:37,role:1},{action:38,role:1},{action:39,role:1},{action:40,role:1}],actions:t.actions.map(o=>({action:o,allowed:this._getRole(Ut.Owner)||this._getRole(Ut.Editor)}))};n.push(i)}}),n}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(t){}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(t){}};exports.AuthzIoLocalService=oE([nl(0,zs),nl(1,Ae.Inject(Lr))],exports.AuthzIoLocalService);const dh=Ae.createIdentifier("IAuthzIoIoService");var fh=typeof global=="object"&&global&&global.Object===Object&&global,aE=typeof self=="object"&&self&&self.Object===Object&&self,vn=fh||aE||Function("return this")(),zn=vn.Symbol,mh=Object.prototype,lE=mh.hasOwnProperty,cE=mh.toString,sr=zn?zn.toStringTag:void 0;function uE(e){var t=lE.call(e,sr),n=e[sr];try{e[sr]=void 0;var r=!0}catch{}var s=cE.call(e);return r&&(t?e[sr]=n:delete e[sr]),s}var hE=Object.prototype,dE=hE.toString;function fE(e){return dE.call(e)}var mE="[object Null]",gE="[object Undefined]",rl=zn?zn.toStringTag:void 0;function Vr(e){return e==null?e===void 0?gE:mE:rl&&rl in Object(e)?uE(e):fE(e)}function Jn(e){return e!=null&&typeof e=="object"}var _E="[object Symbol]";function Ks(e){return typeof e=="symbol"||Jn(e)&&Vr(e)==_E}function pE(e,t){for(var n=-1,r=e==null?0:e.length,s=Array(r);++n<r;)s[n]=t(e[n],n,e);return s}var Kn=Array.isArray,sl=zn?zn.prototype:void 0,il=sl?sl.toString:void 0;function gh(e){if(typeof e=="string")return e;if(Kn(e))return pE(e,gh)+"";if(Ks(e))return il?il.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}var EE=/\s/;function CE(e){for(var t=e.length;t--&&EE.test(e.charAt(t)););return t}var RE=/^\s+/;function IE(e){return e&&e.slice(0,CE(e)+1).replace(RE,"")}function Rt(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var ol=NaN,SE=/^[-+]0x[0-9a-f]+$/i,OE=/^0b[01]+$/i,vE=/^0o[0-7]+$/i,wE=parseInt;function al(e){if(typeof e=="number")return e;if(Ks(e))return ol;if(Rt(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Rt(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=IE(e);var n=OE.test(e);return n||vE.test(e)?wE(e.slice(2),n?2:8):SE.test(e)?ol:+e}function _h(e){return e}var bE="[object AsyncFunction]",AE="[object Function]",TE="[object GeneratorFunction]",yE="[object Proxy]";function Jo(e){if(!Rt(e))return!1;var t=Vr(e);return t==AE||t==TE||t==bE||t==yE}var Ci=vn["__core-js_shared__"],ll=function(){var e=/[^.]+$/.exec(Ci&&Ci.keys&&Ci.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function NE(e){return!!ll&&ll in e}var ME=Function.prototype,LE=ME.toString;function DE(e){if(e!=null){try{return LE.call(e)}catch{}try{return e+""}catch{}}return""}var xE=/[\\^$.*+?()[\]{}|]/g,UE=/^\[object .+?Constructor\]$/,PE=Function.prototype,kE=Object.prototype,FE=PE.toString,BE=kE.hasOwnProperty,$E=RegExp("^"+FE.call(BE).replace(xE,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function HE(e){if(!Rt(e)||NE(e))return!1;var t=Jo(e)?$E:UE;return t.test(DE(e))}function jE(e,t){return e==null?void 0:e[t]}function Qo(e,t){var n=jE(e,t);return HE(n)?n:void 0}var cl=Object.create,WE=function(){function e(){}return function(t){if(!Rt(t))return{};if(cl)return cl(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function YE(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function GE(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}var VE=800,zE=16,KE=Date.now;function XE(e){var t=0,n=0;return function(){var r=KE(),s=zE-(r-n);if(n=r,s>0){if(++t>=VE)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function qE(e){return function(){return e}}var Us=function(){try{var e=Qo(Object,"defineProperty");return e({},"",{}),e}catch{}}(),ZE=Us?function(e,t){return Us(e,"toString",{configurable:!0,enumerable:!1,value:qE(t),writable:!0})}:_h,JE=XE(ZE),QE=9007199254740991,e0=/^(?:0|[1-9]\d*)$/;function ea(e,t){var n=typeof e;return t=t==null?QE:t,!!t&&(n=="number"||n!="symbol"&&e0.test(e))&&e>-1&&e%1==0&&e<t}function ta(e,t,n){t=="__proto__"&&Us?Us(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function Xs(e,t){return e===t||e!==e&&t!==t}var t0=Object.prototype,n0=t0.hasOwnProperty;function ph(e,t,n){var r=e[t];(!(n0.call(e,t)&&Xs(r,n))||n===void 0&&!(t in e))&&ta(e,t,n)}function r0(e,t,n,r){var s=!n;n||(n={});for(var i=-1,o=t.length;++i<o;){var a=t[i],l=void 0;l===void 0&&(l=e[a]),s?ta(n,a,l):ph(n,a,l)}return n}var ul=Math.max;function s0(e,t,n){return t=ul(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,i=ul(r.length-t,0),o=Array(i);++s<i;)o[s]=r[t+s];s=-1;for(var a=Array(t+1);++s<t;)a[s]=r[s];return a[t]=n(o),YE(e,this,a)}}function i0(e,t){return JE(s0(e,t,_h),e+"")}var o0=9007199254740991;function Eh(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=o0}function na(e){return e!=null&&Eh(e.length)&&!Jo(e)}function a0(e,t,n){if(!Rt(n))return!1;var r=typeof t;return(r=="number"?na(n)&&ea(t,n.length):r=="string"&&t in n)?Xs(n[t],e):!1}function Ch(e){return i0(function(t,n){var r=-1,s=n.length,i=s>1?n[s-1]:void 0,o=s>2?n[2]:void 0;for(i=e.length>3&&typeof i=="function"?(s--,i):void 0,o&&a0(n[0],n[1],o)&&(i=s<3?void 0:i,s=1),t=Object(t);++r<s;){var a=n[r];a&&e(t,a,r,i)}return t})}var l0=Object.prototype;function Rh(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||l0;return e===n}function c0(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var u0="[object Arguments]";function hl(e){return Jn(e)&&Vr(e)==u0}var Ih=Object.prototype,h0=Ih.hasOwnProperty,d0=Ih.propertyIsEnumerable,Xi=hl(function(){return arguments}())?hl:function(e){return Jn(e)&&h0.call(e,"callee")&&!d0.call(e,"callee")};function f0(){return!1}var Sh=typeof exports=="object"&&exports&&!exports.nodeType&&exports,dl=Sh&&typeof module=="object"&&module&&!module.nodeType&&module,m0=dl&&dl.exports===Sh,fl=m0?vn.Buffer:void 0,g0=fl?fl.isBuffer:void 0,Oh=g0||f0,_0="[object Arguments]",p0="[object Array]",E0="[object Boolean]",C0="[object Date]",R0="[object Error]",I0="[object Function]",S0="[object Map]",O0="[object Number]",v0="[object Object]",w0="[object RegExp]",b0="[object Set]",A0="[object String]",T0="[object WeakMap]",y0="[object ArrayBuffer]",N0="[object DataView]",M0="[object Float32Array]",L0="[object Float64Array]",D0="[object Int8Array]",x0="[object Int16Array]",U0="[object Int32Array]",P0="[object Uint8Array]",k0="[object Uint8ClampedArray]",F0="[object Uint16Array]",B0="[object Uint32Array]",Fe={};Fe[M0]=Fe[L0]=Fe[D0]=Fe[x0]=Fe[U0]=Fe[P0]=Fe[k0]=Fe[F0]=Fe[B0]=!0;Fe[_0]=Fe[p0]=Fe[y0]=Fe[E0]=Fe[N0]=Fe[C0]=Fe[R0]=Fe[I0]=Fe[S0]=Fe[O0]=Fe[v0]=Fe[w0]=Fe[b0]=Fe[A0]=Fe[T0]=!1;function $0(e){return Jn(e)&&Eh(e.length)&&!!Fe[Vr(e)]}function H0(e){return function(t){return e(t)}}var vh=typeof exports=="object"&&exports&&!exports.nodeType&&exports,wr=vh&&typeof module=="object"&&module&&!module.nodeType&&module,j0=wr&&wr.exports===vh,Ri=j0&&fh.process,ml=function(){try{var e=wr&&wr.require&&wr.require("util").types;return e||Ri&&Ri.binding&&Ri.binding("util")}catch{}}(),gl=ml&&ml.isTypedArray,wh=gl?H0(gl):$0;function W0(e,t){var n=Kn(e),r=!n&&Xi(e),s=!n&&!r&&Oh(e),i=!n&&!r&&!s&&wh(e),o=n||r||s||i,a=o?c0(e.length,String):[],l=a.length;for(var c in e)o&&(c=="length"||s&&(c=="offset"||c=="parent")||i&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||ea(c,l))||a.push(c);return a}function Y0(e,t){return function(n){return e(t(n))}}function G0(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var V0=Object.prototype,z0=V0.hasOwnProperty;function K0(e){if(!Rt(e))return G0(e);var t=Rh(e),n=[];for(var r in e)r=="constructor"&&(t||!z0.call(e,r))||n.push(r);return n}function bh(e){return na(e)?W0(e):K0(e)}var X0=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,q0=/^\w*$/;function Z0(e,t){if(Kn(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Ks(e)?!0:q0.test(e)||!X0.test(e)||t!=null&&e in Object(t)}var Dr=Qo(Object,"create");function J0(){this.__data__=Dr?Dr(null):{},this.size=0}function Q0(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var eC="__lodash_hash_undefined__",tC=Object.prototype,nC=tC.hasOwnProperty;function rC(e){var t=this.__data__;if(Dr){var n=t[e];return n===eC?void 0:n}return nC.call(t,e)?t[e]:void 0}var sC=Object.prototype,iC=sC.hasOwnProperty;function oC(e){var t=this.__data__;return Dr?t[e]!==void 0:iC.call(t,e)}var aC="__lodash_hash_undefined__";function lC(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Dr&&t===void 0?aC:t,this}function Sn(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Sn.prototype.clear=J0;Sn.prototype.delete=Q0;Sn.prototype.get=rC;Sn.prototype.has=oC;Sn.prototype.set=lC;function cC(){this.__data__=[],this.size=0}function qs(e,t){for(var n=e.length;n--;)if(Xs(e[n][0],t))return n;return-1}var uC=Array.prototype,hC=uC.splice;function dC(e){var t=this.__data__,n=qs(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():hC.call(t,n,1),--this.size,!0}function fC(e){var t=this.__data__,n=qs(t,e);return n<0?void 0:t[n][1]}function mC(e){return qs(this.__data__,e)>-1}function gC(e,t){var n=this.__data__,r=qs(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function zt(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}zt.prototype.clear=cC;zt.prototype.delete=dC;zt.prototype.get=fC;zt.prototype.has=mC;zt.prototype.set=gC;var Ah=Qo(vn,"Map");function _C(){this.size=0,this.__data__={hash:new Sn,map:new(Ah||zt),string:new Sn}}function pC(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Zs(e,t){var n=e.__data__;return pC(t)?n[typeof t=="string"?"string":"hash"]:n.map}function EC(e){var t=Zs(this,e).delete(e);return this.size-=t?1:0,t}function CC(e){return Zs(this,e).get(e)}function RC(e){return Zs(this,e).has(e)}function IC(e,t){var n=Zs(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function ln(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}ln.prototype.clear=_C;ln.prototype.delete=EC;ln.prototype.get=CC;ln.prototype.has=RC;ln.prototype.set=IC;var SC="Expected a function";function ra(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(SC);var n=function(){var r=arguments,s=t?t.apply(this,r):r[0],i=n.cache;if(i.has(s))return i.get(s);var o=e.apply(this,r);return n.cache=i.set(s,o)||i,o};return n.cache=new(ra.Cache||ln),n}ra.Cache=ln;var OC=500;function vC(e){var t=ra(e,function(r){return n.size===OC&&n.clear(),r}),n=t.cache;return t}var wC=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,bC=/\\(\\)?/g,AC=vC(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(wC,function(n,r,s,i){t.push(s?i.replace(bC,"$1"):r||n)}),t});function TC(e){return e==null?"":gh(e)}function Th(e,t){return Kn(e)?e:Z0(e,t)?[e]:AC(TC(e))}function yh(e){if(typeof e=="string"||Ks(e))return e;var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function yC(e,t){t=Th(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[yh(t[n++])];return n&&n==r?e:void 0}function Nh(e,t,n){var r=e==null?void 0:yC(e,t);return r===void 0?n:r}var Mh=Y0(Object.getPrototypeOf,Object),NC="[object Object]",MC=Function.prototype,LC=Object.prototype,Lh=MC.toString,DC=LC.hasOwnProperty,xC=Lh.call(Object);function UC(e){if(!Jn(e)||Vr(e)!=NC)return!1;var t=Mh(e);if(t===null)return!0;var n=DC.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Lh.call(n)==xC}function PC(){this.__data__=new zt,this.size=0}function kC(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function FC(e){return this.__data__.get(e)}function BC(e){return this.__data__.has(e)}var $C=200;function HC(e,t){var n=this.__data__;if(n instanceof zt){var r=n.__data__;if(!Ah||r.length<$C-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new ln(r)}return n.set(e,t),this.size=n.size,this}function Qn(e){var t=this.__data__=new zt(e);this.size=t.size}Qn.prototype.clear=PC;Qn.prototype.delete=kC;Qn.prototype.get=FC;Qn.prototype.has=BC;Qn.prototype.set=HC;var Dh=typeof exports=="object"&&exports&&!exports.nodeType&&exports,_l=Dh&&typeof module=="object"&&module&&!module.nodeType&&module,jC=_l&&_l.exports===Dh,pl=jC?vn.Buffer:void 0;pl&&pl.allocUnsafe;function WC(e,t){return e.slice()}var El=vn.Uint8Array;function YC(e){var t=new e.constructor(e.byteLength);return new El(t).set(new El(e)),t}function GC(e,t){var n=YC(e.buffer);return new e.constructor(n,e.byteOffset,e.length)}function VC(e){return typeof e.constructor=="function"&&!Rh(e)?WE(Mh(e)):{}}function zC(e){return function(t,n,r){for(var s=-1,i=Object(t),o=r(t),a=o.length;a--;){var l=o[++s];if(n(i[l],l,i)===!1)break}return t}}var KC=zC(),Ii=function(){return vn.Date.now()},XC="Expected a function",qC=Math.max,ZC=Math.min;function JC(e,t,n){var r,s,i,o,a,l,c=0,u=!1,h=!1,d=!0;if(typeof e!="function")throw new TypeError(XC);t=al(t)||0,Rt(n)&&(u=!!n.leading,h="maxWait"in n,i=h?qC(al(n.maxWait)||0,t):i,d="trailing"in n?!!n.trailing:d);function f(C){var w=r,T=s;return r=s=void 0,c=C,o=e.apply(T,w),o}function g(C){return c=C,a=setTimeout(b,t),u?f(C):o}function _(C){var w=C-l,T=C-c,B=t-w;return h?ZC(B,i-T):B}function R(C){var w=C-l,T=C-c;return l===void 0||w>=t||w<0||h&&T>=i}function b(){var C=Ii();if(R(C))return F(C);a=setTimeout(b,_(C))}function F(C){return a=void 0,d&&r?f(C):(r=s=void 0,o)}function k(){a!==void 0&&clearTimeout(a),c=0,r=l=s=a=void 0}function W(){return a===void 0?o:F(Ii())}function S(){var C=Ii(),w=R(C);if(r=arguments,s=this,l=C,w){if(a===void 0)return g(l);if(h)return clearTimeout(a),a=setTimeout(b,t),f(l)}return a===void 0&&(a=setTimeout(b,t)),o}return S.cancel=k,S.flush=W,S}function qi(e,t,n){(n!==void 0&&!Xs(e[t],n)||n===void 0&&!(t in e))&&ta(e,t,n)}function QC(e){return Jn(e)&&na(e)}function Zi(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}function eR(e){return r0(e,bh(e))}function tR(e,t,n,r,s,i,o){var a=Zi(e,n),l=Zi(t,n),c=o.get(l);if(c){qi(e,n,c);return}var u=i?i(a,l,n+"",e,t,o):void 0,h=u===void 0;if(h){var d=Kn(l),f=!d&&Oh(l),g=!d&&!f&&wh(l);u=l,d||f||g?Kn(a)?u=a:QC(a)?u=GE(a):f?(h=!1,u=WC(l)):g?(h=!1,u=GC(l)):u=[]:UC(l)||Xi(l)?(u=a,Xi(a)?u=eR(a):(!Rt(a)||Jo(a))&&(u=VC(l))):h=!1}h&&(o.set(l,u),s(u,l,r,i,o),o.delete(l)),qi(e,n,u)}function sa(e,t,n,r,s){e!==t&&KC(t,function(i,o){if(s||(s=new Qn),Rt(i))tR(e,t,o,n,sa,r,s);else{var a=r?r(Zi(e,o),i,o+"",e,t,s):void 0;a===void 0&&(a=i),qi(e,o,a)}},bh)}var nR=Ch(function(e,t,n,r){sa(e,t,n,r)}),ia=Ch(function(e,t,n){sa(e,t,n)});function rR(e,t,n,r){if(!Rt(e))return e;t=Th(t,e);for(var s=-1,i=t.length,o=i-1,a=e;a!=null&&++s<i;){var l=yh(t[s]),c=n;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(s!=o){var u=a[l];c=void 0,c===void 0&&(c=Rt(u)?u:ea(t[s+1])?[]:{})}ph(a,l,c),a=a[l]}return e}function sR(e,t,n){return e==null?e:rR(e,t,n)}const oa=Ae.createIdentifier("univer.config-service");class xh{constructor(){p(this,"_configChanged$",new ce.Subject);p(this,"configChanged$",this._configChanged$.asObservable());p(this,"_config",new Map)}dispose(){this._config.clear(),this._configChanged$.complete()}getConfig(t){return this._config.get(t)}setConfig(t,n,r){var o;const{merge:s=!1}=r||{};let i=(o=this._config.get(t))!=null?o:{};s?i=ia(i,n):i=n,this._config.set(t,i),this._configChanged$.next({[t]:i})}deleteConfig(t){return this._config.delete(t)}subscribeConfigValue$(t){return new ce.Observable(n=>{Object.prototype.hasOwnProperty.call(this._config,t)&&n.next(this._config.get(t));const r=this.configChanged$.pipe(ce.filter(s=>Object.prototype.hasOwnProperty.call(s,t))).subscribe(s=>n.next(s[t]));return()=>r.unsubscribe()})}}const Cr="FOCUSING_UNIT",Hn="FOCUSING_SHEET",Rr="FOCUSING_DOC",Ir="FOCUSING_SLIDE",iR="FOCUSING_EDITOR_BUT_HIDDEN",Uh="EDITOR_ACTIVATED",oR="FOCUSING_EDITOR_INPUT_FORMULA",Ph="FOCUSING_FX_BAR_EDITOR",aR="FOCUSING_UNIVER_EDITOR",lR="FOCUSING_EDITOR_INPUT_FORMULA",cR="FOCUSING_PANEL_EDITOR",uR="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",hR="FOCUSING_COMMON_DRAWINGS",dR="FORMULA_EDITOR_ACTIVATED";class kh extends Ke{constructor(){super(...arguments);p(this,"_error$",new ce.Subject);p(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(n){this._error$.next({errorKey:n})}}var aa=(e=>(e.URL="URL",e.UUID="UUID",e.BASE64="BASE64",e))(aa||{}),Fh=(e=>(e.SUCCUSS="0",e.ERROR_EXCEED_SIZE="1",e.ERROR_IMAGE_TYPE="2",e.ERROR_UPLOAD_COUNT_LIMIT="3",e.ERROR_IMAGE="4",e))(Fh||{});const Ji=Ae.createIdentifier("core.image-io.service"),fR="0.9.3",mR={version:fR};function gR(e="",t=Br.ZH_CN,n=""){return{id:e,sheetOrder:[],name:n,appVersion:mR.version,locale:t,styles:{},sheets:{},resources:[]}}class Bh{constructor(t={}){p(this,"_styles");p(this,"_cacheMap",new Tr(1e5));this._styles=t,this._generateCacheMap()}each(t){return Object.entries(this._styles).forEach(t),this}search(t,n){if(this._cacheMap.has(n))return this._cacheMap.get(n);const r=this._getExistingStyleId(t);return r||"-1"}get(t){return typeof t!="string"?t:(t=String(t),this._styles[t])}add(t,n){const r=tt(6);return this._styles[r]=t,this._cacheMap.set(n,r),r}setValue(t){if(t==null)return;const n=JSON.stringify(t),r=this.search(t,n);return r!=="-1"?r:this.add(t,n)}toJSON(){return this._styles}getStyleByCell(t){let n;t&&q.isObject(t.s)?n=t.s:n=(t==null?void 0:t.s)&&this.get(t.s);const r=t==null?void 0:t.interceptorStyle;return r?{...n,...r}:n}_generateCacheMap(){const{_styles:t,_cacheMap:n}=this;for(const r in t){const s=JSON.stringify(t[r]);n.set(s,r)}}_getExistingStyleId(t){const{_styles:n}=this;for(const r in n)if(q.diffValue(n[r],t))return r;return null}}const _R=(e,t)=>t.length===e.length&&!e.some(n=>t.some(r=>!on.equals(r,n))),pR=(e,t)=>t.length===e.length&&e.every((n,r)=>{const s=t[r];return s.unitId===n.unitId&&s.sheetId===n.sheetId&&on.equals(n.range,s.range)}),Qi={t:0,b:2,l:2,r:2},ER=e=>({sbr:.6,sbo:e,spr:.6,spo:e}),Cl=90;function Sr(e,t,n={}){const r=e.length,{textRotation:s,paddingData:i,horizontalAlign:o=Tt.UNSPECIFIED,verticalAlign:a=_n.UNSPECIFIED,wrapStrategy:l=Rn.UNSPECIFIED,cellValueType:c}=n,{t:u,r:h,b:d,l:f}=i||Qi,{vertexAngle:g,centerAngle:_}=jh(s),R={id:"d",body:{dataStream:`${e}${Nl}`,textRuns:[{ts:t,st:0,ed:r}],paragraphs:[{startIndex:r,paragraphStyle:{horizontalAlign:o}}],sectionBreaks:[{startIndex:r+1}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},marginTop:u,marginBottom:d,marginRight:h,marginLeft:f,renderConfig:{horizontalAlign:o,verticalAlign:a,centerAngle:_,vertexAngle:g,wrapStrategy:l,cellValueType:c,zeroWidthParagraphBreak:1}},drawings:{},drawingsOrder:[]};return new Nt(R)}function CR(e){if(!e)return{};const{tr:t,td:n,ht:r,vt:s,tb:i,pd:o}=e;return{textRotation:t,textDirection:n,horizontalAlign:r,verticalAlign:s,wrapStrategy:i,paddingData:o}}function Rl(e){if(!e)return{};const{ff:t,fs:n,it:r,bl:s,ul:i,st:o,ol:a,cl:l}=e,c={};return t&&(c.ff=t),n&&(c.fs=n),r&&(c.it=r),s&&(c.bl=s),i&&(c.ul=i),o&&(c.st=o),a&&(c.ol=a),l&&(c.cl=l),c}function $h(e,t,n){var i;const r=e.getBody();if((i=r.customRanges)!=null&&i.some(o=>o.rangeType===sn.HYPERLINK))return;const s=Qe.customRange.add({ranges:[{startOffset:0,endOffset:r.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:sn.HYPERLINK,body:r,properties:{url:t,refId:n}});s&&Me.apply(r,s.serialize())}function Hh(e){return e!=null}const RR='"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif';function Il(e){const t=st.ff,n=st.fs;if(!e){const h=`${n}pt ${t}`;return{fontCache:h,fontString:h,fontSize:n,originFontSize:n,fontFamily:t}}let r=$n.ITALIC;(e.it===0||e.it===void 0)&&(r=$n.NORMAL);let s=$n.BOLD;(e.bl===0||e.bl===void 0)&&(s=$n.NORMAL);let i=n;e.fs&&(i=Math.ceil(e.fs));let o=t;if(e.ff){let h=e.ff;h=h.replace(/"/g,"").replace(/'/g,""),h.indexOf(" ")>-1&&(h=`"${h}"`),h==null&&(h=t),o=h}const{va:a}=e;let l=i;if(a===Yt.SUBSCRIPT||a===Yt.SUPERSCRIPT){const h=IR(o,l),{sbr:d,spr:f}=h;l*=a===Yt.SUBSCRIPT?d:f}const c=`${r} ${s} ${l}pt ${o}`,u=`${c}, ${RR} `;return{fontCache:c,fontString:u,fontSize:l,originFontSize:i,fontFamily:o}}function IR(e,t){return ER(t)}function jh(e){const{a:t=0,v:n=ie.FALSE}=e||{a:0,v:ie.FALSE};let r=0,s=t;return n===ie.TRUE&&(r=Cl,s=Cl),{centerAngle:r,vertexAngle:s}}class SR{constructor(t,n){p(this,"_columnData",{});this._config=t,this._columnData=n}getColumnData(){return this._columnData}getColVisible(t){const{_columnData:n}=this,r=n[t];return r?r.hd!==ie.TRUE:!0}getColumnStyle(t){var n;return(n=this._columnData[t])==null?void 0:n.s}setColumnStyle(t,n){const r=this.getColumnOrCreate(t);r.s=n}getHiddenCols(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getColVisible(o);s&&a?(s=!1,r.push({rangeType:_e.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:_e.COLUMN}),r}getVisibleCols(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getColVisible(o);s&&!a?(s=!1,r.push({rangeType:_e.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:_e.COLUMN}),r}getColumnDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getColumn(i);r[s]=o!=null?o:{w:this._config.defaultColumnWidth,hd:ie.FALSE},s++}return r}getSize(){return tn(this._columnData)}getColumnWidth(t){var n,r;return(r=(n=this._columnData[t])==null?void 0:n.w)!=null?r:this._config.defaultColumnWidth}setColumnWidth(t,n){const r=this._columnData[t];n===this._config.defaultColumnWidth?r&&(delete r.w,Object.keys(r).length===0&&delete this._columnData[t]):this._columnData[t]=r?{...r,w:n}:{w:n}}getColumn(t){return this._columnData[t]}removeColumn(t){delete this._columnData[t]}getColumnOrCreate(t){const{_columnData:n}=this,r=n[t];if(r)return r;const s={};return this._columnData[t]=s,s}setCustomMetadata(t,n){const r=this.getColumn(t);r&&(r.custom=n)}getCustomMetadata(t){var n;return(n=this.getColumn(t))==null?void 0:n.custom}}const OR=2e3;class vR{constructor(t,n,r){p(this,"_rowData");this._config=t,this._viewModel=n,this._rowData=r}getRowData(){return this._rowData}getRowStyle(t){var n;return(n=this._rowData[t])==null?void 0:n.s}setRowStyle(t,n){const r=this.getRowOrCreate(t);r.s=n}getRowDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getRow(i);r[s]=o!=null?o:{h:this._config.defaultRowHeight,hd:ie.FALSE},s++}return r}getRowHeight(t,n=1){const{_rowData:r}=this,s=this._config;let i=0;for(let o=0;o<n;o++){const a=r[o+t]||{hd:ie.FALSE,h:s.defaultRowHeight},{ia:l,ah:c,h:u=s.defaultRowHeight}=a;i+=(l==null||l===ie.TRUE)&&typeof c=="number"?c:u}return i}setRowHeight(t,n){const r=this._rowData[t];if(n===this._config.defaultRowHeight)r&&(delete r.h,Object.keys(r).length===0&&delete this._rowData[t]);else{const s=Math.min(n,OR);this._rowData[t]=r?{...r,h:s}:{h:s}}}getRow(t){return this._rowData[t]}removeRow(t){delete this._rowData[t]}getRowOrCreate(t){const{_rowData:n}=this,r=n[t];if(r)return r;const s={};return n[t]=s,s}getHiddenRows(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getRowRawVisible(o);s&&a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:_e.ROW})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:_e.ROW}),r}getVisibleRows(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getRowRawVisible(o);s&&!a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:_e.ROW})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:_e.ROW}),r}getRowRawVisible(t){const n=this.getRow(t);return n?n.hd!==ie.TRUE:!0}getSize(){return tn(this._rowData)}setCustomMetadata(t,n){const r=this.getRow(t);r&&(r.custom=n)}getCustomMetadata(t){var n;return(n=this.getRow(t))==null?void 0:n.custom}}const wR="DEFAULT_WORKSHEET_ROW_COUNT",Wh=1e3,bR="DEFAULT_WORKSHEET_COLUMN_COUNT",Yh=20,AR="DEFAULT_WORKSHEET_ROW_HEIGHT",Gh=24,TR="DEFAULT_WORKSHEET_COLUMN_WIDTH",Vh=88,yR="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",zh=46,NR="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Kh=20;function Xh(e){const t={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:ie.FALSE,rowCount:Wh,columnCount:Yh,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:Vh,defaultRowHeight:Gh,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:ie.TRUE,rowHeader:{width:zh,hidden:ie.FALSE},columnHeader:{height:Kh,hidden:ie.FALSE},rightToLeft:ie.FALSE};return Object.keys(t).forEach(n=>{const r=n;typeof e[r]>"u"&&(e[r]=t[r])}),e}class MR extends Ke{constructor(n){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");p(this,"_rangeMap",new Tr(5e4));p(this,"_skeletonCache",new Tr(5e4));this._init(n.concat())}_init(n){this._mergeData=n,this._createCache(n)}_clearCache(){this._cellCache.clear(),this._rowCache.clear(),this._columnCache.clear(),this._hasAll=!1,this._allIndex=-1,this._rangeMap.clear(),this._skeletonCache.clear(),this._hasColumn=!1,this._hasRow=!1}_createCache(n){let r=0;for(const s of n){const{rangeType:i}=s;i===_e.ROW?this._createRowCache(s,r):i===_e.COLUMN?this._createColumnCache(s,r):i===_e.ALL?this._createCellAllCache(r):this._createCellCache(s,r),r++}}rebuild(n){this._clearCache(),this._init(n.concat())}_createRowCache(n,r){const{startRow:s,endRow:i}=n;for(let o=s;o<=i;o++)this._rowCache.set(o,r),this._hasRow=!0}_createColumnCache(n,r){const{startColumn:s,endColumn:i}=n;for(let o=s;o<=i;o++)this._columnCache.set(o,r),this._hasColumn=!0}_createCellAllCache(n){this._hasAll=!0,this._allIndex=n}_createCellCache(n,r){for(let s=n.startRow;s<=n.endRow;s++){let i=this._cellCache.get(s);i==null&&(i=new Map,this._cellCache.set(s,i));for(let o=n.startColumn;o<=n.endColumn;o++)i.set(o,r)}}add(n){this._mergeData.push(n),this._clearCache(),this._createCache(this._mergeData)}remove(n,r){const s=this._getMergeDataIndex(n,r);s!==-1&&(this._mergeData.splice(s,1),this._clearCache(),this._createCache(this._mergeData))}getMergedCell(n,r){const s=this._getMergeDataIndex(n,r);return s!==-1?this._mergeData[s]:null}getMergeDataIndex(n,r){return this._getMergeDataIndex(n,r)}isRowContainsMergedCell(n){return this._hasAll||!q.isEmptyObject(this._columnCache)?!0:this._mergeData.some(r=>r.startRow<=n&&n<=r.endRow)}isColumnContainsMergedCell(n){return this._hasAll||!q.isEmptyObject(this._rowCache)?!0:this._mergeData.some(r=>r.startColumn<=n&&n<=r.endColumn)}getMergedCellRange(n,r,s,i){const o=[],a=`${n}-${r}-${s}-${i}`;if(this._rangeMap.has(a))return this._getRangeFromCache(a);let l=0;const c=[];for(const u of this._mergeData||[])on.intersects(u,{startRow:n,endRow:s,startColumn:r,endColumn:i})&&(o.push({...u}),c.push(l)),l++;return this._rangeMap.set(a,c),o}getMergedCellRangeForSkeleton(n,r,s,i){const o=[],a=this._mergeData,l=`${n}-${r}-${s}-${i}`;if(this._skeletonCache.has(l))return this._getSkeletonRangeFromCache(l);const c=[];for(let u=0;u<a.length;u++){const{startRow:h,endRow:d,startColumn:f,endColumn:g}=a[u];for(let _=n;_<=s;_++){let R=!1;for(let b=r;b<=i;b++)if(_>=h&&_<=d&&b>=f&&b<=g){o.push({startRow:h,endRow:d,startColumn:f,endColumn:g}),c.push(u),R=!0;break}if(R)break}}return this._skeletonCache.set(l,c),o}_getRangeFromCache(n){const r=this._rangeMap.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getSkeletonRangeFromCache(n){const r=this._skeletonCache.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getMergeDataIndex(n,r){var i;if(this._hasAll)return this._allIndex;if(this._hasRow){const o=this._rowCache.get(n);if(o!==void 0)return o}if(this._hasColumn){const o=this._columnCache.get(r);if(o!==void 0)return o}const s=(i=this._cellCache.get(n))==null?void 0:i.get(r);return s!==void 0?s:-1}getMergeDataSnapshot(){return this._mergeData}dispose(){this._clearCache(),this._mergeData=[]}}class qh extends Ke{constructor(n){super();p(this,"_cellContentInterceptor",null);p(this,"_rowFilteredInterceptor",null);this.getRawCell=n}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(n,r,s,i){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,Pn.Value|Pn.Style,s,i):this.getRawCell(n,r)}getCellValueOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,Pn.Value):this.getRawCell(n,r)}getCellStyleOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,Pn.Style):this.getRawCell(n,r)}getRowFiltered(n){var r,s;return(s=(r=this._rowFilteredInterceptor)==null?void 0:r.getRowFiltered(n))!=null?s:!1}registerCellContentInterceptor(n){if(this._cellContentInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptor=n,We(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(n){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=n,We(()=>this._rowFilteredInterceptor=null)}}const Sl={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};class xr{constructor(t,n,r){p(this,"_sheetId");p(this,"_snapshot");p(this,"_cellData");p(this,"_rowManager");p(this,"_columnManager");p(this,"_viewModel");p(this,"_spanModel");p(this,"_isRowStylePrecedeColumnStyle",!0);p(this,"_getCellHeight");var a;this.unitId=t,this._styles=r,this._snapshot=Xh(n);const{columnData:s,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:tt(6),this._cellData=new dt(o),this._viewModel=new qh((l,c)=>this.getCellRaw(l,c)),this._rowManager=new vR(this._snapshot,this._viewModel,i),this._columnManager=new SR(this._snapshot,s),this._spanModel=new MR(this._snapshot.mergeData)}__interceptViewModel(t){t(this._viewModel)}__registerGetCellHeight(t){return this._getCellHeight=t,We(()=>{this._getCellHeight=null})}getSnapshot(){return this._snapshot}getCellHeight(t,n){return this._getCellHeight?this._getCellHeight(t,n):this._snapshot.defaultRowHeight}setMergeData(t){this._snapshot.mergeData=t,this.getSpanModel().rebuild(t)}getSpanModel(){return this._spanModel}setIsRowStylePrecedeColumnStyle(t){this._isRowStylePrecedeColumnStyle=t}getStyleDataByHash(t){return{...this._styles.get(t)}}setStyleData(t){return this._styles.setValue(t)}getColumnStyle(t,n=!1){return n?this._columnManager.getColumnStyle(t):this._styles.get(this._columnManager.getColumnStyle(t))}setColumnStyle(t,n){this._columnManager.setColumnStyle(t,n)}getRowStyle(t,n=!1){return n?this._rowManager.getRowStyle(t):this._styles.get(this._rowManager.getRowStyle(t))}setRowStyle(t,n){this._rowManager.setRowStyle(t,n)}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){const t=this._snapshot.defaultStyle;return this._styles.get(t)}setDefaultCellStyle(t){this._snapshot.defaultStyle=t}getCellStyle(t,n){const r=this.getCell(t,n);if(r){const s=r.s;return typeof s=="string"?this._styles.get(s):s}return null}getComposedCellStyle(t,n,r){const s=this.getDefaultCellStyleInternal(),i=this.getRowStyle(t),o=this.getColumnStyle(n),a=this.getCell(t,n),l=this._styles.getStyleByCell(a);return(r!=null?r:this._isRowStylePrecedeColumnStyle)?cr(s,o,i,a==null?void 0:a.themeStyle,l):cr(s,i,o,a==null?void 0:a.themeStyle,l)}getComposedCellStyleByCellData(t,n,r,s){const i=this.getDefaultCellStyleInternal(),o=this.getRowStyle(t),a=this.getColumnStyle(n),l=this._styles.getStyleByCell(r);return(s!=null?s:this._isRowStylePrecedeColumnStyle)?cr(i,a,o,r==null?void 0:r.themeStyle,l):cr(i,o,a,r==null?void 0:r.themeStyle,l)}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const t=this.getCellMatrix(),n=this.getMergeData();let r=-1,s=-1,i=-1,o=-1,a=!1,l=!1;return t.forEach((c,u)=>{Object.keys(u).forEach(h=>{const d=+h,f=t.getValue(c,d),g=f!=null&&f.s?this._styles.get(f.s):null,_=(g==null?void 0:g.bd)&&(g.bd.b||g.bd.l||g.bd.r||g.bd.t||g.bd.bc_tr||g.bd.bl_tr||g.bd.ml_tr||g.bd.tl_bc||g.bd.tl_br||g.bd.tl_mr);(f&&(f.v||f.p)||g!=null&&g.bg||_)&&(a?r=Math.min(r,c):(r=c,a=!0),s=Math.max(s,c),l?i=Math.min(i,d):(l=!0,i=d),o=Math.max(o,d))})}),n.forEach(c=>{a?r=Math.min(r,c.startRow):(r=c.startRow,a=!0),s=Math.max(s,c.endRow),l?i=Math.min(i,c.startColumn):(i=c.startColumn,a=!0),o=Math.max(o,c.endColumn)}),!a||!l?null:{startColumn:i,startRow:r,endColumn:o,endRow:s}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:t}=this,n=q.deepClone(t);return new xr(this.unitId,n,this._styles)}getMergeData(){return this._spanModel.getMergeDataSnapshot()}getMergedCell(t,n){return this._spanModel.getMergedCell(t,n)}getMergedCellRange(t,n,r,s){return this._spanModel.getMergedCellRange(t,n,r,s)}isRowContainsMergedCell(t){return this._spanModel.isRowContainsMergedCell(t)}isColumnContainsMergedCell(t){return this._spanModel.isColumnContainsMergedCell(t)}getCellInfoInMergeData(t,n){const r=this.getMergedCell(t,n);let s=!1,i=!1,o=t,a=n,l=t,c=n;if(r){const{startRow:u,endRow:h,startColumn:d,endColumn:f}=r;t===u&&n===d?(o=h,a=f,l=u,c=d,i=!0):t>=u&&t<=h&&n>=d&&n<=f&&(o=h,a=f,l=u,c=d,s=!0)}return{actualRow:t,actualColumn:n,isMergedMainCell:i,isMerged:s,endRow:o,endColumn:a,startRow:l,startColumn:c}}getCell(t,n){return t<0||n<0?null:this._viewModel.getCell(t,n)}getCellValueOnly(t,n){return t<0||n<0?null:this._viewModel.getCellValueOnly(t,n)}getCellStyleOnly(t,n){return t<0||n<0?null:this._viewModel.getCellStyleOnly(t,n)}getCellRaw(t,n){return this.getCellMatrix().getValue(t,n)}getCellWithFilteredInterceptors(t,n,r,s){return this._viewModel.getCell(t,n,r,s)}getRowFiltered(t){return this._viewModel.getRowFiltered(t)}getRangeFilterRows(t){const n=[];for(let r=t.startRow;r<=t.endRow;r++)this.getRowFiltered(r)&&n.push(r);return n}getMatrixWithMergedCells(t,n,r,s,i=kn.Raw){const o=this.getCellMatrix(),a=this._spanModel.getMergedCellRange(t,n,r,s),l=new dt;return $i(t,r,n,s).forEach((c,u)=>{var d;let h;if(i===kn.Raw)h=this.getCellRaw(c,u);else if(i===kn.Intercepted)h=this.getCell(c,u);else if(i===kn.Both){const f=this.getCellRaw(c,u);if(f){h={...f};const g=(d=this.getCell(c,u))==null?void 0:d.v;Hh(g)&&h&&(h.displayV=String(g))}}h&&l.setValue(c,u,h)}),a.forEach(c=>{const{startColumn:u,startRow:h,endColumn:d,endRow:f}=c;$i(h,f,u,d).forEach((g,_)=>{g===h&&_===u&&l.setValue(g,_,{...o.getValue(g,_),rowSpan:f-h+1,colSpan:d-u+1}),(g!==h||_!==u)&&l.realDeleteValue(g,_)})}),l}getRange(t,n,r,s){return typeof t=="object"?new Vn(this,t,{getStyles:()=>this._styles}):new Vn(this,{startRow:t,startColumn:n,endColumn:s||n,endRow:r||t},{getStyles:()=>this._styles})}getScrollLeftTopFromSnapshot(){return{scrollLeft:this._snapshot.scrollLeft,scrollTop:this._snapshot.scrollTop}}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){const{_snapshot:t}=this,{columnCount:n}=t;return n}getMaxRows(){const{_snapshot:t}=this,{rowCount:n}=t;return n}getRowCount(){return this._snapshot.rowCount}setRowCount(t){this._snapshot.rowCount=t}getColumnCount(){return this._snapshot.columnCount}setColumnCount(t){this._snapshot.columnCount=t}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:t}=this,{showGridlines:n}=t;return n===0}getGridlinesColor(){return this.getConfig().gridlinesColor}getTabColor(){const{_snapshot:t}=this,{tabColor:n}=t;return n}getColumnWidth(t){return this.getColumnManager().getColumnWidth(t)}getRowHeight(t){return this._viewModel.getRowFiltered(t)?0:this.getRowManager().getRowHeight(t)}isRowFiltered(t){return this._viewModel.getRowFiltered(t)}getRowVisible(t){return!this.isRowFiltered(t)&&this.getRowRawVisible(t)}getRowRawVisible(t){return this.getRowManager().getRowRawVisible(t)}getHiddenRows(t,n){const r=this.getMaxColumns()-1,s=this._rowManager.getHiddenRows(t,n);return s.forEach(i=>i.endColumn=r),s}getColVisible(t){return this._columnManager.getColVisible(t)}getHiddenCols(t,n){const r=this.getMaxRows()-1,s=this._columnManager.getHiddenCols(t,n);return s.forEach(i=>i.endRow=r),s}getVisibleRows(){const t=this.getRowCount();return this._rowManager.getVisibleRows(0,t-1)}getVisibleCols(){const t=this.getColumnCount();return this._columnManager.getVisibleCols(0,t-1)}isRightToLeft(){const{_snapshot:t}=this,{rightToLeft:n}=t;return n}getLastRowWithContent(){return this._cellData.getLength()-1}getLastColumnWithContent(){return this._cellData.getRange().endColumn}getDataRangeScope(){return this._cellData.getStartEndScope()}cellHasValue(t){return t&&(t.v!==void 0||t.f!==void 0||t.p!==void 0)}iterateByRow(t,n=!0){const{startRow:r,startColumn:s,endRow:i,endColumn:o}=t,a=this;return{[Symbol.iterator]:()=>{let l=r,c=s;return{next(){for(;;){if(c>o&&(l+=1,c=s),l>i)return{done:!0,value:void 0};const u=a.getCell(l,c),h=!u,d=a.getMergedCell(l,c);if(d){if(l!==d.startRow||c!==d.startColumn){c=d.endColumn+1;continue}if(h&&n){c=d.endColumn+1;continue}const g={row:l,col:c,value:u};return g.colSpan=d.endColumn-d.startColumn+1,g.rowSpan=d.endRow-d.startRow+1,c=d.endColumn+1,{done:!1,value:g}}if(h&&n)c+=1;else{const f={row:l,col:c,value:u};return c+=1,{done:!1,value:f}}}}}}}}iterateByColumn(t,n=!0,r=!0){const{startRow:s,startColumn:i,endRow:o,endColumn:a}=t,l=this;return{[Symbol.iterator]:()=>{let c=s,u=i;return{next(){for(;;){if(c>o&&(u+=1,c=s),u>a)return{done:!0,value:void 0};const h=l.getMergedCell(c,u);if(h){const g=c!==h.startRow,_=g||u!==h.startColumn;if(r&&_||!r&&g){c=h.endRow+1;continue}const R=l.getCell(h.startRow,h.startColumn);if(!R&&n){c=h.endRow+1;continue}const F={row:c,col:h.startColumn,value:R};return F.colSpan=h.endColumn-h.startColumn+1,F.rowSpan=h.endRow-h.startRow+1,c=h.endRow+1,{done:!1,value:F}}const d=l.getCell(c,u);if(!d&&n)c+=1;else{const g={row:c,col:u,value:d};return c+=1,{done:!1,value:g}}}}}}}}getCellDocumentModel(t,n,r=Sl){var _;if(!t)return;const{isDeepClone:s,displayRawFormula:i,ignoreTextRotation:o}={...Sl,...r};let a,l="document";const c=CR(n),u=o?st.tr:c.textRotation||st.tr;let h=c.horizontalAlign||st.ht;const d=c.verticalAlign||st.vt,f=c.wrapStrategy||st.tb,g=c.paddingData||Qi;if(t.f&&i)a=Sr(t.f.toString(),{},{verticalAlign:d}),h=st.ht;else if(t.p){const{centerAngle:R,vertexAngle:b}=jh(u);a=this._updateConfigAndGetDocumentModel(s?q.deepClone(t.p):t.p,h,g,{horizontalAlign:h,verticalAlign:d,centerAngle:R,vertexAngle:b,wrapStrategy:f,zeroWidthParagraphBreak:1})}else if(t.v!=null){const R=Rl(n);l=Il(R).fontCache;let b=Zh(t);t.t===en.FORCE_STRING&&i&&(b=`'${b}`),a=Sr(b,R,{...c,textRotation:u,cellValueType:t.t})}return a&&t.linkUrl&&t.linkId&&$h(a,t.linkUrl,t.linkId),{documentModel:a,fontString:l,textRotation:u,wrapStrategy:f,verticalAlign:d,horizontalAlign:h,paddingData:g,fill:(_=n==null?void 0:n.bg)==null?void 0:_.rgb}}_updateConfigAndGetDocumentModel(t,n,r,s){var o,a,l,c,u;if(!s||!((o=t.body)!=null&&o.dataStream))return;t.documentStyle||(t.documentStyle={}),t.documentStyle.marginTop=(a=r.t)!=null?a:0,t.documentStyle.marginBottom=(l=r.b)!=null?l:2,t.documentStyle.marginLeft=(c=r.l)!=null?c:2,t.documentStyle.marginRight=(u=r.r)!=null?u:2,t.documentStyle.pageSize={width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},t.documentStyle.renderConfig={...t.documentStyle.renderConfig,...s};const i=t.body.paragraphs||[];for(const h of i)h.paragraphStyle||(h.paragraphStyle={}),h.paragraphStyle.horizontalAlign=n;return new Nt(t)}getBlankCellDocumentModel(t,n,r){const s=this.getComposedCellStyleByCellData(n,r,t),i=Rl(s),o=this.getCellDocumentModel(t,s,{ignoreTextRotation:!0});if(o!=null)return o.documentModel==null&&(o.documentModel=Sr("",i)),o;const a="";let l="document";const c=st.tr,u=st.ht,h=st.vt,d=st.tb,f=Qi;return l=Il({}).fontCache,{documentModel:Sr(a,i),fontString:l,textRotation:c,wrapStrategy:d,verticalAlign:h,horizontalAlign:u,paddingData:f}}getCellDocumentModelWithFormula(t,n,r){const s=this.getComposedCellStyleByCellData(n,r,t);return this.getCellDocumentModel(t,s,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(t){this._snapshot.custom=t}}function Zh(e){var r,s;if(!e)return"";const t=(s=(r=e.p)==null?void 0:r.body)==null?void 0:s.dataStream;if(t)return Qe.transform.getPlainText(t);const n=e.v;return typeof n=="string"?e.t===en.BOOLEAN?n.toUpperCase():n.replace(/[\r\n]/g,""):typeof n=="number"?e.t===en.BOOLEAN?n?"TRUE":"FALSE":n.toString():typeof n=="boolean"?n?"TRUE":"FALSE":""}function LR(e){if(e===null)return"";if(e!=null&&e.p){const t=e==null?void 0:e.p.body;if(t==null)return"";const n=t.dataStream;return Qe.transform.getPlainText(n)}return e==null?void 0:e.v}var DR=Object.getOwnPropertyDescriptor,xR=(e,t,n,r)=>{for(var s=r>1?void 0:r?DR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},UR=(e,t)=>(n,r)=>t(n,r,e);function PR(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}exports.Workbook=class extends Gs{constructor(n={},r){super();p(this,"type",ve.UNIVER_SHEET);p(this,"_sheetCreated$",new ce.Subject);p(this,"sheetCreated$",this._sheetCreated$.asObservable());p(this,"_sheetDisposed$",new ce.Subject);p(this,"sheetDisposed$",this._sheetDisposed$.asObservable());p(this,"_activeSheet$",new ce.BehaviorSubject(null));p(this,"activeSheet$",this._activeSheet$.asObservable());p(this,"_worksheets");p(this,"_styles");p(this,"_snapshot");p(this,"_unitId");p(this,"_count");p(this,"_name$");p(this,"name$");this._logService=r;const s=gR();q.isEmptyObject(n)?this._snapshot=s:this._snapshot=q.commonExtend(s,n);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=tt(6)),this._unitId=this._snapshot.id,this._styles=new Bh(i),this._count=1,this._worksheets=new Map,this._name$=new ce.BehaviorSubject(n.name||""),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}static isIRangeType(n){return typeof n=="string"||"startRow"in n||"row"in n}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete()}save(){return q.deepClone(this._snapshot)}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(n){this._name$.next(n),this._snapshot.name=n}getUnitId(){return this._unitId}getRev(){var n;return(n=this._snapshot.rev)!=null?n:1}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(n){this._snapshot.rev=n}addWorksheet(n,r,s){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[n])return!1;i[n]=s,o.splice(r,0,n);const a=new xr(this._unitId,s,this._styles);return this._worksheets.set(n,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}getConfig(){return this._snapshot}getIndexBySheetId(n){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>s===n)}getActiveSheet(n){if(!this._activeSheet&&typeof n>"u")throw new Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){const n=this._activeSheet;if(n)return n;const r=this._snapshot.sheetOrder;for(let i=0,o=r.length;i<o;i++){const a=this._worksheets.get(r[i]);if(a&&a.isSheetHidden()!==ie.TRUE)return this.setActiveSheet(a),a}const s=this._worksheets.get(r[0]);return this.setActiveSheet(s),s}setActiveSheet(n){this._activeSheet$.next(n)}removeSheet(n){const r=this._worksheets.get(n);return r?(this._worksheets.delete(n),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(n),1),delete this._snapshot.sheets[n],this._sheetDisposed$.next(r),!0):!1}getActiveSheetIndex(){const{sheetOrder:n}=this._snapshot;return n.findIndex(r=>this._worksheets.get(r)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:n}=this._snapshot;return n.map(r=>this._worksheets.get(r))}getSheetsName(){const{sheetOrder:n}=this._snapshot,r=[];return n.forEach(s=>{const i=this._worksheets.get(s);i&&r.push(i.getName())}),r}getSheetIndex(n){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>n.getSheetId()===s)}getSheetBySheetName(n){const{sheetOrder:r}=this._snapshot,s=r.find(i=>this._worksheets.get(i).getName()===n);return this._worksheets.get(s)}getSheetBySheetId(n){return this._worksheets.get(n)}getSheetByIndex(n){const{sheetOrder:r}=this._snapshot;return this._worksheets.get(r[n])}getHiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden===ie.TRUE).map(n=>n.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden!==ie.TRUE).map(n=>n.getConfig().id)}load(n){this._snapshot=n}checkSheetName(n){return this.getSheetsName().includes(n)}uniqueSheetName(n="Sheet1"){let r=n;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}generateNewSheetName(n){let r=n+this._count;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}_parseWorksheetSnapshots(){const{_snapshot:n,_worksheets:r}=this,{sheets:s,sheetOrder:i}=n;if(q.isEmptyObject(s)){const o=tt();s[o]={id:o}}for(const o in s){const a=s[o],{name:l}=a;a.name=this.uniqueSheetName(l),a.name!==l&&this._logService.debug("[Workbook]",`The worksheet name ${l} is duplicated, we changed it to ${a.name}. Please fix the problem in your snapshot.`);const c=new xr(this._unitId,a,this._styles);r.set(o,c),i.includes(o)||i.push(o)}this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(n){this._snapshot.custom=n}};exports.Workbook=xR([UR(1,Et)],exports.Workbook);class la extends Gs{constructor(n){var r;super();p(this,"type",ve.UNIVER_SLIDE);p(this,"_activePage$",new ce.BehaviorSubject(null));p(this,"activePage$",this._activePage$.asObservable());p(this,"_name$");p(this,"name$");p(this,"_snapshot");p(this,"_unitId");this._snapshot={...Mu,...n},this._unitId=(r=this._snapshot.id)!=null?r:tt(6),this._name$=new ce.BehaviorSubject(this._snapshot.title),this.name$=this._name$.asObservable()}get _activePage(){var r,s;const n=this._activePage$.getValue();if(!n){const i=(r=this.getPageOrder())==null?void 0:r[0];return i?(s=this.getPages())==null?void 0:s[i]:null}return n}setName(n){var r;this._snapshot.title=n,this._name$.next(n),this._unitId=(r=this._snapshot.id)!=null?r:tt(6)}getRev(){return 0}incrementRev(){}setRev(n){}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var n;return(n=this._snapshot.body)==null?void 0:n.pages}getPageOrder(){var n;return(n=this._snapshot.body)==null?void 0:n.pageOrder}getPage(n){const r=this.getPages();return r==null?void 0:r[n]}getElementsByPage(n){var r;return(r=this.getPage(n))==null?void 0:r.pageElements}getElement(n,r){var s;return(s=this.getElementsByPage(n))==null?void 0:s[r]}getPageSize(){return this._snapshot.pageSize}getBlankPage(){const n=tt(6);return{id:n,pageType:Yo.SLIDE,zIndex:10,title:n,description:"",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}setActivePage(n){this._activePage$.next(n)}getActivePage(){return this._activePage}updatePage(n,r){this._snapshot.body&&(this._snapshot.body.pages[n]=r)}appendPage(n){var i;if(!this._snapshot.body)return;this._snapshot.body.pages[n.id]=n;const r=this._activePage,s=this._snapshot.body.pageOrder.indexOf((i=r==null?void 0:r.id)!=null?i:"");this._snapshot.body.pageOrder.splice(s+1,0,n.id)}}var kR=Object.getOwnPropertyDescriptor,FR=(e,t,n,r)=>{for(var s=r>1?void 0:r?kR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Ol=(e,t)=>(n,r)=>t(n,r,e);const Xn=Ae.createIdentifier("univer.current");exports.UniverInstanceService=class extends Ke{constructor(n,r){super();p(this,"_unitsByType",new Map);p(this,"_createHandler");p(this,"_ctorByType",new Map);p(this,"_currentUnits",new Map);p(this,"_currentUnits$",new ce.BehaviorSubject(this._currentUnits));p(this,"currentUnits$",this._currentUnits$.asObservable());p(this,"_unitAdded$",new ce.Subject);p(this,"unitAdded$",this._unitAdded$.asObservable());p(this,"_unitDisposed$",new ce.Subject);p(this,"unitDisposed$",this._unitDisposed$.asObservable());p(this,"_focused$",new ce.BehaviorSubject(null));p(this,"focused$",this._focused$.asObservable());this._injector=n,this._contextService=r}dispose(){super.dispose(),this._focused$.complete()}__setCreateHandler(n){this._createHandler=n}createUnit(n,r,s){return this._createHandler(n,r,this._ctorByType.get(n),s)}registerCtorForType(n,r){return this._ctorByType.set(n,r),{dispose:()=>{this._ctorByType.delete(n)}}}getCurrentTypeOfUnit$(n){return this.currentUnits$.pipe(ce.map(r=>{var s;return(s=r.get(n))!=null?s:null}),ce.distinctUntilChanged())}getCurrentUnitForType(n){return this._currentUnits.get(n)}getCurrentUnitOfType(n){return this.getCurrentUnitForType(n)}setCurrentUnitForType(n){const r=this._getUnitById(n);if(!r)throw new Error(`[UniverInstanceService]: no document with unitId ${n}!`);this._currentUnits.set(r[1],r[0]),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(n){return this._unitAdded$.pipe(ce.filter(r=>r.type===n))}__addUnit(n,r){var a;const s=n.type;this._unitsByType.has(s)||this._unitsByType.set(s,[]);const i=this._unitsByType.get(s),o=n.getUnitId();if(i.findIndex(l=>l.getUnitId()===o)!==-1)throw new Error(`[UniverInstanceService]: cannot create a unit with the same unit id: ${o}.`);i.push(n),this._unitAdded$.next(n),((a=r==null?void 0:r.makeCurrent)==null||a)&&this.setCurrentUnitForType(n.getUnitId())}getTypeOfUnitDisposed$(n){return this.unitDisposed$.pipe(ce.filter(r=>r.type===n))}getUnit(n,r){var i;const s=(i=this._getUnitById(n))==null?void 0:i[0];return r&&(s==null?void 0:s.type)!==r?null:s}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(ve.UNIVER_DOC)}getUniverDocInstance(n){return this.getUnit(n,ve.UNIVER_DOC)}getUniverSheetInstance(n){return this.getUnit(n,ve.UNIVER_SHEET)}getAllUnitsForType(n){var r;return(r=this._unitsByType.get(n))!=null?r:[]}changeDoc(n,r){const s=this.getAllUnitsForType(ve.UNIVER_DOC),i=s.find(o=>o.getUnitId()===n);if(i!=null){const o=s.indexOf(i);s.splice(o,1)}this.__addUnit(r)}get focused(){var r;const n=this._focused$.getValue();return n?(r=this._getUnitById(n))==null?void 0:r[0]:null}focusUnit(n){this._focused$.next(n),this.focused instanceof exports.Workbook?(this._contextService.setContextValue(Cr,!0),this._contextService.setContextValue(Rr,!1),this._contextService.setContextValue(Hn,!0),this._contextService.setContextValue(Ir,!1),this.setCurrentUnitForType(n)):this.focused instanceof Nt?(this._contextService.setContextValue(Cr,!0),this._contextService.setContextValue(Rr,!0),this._contextService.setContextValue(Hn,!1),this._contextService.setContextValue(Ir,!1),this.setCurrentUnitForType(n)):this.focused instanceof la?(this._contextService.setContextValue(Cr,!0),this._contextService.setContextValue(Rr,!1),this._contextService.setContextValue(Hn,!1),this._contextService.setContextValue(Ir,!0),this.setCurrentUnitForType(n)):(this._contextService.setContextValue(Cr,!1),this._contextService.setContextValue(Rr,!1),this._contextService.setContextValue(Hn,!1),this._contextService.setContextValue(Ir,!1))}getFocusedUnit(){return this.focused}getUnitType(n){const r=this._getUnitById(n);return r?r[1]:ve.UNRECOGNIZED}disposeUnit(n){const r=this._getUnitById(n);if(!r)return!1;const[s,i]=r,o=this._unitsByType.get(i),a=o.indexOf(s);return o.splice(a,1),this._tryResetCurrentOnRemoval(n,i),this._tryResetFocusOnRemoval(n),this._unitDisposed$.next(s),!0}_tryResetCurrentOnRemoval(n,r){const s=this.getCurrentUnitForType(r);(s==null?void 0:s.getUnitId())===n&&(this._currentUnits.set(r,null),this._currentUnits$.next(this._currentUnits))}_tryResetFocusOnRemoval(n){var r;((r=this.focused)==null?void 0:r.getUnitId())===n&&this._focused$.next(null)}_getUnitById(n){for(const[r,s]of this._unitsByType){const i=s.find(o=>o.getUnitId()===n);if(i)return[i,r]}}};exports.UniverInstanceService=FR([Ol(0,Ae.Inject(Ae.Injector)),Ol(1,qn)],exports.UniverInstanceService);var Ue=(e=>(e[e.Starting=0]="Starting",e[e.Ready=1]="Ready",e[e.Rendered=2]="Rendered",e[e.Steady=3]="Steady",e))(Ue||{});const Jh={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"};var BR=Object.getOwnPropertyDescriptor,$R=(e,t,n,r)=>{for(var s=r>1?void 0:r?BR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},HR=(e,t)=>(n,r)=>t(n,r,e);class Qh extends Error{constructor(t){super(`[LifecycleService]: lifecycle stage "${Jh[t]}" will never be reached!`),this.name="LifecycleUnreachableError"}}exports.LifecycleService=class extends Ke{constructor(n){super();p(this,"_lifecycle$",new ce.BehaviorSubject(Ue.Starting));p(this,"lifecycle$",this._lifecycle$.asObservable());p(this,"_lock",!1);this._logService=n,this._reportProgress(Ue.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(n){if(this._lock)throw new Error("[LifecycleService]: cannot set new stage when related logic is all handled!");if(n<this.stage)throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");n!==this.stage&&(this._lock=!0,this._reportProgress(n),this._lifecycle$.next(n),this._lock=!1)}dispose(){this._lifecycle$.complete(),super.dispose()}onStage(n){return ce.firstValueFrom(this.lifecycle$.pipe(ce.filter(r=>r>=n),bi(r=>r===n),ce.map(()=>{}))).catch(r=>r.name==="EmptyError"?Promise.reject(new Qh(n)):Promise.reject(r))}subscribeWithPrevious(){return ce.merge(ed(this.stage),this._lifecycle$.pipe(ce.skip(1))).pipe(bi(n=>n===Ue.Steady))}_reportProgress(n){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${Jh[n]}".`)}};exports.LifecycleService=$R([HR(0,Et)],exports.LifecycleService);function ed(e){switch(e){case Ue.Starting:return ce.of(Ue.Starting);case Ue.Ready:return ce.of(Ue.Starting,Ue.Ready);case Ue.Rendered:return ce.of(Ue.Starting,Ue.Ready,Ue.Rendered);default:return ce.of(Ue.Starting,Ue.Ready,Ue.Rendered,Ue.Steady)}}const jR=Ae.createIdentifier("ILocalStorageService");class Cn extends Ke{constructor(){super();p(this,"_currentLocale$",new ce.BehaviorSubject(Br.ZH_CN));p(this,"currentLocale$",this._currentLocale$.asObservable());p(this,"_locales",null);p(this,"localeChanged$",new ce.Subject);p(this,"t",(n,...r)=>{if(!this._locales)throw new Error("[LocaleService]: Locale not initialized");const s=n.split("."),i=this.resolveKeyPath(this._locales[this._currentLocale],s);if(typeof i=="string"){let o=i;return r.forEach((a,l)=>{o=o.replace(`{${l}}`,a)}),o}else return n});this.disposeWithMe(We(()=>{this._locales=null,this._currentLocale$.complete(),this.localeChanged$.complete()}))}get _currentLocale(){return this._currentLocale$.value}load(n){var r;this._locales=ia((r=this._locales)!=null?r:{},n)}setLocale(n){this._currentLocale$.next(n),this.localeChanged$.next()}getLocales(){var n;return(n=this._locales)==null?void 0:n[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(n,r){const s=r.shift();if(s&&n&&s in n){const i=n[s];return r.length>0&&(typeof i=="object"||Array.isArray(i))?this.resolveKeyPath(i,r):i}return null}}var WR=Object.getOwnPropertyDescriptor,YR=(e,t,n,r)=>{for(var s=r>1?void 0:r?WR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},GR=(e,t)=>(n,r)=>t(n,r,e);exports.MentionIOLocalService=class{constructor(t){this._userManagerService=t}async list(t){return{list:[{type:vs.PERSON,mentions:[{objectType:vs.PERSON,objectId:this._userManagerService.getCurrentUser().userID,label:this._userManagerService.getCurrentUser().name,metadata:{icon:this._userManagerService.getCurrentUser().avatar}}],metadata:{},title:"PEOPLE"}],page:t.page,size:t.size,total:1}}};exports.MentionIOLocalService=YR([GR(0,Ae.Inject(Lr))],exports.MentionIOLocalService);const td=Ae.createIdentifier("univer.service.mention-io");var ca=(e=>(e.INIT="init",e.FETCHING="fetching",e.DONE="done",e))(ca||{});const nd=Ae.createIdentifier("univer.permission-service");class rd extends Ke{constructor(){super(...arguments);p(this,"_permissionPointMap",new Map);p(this,"_permissionPointUpdate$",new ce.Subject);p(this,"permissionPointUpdate$",this._permissionPointUpdate$.asObservable());p(this,"_showComponents",!0)}setShowComponents(n){this._showComponents=n}getShowComponents(){return this._showComponents}deletePermissionPoint(n){const r=this._permissionPointMap.get(n);r&&(r.complete(),this._permissionPointMap.delete(n))}addPermissionPoint(n){const r=n instanceof ce.BehaviorSubject,s=r?n.getValue():n;if(!s.id)return!1;if(this._permissionPointMap.get(s.id))throw new Error(`${s.id} PermissionPoint already exists`);return this._permissionPointMap.set(s.id,r?n:new ce.BehaviorSubject(s)),this._permissionPointUpdate$.next(s),!0}updatePermissionPoint(n,r){const s=this._permissionPointMap.get(n);if(!s)return;const i=s.getValue();i.value=r,i.status=ca.DONE,s.next(i),this._permissionPointUpdate$.next(i)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(n){const r=this._permissionPointMap.get(n);if(r)return r.getValue()}getPermissionPoint$(n){const r=this._permissionPointMap.get(n);if(r)return r}composePermission$(n){const r=n.map(s=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(s);if(!i)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return i.asObservable()});return ce.combineLatest(r).pipe(ls.map(s=>s))}composePermission(n){return n.map(s=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(s);if(!i)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return i.getValue()})}getAllPermissionPoint(){const n=new Map;return this._permissionPointMap.forEach((r,s)=>{n.set(s,r)}),n}}function sd(e,t){if(!t)return e;const n=[];for(const r of e){const s=t.find(([i])=>i===r[0]);if(s){if(s[1]===null)continue;n.push([r[0],s[1]])}else n.push(r)}return n}var VR=Object.getOwnPropertyDescriptor,zR=(e,t,n,r)=>{for(var s=r>1?void 0:r?VR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Si=(e,t)=>(n,r)=>t(n,r,e);const KR=4,id=Symbol("DependentOn");class eo extends Ke{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}p(eo,"pluginName"),p(eo,"type",ve.UNIVER_UNKNOWN);class XR{constructor(){p(this,"_plugins",[])}addPlugin(t){this._plugins.push(t)}removePlugins(){const t=this._plugins.slice();return this._plugins.length=0,t}forEachPlugin(t){this._plugins.forEach(t)}}function qR(...e){return function(t){t[id]=e}}exports.PluginService=class{constructor(t,n,r){p(this,"_pluginRegistry",new Map);p(this,"_pluginStore",new XR);p(this,"_seenPlugins",new Set);p(this,"_loadedPlugins",new Set);p(this,"_loadedPluginTypes",new Set([ve.UNIVER_UNKNOWN]));p(this,"_flushTimerByType",new Map);this._injector=t,this._lifecycleService=n,this._logService=r}dispose(){this._pluginStore.removePlugins().forEach(t=>t.dispose()),this._flushTimerByType.forEach(t=>clearTimeout(t))}registerPlugin(t,n){this._assertPluginValid(t);const r={plugin:t,options:n};this._pluginRegistry.set(t.pluginName,r),this._logService.debug("[PluginService]",`Plugin "${t.pluginName}" registered.`);const{type:s}=t;this._loadedPluginTypes.has(s)&&(s===ve.UNIVER_UNKNOWN?this._loadFromPlugins([r]):this._flushType(s))}startPluginsForType(t){this._loadedPluginTypes.has(t)||this._loadPluginsForType(t)}_loadPluginsForType(t){const n=Array.from(this._pluginRegistry.keys()),r=[];n.forEach(s=>{const i=this._pluginRegistry.get(s);i.plugin.type===t&&r.push(i)}),this._loadFromPlugins(r),this._loadedPluginTypes.add(t)}_assertPluginValid(t){const{type:n,pluginName:r}=t;if(n===ve.UNRECOGNIZED)throw new Error(`[PluginService]: invalid plugin type for ${t.name}. Please assign a "type" to your plugin.`);if(!r)throw new Error(`[PluginService]: no plugin name for ${t.name}. Please assign a "pluginName" to your plugin.`);if(this._seenPlugins.has(r))throw new Error(`[PluginService]: duplicated plugin name for "${r}". Maybe a plugin that dependents on "${r} has already registered it. In that case please register "${r}" before the that plugin.`);this._seenPlugins.add(t.pluginName)}_flushType(t){this._flushTimerByType.get(t)===void 0&&this._flushTimerByType.set(t,setTimeout(()=>{this._loadPluginsForType(t),this._flushTimerByType.delete(t)},KR))}_loadFromPlugins(t){const n=[],r=new Set,s=o=>{const{plugin:a}=o,{pluginName:l}=a;if(this._loadedPlugins.has(l)||r.has(l))return;r.add(l),this._pluginRegistry.delete(l);const c=a[id];c&&c.forEach(u=>{const h=this._pluginRegistry.get(u.pluginName);if(h)s(h);else if(!this._seenPlugins.has(u.pluginName)&&!r.has(u.pluginName)){if(a.type===ve.UNIVER_UNKNOWN&&u.type!==ve.UNIVER_UNKNOWN)throw new Error(`[PluginService]: cannot register a plugin with Univer type that depends on a plugin with other type. The dependent is ${a.pluginName} and the dependency is ${u.pluginName}.`);a.type!==u.type&&u.type!==ve.UNIVER_UNKNOWN&&this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${u.pluginName}" which has different type.`),this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${u.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(u),s({plugin:u,options:void 0})}}),n.push(o)};t.forEach(o=>s(o));const i=n.map(o=>this._initPlugin(o.plugin,o.options));this._pluginsRunLifecycle(i)}_pluginsRunLifecycle(t){const n=this._lifecycleService.stage;if(ed(n).subscribe(r=>this._runStage(t,r)),n!==Ue.Steady){const r=this._lifecycleService.lifecycle$.pipe(ce.skip(1)).subscribe(s=>{this._runStage(t,s),s===Ue.Steady&&r.unsubscribe()})}}_runStage(t,n){t.forEach(r=>{switch(n){case Ue.Starting:r.onStarting();break;case Ue.Ready:r.onReady();break;case Ue.Rendered:r.onRendered();break;case Ue.Steady:r.onSteady();break}})}_initPlugin(t,n){const r=this._injector.createInstance(t,n);return this._pluginStore.addPlugin(r),this._loadedPlugins.add(t.pluginName),this._logService.debug("[PluginService]",`Plugin "${r.getPluginName()}" loaded.`),r}};exports.PluginService=zR([Si(0,Ae.Inject(Ae.Injector)),Si(1,Ae.Inject(exports.LifecycleService)),Si(2,Et)],exports.PluginService);const to=Ae.createIdentifier("resource-loader-service");var ZR=Object.getOwnPropertyDescriptor,JR=(e,t,n,r)=>{for(var s=r>1?void 0:r?ZR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},QR=(e,t)=>(n,r)=>t(n,r,e);exports.ResourceManagerService=class extends Ke{constructor(n){super();p(this,"_resourceMap",new Map);p(this,"_register$",new ce.Subject);p(this,"register$",this._register$.asObservable());this._logService=n}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(n,r){return r?this.getResourcesByType(n,r):this.getAllResourceHooks().map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}getResourcesByType(n,r){return this.getAllResourceHooks().filter(o=>o.businesses.includes(r)).map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}registerPluginResource(n){const r=n.pluginName;if(this._resourceMap.has(r))throw new Error(`the pluginName is registered {${r}}`);return this._resourceMap.set(r,n),this._register$.next(n),We(()=>this._resourceMap.delete(r))}disposePluginResource(n){this._resourceMap.delete(n)}loadResources(n,r){this.getAllResourceHooks().forEach(s=>{var o;const i=(o=r==null?void 0:r.find(a=>a.name===s.pluginName))==null?void 0:o.data;if(i)try{const a=s.parseJson(i);s.onLoad(n,a)}catch(a){this._logService.error("[ResourceManagerService]","loadResources error",a)}})}unloadResources(n){this.getAllResourceHooks().forEach(r=>{r.onUnLoad(n)})}dispose(){this._register$.complete(),this._resourceMap.clear()}};exports.ResourceManagerService=JR([QR(0,Et)],exports.ResourceManagerService);class Ps extends Ke{constructor(){super();p(this,"_darkMode$",new ce.BehaviorSubject(!1));p(this,"darkMode$",this._darkMode$.asObservable());p(this,"_validColorCache",new Map);p(this,"_currentTheme",Kr.defaultTheme);p(this,"_currentTheme$",new ce.BehaviorSubject(this._currentTheme));p(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(We(()=>{this._currentTheme=Kr.defaultTheme,this._currentTheme$.complete(),this._darkMode$.complete()}))}get darkMode(){return this._darkMode$.getValue()}isValidThemeColor(n){if(this._validColorCache.has(n))return this._validColorCache.get(n);let r=!1;const s=n.split(".");if(s.length===1)r=n in Kr.defaultTheme;else if(s.length===2){const[i,o]=s;r=i in Kr.defaultTheme&&o in this._currentTheme[i]}return this._validColorCache.set(n,r),r}getCurrentTheme(){return this._currentTheme}setTheme(n){this._currentTheme=n,this._currentTheme$.next(n)}setDarkMode(n){this._darkMode$.next(n)}getColorFromTheme(n){return Nh(this._currentTheme,n)}}var eI=Object.getOwnPropertyDescriptor,tI=(e,t,n,r)=>{for(var s=r>1?void 0:r?eI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Oi=(e,t)=>(n,r)=>t(n,r,e);const Js=Ae.createIdentifier("univer.undo-redo.service"),nI=20;class od{dispose(){}async dispatchToHandlers(){return!1}}const ad="univer.command.redo",ld="univer.command.undo",cd=new class extends od{constructor(){super(...arguments);p(this,"type",kr.COMMAND);p(this,"id",ld)}handler(t){const n=t.get(Js),r=n.pitchTopUndoElement();if(!r)return!1;const s=t.get(Fr);return Fs(r.undoMutations,s)?(n.popUndoToRedo(),!0):!1}},ud=new class extends od{constructor(){super(...arguments);p(this,"type",kr.COMMAND);p(this,"id",ad)}handler(t){const n=t.get(Js),r=n.pitchTopRedoElement();if(!r)return!1;const s=t.get(Fr);return Fs(r.redoMutations,s)?(n.popRedoToUndo(),!0):!1}};exports.LocalUndoRedoService=class extends Ke{constructor(n,r,s){super();p(this,"undoRedoStatus$");p(this,"_undoRedoStatus$",new ce.BehaviorSubject({undos:0,redos:0}));p(this,"_undoStacks",new Map);p(this,"_redoStacks",new Map);p(this,"_batchingStatus",new Map);this._univerInstanceService=n,this._commandService=r,this._contextService=s,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(cd)),this.disposeWithMe(this._commandService.registerCommand(ud)),this.disposeWithMe(We(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(We(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(n){const{unitID:r}=n,s=this._getRedoStack(r,!0),i=this._getUndoStack(r,!0);if(s.length=0,this._batchingStatus.has(n.unitID)){const a=this._batchingStatus.get(n.unitID),l=this._pitchUndoElement(n.unitID);a===0||!l?(o(n),this._batchingStatus.set(n.unitID,1)):this._tryBatchingElements(l,n)}else o(n);function o(a){i.push(a),i.length>nI&&i.splice(0,1)}this._updateStatus()}clearUndoRedo(n){const r=this._getRedoStack(n);r&&(r.length=0);const s=this._getUndoStack(n);s&&(s.length=0),this._updateStatus()}pitchTopUndoElement(){const n=this._getFocusedUnitId();return this._pitchUndoElement(n)}pitchTopRedoElement(){const n=this._getFocusedUnitId();return this._pitchRedoElement(n)}_pitchUndoElement(n){const r=this._getUndoStack(n);return r!=null&&r.length?r[r.length-1]:null}_pitchRedoElement(n){const r=this._getRedoStack(n);return r!=null&&r.length?r[r.length-1]:null}popUndoToRedo(){const r=this._getUndoStackForFocused().pop();r&&(this._getRedoStackForFocused().push(r),this._updateStatus())}popRedoToUndo(){const r=this._getRedoStackForFocused().pop();r&&(this._getUndoStackForFocused().push(r),this._updateStatus())}rollback(n,r){const s=r||this._getFocusedUnitId(),i=this._getUndoStack(s),o=i==null?void 0:i[(i==null?void 0:i.length)-1];o&&o.id===n&&(i.pop(),Fs(o.undoMutations,this._commandService))}__tempBatchingUndoRedo(n){if(this._batchingStatus.has(n))throw new Error("[LocalUndoRedoService]: cannot batching undo redo twice at the same time!");return this._batchingStatus.set(n,0),We(()=>this._batchingStatus.delete(n))}_updateStatus(){var i,o;const n=this._getFocusedUnitId(),r=n&&((i=this._undoStacks.get(n))==null?void 0:i.length)||0,s=n&&((o=this._redoStacks.get(n))==null?void 0:o.length)||0;this._undoRedoStatus$.next({undos:r,redos:s})}_getUndoStack(n,r=!1){let s=this._undoStacks.get(n);return!s&&r&&(s=[],this._undoStacks.set(n,s)),s||null}_getRedoStack(n,r=!1){let s=this._redoStacks.get(n);return!s&&r&&(s=[],this._redoStacks.set(n,s)),s||null}_getUndoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getUndoStack(n,!0)}_getRedoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getRedoStack(n,!0)}_tryBatchingElements(n,r){n.redoMutations.push(...r.redoMutations),n.undoMutations.push(...r.undoMutations)}_getFocusedUnitId(){var o,a,l,c;let n="";const r=this._contextService.getContextValue(Hn),s=this._contextService.getContextValue(Ph),i=this._contextService.getContextValue(Uh);return r?s?n=io:i?n=so:n=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":n=(c=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?c:"",n}};exports.LocalUndoRedoService=tI([Oi(0,Xn),Oi(1,Fr),Oi(2,qn)],exports.LocalUndoRedoService);class hd{constructor(t,n=100){p(this,"_imageCacheMap");this._injector=t,this._imageCacheMap=new Tr(n)}_getImageCacheKey(t,n){return`${t}-${n}`}getImage(t,n,r,s){const i=this._getImageCacheKey(t,n),o=this._imageCacheMap.get(i);return o||((async()=>{const a=new Image,l=this._injector.has(Ji)?this._injector.get(Ji):null;if(t===aa.UUID)try{a.src=await(l==null?void 0:l.getImage(n))||""}catch(c){console.error(c)}else a.src=n;a.onload=()=>{a.removeAttribute("data-error"),r==null||r()},a.onerror=()=>{a.setAttribute("data-error","true"),s==null||s()},this._imageCacheMap.set(i,a)})(),null)}}function rI(e){return!(e.length===0||e.length>31||e.startsWith("'")||e.endsWith("'")||/[:\\\/\?\*\[\]]/.test(e))}const vl=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],vi=1,ir=8;class ua{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[n,r]=new Uint8Array(t,0,2);if(n!==219)throw new Error("Data does not appear to be in a KDBush format.");const s=r>>4;if(s!==vi)throw new Error(`Got v${s} data when expected v${vi}.`);const i=vl[r&15];if(!i)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new ua(a,o,i,t)}constructor(t,n=64,r=Float64Array,s){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+n,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=vl.indexOf(this.ArrayType),o=t*2*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);s&&s instanceof ArrayBuffer?(this.data=s,this.ids=new this.IndexArrayType(this.data,ir,t),this.coords=new this.ArrayType(this.data,ir+a+l,t*2),this._pos=t*2,this._finished=!0):(this.data=new ArrayBuffer(ir+o+a+l),this.ids=new this.IndexArrayType(this.data,ir,t),this.coords=new this.ArrayType(this.data,ir+a+l,t*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(vi<<4)+i]),new Uint16Array(this.data,2,1)[0]=n,new Uint32Array(this.data,4,1)[0]=t)}add(t,n){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=n,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return no(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,n,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:o,nodeSize:a}=this,l=[0,i.length-1,0],c=[];for(;l.length;){const u=l.pop()||0,h=l.pop()||0,d=l.pop()||0;if(h-d<=a){for(let R=d;R<=h;R++){const b=o[2*R],F=o[2*R+1];b>=t&&b<=r&&F>=n&&F<=s&&c.push(i[R])}continue}const f=d+h>>1,g=o[2*f],_=o[2*f+1];g>=t&&g<=r&&_>=n&&_<=s&&c.push(i[f]),(u===0?t<=g:n<=_)&&(l.push(d),l.push(f-1),l.push(1-u)),(u===0?r>=g:s>=_)&&(l.push(f+1),l.push(h),l.push(1-u))}return c}within(t,n,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:i,nodeSize:o}=this,a=[0,s.length-1,0],l=[],c=r*r;for(;a.length;){const u=a.pop()||0,h=a.pop()||0,d=a.pop()||0;if(h-d<=o){for(let R=d;R<=h;R++)wl(i[2*R],i[2*R+1],t,n)<=c&&l.push(s[R]);continue}const f=d+h>>1,g=i[2*f],_=i[2*f+1];wl(g,_,t,n)<=c&&l.push(s[f]),(u===0?t-r<=g:n-r<=_)&&(a.push(d),a.push(f-1),a.push(1-u)),(u===0?t+r>=g:n+r>=_)&&(a.push(f+1),a.push(h),a.push(1-u))}return l}}function no(e,t,n,r,s,i){if(s-r<=n)return;const o=r+s>>1;dd(e,t,o,r,s,i),no(e,t,n,r,o-1,1-i),no(e,t,n,o+1,s,1-i)}function dd(e,t,n,r,s,i){for(;s>r;){if(s-r>600){const c=s-r+1,u=n-r+1,h=Math.log(c),d=.5*Math.exp(2*h/3),f=.5*Math.sqrt(h*d*(c-d)/c)*(u-c/2<0?-1:1),g=Math.max(r,Math.floor(n-u*d/c+f)),_=Math.min(s,Math.floor(n+(c-u)*d/c+f));dd(e,t,n,g,_,i)}const o=t[2*n+i];let a=r,l=s;for(or(e,t,r,n),t[2*s+i]>o&&or(e,t,r,s);a<l;){for(or(e,t,a,l),a++,l--;t[2*a+i]<o;)a++;for(;t[2*l+i]>o;)l--}t[2*r+i]===o?or(e,t,r,l):(l++,or(e,t,l,s)),l<=n&&(r=l+1),n<=l&&(s=l-1)}}function or(e,t,n,r){wi(e,n,r),wi(t,2*n,2*r),wi(t,2*n+1,2*r+1)}function wi(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function wl(e,t,n,r){const s=e-n,i=t-r;return s*s+i*i}class sI{constructor(t=!1){p(this,"_tree",new Map);p(this,"_oneCellCache",new Map);p(this,"_kdTree",new Map);this._enableOneCellCache=t}dispose(){this.clear()}getTree(t,n){return this._tree.has(t)||this._tree.set(t,new Map),this._tree.get(t).has(n)||this._tree.get(t).set(n,new Ms),this._tree.get(t).get(n)}_getOneCellCache(t,n,r,s){return this._oneCellCache.has(t)||this._oneCellCache.set(t,new Map),this._oneCellCache.get(t).has(n)||this._oneCellCache.get(t).set(n,new Map),this._oneCellCache.get(t).get(n).has(r)||this._oneCellCache.get(t).get(n).set(r,new Map),this._oneCellCache.get(t).get(n).get(r).has(s)||this._oneCellCache.get(t).get(n).get(r).set(s,new Set),this._oneCellCache.get(t).get(n).get(r).get(s)}_removeOneCellCache(t,n,r,s,i){const o=this._oneCellCache.get(t);if(!o)return;const a=o.get(n);if(!a)return;const l=a.get(r);if(!l)return;const c=l.get(s);c&&c.delete(i)}_removeCellCacheByRange(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this._oneCellCache.get(n);if(!o)return;const a=o.get(r);if(!a)return;const{startRow:l,startColumn:c,endRow:u,endColumn:h}=s;for(let d=l;d<=u;d++){const f=a.get(d);if(f)for(let g=c;g<=h;g++){const _=f.get(g);_&&_.delete(i)}}}_insertOneCellCache(t,n,r,s,i){this._getOneCellCache(t,n,r,s).add(i)}_getRdTreeItems(t){const n=[];for(const[r,s]of t)for(const[i,o]of s)n.push({x:i,y:r,ids:o});return n}_searchByOneCellCache(t){var g;const{unitId:n,sheetId:r,range:s}=t,{startRow:i,startColumn:o,endRow:a,endColumn:l}=s,c=(g=this._kdTree.get(n))==null?void 0:g.get(r);if(!c)return[];const{tree:u,items:h}=c,d=u.range(o,i,l,a),f=[];for(const _ of d){const R=h[_];f.push(...Array.from(R.ids))}return f}openKdTree(){var t;for(const[n,r]of this._oneCellCache){this._kdTree.has(n)||this._kdTree.set(n,new Map);for(const[s,i]of r){const o=this._getRdTreeItems(i),a=new ua(o.length);(t=this._kdTree.get(n))==null||t.set(s,{tree:a,items:o});for(const l of o)a.add(l.x,l.y);a.finish()}}}closeKdTree(){var t;for(const[n,r]of this._oneCellCache)for(const[s,i]of r)(t=this._kdTree.get(n))==null||t.set(s,void 0)}insert(t){const{unitId:n,sheetId:r,range:s,id:i}=t;if(!n||n.length===0)return;let{startRow:o,endRow:a,startColumn:l,endColumn:c}=s;if(this._enableOneCellCache&&o===a&&l===c){this._insertOneCellCache(n,r,o,l,i);return}const u=this.getTree(n,r);Number.isNaN(o)&&(o=0),Number.isNaN(l)&&(l=0),Number.isNaN(a)&&(a=Number.POSITIVE_INFINITY),Number.isNaN(c)&&(c=Number.POSITIVE_INFINITY),u.insert({minX:l,minY:o,maxX:c,maxY:a,id:i})}bulkInsert(t){for(const n of t)this.insert(n)}*searchGenerator(t){var a;const{unitId:n,sheetId:r,range:s}=t;if(this._enableOneCellCache){const l=this._searchByOneCellCache(t);for(const c of l)yield c}const i=(a=this._tree.get(n))==null?void 0:a.get(r);if(!i)return;const o=i.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(const l of o)yield l.id}bulkSearch(t,n){const r=new Set;for(const s of t)for(const i of this.searchGenerator(s))(n==null?void 0:n.has(i))!==!0&&r.add(i);return r}removeById(t,n){var r,s;n?((r=this._tree.get(t))==null||r.delete(n),(s=this._oneCellCache.get(t))==null||s.delete(n)):(this._tree.delete(t),this._oneCellCache.delete(t))}_removeRTreeItem(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this.getTree(n,r),a=o.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(let l=0;l<a.length;l++)a[l].id===i&&o.remove(a[l])}remove(t){const{unitId:n,sheetId:r,range:s,id:i}=t,{startRow:o,startColumn:a,endRow:l,endColumn:c}=s;this._enableOneCellCache?o===l&&a===c?this._removeOneCellCache(n,r,s.startRow,s.startColumn,i):(this._removeCellCacheByRange(t),this._removeRTreeItem(t)):this._removeRTreeItem(t)}bulkRemove(t){for(const n of t)this.remove(n)}clear(){this._tree.clear(),this._oneCellCache.clear()}toJSON(){const t={};return this._tree.forEach((n,r)=>{t[r]={},n.forEach((s,i)=>{t[r][i]=s.toJSON()})}),t}fromJSON(t){this._tree.clear();for(const n in t){this._tree.set(n,new Map);for(const r in t[n]){const s=new Ms;s.fromJSON(t[n][r]),this._tree.get(n).set(r,s)}}}}function iI(e){return new Promise(t=>setTimeout(t,e))}function oI(e=1){return new Promise(t=>{let n=0;const r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}var aI=Object.getOwnPropertyDescriptor,lI=(e,t,n,r)=>{for(var s=r>1?void 0:r?aI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},cI=(e,t)=>(n,r)=>t(n,r,e);exports.Skeleton=class extends Ke{constructor(n){super();p(this,"_fontLocale");p(this,"_dirty",!0);this._localeService=n,this._localeInitial()}get dirty(){return this._dirty}getFontLocale(){return this._fontLocale}makeDirty(n){this._dirty=n}dispose(){super.dispose(),this._fontLocale=null}_localeInitial(){}};exports.Skeleton=lI([cI(0,Ae.Inject(Cn))],exports.Skeleton);var uI=Object.getOwnPropertyDescriptor,hI=(e,t,n,r)=>{for(var s=r>1?void 0:r?uI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},as=(e,t)=>(n,r)=>t(n,r,e);exports.SheetSkeleton=class extends exports.Skeleton{constructor(n,r,s,i,o,a){super(s);p(this,"_worksheetData");p(this,"_renderRawFormula",!1);p(this,"_cellData");p(this,"_imageCacheMap");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");p(this,"_scaleY");p(this,"_scrollX");p(this,"_scrollY");this.worksheet=n,this._styles=r,this._contextService=i,this._configService=o,this._injector=a,this._worksheetData=this.worksheet.getConfig(),this._cellData=this.worksheet.getCellMatrix(),this._imageCacheMap=new hd(this._injector),this.initConfig()}initConfig(){var n,r;this._skipAutoHeightForMergedCells=!((n=this._configService.getConfig(Ll))!=null&&n),this.worksheet.setIsRowStylePrecedeColumnStyle((r=this._configService.getConfig(Ml))!=null?r:!1)}resetCache(){}getWorksheetConfig(){return this._worksheetData}getLocation(){return[this.worksheet.getUnitId(),this.worksheet.getSheetId()]}set columnHeaderHeight(n){this._columnHeaderHeight=n,this._worksheetData.columnHeader.height=n}set rowHeaderWidth(n){this._rowHeaderWidth=n,this._worksheetData.rowHeader.width=n}get rowHeightAccumulation(){return this._rowHeightAccumulation}get rowTotalHeight(){return this._rowTotalHeight}get columnWidthAccumulation(){return this._columnWidthAccumulation}get columnTotalWidth(){return this._columnTotalWidth}get rowHeaderWidth(){return this._rowHeaderWidth}get columnHeaderHeight(){return this._columnHeaderHeight}setMarginLeft(n){this._marginLeft=n}setMarginTop(n){this._marginTop=n}setScale(n,r){this._updateLayout(),this._scaleX=n,this._scaleY=r||n,this._updateLayout()}setScroll(n,r){q.isDefine(n)&&(this._scrollX=n),q.isDefine(r)&&(this._scrollY=r)}get scrollX(){return this._scrollX}get scrollY(){return this._scrollY}get scaleX(){return this._scaleX}get scaleY(){return this._scaleY}get rowHeaderWidthAndMarginLeft(){return this.rowHeaderWidth+this._marginLeft}get columnHeaderHeightAndMarginTop(){return this.columnHeaderHeight+this._marginTop}get imageCacheMap(){return this._imageCacheMap}_generateRowMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let c=s;if(this.worksheet.getRowFiltered(l))c=0;else if(a[l]!=null){const u=a[l];if(!u)continue;const{h=s,ah:d,ia:f}=u;(f==null||f===ie.TRUE)&&typeof d=="number"?c=d:c=h,u.hd===ie.TRUE&&(c=0)}i+=c,o.push(i)}return{rowTotalHeight:i,rowHeightAccumulation:o}}_generateColumnMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let c=s;if(a[l]!=null){const u=a[l];if(!u)continue;u.w!=null&&(c=u.w),u.hd===ie.TRUE&&(c=0)}i+=c,o.push(i)}return{columnTotalWidth:i,columnWidthAccumulation:o}}intersectMergeRange(n,r){return!!this.worksheet.getMergedCell(n,r)}_getOverflowBound(n,r,s,i,o=Tt.LEFT){let a=0;if(r>s){const l=this._columnWidthAccumulation.length-1;for(let c=r;c>=s;c--){const u=c,h=this.worksheet.getCell(n,u);if(!Li(h)&&u!==r||this.intersectMergeRange(n,u))return u===r?u:u+1>l?l:u+1;const{startX:d,endX:f}=Un(n,u,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===Tt.CENTER&&u===r?a+=(f-d)/2:a+=f-d,i<a)return u}return r}for(let l=r;l<=s;l++){const c=l,u=this.worksheet.getCell(n,c);if(!Li(u)&&c!==r||this.intersectMergeRange(n,c))return c===r?c:c-1<0?0:c-1;const{startX:h,endX:d}=Un(n,c,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===Tt.CENTER&&c===r?a+=(d-h)/2:a+=d-h,i<a)return c}return s}_updateLayout(){if(!this.dirty)return;const{rowData:n,columnData:r,defaultRowHeight:s,defaultColumnWidth:i,rowCount:o,columnCount:a,rowHeader:l,columnHeader:c}=this._worksheetData,{rowTotalHeight:u,rowHeightAccumulation:h}=this._generateRowMatrixCache(o,n,s),{columnTotalWidth:d,columnWidthAccumulation:f}=this._generateColumnMatrixCache(a,r,i);this._rowHeaderWidth=l.hidden!==ie.TRUE?this._dynamicallyUpdateRowHeaderWidth(l):0,this._columnHeaderHeight=c.hidden!==ie.TRUE?c.height:0,this._rowTotalHeight=u,this._rowHeightAccumulation=h,this._columnTotalWidth=d,this._columnWidthAccumulation=f,this.makeDirty(!1)}calculate(){return this.resetCache(),this._updateLayout(),this}resetRangeCache(n){}_dynamicallyUpdateRowHeaderWidth(n){const s=`${this.worksheet.getRowCount()}`.length*8;return Math.max(n.width,s)}_hasUnMergedCellInRow(n,r,s){if(!this.worksheet.getMergeData())return!1;for(let o=r;o<=s;o++){const{isMerged:a,isMergedMainCell:l}=this.worksheet.getCellInfoInMergeData(n,o);if(!a&&!l)return!0}return!1}expandRangeByMerge(n){let{startRow:r,startColumn:s,endRow:i,endColumn:o}=n;const a=this._worksheetData.mergeData;if(!a)return{startRow:r,startColumn:s,endRow:i,endColumn:o};let l=!0;const c=new dt;for(;l;){l=!1;for(let u=0;u<a.length;u++){const{startRow:h,startColumn:d,endRow:f,endColumn:g}=a[u];if(c.getValue(h,d))continue;xu({startColumn:s,startRow:r,endColumn:o,endRow:i},{startColumn:d,startRow:h,endColumn:g,endRow:f})&&(r=Math.min(r,h),s=Math.min(s,d),i=Math.max(i,f),o=Math.max(o,g),c.setValue(h,d,!0),l=!0)}}return{startRow:r,startColumn:s,endRow:i,endColumn:o}}getColumnCount(){return this._columnWidthAccumulation.length}getRowCount(){return this._rowHeightAccumulation.length}_getCellMergeInfo(n,r){return this.worksheet.getCellInfoInMergeData(n,r)}getNoMergeCellPositionByIndex(n,r,s=!0){return this.getNoMergeCellWithCoordByIndex(n,r,s)}getNoMergeCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this;let{startY:c,endY:u,startX:h,endX:d}=Un(n,r,i,o);return s&&(c+=l,u+=l,h+=a,d+=a),{startY:c,endY:u,startX:h,endX:d}}getNoMergeCellPositionByIndexWithNoHeader(n,r){const{rowHeightAccumulation:s,columnWidthAccumulation:i}=this,{startY:o,endY:a,startX:l,endX:c}=Un(n,r,s,i);return{startY:o,endY:a,startX:l,endX:c}}getRowIndexByOffsetY(n,r,s,i){var l;const{rowHeightAccumulation:o}=this;n=md(n,r,s,this.columnHeaderHeightAndMarginTop);let a=ar(o,n,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(o[a]-n)<Math.abs(n-((l=o[a-1])!=null?l:0))&&(a=a+1),a}getColumnIndexByOffsetX(n,r,s,i){var c;const o=fd(n,r,s,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this;let l=ar(a,o,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(a[l]-o)<Math.abs(o-((c=a[l-1])!=null?c:0))&&(l=l+1),l}getCellIndexByOffset(n,r,s,i,o,a){const l=this.getRowIndexByOffsetY(r,i,o,a),c=this.getColumnIndexByOffsetX(n,s,o,a);return{row:l,column:c}}getCellByOffset(n,r,s,i,o){const a=this==null?void 0:this.getCellIndexByOffset(n,r,s,i,o,{firstMatch:!0});return a?this.worksheet.getCellInfoInMergeData(a.row,a.column):null}getCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this,c=Un(n,r,i,o,this.worksheet.getCellInfoInMergeData(n,r)),{isMerged:u,isMergedMainCell:h}=c;let{startY:d,endY:f,startX:g,endX:_,mergeInfo:R}=c,b=a,F=l;return s===!1&&(b=0,F=0),d+=F,f+=F,g+=b,_+=b,R.startY+=F,R.endY+=F,R.startX+=b,R.endX+=b,{actualRow:n,actualColumn:r,startX:g,startY:d,endX:_,endY:f,isMerged:u,isMergedMainCell:h,mergeInfo:R}}getCellWithCoordByOffset(n,r,s,i,o,a){const{row:l,column:c}=this.getCellIndexByOffset(n,r,s,i,o,a);return this.getCellWithCoordByIndex(l,c)}getOffsetByColumn(n){const{columnWidthAccumulation:r,rowHeaderWidthAndMarginLeft:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetByRow(n){const{rowHeightAccumulation:r,columnHeaderHeightAndMarginTop:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetRelativeToRowCol(n,r){const s=ar(this.columnWidthAccumulation,n);let i=0;s===0?i=n:i=n-this._columnWidthAccumulation[s-1];const o=ar(this.rowHeightAccumulation,r);let a=0;return o===0?a=r:a=r-this._rowHeightAccumulation[o-1],{row:o,column:s,columnOffset:i,rowOffset:a}}_updateConfigAndGetDocumentModel(n,r,s,i){var a,l,c,u,h;if(!i||!((a=n.body)!=null&&a.dataStream))return;n.documentStyle||(n.documentStyle={}),n.documentStyle.marginTop=(l=s.t)!=null?l:0,n.documentStyle.marginBottom=(c=s.b)!=null?c:2,n.documentStyle.marginLeft=(u=s.l)!=null?u:2,n.documentStyle.marginRight=(h=s.r)!=null?h:2,n.documentStyle.pageSize={width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},n.documentStyle.renderConfig={...n.documentStyle.renderConfig,...i};const o=n.body.paragraphs||[];for(const d of o)d.paragraphStyle||(d.paragraphStyle={}),d.paragraphStyle.horizontalAlign=r;return new Nt(n)}dispose(){super.dispose(),this._rowHeightAccumulation=[],this._columnWidthAccumulation=[],this._rowTotalHeight=0,this._columnTotalWidth=0,this._rowHeaderWidth=0,this._columnHeaderHeight=0,this._worksheetData=null,this._cellData=null,this._styles=null}};exports.SheetSkeleton=hI([as(2,Ae.Inject(Cn)),as(3,qn),as(4,oa),as(5,Ae.Inject(Ae.Injector))],exports.SheetSkeleton);function ha(e,t,n,r){const s=e-1,i=t-1,o=n[s]||0;let a=n[e];a==null&&(a=n[n.length-1]);const l=r[i]||0;let c=r[t];return c==null&&(c=r[r.length-1]),{startY:o,endY:a,startX:l,endX:c}}function dI(e,t,n,r){return ha(e,t,n,r)}function Un(e,t,n,r,s){e=q.clamp(e,0,n.length-1),t=q.clamp(t,0,r.length-1);let{startY:i,endY:o,startX:a,endX:l}=ha(e,t,n,r);if(!s)return{startY:i,endY:o,startX:a,endX:l,isMerged:!1,isMergedMainCell:!1,actualRow:e,actualColumn:t,mergeInfo:{startY:i,endY:o,startX:a,endX:l,startRow:e,startColumn:t,endRow:e,endColumn:t}};const{isMerged:c,isMergedMainCell:u,startRow:h,startColumn:d,endRow:f,endColumn:g}=s;let _={startRow:h,startColumn:d,endRow:f,endColumn:g,startY:i,endY:o,startX:a,endX:l};const R=n.length-1,b=r.length-1;if(c&&h!==-1&&d!==-1){const F=n[h-1]||0,k=n[f]||n[R],W=r[d-1]||0,S=r[g]||r[b];_={..._,startY:F,endY:k,startX:W,endX:S}}else if(!c&&f!==-1&&g!==-1){const F=n[f]||n[R],k=r[g]||r[b];_={..._,startY:i,endY:F,startX:a,endX:k}}return{isMerged:c,isMergedMainCell:u,actualRow:e,actualColumn:t,startY:i,endY:o,startX:a,endX:l,mergeInfo:_}}function fd(e,t,n,r){const{x:s}=n;return e/t+s-r}function md(e,t,n,r){const{y:s}=n;return e=e/t+s-r,e}const fI=["script","style","meta","comment","link"];var gd=(e=>(e[e.INFO=0]="INFO",e[e.STOP=1]="STOP",e[e.WARNING=2]="WARNING",e))(gd||{}),_d=(e=>(e[e.DISABLED=0]="DISABLED",e[e.FULL_ALPHA=1]="FULL_ALPHA",e[e.FULL_HANGUL=2]="FULL_HANGUL",e[e.FULL_KATAKANA=3]="FULL_KATAKANA",e[e.HALF_ALPHA=4]="HALF_ALPHA",e[e.HALF_HANGUL=5]="HALF_HANGUL",e[e.HALF_KATAKANA=6]="HALF_KATAKANA",e[e.HIRAGANA=7]="HIRAGANA",e[e.NO_CONTROL=8]="NO_CONTROL",e[e.OFF=9]="OFF",e[e.ON=10]="ON",e))(_d||{}),pd=(e=>(e.BETWEEN="between",e.EQUAL="equal",e.GREATER_THAN="greaterThan",e.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",e.LESS_THAN="lessThan",e.LESS_THAN_OR_EQUAL="lessThanOrEqual",e.NOT_BETWEEN="notBetween",e.NOT_EQUAL="notEqual",e))(pd||{}),Ed=(e=>(e[e.TEXT=0]="TEXT",e[e.ARROW=1]="ARROW",e[e.CUSTOM=2]="CUSTOM",e))(Ed||{}),Cd=(e=>(e.VALID="valid",e.INVALID="invalid",e.VALIDATING="validating",e))(Cd||{}),Rd=(e=>(e.CUSTOM="custom",e.LIST="list",e.LIST_MULTIPLE="listMultiple",e.NONE="none",e.TEXT_LENGTH="textLength",e.DATE="date",e.TIME="time",e.WHOLE="whole",e.DECIMAL="decimal",e.CHECKBOX="checkbox",e.ANY="any",e))(Rd||{}),mI=Object.getOwnPropertyDescriptor,gI=(e,t,n,r)=>{for(var s=r>1?void 0:r?mI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},bl=(e,t)=>(n,r)=>t(n,r,e);let ro=class extends Ke{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){const e=n=>{n.businesses.forEach(r=>{switch(r){case ve.UNRECOGNIZED:case ve.UNIVER_UNKNOWN:case ve.UNIVER_SLIDE:case ve.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType(ve.UNIVER_DOC).forEach(s=>{const o=(s.getSnapshot().resources||[]).find(a=>a.name===n.pluginName);if(o)try{const a=n.parseJson(o.data);n.onLoad(s.getUnitId(),a)}catch{console.error(`Load Document{${s.getUnitId()}} Resources{${n.pluginName}} Data Error.`)}});break}case ve.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(ve.UNIVER_SHEET).forEach(s=>{const o=(s.getSnapshot().resources||[]).find(a=>a.name===n.pluginName);if(o)try{const a=n.parseJson(o.data);n.onLoad(s.getUnitId(),a)}catch{console.error(`Load Workbook{${s.getUnitId()}} Resources{${n.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(n=>e(n)),this.disposeWithMe(this._resourceManagerService.register$.subscribe(n=>e(n))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(ve.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(ve.UNIVER_DOC).subscribe(n=>{const r=n.getUnitId();Dl(r)||this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(ve.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(ve.UNIVER_DOC).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())}))}saveUnit(e){const t=this._univerInstanceService.getUnit(e);if(!t)return null;const n=this._resourceManagerService.getResources(e,t.type),r=q.deepClone(t.getSnapshot());return r.resources=n,r}};ro=gI([bl(0,Ae.Inject(zs)),bl(1,Ae.Inject(Xn))],ro);class _I{constructor(t={},n){p(this,"_startedTypes",new Set);p(this,"_injector");p(this,"_disposingCallbacks",new ks);const r=this._injector=pI(n,t==null?void 0:t.override),{theme:s,darkMode:i,locale:o,locales:a,logLevel:l}=t;s&&this._injector.get(Ps).setTheme(s),i&&this._injector.get(Ps).setDarkMode(i),a&&this._injector.get(Cn).load(a),o&&this._injector.get(Cn).setLocale(o),l&&this._injector.get(Et).setLogLevel(l),this._init(r)}get _univerInstanceService(){return this._injector.get(Xn)}get _pluginService(){return this._injector.get(exports.PluginService)}__getInjector(){return this._injector}onDispose(t){const n=this._disposingCallbacks.add(We(t));return We(()=>n.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(t){this._injector.get(Cn).setLocale(t)}createUnit(t,n){return this._univerInstanceService.createUnit(t,n)}createUniverSheet(t){return this._injector.get(Et).warn("[Univer]","Univer.createUniverSheet is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(ve.UNIVER_SHEET,t)}createUniverDoc(t){return this._injector.get(Et).warn("[Univer]","Univer.createUniverDoc is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(ve.UNIVER_DOC,t)}createUniverSlide(t){return this._injector.get(Et).warn("[Univer]","Univer.createUniverSlide is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(ve.UNIVER_SLIDE,t)}_init(t){this._univerInstanceService.registerCtorForType(ve.UNIVER_SHEET,exports.Workbook),this._univerInstanceService.registerCtorForType(ve.UNIVER_DOC,Nt),this._univerInstanceService.registerCtorForType(ve.UNIVER_SLIDE,la);const n=t.get(Xn);n.__setCreateHandler((r,s,i,o)=>{if(!this._startedTypes.has(r)){this._pluginService.startPluginsForType(r),this._startedTypes.add(r);const l=t.createInstance(i,s);return n.__addUnit(l,o),this._tryProgressToReady(),l}const a=t.createInstance(i,s);return n.__addUnit(a,o),a})}_tryProgressToReady(){this._injector.get(exports.LifecycleService).stage<Ue.Ready&&(this._injector.get(exports.LifecycleService).stage=Ue.Ready)}registerPlugin(t,n){this._pluginService.registerPlugin(t,n)}}function pI(e,t){const n=sd([[kh],[Cn],[Ps],[exports.LifecycleService],[exports.PluginService],[Lr],[Xn,{useClass:exports.UniverInstanceService}],[nd,{useClass:rd}],[Et,{useClass:Yl,lazy:!0}],[Fr,{useClass:exports.CommandService}],[Js,{useClass:exports.LocalUndoRedoService,lazy:!0}],[oa,{useClass:xh}],[qn,{useClass:jl}],[zs,{useClass:exports.ResourceManagerService,lazy:!0}],[to,{useClass:ro,lazy:!0}],[dh,{useClass:exports.AuthzIoLocalService}],[td,{useClass:exports.MentionIOLocalService,lazy:!0}]],t),r=e?e.createChild(n):new Ae.Injector(n);return xl(r,[[Lr],[to]]),r}Ad();exports.ABCToNumber=L_;exports.AUTO_HEIGHT_FOR_MERGED_CELLS=Ll;exports.AbsoluteRefType=Ne;exports.ActionIterator=xn;exports.AlignTypeH=Ou;exports.AlignTypeV=vu;exports.ArrangeTypeEnum=Au;exports.ArrowsAndMarkersShapes=ac;exports.AsyncInterceptorManager=Kd;exports.AsyncLock=kd;exports.AutoFillSeries=ql;exports.BaselineOffset=Yt;exports.BasicShapes=oc;exports.BlockType=ru;exports.BooleanNumber=ie;exports.BorderStyleTypes=De;exports.BorderType=Zl;exports.BuildTextUtils=Qe;exports.BulletAlignment=$r;exports.COLORS=Ti;exports.CanceledError=jd;exports.CellModeEnum=kn;exports.CellValueType=en;exports.Color=In;exports.ColorBuilder=$s;exports.ColorKit=At;exports.ColorType=pt;exports.ColumnSeparatorType=ou;exports.CommandType=kr;exports.CommonHideTypes=Jl;exports.ConfigService=xh;exports.ContextService=jl;exports.CopyPasteType=Ql;exports.CustomCommandExecutionError=Ss;exports.CustomDecorationType=pn;exports.CustomRangeType=sn;exports.DEFAULT_CELL=l_;exports.DEFAULT_DOC=Xo;exports.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=tE;exports.DEFAULT_EMPTY_DOCUMENT_VALUE=Nl;exports.DEFAULT_NUMBER_FORMAT=eu;exports.DEFAULT_RANGE=o_;exports.DEFAULT_RANGE_ARRAY=i_;exports.DEFAULT_SELECTION=a_;exports.DEFAULT_SLIDE=Mu;exports.DEFAULT_STYLES=st;exports.DEFAULT_TEXT_FORMAT=Jc;exports.DEFAULT_TEXT_FORMAT_EXCEL=Qc;exports.DEFAULT_WORKSHEET_COLUMN_COUNT=Yh;exports.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=bR;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Kh;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=NR;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH=Vh;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=TR;exports.DEFAULT_WORKSHEET_ROW_COUNT=Wh;exports.DEFAULT_WORKSHEET_ROW_COUNT_KEY=wR;exports.DEFAULT_WORKSHEET_ROW_HEIGHT=Gh;exports.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=AR;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=zh;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=yR;exports.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=io;exports.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=so;exports.DOCS_ZEN_EDITOR_UNIT_ID_KEY=yl;exports.DOC_DRAWING_PRINTING_COMPONENT_KEY=f_;exports.DOC_RANGE_TYPE=Sc;exports.DashStyleType=du;exports.DataStreamTreeNodeType=oh;exports.DataStreamTreeTokenType=at;exports.DataValidationErrorStyle=gd;exports.DataValidationImeMode=_d;exports.DataValidationOperator=pd;exports.DataValidationRenderMode=Ed;exports.DataValidationStatus=Cd;exports.DataValidationType=Rd;exports.DeleteDirection=ec;exports.DependentOn=qR;exports.DesktopLogService=Yl;exports.DeveloperMetadataVisibility=tc;exports.Dimension=nc;exports.Direction=rc;exports.Disposable=Ke;exports.DisposableCollection=ks;exports.DocStyleType=tu;exports.DocumentDataModel=Nt;exports.DocumentFlavor=Wo;exports.DrawingTypeEnum=Tu;exports.EDITOR_ACTIVATED=Uh;exports.EXTENSION_NAMES=Lu;exports.ErrorService=kh;exports.EventState=hh;exports.EventSubject=nE;exports.FOCUSING_COMMON_DRAWINGS=hR;exports.FOCUSING_DOC=Rr;exports.FOCUSING_EDITOR_BUT_HIDDEN=iR;exports.FOCUSING_EDITOR_INPUT_FORMULA=oR;exports.FOCUSING_EDITOR_STANDALONE=lR;exports.FOCUSING_FX_BAR_EDITOR=Ph;exports.FOCUSING_PANEL_EDITOR=cR;exports.FOCUSING_SHEET=Hn;exports.FOCUSING_SLIDE=Ir;exports.FOCUSING_UNIT=Cr;exports.FOCUSING_UNIVER_EDITOR=aR;exports.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=uR;exports.FORMULA_EDITOR_ACTIVATED=dR;exports.FollowNumberWithType=nu;exports.FontItalic=ws;exports.FontStyleType=$n;exports.FontWeight=bs;exports.GridType=su;exports.HLSColor=pc;exports.HorizontalAlign=Tt;exports.IAuthzIoService=dh;exports.ICommandService=Fr;exports.IConfigService=oa;exports.IContextService=qn;exports.IImageIoService=Ji;exports.ILocalStorageService=jR;exports.ILogService=Et;exports.IMentionIOService=td;exports.IPermissionService=nd;exports.IResourceLoaderService=to;exports.IResourceManagerService=zs;exports.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE=Ml;exports.IUndoRedoService=Js;exports.IUniverInstanceService=Xn;exports.ImageCacheMap=hd;exports.ImageSourceType=aa;exports.ImageUploadStatusType=Fh;exports.InterceptorEffectEnum=Pn;exports.InterceptorManager=Gd;exports.InterpolationPointType=sc;exports.JSON1=V_;exports.JSONX=Gt;exports.LRUHelper=ur;exports.LRUMap=Tr;exports.LifecycleStages=Ue;exports.LifecycleUnreachableError=Qh;exports.ListGlyphType=fe;exports.LocaleService=Cn;exports.LocaleType=Br;exports.LogLevel=Wl;exports.MOVE_BUFFER_VALUE=lr;exports.MemoryCursor=On;exports.MentionType=vs;exports.NAMED_STYLE_MAP=u_;exports.NAMED_STYLE_SPACE_MAP=h_;exports.NamedStyleType=Xe;exports.NilCommand=Gl;exports.NumberUnitType=Su;exports.ObjectMatrix=dt;exports.ObjectRelativeFromH=Ru;exports.ObjectRelativeFromV=Iu;exports.OtherShapes=lc;exports.PAGE_SIZE=m_;exports.PAPER_TYPES=s_;exports.PRESET_LIST_TYPE=Wr;exports.PRINT_CHART_COMPONENT_KEY=d_;exports.PageElementType=yu;exports.PageOrientType=bu;exports.PageType=Yo;exports.PaperType=ct;exports.ParagraphElementType=lu;exports.ParagraphStyleBuilder=Mr;exports.ParagraphStyleValue=Gr;exports.PermissionService=rd;exports.PermissionStatus=ca;exports.Plugin=eo;exports.PositionedObjectLayoutType=uu;exports.PresetListType=kt;exports.ProtectionType=ic;exports.QuickListType=Zu;exports.QuickListTypeMap=J_;exports.RANGE_DIRECTION=Ic;exports.RANGE_TYPE=_e;exports.RBush=Ms;exports.RCDisposable=df;exports.RGBA_PAREN=jf;exports.RGB_PAREN=Hf;exports.ROTATE_BUFFER_VALUE=Xl;exports.RTree=sI;exports.Range=Vn;exports.Rectangle=on;exports.RedoCommand=ud;exports.RedoCommandId=ad;exports.RefAlias=M_;exports.Registry=oo;exports.RegistryAsMap=ao;exports.RelativeDate=uc;exports.RelativeSlideLink=Nu;exports.RgbColor=As;exports.RichTextBuilder=En;exports.RichTextValue=Qt;exports.RxDisposable=hf;exports.SHEET_EDITOR_UNITS=c_;exports.SectionType=iu;exports.SheetTypes=hc;exports.SheetViewModel=qh;exports.SliceBodyType=Ko;exports.SlideDataModel=la;exports.SpacingRule=hu;exports.SpecialShapes=cc;exports.Styles=Bh;exports.THEME_COLORS=_c;exports.TabStopAlignment=fu;exports.TableAlignmentType=gu;exports.TableLayoutType=_u;exports.TableRowHeightRule=Eu;exports.TableSizeType=mu;exports.TableTextWrapType=pu;exports.TextDecoration=dc;exports.TextDecorationBuilder=Jt;exports.TextDirection=Ar;exports.TextDirectionType=au;exports.TextStyleBuilder=nn;exports.TextStyleValue=Yr;exports.TextX=Me;exports.TextXActionType=Z;exports.ThemeColor=Ts;exports.ThemeColorType=it;exports.ThemeColors=Bs;exports.ThemeService=Ps;exports.Tools=q;exports.UndoCommand=cd;exports.UndoCommandId=ld;exports.UnitModel=Gs;exports.Univer=_I;exports.UniverInstanceType=ve;exports.UpdateDocsAttributeType=Ee;exports.UserManagerService=Lr;exports.VerticalAlign=_n;exports.VerticalAlignmentType=Cu;exports.Worksheet=xr;exports.WrapStrategy=Rn;exports.WrapTextType=cu;exports.addLinkToDocumentModel=$h;exports.afterInitApply=Sf;exports.afterTime=Rf;exports.awaitTime=iI;exports.binSearchFirstGreaterThanTarget=Kl;exports.binarySearchArray=Of;exports.bufferDebounceTime=Cf;exports.cellToRange=Em;exports.characterSpacingControlType=wu;exports.checkForSubstrings=Rm;exports.checkIfMove=wf;exports.checkParagraphHasBullet=ng;exports.checkParagraphHasIndent=rg;exports.checkParagraphHasIndentByStyle=Ac;exports.codeToBlob=vf;exports.composeBody=Gi;exports.composeInterceptors=Pl;exports.composeStyles=cr;exports.concatMatrixArray=am;exports.convertBodyToHtml=$f;exports.convertCellToRange=Oc;exports.convertObservableToBehaviorSubject=If;exports.covertCellValue=Di;exports.covertCellValues=Cm;exports.covertTextRunToHtml=Ai;exports.createAsyncInterceptorKey=Vd;exports.createDefaultUser=xs;exports.createDocumentModelWithStyle=Sr;exports.createInterceptorKey=Yd;exports.createInternalEditorID=$d;exports.createRowColIter=$i;exports.dayjs=Vt;exports.debounce=JC;exports.dedupe=Td;exports.dedupeBy=yd;exports.deepCompare=co;exports.delayAnimationFrame=oI;exports.deleteContent=yc;exports.extractPureTextFromCell=Zh;exports.fromCallback=Vl;exports.fromEventSubject=rE;exports.fromObservable=uf;exports.generateRandomId=tt;exports.get=Nh;exports.getArrayLength=tn;exports.getBodySlice=yt;exports.getBodySliceHtml=cs;exports.getBorderStyleType=gm;exports.getCellCoordByIndexSimple=ha;exports.getCellInfoInMergeData=im;exports.getCellPositionByIndexSimple=dI;exports.getCellValueType=nm;exports.getCellWithCoordByIndexCore=Un;exports.getColorStyle=Dt;exports.getCustomBlockSlice=th;exports.getCustomDecorationSlice=rh;exports.getCustomRangeSlice=nh;exports.getDocsUpdateBody=_m;exports.getIntersectRange=xu;exports.getOriginCellValue=LR;exports.getParagraphsSlice=eh;exports.getPlainText=Vs;exports.getReverseDirection=bf;exports.getSectionBreakSlice=ap;exports.getTableSlice=Qu;exports.getTextRunSlice=Ds;exports.getTransformOffsetX=fd;exports.getTransformOffsetY=md;exports.getWorksheetUID=PR;exports.groupBy=Ld;exports.handleStyleToString=mm;exports.hashAlgorithm=ig;exports.horizontalLineSegmentsSubtraction=Hs;exports.insertMatrixArray=yi;exports.insertTextToContent=Tc;exports.invertColorByHSL=ef;exports.invertColorByMatrix=nf;exports.isBlackColor=em;exports.isBooleanString=Bd;exports.isCellCoverable=Li;exports.isCellV=Rc;exports.isDefaultFormat=n_;exports.isEmptyCell=vc;exports.isFormulaId=fm;exports.isFormulaString=wc;exports.isICellData=Cc;exports.isInternalEditorID=Dl;exports.isNodeEnv=Bf;exports.isNotNullOrUndefined=Hh;exports.isNullCell=rm;exports.isNumeric=Bl;exports.isPatternEqualWithoutDecimal=r_;exports.isRangesEqual=_R;exports.isRealNum=sg;exports.isSafeNumeric=sf;exports.isSameStyleTextRun=bc;exports.isTextFormat=t_;exports.isUnitRangesEqual=pR;exports.isValidRange=pm;exports.isWhiteColor=tm;exports.makeArray=Dd;exports.makeCellRangeToRangeData=dm;exports.makeCellToSelection=hm;exports.makeCustomRangeStream=Ip;exports.mapObjectMatrix=om;exports.merge=ia;exports.mergeOverrideWithDependencies=sd;exports.mergeSets=lf;exports.mergeWith=nR;exports.mergeWorksheetSnapshotWithDefault=Xh;exports.mixinClass=rf;exports.moveMatrixArray=Mi;exports.moveRangeByOffset=I_;exports.nameCharacterCheck=rI;exports.normalizeBody=lp;exports.normalizeTextRuns=jr;exports.numberToABC=x_;exports.numberToListABC=U_;exports.numfmt=e_;exports.queryObjectMatrix=N_;exports.registerDependencies=Hd;exports.remove=Ur;exports.repeatStringNumTimes=Pu;exports.replaceInDocumentBody=Qp;exports.requestImmediateMacroTask=af;exports.rotate=Md;exports.searchArray=ar;exports.searchInOrderedArray=zl;exports.selectionToArray=sm;exports.sequence=Hl;exports.sequenceAsync=$l;exports.sequenceExecute=Fs;exports.sequenceExecuteAsync=Ef;exports.set=sR;exports.shallowEqual=Ul;exports.skipParseTagNames=fI;exports.sliceMatrixArray=lm;exports.sortRules=P_;exports.sortRulesByDesc=k_;exports.sortRulesFactory=Hr;exports.spliceArray=Ni;exports.splitIntoGrid=Go;exports.takeAfter=bi;exports.textDiff=qo;exports.throttle=Wd;exports.toDisposable=We;exports.touchDependencies=xl;exports.updateAttributeByDelete=sh;exports.updateAttributeByInsert=ih;exports.willLoseNumericPrecision=of;Object.keys(Ae).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>Ae[e]})});
|
|
8
|
+
`,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(n){return new En(n!=null?n:En.newEmptyData())}insertText(n,r,s){var u,h;let i=((h=(u=this._data.body)==null?void 0:u.dataStream.length)!=null?h:2)-2,o,a;if(typeof n=="string"?o=n:(i=Math.min(n,i),o=r),typeof r=="object"?a=r instanceof nn?r.build():r:a=s instanceof nn?s.build():s,!o)return this;const l={dataStream:o,textRuns:a?[{ts:a,st:i,ed:i+o.length}]:[]},c=Qe.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:l});if(!c)throw new Error("Insert text failed, please check.");return Me.apply(this._doc.getBody(),c.serialize()),this}insertRichText(n,r){var a,l;let s=((l=(a=this._data.body)==null?void 0:a.dataStream.length)!=null?l:2)-2,i;typeof n=="object"?i=n instanceof Qt?n.getData():n:(s=Math.min(n,s),i=r instanceof Qt?r.getData():r);const o=Qe.selection.replace({doc:this._doc,selection:{startOffset:s,endOffset:s,collapsed:!0},body:i.body});if(!o)throw new Error("Insert text failed, please check.");return Me.apply(this._doc.getBody(),o.serialize()),this}delete(n,r){if(r!==void 0){if(!r)return this;const s=Qe.selection.delete([{startOffset:n,endOffset:n+r,collapsed:!0}],this._data.body);Me.apply(this._doc.getBody(),s)}return this}setStyle(n,r,s){const i={dataStream:"",textRuns:[{ts:s instanceof nn?s.build():s,st:0,ed:r-n}]},o=Qe.selection.retain([{startOffset:n,endOffset:r,collapsed:!0}],i);return Me.apply(this._doc.getBody(),o),this}setLink(n,r,s){const i=Qe.customRange.add({rangeType:sn.HYPERLINK,rangeId:tt(),properties:{url:s},ranges:[{startOffset:n,endOffset:r,collapsed:!1}],body:this._data.body});if(!i)throw new Error("Insert text failed, please check.");return Me.apply(this._doc.getBody(),i.serialize()),this}cancelLink(n,r){if(typeof n=="string"){const s=Qe.customRange.delete({rangeId:n,documentDataModel:this._doc});if(!s)throw new Error("Insert text failed, please check.");Me.apply(this._doc.getBody(),s.serialize())}else this.slice(n,r).getLinks().forEach(i=>{const o=Qe.customRange.delete({rangeId:i.rangeId,documentDataModel:this._doc});if(!o)throw new Error("Insert text failed, please check.");Me.apply(this._doc.getBody(),o.serialize())});return this}updateLink(n,r){var i,o;const s=(o=(i=this._data.body)==null?void 0:i.customRanges)==null?void 0:o.find(a=>a.rangeId===n);if(!s)throw new Error("Link not found");return s.properties.url=r,this}insertParagraph(n,r){var o,a;let s,i;return typeof n=="object"?(s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:n.build()}]},i=((a=(o=this._data.body)==null?void 0:o.dataStream.length)!=null?a:2)-2):(i=n,s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:r==null?void 0:r.build()}]}),this.insertRichText(i,Qt.create({body:s,id:"d",documentStyle:{}})),this}insertLink(n,r,s){let i="",o="";typeof n=="string"?(i=n,o=r):(i=r,o=s);const a=En.createByBody({dataStream:i,customRanges:[{rangeType:sn.HYPERLINK,rangeId:tt(),properties:{url:o},startIndex:0,endIndex:i.length-1}]});return typeof n=="number"?this.insertRichText(n,a):this.insertRichText(a)}}const tE="__default_document_sub_component_id20231101__";class hh{constructor(){p(this,"skipNextObservers",!1);p(this,"lastReturnValue");p(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class nE extends ce.Subject{constructor(){super(...arguments);p(this,"_sortedObservers",[])}subscribe(){throw new Error("[EventSubject]: please use `subscribeEvent` instead of `subscribe` method for `EventSubject`.")}next(){throw new Error("[EventSubject]: please use `emitEvent` instead of `next` method for `EventSubject`.")}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(n){let r;typeof n=="function"?r={next:([i,o])=>n(i,o)}:r=n;const s=super.subscribe(r);return this._sortedObservers.push(r),this._sortedObservers.sort((i,o)=>{var a,l;return((a=i.priority)!=null?a:0)-((l=o.priority)!=null?l:0)}),s.add(()=>this._sortedObservers=this._sortedObservers.filter(i=>i!==r)),s}clearObservers(){this._sortedObservers.forEach(n=>{var r;return(r=n.complete)==null?void 0:r.call(n)}),this._sortedObservers.length=0}emitEvent(n){var r;if(!this.closed){const s=new hh;s.lastReturnValue=n;for(const i of this._sortedObservers){const o=(r=i.next)==null?void 0:r.call(i,[n,s]);if(s.lastReturnValue=o,s.skipNextObservers)return{handled:!0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}throw new Error("[EventSubject]: cannot emit event on a closed subject.")}}function rE(e){return new ce.Observable(t=>{const n=e.subscribeEvent(r=>{t.next(r)});return()=>n.unsubscribe()})}const zs=Ae.createIdentifier("core.resource-manager.service"),Ki={[Ut.Editor]:"Editor",[Ut.Owner]:"Owner",[Ut.Reader]:"Reader",[Ut.UNRECOGNIZED]:"UNRECOGNIZED"},xs=e=>e?{userID:`${Ki[e]}_${tt(8)}`,name:Ki[e],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},sE=(e,t)=>e.startsWith(Ki[t]);class Lr extends Ke{constructor(){super(...arguments);p(this,"_model",new Map);p(this,"_userChange$",new ce.Subject);p(this,"userChange$",this._userChange$.asObservable());p(this,"_currentUser$",new ce.BehaviorSubject(xs()));p(this,"currentUser$",this._currentUser$.asObservable())}dispose(){super.dispose(),this._model.clear(),this._userChange$.complete(),this._currentUser$.complete()}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(n){this.addUser(n),this._currentUser$.next(n)}addUser(n){this._model.set(n.userID,n),this._userChange$.next({type:"add",user:n})}getUser(n,r){const s=this._model.get(n);if(s)return s;r&&r()}delete(n){const r=this.getUser(n);this._model.delete(n),r&&this._userChange$.next({type:"delete",user:r})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}list(){return Array.from(this._model.values())}}var iE=Object.getOwnPropertyDescriptor,oE=(e,t,n,r)=>{for(var s=r>1?void 0:r?iE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},nl=(e,t)=>(n,r)=>t(n,r,e);exports.AuthzIoLocalService=class{constructor(t,n){p(this,"_permissionMap",new Map([]));this._resourceManagerService=t,this._userManagerService=n,this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){const t=this._userManagerService.getCurrentUser();t&&t.userID||this._userManagerService.setCurrentUser(xs(Ut.Owner))}_getRole(t){const n=this._userManagerService.getCurrentUser();return n?sE(n.userID,t):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:t=>{const n=[...this._permissionMap.keys()].reduce((r,s)=>{const i=this._permissionMap.get(s);return r[s]=i,r},{});return JSON.stringify(n)},parseJson:t=>JSON.parse(t),pluginName:"SHEET_AuthzIoMockService_PLUGIN",businesses:[ve.UNIVER_SHEET,ve.UNIVER_DOC,ve.UNIVER_SLIDE],onLoad:(t,n)=>{for(const r in n)this._permissionMap.set(r,n[r])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(t){return tt(8)}async allowed(t){return Promise.resolve([])}async batchAllowed(t){return Promise.resolve([])}async list(t){const n=[];return t.objectIDs.forEach(r=>{const s=this._permissionMap.get(r);if(s){const i={objectID:r,unitID:t.unitID,objectType:s.objectType,name:s.name,shareOn:!1,shareRole:Ut.Owner,shareScope:-1,scope:{read:Hi.AllCollaborator,edit:Hi.AllCollaborator},creator:xs(Ut.Owner),strategies:[{action:6,role:1},{action:16,role:1},{action:17,role:1},{action:18,role:1},{action:19,role:1},{action:33,role:1},{action:34,role:1},{action:35,role:1},{action:36,role:1},{action:37,role:1},{action:38,role:1},{action:39,role:1},{action:40,role:1}],actions:t.actions.map(o=>({action:o,allowed:this._getRole(Ut.Owner)||this._getRole(Ut.Editor)}))};n.push(i)}}),n}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(t){}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(t){}};exports.AuthzIoLocalService=oE([nl(0,zs),nl(1,Ae.Inject(Lr))],exports.AuthzIoLocalService);const dh=Ae.createIdentifier("IAuthzIoIoService");var fh=typeof global=="object"&&global&&global.Object===Object&&global,aE=typeof self=="object"&&self&&self.Object===Object&&self,vn=fh||aE||Function("return this")(),zn=vn.Symbol,mh=Object.prototype,lE=mh.hasOwnProperty,cE=mh.toString,sr=zn?zn.toStringTag:void 0;function uE(e){var t=lE.call(e,sr),n=e[sr];try{e[sr]=void 0;var r=!0}catch{}var s=cE.call(e);return r&&(t?e[sr]=n:delete e[sr]),s}var hE=Object.prototype,dE=hE.toString;function fE(e){return dE.call(e)}var mE="[object Null]",gE="[object Undefined]",rl=zn?zn.toStringTag:void 0;function Vr(e){return e==null?e===void 0?gE:mE:rl&&rl in Object(e)?uE(e):fE(e)}function Jn(e){return e!=null&&typeof e=="object"}var _E="[object Symbol]";function Ks(e){return typeof e=="symbol"||Jn(e)&&Vr(e)==_E}function pE(e,t){for(var n=-1,r=e==null?0:e.length,s=Array(r);++n<r;)s[n]=t(e[n],n,e);return s}var Kn=Array.isArray,sl=zn?zn.prototype:void 0,il=sl?sl.toString:void 0;function gh(e){if(typeof e=="string")return e;if(Kn(e))return pE(e,gh)+"";if(Ks(e))return il?il.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}var EE=/\s/;function CE(e){for(var t=e.length;t--&&EE.test(e.charAt(t)););return t}var RE=/^\s+/;function IE(e){return e&&e.slice(0,CE(e)+1).replace(RE,"")}function Rt(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var ol=NaN,SE=/^[-+]0x[0-9a-f]+$/i,OE=/^0b[01]+$/i,vE=/^0o[0-7]+$/i,wE=parseInt;function al(e){if(typeof e=="number")return e;if(Ks(e))return ol;if(Rt(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Rt(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=IE(e);var n=OE.test(e);return n||vE.test(e)?wE(e.slice(2),n?2:8):SE.test(e)?ol:+e}function _h(e){return e}var bE="[object AsyncFunction]",AE="[object Function]",TE="[object GeneratorFunction]",yE="[object Proxy]";function Jo(e){if(!Rt(e))return!1;var t=Vr(e);return t==AE||t==TE||t==bE||t==yE}var Ci=vn["__core-js_shared__"],ll=function(){var e=/[^.]+$/.exec(Ci&&Ci.keys&&Ci.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function NE(e){return!!ll&&ll in e}var ME=Function.prototype,LE=ME.toString;function DE(e){if(e!=null){try{return LE.call(e)}catch{}try{return e+""}catch{}}return""}var xE=/[\\^$.*+?()[\]{}|]/g,UE=/^\[object .+?Constructor\]$/,PE=Function.prototype,kE=Object.prototype,FE=PE.toString,BE=kE.hasOwnProperty,$E=RegExp("^"+FE.call(BE).replace(xE,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function HE(e){if(!Rt(e)||NE(e))return!1;var t=Jo(e)?$E:UE;return t.test(DE(e))}function jE(e,t){return e==null?void 0:e[t]}function Qo(e,t){var n=jE(e,t);return HE(n)?n:void 0}var cl=Object.create,WE=function(){function e(){}return function(t){if(!Rt(t))return{};if(cl)return cl(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function YE(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function GE(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}var VE=800,zE=16,KE=Date.now;function XE(e){var t=0,n=0;return function(){var r=KE(),s=zE-(r-n);if(n=r,s>0){if(++t>=VE)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function qE(e){return function(){return e}}var Us=function(){try{var e=Qo(Object,"defineProperty");return e({},"",{}),e}catch{}}(),ZE=Us?function(e,t){return Us(e,"toString",{configurable:!0,enumerable:!1,value:qE(t),writable:!0})}:_h,JE=XE(ZE),QE=9007199254740991,e0=/^(?:0|[1-9]\d*)$/;function ea(e,t){var n=typeof e;return t=t==null?QE:t,!!t&&(n=="number"||n!="symbol"&&e0.test(e))&&e>-1&&e%1==0&&e<t}function ta(e,t,n){t=="__proto__"&&Us?Us(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function Xs(e,t){return e===t||e!==e&&t!==t}var t0=Object.prototype,n0=t0.hasOwnProperty;function ph(e,t,n){var r=e[t];(!(n0.call(e,t)&&Xs(r,n))||n===void 0&&!(t in e))&&ta(e,t,n)}function r0(e,t,n,r){var s=!n;n||(n={});for(var i=-1,o=t.length;++i<o;){var a=t[i],l=void 0;l===void 0&&(l=e[a]),s?ta(n,a,l):ph(n,a,l)}return n}var ul=Math.max;function s0(e,t,n){return t=ul(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,i=ul(r.length-t,0),o=Array(i);++s<i;)o[s]=r[t+s];s=-1;for(var a=Array(t+1);++s<t;)a[s]=r[s];return a[t]=n(o),YE(e,this,a)}}function i0(e,t){return JE(s0(e,t,_h),e+"")}var o0=9007199254740991;function Eh(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=o0}function na(e){return e!=null&&Eh(e.length)&&!Jo(e)}function a0(e,t,n){if(!Rt(n))return!1;var r=typeof t;return(r=="number"?na(n)&&ea(t,n.length):r=="string"&&t in n)?Xs(n[t],e):!1}function Ch(e){return i0(function(t,n){var r=-1,s=n.length,i=s>1?n[s-1]:void 0,o=s>2?n[2]:void 0;for(i=e.length>3&&typeof i=="function"?(s--,i):void 0,o&&a0(n[0],n[1],o)&&(i=s<3?void 0:i,s=1),t=Object(t);++r<s;){var a=n[r];a&&e(t,a,r,i)}return t})}var l0=Object.prototype;function Rh(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||l0;return e===n}function c0(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var u0="[object Arguments]";function hl(e){return Jn(e)&&Vr(e)==u0}var Ih=Object.prototype,h0=Ih.hasOwnProperty,d0=Ih.propertyIsEnumerable,Xi=hl(function(){return arguments}())?hl:function(e){return Jn(e)&&h0.call(e,"callee")&&!d0.call(e,"callee")};function f0(){return!1}var Sh=typeof exports=="object"&&exports&&!exports.nodeType&&exports,dl=Sh&&typeof module=="object"&&module&&!module.nodeType&&module,m0=dl&&dl.exports===Sh,fl=m0?vn.Buffer:void 0,g0=fl?fl.isBuffer:void 0,Oh=g0||f0,_0="[object Arguments]",p0="[object Array]",E0="[object Boolean]",C0="[object Date]",R0="[object Error]",I0="[object Function]",S0="[object Map]",O0="[object Number]",v0="[object Object]",w0="[object RegExp]",b0="[object Set]",A0="[object String]",T0="[object WeakMap]",y0="[object ArrayBuffer]",N0="[object DataView]",M0="[object Float32Array]",L0="[object Float64Array]",D0="[object Int8Array]",x0="[object Int16Array]",U0="[object Int32Array]",P0="[object Uint8Array]",k0="[object Uint8ClampedArray]",F0="[object Uint16Array]",B0="[object Uint32Array]",Fe={};Fe[M0]=Fe[L0]=Fe[D0]=Fe[x0]=Fe[U0]=Fe[P0]=Fe[k0]=Fe[F0]=Fe[B0]=!0;Fe[_0]=Fe[p0]=Fe[y0]=Fe[E0]=Fe[N0]=Fe[C0]=Fe[R0]=Fe[I0]=Fe[S0]=Fe[O0]=Fe[v0]=Fe[w0]=Fe[b0]=Fe[A0]=Fe[T0]=!1;function $0(e){return Jn(e)&&Eh(e.length)&&!!Fe[Vr(e)]}function H0(e){return function(t){return e(t)}}var vh=typeof exports=="object"&&exports&&!exports.nodeType&&exports,wr=vh&&typeof module=="object"&&module&&!module.nodeType&&module,j0=wr&&wr.exports===vh,Ri=j0&&fh.process,ml=function(){try{var e=wr&&wr.require&&wr.require("util").types;return e||Ri&&Ri.binding&&Ri.binding("util")}catch{}}(),gl=ml&&ml.isTypedArray,wh=gl?H0(gl):$0;function W0(e,t){var n=Kn(e),r=!n&&Xi(e),s=!n&&!r&&Oh(e),i=!n&&!r&&!s&&wh(e),o=n||r||s||i,a=o?c0(e.length,String):[],l=a.length;for(var c in e)o&&(c=="length"||s&&(c=="offset"||c=="parent")||i&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||ea(c,l))||a.push(c);return a}function Y0(e,t){return function(n){return e(t(n))}}function G0(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var V0=Object.prototype,z0=V0.hasOwnProperty;function K0(e){if(!Rt(e))return G0(e);var t=Rh(e),n=[];for(var r in e)r=="constructor"&&(t||!z0.call(e,r))||n.push(r);return n}function bh(e){return na(e)?W0(e):K0(e)}var X0=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,q0=/^\w*$/;function Z0(e,t){if(Kn(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Ks(e)?!0:q0.test(e)||!X0.test(e)||t!=null&&e in Object(t)}var Dr=Qo(Object,"create");function J0(){this.__data__=Dr?Dr(null):{},this.size=0}function Q0(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var eC="__lodash_hash_undefined__",tC=Object.prototype,nC=tC.hasOwnProperty;function rC(e){var t=this.__data__;if(Dr){var n=t[e];return n===eC?void 0:n}return nC.call(t,e)?t[e]:void 0}var sC=Object.prototype,iC=sC.hasOwnProperty;function oC(e){var t=this.__data__;return Dr?t[e]!==void 0:iC.call(t,e)}var aC="__lodash_hash_undefined__";function lC(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Dr&&t===void 0?aC:t,this}function Sn(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Sn.prototype.clear=J0;Sn.prototype.delete=Q0;Sn.prototype.get=rC;Sn.prototype.has=oC;Sn.prototype.set=lC;function cC(){this.__data__=[],this.size=0}function qs(e,t){for(var n=e.length;n--;)if(Xs(e[n][0],t))return n;return-1}var uC=Array.prototype,hC=uC.splice;function dC(e){var t=this.__data__,n=qs(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():hC.call(t,n,1),--this.size,!0}function fC(e){var t=this.__data__,n=qs(t,e);return n<0?void 0:t[n][1]}function mC(e){return qs(this.__data__,e)>-1}function gC(e,t){var n=this.__data__,r=qs(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function zt(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}zt.prototype.clear=cC;zt.prototype.delete=dC;zt.prototype.get=fC;zt.prototype.has=mC;zt.prototype.set=gC;var Ah=Qo(vn,"Map");function _C(){this.size=0,this.__data__={hash:new Sn,map:new(Ah||zt),string:new Sn}}function pC(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Zs(e,t){var n=e.__data__;return pC(t)?n[typeof t=="string"?"string":"hash"]:n.map}function EC(e){var t=Zs(this,e).delete(e);return this.size-=t?1:0,t}function CC(e){return Zs(this,e).get(e)}function RC(e){return Zs(this,e).has(e)}function IC(e,t){var n=Zs(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function ln(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}ln.prototype.clear=_C;ln.prototype.delete=EC;ln.prototype.get=CC;ln.prototype.has=RC;ln.prototype.set=IC;var SC="Expected a function";function ra(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(SC);var n=function(){var r=arguments,s=t?t.apply(this,r):r[0],i=n.cache;if(i.has(s))return i.get(s);var o=e.apply(this,r);return n.cache=i.set(s,o)||i,o};return n.cache=new(ra.Cache||ln),n}ra.Cache=ln;var OC=500;function vC(e){var t=ra(e,function(r){return n.size===OC&&n.clear(),r}),n=t.cache;return t}var wC=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,bC=/\\(\\)?/g,AC=vC(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(wC,function(n,r,s,i){t.push(s?i.replace(bC,"$1"):r||n)}),t});function TC(e){return e==null?"":gh(e)}function Th(e,t){return Kn(e)?e:Z0(e,t)?[e]:AC(TC(e))}function yh(e){if(typeof e=="string"||Ks(e))return e;var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function yC(e,t){t=Th(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[yh(t[n++])];return n&&n==r?e:void 0}function Nh(e,t,n){var r=e==null?void 0:yC(e,t);return r===void 0?n:r}var Mh=Y0(Object.getPrototypeOf,Object),NC="[object Object]",MC=Function.prototype,LC=Object.prototype,Lh=MC.toString,DC=LC.hasOwnProperty,xC=Lh.call(Object);function UC(e){if(!Jn(e)||Vr(e)!=NC)return!1;var t=Mh(e);if(t===null)return!0;var n=DC.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Lh.call(n)==xC}function PC(){this.__data__=new zt,this.size=0}function kC(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function FC(e){return this.__data__.get(e)}function BC(e){return this.__data__.has(e)}var $C=200;function HC(e,t){var n=this.__data__;if(n instanceof zt){var r=n.__data__;if(!Ah||r.length<$C-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new ln(r)}return n.set(e,t),this.size=n.size,this}function Qn(e){var t=this.__data__=new zt(e);this.size=t.size}Qn.prototype.clear=PC;Qn.prototype.delete=kC;Qn.prototype.get=FC;Qn.prototype.has=BC;Qn.prototype.set=HC;var Dh=typeof exports=="object"&&exports&&!exports.nodeType&&exports,_l=Dh&&typeof module=="object"&&module&&!module.nodeType&&module,jC=_l&&_l.exports===Dh,pl=jC?vn.Buffer:void 0;pl&&pl.allocUnsafe;function WC(e,t){return e.slice()}var El=vn.Uint8Array;function YC(e){var t=new e.constructor(e.byteLength);return new El(t).set(new El(e)),t}function GC(e,t){var n=YC(e.buffer);return new e.constructor(n,e.byteOffset,e.length)}function VC(e){return typeof e.constructor=="function"&&!Rh(e)?WE(Mh(e)):{}}function zC(e){return function(t,n,r){for(var s=-1,i=Object(t),o=r(t),a=o.length;a--;){var l=o[++s];if(n(i[l],l,i)===!1)break}return t}}var KC=zC(),Ii=function(){return vn.Date.now()},XC="Expected a function",qC=Math.max,ZC=Math.min;function JC(e,t,n){var r,s,i,o,a,l,c=0,u=!1,h=!1,d=!0;if(typeof e!="function")throw new TypeError(XC);t=al(t)||0,Rt(n)&&(u=!!n.leading,h="maxWait"in n,i=h?qC(al(n.maxWait)||0,t):i,d="trailing"in n?!!n.trailing:d);function f(C){var w=r,T=s;return r=s=void 0,c=C,o=e.apply(T,w),o}function g(C){return c=C,a=setTimeout(b,t),u?f(C):o}function _(C){var w=C-l,T=C-c,B=t-w;return h?ZC(B,i-T):B}function R(C){var w=C-l,T=C-c;return l===void 0||w>=t||w<0||h&&T>=i}function b(){var C=Ii();if(R(C))return F(C);a=setTimeout(b,_(C))}function F(C){return a=void 0,d&&r?f(C):(r=s=void 0,o)}function k(){a!==void 0&&clearTimeout(a),c=0,r=l=s=a=void 0}function W(){return a===void 0?o:F(Ii())}function S(){var C=Ii(),w=R(C);if(r=arguments,s=this,l=C,w){if(a===void 0)return g(l);if(h)return clearTimeout(a),a=setTimeout(b,t),f(l)}return a===void 0&&(a=setTimeout(b,t)),o}return S.cancel=k,S.flush=W,S}function qi(e,t,n){(n!==void 0&&!Xs(e[t],n)||n===void 0&&!(t in e))&&ta(e,t,n)}function QC(e){return Jn(e)&&na(e)}function Zi(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}function eR(e){return r0(e,bh(e))}function tR(e,t,n,r,s,i,o){var a=Zi(e,n),l=Zi(t,n),c=o.get(l);if(c){qi(e,n,c);return}var u=i?i(a,l,n+"",e,t,o):void 0,h=u===void 0;if(h){var d=Kn(l),f=!d&&Oh(l),g=!d&&!f&&wh(l);u=l,d||f||g?Kn(a)?u=a:QC(a)?u=GE(a):f?(h=!1,u=WC(l)):g?(h=!1,u=GC(l)):u=[]:UC(l)||Xi(l)?(u=a,Xi(a)?u=eR(a):(!Rt(a)||Jo(a))&&(u=VC(l))):h=!1}h&&(o.set(l,u),s(u,l,r,i,o),o.delete(l)),qi(e,n,u)}function sa(e,t,n,r,s){e!==t&&KC(t,function(i,o){if(s||(s=new Qn),Rt(i))tR(e,t,o,n,sa,r,s);else{var a=r?r(Zi(e,o),i,o+"",e,t,s):void 0;a===void 0&&(a=i),qi(e,o,a)}},bh)}var nR=Ch(function(e,t,n,r){sa(e,t,n,r)}),ia=Ch(function(e,t,n){sa(e,t,n)});function rR(e,t,n,r){if(!Rt(e))return e;t=Th(t,e);for(var s=-1,i=t.length,o=i-1,a=e;a!=null&&++s<i;){var l=yh(t[s]),c=n;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(s!=o){var u=a[l];c=void 0,c===void 0&&(c=Rt(u)?u:ea(t[s+1])?[]:{})}ph(a,l,c),a=a[l]}return e}function sR(e,t,n){return e==null?e:rR(e,t,n)}const oa=Ae.createIdentifier("univer.config-service");class xh{constructor(){p(this,"_configChanged$",new ce.Subject);p(this,"configChanged$",this._configChanged$.asObservable());p(this,"_config",new Map)}dispose(){this._config.clear(),this._configChanged$.complete()}getConfig(t){return this._config.get(t)}setConfig(t,n,r){var o;const{merge:s=!1}=r||{};let i=(o=this._config.get(t))!=null?o:{};s?i=ia(i,n):i=n,this._config.set(t,i),this._configChanged$.next({[t]:i})}deleteConfig(t){return this._config.delete(t)}subscribeConfigValue$(t){return new ce.Observable(n=>{Object.prototype.hasOwnProperty.call(this._config,t)&&n.next(this._config.get(t));const r=this.configChanged$.pipe(ce.filter(s=>Object.prototype.hasOwnProperty.call(s,t))).subscribe(s=>n.next(s[t]));return()=>r.unsubscribe()})}}const Cr="FOCUSING_UNIT",Hn="FOCUSING_SHEET",Rr="FOCUSING_DOC",Ir="FOCUSING_SLIDE",iR="FOCUSING_EDITOR_BUT_HIDDEN",Uh="EDITOR_ACTIVATED",oR="FOCUSING_EDITOR_INPUT_FORMULA",Ph="FOCUSING_FX_BAR_EDITOR",aR="FOCUSING_UNIVER_EDITOR",lR="FOCUSING_EDITOR_INPUT_FORMULA",cR="FOCUSING_PANEL_EDITOR",uR="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",hR="FOCUSING_COMMON_DRAWINGS",dR="FORMULA_EDITOR_ACTIVATED";class kh extends Ke{constructor(){super(...arguments);p(this,"_error$",new ce.Subject);p(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(n){this._error$.next({errorKey:n})}}var aa=(e=>(e.URL="URL",e.UUID="UUID",e.BASE64="BASE64",e))(aa||{}),Fh=(e=>(e.SUCCUSS="0",e.ERROR_EXCEED_SIZE="1",e.ERROR_IMAGE_TYPE="2",e.ERROR_UPLOAD_COUNT_LIMIT="3",e.ERROR_IMAGE="4",e))(Fh||{});const Ji=Ae.createIdentifier("core.image-io.service"),fR="0.9.4",mR={version:fR};function gR(e="",t=Br.ZH_CN,n=""){return{id:e,sheetOrder:[],name:n,appVersion:mR.version,locale:t,styles:{},sheets:{},resources:[]}}class Bh{constructor(t={}){p(this,"_styles");p(this,"_cacheMap",new Tr(1e5));this._styles=t,this._generateCacheMap()}each(t){return Object.entries(this._styles).forEach(t),this}search(t,n){if(this._cacheMap.has(n))return this._cacheMap.get(n);const r=this._getExistingStyleId(t);return r||"-1"}get(t){return typeof t!="string"?t:(t=String(t),this._styles[t])}add(t,n){const r=tt(6);return this._styles[r]=t,this._cacheMap.set(n,r),r}setValue(t){if(t==null)return;const n=JSON.stringify(t),r=this.search(t,n);return r!=="-1"?r:this.add(t,n)}toJSON(){return this._styles}getStyleByCell(t){let n;t&&q.isObject(t.s)?n=t.s:n=(t==null?void 0:t.s)&&this.get(t.s);const r=t==null?void 0:t.interceptorStyle;return r?{...n,...r}:n}_generateCacheMap(){const{_styles:t,_cacheMap:n}=this;for(const r in t){const s=JSON.stringify(t[r]);n.set(s,r)}}_getExistingStyleId(t){const{_styles:n}=this;for(const r in n)if(q.diffValue(n[r],t))return r;return null}}const _R=(e,t)=>t.length===e.length&&!e.some(n=>t.some(r=>!on.equals(r,n))),pR=(e,t)=>t.length===e.length&&e.every((n,r)=>{const s=t[r];return s.unitId===n.unitId&&s.sheetId===n.sheetId&&on.equals(n.range,s.range)}),Qi={t:0,b:2,l:2,r:2},ER=e=>({sbr:.6,sbo:e,spr:.6,spo:e}),Cl=90;function Sr(e,t,n={}){const r=e.length,{textRotation:s,paddingData:i,horizontalAlign:o=Tt.UNSPECIFIED,verticalAlign:a=_n.UNSPECIFIED,wrapStrategy:l=Rn.UNSPECIFIED,cellValueType:c}=n,{t:u,r:h,b:d,l:f}=i||Qi,{vertexAngle:g,centerAngle:_}=jh(s),R={id:"d",body:{dataStream:`${e}${Nl}`,textRuns:[{ts:t,st:0,ed:r}],paragraphs:[{startIndex:r,paragraphStyle:{horizontalAlign:o}}],sectionBreaks:[{startIndex:r+1}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},marginTop:u,marginBottom:d,marginRight:h,marginLeft:f,renderConfig:{horizontalAlign:o,verticalAlign:a,centerAngle:_,vertexAngle:g,wrapStrategy:l,cellValueType:c,zeroWidthParagraphBreak:1}},drawings:{},drawingsOrder:[]};return new Nt(R)}function CR(e){if(!e)return{};const{tr:t,td:n,ht:r,vt:s,tb:i,pd:o}=e;return{textRotation:t,textDirection:n,horizontalAlign:r,verticalAlign:s,wrapStrategy:i,paddingData:o}}function Rl(e){if(!e)return{};const{ff:t,fs:n,it:r,bl:s,ul:i,st:o,ol:a,cl:l}=e,c={};return t&&(c.ff=t),n&&(c.fs=n),r&&(c.it=r),s&&(c.bl=s),i&&(c.ul=i),o&&(c.st=o),a&&(c.ol=a),l&&(c.cl=l),c}function $h(e,t,n){var i;const r=e.getBody();if((i=r.customRanges)!=null&&i.some(o=>o.rangeType===sn.HYPERLINK))return;const s=Qe.customRange.add({ranges:[{startOffset:0,endOffset:r.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:sn.HYPERLINK,body:r,properties:{url:t,refId:n}});s&&Me.apply(r,s.serialize())}function Hh(e){return e!=null}const RR='"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif';function Il(e){const t=st.ff,n=st.fs;if(!e){const h=`${n}pt ${t}`;return{fontCache:h,fontString:h,fontSize:n,originFontSize:n,fontFamily:t}}let r=$n.ITALIC;(e.it===0||e.it===void 0)&&(r=$n.NORMAL);let s=$n.BOLD;(e.bl===0||e.bl===void 0)&&(s=$n.NORMAL);let i=n;e.fs&&(i=Math.ceil(e.fs));let o=t;if(e.ff){let h=e.ff;h=h.replace(/"/g,"").replace(/'/g,""),h.indexOf(" ")>-1&&(h=`"${h}"`),h==null&&(h=t),o=h}const{va:a}=e;let l=i;if(a===Yt.SUBSCRIPT||a===Yt.SUPERSCRIPT){const h=IR(o,l),{sbr:d,spr:f}=h;l*=a===Yt.SUBSCRIPT?d:f}const c=`${r} ${s} ${l}pt ${o}`,u=`${c}, ${RR} `;return{fontCache:c,fontString:u,fontSize:l,originFontSize:i,fontFamily:o}}function IR(e,t){return ER(t)}function jh(e){const{a:t=0,v:n=ie.FALSE}=e||{a:0,v:ie.FALSE};let r=0,s=t;return n===ie.TRUE&&(r=Cl,s=Cl),{centerAngle:r,vertexAngle:s}}class SR{constructor(t,n){p(this,"_columnData",{});this._config=t,this._columnData=n}getColumnData(){return this._columnData}getColVisible(t){const{_columnData:n}=this,r=n[t];return r?r.hd!==ie.TRUE:!0}getColumnStyle(t){var n;return(n=this._columnData[t])==null?void 0:n.s}setColumnStyle(t,n){const r=this.getColumnOrCreate(t);r.s=n}getHiddenCols(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getColVisible(o);s&&a?(s=!1,r.push({rangeType:_e.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:_e.COLUMN}),r}getVisibleCols(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getColVisible(o);s&&!a?(s=!1,r.push({rangeType:_e.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:_e.COLUMN}),r}getColumnDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getColumn(i);r[s]=o!=null?o:{w:this._config.defaultColumnWidth,hd:ie.FALSE},s++}return r}getSize(){return tn(this._columnData)}getColumnWidth(t){var n,r;return(r=(n=this._columnData[t])==null?void 0:n.w)!=null?r:this._config.defaultColumnWidth}setColumnWidth(t,n){const r=this._columnData[t];n===this._config.defaultColumnWidth?r&&(delete r.w,Object.keys(r).length===0&&delete this._columnData[t]):this._columnData[t]=r?{...r,w:n}:{w:n}}getColumn(t){return this._columnData[t]}removeColumn(t){delete this._columnData[t]}getColumnOrCreate(t){const{_columnData:n}=this,r=n[t];if(r)return r;const s={};return this._columnData[t]=s,s}setCustomMetadata(t,n){const r=this.getColumn(t);r&&(r.custom=n)}getCustomMetadata(t){var n;return(n=this.getColumn(t))==null?void 0:n.custom}}const OR=2e3;class vR{constructor(t,n,r){p(this,"_rowData");this._config=t,this._viewModel=n,this._rowData=r}getRowData(){return this._rowData}getRowStyle(t){var n;return(n=this._rowData[t])==null?void 0:n.s}setRowStyle(t,n){const r=this.getRowOrCreate(t);r.s=n}getRowDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getRow(i);r[s]=o!=null?o:{h:this._config.defaultRowHeight,hd:ie.FALSE},s++}return r}getRowHeight(t,n=1){const{_rowData:r}=this,s=this._config;let i=0;for(let o=0;o<n;o++){const a=r[o+t]||{hd:ie.FALSE,h:s.defaultRowHeight},{ia:l,ah:c,h:u=s.defaultRowHeight}=a;i+=(l==null||l===ie.TRUE)&&typeof c=="number"?c:u}return i}setRowHeight(t,n){const r=this._rowData[t];if(n===this._config.defaultRowHeight)r&&(delete r.h,Object.keys(r).length===0&&delete this._rowData[t]);else{const s=Math.min(n,OR);this._rowData[t]=r?{...r,h:s}:{h:s}}}getRow(t){return this._rowData[t]}removeRow(t){delete this._rowData[t]}getRowOrCreate(t){const{_rowData:n}=this,r=n[t];if(r)return r;const s={};return n[t]=s,s}getHiddenRows(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getRowRawVisible(o);s&&a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:_e.ROW})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:_e.ROW}),r}getVisibleRows(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getRowRawVisible(o);s&&!a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:_e.ROW})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:_e.ROW}),r}getRowRawVisible(t){const n=this.getRow(t);return n?n.hd!==ie.TRUE:!0}getSize(){return tn(this._rowData)}setCustomMetadata(t,n){const r=this.getRow(t);r&&(r.custom=n)}getCustomMetadata(t){var n;return(n=this.getRow(t))==null?void 0:n.custom}}const wR="DEFAULT_WORKSHEET_ROW_COUNT",Wh=1e3,bR="DEFAULT_WORKSHEET_COLUMN_COUNT",Yh=20,AR="DEFAULT_WORKSHEET_ROW_HEIGHT",Gh=24,TR="DEFAULT_WORKSHEET_COLUMN_WIDTH",Vh=88,yR="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",zh=46,NR="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Kh=20;function Xh(e){const t={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:ie.FALSE,rowCount:Wh,columnCount:Yh,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:Vh,defaultRowHeight:Gh,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:ie.TRUE,rowHeader:{width:zh,hidden:ie.FALSE},columnHeader:{height:Kh,hidden:ie.FALSE},rightToLeft:ie.FALSE};return Object.keys(t).forEach(n=>{const r=n;typeof e[r]>"u"&&(e[r]=t[r])}),e}class MR extends Ke{constructor(n){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");p(this,"_rangeMap",new Tr(5e4));p(this,"_skeletonCache",new Tr(5e4));this._init(n.concat())}_init(n){this._mergeData=n,this._createCache(n)}_clearCache(){this._cellCache.clear(),this._rowCache.clear(),this._columnCache.clear(),this._hasAll=!1,this._allIndex=-1,this._rangeMap.clear(),this._skeletonCache.clear(),this._hasColumn=!1,this._hasRow=!1}_createCache(n){let r=0;for(const s of n){const{rangeType:i}=s;i===_e.ROW?this._createRowCache(s,r):i===_e.COLUMN?this._createColumnCache(s,r):i===_e.ALL?this._createCellAllCache(r):this._createCellCache(s,r),r++}}rebuild(n){this._clearCache(),this._init(n.concat())}_createRowCache(n,r){const{startRow:s,endRow:i}=n;for(let o=s;o<=i;o++)this._rowCache.set(o,r),this._hasRow=!0}_createColumnCache(n,r){const{startColumn:s,endColumn:i}=n;for(let o=s;o<=i;o++)this._columnCache.set(o,r),this._hasColumn=!0}_createCellAllCache(n){this._hasAll=!0,this._allIndex=n}_createCellCache(n,r){for(let s=n.startRow;s<=n.endRow;s++){let i=this._cellCache.get(s);i==null&&(i=new Map,this._cellCache.set(s,i));for(let o=n.startColumn;o<=n.endColumn;o++)i.set(o,r)}}add(n){this._mergeData.push(n),this._clearCache(),this._createCache(this._mergeData)}remove(n,r){const s=this._getMergeDataIndex(n,r);s!==-1&&(this._mergeData.splice(s,1),this._clearCache(),this._createCache(this._mergeData))}getMergedCell(n,r){const s=this._getMergeDataIndex(n,r);return s!==-1?this._mergeData[s]:null}getMergeDataIndex(n,r){return this._getMergeDataIndex(n,r)}isRowContainsMergedCell(n){return this._hasAll||!q.isEmptyObject(this._columnCache)?!0:this._mergeData.some(r=>r.startRow<=n&&n<=r.endRow)}isColumnContainsMergedCell(n){return this._hasAll||!q.isEmptyObject(this._rowCache)?!0:this._mergeData.some(r=>r.startColumn<=n&&n<=r.endColumn)}getMergedCellRange(n,r,s,i){const o=[],a=`${n}-${r}-${s}-${i}`;if(this._rangeMap.has(a))return this._getRangeFromCache(a);let l=0;const c=[];for(const u of this._mergeData||[])on.intersects(u,{startRow:n,endRow:s,startColumn:r,endColumn:i})&&(o.push({...u}),c.push(l)),l++;return this._rangeMap.set(a,c),o}getMergedCellRangeForSkeleton(n,r,s,i){const o=[],a=this._mergeData,l=`${n}-${r}-${s}-${i}`;if(this._skeletonCache.has(l))return this._getSkeletonRangeFromCache(l);const c=[];for(let u=0;u<a.length;u++){const{startRow:h,endRow:d,startColumn:f,endColumn:g}=a[u];for(let _=n;_<=s;_++){let R=!1;for(let b=r;b<=i;b++)if(_>=h&&_<=d&&b>=f&&b<=g){o.push({startRow:h,endRow:d,startColumn:f,endColumn:g}),c.push(u),R=!0;break}if(R)break}}return this._skeletonCache.set(l,c),o}_getRangeFromCache(n){const r=this._rangeMap.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getSkeletonRangeFromCache(n){const r=this._skeletonCache.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getMergeDataIndex(n,r){var i;if(this._hasAll)return this._allIndex;if(this._hasRow){const o=this._rowCache.get(n);if(o!==void 0)return o}if(this._hasColumn){const o=this._columnCache.get(r);if(o!==void 0)return o}const s=(i=this._cellCache.get(n))==null?void 0:i.get(r);return s!==void 0?s:-1}getMergeDataSnapshot(){return this._mergeData}dispose(){this._clearCache(),this._mergeData=[]}}class qh extends Ke{constructor(n){super();p(this,"_cellContentInterceptor",null);p(this,"_rowFilteredInterceptor",null);this.getRawCell=n}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(n,r,s,i){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,Pn.Value|Pn.Style,s,i):this.getRawCell(n,r)}getCellValueOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,Pn.Value):this.getRawCell(n,r)}getCellStyleOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,Pn.Style):this.getRawCell(n,r)}getRowFiltered(n){var r,s;return(s=(r=this._rowFilteredInterceptor)==null?void 0:r.getRowFiltered(n))!=null?s:!1}registerCellContentInterceptor(n){if(this._cellContentInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptor=n,We(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(n){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=n,We(()=>this._rowFilteredInterceptor=null)}}const Sl={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};class xr{constructor(t,n,r){p(this,"_sheetId");p(this,"_snapshot");p(this,"_cellData");p(this,"_rowManager");p(this,"_columnManager");p(this,"_viewModel");p(this,"_spanModel");p(this,"_isRowStylePrecedeColumnStyle",!0);p(this,"_getCellHeight");var a;this.unitId=t,this._styles=r,this._snapshot=Xh(n);const{columnData:s,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:tt(6),this._cellData=new dt(o),this._viewModel=new qh((l,c)=>this.getCellRaw(l,c)),this._rowManager=new vR(this._snapshot,this._viewModel,i),this._columnManager=new SR(this._snapshot,s),this._spanModel=new MR(this._snapshot.mergeData)}__interceptViewModel(t){t(this._viewModel)}__registerGetCellHeight(t){return this._getCellHeight=t,We(()=>{this._getCellHeight=null})}getSnapshot(){return this._snapshot}getCellHeight(t,n){return this._getCellHeight?this._getCellHeight(t,n):this._snapshot.defaultRowHeight}setMergeData(t){this._snapshot.mergeData=t,this.getSpanModel().rebuild(t)}getSpanModel(){return this._spanModel}setIsRowStylePrecedeColumnStyle(t){this._isRowStylePrecedeColumnStyle=t}getStyleDataByHash(t){return{...this._styles.get(t)}}setStyleData(t){return this._styles.setValue(t)}getColumnStyle(t,n=!1){return n?this._columnManager.getColumnStyle(t):this._styles.get(this._columnManager.getColumnStyle(t))}setColumnStyle(t,n){this._columnManager.setColumnStyle(t,n)}getRowStyle(t,n=!1){return n?this._rowManager.getRowStyle(t):this._styles.get(this._rowManager.getRowStyle(t))}setRowStyle(t,n){this._rowManager.setRowStyle(t,n)}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){const t=this._snapshot.defaultStyle;return this._styles.get(t)}setDefaultCellStyle(t){this._snapshot.defaultStyle=t}getCellStyle(t,n){const r=this.getCell(t,n);if(r){const s=r.s;return typeof s=="string"?this._styles.get(s):s}return null}getComposedCellStyle(t,n,r){const s=this.getDefaultCellStyleInternal(),i=this.getRowStyle(t),o=this.getColumnStyle(n),a=this.getCell(t,n),l=this._styles.getStyleByCell(a);return(r!=null?r:this._isRowStylePrecedeColumnStyle)?cr(s,o,i,a==null?void 0:a.themeStyle,l):cr(s,i,o,a==null?void 0:a.themeStyle,l)}getComposedCellStyleByCellData(t,n,r,s){const i=this.getDefaultCellStyleInternal(),o=this.getRowStyle(t),a=this.getColumnStyle(n),l=this._styles.getStyleByCell(r);return(s!=null?s:this._isRowStylePrecedeColumnStyle)?cr(i,a,o,r==null?void 0:r.themeStyle,l):cr(i,o,a,r==null?void 0:r.themeStyle,l)}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const t=this.getCellMatrix(),n=this.getMergeData();let r=-1,s=-1,i=-1,o=-1,a=!1,l=!1;return t.forEach((c,u)=>{Object.keys(u).forEach(h=>{const d=+h,f=t.getValue(c,d),g=f!=null&&f.s?this._styles.get(f.s):null,_=(g==null?void 0:g.bd)&&(g.bd.b||g.bd.l||g.bd.r||g.bd.t||g.bd.bc_tr||g.bd.bl_tr||g.bd.ml_tr||g.bd.tl_bc||g.bd.tl_br||g.bd.tl_mr);(f&&(f.v||f.p)||g!=null&&g.bg||_)&&(a?r=Math.min(r,c):(r=c,a=!0),s=Math.max(s,c),l?i=Math.min(i,d):(l=!0,i=d),o=Math.max(o,d))})}),n.forEach(c=>{a?r=Math.min(r,c.startRow):(r=c.startRow,a=!0),s=Math.max(s,c.endRow),l?i=Math.min(i,c.startColumn):(i=c.startColumn,a=!0),o=Math.max(o,c.endColumn)}),!a||!l?null:{startColumn:i,startRow:r,endColumn:o,endRow:s}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:t}=this,n=q.deepClone(t);return new xr(this.unitId,n,this._styles)}getMergeData(){return this._spanModel.getMergeDataSnapshot()}getMergedCell(t,n){return this._spanModel.getMergedCell(t,n)}getMergedCellRange(t,n,r,s){return this._spanModel.getMergedCellRange(t,n,r,s)}isRowContainsMergedCell(t){return this._spanModel.isRowContainsMergedCell(t)}isColumnContainsMergedCell(t){return this._spanModel.isColumnContainsMergedCell(t)}getCellInfoInMergeData(t,n){const r=this.getMergedCell(t,n);let s=!1,i=!1,o=t,a=n,l=t,c=n;if(r){const{startRow:u,endRow:h,startColumn:d,endColumn:f}=r;t===u&&n===d?(o=h,a=f,l=u,c=d,i=!0):t>=u&&t<=h&&n>=d&&n<=f&&(o=h,a=f,l=u,c=d,s=!0)}return{actualRow:t,actualColumn:n,isMergedMainCell:i,isMerged:s,endRow:o,endColumn:a,startRow:l,startColumn:c}}getCell(t,n){return t<0||n<0?null:this._viewModel.getCell(t,n)}getCellValueOnly(t,n){return t<0||n<0?null:this._viewModel.getCellValueOnly(t,n)}getCellStyleOnly(t,n){return t<0||n<0?null:this._viewModel.getCellStyleOnly(t,n)}getCellRaw(t,n){return this.getCellMatrix().getValue(t,n)}getCellWithFilteredInterceptors(t,n,r,s){return this._viewModel.getCell(t,n,r,s)}getRowFiltered(t){return this._viewModel.getRowFiltered(t)}getRangeFilterRows(t){const n=[];for(let r=t.startRow;r<=t.endRow;r++)this.getRowFiltered(r)&&n.push(r);return n}getMatrixWithMergedCells(t,n,r,s,i=kn.Raw){const o=this.getCellMatrix(),a=this._spanModel.getMergedCellRange(t,n,r,s),l=new dt;return $i(t,r,n,s).forEach((c,u)=>{var d;let h;if(i===kn.Raw)h=this.getCellRaw(c,u);else if(i===kn.Intercepted)h=this.getCell(c,u);else if(i===kn.Both){const f=this.getCellRaw(c,u);if(f){h={...f};const g=(d=this.getCell(c,u))==null?void 0:d.v;Hh(g)&&h&&(h.displayV=String(g))}}h&&l.setValue(c,u,h)}),a.forEach(c=>{const{startColumn:u,startRow:h,endColumn:d,endRow:f}=c;$i(h,f,u,d).forEach((g,_)=>{g===h&&_===u&&l.setValue(g,_,{...o.getValue(g,_),rowSpan:f-h+1,colSpan:d-u+1}),(g!==h||_!==u)&&l.realDeleteValue(g,_)})}),l}getRange(t,n,r,s){return typeof t=="object"?new Vn(this,t,{getStyles:()=>this._styles}):new Vn(this,{startRow:t,startColumn:n,endColumn:s||n,endRow:r||t},{getStyles:()=>this._styles})}getScrollLeftTopFromSnapshot(){return{scrollLeft:this._snapshot.scrollLeft,scrollTop:this._snapshot.scrollTop}}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){const{_snapshot:t}=this,{columnCount:n}=t;return n}getMaxRows(){const{_snapshot:t}=this,{rowCount:n}=t;return n}getRowCount(){return this._snapshot.rowCount}setRowCount(t){this._snapshot.rowCount=t}getColumnCount(){return this._snapshot.columnCount}setColumnCount(t){this._snapshot.columnCount=t}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:t}=this,{showGridlines:n}=t;return n===0}getGridlinesColor(){return this.getConfig().gridlinesColor}getTabColor(){const{_snapshot:t}=this,{tabColor:n}=t;return n}getColumnWidth(t){return this.getColumnManager().getColumnWidth(t)}getRowHeight(t){return this._viewModel.getRowFiltered(t)?0:this.getRowManager().getRowHeight(t)}isRowFiltered(t){return this._viewModel.getRowFiltered(t)}getRowVisible(t){return!this.isRowFiltered(t)&&this.getRowRawVisible(t)}getRowRawVisible(t){return this.getRowManager().getRowRawVisible(t)}getHiddenRows(t,n){const r=this.getMaxColumns()-1,s=this._rowManager.getHiddenRows(t,n);return s.forEach(i=>i.endColumn=r),s}getColVisible(t){return this._columnManager.getColVisible(t)}getHiddenCols(t,n){const r=this.getMaxRows()-1,s=this._columnManager.getHiddenCols(t,n);return s.forEach(i=>i.endRow=r),s}getVisibleRows(){const t=this.getRowCount();return this._rowManager.getVisibleRows(0,t-1)}getVisibleCols(){const t=this.getColumnCount();return this._columnManager.getVisibleCols(0,t-1)}isRightToLeft(){const{_snapshot:t}=this,{rightToLeft:n}=t;return n}getLastRowWithContent(){return this._cellData.getLength()-1}getLastColumnWithContent(){return this._cellData.getRange().endColumn}getDataRangeScope(){return this._cellData.getStartEndScope()}cellHasValue(t){return t&&(t.v!==void 0||t.f!==void 0||t.p!==void 0)}iterateByRow(t,n=!0){const{startRow:r,startColumn:s,endRow:i,endColumn:o}=t,a=this;return{[Symbol.iterator]:()=>{let l=r,c=s;return{next(){for(;;){if(c>o&&(l+=1,c=s),l>i)return{done:!0,value:void 0};const u=a.getCell(l,c),h=!u,d=a.getMergedCell(l,c);if(d){if(l!==d.startRow||c!==d.startColumn){c=d.endColumn+1;continue}if(h&&n){c=d.endColumn+1;continue}const g={row:l,col:c,value:u};return g.colSpan=d.endColumn-d.startColumn+1,g.rowSpan=d.endRow-d.startRow+1,c=d.endColumn+1,{done:!1,value:g}}if(h&&n)c+=1;else{const f={row:l,col:c,value:u};return c+=1,{done:!1,value:f}}}}}}}}iterateByColumn(t,n=!0,r=!0){const{startRow:s,startColumn:i,endRow:o,endColumn:a}=t,l=this;return{[Symbol.iterator]:()=>{let c=s,u=i;return{next(){for(;;){if(c>o&&(u+=1,c=s),u>a)return{done:!0,value:void 0};const h=l.getMergedCell(c,u);if(h){const g=c!==h.startRow,_=g||u!==h.startColumn;if(r&&_||!r&&g){c=h.endRow+1;continue}const R=l.getCell(h.startRow,h.startColumn);if(!R&&n){c=h.endRow+1;continue}const F={row:c,col:h.startColumn,value:R};return F.colSpan=h.endColumn-h.startColumn+1,F.rowSpan=h.endRow-h.startRow+1,c=h.endRow+1,{done:!1,value:F}}const d=l.getCell(c,u);if(!d&&n)c+=1;else{const g={row:c,col:u,value:d};return c+=1,{done:!1,value:g}}}}}}}}getCellDocumentModel(t,n,r=Sl){var _;if(!t)return;const{isDeepClone:s,displayRawFormula:i,ignoreTextRotation:o}={...Sl,...r};let a,l="document";const c=CR(n),u=o?st.tr:c.textRotation||st.tr;let h=c.horizontalAlign||st.ht;const d=c.verticalAlign||st.vt,f=c.wrapStrategy||st.tb,g=c.paddingData||Qi;if(t.f&&i)a=Sr(t.f.toString(),{},{verticalAlign:d}),h=st.ht;else if(t.p){const{centerAngle:R,vertexAngle:b}=jh(u);a=this._updateConfigAndGetDocumentModel(s?q.deepClone(t.p):t.p,h,g,{horizontalAlign:h,verticalAlign:d,centerAngle:R,vertexAngle:b,wrapStrategy:f,zeroWidthParagraphBreak:1})}else if(t.v!=null){const R=Rl(n);l=Il(R).fontCache;let b=Zh(t);t.t===en.FORCE_STRING&&i&&(b=`'${b}`),a=Sr(b,R,{...c,textRotation:u,cellValueType:t.t})}return a&&t.linkUrl&&t.linkId&&$h(a,t.linkUrl,t.linkId),{documentModel:a,fontString:l,textRotation:u,wrapStrategy:f,verticalAlign:d,horizontalAlign:h,paddingData:g,fill:(_=n==null?void 0:n.bg)==null?void 0:_.rgb}}_updateConfigAndGetDocumentModel(t,n,r,s){var o,a,l,c,u;if(!s||!((o=t.body)!=null&&o.dataStream))return;t.documentStyle||(t.documentStyle={}),t.documentStyle.marginTop=(a=r.t)!=null?a:0,t.documentStyle.marginBottom=(l=r.b)!=null?l:2,t.documentStyle.marginLeft=(c=r.l)!=null?c:2,t.documentStyle.marginRight=(u=r.r)!=null?u:2,t.documentStyle.pageSize={width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},t.documentStyle.renderConfig={...t.documentStyle.renderConfig,...s};const i=t.body.paragraphs||[];for(const h of i)h.paragraphStyle||(h.paragraphStyle={}),h.paragraphStyle.horizontalAlign=n;return new Nt(t)}getBlankCellDocumentModel(t,n,r){const s=this.getComposedCellStyleByCellData(n,r,t),i=Rl(s),o=this.getCellDocumentModel(t,s,{ignoreTextRotation:!0});if(o!=null)return o.documentModel==null&&(o.documentModel=Sr("",i)),o;const a="";let l="document";const c=st.tr,u=st.ht,h=st.vt,d=st.tb,f=Qi;return l=Il({}).fontCache,{documentModel:Sr(a,i),fontString:l,textRotation:c,wrapStrategy:d,verticalAlign:h,horizontalAlign:u,paddingData:f}}getCellDocumentModelWithFormula(t,n,r){const s=this.getComposedCellStyleByCellData(n,r,t);return this.getCellDocumentModel(t,s,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(t){this._snapshot.custom=t}}function Zh(e){var r,s;if(!e)return"";const t=(s=(r=e.p)==null?void 0:r.body)==null?void 0:s.dataStream;if(t)return Qe.transform.getPlainText(t);const n=e.v;return typeof n=="string"?e.t===en.BOOLEAN?n.toUpperCase():n.replace(/[\r\n]/g,""):typeof n=="number"?e.t===en.BOOLEAN?n?"TRUE":"FALSE":n.toString():typeof n=="boolean"?n?"TRUE":"FALSE":""}function LR(e){if(e===null)return"";if(e!=null&&e.p){const t=e==null?void 0:e.p.body;if(t==null)return"";const n=t.dataStream;return Qe.transform.getPlainText(n)}return e==null?void 0:e.v}var DR=Object.getOwnPropertyDescriptor,xR=(e,t,n,r)=>{for(var s=r>1?void 0:r?DR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},UR=(e,t)=>(n,r)=>t(n,r,e);function PR(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}exports.Workbook=class extends Gs{constructor(n={},r){super();p(this,"type",ve.UNIVER_SHEET);p(this,"_sheetCreated$",new ce.Subject);p(this,"sheetCreated$",this._sheetCreated$.asObservable());p(this,"_sheetDisposed$",new ce.Subject);p(this,"sheetDisposed$",this._sheetDisposed$.asObservable());p(this,"_activeSheet$",new ce.BehaviorSubject(null));p(this,"activeSheet$",this._activeSheet$.asObservable());p(this,"_worksheets");p(this,"_styles");p(this,"_snapshot");p(this,"_unitId");p(this,"_count");p(this,"_name$");p(this,"name$");this._logService=r;const s=gR();q.isEmptyObject(n)?this._snapshot=s:this._snapshot=q.commonExtend(s,n);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=tt(6)),this._unitId=this._snapshot.id,this._styles=new Bh(i),this._count=1,this._worksheets=new Map,this._name$=new ce.BehaviorSubject(n.name||""),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}static isIRangeType(n){return typeof n=="string"||"startRow"in n||"row"in n}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete()}save(){return q.deepClone(this._snapshot)}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(n){this._name$.next(n),this._snapshot.name=n}getUnitId(){return this._unitId}getRev(){var n;return(n=this._snapshot.rev)!=null?n:1}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(n){this._snapshot.rev=n}addWorksheet(n,r,s){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[n])return!1;i[n]=s,o.splice(r,0,n);const a=new xr(this._unitId,s,this._styles);return this._worksheets.set(n,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}getConfig(){return this._snapshot}getIndexBySheetId(n){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>s===n)}getActiveSheet(n){if(!this._activeSheet&&typeof n>"u")throw new Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){const n=this._activeSheet;if(n)return n;const r=this._snapshot.sheetOrder;for(let i=0,o=r.length;i<o;i++){const a=this._worksheets.get(r[i]);if(a&&a.isSheetHidden()!==ie.TRUE)return this.setActiveSheet(a),a}const s=this._worksheets.get(r[0]);return this.setActiveSheet(s),s}setActiveSheet(n){this._activeSheet$.next(n)}removeSheet(n){const r=this._worksheets.get(n);return r?(this._worksheets.delete(n),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(n),1),delete this._snapshot.sheets[n],this._sheetDisposed$.next(r),!0):!1}getActiveSheetIndex(){const{sheetOrder:n}=this._snapshot;return n.findIndex(r=>this._worksheets.get(r)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:n}=this._snapshot;return n.map(r=>this._worksheets.get(r))}getSheetsName(){const{sheetOrder:n}=this._snapshot,r=[];return n.forEach(s=>{const i=this._worksheets.get(s);i&&r.push(i.getName())}),r}getSheetIndex(n){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>n.getSheetId()===s)}getSheetBySheetName(n){const{sheetOrder:r}=this._snapshot,s=r.find(i=>this._worksheets.get(i).getName()===n);return this._worksheets.get(s)}getSheetBySheetId(n){return this._worksheets.get(n)}getSheetByIndex(n){const{sheetOrder:r}=this._snapshot;return this._worksheets.get(r[n])}getHiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden===ie.TRUE).map(n=>n.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden!==ie.TRUE).map(n=>n.getConfig().id)}load(n){this._snapshot=n}checkSheetName(n){return this.getSheetsName().includes(n)}uniqueSheetName(n="Sheet1"){let r=n;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}generateNewSheetName(n){let r=n+this._count;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}_parseWorksheetSnapshots(){const{_snapshot:n,_worksheets:r}=this,{sheets:s,sheetOrder:i}=n;if(q.isEmptyObject(s)){const o=tt();s[o]={id:o}}for(const o in s){const a=s[o],{name:l}=a;a.name=this.uniqueSheetName(l),a.name!==l&&this._logService.debug("[Workbook]",`The worksheet name ${l} is duplicated, we changed it to ${a.name}. Please fix the problem in your snapshot.`);const c=new xr(this._unitId,a,this._styles);r.set(o,c),i.includes(o)||i.push(o)}this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(n){this._snapshot.custom=n}};exports.Workbook=xR([UR(1,Et)],exports.Workbook);class la extends Gs{constructor(n){var r;super();p(this,"type",ve.UNIVER_SLIDE);p(this,"_activePage$",new ce.BehaviorSubject(null));p(this,"activePage$",this._activePage$.asObservable());p(this,"_name$");p(this,"name$");p(this,"_snapshot");p(this,"_unitId");this._snapshot={...Mu,...n},this._unitId=(r=this._snapshot.id)!=null?r:tt(6),this._name$=new ce.BehaviorSubject(this._snapshot.title),this.name$=this._name$.asObservable()}get _activePage(){var r,s;const n=this._activePage$.getValue();if(!n){const i=(r=this.getPageOrder())==null?void 0:r[0];return i?(s=this.getPages())==null?void 0:s[i]:null}return n}setName(n){var r;this._snapshot.title=n,this._name$.next(n),this._unitId=(r=this._snapshot.id)!=null?r:tt(6)}getRev(){return 0}incrementRev(){}setRev(n){}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var n;return(n=this._snapshot.body)==null?void 0:n.pages}getPageOrder(){var n;return(n=this._snapshot.body)==null?void 0:n.pageOrder}getPage(n){const r=this.getPages();return r==null?void 0:r[n]}getElementsByPage(n){var r;return(r=this.getPage(n))==null?void 0:r.pageElements}getElement(n,r){var s;return(s=this.getElementsByPage(n))==null?void 0:s[r]}getPageSize(){return this._snapshot.pageSize}getBlankPage(){const n=tt(6);return{id:n,pageType:Yo.SLIDE,zIndex:10,title:n,description:"",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}setActivePage(n){this._activePage$.next(n)}getActivePage(){return this._activePage}updatePage(n,r){this._snapshot.body&&(this._snapshot.body.pages[n]=r)}appendPage(n){var i;if(!this._snapshot.body)return;this._snapshot.body.pages[n.id]=n;const r=this._activePage,s=this._snapshot.body.pageOrder.indexOf((i=r==null?void 0:r.id)!=null?i:"");this._snapshot.body.pageOrder.splice(s+1,0,n.id)}}var kR=Object.getOwnPropertyDescriptor,FR=(e,t,n,r)=>{for(var s=r>1?void 0:r?kR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Ol=(e,t)=>(n,r)=>t(n,r,e);const Xn=Ae.createIdentifier("univer.current");exports.UniverInstanceService=class extends Ke{constructor(n,r){super();p(this,"_unitsByType",new Map);p(this,"_createHandler");p(this,"_ctorByType",new Map);p(this,"_currentUnits",new Map);p(this,"_currentUnits$",new ce.BehaviorSubject(this._currentUnits));p(this,"currentUnits$",this._currentUnits$.asObservable());p(this,"_unitAdded$",new ce.Subject);p(this,"unitAdded$",this._unitAdded$.asObservable());p(this,"_unitDisposed$",new ce.Subject);p(this,"unitDisposed$",this._unitDisposed$.asObservable());p(this,"_focused$",new ce.BehaviorSubject(null));p(this,"focused$",this._focused$.asObservable());this._injector=n,this._contextService=r}dispose(){super.dispose(),this._focused$.complete()}__setCreateHandler(n){this._createHandler=n}createUnit(n,r,s){return this._createHandler(n,r,this._ctorByType.get(n),s)}registerCtorForType(n,r){return this._ctorByType.set(n,r),{dispose:()=>{this._ctorByType.delete(n)}}}getCurrentTypeOfUnit$(n){return this.currentUnits$.pipe(ce.map(r=>{var s;return(s=r.get(n))!=null?s:null}),ce.distinctUntilChanged())}getCurrentUnitForType(n){return this._currentUnits.get(n)}getCurrentUnitOfType(n){return this.getCurrentUnitForType(n)}setCurrentUnitForType(n){const r=this._getUnitById(n);if(!r)throw new Error(`[UniverInstanceService]: no document with unitId ${n}!`);this._currentUnits.set(r[1],r[0]),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(n){return this._unitAdded$.pipe(ce.filter(r=>r.type===n))}__addUnit(n,r){var a;const s=n.type;this._unitsByType.has(s)||this._unitsByType.set(s,[]);const i=this._unitsByType.get(s),o=n.getUnitId();if(i.findIndex(l=>l.getUnitId()===o)!==-1)throw new Error(`[UniverInstanceService]: cannot create a unit with the same unit id: ${o}.`);i.push(n),this._unitAdded$.next(n),((a=r==null?void 0:r.makeCurrent)==null||a)&&this.setCurrentUnitForType(n.getUnitId())}getTypeOfUnitDisposed$(n){return this.unitDisposed$.pipe(ce.filter(r=>r.type===n))}getUnit(n,r){var i;const s=(i=this._getUnitById(n))==null?void 0:i[0];return r&&(s==null?void 0:s.type)!==r?null:s}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(ve.UNIVER_DOC)}getUniverDocInstance(n){return this.getUnit(n,ve.UNIVER_DOC)}getUniverSheetInstance(n){return this.getUnit(n,ve.UNIVER_SHEET)}getAllUnitsForType(n){var r;return(r=this._unitsByType.get(n))!=null?r:[]}changeDoc(n,r){const s=this.getAllUnitsForType(ve.UNIVER_DOC),i=s.find(o=>o.getUnitId()===n);if(i!=null){const o=s.indexOf(i);s.splice(o,1)}this.__addUnit(r)}get focused(){var r;const n=this._focused$.getValue();return n?(r=this._getUnitById(n))==null?void 0:r[0]:null}focusUnit(n){this._focused$.next(n),this.focused instanceof exports.Workbook?(this._contextService.setContextValue(Cr,!0),this._contextService.setContextValue(Rr,!1),this._contextService.setContextValue(Hn,!0),this._contextService.setContextValue(Ir,!1),this.setCurrentUnitForType(n)):this.focused instanceof Nt?(this._contextService.setContextValue(Cr,!0),this._contextService.setContextValue(Rr,!0),this._contextService.setContextValue(Hn,!1),this._contextService.setContextValue(Ir,!1),this.setCurrentUnitForType(n)):this.focused instanceof la?(this._contextService.setContextValue(Cr,!0),this._contextService.setContextValue(Rr,!1),this._contextService.setContextValue(Hn,!1),this._contextService.setContextValue(Ir,!0),this.setCurrentUnitForType(n)):(this._contextService.setContextValue(Cr,!1),this._contextService.setContextValue(Rr,!1),this._contextService.setContextValue(Hn,!1),this._contextService.setContextValue(Ir,!1))}getFocusedUnit(){return this.focused}getUnitType(n){const r=this._getUnitById(n);return r?r[1]:ve.UNRECOGNIZED}disposeUnit(n){const r=this._getUnitById(n);if(!r)return!1;const[s,i]=r,o=this._unitsByType.get(i),a=o.indexOf(s);return o.splice(a,1),this._tryResetCurrentOnRemoval(n,i),this._tryResetFocusOnRemoval(n),this._unitDisposed$.next(s),!0}_tryResetCurrentOnRemoval(n,r){const s=this.getCurrentUnitForType(r);(s==null?void 0:s.getUnitId())===n&&(this._currentUnits.set(r,null),this._currentUnits$.next(this._currentUnits))}_tryResetFocusOnRemoval(n){var r;((r=this.focused)==null?void 0:r.getUnitId())===n&&this._focused$.next(null)}_getUnitById(n){for(const[r,s]of this._unitsByType){const i=s.find(o=>o.getUnitId()===n);if(i)return[i,r]}}};exports.UniverInstanceService=FR([Ol(0,Ae.Inject(Ae.Injector)),Ol(1,qn)],exports.UniverInstanceService);var Ue=(e=>(e[e.Starting=0]="Starting",e[e.Ready=1]="Ready",e[e.Rendered=2]="Rendered",e[e.Steady=3]="Steady",e))(Ue||{});const Jh={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"};var BR=Object.getOwnPropertyDescriptor,$R=(e,t,n,r)=>{for(var s=r>1?void 0:r?BR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},HR=(e,t)=>(n,r)=>t(n,r,e);class Qh extends Error{constructor(t){super(`[LifecycleService]: lifecycle stage "${Jh[t]}" will never be reached!`),this.name="LifecycleUnreachableError"}}exports.LifecycleService=class extends Ke{constructor(n){super();p(this,"_lifecycle$",new ce.BehaviorSubject(Ue.Starting));p(this,"lifecycle$",this._lifecycle$.asObservable());p(this,"_lock",!1);this._logService=n,this._reportProgress(Ue.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(n){if(this._lock)throw new Error("[LifecycleService]: cannot set new stage when related logic is all handled!");if(n<this.stage)throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");n!==this.stage&&(this._lock=!0,this._reportProgress(n),this._lifecycle$.next(n),this._lock=!1)}dispose(){this._lifecycle$.complete(),super.dispose()}onStage(n){return ce.firstValueFrom(this.lifecycle$.pipe(ce.filter(r=>r>=n),bi(r=>r===n),ce.map(()=>{}))).catch(r=>r.name==="EmptyError"?Promise.reject(new Qh(n)):Promise.reject(r))}subscribeWithPrevious(){return ce.merge(ed(this.stage),this._lifecycle$.pipe(ce.skip(1))).pipe(bi(n=>n===Ue.Steady))}_reportProgress(n){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${Jh[n]}".`)}};exports.LifecycleService=$R([HR(0,Et)],exports.LifecycleService);function ed(e){switch(e){case Ue.Starting:return ce.of(Ue.Starting);case Ue.Ready:return ce.of(Ue.Starting,Ue.Ready);case Ue.Rendered:return ce.of(Ue.Starting,Ue.Ready,Ue.Rendered);default:return ce.of(Ue.Starting,Ue.Ready,Ue.Rendered,Ue.Steady)}}const jR=Ae.createIdentifier("ILocalStorageService");class Cn extends Ke{constructor(){super();p(this,"_currentLocale$",new ce.BehaviorSubject(Br.ZH_CN));p(this,"currentLocale$",this._currentLocale$.asObservable());p(this,"_locales",null);p(this,"localeChanged$",new ce.Subject);p(this,"t",(n,...r)=>{if(!this._locales)throw new Error("[LocaleService]: Locale not initialized");const s=n.split("."),i=this.resolveKeyPath(this._locales[this._currentLocale],s);if(typeof i=="string"){let o=i;return r.forEach((a,l)=>{o=o.replace(`{${l}}`,a)}),o}else return n});this.disposeWithMe(We(()=>{this._locales=null,this._currentLocale$.complete(),this.localeChanged$.complete()}))}get _currentLocale(){return this._currentLocale$.value}load(n){var r;this._locales=ia((r=this._locales)!=null?r:{},n)}setLocale(n){this._currentLocale$.next(n),this.localeChanged$.next()}getLocales(){var n;return(n=this._locales)==null?void 0:n[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(n,r){const s=r.shift();if(s&&n&&s in n){const i=n[s];return r.length>0&&(typeof i=="object"||Array.isArray(i))?this.resolveKeyPath(i,r):i}return null}}var WR=Object.getOwnPropertyDescriptor,YR=(e,t,n,r)=>{for(var s=r>1?void 0:r?WR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},GR=(e,t)=>(n,r)=>t(n,r,e);exports.MentionIOLocalService=class{constructor(t){this._userManagerService=t}async list(t){return{list:[{type:vs.PERSON,mentions:[{objectType:vs.PERSON,objectId:this._userManagerService.getCurrentUser().userID,label:this._userManagerService.getCurrentUser().name,metadata:{icon:this._userManagerService.getCurrentUser().avatar}}],metadata:{},title:"PEOPLE"}],page:t.page,size:t.size,total:1}}};exports.MentionIOLocalService=YR([GR(0,Ae.Inject(Lr))],exports.MentionIOLocalService);const td=Ae.createIdentifier("univer.service.mention-io");var ca=(e=>(e.INIT="init",e.FETCHING="fetching",e.DONE="done",e))(ca||{});const nd=Ae.createIdentifier("univer.permission-service");class rd extends Ke{constructor(){super(...arguments);p(this,"_permissionPointMap",new Map);p(this,"_permissionPointUpdate$",new ce.Subject);p(this,"permissionPointUpdate$",this._permissionPointUpdate$.asObservable());p(this,"_showComponents",!0)}setShowComponents(n){this._showComponents=n}getShowComponents(){return this._showComponents}deletePermissionPoint(n){const r=this._permissionPointMap.get(n);r&&(r.complete(),this._permissionPointMap.delete(n))}addPermissionPoint(n){const r=n instanceof ce.BehaviorSubject,s=r?n.getValue():n;if(!s.id)return!1;if(this._permissionPointMap.get(s.id))throw new Error(`${s.id} PermissionPoint already exists`);return this._permissionPointMap.set(s.id,r?n:new ce.BehaviorSubject(s)),this._permissionPointUpdate$.next(s),!0}updatePermissionPoint(n,r){const s=this._permissionPointMap.get(n);if(!s)return;const i=s.getValue();i.value=r,i.status=ca.DONE,s.next(i),this._permissionPointUpdate$.next(i)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(n){const r=this._permissionPointMap.get(n);if(r)return r.getValue()}getPermissionPoint$(n){const r=this._permissionPointMap.get(n);if(r)return r}composePermission$(n){const r=n.map(s=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(s);if(!i)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return i.asObservable()});return ce.combineLatest(r).pipe(ls.map(s=>s))}composePermission(n){return n.map(s=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(s);if(!i)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return i.getValue()})}getAllPermissionPoint(){const n=new Map;return this._permissionPointMap.forEach((r,s)=>{n.set(s,r)}),n}}function sd(e,t){if(!t)return e;const n=[];for(const r of e){const s=t.find(([i])=>i===r[0]);if(s){if(s[1]===null)continue;n.push([r[0],s[1]])}else n.push(r)}return n}var VR=Object.getOwnPropertyDescriptor,zR=(e,t,n,r)=>{for(var s=r>1?void 0:r?VR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Si=(e,t)=>(n,r)=>t(n,r,e);const KR=4,id=Symbol("DependentOn");class eo extends Ke{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}p(eo,"pluginName"),p(eo,"type",ve.UNIVER_UNKNOWN);class XR{constructor(){p(this,"_plugins",[])}addPlugin(t){this._plugins.push(t)}removePlugins(){const t=this._plugins.slice();return this._plugins.length=0,t}forEachPlugin(t){this._plugins.forEach(t)}}function qR(...e){return function(t){t[id]=e}}exports.PluginService=class{constructor(t,n,r){p(this,"_pluginRegistry",new Map);p(this,"_pluginStore",new XR);p(this,"_seenPlugins",new Set);p(this,"_loadedPlugins",new Set);p(this,"_loadedPluginTypes",new Set([ve.UNIVER_UNKNOWN]));p(this,"_flushTimerByType",new Map);this._injector=t,this._lifecycleService=n,this._logService=r}dispose(){this._pluginStore.removePlugins().forEach(t=>t.dispose()),this._flushTimerByType.forEach(t=>clearTimeout(t))}registerPlugin(t,n){this._assertPluginValid(t);const r={plugin:t,options:n};this._pluginRegistry.set(t.pluginName,r),this._logService.debug("[PluginService]",`Plugin "${t.pluginName}" registered.`);const{type:s}=t;this._loadedPluginTypes.has(s)&&(s===ve.UNIVER_UNKNOWN?this._loadFromPlugins([r]):this._flushType(s))}startPluginsForType(t){this._loadedPluginTypes.has(t)||this._loadPluginsForType(t)}_loadPluginsForType(t){const n=Array.from(this._pluginRegistry.keys()),r=[];n.forEach(s=>{const i=this._pluginRegistry.get(s);i.plugin.type===t&&r.push(i)}),this._loadFromPlugins(r),this._loadedPluginTypes.add(t)}_assertPluginValid(t){const{type:n,pluginName:r}=t;if(n===ve.UNRECOGNIZED)throw new Error(`[PluginService]: invalid plugin type for ${t.name}. Please assign a "type" to your plugin.`);if(!r)throw new Error(`[PluginService]: no plugin name for ${t.name}. Please assign a "pluginName" to your plugin.`);if(this._seenPlugins.has(r))throw new Error(`[PluginService]: duplicated plugin name for "${r}". Maybe a plugin that dependents on "${r} has already registered it. In that case please register "${r}" before the that plugin.`);this._seenPlugins.add(t.pluginName)}_flushType(t){this._flushTimerByType.get(t)===void 0&&this._flushTimerByType.set(t,setTimeout(()=>{this._loadPluginsForType(t),this._flushTimerByType.delete(t)},KR))}_loadFromPlugins(t){const n=[],r=new Set,s=o=>{const{plugin:a}=o,{pluginName:l}=a;if(this._loadedPlugins.has(l)||r.has(l))return;r.add(l),this._pluginRegistry.delete(l);const c=a[id];c&&c.forEach(u=>{const h=this._pluginRegistry.get(u.pluginName);if(h)s(h);else if(!this._seenPlugins.has(u.pluginName)&&!r.has(u.pluginName)){if(a.type===ve.UNIVER_UNKNOWN&&u.type!==ve.UNIVER_UNKNOWN)throw new Error(`[PluginService]: cannot register a plugin with Univer type that depends on a plugin with other type. The dependent is ${a.pluginName} and the dependency is ${u.pluginName}.`);a.type!==u.type&&u.type!==ve.UNIVER_UNKNOWN&&this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${u.pluginName}" which has different type.`),this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${u.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(u),s({plugin:u,options:void 0})}}),n.push(o)};t.forEach(o=>s(o));const i=n.map(o=>this._initPlugin(o.plugin,o.options));this._pluginsRunLifecycle(i)}_pluginsRunLifecycle(t){const n=this._lifecycleService.stage;if(ed(n).subscribe(r=>this._runStage(t,r)),n!==Ue.Steady){const r=this._lifecycleService.lifecycle$.pipe(ce.skip(1)).subscribe(s=>{this._runStage(t,s),s===Ue.Steady&&r.unsubscribe()})}}_runStage(t,n){t.forEach(r=>{switch(n){case Ue.Starting:r.onStarting();break;case Ue.Ready:r.onReady();break;case Ue.Rendered:r.onRendered();break;case Ue.Steady:r.onSteady();break}})}_initPlugin(t,n){const r=this._injector.createInstance(t,n);return this._pluginStore.addPlugin(r),this._loadedPlugins.add(t.pluginName),this._logService.debug("[PluginService]",`Plugin "${r.getPluginName()}" loaded.`),r}};exports.PluginService=zR([Si(0,Ae.Inject(Ae.Injector)),Si(1,Ae.Inject(exports.LifecycleService)),Si(2,Et)],exports.PluginService);const to=Ae.createIdentifier("resource-loader-service");var ZR=Object.getOwnPropertyDescriptor,JR=(e,t,n,r)=>{for(var s=r>1?void 0:r?ZR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},QR=(e,t)=>(n,r)=>t(n,r,e);exports.ResourceManagerService=class extends Ke{constructor(n){super();p(this,"_resourceMap",new Map);p(this,"_register$",new ce.Subject);p(this,"register$",this._register$.asObservable());this._logService=n}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(n,r){return r?this.getResourcesByType(n,r):this.getAllResourceHooks().map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}getResourcesByType(n,r){return this.getAllResourceHooks().filter(o=>o.businesses.includes(r)).map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}registerPluginResource(n){const r=n.pluginName;if(this._resourceMap.has(r))throw new Error(`the pluginName is registered {${r}}`);return this._resourceMap.set(r,n),this._register$.next(n),We(()=>this._resourceMap.delete(r))}disposePluginResource(n){this._resourceMap.delete(n)}loadResources(n,r){this.getAllResourceHooks().forEach(s=>{var o;const i=(o=r==null?void 0:r.find(a=>a.name===s.pluginName))==null?void 0:o.data;if(i)try{const a=s.parseJson(i);s.onLoad(n,a)}catch(a){this._logService.error("[ResourceManagerService]","loadResources error",a)}})}unloadResources(n){this.getAllResourceHooks().forEach(r=>{r.onUnLoad(n)})}dispose(){this._register$.complete(),this._resourceMap.clear()}};exports.ResourceManagerService=JR([QR(0,Et)],exports.ResourceManagerService);class Ps extends Ke{constructor(){super();p(this,"_darkMode$",new ce.BehaviorSubject(!1));p(this,"darkMode$",this._darkMode$.asObservable());p(this,"_validColorCache",new Map);p(this,"_currentTheme",Kr.defaultTheme);p(this,"_currentTheme$",new ce.BehaviorSubject(this._currentTheme));p(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(We(()=>{this._currentTheme=Kr.defaultTheme,this._currentTheme$.complete(),this._darkMode$.complete()}))}get darkMode(){return this._darkMode$.getValue()}isValidThemeColor(n){if(this._validColorCache.has(n))return this._validColorCache.get(n);let r=!1;const s=n.split(".");if(s.length===1)r=n in Kr.defaultTheme;else if(s.length===2){const[i,o]=s;r=i in Kr.defaultTheme&&o in this._currentTheme[i]}return this._validColorCache.set(n,r),r}getCurrentTheme(){return this._currentTheme}setTheme(n){this._currentTheme=n,this._currentTheme$.next(n)}setDarkMode(n){this._darkMode$.next(n)}getColorFromTheme(n){return Nh(this._currentTheme,n)}}var eI=Object.getOwnPropertyDescriptor,tI=(e,t,n,r)=>{for(var s=r>1?void 0:r?eI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Oi=(e,t)=>(n,r)=>t(n,r,e);const Js=Ae.createIdentifier("univer.undo-redo.service"),nI=20;class od{dispose(){}async dispatchToHandlers(){return!1}}const ad="univer.command.redo",ld="univer.command.undo",cd=new class extends od{constructor(){super(...arguments);p(this,"type",kr.COMMAND);p(this,"id",ld)}handler(t){const n=t.get(Js),r=n.pitchTopUndoElement();if(!r)return!1;const s=t.get(Fr);return Fs(r.undoMutations,s)?(n.popUndoToRedo(),!0):!1}},ud=new class extends od{constructor(){super(...arguments);p(this,"type",kr.COMMAND);p(this,"id",ad)}handler(t){const n=t.get(Js),r=n.pitchTopRedoElement();if(!r)return!1;const s=t.get(Fr);return Fs(r.redoMutations,s)?(n.popRedoToUndo(),!0):!1}};exports.LocalUndoRedoService=class extends Ke{constructor(n,r,s){super();p(this,"undoRedoStatus$");p(this,"_undoRedoStatus$",new ce.BehaviorSubject({undos:0,redos:0}));p(this,"_undoStacks",new Map);p(this,"_redoStacks",new Map);p(this,"_batchingStatus",new Map);this._univerInstanceService=n,this._commandService=r,this._contextService=s,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(cd)),this.disposeWithMe(this._commandService.registerCommand(ud)),this.disposeWithMe(We(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(We(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(n){const{unitID:r}=n,s=this._getRedoStack(r,!0),i=this._getUndoStack(r,!0);if(s.length=0,this._batchingStatus.has(n.unitID)){const a=this._batchingStatus.get(n.unitID),l=this._pitchUndoElement(n.unitID);a===0||!l?(o(n),this._batchingStatus.set(n.unitID,1)):this._tryBatchingElements(l,n)}else o(n);function o(a){i.push(a),i.length>nI&&i.splice(0,1)}this._updateStatus()}clearUndoRedo(n){const r=this._getRedoStack(n);r&&(r.length=0);const s=this._getUndoStack(n);s&&(s.length=0),this._updateStatus()}pitchTopUndoElement(){const n=this._getFocusedUnitId();return this._pitchUndoElement(n)}pitchTopRedoElement(){const n=this._getFocusedUnitId();return this._pitchRedoElement(n)}_pitchUndoElement(n){const r=this._getUndoStack(n);return r!=null&&r.length?r[r.length-1]:null}_pitchRedoElement(n){const r=this._getRedoStack(n);return r!=null&&r.length?r[r.length-1]:null}popUndoToRedo(){const r=this._getUndoStackForFocused().pop();r&&(this._getRedoStackForFocused().push(r),this._updateStatus())}popRedoToUndo(){const r=this._getRedoStackForFocused().pop();r&&(this._getUndoStackForFocused().push(r),this._updateStatus())}rollback(n,r){const s=r||this._getFocusedUnitId(),i=this._getUndoStack(s),o=i==null?void 0:i[(i==null?void 0:i.length)-1];o&&o.id===n&&(i.pop(),Fs(o.undoMutations,this._commandService))}__tempBatchingUndoRedo(n){if(this._batchingStatus.has(n))throw new Error("[LocalUndoRedoService]: cannot batching undo redo twice at the same time!");return this._batchingStatus.set(n,0),We(()=>this._batchingStatus.delete(n))}_updateStatus(){var i,o;const n=this._getFocusedUnitId(),r=n&&((i=this._undoStacks.get(n))==null?void 0:i.length)||0,s=n&&((o=this._redoStacks.get(n))==null?void 0:o.length)||0;this._undoRedoStatus$.next({undos:r,redos:s})}_getUndoStack(n,r=!1){let s=this._undoStacks.get(n);return!s&&r&&(s=[],this._undoStacks.set(n,s)),s||null}_getRedoStack(n,r=!1){let s=this._redoStacks.get(n);return!s&&r&&(s=[],this._redoStacks.set(n,s)),s||null}_getUndoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getUndoStack(n,!0)}_getRedoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getRedoStack(n,!0)}_tryBatchingElements(n,r){n.redoMutations.push(...r.redoMutations),n.undoMutations.push(...r.undoMutations)}_getFocusedUnitId(){var o,a,l,c;let n="";const r=this._contextService.getContextValue(Hn),s=this._contextService.getContextValue(Ph),i=this._contextService.getContextValue(Uh);return r?s?n=io:i?n=so:n=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":n=(c=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?c:"",n}};exports.LocalUndoRedoService=tI([Oi(0,Xn),Oi(1,Fr),Oi(2,qn)],exports.LocalUndoRedoService);class hd{constructor(t,n=100){p(this,"_imageCacheMap");this._injector=t,this._imageCacheMap=new Tr(n)}_getImageCacheKey(t,n){return`${t}-${n}`}getImage(t,n,r,s){const i=this._getImageCacheKey(t,n),o=this._imageCacheMap.get(i);return o||((async()=>{const a=new Image,l=this._injector.has(Ji)?this._injector.get(Ji):null;if(t===aa.UUID)try{a.src=await(l==null?void 0:l.getImage(n))||""}catch(c){console.error(c)}else a.src=n;a.onload=()=>{a.removeAttribute("data-error"),r==null||r()},a.onerror=()=>{a.setAttribute("data-error","true"),s==null||s()},this._imageCacheMap.set(i,a)})(),null)}}function rI(e){return!(e.length===0||e.length>31||e.startsWith("'")||e.endsWith("'")||/[:\\\/\?\*\[\]]/.test(e))}const vl=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],vi=1,ir=8;class ua{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[n,r]=new Uint8Array(t,0,2);if(n!==219)throw new Error("Data does not appear to be in a KDBush format.");const s=r>>4;if(s!==vi)throw new Error(`Got v${s} data when expected v${vi}.`);const i=vl[r&15];if(!i)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new ua(a,o,i,t)}constructor(t,n=64,r=Float64Array,s){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+n,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=vl.indexOf(this.ArrayType),o=t*2*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);s&&s instanceof ArrayBuffer?(this.data=s,this.ids=new this.IndexArrayType(this.data,ir,t),this.coords=new this.ArrayType(this.data,ir+a+l,t*2),this._pos=t*2,this._finished=!0):(this.data=new ArrayBuffer(ir+o+a+l),this.ids=new this.IndexArrayType(this.data,ir,t),this.coords=new this.ArrayType(this.data,ir+a+l,t*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(vi<<4)+i]),new Uint16Array(this.data,2,1)[0]=n,new Uint32Array(this.data,4,1)[0]=t)}add(t,n){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=n,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return no(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,n,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:o,nodeSize:a}=this,l=[0,i.length-1,0],c=[];for(;l.length;){const u=l.pop()||0,h=l.pop()||0,d=l.pop()||0;if(h-d<=a){for(let R=d;R<=h;R++){const b=o[2*R],F=o[2*R+1];b>=t&&b<=r&&F>=n&&F<=s&&c.push(i[R])}continue}const f=d+h>>1,g=o[2*f],_=o[2*f+1];g>=t&&g<=r&&_>=n&&_<=s&&c.push(i[f]),(u===0?t<=g:n<=_)&&(l.push(d),l.push(f-1),l.push(1-u)),(u===0?r>=g:s>=_)&&(l.push(f+1),l.push(h),l.push(1-u))}return c}within(t,n,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:i,nodeSize:o}=this,a=[0,s.length-1,0],l=[],c=r*r;for(;a.length;){const u=a.pop()||0,h=a.pop()||0,d=a.pop()||0;if(h-d<=o){for(let R=d;R<=h;R++)wl(i[2*R],i[2*R+1],t,n)<=c&&l.push(s[R]);continue}const f=d+h>>1,g=i[2*f],_=i[2*f+1];wl(g,_,t,n)<=c&&l.push(s[f]),(u===0?t-r<=g:n-r<=_)&&(a.push(d),a.push(f-1),a.push(1-u)),(u===0?t+r>=g:n+r>=_)&&(a.push(f+1),a.push(h),a.push(1-u))}return l}}function no(e,t,n,r,s,i){if(s-r<=n)return;const o=r+s>>1;dd(e,t,o,r,s,i),no(e,t,n,r,o-1,1-i),no(e,t,n,o+1,s,1-i)}function dd(e,t,n,r,s,i){for(;s>r;){if(s-r>600){const c=s-r+1,u=n-r+1,h=Math.log(c),d=.5*Math.exp(2*h/3),f=.5*Math.sqrt(h*d*(c-d)/c)*(u-c/2<0?-1:1),g=Math.max(r,Math.floor(n-u*d/c+f)),_=Math.min(s,Math.floor(n+(c-u)*d/c+f));dd(e,t,n,g,_,i)}const o=t[2*n+i];let a=r,l=s;for(or(e,t,r,n),t[2*s+i]>o&&or(e,t,r,s);a<l;){for(or(e,t,a,l),a++,l--;t[2*a+i]<o;)a++;for(;t[2*l+i]>o;)l--}t[2*r+i]===o?or(e,t,r,l):(l++,or(e,t,l,s)),l<=n&&(r=l+1),n<=l&&(s=l-1)}}function or(e,t,n,r){wi(e,n,r),wi(t,2*n,2*r),wi(t,2*n+1,2*r+1)}function wi(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function wl(e,t,n,r){const s=e-n,i=t-r;return s*s+i*i}class sI{constructor(t=!1){p(this,"_tree",new Map);p(this,"_oneCellCache",new Map);p(this,"_kdTree",new Map);this._enableOneCellCache=t}dispose(){this.clear()}getTree(t,n){return this._tree.has(t)||this._tree.set(t,new Map),this._tree.get(t).has(n)||this._tree.get(t).set(n,new Ms),this._tree.get(t).get(n)}_getOneCellCache(t,n,r,s){return this._oneCellCache.has(t)||this._oneCellCache.set(t,new Map),this._oneCellCache.get(t).has(n)||this._oneCellCache.get(t).set(n,new Map),this._oneCellCache.get(t).get(n).has(r)||this._oneCellCache.get(t).get(n).set(r,new Map),this._oneCellCache.get(t).get(n).get(r).has(s)||this._oneCellCache.get(t).get(n).get(r).set(s,new Set),this._oneCellCache.get(t).get(n).get(r).get(s)}_removeOneCellCache(t,n,r,s,i){const o=this._oneCellCache.get(t);if(!o)return;const a=o.get(n);if(!a)return;const l=a.get(r);if(!l)return;const c=l.get(s);c&&c.delete(i)}_removeCellCacheByRange(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this._oneCellCache.get(n);if(!o)return;const a=o.get(r);if(!a)return;const{startRow:l,startColumn:c,endRow:u,endColumn:h}=s;for(let d=l;d<=u;d++){const f=a.get(d);if(f)for(let g=c;g<=h;g++){const _=f.get(g);_&&_.delete(i)}}}_insertOneCellCache(t,n,r,s,i){this._getOneCellCache(t,n,r,s).add(i)}_getRdTreeItems(t){const n=[];for(const[r,s]of t)for(const[i,o]of s)n.push({x:i,y:r,ids:o});return n}_searchByOneCellCache(t){var g;const{unitId:n,sheetId:r,range:s}=t,{startRow:i,startColumn:o,endRow:a,endColumn:l}=s,c=(g=this._kdTree.get(n))==null?void 0:g.get(r);if(!c)return[];const{tree:u,items:h}=c,d=u.range(o,i,l,a),f=[];for(const _ of d){const R=h[_];f.push(...Array.from(R.ids))}return f}openKdTree(){var t;for(const[n,r]of this._oneCellCache){this._kdTree.has(n)||this._kdTree.set(n,new Map);for(const[s,i]of r){const o=this._getRdTreeItems(i),a=new ua(o.length);(t=this._kdTree.get(n))==null||t.set(s,{tree:a,items:o});for(const l of o)a.add(l.x,l.y);a.finish()}}}closeKdTree(){var t;for(const[n,r]of this._oneCellCache)for(const[s,i]of r)(t=this._kdTree.get(n))==null||t.set(s,void 0)}insert(t){const{unitId:n,sheetId:r,range:s,id:i}=t;if(!n||n.length===0)return;let{startRow:o,endRow:a,startColumn:l,endColumn:c}=s;if(this._enableOneCellCache&&o===a&&l===c){this._insertOneCellCache(n,r,o,l,i);return}const u=this.getTree(n,r);Number.isNaN(o)&&(o=0),Number.isNaN(l)&&(l=0),Number.isNaN(a)&&(a=Number.POSITIVE_INFINITY),Number.isNaN(c)&&(c=Number.POSITIVE_INFINITY),u.insert({minX:l,minY:o,maxX:c,maxY:a,id:i})}bulkInsert(t){for(const n of t)this.insert(n)}*searchGenerator(t){var a;const{unitId:n,sheetId:r,range:s}=t;if(this._enableOneCellCache){const l=this._searchByOneCellCache(t);for(const c of l)yield c}const i=(a=this._tree.get(n))==null?void 0:a.get(r);if(!i)return;const o=i.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(const l of o)yield l.id}bulkSearch(t,n){const r=new Set;for(const s of t)for(const i of this.searchGenerator(s))(n==null?void 0:n.has(i))!==!0&&r.add(i);return r}removeById(t,n){var r,s;n?((r=this._tree.get(t))==null||r.delete(n),(s=this._oneCellCache.get(t))==null||s.delete(n)):(this._tree.delete(t),this._oneCellCache.delete(t))}_removeRTreeItem(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this.getTree(n,r),a=o.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(let l=0;l<a.length;l++)a[l].id===i&&o.remove(a[l])}remove(t){const{unitId:n,sheetId:r,range:s,id:i}=t,{startRow:o,startColumn:a,endRow:l,endColumn:c}=s;this._enableOneCellCache?o===l&&a===c?this._removeOneCellCache(n,r,s.startRow,s.startColumn,i):(this._removeCellCacheByRange(t),this._removeRTreeItem(t)):this._removeRTreeItem(t)}bulkRemove(t){for(const n of t)this.remove(n)}clear(){this._tree.clear(),this._oneCellCache.clear()}toJSON(){const t={};return this._tree.forEach((n,r)=>{t[r]={},n.forEach((s,i)=>{t[r][i]=s.toJSON()})}),t}fromJSON(t){this._tree.clear();for(const n in t){this._tree.set(n,new Map);for(const r in t[n]){const s=new Ms;s.fromJSON(t[n][r]),this._tree.get(n).set(r,s)}}}}function iI(e){return new Promise(t=>setTimeout(t,e))}function oI(e=1){return new Promise(t=>{let n=0;const r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}var aI=Object.getOwnPropertyDescriptor,lI=(e,t,n,r)=>{for(var s=r>1?void 0:r?aI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},cI=(e,t)=>(n,r)=>t(n,r,e);exports.Skeleton=class extends Ke{constructor(n){super();p(this,"_fontLocale");p(this,"_dirty",!0);this._localeService=n,this._localeInitial()}get dirty(){return this._dirty}getFontLocale(){return this._fontLocale}makeDirty(n){this._dirty=n}dispose(){super.dispose(),this._fontLocale=null}_localeInitial(){}};exports.Skeleton=lI([cI(0,Ae.Inject(Cn))],exports.Skeleton);var uI=Object.getOwnPropertyDescriptor,hI=(e,t,n,r)=>{for(var s=r>1?void 0:r?uI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},as=(e,t)=>(n,r)=>t(n,r,e);exports.SheetSkeleton=class extends exports.Skeleton{constructor(n,r,s,i,o,a){super(s);p(this,"_worksheetData");p(this,"_renderRawFormula",!1);p(this,"_cellData");p(this,"_imageCacheMap");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");p(this,"_scaleY");p(this,"_scrollX");p(this,"_scrollY");this.worksheet=n,this._styles=r,this._contextService=i,this._configService=o,this._injector=a,this._worksheetData=this.worksheet.getConfig(),this._cellData=this.worksheet.getCellMatrix(),this._imageCacheMap=new hd(this._injector),this.initConfig()}initConfig(){var n,r;this._skipAutoHeightForMergedCells=!((n=this._configService.getConfig(Ll))!=null&&n),this.worksheet.setIsRowStylePrecedeColumnStyle((r=this._configService.getConfig(Ml))!=null?r:!1)}resetCache(){}getWorksheetConfig(){return this._worksheetData}getLocation(){return[this.worksheet.getUnitId(),this.worksheet.getSheetId()]}set columnHeaderHeight(n){this._columnHeaderHeight=n,this._worksheetData.columnHeader.height=n}set rowHeaderWidth(n){this._rowHeaderWidth=n,this._worksheetData.rowHeader.width=n}get rowHeightAccumulation(){return this._rowHeightAccumulation}get rowTotalHeight(){return this._rowTotalHeight}get columnWidthAccumulation(){return this._columnWidthAccumulation}get columnTotalWidth(){return this._columnTotalWidth}get rowHeaderWidth(){return this._rowHeaderWidth}get columnHeaderHeight(){return this._columnHeaderHeight}setMarginLeft(n){this._marginLeft=n}setMarginTop(n){this._marginTop=n}setScale(n,r){this._updateLayout(),this._scaleX=n,this._scaleY=r||n,this._updateLayout()}setScroll(n,r){q.isDefine(n)&&(this._scrollX=n),q.isDefine(r)&&(this._scrollY=r)}get scrollX(){return this._scrollX}get scrollY(){return this._scrollY}get scaleX(){return this._scaleX}get scaleY(){return this._scaleY}get rowHeaderWidthAndMarginLeft(){return this.rowHeaderWidth+this._marginLeft}get columnHeaderHeightAndMarginTop(){return this.columnHeaderHeight+this._marginTop}get imageCacheMap(){return this._imageCacheMap}_generateRowMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let c=s;if(this.worksheet.getRowFiltered(l))c=0;else if(a[l]!=null){const u=a[l];if(!u)continue;const{h=s,ah:d,ia:f}=u;(f==null||f===ie.TRUE)&&typeof d=="number"?c=d:c=h,u.hd===ie.TRUE&&(c=0)}i+=c,o.push(i)}return{rowTotalHeight:i,rowHeightAccumulation:o}}_generateColumnMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let c=s;if(a[l]!=null){const u=a[l];if(!u)continue;u.w!=null&&(c=u.w),u.hd===ie.TRUE&&(c=0)}i+=c,o.push(i)}return{columnTotalWidth:i,columnWidthAccumulation:o}}intersectMergeRange(n,r){return!!this.worksheet.getMergedCell(n,r)}_getOverflowBound(n,r,s,i,o=Tt.LEFT){let a=0;if(r>s){const l=this._columnWidthAccumulation.length-1;for(let c=r;c>=s;c--){const u=c,h=this.worksheet.getCell(n,u);if(!Li(h)&&u!==r||this.intersectMergeRange(n,u))return u===r?u:u+1>l?l:u+1;const{startX:d,endX:f}=Un(n,u,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===Tt.CENTER&&u===r?a+=(f-d)/2:a+=f-d,i<a)return u}return r}for(let l=r;l<=s;l++){const c=l,u=this.worksheet.getCell(n,c);if(!Li(u)&&c!==r||this.intersectMergeRange(n,c))return c===r?c:c-1<0?0:c-1;const{startX:h,endX:d}=Un(n,c,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===Tt.CENTER&&c===r?a+=(d-h)/2:a+=d-h,i<a)return c}return s}_updateLayout(){if(!this.dirty)return;const{rowData:n,columnData:r,defaultRowHeight:s,defaultColumnWidth:i,rowCount:o,columnCount:a,rowHeader:l,columnHeader:c}=this._worksheetData,{rowTotalHeight:u,rowHeightAccumulation:h}=this._generateRowMatrixCache(o,n,s),{columnTotalWidth:d,columnWidthAccumulation:f}=this._generateColumnMatrixCache(a,r,i);this._rowHeaderWidth=l.hidden!==ie.TRUE?this._dynamicallyUpdateRowHeaderWidth(l):0,this._columnHeaderHeight=c.hidden!==ie.TRUE?c.height:0,this._rowTotalHeight=u,this._rowHeightAccumulation=h,this._columnTotalWidth=d,this._columnWidthAccumulation=f,this.makeDirty(!1)}calculate(){return this.resetCache(),this._updateLayout(),this}resetRangeCache(n){}_dynamicallyUpdateRowHeaderWidth(n){const s=`${this.worksheet.getRowCount()}`.length*8;return Math.max(n.width,s)}_hasUnMergedCellInRow(n,r,s){if(!this.worksheet.getMergeData())return!1;for(let o=r;o<=s;o++){const{isMerged:a,isMergedMainCell:l}=this.worksheet.getCellInfoInMergeData(n,o);if(!a&&!l)return!0}return!1}expandRangeByMerge(n){let{startRow:r,startColumn:s,endRow:i,endColumn:o}=n;const a=this._worksheetData.mergeData;if(!a)return{startRow:r,startColumn:s,endRow:i,endColumn:o};let l=!0;const c=new dt;for(;l;){l=!1;for(let u=0;u<a.length;u++){const{startRow:h,startColumn:d,endRow:f,endColumn:g}=a[u];if(c.getValue(h,d))continue;xu({startColumn:s,startRow:r,endColumn:o,endRow:i},{startColumn:d,startRow:h,endColumn:g,endRow:f})&&(r=Math.min(r,h),s=Math.min(s,d),i=Math.max(i,f),o=Math.max(o,g),c.setValue(h,d,!0),l=!0)}}return{startRow:r,startColumn:s,endRow:i,endColumn:o}}getColumnCount(){return this._columnWidthAccumulation.length}getRowCount(){return this._rowHeightAccumulation.length}_getCellMergeInfo(n,r){return this.worksheet.getCellInfoInMergeData(n,r)}getNoMergeCellPositionByIndex(n,r,s=!0){return this.getNoMergeCellWithCoordByIndex(n,r,s)}getNoMergeCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this;let{startY:c,endY:u,startX:h,endX:d}=Un(n,r,i,o);return s&&(c+=l,u+=l,h+=a,d+=a),{startY:c,endY:u,startX:h,endX:d}}getNoMergeCellPositionByIndexWithNoHeader(n,r){const{rowHeightAccumulation:s,columnWidthAccumulation:i}=this,{startY:o,endY:a,startX:l,endX:c}=Un(n,r,s,i);return{startY:o,endY:a,startX:l,endX:c}}getRowIndexByOffsetY(n,r,s,i){var l;const{rowHeightAccumulation:o}=this;n=md(n,r,s,this.columnHeaderHeightAndMarginTop);let a=ar(o,n,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(o[a]-n)<Math.abs(n-((l=o[a-1])!=null?l:0))&&(a=a+1),a}getColumnIndexByOffsetX(n,r,s,i){var c;const o=fd(n,r,s,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this;let l=ar(a,o,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(a[l]-o)<Math.abs(o-((c=a[l-1])!=null?c:0))&&(l=l+1),l}getCellIndexByOffset(n,r,s,i,o,a){const l=this.getRowIndexByOffsetY(r,i,o,a),c=this.getColumnIndexByOffsetX(n,s,o,a);return{row:l,column:c}}getCellByOffset(n,r,s,i,o){const a=this==null?void 0:this.getCellIndexByOffset(n,r,s,i,o,{firstMatch:!0});return a?this.worksheet.getCellInfoInMergeData(a.row,a.column):null}getCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this,c=Un(n,r,i,o,this.worksheet.getCellInfoInMergeData(n,r)),{isMerged:u,isMergedMainCell:h}=c;let{startY:d,endY:f,startX:g,endX:_,mergeInfo:R}=c,b=a,F=l;return s===!1&&(b=0,F=0),d+=F,f+=F,g+=b,_+=b,R.startY+=F,R.endY+=F,R.startX+=b,R.endX+=b,{actualRow:n,actualColumn:r,startX:g,startY:d,endX:_,endY:f,isMerged:u,isMergedMainCell:h,mergeInfo:R}}getCellWithCoordByOffset(n,r,s,i,o,a){const{row:l,column:c}=this.getCellIndexByOffset(n,r,s,i,o,a);return this.getCellWithCoordByIndex(l,c)}getOffsetByColumn(n){const{columnWidthAccumulation:r,rowHeaderWidthAndMarginLeft:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetByRow(n){const{rowHeightAccumulation:r,columnHeaderHeightAndMarginTop:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetRelativeToRowCol(n,r){const s=ar(this.columnWidthAccumulation,n);let i=0;s===0?i=n:i=n-this._columnWidthAccumulation[s-1];const o=ar(this.rowHeightAccumulation,r);let a=0;return o===0?a=r:a=r-this._rowHeightAccumulation[o-1],{row:o,column:s,columnOffset:i,rowOffset:a}}_updateConfigAndGetDocumentModel(n,r,s,i){var a,l,c,u,h;if(!i||!((a=n.body)!=null&&a.dataStream))return;n.documentStyle||(n.documentStyle={}),n.documentStyle.marginTop=(l=s.t)!=null?l:0,n.documentStyle.marginBottom=(c=s.b)!=null?c:2,n.documentStyle.marginLeft=(u=s.l)!=null?u:2,n.documentStyle.marginRight=(h=s.r)!=null?h:2,n.documentStyle.pageSize={width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},n.documentStyle.renderConfig={...n.documentStyle.renderConfig,...i};const o=n.body.paragraphs||[];for(const d of o)d.paragraphStyle||(d.paragraphStyle={}),d.paragraphStyle.horizontalAlign=r;return new Nt(n)}dispose(){super.dispose(),this._rowHeightAccumulation=[],this._columnWidthAccumulation=[],this._rowTotalHeight=0,this._columnTotalWidth=0,this._rowHeaderWidth=0,this._columnHeaderHeight=0,this._worksheetData=null,this._cellData=null,this._styles=null}};exports.SheetSkeleton=hI([as(2,Ae.Inject(Cn)),as(3,qn),as(4,oa),as(5,Ae.Inject(Ae.Injector))],exports.SheetSkeleton);function ha(e,t,n,r){const s=e-1,i=t-1,o=n[s]||0;let a=n[e];a==null&&(a=n[n.length-1]);const l=r[i]||0;let c=r[t];return c==null&&(c=r[r.length-1]),{startY:o,endY:a,startX:l,endX:c}}function dI(e,t,n,r){return ha(e,t,n,r)}function Un(e,t,n,r,s){e=q.clamp(e,0,n.length-1),t=q.clamp(t,0,r.length-1);let{startY:i,endY:o,startX:a,endX:l}=ha(e,t,n,r);if(!s)return{startY:i,endY:o,startX:a,endX:l,isMerged:!1,isMergedMainCell:!1,actualRow:e,actualColumn:t,mergeInfo:{startY:i,endY:o,startX:a,endX:l,startRow:e,startColumn:t,endRow:e,endColumn:t}};const{isMerged:c,isMergedMainCell:u,startRow:h,startColumn:d,endRow:f,endColumn:g}=s;let _={startRow:h,startColumn:d,endRow:f,endColumn:g,startY:i,endY:o,startX:a,endX:l};const R=n.length-1,b=r.length-1;if(c&&h!==-1&&d!==-1){const F=n[h-1]||0,k=n[f]||n[R],W=r[d-1]||0,S=r[g]||r[b];_={..._,startY:F,endY:k,startX:W,endX:S}}else if(!c&&f!==-1&&g!==-1){const F=n[f]||n[R],k=r[g]||r[b];_={..._,startY:i,endY:F,startX:a,endX:k}}return{isMerged:c,isMergedMainCell:u,actualRow:e,actualColumn:t,startY:i,endY:o,startX:a,endX:l,mergeInfo:_}}function fd(e,t,n,r){const{x:s}=n;return e/t+s-r}function md(e,t,n,r){const{y:s}=n;return e=e/t+s-r,e}const fI=["script","style","meta","comment","link"];var gd=(e=>(e[e.INFO=0]="INFO",e[e.STOP=1]="STOP",e[e.WARNING=2]="WARNING",e))(gd||{}),_d=(e=>(e[e.DISABLED=0]="DISABLED",e[e.FULL_ALPHA=1]="FULL_ALPHA",e[e.FULL_HANGUL=2]="FULL_HANGUL",e[e.FULL_KATAKANA=3]="FULL_KATAKANA",e[e.HALF_ALPHA=4]="HALF_ALPHA",e[e.HALF_HANGUL=5]="HALF_HANGUL",e[e.HALF_KATAKANA=6]="HALF_KATAKANA",e[e.HIRAGANA=7]="HIRAGANA",e[e.NO_CONTROL=8]="NO_CONTROL",e[e.OFF=9]="OFF",e[e.ON=10]="ON",e))(_d||{}),pd=(e=>(e.BETWEEN="between",e.EQUAL="equal",e.GREATER_THAN="greaterThan",e.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",e.LESS_THAN="lessThan",e.LESS_THAN_OR_EQUAL="lessThanOrEqual",e.NOT_BETWEEN="notBetween",e.NOT_EQUAL="notEqual",e))(pd||{}),Ed=(e=>(e[e.TEXT=0]="TEXT",e[e.ARROW=1]="ARROW",e[e.CUSTOM=2]="CUSTOM",e))(Ed||{}),Cd=(e=>(e.VALID="valid",e.INVALID="invalid",e.VALIDATING="validating",e))(Cd||{}),Rd=(e=>(e.CUSTOM="custom",e.LIST="list",e.LIST_MULTIPLE="listMultiple",e.NONE="none",e.TEXT_LENGTH="textLength",e.DATE="date",e.TIME="time",e.WHOLE="whole",e.DECIMAL="decimal",e.CHECKBOX="checkbox",e.ANY="any",e))(Rd||{}),mI=Object.getOwnPropertyDescriptor,gI=(e,t,n,r)=>{for(var s=r>1?void 0:r?mI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},bl=(e,t)=>(n,r)=>t(n,r,e);let ro=class extends Ke{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){const e=n=>{n.businesses.forEach(r=>{switch(r){case ve.UNRECOGNIZED:case ve.UNIVER_UNKNOWN:case ve.UNIVER_SLIDE:case ve.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType(ve.UNIVER_DOC).forEach(s=>{const o=(s.getSnapshot().resources||[]).find(a=>a.name===n.pluginName);if(o)try{const a=n.parseJson(o.data);n.onLoad(s.getUnitId(),a)}catch{console.error(`Load Document{${s.getUnitId()}} Resources{${n.pluginName}} Data Error.`)}});break}case ve.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(ve.UNIVER_SHEET).forEach(s=>{const o=(s.getSnapshot().resources||[]).find(a=>a.name===n.pluginName);if(o)try{const a=n.parseJson(o.data);n.onLoad(s.getUnitId(),a)}catch{console.error(`Load Workbook{${s.getUnitId()}} Resources{${n.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(n=>e(n)),this.disposeWithMe(this._resourceManagerService.register$.subscribe(n=>e(n))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(ve.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(ve.UNIVER_DOC).subscribe(n=>{const r=n.getUnitId();Dl(r)||this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(ve.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(ve.UNIVER_DOC).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())}))}saveUnit(e){const t=this._univerInstanceService.getUnit(e);if(!t)return null;const n=this._resourceManagerService.getResources(e,t.type),r=q.deepClone(t.getSnapshot());return r.resources=n,r}};ro=gI([bl(0,Ae.Inject(zs)),bl(1,Ae.Inject(Xn))],ro);class _I{constructor(t={},n){p(this,"_startedTypes",new Set);p(this,"_injector");p(this,"_disposingCallbacks",new ks);const r=this._injector=pI(n,t==null?void 0:t.override),{theme:s,darkMode:i,locale:o,locales:a,logLevel:l}=t;s&&this._injector.get(Ps).setTheme(s),i&&this._injector.get(Ps).setDarkMode(i),a&&this._injector.get(Cn).load(a),o&&this._injector.get(Cn).setLocale(o),l&&this._injector.get(Et).setLogLevel(l),this._init(r)}get _univerInstanceService(){return this._injector.get(Xn)}get _pluginService(){return this._injector.get(exports.PluginService)}__getInjector(){return this._injector}onDispose(t){const n=this._disposingCallbacks.add(We(t));return We(()=>n.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(t){this._injector.get(Cn).setLocale(t)}createUnit(t,n){return this._univerInstanceService.createUnit(t,n)}createUniverSheet(t){return this._injector.get(Et).warn("[Univer]","Univer.createUniverSheet is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(ve.UNIVER_SHEET,t)}createUniverDoc(t){return this._injector.get(Et).warn("[Univer]","Univer.createUniverDoc is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(ve.UNIVER_DOC,t)}createUniverSlide(t){return this._injector.get(Et).warn("[Univer]","Univer.createUniverSlide is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(ve.UNIVER_SLIDE,t)}_init(t){this._univerInstanceService.registerCtorForType(ve.UNIVER_SHEET,exports.Workbook),this._univerInstanceService.registerCtorForType(ve.UNIVER_DOC,Nt),this._univerInstanceService.registerCtorForType(ve.UNIVER_SLIDE,la);const n=t.get(Xn);n.__setCreateHandler((r,s,i,o)=>{if(!this._startedTypes.has(r)){this._pluginService.startPluginsForType(r),this._startedTypes.add(r);const l=t.createInstance(i,s);return n.__addUnit(l,o),this._tryProgressToReady(),l}const a=t.createInstance(i,s);return n.__addUnit(a,o),a})}_tryProgressToReady(){this._injector.get(exports.LifecycleService).stage<Ue.Ready&&(this._injector.get(exports.LifecycleService).stage=Ue.Ready)}registerPlugin(t,n){this._pluginService.registerPlugin(t,n)}}function pI(e,t){const n=sd([[kh],[Cn],[Ps],[exports.LifecycleService],[exports.PluginService],[Lr],[Xn,{useClass:exports.UniverInstanceService}],[nd,{useClass:rd}],[Et,{useClass:Yl,lazy:!0}],[Fr,{useClass:exports.CommandService}],[Js,{useClass:exports.LocalUndoRedoService,lazy:!0}],[oa,{useClass:xh}],[qn,{useClass:jl}],[zs,{useClass:exports.ResourceManagerService,lazy:!0}],[to,{useClass:ro,lazy:!0}],[dh,{useClass:exports.AuthzIoLocalService}],[td,{useClass:exports.MentionIOLocalService,lazy:!0}]],t),r=e?e.createChild(n):new Ae.Injector(n);return xl(r,[[Lr],[to]]),r}Ad();exports.ABCToNumber=L_;exports.AUTO_HEIGHT_FOR_MERGED_CELLS=Ll;exports.AbsoluteRefType=Ne;exports.ActionIterator=xn;exports.AlignTypeH=Ou;exports.AlignTypeV=vu;exports.ArrangeTypeEnum=Au;exports.ArrowsAndMarkersShapes=ac;exports.AsyncInterceptorManager=Kd;exports.AsyncLock=kd;exports.AutoFillSeries=ql;exports.BaselineOffset=Yt;exports.BasicShapes=oc;exports.BlockType=ru;exports.BooleanNumber=ie;exports.BorderStyleTypes=De;exports.BorderType=Zl;exports.BuildTextUtils=Qe;exports.BulletAlignment=$r;exports.COLORS=Ti;exports.CanceledError=jd;exports.CellModeEnum=kn;exports.CellValueType=en;exports.Color=In;exports.ColorBuilder=$s;exports.ColorKit=At;exports.ColorType=pt;exports.ColumnSeparatorType=ou;exports.CommandType=kr;exports.CommonHideTypes=Jl;exports.ConfigService=xh;exports.ContextService=jl;exports.CopyPasteType=Ql;exports.CustomCommandExecutionError=Ss;exports.CustomDecorationType=pn;exports.CustomRangeType=sn;exports.DEFAULT_CELL=l_;exports.DEFAULT_DOC=Xo;exports.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=tE;exports.DEFAULT_EMPTY_DOCUMENT_VALUE=Nl;exports.DEFAULT_NUMBER_FORMAT=eu;exports.DEFAULT_RANGE=o_;exports.DEFAULT_RANGE_ARRAY=i_;exports.DEFAULT_SELECTION=a_;exports.DEFAULT_SLIDE=Mu;exports.DEFAULT_STYLES=st;exports.DEFAULT_TEXT_FORMAT=Jc;exports.DEFAULT_TEXT_FORMAT_EXCEL=Qc;exports.DEFAULT_WORKSHEET_COLUMN_COUNT=Yh;exports.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=bR;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Kh;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=NR;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH=Vh;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=TR;exports.DEFAULT_WORKSHEET_ROW_COUNT=Wh;exports.DEFAULT_WORKSHEET_ROW_COUNT_KEY=wR;exports.DEFAULT_WORKSHEET_ROW_HEIGHT=Gh;exports.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=AR;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=zh;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=yR;exports.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=io;exports.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=so;exports.DOCS_ZEN_EDITOR_UNIT_ID_KEY=yl;exports.DOC_DRAWING_PRINTING_COMPONENT_KEY=f_;exports.DOC_RANGE_TYPE=Sc;exports.DashStyleType=du;exports.DataStreamTreeNodeType=oh;exports.DataStreamTreeTokenType=at;exports.DataValidationErrorStyle=gd;exports.DataValidationImeMode=_d;exports.DataValidationOperator=pd;exports.DataValidationRenderMode=Ed;exports.DataValidationStatus=Cd;exports.DataValidationType=Rd;exports.DeleteDirection=ec;exports.DependentOn=qR;exports.DesktopLogService=Yl;exports.DeveloperMetadataVisibility=tc;exports.Dimension=nc;exports.Direction=rc;exports.Disposable=Ke;exports.DisposableCollection=ks;exports.DocStyleType=tu;exports.DocumentDataModel=Nt;exports.DocumentFlavor=Wo;exports.DrawingTypeEnum=Tu;exports.EDITOR_ACTIVATED=Uh;exports.EXTENSION_NAMES=Lu;exports.ErrorService=kh;exports.EventState=hh;exports.EventSubject=nE;exports.FOCUSING_COMMON_DRAWINGS=hR;exports.FOCUSING_DOC=Rr;exports.FOCUSING_EDITOR_BUT_HIDDEN=iR;exports.FOCUSING_EDITOR_INPUT_FORMULA=oR;exports.FOCUSING_EDITOR_STANDALONE=lR;exports.FOCUSING_FX_BAR_EDITOR=Ph;exports.FOCUSING_PANEL_EDITOR=cR;exports.FOCUSING_SHEET=Hn;exports.FOCUSING_SLIDE=Ir;exports.FOCUSING_UNIT=Cr;exports.FOCUSING_UNIVER_EDITOR=aR;exports.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=uR;exports.FORMULA_EDITOR_ACTIVATED=dR;exports.FollowNumberWithType=nu;exports.FontItalic=ws;exports.FontStyleType=$n;exports.FontWeight=bs;exports.GridType=su;exports.HLSColor=pc;exports.HorizontalAlign=Tt;exports.IAuthzIoService=dh;exports.ICommandService=Fr;exports.IConfigService=oa;exports.IContextService=qn;exports.IImageIoService=Ji;exports.ILocalStorageService=jR;exports.ILogService=Et;exports.IMentionIOService=td;exports.IPermissionService=nd;exports.IResourceLoaderService=to;exports.IResourceManagerService=zs;exports.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE=Ml;exports.IUndoRedoService=Js;exports.IUniverInstanceService=Xn;exports.ImageCacheMap=hd;exports.ImageSourceType=aa;exports.ImageUploadStatusType=Fh;exports.InterceptorEffectEnum=Pn;exports.InterceptorManager=Gd;exports.InterpolationPointType=sc;exports.JSON1=V_;exports.JSONX=Gt;exports.LRUHelper=ur;exports.LRUMap=Tr;exports.LifecycleStages=Ue;exports.LifecycleUnreachableError=Qh;exports.ListGlyphType=fe;exports.LocaleService=Cn;exports.LocaleType=Br;exports.LogLevel=Wl;exports.MOVE_BUFFER_VALUE=lr;exports.MemoryCursor=On;exports.MentionType=vs;exports.NAMED_STYLE_MAP=u_;exports.NAMED_STYLE_SPACE_MAP=h_;exports.NamedStyleType=Xe;exports.NilCommand=Gl;exports.NumberUnitType=Su;exports.ObjectMatrix=dt;exports.ObjectRelativeFromH=Ru;exports.ObjectRelativeFromV=Iu;exports.OtherShapes=lc;exports.PAGE_SIZE=m_;exports.PAPER_TYPES=s_;exports.PRESET_LIST_TYPE=Wr;exports.PRINT_CHART_COMPONENT_KEY=d_;exports.PageElementType=yu;exports.PageOrientType=bu;exports.PageType=Yo;exports.PaperType=ct;exports.ParagraphElementType=lu;exports.ParagraphStyleBuilder=Mr;exports.ParagraphStyleValue=Gr;exports.PermissionService=rd;exports.PermissionStatus=ca;exports.Plugin=eo;exports.PositionedObjectLayoutType=uu;exports.PresetListType=kt;exports.ProtectionType=ic;exports.QuickListType=Zu;exports.QuickListTypeMap=J_;exports.RANGE_DIRECTION=Ic;exports.RANGE_TYPE=_e;exports.RBush=Ms;exports.RCDisposable=df;exports.RGBA_PAREN=jf;exports.RGB_PAREN=Hf;exports.ROTATE_BUFFER_VALUE=Xl;exports.RTree=sI;exports.Range=Vn;exports.Rectangle=on;exports.RedoCommand=ud;exports.RedoCommandId=ad;exports.RefAlias=M_;exports.Registry=oo;exports.RegistryAsMap=ao;exports.RelativeDate=uc;exports.RelativeSlideLink=Nu;exports.RgbColor=As;exports.RichTextBuilder=En;exports.RichTextValue=Qt;exports.RxDisposable=hf;exports.SHEET_EDITOR_UNITS=c_;exports.SectionType=iu;exports.SheetTypes=hc;exports.SheetViewModel=qh;exports.SliceBodyType=Ko;exports.SlideDataModel=la;exports.SpacingRule=hu;exports.SpecialShapes=cc;exports.Styles=Bh;exports.THEME_COLORS=_c;exports.TabStopAlignment=fu;exports.TableAlignmentType=gu;exports.TableLayoutType=_u;exports.TableRowHeightRule=Eu;exports.TableSizeType=mu;exports.TableTextWrapType=pu;exports.TextDecoration=dc;exports.TextDecorationBuilder=Jt;exports.TextDirection=Ar;exports.TextDirectionType=au;exports.TextStyleBuilder=nn;exports.TextStyleValue=Yr;exports.TextX=Me;exports.TextXActionType=Z;exports.ThemeColor=Ts;exports.ThemeColorType=it;exports.ThemeColors=Bs;exports.ThemeService=Ps;exports.Tools=q;exports.UndoCommand=cd;exports.UndoCommandId=ld;exports.UnitModel=Gs;exports.Univer=_I;exports.UniverInstanceType=ve;exports.UpdateDocsAttributeType=Ee;exports.UserManagerService=Lr;exports.VerticalAlign=_n;exports.VerticalAlignmentType=Cu;exports.Worksheet=xr;exports.WrapStrategy=Rn;exports.WrapTextType=cu;exports.addLinkToDocumentModel=$h;exports.afterInitApply=Sf;exports.afterTime=Rf;exports.awaitTime=iI;exports.binSearchFirstGreaterThanTarget=Kl;exports.binarySearchArray=Of;exports.bufferDebounceTime=Cf;exports.cellToRange=Em;exports.characterSpacingControlType=wu;exports.checkForSubstrings=Rm;exports.checkIfMove=wf;exports.checkParagraphHasBullet=ng;exports.checkParagraphHasIndent=rg;exports.checkParagraphHasIndentByStyle=Ac;exports.codeToBlob=vf;exports.composeBody=Gi;exports.composeInterceptors=Pl;exports.composeStyles=cr;exports.concatMatrixArray=am;exports.convertBodyToHtml=$f;exports.convertCellToRange=Oc;exports.convertObservableToBehaviorSubject=If;exports.covertCellValue=Di;exports.covertCellValues=Cm;exports.covertTextRunToHtml=Ai;exports.createAsyncInterceptorKey=Vd;exports.createDefaultUser=xs;exports.createDocumentModelWithStyle=Sr;exports.createInterceptorKey=Yd;exports.createInternalEditorID=$d;exports.createRowColIter=$i;exports.dayjs=Vt;exports.debounce=JC;exports.dedupe=Td;exports.dedupeBy=yd;exports.deepCompare=co;exports.delayAnimationFrame=oI;exports.deleteContent=yc;exports.extractPureTextFromCell=Zh;exports.fromCallback=Vl;exports.fromEventSubject=rE;exports.fromObservable=uf;exports.generateRandomId=tt;exports.get=Nh;exports.getArrayLength=tn;exports.getBodySlice=yt;exports.getBodySliceHtml=cs;exports.getBorderStyleType=gm;exports.getCellCoordByIndexSimple=ha;exports.getCellInfoInMergeData=im;exports.getCellPositionByIndexSimple=dI;exports.getCellValueType=nm;exports.getCellWithCoordByIndexCore=Un;exports.getColorStyle=Dt;exports.getCustomBlockSlice=th;exports.getCustomDecorationSlice=rh;exports.getCustomRangeSlice=nh;exports.getDocsUpdateBody=_m;exports.getIntersectRange=xu;exports.getOriginCellValue=LR;exports.getParagraphsSlice=eh;exports.getPlainText=Vs;exports.getReverseDirection=bf;exports.getSectionBreakSlice=ap;exports.getTableSlice=Qu;exports.getTextRunSlice=Ds;exports.getTransformOffsetX=fd;exports.getTransformOffsetY=md;exports.getWorksheetUID=PR;exports.groupBy=Ld;exports.handleStyleToString=mm;exports.hashAlgorithm=ig;exports.horizontalLineSegmentsSubtraction=Hs;exports.insertMatrixArray=yi;exports.insertTextToContent=Tc;exports.invertColorByHSL=ef;exports.invertColorByMatrix=nf;exports.isBlackColor=em;exports.isBooleanString=Bd;exports.isCellCoverable=Li;exports.isCellV=Rc;exports.isDefaultFormat=n_;exports.isEmptyCell=vc;exports.isFormulaId=fm;exports.isFormulaString=wc;exports.isICellData=Cc;exports.isInternalEditorID=Dl;exports.isNodeEnv=Bf;exports.isNotNullOrUndefined=Hh;exports.isNullCell=rm;exports.isNumeric=Bl;exports.isPatternEqualWithoutDecimal=r_;exports.isRangesEqual=_R;exports.isRealNum=sg;exports.isSafeNumeric=sf;exports.isSameStyleTextRun=bc;exports.isTextFormat=t_;exports.isUnitRangesEqual=pR;exports.isValidRange=pm;exports.isWhiteColor=tm;exports.makeArray=Dd;exports.makeCellRangeToRangeData=dm;exports.makeCellToSelection=hm;exports.makeCustomRangeStream=Ip;exports.mapObjectMatrix=om;exports.merge=ia;exports.mergeOverrideWithDependencies=sd;exports.mergeSets=lf;exports.mergeWith=nR;exports.mergeWorksheetSnapshotWithDefault=Xh;exports.mixinClass=rf;exports.moveMatrixArray=Mi;exports.moveRangeByOffset=I_;exports.nameCharacterCheck=rI;exports.normalizeBody=lp;exports.normalizeTextRuns=jr;exports.numberToABC=x_;exports.numberToListABC=U_;exports.numfmt=e_;exports.queryObjectMatrix=N_;exports.registerDependencies=Hd;exports.remove=Ur;exports.repeatStringNumTimes=Pu;exports.replaceInDocumentBody=Qp;exports.requestImmediateMacroTask=af;exports.rotate=Md;exports.searchArray=ar;exports.searchInOrderedArray=zl;exports.selectionToArray=sm;exports.sequence=Hl;exports.sequenceAsync=$l;exports.sequenceExecute=Fs;exports.sequenceExecuteAsync=Ef;exports.set=sR;exports.shallowEqual=Ul;exports.skipParseTagNames=fI;exports.sliceMatrixArray=lm;exports.sortRules=P_;exports.sortRulesByDesc=k_;exports.sortRulesFactory=Hr;exports.spliceArray=Ni;exports.splitIntoGrid=Go;exports.takeAfter=bi;exports.textDiff=qo;exports.throttle=Wd;exports.toDisposable=We;exports.touchDependencies=xl;exports.updateAttributeByDelete=sh;exports.updateAttributeByInsert=ih;exports.willLoseNumericPrecision=of;Object.keys(Ae).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>Ae[e]})});
|