@univerjs/core 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1,9 +1,9 @@
1
- "use strict";var Mo=Object.defineProperty;var Uo=(t,n,e)=>n in t?Mo(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var g=(t,n,e)=>Uo(t,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Z=require("rxjs"),cn=require("rxjs/operators"),ut=require("@wendellhu/redi");function Lo(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 Do(){yo()}const rn=typeof global<"u"?global:typeof self<"u"?self:window;function yo(){typeof rn.requestIdleCallback!="function"&&(rn.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 rn.cancelIdleCallback!="function"&&(rn.cancelIdleCallback=function(e){clearTimeout(e)})}const xo="__default_document_sub_component_id20231101__",$e=2,zs=1;function Po(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:c=0,width:h=0,angle:u=0}=t,d=h,f=c,m=i,E=r;return Math.abs(a-e)>$e||Math.abs(l-s)>$e||Math.abs(d-m)>$e||Math.abs(f-E)>$e||Math.abs(u-o)>zs}function Xs(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 qs(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 ko(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=qs(t,n):e=Xs(t,n),e)}function Ho(t){const n=new Blob([t],{type:"text/javascript"});return window.URL.createObjectURL(n)}var Zs=(t=>(t[t.DEFAULT_SERIES=0]="DEFAULT_SERIES",t[t.ALTERNATE_SERIES=1]="ALTERNATE_SERIES",t))(Zs||{}),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||{}),Js=(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))(Js||{}),zt=(t=>(t[t.UNSUPPORTED=0]="UNSUPPORTED",t[t.RGB=1]="RGB",t[t.HEX=2]="HEX",t[t.THEME=3]="THEME",t))(zt||{}),Qs=(t=>(t[t.ON=0]="ON",t[t.OFF=1]="OFF",t))(Qs||{}),tr=(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))(tr||{}),er=(t=>(t[t.DOCUMENT=0]="DOCUMENT",t[t.PROJECT=1]="PROJECT",t))(er||{}),nr=(t=>(t[t.COLUMNS=0]="COLUMNS",t[t.ROWS=1]="ROWS",t))(nr||{}),sr=(t=>(t[t.UP=0]="UP",t[t.RIGHT=1]="RIGHT",t[t.DOWN=2]="DOWN",t[t.LEFT=3]="LEFT",t))(sr||{});function Fo(t){switch(t){case 3:return 1;case 1:return 3;case 0:return 2;case 2:return 0}}var rr=(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))(rr||{}),ir=(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))(ir||{}),Te=(t=>(t.EN_US="enUS",t.ZH_CN="zhCN",t.RU_RU="ruRU",t.ZH_TW="zhTW",t.VI_VN="viVN",t))(Te||{}),or=(t=>(t[t.RANGE=0]="RANGE",t[t.SHEET=1]="SHEET",t))(or||{}),ar=(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))(ar||{}),An=(t=>(t[t.GRID=0]="GRID",t[t.KANBAN=1]="KANBAN",t[t.GANTT=2]="GANTT",t))(An||{}),qe=(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))(qe||{}),lr=(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))(lr||{}),Ne=(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))(Ne||{}),xe=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.TOP=1]="TOP",t[t.MIDDLE=2]="MIDDLE",t[t.BOTTOM=3]="BOTTOM",t))(xe||{}),Pe=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.OVERFLOW=1]="OVERFLOW",t[t.CLIP=2]="CLIP",t[t.WRAP=3]="WRAP",t))(Pe||{}),En=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ITALIC=1]="ITALIC",t))(En||{}),pn=(t=>(t[t.NORMAL=0]="NORMAL",t[t.BOLD=1]="BOLD",t))(pn||{}),ke=(t=>(t[t.NORMAL=1]="NORMAL",t[t.SUBSCRIPT=2]="SUBSCRIPT",t[t.SUPERSCRIPT=3]="SUPERSCRIPT",t))(ke||{}),K=(t=>(t[t.FALSE=0]="FALSE",t[t.TRUE=1]="TRUE",t))(K||{}),Ae=(t=>(t[t.STRING=1]="STRING",t[t.NUMBER=2]="NUMBER",t[t.BOOLEAN=3]="BOOLEAN",t[t.FORCE_STRING=4]="FORCE_STRING",t))(Ae||{}),Ht=(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))(Ht||{}),bn=(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))(bn||{}),ur=(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))(ur||{}),cr=(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))(cr||{}),hr=(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))(hr||{}),dr=(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))(dr||{});const fr={[bn.OFFICE]:{[Ht.ACCENT1]:"#4472C4",[Ht.ACCENT2]:"#ED7D31",[Ht.ACCENT3]:"#A5A5A5",[Ht.ACCENT4]:"#70AD47",[Ht.ACCENT5]:"#5B9BD5",[Ht.ACCENT6]:"#70AD47",[Ht.DARK1]:"#000000",[Ht.DARK2]:"#44546A",[Ht.LIGHT1]:"#FFFFFF",[Ht.LIGHT2]:"#E7E6E6",[Ht.HYPERLINK]:"#0563C1",[Ht.FOLLOWED_HYPERLINK]:"#954F72"}};class vn{constructor(){g(this,"_themeValue",Ht.LIGHT1);g(this,"_themeColors");g(this,"_themeTint");g(this,"_rgbValue","");g(this,"_colorType");this._colorType=zt.UNSUPPORTED,this._themeColors=bn.OFFICE,this._themeTint=0}asRgbColor(){return new Rn(this._rgbValue,this)}asThemeColor(){return new Cn(this._themeValue,this._themeTint,this._themeColors,this)}build(){switch(this._colorType){case zt.THEME:return this.asThemeColor();case zt.RGB:return this.asRgbColor();case zt.UNSUPPORTED:throw new Error("unsupported color type")}}setRgbColor(n){return this._colorType=zt.RGB,this._rgbValue=n,this}setThemeColors(n){this._colorType=zt.THEME,this._themeColors=n}setThemeTint(n){this._colorType=zt.THEME,this._themeTint=n}setThemeColor(n){return this._colorType=zt.THEME,this._themeValue=n,this}getColorType(){return this._colorType}}class be{constructor(n){g(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 vn().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 be(this._builder)}equals(n){return!1}}class gr{constructor(n){g(this,"_saturation",0);g(this,"_hue",0);g(this,"_lightness",0);g(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 vn;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,c=this.setColor(e,s,l);return n.setRgbColor(`rgba(${Math.round(o*255)},${Math.round(a*255)},${Math.round(c*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 Yt=class Yt extends be{constructor(e,s){super(s);g(this,"_cssString");g(this,"_red");g(this,"_green");g(this,"_blue");g(this,"_alpha");let r=e.match(Yt.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(Yt.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 be.rgbColorToHexValue(this)}getRed(){let e=this._red+Yt.RGB_COLOR_AMT;return e>255?e=255:e<0&&(e=0),e}getGreen(){let e=this._green+Yt.RGB_COLOR_AMT;return e>255?e=255:e<0&&(e=0),e}getBlue(){let e=this._blue+Yt.RGB_COLOR_AMT;return e>255?e=255:e<0&&(e=0),e}getAlpha(){return this._alpha}getColorType(){return zt.RGB}clone(){return new Yt(this._cssString,this._builder)}asThemeColor(){throw new Error("rgb color not support to themeColor")}equals(e){return e instanceof Yt?e._red===this._red&&e._blue===this._blue&&e._green===this._green&&e._alpha===this._alpha:!1}getCssString(){return this._cssString}};g(Yt,"RGB_COLOR_AMT",0),g(Yt,"RGBA_EXTRACT",new RegExp("\\s*rgba\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d.\\d|\\d\\s*)\\)\\s*")),g(Yt,"RGB_EXTRACT",new RegExp("\\s*rgb\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*)\\)\\s*"));let Rn=Yt;const ge=class ge extends be{constructor(e,s,r,i){super(i);g(this,"_themeColorType");g(this,"_themeTint");g(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=fr[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(ge._cacheThemeColor.has(this._themeColors)){if(r=ge._cacheThemeColor.get(this._themeColors),r.has(this._themeColorType))return r.get(this._themeColorType)}else r=new Map,ge._cacheThemeColor.set(this._themeColors,r);const i=new gr(be.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 ge(this._themeColorType,this._themeTint,this._themeColors,this._builder)}equals(e){return e instanceof ge?e._themeColorType===this._themeColorType:!1}getColorType(){return zt.THEME}getThemeColorType(){return this._themeColorType}};g(ge,"_cacheThemeColor",new Map);let Cn=ge;const Wo="rgb(",$o="rgba(",Yn={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 te{constructor(n){g(this,"_color");g(this,"_rgbColor");g(this,"_isValid",!1);if(n==null){this._setNullColor();return}if(n instanceof te){this._color={...n._color},this._rgbColor={...n._rgbColor};return}const e=_r(n);if(e==null){this._setNullColor();return}this._color=e;const s=Ko(this._color);if(s==null){this._setNullColor();return}this._rgbColor=s,this._isValid=!0}static mix(n,e,s){var c,h;s=Math.min(1,Math.max(0,s));const r=new te(n).toRgb(),i=new te(e).toRgb(),o=(c=r.a)!=null?c:1,a=(h=i.a)!=null?h: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 te(l)}static getContrastRatio(n,e){const s=new te(n).getLuminance(),r=new te(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=[on(Math.round(e).toString(16)),on(Math.round(s).toString(16)),on(Math.round(r).toString(16)),on(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 qo(this.toRgb())}toHsl(){return Xo(this.toRgb())}lighten(n=10){const e=this.toHsl();return e.l+=n,e.l=Math.min(Math.max(e.l,0),100),new te(e)}darken(n=10){const e=this.toHsl();return e.l-=n,e.l=Math.min(Math.max(e.l,0),100),new te(e)}setAlpha(n){return new te({...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 on=t=>t.length===1?`0${t}`:t,Fn=t=>(t/=255,t<=.03928?t/12.92:((t+.055)/1.055)**2.4),_r=t=>{if(Jo(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(Yn[n]){const e=Yn[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 Bo(n);if(n.startsWith("rgb"))return Go(n);if(n.startsWith("hsl"))return jo(n);if(n.startsWith("hsv"))return Vo(n)},Bo=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},Go=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},jo=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},Vo=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},Ko=t=>{const n=_r(t);if(n!=null)return"r"in n?n:"l"in n?Yo(n):zo(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),Yo=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,c=2*s-l;r=Wn(c,l,n+1/3),i=Wn(c,l,n),o=Wn(c,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},zo=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),c=r%6,h=[s,a,o,o,l,s][c],u=[l,s,s,a,o,o][c],d=[o,o,l,s,s,a][c],f={r:h*255,g:u*255,b:d*255};return t.a!==void 0&&(f.a=t.a),f},Xo=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 h=r-i;switch(l=o>.5?h/(2-r-i):h/(r+i),r){case n:a=(e-s)/h+(e<s?6:0);break;case e:a=(s-n)/h+2;break;default:a=(n-e)/h+4;break}a/=6}const c={h:Math.round(a*360),s:Math.round(l*100),l:Math.round(o*100)};return t.a!==void 0&&(c.a=t.a),c},qo=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,c=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 h={h:Math.round(o*360),s:Math.round(c*100),v:Math.round(a*100)};return t.a!==void 0&&(h.a=t.a),h},Zo=t=>t==null,Jo=t=>!Zo(t)&&typeof t=="object";function Qo(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 ta(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 Pt=(t=>(t[t.COVER=0]="COVER",t[t.REPLACE=1]="REPLACE",t[t.INTERSECTION=2]="INTERSECTION",t))(Pt||{});function ea(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 na(t){if(t.t!==void 0)return t.t;if(typeof t.v=="string")return Ae.STRING;if(typeof t.v=="number")return Ae.NUMBER;if(typeof t.v=="boolean")return Ae.BOOLEAN}function sa(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 ra(t){return t!=null&&(typeof t=="string"||typeof t=="number"||typeof t=="boolean")}var mr=(t=>(t[t.character=0]="character",t[t.paragraph=1]="paragraph",t[t.table=2]="table",t[t.numbering=3]="numbering",t))(mr||{}),Er=(t=>(t[t.TAB=0]="TAB",t[t.SPACE=1]="SPACE",t[t.NOTHING=2]="NOTHING",t))(Er||{}),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||{}),pr=(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))(pr||{}),Rr=(t=>(t[t.COMMENT=0]="COMMENT",t))(Rr||{}),Cr=(t=>(t[t.DRAWING=0]="DRAWING",t[t.CUSTOM=1]="CUSTOM",t))(Cr||{}),Ir=(t=>(t[t.TRADITIONAL=0]="TRADITIONAL",t[t.MODERN=1]="MODERN",t))(Ir||{}),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||{}),Or=(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))(Or||{}),Nr=(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))(Nr||{}),Ar=(t=>(t[t.NORMAL=0]="NORMAL",t[t.TBRL=1]="TBRL",t[t.LRTBV=2]="LRTBV",t))(Ar||{}),br=(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))(br||{}),vr=(t=>(t[t.BOTH_SIDES=0]="BOTH_SIDES",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.LARGEST=3]="LARGEST",t))(vr||{}),wr=(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))(wr||{}),Tr=(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))(Tr||{}),Mr=(t=>(t[t.AUTO=0]="AUTO",t[t.AT_LEAST=1]="AT_LEAST",t[t.EXACT=2]="EXACT",t))(Mr||{}),Ur=(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))(Ur||{}),Lr=(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))(Lr||{}),Dr=(t=>(t.EVENLY_DISTRIBUTED="0",t.FIXED_WIDTH="1",t))(Dr||{}),yr=(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))(yr||{}),xr=(t=>(t.NORMAL="normal",t.BOLD="bold",t.ITALIC="italic",t))(xr||{}),Pr=(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))(Pr||{}),kr=(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))(kr||{}),Hr=(t=>(t[t.POINT=0]="POINT",t[t.LINE=1]="LINE",t[t.CHARACTER=2]="CHARACTER",t))(Hr||{}),Fr=(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))(Fr||{}),Wr=(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))(Wr||{}),$r=(t=>(t[t.compressPunctuation=0]="compressPunctuation",t[t.compressPunctuationAndJapaneseKana=1]="compressPunctuationAndJapaneseKana",t[t.doNotCompress=2]="doNotCompress",t))($r||{}),Br=(t=>(t[t.PORTRAIT=0]="PORTRAIT",t[t.LANDSCAPE=1]="LANDSCAPE",t))(Br||{}),Gr=(t=>(t[t.forward=0]="forward",t[t.backward=1]="backward",t[t.front=2]="front",t[t.back=3]="back",t))(Gr||{}),jr=(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))(jr||{}),it=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(it||{}),At=(t=>(t[t.NONE=0]="NONE",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(At||{});function ia(t){return[t.startRow,t.startColumn,t.endRow,t.endColumn]}function oa(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 c=0;c<e.length;c++){const{startRow:h,endRow:u,startColumn:d,endColumn:f}=e[c];if(t===h&&n===d){i=u,o=f,a=h,l=d,r=!0;break}if(t>=h&&t<=u&&n>=d&&n<=f){i=u,o=f,a=h,l=d,s=!0;break}}return{actualRow:t,actualColumn:n,isMergedMainCell:r,isMerged:s,endRow:i,endColumn:o,startRow:a,startColumn:l}}var as=(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))(as||{}),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||{}),Kr=(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))(Kr||{});const aa="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let la=t=>crypto.getRandomValues(new Uint8Array(t)),ua=(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}}},ca=(t,n=21)=>ua(t,n,la),ha=(t=21)=>{let n="",e=crypto.getRandomValues(new Uint8Array(t));for(;t--;)n+=aa[e[t]&63];return n};const da=/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi,fa=new RegExp(da);function ga(t){return Number.isNaN(+t)?t.startsWith("http://localhost:3002")||t.startsWith("localhost:3002")?!0:!!t.match(fa):!1}const _a=/^-ms-/,ma=/-([a-z])/g,de=["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(n){let e="",s=n;for(;s>=de.length;)s/=de.length,s-=1,e+=de[s%de.length];const r=n%de.length;return e+=de[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+=de.length**i+de.length*r}return e+=n.charCodeAt(n.length-1)-65,e}static deleteBlank(n){return y.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 h=Number.parseFloat(RegExp.$1);return h===7?"IE7":h===8?"IE8":h===9?"IE9":h===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?ca(e,n)():ha(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,c)=>{var h,u;if(y.isArray(l)){const d=(h=a[c])!=null?h:[];a[c]=d,s(l,d);return}if(y.isObject(l)){const d=(u=a[c])!=null?u:{};a[c]=d,r(l,d);return}a[c]=l})}function r(o,a){Object.keys(o).forEach(l=>{var h,u;const c=o[l];if(y.isObject(c)){const d=(h=a[l])!=null?h:{};a[l]=d,r(c,d);return}if(y.isArray(c)){const d=(u=a[l])!=null?u:[];a[l]=d,s(c,d);return}a[l]=c})}function i(o){Object.keys(o).forEach(a=>{var c,h;const l=o[a];if(y.isArray(l)){const u=(c=n[a])!=null?c:[];n[a]=u,s(l,u);return}if(y.isObject(l)){const u=(h=n[a])!=null?h:{};n[a]=u,r(l,u);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=y.getValueType(o),c=y.getValueType(a);return l!==c?!1:y.isArray(o)?r(o,a):y.isObject(o)?i(o,a):y.isDate(o)?o.getTime()===a.getTime():y.isRegExp(o)?o.toString()===a.toString():o===a}function r(o,a){if(n.length!==e.length)return!1;for(let l=0,c=o.length;l<c;l++){const h=o[l],u=a[l];if(!s(h,u))return!1}return!0}function i(o,a){const l=Object.keys(o),c=Object.keys(a);if(l.length!==c.length)return!1;for(const h of l){if(!c.includes(h))return!1;const u=o[h],d=a[h];if(!s(u,d))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]=y.deepClone(s)}),e}if(this.isObject(n)){const e={};return Object.keys(n).forEach(s=>{const r=n[s];e[s]=y.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 ga(n)}static itCount(n){return e=>{for(let s=0;s<n;s++)e&&e()}}static hasLength(n,e){return y.isDefine(n)?y.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(_a,"ms-").replace(ma,this.fCamelCase)}static removeNull(n){return this.isObject(n)&&Object.keys(n).forEach(e=>{const s=n[e];s==null?delete n[e]:y.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 Ea(t){const{actualRow:n,actualColumn:e,isMerged:s,isMergedMainCell:r,mergeInfo:i}=t;let{startY:o,endY:a,startX:l,endX:c}=t,h=n,u=e,d=n,f=e;if(s&&i){const{startRow:m,startColumn:E,endRow:D,endColumn:P,startY:tt,endY:mt,startX:ht,endX:p}=i;h=m,u=E,d=D,f=P,o=tt,a=mt,l=ht,c=p}return r&&(o=i.startY,a=i.endY,l=i.startX,c=i.endX,d=i.endRow,f=i.endColumn),{startRow:h,startColumn:u,endRow:d,endColumn:f,startY:o,endY:a,startX:l,endX:c}}function pa(t){if(!t)return;const{actualRow:n,actualColumn:e,isMerged:s,isMergedMainCell:r,startRow:i,startColumn:o,endRow:a,endColumn:l}=t;let c=n,h=e,u=n,d=e;return(s||r)&&(c=i,h=o,u=a,d=l),{startRow:c,startColumn:h,endRow:u,endColumn:d}}function Yr(t){var e;return!t||(((e=t==null?void 0:t.v)==null?void 0:e.toString())||"").length===0&&!t.p}function Ra(t){return Yr(t)&&(t==null?void 0:t.coverable)!==!1}function re(t){if(t){if(t.rgb)return t.rgb;if(t.th)return new vn().setThemeColor(t.th).asThemeColor().asRgbColor().getCssString()}return null}function Ca(t){return y.isString(t)&&t.substring(0,1)==="="&&t.length>1}function Ia(t){return y.isString(t)&&t.length>0}function Sa(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: ${re(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: ${re(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: ${re(t.ol.cl)}; `),t.ol.t&&e.indexOf("text-decoration-style")===-1&&(e+=`text-decoration-style: ${t.ol.t} `))}],["bg",()=>{t.bg&&(e+=`background: ${re(t.bg)}; `)}],["bd",()=>{var o,a,l,c,h,u,d,f,m,E,D,P;(o=t.bd)!=null&&o.b&&(e+=`border-bottom: ${an((a=t.bd)==null?void 0:a.b.s)} ${(l=re(t.bd.b.cl))!=null?l:""}; `),(c=t.bd)!=null&&c.t&&(e+=`border-top: ${an((h=t.bd)==null?void 0:h.t.s)} ${(u=re(t.bd.t.cl))!=null?u:""}; `),(d=t.bd)!=null&&d.r&&(e+=`border-right: ${an((f=t.bd)==null?void 0:f.r.s)} ${(m=re(t.bd.r.cl))!=null?m:""}; `),(E=t.bd)!=null&&E.l&&(e+=`border-left: ${an((D=t.bd)==null?void 0:D.l.s)} ${(P=re(t.bd.l.cl))!=null?P:""}; `)}],["cl",()=>{t.cl&&(e+=`color: ${re(t.cl)}; `)}],["va",()=>{t.va===ke.SUBSCRIPT?e+="vertical-align: sub; ":t.va===ke.SUPERSCRIPT&&(e+="vertical-align: super; ")}],["td",()=>{t.td===qe.LEFT_TO_RIGHT?e+="direction: ltr; ":t.td===qe.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===Ne.LEFT?e+="text-align: left; ":t.ht===Ne.RIGHT?e+="text-align: right; ":t.ht===Ne.CENTER?e+="text-align: center; ":t.ht===Ne.JUSTIFIED&&(e+="text-align: justify; ")}],["vt",()=>{t.vt===xe.BOTTOM?e+="vertical-align: bottom; ":t.vt===xe.TOP?e+="vertical-align: top; ":t.vt===xe.MIDDLE&&(e+="vertical-align: middle; ")}],["tb",()=>{t.tb===Pe.CLIP?e+="white-space: clip; ":t.tb===Pe.WRAP&&(e+="white-space: normal;")}],["pd",()=>{var h,u,d,f,m,E,D,P;const o=`${(h=t.pd)==null?void 0:h.b}pt`,a=`${(u=t.pd)==null?void 0:u.t}pt`,l=`${(d=t.pd)==null?void 0:d.l}pt`,c=`${(f=t.pd)==null?void 0:f.r}pt`;(m=t.pd)!=null&&m.b&&(e+=`padding-bottom: ${o}; `),(E=t.pd)!=null&&E.t&&(e+=`padding-top: ${a}; `),(D=t.pd)!=null&&D.l&&(e+=`padding-left: ${l}; `),(P=t.pd)!=null&&P.r&&(e+=`padding-right: ${c}; `)}]]),r=["bd","tr","tb"];for(const o in t)n&&r.includes(o)||(i=s.get(o))==null||i();return e}function an(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 Oa(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 Na(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 Aa(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===it.COLUMN||!(Number.isNaN(s)&&Number.isNaN(r))&&i===it.ROW||i!==it.ROW&&i!==it.COLUMN&&(Number.isNaN(s)||Number.isNaN(n)||Number.isNaN(r)||Number.isNaN(e)))}function ba(t,n){return{startRow:t,endRow:t,startColumn:n,endColumn:n}}function ls(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=>ls(t[e],n[e])):t===n:!1}function zr(t,n){const e=t.ts||{},s=n.ts||{};return t.sId!==n.sId?!1:ls(e,s)}function va(t,n){return n.some(e=>t.indexOf(e)>-1)}function wn(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 wa(t){if(t==null)return!1;const n=t.bullet;return(n==null?void 0:n.listId)!=null}function Ta(t){if(t==null)return!1;const n=t.paragraphStyle;return Xr(n)}function Xr(t){return!(t==null||(t.indentStart==null||t.indentStart===0)&&t.hanging==null||t.hanging===0)}function qr(t,n,e){return t.slice(0,n)+e+t.slice(n)}function Zr(t,n,e){return n>e?t:t.slice(0,n)+t.slice(e)}function Ma(t){return t===null||t.toString().replace(/\s/g,"")===""||typeof t=="boolean"?!1:!isNaN(t)}function Ua(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 Us(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 Ls(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 Ds(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))}function Ve(t){return typeof t=="function"}function La(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 $n=La(function(t){return function(e){t(this),this.message=e?e.length+` errors occurred during unsubscription:
1
+ "use strict";var Lo=Object.defineProperty;var Do=(t,n,e)=>n in t?Lo(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var _=(t,n,e)=>Do(t,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Z=require("rxjs"),cn=require("rxjs/operators"),ut=require("@wendellhu/redi");function yo(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 xo(){Po()}const rn=typeof global<"u"?global:typeof self<"u"?self:window;function Po(){typeof rn.requestIdleCallback!="function"&&(rn.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 rn.cancelIdleCallback!="function"&&(rn.cancelIdleCallback=function(e){clearTimeout(e)})}const ko="__default_document_sub_component_id20231101__",We=2,Xs=1;function Ho(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:c=0,angle:u=0}=t,d=c,f=h,m=i,E=r;return Math.abs(a-e)>We||Math.abs(l-s)>We||Math.abs(d-m)>We||Math.abs(f-E)>We||Math.abs(u-o)>Xs}function qs(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 Zs(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 Fo(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=Zs(t,n):e=qs(t,n),e)}function $o(t){const n=new Blob([t],{type:"text/javascript"});return window.URL.createObjectURL(n)}var Js=(t=>(t[t.DEFAULT_SERIES=0]="DEFAULT_SERIES",t[t.ALTERNATE_SERIES=1]="ALTERNATE_SERIES",t))(Js||{}),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||{}),Qs=(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))(Qs||{}),zt=(t=>(t[t.UNSUPPORTED=0]="UNSUPPORTED",t[t.RGB=1]="RGB",t[t.HEX=2]="HEX",t[t.THEME=3]="THEME",t))(zt||{}),tr=(t=>(t[t.ON=0]="ON",t[t.OFF=1]="OFF",t))(tr||{}),er=(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))(er||{}),nr=(t=>(t[t.DOCUMENT=0]="DOCUMENT",t[t.PROJECT=1]="PROJECT",t))(nr||{}),sr=(t=>(t[t.COLUMNS=0]="COLUMNS",t[t.ROWS=1]="ROWS",t))(sr||{}),rr=(t=>(t[t.UP=0]="UP",t[t.RIGHT=1]="RIGHT",t[t.DOWN=2]="DOWN",t[t.LEFT=3]="LEFT",t))(rr||{});function Wo(t){switch(t){case 3:return 1;case 1:return 3;case 0:return 2;case 2:return 0}}var ir=(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))(ir||{}),or=(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))(or||{}),Te=(t=>(t.EN_US="enUS",t.ZH_CN="zhCN",t.RU_RU="ruRU",t.ZH_TW="zhTW",t.VI_VN="viVN",t))(Te||{}),ar=(t=>(t[t.RANGE=0]="RANGE",t[t.SHEET=1]="SHEET",t))(ar||{}),lr=(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))(lr||{}),An=(t=>(t[t.GRID=0]="GRID",t[t.KANBAN=1]="KANBAN",t[t.GANTT=2]="GANTT",t))(An||{}),qe=(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))(qe||{}),ur=(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))(ur||{}),Ne=(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))(Ne||{}),xe=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.TOP=1]="TOP",t[t.MIDDLE=2]="MIDDLE",t[t.BOTTOM=3]="BOTTOM",t))(xe||{}),Pe=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.OVERFLOW=1]="OVERFLOW",t[t.CLIP=2]="CLIP",t[t.WRAP=3]="WRAP",t))(Pe||{}),En=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ITALIC=1]="ITALIC",t))(En||{}),pn=(t=>(t[t.NORMAL=0]="NORMAL",t[t.BOLD=1]="BOLD",t))(pn||{}),ke=(t=>(t[t.NORMAL=1]="NORMAL",t[t.SUBSCRIPT=2]="SUBSCRIPT",t[t.SUPERSCRIPT=3]="SUPERSCRIPT",t))(ke||{}),K=(t=>(t[t.FALSE=0]="FALSE",t[t.TRUE=1]="TRUE",t))(K||{}),Ae=(t=>(t[t.STRING=1]="STRING",t[t.NUMBER=2]="NUMBER",t[t.BOOLEAN=3]="BOOLEAN",t[t.FORCE_STRING=4]="FORCE_STRING",t))(Ae||{}),Ht=(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))(Ht||{}),bn=(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))(bn||{}),cr=(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))(cr||{}),hr=(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))(hr||{}),dr=(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))(dr||{}),fr=(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))(fr||{});const _r={[bn.OFFICE]:{[Ht.ACCENT1]:"#4472C4",[Ht.ACCENT2]:"#ED7D31",[Ht.ACCENT3]:"#A5A5A5",[Ht.ACCENT4]:"#70AD47",[Ht.ACCENT5]:"#5B9BD5",[Ht.ACCENT6]:"#70AD47",[Ht.DARK1]:"#000000",[Ht.DARK2]:"#44546A",[Ht.LIGHT1]:"#FFFFFF",[Ht.LIGHT2]:"#E7E6E6",[Ht.HYPERLINK]:"#0563C1",[Ht.FOLLOWED_HYPERLINK]:"#954F72"}};class vn{constructor(){_(this,"_themeValue",Ht.LIGHT1);_(this,"_themeColors");_(this,"_themeTint");_(this,"_rgbValue","");_(this,"_colorType");this._colorType=zt.UNSUPPORTED,this._themeColors=bn.OFFICE,this._themeTint=0}asRgbColor(){return new Rn(this._rgbValue,this)}asThemeColor(){return new Cn(this._themeValue,this._themeTint,this._themeColors,this)}build(){switch(this._colorType){case zt.THEME:return this.asThemeColor();case zt.RGB:return this.asRgbColor();case zt.UNSUPPORTED:throw new Error("unsupported color type")}}setRgbColor(n){return this._colorType=zt.RGB,this._rgbValue=n,this}setThemeColors(n){this._colorType=zt.THEME,this._themeColors=n}setThemeTint(n){this._colorType=zt.THEME,this._themeTint=n}setThemeColor(n){return this._colorType=zt.THEME,this._themeValue=n,this}getColorType(){return this._colorType}}class be{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 vn().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 be(this._builder)}equals(n){return!1}}class gr{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 vn;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 Yt=class Yt extends be{constructor(e,s){super(s);_(this,"_cssString");_(this,"_red");_(this,"_green");_(this,"_blue");_(this,"_alpha");let r=e.match(Yt.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(Yt.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 be.rgbColorToHexValue(this)}getRed(){let e=this._red+Yt.RGB_COLOR_AMT;return e>255?e=255:e<0&&(e=0),e}getGreen(){let e=this._green+Yt.RGB_COLOR_AMT;return e>255?e=255:e<0&&(e=0),e}getBlue(){let e=this._blue+Yt.RGB_COLOR_AMT;return e>255?e=255:e<0&&(e=0),e}getAlpha(){return this._alpha}getColorType(){return zt.RGB}clone(){return new Yt(this._cssString,this._builder)}asThemeColor(){throw new Error("rgb color not support to themeColor")}equals(e){return e instanceof Yt?e._red===this._red&&e._blue===this._blue&&e._green===this._green&&e._alpha===this._alpha:!1}getCssString(){return this._cssString}};_(Yt,"RGB_COLOR_AMT",0),_(Yt,"RGBA_EXTRACT",new RegExp("\\s*rgba\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d.\\d|\\d\\s*)\\)\\s*")),_(Yt,"RGB_EXTRACT",new RegExp("\\s*rgb\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*)\\)\\s*"));let Rn=Yt;const _e=class _e extends be{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=_r[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(_e._cacheThemeColor.has(this._themeColors)){if(r=_e._cacheThemeColor.get(this._themeColors),r.has(this._themeColorType))return r.get(this._themeColorType)}else r=new Map,_e._cacheThemeColor.set(this._themeColors,r);const i=new gr(be.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 _e(this._themeColorType,this._themeTint,this._themeColors,this._builder)}equals(e){return e instanceof _e?e._themeColorType===this._themeColorType:!1}getColorType(){return zt.THEME}getThemeColorType(){return this._themeColorType}};_(_e,"_cacheThemeColor",new Map);let Cn=_e;const Bo="rgb(",Go="rgba(",Yn={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 te{constructor(n){_(this,"_color");_(this,"_rgbColor");_(this,"_isValid",!1);if(n==null){this._setNullColor();return}if(n instanceof te){this._color={...n._color},this._rgbColor={...n._rgbColor};return}const e=mr(n);if(e==null){this._setNullColor();return}this._color=e;const s=zo(this._color);if(s==null){this._setNullColor();return}this._rgbColor=s,this._isValid=!0}static mix(n,e,s){var h,c;s=Math.min(1,Math.max(0,s));const r=new te(n).toRgb(),i=new te(e).toRgb(),o=(h=r.a)!=null?h:1,a=(c=i.a)!=null?c: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 te(l)}static getContrastRatio(n,e){const s=new te(n).getLuminance(),r=new te(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=[on(Math.round(e).toString(16)),on(Math.round(s).toString(16)),on(Math.round(r).toString(16)),on(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 Jo(this.toRgb())}toHsl(){return Zo(this.toRgb())}lighten(n=10){const e=this.toHsl();return e.l+=n,e.l=Math.min(Math.max(e.l,0),100),new te(e)}darken(n=10){const e=this.toHsl();return e.l-=n,e.l=Math.min(Math.max(e.l,0),100),new te(e)}setAlpha(n){return new te({...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 on=t=>t.length===1?`0${t}`:t,Fn=t=>(t/=255,t<=.03928?t/12.92:((t+.055)/1.055)**2.4),mr=t=>{if(ta(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(Yn[n]){const e=Yn[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 jo(n);if(n.startsWith("rgb"))return Vo(n);if(n.startsWith("hsl"))return Ko(n);if(n.startsWith("hsv"))return Yo(n)},jo=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},Vo=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},Ko=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},Yo=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},zo=t=>{const n=mr(t);if(n!=null)return"r"in n?n:"l"in n?Xo(n):qo(n)},$n=(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=$n(h,l,n+1/3),i=$n(h,l,n),o=$n(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},qo=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,c=[s,a,o,o,l,s][h],u=[l,s,s,a,o,o][h],d=[o,o,l,s,s,a][h],f={r:c*255,g:u*255,b:d*255};return t.a!==void 0&&(f.a=t.a),f},Zo=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 c=r-i;switch(l=o>.5?c/(2-r-i):c/(r+i),r){case n:a=(e-s)/c+(e<s?6:0);break;case e:a=(s-n)/c+2;break;default:a=(n-e)/c+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},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);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 c={h:Math.round(o*360),s:Math.round(h*100),v:Math.round(a*100)};return t.a!==void 0&&(c.a=t.a),c},Qo=t=>t==null,ta=t=>!Qo(t)&&typeof t=="object";function ea(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 na(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 Pt=(t=>(t[t.COVER=0]="COVER",t[t.REPLACE=1]="REPLACE",t[t.INTERSECTION=2]="INTERSECTION",t))(Pt||{});function sa(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 ra(t){if(t.t!==void 0)return t.t;if(typeof t.v=="string")return Ae.STRING;if(typeof t.v=="number")return Ae.NUMBER;if(typeof t.v=="boolean")return Ae.BOOLEAN}function ia(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 oa(t){return t!=null&&(typeof t=="string"||typeof t=="number"||typeof t=="boolean")}var Er=(t=>(t[t.character=0]="character",t[t.paragraph=1]="paragraph",t[t.table=2]="table",t[t.numbering=3]="numbering",t))(Er||{}),pr=(t=>(t[t.TAB=0]="TAB",t[t.SPACE=1]="SPACE",t[t.NOTHING=2]="NOTHING",t))(pr||{}),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||{}),Rr=(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[t.UNI_FORMULA=7]="UNI_FORMULA",t))(Rr||{}),Cr=(t=>(t[t.COMMENT=0]="COMMENT",t))(Cr||{}),Ir=(t=>(t[t.DRAWING=0]="DRAWING",t[t.CUSTOM=1]="CUSTOM",t))(Ir||{}),Sr=(t=>(t[t.TRADITIONAL=0]="TRADITIONAL",t[t.MODERN=1]="MODERN",t))(Sr||{}),Or=(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))(Or||{}),Nr=(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))(Nr||{}),Ar=(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))(Ar||{}),br=(t=>(t[t.NORMAL=0]="NORMAL",t[t.TBRL=1]="TBRL",t[t.LRTBV=2]="LRTBV",t))(br||{}),vr=(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))(vr||{}),wr=(t=>(t[t.BOTH_SIDES=0]="BOTH_SIDES",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.LARGEST=3]="LARGEST",t))(wr||{}),Tr=(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))(Tr||{}),Mr=(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))(Mr||{}),Ur=(t=>(t[t.AUTO=0]="AUTO",t[t.AT_LEAST=1]="AT_LEAST",t[t.EXACT=2]="EXACT",t))(Ur||{}),Lr=(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))(Lr||{}),Dr=(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))(Dr||{}),yr=(t=>(t.EVENLY_DISTRIBUTED="0",t.FIXED_WIDTH="1",t))(yr||{}),xr=(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))(xr||{}),Pr=(t=>(t.NORMAL="normal",t.BOLD="bold",t.ITALIC="italic",t))(Pr||{}),kr=(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))(kr||{}),Hr=(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))(Hr||{}),Fr=(t=>(t[t.POINT=0]="POINT",t[t.LINE=1]="LINE",t[t.CHARACTER=2]="CHARACTER",t[t.PIXEL=3]="PIXEL",t))(Fr||{}),$r=(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[t.BOTH=5]="BOTH",t[t.DISTRIBUTE=6]="DISTRIBUTE",t))($r||{}),Wr=(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))(Wr||{}),Br=(t=>(t[t.compressPunctuation=0]="compressPunctuation",t[t.compressPunctuationAndJapaneseKana=1]="compressPunctuationAndJapaneseKana",t[t.doNotCompress=2]="doNotCompress",t))(Br||{}),Gr=(t=>(t[t.PORTRAIT=0]="PORTRAIT",t[t.LANDSCAPE=1]="LANDSCAPE",t))(Gr||{}),jr=(t=>(t[t.forward=0]="forward",t[t.backward=1]="backward",t[t.front=2]="front",t[t.back=3]="back",t))(jr||{}),Vr=(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))(Vr||{}),it=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(it||{}),At=(t=>(t[t.NONE=0]="NONE",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(At||{});function aa(t){return[t.startRow,t.startColumn,t.endRow,t.endColumn]}function la(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:c,endRow:u,startColumn:d,endColumn:f}=e[h];if(t===c&&n===d){i=u,o=f,a=c,l=d,r=!0;break}if(t>=c&&t<=u&&n>=d&&n<=f){i=u,o=f,a=c,l=d,s=!0;break}}return{actualRow:t,actualColumn:n,isMergedMainCell:r,isMerged:s,endRow:i,endColumn:o,startRow:a,startColumn:l}}var as=(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))(as||{}),Kr=(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))(Kr||{}),Yr=(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))(Yr||{});const ua="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ca=t=>crypto.getRandomValues(new Uint8Array(t)),ha=(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}}},da=(t,n=21)=>ha(t,n,ca),fa=(t=21)=>{let n="",e=crypto.getRandomValues(new Uint8Array(t));for(;t--;)n+=ua[e[t]&63];return n};const _a=new RegExp("^(?:(?:(?:https?|ftp):)?\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62})?[a-z0-9\\u00a1-\\uffff]\\.)+(?:[a-z\\u00a1-\\uffff]{2,}\\.?))(?::\\d{2,5})?(?:[/?#]\\S*)?$","i");function ga(t){return Number.isNaN(+t)?t.startsWith("http://localhost:3002")||t.startsWith("localhost:3002")?!0:_a.test(t):!1}function ma(t){return/^[a-zA-Z]+:\/\//.test(t)}function Ea(t){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(t)}function pa(t){return ma(t)?t:Ea(t)?`mailto://${t}`:`https://${t}`}const Ra=/^-ms-/,Ca=/-([a-z])/g,de=["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 x{static stringAt(n){let e="",s=n;for(;s>=de.length;)s/=de.length,s-=1,e+=de[s%de.length];const r=n%de.length;return e+=de[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+=de.length**i+de.length*r}return e+=n.charCodeAt(n.length-1)-65,e}static deleteBlank(n){return x.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 c=Number.parseFloat(RegExp.$1);return c===7?"IE7":c===8?"IE8":c===9?"IE9":c===10?"IE10":"0"}return o?"FF":e?"Opera":a?"Safari":l?"Chrome":i?"Edge":r?"IE11":"Unknown browser"}static generateRandomId(n=21,e){return zr(n,e)}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 c,u;if(x.isArray(l)){const d=(c=a[h])!=null?c:[];a[h]=d,s(l,d);return}if(x.isObject(l)){const d=(u=a[h])!=null?u:{};a[h]=d,r(l,d);return}a[h]=l})}function r(o,a){Object.keys(o).forEach(l=>{var c,u;const h=o[l];if(x.isObject(h)){const d=(c=a[l])!=null?c:{};a[l]=d,r(h,d);return}if(x.isArray(h)){const d=(u=a[l])!=null?u:[];a[l]=d,s(h,d);return}a[l]=h})}function i(o){Object.keys(o).forEach(a=>{var h,c;const l=o[a];if(x.isArray(l)){const u=(h=n[a])!=null?h:[];n[a]=u,s(l,u);return}if(x.isObject(l)){const u=(c=n[a])!=null?c:{};n[a]=u,r(l,u);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=x.getValueType(o),h=x.getValueType(a);return l!==h?!1:x.isArray(o)?r(o,a):x.isObject(o)?i(o,a):x.isDate(o)?o.getTime()===a.getTime():x.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 c=o[l],u=a[l];if(!s(c,u))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 c of l){if(!h.includes(c))return!1;const u=o[c],d=a[c];if(!s(u,d))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]=x.deepClone(s)}),e}if(this.isObject(n)){const e={};return Object.keys(n).forEach(s=>{const r=n[s];e[s]=x.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 ga(n)}static normalizeUrl(n){return pa(n)}static itCount(n){return e=>{for(let s=0;s<n;s++)e&&e()}}static hasLength(n,e){return x.isDefine(n)?x.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(Ra,"ms-").replace(Ca,this.fCamelCase)}static removeNull(n){return this.isObject(n)&&Object.keys(n).forEach(e=>{const s=n[e];s==null?delete n[e]:x.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 zr(t=21,n){return n?da(n,t)():fa(t)}function Ia(t){const{actualRow:n,actualColumn:e,isMerged:s,isMergedMainCell:r,mergeInfo:i}=t;let{startY:o,endY:a,startX:l,endX:h}=t,c=n,u=e,d=n,f=e;if(s&&i){const{startRow:m,startColumn:E,endRow:M,endColumn:L,startY:tt,endY:mt,startX:ht,endX:p}=i;c=m,u=E,d=M,f=L,o=tt,a=mt,l=ht,h=p}return r&&(o=i.startY,a=i.endY,l=i.startX,h=i.endX,d=i.endRow,f=i.endColumn),{startRow:c,startColumn:u,endRow:d,endColumn:f,startY:o,endY:a,startX:l,endX:h}}function Sa(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,c=e,u=n,d=e;return(s||r)&&(h=i,c=o,u=a,d=l),{startRow:h,startColumn:c,endRow:u,endColumn:d}}function Xr(t){var e;return!t||(((e=t==null?void 0:t.v)==null?void 0:e.toString())||"").length===0&&!t.p}function Oa(t){return Xr(t)&&(t==null?void 0:t.coverable)!==!1}function re(t){if(t){if(t.rgb)return t.rgb;if(t.th)return new vn().setThemeColor(t.th).asThemeColor().asRgbColor().getCssString()}return null}function Na(t){return x.isString(t)&&t.substring(0,1)==="="&&t.length>1}function Aa(t){return x.isString(t)&&t.length>0}function ba(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: ${re(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: ${re(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: ${re(t.ol.cl)}; `),t.ol.t&&e.indexOf("text-decoration-style")===-1&&(e+=`text-decoration-style: ${t.ol.t} `))}],["bg",()=>{t.bg&&(e+=`background: ${re(t.bg)}; `)}],["bd",()=>{var o,a,l,h,c,u,d,f,m,E,M,L;(o=t.bd)!=null&&o.b&&(e+=`border-bottom: ${an((a=t.bd)==null?void 0:a.b.s)} ${(l=re(t.bd.b.cl))!=null?l:""}; `),(h=t.bd)!=null&&h.t&&(e+=`border-top: ${an((c=t.bd)==null?void 0:c.t.s)} ${(u=re(t.bd.t.cl))!=null?u:""}; `),(d=t.bd)!=null&&d.r&&(e+=`border-right: ${an((f=t.bd)==null?void 0:f.r.s)} ${(m=re(t.bd.r.cl))!=null?m:""}; `),(E=t.bd)!=null&&E.l&&(e+=`border-left: ${an((M=t.bd)==null?void 0:M.l.s)} ${(L=re(t.bd.l.cl))!=null?L:""}; `)}],["cl",()=>{t.cl&&(e+=`color: ${re(t.cl)}; `)}],["va",()=>{t.va===ke.SUBSCRIPT?e+="vertical-align: sub; ":t.va===ke.SUPERSCRIPT&&(e+="vertical-align: super; ")}],["td",()=>{t.td===qe.LEFT_TO_RIGHT?e+="direction: ltr; ":t.td===qe.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===Ne.LEFT?e+="text-align: left; ":t.ht===Ne.RIGHT?e+="text-align: right; ":t.ht===Ne.CENTER?e+="text-align: center; ":t.ht===Ne.JUSTIFIED&&(e+="text-align: justify; ")}],["vt",()=>{t.vt===xe.BOTTOM?e+="vertical-align: bottom; ":t.vt===xe.TOP?e+="vertical-align: top; ":t.vt===xe.MIDDLE&&(e+="vertical-align: middle; ")}],["tb",()=>{t.tb===Pe.CLIP?e+="white-space: nowrap; overflow-x: hidden; ":t.tb===Pe.WRAP&&(e+="white-space: normal;")}],["pd",()=>{var c,u,d,f,m,E,M,L;const o=`${(c=t.pd)==null?void 0:c.b}pt`,a=`${(u=t.pd)==null?void 0:u.t}pt`,l=`${(d=t.pd)==null?void 0:d.l}pt`,h=`${(f=t.pd)==null?void 0:f.r}pt`;(m=t.pd)!=null&&m.b&&(e+=`padding-bottom: ${o}; `),(E=t.pd)!=null&&E.t&&(e+=`padding-top: ${a}; `),(M=t.pd)!=null&&M.l&&(e+=`padding-left: ${l}; `),(L=t.pd)!=null&&L.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 an(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 va(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 wa(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 Ta(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===it.COLUMN||!(Number.isNaN(s)&&Number.isNaN(r))&&i===it.ROW||i!==it.ROW&&i!==it.COLUMN&&(Number.isNaN(s)||Number.isNaN(n)||Number.isNaN(r)||Number.isNaN(e)))}function Ma(t,n){return{startRow:t,endRow:t,startColumn:n,endColumn:n}}function ls(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=>ls(t[e],n[e])):t===n:!1}function qr(t,n){const e=t.ts||{},s=n.ts||{};return t.sId!==n.sId?!1:ls(e,s)}function Ua(t,n){return n.some(e=>t.indexOf(e)>-1)}function wn(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 La(t){if(t==null)return!1;const n=t.bullet;return(n==null?void 0:n.listId)!=null}function Da(t){if(t==null)return!1;const n=t.paragraphStyle;return Zr(n)}function Zr(t){var n;return!(t==null||(t.indentStart==null||t.indentStart.v===0)&&t.hanging==null||((n=t.hanging)==null?void 0:n.v)===0)}function Jr(t,n,e){return t.slice(0,n)+e+t.slice(n)}function Qr(t,n,e){return n>e?t:t.slice(0,n)+t.slice(e)}function ya(t){return t===null||t.toString().replace(/\s/g,"")===""||typeof t=="boolean"?!1:!isNaN(t)}function xa(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 Ls(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 Ds(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 ys(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))}function Ve(t){return typeof t=="function"}function Pa(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 Wn=Pa(function(t){return function(e){t(this),this.message=e?e.length+` errors occurred during unsubscription:
2
2
  `+e.map(function(s,r){return r+1+") "+s.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=e}});function ys(t,n){if(t){var e=t.indexOf(n);0<=e&&t.splice(e,1)}}var Jr=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=Us(o),l=a.next();!l.done;l=a.next()){var c=l.value;c.remove(this)}}catch(E){n={error:E}}finally{try{l&&!l.done&&(e=a.return)&&e.call(a)}finally{if(n)throw n.error}}else o.remove(this);var h=this.initialTeardown;if(Ve(h))try{h()}catch(E){i=E instanceof $n?E.errors:[E]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var d=Us(u),f=d.next();!f.done;f=d.next()){var m=f.value;try{xs(m)}catch(E){i=i!=null?i:[],E instanceof $n?i=Ds(Ds([],Ls(i)),Ls(E.errors)):i.push(E)}}}catch(E){s={error:E}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(s)throw s.error}}}if(i)throw new $n(i)}},t.prototype.add=function(n){var e;if(n&&n!==this)if(this.closed)xs(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)&&ys(e,n)},t.prototype.remove=function(n){var e=this._finalizers;e&&ys(e,n),n instanceof t&&n._removeParent(this)},t.EMPTY=function(){var n=new t;return n.closed=!0,n}(),t}();Jr.EMPTY;function Da(t){return t instanceof Jr||t&&"closed"in t&&Ve(t.remove)&&Ve(t.add)&&Ve(t.unsubscribe)}function xs(t){Ve(t)?t():t.unsubscribe()}function bt(t){let n=!1;return t?Da(t)?{dispose:()=>t.unsubscribe()}:typeof t=="function"?{dispose:()=>{n||(n=!0,t())}}:t:bt(()=>{})}function ya(t){return bt(()=>{t.unsubscribe()})}class us{constructor(){g(this,"_disposables",new Set)}add(n){const e=bt(n);return this._disposables.add(e),{dispose:()=>{e.dispose(),this._disposables.delete(e)}}}dispose(){this._disposables.forEach(n=>{n.dispose()}),this._disposables.clear()}}class Dt{constructor(){g(this,"_disposed",!1);g(this,"_collection",new us)}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 xa extends Dt{constructor(){super(...arguments);g(this,"dispose$",new Z.Subject)}dispose(){super.dispose(),this.dispose$.next(),this.dispose$.complete()}}class Be{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 Tn(t,n){const e=t.indexOf(n);return e>-1?(t.splice(e,1),!0):!1}function Pa(t){const n=new Set,e=[];for(const s of t)n.has(s)||(n.add(s),e.push(s));return e}function ka(t,n){for(let e=t.length-1;e>-1;e--){const s=t[e];if(n(s,e))return s}return null}function Ha(t,n){if(t.length===0)return t;const e=n%t.length;return t.slice(e).concat(t.slice(0,e))}function Fa(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 Wa(t){return Array.isArray(t)?t:[t]}const ct=Symbol("newer"),Lt=Symbol("older");class Qr{constructor(n){g(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ct],{done:!1,value:n.key}):{done:!0,value:void 0}}}class ti{constructor(n){g(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ct],{done:!1,value:n.value}):{done:!0,value:void 0}}}class ei{constructor(n){g(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ct],{done:!1,value:[n.key,n.value]}):{done:!0,value:void 0}}}var Ks,Ys;Ys=ct,Ks=Lt;class zn{constructor(n,e){g(this,"key");g(this,"value");g(this,Ys);g(this,Ks);this.key=n,this.value=e,this[ct]=void 0,this[Lt]=void 0}toJSON(){return{key:this.key,value:this.value}}}class ni{constructor(...n){g(this,"_keymap");g(this,"size",0);g(this,"limit");g(this,"oldest");g(this,"newest");g(this,"_onShiftListeners",[]);if(Be.hasLength(n,1)){if(Be.isNumber(n[0])){const e=n[0];this._initialize(e,void 0);return}if(Be.isIterable(n[0])){const e=n[0];this._initialize(0,e);return}return}if(Be.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),bt(()=>Tn(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[ct]&&(n===this.oldest&&(this.oldest=n[ct]),n[ct][Lt]=n[Lt]),n[Lt]&&(n[Lt][ct]=n[ct]),n[ct]=void 0,n[Lt]=this.newest,this.newest&&(this.newest[ct]=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 zn(i.value[0],i.value[1]);if(this._keymap.set(o.key,o),e?(e[ct]=o,o[Lt]=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 zn(n,e)),this.newest?(this.newest[ct]=s,s[Lt]=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[ct]?(this.oldest=this.oldest[ct],this.oldest[Lt]=void 0):(this.oldest=void 0,this.newest=void 0),n[ct]=n[Lt]=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[ct]&&e[Lt]?(e[Lt][ct]=e[ct],e[ct][Lt]=e[Lt]):e[ct]?(e[ct][Lt]=void 0,this.oldest=e[ct]):e[Lt]?(e[Lt][ct]=void 0,this.newest=e[Lt]):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 Qr(this.oldest)}values(){return new ti(this.oldest)}entries(){return this[Symbol.iterator]()}[Symbol.iterator](){return new ei(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[ct]}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[ct];return n}toString(){let n="",e=this.oldest;for(;e;)n+=`${String(e.key)}:${e.value}`,e=e[ct],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 Xn(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 qn(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 $a(t,n){const e=t,s=Object.keys(e),r=s.length,i=n,o=Object.keys(i),a=o.length,l={};let c=0;for(let h=0;h<r;h++,c++){const u=s[h];l[c]=e[u]}for(let h=0;h<a;h++,c++){const u=o[h];l[c]=i[u]}return l}function Ba(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 Zn(t,n,e,s){const r=t>e;if(!r&&t+n>e)throw new Error("Invalid move operation");r?Ga(t,n,e,s):ja(t,n,e,s)}function Ga(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 ja(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 ee{constructor(n={}){g(this,"_matrix");this._setOriginValue(n)}static MakeObjectMatrixSize(n){return new ee({[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 c=Number(l),h=o[Number(l)];if(n(i,c,h)===!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){Zn(n,e,s,this._matrix)}moveColumns(n,e,s){this.forEach((r,i)=>{Zn(n,e,s,i)})}insertRows(n,e){for(let s=n;s<n+e;s++)Xn(s,{},this._matrix)}insertColumns(n,e){for(let s=n;s<n+e;s++)this.forEach((r,i)=>{i&&Xn(s,void 0,i)})}removeRows(n,e){qn(n,e,this._matrix)}removeColumns(n,e){this.forEach((s,r)=>{r&&qn(n,e,r)})}getFragment(n,e,s,r){const i=new ee;let o=0;for(let a=n;a<=e;a++){const l={};let c=0;for(let h=s;h<=r;h++){const u=this.getValue(a,h);l[c]=u,c++}i.setRow(o,l),o++}return i}getSlice(n,e,s,r){const i=new ee;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,y.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 ee;return this.forEach((o,a)=>{s||(s=!0,n=o),Object.keys(a).forEach(l=>{const c=Number(l);r?c<e&&(e=c):(r=!0,e=c);const h=this.getValue(o,c);i.setValue(o-n,c-e,h)})}),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 c=_e(l)-1;c>s&&(s=c),Object.keys(l).forEach(h=>{const u=Number(h);o?u<e&&(e=u):(o=!0,e=u)}),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 ue=class ue{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===it.NORMAL||e.rangeType===void 0&&n.rangeType===it.NORMAL)}static intersects(n,e){if(n.rangeType===it.ROW&&e.rangeType===it.COLUMN||n.rangeType===it.COLUMN&&e.rangeType===it.ROW)return!0;if(n.rangeType===it.ROW&&e.rangeType===it.ROW)return n.startRow<=e.endRow&&n.endRow>=e.startRow;if(n.rangeType===it.COLUMN&&e.rangeType===it.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,c=Number.isNaN(e.endRow)?s:e.endRow,h=Number.isNaN(e.startColumn)?0:e.startColumn,u=Number.isNaN(e.endColumn)?s:e.endColumn,d=Math.abs(o+a-h-u),f=Math.abs(o-a)+Math.abs(h-u),m=Math.abs(r+i-l-c),E=Math.abs(r-i)+Math.abs(l-c);return d<=f&&m<=E}static getIntersects(n,e){const s=n.startRow,r=n.endRow,i=n.startColumn,o=n.endColumn,a=e.startRow,l=e.endRow,c=e.startColumn,h=e.endColumn;let u,d,f,m;if(a<=r)a>=s?d=a:d=s;else return null;if(l>=s)l>=r?m=r:m=l;else return null;if(c<=o)c>i?u=c:u=i;else return null;if(h>=i)h>=o?f=o:f=h;else return null;return{startRow:d,endRow:m,startColumn:u,endColumn:f,rangeType:it.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 ue.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:it.NORMAL}),n[0])}static realUnion(...n){const e=n.some(i=>i.rangeType===it.COLUMN),s=n.some(i=>i.rangeType===it.ROW),r=ue.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?it.ROW:e?it.COLUMN:it.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}}};g(ue,"getRelativeRange",(n,e)=>({startRow:n.startRow-e.startRow,endRow:n.endRow-n.startRow,startColumn:n.startColumn-e.startColumn,endColumn:n.endColumn-n.startColumn})),g(ue,"getPositionRange",(n,e,s)=>({...s||{},startRow:s&&[At.ROW,At.ALL].includes(s.startAbsoluteRefType||0)?s.startRow:n.startRow+e.startRow,endRow:s&&[At.ROW,At.ALL].includes(s.endAbsoluteRefType||0)?s.endRow:n.endRow+n.startRow+e.startRow,startColumn:s&&[At.COLUMN,At.ALL].includes(s.startAbsoluteRefType||0)?s.startColumn:n.startColumn+e.startColumn,endColumn:s&&[At.COLUMN,At.ALL].includes(s.endAbsoluteRefType||0)?s.endColumn:n.endColumn+n.startColumn+e.startColumn})),g(ue,"moveHorizontal",(n,e=0,s=0)=>({...n,startColumn:n.startColumn+e,endColumn:n.endColumn+e+s})),g(ue,"moveVertical",(n,e=0,s=0)=>({...n,startRow:n.startRow+e,endRow:n.endRow+e+s})),g(ue,"moveOffset",(n,e,s)=>({...n,startRow:n.startRow+s,endRow:n.endRow+s,startColumn:n.startColumn+e,endColumn:n.endColumn+e}));let me=ue;class Va{constructor(n,e){g(this,"_values",[]);g(this,"_keys",[]);g(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 Jn(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 Ka(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 In=65,si=90,Ya=97;function za(t){const n=si-In+1;let e="";for(;t>=0;)e=String.fromCharCode(t%n+In)+e,t=Math.floor(t/n)-1;return e}function ri(t,n){let e="";for(;n>0;)e+=t,n--;return e}function Xa(t,n=!1){const e=si-In+1;let s=Ya;n&&(s=In);const r=String.fromCharCode(t%e+s),i=Math.floor(t/e)+1;return ri(r,i)}function qa(t,n){return t.zIndex>n.zIndex?1:t.zIndex===n.zIndex?0:-1}function Za(t,n){return t.zIndex>n.zIndex?-1:t.zIndex===n.zIndex?0:1}function Me(t="index",n=1){return(e,s)=>e[t]>s[t]?n:e[t]===s[t]?0:-n}function Ja(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 hn(t,n,e){const{dataStream:s,textRuns:r=[]}=t;let i=n;const o=[];for(const a of r){const{st:l,ed:c}=a;y.hasIntersectionBetweenTwoRanges(n,e,l,c)&&(l>i?(o.push(s.slice(i,l)),o.push(Qn(s,{...a,ed:Math.min(c,e)}))):o.push(Qn(s,{...a,st:i,ed:Math.min(c,e)}))),i=Math.max(n,Math.min(c,e))}return i!==e&&o.push(s.slice(i,e)),o.join("")}function Qa(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:c={}}=a,{spaceAbove:h,spaceBelow:u,lineSpacing:d}=c,f=[];h!=null&&(typeof h=="number"?f.push(`margin-top: ${h}px`):f.push(`margin-top: ${h.v}px`)),u!=null&&(typeof u=="number"?f.push(`margin-bottom: ${u}px`):f.push(`margin-bottom: ${u.v}px`)),d!=null&&f.push(`line-height: ${d}`),l>o+1?i+=`<p class="UniverNormal" ${f.length?`style="${f.join("; ")};"`:""}>${hn(t,o+1,l)}</p>`:i+=`<p class="UniverNormal" ${f.length?`style="${f.join("; ")};"`:""}></p>`,o=l}return o!==s.length&&(i+=hn(t,o,s.length)),i}else return hn(t,0,t.dataStream.length)}function Qn(t,n){const{st:e,ed:s,ts:r={}}=n,{ff:i,fs:o,it:a,bl:l,ul:c,st:h,ol:u,bg:d,cl:f,va:m}=r;let E=t.slice(e,s);const D=[];return a===K.TRUE&&(E=`<i>${E}</i>`),m===ke.SUPERSCRIPT?E=`<sup>${E}</sup>`:m===ke.SUBSCRIPT&&(E=`<sub>${E}</sub>`),(c==null?void 0:c.s)===K.TRUE&&(E=`<u>${E}</u>`),(h==null?void 0:h.s)===K.TRUE&&(E=`<s>${E}</s>`),l===K.TRUE&&(E=`<strong>${E}</strong>`),i&&D.push(`font-family: ${i}`),f&&D.push(`color: ${f.rgb}`),o&&D.push(`font-size: ${o}pt`),u&&D.push("text-decoration: overline"),d&&D.push(`background: ${d.rgb}`),D.length?`<span style="${D.join("; ")};">${E}</span>`:E}const tl={sheetId:"",range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},el={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},nl={startRow:0,startColumn:0,endRow:0,endColumn:0},sl={row:0,column:0},dn={ff:"Arial",fs:11,it:K.FALSE,bl:K.FALSE,ul:{s:K.FALSE},st:{s:K.FALSE},ol:{s:K.FALSE},tr:{a:0,v:K.FALSE},td:qe.UNSPECIFIED,cl:{rgb:"#000"},bg:{rgb:"#fff"},ht:Ne.UNSPECIFIED,vt:xe.UNSPECIFIED,tb:Pe.UNSPECIFIED,pd:{t:0,r:0,b:0,l:0}},ii={id:"default_slide",title:"defaultSlide",pageSize:{width:300,height:300}};var oi=(t=>(t.ARRAY_CONVERTOR="ARRAY_CONVERTOR",t.MATRIX_CONVERTOR="MATRIX_CONVERTOR",t))(oi||{});function ln(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 K.FALSE;switch(t){case"bl":case"it":{if(o[t]===K.FALSE)return K.FALSE;break}case"ul":case"st":{if(o[t].s===K.FALSE)return K.FALSE;break}default:throw new Error(`unknown style key: ${t} in IStyleBase`)}s+=l-a}return n.dataStream.indexOf(`\r
4
- `)===s?K.TRUE:K.FALSE}const ze=class ze{constructor(n,e,s){g(this,"_range");g(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 ee;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 ee;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=y.numToWord(s+1)+(n+1),o=y.numToWord(r+1)+(e+1)):(i=y.numToWord(r+1)+(e+1),o=y.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)||dn.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 ze(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 c=0;c<=s-e;c++)for(let h=0;h<=i-r;h++){if(o==null||((a=o==null?void 0:o[c])==null?void 0:a[h])==null)continue;const u=o[c][h].s;u&&(o[c][h].s=l.get(u))}}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)||dn.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?ln("ul",n.body)===K.TRUE?{s:K.TRUE}:{s:K.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?ln("st",n.body)===K.TRUE?{s:K.TRUE}:{s:K.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?ln("it",n.body)===K.TRUE?En.ITALIC:En.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?ln("bl",n.body)===K.TRUE?pn.BOLD:pn.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()===Pe.WRAP?K.TRUE:K.FALSE}getWrapStrategies(){return this._getStyles("tb")}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(n){ze.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]||dn[n]}))}};g(ze,"transformRange",(n,e)=>n.rangeType===it.ALL?{startColumn:0,startRow:0,endColumn:e.getMaxColumns()-1,endRow:e.getMaxRows()-1}:n.rangeType===it.COLUMN?{startRow:0,endRow:e.getMaxRows()-1,startColumn:n.startColumn,endColumn:n.endColumn}:n.rangeType===it.ROW?{startColumn:0,endColumn:e.getMaxColumns()-1,startRow:n.startRow,endRow:n.endRow}:n);let He=ze;function rl(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=il(e);o.area>s&&(s=o.area,r={startColumn:o.start,startRow:i-o.height+1,endColumn:o.end,endRow:i})}return r}function il(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 ol(t,n){He.foreach(n,(e,s)=>{t[e][s]=void 0})}function al(t,n){const e=t.toFullArray(),s=[];for(;;){const r=rl(e,n);if(!r)break;s.push(r),ol(e,r)}return s}function ll(t,n,e,s=!1){let r={...t};const i=r.startAbsoluteRefType||At.NONE,o=r.endAbsoluteRefType||At.NONE;return!s&&i===At.ALL&&o===At.ALL?r:s||i===At.NONE&&o===At.NONE?me.moveOffset(r,n,e):(i===At.NONE?r={...r,startRow:r.startRow+e,startColumn:r.startColumn+n}:i===At.COLUMN?r={...r,startRow:r.startRow+e}:i===At.ROW&&(r={...r,startColumn:r.startColumn+n}),o===At.NONE?r={...r,endRow:r.endRow+e,endColumn:r.endColumn+n}:o===At.COLUMN?r={...r,endRow:r.endRow+e}:o===At.ROW&&(r={...r,endColumn:r.endColumn+n}),r)}async function ai(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 li(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 Qe=ut.createIdentifier("univer.context-service");class ui extends Dt{constructor(){super(...arguments);g(this,"_contextChanged$",new Z.Subject);g(this,"contextChanged$",this._contextChanged$.asObservable());g(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 Z.Observable(s=>{const r=this._contextChanged$.pipe(Z.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 ci=(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))(ci||{});const pe=ut.createIdentifier("univer.log");class hi extends Dt{constructor(){super(...arguments);g(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 ul=Object.defineProperty,cl=Object.getOwnPropertyDescriptor,hl=(t,n,e,s)=>{for(var r=s>1?void 0:s?cl(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&&ul(n,e,r),r},Ps=(t,n)=>(e,s)=>n(e,s,t),tn=(t=>(t[t.COMMAND=0]="COMMAND",t[t.OPERATION=1]="OPERATION",t[t.MUTATION=2]="MUTATION",t))(tn||{});const en=ut.createIdentifier("anywhere.command-service");class dl{constructor(){g(this,"_commands",new Map);g(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),bt(()=>{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 di={id:"nil",type:0,handler:()=>!0};exports.CommandService=class extends Dt{constructor(e,s){super();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=s,this._commandRegistry=new dl,this._registerCommand(di)}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),bt(()=>{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),bt(()=>{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(h=>h(a,r));const c=await this._execute(o,s,r);return this._commandExecutedListeners.forEach(h=>h(a,r)),l.dispose(),c}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 u=ka(this._commandExecutionStack,d=>d.type===0);u&&(l.params=(o=l.params)!=null?o:{},l.params.trigger=u.id)}const c=this._pushCommandExecutionStack(l);this._beforeCommandExecutionListeners.forEach(u=>u(l,r));const h=this._syncExecute(a,s,r);return this._commandExecutedListeners.forEach(u=>u(l,r)),c.dispose(),h}throw new Error(`[CommandService]: command "${e}" is not registered.`)}_pushCommandExecutionStack(e){return this._commandExecutionStack.push(e),bt(()=>Tn(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 us;r=new fl(e.id),o.add(this._commandRegistry.registerCommand(r)),o.add(bt(()=>{this._multiCommandDisposables.delete(e.id)})),this._multiCommandDisposables.set(e.id,o)}const i=r.registerImplementation(e);return bt(()=>{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}};exports.CommandService=hl([Ps(0,ut.Inject(ut.Injector)),Ps(1,pe)],exports.CommandService);class fl{constructor(n){g(this,"name");g(this,"multi",!0);g(this,"type",0);g(this,"priority",0);g(this,"_implementations",[]);g(this,"handler",async(n,e)=>{if(!this._implementations.length)return!1;const s=n.get(pe),r=n.get(Qe),i=n.get(ut.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),bt(()=>{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 cs(t,n,e){const s=t.map(r=>()=>n.syncExecuteCommand(r.id,r.params,e));return li(s)}function gl(t,n,e){const s=t.map(r=>()=>n.executeCommand(r.id,r.params,e));return ai(s)}function fi(t){return new Z.Observable(n=>{const e=t((...s)=>n.next(s));return()=>e==null?void 0:e.dispose()})}function gi(t){return function(e){return new Z.Observable(s=>(e.subscribe({next:r=>{s.next(r),t(r)&&s.complete()},complete:()=>s.complete(),error:r=>s.error(r)}),()=>s.unsubscribe()))}}const _l=t=>new Promise(n=>{Z.merge(fi(t.onCommandExecuted.bind(t)).pipe(cn.filter(([e])=>e.type===tn.MUTATION)),Z.timer(300)).pipe(cn.debounceTime(16),cn.first()).subscribe(()=>{n()})});var Xt=(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))(Xt||{});function _i(t){return!!(t&&t.code&&t.code!==Xt.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||{}),mi=(t=>(t[t.SomeCollaborator=0]="SomeCollaborator",t[t.AllCollaborator=1]="AllCollaborator",t[t.OneSelf=2]="OneSelf",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(mi||{}),Ft=(t=>(t[t.Reader=0]="Reader",t[t.Editor=1]="Editor",t[t.Owner=2]="Owner",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(Ft||{}),fn=(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))(fn||{});class Mn extends Dt{}class hs{constructor(){g(this,"_data",[])}static create(){return new hs}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 ds{constructor(){g(this,"_data",new Map)}static create(){return new ds}add(n,e){this._data.has(n)||this._data.set(n,e)}delete(n){this._data.delete(n)}getData(){return this._data}}var Ei=(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))(Ei||{}),ce=(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))(ce||{}),Sn=(t=>(t.BULLET_LIST="BULLET_LIST",t.ORDER_LIST="ORDER_LIST",t))(Sn||{});const ml={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 fs(t){const n=[];for(const e of t){const{ed:s,ts:r}=e;if(e.sId===void 0&&delete e.sId,y.isEmptyObject(r)&&e.sId==null)continue;if(n.length===0){n.push(e);continue}const i=n.pop();zr(e,i)&&y.hasIntersectionBetweenTwoRanges(i.st,i.ed,e.st,e.ed)?n.push({...e,st:i.st,ed:s}):n.push(i,e)}return n}function pi(t,n,e,s){var c;const{textRuns:r}=t;if(r==null)return;const i=[],o=r.length;let a=!1;const l=(c=n.textRuns)!=null?c:[];if(l.length)for(const h of l)h.st+=s,h.ed+=s;for(let h=0;h<o;h++){const u=r[h],d=r[h+1],{st:f,ed:m}=u;if(m<s)i.push(u);else if(s>=f&&s<=m){if(d&&d.st===d.ed&&s===d.st){i.push(u);continue}if(a)u.st+=e,u.ed+=e,i.push(u);else{a=!0,u.ed+=e;const E=[];if(l.length){const D={...u,st:f,ed:l[0].st};D.ed>D.st&&E.push(D),E.push(...l);const P=l[l.length-1],tt={...u,st:P.ed,ed:m+e};tt.ed>tt.st&&E.push(tt)}else E.push(u);i.push(...E)}}else u.st+=e,u.ed+=e,a||(a=!0,i.push(...l)),i.push(u)}a||(a=!0,i.push(...l)),t.textRuns=fs(i)}function gs(t,n,e,s){const{paragraphs:r}=t;if(r==null)return;const{paragraphs:i,dataStream:o}=n,a=[];let l=-1;for(let h=0,u=r.length;h<u;h++){const d=r[h],{startIndex:f}=d;f>=s&&(d.startIndex+=e),l===-1&&f>=s&&(l=h),a.push(d.startIndex)}let c=-1;if(i){for(let h=0,u=i.length;h<u;h++){const d=i[h];d.startIndex+=s;const f=d.startIndex;c=a.indexOf(f)}if(o===ce.PARAGRAPH&&i.length===1){const h=r[l],u=i[0],d=h.paragraphStyle,f=h.bullet;h.paragraphStyle=u.paragraphStyle,h.bullet=u.bullet,u.paragraphStyle=d,u.bullet=f}c!==-1&&r.splice(c,1),r.push(...i),r.sort(Me("startIndex"))}}function El(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:c}=l;c>=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(Me("startIndex"))}}function Ri(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:c}=l;c>=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(Me("startIndex"))}}function Ci(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:c,endIndex:h}=l;c>s?(l.startIndex+=e,l.endIndex+=e):h>=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(Me("startIndex"))}}function Ii(t,n,e,s){t.customRanges||(t.customRanges=[]);const{customRanges:r}=t,i={};for(let a=0,l=r.length;a<l;a++){const c=r[a];i[c.rangeId]=c;const{startIndex:h,endIndex:u}=c;h>=s?(c.startIndex+=e,c.endIndex+=e):u>s-1&&(c.endIndex+=e)}const o=[];if(n.customRanges){for(let a=0,l=n.customRanges.length;a<l;a++){const c=n.customRanges[a],h=i[c.rangeId];if(c.startIndex+=s,c.endIndex+=s,h){if(h.startIndex<=c.startIndex&&h.endIndex>=c.endIndex)continue;if(t.dataStream[h.startIndex]===ce.CUSTOM_RANGE_START&&t.dataStream[h.endIndex]===ce.CUSTOM_RANGE_END){o.push(c);continue}if(t.dataStream[h.startIndex]===ce.CUSTOM_RANGE_START){h.endIndex=c.endIndex;continue}if(t.dataStream[h.endIndex]===ce.CUSTOM_RANGE_END){h.startIndex=c.startIndex;continue}}o.push(c)}r.push(...o),r.sort(Me("startIndex"))}}function pl(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 Rl(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=pl(s);n[e]=r}),Object.values(n).flat()}function Si(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:c}=a;l>=s?(a.startIndex+=e,a.endIndex+=e):c>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=Rl(r),t.customDecorations.sort(Me("startIndex"))}}function Oi(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(c=>c.st===e&&c.ed===e);return o.push({...l,st:l.st-e,ed:l.ed-e}),t.textRuns=(a=t.textRuns)==null?void 0:a.filter(c=>c!==l),o}if(s){const l=[];for(let c=0,h=s.length;c<h;c++){const u=s[c],{st:d,ed:f}=u;if(r<=d&&i>=f){o.push({...u,st:d-r,ed:f-r});continue}else d<=r&&f>=i?(o.push({...u,st:r-r,ed:i-r}),u.ed-=n):r>=d&&r<f?(o.push({...u,st:r-r,ed:f-r}),u.ed=r):i>d&&i<=f?(o.push({...u,st:d-r,ed:i-r}),u.st=i-n,u.ed-=n):d>=i&&(u.st-=n,u.ed-=n);l.push(u)}t.textRuns=l}return o.length===0&&o.push({st:0,ed:n,ts:{}}),o}function Ni(t,n,e){const{paragraphs:s}=t,r=e,i=e+n,o=[];if(s){const a=[];for(let l=0,c=s.length;l<c;l++){const h=s[l],{startIndex:u}=h;if(u>=r&&u<i){o.push({...h,startIndex:u-e});continue}else u>=i&&(h.startIndex-=n);a.push(h)}t.paragraphs=a}return o}function Ai(t,n,e){const{sectionBreaks:s}=t,r=e,i=e+n-1,o=[];if(s){const a=[];for(let l=0,c=s.length;l<c;l++){const h=s[l],{startIndex:u}=h;if(u>=r&&u<=i){o.push({...h,startIndex:u-e});continue}else u>i&&(h.startIndex-=n);a.push(h)}t.sectionBreaks=a}return o}function bi(t,n,e){const{customBlocks:s}=t,r=e,i=e+n-1,o=[];if(s){const a=[];for(let l=0,c=s.length;l<c;l++){const h=s[l],{startIndex:u}=h;if(u>=r&&u<=i){o.push({...h,startIndex:u-e});continue}else u>i&&(h.startIndex-=n);a.push(h)}t.customBlocks=a}return o}function vi(t,n,e){const{tables:s}=t,r=e,i=e+n-1,o=[];if(s){const a=[];for(let l=0,c=s.length;l<c;l++){const h=s[l],{startIndex:u,endIndex:d}=h;if(r<=u&&i>=d){o.push({...h,startIndex:u-e,endIndex:d-e});continue}else if(u<=r&&d>=i){const f=wn(u,d,r,i);h.startIndex=f[0],h.endIndex=f[1]}else i<u&&(h.startIndex-=n,h.endIndex-=n);a.push(h)}t.tables=a}return o}function wi(t,n,e){const{customRanges:s}=t,r=e,i=e+n-1,o=[];if(s){const a=[];for(let l=0,c=s.length;l<c;l++){const h=s[l],{startIndex:u,endIndex:d}=h;if(r<=u&&i>=u){o.push({...h,startIndex:u-e,endIndex:d-e});continue}else if(u<=r&&d>=i){const f=wn(u,d,r,i);h.startIndex=f[0],h.endIndex=f[1]}else i<u&&(h.startIndex-=n,h.endIndex-=n);a.push(h)}t.customRanges=a}return o}function Ti(t,n,e,s=!0){const{customDecorations:r}=t,i=e,o=e+n-1,a=[];if(r){const l=[];for(let c=0,h=r.length;c<h;c++){const u=r[c],{startIndex:d,endIndex:f}=u;if(d>=i&&f<=o){a.push(u);continue}else if(Math.max(i,d)<=Math.min(o,f)){const m=wn(d,f,i,o);u.startIndex=m[0],u.endIndex=m[1]}else o<d&&s&&(u.startIndex-=n,u.endIndex-=n);l.push(u)}t.customDecorations=l}return a}function Cl(t,n,e,s,r){const i=Il(t,n,e,s,r),o=Sl(t,n,e,s,r),a=Ol(t,n,e,s,r),l=Nl(t,n,e,s,r),c=Al(t,n,e,s,r),h=bl(t,n,e,s,r),u=vl(t,n,e,s,r);return{dataStream:"",textRuns:i,paragraphs:o,sectionBreaks:a,customBlocks:l,tables:c,customRanges:h,customDecorations:u}}function Il(t,n,e,s,r){const{textRuns:i}=t,{textRuns:o}=n;if(i==null||o==null)return;const a=Oi(t,e,s);if(r!==Pt.REPLACE){const l=Mi(o,a,r);n.textRuns=l}return pi(t,n,e,s),a}function Mi(t,n,e){if(n.length===0)return t;t=y.deepClone(t),n=y.deepClone(n);const s=[],r=t.length,i=n.length;let o=0,a=0,l=null;function c(){return l?(s.push(l),l=null,!0):!1}for(;o<r&&a<i;){const{st:f,ed:m,ts:E}=t[o],{st:D,ed:P,ts:tt,sId:mt}=n[a];let ht;if(e===Pt.COVER?ht={...tt,...E}:ht={...E,...tt},m<D)c()||s.push(t[o]),o++;else if(P<f)c()||s.push(n[a]),a++;else{const p={st:Math.min(f,D),ed:Math.max(f,D),ts:f<D?{...E}:{...tt},sId:f<D?void 0:mt};p.ed>p.st&&s.push(p),s.push({st:Math.max(f,D),ed:Math.min(m,P),ts:ht,sId:mt}),m<P?(o++,n[a].st=m,n[a].st===n[a].ed&&a++):(a++,t[o].st=P,t[o].st===t[o].ed&&o++);const S={st:Math.min(m,P),ed:Math.max(m,P),ts:m<P?{...tt}:{...E},sId:m<P?mt:void 0};l=S.ed>S.st?S:null}}c();const h=s[s.length-1],u=t[r-1],d=n[i-1];return h.ed!==Math.max(u.ed,d.ed)&&(u.ed>d.ed?s.push(u):s.push(d)),fs(s)}function Sl(t,n,e,s,r){const{paragraphs:i}=t,{paragraphs:o}=n;if(i==null||o==null)return;const a=Ni(t,e,s);if(r!==Pt.REPLACE){const l=[];for(const c of o){const{startIndex:h,paragraphStyle:u,bullet:d}=c;let f=[];for(const m of a){const{startIndex:E,paragraphStyle:D,bullet:P}=m;let tt,mt;if(r===Pt.COVER?(tt={...D,...u},mt={listId:"",listType:Sn.BULLET_LIST,nestingLevel:0,textStyle:{},...P,...d}):(tt={...u,...D},mt={listId:"",listType:Sn.BULLET_LIST,nestingLevel:0,textStyle:{},...d,...P}),h===E){f.push({startIndex:h,paragraphStyle:tt,bullet:mt});break}}l.push(...f),f=[]}n.paragraphs=l}return gs(t,n,e,s),a}function Ol(t,n,e,s,r){const{sectionBreaks:i}=t,{sectionBreaks:o}=n;if(i==null||o==null)return;const a=Ai(t,e,s);if(r!==Pt.REPLACE){const l=[];for(const c of o){const{startIndex:h}=c;let u=[];for(const d of a){const{startIndex:f}=d;if(h===f){r===Pt.COVER?u.push({...d,...c}):u.push({...c,...d});break}}l.push(...u),u=[]}n.sectionBreaks=l}return gs(t,n,e,s),a}function Nl(t,n,e,s,r){const{customBlocks:i}=t,{customBlocks:o}=n;if(i==null||o==null)return;const a=bi(t,e,s);if(r!==Pt.REPLACE){const l=[];for(const c of o){const{startIndex:h}=c;let u=[];for(const d of a){const{startIndex:f}=d;if(h===f){r===Pt.COVER?u.push({...d,...c}):u.push({...c,...d});break}}l.push(...u),u=[]}n.customBlocks=l}return Ri(t,n,e,s),a}function Al(t,n,e,s,r){const{tables:i}=t,{tables:o}=n;if(i==null||o==null)return;const a=vi(t,e,s);if(r!==Pt.REPLACE){const l=[];for(const c of o){const{startIndex:h,endIndex:u}=c;let d=[];for(const f of a){const{startIndex:m,endIndex:E}=f;if(m>=h&&E<=u){r===Pt.COVER?d.push({...f,...c}):d.push({...c,...f});break}}l.push(...d),d=[]}n.tables=l}return Ci(t,n,e,s),a}function bl(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===Pt.REPLACE&&(a=wi(t,e,s)),Ii(t,n,0,s),a}function vl(t,n,e,s,r){t.customDecorations||(t.customDecorations=[]);let i=[];return r===Pt.REPLACE&&(i=Ti(t,e,s,!1)),Si(t,n,0,s),i}function Ze(t,n,e,s=!1){const{dataStream:r,textRuns:i=[],paragraphs:o=[],customBlocks:a=[]}=t,l={dataStream:r.slice(n,e)},c=[];for(const f of i){const m=y.deepClone(f),{st:E,ed:D}=m;y.hasIntersectionBetweenTwoRanges(E,D,n,e)&&(n>=E&&n<=D?c.push({...m,st:n,ed:Math.min(e,D)}):e>=E&&e<=D?c.push({...m,st:Math.max(n,E),ed:e}):c.push(m))}c.length?l.textRuns=c.map(f=>{const{st:m,ed:E}=f;return{...f,st:m-n,ed:E-n}}):s&&(l.textRuns=[{st:0,ed:e-n,ts:{}}]);const h=[];for(const f of o){const{startIndex:m}=f;m>=n&&m<=e&&h.push(y.deepClone(f))}h.length&&(l.paragraphs=h.map(f=>({...f,startIndex:f.startIndex-n}))),l.customDecorations=Li(t,n,e);const{customRanges:u}=Ui(t,n,e);l.customRanges=u;const d=[];for(const f of a){const{startIndex:m}=f;m>=n&&m<=e&&d.push(y.deepClone(f))}return d.length&&(l.customBlocks=d.map(f=>({...f,startIndex:f.startIndex-n}))),l}function wl(t){const{dataStream:n,textRuns:e,paragraphs:s,customRanges:r,customDecorations:i}=t;let o=0,a=0;r==null||r.forEach(c=>{c.startIndex<0&&(o=Math.max(o,-c.startIndex)),c.endIndex>n.length-1&&(a=Math.max(a,c.endIndex-n.length+1))});const l=`${ce.CUSTOM_RANGE_START.repeat(o)}${n}${ce.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(c=>{c.st+=o,c.ed+=o}),s==null||s.forEach(c=>{c.startIndex+=o}),r==null||r.forEach(c=>{c.startIndex+=o,c.endIndex+=o}),i==null||i.forEach(c=>{c.startIndex+=o,c.endIndex+=a}),{...t,dataStream:l,textRuns:e,paragraphs:s,customRanges:r,customDecorations:i}}function Ui(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,c)=>c.endIndex-l.endIndex);for(let l=0;l<i;l++){const c=a[l];c.endIndex=e+i-l-1}}}return{customRanges:o.map(a=>({...a,startIndex:a.startIndex-n,endIndex:a.endIndex-n})),leftOffset:r,rightOffset:i}}function Li(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=y.deepClone(i);r.push({...o,startIndex:Math.max(o.startIndex-n,0),endIndex:Math.min(o.endIndex,e)-n})}}),r}function ts(t,n,e=Pt.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=Mi(o,r,e);l.length&&(s.textRuns=l);const c=[];let h=0,u=0;for(;h<i.length&&u<a.length;){const d=i[h],f=a[u],{startIndex:m}=d,{startIndex:E}=f;m===E?(c.push(y.deepMerge(d,f)),h++,u++):m<E?(c.push(y.deepClone(d)),h++):(c.push(y.deepClone(f)),u++)}return h<i.length&&c.push(...i.slice(h)),u<a.length&&c.push(...a.slice(u)),c.length&&(s.paragraphs=c),s}function Tl(t){const{body:n}=t;if(n==null)return!0;const{textRuns:e=[],paragraphs:s=[]}=n;return e.length===0&&s.length===0}function Ml(t=y.generateRandomId(6),n=Te.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 $t=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ul(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Wt={},Di={},_s={};Object.defineProperty(_s,"__esModule",{value:!0});function Ll(t,n){if(Array.isArray(n))return!1;for(let e in t)if(!ms(t[e],n[e]))return!1;for(let e in n)if(t[e]===void 0)return!1;return!0}function Dl(t,n){if(!Array.isArray(n)||t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(!ms(t[e],n[e]))return!1;return!0}function ms(t,n){return t===n?!0:t===null||n===null||typeof t!="object"||typeof n!="object"?!1:Array.isArray(t)?Dl(t,n):Ll(t,n)}_s.default=ms;var Es={};Object.defineProperty(Es,"__esModule",{value:!0});function es(t){if(t===null)return null;if(Array.isArray(t))return t.map(es);if(typeof t=="object"){const n={};for(let e in t)n[e]=es(t[e]);return n}else return t}Es.default=es;var ps={};(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(h,u){if(!h)throw new Error(u)}const e=h=>h!=null&&typeof h=="object"&&!Array.isArray(h),s=(h,u)=>typeof h==typeof u?h>u:typeof h=="string"&&typeof u=="number";function r(h,u){for(let d in h){const f=d;u.write(f,h[f])}}t.isValidPathItem=h=>typeof h=="number"||typeof h=="string"&&h!=="__proto__";class i{constructor(u=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=u}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 u=[];let d=this.container,f=this.parents.length-1,m=this.idx;for(;m>=0;)u.unshift(d[m]),m===0?(m=this.indexes[f*2],d=this.parents[f--]):m-=e(d[m-1])?2:1;return u}}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 u;return this.container&&this.container.length>this.idx+1&&e(u=this.container[this.idx+1])?u:null}descendFirst(){let u=this.idx+1;if(!this.container||u>=this.container.length||e(this.container[u])&&u+1>=this.container.length)return!1;e(this.container[u])&&u++;const d=this.container[u];return Array.isArray(d)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(u),this.idx=0,this.container=d):this.idx=u,!0}nextSibling(){if(n(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;const u=this.indexes[this.indexes.length-1]+1,d=this.parents[this.parents.length-1];return u>=d.length?!1:(n(!isNaN(u)),this.indexes[this.indexes.length-1]=u,this.container=d[u],!0)}_init(u,d,f,m){this.container=u,this.idx=d,this.parents=f.slice(),this.indexes=m.slice()}clone(){const u=new o;return u._init(this.container,this.idx,this.parents,this.indexes),u}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(u,d){const f=this.getComponent();f&&d(f,u);for(const m of this)u&&u.descend(m),this.traverse(u,d),u&&u.ascend()}eachPick(u,d){this.traverse(u,(f,m)=>{f.p!=null&&d(f.p,m)})}eachDrop(u,d){this.traverse(u,(f,m)=>{f.d!=null&&d(f.d,m)})}}t.ReadCursor=o;class a extends i{constructor(u=null){super(u),this.pendingDescent=[],this._op=u}flushDescent(){n(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let u=0;u<this.pendingDescent.length;u++){const d=this.pendingDescent[u];let f=this.idx+1;if(f<this.container.length&&e(this.container[f])&&f++,n(f===this.container.length||!e(this.container[f])),f===this.container.length)this.container.push(d),this.idx=f;else if(this.container[f]===d)this.idx=f;else{if(!Array.isArray(this.container[f])){const m=this.container.splice(f,this.container.length-f);this.container.push(m),this.lcIdx>-1&&(this.lcIdx=f)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(n(s(d,this.container[this.lcIdx][0])),f=this.lcIdx+1,this.lcIdx=-1);f<this.container.length&&s(d,this.container[f][0]);)f++;if(this.indexes.push(f),this.idx=0,f<this.container.length&&this.container[f][0]===d)this.container=this.container[f];else{const m=[d];this.container.splice(f,0,m),this.container=m}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();const u=this.idx+1;if(u<this.container.length&&e(this.container[u]))return this.container[u];{const d={};return this.container.splice(u,0,d),d}}write(u,d){const f=this.getComponent();n(f[u]==null||f[u]===d,"Internal consistency error: Overwritten component. File a bug"),f[u]=d}get(){return this._op}descend(u){if(!t.isValidPathItem(u))throw Error("Invalid JSON key");this.pendingDescent.push(u)}descendPath(u){return this.pendingDescent.push(...u),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(u,d=r){if(u===null)return;if(n(Array.isArray(u)),u===this._op)throw Error("Cannot merge into my own tree");const f=this.lcIdx,m=this.parents.length;let E=0;for(let D=0;D<u.length;D++){const P=u[D];typeof P=="string"||typeof P=="number"?(E++,this.descend(P)):Array.isArray(P)?this.mergeTree(P,d):typeof P=="object"&&d(P,this)}for(;E--;)this.ascend();this.lcIdx=this.parents.length===m?f:-1}at(u,d){this.descendPath(u),d(this);for(let f=0;f<u.length;f++)this.ascend();return this}writeAtPath(u,d,f){return this.at(u,()=>this.write(d,f)),this.reset(),this}writeMove(u,d,f=0){return this.writeAtPath(u,"p",f).writeAtPath(d,"d",f)}getPath(){const u=super.getPath();return u.push(...this.pendingDescent),u}}t.WriteCursor=a,t.writeCursor=()=>new a,t.readCursor=h=>new o(h);function l(h,u,d){let f,m;m=f=h?h.descendFirst():!1;function E(D){let P;for(;m;){const tt=P=h.getKey();if(D!=null){let mt=!1;if(u&&typeof tt=="number"&&(P=u(tt,h.getComponent()),P<0&&(P=~P,mt=!0)),s(P,D))return null;if(P===D&&!mt)return h}d&&typeof P=="number"&&d(P,h.getComponent()),m=h.nextSibling()}return null}return E.end=()=>{f&&h.ascend()},E}t.advancer=l;function c(h,u,d){let f,m,E,D;for(f=m=h&&h.descendFirst(),E=D=u&&u.descendFirst();f||E;){let P=f?h.getKey():null,tt=E?u.getKey():null;P!==null&&tt!==null&&(s(tt,P)?tt=null:P!==tt&&(P=null)),d(P==null?tt:P,P!=null?h:null,tt!=null?u:null),P!=null&&f&&(f=h.nextSibling()),tt!=null&&E&&(E=u.nextSibling())}m&&h.ascend(),D&&u.ascend()}t.eachChildOf=c})(ps);var Rs={};(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={}))})(Rs);var Bn={},Oe={},ks;function Cs(){return ks||(ks=1,Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.uniToStrPos=Oe.strPosToUni=void 0,Oe.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},Oe.uniToStrPos=(t,n)=>{let e=0;for(;n>0;n--){const s=t.charCodeAt(e);e+=s>=55296&&s<=57343?2:1}return e}),Oe}var Gn={},Hs;function ns(){return Hs||(Hs=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.uniSlice=t.dlen=t.eachOp=void 0;const n=Cs(),e=p=>{if(!Array.isArray(p))throw Error("Op must be an array of components");let S=null;for(let v=0;v<p.length;v++){const z=p[v];switch(typeof z){case"object":if(typeof z.d!="number"&&typeof z.d!="string")throw Error("Delete must be number or string");if(t.dlen(z.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(z.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(z>0))throw Error("Skip components must be >0");if(typeof S=="number")throw Error("Adjacent skip components should be combined");break}S=z}if(typeof S=="number")throw Error("Op has a trailing skip")};function s(p,S){let v=0,z=0;for(let nt=0;nt<p.length;nt++){const X=p[nt];switch(S(X,v,z),typeof X){case"object":v+=t.dlen(X.d);break;case"string":z+=n.strPosToUni(X);break;case"number":v+=X,z+=X;break}}}t.eachOp=s;function r(p,S){const v=[],z=a(v);return s(p,(nt,X,Gt)=>{z(S(nt,X,Gt))}),u(v)}const i=p=>p,o=p=>r(p,i);t.dlen=p=>typeof p=="number"?p:n.strPosToUni(p);const a=p=>S=>{if(!(!S||S.d===0||S.d===""))if(p.length===0)p.push(S);else if(typeof S==typeof p[p.length-1])if(typeof S=="object"){const v=p[p.length-1];v.d=typeof v.d=="string"&&typeof S.d=="string"?v.d+S.d:t.dlen(v.d)+t.dlen(S.d)}else p[p.length-1]+=S;else p.push(S)},l=p=>typeof p=="number"?p:typeof p=="string"?n.strPosToUni(p):typeof p.d=="number"?p.d:n.strPosToUni(p.d);t.uniSlice=(p,S,v)=>{const z=n.uniToStrPos(p,S),nt=v==null?1/0:n.uniToStrPos(p,v);return p.slice(z,nt)};const c=(p,S,v)=>typeof p=="number"?v==null?p-S:Math.min(p,v)-S:t.uniSlice(p,S,v),h=p=>{let S=0,v=0;return{take:(X,Gt)=>{if(S===p.length)return X===-1?null:X;const Ot=p[S];let gt;if(typeof Ot=="number")return X===-1||Ot-v<=X?(gt=Ot-v,++S,v=0,gt):(v+=X,X);if(typeof Ot=="string"){if(X===-1||Gt==="i"||n.strPosToUni(Ot.slice(v))<=X)return gt=Ot.slice(v),++S,v=0,gt;{const It=v+n.uniToStrPos(Ot.slice(v),X);return gt=Ot.slice(v,It),v=It,gt}}else{if(X===-1||Gt==="d"||t.dlen(Ot.d)-v<=X)return gt={d:c(Ot.d,v)},++S,v=0,gt;{let It=c(Ot.d,v,v+X);return v+=X,{d:It}}}},peek:()=>p[S]}},u=p=>(p.length>0&&typeof p[p.length-1]=="number"&&p.pop(),p);function d(p,S,v){if(v!=="left"&&v!=="right")throw Error("side ("+v+") must be 'left' or 'right'");e(p),e(S);const z=[],nt=a(z),{take:X,peek:Gt}=h(p);for(let gt=0;gt<S.length;gt++){const It=S[gt];let Tt,jt;switch(typeof It){case"number":for(Tt=It;Tt>0;)jt=X(Tt,"i"),nt(jt),typeof jt!="string"&&(Tt-=l(jt));break;case"string":v==="left"&&typeof Gt()=="string"&&nt(X(-1)),nt(n.strPosToUni(It));break;case"object":for(Tt=t.dlen(It.d);Tt>0;)switch(jt=X(Tt,"i"),typeof jt){case"number":Tt-=jt;break;case"string":nt(jt);break;case"object":Tt-=t.dlen(jt.d)}break}}let Ot;for(;Ot=X(-1);)nt(Ot);return u(z)}function f(p,S){e(p),e(S);const v=[],z=a(v),{take:nt}=h(p);for(let Gt=0;Gt<S.length;Gt++){const Ot=S[Gt];let gt,It;switch(typeof Ot){case"number":for(gt=Ot;gt>0;)It=nt(gt,"d"),z(It),typeof It!="object"&&(gt-=l(It));break;case"string":z(Ot);break;case"object":gt=t.dlen(Ot.d);let Tt=0;for(;Tt<gt;)switch(It=nt(gt-Tt,"d"),typeof It){case"number":z({d:c(Ot.d,Tt,Tt+It)}),Tt+=It;break;case"string":Tt+=n.strPosToUni(It);break;case"object":z(It)}break}}let X;for(;X=nt(-1);)z(X);return u(v)}const m=(p,S)=>{let v=0;for(let z=0;z<S.length&&p>v;z++){const nt=S[z];switch(typeof nt){case"number":{v+=nt;break}case"string":const X=n.strPosToUni(nt);v+=X,p+=X;break;case"object":p-=Math.min(t.dlen(nt.d),p-v);break}}return p},E=(p,S)=>typeof p=="number"?m(p,S):p.map(v=>m(v,S));function D(p,S,v){return r(p,(z,nt)=>typeof z=="object"&&typeof z.d=="number"?{d:v.slice(S,nt,nt+z.d)}:z)}function P(p){return r(p,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 tt(p){return r(p,S=>typeof S=="object"&&typeof S.d=="string"?{d:n.strPosToUni(S.d)}:S)}function mt(p){let S=!0;return s(p,v=>{typeof v=="object"&&typeof v.d=="number"&&(S=!1)}),S}function ht(p){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:u,normalize:o,checkOp:e,create(S=""){if(typeof S!="string")throw Error("Initial data must be a string");return p.create(S)},apply(S,v){e(v);const z=p.builder(S);for(let nt=0;nt<v.length;nt++){const X=v[nt];switch(typeof X){case"number":z.skip(X);break;case"string":z.append(X);break;case"object":z.del(t.dlen(X.d));break}}return z.build()},transform:d,compose:f,transformPosition:m,transformSelection:E,isInvertible:mt,makeInvertible(S,v){return D(S,v,p)},stripInvertible:tt,invert:P,invertWithDoc(S,v){return P(D(S,v,p))},isNoop:S=>S.length===0}}t.default=ht}(Gn)),Gn}var un={},Fs;function yl(){if(Fs)return un;Fs=1,Object.defineProperty(un,"__esModule",{value:!0});const t=ns(),n=Cs();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 c=t.dlen(o.d);this.onRemove&&this.onRemove(l,c)}})},onInsert:null,onRemove:null}}return un.default=e,e.provides={text:!0},un}var Ws;function xl(){return Ws||(Ws=1,function(t){var n=$t&&$t.__createBinding||(Object.create?function(d,f,m,E){E===void 0&&(E=m),Object.defineProperty(d,E,{enumerable:!0,get:function(){return f[m]}})}:function(d,f,m,E){E===void 0&&(E=m),d[E]=f[m]}),e=$t&&$t.__setModuleDefault||(Object.create?function(d,f){Object.defineProperty(d,"default",{enumerable:!0,value:f})}:function(d,f){d.default=f}),s=$t&&$t.__importStar||function(d){if(d&&d.__esModule)return d;var f={};if(d!=null)for(var m in d)Object.hasOwnProperty.call(d,m)&&n(f,d,m);return e(f,d),f},r=$t&&$t.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(t,"__esModule",{value:!0}),t.type=t.remove=t.insert=void 0;const i=Cs(),o=s(ns()),a=r(yl()),l={create(d){return d},toString(d){return d},builder(d){if(typeof d!="string")throw Error("Invalid document snapshot: "+d);const f=[];return{skip(m){let E=i.uniToStrPos(d,m);if(E>d.length)throw Error("The op is too long for this document");f.push(d.slice(0,E)),d=d.slice(E)},append(m){f.push(m)},del(m){d=d.slice(i.uniToStrPos(d,m))},build(){return f.join("")+d}}},slice:o.uniSlice},c=o.default(l),h=Object.assign(Object.assign({},c),{api:a.default});t.type=h,t.insert=(d,f)=>f.length===0?[]:d===0?[f]:[d,f],t.remove=(d,f)=>o.dlen(f)===0?[]:d===0?[{d:f}]:[d,{d:f}];var u=ns();Object.defineProperty(t,"makeType",{enumerable:!0,get:function(){return u.default}})}(Bn)),Bn}(function(t){var n=$t&&$t.__importDefault||function(_){return _&&_.__esModule?_:{default:_}};Object.defineProperty(t,"__esModule",{value:!0}),t.editOp=t.replaceOp=t.insertOp=t.moveOp=t.removeOp=t.type=void 0;const e=n(_s),s=n(Es),r=ps,i=Rs;function o(_,R){if(!_)throw new Error(R)}t.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:r.readCursor,writeCursor:r.writeCursor,create:_=>_,isNoop:_=>_==null,setDebug(_){},registerSubtype:P,checkValidOp:nt,normalize:X,apply:Gt,transformPosition:Ot,compose:gt,tryTransform:kn,transform:wo,makeInvertible:jt,invert:It,invertWithDoc:vo,RM_UNEXPECTED_CONTENT:i.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:i.ConflictType.DROP_COLLISION,BLACKHOLE:i.ConflictType.BLACKHOLE,transformNoConflict:(_,R,N)=>Ts(()=>!0,_,R,N),typeAllowingConflictsPred:_=>Object.assign(Object.assign({},t.type),{transform:(R,N,M)=>Ts(_,R,N,M)})};const a=_=>_?_.getComponent():null;function l(_){return _&&typeof _=="object"&&!Array.isArray(_)}const c=_=>Array.isArray(_)?_.slice():_!==null&&typeof _=="object"?Object.assign({},_):_,h=_=>_&&(_.p!=null||_.r!==void 0),u=_=>_&&(_.d!=null||_.i!==void 0);function d(_,R){return o(_!=null),typeof R=="number"?(o(Array.isArray(_),"Invalid key - child is not an array"),(_=_.slice()).splice(R,1)):(o(l(_),"Invalid key - child is not an object"),delete(_=Object.assign({},_))[R]),_}function f(_,R,N){return typeof R=="number"?(o(_!=null,"Container is missing for key"),o(Array.isArray(_),"Cannot use numerical key for object container"),o(_.length>=R,"Cannot insert into out of bounds index"),_.splice(R,0,N)):(o(l(_),"Cannot insert into missing item"),o(_[R]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),_[R]=N),N}t.removeOp=(_,R=!0)=>r.writeCursor().writeAtPath(_,"r",R).get(),t.moveOp=(_,R)=>r.writeCursor().writeMove(_,R).get(),t.insertOp=(_,R)=>r.writeCursor().writeAtPath(_,"i",R).get(),t.replaceOp=(_,R,N)=>r.writeCursor().at(_,M=>{M.write("r",R),M.write("i",N)}).get(),t.editOp=(_,R,N,M=!1)=>r.writeCursor().at(_,A=>S(A,R,N,M)).get();const m=(_,R)=>_!=null&&(typeof R=="number"?Array.isArray(_):typeof _=="object"),E=(_,R)=>m(_,R)?_[R]:void 0,D={};function P(_){let R=_.type?_.type:_;R.name&&(D[R.name]=R),R.uri&&(D[R.uri]=R)}const tt=_=>{const R=D[_];if(R)return R;throw Error("Missing type: "+_)};P(xl());const mt=(_,R)=>_+R;P({name:"number",apply:mt,compose:mt,invert:_=>-_,transform:_=>_});const ht=_=>_==null?null:_.et?tt(_.et):_.es?D["text-unicode"]:_.ena!=null?D.number:null,p=_=>_.es?_.es:_.ena!=null?_.ena:_.e,S=(_,R,N,M=!1)=>{const[A,T]=typeof R=="string"?[tt(R),R]:[R,R.name];!M&&A.isNoop&&A.isNoop(N)||(T==="number"?_.write("ena",N):T==="text-unicode"?_.write("es",N):(_.write("et",T),_.write("e",N)))};function v(_){o(typeof _=="number"),o(_>=0),o(_===(0|_))}function z(_){typeof _=="number"?v(_):o(typeof _=="string")}function nt(_){if(_===null)return;const R=new Set,N=new Set,M=T=>{let G=!0,$=!1;for(let C in T){const O=T[C];if(G=!1,o(C==="p"||C==="r"||C==="d"||C==="i"||C==="e"||C==="es"||C==="ena"||C==="et","Invalid component item '"+C+"'"),C==="p")v(O),o(!R.has(O)),R.add(O),o(T.r===void 0);else if(C==="d")v(O),o(!N.has(O)),N.add(O),o(T.i===void 0);else if(C==="e"||C==="es"||C==="ena"){o(!$),$=!0;const b=ht(T);o(b,"Missing type in edit"),b.checkValidOp&&b.checkValidOp(p(T))}}o(!G)},A=(T,G,$)=>{if(!Array.isArray(T))throw Error("Op must be null or a list");if(T.length===0)throw Error("Empty descent");G||z(T[0]);let C=1,O=0,b=0;for(let w=0;w<T.length;w++){const B=T[w];if(o(B!=null),Array.isArray(B)){const j=A(B,!1);if(O){const I=typeof b,H=typeof j;I===H?o(b<j,"descent keys are not in order"):o(I==="number"&&H==="string")}b=j,O++,C=3}else typeof B=="object"?(o(C===1,`Prev not scalar - instead ${C}`),M(B),C=2):(o(C!==3),z(B),o(r.isValidPathItem(B),"Invalid path key"),C=1)}return o(O!==1,"Operation makes multiple descents. Remove some []"),o(C===2||C===3),T[0]};A(_,!0),o(R.size===N.size,"Mismatched picks and drops in op");for(let T=0;T<R.size;T++)o(R.has(T)),o(N.has(T))}function X(_){let R=0,N=[];const M=r.writeCursor();return M.mergeTree(_,(A,T)=>{const G=ht(A);if(G){const C=p(A);S(T,G,G.normalize?G.normalize(C):C)}for(const C of["r","p","i","d"])if(A[C]!==void 0){const O=C==="p"||C==="d"?($=A[C],N[$]==null&&(N[$]=R++),N[$]):A[C];T.write(C,O)}var $}),M.get()}function Gt(_,R){if(nt(R),R===null)return _;const N=[];return function M(A,T){let G=A,$=0,C={root:A},O=0,b=C,w="root";function B(){for(;O<$;O++){let j=T[O];typeof j!="object"&&(o(m(b,w)),b=b[w]=c(b[w]),w=j)}}for(;$<T.length;$++){const j=T[$];if(Array.isArray(j)){const I=M(G,j);I!==G&&I!==void 0&&(B(),G=b[w]=I)}else if(typeof j=="object"){j.d!=null?(B(),G=f(b,w,N[j.d])):j.i!==void 0&&(B(),G=f(b,w,j.i));const I=ht(j);if(I)B(),G=b[w]=I.apply(G,p(j));else if(j.e!==void 0)throw Error("Subtype "+j.et+" undefined")}else G=E(G,j)}return C.root}(_=function M(A,T){const G=[];let $=0;for(;$<T.length;$++){const w=T[$];if(Array.isArray(w))break;typeof w!="object"&&(G.push(A),A=E(A,w))}for(let w=T.length-1;w>=$;w--)A=M(A,T[w]);for(--$;$>=0;$--){const w=T[$];if(typeof w!="object"){const B=G.pop();A=A===E(B,w)?B:A===void 0?d(B,w):(O=w,b=A,(C=c(C=B))[O]=b,C)}else h(w)&&(o(A!==void 0,"Cannot pick up or remove undefined"),w.p!=null&&(N[w.p]=A),A=void 0)}var C,O,b;return A}(_,R),R)}function Ot(_,R){_=_.slice(),nt(R);const N=r.readCursor(R);let M,A,T=!1;const G=[];for(let C=0;;C++){const O=_[C],b=N.getComponent();if(b&&(b.r!==void 0?T=!0:b.p!=null&&(T=!1,M=b.p,A=C)),C>=_.length)break;let w=0;const B=r.advancer(N,void 0,(I,H)=>{h(H)&&w++});G.unshift(B);const j=B(O);if(typeof O=="number"&&(_[C]-=w),!j)break}if(G.forEach(C=>C.end()),T)return null;const $=()=>{let C=0;if(M!=null){const O=N.getPath();C=O.length,_=O.concat(_.slice(A))}for(;C<_.length;C++){const O=_[C],b=a(N),w=ht(b);if(w){const I=p(b);w.transformPosition&&(_[C]=w.transformPosition(_[C],I));break}let B=0;const j=r.advancer(N,(I,H)=>u(H)?~(I-B):I-B,(I,H)=>{u(H)&&B++})(O);if(typeof O=="number"&&(_[C]+=B),!j)break}};return M!=null?N.eachDrop(null,C=>{C===M&&$()}):$(),_}function gt(_,R){if(nt(_),nt(R),_==null)return R;if(R==null)return _;let N=0;const M=r.readCursor(_),A=r.readCursor(R),T=r.writeCursor(),G=[],$=[],C=[],O=[],b=[],w=[],B=new Set;M.traverse(null,I=>{I.p!=null&&(C[I.p]=M.clone())}),A.traverse(null,I=>{I.d!=null&&(O[I.d]=A.clone())});const j=r.writeCursor();return function I(H,_t,lt,q,pt,ie,xt,Mt){o(_t||lt);const Rt=a(_t),Vt=a(lt),qt=!!Vt&&Vt.r!==void 0,Re=!!Rt&&Rt.i!==void 0,Kt=Rt?Rt.d:null,Bt=Vt?Vt.p:null,oe=(ie||qt)&&Bt==null;if(Bt!=null)q=O[Bt],xt=$[Bt]=new r.WriteCursor;else if(Vt&&Vt.r!==void 0)q=null;else{const L=a(q);L&&L.d!=null&&(q=null)}const ot=a(q);if(Kt!=null)if(H=C[Kt],Mt=G[Kt]=new r.WriteCursor,oe)ie&&!qt&&Mt.write("r",!0);else{const L=b[Kt]=N++;xt.write("d",L)}else if(Rt&&Rt.i!==void 0)H=null;else{const L=a(H);L&&L.p!=null&&(H=null)}let x;Re?(o(pt===void 0),x=Rt.i):x=pt;const V=(Bt==null?!Re||ie||qt:x===void 0)?null:xt.getComponent();if(Bt!=null){if(!(pt!==void 0||Re)){const L=Kt!=null?b[Kt]:N++;w[Bt]=L,Mt.write("p",L)}}else qt&&(Re||pt!==void 0||(Vt.r,Mt.write("r",Vt.r)));const k=oe?null:ht(Rt),U=ht(ot);if((k||U)&&(k&&k.name,U&&U.name),k&&U){o(k===U);const L=p(Rt),Y=p(ot),wt=k.compose(L,Y);S(xt,k,wt),B.add(ot)}else k?S(xt,k,p(Rt)):U&&(S(xt,U,p(ot)),B.add(ot));const F=typeof x=="object"&&x!=null;let st=!1,rt=0,at=0,vt=0,Nt=0,Ct=0;const yt=r.advancer(q,(L,Y)=>u(Y)?Nt-L-1:L-Nt,(L,Y)=>{u(Y)&&Nt++}),et=r.advancer(H,(L,Y)=>h(Y)?rt-L-1:L-rt,(L,Y)=>{h(Y)&&rt++});if(r.eachChildOf(_t,lt,(L,Y,wt)=>{let kt,ae,Ce=L,Zt=L,We=L;if(typeof L=="number"){let Ut=L+vt;ae=yt(Ut),Zt=Ut+Nt;let St=L+at;kt=et(St),u(a(ae))&&(kt=null),Ce=St+rt,We=L+Ct,o(Ce>=0,"p1PickKey is negative"),o(Zt>=0,"p2DropKey is negative");const Jt=u(a(Y)),le=h(a(wt));(Jt||le&&!oe)&&Ct--,Jt&&at--,le&&vt--}else kt=et(L),ae=yt(L);Mt.descend(Ce),xt.descend(Zt);const Le=F&&!u(a(Y))?x[We]:void 0,ne=I(kt,Y,wt,ae,Le,oe,xt,Mt);var se,W,Et;F&&!oe?Le!==ne&&(st||(x=Array.isArray(x)?x.slice():Object.assign({},x),st=!0),se=x,Et=ne,typeof(W=We)=="number"?(o(Array.isArray(se)),o(W<se.length)):(o(!Array.isArray(se)),o(se[W]!==void 0)),Et===void 0?typeof W=="number"?se.splice(W,1):delete se[W]:se[W]=Et):o(ne===void 0),xt.ascend(),Mt.ascend()}),et.end(),yt.end(),V!=null)V.i=x;else if(!ie&&!qt&&Bt==null)return x}(M,M.clone(),A,A.clone(),void 0,!1,T,j),T.reset(),T.mergeTree(j.get()),T.reset(),T.get(),G.map(I=>I.get()),$.map(I=>I.get()),M.traverse(T,(I,H)=>{const _t=I.p;if(_t!=null){const lt=b[_t];lt!=null&&H.write("p",lt);const q=G[_t];q&&q.get(),q&&H.mergeTree(q.get())}else I.r!==void 0&&H.write("r",I.r)}),T.reset(),T.get(),A.traverse(T,(I,H)=>{const _t=I.d;if(_t!=null){const q=w[_t];q!=null&&H.write("d",q);const pt=$[_t];pt&&H.mergeTree(pt.get())}else I.i!==void 0&&H.write("i",I.i);const lt=ht(I);lt&&!B.has(I)&&S(H,lt,p(I))}),T.get()}function It(_){if(_==null)return null;const R=new r.ReadCursor(_),N=new r.WriteCursor;let M;const A=[],T=[];return function G($,C,O){const b=$.getComponent();let w,B=!1;if(b){b.p!=null&&(C.write("d",b.p),A[b.p]=$.clone()),b.r!==void 0&&C.write("i",b.r),b.d!=null&&(C.write("p",b.d),O=void 0),b.i!==void 0&&(O=w=b.i);const I=ht(b);I&&(O===void 0?(M||(M=new Set),M.add(b)):(p(b),O=I.apply(O,p(b)),B=!0))}let j=0;for(const I of $){C.descend(I);const H=typeof I=="number"?I-j:I,_t=E(O,H);u($.getComponent())&&j++;const lt=G($,C,_t);if(O!==void 0&&lt!==void 0){if(B||(B=!0,O=c(O)),!m(O,H))throw Error("Cannot modify child - invalid operation");O[H]=lt}C.ascend()}if(w===void 0)return B?O:void 0;C.write("r",O)}(R,N,void 0),M&&(N.reset(),function G($,C,O){const b=C.getComponent();if(b){const I=b.d;if(I!=null&&($=A[I],O=T[I]=r.writeCursor()),M.has(b)){const H=ht(b);if(!H.invert)throw Error(`Cannot invert subtype ${H.name}`);S(O,H,H.invert(p(b)))}}let w=0,B=0;const j=r.advancer($,(I,H)=>h(H)?w-I-1:I-w,(I,H)=>{h(H)&&w++});for(const I of C)if(typeof I=="number"){const H=I-B,_t=j(H),lt=H+w;O.descend(lt),G(_t,C,O),u(C.getComponent())&&B++,O.ascend()}else O.descend(I),G(j(I),C,O),O.ascend();j.end()}(R.clone(),R,N),T.length&&(N.reset(),R.traverse(N,(G,$)=>{const C=G.p;if(C!=null){const O=T[C];O&&O.get(),O&&$.mergeTree(O.get())}}))),N.get()}const Tt=(_,R)=>_.some(N=>typeof N=="object"&&(Array.isArray(N)?Tt(N,R):R(N)));function jt(_,R){if(_==null||!Tt(_,C=>{var O;return C.r!==void 0||((O=ht(C))===null||O===void 0?void 0:O.makeInvertible)!=null}))return _;const N=new r.ReadCursor(_),M=new r.WriteCursor;let A=!1;const T=[],G=[],$=(C,O,b)=>{const w=C.getComponent();let B=!1;if(w){w.d!=null&&O.write("d",w.d),w.i!==void 0&&O.write("i",w.i);const I=w.p;if(I!=null&&(T[I]=C.clone(),o(b!==void 0,"Operation picks up at an invalid key"),G[I]=b,O.write("p",w.p)),w.r!==void 0&&b===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const H=ht(w);H&&(H.makeInvertible?A=!0:S(O,H,p(w),!0))}let j=0;for(const I of C){O.descend(I);const H=typeof I=="number"?I-j:I,_t=E(b,H),lt=$(C,O,_t);_t!==lt&&(B||(B=!0,b=c(b)),lt===void 0?(b=d(b,H),typeof I=="number"&&j++):b[H]=lt),O.ascend()}return w&&(w.r!==void 0?(O.write("r",s.default(b)),b=void 0):w.p!=null&&(b=void 0)),b};return $(N,M,R),M.get(),A&&(M.reset(),function C(O,b,w,B,j){const I=b.getComponent();if(I){I.i!==void 0?(B=I.i,j=!0):I.d!=null&&(B=G[I.d],O=T[I.d],j=!1,I.d);let q=ht(I);if(q&&q.makeInvertible){const pt=p(I);S(w,q,q.makeInvertible(pt,B),!0)}}let H=0,_t=0;const lt=r.advancer(O,(q,pt)=>h(pt)?H-q-1:q-H,(q,pt)=>{h(pt)&&H++});for(const q of b)if(typeof q=="number"){const pt=q-_t,ie=lt(pt),xt=pt+H,Mt=E(B,j?pt:xt);w.descend(q),C(ie,b,w,Mt,j),u(b.getComponent())&&_t++,w.ascend()}else{const pt=E(B,q);w.descend(q),C(lt(q),b,w,pt,j),w.ascend()}lt.end()}(N.clone(),N,M,R,!1)),M.get()}function vo(_,R){return It(jt(_,R))}const Pn=_=>{if(_==null)return null;const R=_.slice();for(let N=0;N<_.length;N++){const M=R[N];Array.isArray(M)&&(R[N]=Pn(M))}return R};function kn(_,R,N){o(N==="left"||N==="right","Direction must be left or right");const M=N==="left"?0:1;if(R==null)return{ok:!0,result:_};nt(_),nt(R);let A=null;const T=[],G=[],$=[],C=[],O=[],b=[],w=[],B=[],j=[],I=[],H=[],_t=[],lt=[],q=[],pt=[];let ie=0;const xt=r.readCursor(_),Mt=r.readCursor(R),Rt=r.writeCursor();if(function ot(x,V=null,k){const U=a(V);U&&(U.r!==void 0?k=V.clone():U.p!=null&&(k=null,b[U.p]=x.clone()));const F=x.getComponent();let st;F&&(st=F.p)!=null&&(O[st]=V?V.clone():null,$[st]=x.clone(),k&&(I[st]=!0,j[st]=k),U&&U.p!=null&&(q[st]=U.p));const rt=r.advancer(V);for(const at of x)ot(x,rt(at),k);rt.end()}(Mt,xt,null),function ot(x,V,k,U,F){const st=k.getComponent();let rt,at=!1;st&&((rt=st.d)!=null?(C[rt]=k.clone(),U!=null&&(pt[U]==null&&(pt[U]=[]),pt[U].push(rt)),x=O[rt]||null,V=$[rt]||null,I[rt]?(F&&(H[rt]=!0),F=j[rt]||null):!F||M!==1&&q[rt]!=null||A==null&&(A={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.removeOp(F.getPath()),op2:t.moveOp(V.getPath(),k.getPath())}),at=!0):st.i!==void 0&&(x=V=null,at=!0,F&&A==null&&(A={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.removeOp(F.getPath()),op2:t.insertOp(k.getPath(),st.i)})));const vt=a(x);vt&&(vt.r!==void 0?F=x.clone():vt.p!=null&&(vt.p,U=vt.p,F=null));const Nt=ht(st);Nt&&F&&A==null&&(A={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.removeOp(F.getPath()),op2:t.editOp(k.getPath(),Nt,p(st),!0)});let Ct=0,yt=0;const et=r.advancer(V,(Y,wt)=>h(wt)?Ct-Y-1:Y-Ct,(Y,wt)=>{h(wt)&&Ct++}),L=r.advancer(x);for(const Y of k)if(typeof Y=="number"){const wt=Y-yt,kt=et(wt);yt+=+ot(L(wt+Ct),kt,k,U,F)}else{const wt=et(Y);ot(L(Y),wt,k,U,F)}return et.end(),L.end(),at}(xt,Mt,Mt.clone(),null,null),C.map(ot=>ot&&ot.get()),A)return{ok:!1,conflict:A};H.map(ot=>!!ot);const Vt=[];let qt=null;(function ot(x,V,k,U,F){let st=!1;const rt=a(V);if(h(rt)){const et=rt.p;et!=null?(k=C[et],U=_t[et]=r.writeCursor(),st=!0,F=null):(k=null,F=V.clone())}else u(a(k))&&(k=null);const at=x.getComponent();if(at){const et=at.p;et!=null?(F&&(B[et]=F),Vt[et]=F||M===1&&st?null:U.getComponent(),T[et]=x.clone(),k&&(w[et]=k.clone())):at.r!==void 0&&(F||U.write("r",!0),(F||st)&&(qt==null&&(qt=new Set),qt.add(at)))}let vt=0,Nt=0;const Ct=r.advancer(V,void 0,(et,L)=>{h(L)&&vt++}),yt=r.advancer(k,(et,L)=>u(L)?~(et-Nt):et-Nt,(et,L)=>{u(L)&&Nt++});if(x)for(const et of x)if(typeof et=="string"){const L=Ct(et),Y=yt(et);U.descend(et),ot(x,L,Y,U,F),U.ascend()}else{const L=Ct(et),Y=et-vt,wt=h(a(L))?null:yt(Y),kt=Y+Nt;o(kt>=0),U.descend(kt),ot(x,L,wt,U,F),U.ascend()}Ct.end(),yt.end()})(xt,Mt,Mt.clone(),Rt,null),Rt.reset();let Re=[];if(function ot(x,V,k,U,F,st){o(V);const rt=V.getComponent();let at=a(U),vt=!1;const Nt=(W,Et,Ut)=>W?t.moveOp(W.getPath(),Et.getPath()):t.insertOp(Et.getPath(),Ut.i);if(u(rt)){const W=rt.d;W!=null&&(G[W]=V.clone());const Et=W!=null?Vt[W]:null;let Ut=!1;if(rt.i!==void 0||W!=null&&Et){let St;at&&(at.i!==void 0||(St=at.d)!=null&&!I[St])&&(Ut=St!=null?W!=null&&W===q[St]:e.default(at.i,rt.i),Ut||St!=null&&M!==1&&q[St]!=null||A==null&&(A={type:i.ConflictType.DROP_COLLISION,op1:Nt(W!=null?T[W]:null,V,rt),op2:Nt(St!=null?$[St]:null,U,at)})),Ut||(st?A==null&&(A={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:Nt(W!=null?T[W]:null,V,rt),op2:t.removeOp(st.getPath())}):(W!=null?(Re[ie]=W,F.write("d",Et.p=ie++)):F.write("i",s.default(rt.i)),vt=!0))}else if(W!=null&&!Et){const St=B[W];St&&(st=St.clone())}W!=null?(x=T[W],k=b[W],U=w[W]):rt.i!==void 0&&(x=k=null,Ut||(U=null))}else h(a(x))&&(x=k=U=null);const Ct=a(x),yt=a(k);if(h(yt)){const W=yt.p;yt.r!==void 0&&(!Ct||Ct.r===void 0)||I[W]?(U=null,st=k.clone()):W!=null&&(U=C[W],M!==1&&q[W]!=null||((F=lt[W])||(F=lt[W]=r.writeCursor()),F.reset(),st=null))}else!u(rt)&&u(at)&&(U=null);at=U!=null?U.getComponent():null;const et=ht(rt);if(et){const W=p(rt);if(st)A==null&&(A={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.editOp(V.getPath(),et,W,!0),op2:t.removeOp(st.getPath())});else{const Et=ht(at);let Ut;if(Et){if(et!==Et)throw Error("Transforming incompatible types");const St=p(at);Ut=et.transform(W,St,N)}else Ut=s.default(W);S(F,et,Ut)}}let L=0,Y=0,wt=0,kt=0,ae=0,Ce=0,Zt=x!=null&&x.descendFirst(),We=Zt;const Le=r.advancer(k,void 0,(W,Et)=>{h(Et)&&wt++});let ne=U!=null&&U.descendFirst(),se=ne;for(const W of V)if(typeof W=="number"){let Et;const Ut=u(V.getComponent()),St=W-Y;{let he;for(;Zt&&typeof(he=x.getKey())=="number";){he+=L;const Qt=x.getComponent(),De=h(Qt);if(he>St||he===St&&(!De||M===0&&Ut))break;if(De){L--;const Ie=Qt.p;q.includes(Ie),Qt.d,a(lt[Qt.d]),h(a(lt[Qt.d])),(Qt.r===void 0||qt&&qt.has(Qt))&&(Ie==null||!Vt[Ie]||M!==1&&q.includes(Ie))||ae--}Zt=x.nextSibling()}Et=Zt&&he===St?x:null}const Jt=St-L;let le=Le(Jt);const Hn=Jt-wt;let sn=null;{let he,Qt;for(;ne&&typeof(he=U.getKey())=="number";){Qt=he-kt;const De=U.getComponent(),Ie=u(De);if(Qt>Hn)break;if(Qt===Hn){if(!Ie){sn=U;break}{if(M===0&&Ut){sn=U;break}const Se=le&&h(le.getComponent());if(M===0&&Se)break}}if(Ie){const Se=De.d;q[Se],De.i===void 0&&(I[Se]||q[Se]!=null&&M!==1)?(I[Se]||q[Se]!=null&&M===0)&&(kt++,Ce--):kt++}ne=U.nextSibling()}}const Ms=Hn+kt+ae+Ce;o(Ms>=0,"trying to descend to a negative index"),F.descend(Ms),Ut&&(Et=le=sn=null,Y++),ot(Et,V,le,sn,F,st)&&Ce++,F.ascend()}else{let Et;for(;Zt&&(Et=x.getKey(),typeof Et!="string"||!(Et>W||Et===W));)Zt=x.nextSibling();const Ut=Zt&&Et===W?x:null,St=Le(W);let Jt;for(;ne&&(Jt=U.getKey(),typeof Jt!="string"||!(Jt>W||Jt===W));)ne=U.nextSibling();const le=ne&&Jt===W?U:null;F.descend(W),ot(Ut,V,St,le,F,st),F.ascend()}return Le.end(),We&&x.ascend(),se&&U.ascend(),vt}(xt,xt.clone(),Mt,Mt.clone(),Rt,null),A)return{ok:!1,conflict:A};Rt.reset();const Kt=(ot,x,V)=>ot.traverse(x,(k,U)=>{k.d!=null&&V(k.d,ot,U)});(I.length||_t.length)&&(Kt(Mt,Rt,(ot,x,V)=>{I[ot]&&!H[ot]&&V.write("r",!0),_t[ot]&&V.mergeTree(_t[ot].get())}),Rt.reset());const Bt=[],oe=[];if((lt.length||I.length)&&!A){const ot=r.readCursor(Pn(Rt.get()));if(Kt(ot,null,(x,V)=>{Bt[x]=V.clone()}),lt.forEach(x=>{x&&Kt(r.readCursor(x.get()),null,(V,k)=>{Bt[V]=k.clone()})}),function x(V,k,U,F,st,rt){const at=a(k);if(at&&h(at))if(at.p!=null){const L=at.p;Bt[L].getPath(),U=Bt[L],F=oe[L]=r.writeCursor()}else at.r!==void 0&&(U=null);else u(a(U))&&(U=null);const vt=V.getComponent();if(vt){let L;if((L=vt.d)!=null){const Y=lt[L];Y&&(Y.get(),F.mergeTree(Y.get()),U=r.readCursor(Y.get()))}}let Nt=0,Ct=0;const yt=r.advancer(k,void 0,(L,Y)=>{h(Y)&&Nt--}),et=r.advancer(U,(L,Y)=>u(Y)?-(L-Ct)-1:L-Ct,(L,Y)=>{u(Y)&&Ct++});for(const L of V)if(typeof L=="number"){const Y=yt(L),wt=L+Nt,kt=et(wt),ae=wt+Ct;F.descend(ae),x(V,Y,kt,F),F.ascend()}else F.descend(L),x(V,yt(L),et(L),F),F.ascend();yt.end(),et.end()}(Mt,ot,ot.clone(),Rt),Rt.reset(),A)return{ok:!1,conflict:A};if(Rt.get(),oe.length){const x=oe.map(k=>k?k.get():null),V=r.readCursor(Pn(Rt.get()));if(Kt(V,Rt,(k,U,F)=>{const st=x[k];st&&(F.mergeTree(st),x[k]=null)}),x.find(k=>k)){const k=r.writeCursor(),U=r.writeCursor();let F=0,st=0;x.forEach(rt=>{rt!=null&&Kt(r.readCursor(rt),null,at=>{const vt=Re[at];k.writeMove(T[vt].getPath(),G[vt].getPath(),F++);const Nt=pt[vt];Nt&&Nt.forEach(Ct=>{I[Ct]||M!==1&&q[Ct]!=null||U.writeMove($[Ct].getPath(),C[Ct].getPath(),st++)})})}),A={type:i.ConflictType.BLACKHOLE,op1:k.get(),op2:U.get()}}}}return A?{ok:!1,conflict:A}:{ok:!0,result:Rt.get()}}const ws=_=>{const R=new Error("Transform detected write conflict");throw R.conflict=_,R.type=R.name="writeConflict",R};function wo(_,R,N){const M=kn(_,R,N);if(M.ok)return M.result;ws(M.conflict)}const Ue=_=>{const R=r.writeCursor();return r.readCursor(_).traverse(R,(N,M)=>{(u(N)||ht(N))&&M.write("r",!0)}),R.get()},To=(_,R)=>{const{type:N,op1:M,op2:A}=_;switch(N){case i.ConflictType.DROP_COLLISION:return R==="left"?[null,Ue(A)]:[Ue(M),null];case i.ConflictType.RM_UNEXPECTED_CONTENT:let T=!1;return r.readCursor(M).traverse(null,G=>{G.r!==void 0&&(T=!0)}),T?[null,Ue(A)]:[Ue(M),null];case i.ConflictType.BLACKHOLE:return[Ue(M),Ue(A)];default:throw Error("Unrecognised conflict: "+N)}};function Ts(_,R,N,M){let A=null;for(;;){const T=kn(R,N,M);if(T.ok)return gt(A,T.result);{const{conflict:G}=T;_(G)||ws(G);const[$,C]=To(G,M);R=gt(X(R),$),N=gt(X(N),C),A=gt(A,C)}}}})(Di);(function(t){var n=$t&&$t.__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=$t&&$t.__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(Di,t);var s=ps;Object.defineProperty(t,"ReadCursor",{enumerable:!0,get:function(){return s.ReadCursor}}),Object.defineProperty(t,"WriteCursor",{enumerable:!0,get:function(){return s.WriteCursor}});var r=Rs;Object.defineProperty(t,"ConflictType",{enumerable:!0,get:function(){return r.ConflictType}})})(Wt);const Pl=Ul(Wt),kl=Lo({__proto__:null,default:Pl},[Wt]);var J=(t=>(t.RETAIN="r",t.INSERT="i",t.DELETE="d",t))(J||{});class ss{constructor(n){g(this,"_index",0);g(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===J.DELETE||e.t===J.RETAIN&&e.body==null?y.deepClone({...e,len:n}):y.deepClone({...e,len:n,body:Ze(e.body,s,s+n)})}else return{t:J.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:J.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 yi{constructor(){g(this,"cursor",0)}reset(){return this.cursor=0,this}moveCursor(n){this.cursor+=n}moveCursorTo(n){this.cursor=n}}function xi(t,n,e){const{dataStream:s}=t,r=e,i=e+n,o=Oi(t,n,e),a=Ni(t,n,e),l=Ai(t,n,e),c=bi(t,n,e),h=vi(t,n,e),u=wi(t,n,e),d=Ti(t,n,e);let f="";return s&&(t.dataStream=Zr(s,r,i),f=s.slice(r,i)),{dataStream:f,textRuns:o,paragraphs:a,sectionBreaks:l,customBlocks:c,tables:h,customRanges:u,customDecorations:d}}function Pi(t,n,e,s){t.dataStream=qr(t.dataStream,s,n.dataStream),pi(t,n,e,s),gs(t,n,e,s),El(t,n,e,s),Ri(t,n,e,s),Ci(t,n,e,s),Ii(t,n,e,s),Si(t,n,e,s)}function Hl(t,n,e,s,r=Pt.COVER){return Cl(t,n,e,s,r)}function Fl(t,n,e){return n<=0?{dataStream:""}:xi(t,n,e)}function Wl(t,n,e,s){e!==0&&Pi(t,n,e,s)}function $l(t,n){const e=new yi;return e.reset(),n.forEach(s=>{switch(s=y.deepClone(s),s.t){case J.RETAIN:{const{coverType:r,body:i,len:o}=s;i!=null&&Hl(t,i,o,e.cursor,r),e.moveCursor(o);break}case J.INSERT:{const{body:r,len:i}=s;Wl(t,r,i,e.cursor),e.moveCursor(i);break}case J.DELETE:{const{len:r}=s;Fl(t,r,e.cursor);break}default:throw new Error(`Unknown action type for action: ${s}.`)}}),t}function $s(t){return Object.keys(t).length===1}const Xe=class Xe{constructor(){g(this,"_actions",[])}static apply(n,e){return $l(n,e)}static compose(n,e){const s=new ss(n),r=new ss(e),i=new Xe;for(;s.hasNext()||r.hasNext();)if(r.peekType()===J.INSERT)i.push(r.next());else if(s.peekType()===J.DELETE)i.push(s.next());else{const o=Math.min(s.peekLength(),r.peekLength()),a=s.next(o),l=r.next(o);a.t===J.INSERT&&l.t===J.RETAIN?l.body==null?i.push(a):i.push({...a,body:ts(a.body,l.body,l.coverType)}):a.t===J.RETAIN&&l.t===J.RETAIN?a.body==null&&l.body==null?i.push(a.len!==Number.POSITIVE_INFINITY?a:l):a.body&&l.body?i.push({...a,body:ts(a.body,l.body,l.coverType)}):i.push(a.body?a:l):a.t===J.RETAIN&&l.t===J.DELETE?i.push(l):a.t===J.INSERT&&(l.t,J.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===J.INSERT)e.push({t:J.DELETE,len:s.len,line:0,body:s.body,segmentId:s.segmentId});else if(s.t===J.DELETE){if(s.body==null)throw new Error("Can not invert DELETE action without body property, makeInvertible must be called first.");e.push({t:J.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:J.RETAIN,body:s.oldBody,oldBody:s.body,len:s.len,coverType:Pt.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===J.DELETE&&i.body==null){const o=Ze(e,r,r+i.len,!1);i.len=o.dataStream.length,i.body=o}if(i.t===J.RETAIN&&i.body!=null){const o=Ze(e,r,r+i.len,!0);i.oldBody={...o,dataStream:""},i.len=o.dataStream.length}s.push(i),i.t!==J.INSERT&&(r+=i.len)}return s}insert(n,e,s=""){const r={t:J.INSERT,body:e,len:n,line:0,segmentId:s};return this.push(r),this}retain(n,e="",s,r){const i={t:J.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:J.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=y.deepClone(n[0]);if(r.t===J.RETAIN&&r.len===0&&r.body==null)return this;if(typeof s=="object"){if(s.t===J.DELETE&&r.t===J.DELETE)return s.len+=r.len,this;if(s.t===J.DELETE&&r.t===J.INSERT&&(e-=1,s=this._actions[e-1],s==null))return this._actions.unshift(r),this;if(s.t===J.RETAIN&&r.t===J.RETAIN&&s.body==null&&r.body==null)return s.len+=r.len,this;if(s.t===J.INSERT&&$s(s.body)&&r.t===J.INSERT&&$s(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===J.RETAIN&&Tl(n);)this._actions.pop(),n=this._actions[this._actions.length-1];return this}};g(Xe,"id","text-x"),g(Xe,"uri","https://github.com/dream-num/univer#text-x");let Ee=Xe;Object.defineProperty(Ee,"name",{value:"text-x"});const ye=class ye{static registerSubtype(n){var e;this._subTypes.has(n.name)&&((e=this._subTypes.get(n.name))==null?void 0:e.id)!==Ee.id||(this._subTypes.set(n.name,n),Wt.type.registerSubtype(n))}static apply(n,e){if(!Wt.type.isNoop(e))return Wt.type.apply(n,e)}static compose(n,e){return Wt.type.compose(n,e)}static transform(n,e,s){throw new Error("transform is not implemented in JsonX")}static invertWithDoc(n,e){return Wt.type.invertWithDoc(n,e)}static isNoop(n){return Wt.type.isNoop(n)}static getInstance(){return this._instance==null&&(this._instance=new ye),this._instance}removeOp(n,e){return Wt.removeOp(n,e)}moveOp(n,e){return Wt.moveOp(n,e)}insertOp(n,e){return Wt.insertOp(n,e)}replaceOp(n,e,s){return Wt.replaceOp(n,e,s)}editOp(n,e=["body"]){return Wt.editOp(e,Ee.name,n)}};g(ye,"uri","https://github.com/dream-num/univer#json-x"),g(ye,"_subTypes",new Map),g(ye,"_instance",null);let ve=ye;ve.registerSubtype(Ee);const Is={id:"default_doc",documentStyle:{}};class Bl extends Mn{constructor(e){super();g(this,"type",Q.UNIVER_DOC);g(this,"snapshot");this.snapshot={...Is,...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,c=r==null?void 0:r[e];if(!c)return;const h=c.docTransform;h.size.width=i,h.size.height=o,h.positionH.posOffset=a,h.positionV.posOffset=l}setZoomRatio(e=1){this.snapshot.settings==null?this.snapshot.settings={zoomRatio:e}:this.snapshot.settings.zoomRatio=1}}class we extends Bl{constructor(e){var r;super(y.isEmptyObject(e)?Ml():e);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(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={...Is,...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 Ze(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 ki=ut.createIdentifier("univer.config-service");class Hi{constructor(){g(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 Fi extends Dt{constructor(){super(...arguments);g(this,"_error$",new Z.Subject);g(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(e){this._error$.next({errorKey:e})}}class Wi{constructor(n={}){g(this,"_styles");g(this,"_cacheMap",new ni(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=y.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&&y.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(y.diffValue(e[s],n))return s;return null}}class Gl{constructor(n,e){g(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!==K.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:it.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:it.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:it.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:it.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:K.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:K.FALSE};return this._columnData[n]=i,i}}class jl{constructor(n,e,s){g(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:K.FALSE,h:r.defaultRowHeight},{ia:l,ah:c,h=r.defaultRowHeight}=a;i+=(l==null||l===K.TRUE)&&typeof c=="number"?c:h}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:K.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:it.ROW})):!r&&!a&&(r=!0,i=o)}return r&&s.push({startRow:i,endRow:e,startColumn:0,endColumn:0,rangeType:it.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:it.ROW})):!r&&a&&(r=!0,i=o)}return r&&s.push({startRow:i,endRow:e,startColumn:0,endColumn:0,rangeType:it.ROW}),s}getRowRawVisible(n){const e=this.getRow(n);return e?e.hd!==K.TRUE:!0}getSize(){return _e(this._rowData)}}const Vl="DEFAULT_WORKSHEET_ROW_COUNT",$i=1e3,Kl="DEFAULT_WORKSHEET_COLUMN_COUNT",Bi=20,Yl="DEFAULT_WORKSHEET_ROW_HEIGHT",Gi=24,zl="DEFAULT_WORKSHEET_COLUMN_WIDTH",ji=88,Xl="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",Vi=46,ql="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Ki=20;function Yi(t){const n={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:K.FALSE,rowCount:$i,columnCount:Bi,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:ji,defaultRowHeight:Gi,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:K.TRUE,rowHeader:{width:Vi,hidden:K.FALSE},columnHeader:{height:Ki,hidden:K.FALSE},selections:["A1"],rightToLeft:K.FALSE};return Object.keys(n).forEach(e=>{const s=e;typeof t[s]>"u"&&(t[s]=n[s])}),t}class zi extends Dt{constructor(e){super();g(this,"_cellContentInterceptor",null);g(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,bt(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(e){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=e,bt(()=>this._rowFilteredInterceptor=null)}}class Je{constructor(n,e,s){g(this,"_sheetId");g(this,"_snapshot");g(this,"_cellData");g(this,"_rowManager");g(this,"_columnManager");g(this,"_viewModel");var a;this.unitId=n,this._styles=s,this._snapshot=Yi(e);const{columnData:r,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:y.generateRandomId(6),this._cellData=new ee(o),this._viewModel=new zi((l,c)=>this.getCellRaw(l,c)),this._rowManager=new jl(this._snapshot,this._viewModel,i),this._columnManager=new Gl(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((c,h)=>{Object.keys(h).forEach(u=>{const d=+u,f=n.getValue(c,d),m=f!=null&&f.s?this._styles.get(f.s):null,E=(m==null?void 0:m.bd)&&(m.bd.b||m.bd.l||m.bd.r||m.bd.t||m.bd.bc_tr||m.bd.bl_tr||m.bd.ml_tr||m.bd.tl_bc||m.bd.tl_br||m.bd.tl_mr);(f&&(f.v||f.p)||m!=null&&m.bg||E)&&(a?s=Math.min(s,c):(s=c,a=!0),r=Math.max(r,c),l?i=Math.min(i,d):(l=!0,i=d),o=Math.max(o,d))})}),e.forEach(c=>{a?s=Math.min(s,c.startRow):(s=c.startRow,a=!0),r=Math.max(r,c.endRow),l?i=Math.min(i,c.startColumn):(i=c.startColumn,a=!0),o=Math.max(o,c.endColumn)}),!a||!l?null:{startColumn:i,startRow: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=y.deepClone(n);return new Je(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(c=>me.intersects({startRow:n,startColumn:e,endRow:s,endColumn:r},c)),l=new ee;return Jn(n,s,e,r).forEach((c,h)=>{const u=i?this.getCellRaw(c,h):this.getCell(c,h);u&&l.setValue(c,h,u)}),a.forEach(c=>{const{startColumn:h,startRow:u,endColumn:d,endRow:f}=c;Jn(u,f,h,d).forEach((m,E)=>{m===u&&E===h&&l.setValue(m,E,{...o.getValue(m,E),rowSpan:f-u+1,colSpan:d-h+1}),(m!==u||E!==h)&&l.realDeleteValue(m,E)})}),l}getRange(n,e,s,r){return typeof n=="object"?new He(this,n,{getStyles:()=>this._styles}):new He(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,c=r;return{next(){for(;;){if(c>o&&(l+=1,c=r),l>i)return{done:!0,value:void 0};const h=a.getCell(l,c),u=!h,d=a.getMergedCell(l,c);if(d){if(l!==d.startRow||c!==d.startColumn){c=d.endColumn+1;continue}if(u&&e){c=d.endColumn+1;continue}const m={row:l,col:c,value:h};return m.colSpan=d.endColumn-d.startColumn+1,m.rowSpan=d.endRow-d.startRow+1,c=d.endColumn+1,{done:!1,value:m}}if(u&&e)c+=1;else{const f={row:l,col:c,value:h};return c+=1,{done:!1,value:f}}}}}}}}iterateByColumn(n,e=!0,s=!0){const{startRow:r,startColumn:i,endRow:o,endColumn:a}=n,l=this;return{[Symbol.iterator]:()=>{let c=r,h=i;return{next(){for(;;){if(c>o&&(h+=1,c=r),h>a)return{done:!0,value:void 0};const u=l.getMergedCell(c,h);if(u){const m=c!==u.startRow,E=m||h!==u.startColumn;if(s&&E||!s&&m){c=u.endRow+1;continue}const D=l.getCell(u.startRow,u.startColumn);if(!D&&e){c=u.endRow+1;continue}const tt={row:c,col:u.startColumn,value:D};return tt.colSpan=u.endColumn-u.startColumn+1,tt.rowSpan=u.endRow-u.startRow+1,c=u.endRow+1,{done:!1,value:tt}}const d=l.getCell(c,h);if(!d&&e)c+=1;else{const m={row:c,col:h,value:d};return c+=1,{done:!1,value:m}}}}}}}}}function Zl(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===Ae.BOOLEAN?e.toUpperCase():e.replace(/[\r\n]/g,""):typeof e=="number"?t.t===Ae.BOOLEAN?e?"TRUE":"FALSE":e.toString():typeof e=="boolean"?e?"TRUE":"FALSE":""}const Jl="0.2.3";function Ql(t="",n=Te.ZH_CN,e=""){return{id:t,sheetOrder:[],name:e,appVersion:Jl,locale:n,styles:{},sheets:{},resources:[]}}var tu=Object.defineProperty,eu=Object.getOwnPropertyDescriptor,nu=(t,n,e,s)=>{for(var r=s>1?void 0:s?eu(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&&tu(n,e,r),r},su=(t,n)=>(e,s)=>n(e,s,t);function ru(t,n){return`${t.getUnitId()}|${n.getSheetId()}`}exports.Workbook=class extends Mn{constructor(e={},s){super();g(this,"type",Q.UNIVER_SHEET);g(this,"_sheetCreated$",new Z.Subject);g(this,"sheetCreated$",this._sheetCreated$.asObservable());g(this,"_sheetDisposed$",new Z.Subject);g(this,"sheetDisposed$",this._sheetDisposed$.asObservable());g(this,"_activeSheet$",new Z.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=Ql();y.isEmptyObject(e)?this._snapshot=r:this._snapshot=y.commonExtend(r,e);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 Wi(i),this._count=1,this._worksheets=new Map,this._name$=new Z.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 y.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 Je(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()!==K.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===K.TRUE).map(e=>e.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden!==K.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(y.isEmptyObject(r)){const o=y.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 c=new Je(this._unitId,a,this._styles);s.set(o,c),i.includes(o)||i.push(o)}this.ensureActiveSheet()}};exports.Workbook=nu([su(1,pe)],exports.Workbook);class Ss extends Mn{constructor(e){var s;super();g(this,"type",Q.UNIVER_SLIDE);g(this,"_snapshot");g(this,"_unitId");this._snapshot={...ii,...e},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 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:as.SLIDE,zIndex:1,title:"cover",description:"this is first page, cover",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}}const Ke="FOCUSING_SHEET",gn="FOCUSING_DOC",_n="FOCUSING_SLIDE",iu="FOCUSING_EDITOR_BUT_HIDDEN",Xi="EDITOR_ACTIVATED",ou="FOCUSING_EDITOR_INPUT_FORMULA",qi="FOCUSING_FORMULA_EDITOR",au="FOCUSING_UNIVER_EDITOR",lu="FOCUSING_EDITOR_INPUT_FORMULA",uu="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",cu="FOCUSING_COMMON_DRAWINGS";var hu=Object.defineProperty,du=Object.getOwnPropertyDescriptor,fu=(t,n,e,s)=>{for(var r=s>1?void 0:s?du(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&&hu(n,e,r),r},Bs=(t,n)=>(e,s)=>n(e,s,t);const Fe=ut.createIdentifier("univer.current");exports.UniverInstanceService=class extends Dt{constructor(e,s){super();g(this,"_unitsByType",new Map);g(this,"_createHandler");g(this,"_ctorByType",new Map);g(this,"_currentUnits",new Map);g(this,"_currentUnits$",new Z.BehaviorSubject(this._currentUnits));g(this,"currentUnits$",this._currentUnits$.asObservable());g(this,"_unitAdded$",new Z.Subject);g(this,"unitAdded$",this._unitAdded$.asObservable());g(this,"_unitDisposed$",new Z.Subject);g(this,"unitDisposed$",this._unitDisposed$.asObservable());g(this,"_focused$",new Z.BehaviorSubject(null));g(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(Z.map(s=>{var r;return(r=s.get(e))!=null?r:null}),Z.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(Z.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(Z.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 exports.Workbook?(this._contextService.setContextValue(gn,!1),this._contextService.setContextValue(Ke,!0),this._contextService.setContextValue(_n,!1)):this.focused instanceof we?(this._contextService.setContextValue(gn,!0),this._contextService.setContextValue(Ke,!1),this._contextService.setContextValue(_n,!1)):this.focused instanceof Ss&&(this._contextService.setContextValue(gn,!1),this._contextService.setContextValue(Ke,!1),this._contextService.setContextValue(_n,!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]}}};exports.UniverInstanceService=fu([Bs(0,ut.Inject(ut.Injector)),Bs(1,Qe)],exports.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 gu={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"},mn=new Map;function Zi(t,n){return function(r){Un(t,n)}}function Un(t,n){mn.has(t)||mn.set(t,[]),mn.get(t).push(n)}var _u=Object.defineProperty,mu=Object.getOwnPropertyDescriptor,Ji=(t,n,e,s)=>{for(var r=s>1?void 0:s?mu(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&&_u(n,e,r),r},Qi=(t,n)=>(e,s)=>n(e,s,t);exports.LifecycleService=class extends Dt{constructor(e){super();g(this,"_lifecycle$",new Z.BehaviorSubject(ft.Starting));g(this,"lifecycle$",this._lifecycle$.asObservable());g(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 Z.merge(to(this.stage),this._lifecycle$.pipe(Z.skip(1))).pipe(gi(e=>e===ft.Steady))}_reportProgress(e){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${gu[e]}".`)}};exports.LifecycleService=Ji([Qi(0,pe)],exports.LifecycleService);exports.LifecycleInitializerService=class extends Dt{constructor(e){super();g(this,"_seenTokens",new Set);this._injector=e}initModulesOnStage(e){var s;(s=mn.get(e))==null||s.forEach(r=>{this._injector.has(r)&&!this._seenTokens.has(r)&&(this._injector.get(r),this._seenTokens.add(r))})}};exports.LifecycleInitializerService=Ji([Qi(0,ut.Inject(ut.Injector))],exports.LifecycleInitializerService);function to(t){switch(t){case ft.Starting:return Z.of(ft.Starting);case ft.Ready:return Z.of(ft.Starting,ft.Ready);case ft.Rendered:return Z.of(ft.Starting,ft.Ready,ft.Rendered);default:return Z.of(ft.Starting,ft.Ready,ft.Rendered,ft.Steady)}}class Ye extends Dt{constructor(){super();g(this,"_currentLocale$",new Z.BehaviorSubject(Te.ZH_CN));g(this,"currentLocale$",this._currentLocale$.asObservable());g(this,"_locales",null);g(this,"localeChanged$",new Z.Subject);g(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(bt(()=>this.localeChanged$.complete()))}get _currentLocale(){return this._currentLocale$.value}load(e){var s;this._locales=y.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 Os=(t=>(t.INIT="init",t.FETCHING="fetching",t.DONE="done",t))(Os||{});const Ns=ut.createIdentifier("univer.permission-service");Un(ft.Starting,Ns);class eo extends Dt{constructor(){super(...arguments);g(this,"_permissionPointMap",new Map);g(this,"_permissionPointUpdate$",new Z.Subject);g(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 Z.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 Z.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=Os.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 Z.combineLatest(s).pipe(cn.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 no extends Dt{constructor(){super(...arguments);g(this,"_resourceMap",new Map);g(this,"_register$",new Z.Subject);g(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),bt(()=>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 Ln=ut.createIdentifier("resource-manager-service");var Eu=Object.defineProperty,pu=Object.getOwnPropertyDescriptor,Ru=(t,n,e,s)=>{for(var r=s>1?void 0:s?pu(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&&Eu(n,e,r),r},Gs=(t,n)=>(e,s)=>n(e,s,t);let rs=class extends Dt{constructor(n,e){super();g(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(bt(this._univerInstanceService.getTypeOfUnitAdded$(Q.UNIVER_SHEET).subscribe(s=>{this._resourceManagerService.loadResources(s.getUnitId(),s.getSnapshot().resources)}))),this.disposeWithMe(bt(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}};rs=Ru([Gs(0,ut.Inject(Ln)),Gs(1,ut.Inject(Fe))],rs);const As=ut.createIdentifier("resource-loader-service");Un(ft.Ready,As);class bs extends Dt{constructor(){super();g(this,"_currentTheme");g(this,"_currentTheme$",new Z.BehaviorSubject({}));g(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(bt(()=>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 Dn="__INTERNAL_EDITOR__",so=`${Dn}DOCS_NORMAL`,ro=`${Dn}DOCS_FORMULA_BAR`,Cu=`\r
7
- `;function Iu(t){return`${Dn}${t}`}function Su(t){return t.startsWith(Dn)}var Ou=Object.defineProperty,Nu=Object.getOwnPropertyDescriptor,Au=(t,n,e,s)=>{for(var r=s>1?void 0:s?Nu(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},jn=(t,n)=>(e,s)=>n(e,s,t);const yn=ut.createIdentifier("univer.undo-redo.service"),bu=20;class io{dispose(){}async dispatchToHandlers(){return!1}}const oo="univer.command.redo",ao="univer.command.undo",lo=new class extends io{constructor(){super(...arguments);g(this,"type",tn.COMMAND);g(this,"id",ao)}async handler(n){const e=n.get(yn),s=e.pitchTopUndoElement();if(!s)return!1;const r=n.get(en);return cs(s.undoMutations,r)?(e.popUndoToRedo(),!0):!1}},uo=new class extends io{constructor(){super(...arguments);g(this,"type",tn.COMMAND);g(this,"id",oo)}async handler(n){const e=n.get(yn),s=e.pitchTopRedoElement();if(!s)return!1;const r=n.get(en);return cs(s.redoMutations,r)?(e.popRedoToUndo(),!0):!1}};exports.LocalUndoRedoService=class extends Dt{constructor(e,s,r){super();g(this,"undoRedoStatus$");g(this,"_undoRedoStatus$",new Z.BehaviorSubject({undos:0,redos:0}));g(this,"_undoStacks",new Map);g(this,"_redoStacks",new Map);g(this,"_batchingStatus",new Map);this._univerInstanceService=e,this._commandService=s,this._contextService=r,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(lo)),this.disposeWithMe(this._commandService.registerCommand(uo)),this.disposeWithMe(bt(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(bt(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>bu&&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),bt(()=>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,c;let e="";const s=this._contextService.getContextValue(Ke),r=this._contextService.getContextValue(qi),i=this._contextService.getContextValue(Xi);return s?r?e=ro:i?e=so:e=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":e=(c=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?c:"",e}};exports.LocalUndoRedoService=Au([jn(0,Fe),jn(1,en),jn(2,Qe)],exports.LocalUndoRedoService);const co=Symbol("DependentOn");class is extends Dt{onStarting(n){}onReady(){}onRendered(){}onSteady(){}getUniverInstanceType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}g(is,"pluginName"),g(is,"type",Q.UNIVER_UNKNOWN);class vu{constructor(){g(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 wu{constructor(){g(this,"_pluginsRegistered",[])}registerPlugin(n,e){this._pluginsRegistered.push({plugin:n,options:e})}getRegisterPlugins(){return this._pluginsRegistered.slice()}removePlugins(){this._pluginsRegistered=[]}}var Tu=Object.defineProperty,Mu=Object.getOwnPropertyDescriptor,ho=(t,n,e,s)=>{for(var r=s>1?void 0:s?Mu(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&&Tu(n,e,r),r},Ge=(t,n)=>(e,s)=>n(e,s,t);const Uu=4;function Lu(...t){return function(n){n[co]=t}}exports.PluginService=class{constructor(n){g(this,"_pluginHolderForUniver");g(this,"_pluginHoldersForTypes",new Map);g(this,"_seenPlugins",new Set);g(this,"_flushTimer");this._injector=n,this._pluginHolderForUniver=this._injector.createInstance(On,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(On,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()},Uu))}_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()}};exports.PluginService=ho([Ge(0,ut.Inject(ut.Injector))],exports.PluginService);let On=class extends Dt{constructor(n,e,s,r,i,o){super();g(this,"_started",!1);g(this,"_pluginRegistry",new wu);g(this,"_pluginStore",new vu);g(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(Z.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[co];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){to(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)}};On=ho([Ge(2,pe),Ge(3,ut.Inject(ut.Injector)),Ge(4,ut.Inject(exports.LifecycleService)),Ge(5,ut.Inject(exports.LifecycleInitializerService))],On);function fo(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 os={[Ft.Editor]:"Editor",[Ft.Owner]:"Owner",[Ft.Reader]:"Reader",[Ft.UNRECOGNIZED]:"UNRECOGNIZED"},Nn=t=>t?{userID:`${os[t]}_${y.generateRandomId(8)}`,name:os[t],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},Vn=(t,n)=>t.startsWith(os[n]);var Du=Object.defineProperty,yu=Object.getOwnPropertyDescriptor,xu=(t,n,e,s)=>{for(var r=s>1?void 0:s?yu(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};exports.UserManagerService=class{constructor(){g(this,"_model",new Map);g(this,"_userChange$",new Z.Subject);g(this,"userChange$",this._userChange$.asObservable());g(this,"_currentUser$",new Z.BehaviorSubject(Nn()));g(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"})}};exports.UserManagerService=xu([Zi(ft.Starting,exports.UserManagerService)],exports.UserManagerService);var Pu=Object.defineProperty,ku=Object.getOwnPropertyDescriptor,Hu=(t,n,e,s)=>{for(var r=s>1?void 0:s?ku(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&&Pu(n,e,r),r},js=(t,n)=>(e,s)=>n(e,s,t);exports.AuthzIoLocalService=class{constructor(n,e){g(this,"_permissionMap",new Map([]));this._resourceManagerService=n,this._userManagerService=e,this._initSnapshot(),e.setCurrentUser(Nn(Ft.Owner))}_getRole(n){const e=this._userManagerService.getCurrentUser();return e?Vn(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=y.generateRandomId(8);switch(n.objectType){case fn.SelectRange:{const s=n.selectRangeObject;this._permissionMap.set(e,{...s,objectType:n.objectType});break}case fn.Worksheet:{const s=n.worksheetObject;this._permissionMap.set(e,{...s,objectType:n.objectType,readScope:mi.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===fn.Worksheet)return(e=s==null?void 0:s.strategies)==null?void 0:e.map(r=>({action:r.action,allowed:r.role===Ft.Editor}))}return n.actions.map(s=>({action:s,allowed:this._getRole(Ft.Owner)||this._getRole(Ft.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&&(Vn(e.userID,Ft.Owner)||Vn(e.userID,Ft.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:Ft.Owner,shareScope:-1,creator:Nn(Ft.Owner),strategies:[],actions:n.actions.map(o=>({action:o,allowed:this._getRole(Ft.Owner)||this._getRole(Ft.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){}};exports.AuthzIoLocalService=Hu([js(0,Ln),js(1,ut.Inject(exports.UserManagerService))],exports.AuthzIoLocalService);const go=ut.createIdentifier("IAuthzIoIoService");class Fu{constructor(n={},e){g(this,"_startedTypes",new Set);g(this,"_injector");const s=this._injector=Wu(e,n==null?void 0:n.override),{theme:r,locale:i,locales:o,logLevel:a}=n;r&&this._injector.get(bs).setTheme(r),o&&this._injector.get(Ye).load(o),i&&this._injector.get(Ye).setLocale(i),a&&this._injector.get(pe).setLogLevel(a),this._init(s)}get _univerInstanceService(){return this._injector.get(Fe)}get _pluginService(){return this._injector.get(exports.PluginService)}__getInjector(){return this._injector}dispose(){this._injector.dispose()}setLocale(n){this._injector.get(Ye).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,exports.Workbook),this._univerInstanceService.registerCtorForType(Q.UNIVER_DOC,we),this._univerInstanceService.registerCtorForType(Q.UNIVER_SLIDE,Ss);const e=n.get(Fe);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(exports.LifecycleService).stage<ft.Ready&&(this._injector.get(exports.LifecycleService).stage=ft.Ready)}registerPlugin(n,e){this._pluginService.registerPlugin(n,e)}}function Wu(t,n){const e=fo([[Fi],[Ye],[bs],[exports.LifecycleService],[exports.LifecycleInitializerService],[exports.PluginService],[exports.UserManagerService],[Fe,{useClass:exports.UniverInstanceService}],[Ns,{useClass:eo}],[pe,{useClass:hi,lazy:!0}],[en,{useClass:exports.CommandService}],[yn,{useClass:exports.LocalUndoRedoService,lazy:!0}],[ki,{useClass:Hi}],[Qe,{useClass:ui}],[Ln,{useClass:no,lazy:!0}],[As,{useClass:rs,lazy:!0}],[go,{useClass:exports.AuthzIoLocalService,lazy:!0}]],n);return t?t.createChild(e):new ut.Injector(e)}const $u=(t,n)=>n.length===t.length&&!t.some(e=>n.some(s=>!me.equals(s,e))),Bu=(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 Gu(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 _o(t){return/^-?\d+(\.\d+)?$/.test(t)}function ju(t){return _o(t)?Number(t)<=Number.MAX_SAFE_INTEGER:!1}function Vu(t){return["true","false"].includes(t.toLowerCase())}function Ku(t,n){return n.forEach(e=>t.add(e)),t}function Yu(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 zu(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 mo=(t=>(t[t.TEXT=0]="TEXT",t[t.ARROW=1]="ARROW",t[t.CUSTOM=2]="CUSTOM",t))(mo||{});function Xu(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 Ee,c=ve.getInstance();if(o>0&&l.retain(o),e.length>0){const h=r.sliceBody(o,o+i),u={dataStream:e};Array.isArray(h==null?void 0:h.textRuns)&&h.textRuns.length&&(u.textRuns=[{...h.textRuns[0],st:0,ed:e.length}]),l.insert(e.length,u)}l.delete(i),r.apply(c.editOp(l.serialize()))}const a=r.getBody();return r.dispose(),a}class Eo{constructor(){g(this,"skipNextObservers",!1);g(this,"lastReturnValue");g(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class qu extends Z.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(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 Eo;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 Zu=ut.createIdentifier("ILocalStorageService");function Ju(t){return`sheet_interceptor_${t}`}const po=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 Qu{constructor(n){g(this,"_interceptorsByName",new Map);g(this,"_interceptorPoints");this._interceptorPoints=n}fetchThroughInterceptors(n){const e=n,s=this._interceptorsByName.get(e);return po(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)})),()=>Tn(this._interceptorsByName.get(s),e)}getInterceptPoints(){return this._interceptorPoints}}const tc=ut.createIdentifier("univer.snapshot-server-service");class ec{constructor(){g(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:Xt.OK,message:""}})}getSheetBlock(n,e){const s=this._sheetBlockCache.get(e.blockID);return Promise.resolve({block:s,error:{code:Xt.OK,message:""}})}fetchMissingChangesets(n,e){return Promise.resolve({changesets:[],error:{code:Xt.OK,message:""}})}getResourcesRequest(n,e){return Promise.resolve({resources:{},error:{code:Xt.OK,message:""}})}saveSnapshot(n,e){return Promise.resolve({error:{code:Xt.OK,message:""}})}saveSheetBlock(n,e){const{block:s}=e;return s?(this._sheetBlockCache.set(s.id,s),Promise.resolve({error:{code:Xt.OK,message:""},blockID:s.id})):Promise.resolve({error:{code:Xt.UNDEFINED,message:"block is required"},blockID:""})}saveChangeset(n,e){return Promise.resolve({error:{code:Xt.OK,message:""},concurrent:[]})}}function nc(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,(n,e)=>String.fromCharCode(Number.parseInt(e,16))))}function vs(t){return decodeURIComponent(Array.prototype.map.call(atob(t),n=>`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""))}const nn=new TextEncoder,xn=new TextDecoder;function Ro(t){const n=y.deepClone(t);return delete n.id,delete n.name,delete n.rowCount,delete n.columnCount,delete n.cellData,nn.encode(JSON.stringify(n))}function Co(t){const n=y.deepClone(t);return delete n.id,delete n.rev,delete n.name,delete n.sheetOrder,delete n.sheets,nn.encode(JSON.stringify(n))}function sc(t){const n=y.deepClone(t);return delete n.id,delete n.rev,delete n.title,delete n.resources,nn.encode(JSON.stringify(n))}function Vs(t){return JSON.parse(xn.decode(t))}function rc(t){return JSON.parse(typeof t=="string"?vs(t):xn.decode(t))}function ic(t){return JSON.parse(typeof t=="string"?vs(t):xn.decode(t))}const Kn=256*20;function Io(t,n){const e=new ee(t),s=e.getLength(),r=[];let i=0;for(;i<s;){const o=Math.min(i+Kn,s-1),a=e.getSlice(i,Math.min(i+Kn,s-1),0,n),l=oc(a);r.push({id:y.generateRandomId(19,"0123456789"),startRow:i,endRow:o,data:l}),i+=Kn}return r}function oc(t){const n=t.getData();return nn.encode(JSON.stringify(n))}async function ac(t,n,e,s,r){const i={},o={};if(!await Promise.all(Object.entries(n.sheets).map(async([u,d])=>{const f={id:d.id,type:An.GRID,name:d.name,rowCount:d.rowCount,columnCount:d.columnCount,originalMeta:Ro(d)};if(o[u]=f,d.cellData){const m=Io(d.cellData,d.rowCount),E=await Promise.all(m.map(D=>r.saveSheetBlock(t,{unitID:e,type:Q.UNIVER_SHEET,block:D})));if(E.some(D=>{var P;return((P=D.error)==null?void 0:P.code)!==Xt.OK}))return!1;i[u]={sheetID:u,blocks:E.map(D=>D.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const l=Co(n),c={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:c.rev,type:Q.UNIVER_SHEET,workbook:c,doc:void 0}}}async function lc(t,n,e,s,r){var d,f;const i={},o={};if(!await Promise.all(Object.entries(n.sheets).map(async([m,E])=>{const D={id:E.id,type:An.GRID,name:E.name,rowCount:E.rowCount,columnCount:E.columnCount,originalMeta:Ro(E)};if(o[m]=D,E.cellData){const P=Io(E.cellData,E.rowCount),tt=await Promise.all(P.map(mt=>r.saveSheetBlock(t,{unitID:e,type:Q.UNIVER_SHEET,block:mt})));if(tt.some(mt=>{var ht;return((ht=mt.error)==null?void 0:ht.code)!==Xt.OK}))return!1;i[m]={sheetID:m,blocks:tt.map(mt=>mt.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const l=Co(n),c={unitID:n.id,rev:s,creator:"",name:n.name,sheetOrder:n.sheetOrder,sheets:o,blockMeta:i,resources:n.resources||[],originalMeta:l},h={unitID:e,rev:c.rev,type:Q.UNIVER_SHEET,workbook:c,doc:void 0},u=await r.saveSnapshot(t,{unitID:e,type:Q.UNIVER_SHEET,snapshot:h});if(_i(u.error))throw new Error(`transformWorkbookDataToSnapshot(): Failed to save snapshot.
8
- ErrorCode: ${(d=u.error)==null?void 0:d.code}:${(f=u.error)==null?void 0:f.message}`);return{snapshot:h}}function uc(t,n,e){const s=t.workbook;if(!s)throw new Error("");const r={};Object.entries(s.sheets).forEach(([l,c])=>{const h=Vs(c.originalMeta);r[l]={id:c.id,name:c.name,rowCount:c.rowCount,columnCount:c.columnCount,...h}});const i=new Map;n.forEach(l=>{i.set(l.id,l)}),s.blockMeta&&Object.entries(s.blockMeta).forEach(([l,c])=>{var d;const h=r[l];h.cellData={};const u=[];(d=c.blocks)==null||d.forEach(f=>{const m=i.get(f);if(m)u.push(m);else throw new Error("")}),u.forEach(f=>{const m=rc(f.data);Object.entries(m).forEach(([E,D])=>{const P=h.cellData[+E]={};Object.entries(D).forEach(([tt,mt])=>{P[+tt]=mt})})})});const o=Vs(s.originalMeta);return{id:t.unitID,rev:s.rev,name:s.name,sheetOrder:s.sheetOrder,appVersion:"",locale:Te.EN_US,sheets:r,styles:{},resources:s.resources||[],...o}}function cc(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:c={},drawings:h={},drawingsOrder:u=[]}=ic(i);return{id:e,rev:s,locale:Te.EN_US,title:r,body:a,documentStyle:l,settings:c,drawings:h,drawingsOrder:u,resources:o}}async function hc(t,n,e,s,r){var l,c,h;const i={unitID:n.id,rev:s,creator:"",name:(l=n.title)!=null?l:"",resources:n.resources||[],originalMeta:sc(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(_i(a.error))throw new Error(`transformDocumentDataToSnapshot(): Failed to save snapshot.
9
- ErrorCode: ${(c=a.error)==null?void 0:c.code}:${(h=a.error)==null?void 0:h.message}`);return{snapshot:o}}async function dc(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 c={unitID:e.unitID,type:Q.UNIVER_SHEET,blockID:l},{block:h}=await n.getSheetBlock({},c);if(h)s.push(h);else throw new Error("Block not found")});r.push(...a)}),await Promise.all(r),s}var So=(t=>(t[t.INFO=0]="INFO",t[t.STOP=1]="STOP",t[t.WARNING=2]="WARNING",t))(So||{}),Oo=(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))(Oo||{}),No=(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))(No||{}),Ao=(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))(Ao||{}),bo=(t=>(t.VALID="valid",t.INVALID="invalid",t.VALIDATING="validating",t))(bo||{});const fc=["script","style","meta","comment","link"];function gc(t){return!(t.length===0||t.length>31||t.startsWith("'")||t.endsWith("'")||/[:\\\/\?\*\[\]]/.test(t))}Do();exports.ABCToNumber=Ka;exports.AbsoluteRefType=At;exports.ActionIterator=ss;exports.AlignTypeH=Fr;exports.AlignTypeV=Wr;exports.ArrangeTypeEnum=Gr;exports.ArrowsAndMarkersShapes=cr;exports.AutoFillSeries=Zs;exports.BaselineOffset=ke;exports.BasicShapes=ur;exports.BlockType=Cr;exports.BooleanNumber=K;exports.BorderStyleTypes=dt;exports.BorderType=Js;exports.BulletAlignment=fe;exports.COLORS=Yn;exports.CellValueType=Ae;exports.ClientSnapshotServerService=ec;exports.Color=be;exports.ColorBuilder=vn;exports.ColorKit=te;exports.ColorType=zt;exports.ColumnSeparatorType=Nr;exports.CommandType=tn;exports.CommonHideTypes=Qs;exports.ConfigService=Hi;exports.ContentAlignment=yr;exports.ContextService=ui;exports.CopyPasteType=tr;exports.CustomDecorationType=Rr;exports.CustomRangeType=pr;exports.DEFAULT_CELL=sl;exports.DEFAULT_DOC=Is;exports.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=xo;exports.DEFAULT_EMPTY_DOCUMENT_VALUE=Cu;exports.DEFAULT_RANGE=el;exports.DEFAULT_RANGE_ARRAY=tl;exports.DEFAULT_SELECTION=nl;exports.DEFAULT_SLIDE=ii;exports.DEFAULT_STYLES=dn;exports.DEFAULT_WORKSHEET_COLUMN_COUNT=Bi;exports.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=Kl;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Ki;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=ql;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH=ji;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=zl;exports.DEFAULT_WORKSHEET_ROW_COUNT=$i;exports.DEFAULT_WORKSHEET_ROW_COUNT_KEY=Vl;exports.DEFAULT_WORKSHEET_ROW_HEIGHT=Gi;exports.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=Yl;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=Vi;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=Xl;exports.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=ro;exports.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=so;exports.DashStyleType=Ur;exports.DataStreamTreeNodeType=Ei;exports.DataStreamTreeTokenType=ce;exports.DataValidationErrorStyle=So;exports.DataValidationImeMode=Oo;exports.DataValidationOperator=No;exports.DataValidationRenderMode=mo;exports.DataValidationStatus=bo;exports.DataValidationType=Ao;exports.DependentOn=Lu;exports.DesktopLogService=hi;exports.DeveloperMetadataVisibility=er;exports.Dimension=nr;exports.Direction=sr;exports.Disposable=Dt;exports.DisposableCollection=us;exports.DocStyleType=mr;exports.DocumentDataModel=we;exports.DocumentFlavor=Ir;exports.DrawingTypeEnum=jr;exports.EDITOR_ACTIVATED=Xi;exports.EXTENSION_NAMES=oi;exports.Entry=zn;exports.EntryIterator=ei;exports.ErrorService=Fi;exports.EventState=Eo;exports.EventSubject=qu;exports.FOCUSING_COMMON_DRAWINGS=cu;exports.FOCUSING_DOC=gn;exports.FOCUSING_EDITOR_BUT_HIDDEN=iu;exports.FOCUSING_EDITOR_INPUT_FORMULA=ou;exports.FOCUSING_EDITOR_STANDALONE=lu;exports.FOCUSING_FORMULA_EDITOR=qi;exports.FOCUSING_SHEET=Ke;exports.FOCUSING_SLIDE=_n;exports.FOCUSING_UNIVER_EDITOR=au;exports.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=uu;exports.FollowNumberWithType=Er;exports.FontItalic=En;exports.FontStyleType=xr;exports.FontWeight=pn;exports.FormatType=rr;exports.GlyphType=je;exports.GridType=Sr;exports.HLSColor=gr;exports.HorizontalAlign=Ne;exports.IAuthzIoService=go;exports.ICommandService=en;exports.IConfigService=ki;exports.IContextService=Qe;exports.ILocalStorageService=Zu;exports.ILogService=pe;exports.IPermissionService=Ns;exports.IResourceLoaderService=As;exports.IResourceManagerService=Ln;exports.ISnapshotServerService=tc;exports.IUndoRedoService=yn;exports.IUniverInstanceService=Fe;exports.InterceptorManager=Qu;exports.InterpolationPointType=ir;exports.JSON1=kl;exports.JSONX=ve;exports.KeyIterator=Qr;exports.LRUHelper=Be;exports.LRUMap=ni;exports.LifecycleStages=ft;exports.LocaleService=Ye;exports.LocaleType=Te;exports.LogLevel=ci;exports.MOVE_BUFFER_VALUE=$e;exports.MemoryCursor=yi;exports.NamedStyleType=Tr;exports.NilCommand=di;exports.NumberUnitType=Hr;exports.ObjectMatrix=ee;exports.ObjectRelativeFromH=Pr;exports.ObjectRelativeFromV=kr;exports.OnLifecycle=Zi;exports.OtherShapes=hr;exports.PRESET_LIST_TYPE=ml;exports.PageElementType=Vr;exports.PageOrientType=Br;exports.PageType=as;exports.ParagraphElementType=br;exports.PermissionService=eo;exports.PermissionStatus=Os;exports.Plugin=is;exports.PositionedObjectLayoutType=wr;exports.PresetListType=Sn;exports.ProtectionType=or;exports.RANGE_TYPE=it;exports.RGBA_PAREN=$o;exports.RGB_PAREN=Wo;exports.ROTATE_BUFFER_VALUE=zs;exports.Range=He;exports.Rectangle=me;exports.RedoCommand=uo;exports.RedoCommandId=oo;exports.RefAlias=Va;exports.Registry=hs;exports.RegistryAsMap=ds;exports.RelativeDate=ar;exports.RelativeSlideLink=Kr;exports.ResourceManagerService=no;exports.RgbColor=Rn;exports.RxDisposable=xa;exports.SectionType=Or;exports.SheetTypes=An;exports.SheetViewModel=zi;exports.SlideDataModel=Ss;exports.SpacingRule=Mr;exports.SpecialShapes=dr;exports.Styles=Wi;exports.THEME_COLORS=fr;exports.TabStopAlignment=Lr;exports.TextDecoration=lr;exports.TextDirection=qe;exports.TextDirectionType=Ar;exports.TextX=Ee;exports.TextXActionType=J;exports.ThemeColor=Cn;exports.ThemeColorType=Ht;exports.ThemeColors=bn;exports.ThemeService=bs;exports.Tools=y;exports.UndoCommand=lo;exports.UndoCommandId=ao;exports.UnitModel=Mn;exports.Univer=Fu;exports.UniverInstanceType=Q;exports.UpdateDocsAttributeType=Pt;exports.ValueIterator=ti;exports.VerticalAlign=xe;exports.WidthType=Dr;exports.Worksheet=Je;exports.WrapStrategy=Pe;exports.WrapTextType=vr;exports.afterInitApply=_l;exports.b64DecodeUnicode=vs;exports.b64EncodeUnicode=nc;exports.binarySearchArray=Xs;exports.cellToRange=ba;exports.characterSpacingControlType=$r;exports.checkForSubstrings=va;exports.checkIfMove=Po;exports.checkParagraphHasBullet=wa;exports.checkParagraphHasIndent=Ta;exports.checkParagraphHasIndentByStyle=Xr;exports.codeToBlob=Ho;exports.composeBody=ts;exports.composeInterceptors=po;exports.concatMatrixArray=$a;exports.convertBodyToHtml=Qa;exports.covertTextRunToHtml=Qn;exports.createDefaultUser=Nn;exports.createInterceptorKey=Ju;exports.createInternalEditorID=Iu;exports.createRowColIter=Jn;exports.debounce=Ja;exports.dedupe=Pa;exports.deepCompare=ls;exports.deleteContent=Zr;exports.extractPureTextFromCell=Zl;exports.fromCallback=fi;exports.fromObservable=ya;exports.generateTemporarySnap=ac;exports.getArrayLength=_e;exports.getBodySlice=Ze;exports.getBodySliceHtml=hn;exports.getBorderStyleType=Oa;exports.getCellInfoInMergeData=oa;exports.getCellValueType=na;exports.getColorStyle=re;exports.getCustomDecorationSlice=Li;exports.getCustomRangeSlice=Ui;exports.getDocsUpdateBody=Na;exports.getReverseDirection=Fo;exports.getSheetBlocksFromSnapshot=dc;exports.getWorksheetUID=ru;exports.groupBy=Fa;exports.handleStyleToString=Sa;exports.hashAlgorithm=Ua;exports.horizontalLineSegmentsSubtraction=wn;exports.insertMatrixArray=Xn;exports.insertTextToContent=qr;exports.isBlackColor=Qo;exports.isBooleanString=Vu;exports.isCellCoverable=Ra;exports.isCellV=ra;exports.isEmptyCell=Yr;exports.isFormulaId=Ia;exports.isFormulaString=Ca;exports.isICellData=ea;exports.isInternalEditorID=Su;exports.isNullCell=sa;exports.isNumeric=_o;exports.isRangesEqual=$u;exports.isRealNum=Ma;exports.isSafeNumeric=ju;exports.isSameStyleTextRun=zr;exports.isUnitRangesEqual=Bu;exports.isValidRange=Aa;exports.isWhiteColor=ta;exports.makeArray=Wa;exports.makeCellRangeToRangeData=pa;exports.makeCellToSelection=Ea;exports.mergeOverrideWithDependencies=fo;exports.mergeSets=Ku;exports.mergeWorksheetSnapshotWithDefault=Yi;exports.moveMatrixArray=Zn;exports.moveRangeByOffset=ll;exports.nameCharacterCheck=gc;exports.normalizeBody=wl;exports.normalizeTextRuns=fs;exports.numberToABC=za;exports.numberToListABC=Xa;exports.orderSearchArray=qs;exports.queryObjectMatrix=al;exports.remove=Tn;exports.repeatStringNumTimes=ri;exports.replaceInDocumentBody=Xu;exports.requestImmediateMacroTask=zu;exports.rotate=Ha;exports.runOnLifecycle=Un;exports.searchArray=ko;exports.selectionToArray=ia;exports.sequence=li;exports.sequenceAsync=ai;exports.sequenceExecute=cs;exports.sequenceExecuteAsync=gl;exports.shallowEqual=Gu;exports.skipParseTagNames=fc;exports.sliceMatrixArray=Ba;exports.sortRules=qa;exports.sortRulesByDesc=Za;exports.sortRulesFactory=Me;exports.spliceArray=qn;exports.takeAfter=gi;exports.textDecoder=xn;exports.textEncoder=nn;exports.throttle=Yu;exports.toDisposable=bt;exports.transformDocumentDataToSnapshot=hc;exports.transformSnapshotToDocumentData=cc;exports.transformSnapshotToWorkbookData=uc;exports.transformWorkbookDataToSnapshot=lc;exports.updateAttributeByDelete=xi;exports.updateAttributeByInsert=Pi;
3
+ `):"",this.name="UnsubscriptionError",this.errors=e}});function xs(t,n){if(t){var e=t.indexOf(n);0<=e&&t.splice(e,1)}}var ti=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=Ls(o),l=a.next();!l.done;l=a.next()){var h=l.value;h.remove(this)}}catch(E){n={error:E}}finally{try{l&&!l.done&&(e=a.return)&&e.call(a)}finally{if(n)throw n.error}}else o.remove(this);var c=this.initialTeardown;if(Ve(c))try{c()}catch(E){i=E instanceof Wn?E.errors:[E]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var d=Ls(u),f=d.next();!f.done;f=d.next()){var m=f.value;try{Ps(m)}catch(E){i=i!=null?i:[],E instanceof Wn?i=ys(ys([],Ds(i)),Ds(E.errors)):i.push(E)}}}catch(E){s={error:E}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(s)throw s.error}}}if(i)throw new Wn(i)}},t.prototype.add=function(n){var e;if(n&&n!==this)if(this.closed)Ps(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)&&xs(e,n)},t.prototype.remove=function(n){var e=this._finalizers;e&&xs(e,n),n instanceof t&&n._removeParent(this)},t.EMPTY=function(){var n=new t;return n.closed=!0,n}(),t}();ti.EMPTY;function ka(t){return t instanceof ti||t&&"closed"in t&&Ve(t.remove)&&Ve(t.add)&&Ve(t.unsubscribe)}function Ps(t){Ve(t)?t():t.unsubscribe()}function bt(t){let n=!1;return t?ka(t)?{dispose:()=>t.unsubscribe()}:typeof t=="function"?{dispose:()=>{n||(n=!0,t())}}:t:bt(()=>{})}function Ha(t){return bt(()=>{t.unsubscribe()})}class us{constructor(){_(this,"_disposables",new Set)}add(n){const e=bt(n);return this._disposables.add(e),{dispose:()=>{e.dispose(),this._disposables.delete(e)}}}dispose(){this._disposables.forEach(n=>{n.dispose()}),this._disposables.clear()}}class Tt{constructor(){_(this,"_disposed",!1);_(this,"_collection",new us)}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 Fa extends Tt{constructor(){super(...arguments);_(this,"dispose$",new Z.Subject)}dispose(){super.dispose(),this.dispose$.next(),this.dispose$.complete()}}class $a extends Tt{constructor(e){super();_(this,"_ref",0);this._rootDisposable=e}inc(){if(this._disposed)throw new Error("[RCDisposable]: should not ref to a disposed.");this._ref+=1}dec(){this._ref-=1,this._ref===0&&(this._rootDisposable.dispose(),this.dispose())}}class Be{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 Tn(t,n){const e=t.indexOf(n);return e>-1?(t.splice(e,1),!0):!1}function Wa(t){const n=new Set,e=[];for(const s of t)n.has(s)||(n.add(s),e.push(s));return e}function Ba(t,n){for(let e=t.length-1;e>-1;e--){const s=t[e];if(n(s,e))return s}return null}function Ga(t,n){if(t.length===0)return t;const e=n%t.length;return t.slice(e).concat(t.slice(0,e))}function ja(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 Va(t){return Array.isArray(t)?t:[t]}const ct=Symbol("newer"),Dt=Symbol("older");class ei{constructor(n){_(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ct],{done:!1,value:n.key}):{done:!0,value:void 0}}}class ni{constructor(n){_(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ct],{done:!1,value:n.value}):{done:!0,value:void 0}}}class si{constructor(n){_(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ct],{done:!1,value:[n.key,n.value]}):{done:!0,value:void 0}}}var Ys,zs;zs=ct,Ys=Dt;class zn{constructor(n,e){_(this,"key");_(this,"value");_(this,zs);_(this,Ys);this.key=n,this.value=e,this[ct]=void 0,this[Dt]=void 0}toJSON(){return{key:this.key,value:this.value}}}class ri{constructor(...n){_(this,"_keymap");_(this,"size",0);_(this,"limit");_(this,"oldest");_(this,"newest");_(this,"_onShiftListeners",[]);if(Be.hasLength(n,1)){if(Be.isNumber(n[0])){const e=n[0];this._initialize(e,void 0);return}if(Be.isIterable(n[0])){const e=n[0];this._initialize(0,e);return}return}if(Be.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),bt(()=>Tn(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[ct]&&(n===this.oldest&&(this.oldest=n[ct]),n[ct][Dt]=n[Dt]),n[Dt]&&(n[Dt][ct]=n[ct]),n[ct]=void 0,n[Dt]=this.newest,this.newest&&(this.newest[ct]=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 zn(i.value[0],i.value[1]);if(this._keymap.set(o.key,o),e?(e[ct]=o,o[Dt]=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 zn(n,e)),this.newest?(this.newest[ct]=s,s[Dt]=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[ct]?(this.oldest=this.oldest[ct],this.oldest[Dt]=void 0):(this.oldest=void 0,this.newest=void 0),n[ct]=n[Dt]=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[ct]&&e[Dt]?(e[Dt][ct]=e[ct],e[ct][Dt]=e[Dt]):e[ct]?(e[ct][Dt]=void 0,this.oldest=e[ct]):e[Dt]?(e[Dt][ct]=void 0,this.newest=e[Dt]):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 ei(this.oldest)}values(){return new ni(this.oldest)}entries(){return this[Symbol.iterator]()}[Symbol.iterator](){return new si(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[ct]}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[ct];return n}toString(){let n="",e=this.oldest;for(;e;)n+=`${String(e.key)}:${e.value}`,e=e[ct],e&&(n+=" < ");return n}}function ge(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 Xn(t,n,e){const s=ge(e),r=e;for(let i=s-1;i>=t;i--)r[i+1]=r[i];r[t]=n}function qn(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 Ka(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 c=0;c<r;c++,h++){const u=s[c];l[h]=e[u]}for(let c=0;c<a;c++,h++){const u=o[c];l[h]=i[u]}return l}function Ya(t,n,e){const s=e;if(ge(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 Zn(t,n,e,s){const r=t>e;if(!r&&t+n>e)throw new Error("Invalid move operation");r?za(t,n,e,s):Xa(t,n,e,s)}function za(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 Xa(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 ee{constructor(n={}){_(this,"_matrix");this._setOriginValue(n)}static MakeObjectMatrixSize(n){return new ee({[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),c=o[Number(l)];if(n(i,h,c)===!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){Zn(n,e,s,this._matrix)}moveColumns(n,e,s){this.forEach((r,i)=>{Zn(n,e,s,i)})}insertRows(n,e){for(let s=n;s<n+e;s++)Xn(s,{},this._matrix)}insertColumns(n,e){for(let s=n;s<n+e;s++)this.forEach((r,i)=>{i&&Xn(s,void 0,i)})}removeRows(n,e){qn(n,e,this._matrix)}removeColumns(n,e){this.forEach((s,r)=>{r&&qn(n,e,r)})}getFragment(n,e,s,r){const i=new ee;let o=0;for(let a=n;a<=e;a++){const l={};let h=0;for(let c=s;c<=r;c++){const u=this.getValue(a,c);l[h]=u,h++}i.setRow(o,l),o++}return i}getSlice(n,e,s,r){const i=new ee;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,x.deepClone(l))}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 a=this.getRow(o);if(a){const l=ge(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 ee;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 c=this.getValue(o,h);i.setValue(o-n,h-e,c)})}),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=ge(l)-1;h>s&&(s=h),Object.keys(l).forEach(c=>{const u=Number(c);o?u<e&&(e=u):(o=!0,e=u)}),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 ue=class ue{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===it.NORMAL||e.rangeType===void 0&&n.rangeType===it.NORMAL)}static intersects(n,e){if(n.rangeType===it.ROW&&e.rangeType===it.COLUMN||n.rangeType===it.COLUMN&&e.rangeType===it.ROW)return!0;if(n.rangeType===it.ROW&&e.rangeType===it.ROW)return n.startRow<=e.endRow&&n.endRow>=e.startRow;if(n.rangeType===it.COLUMN&&e.rangeType===it.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,c=Number.isNaN(e.startColumn)?0:e.startColumn,u=Number.isNaN(e.endColumn)?s:e.endColumn,d=Math.abs(o+a-c-u),f=Math.abs(o-a)+Math.abs(c-u),m=Math.abs(r+i-l-h),E=Math.abs(r-i)+Math.abs(l-h);return d<=f&&m<=E}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,c=e.endColumn;let u,d,f,m;if(a<=r)a>=s?d=a:d=s;else return null;if(l>=s)l>=r?m=r:m=l;else return null;if(h<=o)h>i?u=h:u=i;else return null;if(c>=i)c>=o?f=o:f=c;else return null;return{startRow:d,endRow:m,startColumn:u,endColumn:f,rangeType:it.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 ue.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:it.NORMAL}),n[0])}static realUnion(...n){const e=n.some(i=>i.rangeType===it.COLUMN),s=n.some(i=>i.rangeType===it.ROW),r=ue.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?it.ROW:e?it.COLUMN:it.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}}};_(ue,"getRelativeRange",(n,e)=>({startRow:n.startRow-e.startRow,endRow:n.endRow-n.startRow,startColumn:n.startColumn-e.startColumn,endColumn:n.endColumn-n.startColumn})),_(ue,"getPositionRange",(n,e,s)=>({...s||{},startRow:s&&[At.ROW,At.ALL].includes(s.startAbsoluteRefType||0)?s.startRow:n.startRow+e.startRow,endRow:s&&[At.ROW,At.ALL].includes(s.endAbsoluteRefType||0)?s.endRow:n.endRow+n.startRow+e.startRow,startColumn:s&&[At.COLUMN,At.ALL].includes(s.startAbsoluteRefType||0)?s.startColumn:n.startColumn+e.startColumn,endColumn:s&&[At.COLUMN,At.ALL].includes(s.endAbsoluteRefType||0)?s.endColumn:n.endColumn+n.startColumn+e.startColumn})),_(ue,"moveHorizontal",(n,e=0,s=0)=>({...n,startColumn:n.startColumn+e,endColumn:n.endColumn+e+s})),_(ue,"moveVertical",(n,e=0,s=0)=>({...n,startRow:n.startRow+e,endRow:n.endRow+e+s})),_(ue,"moveOffset",(n,e,s)=>({...n,startRow:n.startRow+s,endRow:n.endRow+s,startColumn:n.startColumn+e,endColumn:n.endColumn+e}));let me=ue;class qa{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 Jn(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 Za(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 In=65,ii=90,Ja=97;function Qa(t){const n=ii-In+1;let e="";for(;t>=0;)e=String.fromCharCode(t%n+In)+e,t=Math.floor(t/n)-1;return e}function oi(t,n){let e="";for(;n>0;)e+=t,n--;return e}function tl(t,n=!1){const e=ii-In+1;let s=Ja;n&&(s=In);const r=String.fromCharCode(t%e+s),i=Math.floor(t/e)+1;return oi(r,i)}function el(t,n){return t.zIndex>n.zIndex?1:t.zIndex===n.zIndex?0:-1}function nl(t,n){return t.zIndex>n.zIndex?-1:t.zIndex===n.zIndex?0:1}function Me(t="index",n=1){return(e,s)=>e[t]>s[t]?n:e[t]===s[t]?0:-n}function sl(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 hn(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;x.hasIntersectionBetweenTwoRanges(n,e,l,h)&&(l>i?(o.push(s.slice(i,l)),o.push(Qn(s,{...a,ed:Math.min(h,e)}))):o.push(Qn(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 rl(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:c,spaceBelow:u,lineSpacing:d}=h,f=[];c!=null&&(typeof c=="number"?f.push(`margin-top: ${c}px`):f.push(`margin-top: ${c.v}px`)),u!=null&&(typeof u=="number"?f.push(`margin-bottom: ${u}px`):f.push(`margin-bottom: ${u.v}px`)),d!=null&&f.push(`line-height: ${d}`),l>o+1?i+=`<p class="UniverNormal" ${f.length?`style="${f.join("; ")};"`:""}>${hn(t,o+1,l)}</p>`:i+=`<p class="UniverNormal" ${f.length?`style="${f.join("; ")};"`:""}></p>`,o=l}return o!==s.length&&(i+=hn(t,o,s.length)),i}else return hn(t,0,t.dataStream.length)}function Qn(t,n){const{st:e,ed:s,ts:r={}}=n,{ff:i,fs:o,it:a,bl:l,ul:h,st:c,ol:u,bg:d,cl:f,va:m}=r;let E=t.slice(e,s);const M=[];return a===K.TRUE&&(E=`<i>${E}</i>`),m===ke.SUPERSCRIPT?E=`<sup>${E}</sup>`:m===ke.SUBSCRIPT&&(E=`<sub>${E}</sub>`),(h==null?void 0:h.s)===K.TRUE&&(E=`<u>${E}</u>`),(c==null?void 0:c.s)===K.TRUE&&(E=`<s>${E}</s>`),l===K.TRUE&&(E=`<strong>${E}</strong>`),i&&M.push(`font-family: ${i}`),f&&M.push(`color: ${f.rgb}`),o&&M.push(`font-size: ${o}pt`),u&&M.push("text-decoration: overline"),d&&M.push(`background: ${d.rgb}`),M.length?`<span style="${M.join("; ")};">${E}</span>`:E}const il={sheetId:"",range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},ol={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},al={startRow:0,startColumn:0,endRow:0,endColumn:0},ll={row:0,column:0},dn={ff:"Arial",fs:11,it:K.FALSE,bl:K.FALSE,ul:{s:K.FALSE},st:{s:K.FALSE},ol:{s:K.FALSE},tr:{a:0,v:K.FALSE},td:qe.UNSPECIFIED,cl:{rgb:"#000"},bg:{rgb:"#fff"},ht:Ne.UNSPECIFIED,vt:xe.UNSPECIFIED,tb:Pe.UNSPECIFIED,pd:{t:0,r:0,b:0,l:0}},ai={id:"default_slide",title:"defaultSlide",pageSize:{width:300,height:300}};var li=(t=>(t.ARRAY_CONVERTOR="ARRAY_CONVERTOR",t.MATRIX_CONVERTOR="MATRIX_CONVERTOR",t))(li||{});function ln(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 K.FALSE;switch(t){case"bl":case"it":{if(o[t]===K.FALSE)return K.FALSE;break}case"ul":case"st":{if(o[t].s===K.FALSE)return K.FALSE;break}default:throw new Error(`unknown style key: ${t} in IStyleBase`)}s+=l-a}return n.dataStream.indexOf(`\r
4
+ `)===s?K.TRUE:K.FALSE}const ze=class ze{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 ee;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 ee;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=x.numToWord(s+1)+(n+1),o=x.numToWord(r+1)+(e+1)):(i=x.numToWord(r+1)+(e+1),o=x.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)||dn.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 ze(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 c=0;c<=i-r;c++){if(o==null||((a=o==null?void 0:o[h])==null?void 0:a[c])==null)continue;const u=o[h][c].s;u&&(o[h][c].s=l.get(u))}}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)||dn.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?ln("ul",n.body)===K.TRUE?{s:K.TRUE}:{s:K.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?ln("st",n.body)===K.TRUE?{s:K.TRUE}:{s:K.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?ln("it",n.body)===K.TRUE?En.ITALIC:En.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?ln("bl",n.body)===K.TRUE?pn.BOLD:pn.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()===Pe.WRAP?K.TRUE:K.FALSE}getWrapStrategies(){return this._getStyles("tb")}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(n){ze.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]||dn[n]}))}};_(ze,"transformRange",(n,e)=>n.rangeType===it.ALL?{startColumn:0,startRow:0,endColumn:e.getMaxColumns()-1,endRow:e.getMaxRows()-1}:n.rangeType===it.COLUMN?{startRow:0,endRow:e.getMaxRows()-1,startColumn:n.startColumn,endColumn:n.endColumn}:n.rangeType===it.ROW?{startColumn:0,endColumn:e.getMaxColumns()-1,startRow:n.startRow,endRow:n.endRow}:n);let He=ze;function ul(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=cl(e);o.area>s&&(s=o.area,r={startColumn:o.start,startRow:i-o.height+1,endColumn:o.end,endRow:i})}return r}function cl(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 hl(t,n){He.foreach(n,(e,s)=>{t[e][s]=void 0})}function dl(t,n){const e=t.toFullArray(),s=[];for(;;){const r=ul(e,n);if(!r)break;s.push(r),hl(e,r)}return s}function fl(t,n,e,s=!1){let r={...t};const i=r.startAbsoluteRefType||At.NONE,o=r.endAbsoluteRefType||At.NONE;return!s&&i===At.ALL&&o===At.ALL?r:s||i===At.NONE&&o===At.NONE?me.moveOffset(r,n,e):(i===At.NONE?r={...r,startRow:r.startRow+e,startColumn:r.startColumn+n}:i===At.COLUMN?r={...r,startRow:r.startRow+e}:i===At.ROW&&(r={...r,startColumn:r.startColumn+n}),o===At.NONE?r={...r,endRow:r.endRow+e,endColumn:r.endColumn+n}:o===At.COLUMN?r={...r,endRow:r.endRow+e}:o===At.ROW&&(r={...r,endColumn:r.endColumn+n}),r)}async function ui(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 ci(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 Qe=ut.createIdentifier("univer.context-service");class hi extends Tt{constructor(){super(...arguments);_(this,"_contextChanged$",new Z.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 Z.Observable(s=>{const r=this._contextChanged$.pipe(Z.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 di=(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))(di||{});const pe=ut.createIdentifier("univer.log");class fi extends Tt{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 _l=Object.defineProperty,gl=Object.getOwnPropertyDescriptor,ml=(t,n,e,s)=>{for(var r=s>1?void 0:s?gl(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&&_l(n,e,r),r},ks=(t,n)=>(e,s)=>n(e,s,t),tn=(t=>(t[t.COMMAND=0]="COMMAND",t[t.OPERATION=1]="OPERATION",t[t.MUTATION=2]="MUTATION",t))(tn||{});const en=ut.createIdentifier("anywhere.command-service");class El{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),bt(()=>{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 _i={id:"nil",type:0,handler:()=>!0};exports.CommandService=class extends Tt{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 El,this._registerCommand(_i)}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),bt(()=>{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),bt(()=>{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(c=>c(a,r));const h=await this._execute(o,s,r);return this._commandExecutedListeners.forEach(c=>c(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 u=Ba(this._commandExecutionStack,d=>d.type===0);u&&(l.params=(o=l.params)!=null?o:{},l.params.trigger=u.id)}const h=this._pushCommandExecutionStack(l);this._beforeCommandExecutionListeners.forEach(u=>u(l,r));const c=this._syncExecute(a,s,r);return this._commandExecutedListeners.forEach(u=>u(l,r)),h.dispose(),c}throw new Error(`[CommandService]: command "${e}" is not registered.`)}_pushCommandExecutionStack(e){return this._commandExecutionStack.push(e),bt(()=>Tn(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 us;r=new pl(e.id),o.add(this._commandRegistry.registerCommand(r)),o.add(bt(()=>{this._multiCommandDisposables.delete(e.id)})),this._multiCommandDisposables.set(e.id,o)}const i=r.registerImplementation(e);return bt(()=>{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}};exports.CommandService=ml([ks(0,ut.Inject(ut.Injector)),ks(1,pe)],exports.CommandService);class pl{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(pe),r=n.get(Qe),i=n.get(ut.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),bt(()=>{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 cs(t,n,e){const s=t.map(r=>()=>n.syncExecuteCommand(r.id,r.params,e));return ci(s)}function Rl(t,n,e){const s=t.map(r=>()=>n.executeCommand(r.id,r.params,e));return ui(s)}function gi(t){return new Z.Observable(n=>{const e=t((...s)=>n.next(s));return()=>e==null?void 0:e.dispose()})}function mi(t){return function(e){return new Z.Observable(s=>(e.subscribe({next:r=>{s.next(r),t(r)&&s.complete()},complete:()=>s.complete(),error:r=>s.error(r)}),()=>s.unsubscribe()))}}const Cl=t=>new Promise(n=>{Z.merge(gi(t.onCommandExecuted.bind(t)).pipe(cn.filter(([e])=>e.type===tn.MUTATION)),Z.timer(300)).pipe(cn.debounceTime(16),cn.first()).subscribe(()=>{n()})});var Xt=(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))(Xt||{});function Ei(t){return!!(t&&t.code&&t.code!==Xt.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||{}),pi=(t=>(t[t.SomeCollaborator=0]="SomeCollaborator",t[t.AllCollaborator=1]="AllCollaborator",t[t.OneSelf=2]="OneSelf",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(pi||{}),Ft=(t=>(t[t.Reader=0]="Reader",t[t.Editor=1]="Editor",t[t.Owner=2]="Owner",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(Ft||{}),fn=(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))(fn||{});class Mn extends Tt{}class hs{constructor(){_(this,"_data",[])}static create(){return new hs}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 ds{constructor(){_(this,"_data",new Map)}static create(){return new ds}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||{}),ce=(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))(ce||{}),Sn=(t=>(t.BULLET_LIST="BULLET_LIST",t.ORDER_LIST="ORDER_LIST",t))(Sn||{});const Il={BULLET_LIST:{listType:"BULLET_LIST",nestingLevel:[{bulletAlignment:fe.START,glyphFormat:" %0",textStyle:{fs:12},startNumber:0,glyphSymbol:"●",hanging:{v:21},indentStart:{v:21}},{bulletAlignment:fe.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"■",hanging:{v:21},indentStart:{v:42}},{bulletAlignment:fe.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"◆",hanging:{v:21},indentStart:{v:63}}]},ORDER_LIST:{listType:"ORDER_LIST",nestingLevel:[{bulletAlignment:fe.START,glyphFormat:" %1.",textStyle:{fs:12},startNumber:0,glyphType:je.DECIMAL,hanging:{v:21},indentStart:{v:21}},{bulletAlignment:fe.START,glyphFormat:" %1.%2)",textStyle:{fs:12},startNumber:0,glyphType:je.DECIMAL,hanging:{v:21},indentStart:{v:42}},{bulletAlignment:fe.START,glyphFormat:" %1.%2.%3.",textStyle:{fs:12},startNumber:0,glyphType:je.DECIMAL,hanging:{v:21},indentStart:{v:63}}]}};function fs(t){const n=[];for(const e of t){const{ed:s,ts:r}=e;if(e.sId===void 0&&delete e.sId,x.isEmptyObject(r)&&e.sId==null)continue;if(n.length===0){n.push(e);continue}const i=n.pop();qr(e,i)&&x.hasIntersectionBetweenTwoRanges(i.st,i.ed,e.st,e.ed)?n.push({...e,st:i.st,ed:s}):n.push(i,e)}return n}function Ci(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 c of l)c.st+=s,c.ed+=s;for(let c=0;c<o;c++){const u=r[c],d=r[c+1],{st:f,ed:m}=u;if(m<s)i.push(u);else if(s>=f&&s<=m){if(d&&d.st===d.ed&&s===d.st){i.push(u);continue}if(a)u.st+=e,u.ed+=e,i.push(u);else{a=!0,u.ed+=e;const E=[];if(l.length){const M={...u,st:f,ed:l[0].st};M.ed>M.st&&E.push(M),E.push(...l);const L=l[l.length-1],tt={...u,st:L.ed,ed:m+e};tt.ed>tt.st&&E.push(tt)}else E.push(u);i.push(...E)}}else u.st+=e,u.ed+=e,a||(a=!0,i.push(...l)),i.push(u)}a||(a=!0,i.push(...l)),t.textRuns=fs(i)}function _s(t,n,e,s){const{paragraphs:r}=t;if(r==null)return;const{paragraphs:i,dataStream:o}=n,a=[];let l=-1;for(let c=0,u=r.length;c<u;c++){const d=r[c],{startIndex:f}=d;f>=s&&(d.startIndex+=e),l===-1&&f>=s&&(l=c),a.push(d.startIndex)}let h=-1;if(i){for(let c=0,u=i.length;c<u;c++){const d=i[c];d.startIndex+=s;const f=d.startIndex;h=a.indexOf(f)}if(o===ce.PARAGRAPH&&i.length===1){const c=r[l],u=i[0],d=c.paragraphStyle,f=c.bullet;c.paragraphStyle=u.paragraphStyle,c.bullet=u.bullet,u.paragraphStyle=d,u.bullet=f}h!==-1&&r.splice(h,1),r.push(...i),r.sort(Me("startIndex"))}}function Sl(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(Me("startIndex"))}}function Ii(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(Me("startIndex"))}}function Si(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:c}=l;h>s?(l.startIndex+=e,l.endIndex+=e):c>=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(Me("startIndex"))}}function Oi(t,n,e,s){t.customRanges||(t.customRanges=[]);const{customRanges:r}=t,i={};for(let l=0,h=r.length;l<h;l++){const c=r[l];i[c.rangeId]=c;const{startIndex:u,endIndex:d}=c;u>=s?(c.startIndex+=e,c.endIndex+=e):d>s-1&&(c.endIndex+=e)}if(r.find(l=>l.startIndex>s&&l.endIndex<s))return;const a=[];if(n.customRanges){for(let l=0,h=n.customRanges.length;l<h;l++){const c=n.customRanges[l],u=i[c.rangeId];if(c.startIndex+=s,c.endIndex+=s,u){if(u.startIndex<=c.startIndex&&u.endIndex>=c.endIndex||t.dataStream[u.startIndex]===ce.CUSTOM_RANGE_START&&t.dataStream[u.endIndex]===ce.CUSTOM_RANGE_END)continue;if(t.dataStream[u.startIndex]===ce.CUSTOM_RANGE_START){u.endIndex=c.endIndex;continue}if(t.dataStream[u.endIndex]===ce.CUSTOM_RANGE_END){u.startIndex=c.startIndex;continue}}a.push(c)}r.push(...a),r.sort(Me("startIndex"))}}function Ol(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 Nl(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=Ol(s);n[e]=r}),Object.values(n).flat()}function Ni(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=Nl(r),t.customDecorations.sort(Me("startIndex"))}}function Ai(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,c=s.length;h<c;h++){const u=s[h],{st:d,ed:f}=u;if(r<=d&&i>=f){o.push({...u,st:d-r,ed:f-r});continue}else d<=r&&f>=i?(o.push({...u,st:r-r,ed:i-r}),u.ed-=n):r>=d&&r<f?(o.push({...u,st:r-r,ed:f-r}),u.ed=r):i>d&&i<=f?(o.push({...u,st:d-r,ed:i-r}),u.st=i-n,u.ed-=n):d>=i&&(u.st-=n,u.ed-=n);l.push(u)}t.textRuns=l}return o.length===0&&o.push({st:0,ed:n,ts:{}}),o}function bi(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 c=s[l],{startIndex:u}=c;if(u>=r&&u<i){o.push({...c,startIndex:u-e});continue}else u>=i&&(c.startIndex-=n);a.push(c)}t.paragraphs=a}return o}function vi(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 c=s[l],{startIndex:u}=c;if(u>=r&&u<=i){o.push({...c,startIndex:u-e});continue}else u>i&&(c.startIndex-=n);a.push(c)}t.sectionBreaks=a}return o}function wi(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 c=s[l],{startIndex:u}=c;if(u>=r&&u<=i){o.push({...c,startIndex:u-e});continue}else u>i&&(c.startIndex-=n);a.push(c)}t.customBlocks=a}return o}function Ti(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 c=s[l],{startIndex:u,endIndex:d}=c;if(r<=u&&i>=d){o.push({...c,startIndex:u-e,endIndex:d-e});continue}else if(u<=r&&d>=i){const f=wn(u,d,r,i);c.startIndex=f[0],c.endIndex=f[1]}else i<u&&(c.startIndex-=n,c.endIndex-=n);a.push(c)}t.tables=a}return o}function Mi(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 c=s[l],{startIndex:u,endIndex:d}=c;if(r<=u&&i>=u){o.push({...c,startIndex:u-e,endIndex:d-e});continue}else if(u<=r&&d>=i){const f=wn(u,d,r,i);c.startIndex=f[0],c.endIndex=f[1]}else i<u&&(c.startIndex-=n,c.endIndex-=n);a.push(c)}t.customRanges=a}return o}function Ui(t,n,e,s=!0){const{customDecorations:r}=t,i=e,o=e+n-1,a=[];if(r){const l=[];for(let h=0,c=r.length;h<c;h++){const u=r[h],{startIndex:d,endIndex:f}=u;if(d>=i&&f<=o){a.push(u);continue}else if(Math.max(i,d)<=Math.min(o,f)){const m=wn(d,f,i,o);u.startIndex=m[0],u.endIndex=m[1]}else o<d&&s&&(u.startIndex-=n,u.endIndex-=n);l.push(u)}t.customDecorations=l}return a}function Al(t,n,e,s,r){const i=bl(t,n,e,s,r),o=vl(t,n,e,s,r),a=wl(t,n,e,s,r),l=Tl(t,n,e,s,r),h=Ml(t,n,e,s,r),c=Ul(t,n,e,s,r),u=Ll(t,n,e,s,r);return{dataStream:"",textRuns:i,paragraphs:o,sectionBreaks:a,customBlocks:l,tables:h,customRanges:c,customDecorations:u}}function bl(t,n,e,s,r){const{textRuns:i}=t,{textRuns:o}=n;if(i==null||o==null)return;const a=Ai(t,e,s);if(r!==Pt.REPLACE){const l=Li(o,a,r);n.textRuns=l}return Ci(t,n,e,s),a}function Li(t,n,e){if(n.length===0)return t;t=x.deepClone(t),n=x.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:f,ed:m,ts:E}=t[o],{st:M,ed:L,ts:tt,sId:mt}=n[a];let ht;if(e===Pt.COVER?ht={...tt,...E}:ht={...E,...tt},m<M)h()||s.push(t[o]),o++;else if(L<f)h()||s.push(n[a]),a++;else{const p={st:Math.min(f,M),ed:Math.max(f,M),ts:f<M?{...E}:{...tt},sId:f<M?void 0:mt};p.ed>p.st&&s.push(p),s.push({st:Math.max(f,M),ed:Math.min(m,L),ts:ht,sId:mt}),m<L?(o++,n[a].st=m,n[a].st===n[a].ed&&a++):(a++,t[o].st=L,t[o].st===t[o].ed&&o++);const S={st:Math.min(m,L),ed:Math.max(m,L),ts:m<L?{...tt}:{...E},sId:m<L?mt:void 0};l=S.ed>S.st?S:null}}h();const c=s[s.length-1],u=t[r-1],d=n[i-1];return c.ed!==Math.max(u.ed,d.ed)&&(u.ed>d.ed?s.push(u):s.push(d)),fs(s)}function vl(t,n,e,s,r){const{paragraphs:i}=t,{paragraphs:o}=n;if(i==null||o==null)return;const a=bi(t,e,s);if(r!==Pt.REPLACE){const l=[];for(const h of o){const{startIndex:c,paragraphStyle:u,bullet:d}=h;let f=[];for(const m of a){const{startIndex:E,paragraphStyle:M,bullet:L}=m;let tt,mt;if(r===Pt.COVER?(tt={...M,...u},mt={listId:"",listType:Sn.BULLET_LIST,nestingLevel:0,textStyle:{},...L,...d}):(tt={...u,...M},mt={listId:"",listType:Sn.BULLET_LIST,nestingLevel:0,textStyle:{},...d,...L}),c===E){f.push({startIndex:c,paragraphStyle:tt,bullet:mt});break}}l.push(...f),f=[]}n.paragraphs=l}return _s(t,n,e,s),a}function wl(t,n,e,s,r){const{sectionBreaks:i}=t,{sectionBreaks:o}=n;if(i==null||o==null)return;const a=vi(t,e,s);if(r!==Pt.REPLACE){const l=[];for(const h of o){const{startIndex:c}=h;let u=[];for(const d of a){const{startIndex:f}=d;if(c===f){r===Pt.COVER?u.push({...d,...h}):u.push({...h,...d});break}}l.push(...u),u=[]}n.sectionBreaks=l}return _s(t,n,e,s),a}function Tl(t,n,e,s,r){const{customBlocks:i}=t,{customBlocks:o}=n;if(i==null||o==null)return;const a=wi(t,e,s);if(r!==Pt.REPLACE){const l=[];for(const h of o){const{startIndex:c}=h;let u=[];for(const d of a){const{startIndex:f}=d;if(c===f){r===Pt.COVER?u.push({...d,...h}):u.push({...h,...d});break}}l.push(...u),u=[]}n.customBlocks=l}return Ii(t,n,e,s),a}function Ml(t,n,e,s,r){const{tables:i}=t,{tables:o}=n;if(i==null||o==null)return;const a=Ti(t,e,s);if(r!==Pt.REPLACE){const l=[];for(const h of o){const{startIndex:c,endIndex:u}=h;let d=[];for(const f of a){const{startIndex:m,endIndex:E}=f;if(m>=c&&E<=u){r===Pt.COVER?d.push({...f,...h}):d.push({...h,...f});break}}l.push(...d),d=[]}n.tables=l}return Si(t,n,e,s),a}function Ul(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===Pt.REPLACE&&(a=Mi(t,e,s)),Oi(t,n,0,s),a}function Ll(t,n,e,s,r){t.customDecorations||(t.customDecorations=[]);let i=[];return r===Pt.REPLACE&&(i=Ui(t,e,s,!1)),Ni(t,n,0,s),i}var gs=(t=>(t[t.copy=0]="copy",t[t.cut=1]="cut",t))(gs||{});function Ze(t,n,e,s=!1,r=1){const{dataStream:i,textRuns:o=[],paragraphs:a=[],customBlocks:l=[]}=t,h={dataStream:i.slice(n,e)},c=[];for(const m of o){const E=x.deepClone(m),{st:M,ed:L}=E;x.hasIntersectionBetweenTwoRanges(M,L,n,e)&&(n>=M&&n<=L?c.push({...E,st:n,ed:Math.min(e,L)}):e>=M&&e<=L?c.push({...E,st:Math.max(n,M),ed:e}):c.push(E))}c.length?h.textRuns=c.map(m=>{const{st:E,ed:M}=m;return{...m,st:E-n,ed:M-n}}):s&&(h.textRuns=[{st:0,ed:e-n,ts:{}}]);const u=[];for(const m of a){const{startIndex:E}=m;E>=n&&E<=e&&u.push(x.deepClone(m))}u.length&&(h.paragraphs=u.map(m=>({...m,startIndex:m.startIndex-n}))),r===1&&(h.customDecorations=yi(t,n,e));const{customRanges:d}=Di(t,n,e);h.customRanges=d;const f=[];for(const m of l){const{startIndex:E}=m;E>=n&&E<=e&&f.push(x.deepClone(m))}return f.length&&(h.customBlocks=f.map(m=>({...m,startIndex:m.startIndex-n}))),h}function Dl(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=`${ce.CUSTOM_RANGE_START.repeat(o)}${n}${ce.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 Di(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 yi(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=x.deepClone(i);r.push({...o,startIndex:Math.max(o.startIndex-n,0),endIndex:Math.min(o.endIndex,e)-n})}}),r}function ts(t,n,e=Pt.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=Li(o,r,e);l.length&&(s.textRuns=l);const h=[];let c=0,u=0;for(;c<i.length&&u<a.length;){const d=i[c],f=a[u],{startIndex:m}=d,{startIndex:E}=f;m===E?(h.push(x.deepMerge(d,f)),c++,u++):m<E?(h.push(x.deepClone(d)),c++):(h.push(x.deepClone(f)),u++)}return c<i.length&&h.push(...i.slice(c)),u<a.length&&h.push(...a.slice(u)),h.length&&(s.paragraphs=h),s}function yl(t){const{body:n}=t;if(n==null)return!0;const{textRuns:e=[],paragraphs:s=[]}=n;return e.length===0&&s.length===0}function xl(t=x.generateRandomId(6),n=Te.EN_US,e=""){return{id:t,locale:n,title:e,body:{dataStream:`\r
6
+ `,textRuns:[],paragraphs:[{startIndex:0,paragraphStyle:{spaceAbove:{v:5},lineSpacing:1,spaceBelow:{v: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 Wt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Pl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var $t={},xi={},ms={};Object.defineProperty(ms,"__esModule",{value:!0});function kl(t,n){if(Array.isArray(n))return!1;for(let e in t)if(!Es(t[e],n[e]))return!1;for(let e in n)if(t[e]===void 0)return!1;return!0}function Hl(t,n){if(!Array.isArray(n)||t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(!Es(t[e],n[e]))return!1;return!0}function Es(t,n){return t===n?!0:t===null||n===null||typeof t!="object"||typeof n!="object"?!1:Array.isArray(t)?Hl(t,n):kl(t,n)}ms.default=Es;var ps={};Object.defineProperty(ps,"__esModule",{value:!0});function es(t){if(t===null)return null;if(Array.isArray(t))return t.map(es);if(typeof t=="object"){const n={};for(let e in t)n[e]=es(t[e]);return n}else return t}ps.default=es;var Rs={};(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(c,u){if(!c)throw new Error(u)}const e=c=>c!=null&&typeof c=="object"&&!Array.isArray(c),s=(c,u)=>typeof c==typeof u?c>u:typeof c=="string"&&typeof u=="number";function r(c,u){for(let d in c){const f=d;u.write(f,c[f])}}t.isValidPathItem=c=>typeof c=="number"||typeof c=="string"&&c!=="__proto__";class i{constructor(u=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=u}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 u=[];let d=this.container,f=this.parents.length-1,m=this.idx;for(;m>=0;)u.unshift(d[m]),m===0?(m=this.indexes[f*2],d=this.parents[f--]):m-=e(d[m-1])?2:1;return u}}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 u;return this.container&&this.container.length>this.idx+1&&e(u=this.container[this.idx+1])?u:null}descendFirst(){let u=this.idx+1;if(!this.container||u>=this.container.length||e(this.container[u])&&u+1>=this.container.length)return!1;e(this.container[u])&&u++;const d=this.container[u];return Array.isArray(d)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(u),this.idx=0,this.container=d):this.idx=u,!0}nextSibling(){if(n(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;const u=this.indexes[this.indexes.length-1]+1,d=this.parents[this.parents.length-1];return u>=d.length?!1:(n(!isNaN(u)),this.indexes[this.indexes.length-1]=u,this.container=d[u],!0)}_init(u,d,f,m){this.container=u,this.idx=d,this.parents=f.slice(),this.indexes=m.slice()}clone(){const u=new o;return u._init(this.container,this.idx,this.parents,this.indexes),u}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(u,d){const f=this.getComponent();f&&d(f,u);for(const m of this)u&&u.descend(m),this.traverse(u,d),u&&u.ascend()}eachPick(u,d){this.traverse(u,(f,m)=>{f.p!=null&&d(f.p,m)})}eachDrop(u,d){this.traverse(u,(f,m)=>{f.d!=null&&d(f.d,m)})}}t.ReadCursor=o;class a extends i{constructor(u=null){super(u),this.pendingDescent=[],this._op=u}flushDescent(){n(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let u=0;u<this.pendingDescent.length;u++){const d=this.pendingDescent[u];let f=this.idx+1;if(f<this.container.length&&e(this.container[f])&&f++,n(f===this.container.length||!e(this.container[f])),f===this.container.length)this.container.push(d),this.idx=f;else if(this.container[f]===d)this.idx=f;else{if(!Array.isArray(this.container[f])){const m=this.container.splice(f,this.container.length-f);this.container.push(m),this.lcIdx>-1&&(this.lcIdx=f)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(n(s(d,this.container[this.lcIdx][0])),f=this.lcIdx+1,this.lcIdx=-1);f<this.container.length&&s(d,this.container[f][0]);)f++;if(this.indexes.push(f),this.idx=0,f<this.container.length&&this.container[f][0]===d)this.container=this.container[f];else{const m=[d];this.container.splice(f,0,m),this.container=m}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();const u=this.idx+1;if(u<this.container.length&&e(this.container[u]))return this.container[u];{const d={};return this.container.splice(u,0,d),d}}write(u,d){const f=this.getComponent();n(f[u]==null||f[u]===d,"Internal consistency error: Overwritten component. File a bug"),f[u]=d}get(){return this._op}descend(u){if(!t.isValidPathItem(u))throw Error("Invalid JSON key");this.pendingDescent.push(u)}descendPath(u){return this.pendingDescent.push(...u),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(u,d=r){if(u===null)return;if(n(Array.isArray(u)),u===this._op)throw Error("Cannot merge into my own tree");const f=this.lcIdx,m=this.parents.length;let E=0;for(let M=0;M<u.length;M++){const L=u[M];typeof L=="string"||typeof L=="number"?(E++,this.descend(L)):Array.isArray(L)?this.mergeTree(L,d):typeof L=="object"&&d(L,this)}for(;E--;)this.ascend();this.lcIdx=this.parents.length===m?f:-1}at(u,d){this.descendPath(u),d(this);for(let f=0;f<u.length;f++)this.ascend();return this}writeAtPath(u,d,f){return this.at(u,()=>this.write(d,f)),this.reset(),this}writeMove(u,d,f=0){return this.writeAtPath(u,"p",f).writeAtPath(d,"d",f)}getPath(){const u=super.getPath();return u.push(...this.pendingDescent),u}}t.WriteCursor=a,t.writeCursor=()=>new a,t.readCursor=c=>new o(c);function l(c,u,d){let f,m;m=f=c?c.descendFirst():!1;function E(M){let L;for(;m;){const tt=L=c.getKey();if(M!=null){let mt=!1;if(u&&typeof tt=="number"&&(L=u(tt,c.getComponent()),L<0&&(L=~L,mt=!0)),s(L,M))return null;if(L===M&&!mt)return c}d&&typeof L=="number"&&d(L,c.getComponent()),m=c.nextSibling()}return null}return E.end=()=>{f&&c.ascend()},E}t.advancer=l;function h(c,u,d){let f,m,E,M;for(f=m=c&&c.descendFirst(),E=M=u&&u.descendFirst();f||E;){let L=f?c.getKey():null,tt=E?u.getKey():null;L!==null&&tt!==null&&(s(tt,L)?tt=null:L!==tt&&(L=null)),d(L==null?tt:L,L!=null?c:null,tt!=null?u:null),L!=null&&f&&(f=c.nextSibling()),tt!=null&&E&&(E=u.nextSibling())}m&&c.ascend(),M&&u.ascend()}t.eachChildOf=h})(Rs);var Cs={};(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={}))})(Cs);var Bn={},Oe={},Hs;function Is(){return Hs||(Hs=1,Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.uniToStrPos=Oe.strPosToUni=void 0,Oe.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},Oe.uniToStrPos=(t,n)=>{let e=0;for(;n>0;n--){const s=t.charCodeAt(e);e+=s>=55296&&s<=57343?2:1}return e}),Oe}var Gn={},Fs;function ns(){return Fs||(Fs=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.uniSlice=t.dlen=t.eachOp=void 0;const n=Is(),e=p=>{if(!Array.isArray(p))throw Error("Op must be an array of components");let S=null;for(let v=0;v<p.length;v++){const z=p[v];switch(typeof z){case"object":if(typeof z.d!="number"&&typeof z.d!="string")throw Error("Delete must be number or string");if(t.dlen(z.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(z.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(z>0))throw Error("Skip components must be >0");if(typeof S=="number")throw Error("Adjacent skip components should be combined");break}S=z}if(typeof S=="number")throw Error("Op has a trailing skip")};function s(p,S){let v=0,z=0;for(let nt=0;nt<p.length;nt++){const X=p[nt];switch(S(X,v,z),typeof X){case"object":v+=t.dlen(X.d);break;case"string":z+=n.strPosToUni(X);break;case"number":v+=X,z+=X;break}}}t.eachOp=s;function r(p,S){const v=[],z=a(v);return s(p,(nt,X,Gt)=>{z(S(nt,X,Gt))}),u(v)}const i=p=>p,o=p=>r(p,i);t.dlen=p=>typeof p=="number"?p:n.strPosToUni(p);const a=p=>S=>{if(!(!S||S.d===0||S.d===""))if(p.length===0)p.push(S);else if(typeof S==typeof p[p.length-1])if(typeof S=="object"){const v=p[p.length-1];v.d=typeof v.d=="string"&&typeof S.d=="string"?v.d+S.d:t.dlen(v.d)+t.dlen(S.d)}else p[p.length-1]+=S;else p.push(S)},l=p=>typeof p=="number"?p:typeof p=="string"?n.strPosToUni(p):typeof p.d=="number"?p.d:n.strPosToUni(p.d);t.uniSlice=(p,S,v)=>{const z=n.uniToStrPos(p,S),nt=v==null?1/0:n.uniToStrPos(p,v);return p.slice(z,nt)};const h=(p,S,v)=>typeof p=="number"?v==null?p-S:Math.min(p,v)-S:t.uniSlice(p,S,v),c=p=>{let S=0,v=0;return{take:(X,Gt)=>{if(S===p.length)return X===-1?null:X;const Ot=p[S];let _t;if(typeof Ot=="number")return X===-1||Ot-v<=X?(_t=Ot-v,++S,v=0,_t):(v+=X,X);if(typeof Ot=="string"){if(X===-1||Gt==="i"||n.strPosToUni(Ot.slice(v))<=X)return _t=Ot.slice(v),++S,v=0,_t;{const It=v+n.uniToStrPos(Ot.slice(v),X);return _t=Ot.slice(v,It),v=It,_t}}else{if(X===-1||Gt==="d"||t.dlen(Ot.d)-v<=X)return _t={d:h(Ot.d,v)},++S,v=0,_t;{let It=h(Ot.d,v,v+X);return v+=X,{d:It}}}},peek:()=>p[S]}},u=p=>(p.length>0&&typeof p[p.length-1]=="number"&&p.pop(),p);function d(p,S,v){if(v!=="left"&&v!=="right")throw Error("side ("+v+") must be 'left' or 'right'");e(p),e(S);const z=[],nt=a(z),{take:X,peek:Gt}=c(p);for(let _t=0;_t<S.length;_t++){const It=S[_t];let Mt,jt;switch(typeof It){case"number":for(Mt=It;Mt>0;)jt=X(Mt,"i"),nt(jt),typeof jt!="string"&&(Mt-=l(jt));break;case"string":v==="left"&&typeof Gt()=="string"&&nt(X(-1)),nt(n.strPosToUni(It));break;case"object":for(Mt=t.dlen(It.d);Mt>0;)switch(jt=X(Mt,"i"),typeof jt){case"number":Mt-=jt;break;case"string":nt(jt);break;case"object":Mt-=t.dlen(jt.d)}break}}let Ot;for(;Ot=X(-1);)nt(Ot);return u(z)}function f(p,S){e(p),e(S);const v=[],z=a(v),{take:nt}=c(p);for(let Gt=0;Gt<S.length;Gt++){const Ot=S[Gt];let _t,It;switch(typeof Ot){case"number":for(_t=Ot;_t>0;)It=nt(_t,"d"),z(It),typeof It!="object"&&(_t-=l(It));break;case"string":z(Ot);break;case"object":_t=t.dlen(Ot.d);let Mt=0;for(;Mt<_t;)switch(It=nt(_t-Mt,"d"),typeof It){case"number":z({d:h(Ot.d,Mt,Mt+It)}),Mt+=It;break;case"string":Mt+=n.strPosToUni(It);break;case"object":z(It)}break}}let X;for(;X=nt(-1);)z(X);return u(v)}const m=(p,S)=>{let v=0;for(let z=0;z<S.length&&p>v;z++){const nt=S[z];switch(typeof nt){case"number":{v+=nt;break}case"string":const X=n.strPosToUni(nt);v+=X,p+=X;break;case"object":p-=Math.min(t.dlen(nt.d),p-v);break}}return p},E=(p,S)=>typeof p=="number"?m(p,S):p.map(v=>m(v,S));function M(p,S,v){return r(p,(z,nt)=>typeof z=="object"&&typeof z.d=="number"?{d:v.slice(S,nt,nt+z.d)}:z)}function L(p){return r(p,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 tt(p){return r(p,S=>typeof S=="object"&&typeof S.d=="string"?{d:n.strPosToUni(S.d)}:S)}function mt(p){let S=!0;return s(p,v=>{typeof v=="object"&&typeof v.d=="number"&&(S=!1)}),S}function ht(p){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:u,normalize:o,checkOp:e,create(S=""){if(typeof S!="string")throw Error("Initial data must be a string");return p.create(S)},apply(S,v){e(v);const z=p.builder(S);for(let nt=0;nt<v.length;nt++){const X=v[nt];switch(typeof X){case"number":z.skip(X);break;case"string":z.append(X);break;case"object":z.del(t.dlen(X.d));break}}return z.build()},transform:d,compose:f,transformPosition:m,transformSelection:E,isInvertible:mt,makeInvertible(S,v){return M(S,v,p)},stripInvertible:tt,invert:L,invertWithDoc(S,v){return L(M(S,v,p))},isNoop:S=>S.length===0}}t.default=ht}(Gn)),Gn}var un={},$s;function Fl(){if($s)return un;$s=1,Object.defineProperty(un,"__esModule",{value:!0});const t=ns(),n=Is();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 un.default=e,e.provides={text:!0},un}var Ws;function $l(){return Ws||(Ws=1,function(t){var n=Wt&&Wt.__createBinding||(Object.create?function(d,f,m,E){E===void 0&&(E=m),Object.defineProperty(d,E,{enumerable:!0,get:function(){return f[m]}})}:function(d,f,m,E){E===void 0&&(E=m),d[E]=f[m]}),e=Wt&&Wt.__setModuleDefault||(Object.create?function(d,f){Object.defineProperty(d,"default",{enumerable:!0,value:f})}:function(d,f){d.default=f}),s=Wt&&Wt.__importStar||function(d){if(d&&d.__esModule)return d;var f={};if(d!=null)for(var m in d)Object.hasOwnProperty.call(d,m)&&n(f,d,m);return e(f,d),f},r=Wt&&Wt.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(t,"__esModule",{value:!0}),t.type=t.remove=t.insert=void 0;const i=Is(),o=s(ns()),a=r(Fl()),l={create(d){return d},toString(d){return d},builder(d){if(typeof d!="string")throw Error("Invalid document snapshot: "+d);const f=[];return{skip(m){let E=i.uniToStrPos(d,m);if(E>d.length)throw Error("The op is too long for this document");f.push(d.slice(0,E)),d=d.slice(E)},append(m){f.push(m)},del(m){d=d.slice(i.uniToStrPos(d,m))},build(){return f.join("")+d}}},slice:o.uniSlice},h=o.default(l),c=Object.assign(Object.assign({},h),{api:a.default});t.type=c,t.insert=(d,f)=>f.length===0?[]:d===0?[f]:[d,f],t.remove=(d,f)=>o.dlen(f)===0?[]:d===0?[{d:f}]:[d,{d:f}];var u=ns();Object.defineProperty(t,"makeType",{enumerable:!0,get:function(){return u.default}})}(Bn)),Bn}(function(t){var n=Wt&&Wt.__importDefault||function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(t,"__esModule",{value:!0}),t.editOp=t.replaceOp=t.insertOp=t.moveOp=t.removeOp=t.type=void 0;const e=n(ms),s=n(ps),r=Rs,i=Cs;function o(g,R){if(!g)throw new Error(R)}t.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:r.readCursor,writeCursor:r.writeCursor,create:g=>g,isNoop:g=>g==null,setDebug(g){},registerSubtype:L,checkValidOp:nt,normalize:X,apply:Gt,transformPosition:Ot,compose:_t,tryTransform:kn,transform:Mo,makeInvertible:jt,invert:It,invertWithDoc:To,RM_UNEXPECTED_CONTENT:i.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:i.ConflictType.DROP_COLLISION,BLACKHOLE:i.ConflictType.BLACKHOLE,transformNoConflict:(g,R,N)=>Ms(()=>!0,g,R,N),typeAllowingConflictsPred:g=>Object.assign(Object.assign({},t.type),{transform:(R,N,U)=>Ms(g,R,N,U)})};const a=g=>g?g.getComponent():null;function l(g){return g&&typeof g=="object"&&!Array.isArray(g)}const h=g=>Array.isArray(g)?g.slice():g!==null&&typeof g=="object"?Object.assign({},g):g,c=g=>g&&(g.p!=null||g.r!==void 0),u=g=>g&&(g.d!=null||g.i!==void 0);function d(g,R){return o(g!=null),typeof R=="number"?(o(Array.isArray(g),"Invalid key - child is not an array"),(g=g.slice()).splice(R,1)):(o(l(g),"Invalid key - child is not an object"),delete(g=Object.assign({},g))[R]),g}function f(g,R,N){return typeof R=="number"?(o(g!=null,"Container is missing for key"),o(Array.isArray(g),"Cannot use numerical key for object container"),o(g.length>=R,"Cannot insert into out of bounds index"),g.splice(R,0,N)):(o(l(g),"Cannot insert into missing item"),o(g[R]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),g[R]=N),N}t.removeOp=(g,R=!0)=>r.writeCursor().writeAtPath(g,"r",R).get(),t.moveOp=(g,R)=>r.writeCursor().writeMove(g,R).get(),t.insertOp=(g,R)=>r.writeCursor().writeAtPath(g,"i",R).get(),t.replaceOp=(g,R,N)=>r.writeCursor().at(g,U=>{U.write("r",R),U.write("i",N)}).get(),t.editOp=(g,R,N,U=!1)=>r.writeCursor().at(g,A=>S(A,R,N,U)).get();const m=(g,R)=>g!=null&&(typeof R=="number"?Array.isArray(g):typeof g=="object"),E=(g,R)=>m(g,R)?g[R]:void 0,M={};function L(g){let R=g.type?g.type:g;R.name&&(M[R.name]=R),R.uri&&(M[R.uri]=R)}const tt=g=>{const R=M[g];if(R)return R;throw Error("Missing type: "+g)};L($l());const mt=(g,R)=>g+R;L({name:"number",apply:mt,compose:mt,invert:g=>-g,transform:g=>g});const ht=g=>g==null?null:g.et?tt(g.et):g.es?M["text-unicode"]:g.ena!=null?M.number:null,p=g=>g.es?g.es:g.ena!=null?g.ena:g.e,S=(g,R,N,U=!1)=>{const[A,T]=typeof R=="string"?[tt(R),R]:[R,R.name];!U&&A.isNoop&&A.isNoop(N)||(T==="number"?g.write("ena",N):T==="text-unicode"?g.write("es",N):(g.write("et",T),g.write("e",N)))};function v(g){o(typeof g=="number"),o(g>=0),o(g===(0|g))}function z(g){typeof g=="number"?v(g):o(typeof g=="string")}function nt(g){if(g===null)return;const R=new Set,N=new Set,U=T=>{let G=!0,W=!1;for(let C in T){const O=T[C];if(G=!1,o(C==="p"||C==="r"||C==="d"||C==="i"||C==="e"||C==="es"||C==="ena"||C==="et","Invalid component item '"+C+"'"),C==="p")v(O),o(!R.has(O)),R.add(O),o(T.r===void 0);else if(C==="d")v(O),o(!N.has(O)),N.add(O),o(T.i===void 0);else if(C==="e"||C==="es"||C==="ena"){o(!W),W=!0;const b=ht(T);o(b,"Missing type in edit"),b.checkValidOp&&b.checkValidOp(p(T))}}o(!G)},A=(T,G,W)=>{if(!Array.isArray(T))throw Error("Op must be null or a list");if(T.length===0)throw Error("Empty descent");G||z(T[0]);let C=1,O=0,b=0;for(let w=0;w<T.length;w++){const B=T[w];if(o(B!=null),Array.isArray(B)){const j=A(B,!1);if(O){const I=typeof b,H=typeof j;I===H?o(b<j,"descent keys are not in order"):o(I==="number"&&H==="string")}b=j,O++,C=3}else typeof B=="object"?(o(C===1,`Prev not scalar - instead ${C}`),U(B),C=2):(o(C!==3),z(B),o(r.isValidPathItem(B),"Invalid path key"),C=1)}return o(O!==1,"Operation makes multiple descents. Remove some []"),o(C===2||C===3),T[0]};A(g,!0),o(R.size===N.size,"Mismatched picks and drops in op");for(let T=0;T<R.size;T++)o(R.has(T)),o(N.has(T))}function X(g){let R=0,N=[];const U=r.writeCursor();return U.mergeTree(g,(A,T)=>{const G=ht(A);if(G){const C=p(A);S(T,G,G.normalize?G.normalize(C):C)}for(const C of["r","p","i","d"])if(A[C]!==void 0){const O=C==="p"||C==="d"?(W=A[C],N[W]==null&&(N[W]=R++),N[W]):A[C];T.write(C,O)}var W}),U.get()}function Gt(g,R){if(nt(R),R===null)return g;const N=[];return function U(A,T){let G=A,W=0,C={root:A},O=0,b=C,w="root";function B(){for(;O<W;O++){let j=T[O];typeof j!="object"&&(o(m(b,w)),b=b[w]=h(b[w]),w=j)}}for(;W<T.length;W++){const j=T[W];if(Array.isArray(j)){const I=U(G,j);I!==G&&I!==void 0&&(B(),G=b[w]=I)}else if(typeof j=="object"){j.d!=null?(B(),G=f(b,w,N[j.d])):j.i!==void 0&&(B(),G=f(b,w,j.i));const I=ht(j);if(I)B(),G=b[w]=I.apply(G,p(j));else if(j.e!==void 0)throw Error("Subtype "+j.et+" undefined")}else G=E(G,j)}return C.root}(g=function U(A,T){const G=[];let W=0;for(;W<T.length;W++){const w=T[W];if(Array.isArray(w))break;typeof w!="object"&&(G.push(A),A=E(A,w))}for(let w=T.length-1;w>=W;w--)A=U(A,T[w]);for(--W;W>=0;W--){const w=T[W];if(typeof w!="object"){const B=G.pop();A=A===E(B,w)?B:A===void 0?d(B,w):(O=w,b=A,(C=h(C=B))[O]=b,C)}else c(w)&&(o(A!==void 0,"Cannot pick up or remove undefined"),w.p!=null&&(N[w.p]=A),A=void 0)}var C,O,b;return A}(g,R),R)}function Ot(g,R){g=g.slice(),nt(R);const N=r.readCursor(R);let U,A,T=!1;const G=[];for(let C=0;;C++){const O=g[C],b=N.getComponent();if(b&&(b.r!==void 0?T=!0:b.p!=null&&(T=!1,U=b.p,A=C)),C>=g.length)break;let w=0;const B=r.advancer(N,void 0,(I,H)=>{c(H)&&w++});G.unshift(B);const j=B(O);if(typeof O=="number"&&(g[C]-=w),!j)break}if(G.forEach(C=>C.end()),T)return null;const W=()=>{let C=0;if(U!=null){const O=N.getPath();C=O.length,g=O.concat(g.slice(A))}for(;C<g.length;C++){const O=g[C],b=a(N),w=ht(b);if(w){const I=p(b);w.transformPosition&&(g[C]=w.transformPosition(g[C],I));break}let B=0;const j=r.advancer(N,(I,H)=>u(H)?~(I-B):I-B,(I,H)=>{u(H)&&B++})(O);if(typeof O=="number"&&(g[C]+=B),!j)break}};return U!=null?N.eachDrop(null,C=>{C===U&&W()}):W(),g}function _t(g,R){if(nt(g),nt(R),g==null)return R;if(R==null)return g;let N=0;const U=r.readCursor(g),A=r.readCursor(R),T=r.writeCursor(),G=[],W=[],C=[],O=[],b=[],w=[],B=new Set;U.traverse(null,I=>{I.p!=null&&(C[I.p]=U.clone())}),A.traverse(null,I=>{I.d!=null&&(O[I.d]=A.clone())});const j=r.writeCursor();return function I(H,gt,lt,q,pt,ie,xt,Ut){o(gt||lt);const Rt=a(gt),Vt=a(lt),qt=!!Vt&&Vt.r!==void 0,Re=!!Rt&&Rt.i!==void 0,Kt=Rt?Rt.d:null,Bt=Vt?Vt.p:null,oe=(ie||qt)&&Bt==null;if(Bt!=null)q=O[Bt],xt=W[Bt]=new r.WriteCursor;else if(Vt&&Vt.r!==void 0)q=null;else{const y=a(q);y&&y.d!=null&&(q=null)}const ot=a(q);if(Kt!=null)if(H=C[Kt],Ut=G[Kt]=new r.WriteCursor,oe)ie&&!qt&&Ut.write("r",!0);else{const y=b[Kt]=N++;xt.write("d",y)}else if(Rt&&Rt.i!==void 0)H=null;else{const y=a(H);y&&y.p!=null&&(H=null)}let P;Re?(o(pt===void 0),P=Rt.i):P=pt;const V=(Bt==null?!Re||ie||qt:P===void 0)?null:xt.getComponent();if(Bt!=null){if(!(pt!==void 0||Re)){const y=Kt!=null?b[Kt]:N++;w[Bt]=y,Ut.write("p",y)}}else qt&&(Re||pt!==void 0||(Vt.r,Ut.write("r",Vt.r)));const k=oe?null:ht(Rt),D=ht(ot);if((k||D)&&(k&&k.name,D&&D.name),k&&D){o(k===D);const y=p(Rt),Y=p(ot),wt=k.compose(y,Y);S(xt,k,wt),B.add(ot)}else k?S(xt,k,p(Rt)):D&&(S(xt,D,p(ot)),B.add(ot));const F=typeof P=="object"&&P!=null;let st=!1,rt=0,at=0,vt=0,Nt=0,Ct=0;const yt=r.advancer(q,(y,Y)=>u(Y)?Nt-y-1:y-Nt,(y,Y)=>{u(Y)&&Nt++}),et=r.advancer(H,(y,Y)=>c(Y)?rt-y-1:y-rt,(y,Y)=>{c(Y)&&rt++});if(r.eachChildOf(gt,lt,(y,Y,wt)=>{let kt,ae,Ce=y,Zt=y,$e=y;if(typeof y=="number"){let Lt=y+vt;ae=yt(Lt),Zt=Lt+Nt;let St=y+at;kt=et(St),u(a(ae))&&(kt=null),Ce=St+rt,$e=y+Ct,o(Ce>=0,"p1PickKey is negative"),o(Zt>=0,"p2DropKey is negative");const Jt=u(a(Y)),le=c(a(wt));(Jt||le&&!oe)&&Ct--,Jt&&at--,le&&vt--}else kt=et(y),ae=yt(y);Ut.descend(Ce),xt.descend(Zt);const Le=F&&!u(a(Y))?P[$e]:void 0,ne=I(kt,Y,wt,ae,Le,oe,xt,Ut);var se,$,Et;F&&!oe?Le!==ne&&(st||(P=Array.isArray(P)?P.slice():Object.assign({},P),st=!0),se=P,Et=ne,typeof($=$e)=="number"?(o(Array.isArray(se)),o($<se.length)):(o(!Array.isArray(se)),o(se[$]!==void 0)),Et===void 0?typeof $=="number"?se.splice($,1):delete se[$]:se[$]=Et):o(ne===void 0),xt.ascend(),Ut.ascend()}),et.end(),yt.end(),V!=null)V.i=P;else if(!ie&&!qt&&Bt==null)return P}(U,U.clone(),A,A.clone(),void 0,!1,T,j),T.reset(),T.mergeTree(j.get()),T.reset(),T.get(),G.map(I=>I.get()),W.map(I=>I.get()),U.traverse(T,(I,H)=>{const gt=I.p;if(gt!=null){const lt=b[gt];lt!=null&&H.write("p",lt);const q=G[gt];q&&q.get(),q&&H.mergeTree(q.get())}else I.r!==void 0&&H.write("r",I.r)}),T.reset(),T.get(),A.traverse(T,(I,H)=>{const gt=I.d;if(gt!=null){const q=w[gt];q!=null&&H.write("d",q);const pt=W[gt];pt&&H.mergeTree(pt.get())}else I.i!==void 0&&H.write("i",I.i);const lt=ht(I);lt&&!B.has(I)&&S(H,lt,p(I))}),T.get()}function It(g){if(g==null)return null;const R=new r.ReadCursor(g),N=new r.WriteCursor;let U;const A=[],T=[];return function G(W,C,O){const b=W.getComponent();let w,B=!1;if(b){b.p!=null&&(C.write("d",b.p),A[b.p]=W.clone()),b.r!==void 0&&C.write("i",b.r),b.d!=null&&(C.write("p",b.d),O=void 0),b.i!==void 0&&(O=w=b.i);const I=ht(b);I&&(O===void 0?(U||(U=new Set),U.add(b)):(p(b),O=I.apply(O,p(b)),B=!0))}let j=0;for(const I of W){C.descend(I);const H=typeof I=="number"?I-j:I,gt=E(O,H);u(W.getComponent())&&j++;const lt=G(W,C,gt);if(O!==void 0&&lt!==void 0){if(B||(B=!0,O=h(O)),!m(O,H))throw Error("Cannot modify child - invalid operation");O[H]=lt}C.ascend()}if(w===void 0)return B?O:void 0;C.write("r",O)}(R,N,void 0),U&&(N.reset(),function G(W,C,O){const b=C.getComponent();if(b){const I=b.d;if(I!=null&&(W=A[I],O=T[I]=r.writeCursor()),U.has(b)){const H=ht(b);if(!H.invert)throw Error(`Cannot invert subtype ${H.name}`);S(O,H,H.invert(p(b)))}}let w=0,B=0;const j=r.advancer(W,(I,H)=>c(H)?w-I-1:I-w,(I,H)=>{c(H)&&w++});for(const I of C)if(typeof I=="number"){const H=I-B,gt=j(H),lt=H+w;O.descend(lt),G(gt,C,O),u(C.getComponent())&&B++,O.ascend()}else O.descend(I),G(j(I),C,O),O.ascend();j.end()}(R.clone(),R,N),T.length&&(N.reset(),R.traverse(N,(G,W)=>{const C=G.p;if(C!=null){const O=T[C];O&&O.get(),O&&W.mergeTree(O.get())}}))),N.get()}const Mt=(g,R)=>g.some(N=>typeof N=="object"&&(Array.isArray(N)?Mt(N,R):R(N)));function jt(g,R){if(g==null||!Mt(g,C=>{var O;return C.r!==void 0||((O=ht(C))===null||O===void 0?void 0:O.makeInvertible)!=null}))return g;const N=new r.ReadCursor(g),U=new r.WriteCursor;let A=!1;const T=[],G=[],W=(C,O,b)=>{const w=C.getComponent();let B=!1;if(w){w.d!=null&&O.write("d",w.d),w.i!==void 0&&O.write("i",w.i);const I=w.p;if(I!=null&&(T[I]=C.clone(),o(b!==void 0,"Operation picks up at an invalid key"),G[I]=b,O.write("p",w.p)),w.r!==void 0&&b===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const H=ht(w);H&&(H.makeInvertible?A=!0:S(O,H,p(w),!0))}let j=0;for(const I of C){O.descend(I);const H=typeof I=="number"?I-j:I,gt=E(b,H),lt=W(C,O,gt);gt!==lt&&(B||(B=!0,b=h(b)),lt===void 0?(b=d(b,H),typeof I=="number"&&j++):b[H]=lt),O.ascend()}return w&&(w.r!==void 0?(O.write("r",s.default(b)),b=void 0):w.p!=null&&(b=void 0)),b};return W(N,U,R),U.get(),A&&(U.reset(),function C(O,b,w,B,j){const I=b.getComponent();if(I){I.i!==void 0?(B=I.i,j=!0):I.d!=null&&(B=G[I.d],O=T[I.d],j=!1,I.d);let q=ht(I);if(q&&q.makeInvertible){const pt=p(I);S(w,q,q.makeInvertible(pt,B),!0)}}let H=0,gt=0;const lt=r.advancer(O,(q,pt)=>c(pt)?H-q-1:q-H,(q,pt)=>{c(pt)&&H++});for(const q of b)if(typeof q=="number"){const pt=q-gt,ie=lt(pt),xt=pt+H,Ut=E(B,j?pt:xt);w.descend(q),C(ie,b,w,Ut,j),u(b.getComponent())&&gt++,w.ascend()}else{const pt=E(B,q);w.descend(q),C(lt(q),b,w,pt,j),w.ascend()}lt.end()}(N.clone(),N,U,R,!1)),U.get()}function To(g,R){return It(jt(g,R))}const Pn=g=>{if(g==null)return null;const R=g.slice();for(let N=0;N<g.length;N++){const U=R[N];Array.isArray(U)&&(R[N]=Pn(U))}return R};function kn(g,R,N){o(N==="left"||N==="right","Direction must be left or right");const U=N==="left"?0:1;if(R==null)return{ok:!0,result:g};nt(g),nt(R);let A=null;const T=[],G=[],W=[],C=[],O=[],b=[],w=[],B=[],j=[],I=[],H=[],gt=[],lt=[],q=[],pt=[];let ie=0;const xt=r.readCursor(g),Ut=r.readCursor(R),Rt=r.writeCursor();if(function ot(P,V=null,k){const D=a(V);D&&(D.r!==void 0?k=V.clone():D.p!=null&&(k=null,b[D.p]=P.clone()));const F=P.getComponent();let st;F&&(st=F.p)!=null&&(O[st]=V?V.clone():null,W[st]=P.clone(),k&&(I[st]=!0,j[st]=k),D&&D.p!=null&&(q[st]=D.p));const rt=r.advancer(V);for(const at of P)ot(P,rt(at),k);rt.end()}(Ut,xt,null),function ot(P,V,k,D,F){const st=k.getComponent();let rt,at=!1;st&&((rt=st.d)!=null?(C[rt]=k.clone(),D!=null&&(pt[D]==null&&(pt[D]=[]),pt[D].push(rt)),P=O[rt]||null,V=W[rt]||null,I[rt]?(F&&(H[rt]=!0),F=j[rt]||null):!F||U!==1&&q[rt]!=null||A==null&&(A={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.removeOp(F.getPath()),op2:t.moveOp(V.getPath(),k.getPath())}),at=!0):st.i!==void 0&&(P=V=null,at=!0,F&&A==null&&(A={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.removeOp(F.getPath()),op2:t.insertOp(k.getPath(),st.i)})));const vt=a(P);vt&&(vt.r!==void 0?F=P.clone():vt.p!=null&&(vt.p,D=vt.p,F=null));const Nt=ht(st);Nt&&F&&A==null&&(A={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.removeOp(F.getPath()),op2:t.editOp(k.getPath(),Nt,p(st),!0)});let Ct=0,yt=0;const et=r.advancer(V,(Y,wt)=>c(wt)?Ct-Y-1:Y-Ct,(Y,wt)=>{c(wt)&&Ct++}),y=r.advancer(P);for(const Y of k)if(typeof Y=="number"){const wt=Y-yt,kt=et(wt);yt+=+ot(y(wt+Ct),kt,k,D,F)}else{const wt=et(Y);ot(y(Y),wt,k,D,F)}return et.end(),y.end(),at}(xt,Ut,Ut.clone(),null,null),C.map(ot=>ot&&ot.get()),A)return{ok:!1,conflict:A};H.map(ot=>!!ot);const Vt=[];let qt=null;(function ot(P,V,k,D,F){let st=!1;const rt=a(V);if(c(rt)){const et=rt.p;et!=null?(k=C[et],D=gt[et]=r.writeCursor(),st=!0,F=null):(k=null,F=V.clone())}else u(a(k))&&(k=null);const at=P.getComponent();if(at){const et=at.p;et!=null?(F&&(B[et]=F),Vt[et]=F||U===1&&st?null:D.getComponent(),T[et]=P.clone(),k&&(w[et]=k.clone())):at.r!==void 0&&(F||D.write("r",!0),(F||st)&&(qt==null&&(qt=new Set),qt.add(at)))}let vt=0,Nt=0;const Ct=r.advancer(V,void 0,(et,y)=>{c(y)&&vt++}),yt=r.advancer(k,(et,y)=>u(y)?~(et-Nt):et-Nt,(et,y)=>{u(y)&&Nt++});if(P)for(const et of P)if(typeof et=="string"){const y=Ct(et),Y=yt(et);D.descend(et),ot(P,y,Y,D,F),D.ascend()}else{const y=Ct(et),Y=et-vt,wt=c(a(y))?null:yt(Y),kt=Y+Nt;o(kt>=0),D.descend(kt),ot(P,y,wt,D,F),D.ascend()}Ct.end(),yt.end()})(xt,Ut,Ut.clone(),Rt,null),Rt.reset();let Re=[];if(function ot(P,V,k,D,F,st){o(V);const rt=V.getComponent();let at=a(D),vt=!1;const Nt=($,Et,Lt)=>$?t.moveOp($.getPath(),Et.getPath()):t.insertOp(Et.getPath(),Lt.i);if(u(rt)){const $=rt.d;$!=null&&(G[$]=V.clone());const Et=$!=null?Vt[$]:null;let Lt=!1;if(rt.i!==void 0||$!=null&&Et){let St;at&&(at.i!==void 0||(St=at.d)!=null&&!I[St])&&(Lt=St!=null?$!=null&&$===q[St]:e.default(at.i,rt.i),Lt||St!=null&&U!==1&&q[St]!=null||A==null&&(A={type:i.ConflictType.DROP_COLLISION,op1:Nt($!=null?T[$]:null,V,rt),op2:Nt(St!=null?W[St]:null,D,at)})),Lt||(st?A==null&&(A={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:Nt($!=null?T[$]:null,V,rt),op2:t.removeOp(st.getPath())}):($!=null?(Re[ie]=$,F.write("d",Et.p=ie++)):F.write("i",s.default(rt.i)),vt=!0))}else if($!=null&&!Et){const St=B[$];St&&(st=St.clone())}$!=null?(P=T[$],k=b[$],D=w[$]):rt.i!==void 0&&(P=k=null,Lt||(D=null))}else c(a(P))&&(P=k=D=null);const Ct=a(P),yt=a(k);if(c(yt)){const $=yt.p;yt.r!==void 0&&(!Ct||Ct.r===void 0)||I[$]?(D=null,st=k.clone()):$!=null&&(D=C[$],U!==1&&q[$]!=null||((F=lt[$])||(F=lt[$]=r.writeCursor()),F.reset(),st=null))}else!u(rt)&&u(at)&&(D=null);at=D!=null?D.getComponent():null;const et=ht(rt);if(et){const $=p(rt);if(st)A==null&&(A={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.editOp(V.getPath(),et,$,!0),op2:t.removeOp(st.getPath())});else{const Et=ht(at);let Lt;if(Et){if(et!==Et)throw Error("Transforming incompatible types");const St=p(at);Lt=et.transform($,St,N)}else Lt=s.default($);S(F,et,Lt)}}let y=0,Y=0,wt=0,kt=0,ae=0,Ce=0,Zt=P!=null&&P.descendFirst(),$e=Zt;const Le=r.advancer(k,void 0,($,Et)=>{c(Et)&&wt++});let ne=D!=null&&D.descendFirst(),se=ne;for(const $ of V)if(typeof $=="number"){let Et;const Lt=u(V.getComponent()),St=$-Y;{let he;for(;Zt&&typeof(he=P.getKey())=="number";){he+=y;const Qt=P.getComponent(),De=c(Qt);if(he>St||he===St&&(!De||U===0&&Lt))break;if(De){y--;const Ie=Qt.p;q.includes(Ie),Qt.d,a(lt[Qt.d]),c(a(lt[Qt.d])),(Qt.r===void 0||qt&&qt.has(Qt))&&(Ie==null||!Vt[Ie]||U!==1&&q.includes(Ie))||ae--}Zt=P.nextSibling()}Et=Zt&&he===St?P:null}const Jt=St-y;let le=Le(Jt);const Hn=Jt-wt;let sn=null;{let he,Qt;for(;ne&&typeof(he=D.getKey())=="number";){Qt=he-kt;const De=D.getComponent(),Ie=u(De);if(Qt>Hn)break;if(Qt===Hn){if(!Ie){sn=D;break}{if(U===0&&Lt){sn=D;break}const Se=le&&c(le.getComponent());if(U===0&&Se)break}}if(Ie){const Se=De.d;q[Se],De.i===void 0&&(I[Se]||q[Se]!=null&&U!==1)?(I[Se]||q[Se]!=null&&U===0)&&(kt++,Ce--):kt++}ne=D.nextSibling()}}const Us=Hn+kt+ae+Ce;o(Us>=0,"trying to descend to a negative index"),F.descend(Us),Lt&&(Et=le=sn=null,Y++),ot(Et,V,le,sn,F,st)&&Ce++,F.ascend()}else{let Et;for(;Zt&&(Et=P.getKey(),typeof Et!="string"||!(Et>$||Et===$));)Zt=P.nextSibling();const Lt=Zt&&Et===$?P:null,St=Le($);let Jt;for(;ne&&(Jt=D.getKey(),typeof Jt!="string"||!(Jt>$||Jt===$));)ne=D.nextSibling();const le=ne&&Jt===$?D:null;F.descend($),ot(Lt,V,St,le,F,st),F.ascend()}return Le.end(),$e&&P.ascend(),se&&D.ascend(),vt}(xt,xt.clone(),Ut,Ut.clone(),Rt,null),A)return{ok:!1,conflict:A};Rt.reset();const Kt=(ot,P,V)=>ot.traverse(P,(k,D)=>{k.d!=null&&V(k.d,ot,D)});(I.length||gt.length)&&(Kt(Ut,Rt,(ot,P,V)=>{I[ot]&&!H[ot]&&V.write("r",!0),gt[ot]&&V.mergeTree(gt[ot].get())}),Rt.reset());const Bt=[],oe=[];if((lt.length||I.length)&&!A){const ot=r.readCursor(Pn(Rt.get()));if(Kt(ot,null,(P,V)=>{Bt[P]=V.clone()}),lt.forEach(P=>{P&&Kt(r.readCursor(P.get()),null,(V,k)=>{Bt[V]=k.clone()})}),function P(V,k,D,F,st,rt){const at=a(k);if(at&&c(at))if(at.p!=null){const y=at.p;Bt[y].getPath(),D=Bt[y],F=oe[y]=r.writeCursor()}else at.r!==void 0&&(D=null);else u(a(D))&&(D=null);const vt=V.getComponent();if(vt){let y;if((y=vt.d)!=null){const Y=lt[y];Y&&(Y.get(),F.mergeTree(Y.get()),D=r.readCursor(Y.get()))}}let Nt=0,Ct=0;const yt=r.advancer(k,void 0,(y,Y)=>{c(Y)&&Nt--}),et=r.advancer(D,(y,Y)=>u(Y)?-(y-Ct)-1:y-Ct,(y,Y)=>{u(Y)&&Ct++});for(const y of V)if(typeof y=="number"){const Y=yt(y),wt=y+Nt,kt=et(wt),ae=wt+Ct;F.descend(ae),P(V,Y,kt,F),F.ascend()}else F.descend(y),P(V,yt(y),et(y),F),F.ascend();yt.end(),et.end()}(Ut,ot,ot.clone(),Rt),Rt.reset(),A)return{ok:!1,conflict:A};if(Rt.get(),oe.length){const P=oe.map(k=>k?k.get():null),V=r.readCursor(Pn(Rt.get()));if(Kt(V,Rt,(k,D,F)=>{const st=P[k];st&&(F.mergeTree(st),P[k]=null)}),P.find(k=>k)){const k=r.writeCursor(),D=r.writeCursor();let F=0,st=0;P.forEach(rt=>{rt!=null&&Kt(r.readCursor(rt),null,at=>{const vt=Re[at];k.writeMove(T[vt].getPath(),G[vt].getPath(),F++);const Nt=pt[vt];Nt&&Nt.forEach(Ct=>{I[Ct]||U!==1&&q[Ct]!=null||D.writeMove(W[Ct].getPath(),C[Ct].getPath(),st++)})})}),A={type:i.ConflictType.BLACKHOLE,op1:k.get(),op2:D.get()}}}}return A?{ok:!1,conflict:A}:{ok:!0,result:Rt.get()}}const Ts=g=>{const R=new Error("Transform detected write conflict");throw R.conflict=g,R.type=R.name="writeConflict",R};function Mo(g,R,N){const U=kn(g,R,N);if(U.ok)return U.result;Ts(U.conflict)}const Ue=g=>{const R=r.writeCursor();return r.readCursor(g).traverse(R,(N,U)=>{(u(N)||ht(N))&&U.write("r",!0)}),R.get()},Uo=(g,R)=>{const{type:N,op1:U,op2:A}=g;switch(N){case i.ConflictType.DROP_COLLISION:return R==="left"?[null,Ue(A)]:[Ue(U),null];case i.ConflictType.RM_UNEXPECTED_CONTENT:let T=!1;return r.readCursor(U).traverse(null,G=>{G.r!==void 0&&(T=!0)}),T?[null,Ue(A)]:[Ue(U),null];case i.ConflictType.BLACKHOLE:return[Ue(U),Ue(A)];default:throw Error("Unrecognised conflict: "+N)}};function Ms(g,R,N,U){let A=null;for(;;){const T=kn(R,N,U);if(T.ok)return _t(A,T.result);{const{conflict:G}=T;g(G)||Ts(G);const[W,C]=Uo(G,U);R=_t(X(R),W),N=_t(X(N),C),A=_t(A,C)}}}})(xi);(function(t){var n=Wt&&Wt.__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=Wt&&Wt.__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(xi,t);var s=Rs;Object.defineProperty(t,"ReadCursor",{enumerable:!0,get:function(){return s.ReadCursor}}),Object.defineProperty(t,"WriteCursor",{enumerable:!0,get:function(){return s.WriteCursor}});var r=Cs;Object.defineProperty(t,"ConflictType",{enumerable:!0,get:function(){return r.ConflictType}})})($t);const Wl=Pl($t),Bl=yo({__proto__:null,default:Wl},[$t]);var J=(t=>(t.RETAIN="r",t.INSERT="i",t.DELETE="d",t))(J||{});class ss{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===J.DELETE||e.t===J.RETAIN&&e.body==null?x.deepClone({...e,len:n}):x.deepClone({...e,len:n,body:Ze(e.body,s,s+n)})}else return{t:J.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:J.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 Pi{constructor(){_(this,"cursor",0)}reset(){return this.cursor=0,this}moveCursor(n){this.cursor+=n}moveCursorTo(n){this.cursor=n}}function ki(t,n,e){const{dataStream:s}=t,r=e,i=e+n,o=Ai(t,n,e),a=bi(t,n,e),l=vi(t,n,e),h=wi(t,n,e),c=Ti(t,n,e),u=Mi(t,n,e),d=Ui(t,n,e);let f="";return s&&(t.dataStream=Qr(s,r,i),f=s.slice(r,i)),{dataStream:f,textRuns:o,paragraphs:a,sectionBreaks:l,customBlocks:h,tables:c,customRanges:u,customDecorations:d}}function Hi(t,n,e,s){t.dataStream=Jr(t.dataStream,s,n.dataStream),Ci(t,n,e,s),_s(t,n,e,s),Sl(t,n,e,s),Ii(t,n,e,s),Si(t,n,e,s),Oi(t,n,e,s),Ni(t,n,e,s)}function Gl(t,n,e,s,r=Pt.COVER){return Al(t,n,e,s,r)}function jl(t,n,e){return n<=0?{dataStream:""}:ki(t,n,e)}function Vl(t,n,e,s){e!==0&&Hi(t,n,e,s)}function Kl(t,n){const e=new Pi;return e.reset(),n.forEach(s=>{switch(s=x.deepClone(s),s.t){case J.RETAIN:{const{coverType:r,body:i,len:o}=s;i!=null&&Gl(t,i,o,e.cursor,r),e.moveCursor(o);break}case J.INSERT:{const{body:r,len:i}=s;Vl(t,r,i,e.cursor),e.moveCursor(i);break}case J.DELETE:{const{len:r}=s;jl(t,r,e.cursor);break}default:throw new Error(`Unknown action type for action: ${s}.`)}}),t}function Bs(t){return Object.keys(t).length===1}const Xe=class Xe{constructor(){_(this,"_actions",[])}static apply(n,e){return Kl(n,e)}static compose(n,e){const s=new ss(n),r=new ss(e),i=new Xe;for(;s.hasNext()||r.hasNext();)if(r.peekType()===J.INSERT)i.push(r.next());else if(s.peekType()===J.DELETE)i.push(s.next());else{const o=Math.min(s.peekLength(),r.peekLength()),a=s.next(o),l=r.next(o);a.t===J.INSERT&&l.t===J.RETAIN?l.body==null?i.push(a):i.push({...a,body:ts(a.body,l.body,l.coverType)}):a.t===J.RETAIN&&l.t===J.RETAIN?a.body==null&&l.body==null?i.push(a.len!==Number.POSITIVE_INFINITY?a:l):a.body&&l.body?i.push({...a,body:ts(a.body,l.body,l.coverType)}):i.push(a.body?a:l):a.t===J.RETAIN&&l.t===J.DELETE?i.push(l):a.t===J.INSERT&&(l.t,J.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===J.INSERT)e.push({t:J.DELETE,len:s.len,line:0,body:s.body,segmentId:s.segmentId});else if(s.t===J.DELETE){if(s.body==null)throw new Error("Can not invert DELETE action without body property, makeInvertible must be called first.");e.push({t:J.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:J.RETAIN,body:s.oldBody,oldBody:s.body,len:s.len,coverType:Pt.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===J.DELETE&&i.body==null){const o=Ze(e,r,r+i.len,!1);i.len=o.dataStream.length,i.body=o}if(i.t===J.RETAIN&&i.body!=null){const o=Ze(e,r,r+i.len,!0);i.oldBody={...o,dataStream:""},i.len=o.dataStream.length}s.push(i),i.t!==J.INSERT&&(r+=i.len)}return s}insert(n,e,s=""){const r={t:J.INSERT,body:e,len:n,line:0,segmentId:s};return this.push(r),this}retain(n,e="",s,r){const i={t:J.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:J.DELETE,len:n,line:0,segmentId:e};return this.push(s),this}empty(){return this._actions=[],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=x.deepClone(n[0]);if(r.t===J.RETAIN&&r.len===0&&r.body==null)return this;if(typeof s=="object"){if(s.t===J.DELETE&&r.t===J.DELETE)return s.len+=r.len,this;if(s.t===J.DELETE&&r.t===J.INSERT&&(e-=1,s=this._actions[e-1],s==null))return this._actions.unshift(r),this;if(s.t===J.RETAIN&&r.t===J.RETAIN&&s.body==null&&r.body==null)return s.len+=r.len,this;if(s.t===J.INSERT&&Bs(s.body)&&r.t===J.INSERT&&Bs(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===J.RETAIN&&yl(n);)this._actions.pop(),n=this._actions[this._actions.length-1];return this}};_(Xe,"id","text-x"),_(Xe,"uri","https://github.com/dream-num/univer#text-x");let Ee=Xe;Object.defineProperty(Ee,"name",{value:"text-x"});const ye=class ye{static registerSubtype(n){var e;this._subTypes.has(n.name)&&((e=this._subTypes.get(n.name))==null?void 0:e.id)!==Ee.id||(this._subTypes.set(n.name,n),$t.type.registerSubtype(n))}static apply(n,e){if(!$t.type.isNoop(e))return $t.type.apply(n,e)}static compose(n,e){return $t.type.compose(n,e)}static transform(n,e,s){throw new Error("transform is not implemented in JsonX")}static invertWithDoc(n,e){return $t.type.invertWithDoc(n,e)}static isNoop(n){return $t.type.isNoop(n)}static getInstance(){return this._instance==null&&(this._instance=new ye),this._instance}removeOp(n,e){return $t.removeOp(n,e)}moveOp(n,e){return $t.moveOp(n,e)}insertOp(n,e){return $t.insertOp(n,e)}replaceOp(n,e,s){return $t.replaceOp(n,e,s)}editOp(n,e=["body"]){return $t.editOp(e,Ee.name,n)}};_(ye,"uri","https://github.com/dream-num/univer#json-x"),_(ye,"_subTypes",new Map),_(ye,"_instance",null);let ve=ye;ve.registerSubtype(Ee);const Ss={id:"default_doc",documentStyle:{}};class Yl extends Mn{constructor(e){super();_(this,"type",Q.UNIVER_DOC);_(this,"snapshot");this.snapshot={...Ss,...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 c=h.docTransform;c.size.width=i,c.size.height=o,c.positionH.posOffset=a,c.positionV.posOffset=l}setZoomRatio(e=1){this.snapshot.settings==null?this.snapshot.settings={zoomRatio:e}:this.snapshot.settings.zoomRatio=1}}class we extends Yl{constructor(e){var r;super(x.isEmptyObject(e)?xl():e);_(this,"_unitId");_(this,"headerModelMap",new Map);_(this,"footerModelMap",new Map);const s=6;this._unitId=(r=this.snapshot.id)!=null?r:x.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={...Ss,...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,r=gs.copy){const i=this.getBody();if(i!=null)return Ze(i,e,s,!1,r)}_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 Fi=ut.createIdentifier("univer.config-service");class $i{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 Wi extends Tt{constructor(){super(...arguments);_(this,"_error$",new Z.Subject);_(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(e){this._error$.next({errorKey:e})}}class Bi{constructor(n={}){_(this,"_styles");_(this,"_cacheMap",new ri(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=x.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&&x.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(x.diffValue(e[s],n))return s;return null}}class zl{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!==K.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:it.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:it.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:it.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:it.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 ge(this._columnData)}getColumnWidth(n){const{_columnData:e}=this,s=this._config;let r=0;return r=(e[n]||{hd:K.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:K.FALSE};return this._columnData[n]=i,i}}class Xl{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:K.FALSE,h:r.defaultRowHeight},{ia:l,ah:h,h:c=r.defaultRowHeight}=a;i+=(l==null||l===K.TRUE)&&typeof h=="number"?h:c}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:K.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:it.ROW})):!r&&!a&&(r=!0,i=o)}return r&&s.push({startRow:i,endRow:e,startColumn:0,endColumn:0,rangeType:it.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:it.ROW})):!r&&a&&(r=!0,i=o)}return r&&s.push({startRow:i,endRow:e,startColumn:0,endColumn:0,rangeType:it.ROW}),s}getRowRawVisible(n){const e=this.getRow(n);return e?e.hd!==K.TRUE:!0}getSize(){return ge(this._rowData)}}const ql="DEFAULT_WORKSHEET_ROW_COUNT",Gi=1e3,Zl="DEFAULT_WORKSHEET_COLUMN_COUNT",ji=20,Jl="DEFAULT_WORKSHEET_ROW_HEIGHT",Vi=24,Ql="DEFAULT_WORKSHEET_COLUMN_WIDTH",Ki=88,tu="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",Yi=46,eu="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",zi=20;function Xi(t){const n={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:K.FALSE,rowCount:Gi,columnCount:ji,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:Ki,defaultRowHeight:Vi,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:K.TRUE,rowHeader:{width:Yi,hidden:K.FALSE},columnHeader:{height:zi,hidden:K.FALSE},selections:["A1"],rightToLeft:K.FALSE};return Object.keys(n).forEach(e=>{const s=e;typeof t[s]>"u"&&(t[s]=n[s])}),t}class qi extends Tt{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,bt(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(e){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=e,bt(()=>this._rowFilteredInterceptor=null)}}class Je{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=Xi(e);const{columnData:r,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:x.generateRandomId(6),this._cellData=new ee(o),this._viewModel=new qi((l,h)=>this.getCellRaw(l,h)),this._rowManager=new Xl(this._snapshot,this._viewModel,i),this._columnManager=new zl(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,c)=>{Object.keys(c).forEach(u=>{const d=+u,f=n.getValue(h,d),m=f!=null&&f.s?this._styles.get(f.s):null,E=(m==null?void 0:m.bd)&&(m.bd.b||m.bd.l||m.bd.r||m.bd.t||m.bd.bc_tr||m.bd.bl_tr||m.bd.ml_tr||m.bd.tl_bc||m.bd.tl_br||m.bd.tl_mr);(f&&(f.v||f.p)||m!=null&&m.bg||E)&&(a?s=Math.min(s,h):(s=h,a=!0),r=Math.max(r,h),l?i=Math.min(i,d):(l=!0,i=d),o=Math.max(o,d))})}),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=x.deepClone(n);return new Je(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 ee;return Jn(n,s,e,r).forEach((h,c)=>{const u=i?this.getCellRaw(h,c):this.getCell(h,c);u&&l.setValue(h,c,u)}),a.forEach(h=>{const{startColumn:c,startRow:u,endColumn:d,endRow:f}=h;Jn(u,f,c,d).forEach((m,E)=>{m===u&&E===c&&l.setValue(m,E,{...o.getValue(m,E),rowSpan:f-u+1,colSpan:d-c+1}),(m!==u||E!==c)&&l.realDeleteValue(m,E)})}),l}getRange(n,e,s,r){return typeof n=="object"?new He(this,n,{getStyles:()=>this._styles}):new He(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 c=a.getCell(l,h),u=!c,d=a.getMergedCell(l,h);if(d){if(l!==d.startRow||h!==d.startColumn){h=d.endColumn+1;continue}if(u&&e){h=d.endColumn+1;continue}const m={row:l,col:h,value:c};return m.colSpan=d.endColumn-d.startColumn+1,m.rowSpan=d.endRow-d.startRow+1,h=d.endColumn+1,{done:!1,value:m}}if(u&&e)h+=1;else{const f={row:l,col:h,value:c};return h+=1,{done:!1,value:f}}}}}}}}iterateByColumn(n,e=!0,s=!0){const{startRow:r,startColumn:i,endRow:o,endColumn:a}=n,l=this;return{[Symbol.iterator]:()=>{let h=r,c=i;return{next(){for(;;){if(h>o&&(c+=1,h=r),c>a)return{done:!0,value:void 0};const u=l.getMergedCell(h,c);if(u){const m=h!==u.startRow,E=m||c!==u.startColumn;if(s&&E||!s&&m){h=u.endRow+1;continue}const M=l.getCell(u.startRow,u.startColumn);if(!M&&e){h=u.endRow+1;continue}const tt={row:h,col:u.startColumn,value:M};return tt.colSpan=u.endColumn-u.startColumn+1,tt.rowSpan=u.endRow-u.startRow+1,h=u.endRow+1,{done:!1,value:tt}}const d=l.getCell(h,c);if(!d&&e)h+=1;else{const m={row:h,col:c,value:d};return h+=1,{done:!1,value:m}}}}}}}}}function nu(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===Ae.BOOLEAN?e.toUpperCase():e.replace(/[\r\n]/g,""):typeof e=="number"?t.t===Ae.BOOLEAN?e?"TRUE":"FALSE":e.toString():typeof e=="boolean"?e?"TRUE":"FALSE":""}const su="0.2.4";function ru(t="",n=Te.ZH_CN,e=""){return{id:t,sheetOrder:[],name:e,appVersion:su,locale:n,styles:{},sheets:{},resources:[]}}var iu=Object.defineProperty,ou=Object.getOwnPropertyDescriptor,au=(t,n,e,s)=>{for(var r=s>1?void 0:s?ou(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&&iu(n,e,r),r},lu=(t,n)=>(e,s)=>n(e,s,t);function uu(t,n){return`${t.getUnitId()}|${n.getSheetId()}`}exports.Workbook=class extends Mn{constructor(e={},s){super();_(this,"type",Q.UNIVER_SHEET);_(this,"_sheetCreated$",new Z.Subject);_(this,"sheetCreated$",this._sheetCreated$.asObservable());_(this,"_sheetDisposed$",new Z.Subject);_(this,"sheetDisposed$",this._sheetDisposed$.asObservable());_(this,"_activeSheet$",new Z.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=ru();x.isEmptyObject(e)?this._snapshot=r:this._snapshot=x.commonExtend(r,e);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=x.generateRandomId(6)),this._unitId=this._snapshot.id,this._styles=new Bi(i),this._count=1,this._worksheets=new Map,this._name$=new Z.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 x.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 Je(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()!==K.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===K.TRUE).map(e=>e.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden!==K.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(x.isEmptyObject(r)){const o=x.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 Je(this._unitId,a,this._styles);s.set(o,h),i.includes(o)||i.push(o)}this.ensureActiveSheet()}};exports.Workbook=au([lu(1,pe)],exports.Workbook);class Os extends Mn{constructor(e){var s;super();_(this,"type",Q.UNIVER_SLIDE);_(this,"_snapshot");_(this,"_unitId");this._snapshot={...ai,...e},this._unitId=(s=this._snapshot.id)!=null?s:x.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:as.SLIDE,zIndex:1,title:"cover",description:"this is first page, cover",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}}const Ke="FOCUSING_SHEET",_n="FOCUSING_DOC",gn="FOCUSING_SLIDE",cu="FOCUSING_EDITOR_BUT_HIDDEN",Zi="EDITOR_ACTIVATED",hu="FOCUSING_EDITOR_INPUT_FORMULA",Ji="FOCUSING_FORMULA_EDITOR",du="FOCUSING_UNIVER_EDITOR",fu="FOCUSING_EDITOR_INPUT_FORMULA",_u="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",gu="FOCUSING_COMMON_DRAWINGS";var mu=Object.defineProperty,Eu=Object.getOwnPropertyDescriptor,pu=(t,n,e,s)=>{for(var r=s>1?void 0:s?Eu(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&&mu(n,e,r),r},Gs=(t,n)=>(e,s)=>n(e,s,t);const Fe=ut.createIdentifier("univer.current");exports.UniverInstanceService=class extends Tt{constructor(e,s){super();_(this,"_unitsByType",new Map);_(this,"_createHandler");_(this,"_ctorByType",new Map);_(this,"_currentUnits",new Map);_(this,"_currentUnits$",new Z.BehaviorSubject(this._currentUnits));_(this,"currentUnits$",this._currentUnits$.asObservable());_(this,"_unitAdded$",new Z.Subject);_(this,"unitAdded$",this._unitAdded$.asObservable());_(this,"_unitDisposed$",new Z.Subject);_(this,"unitDisposed$",this._unitDisposed$.asObservable());_(this,"_focused$",new Z.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(Z.map(s=>{var r;return(r=s.get(e))!=null?r:null}),Z.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(Z.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(Z.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 exports.Workbook?(this._contextService.setContextValue(_n,!1),this._contextService.setContextValue(Ke,!0),this._contextService.setContextValue(gn,!1)):this.focused instanceof we?(this._contextService.setContextValue(_n,!0),this._contextService.setContextValue(Ke,!1),this._contextService.setContextValue(gn,!1)):this.focused instanceof Os&&(this._contextService.setContextValue(_n,!1),this._contextService.setContextValue(Ke,!1),this._contextService.setContextValue(gn,!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]}}};exports.UniverInstanceService=pu([Gs(0,ut.Inject(ut.Injector)),Gs(1,Qe)],exports.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 Ru={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"},mn=new Map;function Qi(t,n){return function(r){Un(t,n)}}function Un(t,n){mn.has(t)||mn.set(t,[]),mn.get(t).push(n)}var Cu=Object.defineProperty,Iu=Object.getOwnPropertyDescriptor,to=(t,n,e,s)=>{for(var r=s>1?void 0:s?Iu(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},eo=(t,n)=>(e,s)=>n(e,s,t);exports.LifecycleService=class extends Tt{constructor(e){super();_(this,"_lifecycle$",new Z.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 Z.merge(no(this.stage),this._lifecycle$.pipe(Z.skip(1))).pipe(mi(e=>e===ft.Steady))}_reportProgress(e){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${Ru[e]}".`)}};exports.LifecycleService=to([eo(0,pe)],exports.LifecycleService);exports.LifecycleInitializerService=class extends Tt{constructor(e){super();_(this,"_seenTokens",new Set);this._injector=e}initModulesOnStage(e){var s;(s=mn.get(e))==null||s.forEach(r=>{this._injector.has(r)&&!this._seenTokens.has(r)&&(this._injector.get(r),this._seenTokens.add(r))})}};exports.LifecycleInitializerService=to([eo(0,ut.Inject(ut.Injector))],exports.LifecycleInitializerService);function no(t){switch(t){case ft.Starting:return Z.of(ft.Starting);case ft.Ready:return Z.of(ft.Starting,ft.Ready);case ft.Rendered:return Z.of(ft.Starting,ft.Ready,ft.Rendered);default:return Z.of(ft.Starting,ft.Ready,ft.Rendered,ft.Steady)}}class Ye extends Tt{constructor(){super();_(this,"_currentLocale$",new Z.BehaviorSubject(Te.ZH_CN));_(this,"currentLocale$",this._currentLocale$.asObservable());_(this,"_locales",null);_(this,"localeChanged$",new Z.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(bt(()=>this.localeChanged$.complete()))}get _currentLocale(){return this._currentLocale$.value}load(e){var s;this._locales=x.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 Ns=(t=>(t.INIT="init",t.FETCHING="fetching",t.DONE="done",t))(Ns||{});const As=ut.createIdentifier("univer.permission-service");Un(ft.Starting,As);class so extends Tt{constructor(){super(...arguments);_(this,"_permissionPointMap",new Map);_(this,"_permissionPointUpdate$",new Z.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 Z.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 Z.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=Ns.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 Z.combineLatest(s).pipe(cn.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 ro extends Tt{constructor(){super(...arguments);_(this,"_resourceMap",new Map);_(this,"_register$",new Z.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),bt(()=>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 Ln=ut.createIdentifier("resource-manager-service");var Su=Object.defineProperty,Ou=Object.getOwnPropertyDescriptor,Nu=(t,n,e,s)=>{for(var r=s>1?void 0:s?Ou(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&&Su(n,e,r),r},js=(t,n)=>(e,s)=>n(e,s,t);let rs=class extends Tt{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(bt(this._univerInstanceService.getTypeOfUnitAdded$(Q.UNIVER_SHEET).subscribe(s=>{this._resourceManagerService.loadResources(s.getUnitId(),s.getSnapshot().resources)}))),this.disposeWithMe(bt(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}};rs=Nu([js(0,ut.Inject(Ln)),js(1,ut.Inject(Fe))],rs);const bs=ut.createIdentifier("resource-loader-service");Un(ft.Ready,bs);class vs extends Tt{constructor(){super();_(this,"_currentTheme");_(this,"_currentTheme$",new Z.BehaviorSubject({}));_(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(bt(()=>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 Dn="__INTERNAL_EDITOR__",io=`${Dn}DOCS_NORMAL`,oo=`${Dn}DOCS_FORMULA_BAR`,Au=`\r
7
+ `;function bu(t){return`${Dn}${t}`}function vu(t){return t.startsWith(Dn)}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},jn=(t,n)=>(e,s)=>n(e,s,t);const yn=ut.createIdentifier("univer.undo-redo.service"),Uu=20;class ao{dispose(){}async dispatchToHandlers(){return!1}}const lo="univer.command.redo",uo="univer.command.undo",co=new class extends ao{constructor(){super(...arguments);_(this,"type",tn.COMMAND);_(this,"id",uo)}async handler(n){const e=n.get(yn),s=e.pitchTopUndoElement();if(!s)return!1;const r=n.get(en);return cs(s.undoMutations,r)?(e.popUndoToRedo(),!0):!1}},ho=new class extends ao{constructor(){super(...arguments);_(this,"type",tn.COMMAND);_(this,"id",lo)}async handler(n){const e=n.get(yn),s=e.pitchTopRedoElement();if(!s)return!1;const r=n.get(en);return cs(s.redoMutations,r)?(e.popRedoToUndo(),!0):!1}};exports.LocalUndoRedoService=class extends Tt{constructor(e,s,r){super();_(this,"undoRedoStatus$");_(this,"_undoRedoStatus$",new Z.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(co)),this.disposeWithMe(this._commandService.registerCommand(ho)),this.disposeWithMe(bt(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(bt(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>Uu&&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),bt(()=>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(Ke),r=this._contextService.getContextValue(Ji),i=this._contextService.getContextValue(Zi);return s?r?e=oo:i?e=io: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}};exports.LocalUndoRedoService=Mu([jn(0,Fe),jn(1,en),jn(2,Qe)],exports.LocalUndoRedoService);const fo=Symbol("DependentOn");class is extends Tt{onStarting(n){}onReady(){}onRendered(){}onSteady(){}getUniverInstanceType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}_(is,"pluginName"),_(is,"type",Q.UNIVER_UNKNOWN);class Lu{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 Du{constructor(){_(this,"_pluginsRegistered",[])}registerPlugin(n,e){this._pluginsRegistered.push({plugin:n,options:e})}getRegisterPlugins(){return this._pluginsRegistered.slice()}removePlugins(){this._pluginsRegistered=[]}}var yu=Object.defineProperty,xu=Object.getOwnPropertyDescriptor,_o=(t,n,e,s)=>{for(var r=s>1?void 0:s?xu(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&&yu(n,e,r),r},Ge=(t,n)=>(e,s)=>n(e,s,t);const Pu=4;function ku(...t){return function(n){n[fo]=t}}exports.PluginService=class{constructor(n){_(this,"_pluginHolderForUniver");_(this,"_pluginHoldersForTypes",new Map);_(this,"_seenPlugins",new Set);_(this,"_flushTimer");this._injector=n,this._pluginHolderForUniver=this._injector.createInstance(On,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(On,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()},Pu))}_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()}};exports.PluginService=_o([Ge(0,ut.Inject(ut.Injector))],exports.PluginService);let On=class extends Tt{constructor(n,e,s,r,i,o){super();_(this,"_started",!1);_(this,"_pluginRegistry",new Du);_(this,"_pluginStore",new Lu);_(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(Z.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[fo];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){no(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)}};On=_o([Ge(2,pe),Ge(3,ut.Inject(ut.Injector)),Ge(4,ut.Inject(exports.LifecycleService)),Ge(5,ut.Inject(exports.LifecycleInitializerService))],On);function go(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 os={[Ft.Editor]:"Editor",[Ft.Owner]:"Owner",[Ft.Reader]:"Reader",[Ft.UNRECOGNIZED]:"UNRECOGNIZED"},Nn=t=>t?{userID:`${os[t]}_${x.generateRandomId(8)}`,name:os[t],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},Vn=(t,n)=>t.startsWith(os[n]);var Hu=Object.defineProperty,Fu=Object.getOwnPropertyDescriptor,$u=(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&&Hu(n,e,r),r};exports.UserManagerService=class{constructor(){_(this,"_model",new Map);_(this,"_userChange$",new Z.Subject);_(this,"userChange$",this._userChange$.asObservable());_(this,"_currentUser$",new Z.BehaviorSubject(Nn()));_(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"})}list(){return Array.from(this._model.values())}};exports.UserManagerService=$u([Qi(ft.Starting,exports.UserManagerService)],exports.UserManagerService);var Wu=Object.defineProperty,Bu=Object.getOwnPropertyDescriptor,Gu=(t,n,e,s)=>{for(var r=s>1?void 0:s?Bu(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},Vs=(t,n)=>(e,s)=>n(e,s,t);exports.AuthzIoLocalService=class{constructor(n,e){_(this,"_permissionMap",new Map([]));this._resourceManagerService=n,this._userManagerService=e,this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){const n=this._userManagerService.getCurrentUser();n&&n.userID||this._userManagerService.setCurrentUser(Nn(Ft.Owner))}_getRole(n){const e=this._userManagerService.getCurrentUser();return e?Vn(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=x.generateRandomId(8);switch(n.objectType){case fn.SelectRange:{const s=n.selectRangeObject;this._permissionMap.set(e,{...s,objectType:n.objectType});break}case fn.Worksheet:{const s=n.worksheetObject;this._permissionMap.set(e,{...s,objectType:n.objectType,readScope:pi.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===fn.Worksheet)return(e=s==null?void 0:s.strategies)==null?void 0:e.map(r=>({action:r.action,allowed:r.role===Ft.Editor}))}return n.actions.map(s=>({action:s,allowed:this._getRole(Ft.Owner)||this._getRole(Ft.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&&(Vn(e.userID,Ft.Owner)||Vn(e.userID,Ft.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:Ft.Owner,shareScope:-1,creator:Nn(Ft.Owner),strategies:[],actions:n.actions.map(o=>({action:o,allowed:this._getRole(Ft.Owner)||this._getRole(Ft.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){}};exports.AuthzIoLocalService=Gu([Vs(0,Ln),Vs(1,ut.Inject(exports.UserManagerService))],exports.AuthzIoLocalService);const mo=ut.createIdentifier("IAuthzIoIoService");class ju{constructor(n={},e){_(this,"_startedTypes",new Set);_(this,"_injector");const s=this._injector=Vu(e,n==null?void 0:n.override),{theme:r,locale:i,locales:o,logLevel:a}=n;r&&this._injector.get(vs).setTheme(r),o&&this._injector.get(Ye).load(o),i&&this._injector.get(Ye).setLocale(i),a&&this._injector.get(pe).setLogLevel(a),this._init(s)}get _univerInstanceService(){return this._injector.get(Fe)}get _pluginService(){return this._injector.get(exports.PluginService)}__getInjector(){return this._injector}dispose(){this._injector.dispose()}setLocale(n){this._injector.get(Ye).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,exports.Workbook),this._univerInstanceService.registerCtorForType(Q.UNIVER_DOC,we),this._univerInstanceService.registerCtorForType(Q.UNIVER_SLIDE,Os);const e=n.get(Fe);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(exports.LifecycleService).stage<ft.Ready&&(this._injector.get(exports.LifecycleService).stage=ft.Ready)}registerPlugin(n,e){this._pluginService.registerPlugin(n,e)}}function Vu(t,n){const e=go([[Wi],[Ye],[vs],[exports.LifecycleService],[exports.LifecycleInitializerService],[exports.PluginService],[exports.UserManagerService],[Fe,{useClass:exports.UniverInstanceService}],[As,{useClass:so}],[pe,{useClass:fi,lazy:!0}],[en,{useClass:exports.CommandService}],[yn,{useClass:exports.LocalUndoRedoService,lazy:!0}],[Fi,{useClass:$i}],[Qe,{useClass:hi}],[Ln,{useClass:ro,lazy:!0}],[bs,{useClass:rs,lazy:!0}],[mo,{useClass:exports.AuthzIoLocalService,lazy:!0}]],n);return t?t.createChild(e):new ut.Injector(e)}const Ku=(t,n)=>n.length===t.length&&!t.some(e=>n.some(s=>!me.equals(s,e))),Yu=(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 zu(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 Eo(t){return/^-?\d+(\.\d+)?$/.test(t)}function Xu(t){return Eo(t)?Number(t)<=Number.MAX_SAFE_INTEGER:!1}function qu(t){return["true","false"].includes(t.toLowerCase())}function Zu(t,n){return n.forEach(e=>t.add(e)),t}function Ju(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 Qu(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 po=(t=>(t[t.TEXT=0]="TEXT",t[t.ARROW=1]="ARROW",t[t.CUSTOM=2]="CUSTOM",t))(po||{});function tc(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 Ee,h=ve.getInstance();if(o>0&&l.retain(o),e.length>0){const c=r.sliceBody(o,o+i),u={dataStream:e};Array.isArray(c==null?void 0:c.textRuns)&&c.textRuns.length&&(u.textRuns=[{...c.textRuns[0],st:0,ed:e.length}]),l.insert(e.length,u)}l.delete(i),r.apply(h.editOp(l.serialize()))}const a=r.getBody();return r.dispose(),a}class Ro{constructor(){_(this,"skipNextObservers",!1);_(this,"lastReturnValue");_(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class ec extends Z.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 Ro;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 nc=ut.createIdentifier("ILocalStorageService");function sc(t){return`sheet_interceptor_${t}`}const Co=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 rc{constructor(n){_(this,"_interceptorsByName",new Map);_(this,"_interceptorPoints");this._interceptorPoints=n}fetchThroughInterceptors(n){const e=n,s=this._interceptorsByName.get(e);return Co(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)})),()=>Tn(this._interceptorsByName.get(s),e)}getInterceptPoints(){return this._interceptorPoints}}const ic=ut.createIdentifier("univer.snapshot-server-service");class oc{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:Xt.OK,message:""}})}getSheetBlock(n,e){const s=this._sheetBlockCache.get(e.blockID);return Promise.resolve({block:s,error:{code:Xt.OK,message:""}})}fetchMissingChangesets(n,e){return Promise.resolve({changesets:[],error:{code:Xt.OK,message:""}})}getResourcesRequest(n,e){return Promise.resolve({resources:{},error:{code:Xt.OK,message:""}})}saveSnapshot(n,e){return Promise.resolve({error:{code:Xt.OK,message:""}})}saveSheetBlock(n,e){const{block:s}=e;return s?(this._sheetBlockCache.set(s.id,s),Promise.resolve({error:{code:Xt.OK,message:""},blockID:s.id})):Promise.resolve({error:{code:Xt.UNDEFINED,message:"block is required"},blockID:""})}saveChangeset(n,e){return Promise.resolve({error:{code:Xt.OK,message:""},concurrent:[]})}}function ac(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,(n,e)=>String.fromCharCode(Number.parseInt(e,16))))}function ws(t){return decodeURIComponent(Array.prototype.map.call(atob(t),n=>`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""))}const nn=new TextEncoder,xn=new TextDecoder;function Io(t){const n=x.deepClone(t);return delete n.id,delete n.name,delete n.rowCount,delete n.columnCount,delete n.cellData,nn.encode(JSON.stringify(n))}function So(t){const n=x.deepClone(t);return delete n.id,delete n.rev,delete n.name,delete n.sheetOrder,delete n.sheets,nn.encode(JSON.stringify(n))}function lc(t){const n=x.deepClone(t);return delete n.id,delete n.rev,delete n.title,delete n.resources,nn.encode(JSON.stringify(n))}function Ks(t){return JSON.parse(xn.decode(t))}function uc(t){return JSON.parse(typeof t=="string"?ws(t):xn.decode(t))}function cc(t){return JSON.parse(typeof t=="string"?ws(t):xn.decode(t))}const Kn=256*20;function Oo(t,n){const e=new ee(t),s=e.getLength(),r=[];let i=0;for(;i<s;){const o=Math.min(i+Kn,s-1),a=e.getSlice(i,Math.min(i+Kn,s-1),0,n),l=hc(a);r.push({id:x.generateRandomId(19,"0123456789"),startRow:i,endRow:o,data:l}),i+=Kn}return r}function hc(t){const n=t.getData();return nn.encode(JSON.stringify(n))}async function dc(t,n,e,s,r){const i={},o={};if(!await Promise.all(Object.entries(n.sheets).map(async([u,d])=>{const f={id:d.id,type:An.GRID,name:d.name,rowCount:d.rowCount,columnCount:d.columnCount,originalMeta:Io(d)};if(o[u]=f,d.cellData){const m=Oo(d.cellData,d.rowCount),E=await Promise.all(m.map(M=>r.saveSheetBlock(t,{unitID:e,type:Q.UNIVER_SHEET,block:M})));if(E.some(M=>{var L;return((L=M.error)==null?void 0:L.code)!==Xt.OK}))return!1;i[u]={sheetID:u,blocks:E.map(M=>M.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const l=So(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 fc(t,n,e,s,r){var d,f;const i={},o={};if(!await Promise.all(Object.entries(n.sheets).map(async([m,E])=>{const M={id:E.id,type:An.GRID,name:E.name,rowCount:E.rowCount,columnCount:E.columnCount,originalMeta:Io(E)};if(o[m]=M,E.cellData){const L=Oo(E.cellData,E.rowCount),tt=await Promise.all(L.map(mt=>r.saveSheetBlock(t,{unitID:e,type:Q.UNIVER_SHEET,block:mt})));if(tt.some(mt=>{var ht;return((ht=mt.error)==null?void 0:ht.code)!==Xt.OK}))return!1;i[m]={sheetID:m,blocks:tt.map(mt=>mt.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const l=So(n),h={unitID:n.id,rev:s,creator:"",name:n.name,sheetOrder:n.sheetOrder,sheets:o,blockMeta:i,resources:n.resources||[],originalMeta:l},c={unitID:e,rev:h.rev,type:Q.UNIVER_SHEET,workbook:h,doc:void 0},u=await r.saveSnapshot(t,{unitID:e,type:Q.UNIVER_SHEET,snapshot:c});if(Ei(u.error))throw new Error(`transformWorkbookDataToSnapshot(): Failed to save snapshot.
8
+ ErrorCode: ${(d=u.error)==null?void 0:d.code}:${(f=u.error)==null?void 0:f.message}`);return{snapshot:c}}function _c(t,n,e){const s=t.workbook;if(!s)throw new Error("");const r={};Object.entries(s.sheets).forEach(([l,h])=>{const c=Ks(h.originalMeta);r[l]={id:h.id,name:h.name,rowCount:h.rowCount,columnCount:h.columnCount,...c}});const i=new Map;n.forEach(l=>{i.set(l.id,l)}),s.blockMeta&&Object.entries(s.blockMeta).forEach(([l,h])=>{var d;const c=r[l];c.cellData={};const u=[];(d=h.blocks)==null||d.forEach(f=>{const m=i.get(f);if(m)u.push(m);else throw new Error("")}),u.forEach(f=>{const m=uc(f.data);Object.entries(m).forEach(([E,M])=>{const L=c.cellData[+E]={};Object.entries(M).forEach(([tt,mt])=>{L[+tt]=mt})})})});const o=Ks(s.originalMeta);return{id:t.unitID,rev:s.rev,name:s.name,sheetOrder:s.sheetOrder,appVersion:"",locale:Te.EN_US,sheets:r,styles:{},resources:s.resources||[],...o}}function gc(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:c={},drawingsOrder:u=[]}=cc(i);return{id:e,rev:s,locale:Te.EN_US,title:r,body:a,documentStyle:l,settings:h,drawings:c,drawingsOrder:u,resources:o}}async function mc(t,n,e,s,r){var l,h,c;const i={unitID:n.id,rev:s,creator:"",name:(l=n.title)!=null?l:"",resources:n.resources||[],originalMeta:lc(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(Ei(a.error))throw new Error(`transformDocumentDataToSnapshot(): Failed to save snapshot.
9
+ ErrorCode: ${(h=a.error)==null?void 0:h.code}:${(c=a.error)==null?void 0:c.message}`);return{snapshot:o}}async function Ec(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:c}=await n.getSheetBlock({},h);if(c)s.push(c);else throw new Error("Block not found")});r.push(...a)}),await Promise.all(r),s}var No=(t=>(t[t.INFO=0]="INFO",t[t.STOP=1]="STOP",t[t.WARNING=2]="WARNING",t))(No||{}),Ao=(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))(Ao||{}),bo=(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))(bo||{}),vo=(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))(vo||{}),wo=(t=>(t.VALID="valid",t.INVALID="invalid",t.VALIDATING="validating",t))(wo||{});const pc=["script","style","meta","comment","link"];function Rc(t){return!(t.length===0||t.length>31||t.startsWith("'")||t.endsWith("'")||/[:\\\/\?\*\[\]]/.test(t))}xo();exports.ABCToNumber=Za;exports.AbsoluteRefType=At;exports.ActionIterator=ss;exports.AlignTypeH=$r;exports.AlignTypeV=Wr;exports.ArrangeTypeEnum=jr;exports.ArrowsAndMarkersShapes=hr;exports.AutoFillSeries=Js;exports.BaselineOffset=ke;exports.BasicShapes=cr;exports.BlockType=Ir;exports.BooleanNumber=K;exports.BorderStyleTypes=dt;exports.BorderType=Qs;exports.BulletAlignment=fe;exports.COLORS=Yn;exports.CellValueType=Ae;exports.ClientSnapshotServerService=oc;exports.Color=be;exports.ColorBuilder=vn;exports.ColorKit=te;exports.ColorType=zt;exports.ColumnSeparatorType=Ar;exports.CommandType=tn;exports.CommonHideTypes=tr;exports.ConfigService=$i;exports.ContentAlignment=xr;exports.ContextService=hi;exports.CopyPasteType=er;exports.CustomDecorationType=Cr;exports.CustomRangeType=Rr;exports.DEFAULT_CELL=ll;exports.DEFAULT_DOC=Ss;exports.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=ko;exports.DEFAULT_EMPTY_DOCUMENT_VALUE=Au;exports.DEFAULT_RANGE=ol;exports.DEFAULT_RANGE_ARRAY=il;exports.DEFAULT_SELECTION=al;exports.DEFAULT_SLIDE=ai;exports.DEFAULT_STYLES=dn;exports.DEFAULT_WORKSHEET_COLUMN_COUNT=ji;exports.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=Zl;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=zi;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=eu;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH=Ki;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=Ql;exports.DEFAULT_WORKSHEET_ROW_COUNT=Gi;exports.DEFAULT_WORKSHEET_ROW_COUNT_KEY=ql;exports.DEFAULT_WORKSHEET_ROW_HEIGHT=Vi;exports.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=Jl;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=Yi;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=tu;exports.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=oo;exports.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=io;exports.DashStyleType=Lr;exports.DataStreamTreeNodeType=Ri;exports.DataStreamTreeTokenType=ce;exports.DataValidationErrorStyle=No;exports.DataValidationImeMode=Ao;exports.DataValidationOperator=bo;exports.DataValidationRenderMode=po;exports.DataValidationStatus=wo;exports.DataValidationType=vo;exports.DependentOn=ku;exports.DesktopLogService=fi;exports.DeveloperMetadataVisibility=nr;exports.Dimension=sr;exports.Direction=rr;exports.Disposable=Tt;exports.DisposableCollection=us;exports.DocStyleType=Er;exports.DocumentDataModel=we;exports.DocumentFlavor=Sr;exports.DrawingTypeEnum=Vr;exports.EDITOR_ACTIVATED=Zi;exports.EXTENSION_NAMES=li;exports.Entry=zn;exports.EntryIterator=si;exports.ErrorService=Wi;exports.EventState=Ro;exports.EventSubject=ec;exports.FOCUSING_COMMON_DRAWINGS=gu;exports.FOCUSING_DOC=_n;exports.FOCUSING_EDITOR_BUT_HIDDEN=cu;exports.FOCUSING_EDITOR_INPUT_FORMULA=hu;exports.FOCUSING_EDITOR_STANDALONE=fu;exports.FOCUSING_FORMULA_EDITOR=Ji;exports.FOCUSING_SHEET=Ke;exports.FOCUSING_SLIDE=gn;exports.FOCUSING_UNIVER_EDITOR=du;exports.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=_u;exports.FollowNumberWithType=pr;exports.FontItalic=En;exports.FontStyleType=Pr;exports.FontWeight=pn;exports.FormatType=ir;exports.GlyphType=je;exports.GridType=Or;exports.HLSColor=gr;exports.HorizontalAlign=Ne;exports.IAuthzIoService=mo;exports.ICommandService=en;exports.IConfigService=Fi;exports.IContextService=Qe;exports.ILocalStorageService=nc;exports.ILogService=pe;exports.IPermissionService=As;exports.IResourceLoaderService=bs;exports.IResourceManagerService=Ln;exports.ISnapshotServerService=ic;exports.IUndoRedoService=yn;exports.IUniverInstanceService=Fe;exports.InterceptorManager=rc;exports.InterpolationPointType=or;exports.JSON1=Bl;exports.JSONX=ve;exports.KeyIterator=ei;exports.LRUHelper=Be;exports.LRUMap=ri;exports.LifecycleStages=ft;exports.LocaleService=Ye;exports.LocaleType=Te;exports.LogLevel=di;exports.MOVE_BUFFER_VALUE=We;exports.MemoryCursor=Pi;exports.NamedStyleType=Mr;exports.NilCommand=_i;exports.NumberUnitType=Fr;exports.ObjectMatrix=ee;exports.ObjectRelativeFromH=kr;exports.ObjectRelativeFromV=Hr;exports.OnLifecycle=Qi;exports.OtherShapes=dr;exports.PRESET_LIST_TYPE=Il;exports.PageElementType=Kr;exports.PageOrientType=Gr;exports.PageType=as;exports.ParagraphElementType=vr;exports.PermissionService=so;exports.PermissionStatus=Ns;exports.Plugin=is;exports.PositionedObjectLayoutType=Tr;exports.PresetListType=Sn;exports.ProtectionType=ar;exports.RANGE_TYPE=it;exports.RCDisposable=$a;exports.RGBA_PAREN=Go;exports.RGB_PAREN=Bo;exports.ROTATE_BUFFER_VALUE=Xs;exports.Range=He;exports.Rectangle=me;exports.RedoCommand=ho;exports.RedoCommandId=lo;exports.RefAlias=qa;exports.Registry=hs;exports.RegistryAsMap=ds;exports.RelativeDate=lr;exports.RelativeSlideLink=Yr;exports.ResourceManagerService=ro;exports.RgbColor=Rn;exports.RxDisposable=Fa;exports.SectionType=Nr;exports.SheetTypes=An;exports.SheetViewModel=qi;exports.SliceBodyType=gs;exports.SlideDataModel=Os;exports.SpacingRule=Ur;exports.SpecialShapes=fr;exports.Styles=Bi;exports.THEME_COLORS=_r;exports.TabStopAlignment=Dr;exports.TextDecoration=ur;exports.TextDirection=qe;exports.TextDirectionType=br;exports.TextX=Ee;exports.TextXActionType=J;exports.ThemeColor=Cn;exports.ThemeColorType=Ht;exports.ThemeColors=bn;exports.ThemeService=vs;exports.Tools=x;exports.UndoCommand=co;exports.UndoCommandId=uo;exports.UnitModel=Mn;exports.Univer=ju;exports.UniverInstanceType=Q;exports.UpdateDocsAttributeType=Pt;exports.ValueIterator=ni;exports.VerticalAlign=xe;exports.WidthType=yr;exports.Worksheet=Je;exports.WrapStrategy=Pe;exports.WrapTextType=wr;exports.afterInitApply=Cl;exports.b64DecodeUnicode=ws;exports.b64EncodeUnicode=ac;exports.binarySearchArray=qs;exports.cellToRange=Ma;exports.characterSpacingControlType=Br;exports.checkForSubstrings=Ua;exports.checkIfMove=Ho;exports.checkParagraphHasBullet=La;exports.checkParagraphHasIndent=Da;exports.checkParagraphHasIndentByStyle=Zr;exports.codeToBlob=$o;exports.composeBody=ts;exports.composeInterceptors=Co;exports.concatMatrixArray=Ka;exports.convertBodyToHtml=rl;exports.covertTextRunToHtml=Qn;exports.createDefaultUser=Nn;exports.createInterceptorKey=sc;exports.createInternalEditorID=bu;exports.createRowColIter=Jn;exports.debounce=sl;exports.dedupe=Wa;exports.deepCompare=ls;exports.deleteContent=Qr;exports.extractPureTextFromCell=nu;exports.fromCallback=gi;exports.fromObservable=Ha;exports.generateRandomId=zr;exports.generateTemporarySnap=dc;exports.getArrayLength=ge;exports.getBodySlice=Ze;exports.getBodySliceHtml=hn;exports.getBorderStyleType=va;exports.getCellInfoInMergeData=la;exports.getCellValueType=ra;exports.getColorStyle=re;exports.getCustomDecorationSlice=yi;exports.getCustomRangeSlice=Di;exports.getDocsUpdateBody=wa;exports.getReverseDirection=Wo;exports.getSheetBlocksFromSnapshot=Ec;exports.getWorksheetUID=uu;exports.groupBy=ja;exports.handleStyleToString=ba;exports.hashAlgorithm=xa;exports.horizontalLineSegmentsSubtraction=wn;exports.insertMatrixArray=Xn;exports.insertTextToContent=Jr;exports.isBlackColor=ea;exports.isBooleanString=qu;exports.isCellCoverable=Oa;exports.isCellV=oa;exports.isEmptyCell=Xr;exports.isFormulaId=Aa;exports.isFormulaString=Na;exports.isICellData=sa;exports.isInternalEditorID=vu;exports.isNullCell=ia;exports.isNumeric=Eo;exports.isRangesEqual=Ku;exports.isRealNum=ya;exports.isSafeNumeric=Xu;exports.isSameStyleTextRun=qr;exports.isUnitRangesEqual=Yu;exports.isValidRange=Ta;exports.isWhiteColor=na;exports.makeArray=Va;exports.makeCellRangeToRangeData=Sa;exports.makeCellToSelection=Ia;exports.mergeOverrideWithDependencies=go;exports.mergeSets=Zu;exports.mergeWorksheetSnapshotWithDefault=Xi;exports.moveMatrixArray=Zn;exports.moveRangeByOffset=fl;exports.nameCharacterCheck=Rc;exports.normalizeBody=Dl;exports.normalizeTextRuns=fs;exports.numberToABC=Qa;exports.numberToListABC=tl;exports.orderSearchArray=Zs;exports.queryObjectMatrix=dl;exports.remove=Tn;exports.repeatStringNumTimes=oi;exports.replaceInDocumentBody=tc;exports.requestImmediateMacroTask=Qu;exports.rotate=Ga;exports.runOnLifecycle=Un;exports.searchArray=Fo;exports.selectionToArray=aa;exports.sequence=ci;exports.sequenceAsync=ui;exports.sequenceExecute=cs;exports.sequenceExecuteAsync=Rl;exports.shallowEqual=zu;exports.skipParseTagNames=pc;exports.sliceMatrixArray=Ya;exports.sortRules=el;exports.sortRulesByDesc=nl;exports.sortRulesFactory=Me;exports.spliceArray=qn;exports.takeAfter=mi;exports.textDecoder=xn;exports.textEncoder=nn;exports.throttle=Ju;exports.toDisposable=bt;exports.transformDocumentDataToSnapshot=mc;exports.transformSnapshotToDocumentData=gc;exports.transformSnapshotToWorkbookData=_c;exports.transformWorkbookDataToSnapshot=fc;exports.updateAttributeByDelete=ki;exports.updateAttributeByInsert=Hi;