@univerjs/core 0.2.1 → 0.2.3
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/README.md +17 -8
- package/lib/cjs/index.js +9 -9
- package/lib/es/index.js +1848 -1805
- package/lib/types/docs/data-model/types.d.ts +2 -2
- package/lib/types/index.d.ts +1 -1
- package/lib/types/services/command/command.service.d.ts +3 -1
- package/lib/types/services/lifecycle/lifecycle.service.d.ts +2 -2
- package/lib/types/services/plugin/plugin.service.d.ts +2 -0
- package/lib/types/shared/__tests__/rxjs.spec.d.ts +16 -0
- package/lib/types/shared/common.d.ts +1 -1
- package/lib/types/shared/rxjs.d.ts +4 -0
- package/lib/types/sheets/workbook.d.ts +10 -4
- package/lib/types/types/enum/locale-type.d.ts +3 -1
- package/lib/types/types/interfaces/i-data-validation.d.ts +19 -4
- package/lib/types/types/interfaces/i-range.d.ts +13 -11
- package/lib/umd/index.js +9 -9
- package/package.json +3 -3
package/lib/umd/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
(function(u,V){typeof exports=="object"&&typeof module<"u"?V(exports,require("rxjs"),require("rxjs/operators"),require("@wendellhu/redi")):typeof define=="function"&&define.amd?define(["exports","rxjs","rxjs/operators","@wendellhu/redi"],V):(u=typeof globalThis<"u"?globalThis:u||self,V(u.UniverCore={},u.rxjs,u.rxjs.operators,u["@wendellhu/redi"]))})(this,function(u,V,oe,ut){"use strict";var cc=Object.defineProperty;var hc=(u,V,oe)=>V in u?cc(u,V,{enumerable:!0,configurable:!0,writable:!0,value:oe}):u[V]=oe;var g=(u,V,oe)=>hc(u,typeof V!="symbol"?V+"":V,oe);var po,Io;function Ao(t,e){for(var n=0;n<e.length;n++){const s=e[n];if(typeof s!="string"&&!Array.isArray(s)){for(const r in s)if(r!=="default"&&!(r in t)){const i=Object.getOwnPropertyDescriptor(s,r);i&&Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>s[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}function bo(){vo()}const on=typeof global<"u"?global:typeof self<"u"?self:window;function vo(){typeof on.requestIdleCallback!="function"&&(on.requestIdleCallback=function(n){const s=Date.now();return setTimeout(function(){const i=Math.max(0,50-(Date.now()-s));n({didTimeout:i===0,timeRemaining(){return i}})},1)}),typeof on.cancelIdleCallback!="function"&&(on.cancelIdleCallback=function(n){clearTimeout(n)})}const wo="__default_document_sub_component_id20231101__",Ge=2,Ms=1;function To(t,e){if(e==null||t==null)return!0;const{left:n=0,top:s=0,height:r=0,width:i=0,angle:o=0}=e,{left:l=0,top:a=0,height:h=0,width:d=0,angle:c=0}=t,f=d,_=h,E=i,R=r;return Math.abs(l-n)>Ge||Math.abs(a-s)>Ge||Math.abs(f-E)>Ge||Math.abs(_-R)>Ge||Math.abs(c-o)>Ms}function Us(t,e){let n=0,s=t.length-1;for(;n<=s;){const r=Math.floor((s+n)/2);if(e<t[r]&&(r===0||e>=t[r-1]))return r;if(e>=t[r])n=r+1;else if(e<t[r])s=r-1;else return-1}return-1}function Ls(t,e){let n=0,s=0,r=0,i=-1,o=t.length-1;for(;n<t.length&&o>=0&&o>=n;){if(s=t[o],o===0?r=0:r=t[o-1],e>=r&&e<=s){i=o;break}if(s=t[n],n===0?r=0:r=t[n-1],e>=r&&e<s){i=n;break}n++,o--}return i}function Mo(t,e){let n=t.length-1;return e<0?-1:e<t[0]?0:e>t[t.length-1]?Number.POSITIVE_INFINITY:(t.length<40||e<=t[20]||e>=t[n-20]?n=Ls(t,e):n=Us(t,e),n)}function Uo(t){const e=new Blob([t],{type:"text/javascript"});return window.URL.createObjectURL(e)}var Ds=(t=>(t[t.DEFAULT_SERIES=0]="DEFAULT_SERIES",t[t.ALTERNATE_SERIES=1]="ALTERNATE_SERIES",t))(Ds||{}),dt=(t=>(t[t.NONE=0]="NONE",t[t.THIN=1]="THIN",t[t.HAIR=2]="HAIR",t[t.DOTTED=3]="DOTTED",t[t.DASHED=4]="DASHED",t[t.DASH_DOT=5]="DASH_DOT",t[t.DASH_DOT_DOT=6]="DASH_DOT_DOT",t[t.DOUBLE=7]="DOUBLE",t[t.MEDIUM=8]="MEDIUM",t[t.MEDIUM_DASHED=9]="MEDIUM_DASHED",t[t.MEDIUM_DASH_DOT=10]="MEDIUM_DASH_DOT",t[t.MEDIUM_DASH_DOT_DOT=11]="MEDIUM_DASH_DOT_DOT",t[t.SLANT_DASH_DOT=12]="SLANT_DASH_DOT",t[t.THICK=13]="THICK",t))(dt||{}),ys=(t=>(t.TOP="top",t.BOTTOM="bottom",t.LEFT="left",t.RIGHT="right",t.NONE="none",t.ALL="all",t.OUTSIDE="outside",t.INSIDE="inside",t.HORIZONTAL="horizontal",t.VERTICAL="vertical",t.TLBR="tlbr",t.TLBC_TLMR="tlbc_tlmr",t.TLBR_TLBC_TLMR="tlbr_tlbc_tlmr",t.BLTR="bl_tr",t.MLTR_BCTR="mltr_bctr",t))(ys||{}),jt=(t=>(t[t.UNSUPPORTED=0]="UNSUPPORTED",t[t.RGB=1]="RGB",t[t.HEX=2]="HEX",t[t.THEME=3]="THEME",t))(jt||{}),Ps=(t=>(t[t.ON=0]="ON",t[t.OFF=1]="OFF",t))(Ps||{}),ks=(t=>(t[t.PASTE_NORMAL=0]="PASTE_NORMAL",t[t.PASTE_NO_BORDERS=1]="PASTE_NO_BORDERS",t[t.PASTE_FORMAT=2]="PASTE_FORMAT",t[t.PASTE_FORMULA=3]="PASTE_FORMULA",t[t.PASTE_DATA_VALIDATION=4]="PASTE_DATA_VALIDATION",t[t.PASTE_VALUES=5]="PASTE_VALUES",t[t.PASTE_CONDITIONAL_FORMATTING=6]="PASTE_CONDITIONAL_FORMATTING",t[t.PASTE_COLUMN_WIDTHS=7]="PASTE_COLUMN_WIDTHS",t))(ks||{}),Hs=(t=>(t[t.DOCUMENT=0]="DOCUMENT",t[t.PROJECT=1]="PROJECT",t))(Hs||{}),Fs=(t=>(t[t.COLUMNS=0]="COLUMNS",t[t.ROWS=1]="ROWS",t))(Fs||{}),$s=(t=>(t[t.UP=0]="UP",t[t.RIGHT=1]="RIGHT",t[t.DOWN=2]="DOWN",t[t.LEFT=3]="LEFT",t))($s||{});function Lo(t){switch(t){case 3:return 1;case 1:return 3;case 0:return 2;case 2:return 0}}var Ws=(t=>(t[t.NUMBER_FORMAT_TYPE_UNSPECIFIED=0]="NUMBER_FORMAT_TYPE_UNSPECIFIED",t[t.TEXT=1]="TEXT",t[t.NUMBER=2]="NUMBER",t[t.PERCENT=3]="PERCENT",t[t.CURRENCY=4]="CURRENCY",t[t.DATE=5]="DATE",t[t.TIME=6]="TIME",t[t.DATE_TIME=7]="DATE_TIME",t[t.SCIENTIFIC=8]="SCIENTIFIC",t))(Ws||{}),Bs=(t=>(t[t.INTERPOLATION_POINT_TYPE_UNSPECIFIED=0]="INTERPOLATION_POINT_TYPE_UNSPECIFIED",t[t.MIN=1]="MIN",t[t.MAX=2]="MAX",t[t.NUMBER=3]="NUMBER",t[t.PERCENT=4]="PERCENT",t[t.PERCENTILE=5]="PERCENTILE",t))(Bs||{}),Ie=(t=>(t.EN_US="enUS",t.ZH_CN="zhCN",t.RU_RU="ruRU",t))(Ie||{}),Gs=(t=>(t[t.RANGE=0]="RANGE",t[t.SHEET=1]="SHEET",t))(Gs||{}),xs=(t=>(t[t.RELATIVE_DATE_UNSPECIFIED=0]="RELATIVE_DATE_UNSPECIFIED",t[t.PAST_YEAR=1]="PAST_YEAR",t[t.PAST_MONTH=2]="PAST_MONTH",t[t.PAST_WEEK=3]="PAST_WEEK",t[t.YESTERDAY=4]="YESTERDAY",t[t.TODAY=5]="TODAY",t[t.TOMORROW=6]="TOMORROW",t))(xs||{}),ln=(t=>(t[t.GRID=0]="GRID",t[t.KANBAN=1]="KANBAN",t[t.GANTT=2]="GANTT",t))(ln||{}),xe=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",t[t.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",t))(xe||{}),js=(t=>(t[t.DASH=0]="DASH",t[t.DASH_DOT_DOT_HEAVY=1]="DASH_DOT_DOT_HEAVY",t[t.DASH_DOT_HEAVY=2]="DASH_DOT_HEAVY",t[t.DASHED_HEAVY=3]="DASHED_HEAVY",t[t.DASH_LONG=4]="DASH_LONG",t[t.DASH_LONG_HEAVY=5]="DASH_LONG_HEAVY",t[t.DOT_DASH=6]="DOT_DASH",t[t.DOT_DOT_DASH=7]="DOT_DOT_DASH",t[t.DOTTED=8]="DOTTED",t[t.DOTTED_HEAVY=9]="DOTTED_HEAVY",t[t.DOUBLE=10]="DOUBLE",t[t.NONE=11]="NONE",t[t.SINGLE=12]="SINGLE",t[t.THICK=13]="THICK",t[t.WAVE=14]="WAVE",t[t.WAVY_DOUBLE=15]="WAVY_DOUBLE",t[t.WAVY_HEAVY=16]="WAVY_HEAVY",t[t.WORDS=17]="WORDS",t))(js||{}),Oe=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.LEFT=1]="LEFT",t[t.CENTER=2]="CENTER",t[t.RIGHT=3]="RIGHT",t[t.JUSTIFIED=4]="JUSTIFIED",t))(Oe||{}),De=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.TOP=1]="TOP",t[t.MIDDLE=2]="MIDDLE",t[t.BOTTOM=3]="BOTTOM",t))(De||{}),ye=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.OVERFLOW=1]="OVERFLOW",t[t.CLIP=2]="CLIP",t[t.WRAP=3]="WRAP",t))(ye||{}),an=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ITALIC=1]="ITALIC",t))(an||{}),un=(t=>(t[t.NORMAL=0]="NORMAL",t[t.BOLD=1]="BOLD",t))(un||{}),Pe=(t=>(t[t.NORMAL=1]="NORMAL",t[t.SUBSCRIPT=2]="SUBSCRIPT",t[t.SUPERSCRIPT=3]="SUPERSCRIPT",t))(Pe||{}),Y=(t=>(t[t.FALSE=0]="FALSE",t[t.TRUE=1]="TRUE",t))(Y||{}),Se=(t=>(t[t.STRING=1]="STRING",t[t.NUMBER=2]="NUMBER",t[t.BOOLEAN=3]="BOOLEAN",t[t.FORCE_STRING=4]="FORCE_STRING",t))(Se||{}),$t=(t=>(t[t.DARK1=0]="DARK1",t[t.LIGHT1=1]="LIGHT1",t[t.DARK2=2]="DARK2",t[t.LIGHT2=3]="LIGHT2",t[t.ACCENT1=4]="ACCENT1",t[t.ACCENT2=5]="ACCENT2",t[t.ACCENT3=6]="ACCENT3",t[t.ACCENT4=7]="ACCENT4",t[t.ACCENT5=8]="ACCENT5",t[t.ACCENT6=9]="ACCENT6",t[t.HYPERLINK=10]="HYPERLINK",t[t.FOLLOWED_HYPERLINK=11]="FOLLOWED_HYPERLINK",t))($t||{}),cn=(t=>(t.OFFICE="Office",t.OFFICE_2007_2010="Office 2007-2010",t.GRAYSCALE="Grayscale",t.BLUE_WARM="Blue Warm",t.BLUE="Blue",t.BLUE_II="Blue II",t.BLUE_GREEN="Blue Green",t.GREEN="Green",t.GREEN_YELLOW="Green Yellow",t.YELLOW="Yellow",t.YELLOW_ORANGE="Yellow Orange",t.ORANGE="Orange",t.ORANGE_RED="Orange Red",t.RED_ORANGE="Red Orange",t.RED="Red",t.RED_VIOLET="Red Violet",t.VIOLET="Violet",t.VIOLET_II="Violet II",t.MEDIAN="Median",t.PAPER="Paper",t.MARQUEE="Marquee",t.SLIPSTREAM="Slipstream",t.Aspect="Aspect",t))(cn||{}),Vs=(t=>(t.Line="line",t.LineInv="lineInv",t.Triangle="triangle",t.RtTriangle="rtTriangle",t.Rect="rect",t.Diamond="diamond",t.Parallelogram="parallelogram",t.Trapezoid="trapezoid",t.NonIsocelesTrapezoid="nonIsocelesTrapezoid",t.Pentagon="pentagon",t.Hexagon="hexagon",t.Heptagon="heptagon",t.Octagon="octagon",t.Decagon="decagon",t.Dodecagon="dodecagon",t.Star4="star4",t.Star5="star5",t.Star6="star6",t.Star7="star7",t.Star8="star8",t.Star10="star10",t.Star12="star12",t.Star16="star16",t.Star24="star24",t.Star32="star32",t.RoundRect="roundRect",t.Round1Rect="round1Rect",t.Round2SameRect="round2SameRect",t.Round2DiagRect="round2DiagRect",t.Ellipse="ellipse",t))(Vs||{}),Ks=(t=>(t.RightArrow="rightArrow",t.LeftArrow="leftArrow",t.UpArrow="upArrow",t.DownArrow="downArrow",t.LeftRightArrow="leftRightArrow",t.UpDownArrow="upDownArrow",t.QuadArrow="quadArrow",t.LeftRightUpArrow="leftRightUpArrow",t.BentArrow="bentArrow",t.UturnArrow="uturnArrow",t.CircularArrow="circularArrow",t.NotchedRightArrow="notchedRightArrow",t.HomePlate="homePlate",t.Chevron="chevron",t.LeftCircularArrow="leftCircularArrow",t.LeftRightCircularArrow="leftRightCircularArrow",t))(Ks||{}),Ys=(t=>(t.Plaque="plaque",t.Can="can",t.Cube="cube",t.Bevel="bevel",t.Donut="donut",t.NoSmoking="noSmoking",t.BlockArc="blockArc",t.FoldedCorner="foldedCorner",t))(Ys||{}),zs=(t=>(t.SmileyFace="smileyFace",t.Heart="heart",t.LightningBolt="lightningBolt",t.Sun="sun",t.Moon="moon",t.Cloud="cloud",t.Arc="arc",t.Backpack="backpack",t.Frame="frame",t.HalfFrame="halfFrame",t.Corner="corner",t.Chord="chord",t.Pie="pie",t.Teardrop="teardrop",t.WedgeRectCallout="wedgeRectCallout",t.WedgeRRectCallout="wedgeRRectCallout",t.WedgeEllipseCallout="wedgeEllipseCallout",t.CloudCallout="cloudCallout",t.BorderCallout1="borderCallout1",t.BorderCallout2="borderCallout2",t.BorderCallout3="borderCallout3",t.AccentCallout1="accentCallout1",t.AccentCallout2="accentCallout2",t.AccentCallout3="accentCallout3",t.Callout1="callout1",t.Callout2="callout2",t.Callout3="callout3",t.ActionButtonBackPrevious="actionButtonBackPrevious",t.ActionButtonEnd="actionButtonEnd",t.ActionButtonForwardNext="actionButtonForwardNext",t.ActionButtonHelp="actionButtonHelp",t.ActionButtonHome="actionButtonHome",t.ActionButtonInformation="actionButtonInformation",t.ActionButtonMovie="actionButtonMovie",t.ActionButtonReturn="actionButtonReturn",t.ActionButtonSound="actionButtonSound",t))(zs||{});const Xs={[cn.OFFICE]:{[$t.ACCENT1]:"#4472C4",[$t.ACCENT2]:"#ED7D31",[$t.ACCENT3]:"#A5A5A5",[$t.ACCENT4]:"#70AD47",[$t.ACCENT5]:"#5B9BD5",[$t.ACCENT6]:"#70AD47",[$t.DARK1]:"#000000",[$t.DARK2]:"#44546A",[$t.LIGHT1]:"#FFFFFF",[$t.LIGHT2]:"#E7E6E6",[$t.HYPERLINK]:"#0563C1",[$t.FOLLOWED_HYPERLINK]:"#954F72"}};class hn{constructor(){g(this,"_themeValue",$t.LIGHT1);g(this,"_themeColors");g(this,"_themeTint");g(this,"_rgbValue","");g(this,"_colorType");this._colorType=jt.UNSUPPORTED,this._themeColors=cn.OFFICE,this._themeTint=0}asRgbColor(){return new dn(this._rgbValue,this)}asThemeColor(){return new fn(this._themeValue,this._themeTint,this._themeColors,this)}build(){switch(this._colorType){case jt.THEME:return this.asThemeColor();case jt.RGB:return this.asRgbColor();case jt.UNSUPPORTED:throw new Error("unsupported color type")}}setRgbColor(e){return this._colorType=jt.RGB,this._rgbValue=e,this}setThemeColors(e){this._colorType=jt.THEME,this._themeColors=e}setThemeTint(e){this._colorType=jt.THEME,this._themeTint=e}setThemeColor(e){return this._colorType=jt.THEME,this._themeValue=e,this}getColorType(){return this._colorType}}class Ne{constructor(e){g(this,"_builder");this._builder=e}static rgbColorToHexValue(e){return`#${((1<<24)+(e.getRed()<<16)+(e.getGreen()<<8)+e.getBlue()).toString(16).slice(1)}`}static hexValueToRgbColor(e){e?e.indexOf("#")>-1&&(e=e.substring(1)):e="#000000";const n=+`0x${e[0]}${e[1]}`,s=+`0x${e[2]}${e[3]}`,r=+`0x${e[4]}${e[5]}`;return new hn().setRgbColor(`rgb(${n},${s},${r})`).asRgbColor()}static hexToRgbString(e){const n=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;e=e.replace(n,(i,o,l,a)=>o+o+l+l+a+a);const s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);let r=null;if(s){const i=Number.parseInt(s[1],16),o=Number.parseInt(s[2],16),l=Number.parseInt(s[3],16);r=`rgba(${i},${o},${l})`}return r}asRgbColor(){return this._builder.asRgbColor()}asThemeColor(){return this._builder.asThemeColor()}getColorType(){return this._builder.getColorType()}clone(){return new Ne(this._builder)}equals(e){return!1}}class qs{constructor(e){g(this,"_saturation",0);g(this,"_hue",0);g(this,"_lightness",0);g(this,"_alpha",0);const n=e.getRed()/255,s=e.getGreen()/255,r=e.getBlue()/255,i=e.getAlpha()/255,o=Math.min(n,Math.min(s,r)),l=Math.max(n,Math.max(s,r)),a=l-o;if(l===o){this._hue=0,this._saturation=0,this._lightness=l;return}this._lightness=(o+l)/2,this._lightness<.5?this._saturation=a/(l+o):this._saturation=a/(2-l-o),n===l&&(this._hue=(s-r)/a),s===l&&(this._hue=2+(r-n)/a),r===l&&(this._hue=4+(n-s)/a),this._hue*=60,this._hue<0&&(this._hue+=360),this._alpha=i}asRgbColor(){const e=new hn;if(this._saturation===0)return e.setRgbColor(`rgba(${this._lightness*255},${this._lightness*255},${this._lightness*255},${this._alpha*255})`),e.asRgbColor();let n;this._lightness<.5?n=this._lightness*(1+this._saturation):n=this._lightness+this._saturation-this._lightness*this._saturation;const s=2*this._lightness-n,r=this._hue/360,i=r+1/3,o=this.setColor(n,s,i),l=this.setColor(n,s,r),a=r-1/3,h=this.setColor(n,s,a);return e.setRgbColor(`rgba(${Math.round(o*255)},${Math.round(l*255)},${Math.round(h*255)},${this._alpha*255})`),e.asRgbColor()}getLightness(){return this._lightness}getHue(){return this._hue}getSaturation(){return this._saturation}getAlpha(){return this._alpha}setColor(e,n,s){s<0&&(s+=1),s>1&&(s-=1);let r;return 6*s<1?r=n+(e-n)*6*s:2*s<1?r=e:3*s<2?r=n+(e-n)*(2/3-s)*6:r=n,r}setLightness(e){this._lightness=e}}const Kt=class Kt extends Ne{constructor(n,s){super(s);g(this,"_cssString");g(this,"_red");g(this,"_green");g(this,"_blue");g(this,"_alpha");let r=n.match(Kt.RGBA_EXTRACT);if(r){const i=+r[1],o=+r[2],l=+r[3],a=+r[4];this._cssString=n,this._red=i,this._green=o,this._blue=l,this._alpha=a;return}if(r=n.match(Kt.RGB_EXTRACT),r){const i=+r[1],o=+r[2],l=+r[3];this._cssString=n,this._red=i,this._green=o,this._blue=l,this._alpha=1;return}throw new Error("Invalid rgba or rgb color")}asHexString(){return Ne.rgbColorToHexValue(this)}getRed(){let n=this._red+Kt.RGB_COLOR_AMT;return n>255?n=255:n<0&&(n=0),n}getGreen(){let n=this._green+Kt.RGB_COLOR_AMT;return n>255?n=255:n<0&&(n=0),n}getBlue(){let n=this._blue+Kt.RGB_COLOR_AMT;return n>255?n=255:n<0&&(n=0),n}getAlpha(){return this._alpha}getColorType(){return jt.RGB}clone(){return new Kt(this._cssString,this._builder)}asThemeColor(){throw new Error("rgb color not support to themeColor")}equals(n){return n instanceof Kt?n._red===this._red&&n._blue===this._blue&&n._green===this._green&&n._alpha===this._alpha:!1}getCssString(){return this._cssString}};g(Kt,"RGB_COLOR_AMT",0),g(Kt,"RGBA_EXTRACT",new RegExp("\\s*rgba\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d.\\d|\\d\\s*)\\)\\s*")),g(Kt,"RGB_EXTRACT",new RegExp("\\s*rgb\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*)\\)\\s*"));let dn=Kt;const Ce=class Ce extends Ne{constructor(n,s,r,i){super(i);g(this,"_themeColorType");g(this,"_themeTint");g(this,"_themeColors");this._themeColorType=n,this._themeTint=s,this._themeColors=r}lumValue(n,s){if(n==null)return s;let r;return n<0?r=s*(1+n):r=s*(1-n)+(255-255*(1-n)),r}asRgbColor(){const n=Xs[this._themeColors];if(n==null)throw new Error("not find themeColors type");const s=n[this._themeColorType];if(s==null)throw new Error("not find themeColors value");let r;if(Ce._cacheThemeColor.has(this._themeColors)){if(r=Ce._cacheThemeColor.get(this._themeColors),r.has(this._themeColorType))return r.get(this._themeColorType)}else r=new Map,Ce._cacheThemeColor.set(this._themeColors,r);const i=new qs(Ne.hexValueToRgbColor(s));i.setLightness(this.lumValue(this._themeTint,i.getLightness()*255)/255);const o=i.asRgbColor();return r.set(this._themeColorType,o),o}clone(){return new Ce(this._themeColorType,this._themeTint,this._themeColors,this._builder)}equals(n){return n instanceof Ce?n._themeColorType===this._themeColorType:!1}getColorType(){return jt.THEME}getThemeColorType(){return this._themeColorType}};g(Ce,"_cacheThemeColor",new Map);let fn=Ce;const Do="rgb(",yo="rgba(",Hn={aliceBlue:[240,248,255],antiqueWhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blancheAlmond:[255,235,205],blue:[0,0,255],blueViolet:[138,43,226],brown:[165,42,42],burlyWood:[222,184,135],cadetBlue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornFlowerBlue:[100,149,237],cornSilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkCyan:[0,139,139],darkGoldenrod:[184,132,11],darkGray:[169,169,169],darkGreen:[0,100,0],darkGrey:[169,169,169],darkKhaki:[189,183,107],darkMagenta:[139,0,139],darkOliveGreen:[85,107,47],darkOrange:[255,140,0],darkOrchid:[153,50,204],darkRed:[139,0,0],darkSalmon:[233,150,122],darkSeaGreen:[143,188,143],darkSlateBlue:[72,61,139],darkSlateGray:[47,79,79],darkSlateGrey:[47,79,79],darkTurquoise:[0,206,209],darkViolet:[148,0,211],deepPink:[255,20,147],deepSkyBlue:[0,191,255],dimGray:[105,105,105],dimGrey:[105,105,105],dodgerBlue:[30,144,255],firebrick:[178,34,34],floralWhite:[255,255,240],forestGreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostWhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenYellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotPink:[255,105,180],indianRed:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderBlush:[255,240,245],lawnGreen:[124,252,0],lemonChiffon:[255,250,205],lightblue:[173,216,230],lightCoral:[240,128,128],lightCyan:[224,255,255],lightGoldenrodYellow:[250,250,210],lightGray:[211,211,211],lightGreen:[144,238,144],lightGrey:[211,211,211],lightPink:[255,182,193],lightSalmon:[255,160,122],lightSeaGreen:[32,178,170],lightSkyBlue:[135,206,250],lightSlateGray:[119,136,153],lightSlateGrey:[119,136,153],lightSteelBlue:[176,196,222],lightYellow:[255,255,224],lime:[0,255,0],limeGreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumAquamarine:[102,205,170],mediumBlue:[0,0,205],mediumOrchid:[186,85,211],mediumPurple:[147,112,219],mediumSeaGreen:[60,179,113],mediumSlateBlue:[123,104,238],mediumSpringGreen:[0,250,154],mediumTurquoise:[72,209,204],mediumVioletRed:[199,21,133],midBightBlue:[25,25,112],mintCream:[245,255,250],mistyRose:[255,228,225],moccasin:[255,228,181],navajoWhite:[255,222,173],navy:[0,0,128],oldLace:[253,245,230],olive:[128,128,0],oliveDrab:[107,142,35],orange:[255,165,0],orangeRed:[255,69,0],orchid:[218,112,214],paleGoldenrod:[238,232,170],paleGreen:[152,251,152],paleTurquoise:[175,238,238],paleVioletRed:[219,112,147],papayaWhip:[255,239,213],peachPuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderBlue:[176,224,230],purple:[128,0,128],rebeccaPurple:[102,51,153],red:[255,0,0],rosyBrown:[188,143,143],royalBlue:[65,105,225],saddleBrown:[139,69,19],salmon:[250,128,114],sandyBrown:[244,164,96],seaGreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyBlue:[135,206,235],slateBlue:[106,90,205],slateGray:[119,128,144],slateGrey:[119,128,144],snow:[255,255,250],springGreen:[0,255,127],steelBlue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whiteSmoke:[245,245,245],yellow:[255,255,0],yellowGreen:[154,205,5]};class Jt{constructor(e){g(this,"_color");g(this,"_rgbColor");g(this,"_isValid",!1);if(e==null){this._setNullColor();return}if(e instanceof Jt){this._color={...e._color},this._rgbColor={...e._rgbColor};return}const n=Js(e);if(n==null){this._setNullColor();return}this._color=n;const s=$o(this._color);if(s==null){this._setNullColor();return}this._rgbColor=s,this._isValid=!0}static mix(e,n,s){var h,d;s=Math.min(1,Math.max(0,s));const r=new Jt(e).toRgb(),i=new Jt(n).toRgb(),o=(h=r.a)!=null?h:1,l=(d=i.a)!=null?d:1,a={r:(i.r-r.r)*s+r.r,g:(i.g-r.g)*s+r.g,b:(i.b-r.b)*s+r.b,a:(l-o)*s+o};return new Jt(a)}static getContrastRatio(e,n){const s=new Jt(e).getLuminance(),r=new Jt(n).getLuminance();return(Math.max(s,r)+.05)/(Math.min(s,r)+.05)}get isValid(){return this._isValid}toRgb(){return this._rgbColor}toRgbString(){const{r:e,g:n,b:s,a:r=1}=this.toRgb(),i=r<1;return`rgb${i?"a":""}(${e},${n},${s}${i?`,${r}`:""})`}toString(){return this.toRgbString()}toHexString(e){const{r:n,g:s,b:r,a:i=1}=this.toRgb(),o=i<1,l=[_n(Math.round(n).toString(16)),_n(Math.round(s).toString(16)),_n(Math.round(r).toString(16)),_n(Math.round(i*255).toString(16))];return e&&l[0][0]===l[0][1]&&l[1][0]===l[1][1]&&l[2][0]===l[2][1]&&l[3][0]===l[3][1]?o?`#${l[0][0]}${l[1][0]}${l[2][0]}${l[3][0]}`:`#${l[0][0]}${l[1][0]}${l[2][0]}`:o?`#${l[0]}${l[1]}${l[2]}${l[3]}`:`#${l[0]}${l[1]}${l[2]}`}toHsv(){return xo(this.toRgb())}toHsl(){return Go(this.toRgb())}lighten(e=10){const n=this.toHsl();return n.l+=e,n.l=Math.min(Math.max(n.l,0),100),new Jt(n)}darken(e=10){const n=this.toHsl();return n.l-=e,n.l=Math.min(Math.max(n.l,0),100),new Jt(n)}setAlpha(e){return new Jt({...this._rgbColor,a:e})}getLuminance(){let{r:e,g:n,b:s}=this.toRgb();return e=Fn(e),n=Fn(n),s=Fn(s),Number((.2126*e+.7152*n+.0722*s).toFixed(3))}getBrightness(){const{r:e,g:n,b:s}=this.toRgb();return(e*299+n*587+s*114)/1e3}getAlpha(){var e;return(e=this._color.a)!=null?e:1}isDark(){return this.getBrightness()<128}isLight(){return!this.isDark()}_setNullColor(){this._isValid=!1,this._color={r:0,g:0,b:0,a:0},this._rgbColor={r:0,g:0,b:0,a:0}}}const _n=t=>t.length===1?`0${t}`:t,Fn=t=>(t/=255,t<=.03928?t/12.92:((t+.055)/1.055)**2.4),Js=t=>{if(Vo(t)){if("r"in t){const s={r:Math.round(t.r),g:Math.round(t.g),b:Math.round(t.b)};return t.a!==void 0&&(s.a=t.a),s}if("l"in t){const s={h:Math.round(t.h),s:t.s,l:t.l};return t.a!==void 0&&(s.a=t.a),s}const n={h:Math.round(t.h),s:t.s,v:t.v};return t.a!==void 0&&(n.a=t.a),n}const e=t.trim();if(Hn[e]){const n=Hn[e],s={r:Math.round(n[0]),g:Math.round(n[1]),b:Math.round(n[2])};return s.a=n[3]||1,s}if(e.startsWith("#"))return Po(e);if(e.startsWith("rgb"))return ko(e);if(e.startsWith("hsl"))return Ho(e);if(e.startsWith("hsv"))return Fo(e)},Po=t=>{const e=t.substring(1),n=new RegExp(`.{1,${e.length>=6?2:1}}`,"g");let s=e.match(n);if(!s||s.length<3)throw new Error(`The color '${t}' is illegal hex color`);s[0].length===1&&(s=s.map(i=>i+i));const r={r:Number.parseInt(s[0],16),g:Number.parseInt(s[1],16),b:Number.parseInt(s[2],16)};return s.length>3&&(r.a=Number.parseInt(s[3],16)/255),r},ko=t=>{const e=t.indexOf("(");if(e===-1)throw new Error(`The color '${t}' is illegal rgb color`);const n=t.substring(e+1,t.length-1).split(",");if(n.length<3)throw new Error(`The color '${t}' is illegal rgb color`);const s={r:Number.parseInt(n[0],10),g:Number.parseInt(n[1],10),b:Number.parseInt(n[2],10)};return n.length>3&&(s.a=Number.parseFloat(n[3])),s},Ho=t=>{const e=t.indexOf("(");if(e===-1)throw new Error(`The color '${t}' is illegal hsl color`);const n=t.substring(e+1,t.length-1).split(",");if(n.length<3)throw new Error(`The color '${t}' is illegal hsl color`);const s={h:Number.parseInt(n[0],10),s:Number.parseFloat(n[1]),l:Number.parseFloat(n[2])};return n.length>3&&(s.a=Number.parseFloat(n[3])),s},Fo=t=>{const e=t.indexOf("(");if(e===-1)throw new Error(`The color '${t}' is illegal hsv color`);const n=t.substring(e+1,t.length-1).split(",");if(n.length<3)throw new Error(`The color '${t}' is illegal hsv color`);const s={h:Number.parseInt(n[0],10),s:Number.parseFloat(n[1]),v:Number.parseFloat(n[2])};return n.length>3&&(s.a=Number.parseFloat(n[3])),s},$o=t=>{const e=Js(t);if(e!=null)return"r"in e?e:"l"in e?Wo(e):Bo(e)},$n=(t,e,n)=>(n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t),Wo=t=>{let{h:e,s:n,l:s}=t;e/=360,n/=100,s/=100;let r=0,i=0,o=0;if(n===0)r=i=o=s;else{const a=s<.5?s*(1+n):s+n-s*n,h=2*s-a;r=$n(h,a,e+1/3),i=$n(h,a,e),o=$n(h,a,e-1/3)}const l={r:Math.round(r*255),g:Math.round(i*255),b:Math.round(o*255)};return t.a!==void 0&&(l.a=t.a),l},Bo=t=>{let{h:e,s:n,v:s}=t;e=e/360*6,n/=100,s/=100;const r=Math.floor(e),i=e-r,o=s*(1-n),l=s*(1-i*n),a=s*(1-(1-i)*n),h=r%6,d=[s,l,o,o,a,s][h],c=[a,s,s,l,o,o][h],f=[o,o,a,s,s,l][h],_={r:d*255,g:c*255,b:f*255};return t.a!==void 0&&(_.a=t.a),_},Go=t=>{let{r:e,g:n,b:s}=t;e/=255,n/=255,s/=255;const r=Math.max(e,n,s),i=Math.min(e,n,s),o=(r+i)/2;let l,a;if(r===i)l=a=0;else{const d=r-i;switch(a=o>.5?d/(2-r-i):d/(r+i),r){case e:l=(n-s)/d+(n<s?6:0);break;case n:l=(s-e)/d+2;break;default:l=(e-n)/d+4;break}l/=6}const h={h:Math.round(l*360),s:Math.round(a*100),l:Math.round(o*100)};return t.a!==void 0&&(h.a=t.a),h},xo=t=>{let{r:e,g:n,b:s}=t;e/=255,n/=255,s/=255;const r=Math.max(e,n,s),i=Math.min(e,n,s);let o;const l=r,a=r-i,h=r===0?0:a/r;if(r===i)o=0;else{switch(r){case e:o=(n-s)/a+(n<s?6:0);break;case n:o=(s-e)/a+2;break;default:o=(e-n)/a+4;break}o/=6}const d={h:Math.round(o*360),s:Math.round(h*100),v:Math.round(l*100)};return t.a!==void 0&&(d.a=t.a),d},jo=t=>t==null,Vo=t=>!jo(t)&&typeof t=="object";function Ko(t){const e=/^#(?:[0]{3}|[0]{6})\b/,n=/^rgb\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*\)$/,s=/^rgba\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*,\s*(1|1\.0*|0?\.\d+)\)$/,r=/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*\)$/,i=/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/;return!!(e.test(t)||n.test(t)||s.test(t)||r.test(t)||i.test(t))}function Yo(t){const e=/^#(?:[Ff]{3}|[Ff]{6})\b/,n=/^rgb\s*\(\s*255\s*,\s*255\s*,\s*255\s*\)$/,s=/^rgba\s*\(\s*255\s*,\s*255\s*,\s*255\s*,\s*(1|1\.0*|0?\.\d+)\)$/,r=/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*\)$/,i=/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/;return!!(e.test(t)||n.test(t)||s.test(t)||r.test(t)||i.test(t))}var kt=(t=>(t[t.COVER=0]="COVER",t[t.REPLACE=1]="REPLACE",t[t.INTERSECTION=2]="INTERSECTION",t))(kt||{});function zo(t){return t&&(t.s!==void 0||t.p!==void 0||t.v!==void 0||t.t!==void 0||t.f!==void 0||t.si!==void 0)}function Xo(t){if(t.t!==void 0)return t.t;if(typeof t.v=="string")return Se.STRING;if(typeof t.v=="number")return Se.NUMBER;if(typeof t.v=="boolean")return Se.BOOLEAN}function qo(t){if(t==null)return!0;const{v:e,f:n,si:s,p:r,s:i,custom:o}=t;return!(!(e==null||typeof e=="string"&&e.length===0)||n!=null&&n.length>0||s!=null&&s.length>0||r!=null||o!=null)}function Jo(t){return t!=null&&(typeof t=="string"||typeof t=="number"||typeof t=="boolean")}var Zs=(t=>(t[t.character=0]="character",t[t.paragraph=1]="paragraph",t[t.table=2]="table",t[t.numbering=3]="numbering",t))(Zs||{}),Qs=(t=>(t[t.TAB=0]="TAB",t[t.SPACE=1]="SPACE",t[t.NOTHING=2]="NOTHING",t))(Qs||{}),je=(t=>(t[t.GLYPH_TYPE_UNSPECIFIED=0]="GLYPH_TYPE_UNSPECIFIED",t[t.NONE=1]="NONE",t[t.DECIMAL=2]="DECIMAL",t[t.ZERO_DECIMAL=3]="ZERO_DECIMAL",t[t.UPPER_ALPHA=4]="UPPER_ALPHA",t[t.ALPHA=5]="ALPHA",t[t.UPPER_ROMAN=6]="UPPER_ROMAN",t[t.ROMAN=7]="ROMAN",t))(je||{}),fe=(t=>(t[t.BULLET_ALIGNMENT_UNSPECIFIED=0]="BULLET_ALIGNMENT_UNSPECIFIED",t[t.START=1]="START",t[t.CENTER=2]="CENTER",t[t.END=3]="END",t))(fe||{}),tr=(t=>(t[t.HYPERLINK=0]="HYPERLINK",t[t.FIELD=1]="FIELD",t[t.SDT=2]="SDT",t[t.BOOKMARK=3]="BOOKMARK",t[t.COMMENT=4]="COMMENT",t[t.CUSTOM=5]="CUSTOM",t[t.MENTION=6]="MENTION",t))(tr||{}),er=(t=>(t[t.COMMENT=0]="COMMENT",t))(er||{}),nr=(t=>(t[t.DRAWING=0]="DRAWING",t[t.CUSTOM=1]="CUSTOM",t))(nr||{}),sr=(t=>(t[t.TRADITIONAL=0]="TRADITIONAL",t[t.MODERN=1]="MODERN",t))(sr||{}),rr=(t=>(t[t.DEFAULT=0]="DEFAULT",t[t.LINES=1]="LINES",t[t.LINES_AND_CHARS=2]="LINES_AND_CHARS",t[t.SNAP_TO_CHARS=3]="SNAP_TO_CHARS",t))(rr||{}),ir=(t=>(t[t.SECTION_TYPE_UNSPECIFIED=0]="SECTION_TYPE_UNSPECIFIED",t[t.CONTINUOUS=1]="CONTINUOUS",t[t.NEXT_PAGE=2]="NEXT_PAGE",t[t.EVEN_PAGE=3]="EVEN_PAGE",t[t.ODD_PAGE=4]="ODD_PAGE",t))(ir||{}),or=(t=>(t[t.COLUMN_SEPARATOR_STYLE_UNSPECIFIED=0]="COLUMN_SEPARATOR_STYLE_UNSPECIFIED",t[t.NONE=1]="NONE",t[t.BETWEEN_EACH_COLUMN=2]="BETWEEN_EACH_COLUMN",t))(or||{}),lr=(t=>(t[t.NORMAL=0]="NORMAL",t[t.TBRL=1]="TBRL",t[t.LRTBV=2]="LRTBV",t))(lr||{}),ar=(t=>(t[t.TEXT_RUN=0]="TEXT_RUN",t[t.AUTO_TEXT=1]="AUTO_TEXT",t[t.PAGE_BREAK=2]="PAGE_BREAK",t[t.COLUMN_BREAK=3]="COLUMN_BREAK",t[t.FOOT_NOTE_REFERENCE=4]="FOOT_NOTE_REFERENCE",t[t.HORIZONTAL_RULE=5]="HORIZONTAL_RULE",t[t.EQUATION=6]="EQUATION",t[t.DRAWING=7]="DRAWING",t[t.PERSON=8]="PERSON",t[t.RICH_LINK=9]="RICH_LINK",t))(ar||{}),ur=(t=>(t[t.BOTH_SIDES=0]="BOTH_SIDES",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.LARGEST=3]="LARGEST",t))(ur||{}),cr=(t=>(t[t.INLINE=0]="INLINE",t[t.WRAP_NONE=1]="WRAP_NONE",t[t.WRAP_POLYGON=2]="WRAP_POLYGON",t[t.WRAP_SQUARE=3]="WRAP_SQUARE",t[t.WRAP_THROUGH=4]="WRAP_THROUGH",t[t.WRAP_TIGHT=5]="WRAP_TIGHT",t[t.WRAP_TOP_AND_BOTTOM=6]="WRAP_TOP_AND_BOTTOM",t))(cr||{}),hr=(t=>(t[t.NAMED_STYLE_TYPE_UNSPECIFIED=0]="NAMED_STYLE_TYPE_UNSPECIFIED",t[t.NORMAL_TEXT=1]="NORMAL_TEXT",t[t.TITLE=2]="TITLE",t[t.SUBTITLE=3]="SUBTITLE",t[t.HEADING_1=4]="HEADING_1",t[t.HEADING_2=5]="HEADING_2",t[t.HEADING_3=6]="HEADING_3",t[t.HEADING_4=7]="HEADING_4",t[t.HEADING_5=8]="HEADING_5",t[t.HEADING_6=9]="HEADING_6",t))(hr||{}),dr=(t=>(t[t.AUTO=0]="AUTO",t[t.AT_LEAST=1]="AT_LEAST",t[t.EXACT=2]="EXACT",t))(dr||{}),fr=(t=>(t[t.DASH_STYLE_UNSPECIFIED=0]="DASH_STYLE_UNSPECIFIED",t[t.SOLID=1]="SOLID",t[t.DOT=2]="DOT",t[t.DASH=3]="DASH",t))(fr||{}),_r=(t=>(t[t.TAB_STOP_ALIGNMENT_UNSPECIFIED=0]="TAB_STOP_ALIGNMENT_UNSPECIFIED",t[t.START=1]="START",t[t.CENTER=2]="CENTER",t[t.END=3]="END",t))(_r||{}),gr=(t=>(t.EVENLY_DISTRIBUTED="0",t.FIXED_WIDTH="1",t))(gr||{}),mr=(t=>(t[t.CONTENT_ALIGNMENT_UNSPECIFIED=0]="CONTENT_ALIGNMENT_UNSPECIFIED",t[t.CONTENT_ALIGNMENT_UNSUPPORTED=1]="CONTENT_ALIGNMENT_UNSUPPORTED",t[t.TOP=2]="TOP",t[t.MIDDLE=3]="MIDDLE",t[t.BOTTOM=4]="BOTTOM",t))(mr||{}),Er=(t=>(t.NORMAL="normal",t.BOLD="bold",t.ITALIC="italic",t))(Er||{}),Rr=(t=>(t[t.PAGE=0]="PAGE",t[t.COLUMN=1]="COLUMN",t[t.CHARACTER=2]="CHARACTER",t[t.MARGIN=3]="MARGIN",t[t.INSIDE_MARGIN=4]="INSIDE_MARGIN",t[t.OUTSIDE_MARGIN=5]="OUTSIDE_MARGIN",t[t.LEFT_MARGIN=6]="LEFT_MARGIN",t[t.RIGHT_MARGIN=7]="RIGHT_MARGIN",t))(Rr||{}),Cr=(t=>(t[t.PAGE=0]="PAGE",t[t.PARAGRAPH=1]="PARAGRAPH",t[t.LINE=2]="LINE",t[t.MARGIN=3]="MARGIN",t[t.TOP_MARGIN=4]="TOP_MARGIN",t[t.BOTTOM_MARGIN=5]="BOTTOM_MARGIN",t[t.INSIDE_MARGIN=6]="INSIDE_MARGIN",t[t.OUTSIDE_MARGIN=7]="OUTSIDE_MARGIN",t))(Cr||{}),pr=(t=>(t[t.POINT=0]="POINT",t[t.LINE=1]="LINE",t[t.CHARACTER=2]="CHARACTER",t))(pr||{}),Ir=(t=>(t[t.CENTER=0]="CENTER",t[t.INSIDE=1]="INSIDE",t[t.LEFT=2]="LEFT",t[t.OUTSIDE=3]="OUTSIDE",t[t.RIGHT=4]="RIGHT",t))(Ir||{}),Or=(t=>(t[t.BOTTOM=0]="BOTTOM",t[t.CENTER=1]="CENTER",t[t.INSIDE=2]="INSIDE",t[t.OUTSIDE=3]="OUTSIDE",t[t.TOP=4]="TOP",t))(Or||{}),Sr=(t=>(t[t.compressPunctuation=0]="compressPunctuation",t[t.compressPunctuationAndJapaneseKana=1]="compressPunctuationAndJapaneseKana",t[t.doNotCompress=2]="doNotCompress",t))(Sr||{}),Nr=(t=>(t[t.PORTRAIT=0]="PORTRAIT",t[t.LANDSCAPE=1]="LANDSCAPE",t))(Nr||{}),Ar=(t=>(t[t.forward=0]="forward",t[t.backward=1]="backward",t[t.front=2]="front",t[t.back=3]="back",t))(Ar||{}),br=(t=>(t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t[t.DRAWING_IMAGE=0]="DRAWING_IMAGE",t[t.DRAWING_SHAPE=1]="DRAWING_SHAPE",t[t.DRAWING_CHART=2]="DRAWING_CHART",t[t.DRAWING_TABLE=3]="DRAWING_TABLE",t[t.DRAWING_SMART_ART=4]="DRAWING_SMART_ART",t[t.DRAWING_VIDEO=5]="DRAWING_VIDEO",t[t.DRAWING_GROUP=6]="DRAWING_GROUP",t[t.DRAWING_UNIT=7]="DRAWING_UNIT",t[t.DRAWING_DOM=8]="DRAWING_DOM",t))(br||{}),ot=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(ot||{}),Nt=(t=>(t[t.NONE=0]="NONE",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(Nt||{});function Zo(t){return[t.startRow,t.startColumn,t.endRow,t.endColumn]}function Qo(t,e,n){let s=!1,r=!1,i=t,o=e,l=t,a=e;if(n==null)return{actualRow:t,actualColumn:e,isMergedMainCell:r,isMerged:s,endRow:i,endColumn:o,startRow:l,startColumn:a};for(let h=0;h<n.length;h++){const{startRow:d,endRow:c,startColumn:f,endColumn:_}=n[h];if(t===d&&e===f){i=c,o=_,l=d,a=f,r=!0;break}if(t>=d&&t<=c&&e>=f&&e<=_){i=c,o=_,l=d,a=f,s=!0;break}}return{actualRow:t,actualColumn:e,isMergedMainCell:r,isMerged:s,endRow:i,endColumn:o,startRow:l,startColumn:a}}var Wn=(t=>(t[t.SLIDE=0]="SLIDE",t[t.MASTER=1]="MASTER",t[t.LAYOUT=2]="LAYOUT",t[t.HANDOUT_MASTER=3]="HANDOUT_MASTER",t[t.NOTES_MASTER=4]="NOTES_MASTER",t))(Wn||{}),vr=(t=>(t[t.SHAPE=0]="SHAPE",t[t.IMAGE=1]="IMAGE",t[t.TEXT=2]="TEXT",t[t.SPREADSHEET=3]="SPREADSHEET",t[t.DOCUMENT=4]="DOCUMENT",t[t.SLIDE=5]="SLIDE",t))(vr||{}),wr=(t=>(t[t.RELATIVE_SLIDE_LINK_UNSPECIFIED=0]="RELATIVE_SLIDE_LINK_UNSPECIFIED",t[t.NEXT_SLIDE=1]="NEXT_SLIDE",t[t.PREVIOUS_SLIDE=2]="PREVIOUS_SLIDE",t[t.FIRST_SLIDE=3]="FIRST_SLIDE",t[t.LAST_SLIDE=4]="LAST_SLIDE",t))(wr||{});const tl="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let el=t=>crypto.getRandomValues(new Uint8Array(t)),nl=(t,e,n)=>{let s=(2<<Math.log(t.length-1)/Math.LN2)-1,r=-~(1.6*s*e/t.length);return(i=e)=>{let o="";for(;;){let l=n(r),a=r;for(;a--;)if(o+=t[l[a]&s]||"",o.length===i)return o}}},sl=(t,e=21)=>nl(t,e,el),rl=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=tl[n[t]&63];return e};const il=/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi,ol=new RegExp(il);function ll(t){return Number.isNaN(+t)?t.startsWith("http://localhost:3002")||t.startsWith("localhost:3002")?!0:!!t.match(ol):!1}const al=/^-ms-/,ul=/-([a-z])/g,_e=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];class y{static stringAt(e){let n="",s=e;for(;s>=_e.length;)s/=_e.length,s-=1,n+=_e[s%_e.length];const r=e%_e.length;return n+=_e[r],n}static indexAt(e){let n=0;for(let s=0;s<e.length-1;s+=1){const r=e.charCodeAt(s)-65,i=e.length-1-s;n+=_e.length**i+_e.length*r}return n+=e.charCodeAt(e.length-1)-65,n}static deleteBlank(e){return y.isString(e)?e.replace(/\s/g,""):e}static getSystemType(){const e=navigator.userAgent,n=navigator.platform==="Win32"||navigator.platform==="Windows",s=navigator.platform==="Mac68K"||navigator.platform==="MacPPC"||navigator.platform==="Macintosh"||navigator.platform==="MacIntel";if(s)return"Mac";if(navigator.platform==="X11"&&!n&&!s)return"Unix";if(String(navigator.platform).indexOf("Linux")>-1)return"Linux";if(n){if(e.indexOf("Windows NT 5.0")>-1||e.indexOf("Windows 2000")>-1)return"Windows 2000";if(e.indexOf("Windows NT 5.1")>-1||e.indexOf("Windows XP")>-1)return"Windows XP";if(e.indexOf("Windows NT 5.2")>-1||e.indexOf("Windows 2003")>-1)return"Windows 2003";if(e.indexOf("Windows NT 6.0")>-1||e.indexOf("Windows Vista")>-1)return"Windows Vista";if(e.indexOf("Windows NT 6.1")>-1||e.indexOf("Windows 7")>-1)return"Windows 7";if(e.indexOf("Windows NT 10")>-1||e.indexOf("Windows 10")>-1)return"Windows 10";if(e.indexOf("Windows NT 11")>-1||e.indexOf("Windows 11")>-1)return"Windows 11"}return"Unknown system"}static getBrowserType(){const e=navigator.userAgent,n=e.indexOf("Opera")>-1,s=e.indexOf("compatible")>-1&&e.indexOf("MSIE")>-1&&!n,r=e.indexOf("Trident")>-1&&e.indexOf("rv:11.0")>-1,i=e.indexOf("Edge")>-1,o=e.indexOf("Firefox")>-1,l=e.indexOf("Safari")>-1&&e.indexOf("Chrome")===-1,a=e.indexOf("Chrome")>-1&&e.indexOf("Safari")>-1;if(s){new RegExp("MSIE (\\d+\\.\\d+);").test(e);const d=Number.parseFloat(RegExp.$1);return d===7?"IE7":d===8?"IE8":d===9?"IE9":d===10?"IE10":"0"}return o?"FF":n?"Opera":l?"Safari":a?"Chrome":i?"Edge":r?"IE11":"Unknown browser"}static generateRandomId(e=21,n){return n?sl(n,e)():rl(e)}static getClassName(e){return e.constructor.name}static deepMerge(e,...n){n.forEach(o=>o&&i(o));function s(o,l){o.forEach((a,h)=>{var d,c;if(y.isArray(a)){const f=(d=l[h])!=null?d:[];l[h]=f,s(a,f);return}if(y.isObject(a)){const f=(c=l[h])!=null?c:{};l[h]=f,r(a,f);return}l[h]=a})}function r(o,l){Object.keys(o).forEach(a=>{var d,c;const h=o[a];if(y.isObject(h)){const f=(d=l[a])!=null?d:{};l[a]=f,r(h,f);return}if(y.isArray(h)){const f=(c=l[a])!=null?c:[];l[a]=f,s(h,f);return}l[a]=h})}function i(o){Object.keys(o).forEach(l=>{var h,d;const a=o[l];if(y.isArray(a)){const c=(h=e[l])!=null?h:[];e[l]=c,s(a,c);return}if(y.isObject(a)){const c=(d=e[l])!=null?d:{};e[l]=c,r(a,c);return}e[l]=a})}return e}static numberFixed(e,n){return Number(Number(e).toFixed(n))}static diffValue(e,n){function s(o,l){const a=y.getValueType(o),h=y.getValueType(l);return a!==h?!1:y.isArray(o)?r(o,l):y.isObject(o)?i(o,l):y.isDate(o)?o.getTime()===l.getTime():y.isRegExp(o)?o.toString()===l.toString():o===l}function r(o,l){if(e.length!==n.length)return!1;for(let a=0,h=o.length;a<h;a++){const d=o[a],c=l[a];if(!s(d,c))return!1}return!0}function i(o,l){const a=Object.keys(o),h=Object.keys(l);if(a.length!==h.length)return!1;for(const d of a){if(!h.includes(d))return!1;const c=o[d],f=l[d];if(!s(c,f))return!1}return!0}return s(e,n)}static deepClone(e){if(!this.isDefine(e))return e;if(this.isRegExp(e))return new RegExp(e);if(this.isDate(e))return new Date(e);if(this.isArray(e)){const n=[];return e.forEach((s,r)=>{n[r]=y.deepClone(s)}),n}if(this.isObject(e)){const n={};return Object.keys(e).forEach(s=>{const r=e[s];n[s]=y.deepClone(r)}),Object.setPrototypeOf(n,Object.getPrototypeOf(e)),n}return e}static getLanguage(){const e="en-US";return globalThis.navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||e}static getValueType(e){return Object.prototype.toString.apply(e)}static isDefine(e){return e!=null}static isBlank(e){return this.isDefine(e)?this.isString(e)?e.trim()==="":!1:!0}static isAssignableFrom(e,n){return e instanceof n}static isBoolean(e){return this.getValueType(e)==="[object Boolean]"}static isPlainObject(e){return this.isDefine(e)?Object.getPrototypeOf(e)===Object.getPrototypeOf({}):!1}static isFunction(e){return this.getValueType(e)==="[object Function]"}static isDate(e){return this.getValueType(e)==="[object Date]"}static isRegExp(e){return this.getValueType(e)==="[object RegExp]"}static isArray(e){return this.getValueType(e)==="[object Array]"}static isString(e){return this.getValueType(e)==="[object String]"}static isNumber(e){return this.getValueType(e)==="[object Number]"}static isStringNumber(e){return!isNaN(Number.parseFloat(e))&&isFinite(e)}static isObject(e){return this.getValueType(e)==="[object Object]"}static isEmptyObject(e){for(const n in e)return!1;return!0}static isMobile(){let e=0,n=0;return document.body.clientWidth&&(e=document.body.clientWidth),document.body.clientHeight&&(n=document.body.clientHeight),this.isAndroid()||this.isIPhone()||this.isTablet()||e<350&&n<500}static isTablet(){return/ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase())}static isWeChat(){const e=navigator.userAgent.toLowerCase();return String(e.match(/MicroMessenger/i))==="micromessenger"}static isAndroid(){const e=navigator.userAgent;return e.indexOf("Android")>-1||e.indexOf("Linux")>-1}static isIPhone(){return/iPhone/i.test(navigator.userAgent)}static isLegalUrl(e){return ll(e)}static itCount(e){return n=>{for(let s=0;s<e;s++)n&&n()}}static hasLength(e,n){return y.isDefine(e)?y.isDefine(n)?e.length===n:e.length>0:!1}static capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)}static fCamelCase(e,n){return n.toUpperCase()}static camelCase(e){return e.replace(al,"ms-").replace(ul,this.fCamelCase)}static removeNull(e){return this.isObject(e)&&Object.keys(e).forEach(n=>{const s=e[n];s==null?delete e[n]:y.removeNull(s)}),e}static fillTwoDimensionalArray(e,n,s){return new Array(e).fill(s).map(r=>new Array(n).fill(s))}static numToWord(e){let n="";for(;e>0;){let s=e%26;s=s===0?s=26:s,n=String.fromCharCode(96+s)+n,e=(e-s)/26}return n.toLocaleUpperCase()}static ABCatNum(e){if(e==null||e.length===0)return Number.NaN;const n=e.toLowerCase().split(""),s=n.length;let r=0,i=0;for(let o=0;o<s;o++)i=n[o].charCodeAt(0)-96,r+=i*26**(s-o-1);return r===0?Number.NaN:r-1}static chatAtABC(e){let i="";for(;e>=0;)i=String.fromCharCode(e%26+97)+i,e=Math.floor(e/26)-1;return i.toUpperCase()}static randSort(e){for(let n=0,s=e.length;n<s;n++){const r=Number.parseInt((Math.random()*s).toString()),i=e[r];e[r]=e[n],e[n]=i}return e}static commonExtend(e,n){const s={};for(const r in e)s[r]=e[r];for(const r in n)n[r]!=null&&(s[r]=n[r]);return s}static commonExtend1(e,n){for(const s in e)n[s]==null&&(n[s]=e[s]);return n}static arrayToObject(e){const n={};return e.forEach((s,r)=>{n[r]={},s.forEach((i,o)=>{n[r][o]=i})}),n}static hasIntersectionBetweenTwoRanges(e,n,s,r){return n>=s&&r>=e}static isStartValidPosition(e){return/^[A-Za-z_]/.test(e)}static isValidParameter(e){const n=/[~!@#$%^&*()+=\-{}\[\]\|:;"'<>,?\/ ]+/.test(e),s=e.length<=255;return!n&&s}static set(e,n,s){const r=n.split("."),i=r.pop();r.forEach(o=>{e[o]||(e[o]={}),e=e[o]}),i&&(e[i]=s)}static clamp(e,n,s){return Math.max(n,Math.min(s,e))}}function cl(t){if(!t)return;const{actualRow:e,actualColumn:n,isMerged:s,isMergedMainCell:r,mergeInfo:i}=t;let{startY:o,endY:l,startX:a,endX:h}=t,d=e,c=n,f=e,_=n;if(s&&i){const{startRow:E,startColumn:R,endRow:H,endColumn:k,startY:et,endY:mt,startX:ft,endX:C}=i;d=E,c=R,f=H,_=k,o=et,l=mt,a=ft,h=C}return r&&(o=i.startY,l=i.endY,a=i.startX,h=i.endX,f=i.endRow,_=i.endColumn),{startRow:d,startColumn:c,endRow:f,endColumn:_,startY:o,endY:l,startX:a,endX:h}}function hl(t){if(!t)return;const{actualRow:e,actualColumn:n,isMerged:s,isMergedMainCell:r,startRow:i,startColumn:o,endRow:l,endColumn:a}=t;let h=e,d=n,c=e,f=n;return(s||r)&&(h=i,d=o,c=l,f=a),{startRow:h,startColumn:d,endRow:c,endColumn:f}}function Tr(t){var n;return!t||(((n=t==null?void 0:t.v)==null?void 0:n.toString())||"").length===0&&!t.p}function dl(t){return Tr(t)&&(t==null?void 0:t.coverable)!==!1}function se(t){if(t){if(t.rgb)return t.rgb;if(t.th)return new hn().setThemeColor(t.th).asThemeColor().asRgbColor().getCssString()}return null}function fl(t){return y.isString(t)&&t.substring(0,1)==="="&&t.length>1}function _l(t){return y.isString(t)&&t.length>0}function gl(t,e=!1){var i;let n="";const s=new Map([["ff",()=>{t.ff&&(n+=`font-family: ${t.ff}; `)}],["fs",()=>{if(t.fs){let o=t.fs;t.va&&(o/=2),n+=`font-size: ${o}pt; `}}],["it",()=>{t.it&&(n+="font-style: italic; ")}],["bl",()=>{t.bl&&(n+="font-weight: bold; ")}],["ul",()=>{var o;(o=t.ul)!=null&&o.s&&(n.indexOf("text-decoration-line")>-1?n=n.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(l,a)=>`${a} underline`):n+="text-decoration: underline; ",t.ul.cl&&n.indexOf("text-decoration-color")===-1&&(n+=`text-decoration-color: ${se(t.ul.cl)}; `),t.ul.t&&n.indexOf("text-decoration-style")===-1&&(n+=`text-decoration-style: ${t.ul.t} `))}],["st",()=>{var o;(o=t.st)!=null&&o.s&&(n.indexOf("text-decoration-line")>-1?n=n.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(l,a)=>`${a} line-through`):n+="text-decoration-line: line-through; ",t.st.cl&&n.indexOf("text-decoration-color")===-1&&(n+=`text-decoration-color: ${se(t.st.cl)}; `),t.st.t&&n.indexOf("text-decoration-style")===-1&&(n+=`text-decoration-style: ${t.st.t} `))}],["ol",()=>{var o;(o=t.ol)!=null&&o.s&&(n.indexOf("text-decoration-line")>-1?n=n.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(l,a)=>`${a} overline`):n+="text-decoration-line: overline; ",t.ol.cl&&n.indexOf("text-decoration-color")===-1&&(n+=`text-decoration-color: ${se(t.ol.cl)}; `),t.ol.t&&n.indexOf("text-decoration-style")===-1&&(n+=`text-decoration-style: ${t.ol.t} `))}],["bg",()=>{t.bg&&(n+=`background: ${se(t.bg)}; `)}],["bd",()=>{var o,l,a,h,d,c,f,_,E,R,H,k;(o=t.bd)!=null&&o.b&&(n+=`border-bottom: ${gn((l=t.bd)==null?void 0:l.b.s)} ${(a=se(t.bd.b.cl))!=null?a:""}; `),(h=t.bd)!=null&&h.t&&(n+=`border-top: ${gn((d=t.bd)==null?void 0:d.t.s)} ${(c=se(t.bd.t.cl))!=null?c:""}; `),(f=t.bd)!=null&&f.r&&(n+=`border-right: ${gn((_=t.bd)==null?void 0:_.r.s)} ${(E=se(t.bd.r.cl))!=null?E:""}; `),(R=t.bd)!=null&&R.l&&(n+=`border-left: ${gn((H=t.bd)==null?void 0:H.l.s)} ${(k=se(t.bd.l.cl))!=null?k:""}; `)}],["cl",()=>{t.cl&&(n+=`color: ${se(t.cl)}; `)}],["va",()=>{t.va===Pe.SUBSCRIPT?n+="vertical-align: sub; ":t.va===Pe.SUPERSCRIPT&&(n+="vertical-align: super; ")}],["td",()=>{t.td===xe.LEFT_TO_RIGHT?n+="direction: ltr; ":t.td===xe.RIGHT_TO_LEFT&&(n+="direction: rtl; ")}],["tr",()=>{var o,l,a;t.tr&&(n+=`--data-rotate: (${(o=t.tr)==null?void 0:o.a}deg${(l=t.tr)!=null&&l.v?` ,${(a=t.tr)==null?void 0:a.v}`:""});`)}],["ht",()=>{t.ht===Oe.LEFT?n+="text-align: left; ":t.ht===Oe.RIGHT?n+="text-align: right; ":t.ht===Oe.CENTER?n+="text-align: center; ":t.ht===Oe.JUSTIFIED&&(n+="text-align: justify; ")}],["vt",()=>{t.vt===De.BOTTOM?n+="vertical-align: bottom; ":t.vt===De.TOP?n+="vertical-align: top; ":t.vt===De.MIDDLE&&(n+="vertical-align: middle; ")}],["tb",()=>{t.tb===ye.CLIP?n+="white-space: clip; ":t.tb===ye.WRAP&&(n+="white-space: normal;")}],["pd",()=>{var d,c,f,_,E,R,H,k;const o=`${(d=t.pd)==null?void 0:d.b}pt`,l=`${(c=t.pd)==null?void 0:c.t}pt`,a=`${(f=t.pd)==null?void 0:f.l}pt`,h=`${(_=t.pd)==null?void 0:_.r}pt`;(E=t.pd)!=null&&E.b&&(n+=`padding-bottom: ${o}; `),(R=t.pd)!=null&&R.t&&(n+=`padding-top: ${l}; `),(H=t.pd)!=null&&H.l&&(n+=`padding-left: ${a}; `),(k=t.pd)!=null&&k.r&&(n+=`padding-right: ${h}; `)}]]),r=["bd","tr","tb"];for(const o in t)e&&r.includes(o)||(i=s.get(o))==null||i();return n}function gn(t){let e="";return t===dt.NONE?e="none":t===dt.THIN?e="0.5pt solid":t===dt.HAIR?e="0.5pt double":t===dt.DOTTED?e="0.5pt dotted":t===dt.DASHED||t===dt.DASH_DOT?e="0.5pt dashed":t===dt.DASH_DOT_DOT?e="0.5pt dotted":t===dt.DOUBLE?e="0.5pt double":t===dt.MEDIUM?e="1pt solid":t===dt.MEDIUM_DASHED||t===dt.MEDIUM_DASH_DOT?e="1pt dashed":t===dt.MEDIUM_DASH_DOT_DOT?e="1pt dotted":t===dt.SLANT_DASH_DOT?e="0.5pt dashed":t===dt.THICK&&(e="1.5pt solid"),e}function ml(t){let e=0;if(t=t.trim(),t==="none")e=dt.NONE;else if(t==="0.5pt solid")e=dt.THIN;else if(t==="0.5pt double")e=dt.HAIR;else if(t==="0.5pt dotted")e=dt.DOTTED;else if(t==="0.5pt dashed")e=dt.DASHED;else if(t==="1pt solid")e=dt.MEDIUM;else if(t==="1pt dashed")e=dt.MEDIUM_DASHED;else if(t==="1pt dotted")e=dt.MEDIUM_DASH_DOT_DOT;else if(t==="1.5pt solid")e=dt.THICK;else if(!t.includes("none"))e=dt.THIN;else return dt.NONE;return e}function El(t,e){let n=t.body;if(e){const{headers:s,footers:r}=t;s!=null&&s[e]?n=s[e].body:r!=null&&r[e]&&(n=r[e].body)}return n}function Rl(t){const{startRow:e,endRow:n,startColumn:s,endColumn:r,rangeType:i}=t;return!(e<0||s<0||n<0||r<0||!(Number.isNaN(e)&&Number.isNaN(n))&&i===ot.COLUMN||!(Number.isNaN(s)&&Number.isNaN(r))&&i===ot.ROW||i!==ot.ROW&&i!==ot.COLUMN&&(Number.isNaN(s)||Number.isNaN(e)||Number.isNaN(r)||Number.isNaN(n)))}function Cl(t,e){return{startRow:t,endRow:t,startColumn:e,endColumn:e}}function Bn(t,e){return Object.prototype.toString.call(t)===Object.prototype.toString.call(e)?Object.prototype.toString.call(t)==="[object Object]"||Object.prototype.toString.call(t)==="[object Array]"?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(n=>Bn(t[n],e[n])):t===e:!1}function Mr(t,e){const n=t.ts||{},s=e.ts||{};return t.sId!==e.sId?!1:Bn(n,s)}function pl(t,e){return e.some(n=>t.indexOf(n)>-1)}function mn(t,e,n,s){if(t>e&&([t,e]=[e,t]),n>s&&([n,s]=[s,n]),e<n||s<t)return[t,e];n<t&&(n=t),s>e&&(s=e);const r=s-n+1;let i=[];return t===n?i=[s+1-r,e-r]:e===s?i=[t,n-1]:i=[t,e-r],i}function Il(t){if(t==null)return!1;const e=t.bullet;return(e==null?void 0:e.listId)!=null}function Ol(t){if(t==null)return!1;const e=t.paragraphStyle;return Ur(e)}function Ur(t){return!(t==null||(t.indentStart==null||t.indentStart===0)&&t.hanging==null||t.hanging===0)}function Lr(t,e,n){return t.slice(0,e)+n+t.slice(e)}function Dr(t,e,n){return e>n?t:t.slice(0,e)+t.slice(n)}function Sl(t){return t===null||t.toString().replace(/\s/g,"")===""||typeof t=="boolean"?!1:!isNaN(t)}function Nl(t){let e=0;for(let n=0;n<t.length;n++)e=t.charCodeAt(n)+(e<<6)+(e<<16)-e;return e>>>0}function yr(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],s=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Pr(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var s=n.call(t),r,i=[],o;try{for(;(e===void 0||e-- >0)&&!(r=s.next()).done;)i.push(r.value)}catch(l){o={error:l}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return i}function kr(t,e,n){if(n||arguments.length===2)for(var s=0,r=e.length,i;s<r;s++)(i||!(s in e))&&(i||(i=Array.prototype.slice.call(e,0,s)),i[s]=e[s]);return t.concat(i||Array.prototype.slice.call(e))}typeof SuppressedError=="function"&&SuppressedError;function Ve(t){return typeof t=="function"}function Al(t){var e=function(s){Error.call(s),s.stack=new Error().stack},n=t(e);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var Gn=Al(function(t){return function(n){t(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
2
|
-
`+
|
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=n}});function Hr(t,e){if(t){var n=t.indexOf(e);0<=n&&t.splice(n,1)}}var Fr=function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var e,n,s,r,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var l=yr(o),a=l.next();!a.done;a=l.next()){var h=a.value;h.remove(this)}}catch(R){e={error:R}}finally{try{a&&!a.done&&(n=l.return)&&n.call(l)}finally{if(e)throw e.error}}else o.remove(this);var d=this.initialTeardown;if(Ve(d))try{d()}catch(R){i=R instanceof Gn?R.errors:[R]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var f=yr(c),_=f.next();!_.done;_=f.next()){var E=_.value;try{$r(E)}catch(R){i=i!=null?i:[],R instanceof Gn?i=kr(kr([],Pr(i)),Pr(R.errors)):i.push(R)}}}catch(R){s={error:R}}finally{try{_&&!_.done&&(r=f.return)&&r.call(f)}finally{if(s)throw s.error}}}if(i)throw new Gn(i)}},t.prototype.add=function(e){var n;if(e&&e!==this)if(this.closed)$r(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(e)}},t.prototype._hasParent=function(e){var n=this._parentage;return n===e||Array.isArray(n)&&n.includes(e)},t.prototype._addParent=function(e){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(e),n):n?[n,e]:e},t.prototype._removeParent=function(e){var n=this._parentage;n===e?this._parentage=null:Array.isArray(n)&&Hr(n,e)},t.prototype.remove=function(e){var n=this._finalizers;n&&Hr(n,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}();Fr.EMPTY;function bl(t){return t instanceof Fr||t&&"closed"in t&&Ve(t.remove)&&Ve(t.add)&&Ve(t.unsubscribe)}function $r(t){Ve(t)?t():t.unsubscribe()}function At(t){let e=!1;return t?bl(t)?{dispose:()=>t.unsubscribe()}:typeof t=="function"?{dispose:()=>{e||(e=!0,t())}}:t:At(()=>{})}function vl(t){return At(()=>{t.unsubscribe()})}class xn{constructor(){g(this,"_disposables",new Set)}add(e){const n=At(e);return this._disposables.add(n),{dispose:()=>{n.dispose(),this._disposables.delete(n)}}}dispose(){this._disposables.forEach(e=>{e.dispose()}),this._disposables.clear()}}class yt{constructor(){g(this,"_disposed",!1);g(this,"_collection",new xn)}disposeWithMe(e){return this._collection.add(e)}ensureNotDisposed(){if(this._disposed)throw new Error("[Disposable]: object is disposed!")}dispose(){this._disposed||(this._disposed=!0,this._collection.dispose())}}class wl extends yt{constructor(){super(...arguments);g(this,"dispose$",new V.Subject)}dispose(){super.dispose(),this.dispose$.next(),this.dispose$.complete()}}class Ke{static hasLength(e,n){return e.length===n}static getValueType(e){return Object.prototype.toString.apply(e)}static isObject(e){return this.getValueType(e)==="[object Object]"}static isIterable(e){return e[Symbol.iterator]!=null}static isNumber(e){return this.getValueType(e)==="[object Number]"}}function En(t,e){const n=t.indexOf(e);return n>-1?(t.splice(n,1),!0):!1}function Tl(t){const e=new Set,n=[];for(const s of t)e.has(s)||(e.add(s),n.push(s));return n}function Ml(t,e){for(let n=t.length-1;n>-1;n--){const s=t[n];if(e(s,n))return s}return null}function Ul(t,e){if(t.length===0)return t;const n=e%t.length;return t.slice(n).concat(t.slice(0,n))}function Ll(t,e){const n=new Map;return t.forEach(s=>{const r=e(s);let i=n.get(r);n.has(r)||(i=[],n.set(r,i)),i.push(s)}),n}function Dl(t){return Array.isArray(t)?t:[t]}const ht=Symbol("newer"),Mt=Symbol("older");class Wr{constructor(e){g(this,"entry");this.entry=e}[Symbol.iterator](){return this}next(){const e=this.entry;return e?(this.entry=e[ht],{done:!1,value:e.key}):{done:!0,value:void 0}}}class Br{constructor(e){g(this,"entry");this.entry=e}[Symbol.iterator](){return this}next(){const e=this.entry;return e?(this.entry=e[ht],{done:!1,value:e.value}):{done:!0,value:void 0}}}class Gr{constructor(e){g(this,"entry");this.entry=e}[Symbol.iterator](){return this}next(){const e=this.entry;return e?(this.entry=e[ht],{done:!1,value:[e.key,e.value]}):{done:!0,value:void 0}}}Io=ht,po=Mt;class jn{constructor(e,n){g(this,"key");g(this,"value");g(this,Io);g(this,po);this.key=e,this.value=n,this[ht]=void 0,this[Mt]=void 0}toJSON(){return{key:this.key,value:this.value}}}class xr{constructor(...e){g(this,"_keymap");g(this,"size",0);g(this,"limit");g(this,"oldest");g(this,"newest");g(this,"_onShiftListeners",[]);if(Ke.hasLength(e,1)){if(Ke.isNumber(e[0])){const n=e[0];this._initialize(n,void 0);return}if(Ke.isIterable(e[0])){const n=e[0];this._initialize(0,n);return}return}if(Ke.hasLength(e,2)){const n=e[0],s=e[1];this._initialize(n,s)}}onShift(e){if(this._onShiftListeners.indexOf(e)===-1)return this._onShiftListeners.push(e),At(()=>En(this._onShiftListeners,e));throw new Error("[LRUMap]: the listener has been registered!")}_initialize(e,n){this.oldest=void 0,this.newest=void 0,this.size=0,this.limit=e,this._keymap=new Map,n&&(this.assign(n),e<1&&(this.limit=this.size))}_markEntryAsUsed(e){e!==this.newest&&(e[ht]&&(e===this.oldest&&(this.oldest=e[ht]),e[ht][Mt]=e[Mt]),e[Mt]&&(e[Mt][ht]=e[ht]),e[ht]=void 0,e[Mt]=this.newest,this.newest&&(this.newest[ht]=e),this.newest=e)}assign(e){let n,s=this.limit||Number.MAX_VALUE;this._keymap.clear();const r=e[Symbol.iterator]();for(let i=r.next();!i.done;i=r.next()){const o=new jn(i.value[0],i.value[1]);if(this._keymap.set(o.key,o),n?(n[ht]=o,o[Mt]=n):this.oldest=o,n=o,s--===0)throw new Error("overflow")}this.newest=n,this.size=this._keymap.size}set(e,n){let s=this._keymap.get(e);return s?(s.value=n,this._markEntryAsUsed(s),this):(this._keymap.set(e,s=new jn(e,n)),this.newest?(this.newest[ht]=s,s[Mt]=this.newest):this.oldest=s,this.newest=s,++this.size,this.size>this.limit&&this.shift(),this)}shift(){const e=this.oldest;if(e)return this.oldest&&this.oldest[ht]?(this.oldest=this.oldest[ht],this.oldest[Mt]=void 0):(this.oldest=void 0,this.newest=void 0),e[ht]=e[Mt]=void 0,this._keymap.delete(e.key),--this.size,this._onShiftListeners.forEach(n=>n(e)),[e.key,e.value]}get(e){const n=this._keymap.get(e);if(n)return this._markEntryAsUsed(n),n.value}has(e){return this._keymap.has(e)}find(e){const n=this._keymap.get(e);return n?n.value:void 0}delete(e){const n=this._keymap.get(e);if(n)return this._keymap.delete(n.key),n[ht]&&n[Mt]?(n[Mt][ht]=n[ht],n[ht][Mt]=n[Mt]):n[ht]?(n[ht][Mt]=void 0,this.oldest=n[ht]):n[Mt]?(n[Mt][ht]=void 0,this.newest=n[Mt]):this.oldest=this.newest=void 0,this.size--,n.value}clear(){this.oldest=void 0,this.newest=void 0,this.size=0,this._keymap.clear()}keys(){return new Wr(this.oldest)}values(){return new Br(this.oldest)}entries(){return this[Symbol.iterator]()}[Symbol.iterator](){return new Gr(this.oldest)}forEach(e,n){typeof n!="object"&&(n=this);let s=this.oldest;for(;s;)e.call(n,s.value,s.key,this),s=s[ht]}toJSON(){const e=new Array(this.size);let n=0,s=this.oldest;for(;s;)e[n++]={key:s.key,value:s.value},s=s[ht];return e}toString(){let e="",n=this.oldest;for(;n;)e+=`${String(n.key)}:${n.value}`,n=n[ht],n&&(e+=" < ");return e}}function ge(t){let e=0;const n=Object.keys(t);for(const s of n){const r=Number(s);e=Math.max(e,r)}return e+1}function Vn(t,e,n){const s=ge(n),r=n;for(let i=s-1;i>=t;i--)r[i+1]=r[i];r[t]=e}function Kn(t,e,n){const s=Object.keys(n).reduce((r,i)=>Math.max(r,Number.parseInt(i)),0)+1;for(let r=t;r<s;r++)r<t+e?delete n[r]:n[r]!==void 0&&(n[r-e]=n[r],delete n[r])}function yl(t,e){const n=t,s=Object.keys(n),r=s.length,i=e,o=Object.keys(i),l=o.length,a={};let h=0;for(let d=0;d<r;d++,h++){const c=s[d];a[h]=n[c]}for(let d=0;d<l;d++,h++){const c=o[d];a[h]=i[c]}return a}function Pl(t,e,n){const s=n;if(ge(n)>0){const i={};let o=0;for(let l=t;l<=e;l++)s[l]&&(i[o]=s[l],o++);return i}return{}}function Yn(t,e,n,s){const r=t>n;if(!r&&t+e>n)throw new Error("Invalid move operation");r?kl(t,e,n,s):Hl(t,e,n,s)}function kl(t,e,n,s){const r=s,i=[];for(let o=t;o<t+e;o++)i.push(r[o]);for(let o=t-1;o>=n;o--){const l=r[o];r[o+e]=l,l===void 0&&delete r[o+e]}i.forEach((o,l)=>{r[n+l]=o,o===void 0&&delete r[n+l]})}function Hl(t,e,n,s){const r=s,i=[];for(let o=t;o<t+e;o++)i.push(r[o]);for(let o=t+e;o<n;o++){const l=r[o];r[o-e]=l,l===void 0&&delete r[o-e]}i.forEach((o,l)=>{r[n+l-e]=o,o===void 0&&delete r[n+l-e]})}class Zt{constructor(e={}){g(this,"_matrix");this._setOriginValue(e)}static MakeObjectMatrixSize(e){return new Zt({[e-1]:{}})}getMatrix(){return this._matrix}forEach(e){const n=this._matrix,s=Object.keys(n);for(const r of s){const i=Number(r),o=n[i];if(e(i,o)===!1)return this}return this}forRow(e){const n=this._matrix,s=Object.keys(n);for(const r of s){const i=Number(r),o=n[i];if(e(i,Object.keys(o).map(a=>Number(a)))===!1)return this}return this}forValue(e){const n=this._matrix,s=Object.keys(n);for(const r of s){const i=Number(r),o=n[i];if(!o)continue;const l=Object.keys(o);for(const a of l){const h=Number(a),d=o[Number(a)];if(e(i,h,d)===!1)return this}}return this}swapRow(e,n){const s=this._matrix[e],r=this._matrix[n];this._matrix[e]=r,this._matrix[n]=s}getRow(e){return this._matrix[e]}getRowOrCreate(e){let n=this.getRow(e);return n==null&&(n={},this._matrix[e]=n),n}reset(){this._setOriginValue({})}hasValue(){const e=this._matrix,n=Object.keys(e);if(n.length===0)return!1;for(const s of n){const r=Number(s),i=e[r];if(Object.keys(i).length>0)return!0}return!1}getValue(e,n){var s,r;return(r=(s=this._matrix)==null?void 0:s[e])==null?void 0:r[n]}setValue(e,n,s){const r=this.getRowOrCreate(e);r[n]=s}deleteValue(e,n){var s,r;(r=(s=this._matrix)==null?void 0:s[e])==null||delete r[n]}realDeleteValue(e,n){var s,r,i;if((r=(s=this._matrix)==null?void 0:s[e])==null||delete r[n],this.getRow(e)){const o=this.getRow(e);if(o==null)return;Object.keys(o).length===0&&((i=this._matrix)==null||delete i[e])}}setRow(e,n){this._matrix[e]=n}moveRows(e,n,s){Yn(e,n,s,this._matrix)}moveColumns(e,n,s){this.forEach((r,i)=>{Yn(e,n,s,i)})}insertRows(e,n){for(let s=e;s<e+n;s++)Vn(s,{},this._matrix)}insertColumns(e,n){for(let s=e;s<e+n;s++)this.forEach((r,i)=>{i&&Vn(s,void 0,i)})}removeRows(e,n){Kn(e,n,this._matrix)}removeColumns(e,n){this.forEach((s,r)=>{r&&Kn(e,n,r)})}getFragment(e,n,s,r){const i=new Zt;let o=0;for(let l=e;l<=n;l++){const a={};let h=0;for(let d=s;d<=r;d++){const c=this.getValue(l,d);a[h]=c,h++}i.setRow(o,a),o++}return i}getSlice(e,n,s,r){const i=new Zt;for(let o=e;o<=n;o++)for(let l=s;l<=r;l++){const a=this.getValue(o,l);a&&i.setValue(o,l,y.deepClone(a))}return i}getSizeOf(){return Object.keys(this._matrix).length}getLength(){return ge(this._matrix)}getRange(){const s=this.getLength()-1;let r=0;const i=this.getLength();for(let o=0;o<i;o++){const l=this.getRow(o);if(l){const a=ge(l)-1;r=a>r?a:r}}return{startRow:0,startColumn:0,endRow:s,endColumn:r}}toNativeArray(){const e=new Array;return this.forValue((n,s,r)=>{e.push(r)}),e}toArray(){const e=[];return this.forRow((n,s)=>{e[n]==null&&(e[n]=[]),s.forEach(r=>{e[n][r]=this.getValue(n,r)})}),e}toFullArray(){const e=this.getRange(),{endColumn:n,endRow:s}=e,r=[];for(let i=0;i<=s;i++){const o=Array(n+1).fill(void 0);r.push(o)}return this.forValue((i,o,l)=>{r[i][o]=l}),r}toJSON(){return this._matrix}clone(){const e=JSON.stringify(this._matrix);return JSON.parse(e)}getData(){const e=JSON.stringify(this._matrix);return JSON.parse(e)}getArrayData(){let e=0,n=0,s=!1,r=!1;const i=new Zt;return this.forEach((o,l)=>{s||(s=!0,e=o),Object.keys(l).forEach(a=>{const h=Number(a);r?h<n&&(n=h):(r=!0,n=h);const d=this.getValue(o,h);i.setValue(o-e,h-n,d)})}),i.getData()}getDataRange(){let e=0,n=0,s=0,r=-1,i=!1,o=!1;return this.forEach((l,a)=>{if(i||(i=!0,e=l),a==null)return;const h=ge(a)-1;h>s&&(s=h),Object.keys(a).forEach(d=>{const c=Number(d);o?c<n&&(n=c):(o=!0,n=c)}),l>r&&(r=l)}),{startRow:e,startColumn:n,endRow:r,endColumn:s}}getDiscreteRanges(){const e=[];return this.forEach((n,s)=>{Object.keys(s).forEach(r=>{const i=Number(r);let o=!1;for(const l of e)if(n>=l.startRow&&n<=l.endRow+1&&i>=l.startColumn&&i<=l.endColumn+1){l.endRow=Math.max(n,l.endRow),l.endColumn=Math.max(i,l.endColumn),o=!0;break}o||e.push({startRow:n,endRow:n,startColumn:i,endColumn:i})})}),e}merge(e){this.forValue((n,s)=>{const r=e.getValue(n,s);r!=null&&this.setValue(n,s,r)})}_setOriginValue(e={}){this._matrix=e}}const ae=class ae{static clone(e){return e.rangeType!==void 0?{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn,rangeType:e.rangeType}:{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn}}static equals(e,n){return e==null||n==null?!1:e.endRow===n.endRow&&e.endColumn===n.endColumn&&e.startRow===n.startRow&&e.startColumn===n.startColumn&&(e.rangeType===n.rangeType||e.rangeType===void 0&&n.rangeType===ot.NORMAL||n.rangeType===void 0&&e.rangeType===ot.NORMAL)}static intersects(e,n){if(e.rangeType===ot.ROW&&n.rangeType===ot.COLUMN||e.rangeType===ot.COLUMN&&n.rangeType===ot.ROW)return!0;if(e.rangeType===ot.ROW&&n.rangeType===ot.ROW)return e.startRow<=n.endRow&&e.endRow>=n.startRow;if(e.rangeType===ot.COLUMN&&n.rangeType===ot.COLUMN)return e.startColumn<=n.endColumn&&e.endColumn>=n.startColumn;const s=Math.floor(Number.MAX_SAFE_INTEGER/10),r=Number.isNaN(e.startRow)?0:e.startRow,i=Number.isNaN(e.endRow)?s:e.endRow,o=Number.isNaN(e.startColumn)?0:e.startColumn,l=Number.isNaN(e.endColumn)?s:e.endColumn,a=Number.isNaN(n.startRow)?0:n.startRow,h=Number.isNaN(n.endRow)?s:n.endRow,d=Number.isNaN(n.startColumn)?0:n.startColumn,c=Number.isNaN(n.endColumn)?s:n.endColumn,f=Math.abs(o+l-d-c),_=Math.abs(o-l)+Math.abs(d-c),E=Math.abs(r+i-a-h),R=Math.abs(r-i)+Math.abs(a-h);return f<=_&&E<=R}static getIntersects(e,n){const s=e.startRow,r=e.endRow,i=e.startColumn,o=e.endColumn,l=n.startRow,a=n.endRow,h=n.startColumn,d=n.endColumn;let c,f,_,E;if(l<=r)l>=s?f=l:f=s;else return null;if(a>=s)a>=r?E=r:E=a;else return null;if(h<=o)h>i?c=h:c=i;else return null;if(d>=i)d>=o?_=o:_=d;else return null;return{startRow:f,endRow:E,startColumn:c,endColumn:_,rangeType:ot.NORMAL}}static contains(e,n){return e.startRow<=n.startRow&&e.endRow>=n.endRow&&e.startColumn<=n.startColumn&&e.endColumn>=n.endColumn}static realContain(e,n){return ae.contains(e,n)&&(e.startRow<n.startRow||e.endRow>n.endRow||e.startColumn<n.startColumn||e.endColumn>n.endColumn)}static union(...e){return e.reduce((n,s)=>({startRow:Math.min(n.startRow,s.startRow),startColumn:Math.min(n.startColumn,s.startColumn),endRow:Math.max(n.endRow,s.endRow),endColumn:Math.max(n.endColumn,s.endColumn),rangeType:ot.NORMAL}),e[0])}static realUnion(...e){const n=e.some(i=>i.rangeType===ot.COLUMN),s=e.some(i=>i.rangeType===ot.ROW),r=ae.union(...e);return{startColumn:s?Number.NaN:r.startColumn,endColumn:s?Number.NaN:r.endColumn,startRow:n?Number.NaN:r.startRow,endRow:n?Number.NaN:r.endRow,rangeType:s?ot.ROW:n?ot.COLUMN:ot.NORMAL}}static subtract(e,n){if(n.startRow>e.endRow||n.endRow<e.startRow||n.startColumn>e.endColumn||n.endColumn<e.startColumn)return[e];const s=[];n.startRow>=e.startRow&&s.push({startRow:e.startRow,startColumn:e.startColumn,endRow:n.startRow-1,endColumn:e.endColumn}),n.endRow<=e.endRow&&s.push({startRow:n.endRow+1,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn});const r=Math.max(e.startRow,n.startRow),i=Math.min(e.endRow,n.endRow);return n.startColumn>=e.startColumn&&s.push({startRow:r,startColumn:e.startColumn,endRow:i,endColumn:n.startColumn-1}),n.endColumn<=e.endColumn&&s.push({startRow:r,startColumn:n.endColumn+1,endRow:i,endColumn:e.endColumn}),s.filter(l=>l.startRow<=l.endRow&&l.startColumn<=l.endColumn)}static hasIntersectionBetweenTwoRect(e,n){return!(e.left>n.right||e.right<n.left||e.top>n.bottom||e.bottom<n.top)}static getIntersectionBetweenTwoRect(e,n){const s=Math.max(e.left,n.left),r=Math.min(e.right,n.right),i=Math.max(e.top,n.top),o=Math.min(e.bottom,n.bottom);return r<=s||o<=i?null:{left:s,right:r,top:i,bottom:o,width:r-s,height:o-i}}};g(ae,"getRelativeRange",(e,n)=>({startRow:e.startRow-n.startRow,endRow:e.endRow-e.startRow,startColumn:e.startColumn-n.startColumn,endColumn:e.endColumn-e.startColumn})),g(ae,"getPositionRange",(e,n,s)=>({...s||{},startRow:s&&[Nt.ROW,Nt.ALL].includes(s.startAbsoluteRefType||0)?s.startRow:e.startRow+n.startRow,endRow:s&&[Nt.ROW,Nt.ALL].includes(s.endAbsoluteRefType||0)?s.endRow:e.endRow+e.startRow+n.startRow,startColumn:s&&[Nt.COLUMN,Nt.ALL].includes(s.startAbsoluteRefType||0)?s.startColumn:e.startColumn+n.startColumn,endColumn:s&&[Nt.COLUMN,Nt.ALL].includes(s.endAbsoluteRefType||0)?s.endColumn:e.endColumn+e.startColumn+n.startColumn})),g(ae,"moveHorizontal",(e,n=0,s=0)=>({...e,startColumn:e.startColumn+n,endColumn:e.endColumn+n+s})),g(ae,"moveVertical",(e,n=0,s=0)=>({...e,startRow:e.startRow+n,endRow:e.endRow+n+s})),g(ae,"moveOffset",(e,n,s)=>({...e,startRow:e.startRow+s,endRow:e.endRow+s,startColumn:e.startColumn+n,endColumn:e.endColumn+n}));let me=ae;class Fl{constructor(e,n){g(this,"_values",[]);g(this,"_keys",[]);g(this,"_keyMaps",new Map);this._values=e,this._keys=n,e.forEach(s=>{this._initKeyMap(s)})}_initKeyMap(e){this._keys.forEach(n=>{const s=e[n],r=this._keyMaps.get(n)||new Map;r.set(s,e),this._keyMaps.set(n,r)})}getValue(e,n){const s=n||this._keys;for(let r=0;r<s.length;r++){const i=this._keyMaps.get(s[r]);if(i!=null&&i.has(e))return i.get(e)}return null}hasValue(e){for(let n=0;n<this._keys.length;n++){const s=this._keyMaps.get(this._keys[n]);if(s!=null&&s.has(e))return!0}return!1}addValue(e){this._values.push(e),this._initKeyMap(e)}setValue(e,n,s){const r=this.getValue(e);r&&Object.keys(r).includes(n)&&(r[n]=s)}deleteValue(e){const n=this.getValue(e);if(n){this._keys.forEach(r=>{const i=this._keyMaps.get(r),o=n[r];i==null||i.delete(o)});const s=this._values.findIndex(r=>r===n);this._values.splice(s,1)}}getValues(){return this._values}getKeyMap(e){var n;return[...((n=this._keyMaps.get(e))==null?void 0:n.keys())||[]]}clear(){this._values=[],this._keys=[],this._keyMaps.clear()}}function zn(t,e,n,s){return{forEach(r){for(let i=t;i<=e;i++)for(let o=n;o<=s;o++)r(i,o)}}}function $l(t){if(t==null||t.length===0)return Number.NaN;const e=t.toLowerCase().split(""),n=e.length,s=o=>o.charCodeAt(0)-96;let r=0,i=0;for(let o=0;o<n;o++)i=s(e[o]),r+=i*26**(n-o-1);return r===0?Number.NaN:r-1}const Rn=65,jr=90,Wl=97;function Bl(t){const e=jr-Rn+1;let n="";for(;t>=0;)n=String.fromCharCode(t%e+Rn)+n,t=Math.floor(t/e)-1;return n}function Vr(t,e){let n="";for(;e>0;)n+=t,e--;return n}function Gl(t,e=!1){const n=jr-Rn+1;let s=Wl;e&&(s=Rn);const r=String.fromCharCode(t%n+s),i=Math.floor(t/n)+1;return Vr(r,i)}function xl(t,e){return t.zIndex>e.zIndex?1:t.zIndex===e.zIndex?0:-1}function jl(t,e){return t.zIndex>e.zIndex?-1:t.zIndex===e.zIndex?0:1}function Ae(t="index",e=1){return(n,s)=>n[t]>s[t]?e:n[t]===s[t]?0:-e}function Vl(t,e){let n;function s(...r){const i=this,o=function(){n=null,t.apply(i,r)};clearTimeout(n),n=setTimeout(o,e)}return Object.defineProperty(s,"cancel",{value:()=>{clearTimeout(n)},enumerable:!1,writable:!1}),s}function Cn(t,e,n){const{dataStream:s,textRuns:r=[]}=t;let i=e;const o=[];for(const l of r){const{st:a,ed:h}=l;y.hasIntersectionBetweenTwoRanges(e,n,a,h)&&(a>i?(o.push(s.slice(i,a)),o.push(Xn(s,{...l,ed:Math.min(h,n)}))):o.push(Xn(s,{...l,st:i,ed:Math.min(h,n)}))),i=Math.max(e,Math.min(h,n))}return i!==n&&o.push(s.slice(i,n)),o.join("")}function Kl(t,e=!0){var n;if(e&&((n=t.paragraphs)!=null&&n.length)){const{dataStream:s,paragraphs:r=[]}=t;let i="",o=-1;for(const l of r){const{startIndex:a,paragraphStyle:h={}}=l,{spaceAbove:d,spaceBelow:c,lineSpacing:f}=h,_=[];d!=null&&(typeof d=="number"?_.push(`margin-top: ${d}px`):_.push(`margin-top: ${d.v}px`)),c!=null&&(typeof c=="number"?_.push(`margin-bottom: ${c}px`):_.push(`margin-bottom: ${c.v}px`)),f!=null&&_.push(`line-height: ${f}`),a>o+1?i+=`<p class="UniverNormal" ${_.length?`style="${_.join("; ")};"`:""}>${Cn(t,o+1,a)}</p>`:i+=`<p class="UniverNormal" ${_.length?`style="${_.join("; ")};"`:""}></p>`,o=a}return o!==s.length&&(i+=Cn(t,o,s.length)),i}else return Cn(t,0,t.dataStream.length)}function Xn(t,e){const{st:n,ed:s,ts:r={}}=e,{ff:i,fs:o,it:l,bl:a,ul:h,st:d,ol:c,bg:f,cl:_,va:E}=r;let R=t.slice(n,s);const H=[];return l===Y.TRUE&&(R=`<i>${R}</i>`),E===Pe.SUPERSCRIPT?R=`<sup>${R}</sup>`:E===Pe.SUBSCRIPT&&(R=`<sub>${R}</sub>`),(h==null?void 0:h.s)===Y.TRUE&&(R=`<u>${R}</u>`),(d==null?void 0:d.s)===Y.TRUE&&(R=`<s>${R}</s>`),a===Y.TRUE&&(R=`<strong>${R}</strong>`),i&&H.push(`font-family: ${i}`),_&&H.push(`color: ${_.rgb}`),o&&H.push(`font-size: ${o}pt`),c&&H.push("text-decoration: overline"),f&&H.push(`background: ${f.rgb}`),H.length?`<span style="${H.join("; ")};">${R}</span>`:R}const Yl={sheetId:"",range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},zl={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},Xl={startRow:0,startColumn:0,endRow:0,endColumn:0},ql={row:0,column:0},pn={ff:"Arial",fs:11,it:Y.FALSE,bl:Y.FALSE,ul:{s:Y.FALSE},st:{s:Y.FALSE},ol:{s:Y.FALSE},tr:{a:0,v:Y.FALSE},td:xe.UNSPECIFIED,cl:{rgb:"#000"},bg:{rgb:"#fff"},ht:Oe.UNSPECIFIED,vt:De.UNSPECIFIED,tb:ye.UNSPECIFIED,pd:{t:0,r:0,b:0,l:0}},Kr={id:"default_slide",title:"defaultSlide",pageSize:{width:300,height:300}};var Yr=(t=>(t.ARRAY_CONVERTOR="ARRAY_CONVERTOR",t.MATRIX_CONVERTOR="MATRIX_CONVERTOR",t))(Yr||{});function In(t,e){const{textRuns:n=[]}=e;let s=0;for(const i of n){const{ts:o={},st:l,ed:a}=i;if(o[t]==null)return Y.FALSE;switch(t){case"bl":case"it":{if(o[t]===Y.FALSE)return Y.FALSE;break}case"ul":case"st":{if(o[t].s===Y.FALSE)return Y.FALSE;break}default:throw new Error(`unknown style key: ${t} in IStyleBase`)}s+=a-l}return e.dataStream.indexOf(`\r
|
|
4
|
-
`)===s?Y.TRUE:Y.FALSE}const nn=class nn{constructor(e,n,s){g(this,"_range");g(this,"_worksheet");this._deps=s,this._range=n,this._worksheet=e}static foreach(e,n){const{startRow:s,startColumn:r,endRow:i,endColumn:o}=e;for(let l=s;l<=i;l++)for(let a=r;a<=o;a++)n(l,a)}getRangeData(){return this._range}getValue(){return this.getValues()[0][0]}getValues(){const{startRow:e,endRow:n,startColumn:s,endColumn:r}=this._range,i=[];for(let o=e;o<=n;o++){const l=[];for(let a=s;a<=r;a++)l.push(this.getMatrix().getValue(o,a)||null);i.push(l)}return i}getMatrix(){const{startRow:e,endRow:n,startColumn:s,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new Zt;for(let l=e;l<=n;l++)for(let a=s;a<=r;a++)o.setValue(l,a,i.getValue(l,a)||null);return o}getMatrixObject(){const{startRow:e,endRow:n,startColumn:s,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new Zt;for(let l=e;l<=n;l++)for(let a=s;a<=r;a++)o.setValue(l-e,a-s,i.getValue(l,a)||{});return o}getA1Notation(){const{startRow:e,endRow:n,startColumn:s,endColumn:r}=this._range;let i,o;return s<r?(i=y.numToWord(s+1)+(e+1),o=y.numToWord(r+1)+(n+1)):(i=y.numToWord(r+1)+(n+1),o=y.numToWord(s+1)+(e+1)),i===o?`${i}`:`${i}:${o}`}getBackground(){return this.getBackgrounds()[0][0]}getBackgrounds(){const e=this._deps.getStyles();return this.getValues().map(n=>n.map(s=>{var i;const r=e.getStyleByCell(s);return((i=r==null?void 0:r.bg)==null?void 0:i.rgb)||pn.bg.rgb}))}getCell(e,n){const{startRow:s,endRow:r,startColumn:i,endColumn:o}=this._range,l={startRow:s+e,endRow:s+e,startColumn:i+n,endColumn:i+n};return new nn(this._worksheet,l,this._deps)}getColumn(){return this._range.startColumn}getObjectValue(e={}){return this.getObjectValues(e)[0][0]}getObjectValues(e={}){var l;const{startRow:n,endRow:s,startColumn:r,endColumn:i}=this._range,o=this._worksheet.getCellMatrix().getFragment(n,s,r,i).getData();if(e.isIncludeStyle){const a=this._deps.getStyles();for(let h=0;h<=s-n;h++)for(let d=0;d<=i-r;d++){if(o==null||((l=o==null?void 0:o[h])==null?void 0:l[d])==null)continue;const c=o[h][d].s;c&&(o[h][d].s=a.get(c))}}return o}getFontColor(){return this.getFontColors()[0][0]}getFontColors(){const e=this._deps.getStyles();return this.getValues().map(n=>n.map(s=>{var i;const r=e.getStyleByCell(s);return((i=r==null?void 0:r.cl)==null?void 0:i.rgb)||pn.cl.rgb}))}getFontFamilies(){return this._getStyles("ff")}getFontFamily(){return this.getFontFamilies()[0][0]}getUnderlines(){return this._getStyles("ul")}getUnderline(){var n,s;const{p:e}=(n=this.getValue())!=null?n:{};return e&&Array.isArray((s=e.body)==null?void 0:s.textRuns)&&e.body.textRuns.length>0?In("ul",e.body)===Y.TRUE?{s:Y.TRUE}:{s:Y.FALSE}:this.getUnderlines()[0][0]}getOverlines(){return this._getStyles("ol")}getOverline(){return this.getOverlines()[0][0]}getStrikeThrough(){var n,s;const{p:e}=(n=this.getValue())!=null?n:{};return e&&Array.isArray((s=e.body)==null?void 0:s.textRuns)&&e.body.textRuns.length>0?In("st",e.body)===Y.TRUE?{s:Y.TRUE}:{s:Y.FALSE}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles("st")}getFontSize(){var n,s;const e=((n=this.getValue())==null?void 0:n.p)||{};return e&&Array.isArray((s=e.body)==null?void 0:s.textRuns)&&e.body.textRuns.length>0?e.body.textRuns.some(r=>{var i;return((i=r==null?void 0:r.ts)==null?void 0:i.fs)!=null})?Math.max(...e.body.textRuns.map(r=>{var i;return((i=r==null?void 0:r.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,s;const{p:e}=(n=this.getValue())!=null?n:{};return e&&Array.isArray((s=e.body)==null?void 0:s.textRuns)&&e.body.textRuns.length>0?In("it",e.body)===Y.TRUE?an.ITALIC:an.NORMAL:this._getFontStyles()[0][0]}_getFontStyles(){return this._getStyles("it")}getFontWeight(){var n,s;const{p:e}=(n=this.getValue())!=null?n:{};return e&&Array.isArray((s=e.body)==null?void 0:s.textRuns)&&e.body.textRuns.length>0?In("bl",e.body)===Y.TRUE?un.BOLD:un.NORMAL:this._getFontWeights()[0][0]}_getFontWeights(){return this._getStyles("bl")}getGridId(){return this._worksheet.getSheetId()}getHeight(){const{_range:e,_worksheet:n}=this,{startRow:s,endRow:r}=e;let i=0;for(let o=0;o<=r-s;o++){const l=n.getRowHeight(o);i+=l}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:e,endColumn:n}=this._range;return n-e+1}getNumRows(){const{startRow:e,endRow:n}=this._range;return n-e+1}getRichTextValue(){return this.getRichTextValues()[0][0]}getRichTextValues(){return this.getValues().map(e=>e.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 e=this._deps.getStyles();return this.getValues().map(n=>n.map(s=>e.getStyleByCell(s)))}getVerticalAlignment(){return this.getVerticalAlignments()[0][0]}getVerticalAlignments(){return this._getStyles("vt")}getWidth(){const{_range:e,_worksheet:n}=this,{startColumn:s,endColumn:r}=e;let i=0;for(let o=0;o<=r-s;o++)i+=n.getColumnWidth(o);return i}getWrap(){return this.getWrapStrategy()===ye.WRAP?Y.TRUE:Y.FALSE}getWrapStrategies(){return this._getStyles("tb")}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(e){nn.foreach(this._range,e)}_getStyles(e){const n=this._deps.getStyles();return this.getValues().map(s=>s.map(r=>{const i=n&&n.getStyleByCell(r);return i&&i[e]||pn[e]}))}};g(nn,"transformRange",(e,n)=>e.rangeType===ot.ALL?{startColumn:0,startRow:0,endColumn:n.getMaxColumns()-1,endRow:n.getMaxRows()-1}:e.rangeType===ot.COLUMN?{startRow:0,endRow:n.getMaxRows()-1,startColumn:e.startColumn,endColumn:e.endColumn}:e.rangeType===ot.ROW?{startColumn:0,endColumn:n.getMaxColumns()-1,startRow:e.startRow,endRow:e.endRow}:e);let ke=nn;function Jl(t,e){if(t.length===0||t[0].length===0)return null;const n=new Array(t[0].length).fill(0);let s=0,r=null;for(let i=0;i<t.length;i++){for(let l=0;l<t[0].length;l++)n[l]=e(t[i][l])?n[l]+1:0;const o=Zl(n);o.area>s&&(s=o.area,r={startColumn:o.start,startRow:i-o.height+1,endColumn:o.end,endRow:i})}return r}function Zl(t){const e=[];let n=0,s={area:0,height:0,start:0,end:0},r=0;for(;r<t.length;)if(e.length===0||t[r]>=t[e[e.length-1]])e.push(r++);else{const i=t[e.pop()],o=e.length===0?r:r-e[e.length-1]-1;i*o>n&&(n=i*o,s={area:n,height:i,start:e.length===0?0:e[e.length-1]+1,end:r-1})}for(;e.length>0;){const i=t[e.pop()],o=e.length===0?r:r-e[e.length-1]-1;i*o>n&&(n=i*o,s={area:n,height:i,start:e.length===0?0:e[e.length-1]+1,end:r-1})}return s}function Ql(t,e){ke.foreach(e,(n,s)=>{t[n][s]=void 0})}function ta(t,e){const n=t.toFullArray(),s=[];for(;;){const r=Jl(n,e);if(!r)break;s.push(r),Ql(n,r)}return s}function ea(t,e,n,s=!1){let r={...t};const i=r.startAbsoluteRefType||Nt.NONE,o=r.endAbsoluteRefType||Nt.NONE;return!s&&i===Nt.ALL&&o===Nt.ALL?r:s||i===Nt.NONE&&o===Nt.NONE?me.moveOffset(r,e,n):(i===Nt.NONE?r={...r,startRow:r.startRow+n,startColumn:r.startColumn+e}:i===Nt.COLUMN?r={...r,startRow:r.startRow+n}:i===Nt.ROW&&(r={...r,startColumn:r.startColumn+e}),o===Nt.NONE?r={...r,endRow:r.endRow+n,endColumn:r.endColumn+e}:o===Nt.COLUMN?r={...r,endRow:r.endRow+n}:o===Nt.ROW&&(r={...r,endColumn:r.endColumn+e}),r)}async function zr(t){for(const[e,n]of t.entries())try{if(!await n())return{index:e,result:!1}}catch(s){return{index:e,result:!1,error:s}}return{result:!0,index:-1}}function Xr(t){for(const[e,n]of t.entries())try{if(!n())return{index:e,result:!1}}catch(s){return{index:e,result:!1,error:s}}return{result:!0,index:-1}}const Ye=ut.createIdentifier("univer.context-service");class qr extends yt{constructor(){super(...arguments);g(this,"_contextChanged$",new V.Subject);g(this,"contextChanged$",this._contextChanged$.asObservable());g(this,"_contextMap",new Map)}dispose(){super.dispose(),this._contextChanged$.complete()}getContextValue(n){var s;return(s=this._contextMap.get(n))!=null?s:!1}setContextValue(n,s){this._contextMap.set(n,s),this._contextChanged$.next({[n]:s})}subscribeContextValue$(n){return new V.Observable(s=>{const r=this._contextChanged$.pipe(V.filter(i=>typeof i[n]<"u")).subscribe(i=>s.next(i[n]));return this._contextMap.has(n)&&s.next(this._contextMap.get(n)),()=>r.unsubscribe()})}}var Jr=(t=>(t[t.SILENT=0]="SILENT",t[t.ERROR=1]="ERROR",t[t.WARN=2]="WARN",t[t.INFO=3]="INFO",t[t.VERBOSE=4]="VERBOSE",t))(Jr||{});const Ee=ut.createIdentifier("univer.log");class Zr extends yt{constructor(){super(...arguments);g(this,"_logLevel",3)}debug(...n){this._logLevel>=4&&this._log(console.debug,...n)}log(...n){this._logLevel>=3&&this._log(console.log,...n)}warn(...n){this._logLevel>=2&&this._log(console.warn,...n)}error(...n){this._logLevel>=1&&this._log(console.error,...n)}setLogLevel(n){this._logLevel=n}_log(n,...s){const r=s[0];/^\[(.*?)\]/g.test(r)?n(`\x1B[97;104m${r}\x1B[0m`,...s.slice(1)):n(...s)}}var na=Object.defineProperty,sa=Object.getOwnPropertyDescriptor,ra=(t,e,n,s)=>{for(var r=s>1?void 0:s?sa(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(e,n,r):o(r))||r);return s&&r&&na(e,n,r),r},Qr=(t,e)=>(n,s)=>e(n,s,t),ze=(t=>(t[t.COMMAND=0]="COMMAND",t[t.OPERATION=1]="OPERATION",t[t.MUTATION=2]="MUTATION",t))(ze||{});const Xe=ut.createIdentifier("anywhere.command-service");class ia{constructor(){g(this,"_commands",new Map);g(this,"_commandTypes",new Map)}registerCommand(e){if(this._commands.has(e.id))throw new Error(`[CommandRegistry]: command "${e.id}" has been registered before.`);return this._commands.set(e.id,e),this._commandTypes.set(e.id,e.type),At(()=>{var n;this._commands.delete(e.id),this._commandTypes.delete(e.id),(n=e.onDispose)==null||n.call(e)})}hasCommand(e){return this._commands.has(e)}getCommand(e){return this._commands.has(e)?[this._commands.get(e)]:null}getCommandType(e){return this._commandTypes.get(e)}}const ti={id:"nil",type:0,handler:()=>!0};u.CommandService=class{constructor(e,n){g(this,"_commandRegistry");g(this,"_beforeCommandExecutionListeners",[]);g(this,"_commandExecutedListeners",[]);g(this,"_multiCommandDisposables",new Map);g(this,"_commandExecutingLevel",0);g(this,"_commandExecutionStack",[]);this._injector=e,this._logService=n,this._commandRegistry=new ia,this._registerCommand(ti)}hasCommand(e){return this._commandRegistry.hasCommand(e)}registerCommand(e){return this._registerCommand(e)}registerMultipleCommand(e){return this._registerMultiCommand(e)}beforeCommandExecuted(e){if(this._beforeCommandExecutionListeners.indexOf(e)===-1)return this._beforeCommandExecutionListeners.push(e),At(()=>{const n=this._beforeCommandExecutionListeners.indexOf(e);this._beforeCommandExecutionListeners.splice(n,1)});throw new Error("[CommandService]: could not add a listener twice.")}onCommandExecuted(e){if(this._commandExecutedListeners.indexOf(e)===-1)return this._commandExecutedListeners.push(e),At(()=>{const n=this._commandExecutedListeners.indexOf(e);this._commandExecutedListeners.splice(n,1)});throw new Error("[CommandService]: could not add a listener twice.")}async executeCommand(e,n,s){try{const r=this._commandRegistry.getCommand(e);if(r){const[i]=r,o={id:i.id,type:i.type,params:n},l=this._pushCommandExecutionStack(o);this._beforeCommandExecutionListeners.forEach(h=>h(o,s));const a=await this._execute(i,n,s);return this._commandExecutedListeners.forEach(h=>h(o,s)),l.dispose(),a}throw new Error(`[CommandService]: command "${e}" is not registered.`)}catch(r){throw this._logService.error(r),r}}syncExecuteCommand(e,n,s){var i;const r=this._commandRegistry.getCommand(e);if(r){const[o]=r,l={id:o.id,type:o.type,params:n};if(o.type===2){const d=Ml(this._commandExecutionStack,c=>c.type===0);d&&(l.params=(i=l.params)!=null?i:{},l.params.trigger=d.id)}const a=this._pushCommandExecutionStack(l);this._beforeCommandExecutionListeners.forEach(d=>d(l,s));const h=this._syncExecute(o,n,s);return this._commandExecutedListeners.forEach(d=>d(l,s)),a.dispose(),h}throw new Error(`[CommandService]: command "${e}" is not registered.`)}_pushCommandExecutionStack(e){return this._commandExecutionStack.push(e),At(()=>En(this._commandExecutionStack,e))}_registerCommand(e){return this._commandRegistry.registerCommand(e)}_registerMultiCommand(e){const n=this._commandRegistry.getCommand(e.id);let s;if(n){if(n[0].multi!==!0)throw new Error("Command has registered as a single command.");s=n[0]}else{const i=new xn;s=new oa(e.id),i.add(this._commandRegistry.registerCommand(s)),i.add(At(()=>{this._multiCommandDisposables.delete(e.id)})),this._multiCommandDisposables.set(e.id,i)}const r=s.registerImplementation(e);return At(()=>{var i;r.dispose(),s.hasImplementations()||(i=this._multiCommandDisposables.get(e.id))==null||i.dispose()})}async _execute(e,n,s){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(this._commandExecutingLevel,0))}executing command "${e.id}"`),this._commandExecutingLevel++;let r;try{r=await this._injector.invoke(e.handler,n,s),this._commandExecutingLevel--}catch(i){throw r=!1,this._commandExecutingLevel=0,i}return r}_syncExecute(e,n,s){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(0,this._commandExecutingLevel))}executing command "${e.id}".`),this._commandExecutingLevel++;let r;try{if(r=this._injector.invoke(e.handler,n,s),r instanceof Promise)throw new TypeError("[CommandService]: Command handler should not return a promise.");this._commandExecutingLevel--}catch(i){throw r=!1,this._commandExecutingLevel=0,i}return r}},u.CommandService=ra([Qr(0,ut.Inject(ut.Injector)),Qr(1,Ee)],u.CommandService);class oa{constructor(e){g(this,"name");g(this,"multi",!0);g(this,"type",0);g(this,"priority",0);g(this,"_implementations",[]);g(this,"handler",async(e,n)=>{if(!this._implementations.length)return!1;const s=e.get(Ee),r=e.get(Ye),i=e.get(ut.Injector);for(const o of this._implementations){const l=o.command.preconditions;if((!l||l&&l(r))&&(s.debug("[MultiCommand]",`executing implementation "${o.command.name}".`),await i.invoke(o.command.handler,n)))return!0}return!1});this.id=e,this.name=e}registerImplementation(e){const n={command:e};return this._implementations.push(n),this._implementations.sort((s,r)=>r.command.priority-s.command.priority),At(()=>{var r;const s=this._implementations.indexOf(n);this._implementations.splice(s,1),(r=e.onDispose)==null||r.call(e)})}hasImplementations(){return this._implementations.length>0}}function qn(t,e,n){const s=t.map(r=>()=>e.syncExecuteCommand(r.id,r.params,n));return Xr(s)}function la(t,e,n){const s=t.map(r=>()=>e.executeCommand(r.id,r.params,n));return zr(s)}function ei(t){return new V.Observable(e=>{const n=t((...s)=>e.next(s));return()=>n==null?void 0:n.dispose()})}const aa=t=>new Promise(e=>{V.merge(ei(t.onCommandExecuted.bind(t)).pipe(oe.filter(([n])=>n.type===ze.MUTATION)),V.timer(300)).pipe(oe.debounceTime(16),oe.first()).subscribe(()=>{e()})});var Vt=(t=>(t[t.UNDEFINED=0]="UNDEFINED",t[t.OK=1]="OK",t[t.INTERNAL_ERROR=2]="INTERNAL_ERROR",t[t.PERMISSION_DENIED=3]="PERMISSION_DENIED",t[t.NOT_FOUND=4]="NOT_FOUND",t[t.UNAUTHENTICATED=5]="UNAUTHENTICATED",t[t.ALREADY_EXISTS=6]="ALREADY_EXISTS",t[t.INVALID_ARGUMENT=7]="INVALID_ARGUMENT",t[t.TOO_MANY_REQUESTS=8]="TOO_MANY_REQUESTS",t[t.COMPLETION_FINISHED=9]="COMPLETION_FINISHED",t[t.CHANGESET_REVISION_CONFILICT=5001]="CHANGESET_REVISION_CONFILICT",t[t.SNAPSHOT_INVALID_SNAPSHOT=6001]="SNAPSHOT_INVALID_SNAPSHOT",t[t.SNAPSHOT_HAS_BEEN_REMOVED=6002]="SNAPSHOT_HAS_BEEN_REMOVED",t[t.APPLY_REJECT=7001]="APPLY_REJECT",t[t.APPLY_NON_SEQUENTIAL_REVISION=7002]="APPLY_NON_SEQUENTIAL_REVISION",t[t.APPLY_REVISION_CONFILICT=7003]="APPLY_REVISION_CONFILICT",t[t.APPLY_PERMISSION_DENIED=7004]="APPLY_PERMISSION_DENIED",t[t.CONNECTOR_DATA_TOO_LARGE=8001]="CONNECTOR_DATA_TOO_LARGE",t[t.LICENSE_MAX_UNITS_EXCEEDED=9001]="LICENSE_MAX_UNITS_EXCEEDED",t[t.LICENSE_MAX_MEMBERS_PER_UNIT_EXCEEDED=9002]="LICENSE_MAX_MEMBERS_PER_UNIT_EXCEEDED",t[t.LICENSE_IMPORT_SIZE_EXCEEDED=9003]="LICENSE_IMPORT_SIZE_EXCEEDED",t[t.LICENSE_EXPORT_SIZE_EXCEEDED=9004]="LICENSE_EXPORT_SIZE_EXCEEDED",t[t.LICENSE_DISTRO_REJECTED=9005]="LICENSE_DISTRO_REJECTED",t[t.YUUMI_UNABLE_LOAD_URL=10001]="YUUMI_UNABLE_LOAD_URL",t[t.YUUMI_URL_COL_OUT_OF_RANGE=10002]="YUUMI_URL_COL_OUT_OF_RANGE",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(Vt||{});function ni(t){return!!(t&&t.code&&t.code!==Vt.OK&&t.code!=="OK")}var Q=(t=>(t[t.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",t[t.UNIVER_DOC=1]="UNIVER_DOC",t[t.UNIVER_SHEET=2]="UNIVER_SHEET",t[t.UNIVER_SLIDE=3]="UNIVER_SLIDE",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(Q||{}),Wt=(t=>(t[t.Reader=0]="Reader",t[t.Editor=1]="Editor",t[t.Owner=2]="Owner",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(Wt||{}),On=(t=>(t[t.Unkonwn=0]="Unkonwn",t[t.Workbook=1]="Workbook",t[t.Worksheet=2]="Worksheet",t[t.SelectRange=3]="SelectRange",t[t.Document=4]="Document",t[t.Slide=5]="Slide",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(On||{});class Sn extends yt{}class Jn{constructor(){g(this,"_data",[])}static create(){return new Jn}add(e){this._data.indexOf(e)>-1||this._data.push(e)}delete(e){const n=this._data.indexOf(e);this._data.splice(n,1)}getData(){return this._data}}class Zn{constructor(){g(this,"_data",new Map)}static create(){return new Zn}add(e,n){this._data.has(e)||this._data.set(e,n)}delete(e){this._data.delete(e)}getData(){return this._data}}var si=(t=>(t[t.PARAGRAPH=0]="PARAGRAPH",t[t.SECTION_BREAK=1]="SECTION_BREAK",t[t.TABLE=2]="TABLE",t[t.TABLE_ROW=3]="TABLE_ROW",t[t.TABLE_CELL=4]="TABLE_CELL",t[t.CUSTOM_BLOCK=5]="CUSTOM_BLOCK",t))(si||{}),le=(t=>(t.PARAGRAPH="\r",t.SECTION_BREAK=`
|
|
5
|
-
`,t.TABLE_START="",t.TABLE_ROW_START="\x1B",t.TABLE_CELL_START="",t.TABLE_CELL_END="",t.TABLE_ROW_END="*",t.TABLE_END="+",t.CUSTOM_RANGE_START="",t.CUSTOM_RANGE_END="",t.COLUMN_BREAK="\v",t.PAGE_BREAK="\f",t.DOCS_END="\0",t.TAB=" ",t.CUSTOM_BLOCK="\b",t.LETTER="",t.SPACE=" ",t))(le||{}),Nn=(t=>(t.BULLET_LIST="BULLET_LIST",t.ORDER_LIST="ORDER_LIST",t))(Nn||{});const ua={BULLET_LIST:{listType:"BULLET_LIST",nestingLevel:[{bulletAlignment:fe.START,glyphFormat:" %0",textStyle:{fs:12},startNumber:0,glyphSymbol:"●",hanging:21,indentStart:21},{bulletAlignment:fe.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"■",hanging:21,indentStart:42},{bulletAlignment:fe.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"◆",hanging:21,indentStart:63}]},ORDER_LIST:{listType:"ORDER_LIST",nestingLevel:[{bulletAlignment:fe.START,glyphFormat:" %1.",textStyle:{fs:12},startNumber:0,glyphType:je.DECIMAL,hanging:21,indentStart:21},{bulletAlignment:fe.START,glyphFormat:" %1.%2)",textStyle:{fs:12},startNumber:0,glyphType:je.DECIMAL,hanging:21,indentStart:42},{bulletAlignment:fe.START,glyphFormat:" %1.%2.%3.",textStyle:{fs:12},startNumber:0,glyphType:je.DECIMAL,hanging:21,indentStart:63}]}};function Qn(t){const e=[];for(const n of t){const{ed:s,ts:r}=n;if(n.sId===void 0&&delete n.sId,y.isEmptyObject(r)&&n.sId==null)continue;if(e.length===0){e.push(n);continue}const i=e.pop();Mr(n,i)&&y.hasIntersectionBetweenTwoRanges(i.st,i.ed,n.st,n.ed)?e.push({...n,st:i.st,ed:s}):e.push(i,n)}return e}function ri(t,e,n,s){var h;const{textRuns:r}=t;if(r==null)return;const i=[],o=r.length;let l=!1;const a=(h=e.textRuns)!=null?h:[];if(a.length)for(const d of a)d.st+=s,d.ed+=s;for(let d=0;d<o;d++){const c=r[d],f=r[d+1],{st:_,ed:E}=c;if(E<s)i.push(c);else if(s>=_&&s<=E){if(f&&f.st===f.ed&&s===f.st){i.push(c);continue}if(l)c.st+=n,c.ed+=n,i.push(c);else{l=!0,c.ed+=n;const R=[];if(a.length){const H={...c,st:_,ed:a[0].st};H.ed>H.st&&R.push(H),R.push(...a);const k=a[a.length-1],et={...c,st:k.ed,ed:E+n};et.ed>et.st&&R.push(et)}else R.push(c);i.push(...R)}}else c.st+=n,c.ed+=n,l||(l=!0,i.push(...a)),i.push(c)}l||(l=!0,i.push(...a)),t.textRuns=Qn(i)}function ts(t,e,n,s){const{paragraphs:r}=t;if(r==null)return;const{paragraphs:i,dataStream:o}=e,l=[];let a=-1;for(let d=0,c=r.length;d<c;d++){const f=r[d],{startIndex:_}=f;_>=s&&(f.startIndex+=n),a===-1&&_>=s&&(a=d),l.push(f.startIndex)}let h=-1;if(i){for(let d=0,c=i.length;d<c;d++){const f=i[d];f.startIndex+=s;const _=f.startIndex;h=l.indexOf(_)}if(o===le.PARAGRAPH&&i.length===1){const d=r[a],c=i[0],f=d.paragraphStyle,_=d.bullet;d.paragraphStyle=c.paragraphStyle,d.bullet=c.bullet,c.paragraphStyle=f,c.bullet=_}h!==-1&&r.splice(h,1),r.push(...i),r.sort(Ae("startIndex"))}}function ca(t,e,n,s){const{sectionBreaks:r}=t;if(r==null)return;for(let o=0,l=r.length;o<l;o++){const a=r[o],{startIndex:h}=a;h>=s&&(a.startIndex+=n)}const i=e.sectionBreaks;if(i){for(let o=0,l=i.length;o<l;o++){const a=i[o];a.startIndex+=s}r.push(...i),r.sort(Ae("startIndex"))}}function ii(t,e,n,s){const{customBlocks:r}=t;if(r==null)return;for(let o=0,l=r.length;o<l;o++){const a=r[o],{startIndex:h}=a;h>=s&&(a.startIndex+=n)}const i=e.customBlocks;if(i){for(let o=0,l=i.length;o<l;o++){const a=i[o];a.startIndex+=s}r.push(...i),r.sort(Ae("startIndex"))}}function oi(t,e,n,s){const{tables:r}=t;if(r==null)return;for(let o=0,l=r.length;o<l;o++){const a=r[o],{startIndex:h,endIndex:d}=a;h>s?(a.startIndex+=n,a.endIndex+=n):d>=s-1&&(a.endIndex+=n)}const i=e.tables;if(i){for(let o=0,l=i.length;o<l;o++){const a=i[o];a.startIndex+=s,a.endIndex+=s}r.push(...i),r.sort(Ae("startIndex"))}}function li(t,e,n,s){t.customRanges||(t.customRanges=[]);const{customRanges:r}=t,i={};for(let l=0,a=r.length;l<a;l++){const h=r[l];i[h.rangeId]=h;const{startIndex:d,endIndex:c}=h;d>=s?(h.startIndex+=n,h.endIndex+=n):c>s-1&&(h.endIndex+=n)}const o=[];if(e.customRanges){for(let l=0,a=e.customRanges.length;l<a;l++){const h=e.customRanges[l],d=i[h.rangeId];if(h.startIndex+=s,h.endIndex+=s,d){if(d.startIndex<=h.startIndex&&d.endIndex>=h.endIndex)continue;if(t.dataStream[d.startIndex]===le.CUSTOM_RANGE_START&&t.dataStream[d.endIndex]===le.CUSTOM_RANGE_END){o.push(h);continue}if(t.dataStream[d.startIndex]===le.CUSTOM_RANGE_START){d.endIndex=h.endIndex;continue}if(t.dataStream[d.endIndex]===le.CUSTOM_RANGE_END){d.startIndex=h.startIndex;continue}}o.push(h)}r.push(...o),r.sort(Ae("startIndex"))}}function ha(t){t.sort((s,r)=>s.startIndex-r.startIndex);const e=[];let n=t[0];for(let s=1;s<t.length;s++)n.endIndex+1>=t[s].startIndex?n.endIndex=Math.max(n.endIndex,t[s].endIndex):(e.push(n),n=t[s]);return e.push(n),e}function da(t){const e={};for(let n=0,s=t.length;n<s;n++){const r=t[n],i=e[r.id];e[r.id]=[...i!=null?i:[],r]}return Object.keys(e).forEach(n=>{const s=e[n],r=ha(s);e[n]=r}),Object.values(e).flat()}function ai(t,e,n,s){t.customDecorations||(t.customDecorations=[]);const{customDecorations:r}=t;if(n>0)for(let i=0,o=r.length;i<o;i++){const l=r[i],{startIndex:a,endIndex:h}=l;a>=s?(l.startIndex+=n,l.endIndex+=n):h>s-1&&(l.endIndex+=n)}if(e.customDecorations){const i=[];for(let o=0,l=e.customDecorations.length;o<l;o++){const a=e.customDecorations[o];i.push(a),a.startIndex+=s,a.endIndex+=s}r.push(...i),t.customDecorations=da(r),t.customDecorations.sort(Ae("startIndex"))}}function ui(t,e,n){var l;const{textRuns:s}=t,r=n,i=n+e,o=[];if(r===i&&(s!=null&&s.find(a=>a.st===n&&a.ed===n))){const a=s.find(h=>h.st===n&&h.ed===n);return o.push({...a,st:a.st-n,ed:a.ed-n}),t.textRuns=(l=t.textRuns)==null?void 0:l.filter(h=>h!==a),o}if(s){const a=[];for(let h=0,d=s.length;h<d;h++){const c=s[h],{st:f,ed:_}=c;if(r<=f&&i>=_){o.push({...c,st:f-r,ed:_-r});continue}else f<=r&&_>=i?(o.push({...c,st:r-r,ed:i-r}),c.ed-=e):r>=f&&r<_?(o.push({...c,st:r-r,ed:_-r}),c.ed=r):i>f&&i<=_?(o.push({...c,st:f-r,ed:i-r}),c.st=i-e,c.ed-=e):f>=i&&(c.st-=e,c.ed-=e);a.push(c)}t.textRuns=a}return o.length===0&&o.push({st:0,ed:e,ts:{}}),o}function ci(t,e,n){const{paragraphs:s}=t,r=n,i=n+e,o=[];if(s){const l=[];for(let a=0,h=s.length;a<h;a++){const d=s[a],{startIndex:c}=d;if(c>=r&&c<i){o.push({...d,startIndex:c-n});continue}else c>=i&&(d.startIndex-=e);l.push(d)}t.paragraphs=l}return o}function hi(t,e,n){const{sectionBreaks:s}=t,r=n,i=n+e-1,o=[];if(s){const l=[];for(let a=0,h=s.length;a<h;a++){const d=s[a],{startIndex:c}=d;if(c>=r&&c<=i){o.push({...d,startIndex:c-n});continue}else c>i&&(d.startIndex-=e);l.push(d)}t.sectionBreaks=l}return o}function di(t,e,n){const{customBlocks:s}=t,r=n,i=n+e-1,o=[];if(s){const l=[];for(let a=0,h=s.length;a<h;a++){const d=s[a],{startIndex:c}=d;if(c>=r&&c<=i){o.push({...d,startIndex:c-n});continue}else c>i&&(d.startIndex-=e);l.push(d)}t.customBlocks=l}return o}function fi(t,e,n){const{tables:s}=t,r=n,i=n+e-1,o=[];if(s){const l=[];for(let a=0,h=s.length;a<h;a++){const d=s[a],{startIndex:c,endIndex:f}=d;if(r<=c&&i>=f){o.push({...d,startIndex:c-n,endIndex:f-n});continue}else if(c<=r&&f>=i){const _=mn(c,f,r,i);d.startIndex=_[0],d.endIndex=_[1]}else i<c&&(d.startIndex-=e,d.endIndex-=e);l.push(d)}t.tables=l}return o}function _i(t,e,n){const{customRanges:s}=t,r=n,i=n+e-1,o=[];if(s){const l=[];for(let a=0,h=s.length;a<h;a++){const d=s[a],{startIndex:c,endIndex:f}=d;if(r<=c&&i>=c){o.push({...d,startIndex:c-n,endIndex:f-n});continue}else if(c<=r&&f>=i){const _=mn(c,f,r,i);d.startIndex=_[0],d.endIndex=_[1]}else i<c&&(d.startIndex-=e,d.endIndex-=e);l.push(d)}t.customRanges=l}return o}function gi(t,e,n,s=!0){const{customDecorations:r}=t,i=n,o=n+e-1,l=[];if(r){const a=[];for(let h=0,d=r.length;h<d;h++){const c=r[h],{startIndex:f,endIndex:_}=c;if(f>=i&&_<=o){l.push(c);continue}else if(Math.max(i,f)<=Math.min(o,_)){const E=mn(f,_,i,o);c.startIndex=E[0],c.endIndex=E[1]}else o<f&&s&&(c.startIndex-=e,c.endIndex-=e);a.push(c)}t.customDecorations=a}return l}function fa(t,e,n,s,r){const i=_a(t,e,n,s,r),o=ga(t,e,n,s,r),l=ma(t,e,n,s,r),a=Ea(t,e,n,s,r),h=Ra(t,e,n,s,r),d=Ca(t,e,n,s,r),c=pa(t,e,n,s,r);return{dataStream:"",textRuns:i,paragraphs:o,sectionBreaks:l,customBlocks:a,tables:h,customRanges:d,customDecorations:c}}function _a(t,e,n,s,r){const{textRuns:i}=t,{textRuns:o}=e;if(i==null||o==null)return;const l=ui(t,n,s);if(r!==kt.REPLACE){const a=mi(o,l,r);e.textRuns=a}return ri(t,e,n,s),l}function mi(t,e,n){if(e.length===0)return t;t=y.deepClone(t),e=y.deepClone(e);const s=[],r=t.length,i=e.length;let o=0,l=0,a=null;function h(){return a?(s.push(a),a=null,!0):!1}for(;o<r&&l<i;){const{st:_,ed:E,ts:R}=t[o],{st:H,ed:k,ts:et,sId:mt}=e[l];let ft;if(n===kt.COVER?ft={...et,...R}:ft={...R,...et},E<H)h()||s.push(t[o]),o++;else if(k<_)h()||s.push(e[l]),l++;else{const C={st:Math.min(_,H),ed:Math.max(_,H),ts:_<H?{...R}:{...et},sId:_<H?void 0:mt};C.ed>C.st&&s.push(C),s.push({st:Math.max(_,H),ed:Math.min(E,k),ts:ft,sId:mt}),E<k?(o++,e[l].st=E,e[l].st===e[l].ed&&l++):(l++,t[o].st=k,t[o].st===t[o].ed&&o++);const S={st:Math.min(E,k),ed:Math.max(E,k),ts:E<k?{...et}:{...R},sId:E<k?mt:void 0};a=S.ed>S.st?S:null}}h();const d=s[s.length-1],c=t[r-1],f=e[i-1];return d.ed!==Math.max(c.ed,f.ed)&&(c.ed>f.ed?s.push(c):s.push(f)),Qn(s)}function ga(t,e,n,s,r){const{paragraphs:i}=t,{paragraphs:o}=e;if(i==null||o==null)return;const l=ci(t,n,s);if(r!==kt.REPLACE){const a=[];for(const h of o){const{startIndex:d,paragraphStyle:c,bullet:f}=h;let _=[];for(const E of l){const{startIndex:R,paragraphStyle:H,bullet:k}=E;let et,mt;if(r===kt.COVER?(et={...H,...c},mt={listId:"",listType:Nn.BULLET_LIST,nestingLevel:0,textStyle:{},...k,...f}):(et={...c,...H},mt={listId:"",listType:Nn.BULLET_LIST,nestingLevel:0,textStyle:{},...f,...k}),d===R){_.push({startIndex:d,paragraphStyle:et,bullet:mt});break}}a.push(..._),_=[]}e.paragraphs=a}return ts(t,e,n,s),l}function ma(t,e,n,s,r){const{sectionBreaks:i}=t,{sectionBreaks:o}=e;if(i==null||o==null)return;const l=hi(t,n,s);if(r!==kt.REPLACE){const a=[];for(const h of o){const{startIndex:d}=h;let c=[];for(const f of l){const{startIndex:_}=f;if(d===_){r===kt.COVER?c.push({...f,...h}):c.push({...h,...f});break}}a.push(...c),c=[]}e.sectionBreaks=a}return ts(t,e,n,s),l}function Ea(t,e,n,s,r){const{customBlocks:i}=t,{customBlocks:o}=e;if(i==null||o==null)return;const l=di(t,n,s);if(r!==kt.REPLACE){const a=[];for(const h of o){const{startIndex:d}=h;let c=[];for(const f of l){const{startIndex:_}=f;if(d===_){r===kt.COVER?c.push({...f,...h}):c.push({...h,...f});break}}a.push(...c),c=[]}e.customBlocks=a}return ii(t,e,n,s),l}function Ra(t,e,n,s,r){const{tables:i}=t,{tables:o}=e;if(i==null||o==null)return;const l=fi(t,n,s);if(r!==kt.REPLACE){const a=[];for(const h of o){const{startIndex:d,endIndex:c}=h;let f=[];for(const _ of l){const{startIndex:E,endIndex:R}=_;if(E>=d&&R<=c){r===kt.COVER?f.push({..._,...h}):f.push({...h,..._});break}}a.push(...f),f=[]}e.tables=a}return oi(t,e,n,s),l}function Ca(t,e,n,s,r){t.customRanges||(t.customRanges=[]);const{customRanges:i}=t,{customRanges:o}=e;if(i==null||o==null)return;let l=[];return r===kt.REPLACE&&(l=_i(t,n,s)),li(t,e,0,s),l}function pa(t,e,n,s,r){t.customDecorations||(t.customDecorations=[]);let i=[];return r===kt.REPLACE&&(i=gi(t,n,s,!1)),ai(t,e,0,s),i}function qe(t,e,n,s=!1){const{dataStream:r,textRuns:i=[],paragraphs:o=[]}=t,l={dataStream:r.slice(e,n)},a=[];for(const c of i){const f=y.deepClone(c),{st:_,ed:E}=f;y.hasIntersectionBetweenTwoRanges(_,E,e,n)&&(e>=_&&e<=E?a.push({...f,st:e,ed:Math.min(n,E)}):n>=_&&n<=E?a.push({...f,st:Math.max(e,_),ed:n}):a.push(f))}a.length?l.textRuns=a.map(c=>{const{st:f,ed:_}=c;return{...c,st:f-e,ed:_-e}}):s&&(l.textRuns=[{st:0,ed:n-e,ts:{}}]);const h=[];for(const c of o){const{startIndex:f}=c;f>=e&&f<=n&&h.push(y.deepClone(c))}h.length&&(l.paragraphs=h.map(c=>({...c,startIndex:c.startIndex-e}))),l.customDecorations=Ri(t,e,n);const{customRanges:d}=Ei(t,e,n);return l.customRanges=d,l}function Ia(t){const{dataStream:e,textRuns:n,paragraphs:s,customRanges:r,customDecorations:i}=t;let o=0,l=0;r==null||r.forEach(h=>{h.startIndex<0&&(o=Math.max(o,-h.startIndex)),h.endIndex>e.length-1&&(l=Math.max(l,h.endIndex-e.length+1))});const a=`${le.CUSTOM_RANGE_START.repeat(o)}${e}${le.CUSTOM_RANGE_END.repeat(l)}`;return n&&(n[0]&&(n[0].st=n[0].st-o),n[n.length-1]&&(n[n.length-1].ed=n[n.length-1].ed+l)),n==null||n.forEach(h=>{h.st+=o,h.ed+=o}),s==null||s.forEach(h=>{h.startIndex+=o}),r==null||r.forEach(h=>{h.startIndex+=o,h.endIndex+=o}),i==null||i.forEach(h=>{h.startIndex+=o,h.endIndex+=l}),{...t,dataStream:a,textRuns:n,paragraphs:s,customRanges:r,customDecorations:i}}function Ei(t,e,n){const{customRanges:s=[]}=t;let r=0,i=0;const o=s.filter(l=>Math.max(l.startIndex,e)<=Math.min(l.endIndex,n-1)).map(l=>({...l,startIndex:l.startIndex,endIndex:l.endIndex}));if(o.length){o.forEach(l=>{l.startIndex<e&&(r+=1),l.endIndex>n-1&&(i+=1)});for(let l=0;l<r;l++){const a=o[l];a.startIndex=e-r+l}if(i){const l=[...o].sort((a,h)=>h.endIndex-a.endIndex);for(let a=0;a<i;a++){const h=l[a];h.endIndex=n+i-a-1}}}return{customRanges:o.map(l=>({...l,startIndex:l.startIndex-e,endIndex:l.endIndex-e})),leftOffset:r,rightOffset:i}}function Ri(t,e,n){const{customDecorations:s=[]}=t,r=[];return s.forEach(i=>{if(Math.max(i.startIndex,e)<=Math.min(i.endIndex,n-1)){const o=y.deepClone(i);r.push({...o,startIndex:Math.max(o.startIndex-e,0),endIndex:Math.min(o.endIndex,n)-e})}}),r}function es(t,e,n=kt.COVER){if(e.dataStream!=="")throw new Error("Cannot compose other body with non-empty dataStream");const s={dataStream:t.dataStream},{textRuns:r=[],paragraphs:i=[]}=t,{textRuns:o=[],paragraphs:l=[]}=e,a=mi(o,r,n);a.length&&(s.textRuns=a);const h=[];let d=0,c=0;for(;d<i.length&&c<l.length;){const f=i[d],_=l[c],{startIndex:E}=f,{startIndex:R}=_;E===R?(h.push(y.deepMerge(f,_)),d++,c++):E<R?(h.push(y.deepClone(f)),d++):(h.push(y.deepClone(_)),c++)}return d<i.length&&h.push(...i.slice(d)),c<l.length&&h.push(...l.slice(c)),h.length&&(s.paragraphs=h),s}function Oa(t){const{body:e}=t;if(e==null)return!0;const{textRuns:n=[],paragraphs:s=[]}=e;return n.length===0&&s.length===0}function Sa(t=y.generateRandomId(6),e=Ie.EN_US,n=""){return{id:t,locale:e,title:n,body:{dataStream:`\r
|
|
6
|
-
`,textRuns:[],paragraphs:[{startIndex:0,paragraphStyle:{spaceAbove:5,lineSpacing:1,spaceBelow:0}}],sectionBreaks:[{startIndex:1}]},documentStyle:{pageSize:{width:793.3333333333334,height:1122.6666666666667},marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}},settings:{}}}var Bt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Na(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Gt={},Ci={},ns={};Object.defineProperty(ns,"__esModule",{value:!0});function Aa(t,e){if(Array.isArray(e))return!1;for(let n in t)if(!ss(t[n],e[n]))return!1;for(let n in e)if(t[n]===void 0)return!1;return!0}function ba(t,e){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!ss(t[n],e[n]))return!1;return!0}function ss(t,e){return t===e?!0:t===null||e===null||typeof t!="object"||typeof e!="object"?!1:Array.isArray(t)?ba(t,e):Aa(t,e)}ns.default=ss;var rs={};Object.defineProperty(rs,"__esModule",{value:!0});function is(t){if(t===null)return null;if(Array.isArray(t))return t.map(is);if(typeof t=="object"){const e={};for(let n in t)e[n]=is(t[n]);return e}else return t}rs.default=is;var os={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.eachChildOf=t.advancer=t.readCursor=t.writeCursor=t.WriteCursor=t.ReadCursor=t.isValidPathItem=void 0;function e(d,c){if(!d)throw new Error(c)}const n=d=>d!=null&&typeof d=="object"&&!Array.isArray(d),s=(d,c)=>typeof d==typeof c?d>c:typeof d=="string"&&typeof c=="number";function r(d,c){for(let f in d){const _=f;c.write(_,d[_])}}t.isValidPathItem=d=>typeof d=="number"||typeof d=="string"&&d!=="__proto__";class i{constructor(c=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=c}ascend(){e(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):(e(this.idx>0),this.idx--,n(this.container[this.idx])&&this.idx--)}getPath(){const c=[];let f=this.container,_=this.parents.length-1,E=this.idx;for(;E>=0;)c.unshift(f[E]),E===0?(E=this.indexes[_*2],f=this.parents[_--]):E-=n(f[E-1])?2:1;return c}}class o extends i{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return e(this.container!=null,"Invalid call to getKey before cursor descended"),this.container[this.idx]}getComponent(){let c;return this.container&&this.container.length>this.idx+1&&n(c=this.container[this.idx+1])?c:null}descendFirst(){let c=this.idx+1;if(!this.container||c>=this.container.length||n(this.container[c])&&c+1>=this.container.length)return!1;n(this.container[c])&&c++;const f=this.container[c];return Array.isArray(f)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(c),this.idx=0,this.container=f):this.idx=c,!0}nextSibling(){if(e(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;const c=this.indexes[this.indexes.length-1]+1,f=this.parents[this.parents.length-1];return c>=f.length?!1:(e(!isNaN(c)),this.indexes[this.indexes.length-1]=c,this.container=f[c],!0)}_init(c,f,_,E){this.container=c,this.idx=f,this.parents=_.slice(),this.indexes=E.slice()}clone(){const c=new o;return c._init(this.container,this.idx,this.parents,this.indexes),c}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(c,f){const _=this.getComponent();_&&f(_,c);for(const E of this)c&&c.descend(E),this.traverse(c,f),c&&c.ascend()}eachPick(c,f){this.traverse(c,(_,E)=>{_.p!=null&&f(_.p,E)})}eachDrop(c,f){this.traverse(c,(_,E)=>{_.d!=null&&f(_.d,E)})}}t.ReadCursor=o;class l extends i{constructor(c=null){super(c),this.pendingDescent=[],this._op=c}flushDescent(){e(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let c=0;c<this.pendingDescent.length;c++){const f=this.pendingDescent[c];let _=this.idx+1;if(_<this.container.length&&n(this.container[_])&&_++,e(_===this.container.length||!n(this.container[_])),_===this.container.length)this.container.push(f),this.idx=_;else if(this.container[_]===f)this.idx=_;else{if(!Array.isArray(this.container[_])){const E=this.container.splice(_,this.container.length-_);this.container.push(E),this.lcIdx>-1&&(this.lcIdx=_)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(e(s(f,this.container[this.lcIdx][0])),_=this.lcIdx+1,this.lcIdx=-1);_<this.container.length&&s(f,this.container[_][0]);)_++;if(this.indexes.push(_),this.idx=0,_<this.container.length&&this.container[_][0]===f)this.container=this.container[_];else{const E=[f];this.container.splice(_,0,E),this.container=E}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();const c=this.idx+1;if(c<this.container.length&&n(this.container[c]))return this.container[c];{const f={};return this.container.splice(c,0,f),f}}write(c,f){const _=this.getComponent();e(_[c]==null||_[c]===f,"Internal consistency error: Overwritten component. File a bug"),_[c]=f}get(){return this._op}descend(c){if(!t.isValidPathItem(c))throw Error("Invalid JSON key");this.pendingDescent.push(c)}descendPath(c){return this.pendingDescent.push(...c),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(c,f=r){if(c===null)return;if(e(Array.isArray(c)),c===this._op)throw Error("Cannot merge into my own tree");const _=this.lcIdx,E=this.parents.length;let R=0;for(let H=0;H<c.length;H++){const k=c[H];typeof k=="string"||typeof k=="number"?(R++,this.descend(k)):Array.isArray(k)?this.mergeTree(k,f):typeof k=="object"&&f(k,this)}for(;R--;)this.ascend();this.lcIdx=this.parents.length===E?_:-1}at(c,f){this.descendPath(c),f(this);for(let _=0;_<c.length;_++)this.ascend();return this}writeAtPath(c,f,_){return this.at(c,()=>this.write(f,_)),this.reset(),this}writeMove(c,f,_=0){return this.writeAtPath(c,"p",_).writeAtPath(f,"d",_)}getPath(){const c=super.getPath();return c.push(...this.pendingDescent),c}}t.WriteCursor=l,t.writeCursor=()=>new l,t.readCursor=d=>new o(d);function a(d,c,f){let _,E;E=_=d?d.descendFirst():!1;function R(H){let k;for(;E;){const et=k=d.getKey();if(H!=null){let mt=!1;if(c&&typeof et=="number"&&(k=c(et,d.getComponent()),k<0&&(k=~k,mt=!0)),s(k,H))return null;if(k===H&&!mt)return d}f&&typeof k=="number"&&f(k,d.getComponent()),E=d.nextSibling()}return null}return R.end=()=>{_&&d.ascend()},R}t.advancer=a;function h(d,c,f){let _,E,R,H;for(_=E=d&&d.descendFirst(),R=H=c&&c.descendFirst();_||R;){let k=_?d.getKey():null,et=R?c.getKey():null;k!==null&&et!==null&&(s(et,k)?et=null:k!==et&&(k=null)),f(k==null?et:k,k!=null?d:null,et!=null?c:null),k!=null&&_&&(_=d.nextSibling()),et!=null&&R&&(R=c.nextSibling())}E&&d.ascend(),H&&c.ascend()}t.eachChildOf=h})(os);var ls={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ConflictType=void 0,function(e){e[e.RM_UNEXPECTED_CONTENT=1]="RM_UNEXPECTED_CONTENT",e[e.DROP_COLLISION=2]="DROP_COLLISION",e[e.BLACKHOLE=3]="BLACKHOLE"}(t.ConflictType||(t.ConflictType={}))})(ls);var as={},be={},pi;function us(){return pi||(pi=1,Object.defineProperty(be,"__esModule",{value:!0}),be.uniToStrPos=be.strPosToUni=void 0,be.strPosToUni=(t,e=t.length)=>{let n=0,s=0;for(;s<e;s++){const r=t.charCodeAt(s);r>=55296&&r<=57343&&(n++,s++)}if(s!==e)throw Error("Invalid offset - splits unicode bytes");return s-n},be.uniToStrPos=(t,e)=>{let n=0;for(;e>0;e--){const s=t.charCodeAt(n);n+=s>=55296&&s<=57343?2:1}return n}),be}var cs={},Ii;function hs(){return Ii||(Ii=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.uniSlice=t.dlen=t.eachOp=void 0;const e=us(),n=C=>{if(!Array.isArray(C))throw Error("Op must be an array of components");let S=null;for(let w=0;w<C.length;w++){const q=C[w];switch(typeof q){case"object":if(typeof q.d!="number"&&typeof q.d!="string")throw Error("Delete must be number or string");if(t.dlen(q.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(q.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(q>0))throw Error("Skip components must be >0");if(typeof S=="number")throw Error("Adjacent skip components should be combined");break}S=q}if(typeof S=="number")throw Error("Op has a trailing skip")};function s(C,S){let w=0,q=0;for(let st=0;st<C.length;st++){const J=C[st];switch(S(J,w,q),typeof J){case"object":w+=t.dlen(J.d);break;case"string":q+=e.strPosToUni(J);break;case"number":w+=J,q+=J;break}}}t.eachOp=s;function r(C,S){const w=[],q=l(w);return s(C,(st,J,Yt)=>{q(S(st,J,Yt))}),c(w)}const i=C=>C,o=C=>r(C,i);t.dlen=C=>typeof C=="number"?C:e.strPosToUni(C);const l=C=>S=>{if(!(!S||S.d===0||S.d===""))if(C.length===0)C.push(S);else if(typeof S==typeof C[C.length-1])if(typeof S=="object"){const w=C[C.length-1];w.d=typeof w.d=="string"&&typeof S.d=="string"?w.d+S.d:t.dlen(w.d)+t.dlen(S.d)}else C[C.length-1]+=S;else C.push(S)},a=C=>typeof C=="number"?C:typeof C=="string"?e.strPosToUni(C):typeof C.d=="number"?C.d:e.strPosToUni(C.d);t.uniSlice=(C,S,w)=>{const q=e.uniToStrPos(C,S),st=w==null?1/0:e.uniToStrPos(C,w);return C.slice(q,st)};const h=(C,S,w)=>typeof C=="number"?w==null?C-S:Math.min(C,w)-S:t.uniSlice(C,S,w),d=C=>{let S=0,w=0;return{take:(J,Yt)=>{if(S===C.length)return J===-1?null:J;const bt=C[S];let _t;if(typeof bt=="number")return J===-1||bt-w<=J?(_t=bt-w,++S,w=0,_t):(w+=J,J);if(typeof bt=="string"){if(J===-1||Yt==="i"||e.strPosToUni(bt.slice(w))<=J)return _t=bt.slice(w),++S,w=0,_t;{const Ot=w+e.uniToStrPos(bt.slice(w),J);return _t=bt.slice(w,Ot),w=Ot,_t}}else{if(J===-1||Yt==="d"||t.dlen(bt.d)-w<=J)return _t={d:h(bt.d,w)},++S,w=0,_t;{let Ot=h(bt.d,w,w+J);return w+=J,{d:Ot}}}},peek:()=>C[S]}},c=C=>(C.length>0&&typeof C[C.length-1]=="number"&&C.pop(),C);function f(C,S,w){if(w!=="left"&&w!=="right")throw Error("side ("+w+") must be 'left' or 'right'");n(C),n(S);const q=[],st=l(q),{take:J,peek:Yt}=d(C);for(let _t=0;_t<S.length;_t++){const Ot=S[_t];let Ut,zt;switch(typeof Ot){case"number":for(Ut=Ot;Ut>0;)zt=J(Ut,"i"),st(zt),typeof zt!="string"&&(Ut-=a(zt));break;case"string":w==="left"&&typeof Yt()=="string"&&st(J(-1)),st(e.strPosToUni(Ot));break;case"object":for(Ut=t.dlen(Ot.d);Ut>0;)switch(zt=J(Ut,"i"),typeof zt){case"number":Ut-=zt;break;case"string":st(zt);break;case"object":Ut-=t.dlen(zt.d)}break}}let bt;for(;bt=J(-1);)st(bt);return c(q)}function _(C,S){n(C),n(S);const w=[],q=l(w),{take:st}=d(C);for(let Yt=0;Yt<S.length;Yt++){const bt=S[Yt];let _t,Ot;switch(typeof bt){case"number":for(_t=bt;_t>0;)Ot=st(_t,"d"),q(Ot),typeof Ot!="object"&&(_t-=a(Ot));break;case"string":q(bt);break;case"object":_t=t.dlen(bt.d);let Ut=0;for(;Ut<_t;)switch(Ot=st(_t-Ut,"d"),typeof Ot){case"number":q({d:h(bt.d,Ut,Ut+Ot)}),Ut+=Ot;break;case"string":Ut+=e.strPosToUni(Ot);break;case"object":q(Ot)}break}}let J;for(;J=st(-1);)q(J);return c(w)}const E=(C,S)=>{let w=0;for(let q=0;q<S.length&&C>w;q++){const st=S[q];switch(typeof st){case"number":{w+=st;break}case"string":const J=e.strPosToUni(st);w+=J,C+=J;break;case"object":C-=Math.min(t.dlen(st.d),C-w);break}}return C},R=(C,S)=>typeof C=="number"?E(C,S):C.map(w=>E(w,S));function H(C,S,w){return r(C,(q,st)=>typeof q=="object"&&typeof q.d=="number"?{d:w.slice(S,st,st+q.d)}:q)}function k(C){return r(C,S=>{switch(typeof S){case"object":if(typeof S.d=="number")throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");return S.d;case"string":return{d:S};case"number":return S}})}function et(C){return r(C,S=>typeof S=="object"&&typeof S.d=="string"?{d:e.strPosToUni(S.d)}:S)}function mt(C){let S=!0;return s(C,w=>{typeof w=="object"&&typeof w.d=="number"&&(S=!1)}),S}function ft(C){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:c,normalize:o,checkOp:n,create(S=""){if(typeof S!="string")throw Error("Initial data must be a string");return C.create(S)},apply(S,w){n(w);const q=C.builder(S);for(let st=0;st<w.length;st++){const J=w[st];switch(typeof J){case"number":q.skip(J);break;case"string":q.append(J);break;case"object":q.del(t.dlen(J.d));break}}return q.build()},transform:f,compose:_,transformPosition:E,transformSelection:R,isInvertible:mt,makeInvertible(S,w){return H(S,w,C)},stripInvertible:et,invert:k,invertWithDoc(S,w){return k(H(S,w,C))},isNoop:S=>S.length===0}}t.default=ft}(cs)),cs}var An={},Oi;function va(){if(Oi)return An;Oi=1,Object.defineProperty(An,"__esModule",{value:!0});const t=hs(),e=us();function n(s,r){return{get:s,getLength(){return s().length},insert(i,o,l){const a=e.strPosToUni(s(),i);return r([a,o],l)},remove(i,o,l){const a=e.strPosToUni(s(),i);return r([a,{d:o}],l)},_onOp(i){t.eachOp(i,(o,l,a)=>{switch(typeof o){case"string":this.onInsert&&this.onInsert(a,o);break;case"object":const h=t.dlen(o.d);this.onRemove&&this.onRemove(a,h)}})},onInsert:null,onRemove:null}}return An.default=n,n.provides={text:!0},An}var Si;function wa(){return Si||(Si=1,function(t){var e=Bt&&Bt.__createBinding||(Object.create?function(f,_,E,R){R===void 0&&(R=E),Object.defineProperty(f,R,{enumerable:!0,get:function(){return _[E]}})}:function(f,_,E,R){R===void 0&&(R=E),f[R]=_[E]}),n=Bt&&Bt.__setModuleDefault||(Object.create?function(f,_){Object.defineProperty(f,"default",{enumerable:!0,value:_})}:function(f,_){f.default=_}),s=Bt&&Bt.__importStar||function(f){if(f&&f.__esModule)return f;var _={};if(f!=null)for(var E in f)Object.hasOwnProperty.call(f,E)&&e(_,f,E);return n(_,f),_},r=Bt&&Bt.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(t,"__esModule",{value:!0}),t.type=t.remove=t.insert=void 0;const i=us(),o=s(hs()),l=r(va()),a={create(f){return f},toString(f){return f},builder(f){if(typeof f!="string")throw Error("Invalid document snapshot: "+f);const _=[];return{skip(E){let R=i.uniToStrPos(f,E);if(R>f.length)throw Error("The op is too long for this document");_.push(f.slice(0,R)),f=f.slice(R)},append(E){_.push(E)},del(E){f=f.slice(i.uniToStrPos(f,E))},build(){return _.join("")+f}}},slice:o.uniSlice},h=o.default(a),d=Object.assign(Object.assign({},h),{api:l.default});t.type=d,t.insert=(f,_)=>_.length===0?[]:f===0?[_]:[f,_],t.remove=(f,_)=>o.dlen(_)===0?[]:f===0?[{d:_}]:[f,{d:_}];var c=hs();Object.defineProperty(t,"makeType",{enumerable:!0,get:function(){return c.default}})}(as)),as}(function(t){var e=Bt&&Bt.__importDefault||function(m){return m&&m.__esModule?m:{default:m}};Object.defineProperty(t,"__esModule",{value:!0}),t.editOp=t.replaceOp=t.insertOp=t.moveOp=t.removeOp=t.type=void 0;const n=e(ns),s=e(rs),r=os,i=ls;function o(m,p){if(!m)throw new Error(p)}t.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:r.readCursor,writeCursor:r.writeCursor,create:m=>m,isNoop:m=>m==null,setDebug(m){},registerSubtype:k,checkValidOp:st,normalize:J,apply:Yt,transformPosition:bt,compose:_t,tryTransform:ws,transform:ac,makeInvertible:zt,invert:Ot,invertWithDoc:lc,RM_UNEXPECTED_CONTENT:i.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:i.ConflictType.DROP_COLLISION,BLACKHOLE:i.ConflictType.BLACKHOLE,transformNoConflict:(m,p,A)=>So(()=>!0,m,p,A),typeAllowingConflictsPred:m=>Object.assign(Object.assign({},t.type),{transform:(p,A,U)=>So(m,p,A,U)})};const l=m=>m?m.getComponent():null;function a(m){return m&&typeof m=="object"&&!Array.isArray(m)}const h=m=>Array.isArray(m)?m.slice():m!==null&&typeof m=="object"?Object.assign({},m):m,d=m=>m&&(m.p!=null||m.r!==void 0),c=m=>m&&(m.d!=null||m.i!==void 0);function f(m,p){return o(m!=null),typeof p=="number"?(o(Array.isArray(m),"Invalid key - child is not an array"),(m=m.slice()).splice(p,1)):(o(a(m),"Invalid key - child is not an object"),delete(m=Object.assign({},m))[p]),m}function _(m,p,A){return typeof p=="number"?(o(m!=null,"Container is missing for key"),o(Array.isArray(m),"Cannot use numerical key for object container"),o(m.length>=p,"Cannot insert into out of bounds index"),m.splice(p,0,A)):(o(a(m),"Cannot insert into missing item"),o(m[p]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),m[p]=A),A}t.removeOp=(m,p=!0)=>r.writeCursor().writeAtPath(m,"r",p).get(),t.moveOp=(m,p)=>r.writeCursor().writeMove(m,p).get(),t.insertOp=(m,p)=>r.writeCursor().writeAtPath(m,"i",p).get(),t.replaceOp=(m,p,A)=>r.writeCursor().at(m,U=>{U.write("r",p),U.write("i",A)}).get(),t.editOp=(m,p,A,U=!1)=>r.writeCursor().at(m,b=>S(b,p,A,U)).get();const E=(m,p)=>m!=null&&(typeof p=="number"?Array.isArray(m):typeof m=="object"),R=(m,p)=>E(m,p)?m[p]:void 0,H={};function k(m){let p=m.type?m.type:m;p.name&&(H[p.name]=p),p.uri&&(H[p.uri]=p)}const et=m=>{const p=H[m];if(p)return p;throw Error("Missing type: "+m)};k(wa());const mt=(m,p)=>m+p;k({name:"number",apply:mt,compose:mt,invert:m=>-m,transform:m=>m});const ft=m=>m==null?null:m.et?et(m.et):m.es?H["text-unicode"]:m.ena!=null?H.number:null,C=m=>m.es?m.es:m.ena!=null?m.ena:m.e,S=(m,p,A,U=!1)=>{const[b,M]=typeof p=="string"?[et(p),p]:[p,p.name];!U&&b.isNoop&&b.isNoop(A)||(M==="number"?m.write("ena",A):M==="text-unicode"?m.write("es",A):(m.write("et",M),m.write("e",A)))};function w(m){o(typeof m=="number"),o(m>=0),o(m===(0|m))}function q(m){typeof m=="number"?w(m):o(typeof m=="string")}function st(m){if(m===null)return;const p=new Set,A=new Set,U=M=>{let j=!0,G=!1;for(let I in M){const N=M[I];if(j=!1,o(I==="p"||I==="r"||I==="d"||I==="i"||I==="e"||I==="es"||I==="ena"||I==="et","Invalid component item '"+I+"'"),I==="p")w(N),o(!p.has(N)),p.add(N),o(M.r===void 0);else if(I==="d")w(N),o(!A.has(N)),A.add(N),o(M.i===void 0);else if(I==="e"||I==="es"||I==="ena"){o(!G),G=!0;const v=ft(M);o(v,"Missing type in edit"),v.checkValidOp&&v.checkValidOp(C(M))}}o(!j)},b=(M,j,G)=>{if(!Array.isArray(M))throw Error("Op must be null or a list");if(M.length===0)throw Error("Empty descent");j||q(M[0]);let I=1,N=0,v=0;for(let T=0;T<M.length;T++){const x=M[T];if(o(x!=null),Array.isArray(x)){const K=b(x,!1);if(N){const O=typeof v,$=typeof K;O===$?o(v<K,"descent keys are not in order"):o(O==="number"&&$==="string")}v=K,N++,I=3}else typeof x=="object"?(o(I===1,`Prev not scalar - instead ${I}`),U(x),I=2):(o(I!==3),q(x),o(r.isValidPathItem(x),"Invalid path key"),I=1)}return o(N!==1,"Operation makes multiple descents. Remove some []"),o(I===2||I===3),M[0]};b(m,!0),o(p.size===A.size,"Mismatched picks and drops in op");for(let M=0;M<p.size;M++)o(p.has(M)),o(A.has(M))}function J(m){let p=0,A=[];const U=r.writeCursor();return U.mergeTree(m,(b,M)=>{const j=ft(b);if(j){const I=C(b);S(M,j,j.normalize?j.normalize(I):I)}for(const I of["r","p","i","d"])if(b[I]!==void 0){const N=I==="p"||I==="d"?(G=b[I],A[G]==null&&(A[G]=p++),A[G]):b[I];M.write(I,N)}var G}),U.get()}function Yt(m,p){if(st(p),p===null)return m;const A=[];return function U(b,M){let j=b,G=0,I={root:b},N=0,v=I,T="root";function x(){for(;N<G;N++){let K=M[N];typeof K!="object"&&(o(E(v,T)),v=v[T]=h(v[T]),T=K)}}for(;G<M.length;G++){const K=M[G];if(Array.isArray(K)){const O=U(j,K);O!==j&&O!==void 0&&(x(),j=v[T]=O)}else if(typeof K=="object"){K.d!=null?(x(),j=_(v,T,A[K.d])):K.i!==void 0&&(x(),j=_(v,T,K.i));const O=ft(K);if(O)x(),j=v[T]=O.apply(j,C(K));else if(K.e!==void 0)throw Error("Subtype "+K.et+" undefined")}else j=R(j,K)}return I.root}(m=function U(b,M){const j=[];let G=0;for(;G<M.length;G++){const T=M[G];if(Array.isArray(T))break;typeof T!="object"&&(j.push(b),b=R(b,T))}for(let T=M.length-1;T>=G;T--)b=U(b,M[T]);for(--G;G>=0;G--){const T=M[G];if(typeof T!="object"){const x=j.pop();b=b===R(x,T)?x:b===void 0?f(x,T):(N=T,v=b,(I=h(I=x))[N]=v,I)}else d(T)&&(o(b!==void 0,"Cannot pick up or remove undefined"),T.p!=null&&(A[T.p]=b),b=void 0)}var I,N,v;return b}(m,p),p)}function bt(m,p){m=m.slice(),st(p);const A=r.readCursor(p);let U,b,M=!1;const j=[];for(let I=0;;I++){const N=m[I],v=A.getComponent();if(v&&(v.r!==void 0?M=!0:v.p!=null&&(M=!1,U=v.p,b=I)),I>=m.length)break;let T=0;const x=r.advancer(A,void 0,(O,$)=>{d($)&&T++});j.unshift(x);const K=x(N);if(typeof N=="number"&&(m[I]-=T),!K)break}if(j.forEach(I=>I.end()),M)return null;const G=()=>{let I=0;if(U!=null){const N=A.getPath();I=N.length,m=N.concat(m.slice(b))}for(;I<m.length;I++){const N=m[I],v=l(A),T=ft(v);if(T){const O=C(v);T.transformPosition&&(m[I]=T.transformPosition(m[I],O));break}let x=0;const K=r.advancer(A,(O,$)=>c($)?~(O-x):O-x,(O,$)=>{c($)&&x++})(N);if(typeof N=="number"&&(m[I]+=x),!K)break}};return U!=null?A.eachDrop(null,I=>{I===U&&G()}):G(),m}function _t(m,p){if(st(m),st(p),m==null)return p;if(p==null)return m;let A=0;const U=r.readCursor(m),b=r.readCursor(p),M=r.writeCursor(),j=[],G=[],I=[],N=[],v=[],T=[],x=new Set;U.traverse(null,O=>{O.p!=null&&(I[O.p]=U.clone())}),b.traverse(null,O=>{O.d!=null&&(N[O.d]=b.clone())});const K=r.writeCursor();return function O($,gt,ct,Z,Rt,ue,Ht,Lt){o(gt||ct);const Ct=l(gt),Xt=l(ct),Qt=!!Xt&&Xt.r!==void 0,Te=!!Ct&&Ct.i!==void 0,qt=Ct?Ct.d:null,xt=Xt?Xt.p:null,ce=(ue||Qt)&&xt==null;if(xt!=null)Z=N[xt],Ht=G[xt]=new r.WriteCursor;else if(Xt&&Xt.r!==void 0)Z=null;else{const D=l(Z);D&&D.d!=null&&(Z=null)}const lt=l(Z);if(qt!=null)if($=I[qt],Lt=j[qt]=new r.WriteCursor,ce)ue&&!Qt&&Lt.write("r",!0);else{const D=v[qt]=A++;Ht.write("d",D)}else if(Ct&&Ct.i!==void 0)$=null;else{const D=l($);D&&D.p!=null&&($=null)}let P;Te?(o(Rt===void 0),P=Ct.i):P=Rt;const z=(xt==null?!Te||ue||Qt:P===void 0)?null:Ht.getComponent();if(xt!=null){if(!(Rt!==void 0||Te)){const D=qt!=null?v[qt]:A++;T[xt]=D,Lt.write("p",D)}}else Qt&&(Te||Rt!==void 0||(Xt.r,Lt.write("r",Xt.r)));const F=ce?null:ft(Ct),L=ft(lt);if((F||L)&&(F&&F.name,L&&L.name),F&&L){o(F===L);const D=C(Ct),X=C(lt),Tt=F.compose(D,X);S(Ht,F,Tt),x.add(lt)}else F?S(Ht,F,C(Ct)):L&&(S(Ht,L,C(lt)),x.add(lt));const W=typeof P=="object"&&P!=null;let rt=!1,it=0,at=0,wt=0,vt=0,pt=0;const Pt=r.advancer(Z,(D,X)=>c(X)?vt-D-1:D-vt,(D,X)=>{c(X)&&vt++}),nt=r.advancer($,(D,X)=>d(X)?it-D-1:D-it,(D,X)=>{d(X)&&it++});if(r.eachChildOf(gt,ct,(D,X,Tt)=>{let Ft,he,Me=D,te=D,rn=D;if(typeof D=="number"){let Dt=D+wt;he=Pt(Dt),te=Dt+vt;let St=D+at;Ft=nt(St),c(l(he))&&(Ft=null),Me=St+it,rn=D+pt,o(Me>=0,"p1PickKey is negative"),o(te>=0,"p2DropKey is negative");const ee=c(l(X)),de=d(l(Tt));(ee||de&&!ce)&&pt--,ee&&at--,de&&wt--}else Ft=nt(D),he=Pt(D);Lt.descend(Me),Ht.descend(te);const We=W&&!c(l(X))?P[rn]:void 0,re=O(Ft,X,Tt,he,We,ce,Ht,Lt);var ie,B,Et;W&&!ce?We!==re&&(rt||(P=Array.isArray(P)?P.slice():Object.assign({},P),rt=!0),ie=P,Et=re,typeof(B=rn)=="number"?(o(Array.isArray(ie)),o(B<ie.length)):(o(!Array.isArray(ie)),o(ie[B]!==void 0)),Et===void 0?typeof B=="number"?ie.splice(B,1):delete ie[B]:ie[B]=Et):o(re===void 0),Ht.ascend(),Lt.ascend()}),nt.end(),Pt.end(),z!=null)z.i=P;else if(!ue&&!Qt&&xt==null)return P}(U,U.clone(),b,b.clone(),void 0,!1,M,K),M.reset(),M.mergeTree(K.get()),M.reset(),M.get(),j.map(O=>O.get()),G.map(O=>O.get()),U.traverse(M,(O,$)=>{const gt=O.p;if(gt!=null){const ct=v[gt];ct!=null&&$.write("p",ct);const Z=j[gt];Z&&Z.get(),Z&&$.mergeTree(Z.get())}else O.r!==void 0&&$.write("r",O.r)}),M.reset(),M.get(),b.traverse(M,(O,$)=>{const gt=O.d;if(gt!=null){const Z=T[gt];Z!=null&&$.write("d",Z);const Rt=G[gt];Rt&&$.mergeTree(Rt.get())}else O.i!==void 0&&$.write("i",O.i);const ct=ft(O);ct&&!x.has(O)&&S($,ct,C(O))}),M.get()}function Ot(m){if(m==null)return null;const p=new r.ReadCursor(m),A=new r.WriteCursor;let U;const b=[],M=[];return function j(G,I,N){const v=G.getComponent();let T,x=!1;if(v){v.p!=null&&(I.write("d",v.p),b[v.p]=G.clone()),v.r!==void 0&&I.write("i",v.r),v.d!=null&&(I.write("p",v.d),N=void 0),v.i!==void 0&&(N=T=v.i);const O=ft(v);O&&(N===void 0?(U||(U=new Set),U.add(v)):(C(v),N=O.apply(N,C(v)),x=!0))}let K=0;for(const O of G){I.descend(O);const $=typeof O=="number"?O-K:O,gt=R(N,$);c(G.getComponent())&&K++;const ct=j(G,I,gt);if(N!==void 0&&ct!==void 0){if(x||(x=!0,N=h(N)),!E(N,$))throw Error("Cannot modify child - invalid operation");N[$]=ct}I.ascend()}if(T===void 0)return x?N:void 0;I.write("r",N)}(p,A,void 0),U&&(A.reset(),function j(G,I,N){const v=I.getComponent();if(v){const O=v.d;if(O!=null&&(G=b[O],N=M[O]=r.writeCursor()),U.has(v)){const $=ft(v);if(!$.invert)throw Error(`Cannot invert subtype ${$.name}`);S(N,$,$.invert(C(v)))}}let T=0,x=0;const K=r.advancer(G,(O,$)=>d($)?T-O-1:O-T,(O,$)=>{d($)&&T++});for(const O of I)if(typeof O=="number"){const $=O-x,gt=K($),ct=$+T;N.descend(ct),j(gt,I,N),c(I.getComponent())&&x++,N.ascend()}else N.descend(O),j(K(O),I,N),N.ascend();K.end()}(p.clone(),p,A),M.length&&(A.reset(),p.traverse(A,(j,G)=>{const I=j.p;if(I!=null){const N=M[I];N&&N.get(),N&&G.mergeTree(N.get())}}))),A.get()}const Ut=(m,p)=>m.some(A=>typeof A=="object"&&(Array.isArray(A)?Ut(A,p):p(A)));function zt(m,p){if(m==null||!Ut(m,I=>{var N;return I.r!==void 0||((N=ft(I))===null||N===void 0?void 0:N.makeInvertible)!=null}))return m;const A=new r.ReadCursor(m),U=new r.WriteCursor;let b=!1;const M=[],j=[],G=(I,N,v)=>{const T=I.getComponent();let x=!1;if(T){T.d!=null&&N.write("d",T.d),T.i!==void 0&&N.write("i",T.i);const O=T.p;if(O!=null&&(M[O]=I.clone(),o(v!==void 0,"Operation picks up at an invalid key"),j[O]=v,N.write("p",T.p)),T.r!==void 0&&v===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const $=ft(T);$&&($.makeInvertible?b=!0:S(N,$,C(T),!0))}let K=0;for(const O of I){N.descend(O);const $=typeof O=="number"?O-K:O,gt=R(v,$),ct=G(I,N,gt);gt!==ct&&(x||(x=!0,v=h(v)),ct===void 0?(v=f(v,$),typeof O=="number"&&K++):v[$]=ct),N.ascend()}return T&&(T.r!==void 0?(N.write("r",s.default(v)),v=void 0):T.p!=null&&(v=void 0)),v};return G(A,U,p),U.get(),b&&(U.reset(),function I(N,v,T,x,K){const O=v.getComponent();if(O){O.i!==void 0?(x=O.i,K=!0):O.d!=null&&(x=j[O.d],N=M[O.d],K=!1,O.d);let Z=ft(O);if(Z&&Z.makeInvertible){const Rt=C(O);S(T,Z,Z.makeInvertible(Rt,x),!0)}}let $=0,gt=0;const ct=r.advancer(N,(Z,Rt)=>d(Rt)?$-Z-1:Z-$,(Z,Rt)=>{d(Rt)&&$++});for(const Z of v)if(typeof Z=="number"){const Rt=Z-gt,ue=ct(Rt),Ht=Rt+$,Lt=R(x,K?Rt:Ht);T.descend(Z),I(ue,v,T,Lt,K),c(v.getComponent())&>++,T.ascend()}else{const Rt=R(x,Z);T.descend(Z),I(ct(Z),v,T,Rt,K),T.ascend()}ct.end()}(A.clone(),A,U,p,!1)),U.get()}function lc(m,p){return Ot(zt(m,p))}const vs=m=>{if(m==null)return null;const p=m.slice();for(let A=0;A<m.length;A++){const U=p[A];Array.isArray(U)&&(p[A]=vs(U))}return p};function ws(m,p,A){o(A==="left"||A==="right","Direction must be left or right");const U=A==="left"?0:1;if(p==null)return{ok:!0,result:m};st(m),st(p);let b=null;const M=[],j=[],G=[],I=[],N=[],v=[],T=[],x=[],K=[],O=[],$=[],gt=[],ct=[],Z=[],Rt=[];let ue=0;const Ht=r.readCursor(m),Lt=r.readCursor(p),Ct=r.writeCursor();if(function lt(P,z=null,F){const L=l(z);L&&(L.r!==void 0?F=z.clone():L.p!=null&&(F=null,v[L.p]=P.clone()));const W=P.getComponent();let rt;W&&(rt=W.p)!=null&&(N[rt]=z?z.clone():null,G[rt]=P.clone(),F&&(O[rt]=!0,K[rt]=F),L&&L.p!=null&&(Z[rt]=L.p));const it=r.advancer(z);for(const at of P)lt(P,it(at),F);it.end()}(Lt,Ht,null),function lt(P,z,F,L,W){const rt=F.getComponent();let it,at=!1;rt&&((it=rt.d)!=null?(I[it]=F.clone(),L!=null&&(Rt[L]==null&&(Rt[L]=[]),Rt[L].push(it)),P=N[it]||null,z=G[it]||null,O[it]?(W&&($[it]=!0),W=K[it]||null):!W||U!==1&&Z[it]!=null||b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.removeOp(W.getPath()),op2:t.moveOp(z.getPath(),F.getPath())}),at=!0):rt.i!==void 0&&(P=z=null,at=!0,W&&b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.removeOp(W.getPath()),op2:t.insertOp(F.getPath(),rt.i)})));const wt=l(P);wt&&(wt.r!==void 0?W=P.clone():wt.p!=null&&(wt.p,L=wt.p,W=null));const vt=ft(rt);vt&&W&&b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.removeOp(W.getPath()),op2:t.editOp(F.getPath(),vt,C(rt),!0)});let pt=0,Pt=0;const nt=r.advancer(z,(X,Tt)=>d(Tt)?pt-X-1:X-pt,(X,Tt)=>{d(Tt)&&pt++}),D=r.advancer(P);for(const X of F)if(typeof X=="number"){const Tt=X-Pt,Ft=nt(Tt);Pt+=+lt(D(Tt+pt),Ft,F,L,W)}else{const Tt=nt(X);lt(D(X),Tt,F,L,W)}return nt.end(),D.end(),at}(Ht,Lt,Lt.clone(),null,null),I.map(lt=>lt&<.get()),b)return{ok:!1,conflict:b};$.map(lt=>!!lt);const Xt=[];let Qt=null;(function lt(P,z,F,L,W){let rt=!1;const it=l(z);if(d(it)){const nt=it.p;nt!=null?(F=I[nt],L=gt[nt]=r.writeCursor(),rt=!0,W=null):(F=null,W=z.clone())}else c(l(F))&&(F=null);const at=P.getComponent();if(at){const nt=at.p;nt!=null?(W&&(x[nt]=W),Xt[nt]=W||U===1&&rt?null:L.getComponent(),M[nt]=P.clone(),F&&(T[nt]=F.clone())):at.r!==void 0&&(W||L.write("r",!0),(W||rt)&&(Qt==null&&(Qt=new Set),Qt.add(at)))}let wt=0,vt=0;const pt=r.advancer(z,void 0,(nt,D)=>{d(D)&&wt++}),Pt=r.advancer(F,(nt,D)=>c(D)?~(nt-vt):nt-vt,(nt,D)=>{c(D)&&vt++});if(P)for(const nt of P)if(typeof nt=="string"){const D=pt(nt),X=Pt(nt);L.descend(nt),lt(P,D,X,L,W),L.ascend()}else{const D=pt(nt),X=nt-wt,Tt=d(l(D))?null:Pt(X),Ft=X+vt;o(Ft>=0),L.descend(Ft),lt(P,D,Tt,L,W),L.ascend()}pt.end(),Pt.end()})(Ht,Lt,Lt.clone(),Ct,null),Ct.reset();let Te=[];if(function lt(P,z,F,L,W,rt){o(z);const it=z.getComponent();let at=l(L),wt=!1;const vt=(B,Et,Dt)=>B?t.moveOp(B.getPath(),Et.getPath()):t.insertOp(Et.getPath(),Dt.i);if(c(it)){const B=it.d;B!=null&&(j[B]=z.clone());const Et=B!=null?Xt[B]:null;let Dt=!1;if(it.i!==void 0||B!=null&&Et){let St;at&&(at.i!==void 0||(St=at.d)!=null&&!O[St])&&(Dt=St!=null?B!=null&&B===Z[St]:n.default(at.i,it.i),Dt||St!=null&&U!==1&&Z[St]!=null||b==null&&(b={type:i.ConflictType.DROP_COLLISION,op1:vt(B!=null?M[B]:null,z,it),op2:vt(St!=null?G[St]:null,L,at)})),Dt||(rt?b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:vt(B!=null?M[B]:null,z,it),op2:t.removeOp(rt.getPath())}):(B!=null?(Te[ue]=B,W.write("d",Et.p=ue++)):W.write("i",s.default(it.i)),wt=!0))}else if(B!=null&&!Et){const St=x[B];St&&(rt=St.clone())}B!=null?(P=M[B],F=v[B],L=T[B]):it.i!==void 0&&(P=F=null,Dt||(L=null))}else d(l(P))&&(P=F=L=null);const pt=l(P),Pt=l(F);if(d(Pt)){const B=Pt.p;Pt.r!==void 0&&(!pt||pt.r===void 0)||O[B]?(L=null,rt=F.clone()):B!=null&&(L=I[B],U!==1&&Z[B]!=null||((W=ct[B])||(W=ct[B]=r.writeCursor()),W.reset(),rt=null))}else!c(it)&&c(at)&&(L=null);at=L!=null?L.getComponent():null;const nt=ft(it);if(nt){const B=C(it);if(rt)b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.editOp(z.getPath(),nt,B,!0),op2:t.removeOp(rt.getPath())});else{const Et=ft(at);let Dt;if(Et){if(nt!==Et)throw Error("Transforming incompatible types");const St=C(at);Dt=nt.transform(B,St,A)}else Dt=s.default(B);S(W,nt,Dt)}}let D=0,X=0,Tt=0,Ft=0,he=0,Me=0,te=P!=null&&P.descendFirst(),rn=te;const We=r.advancer(F,void 0,(B,Et)=>{d(Et)&&Tt++});let re=L!=null&&L.descendFirst(),ie=re;for(const B of z)if(typeof B=="number"){let Et;const Dt=c(z.getComponent()),St=B-X;{let pe;for(;te&&typeof(pe=P.getKey())=="number";){pe+=D;const ne=P.getComponent(),Be=d(ne);if(pe>St||pe===St&&(!Be||U===0&&Dt))break;if(Be){D--;const Ue=ne.p;Z.includes(Ue),ne.d,l(ct[ne.d]),d(l(ct[ne.d])),(ne.r===void 0||Qt&&Qt.has(ne))&&(Ue==null||!Xt[Ue]||U!==1&&Z.includes(Ue))||he--}te=P.nextSibling()}Et=te&&pe===St?P:null}const ee=St-D;let de=We(ee);const Ts=ee-Tt;let kn=null;{let pe,ne;for(;re&&typeof(pe=L.getKey())=="number";){ne=pe-Ft;const Be=L.getComponent(),Ue=c(Be);if(ne>Ts)break;if(ne===Ts){if(!Ue){kn=L;break}{if(U===0&&Dt){kn=L;break}const Le=de&&d(de.getComponent());if(U===0&&Le)break}}if(Ue){const Le=Be.d;Z[Le],Be.i===void 0&&(O[Le]||Z[Le]!=null&&U!==1)?(O[Le]||Z[Le]!=null&&U===0)&&(Ft++,Me--):Ft++}re=L.nextSibling()}}const No=Ts+Ft+he+Me;o(No>=0,"trying to descend to a negative index"),W.descend(No),Dt&&(Et=de=kn=null,X++),lt(Et,z,de,kn,W,rt)&&Me++,W.ascend()}else{let Et;for(;te&&(Et=P.getKey(),typeof Et!="string"||!(Et>B||Et===B));)te=P.nextSibling();const Dt=te&&Et===B?P:null,St=We(B);let ee;for(;re&&(ee=L.getKey(),typeof ee!="string"||!(ee>B||ee===B));)re=L.nextSibling();const de=re&&ee===B?L:null;W.descend(B),lt(Dt,z,St,de,W,rt),W.ascend()}return We.end(),rn&&P.ascend(),ie&&L.ascend(),wt}(Ht,Ht.clone(),Lt,Lt.clone(),Ct,null),b)return{ok:!1,conflict:b};Ct.reset();const qt=(lt,P,z)=>lt.traverse(P,(F,L)=>{F.d!=null&&z(F.d,lt,L)});(O.length||gt.length)&&(qt(Lt,Ct,(lt,P,z)=>{O[lt]&&!$[lt]&&z.write("r",!0),gt[lt]&&z.mergeTree(gt[lt].get())}),Ct.reset());const xt=[],ce=[];if((ct.length||O.length)&&!b){const lt=r.readCursor(vs(Ct.get()));if(qt(lt,null,(P,z)=>{xt[P]=z.clone()}),ct.forEach(P=>{P&&qt(r.readCursor(P.get()),null,(z,F)=>{xt[z]=F.clone()})}),function P(z,F,L,W,rt,it){const at=l(F);if(at&&d(at))if(at.p!=null){const D=at.p;xt[D].getPath(),L=xt[D],W=ce[D]=r.writeCursor()}else at.r!==void 0&&(L=null);else c(l(L))&&(L=null);const wt=z.getComponent();if(wt){let D;if((D=wt.d)!=null){const X=ct[D];X&&(X.get(),W.mergeTree(X.get()),L=r.readCursor(X.get()))}}let vt=0,pt=0;const Pt=r.advancer(F,void 0,(D,X)=>{d(X)&&vt--}),nt=r.advancer(L,(D,X)=>c(X)?-(D-pt)-1:D-pt,(D,X)=>{c(X)&&pt++});for(const D of z)if(typeof D=="number"){const X=Pt(D),Tt=D+vt,Ft=nt(Tt),he=Tt+pt;W.descend(he),P(z,X,Ft,W),W.ascend()}else W.descend(D),P(z,Pt(D),nt(D),W),W.ascend();Pt.end(),nt.end()}(Lt,lt,lt.clone(),Ct),Ct.reset(),b)return{ok:!1,conflict:b};if(Ct.get(),ce.length){const P=ce.map(F=>F?F.get():null),z=r.readCursor(vs(Ct.get()));if(qt(z,Ct,(F,L,W)=>{const rt=P[F];rt&&(W.mergeTree(rt),P[F]=null)}),P.find(F=>F)){const F=r.writeCursor(),L=r.writeCursor();let W=0,rt=0;P.forEach(it=>{it!=null&&qt(r.readCursor(it),null,at=>{const wt=Te[at];F.writeMove(M[wt].getPath(),j[wt].getPath(),W++);const vt=Rt[wt];vt&&vt.forEach(pt=>{O[pt]||U!==1&&Z[pt]!=null||L.writeMove(G[pt].getPath(),I[pt].getPath(),rt++)})})}),b={type:i.ConflictType.BLACKHOLE,op1:F.get(),op2:L.get()}}}}return b?{ok:!1,conflict:b}:{ok:!0,result:Ct.get()}}const Oo=m=>{const p=new Error("Transform detected write conflict");throw p.conflict=m,p.type=p.name="writeConflict",p};function ac(m,p,A){const U=ws(m,p,A);if(U.ok)return U.result;Oo(U.conflict)}const $e=m=>{const p=r.writeCursor();return r.readCursor(m).traverse(p,(A,U)=>{(c(A)||ft(A))&&U.write("r",!0)}),p.get()},uc=(m,p)=>{const{type:A,op1:U,op2:b}=m;switch(A){case i.ConflictType.DROP_COLLISION:return p==="left"?[null,$e(b)]:[$e(U),null];case i.ConflictType.RM_UNEXPECTED_CONTENT:let M=!1;return r.readCursor(U).traverse(null,j=>{j.r!==void 0&&(M=!0)}),M?[null,$e(b)]:[$e(U),null];case i.ConflictType.BLACKHOLE:return[$e(U),$e(b)];default:throw Error("Unrecognised conflict: "+A)}};function So(m,p,A,U){let b=null;for(;;){const M=ws(p,A,U);if(M.ok)return _t(b,M.result);{const{conflict:j}=M;m(j)||Oo(j);const[G,I]=uc(j,U);p=_t(J(p),G),A=_t(J(A),I),b=_t(b,I)}}}})(Ci),function(t){var e=Bt&&Bt.__createBinding||(Object.create?function(i,o,l,a){a===void 0&&(a=l),Object.defineProperty(i,a,{enumerable:!0,get:function(){return o[l]}})}:function(i,o,l,a){a===void 0&&(a=l),i[a]=o[l]}),n=Bt&&Bt.__exportStar||function(i,o){for(var l in i)l!=="default"&&!o.hasOwnProperty(l)&&e(o,i,l)};Object.defineProperty(t,"__esModule",{value:!0}),n(Ci,t);var s=os;Object.defineProperty(t,"ReadCursor",{enumerable:!0,get:function(){return s.ReadCursor}}),Object.defineProperty(t,"WriteCursor",{enumerable:!0,get:function(){return s.WriteCursor}});var r=ls;Object.defineProperty(t,"ConflictType",{enumerable:!0,get:function(){return r.ConflictType}})}(Gt);const Ta=Ao({__proto__:null,default:Na(Gt)},[Gt]);var tt=(t=>(t.RETAIN="r",t.INSERT="i",t.DELETE="d",t))(tt||{});class ds{constructor(e){g(this,"_index",0);g(this,"_offset",0);this._actions=e}hasNext(){return this.peekLength()<Number.POSITIVE_INFINITY}next(e){e||(e=Number.POSITIVE_INFINITY);const n=this._actions[this._index];if(n){const s=this._offset,r=n.len;return e>=r-s?(e=r-s,this._index+=1,this._offset=0):this._offset+=e,n.t===tt.DELETE||n.t===tt.RETAIN&&n.body==null?y.deepClone({...n,len:e}):y.deepClone({...n,len:e,body:qe(n.body,s,s+e)})}else return{t:tt.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 e=this._actions[this._index];return e?e.t:tt.RETAIN}rest(){if(this.hasNext()){if(this._offset===0)return this._actions.slice(this._index);{const e=this._offset,n=this._index,s=this.next(),r=this._actions.slice(this._index);return this._offset=e,this._index=n,[s].concat(r)}}else return[]}}class Ni{constructor(){g(this,"cursor",0)}reset(){return this.cursor=0,this}moveCursor(e){this.cursor+=e}moveCursorTo(e){this.cursor=e}}function Ai(t,e,n){const{dataStream:s}=t,r=n,i=n+e,o=ui(t,e,n),l=ci(t,e,n),a=hi(t,e,n),h=di(t,e,n),d=fi(t,e,n),c=_i(t,e,n),f=gi(t,e,n);let _="";return s&&(t.dataStream=Dr(s,r,i),_=s.slice(r,i)),{dataStream:_,textRuns:o,paragraphs:l,sectionBreaks:a,customBlocks:h,tables:d,customRanges:c,customDecorations:f}}function bi(t,e,n,s){t.dataStream=Lr(t.dataStream,s,e.dataStream),ri(t,e,n,s),ts(t,e,n,s),ca(t,e,n,s),ii(t,e,n,s),oi(t,e,n,s),li(t,e,n,s),ai(t,e,n,s)}function Ma(t,e,n,s,r=kt.COVER){return fa(t,e,n,s,r)}function Ua(t,e,n){return e<=0?{dataStream:""}:Ai(t,e,n)}function La(t,e,n,s){n!==0&&bi(t,e,n,s)}function Da(t,e){const n=new Ni;return n.reset(),e.forEach(s=>{switch(s=y.deepClone(s),s.t){case tt.RETAIN:{const{coverType:r,body:i,len:o}=s;i!=null&&Ma(t,i,o,n.cursor,r),n.moveCursor(o);break}case tt.INSERT:{const{body:r,len:i}=s;La(t,r,i,n.cursor),n.moveCursor(i);break}case tt.DELETE:{const{len:r}=s;Ua(t,r,n.cursor);break}default:throw new Error(`Unknown action type for action: ${s}.`)}}),t}function vi(t){return Object.keys(t).length===1}const sn=class sn{constructor(){g(this,"_actions",[])}static apply(e,n){return Da(e,n)}static compose(e,n){const s=new ds(e),r=new ds(n),i=new sn;for(;s.hasNext()||r.hasNext();)if(r.peekType()===tt.INSERT)i.push(r.next());else if(s.peekType()===tt.DELETE)i.push(s.next());else{const o=Math.min(s.peekLength(),r.peekLength()),l=s.next(o),a=r.next(o);l.t===tt.INSERT&&a.t===tt.RETAIN?a.body==null?i.push(l):i.push({...l,body:es(l.body,a.body,a.coverType)}):l.t===tt.RETAIN&&a.t===tt.RETAIN?l.body==null&&a.body==null?i.push(l.len!==Number.POSITIVE_INFINITY?l:a):l.body&&a.body?i.push({...l,body:es(l.body,a.body,a.coverType)}):i.push(l.body?l:a):l.t===tt.RETAIN&&a.t===tt.DELETE?i.push(a):l.t===tt.INSERT&&(a.t,tt.DELETE)}return i.trimEndUselessRetainAction(),i.serialize()}static transform(e,n,s){throw new Error("transform is not implemented in TextX")}static isNoop(e){return e.length===0}static invert(e){const n=[];for(const s of e)if(s.t===tt.INSERT)n.push({t:tt.DELETE,len:s.len,line:0,body:s.body,segmentId:s.segmentId});else if(s.t===tt.DELETE){if(s.body==null)throw new Error("Can not invert DELETE action without body property, makeInvertible must be called first.");n.push({t:tt.INSERT,body:s.body,len:s.len,line:0,segmentId:s.segmentId})}else if(s.body!=null){if(s.oldBody==null)throw new Error("Can not invert RETAIN action without oldBody property, makeInvertible must be called first.");n.push({t:tt.RETAIN,body:s.oldBody,oldBody:s.body,len:s.len,coverType:kt.REPLACE,segmentId:s.segmentId})}else n.push(s);return n}static makeInvertible(e,n){const s=[];let r=0;for(const i of e){if(i.t===tt.DELETE&&i.body==null){const o=qe(n,r,r+i.len,!1);i.len=o.dataStream.length,i.body=o}if(i.t===tt.RETAIN&&i.body!=null){const o=qe(n,r,r+i.len,!0);i.oldBody={...o,dataStream:""},i.len=o.dataStream.length}s.push(i),i.t!==tt.INSERT&&(r+=i.len)}return s}insert(e,n,s=""){const r={t:tt.INSERT,body:n,len:e,line:0,segmentId:s};return this.push(r),this}retain(e,n="",s,r){const i={t:tt.RETAIN,len:e,segmentId:n};return s!=null&&(i.body=s),r!=null&&(i.coverType=r),this.push(i),this}delete(e,n=""){const s={t:tt.DELETE,len:e,line:0,segmentId:n};return this.push(s),this}serialize(){return this._actions}push(...e){if(e.length>1){for(const i of e)this.push(i);return this}let n=this._actions.length,s=this._actions[n-1];const r=y.deepClone(e[0]);if(r.t===tt.RETAIN&&r.len===0&&r.body==null)return this;if(typeof s=="object"){if(s.t===tt.DELETE&&r.t===tt.DELETE)return s.len+=r.len,this;if(s.t===tt.DELETE&&r.t===tt.INSERT&&(n-=1,s=this._actions[n-1],s==null))return this._actions.unshift(r),this;if(s.t===tt.RETAIN&&r.t===tt.RETAIN&&s.body==null&&r.body==null)return s.len+=r.len,this;if(s.t===tt.INSERT&&vi(s.body)&&r.t===tt.INSERT&&vi(r.body))return s.len+=r.len,s.body.dataStream+=r.body.dataStream,this}return n===this._actions.length?this._actions.push(r):this._actions.splice(n,0,r),this}trimEndUselessRetainAction(){let e=this._actions[this._actions.length-1];for(;e&&e.t===tt.RETAIN&&Oa(e);)this._actions.pop(),e=this._actions[this._actions.length-1];return this}};g(sn,"id","text-x"),g(sn,"uri","https://github.com/dream-num/univer#text-x");let Re=sn;Object.defineProperty(Re,"name",{value:"text-x"});const Fe=class Fe{static registerSubtype(e){var n;this._subTypes.has(e.name)&&((n=this._subTypes.get(e.name))==null?void 0:n.id)!==Re.id||(this._subTypes.set(e.name,e),Gt.type.registerSubtype(e))}static apply(e,n){if(!Gt.type.isNoop(n))return Gt.type.apply(e,n)}static compose(e,n){return Gt.type.compose(e,n)}static transform(e,n,s){throw new Error("transform is not implemented in JsonX")}static invertWithDoc(e,n){return Gt.type.invertWithDoc(e,n)}static isNoop(e){return Gt.type.isNoop(e)}static getInstance(){return this._instance==null&&(this._instance=new Fe),this._instance}removeOp(e,n){return Gt.removeOp(e,n)}moveOp(e,n){return Gt.moveOp(e,n)}insertOp(e,n){return Gt.insertOp(e,n)}replaceOp(e,n,s){return Gt.replaceOp(e,n,s)}editOp(e,n=["body"]){return Gt.editOp(n,Re.name,e)}};g(Fe,"uri","https://github.com/dream-num/univer#json-x"),g(Fe,"_subTypes",new Map),g(Fe,"_instance",null);let ve=Fe;ve.registerSubtype(Re);const fs={id:"default_doc",documentStyle:{}};class ya extends Sn{constructor(n){super();g(this,"type",Q.UNIVER_DOC);g(this,"snapshot");this.snapshot={...fs,...n}}getUnitId(){throw new Error("Method not implemented.")}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,s){this.snapshot.drawings=n,this.snapshot.drawingsOrder=s}getBody(){return this.snapshot.body}getShouldRenderLoopImmediately(){return this.snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this.snapshot.container}getSnapshot(){return this.snapshot}updateDocumentId(n){this.snapshot.id=n}updateDocumentRenderConfig(n){const{documentStyle:s}=this.snapshot;s.renderConfig==null?s.renderConfig=n:s.renderConfig={...s.renderConfig,...n}}updateDocumentStyle(n){this.snapshot.documentStyle==null?this.snapshot.documentStyle=n:this.snapshot.documentStyle={...this.snapshot.documentStyle,...n}}updateDocumentDataMargin(n){const{t:s,l:r,b:i,r:o}=n,{documentStyle:l}=this.snapshot;s!=null&&(l.marginTop=s),r!=null&&(l.marginLeft=r),i!=null&&(l.marginBottom=i),o!=null&&(l.marginRight=o)}updateDocumentDataPageSize(n,s){const{documentStyle:r}=this.snapshot;if(!r.pageSize){n=n!=null?n:Number.POSITIVE_INFINITY,s=s!=null?s:Number.POSITIVE_INFINITY,r.pageSize={width:n,height:s};return}n!==void 0&&(r.pageSize.width=n),s!==void 0&&(r.pageSize.height=s)}updateDrawing(n,s){const{drawings:r}=this,{width:i,height:o,left:l,top:a}=s,h=r==null?void 0:r[n];if(!h)return;const d=h.docTransform;d.size.width=i,d.size.height=o,d.positionH.posOffset=l,d.positionV.posOffset=a}setZoomRatio(n=1){this.snapshot.settings==null?this.snapshot.settings={zoomRatio:n}:this.snapshot.settings.zoomRatio=1}}class we extends ya{constructor(n){var r;super(y.isEmptyObject(n)?Sa():n);g(this,"_unitId");g(this,"headerModelMap",new Map);g(this,"footerModelMap",new Map);const s=6;this._unitId=(r=this.snapshot.id)!=null?r:y.generateRandomId(s),this._initializeHeaderFooterModel()}dispose(){this.headerModelMap.forEach(n=>{n.dispose()}),this.footerModelMap.forEach(n=>{n.dispose()})}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}getRev(){var n;return(n=this.snapshot.rev)!=null?n:1}incrementRev(){this.snapshot.rev=this.getRev()+1}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={...fs,...n},this._initializeHeaderFooterModel()}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(!ve.isNoop(n))return this.snapshot=ve.apply(this.snapshot,n),n!=null&&n.some(s=>Array.isArray(s)&&((s==null?void 0:s[0])==="headers"||(s==null?void 0:s[0])==="footers"))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.snapshot}sliceBody(n,s){const r=this.getBody();if(r!=null)return qe(r,n,s)}_initializeHeaderFooterModel(){const{headers:n,footers:s}=this.getSnapshot();if(n)for(const r in n){const i=n[r];this.headerModelMap.set(r,new we(i))}if(s)for(const r in s){const i=s[r];this.footerModelMap.set(r,new we(i))}}updateDocumentId(n){super.updateDocumentId(n),this._unitId=n}}const wi=ut.createIdentifier("univer.config-service");class Ti{constructor(){g(this,"_config",new Map)}getConfig(e){return this._config.get(e)}setConfig(e,n){this._config.set(e,n)}deleteConfig(e){this._config.delete(e)}}class Mi extends yt{constructor(){super(...arguments);g(this,"_error$",new V.Subject);g(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(n){this._error$.next({errorKey:n})}}class Ui{constructor(e={}){g(this,"_styles");g(this,"_cacheMap",new xr(1e5));this._styles=e,this._generateCacheMap()}each(e){return Object.entries(this._styles).forEach(e),this}search(e,n){if(this._cacheMap.has(n))return this._cacheMap.get(n);const s=this._getExistingStyleId(e);return s||"-1"}get(e){return typeof e!="string"?e:(e=String(e),this._styles[e])}add(e,n){const s=y.generateRandomId(6);return this._styles[s]=e,this._cacheMap.set(n,s),s}setValue(e){if(e==null)return;const n=JSON.stringify(e),s=this.search(e,n);return s!=="-1"?s:this.add(e,n)}toJSON(){return this._styles}getStyleByCell(e){let n;e&&y.isObject(e.s)?n=e.s:n=(e==null?void 0:e.s)&&this.get(e.s);const s=e==null?void 0:e.interceptorStyle;return s?{...n,...s}:n}_generateCacheMap(){const{_styles:e,_cacheMap:n}=this;for(const s in e){const r=JSON.stringify(e[s]);n.set(r,s)}}_getExistingStyleId(e){const{_styles:n}=this;for(const s in n)if(y.diffValue(n[s],e))return s;return null}}class Pa{constructor(e,n){g(this,"_columnData",{});this._config=e,this._columnData=n}getColumnData(){return this._columnData}getColVisible(e){const{_columnData:n}=this,s=n[e];return s?s.hd!==Y.TRUE:!0}getHiddenCols(e=0,n=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=e;o<=n;o++){const l=this.getColVisible(o);r&&l?(r=!1,s.push({rangeType:ot.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&!l&&(r=!0,i=o)}return r&&s.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:ot.COLUMN}),s}getVisibleCols(e=0,n=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=e;o<=n;o++){const l=this.getColVisible(o);r&&!l?(r=!1,s.push({rangeType:ot.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&l&&(r=!0,i=o)}return r&&s.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:ot.COLUMN}),s}getColumnDatas(e,n){const s={};let r=0;for(let i=e;i<e+n;i++){const o=this.getColumnOrCreate(i);s[r]=o,r++}return s}getSize(){return ge(this._columnData)}getColumnWidth(e){const{_columnData:n}=this,s=this._config;let r=0;return r=(n[e]||{hd:Y.FALSE,w:s.defaultColumnWidth}).w||s.defaultColumnWidth,r}getColumn(e){const n=this._columnData[e];if(n)return n}getColumnOrCreate(e){const{_columnData:n}=this,s=this._config,r=n[e];if(r)return r;const i={w:s.defaultColumnWidth,hd:Y.FALSE};return this._columnData[e]=i,i}}class ka{constructor(e,n,s){g(this,"_rowData");this._config=e,this._viewModel=n,this._rowData=s}getRowData(){return this._rowData}getRowDatas(e,n){const s={};let r=0;for(let i=e;i<e+n;i++){const o=this.getRowOrCreate(i);s[r]=o,r++}return s}getRowHeight(e,n=1){const{_rowData:s}=this,r=this._config;let i=0;for(let o=0;o<n;o++){const l=s[o+e]||{hd:Y.FALSE,h:r.defaultRowHeight},{ia:a,ah:h,h:d=r.defaultRowHeight}=l;i+=(a==null||a===Y.TRUE)&&typeof h=="number"?h:d}return i}getRow(e){return this._rowData[e]}getRowOrCreate(e){const{_rowData:n}=this,s=n[e];if(s)return s;const r=this._config,i={hd:Y.FALSE,h:r.defaultRowHeight};return n[e]=i,i}getHiddenRows(e=0,n=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=e;o<=n;o++){const l=this.getRowRawVisible(o);r&&l?(r=!1,s.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:ot.ROW})):!r&&!l&&(r=!0,i=o)}return r&&s.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:ot.ROW}),s}getVisibleRows(e=0,n=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=e;o<=n;o++){const l=this.getRowRawVisible(o);r&&!l?(r=!1,s.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:ot.ROW})):!r&&l&&(r=!0,i=o)}return r&&s.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:ot.ROW}),s}getRowRawVisible(e){const n=this.getRow(e);return n?n.hd!==Y.TRUE:!0}getSize(){return ge(this._rowData)}}const Ha="DEFAULT_WORKSHEET_ROW_COUNT",Li=1e3,Fa="DEFAULT_WORKSHEET_COLUMN_COUNT",Di=20,$a="DEFAULT_WORKSHEET_ROW_HEIGHT",yi=24,Wa="DEFAULT_WORKSHEET_COLUMN_WIDTH",Pi=88,Ba="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",ki=46,Ga="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Hi=20;function Fi(t){const e={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:Y.FALSE,rowCount:Li,columnCount:Di,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:Pi,defaultRowHeight:yi,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:Y.TRUE,rowHeader:{width:ki,hidden:Y.FALSE},columnHeader:{height:Hi,hidden:Y.FALSE},selections:["A1"],rightToLeft:Y.FALSE};return Object.keys(e).forEach(n=>{const s=n;typeof t[s]>"u"&&(t[s]=e[s])}),t}class $i extends yt{constructor(n){super();g(this,"_cellContentInterceptor",null);g(this,"_rowFilteredInterceptor",null);this.getRawCell=n}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(n,s){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,s):this.getRawCell(n,s)}getRowFiltered(n){var s,r;return(r=(s=this._rowFilteredInterceptor)==null?void 0:s.getRowFiltered(n))!=null?r:!1}registerCellContentInterceptor(n){if(this._cellContentInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptor=n,At(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(n){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=n,At(()=>this._rowFilteredInterceptor=null)}}class Je{constructor(e,n,s){g(this,"_sheetId");g(this,"_snapshot");g(this,"_cellData");g(this,"_rowManager");g(this,"_columnManager");g(this,"_viewModel");var l;this.unitId=e,this._styles=s,this._snapshot=Fi(n);const{columnData:r,rowData:i,cellData:o}=this._snapshot;this._sheetId=(l=this._snapshot.id)!=null?l:y.generateRandomId(6),this._cellData=new Zt(o),this._viewModel=new $i((a,h)=>this.getCellRaw(a,h)),this._rowManager=new ka(this._snapshot,this._viewModel,i),this._columnManager=new Pa(this._snapshot,r)}__interceptViewModel(e){e(this._viewModel)}getSnapshot(){return this._snapshot}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const e=this.getCellMatrix(),n=this.getMergeData();let s=-1,r=-1,i=-1,o=-1,l=!1,a=!1;return e.forEach((h,d)=>{Object.keys(d).forEach(c=>{const f=+c,_=e.getValue(h,f),E=_!=null&&_.s?this._styles.get(_.s):null,R=(E==null?void 0:E.bd)&&(E.bd.b||E.bd.l||E.bd.r||E.bd.t||E.bd.bc_tr||E.bd.bl_tr||E.bd.ml_tr||E.bd.tl_bc||E.bd.tl_br||E.bd.tl_mr);(_&&(_.v||_.p)||E!=null&&E.bg||R)&&(l?s=Math.min(s,h):(s=h,l=!0),r=Math.max(r,h),a?i=Math.min(i,f):(a=!0,i=f),o=Math.max(o,f))})}),n.forEach(h=>{l?s=Math.min(s,h.startRow):(s=h.startRow,l=!0),r=Math.max(r,h.endRow),a?i=Math.min(i,h.startColumn):(i=h.startColumn,l=!0),o=Math.max(o,h.endColumn)}),!l||!a?null:{startColumn:i,startRow:s,endColumn:o,endRow:r}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:e}=this,n=y.deepClone(e);return new Je(this.unitId,n,this._styles)}getMergeData(){return this._snapshot.mergeData}getMergedCell(e,n){const s=this._snapshot.mergeData;for(let r=0;r<s.length;r++){const i=s[r];if(me.intersects({startRow:e,startColumn:n,endRow:e,endColumn:n},i))return i}return null}getCell(e,n){return e<0||n<0?null:this._viewModel.getCell(e,n)}getCellRaw(e,n){return this.getCellMatrix().getValue(e,n)}getRowFiltered(e){return this._viewModel.getRowFiltered(e)}getMatrixWithMergedCells(e,n,s,r,i=!1){const o=this.getCellMatrix(),l=this._snapshot.mergeData.filter(h=>me.intersects({startRow:e,startColumn:n,endRow:s,endColumn:r},h)),a=new Zt;return zn(e,s,n,r).forEach((h,d)=>{const c=i?this.getCellRaw(h,d):this.getCell(h,d);c&&a.setValue(h,d,c)}),l.forEach(h=>{const{startColumn:d,startRow:c,endColumn:f,endRow:_}=h;zn(c,_,d,f).forEach((E,R)=>{E===c&&R===d&&a.setValue(E,R,{...o.getValue(E,R),rowSpan:_-c+1,colSpan:f-d+1}),(E!==c||R!==d)&&a.realDeleteValue(E,R)})}),a}getRange(e,n,s,r){return typeof e=="object"?new ke(this,e,{getStyles:()=>this._styles}):new ke(this,{startRow:e,startColumn:n,endColumn:r||n,endRow:s||e},{getStyles:()=>this._styles})}getScrollLeftTopFromSnapshot(){return{scrollLeft:this._snapshot.scrollLeft,scrollTop:this._snapshot.scrollTop}}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){const{_snapshot:e}=this,{columnCount:n}=e;return n}getMaxRows(){const{_snapshot:e}=this,{rowCount:n}=e;return n}getRowCount(){return this._snapshot.rowCount}setRowCount(e){this._snapshot.rowCount=e}getColumnCount(){return this._snapshot.columnCount}setColumnCount(e){this._snapshot.columnCount=e}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:e}=this,{showGridlines:n}=e;return n===0}getTabColor(){const{_snapshot:e}=this,{tabColor:n}=e;return n}getColumnWidth(e){return this.getColumnManager().getColumnWidth(e)}getRowHeight(e){return this._viewModel.getRowFiltered(e)?0:this.getRowManager().getRowHeight(e)}getRowVisible(e){return this._viewModel.getRowFiltered(e)?!1:this.getRowRawVisible(e)}getRowRawVisible(e){return this.getRowManager().getRowRawVisible(e)}getHiddenRows(e,n){const s=this.getMaxColumns()-1,r=this._rowManager.getHiddenRows(e,n);return r.forEach(i=>i.endColumn=s),r}getColVisible(e){return this._columnManager.getColVisible(e)}getHiddenCols(e,n){const s=this.getMaxRows()-1,r=this._columnManager.getHiddenCols(e,n);return r.forEach(i=>i.endRow=s),r}getVisibleRows(){const e=this.getRowCount();return this._rowManager.getVisibleRows(0,e-1)}getVisibleCols(){const e=this.getColumnCount();return this._columnManager.getVisibleCols(0,e-1)}isRightToLeft(){const{_snapshot:e}=this,{rightToLeft:n}=e;return n}getLastRowWithContent(){return this._cellData.getLength()-1}getLastColumnWithContent(){return this._cellData.getRange().endColumn}cellHasValue(e){return e&&(e.v!==void 0||e.f!==void 0||e.p!==void 0)}iterateByRow(e,n=!0){const{startRow:s,startColumn:r,endRow:i,endColumn:o}=e,l=this;return{[Symbol.iterator]:()=>{let a=s,h=r;return{next(){for(;;){if(h>o&&(a+=1,h=r),a>i)return{done:!0,value:void 0};const d=l.getCell(a,h),c=!d,f=l.getMergedCell(a,h);if(f){if(a!==f.startRow||h!==f.startColumn){h=f.endColumn+1;continue}if(c&&n){h=f.endColumn+1;continue}const E={row:a,col:h,value:d};return E.colSpan=f.endColumn-f.startColumn+1,E.rowSpan=f.endRow-f.startRow+1,h=f.endColumn+1,{done:!1,value:E}}if(c&&n)h+=1;else{const _={row:a,col:h,value:d};return h+=1,{done:!1,value:_}}}}}}}}iterateByColumn(e,n=!0,s=!0){const{startRow:r,startColumn:i,endRow:o,endColumn:l}=e,a=this;return{[Symbol.iterator]:()=>{let h=r,d=i;return{next(){for(;;){if(h>o&&(d+=1,h=r),d>l)return{done:!0,value:void 0};const c=a.getMergedCell(h,d);if(c){const E=h!==c.startRow,R=E||d!==c.startColumn;if(s&&R||!s&&E){h=c.endRow+1;continue}const H=a.getCell(c.startRow,c.startColumn);if(!H&&n){h=c.endRow+1;continue}const et={row:h,col:c.startColumn,value:H};return et.colSpan=c.endColumn-c.startColumn+1,et.rowSpan=c.endRow-c.startRow+1,h=c.endRow+1,{done:!1,value:et}}const f=a.getCell(h,d);if(!f&&n)h+=1;else{const E={row:h,col:d,value:f};return h+=1,{done:!1,value:E}}}}}}}}}function xa(t){var s,r;if(!t)return"";const e=(r=(s=t.p)==null?void 0:s.body)==null?void 0:r.dataStream;if(e)return e;const n=t.v;return typeof n=="string"?t.t===Se.BOOLEAN?n.toUpperCase():n.replace(/[\r\n]/g,""):typeof n=="number"?t.t===Se.BOOLEAN?n?"TRUE":"FALSE":n.toString():typeof n=="boolean"?n?"TRUE":"FALSE":""}const ja="0.2.1";function Va(t="",e=Ie.ZH_CN,n=""){return{id:t,sheetOrder:[],name:n,appVersion:ja,locale:e,styles:{},sheets:{},resources:[]}}var Ka=Object.defineProperty,Ya=Object.getOwnPropertyDescriptor,za=(t,e,n,s)=>{for(var r=s>1?void 0:s?Ya(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(e,n,r):o(r))||r);return s&&r&&Ka(e,n,r),r},Xa=(t,e)=>(n,s)=>e(n,s,t);function qa(t,e){return`${t.getUnitId()}|${e.getSheetId()}`}u.Workbook=class extends Sn{constructor(n={},s){super();g(this,"type",Q.UNIVER_SHEET);g(this,"_sheetCreated$",new V.Subject);g(this,"sheetCreated$",this._sheetCreated$.asObservable());g(this,"_sheetDisposed$",new V.Subject);g(this,"sheetDisposed$",this._sheetDisposed$.asObservable());g(this,"_activeSheet$",new V.BehaviorSubject(null));g(this,"activeSheet$",this._activeSheet$.asObservable());g(this,"_worksheets");g(this,"_styles");g(this,"_snapshot");g(this,"_unitId");g(this,"_count");g(this,"_name$");g(this,"name$");this._logService=s;const r=Va();y.isEmptyObject(n)?this._snapshot=r:this._snapshot=y.commonExtend(r,n);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=y.generateRandomId(6)),this._unitId=this._snapshot.id,this._styles=new Ui(i),this._count=1,this._worksheets=new Map,this._name$=new V.BehaviorSubject(n.name||""),this.name$=this._name$.asObservable(),this._passWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete()}save(){return y.deepClone(this._snapshot)}static isIRangeType(n){return typeof n=="string"||"startRow"in n||"row"in n}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}getShouldRenderLoopImmediately(){return this._snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this._snapshot.container}addWorksheet(n,s,r){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[n])return!1;i[n]=r,o.splice(s,0,n);const l=new Je(this._unitId,r,this._styles);return this._worksheets.set(n,l),this._sheetCreated$.next(l),!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:s}=this._snapshot;return s.findIndex(r=>r===n)}getActiveSheet(){return this._activeSheet}ensureActiveSheet(){const n=this.getActiveSheet();if(n)return n;const s=this._snapshot.sheetOrder;for(let i=0,o=s.length;i<o;i++){const l=this._worksheets.get(s[i]);if(l&&l.isSheetHidden()!==Y.TRUE)return this.setActiveSheet(l),l}const r=this._worksheets.get(s[0]);return this.setActiveSheet(r),r}setActiveSheet(n){this._activeSheet$.next(n)}removeSheet(n){var r;const s=this._worksheets.get(n);return s?(((r=this._activeSheet)==null?void 0:r.getSheetId())===n&&this.setActiveSheet(null),this._worksheets.delete(n),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(n),1),delete this._snapshot.sheets[n],this._sheetDisposed$.next(s),!0):!1}getActiveSheetIndex(){const{sheetOrder:n}=this._snapshot;return n.findIndex(s=>this._worksheets.get(s)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:n}=this._snapshot;return n.map(s=>this._worksheets.get(s))}getSheetsName(){const{sheetOrder:n}=this._snapshot,s=[];return n.forEach(r=>{const i=this._worksheets.get(r);i&&s.push(i.getName())}),s}getSheetIndex(n){const{sheetOrder:s}=this._snapshot;return s.findIndex(r=>n.getSheetId()===r)}getSheetBySheetName(n){const{sheetOrder:s}=this._snapshot,r=s.find(i=>this._worksheets.get(i).getName()===n);return this._worksheets.get(r)}getSheetBySheetId(n){return this._worksheets.get(n)}getSheetByIndex(n){const{sheetOrder:s}=this._snapshot;return this._worksheets.get(s[n])}getHiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden===Y.TRUE).map(n=>n.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden!==Y.TRUE).map(n=>n.getConfig().id)}load(n){this._snapshot=n}checkSheetName(n){return this.getSheetsName().includes(n)}uniqueSheetName(n="Sheet1"){let s=n;for(;this.checkSheetName(s);)s=n+this._count,this._count++;return s}generateNewSheetName(n){let s=n+this._count;for(;this.checkSheetName(s);)s=n+this._count,this._count++;return s}_passWorksheetSnapshots(){const{_snapshot:n,_worksheets:s}=this,{sheets:r,sheetOrder:i}=n;if(y.isEmptyObject(r)){const o=y.generateRandomId();r[o]={id:o}}for(const o in r){const l=r[o],{name:a}=l;l.name=this.uniqueSheetName(a),l.name!==a&&this._logService.debug("[Workbook]",`The worksheet name ${a} is duplicated, we changed it to ${l.name}. Please fix the problem in your snapshot.`);const h=new Je(this._unitId,l,this._styles);s.set(o,h),i.includes(o)||i.push(o)}this.ensureActiveSheet()}},u.Workbook=za([Xa(1,Ee)],u.Workbook);class _s extends Sn{constructor(n){var s;super();g(this,"type",Q.UNIVER_SLIDE);g(this,"_snapshot");g(this,"_unitId");this._snapshot={...Kr,...n},this._unitId=(s=this._snapshot.id)!=null?s:y.generateRandomId(6)}getContainer(){return this._snapshot.container}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 s=this.getPages();return s==null?void 0:s[n]}getElementsByPage(n){var s;return(s=this.getPage(n))==null?void 0:s.pageElements}getElement(n,s){var r;return(r=this.getElementsByPage(n))==null?void 0:r[s]}getPageSize(){return this._snapshot.pageSize}addPage(){return{id:"cover_1",pageType:Wn.SLIDE,zIndex:1,title:"cover",description:"this is first page, cover",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}}const Ze="FOCUSING_SHEET",bn="FOCUSING_DOC",vn="FOCUSING_SLIDE",Ja="FOCUSING_EDITOR_BUT_HIDDEN",Wi="EDITOR_ACTIVATED",Za="FOCUSING_EDITOR_INPUT_FORMULA",Bi="FOCUSING_FORMULA_EDITOR",Qa="FOCUSING_UNIVER_EDITOR",tu="FOCUSING_EDITOR_INPUT_FORMULA",eu="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",nu="FOCUSING_COMMON_DRAWINGS";var su=Object.defineProperty,ru=Object.getOwnPropertyDescriptor,iu=(t,e,n,s)=>{for(var r=s>1?void 0:s?ru(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(e,n,r):o(r))||r);return s&&r&&su(e,n,r),r},Gi=(t,e)=>(n,s)=>e(n,s,t);const He=ut.createIdentifier("univer.current");u.UniverInstanceService=class extends yt{constructor(n,s){super();g(this,"_unitsByType",new Map);g(this,"_createHandler");g(this,"_ctorByType",new Map);g(this,"_currentUnits",new Map);g(this,"_currentUnits$",new V.BehaviorSubject(this._currentUnits));g(this,"currentUnits$",this._currentUnits$.asObservable());g(this,"_unitAdded$",new V.Subject);g(this,"unitAdded$",this._unitAdded$.asObservable());g(this,"_unitDisposed$",new V.Subject);g(this,"unitDisposed$",this._unitDisposed$.asObservable());g(this,"_focused$",new V.BehaviorSubject(null));g(this,"focused$",this._focused$.asObservable());this._injector=n,this._contextService=s}dispose(){super.dispose(),this._focused$.complete()}__setCreateHandler(n){this._createHandler=n}createUnit(n,s){return this._createHandler(n,s,this._ctorByType.get(n))}registerCtorForType(n,s){return this._ctorByType.set(n,s),{dispose:()=>{this._ctorByType.delete(n)}}}getCurrentTypeOfUnit$(n){return this.currentUnits$.pipe(V.map(s=>{var r;return(r=s.get(n))!=null?r:null}),V.distinctUntilChanged())}getCurrentUnitForType(n){return this._currentUnits.get(n)}setCurrentUnitForType(n){const s=this._getUnitById(n);if(!s)throw new Error(`[UniverInstanceService]: no document with unitId ${n}!`);this._currentUnits.set(s[1],s[0]),this._currentUnits$.next(this._currentUnits)}_removeCurrentUnitForType(n){this._currentUnits.set(n,null),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(n){return this._unitAdded$.pipe(V.filter(s=>s.type===n))}__addUnit(n){const s=n.type;this._unitsByType.has(s)||this._unitsByType.set(s,[]),this._unitsByType.get(s).push(n),this._unitAdded$.next(n),this.setCurrentUnitForType(n.getUnitId())}getTypeOfUnitDisposed$(n){return this.unitDisposed$.pipe(V.filter(s=>s.type===n))}getUnit(n,s){var i;const r=(i=this._getUnitById(n))==null?void 0:i[0];return s&&(r==null?void 0:r.type)!==s?null:r}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(Q.UNIVER_DOC)}getUniverDocInstance(n){return this.getUnit(n,Q.UNIVER_DOC)}getUniverSheetInstance(n){return this.getUnit(n,Q.UNIVER_SHEET)}getAllUnitsForType(n){var s;return(s=this._unitsByType.get(n))!=null?s:[]}changeDoc(n,s){const r=this.getAllUnitsForType(Q.UNIVER_DOC),i=r.find(o=>o.getUnitId()===n);if(i!=null){const o=r.indexOf(i);r.splice(o,1)}this.__addUnit(s)}get focused(){var s;const n=this._focused$.getValue();return n?(s=this._getUnitById(n))==null?void 0:s[0]:null}focusUnit(n){this._focused$.next(n),this.focused instanceof u.Workbook?(this._contextService.setContextValue(bn,!1),this._contextService.setContextValue(Ze,!0),this._contextService.setContextValue(vn,!1)):this.focused instanceof we?(this._contextService.setContextValue(bn,!0),this._contextService.setContextValue(Ze,!1),this._contextService.setContextValue(vn,!1)):this.focused instanceof _s&&(this._contextService.setContextValue(bn,!1),this._contextService.setContextValue(Ze,!1),this._contextService.setContextValue(vn,!0))}getFocusedUnit(){return this.focused}getUnitType(n){const s=this._getUnitById(n);if(!s)throw new Error(`[UniverInstanceService]: No document with unitId ${n}`);return s[1]}disposeUnit(n){const s=this._getUnitById(n);if(!s)return!1;const[r,i]=s,o=this._unitsByType.get(i),l=o.indexOf(r);return o.splice(l,1),this._removeCurrentUnitForType(i),this._focused$.next(null),this._unitDisposed$.next(r),!0}_getUnitById(n){for(const[s,r]of this._unitsByType){const i=r.find(o=>o.getUnitId()===n);if(i)return[i,s]}}},u.UniverInstanceService=iu([Gi(0,ut.Inject(ut.Injector)),Gi(1,Ye)],u.UniverInstanceService);var It=(t=>(t[t.Starting=0]="Starting",t[t.Ready=1]="Ready",t[t.Rendered=2]="Rendered",t[t.Steady=3]="Steady",t))(It||{});const ou={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"},wn=new Map;function xi(t,e){return function(r){Tn(t,e)}}function Tn(t,e){wn.has(t)||wn.set(t,[]),wn.get(t).push(e)}var lu=Object.defineProperty,au=Object.getOwnPropertyDescriptor,ji=(t,e,n,s)=>{for(var r=s>1?void 0:s?au(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(e,n,r):o(r))||r);return s&&r&&lu(e,n,r),r},gs=(t,e)=>(n,s)=>e(n,s,t);u.LifecycleService=class extends yt{constructor(n){super();g(this,"_lifecycle$",new V.BehaviorSubject(It.Starting));g(this,"lifecycle$",this._lifecycle$.asObservable());g(this,"_lock",!1);this._logService=n,this._reportProgress(It.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(n){if(n<this.stage)throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");if(n!==this.stage){if(this._lock)throw new Error("[LifecycleService]: cannot set new stage when related logic is all handled!");this._lock=!0,this._reportProgress(n),this._lifecycle$.next(n),this._lock=!1}}dispose(){this._lifecycle$.complete(),super.dispose()}subscribeWithPrevious(){return new V.Observable(n=>{this.stage===It.Starting||(this.stage===It.Ready?n.next(It.Starting):this.stage===It.Rendered?(n.next(It.Starting),n.next(It.Ready)):(n.next(It.Starting),n.next(It.Ready),n.next(It.Rendered))),this._lifecycle$.subscribe(s=>{n.next(s),s===It.Steady&&n.complete()})})}_reportProgress(n){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${ou[n]}".`)}},u.LifecycleService=ji([gs(0,Ee)],u.LifecycleService),u.LifecycleInitializerService=class extends yt{constructor(n,s){super();g(this,"_seenTokens",new Set);this._lifecycleService=n,this._injector=s}initModulesOnStage(n){var s;(s=wn.get(n))==null||s.forEach(r=>{this._injector.has(r)&&!this._seenTokens.has(r)&&(this._injector.get(r),this._seenTokens.add(r))})}},u.LifecycleInitializerService=ji([gs(0,ut.Inject(u.LifecycleService)),gs(1,ut.Inject(ut.Injector))],u.LifecycleInitializerService);class Qe extends yt{constructor(){super();g(this,"_currentLocale$",new V.BehaviorSubject(Ie.ZH_CN));g(this,"currentLocale$",this._currentLocale$.asObservable());g(this,"_locales",null);g(this,"localeChanged$",new V.Subject);g(this,"t",(n,...s)=>{if(!this._locales)throw new Error("[LocaleService]: Locale not initialized");const r=n.split("."),i=this.resolveKeyPath(this._locales[this._currentLocale],r);if(typeof i=="string"){let o=i;return s.forEach((l,a)=>{o=o.replace(`{${a}}`,l)}),o}else return n});this.disposeWithMe(At(()=>this.localeChanged$.complete()))}get _currentLocale(){return this._currentLocale$.value}load(n){var s;this._locales=y.deepMerge((s=this._locales)!=null?s:{},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,s){const r=s.shift();if(r&&n&&r in n){const i=n[r];return s.length>0&&(typeof i=="object"||Array.isArray(i))?this.resolveKeyPath(i,s):i}return null}}var ms=(t=>(t.INIT="init",t.FETCHING="fetching",t.DONE="done",t))(ms||{});const Es=ut.createIdentifier("univer.permission-service");Tn(It.Starting,Es);class Vi extends yt{constructor(){super(...arguments);g(this,"_permissionPointMap",new Map);g(this,"_permissionPointUpdate$",new V.Subject);g(this,"permissionPointUpdate$",this._permissionPointUpdate$.asObservable())}deletePermissionPoint(n){const s=this._permissionPointMap.get(n);s&&(s.complete(),this._permissionPointMap.delete(n))}addPermissionPoint(n){const s=n instanceof V.BehaviorSubject,r=s?n.getValue():n;if(!r.id)return!1;if(this._permissionPointMap.get(r.id))throw new Error(`${r.id} PermissionPoint already exists`);return this._permissionPointMap.set(r.id,s?n:new V.BehaviorSubject(r)),this._permissionPointUpdate$.next(r),!0}updatePermissionPoint(n,s){const r=this._permissionPointMap.get(n);if(!r)return;const i=r.getValue();i.value=s,i.status=ms.DONE,r.next({...i}),this._permissionPointUpdate$.next(i)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(n){const s=this._permissionPointMap.get(n);if(s)return s.getValue()}getPermissionPoint$(n){const s=this._permissionPointMap.get(n);if(s)return s}composePermission$(n){const s=n.map(r=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(r);if(!i)throw new Error(`[PermissionService]: ${r} permissionPoint does not exist!`);return i.asObservable()});return V.combineLatest(s).pipe(oe.map(r=>r))}composePermission(n){return n.map(r=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(r);if(!i)throw new Error(`[PermissionService]: ${r} permissionPoint does not exist!`);return i.getValue()})}getAllPermissionPoint(){const n=new Map;return this._permissionPointMap.forEach((s,r)=>{n.set(r,s)}),n}}class Ki extends yt{constructor(){super(...arguments);g(this,"_resourceMap",new Map);g(this,"_register$",new V.Subject);g(this,"register$",this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(n){return this.getAllResourceHooks().map(i=>{const o=i.toJson(n);return{name:i.pluginName,data:o}})}getResourcesByType(n,s){return this.getAllResourceHooks().filter(o=>o.businesses.includes(s)).map(o=>{const l=o.toJson(n);return{name:o.pluginName,data:l}})}registerPluginResource(n){const s=n.pluginName;if(this._resourceMap.has(s))throw new Error(`the pluginName is registered {${s}}`);return this._resourceMap.set(s,n),this._register$.next(n),At(()=>this._resourceMap.delete(s))}disposePluginResource(n){this._resourceMap.delete(n)}loadResources(n,s){this.getAllResourceHooks().forEach(r=>{var o;const i=(o=s==null?void 0:s.find(l=>l.name===r.pluginName))==null?void 0:o.data;if(i)try{const l=r.parseJson(i);r.onLoad(n,l)}catch{console.error("LoadResources Error!")}})}unloadResources(n){this.getAllResourceHooks().forEach(s=>{s.onUnLoad(n)})}dispose(){this._register$.complete(),this._resourceMap.clear()}}const Mn=ut.createIdentifier("resource-manager-service");var uu=Object.defineProperty,cu=Object.getOwnPropertyDescriptor,hu=(t,e,n,s)=>{for(var r=s>1?void 0:s?cu(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(e,n,r):o(r))||r);return s&&r&&uu(e,n,r),r},Yi=(t,e)=>(n,s)=>e(n,s,t);let Rs=class extends yt{constructor(e,n){super();g(this,"saveWorkbook",e=>{const n=e.getUnitId(),s=this._resourceManagerService.getResources(n)||[],r=e.getSnapshot();return r.resources=s,r});this._resourceManagerService=e,this._univerInstanceService=n,this._init()}_init(){const e=s=>{s.businesses.forEach(r=>{switch(r){case Q.UNRECOGNIZED:case Q.UNIVER_UNKNOWN:case Q.UNIVER_SLIDE:case Q.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType(Q.UNIVER_DOC).forEach(i=>{const l=(i.getSnapshot().resources||[]).find(a=>a.name===s.pluginName);if(l)try{const a=s.parseJson(l.data);s.onLoad(i.getUnitId(),a)}catch{console.error(`Load Document{${i.getUnitId()}} Resources{${s.pluginName}} Data Error.`)}});break}case Q.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(Q.UNIVER_SHEET).forEach(i=>{const l=(i.getSnapshot().resources||[]).find(a=>a.name===s.pluginName);if(l)try{const a=s.parseJson(l.data);s.onLoad(i.getUnitId(),a)}catch{console.error(`Load Workbook{${i.getUnitId()}} Resources{${s.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(s=>{e(s)}),this.disposeWithMe(this._resourceManagerService.register$.subscribe(s=>{e(s)})),this.disposeWithMe(At(this._univerInstanceService.getTypeOfUnitAdded$(Q.UNIVER_SHEET).subscribe(s=>{this._resourceManagerService.loadResources(s.getUnitId(),s.getSnapshot().resources)}))),this.disposeWithMe(At(this._univerInstanceService.getTypeOfUnitDisposed$(Q.UNIVER_SHEET).subscribe(s=>{this._resourceManagerService.unloadResources(s.getUnitId())})))}saveDoc(e){const n=e.getUnitId(),s=this._resourceManagerService.getResourcesByType(n,Q.UNIVER_DOC)||[],r=e.getSnapshot();return r.resources=s,r}};Rs=hu([Yi(0,ut.Inject(Mn)),Yi(1,ut.Inject(He))],Rs);const Cs=ut.createIdentifier("resource-loader-service");Tn(It.Ready,Cs);class ps extends yt{constructor(){super();g(this,"_currentTheme");g(this,"_currentTheme$",new V.BehaviorSubject({}));g(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(At(()=>this._currentTheme$.complete()))}getCurrentTheme(){if(!this._currentTheme)throw new Error("[ThemeService]: current theme is not set!");return this._currentTheme}setTheme(n){this._currentTheme=n,this._currentTheme$.next(n)}}const Un="__INTERNAL_EDITOR__",zi=`${Un}DOCS_NORMAL`,Xi=`${Un}DOCS_FORMULA_BAR`,du=`\r
|
|
7
|
-
`;function fu(t){return`${Un}${t}`}function _u(t){return t.startsWith(Un)}var gu=Object.defineProperty,mu=Object.getOwnPropertyDescriptor,Eu=(t,e,n,s)=>{for(var r=s>1?void 0:s?mu(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(e,n,r):o(r))||r);return s&&r&&gu(e,n,r),r},Is=(t,e)=>(n,s)=>e(n,s,t);const Ln=ut.createIdentifier("univer.undo-redo.service"),Ru=20;class qi{dispose(){}async dispatchToHandlers(){return!1}}const Ji="univer.command.redo",Zi="univer.command.undo",Qi=new class extends qi{constructor(){super(...arguments);g(this,"type",ze.COMMAND);g(this,"id",Zi)}async handler(e){const n=e.get(Ln),s=n.pitchTopUndoElement();if(!s)return!1;const r=e.get(Xe);return qn(s.undoMutations,r)?(n.popUndoToRedo(),!0):!1}},to=new class extends qi{constructor(){super(...arguments);g(this,"type",ze.COMMAND);g(this,"id",Ji)}async handler(e){const n=e.get(Ln),s=n.pitchTopRedoElement();if(!s)return!1;const r=e.get(Xe);return qn(s.redoMutations,r)?(n.popRedoToUndo(),!0):!1}};u.LocalUndoRedoService=class extends yt{constructor(n,s,r){super();g(this,"undoRedoStatus$");g(this,"_undoRedoStatus$",new V.BehaviorSubject({undos:0,redos:0}));g(this,"_undoStacks",new Map);g(this,"_redoStacks",new Map);g(this,"_batchingStatus",new Map);this._univerInstanceService=n,this._commandService=s,this._contextService=r,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(Qi)),this.disposeWithMe(this._commandService.registerCommand(to)),this.disposeWithMe(At(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(At(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(n){const{unitID:s}=n,r=this._getRedoStack(s,!0),i=this._getUndoStack(s,!0);if(r.length=0,this._batchingStatus.has(n.unitID)){const l=this._batchingStatus.get(n.unitID),a=this._pitchUndoElement(n.unitID);l===0||!a?(o(n),this._batchingStatus.set(n.unitID,1)):this._tryBatchingElements(a,n)}else o(n);function o(l){i.push(l),i.length>Ru&&i.splice(0,1)}this._updateStatus()}clearUndoRedo(n){const s=this._getRedoStack(n);s&&(s.length=0);const r=this._getUndoStack(n);r&&(r.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 s=this._getUndoStack(n);return s!=null&&s.length?s[s.length-1]:null}_pitchRedoElement(n){const s=this._getRedoStack(n);return s!=null&&s.length?s[s.length-1]:null}popUndoToRedo(){const s=this._getUndoStackForFocused().pop();s&&(this._getRedoStackForFocused().push(s),this._updateStatus())}popRedoToUndo(){const s=this._getRedoStackForFocused().pop();s&&(this._getUndoStackForFocused().push(s),this._updateStatus())}__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),At(()=>this._batchingStatus.delete(n))}_updateStatus(){var i,o;const n=this._getFocusedUnitId(),s=n&&((i=this._undoStacks.get(n))==null?void 0:i.length)||0,r=n&&((o=this._redoStacks.get(n))==null?void 0:o.length)||0;this._undoRedoStatus$.next({undos:s,redos:r})}_getUndoStack(n,s=!1){let r=this._undoStacks.get(n);return!r&&s&&(r=[],this._undoStacks.set(n,r)),r||null}_getRedoStack(n,s=!1){let r=this._redoStacks.get(n);return!r&&s&&(r=[],this._redoStacks.set(n,r)),r||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,s){n.redoMutations.push(...s.redoMutations),n.undoMutations.push(...s.undoMutations)}_getFocusedUnitId(){var o,l,a,h;let n="";const s=this._contextService.getContextValue(Ze),r=this._contextService.getContextValue(Bi),i=this._contextService.getContextValue(Wi);return s?r?n=Xi:i?n=zi:n=(l=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?l:"":n=(h=(a=this._univerInstanceService.getFocusedUnit())==null?void 0:a.getUnitId())!=null?h:"",n}},u.LocalUndoRedoService=Eu([Is(0,He),Is(1,Xe),Is(2,Ye)],u.LocalUndoRedoService);const eo=Symbol("DependentOn");class Os extends yt{onStarting(e){}onReady(){}onRendered(){}onSteady(){}getUniverInstanceType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}g(Os,"pluginName"),g(Os,"type",Q.UNIVER_UNKNOWN);class Cu{constructor(){g(this,"_plugins",[])}addPlugin(e){this._plugins.push(e)}removePlugins(){const e=this._plugins.slice();return this._plugins.length=0,e}forEachPlugin(e){this._plugins.forEach(e)}}class pu{constructor(){g(this,"_pluginsRegistered",[])}registerPlugin(e,n){this._pluginsRegistered.push({plugin:e,options:n})}getRegisterPlugins(){return this._pluginsRegistered.slice()}removePlugins(){this._pluginsRegistered=[]}}var Iu=Object.defineProperty,Ou=Object.getOwnPropertyDescriptor,no=(t,e,n,s)=>{for(var r=s>1?void 0:s?Ou(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(e,n,r):o(r))||r);return s&&r&&Iu(e,n,r),r},tn=(t,e)=>(n,s)=>e(n,s,t);const Su=4;function Nu(...t){return function(e){e[eo]=t}}u.PluginService=class{constructor(e){g(this,"_pluginHolderForUniver");g(this,"_pluginHoldersForTypes",new Map);g(this,"_seenPlugins",new Set);g(this,"_flushTimer");this._injector=e,this._pluginHolderForUniver=this._injector.createInstance(Dn,this._checkPluginSeen.bind(this),this._immediateInitPlugin.bind(this)),this._pluginHolderForUniver.start()}dispose(){this._clearFlushTimer();for(const e of this._pluginHoldersForTypes.values())e.dispose();this._pluginHolderForUniver.dispose()}registerPlugin(e,n){this._assertPluginValid(e),this._scheduleInitPlugin();const{type:s}=e;s===Q.UNIVER_UNKNOWN?(this._pluginHolderForUniver.register(e,n),this._pluginHolderForUniver.flush()):this._ensurePluginHolderForType(s).register(e,n)}startPluginForType(e){this._ensurePluginHolderForType(e).start()}_ensurePluginHolderForType(e){if(!this._pluginHoldersForTypes.has(e)){const n=this._injector.createInstance(Dn,this._checkPluginSeen.bind(this),this._immediateInitPlugin.bind(this));return this._pluginHoldersForTypes.set(e,n),n}return this._pluginHoldersForTypes.get(e)}_immediateInitPlugin(e){this._seenPlugins.add(e.pluginName),this._ensurePluginHolderForType(e.type).immediateInitPlugin(e)}_checkPluginSeen(e){return this._seenPlugins.has(e.pluginName)}_assertPluginValid(e){const{type:n,pluginName:s}=e;if(n===Q.UNRECOGNIZED)throw new Error(`[PluginService]: invalid plugin type for ${e}. Please assign a "type" to your plugin.`);if(s==="")throw new Error(`[PluginService]: no plugin name for ${e}. Please assign a "pluginName" to your plugin.`);if(this._seenPlugins.has(s))throw new Error(`[PluginService]: duplicated plugin name for "${s}". Maybe a plugin that dependents on "${s} has already registered it. In that case please register "${s}" before the that plugin.`);this._seenPlugins.add(e.pluginName)}_scheduleInitPlugin(){this._flushTimer===void 0&&(this._flushTimer=setTimeout(()=>{this._pluginHolderForUniver.started||this._pluginHolderForUniver.start(),this._flushPlugins(),this._clearFlushTimer()},Su))}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}_flushPlugins(){this._pluginHolderForUniver.flush();for(const[e,n]of this._pluginHoldersForTypes)n.started&&n.flush()}},u.PluginService=no([tn(0,ut.Inject(ut.Injector))],u.PluginService);let Dn=class extends yt{constructor(e,n,s,r,i,o){super();g(this,"_started",!1);g(this,"_pluginRegistry",new pu);g(this,"_pluginStore",new Cu);this._checkPluginRegistered=e,this._registerPlugin=n,this._logService=s,this._injector=r,this._lifecycleService=i,this._lifecycleInitializerService=o}get started(){return this._started}dispose(){super.dispose(),this._pluginStore.forEachPlugin(e=>e.dispose()),this._pluginStore.removePlugins(),this._pluginRegistry.removePlugins()}register(e,n){this._pluginRegistry.registerPlugin(e,n)}immediateInitPlugin(e){const n=this._initPlugin(e,void 0);this._pluginsRunLifecycle([n])}start(){this._started||(this._started=!0,this.flush())}flush(){if(!this._started)return;const e=this._pluginRegistry.getRegisterPlugins().map(({plugin:n,options:s})=>this._initPlugin(n,s));this._pluginsRunLifecycle(e),this._pluginRegistry.removePlugins()}_initPlugin(e,n){const s=e[eo];if(s){const i=()=>{const o=s.find(l=>!this._checkPluginRegistered(l));return o?(this._logService.warn("[PluginService]",`plugin "${e.pluginName}" depends on "${o.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._registerPlugin(o,void 0),!0):!1};for(;i(););}const r=this._injector.createInstance(e,n);return this._pluginStore.addPlugin(r),r}_pluginsRunLifecycle(e){const n=r=>{e.forEach(i=>{switch(r){case It.Starting:i.onStarting(this._injector);break;case It.Ready:i.onReady();break;case It.Rendered:i.onRendered();break;case It.Steady:i.onSteady();break}this._lifecycleInitializerService.initModulesOnStage(r)})},s=this.disposeWithMe(this._lifecycleService.subscribeWithPrevious().pipe(V.finalize(()=>{Promise.resolve().then(()=>s.dispose())})).subscribe(r=>{n(r)}))}};Dn=no([tn(2,Ee),tn(3,ut.Inject(ut.Injector)),tn(4,ut.Inject(u.LifecycleService)),tn(5,ut.Inject(u.LifecycleInitializerService))],Dn);function so(t,e){if(!e)return t;const n=[];for(const s of t){const r=e.find(([i])=>i===s[0]);if(r){if(r[1]===null)continue;n.push([s[0],r[1]])}else n.push(s)}return n}const Ss={[Wt.Editor]:"Editor",[Wt.Owner]:"Owner",[Wt.Reader]:"Reader",[Wt.UNRECOGNIZED]:"UNRECOGNIZED"},yn=t=>t?{userID:`${Ss[t]}_${y.generateRandomId(8)}`,name:Ss[t],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},Ns=(t,e)=>t.startsWith(Ss[e]);var Au=Object.defineProperty,bu=Object.getOwnPropertyDescriptor,vu=(t,e,n,s)=>{for(var r=s>1?void 0:s?bu(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(e,n,r):o(r))||r);return s&&r&&Au(e,n,r),r};u.UserManagerService=class{constructor(){g(this,"_model",new Map);g(this,"_userChange$",new V.Subject);g(this,"userChange$",this._userChange$.asObservable());g(this,"_currentUser$",new V.BehaviorSubject(yn()));g(this,"currentUser$",this._currentUser$.asObservable())}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(e){this.addUser(e),this._currentUser$.next(e)}addUser(e){this._model.set(e.userID,e),this._userChange$.next({type:"add",user:e})}getUser(e,n){const s=this._model.get(e);if(s)return s;n&&n()}delete(e){const n=this.getUser(e);this._model.delete(e),n&&this._userChange$.next({type:"delete",user:n})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}},u.UserManagerService=vu([xi(It.Starting,u.UserManagerService)],u.UserManagerService);var wu=Object.defineProperty,Tu=Object.getOwnPropertyDescriptor,Mu=(t,e,n,s)=>{for(var r=s>1?void 0:s?Tu(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(e,n,r):o(r))||r);return s&&r&&wu(e,n,r),r},ro=(t,e)=>(n,s)=>e(n,s,t);u.AuthzIoLocalService=class{constructor(e,n){g(this,"_permissionMap",new Map([]));this._resourceManagerService=e,this._userManagerService=n,this._initSnapshot(),n.setCurrentUser(yn(Wt.Owner))}_getRole(e){const n=this._userManagerService.getCurrentUser();return n?Ns(n.userID,e):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:e=>{const n=[...this._permissionMap.keys()].reduce((s,r)=>{const i=this._permissionMap.get(r);return s[r]=i,s},{});return JSON.stringify(n)},parseJson:e=>JSON.parse(e),pluginName:"SHEET_AuthzIoMockService_PLUGIN",businesses:[Q.UNIVER_SHEET,Q.UNIVER_DOC,Q.UNIVER_SLIDE],onLoad:(e,n)=>{for(const s in n)this._permissionMap.set(s,n[s])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(e){const n=y.generateRandomId(8);switch(e.objectType){case On.SelectRange:{const s=e.selectRangeObject;this._permissionMap.set(n,{...s,objectType:e.objectType});break}case On.Worksheet:{const s=e.worksheetObject;this._permissionMap.set(n,{...s,objectType:e.objectType})}}return n}async allowed(e){var n;if(this._permissionMap.has(e.objectID)){const s=this._permissionMap.get(e.objectID);if(s&&s.objectType===On.Worksheet)return(n=s==null?void 0:s.strategies)==null?void 0:n.map(r=>({action:r.action,allowed:r.role===Wt.Editor}))}return e.actions.map(s=>({action:s,allowed:this._getRole(Wt.Owner)||this._getRole(Wt.Editor)}))}async batchAllowed(e){const n=this._userManagerService.getCurrentUser(),s=e.map(r=>({unitID:r.unitID,objectID:r.objectID,actions:r.actions.map(i=>({action:i,allowed:!1}))}));return n&&(Ns(n.userID,Wt.Owner)||Ns(n.userID,Wt.Editor))?e.map(r=>({unitID:r.unitID,objectID:r.objectID,actions:r.actions.map(i=>({action:i,allowed:!0}))})):s}async list(e){const n=[];return e.objectIDs.forEach(s=>{const r=this._permissionMap.get(s);if(r){const i={objectID:s,unitID:e.unitID,objectType:r.objectType,name:r.name,shareOn:!1,shareRole:Wt.Owner,shareScope:-1,creator:yn(Wt.Owner),strategies:[],actions:e.actions.map(o=>({action:o,allowed:this._getRole(Wt.Owner)||this._getRole(Wt.Editor)}))};n.push(i)}}),n}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(e){}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(e){}},u.AuthzIoLocalService=Mu([ro(0,Mn),ro(1,ut.Inject(u.UserManagerService))],u.AuthzIoLocalService);const io=ut.createIdentifier("IAuthzIoIoService");class Uu{constructor(e={},n){g(this,"_startedTypes",new Set);g(this,"_injector");const s=this._injector=Lu(n,e==null?void 0:e.override),{theme:r,locale:i,locales:o,logLevel:l}=e;r&&this._injector.get(ps).setTheme(r),o&&this._injector.get(Qe).load(o),i&&this._injector.get(Qe).setLocale(i),l&&this._injector.get(Ee).setLogLevel(l),this._init(s)}get _univerInstanceService(){return this._injector.get(He)}get _pluginService(){return this._injector.get(u.PluginService)}__getInjector(){return this._injector}dispose(){this._injector.dispose()}setLocale(e){this._injector.get(Qe).setLocale(e)}createUnit(e,n){return this._univerInstanceService.createUnit(e,n)}createUniverSheet(e){return this._univerInstanceService.createUnit(Q.UNIVER_SHEET,e)}createUniverDoc(e){return this._univerInstanceService.createUnit(Q.UNIVER_DOC,e)}createUniverSlide(e){return this._univerInstanceService.createUnit(Q.UNIVER_SLIDE,e)}_init(e){this._univerInstanceService.registerCtorForType(Q.UNIVER_SHEET,u.Workbook),this._univerInstanceService.registerCtorForType(Q.UNIVER_DOC,we),this._univerInstanceService.registerCtorForType(Q.UNIVER_SLIDE,_s);const n=e.get(He);n.__setCreateHandler((s,r,i)=>{if(!this._startedTypes.has(s)){this._pluginService.startPluginForType(s),this._startedTypes.add(s);const l=e.createInstance(i,r);return n.__addUnit(l),this._tryProgressToReady(),l}const o=e.createInstance(i,r);return n.__addUnit(o),o})}_tryProgressToReady(){this._injector.get(u.LifecycleService).stage<It.Ready&&(this._injector.get(u.LifecycleService).stage=It.Ready)}registerPlugin(e,n){this._pluginService.registerPlugin(e,n)}}function Lu(t,e){const n=so([[Mi],[Qe],[ps],[u.LifecycleService],[u.LifecycleInitializerService],[u.PluginService],[u.UserManagerService],[He,{useClass:u.UniverInstanceService}],[Es,{useClass:Vi}],[Ee,{useClass:Zr,lazy:!0}],[Xe,{useClass:u.CommandService}],[Ln,{useClass:u.LocalUndoRedoService,lazy:!0}],[wi,{useClass:Ti}],[Ye,{useClass:qr}],[Mn,{useClass:Ki,lazy:!0}],[Cs,{useClass:Rs,lazy:!0}],[io,{useClass:u.AuthzIoLocalService,lazy:!0}]],e);return t?t.createChild(n):new ut.Injector(n)}const Du=(t,e)=>e.length===t.length&&!t.some(n=>e.some(s=>!me.equals(s,n))),yu=(t,e)=>e.length===t.length&&t.every((n,s)=>{const r=e[s];return r.unitId===n.unitId&&r.sheetId===n.sheetId&&me.equals(n.range,r.range)});function Pu(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||!t||typeof e!="object"||!e)return!1;const n=Object.keys(t),s=Object.keys(e);if(n.length!==s.length)return!1;const r=Object.prototype.hasOwnProperty.bind(e);for(let i=0;i<n.length;i++){const o=n[i];if(!r(o))return!1;const l=t[o],a=e[o];if(l!==a)return!1}return!0}function oo(t){return/^-?\d+(\.\d+)?$/.test(t)}function ku(t){return oo(t)?Number(t)<=Number.MAX_SAFE_INTEGER:!1}function Hu(t){return["true","false"].includes(t.toLowerCase())}function Fu(t,e){return e.forEach(n=>t.add(n)),t}function $u(t,e=16){let n=0,s=null;return function(...i){const o=Date.now();o-n<e?(s&&clearTimeout(s),s=setTimeout(()=>{n=o,t.apply(this,i)},e)):(n=o,t.apply(this,i))}}function Wu(t){const e=new MessageChannel;let n=!1;return e.port1.onmessage=()=>{n||t()},e.port2.postMessage(null),()=>{n=!0,e.port1.onmessage=null,e.port1.close(),e.port2.close()}}var lo=(t=>(t[t.TEXT=0]="TEXT",t[t.ARROW=1]="ARROW",t[t.CUSTOM=2]="CUSTOM",t))(lo||{});function Bu(t,e,n){if(e==="")return t;const s={id:"mock-id",body:t,documentStyle:{}},r=new we(s),i=e.length;let o;for(;(o=r.getBody().dataStream.indexOf(e))>=0;){const a=new Re,h=ve.getInstance();if(o>0&&a.retain(o),n.length>0){const d=r.sliceBody(o,o+i),c={dataStream:n};Array.isArray(d==null?void 0:d.textRuns)&&d.textRuns.length&&(c.textRuns=[{...d.textRuns[0],st:0,ed:n.length}]),a.insert(n.length,c)}a.delete(i),r.apply(h.editOp(a.serialize()))}const l=r.getBody();return r.dispose(),l}class ao{constructor(){g(this,"skipNextObservers",!1);g(this,"lastReturnValue");g(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class Gu extends V.Subject{constructor(){super(...arguments);g(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 s;typeof n=="function"?s={next:([i,o])=>n(i,o)}:s=n;const r=super.subscribe(s);return this._sortedObservers.push(s),this._sortedObservers.sort((i,o)=>{var l,a;return((l=i.priority)!=null?l:0)-((a=o.priority)!=null?a:0)}),r.add(()=>this._sortedObservers=this._sortedObservers.filter(i=>i!==s)),r}clearObservers(){this._sortedObservers.forEach(n=>{var s;return(s=n.complete)==null?void 0:s.call(n)}),this._sortedObservers.length=0}emitEvent(n){var s;if(!this.closed){const r=new ao;r.lastReturnValue=n;for(const i of this._sortedObservers){const o=(s=i.next)==null?void 0:s.call(i,[n,r]);if(r.lastReturnValue=o,r.skipNextObservers)return{handled:!0,lastReturnValue:r.lastReturnValue,stopPropagation:r.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:r.lastReturnValue,stopPropagation:r.isStopPropagation}}throw new Error("[EventSubject]: cannot emit event on a closed subject.")}}const xu=ut.createIdentifier("ILocalStorageService");function ju(t){return`sheet_interceptor_${t}`}const uo=t=>function(e,n){let s=-1;function r(i,o){if(i<=s)throw new Error("[SheetInterceptorService]: next() called multiple times!");return s=i,i===t.length?o:t[i].handler(o,n,r.bind(null,i+1))}return r(0,e)};class Vu{constructor(e){g(this,"_interceptorsByName",new Map);g(this,"_interceptorPoints");this._interceptorPoints=e}fetchThroughInterceptors(e){const n=e,s=this._interceptorsByName.get(n);return uo(s||[])}intercept(e,n){const s=e;this._interceptorsByName.has(s)||this._interceptorsByName.set(s,[]);const r=this._interceptorsByName.get(s);return r.push(n),this._interceptorsByName.set(s,r.sort((i,o)=>{var l,a;return((l=o.priority)!=null?l:0)-((a=i.priority)!=null?a:0)})),()=>En(this._interceptorsByName.get(s),n)}getInterceptPoints(){return this._interceptorPoints}}const Ku=ut.createIdentifier("univer.snapshot-server-service");class Yu{constructor(){g(this,"_sheetBlockCache",new Map)}getUnitOnRev(e,n){return Promise.resolve({snapshot:{unitID:"",type:Q.UNIVER_SHEET,rev:0,workbook:void 0,doc:void 0},changesets:[],error:{code:Vt.OK,message:""}})}getSheetBlock(e,n){const s=this._sheetBlockCache.get(n.blockID);return Promise.resolve({block:s,error:{code:Vt.OK,message:""}})}fetchMissingChangesets(e,n){return Promise.resolve({changesets:[],error:{code:Vt.OK,message:""}})}getResourcesRequest(e,n){return Promise.resolve({resources:{},error:{code:Vt.OK,message:""}})}saveSnapshot(e,n){return Promise.resolve({error:{code:Vt.OK,message:""}})}saveSheetBlock(e,n){const{block:s}=n;return s?(this._sheetBlockCache.set(s.id,s),Promise.resolve({error:{code:Vt.OK,message:""},blockID:s.id})):Promise.resolve({error:{code:Vt.UNDEFINED,message:"block is required"},blockID:""})}saveChangeset(e,n){return Promise.resolve({error:{code:Vt.OK,message:""},concurrent:[]})}}function zu(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,(e,n)=>String.fromCharCode(Number.parseInt(n,16))))}function As(t){return decodeURIComponent(Array.prototype.map.call(atob(t),e=>`%${`00${e.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""))}const en=new TextEncoder,Pn=new TextDecoder;function co(t){const e=y.deepClone(t);return delete e.id,delete e.name,delete e.rowCount,delete e.columnCount,delete e.cellData,en.encode(JSON.stringify(e))}function ho(t){const e=y.deepClone(t);return delete e.id,delete e.rev,delete e.name,delete e.sheetOrder,delete e.sheets,en.encode(JSON.stringify(e))}function Xu(t){const e=y.deepClone(t);return delete e.id,delete e.rev,delete e.title,delete e.resources,en.encode(JSON.stringify(e))}function fo(t){return JSON.parse(Pn.decode(t))}function qu(t){return JSON.parse(typeof t=="string"?As(t):Pn.decode(t))}function Ju(t){return JSON.parse(typeof t=="string"?As(t):Pn.decode(t))}const bs=256*20;function _o(t,e){const n=new Zt(t),s=n.getLength(),r=[];let i=0;for(;i<s;){const o=Math.min(i+bs,s-1),l=n.getSlice(i,Math.min(i+bs,s-1),0,e),a=Zu(l);r.push({id:y.generateRandomId(19,"0123456789"),startRow:i,endRow:o,data:a}),i+=bs}return r}function Zu(t){const e=t.getData();return en.encode(JSON.stringify(e))}async function Qu(t,e,n,s,r){const i={},o={};if(!await Promise.all(Object.entries(e.sheets).map(async([c,f])=>{const _={id:f.id,type:ln.GRID,name:f.name,rowCount:f.rowCount,columnCount:f.columnCount,originalMeta:co(f)};if(o[c]=_,f.cellData){const E=_o(f.cellData,f.rowCount),R=await Promise.all(E.map(H=>r.saveSheetBlock(t,{unitID:n,type:Q.UNIVER_SHEET,block:H})));if(R.some(H=>{var k;return((k=H.error)==null?void 0:k.code)!==Vt.OK}))return!1;i[c]={sheetID:c,blocks:R.map(H=>H.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const a=ho(e),h={unitID:e.id,rev:s,creator:"",name:e.name,sheetOrder:e.sheetOrder,sheets:o,blockMeta:i,resources:e.resources||[],originalMeta:a};return{snapshotRes:{unitID:n,rev:h.rev,type:Q.UNIVER_SHEET,workbook:h,doc:void 0}}}async function tc(t,e,n,s,r){var f,_;const i={},o={};if(!await Promise.all(Object.entries(e.sheets).map(async([E,R])=>{const H={id:R.id,type:ln.GRID,name:R.name,rowCount:R.rowCount,columnCount:R.columnCount,originalMeta:co(R)};if(o[E]=H,R.cellData){const k=_o(R.cellData,R.rowCount),et=await Promise.all(k.map(mt=>r.saveSheetBlock(t,{unitID:n,type:Q.UNIVER_SHEET,block:mt})));if(et.some(mt=>{var ft;return((ft=mt.error)==null?void 0:ft.code)!==Vt.OK}))return!1;i[E]={sheetID:E,blocks:et.map(mt=>mt.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const a=ho(e),h={unitID:e.id,rev:s,creator:"",name:e.name,sheetOrder:e.sheetOrder,sheets:o,blockMeta:i,resources:e.resources||[],originalMeta:a},d={unitID:n,rev:h.rev,type:Q.UNIVER_SHEET,workbook:h,doc:void 0},c=await r.saveSnapshot(t,{unitID:n,type:Q.UNIVER_SHEET,snapshot:d});if(ni(c.error))throw new Error(`transformWorkbookDataToSnapshot(): Failed to save snapshot.
|
|
8
|
-
ErrorCode: ${(f=c.error)==null?void 0:f.code}:${(
|
|
9
|
-
ErrorCode: ${(h=
|
|
1
|
+
(function(u,B){typeof exports=="object"&&typeof module<"u"?B(exports,require("rxjs"),require("rxjs/operators"),require("@wendellhu/redi")):typeof define=="function"&&define.amd?define(["exports","rxjs","rxjs/operators","@wendellhu/redi"],B):(u=typeof globalThis<"u"?globalThis:u||self,B(u.UniverCore={},u.rxjs,u.rxjs.operators,u["@wendellhu/redi"]))})(this,function(u,B,oe,ct){"use strict";var fc=Object.defineProperty;var gc=(u,B,oe)=>B in u?fc(u,B,{enumerable:!0,configurable:!0,writable:!0,value:oe}):u[B]=oe;var _=(u,B,oe)=>gc(u,typeof B!="symbol"?B+"":B,oe);var Oo,No;function wo(t,n){for(var e=0;e<n.length;e++){const s=n[e];if(typeof s!="string"&&!Array.isArray(s)){for(const r in s)if(r!=="default"&&!(r in t)){const i=Object.getOwnPropertyDescriptor(s,r);i&&Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>s[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}function To(){Mo()}const on=typeof global<"u"?global:typeof self<"u"?self:window;function Mo(){typeof on.requestIdleCallback!="function"&&(on.requestIdleCallback=function(e){const s=Date.now();return setTimeout(function(){const i=Math.max(0,50-(Date.now()-s));e({didTimeout:i===0,timeRemaining(){return i}})},1)}),typeof on.cancelIdleCallback!="function"&&(on.cancelIdleCallback=function(e){clearTimeout(e)})}const Uo="__default_document_sub_component_id20231101__",Ge=2,Ts=1;function Lo(t,n){if(n==null||t==null)return!0;const{left:e=0,top:s=0,height:r=0,width:i=0,angle:o=0}=n,{left:a=0,top:l=0,height:h=0,width:d=0,angle:c=0}=t,f=d,g=h,E=i,R=r;return Math.abs(a-e)>Ge||Math.abs(l-s)>Ge||Math.abs(f-E)>Ge||Math.abs(g-R)>Ge||Math.abs(c-o)>Ts}function Ms(t,n){let e=0,s=t.length-1;for(;e<=s;){const r=Math.floor((s+e)/2);if(n<t[r]&&(r===0||n>=t[r-1]))return r;if(n>=t[r])e=r+1;else if(n<t[r])s=r-1;else return-1}return-1}function Us(t,n){let e=0,s=0,r=0,i=-1,o=t.length-1;for(;e<t.length&&o>=0&&o>=e;){if(s=t[o],o===0?r=0:r=t[o-1],n>=r&&n<=s){i=o;break}if(s=t[e],e===0?r=0:r=t[e-1],n>=r&&n<s){i=e;break}e++,o--}return i}function Do(t,n){let e=t.length-1;return n<0?-1:n<t[0]?0:n>t[t.length-1]?Number.POSITIVE_INFINITY:(t.length<40||n<=t[20]||n>=t[e-20]?e=Us(t,n):e=Ms(t,n),e)}function yo(t){const n=new Blob([t],{type:"text/javascript"});return window.URL.createObjectURL(n)}var Ls=(t=>(t[t.DEFAULT_SERIES=0]="DEFAULT_SERIES",t[t.ALTERNATE_SERIES=1]="ALTERNATE_SERIES",t))(Ls||{}),dt=(t=>(t[t.NONE=0]="NONE",t[t.THIN=1]="THIN",t[t.HAIR=2]="HAIR",t[t.DOTTED=3]="DOTTED",t[t.DASHED=4]="DASHED",t[t.DASH_DOT=5]="DASH_DOT",t[t.DASH_DOT_DOT=6]="DASH_DOT_DOT",t[t.DOUBLE=7]="DOUBLE",t[t.MEDIUM=8]="MEDIUM",t[t.MEDIUM_DASHED=9]="MEDIUM_DASHED",t[t.MEDIUM_DASH_DOT=10]="MEDIUM_DASH_DOT",t[t.MEDIUM_DASH_DOT_DOT=11]="MEDIUM_DASH_DOT_DOT",t[t.SLANT_DASH_DOT=12]="SLANT_DASH_DOT",t[t.THICK=13]="THICK",t))(dt||{}),Ds=(t=>(t.TOP="top",t.BOTTOM="bottom",t.LEFT="left",t.RIGHT="right",t.NONE="none",t.ALL="all",t.OUTSIDE="outside",t.INSIDE="inside",t.HORIZONTAL="horizontal",t.VERTICAL="vertical",t.TLBR="tlbr",t.TLBC_TLMR="tlbc_tlmr",t.TLBR_TLBC_TLMR="tlbr_tlbc_tlmr",t.BLTR="bl_tr",t.MLTR_BCTR="mltr_bctr",t))(Ds||{}),Vt=(t=>(t[t.UNSUPPORTED=0]="UNSUPPORTED",t[t.RGB=1]="RGB",t[t.HEX=2]="HEX",t[t.THEME=3]="THEME",t))(Vt||{}),ys=(t=>(t[t.ON=0]="ON",t[t.OFF=1]="OFF",t))(ys||{}),Ps=(t=>(t[t.PASTE_NORMAL=0]="PASTE_NORMAL",t[t.PASTE_NO_BORDERS=1]="PASTE_NO_BORDERS",t[t.PASTE_FORMAT=2]="PASTE_FORMAT",t[t.PASTE_FORMULA=3]="PASTE_FORMULA",t[t.PASTE_DATA_VALIDATION=4]="PASTE_DATA_VALIDATION",t[t.PASTE_VALUES=5]="PASTE_VALUES",t[t.PASTE_CONDITIONAL_FORMATTING=6]="PASTE_CONDITIONAL_FORMATTING",t[t.PASTE_COLUMN_WIDTHS=7]="PASTE_COLUMN_WIDTHS",t))(Ps||{}),ks=(t=>(t[t.DOCUMENT=0]="DOCUMENT",t[t.PROJECT=1]="PROJECT",t))(ks||{}),Hs=(t=>(t[t.COLUMNS=0]="COLUMNS",t[t.ROWS=1]="ROWS",t))(Hs||{}),Fs=(t=>(t[t.UP=0]="UP",t[t.RIGHT=1]="RIGHT",t[t.DOWN=2]="DOWN",t[t.LEFT=3]="LEFT",t))(Fs||{});function Po(t){switch(t){case 3:return 1;case 1:return 3;case 0:return 2;case 2:return 0}}var Ws=(t=>(t[t.NUMBER_FORMAT_TYPE_UNSPECIFIED=0]="NUMBER_FORMAT_TYPE_UNSPECIFIED",t[t.TEXT=1]="TEXT",t[t.NUMBER=2]="NUMBER",t[t.PERCENT=3]="PERCENT",t[t.CURRENCY=4]="CURRENCY",t[t.DATE=5]="DATE",t[t.TIME=6]="TIME",t[t.DATE_TIME=7]="DATE_TIME",t[t.SCIENTIFIC=8]="SCIENTIFIC",t))(Ws||{}),$s=(t=>(t[t.INTERPOLATION_POINT_TYPE_UNSPECIFIED=0]="INTERPOLATION_POINT_TYPE_UNSPECIFIED",t[t.MIN=1]="MIN",t[t.MAX=2]="MAX",t[t.NUMBER=3]="NUMBER",t[t.PERCENT=4]="PERCENT",t[t.PERCENTILE=5]="PERCENTILE",t))($s||{}),Ie=(t=>(t.EN_US="enUS",t.ZH_CN="zhCN",t.RU_RU="ruRU",t.ZH_TW="zhTW",t.VI_VN="viVN",t))(Ie||{}),Bs=(t=>(t[t.RANGE=0]="RANGE",t[t.SHEET=1]="SHEET",t))(Bs||{}),Gs=(t=>(t[t.RELATIVE_DATE_UNSPECIFIED=0]="RELATIVE_DATE_UNSPECIFIED",t[t.PAST_YEAR=1]="PAST_YEAR",t[t.PAST_MONTH=2]="PAST_MONTH",t[t.PAST_WEEK=3]="PAST_WEEK",t[t.YESTERDAY=4]="YESTERDAY",t[t.TODAY=5]="TODAY",t[t.TOMORROW=6]="TOMORROW",t))(Gs||{}),an=(t=>(t[t.GRID=0]="GRID",t[t.KANBAN=1]="KANBAN",t[t.GANTT=2]="GANTT",t))(an||{}),xe=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",t[t.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",t))(xe||{}),xs=(t=>(t[t.DASH=0]="DASH",t[t.DASH_DOT_DOT_HEAVY=1]="DASH_DOT_DOT_HEAVY",t[t.DASH_DOT_HEAVY=2]="DASH_DOT_HEAVY",t[t.DASHED_HEAVY=3]="DASHED_HEAVY",t[t.DASH_LONG=4]="DASH_LONG",t[t.DASH_LONG_HEAVY=5]="DASH_LONG_HEAVY",t[t.DOT_DASH=6]="DOT_DASH",t[t.DOT_DOT_DASH=7]="DOT_DOT_DASH",t[t.DOTTED=8]="DOTTED",t[t.DOTTED_HEAVY=9]="DOTTED_HEAVY",t[t.DOUBLE=10]="DOUBLE",t[t.NONE=11]="NONE",t[t.SINGLE=12]="SINGLE",t[t.THICK=13]="THICK",t[t.WAVE=14]="WAVE",t[t.WAVY_DOUBLE=15]="WAVY_DOUBLE",t[t.WAVY_HEAVY=16]="WAVY_HEAVY",t[t.WORDS=17]="WORDS",t))(xs||{}),Se=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.LEFT=1]="LEFT",t[t.CENTER=2]="CENTER",t[t.RIGHT=3]="RIGHT",t[t.JUSTIFIED=4]="JUSTIFIED",t))(Se||{}),De=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.TOP=1]="TOP",t[t.MIDDLE=2]="MIDDLE",t[t.BOTTOM=3]="BOTTOM",t))(De||{}),ye=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.OVERFLOW=1]="OVERFLOW",t[t.CLIP=2]="CLIP",t[t.WRAP=3]="WRAP",t))(ye||{}),ln=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ITALIC=1]="ITALIC",t))(ln||{}),un=(t=>(t[t.NORMAL=0]="NORMAL",t[t.BOLD=1]="BOLD",t))(un||{}),Pe=(t=>(t[t.NORMAL=1]="NORMAL",t[t.SUBSCRIPT=2]="SUBSCRIPT",t[t.SUPERSCRIPT=3]="SUPERSCRIPT",t))(Pe||{}),Y=(t=>(t[t.FALSE=0]="FALSE",t[t.TRUE=1]="TRUE",t))(Y||{}),Oe=(t=>(t[t.STRING=1]="STRING",t[t.NUMBER=2]="NUMBER",t[t.BOOLEAN=3]="BOOLEAN",t[t.FORCE_STRING=4]="FORCE_STRING",t))(Oe||{}),Wt=(t=>(t[t.DARK1=0]="DARK1",t[t.LIGHT1=1]="LIGHT1",t[t.DARK2=2]="DARK2",t[t.LIGHT2=3]="LIGHT2",t[t.ACCENT1=4]="ACCENT1",t[t.ACCENT2=5]="ACCENT2",t[t.ACCENT3=6]="ACCENT3",t[t.ACCENT4=7]="ACCENT4",t[t.ACCENT5=8]="ACCENT5",t[t.ACCENT6=9]="ACCENT6",t[t.HYPERLINK=10]="HYPERLINK",t[t.FOLLOWED_HYPERLINK=11]="FOLLOWED_HYPERLINK",t))(Wt||{}),cn=(t=>(t.OFFICE="Office",t.OFFICE_2007_2010="Office 2007-2010",t.GRAYSCALE="Grayscale",t.BLUE_WARM="Blue Warm",t.BLUE="Blue",t.BLUE_II="Blue II",t.BLUE_GREEN="Blue Green",t.GREEN="Green",t.GREEN_YELLOW="Green Yellow",t.YELLOW="Yellow",t.YELLOW_ORANGE="Yellow Orange",t.ORANGE="Orange",t.ORANGE_RED="Orange Red",t.RED_ORANGE="Red Orange",t.RED="Red",t.RED_VIOLET="Red Violet",t.VIOLET="Violet",t.VIOLET_II="Violet II",t.MEDIAN="Median",t.PAPER="Paper",t.MARQUEE="Marquee",t.SLIPSTREAM="Slipstream",t.Aspect="Aspect",t))(cn||{}),Vs=(t=>(t.Line="line",t.LineInv="lineInv",t.Triangle="triangle",t.RtTriangle="rtTriangle",t.Rect="rect",t.Diamond="diamond",t.Parallelogram="parallelogram",t.Trapezoid="trapezoid",t.NonIsocelesTrapezoid="nonIsocelesTrapezoid",t.Pentagon="pentagon",t.Hexagon="hexagon",t.Heptagon="heptagon",t.Octagon="octagon",t.Decagon="decagon",t.Dodecagon="dodecagon",t.Star4="star4",t.Star5="star5",t.Star6="star6",t.Star7="star7",t.Star8="star8",t.Star10="star10",t.Star12="star12",t.Star16="star16",t.Star24="star24",t.Star32="star32",t.RoundRect="roundRect",t.Round1Rect="round1Rect",t.Round2SameRect="round2SameRect",t.Round2DiagRect="round2DiagRect",t.Ellipse="ellipse",t))(Vs||{}),js=(t=>(t.RightArrow="rightArrow",t.LeftArrow="leftArrow",t.UpArrow="upArrow",t.DownArrow="downArrow",t.LeftRightArrow="leftRightArrow",t.UpDownArrow="upDownArrow",t.QuadArrow="quadArrow",t.LeftRightUpArrow="leftRightUpArrow",t.BentArrow="bentArrow",t.UturnArrow="uturnArrow",t.CircularArrow="circularArrow",t.NotchedRightArrow="notchedRightArrow",t.HomePlate="homePlate",t.Chevron="chevron",t.LeftCircularArrow="leftCircularArrow",t.LeftRightCircularArrow="leftRightCircularArrow",t))(js||{}),Ks=(t=>(t.Plaque="plaque",t.Can="can",t.Cube="cube",t.Bevel="bevel",t.Donut="donut",t.NoSmoking="noSmoking",t.BlockArc="blockArc",t.FoldedCorner="foldedCorner",t))(Ks||{}),Ys=(t=>(t.SmileyFace="smileyFace",t.Heart="heart",t.LightningBolt="lightningBolt",t.Sun="sun",t.Moon="moon",t.Cloud="cloud",t.Arc="arc",t.Backpack="backpack",t.Frame="frame",t.HalfFrame="halfFrame",t.Corner="corner",t.Chord="chord",t.Pie="pie",t.Teardrop="teardrop",t.WedgeRectCallout="wedgeRectCallout",t.WedgeRRectCallout="wedgeRRectCallout",t.WedgeEllipseCallout="wedgeEllipseCallout",t.CloudCallout="cloudCallout",t.BorderCallout1="borderCallout1",t.BorderCallout2="borderCallout2",t.BorderCallout3="borderCallout3",t.AccentCallout1="accentCallout1",t.AccentCallout2="accentCallout2",t.AccentCallout3="accentCallout3",t.Callout1="callout1",t.Callout2="callout2",t.Callout3="callout3",t.ActionButtonBackPrevious="actionButtonBackPrevious",t.ActionButtonEnd="actionButtonEnd",t.ActionButtonForwardNext="actionButtonForwardNext",t.ActionButtonHelp="actionButtonHelp",t.ActionButtonHome="actionButtonHome",t.ActionButtonInformation="actionButtonInformation",t.ActionButtonMovie="actionButtonMovie",t.ActionButtonReturn="actionButtonReturn",t.ActionButtonSound="actionButtonSound",t))(Ys||{});const zs={[cn.OFFICE]:{[Wt.ACCENT1]:"#4472C4",[Wt.ACCENT2]:"#ED7D31",[Wt.ACCENT3]:"#A5A5A5",[Wt.ACCENT4]:"#70AD47",[Wt.ACCENT5]:"#5B9BD5",[Wt.ACCENT6]:"#70AD47",[Wt.DARK1]:"#000000",[Wt.DARK2]:"#44546A",[Wt.LIGHT1]:"#FFFFFF",[Wt.LIGHT2]:"#E7E6E6",[Wt.HYPERLINK]:"#0563C1",[Wt.FOLLOWED_HYPERLINK]:"#954F72"}};class hn{constructor(){_(this,"_themeValue",Wt.LIGHT1);_(this,"_themeColors");_(this,"_themeTint");_(this,"_rgbValue","");_(this,"_colorType");this._colorType=Vt.UNSUPPORTED,this._themeColors=cn.OFFICE,this._themeTint=0}asRgbColor(){return new dn(this._rgbValue,this)}asThemeColor(){return new fn(this._themeValue,this._themeTint,this._themeColors,this)}build(){switch(this._colorType){case Vt.THEME:return this.asThemeColor();case Vt.RGB:return this.asRgbColor();case Vt.UNSUPPORTED:throw new Error("unsupported color type")}}setRgbColor(n){return this._colorType=Vt.RGB,this._rgbValue=n,this}setThemeColors(n){this._colorType=Vt.THEME,this._themeColors=n}setThemeTint(n){this._colorType=Vt.THEME,this._themeTint=n}setThemeColor(n){return this._colorType=Vt.THEME,this._themeValue=n,this}getColorType(){return this._colorType}}class Ne{constructor(n){_(this,"_builder");this._builder=n}static rgbColorToHexValue(n){return`#${((1<<24)+(n.getRed()<<16)+(n.getGreen()<<8)+n.getBlue()).toString(16).slice(1)}`}static hexValueToRgbColor(n){n?n.indexOf("#")>-1&&(n=n.substring(1)):n="#000000";const e=+`0x${n[0]}${n[1]}`,s=+`0x${n[2]}${n[3]}`,r=+`0x${n[4]}${n[5]}`;return new hn().setRgbColor(`rgb(${e},${s},${r})`).asRgbColor()}static hexToRgbString(n){const e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;n=n.replace(e,(i,o,a,l)=>o+o+a+a+l+l);const s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);let r=null;if(s){const i=Number.parseInt(s[1],16),o=Number.parseInt(s[2],16),a=Number.parseInt(s[3],16);r=`rgba(${i},${o},${a})`}return r}asRgbColor(){return this._builder.asRgbColor()}asThemeColor(){return this._builder.asThemeColor()}getColorType(){return this._builder.getColorType()}clone(){return new Ne(this._builder)}equals(n){return!1}}class Xs{constructor(n){_(this,"_saturation",0);_(this,"_hue",0);_(this,"_lightness",0);_(this,"_alpha",0);const e=n.getRed()/255,s=n.getGreen()/255,r=n.getBlue()/255,i=n.getAlpha()/255,o=Math.min(e,Math.min(s,r)),a=Math.max(e,Math.max(s,r)),l=a-o;if(a===o){this._hue=0,this._saturation=0,this._lightness=a;return}this._lightness=(o+a)/2,this._lightness<.5?this._saturation=l/(a+o):this._saturation=l/(2-a-o),e===a&&(this._hue=(s-r)/l),s===a&&(this._hue=2+(r-e)/l),r===a&&(this._hue=4+(e-s)/l),this._hue*=60,this._hue<0&&(this._hue+=360),this._alpha=i}asRgbColor(){const n=new hn;if(this._saturation===0)return n.setRgbColor(`rgba(${this._lightness*255},${this._lightness*255},${this._lightness*255},${this._alpha*255})`),n.asRgbColor();let e;this._lightness<.5?e=this._lightness*(1+this._saturation):e=this._lightness+this._saturation-this._lightness*this._saturation;const s=2*this._lightness-e,r=this._hue/360,i=r+1/3,o=this.setColor(e,s,i),a=this.setColor(e,s,r),l=r-1/3,h=this.setColor(e,s,l);return n.setRgbColor(`rgba(${Math.round(o*255)},${Math.round(a*255)},${Math.round(h*255)},${this._alpha*255})`),n.asRgbColor()}getLightness(){return this._lightness}getHue(){return this._hue}getSaturation(){return this._saturation}getAlpha(){return this._alpha}setColor(n,e,s){s<0&&(s+=1),s>1&&(s-=1);let r;return 6*s<1?r=e+(n-e)*6*s:2*s<1?r=n:3*s<2?r=e+(n-e)*(2/3-s)*6:r=e,r}setLightness(n){this._lightness=n}}const Kt=class Kt extends Ne{constructor(e,s){super(s);_(this,"_cssString");_(this,"_red");_(this,"_green");_(this,"_blue");_(this,"_alpha");let r=e.match(Kt.RGBA_EXTRACT);if(r){const i=+r[1],o=+r[2],a=+r[3],l=+r[4];this._cssString=e,this._red=i,this._green=o,this._blue=a,this._alpha=l;return}if(r=e.match(Kt.RGB_EXTRACT),r){const i=+r[1],o=+r[2],a=+r[3];this._cssString=e,this._red=i,this._green=o,this._blue=a,this._alpha=1;return}throw new Error("Invalid rgba or rgb color")}asHexString(){return Ne.rgbColorToHexValue(this)}getRed(){let e=this._red+Kt.RGB_COLOR_AMT;return e>255?e=255:e<0&&(e=0),e}getGreen(){let e=this._green+Kt.RGB_COLOR_AMT;return e>255?e=255:e<0&&(e=0),e}getBlue(){let e=this._blue+Kt.RGB_COLOR_AMT;return e>255?e=255:e<0&&(e=0),e}getAlpha(){return this._alpha}getColorType(){return Vt.RGB}clone(){return new Kt(this._cssString,this._builder)}asThemeColor(){throw new Error("rgb color not support to themeColor")}equals(e){return e instanceof Kt?e._red===this._red&&e._blue===this._blue&&e._green===this._green&&e._alpha===this._alpha:!1}getCssString(){return this._cssString}};_(Kt,"RGB_COLOR_AMT",0),_(Kt,"RGBA_EXTRACT",new RegExp("\\s*rgba\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d.\\d|\\d\\s*)\\)\\s*")),_(Kt,"RGB_EXTRACT",new RegExp("\\s*rgb\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*)\\)\\s*"));let dn=Kt;const Ce=class Ce extends Ne{constructor(e,s,r,i){super(i);_(this,"_themeColorType");_(this,"_themeTint");_(this,"_themeColors");this._themeColorType=e,this._themeTint=s,this._themeColors=r}lumValue(e,s){if(e==null)return s;let r;return e<0?r=s*(1+e):r=s*(1-e)+(255-255*(1-e)),r}asRgbColor(){const e=zs[this._themeColors];if(e==null)throw new Error("not find themeColors type");const s=e[this._themeColorType];if(s==null)throw new Error("not find themeColors value");let r;if(Ce._cacheThemeColor.has(this._themeColors)){if(r=Ce._cacheThemeColor.get(this._themeColors),r.has(this._themeColorType))return r.get(this._themeColorType)}else r=new Map,Ce._cacheThemeColor.set(this._themeColors,r);const i=new Xs(Ne.hexValueToRgbColor(s));i.setLightness(this.lumValue(this._themeTint,i.getLightness()*255)/255);const o=i.asRgbColor();return r.set(this._themeColorType,o),o}clone(){return new Ce(this._themeColorType,this._themeTint,this._themeColors,this._builder)}equals(e){return e instanceof Ce?e._themeColorType===this._themeColorType:!1}getColorType(){return Vt.THEME}getThemeColorType(){return this._themeColorType}};_(Ce,"_cacheThemeColor",new Map);let fn=Ce;const ko="rgb(",Ho="rgba(",Hn={aliceBlue:[240,248,255],antiqueWhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blancheAlmond:[255,235,205],blue:[0,0,255],blueViolet:[138,43,226],brown:[165,42,42],burlyWood:[222,184,135],cadetBlue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornFlowerBlue:[100,149,237],cornSilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkCyan:[0,139,139],darkGoldenrod:[184,132,11],darkGray:[169,169,169],darkGreen:[0,100,0],darkGrey:[169,169,169],darkKhaki:[189,183,107],darkMagenta:[139,0,139],darkOliveGreen:[85,107,47],darkOrange:[255,140,0],darkOrchid:[153,50,204],darkRed:[139,0,0],darkSalmon:[233,150,122],darkSeaGreen:[143,188,143],darkSlateBlue:[72,61,139],darkSlateGray:[47,79,79],darkSlateGrey:[47,79,79],darkTurquoise:[0,206,209],darkViolet:[148,0,211],deepPink:[255,20,147],deepSkyBlue:[0,191,255],dimGray:[105,105,105],dimGrey:[105,105,105],dodgerBlue:[30,144,255],firebrick:[178,34,34],floralWhite:[255,255,240],forestGreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostWhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenYellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotPink:[255,105,180],indianRed:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderBlush:[255,240,245],lawnGreen:[124,252,0],lemonChiffon:[255,250,205],lightblue:[173,216,230],lightCoral:[240,128,128],lightCyan:[224,255,255],lightGoldenrodYellow:[250,250,210],lightGray:[211,211,211],lightGreen:[144,238,144],lightGrey:[211,211,211],lightPink:[255,182,193],lightSalmon:[255,160,122],lightSeaGreen:[32,178,170],lightSkyBlue:[135,206,250],lightSlateGray:[119,136,153],lightSlateGrey:[119,136,153],lightSteelBlue:[176,196,222],lightYellow:[255,255,224],lime:[0,255,0],limeGreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumAquamarine:[102,205,170],mediumBlue:[0,0,205],mediumOrchid:[186,85,211],mediumPurple:[147,112,219],mediumSeaGreen:[60,179,113],mediumSlateBlue:[123,104,238],mediumSpringGreen:[0,250,154],mediumTurquoise:[72,209,204],mediumVioletRed:[199,21,133],midBightBlue:[25,25,112],mintCream:[245,255,250],mistyRose:[255,228,225],moccasin:[255,228,181],navajoWhite:[255,222,173],navy:[0,0,128],oldLace:[253,245,230],olive:[128,128,0],oliveDrab:[107,142,35],orange:[255,165,0],orangeRed:[255,69,0],orchid:[218,112,214],paleGoldenrod:[238,232,170],paleGreen:[152,251,152],paleTurquoise:[175,238,238],paleVioletRed:[219,112,147],papayaWhip:[255,239,213],peachPuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderBlue:[176,224,230],purple:[128,0,128],rebeccaPurple:[102,51,153],red:[255,0,0],rosyBrown:[188,143,143],royalBlue:[65,105,225],saddleBrown:[139,69,19],salmon:[250,128,114],sandyBrown:[244,164,96],seaGreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyBlue:[135,206,235],slateBlue:[106,90,205],slateGray:[119,128,144],slateGrey:[119,128,144],snow:[255,255,250],springGreen:[0,255,127],steelBlue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whiteSmoke:[245,245,245],yellow:[255,255,0],yellowGreen:[154,205,5]};class Zt{constructor(n){_(this,"_color");_(this,"_rgbColor");_(this,"_isValid",!1);if(n==null){this._setNullColor();return}if(n instanceof Zt){this._color={...n._color},this._rgbColor={...n._rgbColor};return}const e=qs(n);if(e==null){this._setNullColor();return}this._color=e;const s=Go(this._color);if(s==null){this._setNullColor();return}this._rgbColor=s,this._isValid=!0}static mix(n,e,s){var h,d;s=Math.min(1,Math.max(0,s));const r=new Zt(n).toRgb(),i=new Zt(e).toRgb(),o=(h=r.a)!=null?h:1,a=(d=i.a)!=null?d:1,l={r:(i.r-r.r)*s+r.r,g:(i.g-r.g)*s+r.g,b:(i.b-r.b)*s+r.b,a:(a-o)*s+o};return new Zt(l)}static getContrastRatio(n,e){const s=new Zt(n).getLuminance(),r=new Zt(e).getLuminance();return(Math.max(s,r)+.05)/(Math.min(s,r)+.05)}get isValid(){return this._isValid}toRgb(){return this._rgbColor}toRgbString(){const{r:n,g:e,b:s,a:r=1}=this.toRgb(),i=r<1;return`rgb${i?"a":""}(${n},${e},${s}${i?`,${r}`:""})`}toString(){return this.toRgbString()}toHexString(n){const{r:e,g:s,b:r,a:i=1}=this.toRgb(),o=i<1,a=[gn(Math.round(e).toString(16)),gn(Math.round(s).toString(16)),gn(Math.round(r).toString(16)),gn(Math.round(i*255).toString(16))];return n&&a[0][0]===a[0][1]&&a[1][0]===a[1][1]&&a[2][0]===a[2][1]&&a[3][0]===a[3][1]?o?`#${a[0][0]}${a[1][0]}${a[2][0]}${a[3][0]}`:`#${a[0][0]}${a[1][0]}${a[2][0]}`:o?`#${a[0]}${a[1]}${a[2]}${a[3]}`:`#${a[0]}${a[1]}${a[2]}`}toHsv(){return Ko(this.toRgb())}toHsl(){return jo(this.toRgb())}lighten(n=10){const e=this.toHsl();return e.l+=n,e.l=Math.min(Math.max(e.l,0),100),new Zt(e)}darken(n=10){const e=this.toHsl();return e.l-=n,e.l=Math.min(Math.max(e.l,0),100),new Zt(e)}setAlpha(n){return new Zt({...this._rgbColor,a:n})}getLuminance(){let{r:n,g:e,b:s}=this.toRgb();return n=Fn(n),e=Fn(e),s=Fn(s),Number((.2126*n+.7152*e+.0722*s).toFixed(3))}getBrightness(){const{r:n,g:e,b:s}=this.toRgb();return(n*299+e*587+s*114)/1e3}getAlpha(){var n;return(n=this._color.a)!=null?n:1}isDark(){return this.getBrightness()<128}isLight(){return!this.isDark()}_setNullColor(){this._isValid=!1,this._color={r:0,g:0,b:0,a:0},this._rgbColor={r:0,g:0,b:0,a:0}}}const gn=t=>t.length===1?`0${t}`:t,Fn=t=>(t/=255,t<=.03928?t/12.92:((t+.055)/1.055)**2.4),qs=t=>{if(zo(t)){if("r"in t){const s={r:Math.round(t.r),g:Math.round(t.g),b:Math.round(t.b)};return t.a!==void 0&&(s.a=t.a),s}if("l"in t){const s={h:Math.round(t.h),s:t.s,l:t.l};return t.a!==void 0&&(s.a=t.a),s}const e={h:Math.round(t.h),s:t.s,v:t.v};return t.a!==void 0&&(e.a=t.a),e}const n=t.trim();if(Hn[n]){const e=Hn[n],s={r:Math.round(e[0]),g:Math.round(e[1]),b:Math.round(e[2])};return s.a=e[3]||1,s}if(n.startsWith("#"))return Fo(n);if(n.startsWith("rgb"))return Wo(n);if(n.startsWith("hsl"))return $o(n);if(n.startsWith("hsv"))return Bo(n)},Fo=t=>{const n=t.substring(1),e=new RegExp(`.{1,${n.length>=6?2:1}}`,"g");let s=n.match(e);if(!s||s.length<3)throw new Error(`The color '${t}' is illegal hex color`);s[0].length===1&&(s=s.map(i=>i+i));const r={r:Number.parseInt(s[0],16),g:Number.parseInt(s[1],16),b:Number.parseInt(s[2],16)};return s.length>3&&(r.a=Number.parseInt(s[3],16)/255),r},Wo=t=>{const n=t.indexOf("(");if(n===-1)throw new Error(`The color '${t}' is illegal rgb color`);const e=t.substring(n+1,t.length-1).split(",");if(e.length<3)throw new Error(`The color '${t}' is illegal rgb color`);const s={r:Number.parseInt(e[0],10),g:Number.parseInt(e[1],10),b:Number.parseInt(e[2],10)};return e.length>3&&(s.a=Number.parseFloat(e[3])),s},$o=t=>{const n=t.indexOf("(");if(n===-1)throw new Error(`The color '${t}' is illegal hsl color`);const e=t.substring(n+1,t.length-1).split(",");if(e.length<3)throw new Error(`The color '${t}' is illegal hsl color`);const s={h:Number.parseInt(e[0],10),s:Number.parseFloat(e[1]),l:Number.parseFloat(e[2])};return e.length>3&&(s.a=Number.parseFloat(e[3])),s},Bo=t=>{const n=t.indexOf("(");if(n===-1)throw new Error(`The color '${t}' is illegal hsv color`);const e=t.substring(n+1,t.length-1).split(",");if(e.length<3)throw new Error(`The color '${t}' is illegal hsv color`);const s={h:Number.parseInt(e[0],10),s:Number.parseFloat(e[1]),v:Number.parseFloat(e[2])};return e.length>3&&(s.a=Number.parseFloat(e[3])),s},Go=t=>{const n=qs(t);if(n!=null)return"r"in n?n:"l"in n?xo(n):Vo(n)},Wn=(t,n,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?t+(n-t)*6*e:e<1/2?n:e<2/3?t+(n-t)*(2/3-e)*6:t),xo=t=>{let{h:n,s:e,l:s}=t;n/=360,e/=100,s/=100;let r=0,i=0,o=0;if(e===0)r=i=o=s;else{const l=s<.5?s*(1+e):s+e-s*e,h=2*s-l;r=Wn(h,l,n+1/3),i=Wn(h,l,n),o=Wn(h,l,n-1/3)}const a={r:Math.round(r*255),g:Math.round(i*255),b:Math.round(o*255)};return t.a!==void 0&&(a.a=t.a),a},Vo=t=>{let{h:n,s:e,v:s}=t;n=n/360*6,e/=100,s/=100;const r=Math.floor(n),i=n-r,o=s*(1-e),a=s*(1-i*e),l=s*(1-(1-i)*e),h=r%6,d=[s,a,o,o,l,s][h],c=[l,s,s,a,o,o][h],f=[o,o,l,s,s,a][h],g={r:d*255,g:c*255,b:f*255};return t.a!==void 0&&(g.a=t.a),g},jo=t=>{let{r:n,g:e,b:s}=t;n/=255,e/=255,s/=255;const r=Math.max(n,e,s),i=Math.min(n,e,s),o=(r+i)/2;let a,l;if(r===i)a=l=0;else{const d=r-i;switch(l=o>.5?d/(2-r-i):d/(r+i),r){case n:a=(e-s)/d+(e<s?6:0);break;case e:a=(s-n)/d+2;break;default:a=(n-e)/d+4;break}a/=6}const h={h:Math.round(a*360),s:Math.round(l*100),l:Math.round(o*100)};return t.a!==void 0&&(h.a=t.a),h},Ko=t=>{let{r:n,g:e,b:s}=t;n/=255,e/=255,s/=255;const r=Math.max(n,e,s),i=Math.min(n,e,s);let o;const a=r,l=r-i,h=r===0?0:l/r;if(r===i)o=0;else{switch(r){case n:o=(e-s)/l+(e<s?6:0);break;case e:o=(s-n)/l+2;break;default:o=(n-e)/l+4;break}o/=6}const d={h:Math.round(o*360),s:Math.round(h*100),v:Math.round(a*100)};return t.a!==void 0&&(d.a=t.a),d},Yo=t=>t==null,zo=t=>!Yo(t)&&typeof t=="object";function Xo(t){const n=/^#(?:[0]{3}|[0]{6})\b/,e=/^rgb\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*\)$/,s=/^rgba\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*,\s*(1|1\.0*|0?\.\d+)\)$/,r=/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*\)$/,i=/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/;return!!(n.test(t)||e.test(t)||s.test(t)||r.test(t)||i.test(t))}function qo(t){const n=/^#(?:[Ff]{3}|[Ff]{6})\b/,e=/^rgb\s*\(\s*255\s*,\s*255\s*,\s*255\s*\)$/,s=/^rgba\s*\(\s*255\s*,\s*255\s*,\s*255\s*,\s*(1|1\.0*|0?\.\d+)\)$/,r=/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*\)$/,i=/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/;return!!(n.test(t)||e.test(t)||s.test(t)||r.test(t)||i.test(t))}var kt=(t=>(t[t.COVER=0]="COVER",t[t.REPLACE=1]="REPLACE",t[t.INTERSECTION=2]="INTERSECTION",t))(kt||{});function Zo(t){return t&&(t.s!==void 0||t.p!==void 0||t.v!==void 0||t.t!==void 0||t.f!==void 0||t.si!==void 0)}function Jo(t){if(t.t!==void 0)return t.t;if(typeof t.v=="string")return Oe.STRING;if(typeof t.v=="number")return Oe.NUMBER;if(typeof t.v=="boolean")return Oe.BOOLEAN}function Qo(t){if(t==null)return!0;const{v:n,f:e,si:s,p:r,s:i,custom:o}=t;return!(!(n==null||typeof n=="string"&&n.length===0)||e!=null&&e.length>0||s!=null&&s.length>0||r!=null||o!=null)}function ta(t){return t!=null&&(typeof t=="string"||typeof t=="number"||typeof t=="boolean")}var Zs=(t=>(t[t.character=0]="character",t[t.paragraph=1]="paragraph",t[t.table=2]="table",t[t.numbering=3]="numbering",t))(Zs||{}),Js=(t=>(t[t.TAB=0]="TAB",t[t.SPACE=1]="SPACE",t[t.NOTHING=2]="NOTHING",t))(Js||{}),Ve=(t=>(t[t.GLYPH_TYPE_UNSPECIFIED=0]="GLYPH_TYPE_UNSPECIFIED",t[t.NONE=1]="NONE",t[t.DECIMAL=2]="DECIMAL",t[t.ZERO_DECIMAL=3]="ZERO_DECIMAL",t[t.UPPER_ALPHA=4]="UPPER_ALPHA",t[t.ALPHA=5]="ALPHA",t[t.UPPER_ROMAN=6]="UPPER_ROMAN",t[t.ROMAN=7]="ROMAN",t))(Ve||{}),fe=(t=>(t[t.BULLET_ALIGNMENT_UNSPECIFIED=0]="BULLET_ALIGNMENT_UNSPECIFIED",t[t.START=1]="START",t[t.CENTER=2]="CENTER",t[t.END=3]="END",t))(fe||{}),Qs=(t=>(t[t.HYPERLINK=0]="HYPERLINK",t[t.FIELD=1]="FIELD",t[t.SDT=2]="SDT",t[t.BOOKMARK=3]="BOOKMARK",t[t.COMMENT=4]="COMMENT",t[t.CUSTOM=5]="CUSTOM",t[t.MENTION=6]="MENTION",t))(Qs||{}),tr=(t=>(t[t.COMMENT=0]="COMMENT",t))(tr||{}),er=(t=>(t[t.DRAWING=0]="DRAWING",t[t.CUSTOM=1]="CUSTOM",t))(er||{}),nr=(t=>(t[t.TRADITIONAL=0]="TRADITIONAL",t[t.MODERN=1]="MODERN",t))(nr||{}),sr=(t=>(t[t.DEFAULT=0]="DEFAULT",t[t.LINES=1]="LINES",t[t.LINES_AND_CHARS=2]="LINES_AND_CHARS",t[t.SNAP_TO_CHARS=3]="SNAP_TO_CHARS",t))(sr||{}),rr=(t=>(t[t.SECTION_TYPE_UNSPECIFIED=0]="SECTION_TYPE_UNSPECIFIED",t[t.CONTINUOUS=1]="CONTINUOUS",t[t.NEXT_PAGE=2]="NEXT_PAGE",t[t.EVEN_PAGE=3]="EVEN_PAGE",t[t.ODD_PAGE=4]="ODD_PAGE",t))(rr||{}),ir=(t=>(t[t.COLUMN_SEPARATOR_STYLE_UNSPECIFIED=0]="COLUMN_SEPARATOR_STYLE_UNSPECIFIED",t[t.NONE=1]="NONE",t[t.BETWEEN_EACH_COLUMN=2]="BETWEEN_EACH_COLUMN",t))(ir||{}),or=(t=>(t[t.NORMAL=0]="NORMAL",t[t.TBRL=1]="TBRL",t[t.LRTBV=2]="LRTBV",t))(or||{}),ar=(t=>(t[t.TEXT_RUN=0]="TEXT_RUN",t[t.AUTO_TEXT=1]="AUTO_TEXT",t[t.PAGE_BREAK=2]="PAGE_BREAK",t[t.COLUMN_BREAK=3]="COLUMN_BREAK",t[t.FOOT_NOTE_REFERENCE=4]="FOOT_NOTE_REFERENCE",t[t.HORIZONTAL_RULE=5]="HORIZONTAL_RULE",t[t.EQUATION=6]="EQUATION",t[t.DRAWING=7]="DRAWING",t[t.PERSON=8]="PERSON",t[t.RICH_LINK=9]="RICH_LINK",t))(ar||{}),lr=(t=>(t[t.BOTH_SIDES=0]="BOTH_SIDES",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.LARGEST=3]="LARGEST",t))(lr||{}),ur=(t=>(t[t.INLINE=0]="INLINE",t[t.WRAP_NONE=1]="WRAP_NONE",t[t.WRAP_POLYGON=2]="WRAP_POLYGON",t[t.WRAP_SQUARE=3]="WRAP_SQUARE",t[t.WRAP_THROUGH=4]="WRAP_THROUGH",t[t.WRAP_TIGHT=5]="WRAP_TIGHT",t[t.WRAP_TOP_AND_BOTTOM=6]="WRAP_TOP_AND_BOTTOM",t))(ur||{}),cr=(t=>(t[t.NAMED_STYLE_TYPE_UNSPECIFIED=0]="NAMED_STYLE_TYPE_UNSPECIFIED",t[t.NORMAL_TEXT=1]="NORMAL_TEXT",t[t.TITLE=2]="TITLE",t[t.SUBTITLE=3]="SUBTITLE",t[t.HEADING_1=4]="HEADING_1",t[t.HEADING_2=5]="HEADING_2",t[t.HEADING_3=6]="HEADING_3",t[t.HEADING_4=7]="HEADING_4",t[t.HEADING_5=8]="HEADING_5",t[t.HEADING_6=9]="HEADING_6",t))(cr||{}),hr=(t=>(t[t.AUTO=0]="AUTO",t[t.AT_LEAST=1]="AT_LEAST",t[t.EXACT=2]="EXACT",t))(hr||{}),dr=(t=>(t[t.DASH_STYLE_UNSPECIFIED=0]="DASH_STYLE_UNSPECIFIED",t[t.SOLID=1]="SOLID",t[t.DOT=2]="DOT",t[t.DASH=3]="DASH",t))(dr||{}),fr=(t=>(t[t.TAB_STOP_ALIGNMENT_UNSPECIFIED=0]="TAB_STOP_ALIGNMENT_UNSPECIFIED",t[t.START=1]="START",t[t.CENTER=2]="CENTER",t[t.END=3]="END",t))(fr||{}),gr=(t=>(t.EVENLY_DISTRIBUTED="0",t.FIXED_WIDTH="1",t))(gr||{}),_r=(t=>(t[t.CONTENT_ALIGNMENT_UNSPECIFIED=0]="CONTENT_ALIGNMENT_UNSPECIFIED",t[t.CONTENT_ALIGNMENT_UNSUPPORTED=1]="CONTENT_ALIGNMENT_UNSUPPORTED",t[t.TOP=2]="TOP",t[t.MIDDLE=3]="MIDDLE",t[t.BOTTOM=4]="BOTTOM",t))(_r||{}),mr=(t=>(t.NORMAL="normal",t.BOLD="bold",t.ITALIC="italic",t))(mr||{}),Er=(t=>(t[t.PAGE=0]="PAGE",t[t.COLUMN=1]="COLUMN",t[t.CHARACTER=2]="CHARACTER",t[t.MARGIN=3]="MARGIN",t[t.INSIDE_MARGIN=4]="INSIDE_MARGIN",t[t.OUTSIDE_MARGIN=5]="OUTSIDE_MARGIN",t[t.LEFT_MARGIN=6]="LEFT_MARGIN",t[t.RIGHT_MARGIN=7]="RIGHT_MARGIN",t))(Er||{}),Rr=(t=>(t[t.PAGE=0]="PAGE",t[t.PARAGRAPH=1]="PARAGRAPH",t[t.LINE=2]="LINE",t[t.MARGIN=3]="MARGIN",t[t.TOP_MARGIN=4]="TOP_MARGIN",t[t.BOTTOM_MARGIN=5]="BOTTOM_MARGIN",t[t.INSIDE_MARGIN=6]="INSIDE_MARGIN",t[t.OUTSIDE_MARGIN=7]="OUTSIDE_MARGIN",t))(Rr||{}),Cr=(t=>(t[t.POINT=0]="POINT",t[t.LINE=1]="LINE",t[t.CHARACTER=2]="CHARACTER",t))(Cr||{}),pr=(t=>(t[t.CENTER=0]="CENTER",t[t.INSIDE=1]="INSIDE",t[t.LEFT=2]="LEFT",t[t.OUTSIDE=3]="OUTSIDE",t[t.RIGHT=4]="RIGHT",t))(pr||{}),Ir=(t=>(t[t.BOTTOM=0]="BOTTOM",t[t.CENTER=1]="CENTER",t[t.INSIDE=2]="INSIDE",t[t.OUTSIDE=3]="OUTSIDE",t[t.TOP=4]="TOP",t))(Ir||{}),Sr=(t=>(t[t.compressPunctuation=0]="compressPunctuation",t[t.compressPunctuationAndJapaneseKana=1]="compressPunctuationAndJapaneseKana",t[t.doNotCompress=2]="doNotCompress",t))(Sr||{}),Or=(t=>(t[t.PORTRAIT=0]="PORTRAIT",t[t.LANDSCAPE=1]="LANDSCAPE",t))(Or||{}),Nr=(t=>(t[t.forward=0]="forward",t[t.backward=1]="backward",t[t.front=2]="front",t[t.back=3]="back",t))(Nr||{}),Ar=(t=>(t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t[t.DRAWING_IMAGE=0]="DRAWING_IMAGE",t[t.DRAWING_SHAPE=1]="DRAWING_SHAPE",t[t.DRAWING_CHART=2]="DRAWING_CHART",t[t.DRAWING_TABLE=3]="DRAWING_TABLE",t[t.DRAWING_SMART_ART=4]="DRAWING_SMART_ART",t[t.DRAWING_VIDEO=5]="DRAWING_VIDEO",t[t.DRAWING_GROUP=6]="DRAWING_GROUP",t[t.DRAWING_UNIT=7]="DRAWING_UNIT",t[t.DRAWING_DOM=8]="DRAWING_DOM",t))(Ar||{}),ot=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(ot||{}),Nt=(t=>(t[t.NONE=0]="NONE",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(Nt||{});function ea(t){return[t.startRow,t.startColumn,t.endRow,t.endColumn]}function na(t,n,e){let s=!1,r=!1,i=t,o=n,a=t,l=n;if(e==null)return{actualRow:t,actualColumn:n,isMergedMainCell:r,isMerged:s,endRow:i,endColumn:o,startRow:a,startColumn:l};for(let h=0;h<e.length;h++){const{startRow:d,endRow:c,startColumn:f,endColumn:g}=e[h];if(t===d&&n===f){i=c,o=g,a=d,l=f,r=!0;break}if(t>=d&&t<=c&&n>=f&&n<=g){i=c,o=g,a=d,l=f,s=!0;break}}return{actualRow:t,actualColumn:n,isMergedMainCell:r,isMerged:s,endRow:i,endColumn:o,startRow:a,startColumn:l}}var $n=(t=>(t[t.SLIDE=0]="SLIDE",t[t.MASTER=1]="MASTER",t[t.LAYOUT=2]="LAYOUT",t[t.HANDOUT_MASTER=3]="HANDOUT_MASTER",t[t.NOTES_MASTER=4]="NOTES_MASTER",t))($n||{}),br=(t=>(t[t.SHAPE=0]="SHAPE",t[t.IMAGE=1]="IMAGE",t[t.TEXT=2]="TEXT",t[t.SPREADSHEET=3]="SPREADSHEET",t[t.DOCUMENT=4]="DOCUMENT",t[t.SLIDE=5]="SLIDE",t))(br||{}),vr=(t=>(t[t.RELATIVE_SLIDE_LINK_UNSPECIFIED=0]="RELATIVE_SLIDE_LINK_UNSPECIFIED",t[t.NEXT_SLIDE=1]="NEXT_SLIDE",t[t.PREVIOUS_SLIDE=2]="PREVIOUS_SLIDE",t[t.FIRST_SLIDE=3]="FIRST_SLIDE",t[t.LAST_SLIDE=4]="LAST_SLIDE",t))(vr||{});const sa="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ra=t=>crypto.getRandomValues(new Uint8Array(t)),ia=(t,n,e)=>{let s=(2<<Math.log(t.length-1)/Math.LN2)-1,r=-~(1.6*s*n/t.length);return(i=n)=>{let o="";for(;;){let a=e(r),l=r;for(;l--;)if(o+=t[a[l]&s]||"",o.length===i)return o}}},oa=(t,n=21)=>ia(t,n,ra),aa=(t=21)=>{let n="",e=crypto.getRandomValues(new Uint8Array(t));for(;t--;)n+=sa[e[t]&63];return n};const la=/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi,ua=new RegExp(la);function ca(t){return Number.isNaN(+t)?t.startsWith("http://localhost:3002")||t.startsWith("localhost:3002")?!0:!!t.match(ua):!1}const ha=/^-ms-/,da=/-([a-z])/g,ge=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];class P{static stringAt(n){let e="",s=n;for(;s>=ge.length;)s/=ge.length,s-=1,e+=ge[s%ge.length];const r=n%ge.length;return e+=ge[r],e}static indexAt(n){let e=0;for(let s=0;s<n.length-1;s+=1){const r=n.charCodeAt(s)-65,i=n.length-1-s;e+=ge.length**i+ge.length*r}return e+=n.charCodeAt(n.length-1)-65,e}static deleteBlank(n){return P.isString(n)?n.replace(/\s/g,""):n}static getSystemType(){const n=navigator.userAgent,e=navigator.platform==="Win32"||navigator.platform==="Windows",s=navigator.platform==="Mac68K"||navigator.platform==="MacPPC"||navigator.platform==="Macintosh"||navigator.platform==="MacIntel";if(s)return"Mac";if(navigator.platform==="X11"&&!e&&!s)return"Unix";if(String(navigator.platform).indexOf("Linux")>-1)return"Linux";if(e){if(n.indexOf("Windows NT 5.0")>-1||n.indexOf("Windows 2000")>-1)return"Windows 2000";if(n.indexOf("Windows NT 5.1")>-1||n.indexOf("Windows XP")>-1)return"Windows XP";if(n.indexOf("Windows NT 5.2")>-1||n.indexOf("Windows 2003")>-1)return"Windows 2003";if(n.indexOf("Windows NT 6.0")>-1||n.indexOf("Windows Vista")>-1)return"Windows Vista";if(n.indexOf("Windows NT 6.1")>-1||n.indexOf("Windows 7")>-1)return"Windows 7";if(n.indexOf("Windows NT 10")>-1||n.indexOf("Windows 10")>-1)return"Windows 10";if(n.indexOf("Windows NT 11")>-1||n.indexOf("Windows 11")>-1)return"Windows 11"}return"Unknown system"}static getBrowserType(){const n=navigator.userAgent,e=n.indexOf("Opera")>-1,s=n.indexOf("compatible")>-1&&n.indexOf("MSIE")>-1&&!e,r=n.indexOf("Trident")>-1&&n.indexOf("rv:11.0")>-1,i=n.indexOf("Edge")>-1,o=n.indexOf("Firefox")>-1,a=n.indexOf("Safari")>-1&&n.indexOf("Chrome")===-1,l=n.indexOf("Chrome")>-1&&n.indexOf("Safari")>-1;if(s){new RegExp("MSIE (\\d+\\.\\d+);").test(n);const d=Number.parseFloat(RegExp.$1);return d===7?"IE7":d===8?"IE8":d===9?"IE9":d===10?"IE10":"0"}return o?"FF":e?"Opera":a?"Safari":l?"Chrome":i?"Edge":r?"IE11":"Unknown browser"}static generateRandomId(n=21,e){return e?oa(e,n)():aa(n)}static getClassName(n){return n.constructor.name}static deepMerge(n,...e){e.forEach(o=>o&&i(o));function s(o,a){o.forEach((l,h)=>{var d,c;if(P.isArray(l)){const f=(d=a[h])!=null?d:[];a[h]=f,s(l,f);return}if(P.isObject(l)){const f=(c=a[h])!=null?c:{};a[h]=f,r(l,f);return}a[h]=l})}function r(o,a){Object.keys(o).forEach(l=>{var d,c;const h=o[l];if(P.isObject(h)){const f=(d=a[l])!=null?d:{};a[l]=f,r(h,f);return}if(P.isArray(h)){const f=(c=a[l])!=null?c:[];a[l]=f,s(h,f);return}a[l]=h})}function i(o){Object.keys(o).forEach(a=>{var h,d;const l=o[a];if(P.isArray(l)){const c=(h=n[a])!=null?h:[];n[a]=c,s(l,c);return}if(P.isObject(l)){const c=(d=n[a])!=null?d:{};n[a]=c,r(l,c);return}n[a]=l})}return n}static numberFixed(n,e){return Number(Number(n).toFixed(e))}static diffValue(n,e){function s(o,a){const l=P.getValueType(o),h=P.getValueType(a);return l!==h?!1:P.isArray(o)?r(o,a):P.isObject(o)?i(o,a):P.isDate(o)?o.getTime()===a.getTime():P.isRegExp(o)?o.toString()===a.toString():o===a}function r(o,a){if(n.length!==e.length)return!1;for(let l=0,h=o.length;l<h;l++){const d=o[l],c=a[l];if(!s(d,c))return!1}return!0}function i(o,a){const l=Object.keys(o),h=Object.keys(a);if(l.length!==h.length)return!1;for(const d of l){if(!h.includes(d))return!1;const c=o[d],f=a[d];if(!s(c,f))return!1}return!0}return s(n,e)}static deepClone(n){if(!this.isDefine(n))return n;if(this.isRegExp(n))return new RegExp(n);if(this.isDate(n))return new Date(n);if(this.isArray(n)){const e=[];return n.forEach((s,r)=>{e[r]=P.deepClone(s)}),e}if(this.isObject(n)){const e={};return Object.keys(n).forEach(s=>{const r=n[s];e[s]=P.deepClone(r)}),Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}return n}static getLanguage(){const n="en-US";return globalThis.navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||n}static getValueType(n){return Object.prototype.toString.apply(n)}static isDefine(n){return n!=null}static isBlank(n){return this.isDefine(n)?this.isString(n)?n.trim()==="":!1:!0}static isAssignableFrom(n,e){return n instanceof e}static isBoolean(n){return this.getValueType(n)==="[object Boolean]"}static isPlainObject(n){return this.isDefine(n)?Object.getPrototypeOf(n)===Object.getPrototypeOf({}):!1}static isFunction(n){return this.getValueType(n)==="[object Function]"}static isDate(n){return this.getValueType(n)==="[object Date]"}static isRegExp(n){return this.getValueType(n)==="[object RegExp]"}static isArray(n){return this.getValueType(n)==="[object Array]"}static isString(n){return this.getValueType(n)==="[object String]"}static isNumber(n){return this.getValueType(n)==="[object Number]"}static isStringNumber(n){return!isNaN(Number.parseFloat(n))&&isFinite(n)}static isObject(n){return this.getValueType(n)==="[object Object]"}static isEmptyObject(n){for(const e in n)return!1;return!0}static isMobile(){let n=0,e=0;return document.body.clientWidth&&(n=document.body.clientWidth),document.body.clientHeight&&(e=document.body.clientHeight),this.isAndroid()||this.isIPhone()||this.isTablet()||n<350&&e<500}static isTablet(){return/ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase())}static isWeChat(){const n=navigator.userAgent.toLowerCase();return String(n.match(/MicroMessenger/i))==="micromessenger"}static isAndroid(){const n=navigator.userAgent;return n.indexOf("Android")>-1||n.indexOf("Linux")>-1}static isIPhone(){return/iPhone/i.test(navigator.userAgent)}static isLegalUrl(n){return ca(n)}static itCount(n){return e=>{for(let s=0;s<n;s++)e&&e()}}static hasLength(n,e){return P.isDefine(n)?P.isDefine(e)?n.length===e:n.length>0:!1}static capitalize(n){return n.charAt(0).toUpperCase()+n.slice(1)}static fCamelCase(n,e){return e.toUpperCase()}static camelCase(n){return n.replace(ha,"ms-").replace(da,this.fCamelCase)}static removeNull(n){return this.isObject(n)&&Object.keys(n).forEach(e=>{const s=n[e];s==null?delete n[e]:P.removeNull(s)}),n}static fillTwoDimensionalArray(n,e,s){return new Array(n).fill(s).map(r=>new Array(e).fill(s))}static numToWord(n){let e="";for(;n>0;){let s=n%26;s=s===0?s=26:s,e=String.fromCharCode(96+s)+e,n=(n-s)/26}return e.toLocaleUpperCase()}static ABCatNum(n){if(n==null||n.length===0)return Number.NaN;const e=n.toLowerCase().split(""),s=e.length;let r=0,i=0;for(let o=0;o<s;o++)i=e[o].charCodeAt(0)-96,r+=i*26**(s-o-1);return r===0?Number.NaN:r-1}static chatAtABC(n){let i="";for(;n>=0;)i=String.fromCharCode(n%26+97)+i,n=Math.floor(n/26)-1;return i.toUpperCase()}static randSort(n){for(let e=0,s=n.length;e<s;e++){const r=Number.parseInt((Math.random()*s).toString()),i=n[r];n[r]=n[e],n[e]=i}return n}static commonExtend(n,e){const s={};for(const r in n)s[r]=n[r];for(const r in e)e[r]!=null&&(s[r]=e[r]);return s}static commonExtend1(n,e){for(const s in n)e[s]==null&&(e[s]=n[s]);return e}static arrayToObject(n){const e={};return n.forEach((s,r)=>{e[r]={},s.forEach((i,o)=>{e[r][o]=i})}),e}static hasIntersectionBetweenTwoRanges(n,e,s,r){return e>=s&&r>=n}static isStartValidPosition(n){return/^[A-Za-z_]/.test(n)}static isValidParameter(n){const e=/[~!@#$%^&*()+=\-{}\[\]\|:;"'<>,?\/ ]+/.test(n),s=n.length<=255;return!e&&s}static set(n,e,s){const r=e.split("."),i=r.pop();r.forEach(o=>{n[o]||(n[o]={}),n=n[o]}),i&&(n[i]=s)}static clamp(n,e,s){return Math.max(e,Math.min(s,n))}}function fa(t){const{actualRow:n,actualColumn:e,isMerged:s,isMergedMainCell:r,mergeInfo:i}=t;let{startY:o,endY:a,startX:l,endX:h}=t,d=n,c=e,f=n,g=e;if(s&&i){const{startRow:E,startColumn:R,endRow:y,endColumn:H,startY:et,endY:Et,startX:gt,endX:C}=i;d=E,c=R,f=y,g=H,o=et,a=Et,l=gt,h=C}return r&&(o=i.startY,a=i.endY,l=i.startX,h=i.endX,f=i.endRow,g=i.endColumn),{startRow:d,startColumn:c,endRow:f,endColumn:g,startY:o,endY:a,startX:l,endX:h}}function ga(t){if(!t)return;const{actualRow:n,actualColumn:e,isMerged:s,isMergedMainCell:r,startRow:i,startColumn:o,endRow:a,endColumn:l}=t;let h=n,d=e,c=n,f=e;return(s||r)&&(h=i,d=o,c=a,f=l),{startRow:h,startColumn:d,endRow:c,endColumn:f}}function wr(t){var e;return!t||(((e=t==null?void 0:t.v)==null?void 0:e.toString())||"").length===0&&!t.p}function _a(t){return wr(t)&&(t==null?void 0:t.coverable)!==!1}function se(t){if(t){if(t.rgb)return t.rgb;if(t.th)return new hn().setThemeColor(t.th).asThemeColor().asRgbColor().getCssString()}return null}function ma(t){return P.isString(t)&&t.substring(0,1)==="="&&t.length>1}function Ea(t){return P.isString(t)&&t.length>0}function Ra(t,n=!1){var i;let e="";const s=new Map([["ff",()=>{t.ff&&(e+=`font-family: ${t.ff}; `)}],["fs",()=>{if(t.fs){let o=t.fs;t.va&&(o/=2),e+=`font-size: ${o}pt; `}}],["it",()=>{t.it&&(e+="font-style: italic; ")}],["bl",()=>{t.bl&&(e+="font-weight: bold; ")}],["ul",()=>{var o;(o=t.ul)!=null&&o.s&&(e.indexOf("text-decoration-line")>-1?e=e.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(a,l)=>`${l} underline`):e+="text-decoration: underline; ",t.ul.cl&&e.indexOf("text-decoration-color")===-1&&(e+=`text-decoration-color: ${se(t.ul.cl)}; `),t.ul.t&&e.indexOf("text-decoration-style")===-1&&(e+=`text-decoration-style: ${t.ul.t} `))}],["st",()=>{var o;(o=t.st)!=null&&o.s&&(e.indexOf("text-decoration-line")>-1?e=e.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(a,l)=>`${l} line-through`):e+="text-decoration-line: line-through; ",t.st.cl&&e.indexOf("text-decoration-color")===-1&&(e+=`text-decoration-color: ${se(t.st.cl)}; `),t.st.t&&e.indexOf("text-decoration-style")===-1&&(e+=`text-decoration-style: ${t.st.t} `))}],["ol",()=>{var o;(o=t.ol)!=null&&o.s&&(e.indexOf("text-decoration-line")>-1?e=e.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(a,l)=>`${l} overline`):e+="text-decoration-line: overline; ",t.ol.cl&&e.indexOf("text-decoration-color")===-1&&(e+=`text-decoration-color: ${se(t.ol.cl)}; `),t.ol.t&&e.indexOf("text-decoration-style")===-1&&(e+=`text-decoration-style: ${t.ol.t} `))}],["bg",()=>{t.bg&&(e+=`background: ${se(t.bg)}; `)}],["bd",()=>{var o,a,l,h,d,c,f,g,E,R,y,H;(o=t.bd)!=null&&o.b&&(e+=`border-bottom: ${_n((a=t.bd)==null?void 0:a.b.s)} ${(l=se(t.bd.b.cl))!=null?l:""}; `),(h=t.bd)!=null&&h.t&&(e+=`border-top: ${_n((d=t.bd)==null?void 0:d.t.s)} ${(c=se(t.bd.t.cl))!=null?c:""}; `),(f=t.bd)!=null&&f.r&&(e+=`border-right: ${_n((g=t.bd)==null?void 0:g.r.s)} ${(E=se(t.bd.r.cl))!=null?E:""}; `),(R=t.bd)!=null&&R.l&&(e+=`border-left: ${_n((y=t.bd)==null?void 0:y.l.s)} ${(H=se(t.bd.l.cl))!=null?H:""}; `)}],["cl",()=>{t.cl&&(e+=`color: ${se(t.cl)}; `)}],["va",()=>{t.va===Pe.SUBSCRIPT?e+="vertical-align: sub; ":t.va===Pe.SUPERSCRIPT&&(e+="vertical-align: super; ")}],["td",()=>{t.td===xe.LEFT_TO_RIGHT?e+="direction: ltr; ":t.td===xe.RIGHT_TO_LEFT&&(e+="direction: rtl; ")}],["tr",()=>{var o,a,l;t.tr&&(e+=`--data-rotate: (${(o=t.tr)==null?void 0:o.a}deg${(a=t.tr)!=null&&a.v?` ,${(l=t.tr)==null?void 0:l.v}`:""});`)}],["ht",()=>{t.ht===Se.LEFT?e+="text-align: left; ":t.ht===Se.RIGHT?e+="text-align: right; ":t.ht===Se.CENTER?e+="text-align: center; ":t.ht===Se.JUSTIFIED&&(e+="text-align: justify; ")}],["vt",()=>{t.vt===De.BOTTOM?e+="vertical-align: bottom; ":t.vt===De.TOP?e+="vertical-align: top; ":t.vt===De.MIDDLE&&(e+="vertical-align: middle; ")}],["tb",()=>{t.tb===ye.CLIP?e+="white-space: clip; ":t.tb===ye.WRAP&&(e+="white-space: normal;")}],["pd",()=>{var d,c,f,g,E,R,y,H;const o=`${(d=t.pd)==null?void 0:d.b}pt`,a=`${(c=t.pd)==null?void 0:c.t}pt`,l=`${(f=t.pd)==null?void 0:f.l}pt`,h=`${(g=t.pd)==null?void 0:g.r}pt`;(E=t.pd)!=null&&E.b&&(e+=`padding-bottom: ${o}; `),(R=t.pd)!=null&&R.t&&(e+=`padding-top: ${a}; `),(y=t.pd)!=null&&y.l&&(e+=`padding-left: ${l}; `),(H=t.pd)!=null&&H.r&&(e+=`padding-right: ${h}; `)}]]),r=["bd","tr","tb"];for(const o in t)n&&r.includes(o)||(i=s.get(o))==null||i();return e}function _n(t){let n="";return t===dt.NONE?n="none":t===dt.THIN?n="0.5pt solid":t===dt.HAIR?n="0.5pt double":t===dt.DOTTED?n="0.5pt dotted":t===dt.DASHED||t===dt.DASH_DOT?n="0.5pt dashed":t===dt.DASH_DOT_DOT?n="0.5pt dotted":t===dt.DOUBLE?n="0.5pt double":t===dt.MEDIUM?n="1pt solid":t===dt.MEDIUM_DASHED||t===dt.MEDIUM_DASH_DOT?n="1pt dashed":t===dt.MEDIUM_DASH_DOT_DOT?n="1pt dotted":t===dt.SLANT_DASH_DOT?n="0.5pt dashed":t===dt.THICK&&(n="1.5pt solid"),n}function Ca(t){let n=0;if(t=t.trim(),t==="none")n=dt.NONE;else if(t==="0.5pt solid")n=dt.THIN;else if(t==="0.5pt double")n=dt.HAIR;else if(t==="0.5pt dotted")n=dt.DOTTED;else if(t==="0.5pt dashed")n=dt.DASHED;else if(t==="1pt solid")n=dt.MEDIUM;else if(t==="1pt dashed")n=dt.MEDIUM_DASHED;else if(t==="1pt dotted")n=dt.MEDIUM_DASH_DOT_DOT;else if(t==="1.5pt solid")n=dt.THICK;else if(!t.includes("none"))n=dt.THIN;else return dt.NONE;return n}function pa(t,n){let e=t.body;if(n){const{headers:s,footers:r}=t;s!=null&&s[n]?e=s[n].body:r!=null&&r[n]&&(e=r[n].body)}return e}function Ia(t){const{startRow:n,endRow:e,startColumn:s,endColumn:r,rangeType:i}=t;return!(n<0||s<0||e<0||r<0||!(Number.isNaN(n)&&Number.isNaN(e))&&i===ot.COLUMN||!(Number.isNaN(s)&&Number.isNaN(r))&&i===ot.ROW||i!==ot.ROW&&i!==ot.COLUMN&&(Number.isNaN(s)||Number.isNaN(n)||Number.isNaN(r)||Number.isNaN(e)))}function Sa(t,n){return{startRow:t,endRow:t,startColumn:n,endColumn:n}}function Bn(t,n){return Object.prototype.toString.call(t)===Object.prototype.toString.call(n)?Object.prototype.toString.call(t)==="[object Object]"||Object.prototype.toString.call(t)==="[object Array]"?Object.keys(t).length!==Object.keys(n).length?!1:Object.keys(t).every(e=>Bn(t[e],n[e])):t===n:!1}function Tr(t,n){const e=t.ts||{},s=n.ts||{};return t.sId!==n.sId?!1:Bn(e,s)}function Oa(t,n){return n.some(e=>t.indexOf(e)>-1)}function mn(t,n,e,s){if(t>n&&([t,n]=[n,t]),e>s&&([e,s]=[s,e]),n<e||s<t)return[t,n];e<t&&(e=t),s>n&&(s=n);const r=s-e+1;let i=[];return t===e?i=[s+1-r,n-r]:n===s?i=[t,e-1]:i=[t,n-r],i}function Na(t){if(t==null)return!1;const n=t.bullet;return(n==null?void 0:n.listId)!=null}function Aa(t){if(t==null)return!1;const n=t.paragraphStyle;return Mr(n)}function Mr(t){return!(t==null||(t.indentStart==null||t.indentStart===0)&&t.hanging==null||t.hanging===0)}function Ur(t,n,e){return t.slice(0,n)+e+t.slice(n)}function Lr(t,n,e){return n>e?t:t.slice(0,n)+t.slice(e)}function ba(t){return t===null||t.toString().replace(/\s/g,"")===""||typeof t=="boolean"?!1:!isNaN(t)}function va(t){let n=0;for(let e=0;e<t.length;e++)n=t.charCodeAt(e)+(n<<6)+(n<<16)-n;return n>>>0}function Dr(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],s=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function yr(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var s=e.call(t),r,i=[],o;try{for(;(n===void 0||n-- >0)&&!(r=s.next()).done;)i.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=s.return)&&e.call(s)}finally{if(o)throw o.error}}return i}function Pr(t,n,e){if(e||arguments.length===2)for(var s=0,r=n.length,i;s<r;s++)(i||!(s in n))&&(i||(i=Array.prototype.slice.call(n,0,s)),i[s]=n[s]);return t.concat(i||Array.prototype.slice.call(n))}typeof SuppressedError=="function"&&SuppressedError;function je(t){return typeof t=="function"}function wa(t){var n=function(s){Error.call(s),s.stack=new Error().stack},e=t(n);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var Gn=wa(function(t){return function(e){t(this),this.message=e?e.length+` errors occurred during unsubscription:
|
|
2
|
+
`+e.map(function(s,r){return r+1+") "+s.toString()}).join(`
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=e}});function kr(t,n){if(t){var e=t.indexOf(n);0<=e&&t.splice(e,1)}}var Hr=function(){function t(n){this.initialTeardown=n,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var n,e,s,r,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=Dr(o),l=a.next();!l.done;l=a.next()){var h=l.value;h.remove(this)}}catch(R){n={error:R}}finally{try{l&&!l.done&&(e=a.return)&&e.call(a)}finally{if(n)throw n.error}}else o.remove(this);var d=this.initialTeardown;if(je(d))try{d()}catch(R){i=R instanceof Gn?R.errors:[R]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var f=Dr(c),g=f.next();!g.done;g=f.next()){var E=g.value;try{Fr(E)}catch(R){i=i!=null?i:[],R instanceof Gn?i=Pr(Pr([],yr(i)),yr(R.errors)):i.push(R)}}}catch(R){s={error:R}}finally{try{g&&!g.done&&(r=f.return)&&r.call(f)}finally{if(s)throw s.error}}}if(i)throw new Gn(i)}},t.prototype.add=function(n){var e;if(n&&n!==this)if(this.closed)Fr(n);else{if(n instanceof t){if(n.closed||n._hasParent(this))return;n._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(n)}},t.prototype._hasParent=function(n){var e=this._parentage;return e===n||Array.isArray(e)&&e.includes(n)},t.prototype._addParent=function(n){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(n),e):e?[e,n]:n},t.prototype._removeParent=function(n){var e=this._parentage;e===n?this._parentage=null:Array.isArray(e)&&kr(e,n)},t.prototype.remove=function(n){var e=this._finalizers;e&&kr(e,n),n instanceof t&&n._removeParent(this)},t.EMPTY=function(){var n=new t;return n.closed=!0,n}(),t}();Hr.EMPTY;function Ta(t){return t instanceof Hr||t&&"closed"in t&&je(t.remove)&&je(t.add)&&je(t.unsubscribe)}function Fr(t){je(t)?t():t.unsubscribe()}function At(t){let n=!1;return t?Ta(t)?{dispose:()=>t.unsubscribe()}:typeof t=="function"?{dispose:()=>{n||(n=!0,t())}}:t:At(()=>{})}function Ma(t){return At(()=>{t.unsubscribe()})}class xn{constructor(){_(this,"_disposables",new Set)}add(n){const e=At(n);return this._disposables.add(e),{dispose:()=>{e.dispose(),this._disposables.delete(e)}}}dispose(){this._disposables.forEach(n=>{n.dispose()}),this._disposables.clear()}}class Mt{constructor(){_(this,"_disposed",!1);_(this,"_collection",new xn)}disposeWithMe(n){return this._collection.add(n)}ensureNotDisposed(){if(this._disposed)throw new Error("[Disposable]: object is disposed!")}dispose(){this._disposed||(this._disposed=!0,this._collection.dispose())}}class Ua extends Mt{constructor(){super(...arguments);_(this,"dispose$",new B.Subject)}dispose(){super.dispose(),this.dispose$.next(),this.dispose$.complete()}}class Ke{static hasLength(n,e){return n.length===e}static getValueType(n){return Object.prototype.toString.apply(n)}static isObject(n){return this.getValueType(n)==="[object Object]"}static isIterable(n){return n[Symbol.iterator]!=null}static isNumber(n){return this.getValueType(n)==="[object Number]"}}function En(t,n){const e=t.indexOf(n);return e>-1?(t.splice(e,1),!0):!1}function La(t){const n=new Set,e=[];for(const s of t)n.has(s)||(n.add(s),e.push(s));return e}function Da(t,n){for(let e=t.length-1;e>-1;e--){const s=t[e];if(n(s,e))return s}return null}function ya(t,n){if(t.length===0)return t;const e=n%t.length;return t.slice(e).concat(t.slice(0,e))}function Pa(t,n){const e=new Map;return t.forEach(s=>{const r=n(s);let i=e.get(r);e.has(r)||(i=[],e.set(r,i)),i.push(s)}),e}function ka(t){return Array.isArray(t)?t:[t]}const ht=Symbol("newer"),Ut=Symbol("older");class Wr{constructor(n){_(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ht],{done:!1,value:n.key}):{done:!0,value:void 0}}}class $r{constructor(n){_(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ht],{done:!1,value:n.value}):{done:!0,value:void 0}}}class Br{constructor(n){_(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ht],{done:!1,value:[n.key,n.value]}):{done:!0,value:void 0}}}No=ht,Oo=Ut;class Vn{constructor(n,e){_(this,"key");_(this,"value");_(this,No);_(this,Oo);this.key=n,this.value=e,this[ht]=void 0,this[Ut]=void 0}toJSON(){return{key:this.key,value:this.value}}}class Gr{constructor(...n){_(this,"_keymap");_(this,"size",0);_(this,"limit");_(this,"oldest");_(this,"newest");_(this,"_onShiftListeners",[]);if(Ke.hasLength(n,1)){if(Ke.isNumber(n[0])){const e=n[0];this._initialize(e,void 0);return}if(Ke.isIterable(n[0])){const e=n[0];this._initialize(0,e);return}return}if(Ke.hasLength(n,2)){const e=n[0],s=n[1];this._initialize(e,s)}}onShift(n){if(this._onShiftListeners.indexOf(n)===-1)return this._onShiftListeners.push(n),At(()=>En(this._onShiftListeners,n));throw new Error("[LRUMap]: the listener has been registered!")}_initialize(n,e){this.oldest=void 0,this.newest=void 0,this.size=0,this.limit=n,this._keymap=new Map,e&&(this.assign(e),n<1&&(this.limit=this.size))}_markEntryAsUsed(n){n!==this.newest&&(n[ht]&&(n===this.oldest&&(this.oldest=n[ht]),n[ht][Ut]=n[Ut]),n[Ut]&&(n[Ut][ht]=n[ht]),n[ht]=void 0,n[Ut]=this.newest,this.newest&&(this.newest[ht]=n),this.newest=n)}assign(n){let e,s=this.limit||Number.MAX_VALUE;this._keymap.clear();const r=n[Symbol.iterator]();for(let i=r.next();!i.done;i=r.next()){const o=new Vn(i.value[0],i.value[1]);if(this._keymap.set(o.key,o),e?(e[ht]=o,o[Ut]=e):this.oldest=o,e=o,s--===0)throw new Error("overflow")}this.newest=e,this.size=this._keymap.size}set(n,e){let s=this._keymap.get(n);return s?(s.value=e,this._markEntryAsUsed(s),this):(this._keymap.set(n,s=new Vn(n,e)),this.newest?(this.newest[ht]=s,s[Ut]=this.newest):this.oldest=s,this.newest=s,++this.size,this.size>this.limit&&this.shift(),this)}shift(){const n=this.oldest;if(n)return this.oldest&&this.oldest[ht]?(this.oldest=this.oldest[ht],this.oldest[Ut]=void 0):(this.oldest=void 0,this.newest=void 0),n[ht]=n[Ut]=void 0,this._keymap.delete(n.key),--this.size,this._onShiftListeners.forEach(e=>e(n)),[n.key,n.value]}get(n){const e=this._keymap.get(n);if(e)return this._markEntryAsUsed(e),e.value}has(n){return this._keymap.has(n)}find(n){const e=this._keymap.get(n);return e?e.value:void 0}delete(n){const e=this._keymap.get(n);if(e)return this._keymap.delete(e.key),e[ht]&&e[Ut]?(e[Ut][ht]=e[ht],e[ht][Ut]=e[Ut]):e[ht]?(e[ht][Ut]=void 0,this.oldest=e[ht]):e[Ut]?(e[Ut][ht]=void 0,this.newest=e[Ut]):this.oldest=this.newest=void 0,this.size--,e.value}clear(){this.oldest=void 0,this.newest=void 0,this.size=0,this._keymap.clear()}keys(){return new Wr(this.oldest)}values(){return new $r(this.oldest)}entries(){return this[Symbol.iterator]()}[Symbol.iterator](){return new Br(this.oldest)}forEach(n,e){typeof e!="object"&&(e=this);let s=this.oldest;for(;s;)n.call(e,s.value,s.key,this),s=s[ht]}toJSON(){const n=new Array(this.size);let e=0,s=this.oldest;for(;s;)n[e++]={key:s.key,value:s.value},s=s[ht];return n}toString(){let n="",e=this.oldest;for(;e;)n+=`${String(e.key)}:${e.value}`,e=e[ht],e&&(n+=" < ");return n}}function _e(t){let n=0;const e=Object.keys(t);for(const s of e){const r=Number(s);n=Math.max(n,r)}return n+1}function jn(t,n,e){const s=_e(e),r=e;for(let i=s-1;i>=t;i--)r[i+1]=r[i];r[t]=n}function Kn(t,n,e){const s=Object.keys(e).reduce((r,i)=>Math.max(r,Number.parseInt(i)),0)+1;for(let r=t;r<s;r++)r<t+n?delete e[r]:e[r]!==void 0&&(e[r-n]=e[r],delete e[r])}function Ha(t,n){const e=t,s=Object.keys(e),r=s.length,i=n,o=Object.keys(i),a=o.length,l={};let h=0;for(let d=0;d<r;d++,h++){const c=s[d];l[h]=e[c]}for(let d=0;d<a;d++,h++){const c=o[d];l[h]=i[c]}return l}function Fa(t,n,e){const s=e;if(_e(e)>0){const i={};let o=0;for(let a=t;a<=n;a++)s[a]&&(i[o]=s[a],o++);return i}return{}}function Yn(t,n,e,s){const r=t>e;if(!r&&t+n>e)throw new Error("Invalid move operation");r?Wa(t,n,e,s):$a(t,n,e,s)}function Wa(t,n,e,s){const r=s,i=[];for(let o=t;o<t+n;o++)i.push(r[o]);for(let o=t-1;o>=e;o--){const a=r[o];r[o+n]=a,a===void 0&&delete r[o+n]}i.forEach((o,a)=>{r[e+a]=o,o===void 0&&delete r[e+a]})}function $a(t,n,e,s){const r=s,i=[];for(let o=t;o<t+n;o++)i.push(r[o]);for(let o=t+n;o<e;o++){const a=r[o];r[o-n]=a,a===void 0&&delete r[o-n]}i.forEach((o,a)=>{r[e+a-n]=o,o===void 0&&delete r[e+a-n]})}class Jt{constructor(n={}){_(this,"_matrix");this._setOriginValue(n)}static MakeObjectMatrixSize(n){return new Jt({[n-1]:{}})}getMatrix(){return this._matrix}forEach(n){const e=this._matrix,s=Object.keys(e);for(const r of s){const i=Number(r),o=e[i];if(n(i,o)===!1)return this}return this}forRow(n){const e=this._matrix,s=Object.keys(e);for(const r of s){const i=Number(r),o=e[i];if(n(i,Object.keys(o).map(l=>Number(l)))===!1)return this}return this}forValue(n){const e=this._matrix,s=Object.keys(e);for(const r of s){const i=Number(r),o=e[i];if(!o)continue;const a=Object.keys(o);for(const l of a){const h=Number(l),d=o[Number(l)];if(n(i,h,d)===!1)return this}}return this}swapRow(n,e){const s=this._matrix[n],r=this._matrix[e];this._matrix[n]=r,this._matrix[e]=s}getRow(n){return this._matrix[n]}getRowOrCreate(n){let e=this.getRow(n);return e==null&&(e={},this._matrix[n]=e),e}reset(){this._setOriginValue({})}hasValue(){const n=this._matrix,e=Object.keys(n);if(e.length===0)return!1;for(const s of e){const r=Number(s),i=n[r];if(Object.keys(i).length>0)return!0}return!1}getValue(n,e){var s,r;return(r=(s=this._matrix)==null?void 0:s[n])==null?void 0:r[e]}setValue(n,e,s){const r=this.getRowOrCreate(n);r[e]=s}deleteValue(n,e){var s,r;(r=(s=this._matrix)==null?void 0:s[n])==null||delete r[e]}realDeleteValue(n,e){var s,r,i;if((r=(s=this._matrix)==null?void 0:s[n])==null||delete r[e],this.getRow(n)){const o=this.getRow(n);if(o==null)return;Object.keys(o).length===0&&((i=this._matrix)==null||delete i[n])}}setRow(n,e){this._matrix[n]=e}moveRows(n,e,s){Yn(n,e,s,this._matrix)}moveColumns(n,e,s){this.forEach((r,i)=>{Yn(n,e,s,i)})}insertRows(n,e){for(let s=n;s<n+e;s++)jn(s,{},this._matrix)}insertColumns(n,e){for(let s=n;s<n+e;s++)this.forEach((r,i)=>{i&&jn(s,void 0,i)})}removeRows(n,e){Kn(n,e,this._matrix)}removeColumns(n,e){this.forEach((s,r)=>{r&&Kn(n,e,r)})}getFragment(n,e,s,r){const i=new Jt;let o=0;for(let a=n;a<=e;a++){const l={};let h=0;for(let d=s;d<=r;d++){const c=this.getValue(a,d);l[h]=c,h++}i.setRow(o,l),o++}return i}getSlice(n,e,s,r){const i=new Jt;for(let o=n;o<=e;o++)for(let a=s;a<=r;a++){const l=this.getValue(o,a);l&&i.setValue(o,a,P.deepClone(l))}return i}getSizeOf(){return Object.keys(this._matrix).length}getLength(){return _e(this._matrix)}getRange(){const s=this.getLength()-1;let r=0;const i=this.getLength();for(let o=0;o<i;o++){const a=this.getRow(o);if(a){const l=_e(a)-1;r=l>r?l:r}}return{startRow:0,startColumn:0,endRow:s,endColumn:r}}toNativeArray(){const n=new Array;return this.forValue((e,s,r)=>{n.push(r)}),n}toArray(){const n=[];return this.forRow((e,s)=>{n[e]==null&&(n[e]=[]),s.forEach(r=>{n[e][r]=this.getValue(e,r)})}),n}toFullArray(){const n=this.getRange(),{endColumn:e,endRow:s}=n,r=[];for(let i=0;i<=s;i++){const o=Array(e+1).fill(void 0);r.push(o)}return this.forValue((i,o,a)=>{r[i][o]=a}),r}toJSON(){return this._matrix}clone(){const n=JSON.stringify(this._matrix);return JSON.parse(n)}getData(){const n=JSON.stringify(this._matrix);return JSON.parse(n)}getArrayData(){let n=0,e=0,s=!1,r=!1;const i=new Jt;return this.forEach((o,a)=>{s||(s=!0,n=o),Object.keys(a).forEach(l=>{const h=Number(l);r?h<e&&(e=h):(r=!0,e=h);const d=this.getValue(o,h);i.setValue(o-n,h-e,d)})}),i.getData()}getDataRange(){let n=0,e=0,s=0,r=-1,i=!1,o=!1;return this.forEach((a,l)=>{if(i||(i=!0,n=a),l==null)return;const h=_e(l)-1;h>s&&(s=h),Object.keys(l).forEach(d=>{const c=Number(d);o?c<e&&(e=c):(o=!0,e=c)}),a>r&&(r=a)}),{startRow:n,startColumn:e,endRow:r,endColumn:s}}getDiscreteRanges(){const n=[];return this.forEach((e,s)=>{Object.keys(s).forEach(r=>{const i=Number(r);let o=!1;for(const a of n)if(e>=a.startRow&&e<=a.endRow+1&&i>=a.startColumn&&i<=a.endColumn+1){a.endRow=Math.max(e,a.endRow),a.endColumn=Math.max(i,a.endColumn),o=!0;break}o||n.push({startRow:e,endRow:e,startColumn:i,endColumn:i})})}),n}merge(n){this.forValue((e,s)=>{const r=n.getValue(e,s);r!=null&&this.setValue(e,s,r)})}_setOriginValue(n={}){this._matrix=n}}const le=class le{static clone(n){return n.rangeType!==void 0?{startRow:n.startRow,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.endColumn,rangeType:n.rangeType}:{startRow:n.startRow,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.endColumn}}static equals(n,e){return n==null||e==null?!1:n.endRow===e.endRow&&n.endColumn===e.endColumn&&n.startRow===e.startRow&&n.startColumn===e.startColumn&&(n.rangeType===e.rangeType||n.rangeType===void 0&&e.rangeType===ot.NORMAL||e.rangeType===void 0&&n.rangeType===ot.NORMAL)}static intersects(n,e){if(n.rangeType===ot.ROW&&e.rangeType===ot.COLUMN||n.rangeType===ot.COLUMN&&e.rangeType===ot.ROW)return!0;if(n.rangeType===ot.ROW&&e.rangeType===ot.ROW)return n.startRow<=e.endRow&&n.endRow>=e.startRow;if(n.rangeType===ot.COLUMN&&e.rangeType===ot.COLUMN)return n.startColumn<=e.endColumn&&n.endColumn>=e.startColumn;const s=Math.floor(Number.MAX_SAFE_INTEGER/10),r=Number.isNaN(n.startRow)?0:n.startRow,i=Number.isNaN(n.endRow)?s:n.endRow,o=Number.isNaN(n.startColumn)?0:n.startColumn,a=Number.isNaN(n.endColumn)?s:n.endColumn,l=Number.isNaN(e.startRow)?0:e.startRow,h=Number.isNaN(e.endRow)?s:e.endRow,d=Number.isNaN(e.startColumn)?0:e.startColumn,c=Number.isNaN(e.endColumn)?s:e.endColumn,f=Math.abs(o+a-d-c),g=Math.abs(o-a)+Math.abs(d-c),E=Math.abs(r+i-l-h),R=Math.abs(r-i)+Math.abs(l-h);return f<=g&&E<=R}static getIntersects(n,e){const s=n.startRow,r=n.endRow,i=n.startColumn,o=n.endColumn,a=e.startRow,l=e.endRow,h=e.startColumn,d=e.endColumn;let c,f,g,E;if(a<=r)a>=s?f=a:f=s;else return null;if(l>=s)l>=r?E=r:E=l;else return null;if(h<=o)h>i?c=h:c=i;else return null;if(d>=i)d>=o?g=o:g=d;else return null;return{startRow:f,endRow:E,startColumn:c,endColumn:g,rangeType:ot.NORMAL}}static contains(n,e){return n.startRow<=e.startRow&&n.endRow>=e.endRow&&n.startColumn<=e.startColumn&&n.endColumn>=e.endColumn}static realContain(n,e){return le.contains(n,e)&&(n.startRow<e.startRow||n.endRow>e.endRow||n.startColumn<e.startColumn||n.endColumn>e.endColumn)}static union(...n){return n.reduce((e,s)=>({startRow:Math.min(e.startRow,s.startRow),startColumn:Math.min(e.startColumn,s.startColumn),endRow:Math.max(e.endRow,s.endRow),endColumn:Math.max(e.endColumn,s.endColumn),rangeType:ot.NORMAL}),n[0])}static realUnion(...n){const e=n.some(i=>i.rangeType===ot.COLUMN),s=n.some(i=>i.rangeType===ot.ROW),r=le.union(...n);return{startColumn:s?Number.NaN:r.startColumn,endColumn:s?Number.NaN:r.endColumn,startRow:e?Number.NaN:r.startRow,endRow:e?Number.NaN:r.endRow,rangeType:s?ot.ROW:e?ot.COLUMN:ot.NORMAL}}static subtract(n,e){if(e.startRow>n.endRow||e.endRow<n.startRow||e.startColumn>n.endColumn||e.endColumn<n.startColumn)return[n];const s=[];e.startRow>=n.startRow&&s.push({startRow:n.startRow,startColumn:n.startColumn,endRow:e.startRow-1,endColumn:n.endColumn}),e.endRow<=n.endRow&&s.push({startRow:e.endRow+1,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.endColumn});const r=Math.max(n.startRow,e.startRow),i=Math.min(n.endRow,e.endRow);return e.startColumn>=n.startColumn&&s.push({startRow:r,startColumn:n.startColumn,endRow:i,endColumn:e.startColumn-1}),e.endColumn<=n.endColumn&&s.push({startRow:r,startColumn:e.endColumn+1,endRow:i,endColumn:n.endColumn}),s.filter(a=>a.startRow<=a.endRow&&a.startColumn<=a.endColumn)}static hasIntersectionBetweenTwoRect(n,e){return!(n.left>e.right||n.right<e.left||n.top>e.bottom||n.bottom<e.top)}static getIntersectionBetweenTwoRect(n,e){const s=Math.max(n.left,e.left),r=Math.min(n.right,e.right),i=Math.max(n.top,e.top),o=Math.min(n.bottom,e.bottom);return r<=s||o<=i?null:{left:s,right:r,top:i,bottom:o,width:r-s,height:o-i}}};_(le,"getRelativeRange",(n,e)=>({startRow:n.startRow-e.startRow,endRow:n.endRow-n.startRow,startColumn:n.startColumn-e.startColumn,endColumn:n.endColumn-n.startColumn})),_(le,"getPositionRange",(n,e,s)=>({...s||{},startRow:s&&[Nt.ROW,Nt.ALL].includes(s.startAbsoluteRefType||0)?s.startRow:n.startRow+e.startRow,endRow:s&&[Nt.ROW,Nt.ALL].includes(s.endAbsoluteRefType||0)?s.endRow:n.endRow+n.startRow+e.startRow,startColumn:s&&[Nt.COLUMN,Nt.ALL].includes(s.startAbsoluteRefType||0)?s.startColumn:n.startColumn+e.startColumn,endColumn:s&&[Nt.COLUMN,Nt.ALL].includes(s.endAbsoluteRefType||0)?s.endColumn:n.endColumn+n.startColumn+e.startColumn})),_(le,"moveHorizontal",(n,e=0,s=0)=>({...n,startColumn:n.startColumn+e,endColumn:n.endColumn+e+s})),_(le,"moveVertical",(n,e=0,s=0)=>({...n,startRow:n.startRow+e,endRow:n.endRow+e+s})),_(le,"moveOffset",(n,e,s)=>({...n,startRow:n.startRow+s,endRow:n.endRow+s,startColumn:n.startColumn+e,endColumn:n.endColumn+e}));let me=le;class Ba{constructor(n,e){_(this,"_values",[]);_(this,"_keys",[]);_(this,"_keyMaps",new Map);this._values=n,this._keys=e,n.forEach(s=>{this._initKeyMap(s)})}_initKeyMap(n){this._keys.forEach(e=>{const s=n[e],r=this._keyMaps.get(e)||new Map;r.set(s,n),this._keyMaps.set(e,r)})}getValue(n,e){const s=e||this._keys;for(let r=0;r<s.length;r++){const i=this._keyMaps.get(s[r]);if(i!=null&&i.has(n))return i.get(n)}return null}hasValue(n){for(let e=0;e<this._keys.length;e++){const s=this._keyMaps.get(this._keys[e]);if(s!=null&&s.has(n))return!0}return!1}addValue(n){this._values.push(n),this._initKeyMap(n)}setValue(n,e,s){const r=this.getValue(n);r&&Object.keys(r).includes(e)&&(r[e]=s)}deleteValue(n){const e=this.getValue(n);if(e){this._keys.forEach(r=>{const i=this._keyMaps.get(r),o=e[r];i==null||i.delete(o)});const s=this._values.findIndex(r=>r===e);this._values.splice(s,1)}}getValues(){return this._values}getKeyMap(n){var e;return[...((e=this._keyMaps.get(n))==null?void 0:e.keys())||[]]}clear(){this._values=[],this._keys=[],this._keyMaps.clear()}}function zn(t,n,e,s){return{forEach(r){for(let i=t;i<=n;i++)for(let o=e;o<=s;o++)r(i,o)}}}function Ga(t){if(t==null||t.length===0)return Number.NaN;const n=t.toLowerCase().split(""),e=n.length,s=o=>o.charCodeAt(0)-96;let r=0,i=0;for(let o=0;o<e;o++)i=s(n[o]),r+=i*26**(e-o-1);return r===0?Number.NaN:r-1}const Rn=65,xr=90,xa=97;function Va(t){const n=xr-Rn+1;let e="";for(;t>=0;)e=String.fromCharCode(t%n+Rn)+e,t=Math.floor(t/n)-1;return e}function Vr(t,n){let e="";for(;n>0;)e+=t,n--;return e}function ja(t,n=!1){const e=xr-Rn+1;let s=xa;n&&(s=Rn);const r=String.fromCharCode(t%e+s),i=Math.floor(t/e)+1;return Vr(r,i)}function Ka(t,n){return t.zIndex>n.zIndex?1:t.zIndex===n.zIndex?0:-1}function Ya(t,n){return t.zIndex>n.zIndex?-1:t.zIndex===n.zIndex?0:1}function Ae(t="index",n=1){return(e,s)=>e[t]>s[t]?n:e[t]===s[t]?0:-n}function za(t,n){let e;function s(...r){const i=this,o=function(){e=null,t.apply(i,r)};clearTimeout(e),e=setTimeout(o,n)}return Object.defineProperty(s,"cancel",{value:()=>{clearTimeout(e)},enumerable:!1,writable:!1}),s}function Cn(t,n,e){const{dataStream:s,textRuns:r=[]}=t;let i=n;const o=[];for(const a of r){const{st:l,ed:h}=a;P.hasIntersectionBetweenTwoRanges(n,e,l,h)&&(l>i?(o.push(s.slice(i,l)),o.push(Xn(s,{...a,ed:Math.min(h,e)}))):o.push(Xn(s,{...a,st:i,ed:Math.min(h,e)}))),i=Math.max(n,Math.min(h,e))}return i!==e&&o.push(s.slice(i,e)),o.join("")}function Xa(t,n=!0){var e;if(n&&((e=t.paragraphs)!=null&&e.length)){const{dataStream:s,paragraphs:r=[]}=t;let i="",o=-1;for(const a of r){const{startIndex:l,paragraphStyle:h={}}=a,{spaceAbove:d,spaceBelow:c,lineSpacing:f}=h,g=[];d!=null&&(typeof d=="number"?g.push(`margin-top: ${d}px`):g.push(`margin-top: ${d.v}px`)),c!=null&&(typeof c=="number"?g.push(`margin-bottom: ${c}px`):g.push(`margin-bottom: ${c.v}px`)),f!=null&&g.push(`line-height: ${f}`),l>o+1?i+=`<p class="UniverNormal" ${g.length?`style="${g.join("; ")};"`:""}>${Cn(t,o+1,l)}</p>`:i+=`<p class="UniverNormal" ${g.length?`style="${g.join("; ")};"`:""}></p>`,o=l}return o!==s.length&&(i+=Cn(t,o,s.length)),i}else return Cn(t,0,t.dataStream.length)}function Xn(t,n){const{st:e,ed:s,ts:r={}}=n,{ff:i,fs:o,it:a,bl:l,ul:h,st:d,ol:c,bg:f,cl:g,va:E}=r;let R=t.slice(e,s);const y=[];return a===Y.TRUE&&(R=`<i>${R}</i>`),E===Pe.SUPERSCRIPT?R=`<sup>${R}</sup>`:E===Pe.SUBSCRIPT&&(R=`<sub>${R}</sub>`),(h==null?void 0:h.s)===Y.TRUE&&(R=`<u>${R}</u>`),(d==null?void 0:d.s)===Y.TRUE&&(R=`<s>${R}</s>`),l===Y.TRUE&&(R=`<strong>${R}</strong>`),i&&y.push(`font-family: ${i}`),g&&y.push(`color: ${g.rgb}`),o&&y.push(`font-size: ${o}pt`),c&&y.push("text-decoration: overline"),f&&y.push(`background: ${f.rgb}`),y.length?`<span style="${y.join("; ")};">${R}</span>`:R}const qa={sheetId:"",range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},Za={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},Ja={startRow:0,startColumn:0,endRow:0,endColumn:0},Qa={row:0,column:0},pn={ff:"Arial",fs:11,it:Y.FALSE,bl:Y.FALSE,ul:{s:Y.FALSE},st:{s:Y.FALSE},ol:{s:Y.FALSE},tr:{a:0,v:Y.FALSE},td:xe.UNSPECIFIED,cl:{rgb:"#000"},bg:{rgb:"#fff"},ht:Se.UNSPECIFIED,vt:De.UNSPECIFIED,tb:ye.UNSPECIFIED,pd:{t:0,r:0,b:0,l:0}},jr={id:"default_slide",title:"defaultSlide",pageSize:{width:300,height:300}};var Kr=(t=>(t.ARRAY_CONVERTOR="ARRAY_CONVERTOR",t.MATRIX_CONVERTOR="MATRIX_CONVERTOR",t))(Kr||{});function In(t,n){const{textRuns:e=[]}=n;let s=0;for(const i of e){const{ts:o={},st:a,ed:l}=i;if(o[t]==null)return Y.FALSE;switch(t){case"bl":case"it":{if(o[t]===Y.FALSE)return Y.FALSE;break}case"ul":case"st":{if(o[t].s===Y.FALSE)return Y.FALSE;break}default:throw new Error(`unknown style key: ${t} in IStyleBase`)}s+=l-a}return n.dataStream.indexOf(`\r
|
|
4
|
+
`)===s?Y.TRUE:Y.FALSE}const nn=class nn{constructor(n,e,s){_(this,"_range");_(this,"_worksheet");this._deps=s,this._range=e,this._worksheet=n}static foreach(n,e){const{startRow:s,startColumn:r,endRow:i,endColumn:o}=n;for(let a=s;a<=i;a++)for(let l=r;l<=o;l++)e(a,l)}getRangeData(){return this._range}getValue(){return this.getValues()[0][0]}getValues(){const{startRow:n,endRow:e,startColumn:s,endColumn:r}=this._range,i=[];for(let o=n;o<=e;o++){const a=[];for(let l=s;l<=r;l++)a.push(this.getMatrix().getValue(o,l)||null);i.push(a)}return i}getMatrix(){const{startRow:n,endRow:e,startColumn:s,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new Jt;for(let a=n;a<=e;a++)for(let l=s;l<=r;l++)o.setValue(a,l,i.getValue(a,l)||null);return o}getMatrixObject(){const{startRow:n,endRow:e,startColumn:s,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new Jt;for(let a=n;a<=e;a++)for(let l=s;l<=r;l++)o.setValue(a-n,l-s,i.getValue(a,l)||{});return o}getA1Notation(){const{startRow:n,endRow:e,startColumn:s,endColumn:r}=this._range;let i,o;return s<r?(i=P.numToWord(s+1)+(n+1),o=P.numToWord(r+1)+(e+1)):(i=P.numToWord(r+1)+(e+1),o=P.numToWord(s+1)+(n+1)),i===o?`${i}`:`${i}:${o}`}getBackground(){return this.getBackgrounds()[0][0]}getBackgrounds(){const n=this._deps.getStyles();return this.getValues().map(e=>e.map(s=>{var i;const r=n.getStyleByCell(s);return((i=r==null?void 0:r.bg)==null?void 0:i.rgb)||pn.bg.rgb}))}getCell(n,e){const{startRow:s,endRow:r,startColumn:i,endColumn:o}=this._range,a={startRow:s+n,endRow:s+n,startColumn:i+e,endColumn:i+e};return new nn(this._worksheet,a,this._deps)}getColumn(){return this._range.startColumn}getObjectValue(n={}){return this.getObjectValues(n)[0][0]}getObjectValues(n={}){var a;const{startRow:e,endRow:s,startColumn:r,endColumn:i}=this._range,o=this._worksheet.getCellMatrix().getFragment(e,s,r,i).getData();if(n.isIncludeStyle){const l=this._deps.getStyles();for(let h=0;h<=s-e;h++)for(let d=0;d<=i-r;d++){if(o==null||((a=o==null?void 0:o[h])==null?void 0:a[d])==null)continue;const c=o[h][d].s;c&&(o[h][d].s=l.get(c))}}return o}getFontColor(){return this.getFontColors()[0][0]}getFontColors(){const n=this._deps.getStyles();return this.getValues().map(e=>e.map(s=>{var i;const r=n.getStyleByCell(s);return((i=r==null?void 0:r.cl)==null?void 0:i.rgb)||pn.cl.rgb}))}getFontFamilies(){return this._getStyles("ff")}getFontFamily(){return this.getFontFamilies()[0][0]}getUnderlines(){return this._getStyles("ul")}getUnderline(){var e,s;const{p:n}=(e=this.getValue())!=null?e:{};return n&&Array.isArray((s=n.body)==null?void 0:s.textRuns)&&n.body.textRuns.length>0?In("ul",n.body)===Y.TRUE?{s:Y.TRUE}:{s:Y.FALSE}:this.getUnderlines()[0][0]}getOverlines(){return this._getStyles("ol")}getOverline(){return this.getOverlines()[0][0]}getStrikeThrough(){var e,s;const{p:n}=(e=this.getValue())!=null?e:{};return n&&Array.isArray((s=n.body)==null?void 0:s.textRuns)&&n.body.textRuns.length>0?In("st",n.body)===Y.TRUE?{s:Y.TRUE}:{s:Y.FALSE}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles("st")}getFontSize(){var e,s;const n=((e=this.getValue())==null?void 0:e.p)||{};return n&&Array.isArray((s=n.body)==null?void 0:s.textRuns)&&n.body.textRuns.length>0?n.body.textRuns.some(r=>{var i;return((i=r==null?void 0:r.ts)==null?void 0:i.fs)!=null})?Math.max(...n.body.textRuns.map(r=>{var i;return((i=r==null?void 0:r.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 e,s;const{p:n}=(e=this.getValue())!=null?e:{};return n&&Array.isArray((s=n.body)==null?void 0:s.textRuns)&&n.body.textRuns.length>0?In("it",n.body)===Y.TRUE?ln.ITALIC:ln.NORMAL:this._getFontStyles()[0][0]}_getFontStyles(){return this._getStyles("it")}getFontWeight(){var e,s;const{p:n}=(e=this.getValue())!=null?e:{};return n&&Array.isArray((s=n.body)==null?void 0:s.textRuns)&&n.body.textRuns.length>0?In("bl",n.body)===Y.TRUE?un.BOLD:un.NORMAL:this._getFontWeights()[0][0]}_getFontWeights(){return this._getStyles("bl")}getGridId(){return this._worksheet.getSheetId()}getHeight(){const{_range:n,_worksheet:e}=this,{startRow:s,endRow:r}=n;let i=0;for(let o=0;o<=r-s;o++){const a=e.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:n,endColumn:e}=this._range;return e-n+1}getNumRows(){const{startRow:n,endRow:e}=this._range;return e-n+1}getRichTextValue(){return this.getRichTextValues()[0][0]}getRichTextValues(){return this.getValues().map(n=>n.map(e=>(e==null?void 0:e.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 n=this._deps.getStyles();return this.getValues().map(e=>e.map(s=>n.getStyleByCell(s)))}getVerticalAlignment(){return this.getVerticalAlignments()[0][0]}getVerticalAlignments(){return this._getStyles("vt")}getWidth(){const{_range:n,_worksheet:e}=this,{startColumn:s,endColumn:r}=n;let i=0;for(let o=0;o<=r-s;o++)i+=e.getColumnWidth(o);return i}getWrap(){return this.getWrapStrategy()===ye.WRAP?Y.TRUE:Y.FALSE}getWrapStrategies(){return this._getStyles("tb")}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(n){nn.foreach(this._range,n)}_getStyles(n){const e=this._deps.getStyles();return this.getValues().map(s=>s.map(r=>{const i=e&&e.getStyleByCell(r);return i&&i[n]||pn[n]}))}};_(nn,"transformRange",(n,e)=>n.rangeType===ot.ALL?{startColumn:0,startRow:0,endColumn:e.getMaxColumns()-1,endRow:e.getMaxRows()-1}:n.rangeType===ot.COLUMN?{startRow:0,endRow:e.getMaxRows()-1,startColumn:n.startColumn,endColumn:n.endColumn}:n.rangeType===ot.ROW?{startColumn:0,endColumn:e.getMaxColumns()-1,startRow:n.startRow,endRow:n.endRow}:n);let ke=nn;function tl(t,n){if(t.length===0||t[0].length===0)return null;const e=new Array(t[0].length).fill(0);let s=0,r=null;for(let i=0;i<t.length;i++){for(let a=0;a<t[0].length;a++)e[a]=n(t[i][a])?e[a]+1:0;const o=el(e);o.area>s&&(s=o.area,r={startColumn:o.start,startRow:i-o.height+1,endColumn:o.end,endRow:i})}return r}function el(t){const n=[];let e=0,s={area:0,height:0,start:0,end:0},r=0;for(;r<t.length;)if(n.length===0||t[r]>=t[n[n.length-1]])n.push(r++);else{const i=t[n.pop()],o=n.length===0?r:r-n[n.length-1]-1;i*o>e&&(e=i*o,s={area:e,height:i,start:n.length===0?0:n[n.length-1]+1,end:r-1})}for(;n.length>0;){const i=t[n.pop()],o=n.length===0?r:r-n[n.length-1]-1;i*o>e&&(e=i*o,s={area:e,height:i,start:n.length===0?0:n[n.length-1]+1,end:r-1})}return s}function nl(t,n){ke.foreach(n,(e,s)=>{t[e][s]=void 0})}function sl(t,n){const e=t.toFullArray(),s=[];for(;;){const r=tl(e,n);if(!r)break;s.push(r),nl(e,r)}return s}function rl(t,n,e,s=!1){let r={...t};const i=r.startAbsoluteRefType||Nt.NONE,o=r.endAbsoluteRefType||Nt.NONE;return!s&&i===Nt.ALL&&o===Nt.ALL?r:s||i===Nt.NONE&&o===Nt.NONE?me.moveOffset(r,n,e):(i===Nt.NONE?r={...r,startRow:r.startRow+e,startColumn:r.startColumn+n}:i===Nt.COLUMN?r={...r,startRow:r.startRow+e}:i===Nt.ROW&&(r={...r,startColumn:r.startColumn+n}),o===Nt.NONE?r={...r,endRow:r.endRow+e,endColumn:r.endColumn+n}:o===Nt.COLUMN?r={...r,endRow:r.endRow+e}:o===Nt.ROW&&(r={...r,endColumn:r.endColumn+n}),r)}async function Yr(t){for(const[n,e]of t.entries())try{if(!await e())return{index:n,result:!1}}catch(s){return{index:n,result:!1,error:s}}return{result:!0,index:-1}}function zr(t){for(const[n,e]of t.entries())try{if(!e())return{index:n,result:!1}}catch(s){return{index:n,result:!1,error:s}}return{result:!0,index:-1}}const Ye=ct.createIdentifier("univer.context-service");class Xr extends Mt{constructor(){super(...arguments);_(this,"_contextChanged$",new B.Subject);_(this,"contextChanged$",this._contextChanged$.asObservable());_(this,"_contextMap",new Map)}dispose(){super.dispose(),this._contextChanged$.complete()}getContextValue(e){var s;return(s=this._contextMap.get(e))!=null?s:!1}setContextValue(e,s){this._contextMap.set(e,s),this._contextChanged$.next({[e]:s})}subscribeContextValue$(e){return new B.Observable(s=>{const r=this._contextChanged$.pipe(B.filter(i=>typeof i[e]<"u")).subscribe(i=>s.next(i[e]));return this._contextMap.has(e)&&s.next(this._contextMap.get(e)),()=>r.unsubscribe()})}}var qr=(t=>(t[t.SILENT=0]="SILENT",t[t.ERROR=1]="ERROR",t[t.WARN=2]="WARN",t[t.INFO=3]="INFO",t[t.VERBOSE=4]="VERBOSE",t))(qr||{});const Ee=ct.createIdentifier("univer.log");class Zr extends Mt{constructor(){super(...arguments);_(this,"_logLevel",3)}debug(...e){this._logLevel>=4&&this._log(console.debug,...e)}log(...e){this._logLevel>=3&&this._log(console.log,...e)}warn(...e){this._logLevel>=2&&this._log(console.warn,...e)}error(...e){this._logLevel>=1&&this._log(console.error,...e)}setLogLevel(e){this._logLevel=e}_log(e,...s){const r=s[0];/^\[(.*?)\]/g.test(r)?e(`\x1B[97;104m${r}\x1B[0m`,...s.slice(1)):e(...s)}}var il=Object.defineProperty,ol=Object.getOwnPropertyDescriptor,al=(t,n,e,s)=>{for(var r=s>1?void 0:s?ol(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&il(n,e,r),r},Jr=(t,n)=>(e,s)=>n(e,s,t),ze=(t=>(t[t.COMMAND=0]="COMMAND",t[t.OPERATION=1]="OPERATION",t[t.MUTATION=2]="MUTATION",t))(ze||{});const Xe=ct.createIdentifier("anywhere.command-service");class ll{constructor(){_(this,"_commands",new Map);_(this,"_commandTypes",new Map)}registerCommand(n){if(this._commands.has(n.id))throw new Error(`[CommandRegistry]: command "${n.id}" has been registered before.`);return this._commands.set(n.id,n),this._commandTypes.set(n.id,n.type),At(()=>{var e;this._commands.delete(n.id),this._commandTypes.delete(n.id),(e=n.onDispose)==null||e.call(n)})}hasCommand(n){return this._commands.has(n)}getCommand(n){return this._commands.has(n)?[this._commands.get(n)]:null}getCommandType(n){return this._commandTypes.get(n)}}const Qr={id:"nil",type:0,handler:()=>!0};u.CommandService=class extends Mt{constructor(e,s){super();_(this,"_commandRegistry");_(this,"_beforeCommandExecutionListeners",[]);_(this,"_commandExecutedListeners",[]);_(this,"_multiCommandDisposables",new Map);_(this,"_commandExecutingLevel",0);_(this,"_commandExecutionStack",[]);this._injector=e,this._logService=s,this._commandRegistry=new ll,this._registerCommand(Qr)}dispose(){super.dispose(),this._commandExecutedListeners.length=0,this._beforeCommandExecutionListeners.length=0}hasCommand(e){return this._commandRegistry.hasCommand(e)}registerCommand(e){return this._registerCommand(e)}registerMultipleCommand(e){return this._registerMultiCommand(e)}beforeCommandExecuted(e){if(this._beforeCommandExecutionListeners.indexOf(e)===-1)return this._beforeCommandExecutionListeners.push(e),At(()=>{const s=this._beforeCommandExecutionListeners.indexOf(e);this._beforeCommandExecutionListeners.splice(s,1)});throw new Error("[CommandService]: could not add a listener twice.")}onCommandExecuted(e){if(this._commandExecutedListeners.indexOf(e)===-1)return this._commandExecutedListeners.push(e),At(()=>{const s=this._commandExecutedListeners.indexOf(e);this._commandExecutedListeners.splice(s,1)});throw new Error("[CommandService]: could not add a listener twice.")}async executeCommand(e,s,r){try{const i=this._commandRegistry.getCommand(e);if(i){const[o]=i,a={id:o.id,type:o.type,params:s},l=this._pushCommandExecutionStack(a);this._beforeCommandExecutionListeners.forEach(d=>d(a,r));const h=await this._execute(o,s,r);return this._commandExecutedListeners.forEach(d=>d(a,r)),l.dispose(),h}throw new Error(`[CommandService]: command "${e}" is not registered.`)}catch(i){throw this._logService.error(i),i}}syncExecuteCommand(e,s,r){var o;const i=this._commandRegistry.getCommand(e);if(i){const[a]=i,l={id:a.id,type:a.type,params:s};if(a.type===2){const c=Da(this._commandExecutionStack,f=>f.type===0);c&&(l.params=(o=l.params)!=null?o:{},l.params.trigger=c.id)}const h=this._pushCommandExecutionStack(l);this._beforeCommandExecutionListeners.forEach(c=>c(l,r));const d=this._syncExecute(a,s,r);return this._commandExecutedListeners.forEach(c=>c(l,r)),h.dispose(),d}throw new Error(`[CommandService]: command "${e}" is not registered.`)}_pushCommandExecutionStack(e){return this._commandExecutionStack.push(e),At(()=>En(this._commandExecutionStack,e))}_registerCommand(e){return this._commandRegistry.registerCommand(e)}_registerMultiCommand(e){const s=this._commandRegistry.getCommand(e.id);let r;if(s){if(s[0].multi!==!0)throw new Error("Command has registered as a single command.");r=s[0]}else{const o=new xn;r=new ul(e.id),o.add(this._commandRegistry.registerCommand(r)),o.add(At(()=>{this._multiCommandDisposables.delete(e.id)})),this._multiCommandDisposables.set(e.id,o)}const i=r.registerImplementation(e);return At(()=>{var o;i.dispose(),r.hasImplementations()||(o=this._multiCommandDisposables.get(e.id))==null||o.dispose()})}async _execute(e,s,r){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(this._commandExecutingLevel,0))}executing command "${e.id}"`),this._commandExecutingLevel++;let i;try{i=await this._injector.invoke(e.handler,s,r),this._commandExecutingLevel--}catch(o){throw i=!1,this._commandExecutingLevel=0,o}return i}_syncExecute(e,s,r){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(0,this._commandExecutingLevel))}executing command "${e.id}".`),this._commandExecutingLevel++;let i;try{if(i=this._injector.invoke(e.handler,s,r),i instanceof Promise)throw new TypeError("[CommandService]: Command handler should not return a promise.");this._commandExecutingLevel--}catch(o){throw i=!1,this._commandExecutingLevel=0,o}return i}},u.CommandService=al([Jr(0,ct.Inject(ct.Injector)),Jr(1,Ee)],u.CommandService);class ul{constructor(n){_(this,"name");_(this,"multi",!0);_(this,"type",0);_(this,"priority",0);_(this,"_implementations",[]);_(this,"handler",async(n,e)=>{if(!this._implementations.length)return!1;const s=n.get(Ee),r=n.get(Ye),i=n.get(ct.Injector);for(const o of this._implementations){const a=o.command.preconditions;if((!a||a&&a(r))&&(s.debug("[MultiCommand]",`executing implementation "${o.command.name}".`),await i.invoke(o.command.handler,e)))return!0}return!1});this.id=n,this.name=n}registerImplementation(n){const e={command:n};return this._implementations.push(e),this._implementations.sort((s,r)=>r.command.priority-s.command.priority),At(()=>{var r;const s=this._implementations.indexOf(e);this._implementations.splice(s,1),(r=n.onDispose)==null||r.call(n)})}hasImplementations(){return this._implementations.length>0}}function qn(t,n,e){const s=t.map(r=>()=>n.syncExecuteCommand(r.id,r.params,e));return zr(s)}function cl(t,n,e){const s=t.map(r=>()=>n.executeCommand(r.id,r.params,e));return Yr(s)}function ti(t){return new B.Observable(n=>{const e=t((...s)=>n.next(s));return()=>e==null?void 0:e.dispose()})}function ei(t){return function(e){return new B.Observable(s=>(e.subscribe({next:r=>{s.next(r),t(r)&&s.complete()},complete:()=>s.complete(),error:r=>s.error(r)}),()=>s.unsubscribe()))}}const hl=t=>new Promise(n=>{B.merge(ti(t.onCommandExecuted.bind(t)).pipe(oe.filter(([e])=>e.type===ze.MUTATION)),B.timer(300)).pipe(oe.debounceTime(16),oe.first()).subscribe(()=>{n()})});var jt=(t=>(t[t.UNDEFINED=0]="UNDEFINED",t[t.OK=1]="OK",t[t.INTERNAL_ERROR=2]="INTERNAL_ERROR",t[t.PERMISSION_DENIED=3]="PERMISSION_DENIED",t[t.NOT_FOUND=4]="NOT_FOUND",t[t.UNAUTHENTICATED=5]="UNAUTHENTICATED",t[t.ALREADY_EXISTS=6]="ALREADY_EXISTS",t[t.INVALID_ARGUMENT=7]="INVALID_ARGUMENT",t[t.TOO_MANY_REQUESTS=8]="TOO_MANY_REQUESTS",t[t.COMPLETION_FINISHED=9]="COMPLETION_FINISHED",t[t.CHANGESET_REVISION_CONFILICT=5001]="CHANGESET_REVISION_CONFILICT",t[t.SNAPSHOT_INVALID_SNAPSHOT=6001]="SNAPSHOT_INVALID_SNAPSHOT",t[t.SNAPSHOT_HAS_BEEN_REMOVED=6002]="SNAPSHOT_HAS_BEEN_REMOVED",t[t.APPLY_REJECT=7001]="APPLY_REJECT",t[t.APPLY_NON_SEQUENTIAL_REVISION=7002]="APPLY_NON_SEQUENTIAL_REVISION",t[t.APPLY_REVISION_CONFILICT=7003]="APPLY_REVISION_CONFILICT",t[t.APPLY_PERMISSION_DENIED=7004]="APPLY_PERMISSION_DENIED",t[t.CONNECTOR_DATA_TOO_LARGE=8001]="CONNECTOR_DATA_TOO_LARGE",t[t.LICENSE_MAX_UNITS_EXCEEDED=9001]="LICENSE_MAX_UNITS_EXCEEDED",t[t.LICENSE_MAX_MEMBERS_PER_UNIT_EXCEEDED=9002]="LICENSE_MAX_MEMBERS_PER_UNIT_EXCEEDED",t[t.LICENSE_IMPORT_SIZE_EXCEEDED=9003]="LICENSE_IMPORT_SIZE_EXCEEDED",t[t.LICENSE_EXPORT_SIZE_EXCEEDED=9004]="LICENSE_EXPORT_SIZE_EXCEEDED",t[t.LICENSE_DISTRO_REJECTED=9005]="LICENSE_DISTRO_REJECTED",t[t.YUUMI_UNABLE_LOAD_URL=10001]="YUUMI_UNABLE_LOAD_URL",t[t.YUUMI_URL_COL_OUT_OF_RANGE=10002]="YUUMI_URL_COL_OUT_OF_RANGE",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(jt||{});function ni(t){return!!(t&&t.code&&t.code!==jt.OK&&t.code!=="OK")}var Q=(t=>(t[t.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",t[t.UNIVER_DOC=1]="UNIVER_DOC",t[t.UNIVER_SHEET=2]="UNIVER_SHEET",t[t.UNIVER_SLIDE=3]="UNIVER_SLIDE",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(Q||{}),si=(t=>(t[t.SomeCollaborator=0]="SomeCollaborator",t[t.AllCollaborator=1]="AllCollaborator",t[t.OneSelf=2]="OneSelf",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(si||{}),$t=(t=>(t[t.Reader=0]="Reader",t[t.Editor=1]="Editor",t[t.Owner=2]="Owner",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))($t||{}),Sn=(t=>(t[t.Unkonwn=0]="Unkonwn",t[t.Workbook=1]="Workbook",t[t.Worksheet=2]="Worksheet",t[t.SelectRange=3]="SelectRange",t[t.Document=4]="Document",t[t.Slide=5]="Slide",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(Sn||{});class On extends Mt{}class Zn{constructor(){_(this,"_data",[])}static create(){return new Zn}add(n){this._data.indexOf(n)>-1||this._data.push(n)}delete(n){const e=this._data.indexOf(n);this._data.splice(e,1)}getData(){return this._data}}class Jn{constructor(){_(this,"_data",new Map)}static create(){return new Jn}add(n,e){this._data.has(n)||this._data.set(n,e)}delete(n){this._data.delete(n)}getData(){return this._data}}var ri=(t=>(t[t.PARAGRAPH=0]="PARAGRAPH",t[t.SECTION_BREAK=1]="SECTION_BREAK",t[t.TABLE=2]="TABLE",t[t.TABLE_ROW=3]="TABLE_ROW",t[t.TABLE_CELL=4]="TABLE_CELL",t[t.CUSTOM_BLOCK=5]="CUSTOM_BLOCK",t))(ri||{}),ae=(t=>(t.PARAGRAPH="\r",t.SECTION_BREAK=`
|
|
5
|
+
`,t.TABLE_START="",t.TABLE_ROW_START="\x1B",t.TABLE_CELL_START="",t.TABLE_CELL_END="",t.TABLE_ROW_END="",t.TABLE_END="",t.CUSTOM_RANGE_START="",t.CUSTOM_RANGE_END="",t.COLUMN_BREAK="\v",t.PAGE_BREAK="\f",t.DOCS_END="\0",t.TAB=" ",t.CUSTOM_BLOCK="\b",t.LETTER="",t.SPACE=" ",t))(ae||{}),Nn=(t=>(t.BULLET_LIST="BULLET_LIST",t.ORDER_LIST="ORDER_LIST",t))(Nn||{});const dl={BULLET_LIST:{listType:"BULLET_LIST",nestingLevel:[{bulletAlignment:fe.START,glyphFormat:" %0",textStyle:{fs:12},startNumber:0,glyphSymbol:"●",hanging:21,indentStart:21},{bulletAlignment:fe.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"■",hanging:21,indentStart:42},{bulletAlignment:fe.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"◆",hanging:21,indentStart:63}]},ORDER_LIST:{listType:"ORDER_LIST",nestingLevel:[{bulletAlignment:fe.START,glyphFormat:" %1.",textStyle:{fs:12},startNumber:0,glyphType:Ve.DECIMAL,hanging:21,indentStart:21},{bulletAlignment:fe.START,glyphFormat:" %1.%2)",textStyle:{fs:12},startNumber:0,glyphType:Ve.DECIMAL,hanging:21,indentStart:42},{bulletAlignment:fe.START,glyphFormat:" %1.%2.%3.",textStyle:{fs:12},startNumber:0,glyphType:Ve.DECIMAL,hanging:21,indentStart:63}]}};function Qn(t){const n=[];for(const e of t){const{ed:s,ts:r}=e;if(e.sId===void 0&&delete e.sId,P.isEmptyObject(r)&&e.sId==null)continue;if(n.length===0){n.push(e);continue}const i=n.pop();Tr(e,i)&&P.hasIntersectionBetweenTwoRanges(i.st,i.ed,e.st,e.ed)?n.push({...e,st:i.st,ed:s}):n.push(i,e)}return n}function ii(t,n,e,s){var h;const{textRuns:r}=t;if(r==null)return;const i=[],o=r.length;let a=!1;const l=(h=n.textRuns)!=null?h:[];if(l.length)for(const d of l)d.st+=s,d.ed+=s;for(let d=0;d<o;d++){const c=r[d],f=r[d+1],{st:g,ed:E}=c;if(E<s)i.push(c);else if(s>=g&&s<=E){if(f&&f.st===f.ed&&s===f.st){i.push(c);continue}if(a)c.st+=e,c.ed+=e,i.push(c);else{a=!0,c.ed+=e;const R=[];if(l.length){const y={...c,st:g,ed:l[0].st};y.ed>y.st&&R.push(y),R.push(...l);const H=l[l.length-1],et={...c,st:H.ed,ed:E+e};et.ed>et.st&&R.push(et)}else R.push(c);i.push(...R)}}else c.st+=e,c.ed+=e,a||(a=!0,i.push(...l)),i.push(c)}a||(a=!0,i.push(...l)),t.textRuns=Qn(i)}function ts(t,n,e,s){const{paragraphs:r}=t;if(r==null)return;const{paragraphs:i,dataStream:o}=n,a=[];let l=-1;for(let d=0,c=r.length;d<c;d++){const f=r[d],{startIndex:g}=f;g>=s&&(f.startIndex+=e),l===-1&&g>=s&&(l=d),a.push(f.startIndex)}let h=-1;if(i){for(let d=0,c=i.length;d<c;d++){const f=i[d];f.startIndex+=s;const g=f.startIndex;h=a.indexOf(g)}if(o===ae.PARAGRAPH&&i.length===1){const d=r[l],c=i[0],f=d.paragraphStyle,g=d.bullet;d.paragraphStyle=c.paragraphStyle,d.bullet=c.bullet,c.paragraphStyle=f,c.bullet=g}h!==-1&&r.splice(h,1),r.push(...i),r.sort(Ae("startIndex"))}}function fl(t,n,e,s){const{sectionBreaks:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:h}=l;h>=s&&(l.startIndex+=e)}const i=n.sectionBreaks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=s}r.push(...i),r.sort(Ae("startIndex"))}}function oi(t,n,e,s){const{customBlocks:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:h}=l;h>=s&&(l.startIndex+=e)}const i=n.customBlocks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=s}r.push(...i),r.sort(Ae("startIndex"))}}function ai(t,n,e,s){const{tables:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:h,endIndex:d}=l;h>s?(l.startIndex+=e,l.endIndex+=e):d>=s-1&&(l.endIndex+=e)}const i=n.tables;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=s,l.endIndex+=s}r.push(...i),r.sort(Ae("startIndex"))}}function li(t,n,e,s){t.customRanges||(t.customRanges=[]);const{customRanges:r}=t,i={};for(let a=0,l=r.length;a<l;a++){const h=r[a];i[h.rangeId]=h;const{startIndex:d,endIndex:c}=h;d>=s?(h.startIndex+=e,h.endIndex+=e):c>s-1&&(h.endIndex+=e)}const o=[];if(n.customRanges){for(let a=0,l=n.customRanges.length;a<l;a++){const h=n.customRanges[a],d=i[h.rangeId];if(h.startIndex+=s,h.endIndex+=s,d){if(d.startIndex<=h.startIndex&&d.endIndex>=h.endIndex)continue;if(t.dataStream[d.startIndex]===ae.CUSTOM_RANGE_START&&t.dataStream[d.endIndex]===ae.CUSTOM_RANGE_END){o.push(h);continue}if(t.dataStream[d.startIndex]===ae.CUSTOM_RANGE_START){d.endIndex=h.endIndex;continue}if(t.dataStream[d.endIndex]===ae.CUSTOM_RANGE_END){d.startIndex=h.startIndex;continue}}o.push(h)}r.push(...o),r.sort(Ae("startIndex"))}}function gl(t){t.sort((s,r)=>s.startIndex-r.startIndex);const n=[];let e=t[0];for(let s=1;s<t.length;s++)e.endIndex+1>=t[s].startIndex?e.endIndex=Math.max(e.endIndex,t[s].endIndex):(n.push(e),e=t[s]);return n.push(e),n}function _l(t){const n={};for(let e=0,s=t.length;e<s;e++){const r=t[e],i=n[r.id];n[r.id]=[...i!=null?i:[],r]}return Object.keys(n).forEach(e=>{const s=n[e],r=gl(s);n[e]=r}),Object.values(n).flat()}function ui(t,n,e,s){t.customDecorations||(t.customDecorations=[]);const{customDecorations:r}=t;if(e>0)for(let i=0,o=r.length;i<o;i++){const a=r[i],{startIndex:l,endIndex:h}=a;l>=s?(a.startIndex+=e,a.endIndex+=e):h>s-1&&(a.endIndex+=e)}if(n.customDecorations){const i=[];for(let o=0,a=n.customDecorations.length;o<a;o++){const l=n.customDecorations[o];i.push(l),l.startIndex+=s,l.endIndex+=s}r.push(...i),t.customDecorations=_l(r),t.customDecorations.sort(Ae("startIndex"))}}function ci(t,n,e){var a;const{textRuns:s}=t,r=e,i=e+n,o=[];if(r===i&&(s!=null&&s.find(l=>l.st===e&&l.ed===e))){const l=s.find(h=>h.st===e&&h.ed===e);return o.push({...l,st:l.st-e,ed:l.ed-e}),t.textRuns=(a=t.textRuns)==null?void 0:a.filter(h=>h!==l),o}if(s){const l=[];for(let h=0,d=s.length;h<d;h++){const c=s[h],{st:f,ed:g}=c;if(r<=f&&i>=g){o.push({...c,st:f-r,ed:g-r});continue}else f<=r&&g>=i?(o.push({...c,st:r-r,ed:i-r}),c.ed-=n):r>=f&&r<g?(o.push({...c,st:r-r,ed:g-r}),c.ed=r):i>f&&i<=g?(o.push({...c,st:f-r,ed:i-r}),c.st=i-n,c.ed-=n):f>=i&&(c.st-=n,c.ed-=n);l.push(c)}t.textRuns=l}return o.length===0&&o.push({st:0,ed:n,ts:{}}),o}function hi(t,n,e){const{paragraphs:s}=t,r=e,i=e+n,o=[];if(s){const a=[];for(let l=0,h=s.length;l<h;l++){const d=s[l],{startIndex:c}=d;if(c>=r&&c<i){o.push({...d,startIndex:c-e});continue}else c>=i&&(d.startIndex-=n);a.push(d)}t.paragraphs=a}return o}function di(t,n,e){const{sectionBreaks:s}=t,r=e,i=e+n-1,o=[];if(s){const a=[];for(let l=0,h=s.length;l<h;l++){const d=s[l],{startIndex:c}=d;if(c>=r&&c<=i){o.push({...d,startIndex:c-e});continue}else c>i&&(d.startIndex-=n);a.push(d)}t.sectionBreaks=a}return o}function fi(t,n,e){const{customBlocks:s}=t,r=e,i=e+n-1,o=[];if(s){const a=[];for(let l=0,h=s.length;l<h;l++){const d=s[l],{startIndex:c}=d;if(c>=r&&c<=i){o.push({...d,startIndex:c-e});continue}else c>i&&(d.startIndex-=n);a.push(d)}t.customBlocks=a}return o}function gi(t,n,e){const{tables:s}=t,r=e,i=e+n-1,o=[];if(s){const a=[];for(let l=0,h=s.length;l<h;l++){const d=s[l],{startIndex:c,endIndex:f}=d;if(r<=c&&i>=f){o.push({...d,startIndex:c-e,endIndex:f-e});continue}else if(c<=r&&f>=i){const g=mn(c,f,r,i);d.startIndex=g[0],d.endIndex=g[1]}else i<c&&(d.startIndex-=n,d.endIndex-=n);a.push(d)}t.tables=a}return o}function _i(t,n,e){const{customRanges:s}=t,r=e,i=e+n-1,o=[];if(s){const a=[];for(let l=0,h=s.length;l<h;l++){const d=s[l],{startIndex:c,endIndex:f}=d;if(r<=c&&i>=c){o.push({...d,startIndex:c-e,endIndex:f-e});continue}else if(c<=r&&f>=i){const g=mn(c,f,r,i);d.startIndex=g[0],d.endIndex=g[1]}else i<c&&(d.startIndex-=n,d.endIndex-=n);a.push(d)}t.customRanges=a}return o}function mi(t,n,e,s=!0){const{customDecorations:r}=t,i=e,o=e+n-1,a=[];if(r){const l=[];for(let h=0,d=r.length;h<d;h++){const c=r[h],{startIndex:f,endIndex:g}=c;if(f>=i&&g<=o){a.push(c);continue}else if(Math.max(i,f)<=Math.min(o,g)){const E=mn(f,g,i,o);c.startIndex=E[0],c.endIndex=E[1]}else o<f&&s&&(c.startIndex-=n,c.endIndex-=n);l.push(c)}t.customDecorations=l}return a}function ml(t,n,e,s,r){const i=El(t,n,e,s,r),o=Rl(t,n,e,s,r),a=Cl(t,n,e,s,r),l=pl(t,n,e,s,r),h=Il(t,n,e,s,r),d=Sl(t,n,e,s,r),c=Ol(t,n,e,s,r);return{dataStream:"",textRuns:i,paragraphs:o,sectionBreaks:a,customBlocks:l,tables:h,customRanges:d,customDecorations:c}}function El(t,n,e,s,r){const{textRuns:i}=t,{textRuns:o}=n;if(i==null||o==null)return;const a=ci(t,e,s);if(r!==kt.REPLACE){const l=Ei(o,a,r);n.textRuns=l}return ii(t,n,e,s),a}function Ei(t,n,e){if(n.length===0)return t;t=P.deepClone(t),n=P.deepClone(n);const s=[],r=t.length,i=n.length;let o=0,a=0,l=null;function h(){return l?(s.push(l),l=null,!0):!1}for(;o<r&&a<i;){const{st:g,ed:E,ts:R}=t[o],{st:y,ed:H,ts:et,sId:Et}=n[a];let gt;if(e===kt.COVER?gt={...et,...R}:gt={...R,...et},E<y)h()||s.push(t[o]),o++;else if(H<g)h()||s.push(n[a]),a++;else{const C={st:Math.min(g,y),ed:Math.max(g,y),ts:g<y?{...R}:{...et},sId:g<y?void 0:Et};C.ed>C.st&&s.push(C),s.push({st:Math.max(g,y),ed:Math.min(E,H),ts:gt,sId:Et}),E<H?(o++,n[a].st=E,n[a].st===n[a].ed&&a++):(a++,t[o].st=H,t[o].st===t[o].ed&&o++);const O={st:Math.min(E,H),ed:Math.max(E,H),ts:E<H?{...et}:{...R},sId:E<H?Et:void 0};l=O.ed>O.st?O:null}}h();const d=s[s.length-1],c=t[r-1],f=n[i-1];return d.ed!==Math.max(c.ed,f.ed)&&(c.ed>f.ed?s.push(c):s.push(f)),Qn(s)}function Rl(t,n,e,s,r){const{paragraphs:i}=t,{paragraphs:o}=n;if(i==null||o==null)return;const a=hi(t,e,s);if(r!==kt.REPLACE){const l=[];for(const h of o){const{startIndex:d,paragraphStyle:c,bullet:f}=h;let g=[];for(const E of a){const{startIndex:R,paragraphStyle:y,bullet:H}=E;let et,Et;if(r===kt.COVER?(et={...y,...c},Et={listId:"",listType:Nn.BULLET_LIST,nestingLevel:0,textStyle:{},...H,...f}):(et={...c,...y},Et={listId:"",listType:Nn.BULLET_LIST,nestingLevel:0,textStyle:{},...f,...H}),d===R){g.push({startIndex:d,paragraphStyle:et,bullet:Et});break}}l.push(...g),g=[]}n.paragraphs=l}return ts(t,n,e,s),a}function Cl(t,n,e,s,r){const{sectionBreaks:i}=t,{sectionBreaks:o}=n;if(i==null||o==null)return;const a=di(t,e,s);if(r!==kt.REPLACE){const l=[];for(const h of o){const{startIndex:d}=h;let c=[];for(const f of a){const{startIndex:g}=f;if(d===g){r===kt.COVER?c.push({...f,...h}):c.push({...h,...f});break}}l.push(...c),c=[]}n.sectionBreaks=l}return ts(t,n,e,s),a}function pl(t,n,e,s,r){const{customBlocks:i}=t,{customBlocks:o}=n;if(i==null||o==null)return;const a=fi(t,e,s);if(r!==kt.REPLACE){const l=[];for(const h of o){const{startIndex:d}=h;let c=[];for(const f of a){const{startIndex:g}=f;if(d===g){r===kt.COVER?c.push({...f,...h}):c.push({...h,...f});break}}l.push(...c),c=[]}n.customBlocks=l}return oi(t,n,e,s),a}function Il(t,n,e,s,r){const{tables:i}=t,{tables:o}=n;if(i==null||o==null)return;const a=gi(t,e,s);if(r!==kt.REPLACE){const l=[];for(const h of o){const{startIndex:d,endIndex:c}=h;let f=[];for(const g of a){const{startIndex:E,endIndex:R}=g;if(E>=d&&R<=c){r===kt.COVER?f.push({...g,...h}):f.push({...h,...g});break}}l.push(...f),f=[]}n.tables=l}return ai(t,n,e,s),a}function Sl(t,n,e,s,r){t.customRanges||(t.customRanges=[]);const{customRanges:i}=t,{customRanges:o}=n;if(i==null||o==null)return;let a=[];return r===kt.REPLACE&&(a=_i(t,e,s)),li(t,n,0,s),a}function Ol(t,n,e,s,r){t.customDecorations||(t.customDecorations=[]);let i=[];return r===kt.REPLACE&&(i=mi(t,e,s,!1)),ui(t,n,0,s),i}function qe(t,n,e,s=!1){const{dataStream:r,textRuns:i=[],paragraphs:o=[],customBlocks:a=[]}=t,l={dataStream:r.slice(n,e)},h=[];for(const g of i){const E=P.deepClone(g),{st:R,ed:y}=E;P.hasIntersectionBetweenTwoRanges(R,y,n,e)&&(n>=R&&n<=y?h.push({...E,st:n,ed:Math.min(e,y)}):e>=R&&e<=y?h.push({...E,st:Math.max(n,R),ed:e}):h.push(E))}h.length?l.textRuns=h.map(g=>{const{st:E,ed:R}=g;return{...g,st:E-n,ed:R-n}}):s&&(l.textRuns=[{st:0,ed:e-n,ts:{}}]);const d=[];for(const g of o){const{startIndex:E}=g;E>=n&&E<=e&&d.push(P.deepClone(g))}d.length&&(l.paragraphs=d.map(g=>({...g,startIndex:g.startIndex-n}))),l.customDecorations=Ci(t,n,e);const{customRanges:c}=Ri(t,n,e);l.customRanges=c;const f=[];for(const g of a){const{startIndex:E}=g;E>=n&&E<=e&&f.push(P.deepClone(g))}return f.length&&(l.customBlocks=f.map(g=>({...g,startIndex:g.startIndex-n}))),l}function Nl(t){const{dataStream:n,textRuns:e,paragraphs:s,customRanges:r,customDecorations:i}=t;let o=0,a=0;r==null||r.forEach(h=>{h.startIndex<0&&(o=Math.max(o,-h.startIndex)),h.endIndex>n.length-1&&(a=Math.max(a,h.endIndex-n.length+1))});const l=`${ae.CUSTOM_RANGE_START.repeat(o)}${n}${ae.CUSTOM_RANGE_END.repeat(a)}`;return e&&(e[0]&&(e[0].st=e[0].st-o),e[e.length-1]&&(e[e.length-1].ed=e[e.length-1].ed+a)),e==null||e.forEach(h=>{h.st+=o,h.ed+=o}),s==null||s.forEach(h=>{h.startIndex+=o}),r==null||r.forEach(h=>{h.startIndex+=o,h.endIndex+=o}),i==null||i.forEach(h=>{h.startIndex+=o,h.endIndex+=a}),{...t,dataStream:l,textRuns:e,paragraphs:s,customRanges:r,customDecorations:i}}function Ri(t,n,e){const{customRanges:s=[]}=t;let r=0,i=0;const o=s.filter(a=>Math.max(a.startIndex,n)<=Math.min(a.endIndex,e-1)).map(a=>({...a,startIndex:a.startIndex,endIndex:a.endIndex}));if(o.length){o.forEach(a=>{a.startIndex<n&&(r+=1),a.endIndex>e-1&&(i+=1)});for(let a=0;a<r;a++){const l=o[a];l.startIndex=n-r+a}if(i){const a=[...o].sort((l,h)=>h.endIndex-l.endIndex);for(let l=0;l<i;l++){const h=a[l];h.endIndex=e+i-l-1}}}return{customRanges:o.map(a=>({...a,startIndex:a.startIndex-n,endIndex:a.endIndex-n})),leftOffset:r,rightOffset:i}}function Ci(t,n,e){const{customDecorations:s=[]}=t,r=[];return s.forEach(i=>{if(Math.max(i.startIndex,n)<=Math.min(i.endIndex,e-1)){const o=P.deepClone(i);r.push({...o,startIndex:Math.max(o.startIndex-n,0),endIndex:Math.min(o.endIndex,e)-n})}}),r}function es(t,n,e=kt.COVER){if(n.dataStream!=="")throw new Error("Cannot compose other body with non-empty dataStream");const s={dataStream:t.dataStream},{textRuns:r=[],paragraphs:i=[]}=t,{textRuns:o=[],paragraphs:a=[]}=n,l=Ei(o,r,e);l.length&&(s.textRuns=l);const h=[];let d=0,c=0;for(;d<i.length&&c<a.length;){const f=i[d],g=a[c],{startIndex:E}=f,{startIndex:R}=g;E===R?(h.push(P.deepMerge(f,g)),d++,c++):E<R?(h.push(P.deepClone(f)),d++):(h.push(P.deepClone(g)),c++)}return d<i.length&&h.push(...i.slice(d)),c<a.length&&h.push(...a.slice(c)),h.length&&(s.paragraphs=h),s}function Al(t){const{body:n}=t;if(n==null)return!0;const{textRuns:e=[],paragraphs:s=[]}=n;return e.length===0&&s.length===0}function bl(t=P.generateRandomId(6),n=Ie.EN_US,e=""){return{id:t,locale:n,title:e,body:{dataStream:`\r
|
|
6
|
+
`,textRuns:[],paragraphs:[{startIndex:0,paragraphStyle:{spaceAbove:5,lineSpacing:1,spaceBelow:0}}],sectionBreaks:[{startIndex:1}]},documentStyle:{pageSize:{width:793.3333333333334,height:1122.6666666666667},marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}},settings:{}}}var Bt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function vl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Gt={},pi={},ns={};Object.defineProperty(ns,"__esModule",{value:!0});function wl(t,n){if(Array.isArray(n))return!1;for(let e in t)if(!ss(t[e],n[e]))return!1;for(let e in n)if(t[e]===void 0)return!1;return!0}function Tl(t,n){if(!Array.isArray(n)||t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(!ss(t[e],n[e]))return!1;return!0}function ss(t,n){return t===n?!0:t===null||n===null||typeof t!="object"||typeof n!="object"?!1:Array.isArray(t)?Tl(t,n):wl(t,n)}ns.default=ss;var rs={};Object.defineProperty(rs,"__esModule",{value:!0});function is(t){if(t===null)return null;if(Array.isArray(t))return t.map(is);if(typeof t=="object"){const n={};for(let e in t)n[e]=is(t[e]);return n}else return t}rs.default=is;var os={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.eachChildOf=t.advancer=t.readCursor=t.writeCursor=t.WriteCursor=t.ReadCursor=t.isValidPathItem=void 0;function n(d,c){if(!d)throw new Error(c)}const e=d=>d!=null&&typeof d=="object"&&!Array.isArray(d),s=(d,c)=>typeof d==typeof c?d>c:typeof d=="string"&&typeof c=="number";function r(d,c){for(let f in d){const g=f;c.write(g,d[g])}}t.isValidPathItem=d=>typeof d=="number"||typeof d=="string"&&d!=="__proto__";class i{constructor(c=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=c}ascend(){n(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):(n(this.idx>0),this.idx--,e(this.container[this.idx])&&this.idx--)}getPath(){const c=[];let f=this.container,g=this.parents.length-1,E=this.idx;for(;E>=0;)c.unshift(f[E]),E===0?(E=this.indexes[g*2],f=this.parents[g--]):E-=e(f[E-1])?2:1;return c}}class o extends i{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return n(this.container!=null,"Invalid call to getKey before cursor descended"),this.container[this.idx]}getComponent(){let c;return this.container&&this.container.length>this.idx+1&&e(c=this.container[this.idx+1])?c:null}descendFirst(){let c=this.idx+1;if(!this.container||c>=this.container.length||e(this.container[c])&&c+1>=this.container.length)return!1;e(this.container[c])&&c++;const f=this.container[c];return Array.isArray(f)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(c),this.idx=0,this.container=f):this.idx=c,!0}nextSibling(){if(n(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;const c=this.indexes[this.indexes.length-1]+1,f=this.parents[this.parents.length-1];return c>=f.length?!1:(n(!isNaN(c)),this.indexes[this.indexes.length-1]=c,this.container=f[c],!0)}_init(c,f,g,E){this.container=c,this.idx=f,this.parents=g.slice(),this.indexes=E.slice()}clone(){const c=new o;return c._init(this.container,this.idx,this.parents,this.indexes),c}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(c,f){const g=this.getComponent();g&&f(g,c);for(const E of this)c&&c.descend(E),this.traverse(c,f),c&&c.ascend()}eachPick(c,f){this.traverse(c,(g,E)=>{g.p!=null&&f(g.p,E)})}eachDrop(c,f){this.traverse(c,(g,E)=>{g.d!=null&&f(g.d,E)})}}t.ReadCursor=o;class a extends i{constructor(c=null){super(c),this.pendingDescent=[],this._op=c}flushDescent(){n(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let c=0;c<this.pendingDescent.length;c++){const f=this.pendingDescent[c];let g=this.idx+1;if(g<this.container.length&&e(this.container[g])&&g++,n(g===this.container.length||!e(this.container[g])),g===this.container.length)this.container.push(f),this.idx=g;else if(this.container[g]===f)this.idx=g;else{if(!Array.isArray(this.container[g])){const E=this.container.splice(g,this.container.length-g);this.container.push(E),this.lcIdx>-1&&(this.lcIdx=g)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(n(s(f,this.container[this.lcIdx][0])),g=this.lcIdx+1,this.lcIdx=-1);g<this.container.length&&s(f,this.container[g][0]);)g++;if(this.indexes.push(g),this.idx=0,g<this.container.length&&this.container[g][0]===f)this.container=this.container[g];else{const E=[f];this.container.splice(g,0,E),this.container=E}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();const c=this.idx+1;if(c<this.container.length&&e(this.container[c]))return this.container[c];{const f={};return this.container.splice(c,0,f),f}}write(c,f){const g=this.getComponent();n(g[c]==null||g[c]===f,"Internal consistency error: Overwritten component. File a bug"),g[c]=f}get(){return this._op}descend(c){if(!t.isValidPathItem(c))throw Error("Invalid JSON key");this.pendingDescent.push(c)}descendPath(c){return this.pendingDescent.push(...c),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(c,f=r){if(c===null)return;if(n(Array.isArray(c)),c===this._op)throw Error("Cannot merge into my own tree");const g=this.lcIdx,E=this.parents.length;let R=0;for(let y=0;y<c.length;y++){const H=c[y];typeof H=="string"||typeof H=="number"?(R++,this.descend(H)):Array.isArray(H)?this.mergeTree(H,f):typeof H=="object"&&f(H,this)}for(;R--;)this.ascend();this.lcIdx=this.parents.length===E?g:-1}at(c,f){this.descendPath(c),f(this);for(let g=0;g<c.length;g++)this.ascend();return this}writeAtPath(c,f,g){return this.at(c,()=>this.write(f,g)),this.reset(),this}writeMove(c,f,g=0){return this.writeAtPath(c,"p",g).writeAtPath(f,"d",g)}getPath(){const c=super.getPath();return c.push(...this.pendingDescent),c}}t.WriteCursor=a,t.writeCursor=()=>new a,t.readCursor=d=>new o(d);function l(d,c,f){let g,E;E=g=d?d.descendFirst():!1;function R(y){let H;for(;E;){const et=H=d.getKey();if(y!=null){let Et=!1;if(c&&typeof et=="number"&&(H=c(et,d.getComponent()),H<0&&(H=~H,Et=!0)),s(H,y))return null;if(H===y&&!Et)return d}f&&typeof H=="number"&&f(H,d.getComponent()),E=d.nextSibling()}return null}return R.end=()=>{g&&d.ascend()},R}t.advancer=l;function h(d,c,f){let g,E,R,y;for(g=E=d&&d.descendFirst(),R=y=c&&c.descendFirst();g||R;){let H=g?d.getKey():null,et=R?c.getKey():null;H!==null&&et!==null&&(s(et,H)?et=null:H!==et&&(H=null)),f(H==null?et:H,H!=null?d:null,et!=null?c:null),H!=null&&g&&(g=d.nextSibling()),et!=null&&R&&(R=c.nextSibling())}E&&d.ascend(),y&&c.ascend()}t.eachChildOf=h})(os);var as={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ConflictType=void 0,function(n){n[n.RM_UNEXPECTED_CONTENT=1]="RM_UNEXPECTED_CONTENT",n[n.DROP_COLLISION=2]="DROP_COLLISION",n[n.BLACKHOLE=3]="BLACKHOLE"}(t.ConflictType||(t.ConflictType={}))})(as);var ls={},be={},Ii;function us(){return Ii||(Ii=1,Object.defineProperty(be,"__esModule",{value:!0}),be.uniToStrPos=be.strPosToUni=void 0,be.strPosToUni=(t,n=t.length)=>{let e=0,s=0;for(;s<n;s++){const r=t.charCodeAt(s);r>=55296&&r<=57343&&(e++,s++)}if(s!==n)throw Error("Invalid offset - splits unicode bytes");return s-e},be.uniToStrPos=(t,n)=>{let e=0;for(;n>0;n--){const s=t.charCodeAt(e);e+=s>=55296&&s<=57343?2:1}return e}),be}var cs={},Si;function hs(){return Si||(Si=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.uniSlice=t.dlen=t.eachOp=void 0;const n=us(),e=C=>{if(!Array.isArray(C))throw Error("Op must be an array of components");let O=null;for(let w=0;w<C.length;w++){const q=C[w];switch(typeof q){case"object":if(typeof q.d!="number"&&typeof q.d!="string")throw Error("Delete must be number or string");if(t.dlen(q.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(q.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(q>0))throw Error("Skip components must be >0");if(typeof O=="number")throw Error("Adjacent skip components should be combined");break}O=q}if(typeof O=="number")throw Error("Op has a trailing skip")};function s(C,O){let w=0,q=0;for(let st=0;st<C.length;st++){const Z=C[st];switch(O(Z,w,q),typeof Z){case"object":w+=t.dlen(Z.d);break;case"string":q+=n.strPosToUni(Z);break;case"number":w+=Z,q+=Z;break}}}t.eachOp=s;function r(C,O){const w=[],q=a(w);return s(C,(st,Z,Yt)=>{q(O(st,Z,Yt))}),c(w)}const i=C=>C,o=C=>r(C,i);t.dlen=C=>typeof C=="number"?C:n.strPosToUni(C);const a=C=>O=>{if(!(!O||O.d===0||O.d===""))if(C.length===0)C.push(O);else if(typeof O==typeof C[C.length-1])if(typeof O=="object"){const w=C[C.length-1];w.d=typeof w.d=="string"&&typeof O.d=="string"?w.d+O.d:t.dlen(w.d)+t.dlen(O.d)}else C[C.length-1]+=O;else C.push(O)},l=C=>typeof C=="number"?C:typeof C=="string"?n.strPosToUni(C):typeof C.d=="number"?C.d:n.strPosToUni(C.d);t.uniSlice=(C,O,w)=>{const q=n.uniToStrPos(C,O),st=w==null?1/0:n.uniToStrPos(C,w);return C.slice(q,st)};const h=(C,O,w)=>typeof C=="number"?w==null?C-O:Math.min(C,w)-O:t.uniSlice(C,O,w),d=C=>{let O=0,w=0;return{take:(Z,Yt)=>{if(O===C.length)return Z===-1?null:Z;const bt=C[O];let _t;if(typeof bt=="number")return Z===-1||bt-w<=Z?(_t=bt-w,++O,w=0,_t):(w+=Z,Z);if(typeof bt=="string"){if(Z===-1||Yt==="i"||n.strPosToUni(bt.slice(w))<=Z)return _t=bt.slice(w),++O,w=0,_t;{const St=w+n.uniToStrPos(bt.slice(w),Z);return _t=bt.slice(w,St),w=St,_t}}else{if(Z===-1||Yt==="d"||t.dlen(bt.d)-w<=Z)return _t={d:h(bt.d,w)},++O,w=0,_t;{let St=h(bt.d,w,w+Z);return w+=Z,{d:St}}}},peek:()=>C[O]}},c=C=>(C.length>0&&typeof C[C.length-1]=="number"&&C.pop(),C);function f(C,O,w){if(w!=="left"&&w!=="right")throw Error("side ("+w+") must be 'left' or 'right'");e(C),e(O);const q=[],st=a(q),{take:Z,peek:Yt}=d(C);for(let _t=0;_t<O.length;_t++){const St=O[_t];let Lt,zt;switch(typeof St){case"number":for(Lt=St;Lt>0;)zt=Z(Lt,"i"),st(zt),typeof zt!="string"&&(Lt-=l(zt));break;case"string":w==="left"&&typeof Yt()=="string"&&st(Z(-1)),st(n.strPosToUni(St));break;case"object":for(Lt=t.dlen(St.d);Lt>0;)switch(zt=Z(Lt,"i"),typeof zt){case"number":Lt-=zt;break;case"string":st(zt);break;case"object":Lt-=t.dlen(zt.d)}break}}let bt;for(;bt=Z(-1);)st(bt);return c(q)}function g(C,O){e(C),e(O);const w=[],q=a(w),{take:st}=d(C);for(let Yt=0;Yt<O.length;Yt++){const bt=O[Yt];let _t,St;switch(typeof bt){case"number":for(_t=bt;_t>0;)St=st(_t,"d"),q(St),typeof St!="object"&&(_t-=l(St));break;case"string":q(bt);break;case"object":_t=t.dlen(bt.d);let Lt=0;for(;Lt<_t;)switch(St=st(_t-Lt,"d"),typeof St){case"number":q({d:h(bt.d,Lt,Lt+St)}),Lt+=St;break;case"string":Lt+=n.strPosToUni(St);break;case"object":q(St)}break}}let Z;for(;Z=st(-1);)q(Z);return c(w)}const E=(C,O)=>{let w=0;for(let q=0;q<O.length&&C>w;q++){const st=O[q];switch(typeof st){case"number":{w+=st;break}case"string":const Z=n.strPosToUni(st);w+=Z,C+=Z;break;case"object":C-=Math.min(t.dlen(st.d),C-w);break}}return C},R=(C,O)=>typeof C=="number"?E(C,O):C.map(w=>E(w,O));function y(C,O,w){return r(C,(q,st)=>typeof q=="object"&&typeof q.d=="number"?{d:w.slice(O,st,st+q.d)}:q)}function H(C){return r(C,O=>{switch(typeof O){case"object":if(typeof O.d=="number")throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");return O.d;case"string":return{d:O};case"number":return O}})}function et(C){return r(C,O=>typeof O=="object"&&typeof O.d=="string"?{d:n.strPosToUni(O.d)}:O)}function Et(C){let O=!0;return s(C,w=>{typeof w=="object"&&typeof w.d=="number"&&(O=!1)}),O}function gt(C){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:c,normalize:o,checkOp:e,create(O=""){if(typeof O!="string")throw Error("Initial data must be a string");return C.create(O)},apply(O,w){e(w);const q=C.builder(O);for(let st=0;st<w.length;st++){const Z=w[st];switch(typeof Z){case"number":q.skip(Z);break;case"string":q.append(Z);break;case"object":q.del(t.dlen(Z.d));break}}return q.build()},transform:f,compose:g,transformPosition:E,transformSelection:R,isInvertible:Et,makeInvertible(O,w){return y(O,w,C)},stripInvertible:et,invert:H,invertWithDoc(O,w){return H(y(O,w,C))},isNoop:O=>O.length===0}}t.default=gt}(cs)),cs}var An={},Oi;function Ml(){if(Oi)return An;Oi=1,Object.defineProperty(An,"__esModule",{value:!0});const t=hs(),n=us();function e(s,r){return{get:s,getLength(){return s().length},insert(i,o,a){const l=n.strPosToUni(s(),i);return r([l,o],a)},remove(i,o,a){const l=n.strPosToUni(s(),i);return r([l,{d:o}],a)},_onOp(i){t.eachOp(i,(o,a,l)=>{switch(typeof o){case"string":this.onInsert&&this.onInsert(l,o);break;case"object":const h=t.dlen(o.d);this.onRemove&&this.onRemove(l,h)}})},onInsert:null,onRemove:null}}return An.default=e,e.provides={text:!0},An}var Ni;function Ul(){return Ni||(Ni=1,function(t){var n=Bt&&Bt.__createBinding||(Object.create?function(f,g,E,R){R===void 0&&(R=E),Object.defineProperty(f,R,{enumerable:!0,get:function(){return g[E]}})}:function(f,g,E,R){R===void 0&&(R=E),f[R]=g[E]}),e=Bt&&Bt.__setModuleDefault||(Object.create?function(f,g){Object.defineProperty(f,"default",{enumerable:!0,value:g})}:function(f,g){f.default=g}),s=Bt&&Bt.__importStar||function(f){if(f&&f.__esModule)return f;var g={};if(f!=null)for(var E in f)Object.hasOwnProperty.call(f,E)&&n(g,f,E);return e(g,f),g},r=Bt&&Bt.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(t,"__esModule",{value:!0}),t.type=t.remove=t.insert=void 0;const i=us(),o=s(hs()),a=r(Ml()),l={create(f){return f},toString(f){return f},builder(f){if(typeof f!="string")throw Error("Invalid document snapshot: "+f);const g=[];return{skip(E){let R=i.uniToStrPos(f,E);if(R>f.length)throw Error("The op is too long for this document");g.push(f.slice(0,R)),f=f.slice(R)},append(E){g.push(E)},del(E){f=f.slice(i.uniToStrPos(f,E))},build(){return g.join("")+f}}},slice:o.uniSlice},h=o.default(l),d=Object.assign(Object.assign({},h),{api:a.default});t.type=d,t.insert=(f,g)=>g.length===0?[]:f===0?[g]:[f,g],t.remove=(f,g)=>o.dlen(g)===0?[]:f===0?[{d:g}]:[f,{d:g}];var c=hs();Object.defineProperty(t,"makeType",{enumerable:!0,get:function(){return c.default}})}(ls)),ls}(function(t){var n=Bt&&Bt.__importDefault||function(m){return m&&m.__esModule?m:{default:m}};Object.defineProperty(t,"__esModule",{value:!0}),t.editOp=t.replaceOp=t.insertOp=t.moveOp=t.removeOp=t.type=void 0;const e=n(ns),s=n(rs),r=os,i=as;function o(m,p){if(!m)throw new Error(p)}t.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:r.readCursor,writeCursor:r.writeCursor,create:m=>m,isNoop:m=>m==null,setDebug(m){},registerSubtype:H,checkValidOp:st,normalize:Z,apply:Yt,transformPosition:bt,compose:_t,tryTransform:vs,transform:hc,makeInvertible:zt,invert:St,invertWithDoc:cc,RM_UNEXPECTED_CONTENT:i.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:i.ConflictType.DROP_COLLISION,BLACKHOLE:i.ConflictType.BLACKHOLE,transformNoConflict:(m,p,A)=>bo(()=>!0,m,p,A),typeAllowingConflictsPred:m=>Object.assign(Object.assign({},t.type),{transform:(p,A,U)=>bo(m,p,A,U)})};const a=m=>m?m.getComponent():null;function l(m){return m&&typeof m=="object"&&!Array.isArray(m)}const h=m=>Array.isArray(m)?m.slice():m!==null&&typeof m=="object"?Object.assign({},m):m,d=m=>m&&(m.p!=null||m.r!==void 0),c=m=>m&&(m.d!=null||m.i!==void 0);function f(m,p){return o(m!=null),typeof p=="number"?(o(Array.isArray(m),"Invalid key - child is not an array"),(m=m.slice()).splice(p,1)):(o(l(m),"Invalid key - child is not an object"),delete(m=Object.assign({},m))[p]),m}function g(m,p,A){return typeof p=="number"?(o(m!=null,"Container is missing for key"),o(Array.isArray(m),"Cannot use numerical key for object container"),o(m.length>=p,"Cannot insert into out of bounds index"),m.splice(p,0,A)):(o(l(m),"Cannot insert into missing item"),o(m[p]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),m[p]=A),A}t.removeOp=(m,p=!0)=>r.writeCursor().writeAtPath(m,"r",p).get(),t.moveOp=(m,p)=>r.writeCursor().writeMove(m,p).get(),t.insertOp=(m,p)=>r.writeCursor().writeAtPath(m,"i",p).get(),t.replaceOp=(m,p,A)=>r.writeCursor().at(m,U=>{U.write("r",p),U.write("i",A)}).get(),t.editOp=(m,p,A,U=!1)=>r.writeCursor().at(m,b=>O(b,p,A,U)).get();const E=(m,p)=>m!=null&&(typeof p=="number"?Array.isArray(m):typeof m=="object"),R=(m,p)=>E(m,p)?m[p]:void 0,y={};function H(m){let p=m.type?m.type:m;p.name&&(y[p.name]=p),p.uri&&(y[p.uri]=p)}const et=m=>{const p=y[m];if(p)return p;throw Error("Missing type: "+m)};H(Ul());const Et=(m,p)=>m+p;H({name:"number",apply:Et,compose:Et,invert:m=>-m,transform:m=>m});const gt=m=>m==null?null:m.et?et(m.et):m.es?y["text-unicode"]:m.ena!=null?y.number:null,C=m=>m.es?m.es:m.ena!=null?m.ena:m.e,O=(m,p,A,U=!1)=>{const[b,M]=typeof p=="string"?[et(p),p]:[p,p.name];!U&&b.isNoop&&b.isNoop(A)||(M==="number"?m.write("ena",A):M==="text-unicode"?m.write("es",A):(m.write("et",M),m.write("e",A)))};function w(m){o(typeof m=="number"),o(m>=0),o(m===(0|m))}function q(m){typeof m=="number"?w(m):o(typeof m=="string")}function st(m){if(m===null)return;const p=new Set,A=new Set,U=M=>{let j=!0,x=!1;for(let I in M){const N=M[I];if(j=!1,o(I==="p"||I==="r"||I==="d"||I==="i"||I==="e"||I==="es"||I==="ena"||I==="et","Invalid component item '"+I+"'"),I==="p")w(N),o(!p.has(N)),p.add(N),o(M.r===void 0);else if(I==="d")w(N),o(!A.has(N)),A.add(N),o(M.i===void 0);else if(I==="e"||I==="es"||I==="ena"){o(!x),x=!0;const v=gt(M);o(v,"Missing type in edit"),v.checkValidOp&&v.checkValidOp(C(M))}}o(!j)},b=(M,j,x)=>{if(!Array.isArray(M))throw Error("Op must be null or a list");if(M.length===0)throw Error("Empty descent");j||q(M[0]);let I=1,N=0,v=0;for(let T=0;T<M.length;T++){const V=M[T];if(o(V!=null),Array.isArray(V)){const K=b(V,!1);if(N){const S=typeof v,W=typeof K;S===W?o(v<K,"descent keys are not in order"):o(S==="number"&&W==="string")}v=K,N++,I=3}else typeof V=="object"?(o(I===1,`Prev not scalar - instead ${I}`),U(V),I=2):(o(I!==3),q(V),o(r.isValidPathItem(V),"Invalid path key"),I=1)}return o(N!==1,"Operation makes multiple descents. Remove some []"),o(I===2||I===3),M[0]};b(m,!0),o(p.size===A.size,"Mismatched picks and drops in op");for(let M=0;M<p.size;M++)o(p.has(M)),o(A.has(M))}function Z(m){let p=0,A=[];const U=r.writeCursor();return U.mergeTree(m,(b,M)=>{const j=gt(b);if(j){const I=C(b);O(M,j,j.normalize?j.normalize(I):I)}for(const I of["r","p","i","d"])if(b[I]!==void 0){const N=I==="p"||I==="d"?(x=b[I],A[x]==null&&(A[x]=p++),A[x]):b[I];M.write(I,N)}var x}),U.get()}function Yt(m,p){if(st(p),p===null)return m;const A=[];return function U(b,M){let j=b,x=0,I={root:b},N=0,v=I,T="root";function V(){for(;N<x;N++){let K=M[N];typeof K!="object"&&(o(E(v,T)),v=v[T]=h(v[T]),T=K)}}for(;x<M.length;x++){const K=M[x];if(Array.isArray(K)){const S=U(j,K);S!==j&&S!==void 0&&(V(),j=v[T]=S)}else if(typeof K=="object"){K.d!=null?(V(),j=g(v,T,A[K.d])):K.i!==void 0&&(V(),j=g(v,T,K.i));const S=gt(K);if(S)V(),j=v[T]=S.apply(j,C(K));else if(K.e!==void 0)throw Error("Subtype "+K.et+" undefined")}else j=R(j,K)}return I.root}(m=function U(b,M){const j=[];let x=0;for(;x<M.length;x++){const T=M[x];if(Array.isArray(T))break;typeof T!="object"&&(j.push(b),b=R(b,T))}for(let T=M.length-1;T>=x;T--)b=U(b,M[T]);for(--x;x>=0;x--){const T=M[x];if(typeof T!="object"){const V=j.pop();b=b===R(V,T)?V:b===void 0?f(V,T):(N=T,v=b,(I=h(I=V))[N]=v,I)}else d(T)&&(o(b!==void 0,"Cannot pick up or remove undefined"),T.p!=null&&(A[T.p]=b),b=void 0)}var I,N,v;return b}(m,p),p)}function bt(m,p){m=m.slice(),st(p);const A=r.readCursor(p);let U,b,M=!1;const j=[];for(let I=0;;I++){const N=m[I],v=A.getComponent();if(v&&(v.r!==void 0?M=!0:v.p!=null&&(M=!1,U=v.p,b=I)),I>=m.length)break;let T=0;const V=r.advancer(A,void 0,(S,W)=>{d(W)&&T++});j.unshift(V);const K=V(N);if(typeof N=="number"&&(m[I]-=T),!K)break}if(j.forEach(I=>I.end()),M)return null;const x=()=>{let I=0;if(U!=null){const N=A.getPath();I=N.length,m=N.concat(m.slice(b))}for(;I<m.length;I++){const N=m[I],v=a(A),T=gt(v);if(T){const S=C(v);T.transformPosition&&(m[I]=T.transformPosition(m[I],S));break}let V=0;const K=r.advancer(A,(S,W)=>c(W)?~(S-V):S-V,(S,W)=>{c(W)&&V++})(N);if(typeof N=="number"&&(m[I]+=V),!K)break}};return U!=null?A.eachDrop(null,I=>{I===U&&x()}):x(),m}function _t(m,p){if(st(m),st(p),m==null)return p;if(p==null)return m;let A=0;const U=r.readCursor(m),b=r.readCursor(p),M=r.writeCursor(),j=[],x=[],I=[],N=[],v=[],T=[],V=new Set;U.traverse(null,S=>{S.p!=null&&(I[S.p]=U.clone())}),b.traverse(null,S=>{S.d!=null&&(N[S.d]=b.clone())});const K=r.writeCursor();return function S(W,mt,ut,J,Ct,ue,Ht,Dt){o(mt||ut);const pt=a(mt),Xt=a(ut),Qt=!!Xt&&Xt.r!==void 0,Te=!!pt&&pt.i!==void 0,qt=pt?pt.d:null,xt=Xt?Xt.p:null,ce=(ue||Qt)&&xt==null;if(xt!=null)J=N[xt],Ht=x[xt]=new r.WriteCursor;else if(Xt&&Xt.r!==void 0)J=null;else{const D=a(J);D&&D.d!=null&&(J=null)}const at=a(J);if(qt!=null)if(W=I[qt],Dt=j[qt]=new r.WriteCursor,ce)ue&&!Qt&&Dt.write("r",!0);else{const D=v[qt]=A++;Ht.write("d",D)}else if(pt&&pt.i!==void 0)W=null;else{const D=a(W);D&&D.p!=null&&(W=null)}let k;Te?(o(Ct===void 0),k=pt.i):k=Ct;const z=(xt==null?!Te||ue||Qt:k===void 0)?null:Ht.getComponent();if(xt!=null){if(!(Ct!==void 0||Te)){const D=qt!=null?v[qt]:A++;T[xt]=D,Dt.write("p",D)}}else Qt&&(Te||Ct!==void 0||(Xt.r,Dt.write("r",Xt.r)));const F=ce?null:gt(pt),L=gt(at);if((F||L)&&(F&&F.name,L&&L.name),F&&L){o(F===L);const D=C(pt),X=C(at),Tt=F.compose(D,X);O(Ht,F,Tt),V.add(at)}else F?O(Ht,F,C(pt)):L&&(O(Ht,L,C(at)),V.add(at));const $=typeof k=="object"&&k!=null;let rt=!1,it=0,lt=0,wt=0,vt=0,It=0;const Pt=r.advancer(J,(D,X)=>c(X)?vt-D-1:D-vt,(D,X)=>{c(X)&&vt++}),nt=r.advancer(W,(D,X)=>d(X)?it-D-1:D-it,(D,X)=>{d(X)&&it++});if(r.eachChildOf(mt,ut,(D,X,Tt)=>{let Ft,he,Me=D,te=D,rn=D;if(typeof D=="number"){let yt=D+wt;he=Pt(yt),te=yt+vt;let Ot=D+lt;Ft=nt(Ot),c(a(he))&&(Ft=null),Me=Ot+it,rn=D+It,o(Me>=0,"p1PickKey is negative"),o(te>=0,"p2DropKey is negative");const ee=c(a(X)),de=d(a(Tt));(ee||de&&!ce)&&It--,ee&<--,de&&wt--}else Ft=nt(D),he=Pt(D);Dt.descend(Me),Ht.descend(te);const $e=$&&!c(a(X))?k[rn]:void 0,re=S(Ft,X,Tt,he,$e,ce,Ht,Dt);var ie,G,Rt;$&&!ce?$e!==re&&(rt||(k=Array.isArray(k)?k.slice():Object.assign({},k),rt=!0),ie=k,Rt=re,typeof(G=rn)=="number"?(o(Array.isArray(ie)),o(G<ie.length)):(o(!Array.isArray(ie)),o(ie[G]!==void 0)),Rt===void 0?typeof G=="number"?ie.splice(G,1):delete ie[G]:ie[G]=Rt):o(re===void 0),Ht.ascend(),Dt.ascend()}),nt.end(),Pt.end(),z!=null)z.i=k;else if(!ue&&!Qt&&xt==null)return k}(U,U.clone(),b,b.clone(),void 0,!1,M,K),M.reset(),M.mergeTree(K.get()),M.reset(),M.get(),j.map(S=>S.get()),x.map(S=>S.get()),U.traverse(M,(S,W)=>{const mt=S.p;if(mt!=null){const ut=v[mt];ut!=null&&W.write("p",ut);const J=j[mt];J&&J.get(),J&&W.mergeTree(J.get())}else S.r!==void 0&&W.write("r",S.r)}),M.reset(),M.get(),b.traverse(M,(S,W)=>{const mt=S.d;if(mt!=null){const J=T[mt];J!=null&&W.write("d",J);const Ct=x[mt];Ct&&W.mergeTree(Ct.get())}else S.i!==void 0&&W.write("i",S.i);const ut=gt(S);ut&&!V.has(S)&&O(W,ut,C(S))}),M.get()}function St(m){if(m==null)return null;const p=new r.ReadCursor(m),A=new r.WriteCursor;let U;const b=[],M=[];return function j(x,I,N){const v=x.getComponent();let T,V=!1;if(v){v.p!=null&&(I.write("d",v.p),b[v.p]=x.clone()),v.r!==void 0&&I.write("i",v.r),v.d!=null&&(I.write("p",v.d),N=void 0),v.i!==void 0&&(N=T=v.i);const S=gt(v);S&&(N===void 0?(U||(U=new Set),U.add(v)):(C(v),N=S.apply(N,C(v)),V=!0))}let K=0;for(const S of x){I.descend(S);const W=typeof S=="number"?S-K:S,mt=R(N,W);c(x.getComponent())&&K++;const ut=j(x,I,mt);if(N!==void 0&&ut!==void 0){if(V||(V=!0,N=h(N)),!E(N,W))throw Error("Cannot modify child - invalid operation");N[W]=ut}I.ascend()}if(T===void 0)return V?N:void 0;I.write("r",N)}(p,A,void 0),U&&(A.reset(),function j(x,I,N){const v=I.getComponent();if(v){const S=v.d;if(S!=null&&(x=b[S],N=M[S]=r.writeCursor()),U.has(v)){const W=gt(v);if(!W.invert)throw Error(`Cannot invert subtype ${W.name}`);O(N,W,W.invert(C(v)))}}let T=0,V=0;const K=r.advancer(x,(S,W)=>d(W)?T-S-1:S-T,(S,W)=>{d(W)&&T++});for(const S of I)if(typeof S=="number"){const W=S-V,mt=K(W),ut=W+T;N.descend(ut),j(mt,I,N),c(I.getComponent())&&V++,N.ascend()}else N.descend(S),j(K(S),I,N),N.ascend();K.end()}(p.clone(),p,A),M.length&&(A.reset(),p.traverse(A,(j,x)=>{const I=j.p;if(I!=null){const N=M[I];N&&N.get(),N&&x.mergeTree(N.get())}}))),A.get()}const Lt=(m,p)=>m.some(A=>typeof A=="object"&&(Array.isArray(A)?Lt(A,p):p(A)));function zt(m,p){if(m==null||!Lt(m,I=>{var N;return I.r!==void 0||((N=gt(I))===null||N===void 0?void 0:N.makeInvertible)!=null}))return m;const A=new r.ReadCursor(m),U=new r.WriteCursor;let b=!1;const M=[],j=[],x=(I,N,v)=>{const T=I.getComponent();let V=!1;if(T){T.d!=null&&N.write("d",T.d),T.i!==void 0&&N.write("i",T.i);const S=T.p;if(S!=null&&(M[S]=I.clone(),o(v!==void 0,"Operation picks up at an invalid key"),j[S]=v,N.write("p",T.p)),T.r!==void 0&&v===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const W=gt(T);W&&(W.makeInvertible?b=!0:O(N,W,C(T),!0))}let K=0;for(const S of I){N.descend(S);const W=typeof S=="number"?S-K:S,mt=R(v,W),ut=x(I,N,mt);mt!==ut&&(V||(V=!0,v=h(v)),ut===void 0?(v=f(v,W),typeof S=="number"&&K++):v[W]=ut),N.ascend()}return T&&(T.r!==void 0?(N.write("r",s.default(v)),v=void 0):T.p!=null&&(v=void 0)),v};return x(A,U,p),U.get(),b&&(U.reset(),function I(N,v,T,V,K){const S=v.getComponent();if(S){S.i!==void 0?(V=S.i,K=!0):S.d!=null&&(V=j[S.d],N=M[S.d],K=!1,S.d);let J=gt(S);if(J&&J.makeInvertible){const Ct=C(S);O(T,J,J.makeInvertible(Ct,V),!0)}}let W=0,mt=0;const ut=r.advancer(N,(J,Ct)=>d(Ct)?W-J-1:J-W,(J,Ct)=>{d(Ct)&&W++});for(const J of v)if(typeof J=="number"){const Ct=J-mt,ue=ut(Ct),Ht=Ct+W,Dt=R(V,K?Ct:Ht);T.descend(J),I(ue,v,T,Dt,K),c(v.getComponent())&&mt++,T.ascend()}else{const Ct=R(V,J);T.descend(J),I(ut(J),v,T,Ct,K),T.ascend()}ut.end()}(A.clone(),A,U,p,!1)),U.get()}function cc(m,p){return St(zt(m,p))}const bs=m=>{if(m==null)return null;const p=m.slice();for(let A=0;A<m.length;A++){const U=p[A];Array.isArray(U)&&(p[A]=bs(U))}return p};function vs(m,p,A){o(A==="left"||A==="right","Direction must be left or right");const U=A==="left"?0:1;if(p==null)return{ok:!0,result:m};st(m),st(p);let b=null;const M=[],j=[],x=[],I=[],N=[],v=[],T=[],V=[],K=[],S=[],W=[],mt=[],ut=[],J=[],Ct=[];let ue=0;const Ht=r.readCursor(m),Dt=r.readCursor(p),pt=r.writeCursor();if(function at(k,z=null,F){const L=a(z);L&&(L.r!==void 0?F=z.clone():L.p!=null&&(F=null,v[L.p]=k.clone()));const $=k.getComponent();let rt;$&&(rt=$.p)!=null&&(N[rt]=z?z.clone():null,x[rt]=k.clone(),F&&(S[rt]=!0,K[rt]=F),L&&L.p!=null&&(J[rt]=L.p));const it=r.advancer(z);for(const lt of k)at(k,it(lt),F);it.end()}(Dt,Ht,null),function at(k,z,F,L,$){const rt=F.getComponent();let it,lt=!1;rt&&((it=rt.d)!=null?(I[it]=F.clone(),L!=null&&(Ct[L]==null&&(Ct[L]=[]),Ct[L].push(it)),k=N[it]||null,z=x[it]||null,S[it]?($&&(W[it]=!0),$=K[it]||null):!$||U!==1&&J[it]!=null||b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.removeOp($.getPath()),op2:t.moveOp(z.getPath(),F.getPath())}),lt=!0):rt.i!==void 0&&(k=z=null,lt=!0,$&&b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.removeOp($.getPath()),op2:t.insertOp(F.getPath(),rt.i)})));const wt=a(k);wt&&(wt.r!==void 0?$=k.clone():wt.p!=null&&(wt.p,L=wt.p,$=null));const vt=gt(rt);vt&&$&&b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.removeOp($.getPath()),op2:t.editOp(F.getPath(),vt,C(rt),!0)});let It=0,Pt=0;const nt=r.advancer(z,(X,Tt)=>d(Tt)?It-X-1:X-It,(X,Tt)=>{d(Tt)&&It++}),D=r.advancer(k);for(const X of F)if(typeof X=="number"){const Tt=X-Pt,Ft=nt(Tt);Pt+=+at(D(Tt+It),Ft,F,L,$)}else{const Tt=nt(X);at(D(X),Tt,F,L,$)}return nt.end(),D.end(),lt}(Ht,Dt,Dt.clone(),null,null),I.map(at=>at&&at.get()),b)return{ok:!1,conflict:b};W.map(at=>!!at);const Xt=[];let Qt=null;(function at(k,z,F,L,$){let rt=!1;const it=a(z);if(d(it)){const nt=it.p;nt!=null?(F=I[nt],L=mt[nt]=r.writeCursor(),rt=!0,$=null):(F=null,$=z.clone())}else c(a(F))&&(F=null);const lt=k.getComponent();if(lt){const nt=lt.p;nt!=null?($&&(V[nt]=$),Xt[nt]=$||U===1&&rt?null:L.getComponent(),M[nt]=k.clone(),F&&(T[nt]=F.clone())):lt.r!==void 0&&($||L.write("r",!0),($||rt)&&(Qt==null&&(Qt=new Set),Qt.add(lt)))}let wt=0,vt=0;const It=r.advancer(z,void 0,(nt,D)=>{d(D)&&wt++}),Pt=r.advancer(F,(nt,D)=>c(D)?~(nt-vt):nt-vt,(nt,D)=>{c(D)&&vt++});if(k)for(const nt of k)if(typeof nt=="string"){const D=It(nt),X=Pt(nt);L.descend(nt),at(k,D,X,L,$),L.ascend()}else{const D=It(nt),X=nt-wt,Tt=d(a(D))?null:Pt(X),Ft=X+vt;o(Ft>=0),L.descend(Ft),at(k,D,Tt,L,$),L.ascend()}It.end(),Pt.end()})(Ht,Dt,Dt.clone(),pt,null),pt.reset();let Te=[];if(function at(k,z,F,L,$,rt){o(z);const it=z.getComponent();let lt=a(L),wt=!1;const vt=(G,Rt,yt)=>G?t.moveOp(G.getPath(),Rt.getPath()):t.insertOp(Rt.getPath(),yt.i);if(c(it)){const G=it.d;G!=null&&(j[G]=z.clone());const Rt=G!=null?Xt[G]:null;let yt=!1;if(it.i!==void 0||G!=null&&Rt){let Ot;lt&&(lt.i!==void 0||(Ot=lt.d)!=null&&!S[Ot])&&(yt=Ot!=null?G!=null&&G===J[Ot]:e.default(lt.i,it.i),yt||Ot!=null&&U!==1&&J[Ot]!=null||b==null&&(b={type:i.ConflictType.DROP_COLLISION,op1:vt(G!=null?M[G]:null,z,it),op2:vt(Ot!=null?x[Ot]:null,L,lt)})),yt||(rt?b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:vt(G!=null?M[G]:null,z,it),op2:t.removeOp(rt.getPath())}):(G!=null?(Te[ue]=G,$.write("d",Rt.p=ue++)):$.write("i",s.default(it.i)),wt=!0))}else if(G!=null&&!Rt){const Ot=V[G];Ot&&(rt=Ot.clone())}G!=null?(k=M[G],F=v[G],L=T[G]):it.i!==void 0&&(k=F=null,yt||(L=null))}else d(a(k))&&(k=F=L=null);const It=a(k),Pt=a(F);if(d(Pt)){const G=Pt.p;Pt.r!==void 0&&(!It||It.r===void 0)||S[G]?(L=null,rt=F.clone()):G!=null&&(L=I[G],U!==1&&J[G]!=null||(($=ut[G])||($=ut[G]=r.writeCursor()),$.reset(),rt=null))}else!c(it)&&c(lt)&&(L=null);lt=L!=null?L.getComponent():null;const nt=gt(it);if(nt){const G=C(it);if(rt)b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.editOp(z.getPath(),nt,G,!0),op2:t.removeOp(rt.getPath())});else{const Rt=gt(lt);let yt;if(Rt){if(nt!==Rt)throw Error("Transforming incompatible types");const Ot=C(lt);yt=nt.transform(G,Ot,A)}else yt=s.default(G);O($,nt,yt)}}let D=0,X=0,Tt=0,Ft=0,he=0,Me=0,te=k!=null&&k.descendFirst(),rn=te;const $e=r.advancer(F,void 0,(G,Rt)=>{d(Rt)&&Tt++});let re=L!=null&&L.descendFirst(),ie=re;for(const G of z)if(typeof G=="number"){let Rt;const yt=c(z.getComponent()),Ot=G-X;{let pe;for(;te&&typeof(pe=k.getKey())=="number";){pe+=D;const ne=k.getComponent(),Be=d(ne);if(pe>Ot||pe===Ot&&(!Be||U===0&&yt))break;if(Be){D--;const Ue=ne.p;J.includes(Ue),ne.d,a(ut[ne.d]),d(a(ut[ne.d])),(ne.r===void 0||Qt&&Qt.has(ne))&&(Ue==null||!Xt[Ue]||U!==1&&J.includes(Ue))||he--}te=k.nextSibling()}Rt=te&&pe===Ot?k:null}const ee=Ot-D;let de=$e(ee);const ws=ee-Tt;let kn=null;{let pe,ne;for(;re&&typeof(pe=L.getKey())=="number";){ne=pe-Ft;const Be=L.getComponent(),Ue=c(Be);if(ne>ws)break;if(ne===ws){if(!Ue){kn=L;break}{if(U===0&&yt){kn=L;break}const Le=de&&d(de.getComponent());if(U===0&&Le)break}}if(Ue){const Le=Be.d;J[Le],Be.i===void 0&&(S[Le]||J[Le]!=null&&U!==1)?(S[Le]||J[Le]!=null&&U===0)&&(Ft++,Me--):Ft++}re=L.nextSibling()}}const vo=ws+Ft+he+Me;o(vo>=0,"trying to descend to a negative index"),$.descend(vo),yt&&(Rt=de=kn=null,X++),at(Rt,z,de,kn,$,rt)&&Me++,$.ascend()}else{let Rt;for(;te&&(Rt=k.getKey(),typeof Rt!="string"||!(Rt>G||Rt===G));)te=k.nextSibling();const yt=te&&Rt===G?k:null,Ot=$e(G);let ee;for(;re&&(ee=L.getKey(),typeof ee!="string"||!(ee>G||ee===G));)re=L.nextSibling();const de=re&&ee===G?L:null;$.descend(G),at(yt,z,Ot,de,$,rt),$.ascend()}return $e.end(),rn&&k.ascend(),ie&&L.ascend(),wt}(Ht,Ht.clone(),Dt,Dt.clone(),pt,null),b)return{ok:!1,conflict:b};pt.reset();const qt=(at,k,z)=>at.traverse(k,(F,L)=>{F.d!=null&&z(F.d,at,L)});(S.length||mt.length)&&(qt(Dt,pt,(at,k,z)=>{S[at]&&!W[at]&&z.write("r",!0),mt[at]&&z.mergeTree(mt[at].get())}),pt.reset());const xt=[],ce=[];if((ut.length||S.length)&&!b){const at=r.readCursor(bs(pt.get()));if(qt(at,null,(k,z)=>{xt[k]=z.clone()}),ut.forEach(k=>{k&&qt(r.readCursor(k.get()),null,(z,F)=>{xt[z]=F.clone()})}),function k(z,F,L,$,rt,it){const lt=a(F);if(lt&&d(lt))if(lt.p!=null){const D=lt.p;xt[D].getPath(),L=xt[D],$=ce[D]=r.writeCursor()}else lt.r!==void 0&&(L=null);else c(a(L))&&(L=null);const wt=z.getComponent();if(wt){let D;if((D=wt.d)!=null){const X=ut[D];X&&(X.get(),$.mergeTree(X.get()),L=r.readCursor(X.get()))}}let vt=0,It=0;const Pt=r.advancer(F,void 0,(D,X)=>{d(X)&&vt--}),nt=r.advancer(L,(D,X)=>c(X)?-(D-It)-1:D-It,(D,X)=>{c(X)&&It++});for(const D of z)if(typeof D=="number"){const X=Pt(D),Tt=D+vt,Ft=nt(Tt),he=Tt+It;$.descend(he),k(z,X,Ft,$),$.ascend()}else $.descend(D),k(z,Pt(D),nt(D),$),$.ascend();Pt.end(),nt.end()}(Dt,at,at.clone(),pt),pt.reset(),b)return{ok:!1,conflict:b};if(pt.get(),ce.length){const k=ce.map(F=>F?F.get():null),z=r.readCursor(bs(pt.get()));if(qt(z,pt,(F,L,$)=>{const rt=k[F];rt&&($.mergeTree(rt),k[F]=null)}),k.find(F=>F)){const F=r.writeCursor(),L=r.writeCursor();let $=0,rt=0;k.forEach(it=>{it!=null&&qt(r.readCursor(it),null,lt=>{const wt=Te[lt];F.writeMove(M[wt].getPath(),j[wt].getPath(),$++);const vt=Ct[wt];vt&&vt.forEach(It=>{S[It]||U!==1&&J[It]!=null||L.writeMove(x[It].getPath(),I[It].getPath(),rt++)})})}),b={type:i.ConflictType.BLACKHOLE,op1:F.get(),op2:L.get()}}}}return b?{ok:!1,conflict:b}:{ok:!0,result:pt.get()}}const Ao=m=>{const p=new Error("Transform detected write conflict");throw p.conflict=m,p.type=p.name="writeConflict",p};function hc(m,p,A){const U=vs(m,p,A);if(U.ok)return U.result;Ao(U.conflict)}const We=m=>{const p=r.writeCursor();return r.readCursor(m).traverse(p,(A,U)=>{(c(A)||gt(A))&&U.write("r",!0)}),p.get()},dc=(m,p)=>{const{type:A,op1:U,op2:b}=m;switch(A){case i.ConflictType.DROP_COLLISION:return p==="left"?[null,We(b)]:[We(U),null];case i.ConflictType.RM_UNEXPECTED_CONTENT:let M=!1;return r.readCursor(U).traverse(null,j=>{j.r!==void 0&&(M=!0)}),M?[null,We(b)]:[We(U),null];case i.ConflictType.BLACKHOLE:return[We(U),We(b)];default:throw Error("Unrecognised conflict: "+A)}};function bo(m,p,A,U){let b=null;for(;;){const M=vs(p,A,U);if(M.ok)return _t(b,M.result);{const{conflict:j}=M;m(j)||Ao(j);const[x,I]=dc(j,U);p=_t(Z(p),x),A=_t(Z(A),I),b=_t(b,I)}}}})(pi),function(t){var n=Bt&&Bt.__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]}),e=Bt&&Bt.__exportStar||function(i,o){for(var a in i)a!=="default"&&!o.hasOwnProperty(a)&&n(o,i,a)};Object.defineProperty(t,"__esModule",{value:!0}),e(pi,t);var s=os;Object.defineProperty(t,"ReadCursor",{enumerable:!0,get:function(){return s.ReadCursor}}),Object.defineProperty(t,"WriteCursor",{enumerable:!0,get:function(){return s.WriteCursor}});var r=as;Object.defineProperty(t,"ConflictType",{enumerable:!0,get:function(){return r.ConflictType}})}(Gt);const Ll=wo({__proto__:null,default:vl(Gt)},[Gt]);var tt=(t=>(t.RETAIN="r",t.INSERT="i",t.DELETE="d",t))(tt||{});class ds{constructor(n){_(this,"_index",0);_(this,"_offset",0);this._actions=n}hasNext(){return this.peekLength()<Number.POSITIVE_INFINITY}next(n){n||(n=Number.POSITIVE_INFINITY);const e=this._actions[this._index];if(e){const s=this._offset,r=e.len;return n>=r-s?(n=r-s,this._index+=1,this._offset=0):this._offset+=n,e.t===tt.DELETE||e.t===tt.RETAIN&&e.body==null?P.deepClone({...e,len:n}):P.deepClone({...e,len:n,body:qe(e.body,s,s+n)})}else return{t:tt.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 n=this._actions[this._index];return n?n.t:tt.RETAIN}rest(){if(this.hasNext()){if(this._offset===0)return this._actions.slice(this._index);{const n=this._offset,e=this._index,s=this.next(),r=this._actions.slice(this._index);return this._offset=n,this._index=e,[s].concat(r)}}else return[]}}class Ai{constructor(){_(this,"cursor",0)}reset(){return this.cursor=0,this}moveCursor(n){this.cursor+=n}moveCursorTo(n){this.cursor=n}}function bi(t,n,e){const{dataStream:s}=t,r=e,i=e+n,o=ci(t,n,e),a=hi(t,n,e),l=di(t,n,e),h=fi(t,n,e),d=gi(t,n,e),c=_i(t,n,e),f=mi(t,n,e);let g="";return s&&(t.dataStream=Lr(s,r,i),g=s.slice(r,i)),{dataStream:g,textRuns:o,paragraphs:a,sectionBreaks:l,customBlocks:h,tables:d,customRanges:c,customDecorations:f}}function vi(t,n,e,s){t.dataStream=Ur(t.dataStream,s,n.dataStream),ii(t,n,e,s),ts(t,n,e,s),fl(t,n,e,s),oi(t,n,e,s),ai(t,n,e,s),li(t,n,e,s),ui(t,n,e,s)}function Dl(t,n,e,s,r=kt.COVER){return ml(t,n,e,s,r)}function yl(t,n,e){return n<=0?{dataStream:""}:bi(t,n,e)}function Pl(t,n,e,s){e!==0&&vi(t,n,e,s)}function kl(t,n){const e=new Ai;return e.reset(),n.forEach(s=>{switch(s=P.deepClone(s),s.t){case tt.RETAIN:{const{coverType:r,body:i,len:o}=s;i!=null&&Dl(t,i,o,e.cursor,r),e.moveCursor(o);break}case tt.INSERT:{const{body:r,len:i}=s;Pl(t,r,i,e.cursor),e.moveCursor(i);break}case tt.DELETE:{const{len:r}=s;yl(t,r,e.cursor);break}default:throw new Error(`Unknown action type for action: ${s}.`)}}),t}function wi(t){return Object.keys(t).length===1}const sn=class sn{constructor(){_(this,"_actions",[])}static apply(n,e){return kl(n,e)}static compose(n,e){const s=new ds(n),r=new ds(e),i=new sn;for(;s.hasNext()||r.hasNext();)if(r.peekType()===tt.INSERT)i.push(r.next());else if(s.peekType()===tt.DELETE)i.push(s.next());else{const o=Math.min(s.peekLength(),r.peekLength()),a=s.next(o),l=r.next(o);a.t===tt.INSERT&&l.t===tt.RETAIN?l.body==null?i.push(a):i.push({...a,body:es(a.body,l.body,l.coverType)}):a.t===tt.RETAIN&&l.t===tt.RETAIN?a.body==null&&l.body==null?i.push(a.len!==Number.POSITIVE_INFINITY?a:l):a.body&&l.body?i.push({...a,body:es(a.body,l.body,l.coverType)}):i.push(a.body?a:l):a.t===tt.RETAIN&&l.t===tt.DELETE?i.push(l):a.t===tt.INSERT&&(l.t,tt.DELETE)}return i.trimEndUselessRetainAction(),i.serialize()}static transform(n,e,s){throw new Error("transform is not implemented in TextX")}static isNoop(n){return n.length===0}static invert(n){const e=[];for(const s of n)if(s.t===tt.INSERT)e.push({t:tt.DELETE,len:s.len,line:0,body:s.body,segmentId:s.segmentId});else if(s.t===tt.DELETE){if(s.body==null)throw new Error("Can not invert DELETE action without body property, makeInvertible must be called first.");e.push({t:tt.INSERT,body:s.body,len:s.len,line:0,segmentId:s.segmentId})}else if(s.body!=null){if(s.oldBody==null)throw new Error("Can not invert RETAIN action without oldBody property, makeInvertible must be called first.");e.push({t:tt.RETAIN,body:s.oldBody,oldBody:s.body,len:s.len,coverType:kt.REPLACE,segmentId:s.segmentId})}else e.push(s);return e}static makeInvertible(n,e){const s=[];let r=0;for(const i of n){if(i.t===tt.DELETE&&i.body==null){const o=qe(e,r,r+i.len,!1);i.len=o.dataStream.length,i.body=o}if(i.t===tt.RETAIN&&i.body!=null){const o=qe(e,r,r+i.len,!0);i.oldBody={...o,dataStream:""},i.len=o.dataStream.length}s.push(i),i.t!==tt.INSERT&&(r+=i.len)}return s}insert(n,e,s=""){const r={t:tt.INSERT,body:e,len:n,line:0,segmentId:s};return this.push(r),this}retain(n,e="",s,r){const i={t:tt.RETAIN,len:n,segmentId:e};return s!=null&&(i.body=s),r!=null&&(i.coverType=r),this.push(i),this}delete(n,e=""){const s={t:tt.DELETE,len:n,line:0,segmentId:e};return this.push(s),this}serialize(){return this._actions}push(...n){if(n.length>1){for(const i of n)this.push(i);return this}let e=this._actions.length,s=this._actions[e-1];const r=P.deepClone(n[0]);if(r.t===tt.RETAIN&&r.len===0&&r.body==null)return this;if(typeof s=="object"){if(s.t===tt.DELETE&&r.t===tt.DELETE)return s.len+=r.len,this;if(s.t===tt.DELETE&&r.t===tt.INSERT&&(e-=1,s=this._actions[e-1],s==null))return this._actions.unshift(r),this;if(s.t===tt.RETAIN&&r.t===tt.RETAIN&&s.body==null&&r.body==null)return s.len+=r.len,this;if(s.t===tt.INSERT&&wi(s.body)&&r.t===tt.INSERT&&wi(r.body))return s.len+=r.len,s.body.dataStream+=r.body.dataStream,this}return e===this._actions.length?this._actions.push(r):this._actions.splice(e,0,r),this}trimEndUselessRetainAction(){let n=this._actions[this._actions.length-1];for(;n&&n.t===tt.RETAIN&&Al(n);)this._actions.pop(),n=this._actions[this._actions.length-1];return this}};_(sn,"id","text-x"),_(sn,"uri","https://github.com/dream-num/univer#text-x");let Re=sn;Object.defineProperty(Re,"name",{value:"text-x"});const Fe=class Fe{static registerSubtype(n){var e;this._subTypes.has(n.name)&&((e=this._subTypes.get(n.name))==null?void 0:e.id)!==Re.id||(this._subTypes.set(n.name,n),Gt.type.registerSubtype(n))}static apply(n,e){if(!Gt.type.isNoop(e))return Gt.type.apply(n,e)}static compose(n,e){return Gt.type.compose(n,e)}static transform(n,e,s){throw new Error("transform is not implemented in JsonX")}static invertWithDoc(n,e){return Gt.type.invertWithDoc(n,e)}static isNoop(n){return Gt.type.isNoop(n)}static getInstance(){return this._instance==null&&(this._instance=new Fe),this._instance}removeOp(n,e){return Gt.removeOp(n,e)}moveOp(n,e){return Gt.moveOp(n,e)}insertOp(n,e){return Gt.insertOp(n,e)}replaceOp(n,e,s){return Gt.replaceOp(n,e,s)}editOp(n,e=["body"]){return Gt.editOp(e,Re.name,n)}};_(Fe,"uri","https://github.com/dream-num/univer#json-x"),_(Fe,"_subTypes",new Map),_(Fe,"_instance",null);let ve=Fe;ve.registerSubtype(Re);const fs={id:"default_doc",documentStyle:{}};class Hl extends On{constructor(e){super();_(this,"type",Q.UNIVER_DOC);_(this,"snapshot");this.snapshot={...fs,...e}}getUnitId(){throw new Error("Method not implemented.")}get drawings(){return this.snapshot.drawings}get documentStyle(){return this.snapshot.documentStyle}get lists(){return this.snapshot.lists}get zoomRatio(){var e;return((e=this.snapshot.settings)==null?void 0:e.zoomRatio)||1}resetDrawing(e,s){this.snapshot.drawings=e,this.snapshot.drawingsOrder=s}getBody(){return this.snapshot.body}getShouldRenderLoopImmediately(){return this.snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this.snapshot.container}getSnapshot(){return this.snapshot}updateDocumentId(e){this.snapshot.id=e}updateDocumentRenderConfig(e){const{documentStyle:s}=this.snapshot;s.renderConfig==null?s.renderConfig=e:s.renderConfig={...s.renderConfig,...e}}updateDocumentStyle(e){this.snapshot.documentStyle==null?this.snapshot.documentStyle=e:this.snapshot.documentStyle={...this.snapshot.documentStyle,...e}}updateDocumentDataMargin(e){const{t:s,l:r,b:i,r:o}=e,{documentStyle:a}=this.snapshot;s!=null&&(a.marginTop=s),r!=null&&(a.marginLeft=r),i!=null&&(a.marginBottom=i),o!=null&&(a.marginRight=o)}updateDocumentDataPageSize(e,s){const{documentStyle:r}=this.snapshot;if(!r.pageSize){e=e!=null?e:Number.POSITIVE_INFINITY,s=s!=null?s:Number.POSITIVE_INFINITY,r.pageSize={width:e,height:s};return}e!==void 0&&(r.pageSize.width=e),s!==void 0&&(r.pageSize.height=s)}updateDrawing(e,s){const{drawings:r}=this,{width:i,height:o,left:a,top:l}=s,h=r==null?void 0:r[e];if(!h)return;const d=h.docTransform;d.size.width=i,d.size.height=o,d.positionH.posOffset=a,d.positionV.posOffset=l}setZoomRatio(e=1){this.snapshot.settings==null?this.snapshot.settings={zoomRatio:e}:this.snapshot.settings.zoomRatio=1}}class we extends Hl{constructor(e){var r;super(P.isEmptyObject(e)?bl():e);_(this,"_unitId");_(this,"headerModelMap",new Map);_(this,"footerModelMap",new Map);const s=6;this._unitId=(r=this.snapshot.id)!=null?r:P.generateRandomId(s),this._initializeHeaderFooterModel()}dispose(){this.headerModelMap.forEach(e=>{e.dispose()}),this.footerModelMap.forEach(e=>{e.dispose()})}getDrawings(){return this.snapshot.drawings}getDrawingsOrder(){return this.snapshot.drawingsOrder}getCustomRanges(){var e;return(e=this.snapshot.body)==null?void 0:e.customRanges}getCustomDecorations(){var e;return(e=this.snapshot.body)==null?void 0:e.customDecorations}getRev(){var e;return(e=this.snapshot.rev)!=null?e:1}incrementRev(){this.snapshot.rev=this.getRev()+1}getSettings(){return this.snapshot.settings}reset(e){if(e.id&&e.id!==this._unitId)throw new Error("Cannot reset a document model with a different unit id!");this.snapshot={...fs,...e},this._initializeHeaderFooterModel()}getSelfOrHeaderFooterModel(e){if(e!=null){if(this.headerModelMap.has(e))return this.headerModelMap.get(e);if(this.footerModelMap.has(e))return this.footerModelMap.get(e)}return this}getUnitId(){return this._unitId}apply(e){if(!ve.isNoop(e))return this.snapshot=ve.apply(this.snapshot,e),e!=null&&e.some(s=>Array.isArray(s)&&((s==null?void 0:s[0])==="headers"||(s==null?void 0:s[0])==="footers"))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.snapshot}sliceBody(e,s){const r=this.getBody();if(r!=null)return qe(r,e,s)}_initializeHeaderFooterModel(){const{headers:e,footers:s}=this.getSnapshot();if(e)for(const r in e){const i=e[r];this.headerModelMap.set(r,new we(i))}if(s)for(const r in s){const i=s[r];this.footerModelMap.set(r,new we(i))}}updateDocumentId(e){super.updateDocumentId(e),this._unitId=e}}const Ti=ct.createIdentifier("univer.config-service");class Mi{constructor(){_(this,"_config",new Map)}getConfig(n){return this._config.get(n)}setConfig(n,e){this._config.set(n,e)}deleteConfig(n){this._config.delete(n)}}class Ui extends Mt{constructor(){super(...arguments);_(this,"_error$",new B.Subject);_(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(e){this._error$.next({errorKey:e})}}class Li{constructor(n={}){_(this,"_styles");_(this,"_cacheMap",new Gr(1e5));this._styles=n,this._generateCacheMap()}each(n){return Object.entries(this._styles).forEach(n),this}search(n,e){if(this._cacheMap.has(e))return this._cacheMap.get(e);const s=this._getExistingStyleId(n);return s||"-1"}get(n){return typeof n!="string"?n:(n=String(n),this._styles[n])}add(n,e){const s=P.generateRandomId(6);return this._styles[s]=n,this._cacheMap.set(e,s),s}setValue(n){if(n==null)return;const e=JSON.stringify(n),s=this.search(n,e);return s!=="-1"?s:this.add(n,e)}toJSON(){return this._styles}getStyleByCell(n){let e;n&&P.isObject(n.s)?e=n.s:e=(n==null?void 0:n.s)&&this.get(n.s);const s=n==null?void 0:n.interceptorStyle;return s?{...e,...s}:e}_generateCacheMap(){const{_styles:n,_cacheMap:e}=this;for(const s in n){const r=JSON.stringify(n[s]);e.set(r,s)}}_getExistingStyleId(n){const{_styles:e}=this;for(const s in e)if(P.diffValue(e[s],n))return s;return null}}class Fl{constructor(n,e){_(this,"_columnData",{});this._config=n,this._columnData=e}getColumnData(){return this._columnData}getColVisible(n){const{_columnData:e}=this,s=e[n];return s?s.hd!==Y.TRUE:!0}getHiddenCols(n=0,e=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=n;o<=e;o++){const a=this.getColVisible(o);r&&a?(r=!1,s.push({rangeType:ot.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&!a&&(r=!0,i=o)}return r&&s.push({startRow:0,endRow:0,startColumn:i,endColumn:e,rangeType:ot.COLUMN}),s}getVisibleCols(n=0,e=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=n;o<=e;o++){const a=this.getColVisible(o);r&&!a?(r=!1,s.push({rangeType:ot.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&a&&(r=!0,i=o)}return r&&s.push({startRow:0,endRow:0,startColumn:i,endColumn:e,rangeType:ot.COLUMN}),s}getColumnDatas(n,e){const s={};let r=0;for(let i=n;i<n+e;i++){const o=this.getColumnOrCreate(i);s[r]=o,r++}return s}getSize(){return _e(this._columnData)}getColumnWidth(n){const{_columnData:e}=this,s=this._config;let r=0;return r=(e[n]||{hd:Y.FALSE,w:s.defaultColumnWidth}).w||s.defaultColumnWidth,r}getColumn(n){const e=this._columnData[n];if(e)return e}getColumnOrCreate(n){const{_columnData:e}=this,s=this._config,r=e[n];if(r)return r;const i={w:s.defaultColumnWidth,hd:Y.FALSE};return this._columnData[n]=i,i}}class Wl{constructor(n,e,s){_(this,"_rowData");this._config=n,this._viewModel=e,this._rowData=s}getRowData(){return this._rowData}getRowDatas(n,e){const s={};let r=0;for(let i=n;i<n+e;i++){const o=this.getRowOrCreate(i);s[r]=o,r++}return s}getRowHeight(n,e=1){const{_rowData:s}=this,r=this._config;let i=0;for(let o=0;o<e;o++){const a=s[o+n]||{hd:Y.FALSE,h:r.defaultRowHeight},{ia:l,ah:h,h:d=r.defaultRowHeight}=a;i+=(l==null||l===Y.TRUE)&&typeof h=="number"?h:d}return i}getRow(n){return this._rowData[n]}getRowOrCreate(n){const{_rowData:e}=this,s=e[n];if(s)return s;const r=this._config,i={hd:Y.FALSE,h:r.defaultRowHeight};return e[n]=i,i}getHiddenRows(n=0,e=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=n;o<=e;o++){const a=this.getRowRawVisible(o);r&&a?(r=!1,s.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:ot.ROW})):!r&&!a&&(r=!0,i=o)}return r&&s.push({startRow:i,endRow:e,startColumn:0,endColumn:0,rangeType:ot.ROW}),s}getVisibleRows(n=0,e=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=n;o<=e;o++){const a=this.getRowRawVisible(o);r&&!a?(r=!1,s.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:ot.ROW})):!r&&a&&(r=!0,i=o)}return r&&s.push({startRow:i,endRow:e,startColumn:0,endColumn:0,rangeType:ot.ROW}),s}getRowRawVisible(n){const e=this.getRow(n);return e?e.hd!==Y.TRUE:!0}getSize(){return _e(this._rowData)}}const $l="DEFAULT_WORKSHEET_ROW_COUNT",Di=1e3,Bl="DEFAULT_WORKSHEET_COLUMN_COUNT",yi=20,Gl="DEFAULT_WORKSHEET_ROW_HEIGHT",Pi=24,xl="DEFAULT_WORKSHEET_COLUMN_WIDTH",ki=88,Vl="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",Hi=46,jl="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Fi=20;function Wi(t){const n={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:Y.FALSE,rowCount:Di,columnCount:yi,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:ki,defaultRowHeight:Pi,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:Y.TRUE,rowHeader:{width:Hi,hidden:Y.FALSE},columnHeader:{height:Fi,hidden:Y.FALSE},selections:["A1"],rightToLeft:Y.FALSE};return Object.keys(n).forEach(e=>{const s=e;typeof t[s]>"u"&&(t[s]=n[s])}),t}class $i extends Mt{constructor(e){super();_(this,"_cellContentInterceptor",null);_(this,"_rowFilteredInterceptor",null);this.getRawCell=e}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(e,s){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,s):this.getRawCell(e,s)}getRowFiltered(e){var s,r;return(r=(s=this._rowFilteredInterceptor)==null?void 0:s.getRowFiltered(e))!=null?r:!1}registerCellContentInterceptor(e){if(this._cellContentInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptor=e,At(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(e){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=e,At(()=>this._rowFilteredInterceptor=null)}}class Ze{constructor(n,e,s){_(this,"_sheetId");_(this,"_snapshot");_(this,"_cellData");_(this,"_rowManager");_(this,"_columnManager");_(this,"_viewModel");var a;this.unitId=n,this._styles=s,this._snapshot=Wi(e);const{columnData:r,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:P.generateRandomId(6),this._cellData=new Jt(o),this._viewModel=new $i((l,h)=>this.getCellRaw(l,h)),this._rowManager=new Wl(this._snapshot,this._viewModel,i),this._columnManager=new Fl(this._snapshot,r)}__interceptViewModel(n){n(this._viewModel)}getSnapshot(){return this._snapshot}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const n=this.getCellMatrix(),e=this.getMergeData();let s=-1,r=-1,i=-1,o=-1,a=!1,l=!1;return n.forEach((h,d)=>{Object.keys(d).forEach(c=>{const f=+c,g=n.getValue(h,f),E=g!=null&&g.s?this._styles.get(g.s):null,R=(E==null?void 0:E.bd)&&(E.bd.b||E.bd.l||E.bd.r||E.bd.t||E.bd.bc_tr||E.bd.bl_tr||E.bd.ml_tr||E.bd.tl_bc||E.bd.tl_br||E.bd.tl_mr);(g&&(g.v||g.p)||E!=null&&E.bg||R)&&(a?s=Math.min(s,h):(s=h,a=!0),r=Math.max(r,h),l?i=Math.min(i,f):(l=!0,i=f),o=Math.max(o,f))})}),e.forEach(h=>{a?s=Math.min(s,h.startRow):(s=h.startRow,a=!0),r=Math.max(r,h.endRow),l?i=Math.min(i,h.startColumn):(i=h.startColumn,a=!0),o=Math.max(o,h.endColumn)}),!a||!l?null:{startColumn:i,startRow:s,endColumn:o,endRow:r}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:n}=this,e=P.deepClone(n);return new Ze(this.unitId,e,this._styles)}getMergeData(){return this._snapshot.mergeData}getMergedCell(n,e){const s=this._snapshot.mergeData;for(let r=0;r<s.length;r++){const i=s[r];if(me.intersects({startRow:n,startColumn:e,endRow:n,endColumn:e},i))return i}return null}getCell(n,e){return n<0||e<0?null:this._viewModel.getCell(n,e)}getCellRaw(n,e){return this.getCellMatrix().getValue(n,e)}getRowFiltered(n){return this._viewModel.getRowFiltered(n)}getMatrixWithMergedCells(n,e,s,r,i=!1){const o=this.getCellMatrix(),a=this._snapshot.mergeData.filter(h=>me.intersects({startRow:n,startColumn:e,endRow:s,endColumn:r},h)),l=new Jt;return zn(n,s,e,r).forEach((h,d)=>{const c=i?this.getCellRaw(h,d):this.getCell(h,d);c&&l.setValue(h,d,c)}),a.forEach(h=>{const{startColumn:d,startRow:c,endColumn:f,endRow:g}=h;zn(c,g,d,f).forEach((E,R)=>{E===c&&R===d&&l.setValue(E,R,{...o.getValue(E,R),rowSpan:g-c+1,colSpan:f-d+1}),(E!==c||R!==d)&&l.realDeleteValue(E,R)})}),l}getRange(n,e,s,r){return typeof n=="object"?new ke(this,n,{getStyles:()=>this._styles}):new ke(this,{startRow:n,startColumn:e,endColumn:r||e,endRow:s||n},{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:n}=this,{columnCount:e}=n;return e}getMaxRows(){const{_snapshot:n}=this,{rowCount:e}=n;return e}getRowCount(){return this._snapshot.rowCount}setRowCount(n){this._snapshot.rowCount=n}getColumnCount(){return this._snapshot.columnCount}setColumnCount(n){this._snapshot.columnCount=n}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:n}=this,{showGridlines:e}=n;return e===0}getTabColor(){const{_snapshot:n}=this,{tabColor:e}=n;return e}getColumnWidth(n){return this.getColumnManager().getColumnWidth(n)}getRowHeight(n){return this._viewModel.getRowFiltered(n)?0:this.getRowManager().getRowHeight(n)}getRowVisible(n){return this._viewModel.getRowFiltered(n)?!1:this.getRowRawVisible(n)}getRowRawVisible(n){return this.getRowManager().getRowRawVisible(n)}getHiddenRows(n,e){const s=this.getMaxColumns()-1,r=this._rowManager.getHiddenRows(n,e);return r.forEach(i=>i.endColumn=s),r}getColVisible(n){return this._columnManager.getColVisible(n)}getHiddenCols(n,e){const s=this.getMaxRows()-1,r=this._columnManager.getHiddenCols(n,e);return r.forEach(i=>i.endRow=s),r}getVisibleRows(){const n=this.getRowCount();return this._rowManager.getVisibleRows(0,n-1)}getVisibleCols(){const n=this.getColumnCount();return this._columnManager.getVisibleCols(0,n-1)}isRightToLeft(){const{_snapshot:n}=this,{rightToLeft:e}=n;return e}getLastRowWithContent(){return this._cellData.getLength()-1}getLastColumnWithContent(){return this._cellData.getRange().endColumn}cellHasValue(n){return n&&(n.v!==void 0||n.f!==void 0||n.p!==void 0)}iterateByRow(n,e=!0){const{startRow:s,startColumn:r,endRow:i,endColumn:o}=n,a=this;return{[Symbol.iterator]:()=>{let l=s,h=r;return{next(){for(;;){if(h>o&&(l+=1,h=r),l>i)return{done:!0,value:void 0};const d=a.getCell(l,h),c=!d,f=a.getMergedCell(l,h);if(f){if(l!==f.startRow||h!==f.startColumn){h=f.endColumn+1;continue}if(c&&e){h=f.endColumn+1;continue}const E={row:l,col:h,value:d};return E.colSpan=f.endColumn-f.startColumn+1,E.rowSpan=f.endRow-f.startRow+1,h=f.endColumn+1,{done:!1,value:E}}if(c&&e)h+=1;else{const g={row:l,col:h,value:d};return h+=1,{done:!1,value:g}}}}}}}}iterateByColumn(n,e=!0,s=!0){const{startRow:r,startColumn:i,endRow:o,endColumn:a}=n,l=this;return{[Symbol.iterator]:()=>{let h=r,d=i;return{next(){for(;;){if(h>o&&(d+=1,h=r),d>a)return{done:!0,value:void 0};const c=l.getMergedCell(h,d);if(c){const E=h!==c.startRow,R=E||d!==c.startColumn;if(s&&R||!s&&E){h=c.endRow+1;continue}const y=l.getCell(c.startRow,c.startColumn);if(!y&&e){h=c.endRow+1;continue}const et={row:h,col:c.startColumn,value:y};return et.colSpan=c.endColumn-c.startColumn+1,et.rowSpan=c.endRow-c.startRow+1,h=c.endRow+1,{done:!1,value:et}}const f=l.getCell(h,d);if(!f&&e)h+=1;else{const E={row:h,col:d,value:f};return h+=1,{done:!1,value:E}}}}}}}}}function Kl(t){var s,r;if(!t)return"";const n=(r=(s=t.p)==null?void 0:s.body)==null?void 0:r.dataStream;if(n)return n;const e=t.v;return typeof e=="string"?t.t===Oe.BOOLEAN?e.toUpperCase():e.replace(/[\r\n]/g,""):typeof e=="number"?t.t===Oe.BOOLEAN?e?"TRUE":"FALSE":e.toString():typeof e=="boolean"?e?"TRUE":"FALSE":""}const Yl="0.2.3";function zl(t="",n=Ie.ZH_CN,e=""){return{id:t,sheetOrder:[],name:e,appVersion:Yl,locale:n,styles:{},sheets:{},resources:[]}}var Xl=Object.defineProperty,ql=Object.getOwnPropertyDescriptor,Zl=(t,n,e,s)=>{for(var r=s>1?void 0:s?ql(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&Xl(n,e,r),r},Jl=(t,n)=>(e,s)=>n(e,s,t);function Ql(t,n){return`${t.getUnitId()}|${n.getSheetId()}`}u.Workbook=class extends On{constructor(e={},s){super();_(this,"type",Q.UNIVER_SHEET);_(this,"_sheetCreated$",new B.Subject);_(this,"sheetCreated$",this._sheetCreated$.asObservable());_(this,"_sheetDisposed$",new B.Subject);_(this,"sheetDisposed$",this._sheetDisposed$.asObservable());_(this,"_activeSheet$",new B.BehaviorSubject(null));_(this,"activeSheet$",this._activeSheet$.asObservable());_(this,"_worksheets");_(this,"_styles");_(this,"_snapshot");_(this,"_unitId");_(this,"_count");_(this,"_name$");_(this,"name$");this._logService=s;const r=zl();P.isEmptyObject(e)?this._snapshot=r:this._snapshot=P.commonExtend(r,e);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=P.generateRandomId(6)),this._unitId=this._snapshot.id,this._styles=new Li(i),this._count=1,this._worksheets=new Map,this._name$=new B.BehaviorSubject(e.name||""),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete()}save(){return P.deepClone(this._snapshot)}static isIRangeType(e){return typeof e=="string"||"startRow"in e||"row"in e}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(e){this._name$.next(e),this._snapshot.name=e}getUnitId(){return this._unitId}getRev(){var e;return(e=this._snapshot.rev)!=null?e:1}incrementRev(){this._snapshot.rev=this.getRev()+1}getShouldRenderLoopImmediately(){return this._snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this._snapshot.container}addWorksheet(e,s,r){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[e])return!1;i[e]=r,o.splice(s,0,e);const a=new Ze(this._unitId,r,this._styles);return this._worksheets.set(e,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(e){const{sheetOrder:s}=this._snapshot;return s.findIndex(r=>r===e)}getActiveSheet(e){if(!this._activeSheet&&typeof e>"u")throw new Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){const e=this._activeSheet;if(e)return e;const s=this._snapshot.sheetOrder;for(let i=0,o=s.length;i<o;i++){const a=this._worksheets.get(s[i]);if(a&&a.isSheetHidden()!==Y.TRUE)return this.setActiveSheet(a),a}const r=this._worksheets.get(s[0]);return this.setActiveSheet(r),r}setActiveSheet(e){this._activeSheet$.next(e)}removeSheet(e){const s=this._worksheets.get(e);return s?(this._worksheets.delete(e),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(e),1),delete this._snapshot.sheets[e],this._sheetDisposed$.next(s),!0):!1}getActiveSheetIndex(){const{sheetOrder:e}=this._snapshot;return e.findIndex(s=>this._worksheets.get(s)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:e}=this._snapshot;return e.map(s=>this._worksheets.get(s))}getSheetsName(){const{sheetOrder:e}=this._snapshot,s=[];return e.forEach(r=>{const i=this._worksheets.get(r);i&&s.push(i.getName())}),s}getSheetIndex(e){const{sheetOrder:s}=this._snapshot;return s.findIndex(r=>e.getSheetId()===r)}getSheetBySheetName(e){const{sheetOrder:s}=this._snapshot,r=s.find(i=>this._worksheets.get(i).getName()===e);return this._worksheets.get(r)}getSheetBySheetId(e){return this._worksheets.get(e)}getSheetByIndex(e){const{sheetOrder:s}=this._snapshot;return this._worksheets.get(s[e])}getHiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden===Y.TRUE).map(e=>e.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden!==Y.TRUE).map(e=>e.getConfig().id)}load(e){this._snapshot=e}checkSheetName(e){return this.getSheetsName().includes(e)}uniqueSheetName(e="Sheet1"){let s=e;for(;this.checkSheetName(s);)s=e+this._count,this._count++;return s}generateNewSheetName(e){let s=e+this._count;for(;this.checkSheetName(s);)s=e+this._count,this._count++;return s}_parseWorksheetSnapshots(){const{_snapshot:e,_worksheets:s}=this,{sheets:r,sheetOrder:i}=e;if(P.isEmptyObject(r)){const o=P.generateRandomId();r[o]={id:o}}for(const o in r){const a=r[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 h=new Ze(this._unitId,a,this._styles);s.set(o,h),i.includes(o)||i.push(o)}this.ensureActiveSheet()}},u.Workbook=Zl([Jl(1,Ee)],u.Workbook);class gs extends On{constructor(e){var s;super();_(this,"type",Q.UNIVER_SLIDE);_(this,"_snapshot");_(this,"_unitId");this._snapshot={...jr,...e},this._unitId=(s=this._snapshot.id)!=null?s:P.generateRandomId(6)}getContainer(){return this._snapshot.container}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var e;return(e=this._snapshot.body)==null?void 0:e.pages}getPageOrder(){var e;return(e=this._snapshot.body)==null?void 0:e.pageOrder}getPage(e){const s=this.getPages();return s==null?void 0:s[e]}getElementsByPage(e){var s;return(s=this.getPage(e))==null?void 0:s.pageElements}getElement(e,s){var r;return(r=this.getElementsByPage(e))==null?void 0:r[s]}getPageSize(){return this._snapshot.pageSize}addPage(){return{id:"cover_1",pageType:$n.SLIDE,zIndex:1,title:"cover",description:"this is first page, cover",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}}const Je="FOCUSING_SHEET",bn="FOCUSING_DOC",vn="FOCUSING_SLIDE",tu="FOCUSING_EDITOR_BUT_HIDDEN",Bi="EDITOR_ACTIVATED",eu="FOCUSING_EDITOR_INPUT_FORMULA",Gi="FOCUSING_FORMULA_EDITOR",nu="FOCUSING_UNIVER_EDITOR",su="FOCUSING_EDITOR_INPUT_FORMULA",ru="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",iu="FOCUSING_COMMON_DRAWINGS";var ou=Object.defineProperty,au=Object.getOwnPropertyDescriptor,lu=(t,n,e,s)=>{for(var r=s>1?void 0:s?au(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&ou(n,e,r),r},xi=(t,n)=>(e,s)=>n(e,s,t);const He=ct.createIdentifier("univer.current");u.UniverInstanceService=class extends Mt{constructor(e,s){super();_(this,"_unitsByType",new Map);_(this,"_createHandler");_(this,"_ctorByType",new Map);_(this,"_currentUnits",new Map);_(this,"_currentUnits$",new B.BehaviorSubject(this._currentUnits));_(this,"currentUnits$",this._currentUnits$.asObservable());_(this,"_unitAdded$",new B.Subject);_(this,"unitAdded$",this._unitAdded$.asObservable());_(this,"_unitDisposed$",new B.Subject);_(this,"unitDisposed$",this._unitDisposed$.asObservable());_(this,"_focused$",new B.BehaviorSubject(null));_(this,"focused$",this._focused$.asObservable());this._injector=e,this._contextService=s}dispose(){super.dispose(),this._focused$.complete()}__setCreateHandler(e){this._createHandler=e}createUnit(e,s){return this._createHandler(e,s,this._ctorByType.get(e))}registerCtorForType(e,s){return this._ctorByType.set(e,s),{dispose:()=>{this._ctorByType.delete(e)}}}getCurrentTypeOfUnit$(e){return this.currentUnits$.pipe(B.map(s=>{var r;return(r=s.get(e))!=null?r:null}),B.distinctUntilChanged())}getCurrentUnitForType(e){return this._currentUnits.get(e)}setCurrentUnitForType(e){const s=this._getUnitById(e);if(!s)throw new Error(`[UniverInstanceService]: no document with unitId ${e}!`);this._currentUnits.set(s[1],s[0]),this._currentUnits$.next(this._currentUnits)}_removeCurrentUnitForType(e){this._currentUnits.set(e,null),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(e){return this._unitAdded$.pipe(B.filter(s=>s.type===e))}__addUnit(e){const s=e.type;this._unitsByType.has(s)||this._unitsByType.set(s,[]),this._unitsByType.get(s).push(e),this._unitAdded$.next(e),this.setCurrentUnitForType(e.getUnitId())}getTypeOfUnitDisposed$(e){return this.unitDisposed$.pipe(B.filter(s=>s.type===e))}getUnit(e,s){var i;const r=(i=this._getUnitById(e))==null?void 0:i[0];return s&&(r==null?void 0:r.type)!==s?null:r}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(Q.UNIVER_DOC)}getUniverDocInstance(e){return this.getUnit(e,Q.UNIVER_DOC)}getUniverSheetInstance(e){return this.getUnit(e,Q.UNIVER_SHEET)}getAllUnitsForType(e){var s;return(s=this._unitsByType.get(e))!=null?s:[]}changeDoc(e,s){const r=this.getAllUnitsForType(Q.UNIVER_DOC),i=r.find(o=>o.getUnitId()===e);if(i!=null){const o=r.indexOf(i);r.splice(o,1)}this.__addUnit(s)}get focused(){var s;const e=this._focused$.getValue();return e?(s=this._getUnitById(e))==null?void 0:s[0]:null}focusUnit(e){this._focused$.next(e),this.focused instanceof u.Workbook?(this._contextService.setContextValue(bn,!1),this._contextService.setContextValue(Je,!0),this._contextService.setContextValue(vn,!1)):this.focused instanceof we?(this._contextService.setContextValue(bn,!0),this._contextService.setContextValue(Je,!1),this._contextService.setContextValue(vn,!1)):this.focused instanceof gs&&(this._contextService.setContextValue(bn,!1),this._contextService.setContextValue(Je,!1),this._contextService.setContextValue(vn,!0))}getFocusedUnit(){return this.focused}getUnitType(e){const s=this._getUnitById(e);if(!s)throw new Error(`[UniverInstanceService]: No document with unitId ${e}`);return s[1]}disposeUnit(e){const s=this._getUnitById(e);if(!s)return!1;const[r,i]=s,o=this._unitsByType.get(i),a=o.indexOf(r);return o.splice(a,1),this._removeCurrentUnitForType(i),this._focused$.next(null),this._unitDisposed$.next(r),!0}_getUnitById(e){for(const[s,r]of this._unitsByType){const i=r.find(o=>o.getUnitId()===e);if(i)return[i,s]}}},u.UniverInstanceService=lu([xi(0,ct.Inject(ct.Injector)),xi(1,Ye)],u.UniverInstanceService);var ft=(t=>(t[t.Starting=0]="Starting",t[t.Ready=1]="Ready",t[t.Rendered=2]="Rendered",t[t.Steady=3]="Steady",t))(ft||{});const uu={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"},wn=new Map;function Vi(t,n){return function(r){Tn(t,n)}}function Tn(t,n){wn.has(t)||wn.set(t,[]),wn.get(t).push(n)}var cu=Object.defineProperty,hu=Object.getOwnPropertyDescriptor,ji=(t,n,e,s)=>{for(var r=s>1?void 0:s?hu(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&cu(n,e,r),r},Ki=(t,n)=>(e,s)=>n(e,s,t);u.LifecycleService=class extends Mt{constructor(e){super();_(this,"_lifecycle$",new B.BehaviorSubject(ft.Starting));_(this,"lifecycle$",this._lifecycle$.asObservable());_(this,"_lock",!1);this._logService=e,this._reportProgress(ft.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(e){if(e<this.stage)throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");if(e!==this.stage){if(this._lock)throw new Error("[LifecycleService]: cannot set new stage when related logic is all handled!");this._lock=!0,this._reportProgress(e),this._lifecycle$.next(e),this._lock=!1}}dispose(){this._lifecycle$.complete(),super.dispose()}subscribeWithPrevious(){return B.merge(Yi(this.stage),this._lifecycle$.pipe(B.skip(1))).pipe(ei(e=>e===ft.Steady))}_reportProgress(e){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${uu[e]}".`)}},u.LifecycleService=ji([Ki(0,Ee)],u.LifecycleService),u.LifecycleInitializerService=class extends Mt{constructor(e){super();_(this,"_seenTokens",new Set);this._injector=e}initModulesOnStage(e){var s;(s=wn.get(e))==null||s.forEach(r=>{this._injector.has(r)&&!this._seenTokens.has(r)&&(this._injector.get(r),this._seenTokens.add(r))})}},u.LifecycleInitializerService=ji([Ki(0,ct.Inject(ct.Injector))],u.LifecycleInitializerService);function Yi(t){switch(t){case ft.Starting:return B.of(ft.Starting);case ft.Ready:return B.of(ft.Starting,ft.Ready);case ft.Rendered:return B.of(ft.Starting,ft.Ready,ft.Rendered);default:return B.of(ft.Starting,ft.Ready,ft.Rendered,ft.Steady)}}class Qe extends Mt{constructor(){super();_(this,"_currentLocale$",new B.BehaviorSubject(Ie.ZH_CN));_(this,"currentLocale$",this._currentLocale$.asObservable());_(this,"_locales",null);_(this,"localeChanged$",new B.Subject);_(this,"t",(e,...s)=>{if(!this._locales)throw new Error("[LocaleService]: Locale not initialized");const r=e.split("."),i=this.resolveKeyPath(this._locales[this._currentLocale],r);if(typeof i=="string"){let o=i;return s.forEach((a,l)=>{o=o.replace(`{${l}}`,a)}),o}else return e});this.disposeWithMe(At(()=>this.localeChanged$.complete()))}get _currentLocale(){return this._currentLocale$.value}load(e){var s;this._locales=P.deepMerge((s=this._locales)!=null?s:{},e)}setLocale(e){this._currentLocale$.next(e),this.localeChanged$.next()}getLocales(){var e;return(e=this._locales)==null?void 0:e[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(e,s){const r=s.shift();if(r&&e&&r in e){const i=e[r];return s.length>0&&(typeof i=="object"||Array.isArray(i))?this.resolveKeyPath(i,s):i}return null}}var _s=(t=>(t.INIT="init",t.FETCHING="fetching",t.DONE="done",t))(_s||{});const ms=ct.createIdentifier("univer.permission-service");Tn(ft.Starting,ms);class zi extends Mt{constructor(){super(...arguments);_(this,"_permissionPointMap",new Map);_(this,"_permissionPointUpdate$",new B.Subject);_(this,"permissionPointUpdate$",this._permissionPointUpdate$.asObservable())}deletePermissionPoint(e){const s=this._permissionPointMap.get(e);s&&(s.complete(),this._permissionPointMap.delete(e))}addPermissionPoint(e){const s=e instanceof B.BehaviorSubject,r=s?e.getValue():e;if(!r.id)return!1;if(this._permissionPointMap.get(r.id))throw new Error(`${r.id} PermissionPoint already exists`);return this._permissionPointMap.set(r.id,s?e:new B.BehaviorSubject(r)),this._permissionPointUpdate$.next(r),!0}updatePermissionPoint(e,s){const r=this._permissionPointMap.get(e);if(!r)return;const i=r.getValue();i.value=s,i.status=_s.DONE,r.next({...i}),this._permissionPointUpdate$.next(i)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(e){const s=this._permissionPointMap.get(e);if(s)return s.getValue()}getPermissionPoint$(e){const s=this._permissionPointMap.get(e);if(s)return s}composePermission$(e){const s=e.map(r=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(r);if(!i)throw new Error(`[PermissionService]: ${r} permissionPoint does not exist!`);return i.asObservable()});return B.combineLatest(s).pipe(oe.map(r=>r))}composePermission(e){return e.map(r=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(r);if(!i)throw new Error(`[PermissionService]: ${r} permissionPoint does not exist!`);return i.getValue()})}getAllPermissionPoint(){const e=new Map;return this._permissionPointMap.forEach((s,r)=>{e.set(r,s)}),e}}class Xi extends Mt{constructor(){super(...arguments);_(this,"_resourceMap",new Map);_(this,"_register$",new B.Subject);_(this,"register$",this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(e){return this.getAllResourceHooks().map(i=>{const o=i.toJson(e);return{name:i.pluginName,data:o}})}getResourcesByType(e,s){return this.getAllResourceHooks().filter(o=>o.businesses.includes(s)).map(o=>{const a=o.toJson(e);return{name:o.pluginName,data:a}})}registerPluginResource(e){const s=e.pluginName;if(this._resourceMap.has(s))throw new Error(`the pluginName is registered {${s}}`);return this._resourceMap.set(s,e),this._register$.next(e),At(()=>this._resourceMap.delete(s))}disposePluginResource(e){this._resourceMap.delete(e)}loadResources(e,s){this.getAllResourceHooks().forEach(r=>{var o;const i=(o=s==null?void 0:s.find(a=>a.name===r.pluginName))==null?void 0:o.data;if(i)try{const a=r.parseJson(i);r.onLoad(e,a)}catch{console.error("LoadResources Error!")}})}unloadResources(e){this.getAllResourceHooks().forEach(s=>{s.onUnLoad(e)})}dispose(){this._register$.complete(),this._resourceMap.clear()}}const Mn=ct.createIdentifier("resource-manager-service");var du=Object.defineProperty,fu=Object.getOwnPropertyDescriptor,gu=(t,n,e,s)=>{for(var r=s>1?void 0:s?fu(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&du(n,e,r),r},qi=(t,n)=>(e,s)=>n(e,s,t);let Es=class extends Mt{constructor(n,e){super();_(this,"saveWorkbook",n=>{const e=n.getUnitId(),s=this._resourceManagerService.getResources(e)||[],r=n.getSnapshot();return r.resources=s,r});this._resourceManagerService=n,this._univerInstanceService=e,this._init()}_init(){const n=s=>{s.businesses.forEach(r=>{switch(r){case Q.UNRECOGNIZED:case Q.UNIVER_UNKNOWN:case Q.UNIVER_SLIDE:case Q.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType(Q.UNIVER_DOC).forEach(i=>{const a=(i.getSnapshot().resources||[]).find(l=>l.name===s.pluginName);if(a)try{const l=s.parseJson(a.data);s.onLoad(i.getUnitId(),l)}catch{console.error(`Load Document{${i.getUnitId()}} Resources{${s.pluginName}} Data Error.`)}});break}case Q.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(Q.UNIVER_SHEET).forEach(i=>{const a=(i.getSnapshot().resources||[]).find(l=>l.name===s.pluginName);if(a)try{const l=s.parseJson(a.data);s.onLoad(i.getUnitId(),l)}catch{console.error(`Load Workbook{${i.getUnitId()}} Resources{${s.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(s=>{n(s)}),this.disposeWithMe(this._resourceManagerService.register$.subscribe(s=>{n(s)})),this.disposeWithMe(At(this._univerInstanceService.getTypeOfUnitAdded$(Q.UNIVER_SHEET).subscribe(s=>{this._resourceManagerService.loadResources(s.getUnitId(),s.getSnapshot().resources)}))),this.disposeWithMe(At(this._univerInstanceService.getTypeOfUnitDisposed$(Q.UNIVER_SHEET).subscribe(s=>{this._resourceManagerService.unloadResources(s.getUnitId())})))}saveDoc(n){const e=n.getUnitId(),s=this._resourceManagerService.getResourcesByType(e,Q.UNIVER_DOC)||[],r=n.getSnapshot();return r.resources=s,r}};Es=gu([qi(0,ct.Inject(Mn)),qi(1,ct.Inject(He))],Es);const Rs=ct.createIdentifier("resource-loader-service");Tn(ft.Ready,Rs);class Cs extends Mt{constructor(){super();_(this,"_currentTheme");_(this,"_currentTheme$",new B.BehaviorSubject({}));_(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(At(()=>this._currentTheme$.complete()))}getCurrentTheme(){if(!this._currentTheme)throw new Error("[ThemeService]: current theme is not set!");return this._currentTheme}setTheme(e){this._currentTheme=e,this._currentTheme$.next(e)}}const Un="__INTERNAL_EDITOR__",Zi=`${Un}DOCS_NORMAL`,Ji=`${Un}DOCS_FORMULA_BAR`,_u=`\r
|
|
7
|
+
`;function mu(t){return`${Un}${t}`}function Eu(t){return t.startsWith(Un)}var Ru=Object.defineProperty,Cu=Object.getOwnPropertyDescriptor,pu=(t,n,e,s)=>{for(var r=s>1?void 0:s?Cu(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&Ru(n,e,r),r},ps=(t,n)=>(e,s)=>n(e,s,t);const Ln=ct.createIdentifier("univer.undo-redo.service"),Iu=20;class Qi{dispose(){}async dispatchToHandlers(){return!1}}const to="univer.command.redo",eo="univer.command.undo",no=new class extends Qi{constructor(){super(...arguments);_(this,"type",ze.COMMAND);_(this,"id",eo)}async handler(n){const e=n.get(Ln),s=e.pitchTopUndoElement();if(!s)return!1;const r=n.get(Xe);return qn(s.undoMutations,r)?(e.popUndoToRedo(),!0):!1}},so=new class extends Qi{constructor(){super(...arguments);_(this,"type",ze.COMMAND);_(this,"id",to)}async handler(n){const e=n.get(Ln),s=e.pitchTopRedoElement();if(!s)return!1;const r=n.get(Xe);return qn(s.redoMutations,r)?(e.popRedoToUndo(),!0):!1}};u.LocalUndoRedoService=class extends Mt{constructor(e,s,r){super();_(this,"undoRedoStatus$");_(this,"_undoRedoStatus$",new B.BehaviorSubject({undos:0,redos:0}));_(this,"_undoStacks",new Map);_(this,"_redoStacks",new Map);_(this,"_batchingStatus",new Map);this._univerInstanceService=e,this._commandService=s,this._contextService=r,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(no)),this.disposeWithMe(this._commandService.registerCommand(so)),this.disposeWithMe(At(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(At(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(e){const{unitID:s}=e,r=this._getRedoStack(s,!0),i=this._getUndoStack(s,!0);if(r.length=0,this._batchingStatus.has(e.unitID)){const a=this._batchingStatus.get(e.unitID),l=this._pitchUndoElement(e.unitID);a===0||!l?(o(e),this._batchingStatus.set(e.unitID,1)):this._tryBatchingElements(l,e)}else o(e);function o(a){i.push(a),i.length>Iu&&i.splice(0,1)}this._updateStatus()}clearUndoRedo(e){const s=this._getRedoStack(e);s&&(s.length=0);const r=this._getUndoStack(e);r&&(r.length=0),this._updateStatus()}pitchTopUndoElement(){const e=this._getFocusedUnitId();return this._pitchUndoElement(e)}pitchTopRedoElement(){const e=this._getFocusedUnitId();return this._pitchRedoElement(e)}_pitchUndoElement(e){const s=this._getUndoStack(e);return s!=null&&s.length?s[s.length-1]:null}_pitchRedoElement(e){const s=this._getRedoStack(e);return s!=null&&s.length?s[s.length-1]:null}popUndoToRedo(){const s=this._getUndoStackForFocused().pop();s&&(this._getRedoStackForFocused().push(s),this._updateStatus())}popRedoToUndo(){const s=this._getRedoStackForFocused().pop();s&&(this._getUndoStackForFocused().push(s),this._updateStatus())}__tempBatchingUndoRedo(e){if(this._batchingStatus.has(e))throw new Error("[LocalUndoRedoService]: cannot batching undo redo twice at the same time!");return this._batchingStatus.set(e,0),At(()=>this._batchingStatus.delete(e))}_updateStatus(){var i,o;const e=this._getFocusedUnitId(),s=e&&((i=this._undoStacks.get(e))==null?void 0:i.length)||0,r=e&&((o=this._redoStacks.get(e))==null?void 0:o.length)||0;this._undoRedoStatus$.next({undos:s,redos:r})}_getUndoStack(e,s=!1){let r=this._undoStacks.get(e);return!r&&s&&(r=[],this._undoStacks.set(e,r)),r||null}_getRedoStack(e,s=!1){let r=this._redoStacks.get(e);return!r&&s&&(r=[],this._redoStacks.set(e,r)),r||null}_getUndoStackForFocused(){const e=this._getFocusedUnitId();if(!e)throw new Error("No focused univer instance!");return this._getUndoStack(e,!0)}_getRedoStackForFocused(){const e=this._getFocusedUnitId();if(!e)throw new Error("No focused univer instance!");return this._getRedoStack(e,!0)}_tryBatchingElements(e,s){e.redoMutations.push(...s.redoMutations),e.undoMutations.push(...s.undoMutations)}_getFocusedUnitId(){var o,a,l,h;let e="";const s=this._contextService.getContextValue(Je),r=this._contextService.getContextValue(Gi),i=this._contextService.getContextValue(Bi);return s?r?e=Ji:i?e=Zi:e=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":e=(h=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?h:"",e}},u.LocalUndoRedoService=pu([ps(0,He),ps(1,Xe),ps(2,Ye)],u.LocalUndoRedoService);const ro=Symbol("DependentOn");class Is extends Mt{onStarting(n){}onReady(){}onRendered(){}onSteady(){}getUniverInstanceType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}_(Is,"pluginName"),_(Is,"type",Q.UNIVER_UNKNOWN);class Su{constructor(){_(this,"_plugins",[])}addPlugin(n){this._plugins.push(n)}removePlugins(){const n=this._plugins.slice();return this._plugins.length=0,n}forEachPlugin(n){this._plugins.forEach(n)}}class Ou{constructor(){_(this,"_pluginsRegistered",[])}registerPlugin(n,e){this._pluginsRegistered.push({plugin:n,options:e})}getRegisterPlugins(){return this._pluginsRegistered.slice()}removePlugins(){this._pluginsRegistered=[]}}var Nu=Object.defineProperty,Au=Object.getOwnPropertyDescriptor,io=(t,n,e,s)=>{for(var r=s>1?void 0:s?Au(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&Nu(n,e,r),r},tn=(t,n)=>(e,s)=>n(e,s,t);const bu=4;function vu(...t){return function(n){n[ro]=t}}u.PluginService=class{constructor(n){_(this,"_pluginHolderForUniver");_(this,"_pluginHoldersForTypes",new Map);_(this,"_seenPlugins",new Set);_(this,"_flushTimer");this._injector=n,this._pluginHolderForUniver=this._injector.createInstance(Dn,this._checkPluginSeen.bind(this),this._immediateInitPlugin.bind(this)),this._pluginHolderForUniver.start()}dispose(){this._clearFlushTimer();for(const n of this._pluginHoldersForTypes.values())n.dispose();this._pluginHolderForUniver.dispose()}registerPlugin(n,e){this._assertPluginValid(n),this._scheduleInitPlugin();const{type:s}=n;s===Q.UNIVER_UNKNOWN?(this._pluginHolderForUniver.register(n,e),this._pluginHolderForUniver.flush()):this._ensurePluginHolderForType(s).register(n,e)}startPluginForType(n){this._ensurePluginHolderForType(n).start()}_ensurePluginHolderForType(n){if(!this._pluginHoldersForTypes.has(n)){const e=this._injector.createInstance(Dn,this._checkPluginSeen.bind(this),this._immediateInitPlugin.bind(this));return this._pluginHoldersForTypes.set(n,e),e}return this._pluginHoldersForTypes.get(n)}_immediateInitPlugin(n){this._seenPlugins.add(n.pluginName),this._ensurePluginHolderForType(n.type).immediateInitPlugin(n)}_checkPluginSeen(n){return this._seenPlugins.has(n.pluginName)}_assertPluginValid(n){const{type:e,pluginName:s}=n;if(e===Q.UNRECOGNIZED)throw new Error(`[PluginService]: invalid plugin type for ${n}. Please assign a "type" to your plugin.`);if(s==="")throw new Error(`[PluginService]: no plugin name for ${n}. Please assign a "pluginName" to your plugin.`);if(this._seenPlugins.has(s))throw new Error(`[PluginService]: duplicated plugin name for "${s}". Maybe a plugin that dependents on "${s} has already registered it. In that case please register "${s}" before the that plugin.`);this._seenPlugins.add(n.pluginName)}_scheduleInitPlugin(){this._flushTimer===void 0&&(this._flushTimer=setTimeout(()=>{this._pluginHolderForUniver.started||this._pluginHolderForUniver.start(),this._flushPlugins(),this._clearFlushTimer()},bu))}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}_flushPlugins(){this._pluginHolderForUniver.flush();for(const[n,e]of this._pluginHoldersForTypes)e.started&&e.flush()}},u.PluginService=io([tn(0,ct.Inject(ct.Injector))],u.PluginService);let Dn=class extends Mt{constructor(n,e,s,r,i,o){super();_(this,"_started",!1);_(this,"_pluginRegistry",new Ou);_(this,"_pluginStore",new Su);_(this,"_awaitingPlugins",[]);this._checkPluginRegistered=n,this._registerPlugin=e,this._logService=s,this._injector=r,this._lifecycleService=i,this._lifecycleInitializerService=o,this.disposeWithMe(this._lifecycleService.lifecycle$.pipe(B.skip(1)).subscribe(a=>{this._awaitingPlugins.forEach(l=>this._runStage(l,a))}))}get started(){return this._started}dispose(){super.dispose(),this._pluginStore.forEachPlugin(n=>n.dispose()),this._pluginStore.removePlugins(),this._pluginRegistry.removePlugins(),this._awaitingPlugins.length=0}register(n,e){this._pluginRegistry.registerPlugin(n,e)}immediateInitPlugin(n){const e=this._initPlugin(n,void 0);this._pluginsRunLifecycle([e])}start(){this._started||(this._started=!0,this.flush())}flush(){if(!this._started)return;const n=this._pluginRegistry.getRegisterPlugins().map(({plugin:e,options:s})=>this._initPlugin(e,s));n.length&&(this._pluginsRunLifecycle(n),this._pluginRegistry.removePlugins())}_initPlugin(n,e){const s=n[ro];if(s){const i=()=>{const o=s.find(a=>!this._checkPluginRegistered(a));return o?(this._logService.warn("[PluginService]",`plugin "${n.pluginName}" depends on "${o.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._registerPlugin(o,void 0),!0):!1};for(;i(););}const r=this._injector.createInstance(n,e);return this._pluginStore.addPlugin(r),r}_pluginsRunLifecycle(n){Yi(this._lifecycleService.stage).subscribe(e=>this._runStage(n,e)),this._awaitingPlugins.push(n)}_runStage(n,e){n.forEach(s=>{switch(e){case ft.Starting:s.onStarting(this._injector);break;case ft.Ready:s.onReady();break;case ft.Rendered:s.onRendered();break;case ft.Steady:s.onSteady();break}}),this._lifecycleInitializerService.initModulesOnStage(e)}};Dn=io([tn(2,Ee),tn(3,ct.Inject(ct.Injector)),tn(4,ct.Inject(u.LifecycleService)),tn(5,ct.Inject(u.LifecycleInitializerService))],Dn);function oo(t,n){if(!n)return t;const e=[];for(const s of t){const r=n.find(([i])=>i===s[0]);if(r){if(r[1]===null)continue;e.push([s[0],r[1]])}else e.push(s)}return e}const Ss={[$t.Editor]:"Editor",[$t.Owner]:"Owner",[$t.Reader]:"Reader",[$t.UNRECOGNIZED]:"UNRECOGNIZED"},yn=t=>t?{userID:`${Ss[t]}_${P.generateRandomId(8)}`,name:Ss[t],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},Os=(t,n)=>t.startsWith(Ss[n]);var wu=Object.defineProperty,Tu=Object.getOwnPropertyDescriptor,Mu=(t,n,e,s)=>{for(var r=s>1?void 0:s?Tu(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&wu(n,e,r),r};u.UserManagerService=class{constructor(){_(this,"_model",new Map);_(this,"_userChange$",new B.Subject);_(this,"userChange$",this._userChange$.asObservable());_(this,"_currentUser$",new B.BehaviorSubject(yn()));_(this,"currentUser$",this._currentUser$.asObservable())}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,e){const s=this._model.get(n);if(s)return s;e&&e()}delete(n){const e=this.getUser(n);this._model.delete(n),e&&this._userChange$.next({type:"delete",user:e})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}},u.UserManagerService=Mu([Vi(ft.Starting,u.UserManagerService)],u.UserManagerService);var Uu=Object.defineProperty,Lu=Object.getOwnPropertyDescriptor,Du=(t,n,e,s)=>{for(var r=s>1?void 0:s?Lu(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&Uu(n,e,r),r},ao=(t,n)=>(e,s)=>n(e,s,t);u.AuthzIoLocalService=class{constructor(n,e){_(this,"_permissionMap",new Map([]));this._resourceManagerService=n,this._userManagerService=e,this._initSnapshot(),e.setCurrentUser(yn($t.Owner))}_getRole(n){const e=this._userManagerService.getCurrentUser();return e?Os(e.userID,n):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:n=>{const e=[...this._permissionMap.keys()].reduce((s,r)=>{const i=this._permissionMap.get(r);return s[r]=i,s},{});return JSON.stringify(e)},parseJson:n=>JSON.parse(n),pluginName:"SHEET_AuthzIoMockService_PLUGIN",businesses:[Q.UNIVER_SHEET,Q.UNIVER_DOC,Q.UNIVER_SLIDE],onLoad:(n,e)=>{for(const s in e)this._permissionMap.set(s,e[s])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(n){const e=P.generateRandomId(8);switch(n.objectType){case Sn.SelectRange:{const s=n.selectRangeObject;this._permissionMap.set(e,{...s,objectType:n.objectType});break}case Sn.Worksheet:{const s=n.worksheetObject;this._permissionMap.set(e,{...s,objectType:n.objectType,readScope:si.SomeCollaborator})}}return e}async allowed(n){var e;if(this._permissionMap.has(n.objectID)){const s=this._permissionMap.get(n.objectID);if(s&&s.objectType===Sn.Worksheet)return(e=s==null?void 0:s.strategies)==null?void 0:e.map(r=>({action:r.action,allowed:r.role===$t.Editor}))}return n.actions.map(s=>({action:s,allowed:this._getRole($t.Owner)||this._getRole($t.Editor)}))}async batchAllowed(n){const e=this._userManagerService.getCurrentUser(),s=n.map(r=>({unitID:r.unitID,objectID:r.objectID,actions:r.actions.map(i=>({action:i,allowed:!1}))}));return e&&(Os(e.userID,$t.Owner)||Os(e.userID,$t.Editor))?n.map(r=>({unitID:r.unitID,objectID:r.objectID,actions:r.actions.map(i=>({action:i,allowed:!0}))})):s}async list(n){const e=[];return n.objectIDs.forEach(s=>{const r=this._permissionMap.get(s);if(r){const i={objectID:s,unitID:n.unitID,objectType:r.objectType,name:r.name,shareOn:!1,shareRole:$t.Owner,shareScope:-1,creator:yn($t.Owner),strategies:[],actions:n.actions.map(o=>({action:o,allowed:this._getRole($t.Owner)||this._getRole($t.Editor)}))};e.push(i)}}),e}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(n){}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(n){}},u.AuthzIoLocalService=Du([ao(0,Mn),ao(1,ct.Inject(u.UserManagerService))],u.AuthzIoLocalService);const lo=ct.createIdentifier("IAuthzIoIoService");class yu{constructor(n={},e){_(this,"_startedTypes",new Set);_(this,"_injector");const s=this._injector=Pu(e,n==null?void 0:n.override),{theme:r,locale:i,locales:o,logLevel:a}=n;r&&this._injector.get(Cs).setTheme(r),o&&this._injector.get(Qe).load(o),i&&this._injector.get(Qe).setLocale(i),a&&this._injector.get(Ee).setLogLevel(a),this._init(s)}get _univerInstanceService(){return this._injector.get(He)}get _pluginService(){return this._injector.get(u.PluginService)}__getInjector(){return this._injector}dispose(){this._injector.dispose()}setLocale(n){this._injector.get(Qe).setLocale(n)}createUnit(n,e){return this._univerInstanceService.createUnit(n,e)}createUniverSheet(n){return this._univerInstanceService.createUnit(Q.UNIVER_SHEET,n)}createUniverDoc(n){return this._univerInstanceService.createUnit(Q.UNIVER_DOC,n)}createUniverSlide(n){return this._univerInstanceService.createUnit(Q.UNIVER_SLIDE,n)}_init(n){this._univerInstanceService.registerCtorForType(Q.UNIVER_SHEET,u.Workbook),this._univerInstanceService.registerCtorForType(Q.UNIVER_DOC,we),this._univerInstanceService.registerCtorForType(Q.UNIVER_SLIDE,gs);const e=n.get(He);e.__setCreateHandler((s,r,i)=>{if(!this._startedTypes.has(s)){this._pluginService.startPluginForType(s),this._startedTypes.add(s);const a=n.createInstance(i,r);return e.__addUnit(a),this._tryProgressToReady(),a}const o=n.createInstance(i,r);return e.__addUnit(o),o})}_tryProgressToReady(){this._injector.get(u.LifecycleService).stage<ft.Ready&&(this._injector.get(u.LifecycleService).stage=ft.Ready)}registerPlugin(n,e){this._pluginService.registerPlugin(n,e)}}function Pu(t,n){const e=oo([[Ui],[Qe],[Cs],[u.LifecycleService],[u.LifecycleInitializerService],[u.PluginService],[u.UserManagerService],[He,{useClass:u.UniverInstanceService}],[ms,{useClass:zi}],[Ee,{useClass:Zr,lazy:!0}],[Xe,{useClass:u.CommandService}],[Ln,{useClass:u.LocalUndoRedoService,lazy:!0}],[Ti,{useClass:Mi}],[Ye,{useClass:Xr}],[Mn,{useClass:Xi,lazy:!0}],[Rs,{useClass:Es,lazy:!0}],[lo,{useClass:u.AuthzIoLocalService,lazy:!0}]],n);return t?t.createChild(e):new ct.Injector(e)}const ku=(t,n)=>n.length===t.length&&!t.some(e=>n.some(s=>!me.equals(s,e))),Hu=(t,n)=>n.length===t.length&&t.every((e,s)=>{const r=n[s];return r.unitId===e.unitId&&r.sheetId===e.sheetId&&me.equals(e.range,r.range)});function Fu(t,n){if(Object.is(t,n))return!0;if(typeof t!="object"||!t||typeof n!="object"||!n)return!1;const e=Object.keys(t),s=Object.keys(n);if(e.length!==s.length)return!1;const r=Object.prototype.hasOwnProperty.bind(n);for(let i=0;i<e.length;i++){const o=e[i];if(!r(o))return!1;const a=t[o],l=n[o];if(a!==l)return!1}return!0}function uo(t){return/^-?\d+(\.\d+)?$/.test(t)}function Wu(t){return uo(t)?Number(t)<=Number.MAX_SAFE_INTEGER:!1}function $u(t){return["true","false"].includes(t.toLowerCase())}function Bu(t,n){return n.forEach(e=>t.add(e)),t}function Gu(t,n=16){let e=0,s=null;return function(...i){const o=Date.now();o-e<n?(s&&clearTimeout(s),s=setTimeout(()=>{e=o,t.apply(this,i)},n)):(e=o,t.apply(this,i))}}function xu(t){const n=new MessageChannel;let e=!1;const s=()=>{e||t()};return n.port1.onmessage=s,n.port2.postMessage(null),()=>{e=!0,n.port1.close(),n.port2.close()}}var co=(t=>(t[t.TEXT=0]="TEXT",t[t.ARROW=1]="ARROW",t[t.CUSTOM=2]="CUSTOM",t))(co||{});function Vu(t,n,e){if(n==="")return t;const s={id:"mock-id",body:t,documentStyle:{}},r=new we(s),i=n.length;let o;for(;(o=r.getBody().dataStream.indexOf(n))>=0;){const l=new Re,h=ve.getInstance();if(o>0&&l.retain(o),e.length>0){const d=r.sliceBody(o,o+i),c={dataStream:e};Array.isArray(d==null?void 0:d.textRuns)&&d.textRuns.length&&(c.textRuns=[{...d.textRuns[0],st:0,ed:e.length}]),l.insert(e.length,c)}l.delete(i),r.apply(h.editOp(l.serialize()))}const a=r.getBody();return r.dispose(),a}class ho{constructor(){_(this,"skipNextObservers",!1);_(this,"lastReturnValue");_(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class ju extends B.Subject{constructor(){super(...arguments);_(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(e){let s;typeof e=="function"?s={next:([i,o])=>e(i,o)}:s=e;const r=super.subscribe(s);return this._sortedObservers.push(s),this._sortedObservers.sort((i,o)=>{var a,l;return((a=i.priority)!=null?a:0)-((l=o.priority)!=null?l:0)}),r.add(()=>this._sortedObservers=this._sortedObservers.filter(i=>i!==s)),r}clearObservers(){this._sortedObservers.forEach(e=>{var s;return(s=e.complete)==null?void 0:s.call(e)}),this._sortedObservers.length=0}emitEvent(e){var s;if(!this.closed){const r=new ho;r.lastReturnValue=e;for(const i of this._sortedObservers){const o=(s=i.next)==null?void 0:s.call(i,[e,r]);if(r.lastReturnValue=o,r.skipNextObservers)return{handled:!0,lastReturnValue:r.lastReturnValue,stopPropagation:r.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:r.lastReturnValue,stopPropagation:r.isStopPropagation}}throw new Error("[EventSubject]: cannot emit event on a closed subject.")}}const Ku=ct.createIdentifier("ILocalStorageService");function Yu(t){return`sheet_interceptor_${t}`}const fo=t=>function(n,e){let s=-1;function r(i,o){if(i<=s)throw new Error("[SheetInterceptorService]: next() called multiple times!");return s=i,i===t.length?o:t[i].handler(o,e,r.bind(null,i+1))}return r(0,n)};class zu{constructor(n){_(this,"_interceptorsByName",new Map);_(this,"_interceptorPoints");this._interceptorPoints=n}fetchThroughInterceptors(n){const e=n,s=this._interceptorsByName.get(e);return fo(s||[])}intercept(n,e){const s=n;this._interceptorsByName.has(s)||this._interceptorsByName.set(s,[]);const r=this._interceptorsByName.get(s);return r.push(e),this._interceptorsByName.set(s,r.sort((i,o)=>{var a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)})),()=>En(this._interceptorsByName.get(s),e)}getInterceptPoints(){return this._interceptorPoints}}const Xu=ct.createIdentifier("univer.snapshot-server-service");class qu{constructor(){_(this,"_sheetBlockCache",new Map)}getUnitOnRev(n,e){return Promise.resolve({snapshot:{unitID:"",type:Q.UNIVER_SHEET,rev:0,workbook:void 0,doc:void 0},changesets:[],error:{code:jt.OK,message:""}})}getSheetBlock(n,e){const s=this._sheetBlockCache.get(e.blockID);return Promise.resolve({block:s,error:{code:jt.OK,message:""}})}fetchMissingChangesets(n,e){return Promise.resolve({changesets:[],error:{code:jt.OK,message:""}})}getResourcesRequest(n,e){return Promise.resolve({resources:{},error:{code:jt.OK,message:""}})}saveSnapshot(n,e){return Promise.resolve({error:{code:jt.OK,message:""}})}saveSheetBlock(n,e){const{block:s}=e;return s?(this._sheetBlockCache.set(s.id,s),Promise.resolve({error:{code:jt.OK,message:""},blockID:s.id})):Promise.resolve({error:{code:jt.UNDEFINED,message:"block is required"},blockID:""})}saveChangeset(n,e){return Promise.resolve({error:{code:jt.OK,message:""},concurrent:[]})}}function Zu(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,(n,e)=>String.fromCharCode(Number.parseInt(e,16))))}function Ns(t){return decodeURIComponent(Array.prototype.map.call(atob(t),n=>`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""))}const en=new TextEncoder,Pn=new TextDecoder;function go(t){const n=P.deepClone(t);return delete n.id,delete n.name,delete n.rowCount,delete n.columnCount,delete n.cellData,en.encode(JSON.stringify(n))}function _o(t){const n=P.deepClone(t);return delete n.id,delete n.rev,delete n.name,delete n.sheetOrder,delete n.sheets,en.encode(JSON.stringify(n))}function Ju(t){const n=P.deepClone(t);return delete n.id,delete n.rev,delete n.title,delete n.resources,en.encode(JSON.stringify(n))}function mo(t){return JSON.parse(Pn.decode(t))}function Qu(t){return JSON.parse(typeof t=="string"?Ns(t):Pn.decode(t))}function tc(t){return JSON.parse(typeof t=="string"?Ns(t):Pn.decode(t))}const As=256*20;function Eo(t,n){const e=new Jt(t),s=e.getLength(),r=[];let i=0;for(;i<s;){const o=Math.min(i+As,s-1),a=e.getSlice(i,Math.min(i+As,s-1),0,n),l=ec(a);r.push({id:P.generateRandomId(19,"0123456789"),startRow:i,endRow:o,data:l}),i+=As}return r}function ec(t){const n=t.getData();return en.encode(JSON.stringify(n))}async function nc(t,n,e,s,r){const i={},o={};if(!await Promise.all(Object.entries(n.sheets).map(async([c,f])=>{const g={id:f.id,type:an.GRID,name:f.name,rowCount:f.rowCount,columnCount:f.columnCount,originalMeta:go(f)};if(o[c]=g,f.cellData){const E=Eo(f.cellData,f.rowCount),R=await Promise.all(E.map(y=>r.saveSheetBlock(t,{unitID:e,type:Q.UNIVER_SHEET,block:y})));if(R.some(y=>{var H;return((H=y.error)==null?void 0:H.code)!==jt.OK}))return!1;i[c]={sheetID:c,blocks:R.map(y=>y.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const l=_o(n),h={unitID:n.id,rev:s,creator:"",name:n.name,sheetOrder:n.sheetOrder,sheets:o,blockMeta:i,resources:n.resources||[],originalMeta:l};return{snapshotRes:{unitID:e,rev:h.rev,type:Q.UNIVER_SHEET,workbook:h,doc:void 0}}}async function sc(t,n,e,s,r){var f,g;const i={},o={};if(!await Promise.all(Object.entries(n.sheets).map(async([E,R])=>{const y={id:R.id,type:an.GRID,name:R.name,rowCount:R.rowCount,columnCount:R.columnCount,originalMeta:go(R)};if(o[E]=y,R.cellData){const H=Eo(R.cellData,R.rowCount),et=await Promise.all(H.map(Et=>r.saveSheetBlock(t,{unitID:e,type:Q.UNIVER_SHEET,block:Et})));if(et.some(Et=>{var gt;return((gt=Et.error)==null?void 0:gt.code)!==jt.OK}))return!1;i[E]={sheetID:E,blocks:et.map(Et=>Et.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const l=_o(n),h={unitID:n.id,rev:s,creator:"",name:n.name,sheetOrder:n.sheetOrder,sheets:o,blockMeta:i,resources:n.resources||[],originalMeta:l},d={unitID:e,rev:h.rev,type:Q.UNIVER_SHEET,workbook:h,doc:void 0},c=await r.saveSnapshot(t,{unitID:e,type:Q.UNIVER_SHEET,snapshot:d});if(ni(c.error))throw new Error(`transformWorkbookDataToSnapshot(): Failed to save snapshot.
|
|
8
|
+
ErrorCode: ${(f=c.error)==null?void 0:f.code}:${(g=c.error)==null?void 0:g.message}`);return{snapshot:d}}function rc(t,n,e){const s=t.workbook;if(!s)throw new Error("");const r={};Object.entries(s.sheets).forEach(([l,h])=>{const d=mo(h.originalMeta);r[l]={id:h.id,name:h.name,rowCount:h.rowCount,columnCount:h.columnCount,...d}});const i=new Map;n.forEach(l=>{i.set(l.id,l)}),s.blockMeta&&Object.entries(s.blockMeta).forEach(([l,h])=>{var f;const d=r[l];d.cellData={};const c=[];(f=h.blocks)==null||f.forEach(g=>{const E=i.get(g);if(E)c.push(E);else throw new Error("")}),c.forEach(g=>{const E=Qu(g.data);Object.entries(E).forEach(([R,y])=>{const H=d.cellData[+R]={};Object.entries(y).forEach(([et,Et])=>{H[+et]=Et})})})});const o=mo(s.originalMeta);return{id:t.unitID,rev:s.rev,name:s.name,sheetOrder:s.sheetOrder,appVersion:"",locale:Ie.EN_US,sheets:r,styles:{},resources:s.resources||[],...o}}function ic(t){const n=t.doc;if(n==null)throw new Error("transformSnapshotToDocumentData(): snapshot.doc is undefined.");const{unitID:e,rev:s,name:r,originalMeta:i,resources:o=[]}=n,{body:a,documentStyle:l={},settings:h={},drawings:d={},drawingsOrder:c=[]}=tc(i);return{id:e,rev:s,locale:Ie.EN_US,title:r,body:a,documentStyle:l,settings:h,drawings:d,drawingsOrder:c,resources:o}}async function oc(t,n,e,s,r){var l,h,d;const i={unitID:n.id,rev:s,creator:"",name:(l=n.title)!=null?l:"",resources:n.resources||[],originalMeta:Ju(n)},o={unitID:e,rev:i.rev,type:Q.UNIVER_DOC,workbook:void 0,doc:i},a=await r.saveSnapshot(t,{unitID:e,type:Q.UNIVER_DOC,snapshot:o});if(ni(a.error))throw new Error(`transformDocumentDataToSnapshot(): Failed to save snapshot.
|
|
9
|
+
ErrorCode: ${(h=a.error)==null?void 0:h.code}:${(d=a.error)==null?void 0:d.message}`);return{snapshot:o}}async function ac(t,n){const e=t.workbook;if(!e)throw new Error("Workbook metadata is not available");const s=[],r=[];return Object.entries(e.blockMeta).forEach(([i,o])=>{const a=o.blocks.map(async l=>{const h={unitID:e.unitID,type:Q.UNIVER_SHEET,blockID:l},{block:d}=await n.getSheetBlock({},h);if(d)s.push(d);else throw new Error("Block not found")});r.push(...a)}),await Promise.all(r),s}var Ro=(t=>(t[t.INFO=0]="INFO",t[t.STOP=1]="STOP",t[t.WARNING=2]="WARNING",t))(Ro||{}),Co=(t=>(t[t.DISABLED=0]="DISABLED",t[t.FULL_ALPHA=1]="FULL_ALPHA",t[t.FULL_HANGUL=2]="FULL_HANGUL",t[t.FULL_KATAKANA=3]="FULL_KATAKANA",t[t.HALF_ALPHA=4]="HALF_ALPHA",t[t.HALF_HANGUL=5]="HALF_HANGUL",t[t.HALF_KATAKANA=6]="HALF_KATAKANA",t[t.HIRAGANA=7]="HIRAGANA",t[t.NO_CONTROL=8]="NO_CONTROL",t[t.OFF=9]="OFF",t[t.ON=10]="ON",t))(Co||{}),po=(t=>(t.BETWEEN="between",t.EQUAL="equal",t.GREATER_THAN="greaterThan",t.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",t.LESS_THAN="lessThan",t.LESS_THAN_OR_EQUAL="lessThanOrEqual",t.NOT_BETWEEN="notBetween",t.NOT_EQUAL="notEqual",t))(po||{}),Io=(t=>(t.CUSTOM="custom",t.LIST="list",t.LIST_MULTIPLE="listMultiple",t.NONE="none",t.TEXT_LENGTH="textLength",t.DATE="date",t.TIME="time",t.WHOLE="whole",t.DECIMAL="decimal",t.CHECKBOX="checkbox",t))(Io||{}),So=(t=>(t.VALID="valid",t.INVALID="invalid",t.VALIDATING="validating",t))(So||{});const lc=["script","style","meta","comment","link"];function uc(t){return!(t.length===0||t.length>31||t.startsWith("'")||t.endsWith("'")||/[:\\\/\?\*\[\]]/.test(t))}To(),u.ABCToNumber=Ga,u.AbsoluteRefType=Nt,u.ActionIterator=ds,u.AlignTypeH=pr,u.AlignTypeV=Ir,u.ArrangeTypeEnum=Nr,u.ArrowsAndMarkersShapes=js,u.AutoFillSeries=Ls,u.BaselineOffset=Pe,u.BasicShapes=Vs,u.BlockType=er,u.BooleanNumber=Y,u.BorderStyleTypes=dt,u.BorderType=Ds,u.BulletAlignment=fe,u.COLORS=Hn,u.CellValueType=Oe,u.ClientSnapshotServerService=qu,u.Color=Ne,u.ColorBuilder=hn,u.ColorKit=Zt,u.ColorType=Vt,u.ColumnSeparatorType=ir,u.CommandType=ze,u.CommonHideTypes=ys,u.ConfigService=Mi,u.ContentAlignment=_r,u.ContextService=Xr,u.CopyPasteType=Ps,u.CustomDecorationType=tr,u.CustomRangeType=Qs,u.DEFAULT_CELL=Qa,u.DEFAULT_DOC=fs,u.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=Uo,u.DEFAULT_EMPTY_DOCUMENT_VALUE=_u,u.DEFAULT_RANGE=Za,u.DEFAULT_RANGE_ARRAY=qa,u.DEFAULT_SELECTION=Ja,u.DEFAULT_SLIDE=jr,u.DEFAULT_STYLES=pn,u.DEFAULT_WORKSHEET_COLUMN_COUNT=yi,u.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=Bl,u.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Fi,u.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=jl,u.DEFAULT_WORKSHEET_COLUMN_WIDTH=ki,u.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=xl,u.DEFAULT_WORKSHEET_ROW_COUNT=Di,u.DEFAULT_WORKSHEET_ROW_COUNT_KEY=$l,u.DEFAULT_WORKSHEET_ROW_HEIGHT=Pi,u.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=Gl,u.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=Hi,u.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=Vl,u.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=Ji,u.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=Zi,u.DashStyleType=dr,u.DataStreamTreeNodeType=ri,u.DataStreamTreeTokenType=ae,u.DataValidationErrorStyle=Ro,u.DataValidationImeMode=Co,u.DataValidationOperator=po,u.DataValidationRenderMode=co,u.DataValidationStatus=So,u.DataValidationType=Io,u.DependentOn=vu,u.DesktopLogService=Zr,u.DeveloperMetadataVisibility=ks,u.Dimension=Hs,u.Direction=Fs,u.Disposable=Mt,u.DisposableCollection=xn,u.DocStyleType=Zs,u.DocumentDataModel=we,u.DocumentFlavor=nr,u.DrawingTypeEnum=Ar,u.EDITOR_ACTIVATED=Bi,u.EXTENSION_NAMES=Kr,u.Entry=Vn,u.EntryIterator=Br,u.ErrorService=Ui,u.EventState=ho,u.EventSubject=ju,u.FOCUSING_COMMON_DRAWINGS=iu,u.FOCUSING_DOC=bn,u.FOCUSING_EDITOR_BUT_HIDDEN=tu,u.FOCUSING_EDITOR_INPUT_FORMULA=eu,u.FOCUSING_EDITOR_STANDALONE=su,u.FOCUSING_FORMULA_EDITOR=Gi,u.FOCUSING_SHEET=Je,u.FOCUSING_SLIDE=vn,u.FOCUSING_UNIVER_EDITOR=nu,u.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=ru,u.FollowNumberWithType=Js,u.FontItalic=ln,u.FontStyleType=mr,u.FontWeight=un,u.FormatType=Ws,u.GlyphType=Ve,u.GridType=sr,u.HLSColor=Xs,u.HorizontalAlign=Se,u.IAuthzIoService=lo,u.ICommandService=Xe,u.IConfigService=Ti,u.IContextService=Ye,u.ILocalStorageService=Ku,u.ILogService=Ee,u.IPermissionService=ms,u.IResourceLoaderService=Rs,u.IResourceManagerService=Mn,u.ISnapshotServerService=Xu,u.IUndoRedoService=Ln,u.IUniverInstanceService=He,u.InterceptorManager=zu,u.InterpolationPointType=$s,u.JSON1=Ll,u.JSONX=ve,u.KeyIterator=Wr,u.LRUHelper=Ke,u.LRUMap=Gr,u.LifecycleStages=ft,u.LocaleService=Qe,u.LocaleType=Ie,u.LogLevel=qr,u.MOVE_BUFFER_VALUE=Ge,u.MemoryCursor=Ai,u.NamedStyleType=cr,u.NilCommand=Qr,u.NumberUnitType=Cr,u.ObjectMatrix=Jt,u.ObjectRelativeFromH=Er,u.ObjectRelativeFromV=Rr,u.OnLifecycle=Vi,u.OtherShapes=Ks,u.PRESET_LIST_TYPE=dl,u.PageElementType=br,u.PageOrientType=Or,u.PageType=$n,u.ParagraphElementType=ar,u.PermissionService=zi,u.PermissionStatus=_s,u.Plugin=Is,u.PositionedObjectLayoutType=ur,u.PresetListType=Nn,u.ProtectionType=Bs,u.RANGE_TYPE=ot,u.RGBA_PAREN=Ho,u.RGB_PAREN=ko,u.ROTATE_BUFFER_VALUE=Ts,u.Range=ke,u.Rectangle=me,u.RedoCommand=so,u.RedoCommandId=to,u.RefAlias=Ba,u.Registry=Zn,u.RegistryAsMap=Jn,u.RelativeDate=Gs,u.RelativeSlideLink=vr,u.ResourceManagerService=Xi,u.RgbColor=dn,u.RxDisposable=Ua,u.SectionType=rr,u.SheetTypes=an,u.SheetViewModel=$i,u.SlideDataModel=gs,u.SpacingRule=hr,u.SpecialShapes=Ys,u.Styles=Li,u.THEME_COLORS=zs,u.TabStopAlignment=fr,u.TextDecoration=xs,u.TextDirection=xe,u.TextDirectionType=or,u.TextX=Re,u.TextXActionType=tt,u.ThemeColor=fn,u.ThemeColorType=Wt,u.ThemeColors=cn,u.ThemeService=Cs,u.Tools=P,u.UndoCommand=no,u.UndoCommandId=eo,u.UnitModel=On,u.Univer=yu,u.UniverInstanceType=Q,u.UpdateDocsAttributeType=kt,u.ValueIterator=$r,u.VerticalAlign=De,u.WidthType=gr,u.Worksheet=Ze,u.WrapStrategy=ye,u.WrapTextType=lr,u.afterInitApply=hl,u.b64DecodeUnicode=Ns,u.b64EncodeUnicode=Zu,u.binarySearchArray=Ms,u.cellToRange=Sa,u.characterSpacingControlType=Sr,u.checkForSubstrings=Oa,u.checkIfMove=Lo,u.checkParagraphHasBullet=Na,u.checkParagraphHasIndent=Aa,u.checkParagraphHasIndentByStyle=Mr,u.codeToBlob=yo,u.composeBody=es,u.composeInterceptors=fo,u.concatMatrixArray=Ha,u.convertBodyToHtml=Xa,u.covertTextRunToHtml=Xn,u.createDefaultUser=yn,u.createInterceptorKey=Yu,u.createInternalEditorID=mu,u.createRowColIter=zn,u.debounce=za,u.dedupe=La,u.deepCompare=Bn,u.deleteContent=Lr,u.extractPureTextFromCell=Kl,u.fromCallback=ti,u.fromObservable=Ma,u.generateTemporarySnap=nc,u.getArrayLength=_e,u.getBodySlice=qe,u.getBodySliceHtml=Cn,u.getBorderStyleType=Ca,u.getCellInfoInMergeData=na,u.getCellValueType=Jo,u.getColorStyle=se,u.getCustomDecorationSlice=Ci,u.getCustomRangeSlice=Ri,u.getDocsUpdateBody=pa,u.getReverseDirection=Po,u.getSheetBlocksFromSnapshot=ac,u.getWorksheetUID=Ql,u.groupBy=Pa,u.handleStyleToString=Ra,u.hashAlgorithm=va,u.horizontalLineSegmentsSubtraction=mn,u.insertMatrixArray=jn,u.insertTextToContent=Ur,u.isBlackColor=Xo,u.isBooleanString=$u,u.isCellCoverable=_a,u.isCellV=ta,u.isEmptyCell=wr,u.isFormulaId=Ea,u.isFormulaString=ma,u.isICellData=Zo,u.isInternalEditorID=Eu,u.isNullCell=Qo,u.isNumeric=uo,u.isRangesEqual=ku,u.isRealNum=ba,u.isSafeNumeric=Wu,u.isSameStyleTextRun=Tr,u.isUnitRangesEqual=Hu,u.isValidRange=Ia,u.isWhiteColor=qo,u.makeArray=ka,u.makeCellRangeToRangeData=ga,u.makeCellToSelection=fa,u.mergeOverrideWithDependencies=oo,u.mergeSets=Bu,u.mergeWorksheetSnapshotWithDefault=Wi,u.moveMatrixArray=Yn,u.moveRangeByOffset=rl,u.nameCharacterCheck=uc,u.normalizeBody=Nl,u.normalizeTextRuns=Qn,u.numberToABC=Va,u.numberToListABC=ja,u.orderSearchArray=Us,u.queryObjectMatrix=sl,u.remove=En,u.repeatStringNumTimes=Vr,u.replaceInDocumentBody=Vu,u.requestImmediateMacroTask=xu,u.rotate=ya,u.runOnLifecycle=Tn,u.searchArray=Do,u.selectionToArray=ea,u.sequence=zr,u.sequenceAsync=Yr,u.sequenceExecute=qn,u.sequenceExecuteAsync=cl,u.shallowEqual=Fu,u.skipParseTagNames=lc,u.sliceMatrixArray=Fa,u.sortRules=Ka,u.sortRulesByDesc=Ya,u.sortRulesFactory=Ae,u.spliceArray=Kn,u.takeAfter=ei,u.textDecoder=Pn,u.textEncoder=en,u.throttle=Gu,u.toDisposable=At,u.transformDocumentDataToSnapshot=oc,u.transformSnapshotToDocumentData=ic,u.transformSnapshotToWorkbookData=rc,u.transformWorkbookDataToSnapshot=sc,u.updateAttributeByDelete=bi,u.updateAttributeByInsert=vi,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|